@defai.digital/cli 13.4.11 → 13.5.2
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/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +45 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +48 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/integrations/claude-code/claude-code-integration.d.ts +51 -0
- package/dist/integrations/claude-code/claude-code-integration.d.ts.map +1 -0
- package/dist/integrations/claude-code/claude-code-integration.js +120 -0
- package/dist/integrations/claude-code/claude-code-integration.js.map +1 -0
- package/dist/integrations/claude-code/hooks-generator.d.ts +33 -0
- package/dist/integrations/claude-code/hooks-generator.d.ts.map +1 -0
- package/dist/integrations/claude-code/hooks-generator.js +214 -0
- package/dist/integrations/claude-code/hooks-generator.js.map +1 -0
- package/dist/integrations/claude-code/index.d.ts +16 -0
- package/dist/integrations/claude-code/index.d.ts.map +1 -0
- package/dist/integrations/claude-code/index.js +12 -0
- package/dist/integrations/claude-code/index.js.map +1 -0
- package/dist/integrations/claude-code/mcp-project-config.d.ts +16 -0
- package/dist/integrations/claude-code/mcp-project-config.d.ts.map +1 -0
- package/dist/integrations/claude-code/mcp-project-config.js +55 -0
- package/dist/integrations/claude-code/mcp-project-config.js.map +1 -0
- package/dist/integrations/claude-code/settings-manager.d.ts +22 -0
- package/dist/integrations/claude-code/settings-manager.d.ts.map +1 -0
- package/dist/integrations/claude-code/settings-manager.js +75 -0
- package/dist/integrations/claude-code/settings-manager.js.map +1 -0
- package/dist/integrations/claude-code/subagent-generator.d.ts +47 -0
- package/dist/integrations/claude-code/subagent-generator.d.ts.map +1 -0
- package/dist/integrations/claude-code/subagent-generator.js +204 -0
- package/dist/integrations/claude-code/subagent-generator.js.map +1 -0
- package/dist/integrations/claude-code/types.d.ts +95 -0
- package/dist/integrations/claude-code/types.d.ts.map +1 -0
- package/dist/integrations/claude-code/types.js +8 -0
- package/dist/integrations/claude-code/types.js.map +1 -0
- package/dist/integrations/claude-code/utils/file-utils.d.ts +7 -0
- package/dist/integrations/claude-code/utils/file-utils.d.ts.map +1 -0
- package/dist/integrations/claude-code/utils/file-utils.js +22 -0
- package/dist/integrations/claude-code/utils/file-utils.js.map +1 -0
- package/package.json +21 -21
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code Hooks Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates hook scripts in .claude/hooks/ and writes hook configuration
|
|
5
|
+
* into .claude/settings.json via SettingsManager.
|
|
6
|
+
*
|
|
7
|
+
* Supported events: PreToolUse, PostToolUse, SessionStart, SessionEnd
|
|
8
|
+
* Scripts use `set -euo pipefail` and `jq -cn --arg` for safe JSON output.
|
|
9
|
+
*/
|
|
10
|
+
import { mkdir, writeFile, chmod } from 'node:fs/promises';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import { SettingsManager } from './settings-manager.js';
|
|
13
|
+
import { fileExists, writeJsonFile } from './utils/file-utils.js';
|
|
14
|
+
// ─── Default events ───────────────────────────────────────────────────────────
|
|
15
|
+
const DEFAULT_EVENTS = [
|
|
16
|
+
'PreToolUse',
|
|
17
|
+
'PostToolUse',
|
|
18
|
+
'SessionStart',
|
|
19
|
+
'SessionEnd',
|
|
20
|
+
];
|
|
21
|
+
// ─── Shared bash helper ───────────────────────────────────────────────────────
|
|
22
|
+
function sharedHelpers() {
|
|
23
|
+
return `
|
|
24
|
+
# Extract a field from JSON safely using jq (if available)
|
|
25
|
+
ax_jq_field() {
|
|
26
|
+
local field="\$1" default="\$2" input="\$3"
|
|
27
|
+
if command -v jq &>/dev/null; then
|
|
28
|
+
jq -re --arg d "\$default" "\$field // \\$d" <<< "\$input" 2>/dev/null || echo "\$default"
|
|
29
|
+
else
|
|
30
|
+
echo "\$default"
|
|
31
|
+
fi
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
// ─── Hook script templates ────────────────────────────────────────────────────
|
|
36
|
+
function preToolUseScript() {
|
|
37
|
+
return `#!/usr/bin/env bash
|
|
38
|
+
# AutomatosX PreToolUse hook
|
|
39
|
+
# Receives JSON on stdin: { tool_name, tool_input, session_id, cwd }
|
|
40
|
+
# Exit 0 = allow, Exit 2 = block (this script always allows)
|
|
41
|
+
set -euo pipefail
|
|
42
|
+
${sharedHelpers()}
|
|
43
|
+
TRACE_DIR="\${AUTOMATOSX_TRACE_DIR:-.automatosx/logs}"
|
|
44
|
+
mkdir -p "\$TRACE_DIR"
|
|
45
|
+
|
|
46
|
+
INPUT="\$(cat)"
|
|
47
|
+
TOOL="\$(ax_jq_field '.tool_name' 'unknown' "\$INPUT")"
|
|
48
|
+
SESSION="\$(ax_jq_field '.session_id' '' "\$INPUT")"
|
|
49
|
+
|
|
50
|
+
if command -v jq &>/dev/null; then
|
|
51
|
+
jq -cn --arg ts "\$(date -u +"%Y-%m-%dT%H:%M:%SZ")" --arg event "PreToolUse" --arg tool "\$TOOL" --arg session "\$SESSION" \
|
|
52
|
+
'{ts:\$ts,event:\$event,tool:\$tool,session:\$session}' >> "\$TRACE_DIR/hook-trace.jsonl" 2>/dev/null || true
|
|
53
|
+
else
|
|
54
|
+
printf '{"ts":"%s","event":"PreToolUse"}\n' "\$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "\$TRACE_DIR/hook-trace.jsonl" 2>/dev/null || true
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
exit 0
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
function postToolUseScript() {
|
|
61
|
+
return `#!/usr/bin/env bash
|
|
62
|
+
# AutomatosX PostToolUse hook
|
|
63
|
+
# Receives JSON on stdin: { tool_name, tool_input, tool_response, session_id, cwd }
|
|
64
|
+
# Exit 0 = success
|
|
65
|
+
set -euo pipefail
|
|
66
|
+
${sharedHelpers()}
|
|
67
|
+
TRACE_DIR="\${AUTOMATOSX_TRACE_DIR:-.automatosx/logs}"
|
|
68
|
+
mkdir -p "\$TRACE_DIR"
|
|
69
|
+
|
|
70
|
+
INPUT="\$(cat)"
|
|
71
|
+
TOOL="\$(ax_jq_field '.tool_name' 'unknown' "\$INPUT")"
|
|
72
|
+
SESSION="\$(ax_jq_field '.session_id' '' "\$INPUT")"
|
|
73
|
+
|
|
74
|
+
if command -v jq &>/dev/null; then
|
|
75
|
+
jq -cn --arg ts "\$(date -u +"%Y-%m-%dT%H:%M:%SZ")" --arg event "PostToolUse" --arg tool "\$TOOL" --arg session "\$SESSION" \
|
|
76
|
+
'{ts:\$ts,event:\$event,tool:\$tool,session:\$session}' >> "\$TRACE_DIR/hook-trace.jsonl" 2>/dev/null || true
|
|
77
|
+
else
|
|
78
|
+
printf '{"ts":"%s","event":"PostToolUse"}\n' "\$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "\$TRACE_DIR/hook-trace.jsonl" 2>/dev/null || true
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
exit 0
|
|
82
|
+
`;
|
|
83
|
+
}
|
|
84
|
+
function sessionStartScript() {
|
|
85
|
+
return `#!/usr/bin/env bash
|
|
86
|
+
# AutomatosX SessionStart hook
|
|
87
|
+
# Receives JSON on stdin: { session_id, cwd }
|
|
88
|
+
set -euo pipefail
|
|
89
|
+
${sharedHelpers()}
|
|
90
|
+
TRACE_DIR="\${AUTOMATOSX_TRACE_DIR:-.automatosx/logs}"
|
|
91
|
+
mkdir -p "\$TRACE_DIR"
|
|
92
|
+
|
|
93
|
+
INPUT="\$(cat)"
|
|
94
|
+
SESSION="\$(ax_jq_field '.session_id' '' "\$INPUT")"
|
|
95
|
+
CWD="\$(ax_jq_field '.cwd' '' "\$INPUT")"
|
|
96
|
+
|
|
97
|
+
if command -v jq &>/dev/null; then
|
|
98
|
+
jq -cn --arg ts "\$(date -u +"%Y-%m-%dT%H:%M:%SZ")" --arg event "SessionStart" --arg session "\$SESSION" --arg cwd "\$CWD" \
|
|
99
|
+
'{ts:\$ts,event:\$event,session:\$session,cwd:\$cwd}' >> "\$TRACE_DIR/hook-trace.jsonl" 2>/dev/null || true
|
|
100
|
+
else
|
|
101
|
+
printf '{"ts":"%s","event":"SessionStart"}\n' "\$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "\$TRACE_DIR/hook-trace.jsonl" 2>/dev/null || true
|
|
102
|
+
fi
|
|
103
|
+
|
|
104
|
+
exit 0
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
function sessionEndScript() {
|
|
108
|
+
return `#!/usr/bin/env bash
|
|
109
|
+
# AutomatosX SessionEnd hook
|
|
110
|
+
# Receives JSON on stdin: { session_id, cwd }
|
|
111
|
+
set -euo pipefail
|
|
112
|
+
${sharedHelpers()}
|
|
113
|
+
TRACE_DIR="\${AUTOMATOSX_TRACE_DIR:-.automatosx/logs}"
|
|
114
|
+
mkdir -p "\$TRACE_DIR"
|
|
115
|
+
|
|
116
|
+
INPUT="\$(cat)"
|
|
117
|
+
SESSION="\$(ax_jq_field '.session_id' '' "\$INPUT")"
|
|
118
|
+
|
|
119
|
+
if command -v jq &>/dev/null; then
|
|
120
|
+
jq -cn --arg ts "\$(date -u +"%Y-%m-%dT%H:%M:%SZ")" --arg event "SessionEnd" --arg session "\$SESSION" \
|
|
121
|
+
'{ts:\$ts,event:\$event,session:\$session}' >> "\$TRACE_DIR/hook-trace.jsonl" 2>/dev/null || true
|
|
122
|
+
else
|
|
123
|
+
printf '{"ts":"%s","event":"SessionEnd"}\n' "\$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "\$TRACE_DIR/hook-trace.jsonl" 2>/dev/null || true
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
exit 0
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
const HOOK_SCRIPTS = {
|
|
130
|
+
PreToolUse: { filename: 'pre-tool-use.sh', content: preToolUseScript },
|
|
131
|
+
PostToolUse: { filename: 'post-tool-use.sh', content: postToolUseScript },
|
|
132
|
+
PostToolUseFailure: { filename: 'post-tool-use.sh', content: postToolUseScript },
|
|
133
|
+
SessionStart: { filename: 'session-start.sh', content: sessionStartScript },
|
|
134
|
+
SessionEnd: { filename: 'session-end.sh', content: sessionEndScript },
|
|
135
|
+
SubagentStart: { filename: 'session-start.sh', content: sessionStartScript },
|
|
136
|
+
SubagentStop: { filename: 'session-end.sh', content: sessionEndScript },
|
|
137
|
+
};
|
|
138
|
+
export class HooksGenerator {
|
|
139
|
+
projectDir;
|
|
140
|
+
enabledEvents;
|
|
141
|
+
force;
|
|
142
|
+
constructor(options) {
|
|
143
|
+
this.projectDir = options.projectDir;
|
|
144
|
+
this.enabledEvents = options.enabledEvents ?? DEFAULT_EVENTS;
|
|
145
|
+
this.force = options.force ?? false;
|
|
146
|
+
}
|
|
147
|
+
async generate() {
|
|
148
|
+
const hooksDir = join(this.projectDir, '.claude', 'hooks');
|
|
149
|
+
await mkdir(hooksDir, { recursive: true });
|
|
150
|
+
const scriptsWritten = [];
|
|
151
|
+
const scriptsSkipped = [];
|
|
152
|
+
const seen = new Set();
|
|
153
|
+
for (const event of this.enabledEvents) {
|
|
154
|
+
const def = HOOK_SCRIPTS[event];
|
|
155
|
+
if (!def || seen.has(def.filename))
|
|
156
|
+
continue;
|
|
157
|
+
seen.add(def.filename);
|
|
158
|
+
const scriptPath = join(hooksDir, def.filename);
|
|
159
|
+
if ((await fileExists(scriptPath)) && !this.force) {
|
|
160
|
+
scriptsSkipped.push(def.filename);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
await writeFile(scriptPath, def.content(), { encoding: 'utf-8', flag: 'w' });
|
|
164
|
+
await chmod(scriptPath, 0o755);
|
|
165
|
+
scriptsWritten.push(def.filename);
|
|
166
|
+
}
|
|
167
|
+
const settingsUpdated = await this.writeHookConfig();
|
|
168
|
+
return { hooksDir, scriptsWritten, scriptsSkipped, settingsUpdated };
|
|
169
|
+
}
|
|
170
|
+
buildHooksConfig() {
|
|
171
|
+
const config = {};
|
|
172
|
+
for (const event of this.enabledEvents) {
|
|
173
|
+
const def = HOOK_SCRIPTS[event];
|
|
174
|
+
if (!def)
|
|
175
|
+
continue;
|
|
176
|
+
const scriptPath = `.claude/hooks/${def.filename}`;
|
|
177
|
+
const matcher = {
|
|
178
|
+
hooks: [{
|
|
179
|
+
type: 'command',
|
|
180
|
+
command: scriptPath,
|
|
181
|
+
timeout: event === 'SessionStart' || event === 'SessionEnd' ? 15 : 30,
|
|
182
|
+
}],
|
|
183
|
+
};
|
|
184
|
+
if (event === 'PreToolUse' || event === 'PostToolUse' || event === 'PostToolUseFailure') {
|
|
185
|
+
matcher.matcher = '.*';
|
|
186
|
+
}
|
|
187
|
+
config[event] = [matcher];
|
|
188
|
+
}
|
|
189
|
+
return config;
|
|
190
|
+
}
|
|
191
|
+
async writeHookConfig() {
|
|
192
|
+
const mgr = new SettingsManager(this.projectDir);
|
|
193
|
+
const settings = await mgr.read();
|
|
194
|
+
const hooksConfig = this.buildHooksConfig();
|
|
195
|
+
const existing = settings.hooks ?? {};
|
|
196
|
+
settings.hooks = { ...existing, ...hooksConfig };
|
|
197
|
+
await writeJsonFile(mgr.getSettingsPath(), settings);
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
async areHooksGenerated() {
|
|
201
|
+
const hooksDir = join(this.projectDir, '.claude', 'hooks');
|
|
202
|
+
const seen = new Set();
|
|
203
|
+
for (const event of this.enabledEvents) {
|
|
204
|
+
const def = HOOK_SCRIPTS[event];
|
|
205
|
+
if (!def || seen.has(def.filename))
|
|
206
|
+
continue;
|
|
207
|
+
seen.add(def.filename);
|
|
208
|
+
if (!(await fileExists(join(hooksDir, def.filename))))
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=hooks-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks-generator.js","sourceRo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2
|
+
* Claude Code Integration
|
|
3
|
+
*
|
|
4
|
+
* Bidirectional integration between AutomatosX and Claude Code 2026:
|
|
5
|
+
* settings.json management, hooks, .mcp.json, per-agent subagent files.
|
|
6
|
+
*/
|
|
7
|
+
export { ClaudeCodeIntegration } from './claude-code-integration.js';
|
|
8
|
+
export { SettingsManager } from './settings-manager.js';
|
|
9
|
+
export { McpProjectConfigGenerator } from './mcp-project-config.js';
|
|
10
|
+
export { HooksGenerator } from './hooks-generator.js';
|
|
11
|
+
export { SubagentGenerator } from './subagent-generator.js';
|
|
12
|
+
export type { ClaudeCodeSetupOptions, ClaudeCodeSetupResult, } from './claude-code-integration.js';
|
|
13
|
+
export type { HooksGeneratorOptions, HooksGenerateResult } from './hooks-generator.js';
|
|
14
|
+
export type { SubagentGeneratorOptions, SubagentGenerateResult } from './subagent-generator.js';
|
|
15
|
+
export type { ClaudeCodeDiagnostics, ClaudeCodeSettings, HookEvent, HookType, HooksConfig, HookMatcher, HookEntry, McpTransport, ClaudeMCPServer, MCPManifest, ValidationResult, SubagentFrontmatter, SubagentPermissionMode, SubagentMemoryScope, SubagentEffort, AgentClaudeCodeConfig, } from './types.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/claude-code/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,YAAY,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACvF,YAAY,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEhG,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,EACZ,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,cAAc,EACd,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code Integration
|
|
3
|
+
*
|
|
4
|
+
* Bidirectional integration between AutomatosX and Claude Code 2026:
|
|
5
|
+
* settings.json management, hooks, .mcp.json, per-agent subagent files.
|
|
6
|
+
*/
|
|
7
|
+
export { ClaudeCodeIntegration } from './claude-code-integration.js';
|
|
8
|
+
export { SettingsManager } from './settings-manager.js';
|
|
9
|
+
export { McpProjectConfigGenerator } from './mcp-project-config.js';
|
|
10
|
+
export { HooksGenerator } from './hooks-generator.js';
|
|
11
|
+
export { SubagentGenerator } from './subagent-generator.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integrations/claude-code/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .mcp.json Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates the team-shared .mcp.json at the project root.
|
|
5
|
+
* This file is committable and tells Claude Code how to reach the
|
|
6
|
+
* AutomatosX MCP server without per-user registration.
|
|
7
|
+
*/
|
|
8
|
+
export declare class McpProjectConfigGenerator {
|
|
9
|
+
private mcpJsonPath;
|
|
10
|
+
constructor(projectDir: string);
|
|
11
|
+
/** Generate or merge .mcp.json. Never removes existing mcpServers entries. */
|
|
12
|
+
generate(): Promise<void>;
|
|
13
|
+
/** Returns true if the automatosx key is present in .mcp.json */
|
|
14
|
+
isGenerated(): Promise<boolean>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=mcp-project-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-project-config.d.ts","sourceRoot":"","sources":["../../../src/integrations/claude-code/mcp-project-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,WAAW,CAAS;gBAEhB,UAAU,EAAE,MAAM;IAI9B,8EAA8E;IACxE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IA6B/B,iEAAiE;IAC3D,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAStC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .mcp.json Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates the team-shared .mcp.json at the project root.
|
|
5
|
+
* This file is committable and tells Claude Code how to reach the
|
|
6
|
+
* AutomatosX MCP server without per-user registration.
|
|
7
|
+
*/
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { fileExists, readJsonFile, writeJsonFile } from './utils/file-utils.js';
|
|
10
|
+
const AUTOMATOSX_SERVER_NAME = 'automatosx';
|
|
11
|
+
export class McpProjectConfigGenerator {
|
|
12
|
+
mcpJsonPath;
|
|
13
|
+
constructor(projectDir) {
|
|
14
|
+
this.mcpJsonPath = join(projectDir, '.mcp.json');
|
|
15
|
+
}
|
|
16
|
+
/** Generate or merge .mcp.json. Never removes existing mcpServers entries. */
|
|
17
|
+
async generate() {
|
|
18
|
+
let existing = {};
|
|
19
|
+
if (await fileExists(this.mcpJsonPath)) {
|
|
20
|
+
try {
|
|
21
|
+
existing = await readJsonFile(this.mcpJsonPath);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
existing = {};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const mcpServers = existing.mcpServers ?? {};
|
|
28
|
+
// Only add if not already present
|
|
29
|
+
if (!mcpServers[AUTOMATOSX_SERVER_NAME]) {
|
|
30
|
+
mcpServers[AUTOMATOSX_SERVER_NAME] = {
|
|
31
|
+
type: 'stdio',
|
|
32
|
+
command: 'ax',
|
|
33
|
+
args: ['mcp', 'server'],
|
|
34
|
+
env: { AUTOMATOSX_LOG_LEVEL: 'warn' },
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
await writeJsonFile(this.mcpJsonPath, {
|
|
38
|
+
...existing,
|
|
39
|
+
mcpServers,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/** Returns true if the automatosx key is present in .mcp.json */
|
|
43
|
+
async isGenerated() {
|
|
44
|
+
if (!(await fileExists(this.mcpJsonPath)))
|
|
45
|
+
return false;
|
|
46
|
+
try {
|
|
47
|
+
const config = await readJsonFile(this.mcpJsonPath);
|
|
48
|
+
return !!config.mcpServers?.[AUTOMATOSX_SERVER_NAME];
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=mcp-project-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-project-config.js","sourceRoot":"","sources":["../../../src/integrations/claude-code/mcp-project-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAA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c,IAAI,CAAC,WAAW,CAAC,CAAC;YACjE,OAAO,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,sBAAsB,CAAC,CAAC;QACvD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code Settings Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages .claude/settings.json — the project-shared settings file.
|
|
5
|
+
* Uses a safe merge strategy: adds missing entries, never removes existing ones.
|
|
6
|
+
*/
|
|
7
|
+
import type { ClaudeCodeSettings } from './types.js';
|
|
8
|
+
export declare class SettingsManager {
|
|
9
|
+
private claudeDir;
|
|
10
|
+
private settingsPath;
|
|
11
|
+
constructor(projectDir: string);
|
|
12
|
+
getSettingsPath(): string;
|
|
13
|
+
read(): Promise<ClaudeCodeSettings>;
|
|
14
|
+
/**
|
|
15
|
+
* Merge MCP permissions into settings.json.
|
|
16
|
+
* Never removes existing entries — only adds missing ones.
|
|
17
|
+
*/
|
|
18
|
+
writeMcpPermissions(): Promise<void>;
|
|
19
|
+
/** Returns true if all 16 AutomatosX permissions are present */
|
|
20
|
+
hasAutomatosXPermissions(): Promise<boolean>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=settings-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-manager.d.ts","sourceRoot":"","sources":["../../../src/integrations/claude-code/settings-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAuBrD,qBAAa,eAAe;IAC1B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAAS;gBAEjB,UAAU,EAAE,MAAM;IAK9B,eAAe,IAAI,MAAM;IAInB,IAAI,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAWzC;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB1C,gEAAgE;IAC1D,wBAAwB,IAAI,OAAO,CAAC,OAAO,CAAC;CAKnD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code Settings Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages .claude/settings.json — the project-shared settings file.
|
|
5
|
+
* Uses a safe merge strategy: adds missing entries, never removes existing ones.
|
|
6
|
+
*/
|
|
7
|
+
import { mkdir } from 'node:fs/promises';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { fileExists, readJsonFile, writeJsonFile } from './utils/file-utils.js';
|
|
10
|
+
/** MCP tool permissions AutomatosX needs */
|
|
11
|
+
const AUTOMATOSX_MCP_PERMISSIONS = [
|
|
12
|
+
'mcp__automatosx__run_agent',
|
|
13
|
+
'mcp__automatosx__list_agents',
|
|
14
|
+
'mcp__automatosx__search_memory',
|
|
15
|
+
'mcp__automatosx__save_memory',
|
|
16
|
+
'mcp__automatosx__session_create',
|
|
17
|
+
'mcp__automatosx__session_list',
|
|
18
|
+
'mcp__automatosx__session_status',
|
|
19
|
+
'mcp__automatosx__session_close',
|
|
20
|
+
'mcp__automatosx__get_context',
|
|
21
|
+
'mcp__automatosx__update_context',
|
|
22
|
+
'mcp__automatosx__list_workflows',
|
|
23
|
+
'mcp__automatosx__run_workflow',
|
|
24
|
+
'mcp__automatosx__get_trace',
|
|
25
|
+
'mcp__automatosx__list_traces',
|
|
26
|
+
'mcp__automatosx__get_provider_status',
|
|
27
|
+
'mcp__automatosx__health_check',
|
|
28
|
+
];
|
|
29
|
+
export class SettingsManager {
|
|
30
|
+
claudeDir;
|
|
31
|
+
settingsPath;
|
|
32
|
+
constructor(projectDir) {
|
|
33
|
+
this.claudeDir = join(projectDir, '.claude');
|
|
34
|
+
this.settingsPath = join(this.claudeDir, 'settings.json');
|
|
35
|
+
}
|
|
36
|
+
getSettingsPath() {
|
|
37
|
+
return this.settingsPath;
|
|
38
|
+
}
|
|
39
|
+
async read() {
|
|
40
|
+
if (!(await fileExists(this.settingsPath))) {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
return await readJsonFile(this.settingsPath);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Merge MCP permissions into settings.json.
|
|
52
|
+
* Never removes existing entries — only adds missing ones.
|
|
53
|
+
*/
|
|
54
|
+
async writeMcpPermissions() {
|
|
55
|
+
await mkdir(this.claudeDir, { recursive: true });
|
|
56
|
+
const settings = await this.read();
|
|
57
|
+
if (!settings.permissions)
|
|
58
|
+
settings.permissions = {};
|
|
59
|
+
if (!settings.permissions.allow)
|
|
60
|
+
settings.permissions.allow = [];
|
|
61
|
+
const existing = new Set(settings.permissions.allow);
|
|
62
|
+
for (const perm of AUTOMATOSX_MCP_PERMISSIONS) {
|
|
63
|
+
existing.add(perm);
|
|
64
|
+
}
|
|
65
|
+
settings.permissions.allow = Array.from(existing);
|
|
66
|
+
await writeJsonFile(this.settingsPath, settings);
|
|
67
|
+
}
|
|
68
|
+
/** Returns true if all 16 AutomatosX permissions are present */
|
|
69
|
+
async hasAutomatosXPermissions() {
|
|
70
|
+
const settings = await this.read();
|
|
71
|
+
const allowed = new Set(settings.permissions?.allow ?? []);
|
|
72
|
+
return AUTOMATOSX_MCP_PERMISSIONS.every(p => allowed.has(p));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=settings-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-manager.js","sourceRoot":"","sources":["../../../src/integrations/claude-code/settings-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC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AW,GAAG,EAAE,CAAC;QACrD,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK;YAAE,QAAQ,CAAC,WAAW,CAAC,KAAK,GAAG,EAAE,CAAC;QAEjE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACrD,KAAK,MAAM,IAAI,IAAI,0BAA0B,EAAE,CAAC;YAC9C,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;QACD,QAAQ,CAAC,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAElD,MAAM,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACnD,CAAC;IAED,gEAAgE;IAChE,KAAK,CAAC,wBAAwB;QAC5B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QAC3D,OAAO,0BAA0B,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC;CACF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code Subagent File Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates .claude/agents/<name>.md files with Claude Code 2026 YAML
|
|
5
|
+
* frontmatter for each agent, plus the automatosx-coordinator.md.
|
|
6
|
+
*
|
|
7
|
+
* These files enable Claude Code to invoke AutomatosX agents as
|
|
8
|
+
* native subagents with appropriate permissions and MCP access.
|
|
9
|
+
*/
|
|
10
|
+
import type { AgentClaudeCodeConfig } from './types.js';
|
|
11
|
+
/** Minimal agent shape we need from agent-domain */
|
|
12
|
+
interface AgentLike {
|
|
13
|
+
name: string;
|
|
14
|
+
displayName?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
role?: string;
|
|
17
|
+
systemPrompt?: string;
|
|
18
|
+
claude_code?: AgentClaudeCodeConfig;
|
|
19
|
+
}
|
|
20
|
+
export interface SubagentGenerateResult {
|
|
21
|
+
agentsDir: string;
|
|
22
|
+
filesWritten: string[];
|
|
23
|
+
filesSkipped: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface SubagentGeneratorOptions {
|
|
26
|
+
projectDir: string;
|
|
27
|
+
force?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare class SubagentGenerator {
|
|
30
|
+
private projectDir;
|
|
31
|
+
private force;
|
|
32
|
+
constructor(options: SubagentGeneratorOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Generate per-agent subagent files plus the coordinator.
|
|
35
|
+
* Can be called independently (e.g. via `ax init --claude-agents-only`).
|
|
36
|
+
*/
|
|
37
|
+
generate(agents: AgentLike[]): Promise<SubagentGenerateResult>;
|
|
38
|
+
/** Returns true if coordinator file exists */
|
|
39
|
+
areSubagentFilesGenerated(): Promise<boolean>;
|
|
40
|
+
private buildFrontmatter;
|
|
41
|
+
private renderFrontmatter;
|
|
42
|
+
private buildAgentFile;
|
|
43
|
+
private buildCoordinatorFile;
|
|
44
|
+
private getDescription;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=subagent-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent-generator.d.ts","sourceRoot":"","sources":["../../../src/integrations/claude-code/subagent-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAuB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAG7E,oDAAoD;AACpD,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACrC;AAID,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,KAAK,CAAU;gBAEX,OAAO,EAAE,wBAAwB;IAK7C;;;OAGG;IACG,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAmCpE,8CAA8C;IACxC,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC;IAOnD,OAAO,CAAC,gBAAgB;IAmBxB,OAAO,CAAC,iBAAiB;IA0BzB,OAAO,CAAC,cAAc;IA+BtB,OAAO,CAAC,oBAAoB;IAkD5B,OAAO,CAAC,cAAc;CASvB"}
|