@agentbridge1/cli 0.0.8 → 0.0.10

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.
@@ -1,6 +1,6 @@
1
1
  {
2
- "builtAt": "2026-06-20T05:37:34.216Z",
3
- "gitHead": "fb83b92",
4
- "sourceLatestMtime": "2026-06-20T04:44:28.305Z",
5
- "sourceLatestFile": "src/commands/setup-mcp.ts"
2
+ "builtAt": "2026-06-20T13:18:31.649Z",
3
+ "gitHead": "40b250d",
4
+ "sourceLatestMtime": "2026-06-20T13:01:45.098Z",
5
+ "sourceLatestFile": "src/commands/watch.ts"
6
6
  }
@@ -627,6 +627,7 @@ async function runLocalStart(intent) {
627
627
  agentId: "local",
628
628
  laneDomain: null,
629
629
  intent: validatedIntent,
630
+ createdBy: "user_start",
630
631
  domains: [],
631
632
  mode: "local_supervision",
632
633
  });
@@ -8,6 +8,8 @@ exports.finalizeWatchSupervision = finalizeWatchSupervision;
8
8
  exports.syncAndBuildSupervisionSnapshot = syncAndBuildSupervisionSnapshot;
9
9
  exports.renderWatchTaskScopeUsage = renderWatchTaskScopeUsage;
10
10
  exports.renderWatchStartupHeader = renderWatchStartupHeader;
11
+ exports.renderLocalWatchWaiting = renderLocalWatchWaiting;
12
+ exports.renderLocalWatchReady = renderLocalWatchReady;
11
13
  exports.buildWatchBlockingIssue = buildWatchBlockingIssue;
12
14
  exports.renderWatchBlockingIssue = renderWatchBlockingIssue;
13
15
  exports.overlayLocalChangedFilesOnSupervision = overlayLocalChangedFilesOnSupervision;
@@ -30,6 +32,7 @@ const domain_resolution_1 = require("../domain-resolution");
30
32
  const briefing_1 = require("../briefing");
31
33
  const session_1 = require("../session");
32
34
  const session_state_1 = require("../session-state");
35
+ const git_status_1 = require("../git-status");
33
36
  const watch_core_1 = require("../watch-core");
34
37
  const watcher_1 = require("../watcher");
35
38
  const server_sync_1 = require("../server-sync");
@@ -39,6 +42,7 @@ const test_runner_1 = require("../test-runner");
39
42
  const revert_crossing_1 = require("../revert-crossing");
40
43
  const local_proof_1 = require("../local-proof");
41
44
  const supervision_1 = require("../supervision");
45
+ const contract_intelligence_1 = require("../contract-intelligence");
42
46
  const contract_verdict_1 = require("../contract-verdict");
43
47
  const preflight_changed_files_1 = require("../preflight-changed-files");
44
48
  const http_1 = require("../http");
@@ -48,8 +52,8 @@ const session_state_2 = require("../session-state");
48
52
  const file_fingerprints_1 = require("../file-fingerprints");
49
53
  const start_1 = require("./start");
50
54
  const gates_1 = require("../gates");
51
- const git_status_1 = require("../git-status");
52
- Object.defineProperty(exports, "getDirtyWorkingTreeFiles", { enumerable: true, get: function () { return git_status_1.getDirtyWorkingTreeFiles; } });
55
+ const git_status_2 = require("../git-status");
56
+ Object.defineProperty(exports, "getDirtyWorkingTreeFiles", { enumerable: true, get: function () { return git_status_2.getDirtyWorkingTreeFiles; } });
53
57
  const IDLE_CLOSE_MS = 5_000;
54
58
  const CONTRACT_POLL_MS = 2_000;
55
59
  function isLocalFirstMode(cfg) {
@@ -575,6 +579,19 @@ function renderWatchStartupHeader(input) {
575
579
  "",
576
580
  ].join("\n");
577
581
  }
