@cirtium/acent-connect 1.2.5 → 1.3.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,7 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { isAbsolute } from "node:path"
3
- import { main } from "./acent-connect.mjs"
3
+ import { main, recordBoundHookFailure } from "./acent-connect.mjs"
4
+ import { bridgeLifecycle, isBridgeContinuation } from "./bridge-lifecycle.mjs"
4
5
  // Use the documented hook cwd, never a plugin cache folder or another binding.
6
+ const args = process.argv.slice(2)
7
+ const bridgeEventIndex = args.indexOf("--bridge-event")
8
+ const bridgeEvent = bridgeEventIndex === -1 ? undefined : args.splice(bridgeEventIndex, 2)[1]
5
9
  let text = ""
6
10
  try {
7
11
  for await (const chunk of process.stdin) {
@@ -10,6 +14,8 @@ try {
10
14
  throw new Error("Hook event exceeds 2 MiB")
11
15
  }
12
16
  const payload = JSON.parse(text)
17
+ // A host may dispatch the completion reminder as a new prompt event.
18
+ if (isBridgeContinuation(payload)) process.exit(0)
13
19
  const cursor = process.argv.includes("Cursor")
14
20
  const antigravity = process.argv.includes("Antigravity")
15
21
  const roots = cursor ? payload.workspace_roots : antigravity ? payload.workspacePaths : undefined
@@ -20,11 +26,20 @@ try {
20
26
  : payload.cwd
21
27
  if (folder != null && folder !== "" && (typeof folder !== "string" || !isAbsolute(folder)))
22
28
  throw new Error("Hook has an invalid working folder")
23
- const session = payload.session_id || payload.conversation_id || payload.conversationId
24
- if (typeof session !== "string" || !session.trim())
29
+ const session = [payload.session_id, payload.conversation_id, payload.conversationId]
30
+ .find(value => typeof value === "string" && value.trim())
31
+ if (!session) {
32
+ if (folder && !bridgeEvent) await recordBoundHookFailure([...args, "--folder", folder], "missing_session")
25
33
  throw new Error("Hook is missing a conversation identifier")
34
+ }
35
+ if (!antigravity) {
36
+ const event = bridgeEvent ?? payload.hook_event_name
37
+ const tool = args[args.indexOf("--tool") + 1]
38
+ const bridgeOutput = await bridgeLifecycle({ tool, folder, session, payload, args, event }).catch(() => undefined)
39
+ if (bridgeOutput) process.stdout.write(JSON.stringify(bridgeOutput) + "\n")
40
+ }
26
41
  // The host delivers this context to the turn that made the Bridge call.
27
- if (process.argv.includes("Codex") &&
42
+ if (process.env.ACENT_BRIDGE_WORKER !== "1" && process.argv.includes("Codex") &&
28
43
  payload.hook_event_name === "PostToolUse" &&
29
44
  /^mcp__acent__acent_bridge_[a-z_]+$/.test(payload.tool_name ?? "") &&
30
45
  typeof payload.model === "string" && /^[\w][\w.:/-]{0,159}$/.test(payload.model) &&
@@ -34,7 +49,7 @@ try {
34
49
  additionalContext: `Codex reports ${payload.model} as the coordinating model for this turn. Use this ID as currentModel for Bridge review, diagnosis, and refinement in this turn. If candidate selection could not verify a reference model, retry with this currentModel. Use it for this turn's direct-work row in the Acent Bridge report.`,
35
50
  } }) + "\n")
36
51
  }
37
- await main(["collect", ...process.argv.slice(2),
52
+ if (!bridgeEvent) await main(["collect", ...args,
38
53
  ...(folder ? ["--folder", folder] : ["--general"])], text)
39
54
 
40
55
  } catch (error) {
@@ -6,6 +6,7 @@ import { connectionGuidance } from "./host-guidance.mjs"
6
6
  import { clarificationInstructions, clarificationTool, clarify, createQuestionChannel } from "./clarification.mjs"
7
7
  import { connectionContext, createRootsChannel, projectFolder } from "./connection-context.mjs"
8
8
  import { memoryInstructions } from "./memory-instructions.mjs"
9
+ import { decisionConflictInstructions, decisionConflictTool, resolveDecisionConflict } from "./decision-conflict.mjs"
9
10
  import { attachmentTool, saveAttachments } from "./capture-attachments.mjs"
10
11
  import { bridgeInstructions, bridgeTools, createBridge } from "./bridge.mjs"
11
12
  import { bridgeApprovalTool, requestBridgeApproval } from "./bridge-approval.mjs"
@@ -225,6 +226,7 @@ async function handleLine(line) {
225
226
  serverInfo: { name: "acent", version: installation?.version ?? "0.2.0" },
226
227
  instructions:
227
228
  "Use acent_connect to connect Acent when setup is needed; its default scope is auto. If it returns needs_user_input, ask its question once in the user’s language and wait for their answer. Show its authorization link to the user. After approval, refresh tools/list and continue the original request. Never approve on the user's behalf. " + memoryInstructions + "\n\n" + clarificationInstructions +
229
+ "\n\n" + decisionConflictInstructions +
228
230
  (localBridgeTools.length ? "\n\n" + bridgeInstructions : "") +
229
231
  (pluginUpdates ? "\n\n" + pluginUpdateInstructions : ""),
230
232
  })
@@ -400,6 +402,16 @@ async function handleLine(line) {
400
402
  }
401
403
  throw error
402
404
  }
405
+ if (message.method === "tools/call" && message.params?.name === decisionConflictTool.name) {
406
+ try {
407
+ const value = await resolveDecisionConflict(message.params.arguments, clientCapabilities, protocol,
408
+ (params) => questions.request(params, message.id, { waitForUser: true }))
409
+ reply({ ...content(JSON.stringify(value)), structuredContent: value })
410
+ } catch (error) {
411
+ reply(content(error.message, true))
412
+ }
413
+ return
414
+ }
403
415
  if (message.method === "tools/call" && message.params?.name === clarificationTool.name) {
404
416
  try {
405
417
  const value = await clarify(message.params.arguments, clientCapabilities, protocol,
@@ -439,7 +451,7 @@ async function handleLine(line) {
439
451
  const localTools = privateGrant(grant.client_id)
440
452
  ? (grant.captureKey && grant.scope?.split(" ").includes("original:read") ? [encryptedReadTool] : [])
441
453
  : grant.scope?.split(" ").includes("conversation:write") ? [attachmentTool] : []
442
- result.result.tools = [...result.result.tools.filter((tool) => tool.name !== clarificationTool.name), setupTool, clarificationTool, ...localTools, ...localBridgeTools, ...workspaceTools]
454
+ result.result.tools = [...result.result.tools.filter((tool) => tool.name !== clarificationTool.name), setupTool, clarificationTool, decisionConflictTool, ...localTools, ...localBridgeTools, ...workspaceTools]
443
455
  }
444
456
  if (message.method === "tools/call" && result.result)
445
457
  result.result = await withPluginUpdate(result.result)
@@ -467,11 +479,20 @@ async function handleLine(line) {
467
479
 
468
480
  // Keep reading while a tool waits for an elicitation response on this same pipe.
469
481
  const active = new Set()
482
+ // Retry previously approved queued captures while the host connection is open.
483
+ // The shared drain lock and the current server policy still govern every upload.
484
+ const captureRetry = process.env.ACENT_BRIDGE_WORKER === "1" ? null : setInterval(() => {
485
+ const config = activeConfig
486
+ if (!config.bindingKnown) return
487
+ void drain(config, configDirectory(config)).catch(() => {})
488
+ }, 120_000)
489
+ captureRetry?.unref()
470
490
  for await (const line of lines) {
471
491
  const task = handleLine(line)
472
492
  active.add(task)
473
493
  void task.finally(() => active.delete(task))
474
494
  }
495
+ if (captureRetry) clearInterval(captureRetry)
475
496
  rootRequests.close()
476
497
  questions.close()
477
498
  await Promise.allSettled(active)
@@ -1,6 +1,7 @@
1
1
  // Shared by the HTTP server and the packaged stdio proxy. The proxy handles
2
2
  // initialize locally, so upstream server instructions do not reach its host.
3
3
  export const memoryInstructions = [
4
+ "When get_recent_work, get_handoff or search_evidence returns attachments, match them to the relevant conversation by sourceId even if the user did not mention files. When reporting past work, include relevant filenames and their returned download links. When continuing work, read attachments that the prior request or decision relied on, using readWith when provided. Download links may require the user's Acent web session. For a relevant source in attachmentSourcesUnavailable, try search_attachments if the file matters. Describe file contents only after a successful read or inspection.",
4
5
  "Acent has five named skills: Acent Recall finds past context; Acent Trace explains saved code edits; Acent Decisions retrieves choices and reasons; Acent Resume continues saved work; Acent Connect manages connection setup. Recognize these names in user requests and use the relevant exposed tools. These are workflows within the Acent plugin, not separate connections. Automatic capture remains controlled by saving consent.",
5
6
  "Use connected Acent as the first source for missing project history when it could change the answer or next action, including within the same conversation or after context compaction. Search before asking the user to restate that history, even without an explicit mention of Acent. For example, if the user says 'do it like last time' or '저번처럼 해줘' and the earlier approach is unclear, search using the task, feature, or error they mention. Also retrieve for resumed work, unexplained past decisions or constraints, conflicting records, and recurring failures where earlier attempts could affect the next step. Skip retrieval when the current context and files already answer the question. Reuse evidence already read and search again when the task changes, a reference is stale, or later corrections may matter.",
6
7
  "When looking for conversations saved by this plugin connection, use read_saved_sessions when available. For an earlier device-encrypted connection use read_encrypted_sessions when available. Follow the returned pagination to continue a search.",
@@ -15,8 +15,9 @@ Use the Acent Bridge MCP tools in a session with one local project folder open.
15
15
  - Keep straightforward copy or styling edits and dependent steps with the coordinating agent. Start additional automatic tasks only when each has a distinct, useful result. Give each shared contract, state machine, or business rule one writer, even when it spans separate files. Finish a prerequisite first or use `dependsOn` when later work needs its result. Use read-only review or diagnosis for independent work when writes need one owner.
16
16
  - Keep authorized production actions with the coordinating agent, including deployments, database migrations, and live payments or refunds. Bridge can review the plan or verify the outcome independently.
17
17
  - If automatic delegation is disabled, continue directly. If it is enabled and no suitable candidate is available, continue the work you can verify and report why independent work did not run.
18
+ - Before finishing eligible work, confirm that the independent check ran or explain why it could not run. If the host issues a completion reminder, handle this once and finish normally. Bridge worker sessions carry out the assigned task without starting another delegation.
18
19
  - 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, diagnosis, and refinement, pass the host-reported model for this turn as `currentModel`. Supply `originModel` when reviewing earlier work whose originating model is known. Bridge uses the earlier model when supplied and recognized, otherwise it checks independence against the current model. In Codex, if candidate selection returns `origin_model_unverified` and the Bridge hook reports the current model, retry with that ID. Pass the same model inputs to start the selected work. Report when no eligible candidate is available.
19
- - 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.
20
+ - Honor a user-specified model. For automatic selection, choose for task fit and review independence first and check any reported quota. Among similarly suitable candidates, prefer Grok in Cursor and Gemini in Antigravity, marked `preferredForTool`. Use another eligible model such as Claude in Cursor when it fits the task better or when the preferred family is unavailable, within the user's usage and spending settings. Pass the selected model ID explicitly. Treat missing or expired quota data as unknown. In Antigravity, skip candidates marked `includedQuota: exhausted` for automatic selection unless the user has authorized overage use.
20
21
  - Before starting any task or refinement, gather the active decisions, constraints, and prior findings that affect the delegated scope. Use evidence already available. If missing project history could change the work, use [Acent Decisions](../acent-decisions/SKILL.md) for prior choices or [Acent Recall](../acent-recall/SKILL.md) for earlier requirements and attempts. Put the relevant facts, decision rationale where it affects the task, and unresolved points in `context` on the first call. For self-contained work, pass the current facts the delegate needs.
21
22
  - 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. Specify how to verify completion in `acceptance`. The folder shares four baseline slots across implementation, review, and diagnosis and expands up to eight as needed. Ready tasks submitted after all eight slots fill are queued and start as slots open. Track their existing IDs. Pass `dependsOn` when a task needs the result of earlier work. Review and diagnosis run in read-only mode.
22
23
  - 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.
@@ -18,6 +18,8 @@ Read relevant returned references to recover the last user request, completed or
18
18
 
19
19
  When a past command, test, build, or migration result matters, check the returned `activities` for the selected conversation and relevant turn. Use `read_activity` with its `source_id` as `sourceId` and its `id`. Read only the sections you need, such as `output` to verify the result. If you need more records, use `search_activities` with the selected `sourceId`. An unknown status or missing output leaves the outcome unconfirmed.
20
20
 
21
+ Check returned `attachments` for the selected `sourceId`. When reporting past work, include relevant file names and download links. When resuming, read files the original task relied on, using the attachment's `readWith` reference for extracted text when available. If that source appears in `attachmentSourcesUnavailable`, retry with `search_attachments` when the file matters. Report what was actually accessible.
22
+
21
23
  Conversation candidates are not verified task lists. Distinguish message time, collection time and archive storage time. Do not assume the newest conversation is unfinished, or that a reported successful change still exists. Compare the selected evidence with current files and repository state before proceeding.
22
24
 
23
25
  If several tasks fit or the next step is materially ambiguous after a focused search, ask one question with evidence-based choices in the current chat. Use `request_clarification` when available, otherwise the host's question mechanism. Wait for the answer before dependent work; never answer on the user's behalf or retry a cancelled question.
@@ -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.2.5",
5
+ "version": "1.3.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.2.5",
3
+ "version": "1.3.2",
4
4
  "type": "module",
5
5
  "description": "Install and connect the shared Acent coding-tool plugin",
6
6
  "repository": {
package/scripts/acent.mjs CHANGED
@@ -71,7 +71,7 @@ export async function main(
71
71
  if (args.includes("--help") || args[0] === "help") {
72
72
  console.log(
73
73
  [
74
- "Usage\n\n acent [connect|install|update|disconnect|flush]\n [--tool codex|claude|cursor|antigravity] [--folder PATH]",
74
+ "Usage\n\n acent [connect|install|update|disconnect|flush|status]\n [--tool codex|claude|cursor|antigravity] [--folder PATH]",
75
75
  "Install\n\n acent install\n acent install --all\n\n Install for one tool, or prepare all four supported tools with --all.\n After installation, follow the printed steps and ask your agent: Connect Acent.",
76
76
  "Connect\n\n acent connect\n\n Run in your project folder. Running acent without a command also starts connection.",
77
77
  "Update\n\n acent update\n acent update --all\n\n Update one tool, or all plugins installed by this CLI.\n Existing project connections are kept.",
@@ -83,9 +83,9 @@ export async function main(
83
83
  const command =
84
84
  !args.length || args[0].startsWith("--") ? "connect" : args.shift()
85
85
  if (
86
- !["connect", "install", "update", "disconnect", "flush"].includes(command)
86
+ !["connect", "install", "update", "disconnect", "flush", "status"].includes(command)
87
87
  )
88
- throw new Error("Use connect, install, update, disconnect, or flush")
88
+ throw new Error("Use connect, install, update, disconnect, flush, or status")
89
89
  const settings = {}
90
90
  let all = false
91
91
  for (let i = 0; i < args.length; i++) {