@agenticmail/claudecode 0.1.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.
@@ -0,0 +1,8 @@
1
+ import {
2
+ uninstall
3
+ } from "./chunk-ULKJ773Y.js";
4
+ import "./chunk-US5FT2UB.js";
5
+ import "./chunk-XAW5NUNU.js";
6
+ export {
7
+ uninstall
8
+ };
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "@agenticmail/claudecode",
3
+ "version": "0.1.0",
4
+ "description": "Claude Code integration for AgenticMail — surfaces every AgenticMail agent as a native Claude Code subagent so any Claude Code session can delegate to them with the Agent tool",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "agenticmail-claudecode": "dist/cli.js",
10
+ "agenticmail-claudecode-dispatcher": "dist/dispatcher-bin.js"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ },
17
+ "./install": {
18
+ "import": "./dist/install.js",
19
+ "types": "./dist/install.d.ts"
20
+ },
21
+ "./uninstall": {
22
+ "import": "./dist/uninstall.js",
23
+ "types": "./dist/uninstall.d.ts"
24
+ },
25
+ "./status": {
26
+ "import": "./dist/status.js",
27
+ "types": "./dist/status.d.ts"
28
+ },
29
+ "./http-routes": {
30
+ "import": "./dist/http-routes.js",
31
+ "types": "./dist/http-routes.d.ts"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "claudecode.plugin.json",
37
+ "scripts",
38
+ "README.md",
39
+ "REFERENCE.md",
40
+ "LICENSE"
41
+ ],
42
+ "scripts": {
43
+ "build": "tsup src/index.ts src/cli.ts src/install.ts src/uninstall.ts src/status.ts src/http-routes.ts src/dispatcher.ts src/dispatcher-bin.ts --format esm --dts --clean",
44
+ "test": "vitest run --passWithNoTests",
45
+ "preuninstall": "node scripts/uninstall.mjs",
46
+ "prepublishOnly": "npm run build"
47
+ },
48
+ "dependencies": {
49
+ "@agenticmail/mcp": "^0.6.0",
50
+ "@anthropic-ai/claude-agent-sdk": "^0.2.140"
51
+ },
52
+ "peerDependencies": {
53
+ "express": "^4.17.0 || ^5.0.0"
54
+ },
55
+ "peerDependenciesMeta": {
56
+ "express": {
57
+ "optional": true
58
+ }
59
+ },
60
+ "devDependencies": {
61
+ "@types/express": "^5.0.0",
62
+ "@types/supertest": "^6.0.0",
63
+ "express": "^5.0.0",
64
+ "supertest": "^7.0.0",
65
+ "tsup": "^8.4.0",
66
+ "typescript": "^5.7.0",
67
+ "vitest": "^3.0.0"
68
+ },
69
+ "engines": {
70
+ "node": ">=20"
71
+ },
72
+ "repository": {
73
+ "type": "git",
74
+ "url": "https://github.com/agenticmail/agenticmail.git",
75
+ "directory": "packages/claudecode"
76
+ },
77
+ "homepage": "https://github.com/agenticmail/agenticmail",
78
+ "bugs": "https://github.com/agenticmail/agenticmail/issues",
79
+ "keywords": [
80
+ "claude",
81
+ "claude-code",
82
+ "anthropic",
83
+ "mcp",
84
+ "model-context-protocol",
85
+ "subagent",
86
+ "agent",
87
+ "ai-agent",
88
+ "email",
89
+ "sms",
90
+ "agenticmail"
91
+ ],
92
+ "publishConfig": {
93
+ "access": "public"
94
+ },
95
+ "author": "Ope Olatunji",
96
+ "license": "MIT"
97
+ }
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * npm preuninstall hook.
5
+ *
6
+ * Runs automatically when the user does:
7
+ * npm uninstall -g @agenticmail/claudecode
8
+ *
9
+ * Removes:
10
+ * - the mcpServers.agenticmail block from ~/.claude.json (if present)
11
+ * - every Claude Code subagent .md file we wrote (frontmatter marker:
12
+ * "@agenticmail/claudecode") in ~/.claude/agents/
13
+ *
14
+ * Deliberately does NOT:
15
+ * - delete the bridge agent inside AgenticMail (destructive — preserve it
16
+ * so the user's inbox isn't lost)
17
+ * - touch anything in ~/.claude.json other than the single mcpServers key
18
+ *
19
+ * Implemented in pure-node JS (no TS, no dist/ dependency) so this works
20
+ * even when the package's build output is missing — npm sometimes runs
21
+ * preuninstall *after* dist/ has been removed.
22
+ */
23
+
24
+ import { existsSync, readFileSync, writeFileSync, readdirSync, unlinkSync, renameSync } from 'node:fs';
25
+ import { join } from 'node:path';
26
+ import { homedir } from 'node:os';
27
+
28
+ const MCP_SERVER_NAME = process.env.AGENTICMAIL_MCP_SERVER_NAME ?? 'agenticmail';
29
+ const CLAUDE_CONFIG = process.env.CLAUDE_CODE_CONFIG_PATH ?? join(homedir(), '.claude.json');
30
+ const AGENTS_DIR = process.env.CLAUDE_CODE_AGENTS_DIR ?? join(homedir(), '.claude', 'agents');
31
+ const SUBAGENT_PREFIX = 'agenticmail-';
32
+ const MARKER = '@agenticmail/claudecode';
33
+
34
+ function atomicWrite(path, text) {
35
+ const tmp = `${path}.agenticmail-tmp`;
36
+ writeFileSync(tmp, text, 'utf-8');
37
+ renameSync(tmp, path);
38
+ }
39
+
40
+ let touched = false;
41
+
42
+ // 1. Remove the MCP server block.
43
+ if (existsSync(CLAUDE_CONFIG)) {
44
+ try {
45
+ const raw = readFileSync(CLAUDE_CONFIG, 'utf-8');
46
+ const parsed = JSON.parse(raw);
47
+ if (parsed?.mcpServers && Object.prototype.hasOwnProperty.call(parsed.mcpServers, MCP_SERVER_NAME)) {
48
+ delete parsed.mcpServers[MCP_SERVER_NAME];
49
+ atomicWrite(CLAUDE_CONFIG, JSON.stringify(parsed, null, 2) + '\n');
50
+ console.log(`[agenticmail] Removed mcpServers.${MCP_SERVER_NAME} from ${CLAUDE_CONFIG}`);
51
+ touched = true;
52
+ }
53
+ } catch (err) {
54
+ console.warn(`[agenticmail] Could not patch ${CLAUDE_CONFIG}: ${err.message}`);
55
+ }
56
+ }
57
+
58
+ // 2. Remove owned subagent .md files.
59
+ if (existsSync(AGENTS_DIR)) {
60
+ for (const file of readdirSync(AGENTS_DIR)) {
61
+ if (!file.startsWith(SUBAGENT_PREFIX) || !file.endsWith('.md')) continue;
62
+ const full = join(AGENTS_DIR, file);
63
+ let head;
64
+ try { head = readFileSync(full, 'utf-8').slice(0, 1024); } catch { continue; }
65
+ if (!head.includes(MARKER)) continue;
66
+ try {
67
+ unlinkSync(full);
68
+ console.log(`[agenticmail] Removed ${full}`);
69
+ touched = true;
70
+ } catch (err) {
71
+ console.warn(`[agenticmail] Could not remove ${full}: ${err.message}`);
72
+ }
73
+ }
74
+ }
75
+
76
+ if (!touched) {
77
+ // Silent success — nothing was registered, nothing to do.
78
+ }