diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json new file mode 100644 index 00000000..993763e7 --- /dev/null +++ b/.claude-plugin/marketplace.json @@ -0,0 +1,172 @@ +{ + "name": "tiny-engineer", + "owner": { + "name": "Krzysztof Jamroz", + "url": "https://github.com/jamro/tiny-engineer" + }, + "description": "Claude Code plugins for the Tiny Engineer desk robot", + "plugins": [ + { + "name": "tiny-engineer", + "source": "./skills", + "description": "Tiny Engineer desk robot for Claude Code: poses on every agent event (hooks) and speech through its speaker (tiny-engineer-play skill)", + "category": "productivity", + "keywords": [ + "robot", + "esp32", + "hooks", + "tts" + ], + "homepage": "https://github.com/jamro/tiny-engineer/blob/main/docs/integration.md", + "license": "MIT", + "skills": [ + "./" + ], + "hooks": { + "SessionStart": [ + { + "hooks": [ + { + "type": "command", + "command": "grep -qs \"hook claude-code\" \"$CLAUDE_PROJECT_DIR/.claude/settings.json\" \"$CLAUDE_PROJECT_DIR/.claude/settings.local.json\" && exit 0; command -v tiny-engineer >/dev/null 2>&1 || exit 0; tiny-engineer hook claude-code", + "async": true + } + ] + } + ], + "SessionEnd": [ + { + "hooks": [ + { + "type": "command", + "command": "grep -qs \"hook claude-code\" \"$CLAUDE_PROJECT_DIR/.claude/settings.json\" \"$CLAUDE_PROJECT_DIR/.claude/settings.local.json\" && exit 0; command -v tiny-engineer >/dev/null 2>&1 || exit 0; tiny-engineer hook claude-code", + "async": true + } + ] + } + ], + "UserPromptSubmit": [ + { + "hooks": [ + { + "type": "command", + "command": "grep -qs \"hook claude-code\" \"$CLAUDE_PROJECT_DIR/.claude/settings.json\" \"$CLAUDE_PROJECT_DIR/.claude/settings.local.json\" && exit 0; command -v tiny-engineer >/dev/null 2>&1 || exit 0; tiny-engineer hook claude-code", + "async": true + } + ] + } + ], + "SubagentStart": [ + { + "hooks": [ + { + "type": "command", + "command": "grep -qs \"hook claude-code\" \"$CLAUDE_PROJECT_DIR/.claude/settings.json\" \"$CLAUDE_PROJECT_DIR/.claude/settings.local.json\" && exit 0; command -v tiny-engineer >/dev/null 2>&1 || exit 0; tiny-engineer hook claude-code", + "async": true + } + ] + } + ], + "PreToolUse": [ + { + "hooks": [ + { + "type": "command", + "command": "grep -qs \"hook claude-code\" \"$CLAUDE_PROJECT_DIR/.claude/settings.json\" \"$CLAUDE_PROJECT_DIR/.claude/settings.local.json\" && exit 0; command -v tiny-engineer >/dev/null 2>&1 || exit 0; tiny-engineer hook claude-code", + "async": true + } + ] + } + ], + "PostToolBatch": [ + { + "hooks": [ + { + "type": "command", + "command": "grep -qs \"hook claude-code\" \"$CLAUDE_PROJECT_DIR/.claude/settings.json\" \"$CLAUDE_PROJECT_DIR/.claude/settings.local.json\" && exit 0; command -v tiny-engineer >/dev/null 2>&1 || exit 0; tiny-engineer hook claude-code", + "async": true + } + ] + } + ], + "PostToolUseFailure": [ + { + "hooks": [ + { + "type": "command", + "command": "grep -qs \"hook claude-code\" \"$CLAUDE_PROJECT_DIR/.claude/settings.json\" \"$CLAUDE_PROJECT_DIR/.claude/settings.local.json\" && exit 0; command -v tiny-engineer >/dev/null 2>&1 || exit 0; tiny-engineer hook claude-code", + "async": true + } + ] + } + ], + "PreCompact": [ + { + "hooks": [ + { + "type": "command", + "command": "grep -qs \"hook claude-code\" \"$CLAUDE_PROJECT_DIR/.claude/settings.json\" \"$CLAUDE_PROJECT_DIR/.claude/settings.local.json\" && exit 0; command -v tiny-engineer >/dev/null 2>&1 || exit 0; tiny-engineer hook claude-code", + "async": true + } + ] + } + ], + "PermissionRequest": [ + { + "hooks": [ + { + "type": "command", + "command": "grep -qs \"hook claude-code\" \"$CLAUDE_PROJECT_DIR/.claude/settings.json\" \"$CLAUDE_PROJECT_DIR/.claude/settings.local.json\" && exit 0; command -v tiny-engineer >/dev/null 2>&1 || exit 0; tiny-engineer hook claude-code", + "async": true + } + ] + } + ], + "PermissionDenied": [ + { + "hooks": [ + { + "type": "command", + "command": "grep -qs \"hook claude-code\" \"$CLAUDE_PROJECT_DIR/.claude/settings.json\" \"$CLAUDE_PROJECT_DIR/.claude/settings.local.json\" && exit 0; command -v tiny-engineer >/dev/null 2>&1 || exit 0; tiny-engineer hook claude-code", + "async": true + } + ] + } + ], + "Notification": [ + { + "hooks": [ + { + "type": "command", + "command": "grep -qs \"hook claude-code\" \"$CLAUDE_PROJECT_DIR/.claude/settings.json\" \"$CLAUDE_PROJECT_DIR/.claude/settings.local.json\" && exit 0; command -v tiny-engineer >/dev/null 2>&1 || exit 0; tiny-engineer hook claude-code", + "async": true + } + ] + } + ], + "Stop": [ + { + "hooks": [ + { + "type": "command", + "command": "grep -qs \"hook claude-code\" \"$CLAUDE_PROJECT_DIR/.claude/settings.json\" \"$CLAUDE_PROJECT_DIR/.claude/settings.local.json\" && exit 0; command -v tiny-engineer >/dev/null 2>&1 || exit 0; tiny-engineer hook claude-code", + "async": true + } + ] + } + ], + "StopFailure": [ + { + "hooks": [ + { + "type": "command", + "command": "grep -qs \"hook claude-code\" \"$CLAUDE_PROJECT_DIR/.claude/settings.json\" \"$CLAUDE_PROJECT_DIR/.claude/settings.local.json\" && exit 0; command -v tiny-engineer >/dev/null 2>&1 || exit 0; tiny-engineer hook claude-code", + "async": true + } + ] + } + ] + } + } + ] +} diff --git a/AGENTS.md b/AGENTS.md index a612268e..8ca7fc09 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -14,6 +14,7 @@ Tiny Engineer is an open-source ESP32-C3 Wi-Fi desk robot: 3D-printed mechanics, | `ui/` | Web control panel (Vite, TypeScript, Preact); `pio run` builds it into one minified page and embeds it gzipped in the firmware | | `packages/` | HTTP / hook CLIs (Cursor, Antigravity, Claude Code, …) — scope `integrations` | | `skills/` | Agent skills shared by Claude Code, Cursor and Antigravity — scope `integrations` | +| `.claude-plugin/` | Claude Code plugin marketplace; the `tiny-engineer` plugin ships `skills/` plus inline Claude Code hooks — scope `integrations` | | `3d_models/` | CAD and printables (CERN-OHL-S) | | `mods/` | Optional mods; models under `mods//3d_models/` (CERN-OHL-S) | | `hardware/` | KiCad boards (CERN-OHL-S) | @@ -73,7 +74,7 @@ Web UI API page: one-line route descriptions only (except supported-parameter li Format: `type(scope): summary` (imperative, lowercase type, no trailing period; PR title same). Scopes: `firmware`, `http`, `settings`, `anim`, `servos`, `wifi`, `integrations`, `cad`, `mods`, `pcb`, `docs`, `scripts`, `ci`. -`integrations` = anything under `packages/` or `skills/`. Do not add a new scope per package. +`integrations` = anything under `packages/`, `skills/` or `.claude-plugin/`. Do not add a new scope per package. `mods` = anything under `mods/`. Name the mod in the summary. Do not add a new scope per mod. Breaking rules, SemVer mapping, and examples: [CONTRIBUTING.md](CONTRIBUTING.md). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d8522bbd..2aa33919 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -100,7 +100,7 @@ Format: `type(scope): summary` Scopes: `firmware`, `http`, `settings`, `anim`, `servos`, `wifi`, `integrations`, `cad`, `mods`, `pcb`, `docs`, `scripts`, `ci`, `web`, `cli`. -`integrations` is anything under `packages/` (Cursor, Antigravity, Claude Code, later agent CLIs). Do not add a new scope per package. +`integrations` is anything under `packages/` (Cursor, Antigravity, Claude Code, later agent CLIs), `skills/`, or `.claude-plugin/`. Do not add a new scope per package. `mods` is anything under `mods/`. Name the mod in the summary. Do not add a new scope per mod. diff --git a/docs/integration.md b/docs/integration.md index 5fc38115..16c0a5b6 100644 --- a/docs/integration.md +++ b/docs/integration.md @@ -101,6 +101,22 @@ npx -y tiny-engineer uninstall cursor --yes # remove only Tiny Engineer hook ent This firmware repo already ships configs pointing at the **local** CLI bin for developing the package. +### Claude Code plugin (all projects) + +Instead of `setup` per project, Claude Code can install the hooks once for every project as a plugin. This repo is a Claude Code plugin marketplace ([`.claude-plugin/marketplace.json`](../.claude-plugin/marketplace.json)). The `tiny-engineer` plugin brings the same 13 hook events as `setup claude-code` plus the [`tiny-engineer-play`](#speaking-through-the-robot-skill) skill. Run in a terminal: + +```bash +npm i -g tiny-engineer +claude plugin marketplace add jamro/tiny-engineer --sparse .claude-plugin skills +claude plugin install tiny-engineer@tiny-engineer +``` + +`--sparse` makes Claude Code check out only the two folders the plugin needs (a few KB) instead of the whole repo with CAD, PCB, and firmware sources (over 200 MB). Restart Claude Code afterwards. Turn the plugin off or on with `/plugin`. + +- The hooks run `tiny-engineer hook claude-code`, so the CLI must be on `PATH` (the `npm i -g` above, or a system package). Without it the hooks exit quietly and the robot stays still. They do not fall back to `npx`: Claude Code enforces no timeout on async hooks, and a stalled npm registry would leave one `npx` process behind per event. Connection prefs (URL, token, transport) come from the user config file described above, or from process env. +- A project whose `.claude/settings.json` or `.claude/settings.local.json` already has Tiny Engineer hooks (from `setup`, or this repo's dev hooks) keeps those, and the plugin stays quiet there, so events never fire twice. +- The skill is `/tiny-engineer:tiny-engineer-play` (plugin skills are namespaced). Claude also uses it when you ask the robot to say something. + ### Hook smoke test ```bash @@ -121,7 +137,19 @@ WAV for `/play`: 16-bit mono PCM at 22050 Hz. Details: [`api.md#post-play`](api. ### Speaking through the robot (skill) -Install the shared [`tiny-engineer-play`](../skills/tiny-engineer-play/SKILL.md) skill (`curl` + `POST /play`). Same skill works in Claude Code, Cursor, and Antigravity: +Install the shared [`tiny-engineer-play`](../skills/tiny-engineer-play/SKILL.md) skill (`curl` + `POST /play`). It needs a text-to-speech tool (`espeak-ng` on Linux, `say` on macOS) and `ffmpeg`. + +The skill's script reads the robot address and token only from the environment (`TINY_ENGINEER_URL`, default `http://tiny-engineer.local`, and `TINY_ENGINEER_TOKEN`). It does not read the user config that `tiny-engineer setup` writes. If your robot uses another address or an `access_token`, export both before you start the agent: + +```bash +export TINY_ENGINEER_URL=http://192.168.x.x +export TINY_ENGINEER_TOKEN=your-access-token +claude +``` + +**Claude Code:** the [Claude Code plugin](#claude-code-plugin-all-projects) includes this skill. + +**From a checkout.** The same skill works in Claude Code, Cursor, and Antigravity. A symlink follows whatever branch the checkout is on; copy the folder instead for a fixed version: ```bash mkdir -p ~/.claude/skills && ln -s "$PWD/skills/tiny-engineer-play" ~/.claude/skills/ # Claude Code