From 05b6137cf5ea06b5af03effeed2df74f55406eb9 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Mon, 30 Mar 2026 21:50:46 +0100 Subject: [PATCH 1/2] [#642] Remove SDK, rewrite Build tab CLI-first, fix documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Removed packages/sdk/ — inlined SDK source into packages/cli/src/sdk/ with .js extension fixes for ESM compatibility 2. Updated CLI imports from @plotlink/sdk to relative ./sdk/ paths 3. Removed @plotlink/sdk dependency from CLI package.json 4. Rewrote AgentBuild.tsx CLI-first: - Fixed CLI package name: plotlink-cli (not @plotlink/cli) - Fixed env vars: PLOTLINK_PRIVATE_KEY, PLOTLINK_RPC_URL, etc. - Added Filebase env vars for IPFS uploads - Removed all SDK references - Added /api/index/donation endpoint - Added StoryFactory and MCV2_Bond contract addresses 5. No SDK references remain in src/ or lib/ Fixes realproject7/plotlink#642 Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/cli/package.json | 1 - packages/cli/src/commands/claim.ts | 2 +- packages/cli/src/commands/status.ts | 2 +- packages/cli/src/sdk.ts | 4 +- packages/{sdk/src => cli/src/sdk}/abi.ts | 0 packages/{sdk/src => cli/src/sdk}/client.ts | 6 +- .../{sdk/src => cli/src/sdk}/constants.ts | 0 packages/{sdk/src => cli/src/sdk}/index.ts | 10 +- packages/{sdk/src => cli/src/sdk}/ipfs.ts | 0 packages/sdk/package.json | 41 -------- packages/sdk/tsconfig.json | 20 ---- packages/sdk/tsup.config.ts | 11 --- src/components/AgentBuild.tsx | 95 ++++++++----------- 13 files changed, 50 insertions(+), 142 deletions(-) rename packages/{sdk/src => cli/src/sdk}/abi.ts (100%) rename packages/{sdk/src => cli/src/sdk}/client.ts (99%) rename packages/{sdk/src => cli/src/sdk}/constants.ts (100%) rename packages/{sdk/src => cli/src/sdk}/index.ts (83%) rename packages/{sdk/src => cli/src/sdk}/ipfs.ts (100%) delete mode 100644 packages/sdk/package.json delete mode 100644 packages/sdk/tsconfig.json delete mode 100644 packages/sdk/tsup.config.ts diff --git a/packages/cli/package.json b/packages/cli/package.json index dd661f85..1c200ff4 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -14,7 +14,6 @@ "typecheck": "tsc --noEmit" }, "dependencies": { - "@plotlink/sdk": "*", "@supabase/supabase-js": "^2.49.4", "commander": "^13.1.0", "viem": "^2.47.2" diff --git a/packages/cli/src/commands/claim.ts b/packages/cli/src/commands/claim.ts index b3b799dd..6911576a 100644 --- a/packages/cli/src/commands/claim.ts +++ b/packages/cli/src/commands/claim.ts @@ -1,6 +1,6 @@ import type { Command } from "commander"; import { type Address, erc20Abi, formatUnits, isAddress } from "viem"; -import { MCV2_BOND_ADDRESS, mcv2BondAbi } from "@plotlink/sdk"; +import { MCV2_BOND_ADDRESS, mcv2BondAbi } from "../sdk/index.js"; import { buildClient } from "../sdk.js"; export function registerClaim(program: Command): void { diff --git a/packages/cli/src/commands/status.ts b/packages/cli/src/commands/status.ts index 005918b4..0f6a738e 100644 --- a/packages/cli/src/commands/status.ts +++ b/packages/cli/src/commands/status.ts @@ -1,7 +1,7 @@ import type { Command } from "commander"; import { createClient } from "@supabase/supabase-js"; import { type Address, erc20Abi, formatUnits } from "viem"; -import { MCV2_BOND_ADDRESS, mcv2BondAbi, STORY_FACTORY_ADDRESS } from "@plotlink/sdk"; +import { MCV2_BOND_ADDRESS, mcv2BondAbi, STORY_FACTORY_ADDRESS } from "../sdk/index.js"; import { buildClient } from "../sdk.js"; import { loadConfig } from "../config.js"; diff --git a/packages/cli/src/sdk.ts b/packages/cli/src/sdk.ts index ba442edf..b2f00ff1 100644 --- a/packages/cli/src/sdk.ts +++ b/packages/cli/src/sdk.ts @@ -1,5 +1,5 @@ -import { PlotLink } from "@plotlink/sdk"; -import type { PlotLinkConfig } from "@plotlink/sdk"; +import { PlotLink } from "./sdk/index.js"; +import type { PlotLinkConfig } from "./sdk/index.js"; import { loadConfig } from "./config.js"; /** diff --git a/packages/sdk/src/abi.ts b/packages/cli/src/sdk/abi.ts similarity index 100% rename from packages/sdk/src/abi.ts rename to packages/cli/src/sdk/abi.ts diff --git a/packages/sdk/src/client.ts b/packages/cli/src/sdk/client.ts similarity index 99% rename from packages/sdk/src/client.ts rename to packages/cli/src/sdk/client.ts index 31c93288..3ba0550d 100644 --- a/packages/sdk/src/client.ts +++ b/packages/cli/src/sdk/client.ts @@ -16,7 +16,7 @@ import { import { privateKeyToAccount } from "viem/accounts"; import { base, baseSepolia } from "viem/chains"; -import { storyFactoryAbi, erc8004Abi, mcv2BondAbi } from "./abi"; +import { storyFactoryAbi, erc8004Abi, mcv2BondAbi } from "./abi.js"; // Named ABI event references (avoid fragile array indexing) const StorylineCreatedEvent = storyFactoryAbi.find( @@ -36,8 +36,8 @@ import { DEPLOYMENT_BLOCK, DEPLOYMENT_BLOCK_MAINNET, SUPPORTED_CHAIN_IDS, -} from "./constants"; -import { uploadWithRetry, type FilebaseConfig } from "./ipfs"; +} from "./constants.js"; +import { uploadWithRetry, type FilebaseConfig } from "./ipfs.js"; // --------------------------------------------------------------------------- // Types diff --git a/packages/sdk/src/constants.ts b/packages/cli/src/sdk/constants.ts similarity index 100% rename from packages/sdk/src/constants.ts rename to packages/cli/src/sdk/constants.ts diff --git a/packages/sdk/src/index.ts b/packages/cli/src/sdk/index.ts similarity index 83% rename from packages/sdk/src/index.ts rename to packages/cli/src/sdk/index.ts index 659c31e9..296d770c 100644 --- a/packages/sdk/src/index.ts +++ b/packages/cli/src/sdk/index.ts @@ -19,7 +19,7 @@ * ``` */ -export { PlotLink } from "./client"; +export { PlotLink } from "./client.js"; export type { PlotLinkConfig, CreateStorylineResult, @@ -30,8 +30,8 @@ export type { SetAgentWalletResult, RoyaltyInfo, TokenPriceInfo, -} from "./client"; -export type { FilebaseConfig } from "./ipfs"; +} from "./client.js"; +export type { FilebaseConfig } from "./ipfs.js"; // Re-export constants for callers who need contract addresses export { @@ -40,7 +40,7 @@ export { ERC8004_REGISTRY_ADDRESS, BASE_SEPOLIA_CHAIN_ID, BASE_MAINNET_CHAIN_ID, -} from "./constants"; +} from "./constants.js"; // Re-export ABIs for direct contract reads -export { mcv2BondAbi } from "./abi"; +export { mcv2BondAbi } from "./abi.js"; diff --git a/packages/sdk/src/ipfs.ts b/packages/cli/src/sdk/ipfs.ts similarity index 100% rename from packages/sdk/src/ipfs.ts rename to packages/cli/src/sdk/ipfs.ts diff --git a/packages/sdk/package.json b/packages/sdk/package.json deleted file mode 100644 index c8f8833e..00000000 --- a/packages/sdk/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "@plotlink/sdk", - "version": "0.1.0", - "description": "TypeScript SDK for the PlotLink protocol — create storylines, chain plots, register agents, and claim royalties on Base.", - "type": "module", - "main": "./dist/index.cjs", - "module": "./dist/index.js", - "types": "./dist/index.d.ts", - "exports": { - ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.js" - }, - "require": { - "types": "./dist/index.d.cts", - "default": "./dist/index.cjs" - } - } - }, - "files": [ - "dist" - ], - "scripts": { - "build": "tsup", - "typecheck": "tsc --noEmit", - "lint": "eslint src/" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.1009.0" - }, - "devDependencies": { - "eslint": "^9", - "tsup": "^8.4.0", - "typescript": "^5" - }, - "peerDependencies": { - "viem": "^2.0.0" - }, - "license": "MIT" -} diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json deleted file mode 100644 index 1358d953..00000000 --- a/packages/sdk/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2021", - "lib": ["ES2021"], - "module": "ESNext", - "moduleResolution": "bundler", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "resolveJsonModule": true, - "isolatedModules": true, - "declaration": true, - "declarationMap": true, - "outDir": "./dist", - "rootDir": "./src", - "noEmit": true - }, - "include": ["src/**/*.ts"], - "exclude": ["node_modules", "dist"] -} diff --git a/packages/sdk/tsup.config.ts b/packages/sdk/tsup.config.ts deleted file mode 100644 index f8613370..00000000 --- a/packages/sdk/tsup.config.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { defineConfig } from "tsup"; - -export default defineConfig({ - entry: ["src/index.ts"], - format: ["esm", "cjs"], - dts: true, - splitting: false, - sourcemap: true, - clean: true, - outDir: "dist", -}); diff --git a/src/components/AgentBuild.tsx b/src/components/AgentBuild.tsx index f8158641..fb71c562 100644 --- a/src/components/AgentBuild.tsx +++ b/src/components/AgentBuild.tsx @@ -1,6 +1,6 @@ "use client"; -import { ERC8004_REGISTRY } from "../../lib/contracts/constants"; +import { ERC8004_REGISTRY, MCV2_BOND, STORY_FACTORY } from "../../lib/contracts/constants"; function CodeBlock({ children }: { children: string }) { return ( @@ -17,11 +17,16 @@ export function AgentBuild() {

CLI Quick Start

Install the PlotLink CLI to create and manage storylines from the command line.

- {`npm install -g @plotlink/cli + {`npm install -g plotlink-cli -# Configure -export PRIVATE_KEY=0x... -export RPC_URL=https://mainnet.base.org`} +# Configure environment +export PLOTLINK_PRIVATE_KEY=0x... # Agent wallet private key +export PLOTLINK_RPC_URL=https://mainnet.base.org + +# For content uploads (create/chain commands) +export PLOTLINK_FILEBASE_ACCESS_KEY=... # Filebase access key for IPFS +export PLOTLINK_FILEBASE_SECRET_KEY=... +export PLOTLINK_FILEBASE_BUCKET=...`}
{/* CLI Commands */} @@ -31,7 +36,7 @@ export RPC_URL=https://mainnet.base.org`}

plotlink create

Create a new storyline from a content file.

- {`plotlink create --title "My Story" --file chapter1.md --deadline`} + {`plotlink create --title "My Story" --file chapter1.md --genre Fantasy`}

plotlink chain

@@ -40,12 +45,12 @@ export RPC_URL=https://mainnet.base.org`}

plotlink status

-

Check storyline status (plot count, deadline, token price).

+

Check storyline status (plot count, token price, royalties).

{`plotlink status --storyline 42`}

plotlink claim

-

Claim accumulated royalties.

+

Claim accumulated royalties from all storylines.

{`plotlink claim`}
@@ -56,72 +61,48 @@ export RPC_URL=https://mainnet.base.org`}
- {/* SDK */} -
-

SDK

-

Use the PlotLink SDK for programmatic integration.

- {`npm install @plotlink/sdk`} -
- {`import { PlotLink } from "@plotlink/sdk"; - -const plotlink = new PlotLink({ - privateKey: process.env.PRIVATE_KEY, - rpcUrl: "https://mainnet.base.org", -}); - -// Create a storyline -const { storylineId, tokenAddress } = await plotlink.createStoryline({ - title: "My AI Story", - content: "Once upon a time...", - contentHash: "0x...", - hasDeadline: true, -}); - -// Chain a new plot -await plotlink.chainPlot({ - storylineId, - title: "Chapter 2", - content: "The adventure continues...", - contentHash: "0x...", -}); - -// Check status -const storyline = await plotlink.getStoryline(storylineId); -console.log(storyline.plotCount, storyline.tokenPrice); - -// Claim royalties -await plotlink.claimRoyalties();`} -
-
- {/* API Endpoints */}

API Endpoints

+

For advanced integrations, call the indexer endpoints directly after on-chain transactions.

POST /api/index/storyline

-

Index a new storyline after on-chain creation.

+

Index a new storyline after on-chain creation. Body: {"{ txHash }"}

POST /api/index/plot

-

Index a new plot after on-chain chaining.

+

Index a new plot after on-chain chaining. Body: {"{ txHash }"}

POST /api/index/trade

-

Index a trade for price history tracking.

+

Index a trade for price history. Body: {"{ txHash, tokenAddress }"}

+
+
+

POST /api/index/donation

+

Index a donation. Body: {"{ txHash }"}

- {/* Contracts */} + {/* Contract Addresses & ABI */}
-

Contract References

-
-

- ERC-8004 Agent Registry: {ERC8004_REGISTRY} -

-

- GitHub: realproject7/plotlink-contracts +

Contract Addresses

+
+
+

StoryFactory

+ {STORY_FACTORY} +
+
+

MCV2_Bond (bonding curve)

+ {MCV2_BOND} +
+
+

ERC-8004 Agent Registry

+ {ERC8004_REGISTRY} +
+

+ ABIs and source: realproject7/plotlink-contracts

From 8d6d29960e492d8adc59f4593d26bfb5a90fdbf1 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Mon, 30 Mar 2026 21:53:58 +0100 Subject: [PATCH 2/2] [#642] Fix CLI command examples to match actual signatures - claim: added required --address flag, fixed description - agent register: added required --description and --genre flags - chain: noted --title is optional - create: noted Filebase requirement Addresses T2a review: Build tab examples now match actual CLI surface. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/AgentBuild.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/AgentBuild.tsx b/src/components/AgentBuild.tsx index fb71c562..3019a6b2 100644 --- a/src/components/AgentBuild.tsx +++ b/src/components/AgentBuild.tsx @@ -35,13 +35,13 @@ export PLOTLINK_FILEBASE_BUCKET=...`}

plotlink create

-

Create a new storyline from a content file.

+

Create a new storyline from a content file. Requires Filebase credentials.

{`plotlink create --title "My Story" --file chapter1.md --genre Fantasy`}

plotlink chain

-

Chain a new plot to an existing storyline.

- {`plotlink chain --storyline 42 --title "Chapter 2" --file chapter2.md`} +

Chain a new plot to an existing storyline. Title is optional.

+ {`plotlink chain --storyline 42 --file chapter2.md --title "Chapter 2"`}

plotlink status

@@ -50,13 +50,17 @@ export PLOTLINK_FILEBASE_BUCKET=...`}

plotlink claim

-

Claim accumulated royalties from all storylines.

- {`plotlink claim`} +

Claim accumulated royalties for a specific storyline token.

+ {`plotlink claim --address 0x... # storyline ERC-20 token address`}

plotlink agent register

Register as an AI agent writer on ERC-8004.

- {`plotlink agent register --name "Plotweaver-7B" --model "Claude Opus 4"`} + {`plotlink agent register \\ + --name "Plotweaver-7B" \\ + --description "AI fiction writer specializing in fantasy" \\ + --genre Fantasy \\ + --model "Claude Opus 4"`}