@agentbridge1/cli 0.0.1
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/bin/agentbridge.js +11 -0
- package/dist/acceptance-block.js +21 -0
- package/dist/acceptance-preflight.js +91 -0
- package/dist/api-client.js +6 -0
- package/dist/authority-request.js +25 -0
- package/dist/briefing.js +26 -0
- package/dist/bug-registry.js +350 -0
- package/dist/build-info.json +6 -0
- package/dist/canonical-state.js +11 -0
- package/dist/claimed-paths.js +42 -0
- package/dist/cli-failure-log.js +34 -0
- package/dist/commands/accept.js +241 -0
- package/dist/commands/attention.js +85 -0
- package/dist/commands/autopilot.js +93 -0
- package/dist/commands/bug.js +106 -0
- package/dist/commands/check.js +283 -0
- package/dist/commands/connect.js +159 -0
- package/dist/commands/dist-freshness.js +105 -0
- package/dist/commands/doctor.js +300 -0
- package/dist/commands/done.js +292 -0
- package/dist/commands/handoff.js +189 -0
- package/dist/commands/handshake.js +78 -0
- package/dist/commands/health.js +154 -0
- package/dist/commands/identity.js +57 -0
- package/dist/commands/init.js +5 -0
- package/dist/commands/memory.js +400 -0
- package/dist/commands/next.js +21 -0
- package/dist/commands/precommit-check.js +17 -0
- package/dist/commands/recover.js +116 -0
- package/dist/commands/session.js +229 -0
- package/dist/commands/setup-mcp.js +56 -0
- package/dist/commands/start.js +626 -0
- package/dist/commands/status.js +486 -0
- package/dist/commands/use.js +13 -0
- package/dist/commands/verify.js +264 -0
- package/dist/commands/version.js +32 -0
- package/dist/commands/watch.js +1718 -0
- package/dist/config.js +55 -0
- package/dist/domain-resolution.js +63 -0
- package/dist/error-catalog.js +494 -0
- package/dist/errors.js +276 -0
- package/dist/file-fingerprints.js +45 -0
- package/dist/gates.js +200 -0
- package/dist/git-evidence.js +285 -0
- package/dist/git-status.js +81 -0
- package/dist/http.js +151 -0
- package/dist/index.js +622 -0
- package/dist/init.js +458 -0
- package/dist/memory-context-render.js +51 -0
- package/dist/operator-snapshot.js +99 -0
- package/dist/precommit.js +72 -0
- package/dist/preflight-changed-files.js +109 -0
- package/dist/proof-guidance.js +110 -0
- package/dist/redact-secrets.js +15 -0
- package/dist/revert-crossing.js +73 -0
- package/dist/server-sync.js +433 -0
- package/dist/session-state.js +138 -0
- package/dist/session.js +89 -0
- package/dist/supervision.js +212 -0
- package/dist/terminal-ui.js +18 -0
- package/dist/test-runner.js +62 -0
- package/dist/types.js +2 -0
- package/dist/verification-conditions.js +185 -0
- package/dist/watch-core.js +208 -0
- package/dist/watch-packet-handshake.js +71 -0
- package/dist/watcher.js +62 -0
- package/dist/work-context-resolver.js +412 -0
- package/dist/work-contract.js +110 -0
- package/package.json +44 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.resolveInitContext = resolveInitContext;
|
|
5
|
+
exports.resolveCliEntryPath = resolveCliEntryPath;
|
|
6
|
+
exports.main = main;
|
|
7
|
+
const init_1 = require("./init");
|
|
8
|
+
const config_1 = require("./config");
|
|
9
|
+
const use_1 = require("./commands/use");
|
|
10
|
+
const watch_1 = require("./commands/watch");
|
|
11
|
+
const precommit_check_1 = require("./commands/precommit-check");
|
|
12
|
+
const status_1 = require("./commands/status");
|
|
13
|
+
const check_1 = require("./commands/check");
|
|
14
|
+
const start_1 = require("./commands/start");
|
|
15
|
+
const verify_1 = require("./commands/verify");
|
|
16
|
+
const handoff_1 = require("./commands/handoff");
|
|
17
|
+
const accept_1 = require("./commands/accept");
|
|
18
|
+
const version_1 = require("./commands/version");
|
|
19
|
+
const doctor_1 = require("./commands/doctor");
|
|
20
|
+
const done_1 = require("./commands/done");
|
|
21
|
+
const next_1 = require("./commands/next");
|
|
22
|
+
const health_1 = require("./commands/health");
|
|
23
|
+
const identity_1 = require("./commands/identity");
|
|
24
|
+
const memory_1 = require("./commands/memory");
|
|
25
|
+
const session_1 = require("./commands/session");
|
|
26
|
+
const handshake_1 = require("./commands/handshake");
|
|
27
|
+
const connect_1 = require("./commands/connect");
|
|
28
|
+
const setup_mcp_1 = require("./commands/setup-mcp");
|
|
29
|
+
const bug_1 = require("./commands/bug");
|
|
30
|
+
const autopilot_1 = require("./commands/autopilot");
|
|
31
|
+
const attention_1 = require("./commands/attention");
|
|
32
|
+
const recover_1 = require("./commands/recover");
|
|
33
|
+
const node_path_1 = require("node:path");
|
|
34
|
+
const node_child_process_1 = require("node:child_process");
|
|
35
|
+
const node_fs_1 = require("node:fs");
|
|
36
|
+
const errors_1 = require("./errors");
|
|
37
|
+
const cli_failure_log_1 = require("./cli-failure-log");
|
|
38
|
+
const session_state_1 = require("./session-state");
|
|
39
|
+
const COMMAND_HELP = {
|
|
40
|
+
connect: " agentbridge connect [--project <id>] [--api-key <key>] [--api-base-url <url>] [--agent <id>]\n" +
|
|
41
|
+
" Save credentials and verify connection to your AgentBridge project.\n" +
|
|
42
|
+
" Credentials can also come from AGENTBRIDGE_PROJECT_ID / AGENTBRIDGE_API_KEY env vars.\n",
|
|
43
|
+
recover: " agentbridge recover [--force]\n" +
|
|
44
|
+
" Recover project context so AI agents do not start blind.\n" +
|
|
45
|
+
" Shows project name, domains, and known context.\n",
|
|
46
|
+
init: " agentbridge init [--project <id> --api-key <key> --api-base-url <url>]\n" +
|
|
47
|
+
" Recover domains from git history, bootstrap the project, and install the pre-commit hook.\n" +
|
|
48
|
+
" Run `agentbridge connect` first to save credentials.\n",
|
|
49
|
+
use: " agentbridge use <agent-id>\n" +
|
|
50
|
+
" Set the active agent identity used by `watch` and `start`.\n",
|
|
51
|
+
start: " agentbridge start [\"intent\"] [\"scope\"]\n" +
|
|
52
|
+
" Advanced: agentbridge start --summary \"<summary>\" --scope \"<path-or-glob>\" [--domain <name>] [--agent <id>] [--change-request <cr_id>] [--resume]\n" +
|
|
53
|
+
" Start supervised work. Without flags, proposes a smart work contract and asks for confirmation.\n" +
|
|
54
|
+
" --resume Continue the active change request/session instead of creating a new one.\n",
|
|
55
|
+
watch: " agentbridge watch [--change-request <cr_id>] [--execution-surface <es_id>] [--allow-dirty] [--daemon] [--once]\n" +
|
|
56
|
+
" Product entrypoint: AgentBridge infers coding context and reviews proof/scope risk.\n" +
|
|
57
|
+
" --allow-dirty Skip the pre-existing dirty-files prompt.\n" +
|
|
58
|
+
" --daemon Non-interactive mode: skip all prompts, auto-deny domain crossings.\n" +
|
|
59
|
+
" --once Run one startup/supervision pass and exit.\n",
|
|
60
|
+
"setup-mcp": " agentbridge setup-mcp [--editor cursor|windsurf|vscode]\n" +
|
|
61
|
+
" Print the MCP server configuration snippet to add to your editor.\n",
|
|
62
|
+
mcp: " agentbridge mcp\n" +
|
|
63
|
+
" Start the AgentBridge MCP stdio server.\n",
|
|
64
|
+
status: " agentbridge status [--repair] [--json]\n Show current work session status.\n",
|
|
65
|
+
health: " agentbridge health [--json]\n Check project health against server.\n",
|
|
66
|
+
check: " agentbridge check [--json]\n Check whether current work session can be accepted.\n",
|
|
67
|
+
next: " agentbridge next [--json]\n Show the recommended next action.\n",
|
|
68
|
+
verify: " agentbridge verify [--json] -- <command>\n" +
|
|
69
|
+
" Run a command and verify output meets acceptance criteria.\n",
|
|
70
|
+
handoff: " agentbridge handoff [--json] --summary \"<summary>\" [--risks-remaining \"<text>\"]\n" +
|
|
71
|
+
" Submit a handoff with proof of work.\n",
|
|
72
|
+
accept: " agentbridge accept [--json]\n Accept the current change request (human reviewer).\n",
|
|
73
|
+
done: " agentbridge done [--json]\n Mark the current work session as done.\n",
|
|
74
|
+
identity: " agentbridge identity list\n List available agent identities for this project.\n",
|
|
75
|
+
session: " agentbridge session list [--change-request <cr_id>] [--active] [--json]\n" +
|
|
76
|
+
" agentbridge session inspect <work-session-id> [--json]\n" +
|
|
77
|
+
" agentbridge session cleanup [--stale] [--dry-run] [--json]\n" +
|
|
78
|
+
" agentbridge session abandon [--session <id>] --reason \"<why>\" [--json]\n",
|
|
79
|
+
handshake: " agentbridge handshake create --domain <name> --action \"<text>\" --reason \"<text>\" [--cr <id>] [--session <id>]\n" +
|
|
80
|
+
" agentbridge handshake acknowledge|resolve|list\n",
|
|
81
|
+
memory: " agentbridge memory suggest|apply|reject|defer|revert|intake-escaped-bug [...flags]\n" +
|
|
82
|
+
" Manage domain memory packets.\n",
|
|
83
|
+
version: " agentbridge version\n Print CLI version.\n",
|
|
84
|
+
doctor: " agentbridge doctor\n Run config and connectivity diagnostics.\n",
|
|
85
|
+
"precommit-check": " agentbridge precommit-check\n Git pre-commit hook: block commits that violate domain boundaries.\n",
|
|
86
|
+
bug: " agentbridge bug report --title \"<text>\" --severity P0|P1|P2|P3 --category <CATEGORY> \\\n" +
|
|
87
|
+
" [--found-in dogfood,production,...] --observed \"<text>\" --expected \"<text>\" \\\n" +
|
|
88
|
+
" [--project <id>] [--work-session <id>] [--change-request <id>] [--commands a,b] [--files a,b] [--logs \"<text>\"]\n" +
|
|
89
|
+
" Create docs/bugs/YYYY-MM-DD-<slug>.md (secrets redacted).\n" +
|
|
90
|
+
" agentbridge bug validate --file docs/bugs/<file>.md\n" +
|
|
91
|
+
" Enforce P0/P1 close requirements before verified/closed.\n",
|
|
92
|
+
};
|
|
93
|
+
function usage(command, opts) {
|
|
94
|
+
const exitCode = opts?.exitCode ?? 3;
|
|
95
|
+
const stream = opts?.stream ?? "stderr";
|
|
96
|
+
const write = stream === "stdout" ? process.stdout.write.bind(process.stdout) : process.stderr.write.bind(process.stderr);
|
|
97
|
+
if (command && COMMAND_HELP[command]) {
|
|
98
|
+
write(`\n${COMMAND_HELP[command]}\n`);
|
|
99
|
+
process.exit(exitCode);
|
|
100
|
+
}
|
|
101
|
+
write([
|
|
102
|
+
"",
|
|
103
|
+
"Usage: agentbridge <command> [flags]",
|
|
104
|
+
"",
|
|
105
|
+
"Quick start:",
|
|
106
|
+
" New repo:",
|
|
107
|
+
" agentbridge doctor",
|
|
108
|
+
" agentbridge start",
|
|
109
|
+
" Existing repo:",
|
|
110
|
+
" agentbridge doctor",
|
|
111
|
+
" agentbridge recover",
|
|
112
|
+
" agentbridge start",
|
|
113
|
+
"",
|
|
114
|
+
"Commands:",
|
|
115
|
+
" doctor Check AgentBridge connection and repo readiness",
|
|
116
|
+
" recover Understand an existing repo before agents continue",
|
|
117
|
+
" start Start or attach to supervised agent work",
|
|
118
|
+
"",
|
|
119
|
+
"Advanced commands:",
|
|
120
|
+
" connect Save credentials and verify connection to a project",
|
|
121
|
+
" init Recover domain map from git history and bootstrap the project",
|
|
122
|
+
" use Set active agent identity",
|
|
123
|
+
" watch Watch for file changes (advanced/manual)",
|
|
124
|
+
" start --summary ... --scope ... Backward-compatible explicit start mode",
|
|
125
|
+
" setup-mcp Print MCP server config for your editor",
|
|
126
|
+
" mcp Start local MCP stdio server",
|
|
127
|
+
" status Show current session status",
|
|
128
|
+
" health Check project health",
|
|
129
|
+
" check Check acceptance readiness",
|
|
130
|
+
" next Show recommended next action",
|
|
131
|
+
" verify Run command and verify output",
|
|
132
|
+
" handoff Submit a handoff with proof of work",
|
|
133
|
+
" accept Accept a change request (reviewer)",
|
|
134
|
+
" done Mark work session as done",
|
|
135
|
+
" identity Manage agent identities",
|
|
136
|
+
" session Manage work sessions",
|
|
137
|
+
" handshake Domain boundary handshake protocol",
|
|
138
|
+
" memory Domain memory management",
|
|
139
|
+
" version Print version",
|
|
140
|
+
" bug Internal bug report + close validation",
|
|
141
|
+
" precommit-check Git pre-commit hook",
|
|
142
|
+
" autopilot Enable/disable background automation for the current session",
|
|
143
|
+
" attention List and resolve items that need human decision",
|
|
144
|
+
"",
|
|
145
|
+
"Run `agentbridge <command> --help` for command-specific usage.",
|
|
146
|
+
"",
|
|
147
|
+
].join("\n"));
|
|
148
|
+
process.exit(exitCode);
|
|
149
|
+
}
|
|
150
|
+
function parseArgs(argv) {
|
|
151
|
+
const [command, ...rest] = argv;
|
|
152
|
+
if (!command)
|
|
153
|
+
usage();
|
|
154
|
+
let projectId = "";
|
|
155
|
+
let apiKey = "";
|
|
156
|
+
let apiBaseUrl = "";
|
|
157
|
+
const positional = [];
|
|
158
|
+
const flags = {};
|
|
159
|
+
for (let i = 0; i < rest.length; i += 1) {
|
|
160
|
+
const token = rest[i];
|
|
161
|
+
if (token === "--project") {
|
|
162
|
+
projectId = rest[i + 1] ?? "";
|
|
163
|
+
i += 1;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (token === "--api-key") {
|
|
167
|
+
apiKey = rest[i + 1] ?? "";
|
|
168
|
+
i += 1;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (token === "--api-base-url") {
|
|
172
|
+
apiBaseUrl = rest[i + 1] ?? "";
|
|
173
|
+
i += 1;
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (token.startsWith("--")) {
|
|
177
|
+
if (token === "--") {
|
|
178
|
+
positional.push(...rest.slice(i + 1));
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
const next = rest[i + 1];
|
|
182
|
+
if (!next || next.startsWith("--")) {
|
|
183
|
+
flags[token] = "true";
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
flags[token] = next;
|
|
187
|
+
i += 1;
|
|
188
|
+
}
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
positional.push(token);
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
command,
|
|
195
|
+
projectId: projectId || undefined,
|
|
196
|
+
apiKey: apiKey || undefined,
|
|
197
|
+
apiBaseUrl: apiBaseUrl || undefined,
|
|
198
|
+
positional,
|
|
199
|
+
flags,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function resolveInitContext(overrides) {
|
|
203
|
+
const cfg = (0, config_1.readConfig)();
|
|
204
|
+
const projectId = overrides.projectId ??
|
|
205
|
+
process.env.AGENTBRIDGE_PROJECT_ID ??
|
|
206
|
+
cfg.projectId;
|
|
207
|
+
let apiKeySource = "missing";
|
|
208
|
+
let apiKey = "";
|
|
209
|
+
if (overrides.apiKey) {
|
|
210
|
+
apiKey = overrides.apiKey;
|
|
211
|
+
apiKeySource = "flag";
|
|
212
|
+
}
|
|
213
|
+
else if (process.env.AGENTBRIDGE_API_KEY) {
|
|
214
|
+
apiKey = process.env.AGENTBRIDGE_API_KEY;
|
|
215
|
+
apiKeySource = "env";
|
|
216
|
+
}
|
|
217
|
+
else if (cfg.apiKey) {
|
|
218
|
+
apiKey = cfg.apiKey;
|
|
219
|
+
apiKeySource = "config";
|
|
220
|
+
}
|
|
221
|
+
const apiBaseUrl = overrides.apiBaseUrl ??
|
|
222
|
+
process.env.AGENTBRIDGE_BASE_URL ??
|
|
223
|
+
cfg.apiBaseUrl ??
|
|
224
|
+
"https://agentauth-api-production.up.railway.app";
|
|
225
|
+
if (!projectId) {
|
|
226
|
+
throw (0, errors_1.catalogCliError)("CONFIG_INCOMPLETE");
|
|
227
|
+
}
|
|
228
|
+
if (!apiKey) {
|
|
229
|
+
throw (0, errors_1.catalogCliError)("CONFIG_INCOMPLETE");
|
|
230
|
+
}
|
|
231
|
+
return { projectId, apiKey, apiBaseUrl, apiKeySource };
|
|
232
|
+
}
|
|
233
|
+
function resolveCliEntryPath(argv1 = process.argv[1]) {
|
|
234
|
+
if (!argv1)
|
|
235
|
+
return undefined;
|
|
236
|
+
if (argv1.startsWith("/"))
|
|
237
|
+
return argv1;
|
|
238
|
+
try {
|
|
239
|
+
return (0, node_path_1.resolve)(process.cwd(), argv1);
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async function main() {
|
|
246
|
+
const { command, projectId, apiKey, apiBaseUrl, positional, flags } = parseArgs(process.argv.slice(2));
|
|
247
|
+
if (command === "--help" || command === "help") {
|
|
248
|
+
usage(undefined, { exitCode: 0, stream: "stdout" });
|
|
249
|
+
}
|
|
250
|
+
// --help on any subcommand
|
|
251
|
+
if (flags["--help"] === "true") {
|
|
252
|
+
usage(command, { exitCode: 0, stream: "stdout" });
|
|
253
|
+
}
|
|
254
|
+
if (command === "connect") {
|
|
255
|
+
await (0, connect_1.runConnect)({
|
|
256
|
+
projectId,
|
|
257
|
+
apiKey,
|
|
258
|
+
apiBaseUrl,
|
|
259
|
+
agentId: flags["--agent"],
|
|
260
|
+
});
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (command === "recover") {
|
|
264
|
+
await (0, recover_1.runRecover)({ force: Boolean(flags["--force"]) });
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (command === "setup-mcp") {
|
|
268
|
+
await (0, setup_mcp_1.runSetupMcp)({ editor: flags["--editor"] });
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (command === "mcp") {
|
|
272
|
+
const repoRoot = (0, node_path_1.resolve)(__dirname, "..", "..");
|
|
273
|
+
const localMcpEntrypoint = (0, node_path_1.resolve)(repoRoot, "mcp", "agentbridge-mcp.ts");
|
|
274
|
+
if (!(0, node_fs_1.existsSync)(localMcpEntrypoint)) {
|
|
275
|
+
process.stderr.write([
|
|
276
|
+
"",
|
|
277
|
+
"AgentBridge MCP runtime is unavailable in this installation.",
|
|
278
|
+
"",
|
|
279
|
+
"Try:",
|
|
280
|
+
" npm install -g @agentbridge/cli",
|
|
281
|
+
" agentbridge doctor",
|
|
282
|
+
"",
|
|
283
|
+
].join("\n"));
|
|
284
|
+
process.exit(2);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const child = (0, node_child_process_1.spawnSync)("npx", ["tsx", localMcpEntrypoint], {
|
|
288
|
+
stdio: "inherit",
|
|
289
|
+
env: process.env,
|
|
290
|
+
});
|
|
291
|
+
if (child.error) {
|
|
292
|
+
process.stderr.write(`Failed to start MCP server via npx/tsx: ${child.error.message}\n`);
|
|
293
|
+
process.exit(2);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
process.exit(child.status ?? 0);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (command === "init") {
|
|
300
|
+
// If credentials aren't available yet, guide the user to connect first.
|
|
301
|
+
const cfg = (0, config_1.readConfig)();
|
|
302
|
+
const resolvedProjectId = projectId ?? process.env.AGENTBRIDGE_PROJECT_ID ?? cfg.projectId;
|
|
303
|
+
const resolvedApiKey = apiKey ?? process.env.AGENTBRIDGE_API_KEY ?? cfg.apiKey;
|
|
304
|
+
if (!resolvedProjectId || !resolvedApiKey) {
|
|
305
|
+
process.stderr.write([
|
|
306
|
+
"",
|
|
307
|
+
"Credentials not found. Run this first:",
|
|
308
|
+
"",
|
|
309
|
+
" agentbridge connect --project <project-id> --api-key <key>",
|
|
310
|
+
"",
|
|
311
|
+
"Then run `agentbridge init` again.",
|
|
312
|
+
"",
|
|
313
|
+
"Get your credentials at https://agentbridge.dev/dashboard",
|
|
314
|
+
"",
|
|
315
|
+
].join("\n"));
|
|
316
|
+
process.exit(3);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
await (0, init_1.runInit)(resolveInitContext({
|
|
320
|
+
projectId,
|
|
321
|
+
apiKey,
|
|
322
|
+
apiBaseUrl,
|
|
323
|
+
}));
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (command === "use") {
|
|
327
|
+
(0, use_1.runUse)(positional[0] ?? "");
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
if (command === "watch") {
|
|
331
|
+
await (0, watch_1.runWatch)({
|
|
332
|
+
task: flags["--task"],
|
|
333
|
+
scope: flags["--scope"],
|
|
334
|
+
changeRequestId: flags["--change-request"],
|
|
335
|
+
executionSurfaceId: flags["--execution-surface"],
|
|
336
|
+
allowDirty: flags["--allow-dirty"] === "true",
|
|
337
|
+
daemon: flags["--daemon"] === "true",
|
|
338
|
+
once: flags["--once"] === "true",
|
|
339
|
+
});
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
if (command === "start") {
|
|
343
|
+
const summaryFlagProvided = Object.prototype.hasOwnProperty.call(flags, "--summary");
|
|
344
|
+
const scopeFlagProvided = Object.prototype.hasOwnProperty.call(flags, "--scope");
|
|
345
|
+
await (0, start_1.runStart)({
|
|
346
|
+
summary: flags["--summary"],
|
|
347
|
+
scope: flags["--scope"] ?? positional[1],
|
|
348
|
+
prompt: positional[0],
|
|
349
|
+
summaryFlagProvided,
|
|
350
|
+
scopeFlagProvided,
|
|
351
|
+
domain: flags["--domain"],
|
|
352
|
+
agentId: flags["--agent"],
|
|
353
|
+
changeRequestId: flags["--change-request"],
|
|
354
|
+
resume: flags["--resume"] === "true",
|
|
355
|
+
});
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (command === "identity") {
|
|
359
|
+
const sub = positional[0] ?? "";
|
|
360
|
+
if (sub === "list") {
|
|
361
|
+
await (0, identity_1.runIdentityList)();
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
process.stderr.write("Usage: agentbridge identity list\n");
|
|
365
|
+
process.exit(3);
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
if (command === "status") {
|
|
369
|
+
await (0, status_1.runStatus)({
|
|
370
|
+
repair: flags["--repair"] === "true",
|
|
371
|
+
json: flags["--json"] === "true",
|
|
372
|
+
});
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (command === "precommit-check") {
|
|
376
|
+
(0, precommit_check_1.runPrecommitCheckCommand)();
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
if (command === "check") {
|
|
380
|
+
await (0, check_1.runCheck)({ json: flags["--json"] === "true" });
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (command === "next") {
|
|
384
|
+
await (0, next_1.runNext)({ json: flags["--json"] === "true" });
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (command === "health") {
|
|
388
|
+
await (0, health_1.runHealth)({ json: flags["--json"] === "true" });
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
if (command === "verify") {
|
|
392
|
+
await (0, verify_1.runVerify)(positional.join(" "), { json: flags["--json"] === "true" });
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (command === "handoff") {
|
|
396
|
+
const summary = flags["--summary"] ?? "";
|
|
397
|
+
await (0, handoff_1.runHandoff)({
|
|
398
|
+
summary,
|
|
399
|
+
risksRemaining: flags["--risks-remaining"],
|
|
400
|
+
}, { json: flags["--json"] === "true" });
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
if (command === "accept") {
|
|
404
|
+
await (0, accept_1.runAccept)({ json: flags["--json"] === "true" });
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
if (command === "done") {
|
|
408
|
+
await (0, done_1.runDone)({ json: flags["--json"] === "true" });
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
if (command === "handshake") {
|
|
412
|
+
const sub = positional[0] ?? "";
|
|
413
|
+
if (sub === "create") {
|
|
414
|
+
const domain = flags["--domain"] ?? "";
|
|
415
|
+
const action = flags["--action"] ?? "";
|
|
416
|
+
const reason = flags["--reason"] ?? "";
|
|
417
|
+
if (!domain || !action || !reason) {
|
|
418
|
+
process.stderr.write("Usage: agentbridge handshake create --domain <name> --action \"<text>\" --reason \"<text>\" [--cr <id>] [--session <id>]\n");
|
|
419
|
+
process.exit(3);
|
|
420
|
+
}
|
|
421
|
+
await (0, handshake_1.runHandshakeCreate)({
|
|
422
|
+
domain,
|
|
423
|
+
action,
|
|
424
|
+
reason,
|
|
425
|
+
changeRequestId: flags["--cr"],
|
|
426
|
+
workSessionId: flags["--session"],
|
|
427
|
+
});
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (sub === "acknowledge") {
|
|
431
|
+
await (0, handshake_1.runHandshakeAcknowledge)();
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (sub === "resolve") {
|
|
435
|
+
await (0, handshake_1.runHandshakeResolve)();
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
if (sub === "list") {
|
|
439
|
+
await (0, handshake_1.runHandshakeList)();
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
process.stderr.write("Usage: agentbridge handshake create|acknowledge|resolve|list (see agentbridge --help)\n");
|
|
443
|
+
process.exit(3);
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
if (command === "memory") {
|
|
447
|
+
const sub = positional[0] ?? "";
|
|
448
|
+
if (sub === "suggest") {
|
|
449
|
+
await (0, memory_1.runMemorySuggest)({
|
|
450
|
+
workSessionId: flags["--work-session"],
|
|
451
|
+
changeRequestId: flags["--change-request"],
|
|
452
|
+
domain: flags["--domain"],
|
|
453
|
+
compact: flags["--compact"] === "true",
|
|
454
|
+
json: flags["--json"] === "true",
|
|
455
|
+
});
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
if (sub === "apply") {
|
|
459
|
+
const scopeFlag = flags["--scope"];
|
|
460
|
+
const scope = scopeFlag === "project" || scopeFlag === "domain" || scopeFlag === "both"
|
|
461
|
+
? scopeFlag
|
|
462
|
+
: undefined;
|
|
463
|
+
await (0, memory_1.runMemoryApply)({
|
|
464
|
+
workSessionId: flags["--work-session"],
|
|
465
|
+
changeRequestId: flags["--change-request"],
|
|
466
|
+
domain: flags["--domain"],
|
|
467
|
+
scope,
|
|
468
|
+
items: flags["--items"],
|
|
469
|
+
reviewerNote: flags["--note"],
|
|
470
|
+
});
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
if (sub === "reject") {
|
|
474
|
+
await (0, memory_1.runMemoryReject)({
|
|
475
|
+
workSessionId: flags["--work-session"],
|
|
476
|
+
changeRequestId: flags["--change-request"],
|
|
477
|
+
domain: flags["--domain"],
|
|
478
|
+
reviewerNote: flags["--note"],
|
|
479
|
+
});
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
if (sub === "defer") {
|
|
483
|
+
await (0, memory_1.runMemoryDefer)({
|
|
484
|
+
workSessionId: flags["--work-session"],
|
|
485
|
+
changeRequestId: flags["--change-request"],
|
|
486
|
+
domain: flags["--domain"],
|
|
487
|
+
reviewerNote: flags["--note"],
|
|
488
|
+
});
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (sub === "revert") {
|
|
492
|
+
await (0, memory_1.runMemoryRevert)({
|
|
493
|
+
approvalAuditId: flags["--approval-audit"] ?? "",
|
|
494
|
+
reviewerNote: flags["--note"],
|
|
495
|
+
force: flags["--force"] === "true",
|
|
496
|
+
});
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
if (sub === "intake-escaped-bug") {
|
|
500
|
+
await (0, memory_1.runMemoryIntakeEscapedBug)({
|
|
501
|
+
fromFile: flags["--from-file"],
|
|
502
|
+
title: flags["--title"],
|
|
503
|
+
summary: flags["--summary"],
|
|
504
|
+
domain: flags["--domain"],
|
|
505
|
+
workSessionId: flags["--work-session"],
|
|
506
|
+
changeRequestId: flags["--change-request"],
|
|
507
|
+
reviewerNote: flags["--note"],
|
|
508
|
+
invariants: flags["--invariants"],
|
|
509
|
+
knownTraps: flags["--known-traps"],
|
|
510
|
+
futureProofRequirements: flags["--future-proof-requirements"],
|
|
511
|
+
acceptedLessons: flags["--accepted-lessons"],
|
|
512
|
+
compact: flags["--compact"] === "true",
|
|
513
|
+
});
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
process.stderr.write("Usage: agentbridge memory suggest|apply|reject|defer|revert|intake-escaped-bug (see agentbridge --help)\n");
|
|
517
|
+
process.exit(3);
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (command === "session") {
|
|
521
|
+
const sub = positional[0] ?? "";
|
|
522
|
+
if (sub === "list") {
|
|
523
|
+
await (0, session_1.runSessionList)({
|
|
524
|
+
crId: flags["--change-request"],
|
|
525
|
+
activeOnly: flags["--active"] === "true",
|
|
526
|
+
json: flags["--json"] === "true",
|
|
527
|
+
});
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
if (sub === "inspect") {
|
|
531
|
+
await (0, session_1.runSessionInspect)(positional[1] ?? "", { json: flags["--json"] === "true" });
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
if (sub === "abandon") {
|
|
535
|
+
await (0, session_1.runSessionAbandon)({
|
|
536
|
+
sessionId: flags["--session"],
|
|
537
|
+
reason: flags["--reason"] ?? "",
|
|
538
|
+
clearLocal: flags["--keep-local"] !== "true",
|
|
539
|
+
json: flags["--json"] === "true",
|
|
540
|
+
});
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
if (sub === "cleanup") {
|
|
544
|
+
await (0, session_1.runSessionCleanupStale)({
|
|
545
|
+
dryRun: flags["--dry-run"] !== "false",
|
|
546
|
+
json: flags["--json"] === "true",
|
|
547
|
+
});
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
process.stderr.write("Usage: agentbridge session list|inspect|cleanup|abandon (see agentbridge --help)\n");
|
|
551
|
+
process.exit(3);
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
if (command === "version") {
|
|
555
|
+
(0, version_1.runVersion)();
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
if (command === "doctor") {
|
|
559
|
+
process.exitCode = await (0, doctor_1.runDoctor)();
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
if (command === "bug") {
|
|
563
|
+
const sub = positional[0] ?? "";
|
|
564
|
+
if (sub === "report") {
|
|
565
|
+
await (0, bug_1.runBugReport)({
|
|
566
|
+
title: flags["--title"],
|
|
567
|
+
severity: flags["--severity"],
|
|
568
|
+
category: flags["--category"],
|
|
569
|
+
foundIn: flags["--found-in"],
|
|
570
|
+
observed: flags["--observed"],
|
|
571
|
+
expected: flags["--expected"],
|
|
572
|
+
projectId: flags["--project"],
|
|
573
|
+
workSessionId: flags["--work-session"],
|
|
574
|
+
changeRequestId: flags["--change-request"],
|
|
575
|
+
commands: flags["--commands"],
|
|
576
|
+
files: flags["--files"],
|
|
577
|
+
logs: flags["--logs"],
|
|
578
|
+
userImpact: flags["--user-impact"],
|
|
579
|
+
});
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
if (sub === "validate") {
|
|
583
|
+
await (0, bug_1.runBugValidate)({ file: flags["--file"] ?? "" });
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
process.stderr.write("Usage: agentbridge bug report|validate (see agentbridge bug --help)\n");
|
|
587
|
+
process.exit(3);
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
if (command === "autopilot") {
|
|
591
|
+
await (0, autopilot_1.runAutopilot)(positional);
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
if (command === "attention") {
|
|
595
|
+
await (0, attention_1.runAttention)(positional);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
usage();
|
|
599
|
+
}
|
|
600
|
+
if (require.main === module) {
|
|
601
|
+
void main().catch((err) => {
|
|
602
|
+
const session = (0, session_state_1.readSessionState)();
|
|
603
|
+
const cfg = (0, config_1.readConfig)();
|
|
604
|
+
(0, cli_failure_log_1.logCliFailure)(err, {
|
|
605
|
+
command: process.argv.slice(2).join(" ") || process.argv[2],
|
|
606
|
+
projectId: cfg?.projectId,
|
|
607
|
+
workSessionId: session?.serverSessionId ?? session?.id,
|
|
608
|
+
changeRequestId: session?.changeRequestId,
|
|
609
|
+
correlationId: process.env.AGENTBRIDGE_CORRELATION_ID,
|
|
610
|
+
});
|
|
611
|
+
process.stderr.write(`${(0, errors_1.renderCliError)(err)}\n`);
|
|
612
|
+
// Print full stack trace when --debug is present or DEBUG env is set
|
|
613
|
+
if ((process.argv.includes("--debug") || process.env.DEBUG) &&
|
|
614
|
+
err instanceof Error &&
|
|
615
|
+
err.stack) {
|
|
616
|
+
process.stderr.write(`\n[debug] ${err.stack}\n`);
|
|
617
|
+
}
|
|
618
|
+
// Consolidated exit codes: 1 = blocking, 2 = infra, 3 = user input
|
|
619
|
+
const view = (0, errors_1.formatCliError)(err);
|
|
620
|
+
process.exit((0, errors_1.exitCodeForCategory)(view.category));
|
|
621
|
+
});
|
|
622
|
+
}
|