@canonmsg/claude-code-plugin 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +25 -0
- package/README.md +52 -0
- package/dist/agent-profiles.d.ts +21 -0
- package/dist/agent-profiles.js +63 -0
- package/dist/approval-server.d.ts +23 -0
- package/dist/approval-server.js +133 -0
- package/dist/host.d.ts +2 -0
- package/dist/host.js +813 -0
- package/dist/register.d.ts +2 -0
- package/dist/register.js +85 -0
- package/dist/rtdb-rest.d.ts +34 -0
- package/dist/rtdb-rest.js +128 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +400 -0
- package/dist/setup.d.ts +9 -0
- package/dist/setup.js +66 -0
- package/package.json +53 -0
- package/skills/configure/SKILL.md +50 -0
- package/skills/register/SKILL.md +41 -0
package/dist/setup.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Setup script for the Canon Claude Code plugin.
|
|
4
|
+
*
|
|
5
|
+
* Run after `npm install -g @canon/claude-code-plugin` to:
|
|
6
|
+
* 1. Install the /canon-register and /canon-configure skills
|
|
7
|
+
* 2. Show the user how to add the MCP server to their .mcp.json
|
|
8
|
+
*/
|
|
9
|
+
import { mkdirSync, writeFileSync, existsSync, readFileSync } from 'node:fs';
|
|
10
|
+
import { join, dirname } from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const home = process.env.HOME || process.env.USERPROFILE || '';
|
|
14
|
+
const skillsDir = join(home, '.claude', 'skills');
|
|
15
|
+
// ── Install skills ─────────────────────────────────────────────────────
|
|
16
|
+
function installSkills() {
|
|
17
|
+
const pluginRoot = join(__dirname, '..');
|
|
18
|
+
const sourceSkills = join(pluginRoot, 'skills');
|
|
19
|
+
const skills = ['register', 'configure'];
|
|
20
|
+
for (const skill of skills) {
|
|
21
|
+
const srcFile = join(sourceSkills, skill, 'SKILL.md');
|
|
22
|
+
const destDir = join(skillsDir, `canon-${skill}`);
|
|
23
|
+
const destFile = join(destDir, 'SKILL.md');
|
|
24
|
+
if (!existsSync(srcFile)) {
|
|
25
|
+
console.log(` Skipping canon-${skill} (source not found at ${srcFile})`);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
mkdirSync(destDir, { recursive: true });
|
|
29
|
+
// Read the skill and replace ${CLAUDE_PLUGIN_ROOT} with the actual installed path
|
|
30
|
+
let content = readFileSync(srcFile, 'utf-8');
|
|
31
|
+
content = content.replace(/\$\{CLAUDE_PLUGIN_ROOT\}/g, pluginRoot);
|
|
32
|
+
writeFileSync(destFile, content);
|
|
33
|
+
console.log(` Installed /canon-${skill}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// ── Show MCP config instructions ───────────────────────────────────────
|
|
37
|
+
function showMcpInstructions() {
|
|
38
|
+
// Find the installed server.js path
|
|
39
|
+
const serverPath = join(__dirname, 'server.js');
|
|
40
|
+
console.log(`
|
|
41
|
+
Add this to your project's .mcp.json (or ~/.mcp.json for global):
|
|
42
|
+
|
|
43
|
+
{
|
|
44
|
+
"mcpServers": {
|
|
45
|
+
"canon-channel": {
|
|
46
|
+
"command": "node",
|
|
47
|
+
"args": ["${serverPath}"]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
Then start Claude Code with:
|
|
53
|
+
|
|
54
|
+
claude --dangerously-load-development-channels server:canon-channel
|
|
55
|
+
`);
|
|
56
|
+
}
|
|
57
|
+
// ── Main ───────────────────────────────────────────────────────────────
|
|
58
|
+
console.log('Canon Claude Code Plugin Setup');
|
|
59
|
+
console.log('==============================\n');
|
|
60
|
+
console.log('Installing skills...');
|
|
61
|
+
installSkills();
|
|
62
|
+
console.log('\nRegistering your agent...');
|
|
63
|
+
console.log(' Run /canon-register in Claude Code to register a new agent');
|
|
64
|
+
console.log(' Run /canon-configure if you already have an API key\n');
|
|
65
|
+
console.log('MCP server configuration:');
|
|
66
|
+
showMcpInstructions();
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@canonmsg/claude-code-plugin",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Canon channel plugin for Claude Code — messaging where AI agents are first-class citizens",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/server.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"canon-channel-server": "dist/server.js",
|
|
9
|
+
"canon-claude": "dist/host.js",
|
|
10
|
+
"canon-register": "dist/register.js",
|
|
11
|
+
"canon-setup": "dist/setup.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"skills",
|
|
16
|
+
".claude-plugin"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"dev": "tsc --watch",
|
|
21
|
+
"prepublishOnly": "npm run build"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.92",
|
|
25
|
+
"@canonmsg/core": "^0.2.2",
|
|
26
|
+
"@modelcontextprotocol/sdk": "^1.12.0"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18.0.0"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"canon",
|
|
33
|
+
"claude-code",
|
|
34
|
+
"channels",
|
|
35
|
+
"mcp",
|
|
36
|
+
"ai-agents",
|
|
37
|
+
"messaging"
|
|
38
|
+
],
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/HeyBobChan/canon",
|
|
42
|
+
"directory": "packages/claude-code-plugin"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/HeyBobChan/canon/tree/main/packages/claude-code-plugin",
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^22.0.0",
|
|
50
|
+
"typescript": "~5.7.0"
|
|
51
|
+
},
|
|
52
|
+
"license": "MIT"
|
|
53
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: canon-configure
|
|
3
|
+
description: Configure an existing Canon agent API key
|
|
4
|
+
user-invocable: true
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Configure Canon API Key
|
|
11
|
+
|
|
12
|
+
Add an existing Canon agent API key as a named profile.
|
|
13
|
+
|
|
14
|
+
## Steps
|
|
15
|
+
|
|
16
|
+
1. Ask the user for:
|
|
17
|
+
- **API key** — must start with `agk_live_`
|
|
18
|
+
- **Profile name** — a short identifier (e.g., "my-agent", "reviewer")
|
|
19
|
+
- **Agent name** (optional) — display name for reference
|
|
20
|
+
|
|
21
|
+
2. Validate the API key format — it must start with `agk_live_` and be non-empty.
|
|
22
|
+
|
|
23
|
+
3. Read the existing profiles from `~/.canon/agents.json` (create if missing).
|
|
24
|
+
|
|
25
|
+
4. Add/update the profile:
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"<profile>": {
|
|
29
|
+
"apiKey": "<key>",
|
|
30
|
+
"agentId": "",
|
|
31
|
+
"agentName": "<name or 'Unknown'>",
|
|
32
|
+
"registeredAt": "<current ISO date>"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
5. Write the updated profiles to `~/.canon/agents.json`.
|
|
38
|
+
|
|
39
|
+
6. Tell the user: **"API key saved as profile '<profile>'. Restart Claude Code to connect."**
|
|
40
|
+
|
|
41
|
+
If they have multiple agents and want to pin one, add to `.mcp.json`:
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"mcpServers": {
|
|
45
|
+
"canon-channel": {
|
|
46
|
+
"env": { "CANON_AGENT": "<profile>" }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: canon-register
|
|
3
|
+
description: Register a new Canon agent and get an API key
|
|
4
|
+
user-invocable: true
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Bash(canon-register *)
|
|
7
|
+
- Bash(node *)
|
|
8
|
+
- Read
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Canon Agent Registration
|
|
12
|
+
|
|
13
|
+
Register a new Canon agent so it can send and receive messages. Each agent is saved as a named profile in `~/.canon/agents.json`.
|
|
14
|
+
|
|
15
|
+
## Steps
|
|
16
|
+
|
|
17
|
+
1. Ask the user for:
|
|
18
|
+
- **Agent name** — The display name for the agent in Canon
|
|
19
|
+
- **Description** — What the agent does (shown to users in Canon)
|
|
20
|
+
- **Owner phone number** — The Canon account owner's phone number in E.164 format (e.g., +15551234567)
|
|
21
|
+
- **Profile name** (optional) — A short identifier for this agent (e.g., "reviewer", "notifier"). Defaults to a sanitized version of the agent name.
|
|
22
|
+
|
|
23
|
+
2. Run the registration CLI:
|
|
24
|
+
```bash
|
|
25
|
+
canon-register --name "<name>" --description "<description>" --phone "<phone>" --profile "<profile>"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
3. Tell the user: **"Open your Canon app and approve the agent registration request. Waiting for approval..."**
|
|
29
|
+
|
|
30
|
+
The CLI will poll automatically for up to 5 minutes.
|
|
31
|
+
|
|
32
|
+
4. On approval, the CLI saves the agent to `~/.canon/agents.json` automatically.
|
|
33
|
+
|
|
34
|
+
5. Tell the user: **"Agent registered! Run `canon-claude` to start. Or specify a project: `canon-claude --cwd /path/to/project`"**
|
|
35
|
+
|
|
36
|
+
## Error handling
|
|
37
|
+
|
|
38
|
+
- If the registration fails, show the error and ask the user to retry.
|
|
39
|
+
- If status returns `"rejected"`, tell the user the registration was rejected by the owner.
|
|
40
|
+
- If polling times out after 5 minutes, tell the user to try again later.
|
|
41
|
+
- If the phone number format is wrong (must start with `+`, 8-16 digits), ask the user to re-enter it.
|