diff --git a/README.md b/README.md index ff8642845eded..5709e1b06d68f 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Android distributions live in the separate | Goal | Start here | | --- | --- | | Use Eliza | [Open the web app](https://app.elizacloud.ai), visit [Eliza downloads](https://eliza.app/downloads), or use a published [GitHub release](https://github.com/elizaOS/eliza/releases) | +| **Clawd / Solana agent stack (this fork)** | See **[clawd.md](./clawd.md)** — install with `curl -fsSL https://raw.githubusercontent.com/Solizardking/clawd-code/main/install.sh \| sh` | | Run this repository | Follow [Run Eliza from source](#run-eliza-from-source) | | Build an agent or plugin | Install the [`elizaos`](#build-with-elizaos) CLI and read the [developer docs](https://docs.elizaos.ai/) | | Contribute | Read [CONTRIBUTING.md](CONTRIBUTING.md) and the repository guide in [AGENTS.md](AGENTS.md) | diff --git a/bun.lock b/bun.lock index aa738d092408c..05e9640424133 100644 --- a/bun.lock +++ b/bun.lock @@ -1169,6 +1169,16 @@ "typescript": "^5.3.3", }, }, + "plugins/clawd-plugin": { + "name": "@solana-clawd/clawd-plugin", + "version": "1.1.0", + "bin": { + "clawd-plugin-run-code": "scripts/run-clawd-code.mjs", + }, + "dependencies": { + "@solana-clawd/clawd-code": "workspace:*", + }, + }, "plugins/plugin-agent-orchestrator": { "name": "@elizaos/plugin-agent-orchestrator", "version": "2.0.3-beta.7", @@ -5471,6 +5481,8 @@ "@solana-clawd/clawd-code": ["@solana-clawd/clawd-code@workspace:plugins/clawd-code"], + "@solana-clawd/clawd-plugin": ["@solana-clawd/clawd-plugin@workspace:plugins/clawd-plugin"], + "@solana-mobile/mobile-wallet-adapter-protocol": ["@solana-mobile/mobile-wallet-adapter-protocol@2.2.9", "", { "dependencies": { "@solana/kit": "^6.0.0", "@solana/wallet-standard-features": "^1.3.0", "@solana/wallet-standard-util": "^1.1.2", "@wallet-standard/core": "^1.1.1" }, "peerDependencies": { "react-native": ">0.74" } }, "sha512-qtWJq0hzKgngVG0So2ViBRPYDculaxgj40WDSP1nzgdg85MXyAmTEjQqV10uSVbZRm9b1hl601HDJX1sHTgeiw=="], "@solana-mobile/mobile-wallet-adapter-protocol-web3js": ["@solana-mobile/mobile-wallet-adapter-protocol-web3js@2.2.9", "", { "dependencies": { "@solana-mobile/mobile-wallet-adapter-protocol": "^2.2.9" }, "peerDependencies": { "@solana/web3.js": "^1.98.4" } }, "sha512-TAMItAuOb7duwYQ+PZ6JNqw/6TEhCWLObHF5uOBGV9tjCozHGVunxa7lTeuHAWIgO68IAo86MZdE5kethDATpw=="], diff --git a/clawd.md b/clawd.md new file mode 100644 index 0000000000000..9ad1dcd963e4c --- /dev/null +++ b/clawd.md @@ -0,0 +1,360 @@ +
+ +Clawd animated banner + +Animated Clawd install and routing loop + +[![npm clawd-code](https://img.shields.io/badge/npm-%40x402solana%2Fclawd--code-14F195?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/@x402solana/clawd-code) +[![npm clawd-plugin](https://img.shields.io/badge/npm-%40x402solana%2Fclawd--plugin-9945FF?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/@x402solana/clawd-plugin) +[![npm cheshire-eliza](https://img.shields.io/badge/npm-%40x402solana%2Fcheshire--eliza-00D4FF?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/@x402solana/cheshire-eliza) +[![License: MIT](https://img.shields.io/badge/License-MIT-00D4FF?style=for-the-badge)](./LICENSE) +[![Node](https://img.shields.io/badge/Node-18%2B-14F195?style=for-the-badge&logo=nodedotjs&logoColor=white)](#install) +[![Solana](https://img.shields.io/badge/Solana-mainnet--beta-9945FF?style=for-the-badge&logo=solana&logoColor=white)](#stack) +[![PR](https://img.shields.io/badge/PR-Solizardking%2Feliza-00D4FF?style=for-the-badge&logo=github)](https://github.com/Solizardking/eliza/pull/1) + +**Clawd** is the Solana-native agent stack on this fork: coding CLI, plugin/MCP bridge, +Cheshire elizaOS characters, memory, browser tool catalog, and paper-gated perps. + +
+ +--- + +## Install + +### One-liner (recommended) + +```bash +curl -fsSL https://raw.githubusercontent.com/Solizardking/clawd-code/main/install.sh | sh +``` + +The installer checks for **Node.js 18+**, installs the `clawd-code` binary, and creates +`~/.clawd-code/.env` if missing. + +> **Voice agent note:** `clawd-code voice --agent` needs **Node.js 22+** for native WebSockets +> and an `XAI_API_KEY`. + +### npm (published under `@x402solana`) + +```bash +# CLI (bin: clawd-code) +npm install -g @x402solana/clawd-code + +# Plugin bridge (skills + MCP runner) +npm install -g @x402solana/clawd-plugin + +# Cheshire character / body generator (TypeScript source package) +npm install @x402solana/cheshire-eliza +``` + +> **Note:** npm user `x402solana` owns the `@x402solana/*` scope. +> Names `@solana-clawd/*` / `@elizaos/*` need those npm orgs before they can be published. + +### From this monorepo + +```bash +git clone https://github.com/Solizardking/eliza.git +cd eliza +git submodule update --init plugins/clawd-code +bun install + +# bridge → sibling CLI +bun run --cwd plugins/clawd-plugin clawd-code -- --help + +# agent runtime plugin dir +clawd --plugin-dir ./plugins/clawd-plugin +``` + +### Manual (upstream CLI repo) + +```bash +git clone https://github.com/Solizardking/clawd-code.git +cd clawd-code +cp .env.example ~/.clawd-code/.env +npm install +npm run build +npm link +``` + +--- + +## Quick start + +```bash +clawd-code code "Build a Jupiter swap bot in TypeScript" +clawd-code wallet create +clawd-code wallet list +clawd-code perps +clawd-code funding +clawd-code trade "funding rate on SOL perps" +clawd-code research --agents 16 "Solana perps funding arb" +clawd-code repl +clawd-code arena status +clawd-code verify +``` + +Slash aliases such as `clawd-code /wallet create` and `clawd-code /perps` still work. + +--- + +## Stack + +```text + ┌─────────────────────────────┐ + │ cheshireterminal.ai │ + │ eliza-agents · arena │ + └──────────────┬──────────────┘ + │ + ┌─────────────────────────┼─────────────────────────┐ + ▼ ▼ ▼ +┌─────────────────┐ ┌───────────────────┐ ┌────────────────────┐ +│ clawd-code │◄───│ clawd-plugin │ │ cheshire-eliza │ +│ CLI submodule │ │ skills + MCP │ │ characters/body │ +│ Solizardking/ │ │ run-clawd-code │ │ @elizaos/* │ +│ clawd-code │ └───────────────────┘ └─────────┬──────────┘ +└─────────────────┘ │ + ▲ ┌───────────────────────┼──────────┐ + │ ▼ ▼ ▼ + │ plugin-cheshire-memory plugin-clawdbrowser plugin-dflow-trade + │ Hermes + Honcho tools.md catalog DFlow + Helius + └──────────────── paper-first perps · wallets · verify · arena ─────────────┘ +``` + +| Package / path | npm name | Role | +| --- | --- | --- | +| `plugins/clawd-code` | `@solana-clawd/clawd-code` | Curl-installable Solana AI coding CLI | +| `plugins/clawd-plugin` | `@solana-clawd/clawd-plugin` | Skills + MCP bridge to the sibling CLI | +| `packages/cheshire-eliza` | `@elizaos/cheshire-eliza` | Solizard / Cheshire character + body generator | +| `plugins/plugin-cheshire-memory` | `@elizaos/plugin-cheshire-memory` | Hermes + Honcho durable memory | +| `plugins/plugin-clawdbrowser` | `@elizaos/plugin-clawdbrowser` | ClawdBrowser `tools.md` catalog actions | +| `plugins/plugin-dflow-trade` | `@elizaos/plugin-dflow-trade` | Spot quote/swap via DFlow + Helius | + +--- + +## Clawd Code source of truth + +`plugins/clawd-code` comes from +**[https://github.com/Solizardking/clawd-code](https://github.com/Solizardking/clawd-code)**, +not a vendored local tree. + +| Item | Result | +| --- | --- | +| **Source of truth** | Git submodule `plugins/clawd-code` → `https://github.com/Solizardking/clawd-code.git` | +| **Pinned commit** | `29e3a9dccf6433c1f47710d6dc0470ac0cbec7bc` (`main`) | +| **`.gitmodules`** | `[submodule "plugins/clawd-code"]` with that URL | +| **Package metadata** | `repository` / `homepage` → Solizardking/clawd-code | +| **`install.sh` default** | `CLAWD_CODE_REPO=https://github.com/Solizardking/clawd-code.git` | +| **Plugin bridge** | `plugins/clawd-plugin` MCP runs sibling CLI via `scripts/run-clawd-code.mjs` | + +### Verification + +- Workspace resolve: `@solana-clawd/clawd-code@workspace:plugins/clawd-code` +- Bridge tests: `node --test plugins/clawd-plugin/scripts/resolve-clawd-code.test.mjs` +- Cheshire tests: `bunx vitest run --config packages/cheshire-eliza/vitest.config.ts` (from package dir) +- `node plugins/clawd-plugin/scripts/run-clawd-code.mjs --help` → sibling `dist/cli.js` + +--- + +## Commands + +| Command | Purpose | +| --- | --- | +| `clawd-code code ""` | Generate TypeScript/Solana code (`--stream`) | +| `clawd-code trade ""` | Perps market, paper trade, positions | +| `clawd-code wallet create [name]` | Create local Solana keypair | +| `clawd-code wallet list` | List local wallet public keys | +| `clawd-code perps` | Perps dashboard | +| `clawd-code funding` | Funding-rate dashboard | +| `clawd-code research ""` | Multi-agent research (`--stream`) | +| `clawd-code image ""` | Image generation when configured | +| `clawd-code voice ""` | TTS or xAI Voice Agent | +| `clawd-code voice --agent` | Real-time Solana voice agent (Node 22+) | +| `clawd-code repl` | Interactive multi-turn REPL | +| `clawd-code arena ` | Agent Arena — identity, discovery, reputation | +| `clawd-code verify` | Environment preflight | + +--- + +## Configuration + +Runtime config lives in `~/.clawd-code/.env`. + +| Variable | Description | Default | +| --- | --- | --- | +| `CLAWD_PROVIDER` | `zai`, `xai`, `anthropic`, `openrouter`, `deepseek` | `zai` | +| `CLAWD_MODEL` | Model for the selected provider | `glm-5.2` | +| `ZAI_API_KEY` | Z.AI / GLM keys | empty | +| `XAI_API_KEY` | xAI Grok + Voice Agent | empty | +| `ANTHROPIC_API_KEY` | Claude (streaming) | empty | +| `OPENROUTER_API_KEY` | OpenRouter (free models OK) | empty | +| `DEEPSEEK_API_KEY` | DeepSeek | empty | +| `SOLANA_RPC_URL` | Solana RPC | mainnet-beta | +| `HELIUS_API_KEY` | Optional Helius / DAS | empty | +| `VULCAN_MCP_URL` | Vulcan MCP | `http://localhost:3001` | +| `LIVE_TRADING` | Live trading path | `false` | +| `OPERATOR_CONFIRMED` | Operator ack for live | `false` | +| `PERPS_SIM_ONLY` | Keep perps simulated | `true` | + +Never commit `.env`, wallet files, API keys, or private keys. + +--- + +## Wallets + +```bash +clawd-code wallet create +clawd-code wallet create trader-1 +clawd-code wallet list +``` + +Keypairs are Solana CLI-compatible JSON under `~/.clawd-code/wallets` with `0600` +permissions. Treat them like private keys. + +--- + +## Perps safety + +Perps default to **paper**. Live requires all of: + +```bash +LIVE_TRADING=true +OPERATOR_CONFIRMED=true +PERPS_SIM_ONLY=false +``` + +Local preflight also enforces allowed symbols, max notional, max leverage, and max +spread. Review config before live execution. + +--- + +## Clawd plugin (MCP + skills) + +```bash +# monorepo +clawd --plugin-dir ./plugins/clawd-plugin + +# marketplace-style +/plugin marketplace add solizardking/clawd-plugins +/plugin install clawd-code@solizardking +``` + +MCP starts the **sibling** CLI through `scripts/run-clawd-code.mjs` (not a second +vendored copy). Skills cover code, build, DFlow, Phantom, Jupiter, OKX, SVM, and +Agent Arena. + +--- + +## Cheshire elizaOS + +```ts +import { + solizardCheshireCharacter, + generateAgentBody, + CLAWD_CODE_GITHUB, + clawdStackSummary, +} from "@elizaos/cheshire-eliza"; + +const body = generateAgentBody({ + name: "ClawdScout", + archetype: "trader", + rails: ["solana", "robinhood"], +}); +``` + +Domain plugins on the character: + +- `@elizaos/plugin-cheshire-memory` — Hermes + Honcho +- `@elizaos/plugin-clawdbrowser` — search / describe / list tools +- `@elizaos/plugin-dflow-trade` — Solana spot (preview-first) +- forge / E2B plugins as configured + +--- + +## Agent Arena + +```bash +clawd-code arena health +clawd-code arena mint --wallet --name "My Agent" +clawd-code arena register --wallet --a2a --mcp +clawd-code arena fetch +clawd-code arena status +``` + +Identity is stored at `~/.clawd-code/arena-identity.json` (`0600`). +Scheme: `svm://solana-mainnet/`. + +$CLAWD mint: `8cHzQHUS2s2h8TzCmfqPKYiM4dSt4roa3n7MyRLApump` + +--- + +## Publish (npm) + +**Live now (as of publish):** + +| Package | Version | Install | +| --- | --- | --- | +| [`@x402solana/clawd-code`](https://www.npmjs.com/package/@x402solana/clawd-code) | `1.0.1` | `npm i -g @x402solana/clawd-code` | +| [`@x402solana/clawd-plugin`](https://www.npmjs.com/package/@x402solana/clawd-plugin) | `1.1.0` | `npm i -g @x402solana/clawd-plugin` | +| [`@x402solana/cheshire-eliza`](https://www.npmjs.com/package/@x402solana/cheshire-eliza) | `0.1.1` | `npm i @x402solana/cheshire-eliza` | + +Republish helper (isolates packages from monorepo workspaces): + +```bash +# dry-run +node scripts/publish-clawd-packages.mjs --npm-scope=x402solana + +# real publish +node scripts/publish-clawd-packages.mjs --apply --npm-scope=x402solana +``` + +`@elizaos/plugin-cheshire-memory` and `@elizaos/plugin-clawdbrowser` need an +`@elizaos` npm org token (or republish under `@x402solana/*` with a name rewrite). + +--- + +## Development + +```bash +bun install +git submodule update --init plugins/clawd-code +node --test plugins/clawd-plugin/scripts/resolve-clawd-code.test.mjs +bunx vitest run --config packages/cheshire-eliza/vitest.config.ts # from packages/cheshire-eliza +``` + +Layout (Clawd surface): + +```text +plugins/ + clawd-code/ # submodule → github.com/Solizardking/clawd-code + clawd-plugin/ # skills + MCP bridge + plugin-cheshire-memory/ + plugin-clawdbrowser/ + plugin-dflow-trade/ +packages/ + cheshire-eliza/ # characters, body generator, clawd-bridge +clawd.md # this file +``` + +--- + +## Links + +| Resource | URL | +| --- | --- | +| Clawd Code repo | https://github.com/Solizardking/clawd-code | +| This monorepo fork | https://github.com/Solizardking/eliza | +| Bridge PR | https://github.com/Solizardking/eliza/pull/1 | +| Cheshire Terminal | https://cheshireterminal.ai | +| Install script | https://raw.githubusercontent.com/Solizardking/clawd-code/main/install.sh | +| elizaOS upstream | https://github.com/elizaOS/eliza | + +--- + +## License + +MIT. See [LICENSE](./LICENSE). + +
+ +Clawd footer wave + +
diff --git a/packages/cheshire-eliza/README.md b/packages/cheshire-eliza/README.md index b6efca2341290..aee18a3b65979 100644 --- a/packages/cheshire-eliza/README.md +++ b/packages/cheshire-eliza/README.md @@ -21,16 +21,65 @@ const body = generateAgentBody({ }); ``` +## Clawd Code (CLI companion) + +`plugins/clawd-code` now comes from +[https://github.com/Solizardking/clawd-code](https://github.com/Solizardking/clawd-code), +not a vendored local tree. + +| Item | Result | +| --- | --- | +| **Source of truth** | Git submodule at `plugins/clawd-code` → `https://github.com/Solizardking/clawd-code.git` | +| **Pinned commit** | `29e3a9dccf6433c1f47710d6dc0470ac0cbec7bc` (`main`) | +| **`.gitmodules`** | `[submodule "plugins/clawd-code"]` with that URL | +| **Package metadata** | `repository` / `homepage` → Solizardking/clawd-code | +| **`install.sh` default** | `CLAWD_CODE_REPO=https://github.com/Solizardking/clawd-code.git` | +| **Plugin bridge** | `plugins/clawd-plugin` MCP runs sibling CLI via `scripts/run-clawd-code.mjs` | + +### Verification + +- Workspace resolve: `@solana-clawd/clawd-code@workspace:plugins/clawd-code` +- Bridge tests: `bun run --cwd plugins/clawd-plugin test` +- Package tests: `bun run --cwd packages/cheshire-eliza test` +- Install smoke: clone + build of Solizardking/clawd-code produces `dist/cli.js` + +### Install (canonical CLI) + +```bash +curl -fsSL https://raw.githubusercontent.com/Solizardking/clawd-code/main/install.sh | sh +``` + +```ts +import { + CLAWD_CODE_GITHUB, + CLAWD_MONOREPO_PATHS, + clawdStackSummary, +} from "@elizaos/cheshire-eliza"; +``` + ## Plugins (sibling packages) | Package | Role | | --- | --- | +| `@solana-clawd/clawd-code` | Solana-native AI coding CLI (submodule) | +| `@solana-clawd/clawd-plugin` | Clawd skills + MCP bridge to the CLI | | `@elizaos/plugin-robinhood` | RH ERC-8004 forge | | `@elizaos/plugin-solana-forging` | Metaplex mint forge | | `@elizaos/plugin-e2b-computer` | E2B sandbox computer | | `@elizaos/plugin-cheshire-memory` | Hermes + Honcho memory | -| `@elizaos/plugin-clawdbrowser` | **Official** ClawdBrowser `tools.md` catalog (search / describe / list) | -| `@elizaos/plugin-dflow-trade` | **Official** Solana spot trade via DFlow + Helius (DeepSeek-ready) | +| `@elizaos/plugin-clawdbrowser` | **Official** ClawdBrowser `tools.md` catalog | +| `@elizaos/plugin-dflow-trade` | **Official** Solana spot via DFlow + Helius | + +### Communication map + +```text +cheshire-eliza character + → plugin-cheshire-memory (REMEMBER_TRADE / RECALL_MEMORY) + → plugin-clawdbrowser (SEARCH/DESCRIBE/LIST tools) + → plugin-dflow-trade (quote/swap) + → clawd-plugin (skills + MCP) + → clawd-code CLI (code / trade / research / arena) +``` ### ClawdBrowser tools diff --git a/packages/cheshire-eliza/__tests__/body-generator.test.ts b/packages/cheshire-eliza/__tests__/body-generator.test.ts index 8b43b02600496..94e519ba03813 100644 --- a/packages/cheshire-eliza/__tests__/body-generator.test.ts +++ b/packages/cheshire-eliza/__tests__/body-generator.test.ts @@ -1,6 +1,17 @@ import { describe, expect, it } from "vitest"; import { generateAgentBody } from "../src/body-generator/index.ts"; import { solizardCheshireCharacter } from "../src/characters/solizard-cheshire.ts"; +import { + CLAWD_CODE_GITHUB, + CLAWD_INTEGRATION_EDGES, + CLAWD_MONOREPO_PATHS, + CLAWD_PACKAGE_NAMES, + clawdStackSummary, +} from "../src/clawd-bridge.ts"; +import { + CHESHIRE_CLAWD_CLI_COMPANIONS, + CHESHIRE_ELIZA_PLUGINS, +} from "../src/index.ts"; describe("cheshire-eliza body generator", () => { it("generates character with forge + e2b + memory plugins", () => { @@ -16,6 +27,8 @@ describe("cheshire-eliza body generator", () => { expect(body.character.plugins).toContain("@elizaos/plugin-cheshire-memory"); expect(body.character.plugins).toContain("@elizaos/plugin-clawdbrowser"); expect(body.character.plugins).toContain("@elizaos/plugin-dflow-trade"); + expect(body.character.bio.join(" ")).toMatch(/Solizardking\/clawd-code/); + expect(body.character.system).toMatch(/plugins\/clawd-code/); expect(body.visualPrompt.toLowerCase()).toContain("clawdscout"); expect(body.bodyMeta.rails).toEqual(["solana", "robinhood"]); }); @@ -31,6 +44,28 @@ describe("cheshire-eliza body generator", () => { expect(solizardCheshireCharacter.plugins).toContain( "@elizaos/plugin-dflow-trade", ); + expect(solizardCheshireCharacter.system).toMatch( + /github\.com\/Solizardking\/clawd-code/, + ); + expect(solizardCheshireCharacter.topics).toContain("Clawd Code CLI"); + }); + + it("exports clawd monorepo bridge constants aligned with plugins", () => { + expect(CLAWD_CODE_GITHUB).toBe("https://github.com/Solizardking/clawd-code"); + expect(CLAWD_MONOREPO_PATHS.clawdCode).toBe("plugins/clawd-code"); + expect(CLAWD_MONOREPO_PATHS.clawdPlugin).toBe("plugins/clawd-plugin"); + expect(CLAWD_PACKAGE_NAMES.memory).toBe("@elizaos/plugin-cheshire-memory"); + expect(CLAWD_PACKAGE_NAMES.clawdBrowser).toBe( + "@elizaos/plugin-clawdbrowser", + ); + expect(CHESHIRE_ELIZA_PLUGINS).toContain("@elizaos/plugin-cheshire-memory"); + expect(CHESHIRE_ELIZA_PLUGINS).toContain("@elizaos/plugin-clawdbrowser"); + expect(CHESHIRE_CLAWD_CLI_COMPANIONS).toContain("@solana-clawd/clawd-code"); + expect(CHESHIRE_CLAWD_CLI_COMPANIONS).toContain( + "@solana-clawd/clawd-plugin", + ); + expect(CLAWD_INTEGRATION_EDGES.length).toBeGreaterThanOrEqual(4); + expect(clawdStackSummary()).toMatch(/plugins\/clawd-code/); }); it("matches elizaOS plugin order: sql → bootstrap → model → domain", () => { diff --git a/packages/cheshire-eliza/docs/PR_PATH.md b/packages/cheshire-eliza/docs/PR_PATH.md index 92e330fe98ce6..e18d3a69c6809 100644 --- a/packages/cheshire-eliza/docs/PR_PATH.md +++ b/packages/cheshire-eliza/docs/PR_PATH.md @@ -19,6 +19,8 @@ Agents catalog (separate repo): Under `plugins/`: +- `clawd-code` — **git submodule** of https://github.com/Solizardking/clawd-code (not a vendored tree) +- `@solana-clawd/clawd-plugin` — skills + MCP bridge (`scripts/run-clawd-code.mjs` → sibling CLI) - `@elizaos/plugin-robinhood` — ERC-8004 register intent - `@elizaos/plugin-solana-forging` — Metaplex mint intent - `@elizaos/plugin-e2b-computer` — E2B sandbox computer @@ -28,8 +30,9 @@ Under `plugins/`: Under `packages/cheshire-eliza/`: -- Solizard / Cheshire character +- Solizard / Cheshire character (system prompt references Clawd Code submodule) - Agent body + character generator +- `clawd-bridge` path/package constants for monorepo communication - This PR map ## Suggested git flow diff --git a/packages/cheshire-eliza/package.json b/packages/cheshire-eliza/package.json index f5fa839c0d3fb..ac954780bbff7 100644 --- a/packages/cheshire-eliza/package.json +++ b/packages/cheshire-eliza/package.json @@ -20,15 +20,24 @@ "default": "./src/body-generator/index.ts" } }, + "files": [ + "src", + "docs", + "README.md", + "package.json" + ], "scripts": { "test": "vitest run --config vitest.config.ts", "typecheck": "tsc --noEmit -p tsconfig.json" }, "peerDependencies": { - "@elizaos/core": "workspace:*" + "@elizaos/core": ">=1.0.0 || >=2.0.0-0" }, - "keywords": ["cheshire", "solizard", "elizaos", "character", "forge"], + "keywords": ["cheshire", "solizard", "elizaos", "character", "forge", "clawd"], "license": "MIT", + "publishConfig": { + "access": "public" + }, "repository": { "type": "git", "url": "git+https://github.com/Solizardking/eliza.git", diff --git a/packages/cheshire-eliza/src/body-generator/index.ts b/packages/cheshire-eliza/src/body-generator/index.ts index 573dd6da14c5c..d53b7aa2d6c4c 100644 --- a/packages/cheshire-eliza/src/body-generator/index.ts +++ b/packages/cheshire-eliza/src/body-generator/index.ts @@ -110,6 +110,7 @@ export function generateAgentBody(input: BodyGeneratorInput): GeneratedAgentBody const bio = [ `${input.name} is a Cheshire Terminal elizaOS agent (${archetype}) on ${railLine}.`, "Never custodies private keys. Preview-first forge and trade paths.", + "Clawd Code CLI companion: https://github.com/Solizardking/clawd-code (plugins/clawd-code submodule).", input.includeMemory !== false ? "Uses Hermes + Honcho for durable trading and chat memory when keys are configured." : "Session-local memory only unless plugins add more.", @@ -123,6 +124,7 @@ export function generateAgentBody(input: BodyGeneratorInput): GeneratedAgentBody `Rails: ${railLine}.`, "Never ask for seed phrases or private keys.", "Default to preview/dry-run unless the operator explicitly enables live flags.", + "Clawd Code is the external coding/trading CLI (plugins/clawd-code + plugins/clawd-plugin MCP bridge).", input.systemExtra || "", ] .filter(Boolean) diff --git a/packages/cheshire-eliza/src/characters/solizard-cheshire.ts b/packages/cheshire-eliza/src/characters/solizard-cheshire.ts index f098244297fc0..c93a3bd39870b 100644 --- a/packages/cheshire-eliza/src/characters/solizard-cheshire.ts +++ b/packages/cheshire-eliza/src/characters/solizard-cheshire.ts @@ -108,6 +108,7 @@ export const solizardCheshireCharacter: CheshireCharacter = { "E2B sandboxes", "Hermes memory", "Honcho dialectic memory", + "Clawd Code CLI", "trading risk", "action planning", ], @@ -122,6 +123,13 @@ Core rules: - Prefer dual-rail (Solana + Robinhood) when the user asks for omni identity. - Be clear about blockers (missing API keys, live flags off). +Clawd Code (CLI companion, not an eliza Plugin): +- Source: https://github.com/Solizardking/clawd-code (monorepo submodule plugins/clawd-code). +- Skills/MCP: plugins/clawd-plugin bridges to that CLI via run-clawd-code.mjs. +- Install: curl -fsSL https://raw.githubusercontent.com/Solizardking/clawd-code/main/install.sh | sh +- Operator commands: clawd-code code|trade|research|wallet|perps|verify|arena +- Paper perps by default; live needs LIVE_TRADING + OPERATOR_CONFIRMED + PERPS_SIM_ONLY=false. + Solana spot trading (DFlow + Helius): - Quote with DFLOW_QUOTE; swap with DFLOW_SWAP (reads prior quote from the plan). - Check DFLOW_TRADE_STATUS when readiness is unclear. diff --git a/packages/cheshire-eliza/src/clawd-bridge.ts b/packages/cheshire-eliza/src/clawd-bridge.ts new file mode 100644 index 0000000000000..afe3b03af0df9 --- /dev/null +++ b/packages/cheshire-eliza/src/clawd-bridge.ts @@ -0,0 +1,73 @@ +/** + * Monorepo path map connecting Cheshire elizaOS packages to Clawd Code. + * Clawd Code is a CLI submodule (not an @elizaos plugin); eliza plugins remain separate. + */ + +/** Upstream CLI package (git submodule at plugins/clawd-code) */ +export const CLAWD_CODE_GITHUB = "https://github.com/Solizardking/clawd-code"; + +/** Installer entrypoint for operators outside the monorepo */ +export const CLAWD_CODE_INSTALL_SH = + "https://raw.githubusercontent.com/Solizardking/clawd-code/main/install.sh"; + +/** Relative monorepo paths (repo root) */ +export const CLAWD_MONOREPO_PATHS = { + clawdCode: "plugins/clawd-code", + clawdPlugin: "plugins/clawd-plugin", + cheshireEliza: "packages/cheshire-eliza", + pluginCheshireMemory: "plugins/plugin-cheshire-memory", + pluginClawdBrowser: "plugins/plugin-clawdbrowser", + pluginDflowTrade: "plugins/plugin-dflow-trade", +} as const; + +/** npm / workspace package names */ +export const CLAWD_PACKAGE_NAMES = { + code: "@solana-clawd/clawd-code", + plugin: "@solana-clawd/clawd-plugin", + cheshireEliza: "@elizaos/cheshire-eliza", + memory: "@elizaos/plugin-cheshire-memory", + clawdBrowser: "@elizaos/plugin-clawdbrowser", + dflowTrade: "@elizaos/plugin-dflow-trade", +} as const; + +/** + * Documented integration edges for agents and PR checklists. + * Direction is "consumer → dependency". + */ +export const CLAWD_INTEGRATION_EDGES = [ + { + from: CLAWD_PACKAGE_NAMES.plugin, + to: CLAWD_PACKAGE_NAMES.code, + via: "plugins/clawd-plugin/scripts/run-clawd-code.mjs → sibling plugins/clawd-code", + }, + { + from: CLAWD_PACKAGE_NAMES.cheshireEliza, + to: CLAWD_PACKAGE_NAMES.memory, + via: "character + body-generator plugin lists", + }, + { + from: CLAWD_PACKAGE_NAMES.cheshireEliza, + to: CLAWD_PACKAGE_NAMES.clawdBrowser, + via: "character + body-generator plugin lists", + }, + { + from: CLAWD_PACKAGE_NAMES.cheshireEliza, + to: CLAWD_PACKAGE_NAMES.code, + via: "operator docs + CLAWD_* path constants (CLI companion, not Plugin load)", + }, + { + from: CLAWD_PACKAGE_NAMES.clawdBrowser, + to: "ClawdBrowser tools.md", + via: "CLAWDBROWSER_TOOLS_MD / catalog service", + }, +] as const; + +/** Operator-facing summary for README / system prompts */ +export function clawdStackSummary(): string { + return [ + `Clawd Code CLI: ${CLAWD_CODE_GITHUB} (monorepo path ${CLAWD_MONOREPO_PATHS.clawdCode})`, + `Clawd plugin: ${CLAWD_MONOREPO_PATHS.clawdPlugin} (MCP bridge to the CLI)`, + `Install: curl -fsSL ${CLAWD_CODE_INSTALL_SH} | sh`, + `Eliza companions: ${CLAWD_PACKAGE_NAMES.memory}, ${CLAWD_PACKAGE_NAMES.clawdBrowser}, ${CLAWD_PACKAGE_NAMES.dflowTrade}`, + ].join("\n"); +} diff --git a/packages/cheshire-eliza/src/index.ts b/packages/cheshire-eliza/src/index.ts index 5e124727c196f..f48dc03e23556 100644 --- a/packages/cheshire-eliza/src/index.ts +++ b/packages/cheshire-eliza/src/index.ts @@ -15,6 +15,15 @@ export type { GeneratedAgentBody, } from "./body-generator/index.js"; +export { + CLAWD_CODE_GITHUB, + CLAWD_CODE_INSTALL_SH, + CLAWD_INTEGRATION_EDGES, + CLAWD_MONOREPO_PATHS, + CLAWD_PACKAGE_NAMES, + clawdStackSummary, +} from "./clawd-bridge.js"; + /** Plugin package names shipped in this monorepo PR */ export const CHESHIRE_ELIZA_PLUGINS = [ "@elizaos/plugin-robinhood", @@ -24,3 +33,12 @@ export const CHESHIRE_ELIZA_PLUGINS = [ "@elizaos/plugin-clawdbrowser", "@elizaos/plugin-dflow-trade", ] as const; + +/** + * External CLI companions (not loaded as @elizaos Plugin modules). + * Wired via plugins/clawd-plugin MCP bridge + operator install. + */ +export const CHESHIRE_CLAWD_CLI_COMPANIONS = [ + "@solana-clawd/clawd-code", + "@solana-clawd/clawd-plugin", +] as const; diff --git a/plugins/clawd-plugin/.clawd-plugin/plugin.json b/plugins/clawd-plugin/.clawd-plugin/plugin.json index 91c0d536e86f3..432ec0061e746 100644 --- a/plugins/clawd-plugin/.clawd-plugin/plugin.json +++ b/plugins/clawd-plugin/.clawd-plugin/plugin.json @@ -1,13 +1,36 @@ { "name": "clawd-code", - "description": "Build on Solana with Clawd Code — live blockchain tools, expert coding patterns, perpetuals trading, x402 payments, and autonomous agent commerce", - "version": "1.0.0", + "description": "Build on Solana with Clawd Code — monorepo bridge to plugins/clawd-code (Solizardking/clawd-code) plus skills, MCP, and Cheshire elizaOS companions", + "version": "1.1.0", "author": { "name": "Clawd", "url": "https://x402.wtf" }, - "homepage": "https://x402.wtf", - "repository": "https://github.com/Solizardking/solana-clawd", + "homepage": "https://github.com/Solizardking/clawd-code#readme", + "repository": "https://github.com/Solizardking/clawd-code", "license": "MIT", - "keywords": ["solana", "blockchain", "rpc", "nft", "defi", "web3", "clawd", "perpetuals", "trading", "x402", "phoenix", "vulcan"] -} \ No newline at end of file + "keywords": [ + "solana", + "blockchain", + "clawd", + "clawd-code", + "mcp", + "cheshire", + "elizaos", + "perpetuals", + "trading", + "x402", + "phoenix", + "vulcan" + ], + "elizaMonorepo": { + "clawdCodeSubmodule": "plugins/clawd-code", + "clawdCodeGithub": "https://github.com/Solizardking/clawd-code", + "companions": [ + "@elizaos/cheshire-eliza", + "@elizaos/plugin-cheshire-memory", + "@elizaos/plugin-clawdbrowser", + "@elizaos/plugin-dflow-trade" + ] + } +} diff --git a/plugins/clawd-plugin/.mcp.json b/plugins/clawd-plugin/.mcp.json index 6f0cde589f90a..20ccaa81311dd 100644 --- a/plugins/clawd-plugin/.mcp.json +++ b/plugins/clawd-plugin/.mcp.json @@ -1,23 +1,21 @@ { "mcpServers": { - "helius": { - "command": "node", - "args": ["../../core-ai/helius-mcp/dist/index.js"], - "env": { - "HELIUS_API_KEY": "${HELIUS_API_KEY}", - "SOLANA_RPC_URL": "${SOLANA_RPC_URL}" - } - }, "clawd-code": { - "command": "npx", - "args": ["@solana-clawd/clawd-code@latest"] - }, - "pump-mcp": { "command": "node", - "args": ["../../mcp-server/dist/index.js"], + "args": ["./scripts/run-clawd-code.mjs"], "env": { + "CLAWD_PROVIDER": "${CLAWD_PROVIDER}", + "CLAWD_MODEL": "${CLAWD_MODEL}", + "ZAI_API_KEY": "${ZAI_API_KEY}", + "XAI_API_KEY": "${XAI_API_KEY}", + "ANTHROPIC_API_KEY": "${ANTHROPIC_API_KEY}", + "OPENROUTER_API_KEY": "${OPENROUTER_API_KEY}", + "DEEPSEEK_API_KEY": "${DEEPSEEK_API_KEY}", + "HELIUS_API_KEY": "${HELIUS_API_KEY}", "SOLANA_RPC_URL": "${SOLANA_RPC_URL}", - "HELIUS_API_KEY": "${HELIUS_API_KEY}" + "LIVE_TRADING": "${LIVE_TRADING}", + "OPERATOR_CONFIRMED": "${OPERATOR_CONFIRMED}", + "PERPS_SIM_ONLY": "${PERPS_SIM_ONLY}" } }, "phoenix-rise": { diff --git a/plugins/clawd-plugin/README.md b/plugins/clawd-plugin/README.md index 452fe6904d107..d88e3b25add36 100644 --- a/plugins/clawd-plugin/README.md +++ b/plugins/clawd-plugin/README.md @@ -1,73 +1,125 @@ -# Clawd Code Plugin for Clawd Code +# @solana-clawd/clawd-plugin -Build on Solana with Clawd Code — one install gives you live blockchain tools, expert coding patterns, perpetuals trading, x402 payments, and autonomous agent commerce. +Clawd agent plugin for **Clawd Code** — skills, MCP servers, and a monorepo bridge +into the sibling `plugins/clawd-code` checkout (not a second vendored tree). -## Install +## Clawd Code source of truth -### From a marketplace +`plugins/clawd-code` now comes from +[https://github.com/Solizardking/clawd-code](https://github.com/Solizardking/clawd-code), +not a vendored local tree. + +| Item | Result | +| --- | --- | +| **Source of truth** | Git submodule at `plugins/clawd-code` → `https://github.com/Solizardking/clawd-code.git` | +| **Pinned commit** | `29e3a9dccf6433c1f47710d6dc0470ac0cbec7bc` (`main`) | +| **`.gitmodules`** | `[submodule "plugins/clawd-code"]` with that URL | +| **Package metadata** | `repository` / `homepage` → Solizardking/clawd-code | +| **`install.sh` default** | `CLAWD_CODE_REPO=https://github.com/Solizardking/clawd-code.git` | +| **This plugin** | MCP + skills live here; CLI is resolved from the sibling submodule | + +### Verification + +- Workspace resolve: `@solana-clawd/clawd-code@workspace:plugins/clawd-code` +- GitHub install smoke: clone + build of Solizardking/clawd-code produced `dist/cli.js` +- Bridge tests: `bun run --cwd plugins/clawd-plugin test` +- No monorepo-owned install links to `solana-clawd/tree/main/clawd-code` for this package + +### Install (canonical CLI) + +```bash +curl -fsSL https://raw.githubusercontent.com/Solizardking/clawd-code/main/install.sh | sh +``` + +## Monorepo communication map + +```text +plugins/clawd-plugin ← skills + .mcp.json (this package) + │ run-clawd-code.mjs + ▼ +plugins/clawd-code ← git submodule of Solizardking/clawd-code + │ workspace package @solana-clawd/clawd-code + ▼ +packages/cheshire-eliza ← characters + body generator + ├── @elizaos/plugin-cheshire-memory + ├── @elizaos/plugin-clawdbrowser + └── @elizaos/plugin-dflow-trade +``` + +| Package | Role | +| --- | --- | +| `@solana-clawd/clawd-code` | CLI (code / trade / research / voice / arena) | +| `@solana-clawd/clawd-plugin` | Clawd runtime plugin: skills + MCP bridge to the CLI | +| `@elizaos/cheshire-eliza` | Solizard / Cheshire character + agent body generator | +| `@elizaos/plugin-cheshire-memory` | Hermes + Honcho durable memory | +| `@elizaos/plugin-clawdbrowser` | ClawdBrowser `tools.md` catalog actions | + +## Install (marketplace) ``` /plugin marketplace add solizardking/clawd-plugins /plugin install clawd-code@solizardking ``` -### Local testing +## Local monorepo testing ```bash -clawd --plugin-dir ./plugins/clawd-code/clawd-plugin -``` +# from repo root +git submodule update --init plugins/clawd-code +bun install -## What's Included +# bridge resolves sibling CLI +bun run --cwd plugins/clawd-plugin test +bun run --cwd plugins/clawd-plugin clawd-code -- --help -**Helius MCP Server** — auto-starts with the plugin. 10 routed tools covering DAS API, RPC, webhooks, streaming, wallet analysis, and docs. +# agent runtime +clawd --plugin-dir ./plugins/clawd-plugin +``` -**Clawd Code MCP Server** — auto-starts the Clawd Code CLI as an MCP server for code generation, trading, research, images, and voice. +Override the CLI binary if needed: -**Phoenix Rise MCP Server** — auto-starts for real-time perpetuals orderbook and funding rate data. +```bash +export CLAWD_CODE_BIN=/path/to/clawd-code +``` -**DFlow MCP Server** — auto-starts for trading API details, response schemas, and code examples. +## What's included -### Skills +**Clawd Code MCP** — starts the **sibling** monorepo CLI via +`scripts/run-clawd-code.mjs` (prefers `plugins/clawd-code/dist/cli.js`, then +workspace, then `npx @solana-clawd/clawd-code@latest`). -| Skill | Invoke | What It Does | -|---|---|---| -| **Clawd Code** | `/clawd:code` | Makes your agent an expert at using the Clawd Code CLI — 5 modes (code, trade, research, image, voice), wallet ops, perps workflows | -| **Build** | `/clawd:build` | Makes your agent an expert Solana developer — Helius APIs, routing logic, SDK patterns | -| **DFlow** | `/clawd:dflow` | Makes your agent an expert at building Solana trading apps — DFlow swaps, prediction markets, KYC | -| **Phantom** | `/clawd:phantom` | Makes your agent an expert at building frontend dApps — Phantom Connect SDK, token gating, NFT minting | -| **Jupiter** | `/clawd:jupiter` | Makes your agent an expert at building DeFi apps — Jupiter swaps, lending, limit orders, DCA | -| **OKX** | `/clawd:okx` | Compose OKX DEX aggregation and market intelligence with Helius infrastructure | -| **SVM** | `/clawd:svm` | Solana protocol expert — architecture, consensus, execution engine | +**Phoenix Rise / DFlow / zkcompression** — HTTP MCP endpoints for market and +compression tooling. -### Reference Files +### Skills -Deep documentation bundled with each skill covering DAS API, Sender, Priority Fees, Webhooks, WebSockets, LaserStream, Wallet API, Enhanced Transactions, Onboarding, Clawd Code CLI usage, perps workflows, wallet operations, DFlow spot trading/prediction markets, Phantom SDKs, Jupiter APIs, and SVM architecture. +| Skill | Invoke | What it does | +| --- | --- | --- | +| **Clawd Code** | `/clawd:code` | Expert use of the Clawd Code CLI | +| **Build** | `/clawd:build` | Solana + Helius development patterns | +| **DFlow** | `/clawd:dflow` | Spot + prediction markets | +| **Phantom** | `/clawd:phantom` | Wallet / frontend Connect | +| **Jupiter** | `/clawd:jupiter` | DeFi swaps and lending | +| **OKX** | `/clawd:okx` | OKX + Helius composition | +| **SVM** | `/clawd:svm` | Solana protocol internals | +| **Agent Arena** | `/clawd:arena` | On-chain identity + reputation | -## API Key Setup +## API keys -Set in `~/.clawd-code/.env`: +Set in `~/.clawd-code/.env` (shared with the CLI): ```bash -XAI_API_KEY=your-xai-key -HELIUS_API_KEY=your-helius-key -SOLANA_RPC_URL=https://mainnet.helius-rpc.com/?api-key=your-helius-key +CLAWD_PROVIDER=zai +CLAWD_MODEL=glm-5.2 +ZAI_API_KEY= +XAI_API_KEY= +HELIUS_API_KEY= +SOLANA_RPC_URL=https://mainnet.helius-rpc.com/?api-key= +LIVE_TRADING=false +OPERATOR_CONFIRMED=false +PERPS_SIM_ONLY=true ``` -## Usage - -Once installed, just ask questions in plain English: - -- "Build a Jupiter swap bot in TypeScript" -- "What's the funding rate on SOL perps?" -- "Research the latest AI agent frameworks" -- "Generate an image of a cyberpunk Solana trading desk" -- "What NFTs does this wallet own?" -- "Create wallet and show me my balance" -- "Set up webhooks to monitor my wallet" -- "Parse this transaction: 5abc..." - -Your agent picks the right tools and reads the right reference files automatically. - ## License MIT. See [LICENSE](./LICENSE). @@ -75,5 +127,5 @@ MIT. See [LICENSE](./LICENSE). ## Links - [Clawd Code on GitHub](https://github.com/Solizardking/clawd-code) +- [Cheshire eliza package](../../packages/cheshire-eliza/README.md) - [x402 Protocol](https://x402.wtf) -- [Helius Documentation](https://www.helius.dev/docs) diff --git a/plugins/clawd-plugin/package.json b/plugins/clawd-plugin/package.json new file mode 100644 index 0000000000000..f077aefe3b77a --- /dev/null +++ b/plugins/clawd-plugin/package.json @@ -0,0 +1,47 @@ +{ + "name": "@solana-clawd/clawd-plugin", + "version": "1.1.0", + "type": "module", + "description": "Clawd agent plugin (skills + MCP) wired to monorepo sibling @solana-clawd/clawd-code and Cheshire elizaOS plugins", + "main": "scripts/resolve-clawd-code.mjs", + "bin": { + "clawd-plugin-run-code": "scripts/run-clawd-code.mjs" + }, + "files": [ + ".clawd-plugin", + ".mcp.json", + "scripts", + "skills", + "README.md", + "LICENSE" + ], + "scripts": { + "test": "node --test scripts/resolve-clawd-code.test.mjs", + "clawd-code": "node scripts/run-clawd-code.mjs", + "verify:bridge": "node scripts/run-clawd-code.mjs --help" + }, + "dependencies": { + "@solana-clawd/clawd-code": "^1.0.0" + }, + "publishConfig": { + "access": "public" + }, + "keywords": [ + "clawd", + "clawd-code", + "solana", + "mcp", + "cheshire", + "elizaos" + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/Solizardking/eliza.git", + "directory": "plugins/clawd-plugin" + }, + "homepage": "https://github.com/Solizardking/clawd-code#readme", + "bugs": { + "url": "https://github.com/Solizardking/clawd-code/issues" + } +} diff --git a/plugins/clawd-plugin/scripts/resolve-clawd-code.mjs b/plugins/clawd-plugin/scripts/resolve-clawd-code.mjs new file mode 100644 index 0000000000000..63c1886475aa4 --- /dev/null +++ b/plugins/clawd-plugin/scripts/resolve-clawd-code.mjs @@ -0,0 +1,156 @@ +/** + * Resolve the monorepo sibling clawd-code package for MCP and CLI bridges. + * Preference order: CLAWD_CODE_BIN → sibling dist/src → workspace package → npx. + */ + +import { createRequire } from "node:module"; +import { existsSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +/** Absolute path to plugins/clawd-plugin */ +export const CLAWD_PLUGIN_ROOT = resolve(__dirname, ".."); + +/** Absolute path to plugins/clawd-code (git submodule of Solizardking/clawd-code) */ +export const CLAWD_CODE_ROOT = resolve(CLAWD_PLUGIN_ROOT, "../clawd-code"); + +/** Canonical upstream source for the CLI package */ +export const CLAWD_CODE_GITHUB = "https://github.com/Solizardking/clawd-code"; + +/** + * @typedef {{ + * kind: "bin" | "node" | "tsx" | "npx", + * path?: string, + * root?: string, + * package?: string, + * command: string, + * args: string[], + * }} ClawdCodeResolution + */ + +/** + * Resolve how to invoke clawd-code from this plugin package. + * @returns {ClawdCodeResolution} + */ +export function resolveClawdCode() { + const envBin = process.env.CLAWD_CODE_BIN?.trim(); + if (envBin) { + return { + kind: "bin", + path: envBin, + root: CLAWD_CODE_ROOT, + command: envBin, + args: [], + }; + } + + const siblingDist = join(CLAWD_CODE_ROOT, "dist", "cli.js"); + if (existsSync(siblingDist)) { + return { + kind: "node", + path: siblingDist, + root: CLAWD_CODE_ROOT, + command: process.execPath, + args: [siblingDist], + }; + } + + const siblingSrc = join(CLAWD_CODE_ROOT, "src", "cli.ts"); + if (existsSync(siblingSrc)) { + const tsxCli = join(CLAWD_CODE_ROOT, "node_modules", "tsx", "dist", "cli.mjs"); + if (existsSync(tsxCli)) { + return { + kind: "tsx", + path: siblingSrc, + root: CLAWD_CODE_ROOT, + command: process.execPath, + args: [tsxCli, siblingSrc], + }; + } + return { + kind: "tsx", + path: siblingSrc, + root: CLAWD_CODE_ROOT, + command: "npx", + args: ["tsx", siblingSrc], + }; + } + + try { + const require = createRequire(import.meta.url); + const pkgJson = require.resolve("@solana-clawd/clawd-code/package.json"); + const pkgRoot = dirname(pkgJson); + const distCli = join(pkgRoot, "dist", "cli.js"); + if (existsSync(distCli)) { + return { + kind: "node", + path: distCli, + root: pkgRoot, + command: process.execPath, + args: [distCli], + }; + } + } catch { + // workspace package not resolvable yet + } + + return { + kind: "npx", + package: "@solana-clawd/clawd-code@latest", + command: "npx", + args: ["@solana-clawd/clawd-code@latest"], + }; +} + +/** + * Plugin directory for `clawd --plugin-dir`. + * Prefers this monorepo package; falls back to nested clawd-code/clawd-plugin. + * @returns {string} + */ +export function resolveClawdPluginDir() { + if (existsSync(join(CLAWD_PLUGIN_ROOT, ".mcp.json"))) { + return CLAWD_PLUGIN_ROOT; + } + const nested = join(CLAWD_CODE_ROOT, "clawd-plugin"); + if (existsSync(nested)) { + return nested; + } + return CLAWD_PLUGIN_ROOT; +} + +/** + * Paths used by Cheshire elizaOS packages that should stay aligned with clawd. + * @returns {Record} + */ +export function resolveCheshireBridgePaths() { + return { + clawdCodeGithub: CLAWD_CODE_GITHUB, + clawdCodeRoot: CLAWD_CODE_ROOT, + clawdPluginRoot: resolveClawdPluginDir(), + cheshireEliza: resolve(CLAWD_PLUGIN_ROOT, "../../packages/cheshire-eliza"), + pluginCheshireMemory: resolve( + CLAWD_PLUGIN_ROOT, + "../plugin-cheshire-memory", + ), + pluginClawdBrowser: resolve(CLAWD_PLUGIN_ROOT, "../plugin-clawdbrowser"), + }; +} + +export function formatResolution(res = resolveClawdCode()) { + return { + kind: res.kind, + command: res.command, + args: res.args, + path: res.path ?? null, + root: res.root ?? null, + package: res.package ?? null, + pluginDir: resolveClawdPluginDir(), + github: CLAWD_CODE_GITHUB, + }; +} + +if (import.meta.url === `file://${process.argv[1]}`) { + console.log(JSON.stringify(formatResolution(), null, 2)); +} diff --git a/plugins/clawd-plugin/scripts/resolve-clawd-code.test.mjs b/plugins/clawd-plugin/scripts/resolve-clawd-code.test.mjs new file mode 100644 index 0000000000000..ebb062c0b2142 --- /dev/null +++ b/plugins/clawd-plugin/scripts/resolve-clawd-code.test.mjs @@ -0,0 +1,61 @@ +/** + * Real-path tests for clawd-plugin ↔ clawd-code resolution (no mocks of the sibling tree). + */ + +import assert from "node:assert/strict"; +import { existsSync, readFileSync } from "node:fs"; +import { join } from "node:path"; +import { describe, it } from "node:test"; +import { + CLAWD_CODE_GITHUB, + CLAWD_CODE_ROOT, + CLAWD_PLUGIN_ROOT, + formatResolution, + resolveCheshireBridgePaths, + resolveClawdCode, + resolveClawdPluginDir, +} from "./resolve-clawd-code.mjs"; + +describe("clawd-plugin ↔ clawd-code bridge", () => { + it("points at Solizardking/clawd-code submodule root", () => { + assert.equal(CLAWD_CODE_GITHUB, "https://github.com/Solizardking/clawd-code"); + assert.ok(existsSync(join(CLAWD_CODE_ROOT, "package.json"))); + const pkg = JSON.parse( + readFileSync(join(CLAWD_CODE_ROOT, "package.json"), "utf8"), + ); + assert.equal(pkg.name, "@solana-clawd/clawd-code"); + assert.match(pkg.repository?.url ?? "", /Solizardking\/clawd-code/); + }); + + it("resolves a runnable clawd-code entry (sibling dist/src preferred)", () => { + const res = resolveClawdCode(); + assert.ok(["bin", "node", "tsx", "npx"].includes(res.kind)); + assert.ok(res.command); + assert.ok(Array.isArray(res.args)); + if (res.kind === "node" || res.kind === "tsx") { + assert.ok(res.path && existsSync(res.path), `missing ${res.path}`); + assert.ok(String(res.path).includes("clawd-code")); + } + }); + + it("resolves monorepo plugin dir for --plugin-dir", () => { + const dir = resolveClawdPluginDir(); + assert.equal(dir, CLAWD_PLUGIN_ROOT); + assert.ok(existsSync(join(dir, ".mcp.json"))); + assert.ok(existsSync(join(dir, "skills", "clawd-code", "SKILL.md"))); + }); + + it("exposes Cheshire monorepo bridge paths", () => { + const paths = resolveCheshireBridgePaths(); + assert.equal(paths.clawdCodeGithub, CLAWD_CODE_GITHUB); + assert.ok(existsSync(join(paths.cheshireEliza, "package.json"))); + assert.ok(existsSync(join(paths.pluginCheshireMemory, "package.json"))); + assert.ok(existsSync(join(paths.pluginClawdBrowser, "package.json"))); + }); + + it("formatResolution includes github + pluginDir", () => { + const fmt = formatResolution(); + assert.equal(fmt.github, CLAWD_CODE_GITHUB); + assert.ok(fmt.pluginDir.includes("clawd-plugin")); + }); +}); diff --git a/plugins/clawd-plugin/scripts/run-clawd-code.mjs b/plugins/clawd-plugin/scripts/run-clawd-code.mjs new file mode 100644 index 0000000000000..82352ac5ee0ff --- /dev/null +++ b/plugins/clawd-plugin/scripts/run-clawd-code.mjs @@ -0,0 +1,38 @@ +#!/usr/bin/env node +/** + * Spawn the resolved clawd-code binary/package with forwarded args. + * Used by .mcp.json and monorepo verification so the plugin talks to the sibling CLI. + */ + +import { spawn } from "node:child_process"; +import { resolveClawdCode, resolveClawdPluginDir } from "./resolve-clawd-code.mjs"; + +const resolution = resolveClawdCode(); +const forwarded = process.argv.slice(2); +const args = [...resolution.args, ...forwarded]; + +const child = spawn(resolution.command, args, { + stdio: "inherit", + env: { + ...process.env, + CLAWD_PLUGIN_DIR: process.env.CLAWD_PLUGIN_DIR || resolveClawdPluginDir(), + CLAWD_CODE_ROOT: resolution.root || process.env.CLAWD_CODE_ROOT || "", + }, + shell: resolution.kind === "npx", +}); + +child.on("error", (err) => { + console.error( + `[clawd-plugin] failed to start clawd-code (${resolution.kind}):`, + err.message, + ); + process.exit(1); +}); + +child.on("exit", (code, signal) => { + if (signal) { + process.kill(process.pid, signal); + return; + } + process.exit(code ?? 1); +}); diff --git a/plugins/clawd-plugin/skills/clawd-code/SKILL.md b/plugins/clawd-plugin/skills/clawd-code/SKILL.md index 04f5a871bbaee..534270a1f1270 100644 --- a/plugins/clawd-plugin/skills/clawd-code/SKILL.md +++ b/plugins/clawd-plugin/skills/clawd-code/SKILL.md @@ -62,6 +62,25 @@ Required in `~/.clawd-code/.env`: 6. **Signal confidence must be explicit** — label confidence scores for every trading signal 7. **Never invent signatures, prices, or addresses** — say "not available" when data isn't in hand +## Monorepo bridge + +In this eliza checkout, prefer the sibling submodule — not a second vendored tree: + +| Path | Role | +| --- | --- | +| `plugins/clawd-code` | Git submodule of https://github.com/Solizardking/clawd-code | +| `plugins/clawd-plugin` | This package — skills + MCP → sibling CLI | +| `packages/cheshire-eliza` | Solizard character + body generator | +| `plugins/plugin-cheshire-memory` | Hermes + Honcho memory | +| `plugins/plugin-clawdbrowser` | ClawdBrowser tools catalog | + +```bash +# Resolve + invoke monorepo CLI +bun run --cwd plugins/clawd-plugin clawd-code -- verify +# or after global install: +curl -fsSL https://raw.githubusercontent.com/Solizardking/clawd-code/main/install.sh | sh +``` + ## Reference Files - `references/` — Deep reference docs for Clawd Code CLI usage, wallet operations, perps workflows, and integration patterns \ No newline at end of file diff --git a/plugins/plugin-cheshire-memory/README.md b/plugins/plugin-cheshire-memory/README.md index 85d74060c05c9..4818196ddf85f 100644 --- a/plugins/plugin-cheshire-memory/README.md +++ b/plugins/plugin-cheshire-memory/README.md @@ -2,6 +2,17 @@ Persistent **trading + chat** memory for Cheshire / Solizard agents. +## Monorepo companions + +| Package | Role | +| --- | --- | +| `@elizaos/cheshire-eliza` | Character + body generator (loads this plugin) | +| `@elizaos/plugin-clawdbrowser` | ClawdBrowser tool catalog | +| `@solana-clawd/clawd-code` | CLI submodule — https://github.com/Solizardking/clawd-code | +| `@solana-clawd/clawd-plugin` | MCP/skills bridge into the CLI | + +Part of the Cheshire stack documented in [`packages/cheshire-eliza/README.md`](../../packages/cheshire-eliza/README.md). + ## Keys | Variable | Role | diff --git a/plugins/plugin-cheshire-memory/package.json b/plugins/plugin-cheshire-memory/package.json index 93a111d13765c..c3184058ceb96 100644 --- a/plugins/plugin-cheshire-memory/package.json +++ b/plugins/plugin-cheshire-memory/package.json @@ -25,7 +25,10 @@ "typecheck": "tsc --noEmit -p tsconfig.json" }, "peerDependencies": { - "@elizaos/core": "workspace:*" + "@elizaos/core": ">=1.0.0 || >=2.0.0-0" + }, + "publishConfig": { + "access": "public" }, "elizaos": { "plugin": { diff --git a/plugins/plugin-clawdbrowser/README.md b/plugins/plugin-clawdbrowser/README.md index 4cb5b59f693c9..38541051c37cd 100644 --- a/plugins/plugin-clawdbrowser/README.md +++ b/plugins/plugin-clawdbrowser/README.md @@ -4,6 +4,17 @@ Official elizaOS plugin that gives agents the **ClawdBrowser SOL GPT tool catalo Agents can **search**, **describe**, and **list** the 171 non-custodial Solana tools (Phoenix, Imperial, wallets, swaps, browser, Solana Tracker, …) without holding private keys. +## Monorepo companions + +| Package | Role | +| --- | --- | +| `@elizaos/cheshire-eliza` | Character + body generator (loads this plugin) | +| `@elizaos/plugin-cheshire-memory` | Hermes + Honcho durable memory | +| `@solana-clawd/clawd-code` | Coding/trading CLI — https://github.com/Solizardking/clawd-code (`plugins/clawd-code` submodule) | +| `@solana-clawd/clawd-plugin` | Skills + MCP bridge to that CLI | + +See [`packages/cheshire-eliza/README.md`](../../packages/cheshire-eliza/README.md) for the full communication map. + ## Install (monorepo) ```bash diff --git a/plugins/plugin-clawdbrowser/package.json b/plugins/plugin-clawdbrowser/package.json index d167ea557a914..e24ce59021907 100644 --- a/plugins/plugin-clawdbrowser/package.json +++ b/plugins/plugin-clawdbrowser/package.json @@ -26,7 +26,10 @@ "typecheck": "tsc --noEmit -p tsconfig.json" }, "peerDependencies": { - "@elizaos/core": "workspace:*" + "@elizaos/core": ">=1.0.0 || >=2.0.0-0" + }, + "publishConfig": { + "access": "public" }, "elizaos": { "plugin": { diff --git a/scripts/publish-clawd-packages.mjs b/scripts/publish-clawd-packages.mjs new file mode 100644 index 0000000000000..a5d0e08b5b76e --- /dev/null +++ b/scripts/publish-clawd-packages.mjs @@ -0,0 +1,217 @@ +#!/usr/bin/env node +/** + * Publish Clawd-related packages to npm from isolated temp copies + * (avoids monorepo workspace npm conflicts). + * + * Default: dry-run. Use --apply for real publish. + * Scope rewrite: --npm-scope=x402solana maps package names into that scope + * (required when the logged-in user cannot publish @solana-clawd / @elizaos). + * + * Examples: + * node scripts/publish-clawd-packages.mjs + * node scripts/publish-clawd-packages.mjs --apply --npm-scope=x402solana + * node scripts/publish-clawd-packages.mjs --apply --only=clawd-code --npm-scope=x402solana + */ + +import { spawnSync } from "node:child_process"; +import { + cpSync, + existsSync, + mkdtempSync, + readFileSync, + rmSync, + writeFileSync, +} from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const root = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const apply = process.argv.includes("--apply"); +const onlyArg = process.argv.find((a) => a.startsWith("--only=")); +const only = onlyArg ? onlyArg.slice("--only=".length) : null; +const scopeArg = process.argv.find((a) => a.startsWith("--npm-scope=")); +const npmScope = scopeArg ? scopeArg.slice("--npm-scope=".length).replace(/^@/, "") : null; + +const PACKAGES = [ + { + id: "clawd-code", + dir: "plugins/clawd-code", + name: "@solana-clawd/clawd-code", + copyExtra: ["dist", "src", "install.sh", "README.md", "LICENSE", ".env.example", "clawd.json", "tsconfig.json", "package-lock.json", "clawd-plugin", "docs", "spinners"], + }, + { + id: "clawd-plugin", + dir: "plugins/clawd-plugin", + name: "@solana-clawd/clawd-plugin", + copyExtra: [".clawd-plugin", ".mcp.json", "scripts", "skills", "README.md", "LICENSE"], + }, + { + id: "cheshire-eliza", + dir: "packages/cheshire-eliza", + name: "@elizaos/cheshire-eliza", + copyExtra: ["src", "docs", "README.md"], + }, + { + id: "plugin-cheshire-memory", + dir: "plugins/plugin-cheshire-memory", + name: "@elizaos/plugin-cheshire-memory", + build: ["bun", "run", "build.ts"], + copyExtra: ["dist", "src", "README.md", "build.ts", "tsconfig.json"], + }, + { + id: "plugin-clawdbrowser", + dir: "plugins/plugin-clawdbrowser", + name: "@elizaos/plugin-clawdbrowser", + build: ["bun", "run", "build.ts"], + copyExtra: ["dist", "src", "README.md", "build.ts", "tsconfig.json", "registry-entry.json"], + }, +]; + +function run(cmd, args, cwd) { + console.log(`\n$ ${cmd} ${args.join(" ")} (cwd=${cwd})`); + const res = spawnSync(cmd, args, { + cwd, + stdio: "inherit", + env: { ...process.env }, + }); + if (res.status !== 0) { + throw new Error(`${cmd} ${args.join(" ")} failed with code ${res.status}`); + } +} + +function whoami() { + const res = spawnSync("npm", ["whoami"], { encoding: "utf8" }); + if (res.status !== 0) { + throw new Error("Not logged in to npm. Run: npm login"); + } + return res.stdout.trim(); +} + +function mapName(name) { + if (!npmScope) return name; + const bare = name.includes("/") ? name.split("/")[1] : name; + return `@${npmScope}/${bare}`; +} + +function rewriteWorkspaceDeps(pkg) { + const next = { ...pkg, publishConfig: { access: "public", ...(pkg.publishConfig || {}) } }; + for (const field of ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]) { + if (!next[field]) continue; + const deps = { ...next[field] }; + for (const [k, v] of Object.entries(deps)) { + if (typeof v === "string" && v.startsWith("workspace:")) { + deps[k] = v.replace(/^workspace:/, "").replace(/^\*/, ">=0.0.0") || ">=0.0.0"; + if (deps[k] === "*") deps[k] = ">=0.0.0"; + // workspace:* → open range + if (v === "workspace:*") deps[k] = ">=0.0.0"; + } + // map sibling clawd deps into chosen scope when rewriting + if (npmScope && k.startsWith("@solana-clawd/")) { + const bare = k.split("/")[1]; + delete deps[k]; + deps[`@${npmScope}/${bare}`] = deps[`@${npmScope}/${bare}`] || "^1.0.0"; + } + } + next[field] = deps; + } + next.name = mapName(pkg.name); + return next; +} + +function stagePackage(target) { + const srcRoot = join(root, target.dir); + const stage = mkdtempSync(join(tmpdir(), `clawd-pub-${target.id}-`)); + const pkgSrc = join(srcRoot, "package.json"); + const pkg = JSON.parse(readFileSync(pkgSrc, "utf8")); + if (pkg.private === true) throw new Error(`${pkg.name} is private`); + + // Always copy package.json (rewritten) + const rewritten = rewriteWorkspaceDeps(pkg); + writeFileSync(join(stage, "package.json"), `${JSON.stringify(rewritten, null, 2)}\n`); + + for (const rel of target.copyExtra || []) { + const from = join(srcRoot, rel); + if (!existsSync(from)) { + console.warn(` missing optional path: ${rel}`); + continue; + } + cpSync(from, join(stage, rel), { recursive: true }); + } + + // Prefer a README; fall back to monorepo clawd.md snippet name + if (!existsSync(join(stage, "README.md")) && existsSync(join(root, "clawd.md"))) { + cpSync(join(root, "clawd.md"), join(stage, "README.md")); + } + + return { stage, pkg: rewritten }; +} + +function buildInPlace(target) { + if (!target.build) return; + const abs = join(root, target.dir); + try { + run(target.build[0], target.build.slice(1), abs); + } catch (err) { + if (existsSync(join(abs, "dist"))) { + console.warn(`build warning (using existing dist): ${err.message}`); + return; + } + throw err; + } +} + +function main() { + console.log(apply ? "MODE: APPLY (real publish)" : "MODE: dry-run"); + if (npmScope) console.log(`npm scope rewrite: @${npmScope}/*`); + const user = whoami(); + console.log(`npm user: ${user}`); + + const targets = PACKAGES.filter( + (p) => !only || p.id === only || p.name === only || p.dir === only, + ); + if (!targets.length) throw new Error(`No packages matched --only=${only}`); + + const results = []; + + for (const target of targets) { + console.log(`\n========== ${target.name} ==========`); + buildInPlace(target); + const { stage, pkg } = stagePackage(target); + console.log(`staged → ${stage}`); + console.log(`publish name: ${pkg.name}@${pkg.version}`); + + try { + run("npm", ["pack", "--dry-run"], stage); + if (apply) { + run("npm", ["publish", "--access", "public"], stage); + results.push({ name: pkg.name, version: pkg.version, ok: true }); + } else { + run("npm", ["publish", "--access", "public", "--dry-run"], stage); + results.push({ name: pkg.name, version: pkg.version, ok: true, dryRun: true }); + } + } catch (err) { + console.error(err.message); + results.push({ name: pkg.name, version: pkg.version, ok: false, error: err.message }); + } finally { + rmSync(stage, { recursive: true, force: true }); + } + } + + console.log("\n=== Summary ==="); + for (const r of results) { + console.log( + `${r.ok ? "OK" : "FAIL"} ${r.name}@${r.version}${r.dryRun ? " (dry-run)" : ""}${r.error ? ` — ${r.error}` : ""}`, + ); + } + + if (results.some((r) => !r.ok)) process.exit(1); + if (!apply) { + console.log("\nDry-run complete. Publish for real:"); + console.log( + ` node scripts/publish-clawd-packages.mjs --apply --npm-scope=${npmScope || user}`, + ); + } +} + +main();