@cirtium/acent-connect 1.1.1 → 1.1.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acent",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Recall past work, trace code changes, revisit decisions, and resume tasks with Acent.",
5
5
  "mcpServers": "./mcp-claude.json",
6
6
  "hooks": "./hooks/claude.json"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acent",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Recall past work, trace code changes, revisit decisions, and resume tasks with Acent.",
5
5
  "skills": "./skills/",
6
6
  "mcpServers": "./mcp-codex.json",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acent",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Recall past work, trace code changes, revisit decisions, and resume tasks with Acent.",
5
5
  "author": {
6
6
  "name": "Cirtium"
@@ -10,9 +10,12 @@ import {
10
10
  appliedBridgeChanges,
11
11
  bridgeFileVersions,
12
12
  changedBridgePaths,
13
+ delegateScopes,
14
+ delegateWorkspacePath,
13
15
  mismatchedBridgePaths,
14
16
  projectFileVersions,
15
17
  projectSnapshot,
18
+ withinPaths,
16
19
  } from "./bridge-workspace.mjs"
17
20
 
18
21
  export function createBridgeFinalizer({
@@ -52,6 +55,17 @@ export function createBridgeFinalizer({
52
55
  return { status: "integration_required", ids }
53
56
  const baseline = await readJson(join(jobDir, "baseline.json"), null)
54
57
  if (!baseline) return { status: "review_required", ids }
58
+ const reviewedSource = baseline.sourceFiles ?? baseline.files
59
+ const applied = appliedBridgeChanges(tasks)
60
+ if (baseline.scoped) {
61
+ const scopes = baseline.scopes ?? delegateScopes(review)
62
+ const paths = applied
63
+ .map(({ path }) => path)
64
+ .filter(
65
+ (path) => !delegateWorkspacePath(path) || !withinPaths(path, scopes)
66
+ )
67
+ if (paths.length) return { status: "review_scope_incomplete", ids, paths }
68
+ }
55
69
 
56
70
  const base = { ids: taskIds, reviewId, reviewSummary: review.summary }
57
71
  let stored = await readJson(record, null)
@@ -76,9 +90,8 @@ export function createBridgeFinalizer({
76
90
  paths,
77
91
  checkedAt,
78
92
  })
79
- const applied = appliedBridgeChanges(tasks)
80
93
  const readStalePaths = async () =>
81
- changedBridgePaths(baseline.files, await bridgeFileVersions(folder))
94
+ changedBridgePaths(reviewedSource, await bridgeFileVersions(folder))
82
95
  async function checkOriginal() {
83
96
  const stale = await readStalePaths()
84
97
  if (stale.length) return { status: "review_stale", paths: stale }
@@ -168,7 +181,7 @@ export function createBridgeFinalizer({
168
181
  if (!(await readJson(requestFile, null))) {
169
182
  await rm(attemptDir, { recursive: true, force: true })
170
183
  await projectSnapshot(folder, work, async (snapshot) => {
171
- const changed = changedBridgePaths(baseline.files, snapshot.files)
184
+ const changed = changedBridgePaths(reviewedSource, snapshot.files)
172
185
  if (!changed.length)
173
186
  await writeJson(requestFile, {
174
187
  cwd: work,
@@ -16,6 +16,7 @@ import {
16
16
  changedBridgePaths,
17
17
  checkpointBridgeWorkspace,
18
18
  cloneBridgeSnapshot,
19
+ delegateWorkspacePath,
19
20
  inspectBridgeChanges,
20
21
  mismatchedBridgePaths,
21
22
  projectFileVersions,
@@ -46,6 +47,7 @@ const resumableRepairStates = new Set([
46
47
  "model_unavailable",
47
48
  "login_required",
48
49
  "not_installed",
50
+ "workspace_untrusted",
49
51
  ])
50
52
  const terminal = new Set([
51
53
  "verified",
@@ -117,11 +119,15 @@ function cycleInput(args, targets, isId) {
117
119
  throw new Error(
118
120
  "Select a repair model and one to four independent review models from distinct eligible families."
119
121
  )
122
+ const readPaths = args.readPaths ?? []
120
123
  if (
121
124
  !Array.isArray(args.paths) ||
122
125
  !args.paths.length ||
123
126
  args.paths.length > 64 ||
124
- !args.paths.every(workspacePath)
127
+ !args.paths.every(delegateWorkspacePath) ||
128
+ !Array.isArray(readPaths) ||
129
+ readPaths.length > 64 ||
130
+ !readPaths.every(delegateWorkspacePath)
125
131
  )
126
132
  throw new Error("Select one to 64 project-relative paths for refinement.")
127
133
  if (
@@ -152,6 +158,7 @@ function cycleInput(args, targets, isId) {
152
158
  acceptance: args.acceptance,
153
159
  context: args.context,
154
160
  paths: [...new Set(args.paths)].sort(),
161
+ ...(readPaths.length ? { readPaths: [...new Set(readPaths)].sort() } : {}),
155
162
  originModel: args.originModel,
156
163
  repair: pick(args.repair),
157
164
  reviewers: reviewers.map(pick),
@@ -505,6 +512,7 @@ export function createBridgeRefinement({
505
512
  .filter(Boolean)
506
513
  .join("\n"),
507
514
  paths: cycle.input.paths,
515
+ readPaths: cycle.input.readPaths,
508
516
  dependsOn: cycle.round === 1 ? cycle.input.dependsOn : [],
509
517
  automatic: cycle.input.automatic,
510
518
  },
@@ -518,7 +526,7 @@ export function createBridgeRefinement({
518
526
  const families = new Set()
519
527
  for (const [index, job] of jobs.entries()) {
520
528
  const baseline = await getBaseline(job.id)
521
- if (baseline?.head !== cycle.stage.head) {
529
+ if ((baseline?.sourceHead ?? baseline?.head) !== cycle.stage.head) {
522
530
  cycle.waiting.push({
523
531
  id: job.id,
524
532
  status: "review_snapshot_unavailable",
@@ -595,6 +603,7 @@ export function createBridgeRefinement({
595
603
  .filter(Boolean)
596
604
  .join("\n"),
597
605
  paths: cycle.input.paths,
606
+ readPaths: cycle.input.readPaths,
598
607
  automatic: cycle.input.automatic,
599
608
  },
600
609
  current,
@@ -2,7 +2,7 @@ import { spawn } from "node:child_process"
2
2
  import { createHash } from "node:crypto"
3
3
  import { stat } from "node:fs/promises"
4
4
  import { homedir } from "node:os"
5
- import { join } from "node:path"
5
+ import { delimiter, isAbsolute, join } from "node:path"
6
6
  import { createInterface } from "node:readline"
7
7
  import { hostExecutableCandidates } from "./host-executables.mjs"
8
8
 
@@ -98,7 +98,12 @@ export function runProcess(
98
98
  stderr = (stderr + chunk).slice(-16384)
99
99
  })
100
100
  child.on("error", (error) => {
101
- failure = error.code === "ENOENT" ? "not_installed" : "failed"
101
+ failure =
102
+ error.code === "ENOENT"
103
+ ? "not_installed"
104
+ : ["EACCES", "EPERM"].includes(error.code)
105
+ ? "permission_denied"
106
+ : "failed"
102
107
  })
103
108
  if (onSpawn) {
104
109
  child.once("spawn", () => {
@@ -128,6 +133,11 @@ const commands = {
128
133
  Antigravity: "agy",
129
134
  }
130
135
 
136
+ export function bridgeExecutableCandidates(tool) {
137
+ if (!bridgeTargets.includes(tool)) throw new Error("Unknown Bridge tool.")
138
+ return hostExecutableCandidates(tool, commands[tool])
139
+ }
140
+
131
141
  export function bridgeGitEnvironment() {
132
142
  const env = { ...process.env }
133
143
  for (const key of Object.keys(env)) {
@@ -142,16 +152,41 @@ export function bridgeGitEnvironment() {
142
152
  }
143
153
 
144
154
  async function runHost(tool, args, options, run) {
145
- const command = commands[tool]
146
- let result = await run(command, args, options)
147
- if (result.failure !== "not_installed") return result
148
- for (const candidate of (await hostExecutableCandidates(tool, command)).slice(
149
- 1
150
- )) {
151
- result = await run(candidate, args, options)
152
- if (result.failure !== "not_installed") break
155
+ const candidates = await bridgeExecutableCandidates(tool)
156
+ const path = (options.env?.PATH ?? process.env.PATH ?? "")
157
+ .split(delimiter)
158
+ .filter(isAbsolute)
159
+ if (process.platform === "darwin")
160
+ path.push("/opt/homebrew/bin", "/usr/local/bin", "/opt/local/bin")
161
+ const executables =
162
+ run === runProcess && process.platform !== "win32"
163
+ ? candidates.flatMap((candidate) =>
164
+ isAbsolute(candidate)
165
+ ? [candidate]
166
+ : path.map((base) => join(base, candidate))
167
+ )
168
+ : candidates
169
+ const hostOptions =
170
+ run === runProcess && process.platform === "darwin"
171
+ ? {
172
+ ...options,
173
+ env: {
174
+ ...(options.env ?? process.env),
175
+ PATH: [...new Set(path)].join(delimiter),
176
+ },
177
+ }
178
+ : options
179
+ let failure = "not_installed"
180
+ for (const executable of new Set(executables)) {
181
+ const result = await run(executable, args, hostOptions)
182
+ if (result.failure === "not_installed") continue
183
+ if (result.failure === "permission_denied") {
184
+ failure = result.failure
185
+ continue
186
+ }
187
+ return { ...result, executable, env: hostOptions.env }
153
188
  }
154
- return result
189
+ return { failure }
155
190
  }
156
191
 
157
192
  async function claudeModelList(cwd, run) {
@@ -355,7 +390,15 @@ export async function readBridgeQuota(tool, cwd, run = runProcess) {
355
390
  return { accountKey, checkedAt: Date.now(), windows }
356
391
  }
357
392
 
358
- export async function discoverBridgeTarget(tool, cwd, run = runProcess) {
393
+ const authenticationRequired =
394
+ /not (?:logged in|authenticated)|authentication required|login required/i
395
+
396
+ export async function discoverBridgeTarget(
397
+ tool,
398
+ cwd,
399
+ run = runProcess,
400
+ onExecutable
401
+ ) {
359
402
  const statusArgs = {
360
403
  Codex: ["login", "status"],
361
404
  "Claude Code": ["auth", "status"],
@@ -364,12 +407,14 @@ export async function discoverBridgeTarget(tool, cwd, run = runProcess) {
364
407
  }[tool]
365
408
  const result = await runHost(tool, statusArgs, { cwd }, run)
366
409
  if (result.failure) return { tool, status: result.failure, models: [] }
410
+ onExecutable?.(result.executable)
411
+ const runSelected = (_command, args, options) =>
412
+ run(result.executable, args, {
413
+ ...options,
414
+ ...(result.env ? { env: result.env } : {}),
415
+ })
367
416
  const diagnostics = result.stdout + "\n" + result.stderr
368
- if (
369
- /not (?:logged in|authenticated)|authentication required|login required/i.test(
370
- diagnostics
371
- )
372
- ) {
417
+ if (authenticationRequired.test(diagnostics)) {
373
418
  return { tool, status: "login_required", models: [] }
374
419
  }
375
420
  if (tool === "Claude Code") {
@@ -383,7 +428,7 @@ export async function discoverBridgeTarget(tool, cwd, run = runProcess) {
383
428
  return { tool, status: "login_required", models: [] }
384
429
  if (!account.loggedIn || result.code !== 0)
385
430
  return { tool, status: "unavailable", models: [] }
386
- const models = await claudeModelList(cwd, run)
431
+ const models = await claudeModelList(cwd, runSelected)
387
432
  return {
388
433
  tool,
389
434
  status: "ready",
@@ -396,23 +441,40 @@ export async function discoverBridgeTarget(tool, cwd, run = runProcess) {
396
441
  }
397
442
  }
398
443
  if (result.code !== 0) return { tool, status: "unavailable", models: [] }
399
- const codex = tool === "Codex" ? await codexInfo(run, cwd) : undefined
444
+ const codex = tool === "Codex" ? await codexInfo(runSelected, cwd) : undefined
445
+ const cursorModels =
446
+ tool === "Cursor" ? await runSelected(null, ["models"], { cwd }) : undefined
447
+ let modelCatalogFailure = cursorModels?.failure
448
+ if (cursorModels && !modelCatalogFailure) {
449
+ const diagnostics = `${cursorModels.stdout}\n${cursorModels.stderr}`
450
+ if (authenticationRequired.test(diagnostics))
451
+ modelCatalogFailure = "login_required"
452
+ else if (cursorModels.code !== 0) modelCatalogFailure = "failed"
453
+ }
400
454
  const ids = codex
401
455
  ? codex.models
402
456
  : tool === "Antigravity"
403
457
  ? modelRows(result.stdout)
404
- : modelRows((await runHost(tool, ["models"], { cwd }, run)).stdout)
458
+ : !modelCatalogFailure
459
+ ? modelRows(cursorModels?.stdout ?? "")
460
+ : []
405
461
  return {
406
462
  tool,
407
- status: tool === "Antigravity" && !ids.length ? "unverified" : "ready",
463
+ status:
464
+ modelCatalogFailure === "login_required"
465
+ ? "login_required"
466
+ : tool === "Antigravity" && !ids.length
467
+ ? "unverified"
468
+ : "ready",
408
469
  models: ids.map((id) => ({ id, family: modelFamily(id) ?? null })),
409
470
  modelCatalog: ids.length ? "available" : "unverified",
471
+ ...(modelCatalogFailure ? { modelCatalogFailure } : {}),
410
472
  accountKey: codex?.accountKey,
411
473
  }
412
474
  }
413
475
 
414
476
  export async function executeBridgeTarget(
415
- { tool, model, readOnly, cwd, prompt, signal, onSpawn },
477
+ { tool, model, readOnly, managedWorkspace, cwd, prompt, signal, onSpawn },
416
478
  run = runProcess
417
479
  ) {
418
480
  const args = {
@@ -437,6 +499,7 @@ export async function executeBridgeTarget(
437
499
  Cursor: [
438
500
  "--output-format",
439
501
  "json",
502
+ ...(managedWorkspace ? ["--trust"] : []),
440
503
  ...(readOnly ? ["--mode=ask"] : []),
441
504
  ...(model ? ["--model", model] : []),
442
505
  "-p",
@@ -538,6 +601,8 @@ export async function executeBridgeTarget(
538
601
  payload.response ??
539
602
  (typeof payload.result === "string" ? payload.result : undefined)
540
603
  usage = payload.usage
604
+ const reportedModel = payload.model ?? event.model
605
+ if (typeof reportedModel === "string") actualModel = reportedModel
541
606
  if (
542
607
  event.is_error ||
543
608
  payload.is_error ||
@@ -553,7 +618,13 @@ export async function executeBridgeTarget(
553
618
  // A non-JSON response cannot verify that a delegated turn completed.
554
619
  }
555
620
  }
556
- const diagnostics = String(error ?? "") + "\n" + result.stderr
621
+ const diagnostics = [
622
+ error && (typeof error === "string" ? error : JSON.stringify(error)),
623
+ result.stderr,
624
+ result.code !== 0 ? result.stdout : "",
625
+ ]
626
+ .filter(Boolean)
627
+ .join("\n")
557
628
  let failure = result.failure
558
629
  if (!failure && (result.code !== 0 || error || typeof summary !== "string")) {
559
630
  if (
@@ -575,11 +646,13 @@ export async function executeBridgeTarget(
575
646
  )
576
647
  failure = "login_required"
577
648
  else if (
578
- /model.*(?:unavailable|not found|not supported|access denied)|unknown model/i.test(
649
+ /(?:model|variant).*(?:unavailable|not available|not enabled|not found|not supported|access denied)|unknown model|does not have access to (?:this |the )?model/i.test(
579
650
  diagnostics
580
651
  )
581
652
  )
582
653
  failure = "model_unavailable"
654
+ else if (/workspace trust required|untrusted workspace/i.test(diagnostics))
655
+ failure = "workspace_untrusted"
583
656
  else failure = "failed"
584
657
  }
585
658
  const tokens = Object.fromEntries(
@@ -595,9 +668,19 @@ export async function executeBridgeTarget(
595
668
  ],
596
669
  ].filter(([, value]) => Number.isSafeInteger(value) && value >= 0)
597
670
  )
671
+ let failureCode
672
+ if (failure === "failed" && Number.isInteger(result.code)) {
673
+ if (result.code !== 0) failureCode = "cli_exit_nonzero"
674
+ else if (!error && typeof summary !== "string")
675
+ failureCode = "invalid_cli_output"
676
+ }
598
677
  return {
599
678
  failure,
600
- summary: typeof summary === "string" ? summary.slice(0, 16000) : undefined,
679
+ ...(failureCode ? { failureCode } : {}),
680
+ summary:
681
+ !error && typeof summary === "string"
682
+ ? summary.slice(0, 16000)
683
+ : undefined,
601
684
  actualModel,
602
685
  rateLimitResetAt,
603
686
  ...(Object.keys(tokens).length ? { tokens } : {}),
@@ -36,6 +36,25 @@ export function workspacePath(path) {
36
36
  )
37
37
  }
38
38
 
39
+ export function delegateWorkspacePath(path) {
40
+ return (
41
+ workspacePath(path) &&
42
+ !path.split("/").some((part) =>
43
+ /^(?:\.(?:agents?|antigravity|claude|claude\.json|codex|cursor|cursorrules|gemini|vscode)|\.?mcp\.json)$/i.test(
44
+ part
45
+ )
46
+ )
47
+ )
48
+ }
49
+
50
+ export const withinPaths = (path, scopes) =>
51
+ scopes.some((scope) => path === scope || path.startsWith(scope + "/"))
52
+
53
+ export function delegateScopes({ paths = [], readPaths = [], dependencyPaths = [] }) {
54
+ const scopes = [...paths, ...readPaths]
55
+ return scopes.length ? scopes : dependencyPaths
56
+ }
57
+
39
58
  export function pathsOverlap(left, right) {
40
59
  if (process.platform === "darwin" || process.platform === "win32") {
41
60
  left = left.normalize("NFC").toLowerCase()
@@ -177,9 +196,7 @@ export async function bridgeReviewDiff(folder, scopes, from, to) {
177
196
  .then((value) => value.trim())
178
197
  .catch(() => null))
179
198
  const relevant = (path) =>
180
- workspacePath(path) &&
181
- (!scopes.length ||
182
- scopes.some((scope) => path === scope || path.startsWith(scope + "/")))
199
+ delegateWorkspacePath(path) && (!scopes.length || withinPaths(path, scopes))
183
200
  const untracked = !from
184
201
  ? (head
185
202
  ? (
@@ -244,13 +261,26 @@ export async function bridgeReviewDiff(folder, scopes, from, to) {
244
261
  .join("\n")
245
262
  }
246
263
 
247
- export async function projectSnapshot(folder, work, saveBaseline) {
264
+ export async function projectSnapshot(
265
+ folder,
266
+ work,
267
+ saveBaseline,
268
+ { scopes, trackSource = false } = {}
269
+ ) {
248
270
  const paths = await projectFiles(folder)
249
271
  const baseline = Object.create(null)
272
+ const sourceFiles = trackSource ? Object.create(null) : undefined
250
273
  let bytes = 0
251
274
  let fileCount = 0
252
275
  await mkdir(work, { recursive: true, mode: 0o700 })
253
276
  for (const path of paths) {
277
+ if (scopes && (!delegateWorkspacePath(path) || !withinPaths(path, scopes))) {
278
+ if (sourceFiles) {
279
+ const version = await fileVersion(folder, path)
280
+ if (version && version !== "unsupported") sourceFiles[path] = version
281
+ }
282
+ continue
283
+ }
254
284
  const source = join(folder, path)
255
285
  const canonical = await realpath(source).catch((error) => {
256
286
  if (error.code === "ENOENT" || error.code === "ENOTDIR") return null
@@ -271,9 +301,38 @@ export async function projectSnapshot(folder, work, saveBaseline) {
271
301
  await mkdir(dirname(destination), { recursive: true })
272
302
  await copyFile(source, destination, constants.COPYFILE_FICLONE)
273
303
  baseline[path] = await fileVersion(work, path)
304
+ if (sourceFiles) sourceFiles[path] = baseline[path]
274
305
  }
275
306
  await initBridgeGit(work)
276
- await saveBaseline(await checkpointBridgeWorkspace(work, { files: baseline }))
307
+ await saveBaseline({
308
+ ...(await checkpointBridgeWorkspace(work, { files: baseline })),
309
+ ...(scopes ? { scoped: true, scopes } : {}),
310
+ ...(sourceFiles ? { sourceFiles } : {}),
311
+ })
312
+ }
313
+
314
+ export async function checkDelegateWorkspace(work, scopes) {
315
+ const directory = await lstat(work).catch((error) => {
316
+ if (error.code === "ENOENT" || error.code === "ENOTDIR") return null
317
+ throw error
318
+ })
319
+ if (!directory?.isDirectory()) return false
320
+ for (const path of await projectFiles(work, true)) {
321
+ const file = join(work, path)
322
+ const info = await lstat(file).catch((error) => {
323
+ if (error.code === "ENOENT" || error.code === "ENOTDIR") return null
324
+ throw error
325
+ })
326
+ if (
327
+ info &&
328
+ (!info.isFile() ||
329
+ !delegateWorkspacePath(path) ||
330
+ (scopes && !withinPaths(path, scopes)) ||
331
+ (await realpath(file)) !== file)
332
+ )
333
+ return false
334
+ }
335
+ return true
277
336
  }
278
337
 
279
338
  async function initBridgeGit(work) {
@@ -23,12 +23,14 @@ import {
23
23
  import {
24
24
  applyVersionedBridgePatch,
25
25
  bridgeReviewDiff,
26
- cloneBridgeSnapshot,
26
+ checkDelegateWorkspace,
27
+ delegateScopes,
28
+ delegateWorkspacePath,
27
29
  inspectBridgeChanges,
28
30
  mismatchedBridgePaths,
29
31
  pathsOverlap,
30
32
  projectSnapshot,
31
- workspacePath,
33
+ withinPaths,
32
34
  } from "./bridge-workspace.mjs"
33
35
  import {
34
36
  bridgeAccountRevision,
@@ -145,7 +147,16 @@ export const bridgeTools = [
145
147
  ),
146
148
  paths: {
147
149
  type: "array",
148
- items: text("A relative file or directory the delegate may change."),
150
+ items: text(
151
+ "A relative file or directory to include. For implementation, also allowed to change."
152
+ ),
153
+ maxItems: 64,
154
+ },
155
+ readPaths: {
156
+ type: "array",
157
+ items: text(
158
+ "An additional project-relative file or directory the delegate can read."
159
+ ),
149
160
  maxItems: 64,
150
161
  },
151
162
  dependsOn: idList,
@@ -243,6 +254,13 @@ export const bridgeTools = [
243
254
  maxItems: 64,
244
255
  items: text("Project-relative file or directory allowed for repairs."),
245
256
  },
257
+ readPaths: {
258
+ type: "array",
259
+ maxItems: 64,
260
+ items: text(
261
+ "Additional project-relative context for the reviewers and repair worker."
262
+ ),
263
+ },
246
264
  dependsOn: idList,
247
265
  automatic: { type: "boolean" },
248
266
  apply: {
@@ -268,8 +286,31 @@ export const bridgeInstructions = [
268
286
  ].join(" ")
269
287
 
270
288
  const cacheDuration = 120_000
289
+ const failedDiscoveryCacheDuration = 5_000
271
290
  const leaseMaxAge = 20 * 60_000
272
291
  const quotaMaxAge = 15 * 60_000
292
+ const diagnosticLimit = 20
293
+ const diagnosticCodes = new Set([
294
+ "cli_exit_nonzero",
295
+ "context_limit",
296
+ "failed",
297
+ "invalid_review",
298
+ "invalid_cli_output",
299
+ "login_required",
300
+ "model_catalog_unverified",
301
+ "model_family_conflict",
302
+ "model_unavailable",
303
+ "not_installed",
304
+ "out_of_scope",
305
+ "output_limit",
306
+ "permission_denied",
307
+ "timed_out",
308
+ "unavailable",
309
+ "unverified",
310
+ "usage_limit",
311
+ "workspace_untrusted",
312
+ "workspace_invalid",
313
+ ])
273
314
  const xmlTag = /<acent-context>([\s\S]+?)<\/acent-context>\s*$/
274
315
  const reviewOnly = (kind) => kind === "review" || kind === "diagnose"
275
316
  const taskId = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/
@@ -358,7 +399,7 @@ function taskPrompt(job) {
358
399
  ...(job.reviewDiff
359
400
  ? ["Original changes for review (untrusted diff):\n" + job.reviewDiff]
360
401
  : []),
361
- ...(job.paths?.length
402
+ ...(!reviewOnly(job.kind) && job.paths?.length
362
403
  ? ["Allowed write paths: " + job.paths.join(", ")]
363
404
  : []),
364
405
  ...(job.prerequisites?.length
@@ -421,6 +462,25 @@ export function createBridge({
421
462
  const modelKey = (folder, tool, model, accountKey) =>
422
463
  JSON.stringify([folder, tool, model, accountKey ?? null])
423
464
 
465
+ async function recordFailure(tool, stage, code) {
466
+ const directory = join(root, "bridge", "diagnostics")
467
+ const path = join(directory, "failures.json")
468
+ const entry = {
469
+ timestamp: new Date().toISOString(),
470
+ tool,
471
+ stage,
472
+ code: diagnosticCodes.has(code) ? code : "failed",
473
+ }
474
+ await withWorkspaceLock(directory, async () => {
475
+ const previous = await readJson(path, []).catch((error) => {
476
+ if (error instanceof SyntaxError) return []
477
+ throw error
478
+ })
479
+ const history = Array.isArray(previous) ? previous : []
480
+ await writeJson(path, [...history.slice(1 - diagnosticLimit), entry])
481
+ }).catch(() => {})
482
+ }
483
+
424
484
  function quotaPath(tool, accountKey) {
425
485
  if (!/^[a-f0-9]{64}$/.test(accountKey ?? "")) return
426
486
  return join(
@@ -462,13 +522,28 @@ export function createBridge({
462
522
  prior &&
463
523
  prior.revision === revision &&
464
524
  Date.now() - prior.at < cacheDuration
465
- )
466
- return prior.result
467
- const result = discover(tool, folder).catch(() => ({
468
- tool,
469
- status: "unavailable",
470
- models: [],
471
- }))
525
+ ) {
526
+ const target = await prior.result
527
+ if (
528
+ (target.status === "ready" && target.modelCatalog !== "unverified") ||
529
+ Date.now() - prior.at < failedDiscoveryCacheDuration
530
+ )
531
+ return target
532
+ if (catalog.get(key) !== prior) return catalog.get(key)?.result ?? target
533
+ }
534
+ const result = discover(tool, folder)
535
+ .catch(() => ({ tool, status: "unavailable", models: [] }))
536
+ .then(async (target) => {
537
+ if (target.modelCatalog === "unverified")
538
+ await recordFailure(
539
+ tool,
540
+ "model_discovery",
541
+ target.modelCatalogFailure ?? "model_catalog_unverified"
542
+ )
543
+ else if (target.status !== "ready")
544
+ await recordFailure(tool, "target_status", target.status)
545
+ return target
546
+ })
472
547
  catalog.set(key, { at: Date.now(), revision, result })
473
548
  return result
474
549
  }
@@ -514,6 +589,9 @@ export function createBridge({
514
589
  tool: item.tool,
515
590
  status: item.status,
516
591
  modelCatalog: item.modelCatalog,
592
+ ...(item.modelCatalogFailure
593
+ ? { modelCatalogFailure: item.modelCatalogFailure }
594
+ : {}),
517
595
  remainingQuota:
518
596
  item.status === "ready"
519
597
  ? await cachedQuota(item)
@@ -592,6 +670,8 @@ export function createBridge({
592
670
  if (prepare && job.dependsOn?.length) {
593
671
  const blocked = []
594
672
  const prerequisites = []
673
+ const dependencyPaths = new Set()
674
+ const requestedScopes = delegateScopes(job)
595
675
  for (const id of job.dependsOn) {
596
676
  const dependency = await readJson(
597
677
  join(projectDir, id, "job.json"),
@@ -604,11 +684,25 @@ export function createBridge({
604
684
  ) {
605
685
  blocked.push({ id, status: state })
606
686
  } else {
607
- const paths = (dependency.changes ?? [])
608
- .map((change) => change.path)
609
- .join(", ")
610
- .slice(0, 1200)
687
+ const changedPaths = (dependency.changes ?? []).map(
688
+ ({ path }) => path
689
+ )
690
+ const visiblePaths = changedPaths.filter(
691
+ (path) =>
692
+ delegateWorkspacePath(path) &&
693
+ (!requestedScopes.length || withinPaths(path, requestedScopes))
694
+ )
695
+ for (const path of visiblePaths) dependencyPaths.add(path)
696
+ const paths = visiblePaths.join(", ").slice(0, 1200)
697
+ const earlierScopes = delegateScopes(dependency)
698
+ const includeSummary =
699
+ !requestedScopes.length ||
700
+ (earlierScopes.length > 0 &&
701
+ earlierScopes.every((path) =>
702
+ withinPaths(path, requestedScopes)
703
+ ))
611
704
  const patch =
705
+ visiblePaths.length === changedPaths.length &&
612
706
  dependency.patchBytes && dependency.patchBytes <= 3500
613
707
  ? await readFile(
614
708
  join(projectDir, id, "changes.patch"),
@@ -617,8 +711,10 @@ export function createBridge({
617
711
  : ""
618
712
  prerequisites.push(
619
713
  [
620
- dependency.task.slice(0, 600),
621
- (dependency.summary || "").slice(0, 1200),
714
+ includeSummary ? dependency.task.slice(0, 600) : "",
715
+ includeSummary
716
+ ? (dependency.summary || "").slice(0, 1200)
717
+ : "",
622
718
  paths ? "Changed paths: " + paths : "",
623
719
  patch,
624
720
  ]
@@ -629,7 +725,8 @@ export function createBridge({
629
725
  }
630
726
  if (blocked.length)
631
727
  return { status: "waiting_for_dependencies", dependencies: blocked }
632
- job.prerequisites = prerequisites
728
+ job.prerequisites = prerequisites.filter(Boolean)
729
+ job.dependencyPaths = [...dependencyPaths]
633
730
  }
634
731
  const current = await leases(coordination)
635
732
  if (
@@ -676,6 +773,7 @@ export function createBridge({
676
773
  startedAt: lease.startedAt,
677
774
  finishedAt: undefined,
678
775
  lastRunTokens: undefined,
776
+ lastRunErrorCode: undefined,
679
777
  remainingQuota: undefined,
680
778
  })
681
779
  await writeJson(join(coordination, "active.json"), [...current, lease])
@@ -704,16 +802,23 @@ export function createBridge({
704
802
  if (prepare) {
705
803
  await cancelled()
706
804
  if (abort.signal.aborted) throw abort.signal.reason
707
- if (snapshot) {
708
- await cloneBridgeSnapshot(snapshot.work, work)
709
- await writeJson(baselineFile, snapshot.baseline)
710
- } else {
711
- if (reviewOnly(job.kind))
712
- job.reviewDiff = await bridgeReviewDiff(folder, job.paths)
713
- await projectSnapshot(folder, work, (baseline) =>
714
- writeJson(baselineFile, baseline)
715
- )
716
- }
805
+ const scopes = delegateScopes(job)
806
+ if (!snapshot && reviewOnly(job.kind) && scopes.length)
807
+ job.reviewDiff = await bridgeReviewDiff(folder, scopes)
808
+ await projectSnapshot(
809
+ snapshot?.work ?? folder,
810
+ work,
811
+ (baseline) =>
812
+ writeJson(baselineFile, {
813
+ ...baseline,
814
+ ...(snapshot ? { sourceHead: snapshot.baseline.head } : {}),
815
+ }),
816
+ {
817
+ scopes,
818
+ trackSource:
819
+ !snapshot && reviewOnly(job.kind) && Boolean(job.dependsOn?.length),
820
+ }
821
+ )
717
822
  await updateLease(coordination, attempt, (entries, key) =>
718
823
  entries.map((item) =>
719
824
  item.attempt === key ? { ...item, preparing: false } : item
@@ -722,14 +827,25 @@ export function createBridge({
722
827
  }
723
828
  job.phase = "executing"
724
829
  await writeJson(record, job)
725
- const target = await getTarget(job.tool, folder)
830
+ const baseline = await readJson(baselineFile, null)
831
+ const invalidWorkspace =
832
+ baseline?.scoped &&
833
+ !prepare &&
834
+ !(await checkDelegateWorkspace(
835
+ work,
836
+ baseline.scopes ?? delegateScopes(job)
837
+ ))
838
+ const target = invalidWorkspace ? {} : await getTarget(job.tool, folder)
726
839
  await cancelled()
727
- const result = abort.signal.aborted
728
- ? { failure: "cancelled" }
729
- : await execute({
840
+ let result
841
+ if (abort.signal.aborted) result = { failure: "cancelled" }
842
+ else if (invalidWorkspace) result = { failure: "workspace_invalid" }
843
+ else
844
+ result = await execute({
730
845
  tool: job.tool,
731
846
  model: job.model,
732
847
  readOnly: reviewOnly(job.kind),
848
+ managedWorkspace: baseline?.scoped === true,
733
849
  cwd: work,
734
850
  prompt: taskPrompt(job),
735
851
  signal: abort.signal,
@@ -758,18 +874,31 @@ export function createBridge({
758
874
  )
759
875
  job.status = "model_family_conflict"
760
876
  job.lastRunTokens = result.tokens
877
+ job.lastRunErrorCode = result.failureCode
761
878
  job.remainingQuota = { status: "unknown" }
762
879
  job.rateLimitResetAt = result.rateLimitResetAt
763
- const baseline = await readJson(baselineFile, null)
764
- if (baseline) {
880
+ if (invalidWorkspace) {
881
+ job.patchBytes = 0
882
+ job.changes = []
883
+ job.summary =
884
+ "Restart the Bridge task to prepare a clean, scoped workspace."
885
+ } else if (baseline) {
765
886
  const changes = await inspectBridgeChanges(work, baseline, job.paths)
887
+ const restrictedPaths = baseline.scoped
888
+ ? changes.changes
889
+ .map(({ path }) => path)
890
+ .filter((path) => !delegateWorkspacePath(path))
891
+ : []
892
+ const violations = [
893
+ ...new Set([...changes.violations, ...restrictedPaths]),
894
+ ]
766
895
  if (
767
- changes.violations.length ||
896
+ violations.length ||
768
897
  (reviewOnly(job.kind) && changes.changes.length)
769
898
  ) {
770
899
  job.status = "out_of_scope"
771
- job.violations = changes.violations.length
772
- ? changes.violations
900
+ job.violations = violations.length
901
+ ? violations
773
902
  : changes.changes.map((change) => change.path)
774
903
  job.patchBytes = 0
775
904
  job.changes = []
@@ -832,6 +961,20 @@ export function createBridge({
832
961
  job.summary = error.message
833
962
  } finally {
834
963
  clearInterval(watcher)
964
+ if (
965
+ !["cancelled", "completed", "needs_context", "no_changes"].includes(
966
+ job.status === "failed"
967
+ ? job.lastRunErrorCode ?? job.status
968
+ : job.status
969
+ )
970
+ )
971
+ await recordFailure(
972
+ job.tool,
973
+ job.phase === "executing"
974
+ ? "task_execution"
975
+ : "workspace_preparation",
976
+ job.status
977
+ )
835
978
  job.phase = undefined
836
979
  job.finishedAt = Date.now()
837
980
  await withWorkspaceLock(coordination, async () => {
@@ -1144,11 +1287,15 @@ export function createBridge({
1144
1287
  )
1145
1288
  }
1146
1289
  const paths = args.paths ?? []
1290
+ const readPaths = args.readPaths ?? []
1147
1291
  const dependsOn = args.dependsOn ?? []
1148
1292
  if (
1149
1293
  !Array.isArray(paths) ||
1150
1294
  paths.length > 64 ||
1151
- !paths.every(workspacePath)
1295
+ !paths.every(delegateWorkspacePath) ||
1296
+ !Array.isArray(readPaths) ||
1297
+ readPaths.length > 64 ||
1298
+ !readPaths.every(delegateWorkspacePath)
1152
1299
  )
1153
1300
  throw new Error(
1154
1301
  "Use relative project file or directory paths for the Bridge scope."
@@ -1181,6 +1328,7 @@ export function createBridge({
1181
1328
  acceptance: args.acceptance,
1182
1329
  context: args.context,
1183
1330
  paths: [...new Set(paths)].sort(),
1331
+ ...(readPaths.length ? { readPaths: [...new Set(readPaths)].sort() } : {}),
1184
1332
  dependsOn,
1185
1333
  automatic: args.automatic === true,
1186
1334
  history: [],
@@ -1214,7 +1362,7 @@ export function createBridge({
1214
1362
  return available.status === "ready"
1215
1363
  ? { ...available, status: "selection_unavailable" }
1216
1364
  : available
1217
- if (job.automatic && !reviewOnly(job.kind) && !paths.length)
1365
+ if (!reviewOnly(job.kind) && !paths.length)
1218
1366
  return { status: "write_scope_required" }
1219
1367
  return start(job, folder, projectDir, coordination, true)
1220
1368
  }
@@ -1251,6 +1399,7 @@ export function createBridge({
1251
1399
  question,
1252
1400
  patchBytes,
1253
1401
  lastRunTokens,
1402
+ lastRunErrorCode,
1254
1403
  remainingQuota,
1255
1404
  rateLimitResetAt,
1256
1405
  violations,
@@ -1276,6 +1425,7 @@ export function createBridge({
1276
1425
  violations,
1277
1426
  changedPaths: changes?.map((change) => change.path),
1278
1427
  lastRunTokens,
1428
+ ...(lastRunErrorCode ? { errorCode: lastRunErrorCode } : {}),
1279
1429
  rateLimitResetAt,
1280
1430
  remainingQuota: remainingQuota ?? { status: "unknown" },
1281
1431
  }
@@ -10,7 +10,7 @@ Use the Acent Bridge MCP tools in a session with one local project folder open.
10
10
  - Use `acent_bridge_settings` to inspect project settings. Change them in the project's Bridge dialog in Acent. For automatic delegation, pass `automatic: true` when listing candidates and starting a task.
11
11
  - Classify the work as `implement`, `review`, or `diagnose`. Call `acent_bridge_candidates` and select a returned tool and model that fit the task and the user's preference. For review and diagnosis, pass the verified originating model ID so Bridge can restrict candidates to a different model family. Report when no eligible candidate is available.
12
12
  - Use a reported quota snapshot as a tiebreaker among suitable candidates. When a quota is low, favor a lower-usage option if it still fits the task and the user has not pinned a model. Quota windows are provider-specific, and tokens from the last run cannot establish remaining quota.
13
- - Start with `acent_bridge_start`. Include the relevant files, prior decisions, and how to verify completion. Run up to four independent tasks with disjoint write scopes. Pass `dependsOn` when a task needs the result of earlier work. Review and diagnosis run in read-only mode.
13
+ - Start with `acent_bridge_start`. Use `paths` for the files to review or the files an implementation may edit. Use `readPaths` for additional context the delegate may read. Include the relevant decisions and how to verify completion. Run up to four independent tasks with disjoint write scopes. Pass `dependsOn` when a task needs the result of earlier work. Review and diagnosis run in read-only mode.
14
14
  - Check multiple jobs together with `acent_bridge_activity`, or use `acent_bridge_status` for a patch or a full answer. While jobs run, continue independent work and avoid tight polling. If a delegate requests context, answer with the relevant evidence using `acent_bridge_continue`. Ask the user if their judgment is needed. Resume interrupted work from its existing copy or use `acent_bridge_cancel` to stop work that is no longer needed.
15
15
  - Use `acent_bridge_integrate` to check completed patches together. Review them before applying. For substantive changes you are authorized to edit, start `acent_bridge_refine` with a UUID, the original task and constraints, the scoped files, a repair model, and one or more reviewers from distinct model families outside the original and repair families. Pass applied task IDs in `dependsOn`. For a read-only request, use the standalone review instead.
16
16
  - Refinement supplies the original scoped Git diff and the cumulative repair diff to reviewers. It gathers independent findings and re-reviews repairs in a private staging workspace. Keep working on unrelated files while it runs. Check its status when results are needed. If a worker requests context, answer with `acent_bridge_continue` and then check refinement status. If a reviewer cannot run, call `replace_reviewer` with that review ID and an eligible replacement model. Completed reviews in that round stay in place.
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://antigravity.google/schemas/v1/plugin.json",
3
3
  "name": "acent",
4
4
  "displayName": "Acent",
5
- "version": "1.1.1",
5
+ "version": "1.1.2",
6
6
  "description": "Recall past work, trace code changes, revisit decisions, and resume tasks with Acent.",
7
7
  "author": {
8
8
  "name": "Cirtium"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cirtium/acent-connect",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "type": "module",
5
5
  "description": "Install and connect the shared Acent coding-tool plugin",
6
6
  "repository": {