582
+ function renderLocalWatchWaiting() {
583
+ return [
584
+ "AgentBridge watch — live. No contract yet.",
585
+ "Waiting for: agentbridge start \"...\" or agent_hello({ intent: \"...\" })",
586
+ "",
587
+ ].join("\n");
588
+ }
589
+ function renderLocalWatchReady(session) {
590
+ if (!session.intent?.trim()) {
591
+ return renderLocalWatchWaiting();
592
+ }
593
+ return (0, contract_intelligence_1.renderLiveContractBanner)(session).replace(/^\n/, "");
594
+ }
578
595
  function renderStartupPhase(step, status) {
579
596
  const verb = status === "starting" ? "starting" : status === "done" ? "done" : "skipped";
580
597
  return `[startup] ${step}: ${verb}\n`;
@@ -1123,14 +1140,14 @@ function normalizeDirtyWorkingTreeFiles(files) {
1123
1140
  const normalized = normalizeDirtyFilePath(raw);
1124
1141
  if (!normalized || normalized.startsWith(".."))
1125
1142
  continue;
1126
- if (normalized === ".agentbridge" || normalized.startsWith(".agentbridge/"))
1143
+ if ((0, git_status_1.isAgentbridgeLocalPath)(normalized))
1127
1144
  continue;
1128
1145
  const expanded = expandDirectoryToFiles(normalized);
1129
1146
  for (const candidate of expanded) {
1130
1147
  const flat = normalizeDirtyFilePath(candidate);
1131
1148
  if (!flat || flat.startsWith(".."))
1132
1149
  continue;
1133
- if (flat === ".agentbridge" || flat.startsWith(".agentbridge/"))
1150
+ if ((0, git_status_1.isAgentbridgeLocalPath)(flat))
1134
1151
  continue;
1135
1152
  if ((0, local_proof_1.isProofNoiseFile)(flat))
1136
1153
  continue;
@@ -1283,7 +1300,7 @@ function buildStartupScopeDriftIssue(input) {
1283
1300
  async function ensureWatchRepoClean(allowDirty = false, ignoredDirtyFiles = new Set()) {
1284
1301
  if (allowDirty)
1285
1302
  return;
1286
- const dirtyFiles = filterIgnoredDirtyFiles((0, git_status_1.getDirtyWorkingTreeFiles)(), ignoredDirtyFiles);
1303
+ const dirtyFiles = normalizeDirtyWorkingTreeFiles(filterIgnoredDirtyFiles((0, git_status_2.getDirtyWorkingTreeFiles)(), ignoredDirtyFiles));
1287
1304
  if (dirtyFiles.length === 0)
1288
1305
  return;
1289
1306
  const rl = (0, promises_1.createInterface)({ input: process.stdin, output: process.stdout });
@@ -1342,7 +1359,7 @@ async function runWatchOnceFastPath(input) {
1342
1359
  // No server context (offline / unconfigured) — defer to legacy local flow.
1343
1360
  return { handled: false, hadBlockingIssue: false };
1344
1361
  }
1345
- const dirtyFiles = timing.trackSync("git_snapshot", () => normalizeDirtyWorkingTreeFiles(filterIgnoredDirtyFiles((0, git_status_1.getDirtyWorkingTreeFiles)(), ignoredDirtyFiles)));
1362
+ const dirtyFiles = timing.trackSync("git_snapshot", () => normalizeDirtyWorkingTreeFiles(filterIgnoredDirtyFiles((0, git_status_2.getDirtyWorkingTreeFiles)(), ignoredDirtyFiles)));
1346
1363
  const localState = (0, session_state_1.readSessionState)();
1347
1364
  const claimedPaths = [
1348
1365
  ...new Set([scope, ...(localState?.claimedPaths ?? [])].map((path) => path.trim()).filter(Boolean)),
@@ -1535,6 +1552,7 @@ async function runWatch(options = {}) {
1535
1552
  (0, session_state_1.writeSessionState)(localSession);
1536
1553
  }
1537
1554
  const explicitStrictMode = Boolean(taskScopeInput.task && taskScopeInput.scope);
1555
+ const localInferredMode = localFirstMode && !explicitStrictMode;
1538
1556
  if (hasActiveLocalSession && explicitStrictMode) {
1539
1557
  const activeLocalSession = localSession;
1540
1558
  if (!activeLocalSession)
@@ -1559,24 +1577,26 @@ async function runWatch(options = {}) {
1559
1577
  return;
1560
1578
  }
1561
1579
  }
1562
- const startupScope = explicitStrictMode
1563
- ? taskScopeInput.scope ?? localSession?.claimedPaths?.[0] ?? "(scope unavailable)"
1564
- : taskScopeInput.scope;
1565
- const startupTask = explicitStrictMode
1566
- ? taskScopeInput.task ?? "Current AgentBridge task"
1567
- : taskScopeInput.task ?? "Inferred from changed files/current work";
1568
- process.stdout.write(renderWatchStartupHeader({
1569
- mode: explicitStrictMode ? "explicit" : "inferred",
1570
- task: startupTask,
1571
- scope: startupScope,
1572
- currentStatus: "Starting watch runtime.",
1573
- nextGuidance: explicitStrictMode
1574
- ? "AgentBridge will enforce explicit scope and proof checks."
1575
- : "AgentBridge will classify brainstorming vs coding and infer task/scope from repo activity.",
1576
- }));
1577
- await flushStdout();
1578
- process.stdout.write(renderStartupPhase("resolving project", "starting"));
1579
- await flushStdout();
1580
+ if (!localInferredMode) {
1581
+ const startupScope = explicitStrictMode
1582
+ ? taskScopeInput.scope ?? localSession?.claimedPaths?.[0] ?? "(scope unavailable)"
1583
+ : taskScopeInput.scope;
1584
+ const startupTask = explicitStrictMode
1585
+ ? taskScopeInput.task ?? "Current AgentBridge task"
1586
+ : taskScopeInput.task ?? "Inferred from changed files/current work";
1587
+ process.stdout.write(renderWatchStartupHeader({
1588
+ mode: explicitStrictMode ? "explicit" : "inferred",
1589
+ task: startupTask,
1590
+ scope: startupScope,
1591
+ currentStatus: "Starting watch runtime.",
1592
+ nextGuidance: explicitStrictMode
1593
+ ? "AgentBridge will enforce explicit scope and proof checks."
1594
+ : "AgentBridge will classify brainstorming vs coding and infer task/scope from repo activity.",
1595
+ }));
1596
+ await flushStdout();
1597
+ process.stdout.write(renderStartupPhase("resolving project", "starting"));
1598
+ await flushStdout();
1599
+ }
1580
1600
  const hasRecoveredDomainMap = Boolean(cfg.domains && cfg.domains.length > 0);
1581
1601
  timing.trackSync("identity_resolution", () => {
1582
1602
  if (explicitStrictMode && !cfg.activeAgentId) {
@@ -1620,7 +1640,7 @@ async function runWatch(options = {}) {
1620
1640
  ...(options.executionSurfaceId ? { executionSurfaceId: options.executionSurfaceId } : {}),
1621
1641
  });
1622
1642
  }
1623
- if (!options.once) {
1643
+ if (!localInferredMode && !options.once) {
1624
1644
  try {
1625
1645
  await timing.trackAsync("project_access_check", async () => withTimeout((async () => {
1626
1646
  const requestedCr = options.changeRequestId ?? cfg.activeChangeRequestId ?? null;
@@ -1647,8 +1667,10 @@ async function runWatch(options = {}) {
1647
1667
  // If network context is unavailable, continue in local-only mode.
1648
1668
  }
1649
1669
  }
1650
- process.stdout.write(renderStartupPhase("resolving project", "done"));
1651
- await flushStdout();
1670
+ if (!localInferredMode) {
1671
+ process.stdout.write(renderStartupPhase("resolving project", "done"));
1672
+ await flushStdout();
1673
+ }
1652
1674
  // Fast path: collapse the one-shot review into a single bounded server call.
1653
1675
  // Falls through to the legacy multi-call flow when the server predates the
1654
1676
  // consolidated endpoint or no server context is available. `startingTaskAnnounced`
@@ -1744,16 +1766,18 @@ async function runWatch(options = {}) {
1744
1766
  await flushStdout();
1745
1767
  }
1746
1768
  }
1747
- else {
1769
+ else if (!localInferredMode) {
1748
1770
  process.stdout.write("[startup] session: inferred mode (will start tracking when coding begins)\n");
1749
1771
  await flushStdout();
1750
1772
  }
1751
1773
  // In daemon mode, skip interactive dirty-file prompt (treat as --allow-dirty).
1752
1774
  await timing.trackAsync("repo_clean_check", async () => ensureWatchRepoClean(Boolean(options.allowDirty) || Boolean(options.daemon), ignoredDirtyFiles));
1753
- process.stdout.write(renderStartupPhase("checking workspace", "done"));
1754
- await flushStdout();
1775
+ if (!localInferredMode) {
1776
+ process.stdout.write(renderStartupPhase("checking workspace", "done"));
1777
+ await flushStdout();
1778
+ }
1755
1779
  const domainPacketsLoaded = new Set();
1756
- if (!options.once) {
1780
+ if (!options.once && !localInferredMode) {
1757
1781
  try {
1758
1782
  const packetCtx = (0, config_1.contextFromConfig)();
1759
1783
  const projectPacket = await timing.trackAsync("project_packet_fetch", async () => withTimeout((0, server_sync_1.fetchProjectPacket)(packetCtx), WATCH_STARTUP_TIMEOUT_MS, () => new errors_1.SafeCliError({
@@ -1789,15 +1813,15 @@ async function runWatch(options = {}) {
1789
1813
  let verdictInProgress = false;
1790
1814
  const waitForContract = async () => {
1791
1815
  let session = (0, session_state_1.readSessionState)();
1792
- if (!(0, session_state_1.isActiveLocalSession)(session)) {
1793
- process.stdout.write("AgentBridge watching — waiting for contract...\n");
1816
+ if (!(0, session_state_1.hasActiveContract)(session)) {
1817
+ process.stdout.write(renderLocalWatchWaiting());
1794
1818
  await flushStdout();
1795
1819
  }
1796
- while (!(0, session_state_1.isActiveLocalSession)(session)) {
1820
+ while (!(0, session_state_1.hasActiveContract)(session)) {
1797
1821
  await new Promise((resolve) => setTimeout(resolve, CONTRACT_POLL_MS));
1798
1822
  session = (0, session_state_1.readSessionState)();
1799
1823
  }
1800
- process.stdout.write(`\nLIVE — ${session.intent ?? "(no intent)"}\n`);
1824
+ process.stdout.write((0, contract_intelligence_1.renderLiveContractBanner)(session));
1801
1825
  await flushStdout();
1802
1826
  return session;
1803
1827
  };
@@ -1926,7 +1950,7 @@ async function runWatch(options = {}) {
1926
1950
  await printVerdictAndReset();
1927
1951
  return;
1928
1952
  }
1929
- if (!(0, session_state_1.isActiveLocalSession)(state)) {
1953
+ if (!(0, session_state_1.hasActiveContract)(state)) {
1930
1954
  return;
1931
1955
  }
1932
1956
  }
@@ -2303,7 +2327,10 @@ async function runWatch(options = {}) {
2303
2327
  await handling;
2304
2328
  };
2305
2329
  const processStartupDirty = async () => {
2306
- const startupDirtyFiles = timing.trackSync("git_snapshot", () => normalizeDirtyWorkingTreeFiles(filterIgnoredDirtyFiles((0, git_status_1.getDirtyWorkingTreeFiles)(), ignoredDirtyFiles)));
2330
+ if (localInferredMode) {
2331
+ return;
2332
+ }
2333
+ const startupDirtyFiles = timing.trackSync("git_snapshot", () => normalizeDirtyWorkingTreeFiles(filterIgnoredDirtyFiles((0, git_status_2.getDirtyWorkingTreeFiles)(), ignoredDirtyFiles)));
2307
2334
  if (startupDirtyFiles.length === 0) {
2308
2335
  if (!explicitStrictMode) {
2309
2336
  process.stdout.write(`${renderBrainstormingStatus()}\n`);
@@ -2550,32 +2577,39 @@ async function runWatch(options = {}) {
2550
2577
  };
2551
2578
  let stop = null;
2552
2579
  if (!options.once) {
2553
- process.stdout.write(renderStartupPhase("starting watcher", "starting"));
2554
- await flushStdout();
2580
+ if (!localInferredMode) {
2581
+ process.stdout.write(renderStartupPhase("starting watcher", "starting"));
2582
+ await flushStdout();
2583
+ }
2555
2584
  stop = timing.trackSync("watcher_startup", () => (0, watcher_1.startWatcher)((0, node_process_1.cwd)(), (absolutePath) => {
2556
2585
  void onAbsolutePathChange(absolutePath);
2557
2586
  }));
2558
- process.stdout.write(renderStartupPhase("starting watcher", "done"));
2559
- await flushStdout();
2587
+ if (!localInferredMode) {
2588
+ process.stdout.write(renderStartupPhase("starting watcher", "done"));
2589
+ await flushStdout();
2590
+ }
2560
2591
  }
2561
- else {
2592
+ else if (!localInferredMode) {
2562
2593
  process.stdout.write(renderStartupPhase("starting watcher", "skipped"));
2563
2594
  await flushStdout();
2564
2595
  }
2565
2596
  await processStartupDirty();
2566
- process.stdout.write("[startup] ready: watch runtime is live.\n");
2567
- await flushStdout();
2568
- if (localFirstMode && !options.once) {
2569
- if (!(0, session_state_1.isActiveLocalSession)((0, session_state_1.readSessionState)())) {
2570
- await waitForContract();
2597
+ if (localInferredMode && !options.once) {
2598
+ const readySession = (0, session_state_1.readSessionState)();
2599
+ if ((0, session_state_1.hasActiveContract)(readySession)) {
2600
+ process.stdout.write(`${renderLocalWatchReady(readySession)}\n`);
2571
2601
  }
2572
2602
  else {
2573
- const active = (0, session_state_1.readSessionState)();
2574
- if (active) {
2575
- process.stdout.write(`\nLIVE — ${active.intent ?? "(no intent)"}\n`);
2576
- await flushStdout();
2577
- }
2603
+ process.stdout.write(renderLocalWatchWaiting());
2578
2604
  }
2605
+ await flushStdout();
2606
+ }
2607
+ else {
2608
+ process.stdout.write("[startup] ready: watch runtime is live.\n");
2609
+ await flushStdout();
2610
+ }
2611
+ if (localFirstMode && !options.once && !(0, session_state_1.hasActiveContract)((0, session_state_1.readSessionState)())) {
2612
+ await waitForContract();
2579
2613
  }
2580
2614
  if (options.once) {
2581
2615
  if (idleTimer)