@agenthead/cli 0.0.0-stage → 0.2.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/LICENSE +201 -0
- package/README.md +12 -2
- package/THIRD_PARTY_NOTICES.md +471 -0
- package/bin/agenthead.js +5 -0
- package/dist/agents-command.d.ts +2 -0
- package/dist/agents-command.js +12 -0
- package/dist/agents-command.js.map +1 -0
- package/dist/claude-code-skill.d.ts +6 -0
- package/dist/claude-code-skill.js +88 -0
- package/dist/claude-code-skill.js.map +1 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +199 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands.d.ts +9 -0
- package/dist/commands.js +298 -0
- package/dist/commands.js.map +1 -0
- package/dist/context.d.ts +48 -0
- package/dist/context.js +37 -0
- package/dist/context.js.map +1 -0
- package/dist/doctor-command.d.ts +66 -0
- package/dist/doctor-command.js +323 -0
- package/dist/doctor-command.js.map +1 -0
- package/dist/doctor-probes.d.ts +44 -0
- package/dist/doctor-probes.js +176 -0
- package/dist/doctor-probes.js.map +1 -0
- package/dist/doctor-process.d.ts +7 -0
- package/dist/doctor-process.js +149 -0
- package/dist/doctor-process.js.map +1 -0
- package/dist/graph-command.d.ts +4 -0
- package/dist/graph-command.js +88 -0
- package/dist/graph-command.js.map +1 -0
- package/dist/hook-command.d.ts +2 -0
- package/dist/hook-command.js +256 -0
- package/dist/hook-command.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/ledger-command.d.ts +2 -0
- package/dist/ledger-command.js +269 -0
- package/dist/ledger-command.js.map +1 -0
- package/dist/ledger.d.ts +19 -0
- package/dist/ledger.js +47 -0
- package/dist/ledger.js.map +1 -0
- package/dist/memory-command.d.ts +4 -0
- package/dist/memory-command.js +231 -0
- package/dist/memory-command.js.map +1 -0
- package/dist/pack-adapter.d.ts +14 -0
- package/dist/pack-adapter.js +39 -0
- package/dist/pack-adapter.js.map +1 -0
- package/dist/parallel-command.d.ts +2 -0
- package/dist/parallel-command.js +129 -0
- package/dist/parallel-command.js.map +1 -0
- package/dist/route-command.d.ts +2 -0
- package/dist/route-command.js +54 -0
- package/dist/route-command.js.map +1 -0
- package/dist/run-command.d.ts +6 -0
- package/dist/run-command.js +91 -0
- package/dist/run-command.js.map +1 -0
- package/dist/security-command.d.ts +2 -0
- package/dist/security-command.js +203 -0
- package/dist/security-command.js.map +1 -0
- package/dist/security-confirmation.d.ts +2 -0
- package/dist/security-confirmation.js +53 -0
- package/dist/security-confirmation.js.map +1 -0
- package/dist/setup-auto-command.d.ts +6 -0
- package/dist/setup-auto-command.js +113 -0
- package/dist/setup-auto-command.js.map +1 -0
- package/dist/setup-command.d.ts +25 -0
- package/dist/setup-command.js +398 -0
- package/dist/setup-command.js.map +1 -0
- package/dist/setup-guidance-hashes.d.ts +6 -0
- package/dist/setup-guidance-hashes.js +45 -0
- package/dist/setup-guidance-hashes.js.map +1 -0
- package/dist/setup-instructions.d.ts +5 -0
- package/dist/setup-instructions.js +76 -0
- package/dist/setup-instructions.js.map +1 -0
- package/dist/setup-toml.d.ts +4 -0
- package/dist/setup-toml.js +302 -0
- package/dist/setup-toml.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +55 -4
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AgentStatus } from "@agenthead/conductor";
|
|
2
|
+
import { type Context } from "./context.js";
|
|
3
|
+
import { type DoctorProbes } from "./doctor-probes.js";
|
|
4
|
+
import type { McpLaunch } from "./doctor-process.js";
|
|
5
|
+
export type CheckStatus = "ok" | "warn" | "fail" | "skip";
|
|
6
|
+
export interface DoctorCheck {
|
|
7
|
+
id: string;
|
|
8
|
+
status: CheckStatus;
|
|
9
|
+
message: string;
|
|
10
|
+
fix: string;
|
|
11
|
+
fixable: boolean;
|
|
12
|
+
details: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface DoctorSnapshot {
|
|
15
|
+
projectRoot: string | null;
|
|
16
|
+
checks: DoctorCheck[];
|
|
17
|
+
summary: Record<CheckStatus, number>;
|
|
18
|
+
exitCode: 0 | 1 | 2;
|
|
19
|
+
}
|
|
20
|
+
export interface DoctorReport extends DoctorSnapshot {
|
|
21
|
+
schemaVersion: 1;
|
|
22
|
+
before: DoctorSnapshot | null;
|
|
23
|
+
fixes: {
|
|
24
|
+
id: string;
|
|
25
|
+
status: "applied" | "failed";
|
|
26
|
+
message: string;
|
|
27
|
+
}[];
|
|
28
|
+
}
|
|
29
|
+
export declare function checkDoctor(cwd: string, probes?: DoctorProbes): Promise<DoctorSnapshot>;
|
|
30
|
+
export declare const doctorActions: {
|
|
31
|
+
init: (ctx: Context) => Promise<void>;
|
|
32
|
+
setup: (target: string, ctx: Context) => Promise<void>;
|
|
33
|
+
index: (ctx: Context) => Promise<void>;
|
|
34
|
+
};
|
|
35
|
+
export declare function diagnose(ctx: Context, fix: boolean, probes?: {
|
|
36
|
+
nodeVersion: () => string;
|
|
37
|
+
resolveRoot: typeof import("@agenthead/core").resolveProjectRoot;
|
|
38
|
+
findBinary: (name: string, root: string, env?: NodeJS.ProcessEnv) => Promise<string | undefined>;
|
|
39
|
+
version: (command: string, root: string, env?: NodeJS.ProcessEnv) => Promise<string>;
|
|
40
|
+
store: (root: string) => {
|
|
41
|
+
schemaVersion: number;
|
|
42
|
+
expectedSchemaVersion: number;
|
|
43
|
+
integrity: string[];
|
|
44
|
+
};
|
|
45
|
+
storeExists: (root: string) => boolean;
|
|
46
|
+
git: (root: string) => Promise<boolean>;
|
|
47
|
+
workspace: typeof import("./doctor-probes.js").workspaceSelfTest;
|
|
48
|
+
secrets: typeof import("./doctor-probes.js").secretSelfTest;
|
|
49
|
+
clients: (root: string) => Promise<AgentStatus[]>;
|
|
50
|
+
config: typeof import("./doctor-probes.js").readClientConfig;
|
|
51
|
+
handshake: (launch: McpLaunch, root: string) => Promise<string>;
|
|
52
|
+
graph: (root: string) => {
|
|
53
|
+
files: number;
|
|
54
|
+
stale: string[];
|
|
55
|
+
filesWithErrors: string[];
|
|
56
|
+
};
|
|
57
|
+
routingConfig: typeof import("@agenthead/core").loadRoutingConfig;
|
|
58
|
+
route: typeof import("@agenthead/core").routeTask;
|
|
59
|
+
candidates: typeof import("@agenthead/core").routingCandidates;
|
|
60
|
+
}, actions?: {
|
|
61
|
+
init: (ctx: Context) => Promise<void>;
|
|
62
|
+
setup: (target: string, ctx: Context) => Promise<void>;
|
|
63
|
+
index: (ctx: Context) => Promise<void>;
|
|
64
|
+
}): Promise<DoctorReport>;
|
|
65
|
+
export declare function renderDoctor(report: DoctorReport): string;
|
|
66
|
+
export declare function doctor(args: string[], ctx: Context): Promise<number>;
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { EvidenceStore } from "@agenthead/core";
|
|
2
|
+
import { GraphStore } from "@agenthead/graph";
|
|
3
|
+
import { scannerTools } from "@agenthead/security";
|
|
4
|
+
import { emit, parse, UsageError } from "./context.js";
|
|
5
|
+
import { setup } from "./setup-command.js";
|
|
6
|
+
import { clientFiles, clientTargets, doctorProbes, routingInventory, safeMessage, } from "./doctor-probes.js";
|
|
7
|
+
import { version } from "./version.js";
|
|
8
|
+
const install = `npm install --global /absolute/path/to/artifacts/agenthead-{core,graph,conductor,security,cli,mcp}-${version}.tgz`;
|
|
9
|
+
const login = {
|
|
10
|
+
claude: "claude auth login",
|
|
11
|
+
codex: "codex login",
|
|
12
|
+
cursor: "cursor-agent login",
|
|
13
|
+
};
|
|
14
|
+
const recheck = "agenthead doctor";
|
|
15
|
+
export async function checkDoctor(cwd, probes = doctorProbes) {
|
|
16
|
+
const checks = [];
|
|
17
|
+
const add = (id, status, message, fix = recheck, details = {}, fixable = false) => {
|
|
18
|
+
const check = { id, status, message, fix, fixable, details };
|
|
19
|
+
checks.push(check);
|
|
20
|
+
return check;
|
|
21
|
+
};
|
|
22
|
+
const node = probes.nodeVersion();
|
|
23
|
+
add("node", Number(node.split(".")[0]) >= 22 ? "ok" : "fail", `Node ${node}; requires >=22`, "nvm install 22", { version: node });
|
|
24
|
+
let mcp;
|
|
25
|
+
let binariesOk = false;
|
|
26
|
+
try {
|
|
27
|
+
const cli = await probes.findBinary("agenthead", cwd);
|
|
28
|
+
mcp = await probes.findBinary("agenthead-mcp", cwd);
|
|
29
|
+
if (!cli || !mcp)
|
|
30
|
+
add("binaries", "fail", `Missing from PATH: ${[!cli && "agenthead", !mcp && "agenthead-mcp"].filter(Boolean).join(", ")}; install matching tarballs, then add npm's global binary directory to the client's PATH`, install, { cli: cli ?? null, mcp: mcp ?? null });
|
|
31
|
+
else {
|
|
32
|
+
const cliVersion = await probes.version(cli, cwd);
|
|
33
|
+
const mcpVersion = await probes.version(mcp, cwd);
|
|
34
|
+
binariesOk = cliVersion === mcpVersion && cliVersion === version;
|
|
35
|
+
add("binaries", binariesOk ? "ok" : "fail", `PATH CLI ${cliVersion}, MCP ${mcpVersion}, running CLI ${version}`, binariesOk ? recheck : install, { cli, mcp, cliVersion, mcpVersion, runningVersion: version });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
add("binaries", "fail", safeMessage(error), install);
|
|
40
|
+
}
|
|
41
|
+
let root = null;
|
|
42
|
+
try {
|
|
43
|
+
root = probes.resolveRoot(undefined, cwd);
|
|
44
|
+
add("project", "ok", `Resolved project ${root}`, "agenthead stats --json", {
|
|
45
|
+
cwd,
|
|
46
|
+
root,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
add("project", "fail", "Cannot resolve an existing project directory", "cd .");
|
|
51
|
+
}
|
|
52
|
+
let storeOk = false;
|
|
53
|
+
if (root) {
|
|
54
|
+
try {
|
|
55
|
+
if (!probes.storeExists(root))
|
|
56
|
+
add("store", "fail", ".agenthead store is missing", "agenthead init", {}, true);
|
|
57
|
+
else {
|
|
58
|
+
const info = probes.store(root);
|
|
59
|
+
const healthy = info.integrity.length === 1 && info.integrity[0] === "ok";
|
|
60
|
+
storeOk = healthy && info.schemaVersion === info.expectedSchemaVersion;
|
|
61
|
+
const upgrade = healthy &&
|
|
62
|
+
info.schemaVersion > 0 &&
|
|
63
|
+
info.schemaVersion < info.expectedSchemaVersion;
|
|
64
|
+
add("store", storeOk ? "ok" : upgrade ? "warn" : "fail", `Store schema ${info.schemaVersion}/${info.expectedSchemaVersion}; integrity_check ${healthy ? "ok" : "failed"}`, healthy ? "agenthead init" : "agenthead stats --json", info, upgrade);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
add("store", "fail", "Cannot open the store or read its schema/integrity; preserve the store and inspect the error", "agenthead stats --json");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else
|
|
72
|
+
add("store", "fail", "Blocked by project resolution", "cd .");
|
|
73
|
+
try {
|
|
74
|
+
const inside = !!root && (await probes.git(root));
|
|
75
|
+
add("git", inside ? "ok" : "warn", inside ? "Inside a Git worktree" : "Not inside a Git worktree", "git init");
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
add("git", "warn", "Not in a Git worktree, or git is unavailable", "git init");
|
|
79
|
+
}
|
|
80
|
+
let workspaceOk = false;
|
|
81
|
+
try {
|
|
82
|
+
if (!root)
|
|
83
|
+
throw new Error("Project unavailable");
|
|
84
|
+
probes.workspace(root);
|
|
85
|
+
workspaceOk = true;
|
|
86
|
+
add("workspace", "ok", "Boundary rejects outside paths, secrets and store sources; storage paths are safe");
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
add("workspace", "fail", safeMessage(error), "agenthead init");
|
|
90
|
+
}
|
|
91
|
+
let secretsOk = false;
|
|
92
|
+
try {
|
|
93
|
+
probes.secrets();
|
|
94
|
+
secretsOk = true;
|
|
95
|
+
add("secrets", "ok", "Secret filter self-test passed");
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
add("secrets", "fail", "Secret filter self-test failed; reinstall matching release packages", install);
|
|
99
|
+
}
|
|
100
|
+
let agents = [];
|
|
101
|
+
let discoveryError = false;
|
|
102
|
+
try {
|
|
103
|
+
if (root)
|
|
104
|
+
agents = await probes.clients(root);
|
|
105
|
+
else
|
|
106
|
+
discoveryError = true;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
discoveryError = true;
|
|
110
|
+
}
|
|
111
|
+
const launches = [];
|
|
112
|
+
for (const id of Object.keys(clientTargets)) {
|
|
113
|
+
const agent = agents.find((agent) => agent.id === id);
|
|
114
|
+
const prefix = `client.${id}`;
|
|
115
|
+
if (!discoveryError && !agent?.installed) {
|
|
116
|
+
for (const check of ["installed", "login", "config"])
|
|
117
|
+
add(`${prefix}.${check}`, "skip", `${clientTargets[id]} not installed (optional)`);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
add(`${prefix}.installed`, discoveryError ? "fail" : "ok", `${clientTargets[id]} ${discoveryError ? "discovery failed" : "installed"}`, recheck, { binary: agent?.binary ?? null });
|
|
121
|
+
add(`${prefix}.login`, agent?.loggedIn ? "ok" : "warn", `${clientTargets[id]} ${agent?.loggedIn === true ? "logged in" : agent?.loggedIn === false ? "login required" : "login unknown (may use an OS credential store)"}`, login[id], { loggedIn: agent?.loggedIn ?? null });
|
|
122
|
+
try {
|
|
123
|
+
if (!root)
|
|
124
|
+
throw new Error("Project unavailable");
|
|
125
|
+
const config = probes.config(root, id);
|
|
126
|
+
if (!config)
|
|
127
|
+
add(`${prefix}.config`, "fail", `${clientFiles[id]} has no AgentHead server`, `agenthead setup ${clientTargets[id]}`, {}, !!agent?.installed);
|
|
128
|
+
else {
|
|
129
|
+
const binary = await probes.findBinary(config.command, root, {
|
|
130
|
+
...process.env,
|
|
131
|
+
...config.env,
|
|
132
|
+
});
|
|
133
|
+
if (!binary)
|
|
134
|
+
throw new Error("Configured agenthead-mcp is not executable on PATH");
|
|
135
|
+
const configuredVersion = await probes.version(binary, root, config.env);
|
|
136
|
+
if (configuredVersion !== version)
|
|
137
|
+
throw new Error("Configured agenthead-mcp version does not match the running CLI");
|
|
138
|
+
launches.push({ id, launch: { ...config, command: binary } });
|
|
139
|
+
add(`${prefix}.config`, "ok", `${clientFiles[id]} parses and launches MCP ${configuredVersion} for this project`, recheck, {
|
|
140
|
+
file: clientFiles[id],
|
|
141
|
+
command: binary,
|
|
142
|
+
version: configuredVersion,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
add(`${prefix}.config`, "fail", safeMessage(error), id === "codex" &&
|
|
148
|
+
error instanceof Error &&
|
|
149
|
+
error.message.includes("points at a different project")
|
|
150
|
+
? "agenthead setup codex --force"
|
|
151
|
+
: `code ${clientFiles[id]}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (root && storeOk && workspaceOk && secretsOk && mcp && binariesOk) {
|
|
155
|
+
launches.unshift({ id: "PATH", launch: { command: mcp, args: [root] } });
|
|
156
|
+
let failed = false;
|
|
157
|
+
const cache = new Map();
|
|
158
|
+
for (const { id, launch } of launches) {
|
|
159
|
+
const key = JSON.stringify(launch);
|
|
160
|
+
let error = cache.get(key);
|
|
161
|
+
if (error === undefined) {
|
|
162
|
+
try {
|
|
163
|
+
await probes.handshake(launch, root);
|
|
164
|
+
error = null;
|
|
165
|
+
}
|
|
166
|
+
catch (cause) {
|
|
167
|
+
error = safeMessage(cause);
|
|
168
|
+
}
|
|
169
|
+
cache.set(key, error);
|
|
170
|
+
}
|
|
171
|
+
if (error) {
|
|
172
|
+
failed = true;
|
|
173
|
+
const configCheck = checks.find((check) => check.id === `client.${id}.config`);
|
|
174
|
+
if (configCheck) {
|
|
175
|
+
configCheck.status = "fail";
|
|
176
|
+
configCheck.message = `${configCheck.message}; ${error}`;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const failures = [...cache.values()].filter(Boolean);
|
|
181
|
+
add("mcp", failed ? "fail" : "ok", failed
|
|
182
|
+
? failures.join("; ")
|
|
183
|
+
: "initialize + tools/list passed for PATH and configured clients (5s per launch)", recheck, { launches: launches.length });
|
|
184
|
+
}
|
|
185
|
+
else
|
|
186
|
+
add("mcp", "fail", "Handshake blocked until binaries, store, boundary and secret checks pass", recheck);
|
|
187
|
+
try {
|
|
188
|
+
if (!root || !workspaceOk)
|
|
189
|
+
throw new Error();
|
|
190
|
+
const info = probes.graph(root);
|
|
191
|
+
const stale = info.stale.length > 0 || info.filesWithErrors.length > 0;
|
|
192
|
+
add("graph", stale ? "warn" : "ok", `${info.files} source files; ${info.stale.length} stale; ${info.filesWithErrors.length} with parse errors`, "agenthead graph index", info, stale);
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
add("graph", "warn", "Graph index missing, unreadable or incompatible", "agenthead graph index", {}, !!root && workspaceOk);
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
if (!root)
|
|
199
|
+
throw new Error("Project unavailable");
|
|
200
|
+
const config = probes.routingConfig(root);
|
|
201
|
+
const inventory = routingInventory(agents, config);
|
|
202
|
+
const input = {
|
|
203
|
+
task: "Implement a small feature",
|
|
204
|
+
taskClass: "feature",
|
|
205
|
+
agents: inventory,
|
|
206
|
+
};
|
|
207
|
+
const candidates = probes.candidates(input, config);
|
|
208
|
+
let independent = false;
|
|
209
|
+
let reason = "No independent verifier available";
|
|
210
|
+
try {
|
|
211
|
+
probes.route(input, config);
|
|
212
|
+
independent = true;
|
|
213
|
+
reason = "Independent agent/model verifier available";
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
reason = safeMessage(error);
|
|
217
|
+
}
|
|
218
|
+
for (const role of ["plan", "implement", "verify"]) {
|
|
219
|
+
const choices = candidates[role];
|
|
220
|
+
add(`routing.${role}`, choices.length ? "ok" : "warn", `${role}: ${choices.map((choice) => `${choice.agent}/${choice.model}`).join(", ") || "no available agent/model"} (configured models; account access is not probed)`, 'agenthead route "Implement a small feature" --json', { choices, inventory });
|
|
221
|
+
}
|
|
222
|
+
add("routing.independent", independent ? "ok" : "warn", reason, 'agenthead route "Implement a small feature" --json', { independent });
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
for (const role of ["plan", "implement", "verify", "independent"])
|
|
226
|
+
add(`routing.${role}`, "fail", safeMessage(error), "code .agenthead/routing.json");
|
|
227
|
+
}
|
|
228
|
+
const securityTools = [];
|
|
229
|
+
for (const tool of scannerTools) {
|
|
230
|
+
try {
|
|
231
|
+
const binary = await probes.findBinary(tool, root ?? cwd);
|
|
232
|
+
if (binary)
|
|
233
|
+
securityTools.push({ tool, binary });
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
/* Optional scanner discovery never changes doctor health. */
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
add("security.tools", securityTools.length ? "ok" : "skip", securityTools.length
|
|
240
|
+
? `Installed security tools: ${securityTools.map((t) => t.tool).join(", ")}`
|
|
241
|
+
: "No optional security tools installed", "agenthead security scan", { tools: securityTools });
|
|
242
|
+
const summary = { ok: 0, warn: 0, fail: 0, skip: 0 };
|
|
243
|
+
for (const check of checks)
|
|
244
|
+
summary[check.status]++;
|
|
245
|
+
return {
|
|
246
|
+
projectRoot: root,
|
|
247
|
+
checks,
|
|
248
|
+
summary,
|
|
249
|
+
exitCode: summary.fail ? 1 : summary.warn ? 2 : 0,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
export const doctorActions = {
|
|
253
|
+
init: async (ctx) => {
|
|
254
|
+
new EvidenceStore(ctx.cwd).close();
|
|
255
|
+
},
|
|
256
|
+
setup: async (target, ctx) => {
|
|
257
|
+
await setup([target], ctx);
|
|
258
|
+
},
|
|
259
|
+
index: async (ctx) => {
|
|
260
|
+
const graph = new GraphStore(ctx.cwd);
|
|
261
|
+
try {
|
|
262
|
+
await graph.index();
|
|
263
|
+
}
|
|
264
|
+
finally {
|
|
265
|
+
graph.close();
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
export async function diagnose(ctx, fix, probes = doctorProbes, actions = doctorActions) {
|
|
270
|
+
const before = await checkDoctor(ctx.cwd, probes);
|
|
271
|
+
const fixes = [];
|
|
272
|
+
if (fix &&
|
|
273
|
+
before.projectRoot &&
|
|
274
|
+
before.checks.find((check) => check.id === "workspace")?.status === "ok" &&
|
|
275
|
+
before.checks.find((check) => check.id === "secrets")?.status === "ok") {
|
|
276
|
+
const quiet = { ...ctx, cwd: before.projectRoot, stdout: { write() { } } };
|
|
277
|
+
for (const check of before.checks.filter((check) => check.fixable)) {
|
|
278
|
+
try {
|
|
279
|
+
if (check.id === "store")
|
|
280
|
+
await actions.init(quiet);
|
|
281
|
+
else if (check.id === "graph")
|
|
282
|
+
await actions.index(quiet);
|
|
283
|
+
else {
|
|
284
|
+
const id = check.id.split(".")[1];
|
|
285
|
+
await actions.setup(clientTargets[id], quiet);
|
|
286
|
+
}
|
|
287
|
+
fixes.push({ id: check.id, status: "applied", message: check.fix });
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
fixes.push({
|
|
291
|
+
id: check.id,
|
|
292
|
+
status: "failed",
|
|
293
|
+
message: safeMessage(error),
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const after = fix ? await checkDoctor(ctx.cwd, probes) : before;
|
|
299
|
+
return { schemaVersion: 1, ...after, before: fix ? before : null, fixes };
|
|
300
|
+
}
|
|
301
|
+
export function renderDoctor(report) {
|
|
302
|
+
const lines = (checks) => checks.map((check) => `${check.status} ${check.id}: ${check.message}${check.status === "warn" || check.status === "fail" ? ` | fix: ${check.fix}` : ""}`);
|
|
303
|
+
return [
|
|
304
|
+
...(report.before
|
|
305
|
+
? [
|
|
306
|
+
"Before:",
|
|
307
|
+
...lines(report.before.checks),
|
|
308
|
+
...report.fixes.map((fix) => `${fix.status} ${fix.id}: ${fix.message}`),
|
|
309
|
+
"After:",
|
|
310
|
+
]
|
|
311
|
+
: []),
|
|
312
|
+
...lines(report.checks),
|
|
313
|
+
].join("\n");
|
|
314
|
+
}
|
|
315
|
+
export async function doctor(args, ctx) {
|
|
316
|
+
const { values, positionals } = parse(args, { fix: { type: "boolean" } });
|
|
317
|
+
if (positionals.length)
|
|
318
|
+
throw new UsageError("agenthead doctor takes no arguments");
|
|
319
|
+
const report = await diagnose(ctx, values.fix === true);
|
|
320
|
+
emit(ctx, values.json, report, renderDoctor(report));
|
|
321
|
+
return report.exitCode;
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=doctor-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor-command.js","sourceRoot":"","sources":["../src/doctor-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACL,WAAW,EACX,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,WAAW,GAGZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAuBvC,MAAM,OAAO,GAAG,sGAAsG,OAAO,MAAM,CAAC;AACpI,MAAM,KAAK,GAA6B;IACtC,MAAM,EAAE,mBAAmB;IAC3B,KAAK,EAAE,aAAa;IACpB,MAAM,EAAE,oBAAoB;CAC7B,CAAC;AACF,MAAM,OAAO,GAAG,kBAAkB,CAAC;AAEnC,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,GAAW,EACX,SAAuB,YAAY;IAEnC,MAAM,MAAM,GAAkB,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IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,OAAO,EAAE,CACnD;gBACD,QAAQ;aACT;YACH,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;KACxB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAc,EAAE,GAAY;IACvD,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAC1E,IAAI,WAAW,CAAC,MAAM;QACpB,MAAM,IAAI,UAAU,CAAC,qCAAqC,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;IACxD,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC,QAAQ,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type AgentStatus } from "@agenthead/conductor";
|
|
2
|
+
import { loadRoutingConfig, resolveProjectRoot, routeTask, routingCandidates, type AvailableAgent, type RoutingConfig } from "@agenthead/core";
|
|
3
|
+
import { type McpLaunch } from "./doctor-process.js";
|
|
4
|
+
export declare const clientTargets: {
|
|
5
|
+
readonly claude: "claude-code";
|
|
6
|
+
readonly codex: "codex";
|
|
7
|
+
readonly cursor: "cursor";
|
|
8
|
+
};
|
|
9
|
+
export type ClientId = keyof typeof clientTargets;
|
|
10
|
+
export declare const clientFiles: Record<ClientId, string>;
|
|
11
|
+
/** Validate only direct AgentHead launches; never execute arbitrary config wrappers. */
|
|
12
|
+
export declare function readClientConfig(root: string, id: ClientId): McpLaunch | undefined;
|
|
13
|
+
export declare function workspaceSelfTest(root: string): void;
|
|
14
|
+
export declare function secretSelfTest(): void;
|
|
15
|
+
/** Match conductor availability: unknown OS-keychain auth remains usable but is reported. */
|
|
16
|
+
export declare function routingInventory(agents: AgentStatus[], config: RoutingConfig): AvailableAgent[];
|
|
17
|
+
export declare const doctorProbes: {
|
|
18
|
+
nodeVersion: () => string;
|
|
19
|
+
resolveRoot: typeof resolveProjectRoot;
|
|
20
|
+
findBinary: (name: string, root: string, env?: NodeJS.ProcessEnv) => Promise<string | undefined>;
|
|
21
|
+
version: (command: string, root: string, env?: NodeJS.ProcessEnv) => Promise<string>;
|
|
22
|
+
store: (root: string) => {
|
|
23
|
+
schemaVersion: number;
|
|
24
|
+
expectedSchemaVersion: number;
|
|
25
|
+
integrity: string[];
|
|
26
|
+
};
|
|
27
|
+
storeExists: (root: string) => boolean;
|
|
28
|
+
git: (root: string) => Promise<boolean>;
|
|
29
|
+
workspace: typeof workspaceSelfTest;
|
|
30
|
+
secrets: typeof secretSelfTest;
|
|
31
|
+
clients: (root: string) => Promise<AgentStatus[]>;
|
|
32
|
+
config: typeof readClientConfig;
|
|
33
|
+
handshake: (launch: McpLaunch, root: string) => Promise<string>;
|
|
34
|
+
graph: (root: string) => {
|
|
35
|
+
files: number;
|
|
36
|
+
stale: string[];
|
|
37
|
+
filesWithErrors: string[];
|
|
38
|
+
};
|
|
39
|
+
routingConfig: typeof loadRoutingConfig;
|
|
40
|
+
route: typeof routeTask;
|
|
41
|
+
candidates: typeof routingCandidates;
|
|
42
|
+
};
|
|
43
|
+
export type DoctorProbes = typeof doctorProbes;
|
|
44
|
+
export declare function safeMessage(error: unknown): string;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { basename } from "node:path";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { discoverAgents, findBinary, } from "@agenthead/conductor";
|
|
6
|
+
import { EvidenceStore, ExcludedPathError, OutsideProjectError, SecretFilter, StorageSymlinkError, StoreSourceError, WorkspaceBoundary, loadRoutingConfig, resolveProjectRoot, routeTask, routingCandidates, } from "@agenthead/core";
|
|
7
|
+
import { GraphStore } from "@agenthead/graph";
|
|
8
|
+
import { codexServer } from "./setup-toml.js";
|
|
9
|
+
import { probeProcess } from "./doctor-process.js";
|
|
10
|
+
export const clientTargets = {
|
|
11
|
+
claude: "claude-code",
|
|
12
|
+
codex: "codex",
|
|
13
|
+
cursor: "cursor",
|
|
14
|
+
};
|
|
15
|
+
export const clientFiles = {
|
|
16
|
+
claude: ".mcp.json",
|
|
17
|
+
codex: ".codex/config.toml",
|
|
18
|
+
cursor: ".cursor/mcp.json",
|
|
19
|
+
};
|
|
20
|
+
/** Validate only direct AgentHead launches; never execute arbitrary config wrappers. */
|
|
21
|
+
export function readClientConfig(root, id) {
|
|
22
|
+
const boundary = new WorkspaceBoundary(root);
|
|
23
|
+
const file = boundary.resolveStorage(clientFiles[id]);
|
|
24
|
+
let text;
|
|
25
|
+
try {
|
|
26
|
+
text = readFileSync(file, "utf8");
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (error.code === "ENOENT")
|
|
30
|
+
return undefined;
|
|
31
|
+
throw new Error(`Cannot read ${clientFiles[id]}`, { cause: error });
|
|
32
|
+
}
|
|
33
|
+
let entry;
|
|
34
|
+
try {
|
|
35
|
+
if (id === "codex")
|
|
36
|
+
entry = codexServer(text);
|
|
37
|
+
else {
|
|
38
|
+
const config = JSON.parse(text);
|
|
39
|
+
if (!config ||
|
|
40
|
+
typeof config !== "object" ||
|
|
41
|
+
Array.isArray(config) ||
|
|
42
|
+
(config.mcpServers !== undefined &&
|
|
43
|
+
(!config.mcpServers ||
|
|
44
|
+
typeof config.mcpServers !== "object" ||
|
|
45
|
+
Array.isArray(config.mcpServers))))
|
|
46
|
+
throw new Error();
|
|
47
|
+
entry = config.mcpServers?.agenthead;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new Error(`${clientFiles[id]} does not parse with the setup parser`);
|
|
52
|
+
}
|
|
53
|
+
if (entry === undefined)
|
|
54
|
+
return undefined;
|
|
55
|
+
if (!entry ||
|
|
56
|
+
typeof entry !== "object" ||
|
|
57
|
+
Array.isArray(entry) ||
|
|
58
|
+
typeof entry.command !== "string" ||
|
|
59
|
+
!/^agenthead-mcp(?:\.(?:js|cmd|exe))?$/.test(basename(entry.command)) ||
|
|
60
|
+
!Array.isArray(entry.args) ||
|
|
61
|
+
entry.args.length !== 1 ||
|
|
62
|
+
typeof entry.args[0] !== "string" ||
|
|
63
|
+
entry.disabled === true ||
|
|
64
|
+
entry.enabled === false ||
|
|
65
|
+
entry.cwd !== undefined ||
|
|
66
|
+
(entry.type !== undefined && entry.type !== "stdio"))
|
|
67
|
+
throw new Error(`${clientFiles[id]} needs an enabled, direct agenthead-mcp stdio launch with one project argument`);
|
|
68
|
+
const project = id === "cursor" && entry.args[0] === "${workspaceFolder}"
|
|
69
|
+
? root
|
|
70
|
+
: entry.args[0];
|
|
71
|
+
if (resolveProjectRoot(project, root) !== boundary.root)
|
|
72
|
+
throw new Error(`${clientFiles[id]} points at a different project`);
|
|
73
|
+
let env;
|
|
74
|
+
if (entry.env !== undefined) {
|
|
75
|
+
if (!entry.env ||
|
|
76
|
+
typeof entry.env !== "object" ||
|
|
77
|
+
Array.isArray(entry.env) ||
|
|
78
|
+
Object.values(entry.env).some((value) => typeof value !== "string"))
|
|
79
|
+
throw new Error(`${clientFiles[id]} has an invalid env table`);
|
|
80
|
+
env = entry.env;
|
|
81
|
+
}
|
|
82
|
+
return { command: entry.command, args: [project], env };
|
|
83
|
+
}
|
|
84
|
+
export function workspaceSelfTest(root) {
|
|
85
|
+
const boundary = new WorkspaceBoundary(root);
|
|
86
|
+
for (const [path, source, expected] of [
|
|
87
|
+
["../agenthead-doctor-outside", true, OutsideProjectError],
|
|
88
|
+
["../agenthead-doctor-outside", false, OutsideProjectError],
|
|
89
|
+
[".env.agenthead-doctor", true, ExcludedPathError],
|
|
90
|
+
[".agenthead/agenthead.db", true, StoreSourceError],
|
|
91
|
+
]) {
|
|
92
|
+
let refused = false;
|
|
93
|
+
try {
|
|
94
|
+
if (source)
|
|
95
|
+
boundary.resolveSource(path);
|
|
96
|
+
else
|
|
97
|
+
boundary.resolveStorage(path);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
if (error instanceof expected)
|
|
101
|
+
refused = true;
|
|
102
|
+
else
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
if (!refused)
|
|
106
|
+
throw new Error("Workspace boundary self-test failed");
|
|
107
|
+
}
|
|
108
|
+
// Also preflight real storage and SQLite sidecars for redirected paths.
|
|
109
|
+
for (const file of ["agenthead.db", "graph.db"])
|
|
110
|
+
for (const suffix of ["", "-journal", "-wal", "-shm"])
|
|
111
|
+
boundary.resolveStorage(`.agenthead/${file}${suffix}`);
|
|
112
|
+
}
|
|
113
|
+
export function secretSelfTest() {
|
|
114
|
+
const secret = "AKIA" + "ABCDEFGHIJKLMNOP";
|
|
115
|
+
const text = new SecretFilter().redact(`doctor ${secret} ordinary text`);
|
|
116
|
+
if (text.includes(secret) ||
|
|
117
|
+
!text.includes("[REDACTED:aws-access-key]") ||
|
|
118
|
+
!text.includes("ordinary text"))
|
|
119
|
+
throw new Error("Secret filter self-test failed");
|
|
120
|
+
}
|
|
121
|
+
/** Match conductor availability: unknown OS-keychain auth remains usable but is reported. */
|
|
122
|
+
export function routingInventory(agents, config) {
|
|
123
|
+
const detected = agents.map((agent) => ({
|
|
124
|
+
agent: agent.id === "claude" ? "claude-code" : agent.id,
|
|
125
|
+
status: agent.installed && agent.loggedIn !== false
|
|
126
|
+
? "available"
|
|
127
|
+
: "unavailable",
|
|
128
|
+
}));
|
|
129
|
+
return (config.agents?.map((entry) => ({
|
|
130
|
+
...entry,
|
|
131
|
+
status: detected.find((agent) => agent.agent.toLowerCase() === entry.agent.toLowerCase())?.status === "available"
|
|
132
|
+
? (entry.status ?? "available")
|
|
133
|
+
: "unavailable",
|
|
134
|
+
})) ?? detected);
|
|
135
|
+
}
|
|
136
|
+
export const doctorProbes = {
|
|
137
|
+
nodeVersion: () => process.versions.node,
|
|
138
|
+
resolveRoot: resolveProjectRoot,
|
|
139
|
+
findBinary: (name, root, env = process.env) => findBinary(name, env, root),
|
|
140
|
+
version: (command, root, env) => probeProcess({ command, args: ["--version"], env }, root, "version"),
|
|
141
|
+
store: (root) => EvidenceStore.inspect(root),
|
|
142
|
+
storeExists: (root) => {
|
|
143
|
+
const path = new WorkspaceBoundary(root).resolveStorage(".agenthead/agenthead.db");
|
|
144
|
+
return statSync(path, { throwIfNoEntry: false })?.isFile() ?? false;
|
|
145
|
+
},
|
|
146
|
+
git: async (root) => (await promisify(execFile)("git", ["rev-parse", "--is-inside-work-tree"], {
|
|
147
|
+
cwd: root,
|
|
148
|
+
timeout: 5000,
|
|
149
|
+
})).stdout.trim() === "true",
|
|
150
|
+
workspace: workspaceSelfTest,
|
|
151
|
+
secrets: secretSelfTest,
|
|
152
|
+
clients: (root) => discoverAgents({ cwd: root }),
|
|
153
|
+
config: readClientConfig,
|
|
154
|
+
handshake: (launch, root) => probeProcess(launch, root, "mcp"),
|
|
155
|
+
graph: (root) => {
|
|
156
|
+
const graph = new GraphStore(root, { readonly: true });
|
|
157
|
+
try {
|
|
158
|
+
return graph.freshness();
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
graph.close();
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
routingConfig: loadRoutingConfig,
|
|
165
|
+
route: routeTask,
|
|
166
|
+
candidates: routingCandidates,
|
|
167
|
+
};
|
|
168
|
+
export function safeMessage(error) {
|
|
169
|
+
if (error instanceof StorageSymlinkError)
|
|
170
|
+
return "Refused a storage symlink; restore a regular project-local path";
|
|
171
|
+
// Only caller-controlled messages should be used for config/protocol diagnostics.
|
|
172
|
+
return new SecretFilter()
|
|
173
|
+
.redact(error instanceof Error ? error.message : "Check could not complete")
|
|
174
|
+
.replace(/[\r\n\t]/g, " ");
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=doctor-probes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor-probes.js","sourceRoot":"","sources":["../src/doctor-probes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,cAAc,EACd,UAAU,GAEX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,iBAAiB,GAGlB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AAEnE,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,aAAa;IACrB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;CACR,CAAC;AAEX,MAAM,CAAC,MAAM,WAAW,GAA6B;IACnD,MAAM,EAAE,WAAW;IACnB,KAAK,EAAE,oBAAoB;IAC3B,MAAM,EAAE,kBAAkB;CAC3B,CAAC;AAEF,wFAAwF;AACxF,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,EAAY;IAEZ,MAAM,QAAQ,GAAG,IAAI,iBAAiB,CAA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