@cirtium/acent-connect 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/.claude-plugin/marketplace.json +10 -2
  2. package/README.md +29 -12
  3. package/acent/.claude-plugin/plugin.json +2 -2
  4. package/acent/.codex-plugin/plugin.json +4 -4
  5. package/acent/.cursor-plugin/plugin.json +2 -2
  6. package/acent/README.md +16 -7
  7. package/acent/hooks/claude.json +36 -0
  8. package/acent/hooks/codex.json +24 -0
  9. package/acent/hooks/cursor.json +5 -0
  10. package/acent/mcp-codex.json +1 -4
  11. package/acent/scripts/acent-connect.mjs +41 -8
  12. package/acent/scripts/antigravity-capture.mjs +8 -1
  13. package/acent/scripts/antigravity-hook.mjs +1 -1
  14. package/acent/scripts/capture-code-changes.mjs +407 -0
  15. package/acent/scripts/codex-capture.mjs +1 -1
  16. package/acent/scripts/host-guidance.mjs +18 -0
  17. package/acent/scripts/mcp-proxy.mjs +3 -1
  18. package/acent/scripts/memory-instructions.mjs +4 -2
  19. package/acent/skills/acent-connect/SKILL.md +16 -4
  20. package/acent/skills/acent-connect/agents/openai.yaml +4 -0
  21. package/acent/skills/acent-decisions/SKILL.md +18 -0
  22. package/acent/skills/acent-decisions/agents/openai.yaml +4 -0
  23. package/acent/skills/{acent-memory → acent-recall}/SKILL.md +13 -3
  24. package/acent/skills/acent-recall/agents/openai.yaml +4 -0
  25. package/acent/skills/acent-resume/SKILL.md +18 -0
  26. package/acent/skills/acent-resume/agents/openai.yaml +4 -0
  27. package/acent/skills/acent-trace/SKILL.md +21 -0
  28. package/acent/skills/acent-trace/agents/openai.yaml +4 -0
  29. package/antigravity/README.md +15 -6
  30. package/antigravity/build.mjs +9 -3
  31. package/antigravity/plugin.json +2 -2
  32. package/package.json +5 -2
  33. package/scripts/acent.mjs +22 -52
  34. package/scripts/choose-tool.mjs +82 -0
  35. package/scripts/install-plugin.mjs +67 -13
  36. package/scripts/local-registration.mjs +49 -0
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: acent-trace
3
+ description: Acent Trace finds saved code edits, their originating requests and related decision evidence across coding tools. Use when the user asks what changed in a file, who changed it, or why code was modified.
4
+ ---
5
+
6
+ # Acent Trace
7
+
8
+ Search `search_code_changes` with a file path, code symbol or distinctive request words. Omit the query for recent edits, or use a known sourceId to narrow the conversation. Open relevant results with `read_code_change`, passing the returned source_id as sourceId and the edit id. Follow nextOffset and nextDecisionOffset only while needed.
9
+
10
+ Explain the changed file and code, captured request, tool, and recorded explanation. Cite the returned sourceId/id and decision originalReference; use `read_original` when exact source wording or surrounding context is needed. Never invent a source URL.
11
+
12
+ Interpret the capture faithfully:
13
+
14
+ - `host_edit_fragments` contains host-reported change fragments; hunk offsets are not absolute file line numbers.
15
+ - `before_after` shows the observed editing interval and may include concurrent writes. The recorded tool does not prove exclusive authorship.
16
+ - Report missing requests or incomplete capture status. A missing result does not prove no edit occurred; shell edits and disabled hooks may not be captured.
17
+ - Agent notes are reported explanations. A `cites_request` decision shares request evidence; it does not prove that decision caused this specific edit. Use `get_decision_context` for related choices outside that request, identifying unconfirmed relationships.
18
+
19
+ Compare later edits and current code before drawing conclusions about the present. Reading history does not authorize reverting or changing files. Follow the user's current request for any modification.
20
+
21
+ Use only exposed tools and approved project scope. If edit-history tools are unavailable, say so and use permitted conversation evidence for reported changes without claiming an observed diff. For connection setup, use [Acent Connect](../acent-connect/SKILL.md). Capture remains an opt-in background behavior; this skill reads history and does not turn saving on.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Acent Trace"
3
+ short_description: "Trace code edits to requests and evidence."
4
+ default_prompt: "Use $acent-trace to show what changed in this file and why."
@@ -6,19 +6,28 @@ Keep your work conversations, revisit past decisions, and bring relevant context
6
6
 
7
7
  ## Get started
8
8
 
9
- Install the Acent plugin with the Acent CLI from your project folder. Then ask **“Connect Acent”** in the Antigravity agent with your project open. Follow the link to sign in, choose an Acent project, and approve the connection and conversation saving. Start a new turn after connecting to begin saving.
9
+ Install Acent from your tool’s plugin marketplace. Then ask **“Connect Acent”** in the Antigravity agent with your project open. Follow the link to sign in, choose an Acent project, and approve the connection and conversation saving. Start a new turn after connecting to begin saving.
10
10
 
11
11
  ## Use your saved context
12
12
 
13
- Ask your agent to find relevant context in Acent, for example:
13
+ Use the skill name in your request:
14
14
 
15
- - “What did we decide about authentication, and why?”
16
- - “Show the original conversation behind that decision.”
17
- - “Help me pick up where I left off.”
15
+ | Skill | Purpose | Example |
16
+ | --- | --- | --- |
17
+ | **Acent Recall** | Find past conversations and project context | “Recall how we handled this error before.” |
18
+ | **Acent Trace** | Trace saved code edits to requests and evidence | “Trace what changed in this file and why.” |
19
+ | **Acent Decisions** | Find previous choices and their reasons | “Use Decisions to explain our authentication choice.” |
20
+ | **Acent Resume** | Continue saved work across tools | “Resume the task I was working on in Cursor.” |
21
+ | **Acent Connect** | Connect a project and manage saving consent | “Connect Acent to this project.” |
22
+
23
+ The skill identifiers are `acent-recall`, `acent-trace`, `acent-decisions`,
24
+ `acent-resume` and `acent-connect`. Your tool controls how these appear in its
25
+ skill picker. Saving runs through enabled hooks with your consent; invoking a
26
+ retrieval skill does not enable saving.
18
27
 
19
28
  ## Conversation saving
20
29
 
21
- After you approve saving and allow the plugin hooks, Acent saves completed user and assistant text from supported Antigravity conversations. Earlier conversations are not imported. Each project folder needs its own connection.
30
+ After you approve saving and the plugin is enabled, Acent saves completed user and assistant text from supported Antigravity conversations. Earlier conversations are not imported. Each project folder needs its own connection.
22
31
 
23
32
  Your agent can retrieve context from the approved project and account-wide memory. You can revoke the connection in Acent settings.
24
33
 
@@ -18,9 +18,15 @@ export async function build({ output, folder, server = "https://www.acent.cloud"
18
18
  await cp(join(here, "../acent", name), join(destination, name), { recursive: true })
19
19
  await cp(join(here, "plugin.json"), join(destination, "plugin.json"))
20
20
  await writeFile(join(destination, "hooks.json"), JSON.stringify({
21
- "acent-save": Object.fromEntries(["PreInvocation", "PostInvocation", "Stop"].map(event => [event, [{
22
- type: "command", command: `node ./scripts/antigravity-hook.mjs ${event}`, timeout: 40,
23
- }]])),
21
+ "acent-save": {
22
+ ...Object.fromEntries(["PreInvocation", "PostInvocation", "Stop"].map(event => [event, [{
23
+ type: "command", command: `node ./scripts/antigravity-hook.mjs ${event}`, timeout: 40,
24
+ }]])),
25
+ ...Object.fromEntries(["PreToolUse", "PostToolUse"].map(event => [event, [{
26
+ matcher: "write_to_file|replace_file_content|multi_replace_file_content",
27
+ hooks: [{ type: "command", command: `node ./scripts/antigravity-hook.mjs ${event}`, timeout: 40 }],
28
+ }]])),
29
+ },
24
30
  }, null, 2) + "\n")
25
31
  await writeFile(join(destination, "mcp_config.json"), JSON.stringify({
26
32
  mcpServers: { acent: { command: "node", args: [
@@ -2,8 +2,8 @@
2
2
  "$schema": "https://antigravity.google/schemas/v1/plugin.json",
3
3
  "name": "acent",
4
4
  "displayName": "Acent",
5
- "version": "0.2.3",
6
- "description": "Connect conversations across your projects and carry context into your next task.",
5
+ "version": "0.3.0",
6
+ "description": "Recall past work, trace code changes, revisit decisions, and resume tasks with Acent.",
7
7
  "author": {
8
8
  "name": "Cirtium"
9
9
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cirtium/acent-connect",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Install and connect the shared Acent coding-tool plugin",
6
6
  "repository": {
@@ -22,5 +22,8 @@
22
22
  ".claude-plugin",
23
23
  "README.md",
24
24
  "antigravity"
25
- ]
25
+ ],
26
+ "dependencies": {
27
+ "smol-toml": "^1.9.1"
28
+ }
26
29
  }
package/scripts/acent.mjs CHANGED
@@ -1,86 +1,56 @@
1
1
  #!/usr/bin/env node
2
+ import { installationGuidance } from "../acent/scripts/host-guidance.mjs"
2
3
  import { pathToFileURL } from "node:url"
3
4
  import { realpathSync } from "node:fs"
4
5
  import { stat } from "node:fs/promises"
5
- import { createInterface } from "node:readline/promises"
6
+ import { chooseTool } from "./choose-tool.mjs"
6
7
  import { main as adapter, options } from "../acent/scripts/acent-connect.mjs"
7
8
  import {
8
9
  tools,
9
10
  aliases,
10
- detect,
11
11
  isManagedInstallation,
12
12
  installPlugin,
13
13
  run,
14
14
  } from "./install-plugin.mjs"
15
15
  export { installationCommands } from "./install-plugin.mjs"
16
16
 
17
- async function choose() {
18
- if (!process.stdin.isTTY)
19
- throw new Error(
20
- "Specify --tool codex|claude|cursor|antigravity when running without a terminal."
21
- )
22
- const found = await Promise.all(tools.map((tool) => detect(tool)))
23
- const prompt = createInterface({
24
- input: process.stdin,
25
- output: process.stderr,
26
- })
27
- try {
28
- console.error("Choose your AI tool:")
29
- tools.forEach((tool, i) =>
30
- console.error(
31
- ` ${i + 1}. ${tool} — ${found[i] ? "installation command available" : "installation command not found"}`
32
- )
33
- )
34
- const answer = (
35
- await prompt.question("Tool number or name (Ctrl+C to cancel): ")
36
- ).trim()
37
- return tools[Number(answer) - 1] || answer
38
- } finally {
39
- prompt.close()
40
- }
41
- }
17
+ const choose = () => chooseTool(tools)
42
18
 
43
19
  async function applyPlugin(tool, command, settings, folder, execute, dependencies) {
44
- const executable = await (dependencies.detect || detect)(tool, settings.executable)
45
- if (!executable)
46
- throw new Error(
47
- `${tool}'s plugin installation command was not found. The app may be installed without its CLI. Install or enable its CLI, or supply --executable PATH. No connection was started.`
48
- )
49
20
  const installed = await (dependencies.install || installPlugin)(tool, {
50
21
  command,
51
- executable,
52
22
  folder,
53
23
  execute,
54
24
  })
55
- const action = command === "update" ? "updated" : "installed"
25
+ const action = command === "update" ? "files and settings updated" : "files and settings prepared"
56
26
  console.error(`Acent ${installed.version} ${action} for ${tool}.`)
57
- if (tool === "Cursor")
58
- console.error(
59
- "Reload Cursor and check Customize. Organization policies or a marketplace copy may take precedence over this local plugin."
60
- )
61
- console.error(
62
- "Start a new tool session. Review and trust the plugin hooks in your tool; installation does not approve conversation saving."
63
- )
27
+ console.error(installationGuidance(tool))
28
+ return true
64
29
  }
65
30
 
66
- async function updateAll(settings, execute, dependencies) {
31
+ async function applyAll(command, settings, execute, dependencies) {
67
32
  const folder = settings.folder || process.cwd()
68
33
  if (!(await stat(folder)).isDirectory())
69
34
  throw new Error("Choose an existing directory.")
35
+ const updating = command === "update"
70
36
  const failures = []
71
- let updated = 0
37
+ let completed = 0
72
38
  for (const tool of tools) {
73
39
  try {
74
- if (!(await (dependencies.isManaged || isManagedInstallation)(tool))) continue
75
- await applyPlugin(tool, "update", settings, folder, execute, dependencies)
76
- updated++
40
+ if (updating && !(await (dependencies.isManaged || isManagedInstallation)(tool))) continue
41
+ const applied = await applyPlugin(
42
+ tool, command, { skipUnavailable: !updating }, folder, execute, dependencies
43
+ )
44
+ if (applied) completed++
77
45
  } catch (error) {
78
46
  failures.push(`${tool}: ${error.message}`)
79
47
  }
80
48
  }
81
49
  if (failures.length)
82
- throw new Error(`Acent could not update every installation:\n${failures.join("\n")}`)
83
- if (!updated) console.error("No Acent plugins installed by this CLI were found.")
50
+ throw new Error(`Acent could not ${command} for every tool:\n${failures.join("\n")}`)
51
+ if (!completed && !updating)
52
+ throw new Error("No plugins were installed.")
53
+ if (!completed) console.error("No Acent plugins installed by this CLI were found.")
84
54
  }
85
55
 
86
56
  export async function main(
@@ -92,7 +62,7 @@ export async function main(
92
62
  args = [...args]
93
63
  if (args.includes("--help") || args[0] === "help") {
94
64
  console.log(
95
- "Usage: acent [connect|install|update|disconnect|flush] [--tool codex|claude|cursor|antigravity] [--folder PATH] [--executable PATH]\n acent update --all\nNo command starts interactive connection. Run in the project folder to connect.\ninstall: install without authorization; update: apply this CLI release without changing grants.\nupdate --all: update all plugins installed by the Acent CLI.\nGet the latest CLI release before running update. Node 22+ required."
65
+ "Usage: acent [connect|install|update|disconnect|flush] [--tool codex|claude|cursor|antigravity] [--folder PATH]\n acent install --all\n acent update --all\nNo command starts interactive connection. Run in the project folder to connect.\ninstall: install without authorization; update: apply this CLI release without changing grants.\ninstall --all: prepare Acent for all four supported tools.\nupdate --all: update all plugins installed by the Acent CLI.\nGet the latest CLI release before running update. Node 22+ required."
96
66
  )
97
67
  return
98
68
  }
@@ -121,9 +91,9 @@ export async function main(
121
91
  i++
122
92
  }
123
93
  if (all) {
124
- if (command !== "update" || settings.tool || settings.executable)
125
- throw new Error("Use --all with update without --tool or --executable.")
126
- return updateAll(settings, execute, dependencies)
94
+ if (!["install", "update"].includes(command) || settings.tool || settings.executable)
95
+ throw new Error("Use --all with install or update without --tool or --executable.")
96
+ return applyAll(command, settings, execute, dependencies)
127
97
  }
128
98
  const selected = settings.tool || (await (dependencies.choose || choose)())
129
99
  const tool = tools.includes(selected)
@@ -0,0 +1,82 @@
1
+ import { emitKeypressEvents, cursorTo, clearLine, moveCursor } from "node:readline"
2
+ import { createInterface } from "node:readline/promises"
3
+
4
+ export async function chooseTool(tools, {
5
+ input = process.stdin,
6
+ output = process.stderr,
7
+ env = process.env,
8
+ } = {}) {
9
+ if (!input.isTTY) {
10
+ throw new Error("Specify --tool codex|claude|cursor|antigravity when running without a terminal.")
11
+ }
12
+ // Redirected output and basic terminals retain a readable numbered prompt.
13
+ if (!output.isTTY || !input.setRawMode || env.TERM === "dumb" || (output.columns && output.columns < 24)) {
14
+ // This branch is plain text even if the stream advertises TTY support.
15
+ // Otherwise readline uses the real TERM and emits cursor-control sequences.
16
+ const prompt = createInterface({ input, output, terminal: false })
17
+ try {
18
+ output.write("Choose your AI tool:\n" + tools.map((tool, i) => ` ${i + 1}. ${tool}`).join("\n") + "\n")
19
+ const answer = (await prompt.question("Tool number or name (Ctrl+C to cancel): ")).trim()
20
+ return tools[Number(answer) - 1] || answer
21
+ } finally {
22
+ prompt.close()
23
+ }
24
+ }
25
+
26
+ const color = env.NO_COLOR === undefined
27
+ const previousRaw = Boolean(input.isRaw)
28
+ const wasFlowing = input.readableFlowing === true
29
+ let selected = 0
30
+ let rendered = false
31
+ const draw = () => {
32
+ if (rendered) moveCursor(output, 0, -tools.length)
33
+ for (let i = 0; i < tools.length; i++) {
34
+ cursorTo(output, 0)
35
+ clearLine(output, 0)
36
+ const text = `${i === selected ? "›" : " "} ${tools[i]}`
37
+ output.write(i === selected && color ? `\x1b[1;36m${text}\x1b[0m\n` : text + "\n")
38
+ }
39
+ rendered = true
40
+ }
41
+ output.write("Choose your AI tool:\n↑/↓ move · Enter select\nCtrl+C cancel\n\n")
42
+ emitKeypressEvents(input)
43
+ return new Promise((resolve, reject) => {
44
+ let finished = false
45
+ function finish(error) {
46
+ if (finished) return
47
+ finished = true
48
+ input.off("keypress", onKey)
49
+ input.off("end", onEnd)
50
+ input.off("error", onError)
51
+ input.setRawMode(previousRaw)
52
+ if (!wasFlowing) input.pause()
53
+ output.write(error ? "Selection cancelled.\n" : `Selected: ${tools[selected]}\n`)
54
+ if (error) reject(error)
55
+ else resolve(tools[selected])
56
+ }
57
+ function onEnd() { finish(new Error("Tool selection ended before a choice was made.")) }
58
+ function onError(error) { finish(error) }
59
+ function onKey(_text, key = {}) {
60
+ if (key.ctrl && (key.name === "c" || key.name === "d") || key.name === "escape") {
61
+ const error = new Error("Installation cancelled. No tool was selected.")
62
+ error.code = "ABORT_ERR"
63
+ finish(error)
64
+ } else if (key.name === "return" || key.name === "enter") {
65
+ finish()
66
+ } else if (key.name === "up" || key.name === "down") {
67
+ selected = (selected + (key.name === "up" ? -1 : 1) + tools.length) % tools.length
68
+ draw()
69
+ }
70
+ }
71
+ input.on("keypress", onKey)
72
+ input.once("end", onEnd)
73
+ input.once("error", onError)
74
+ try {
75
+ input.setRawMode(true)
76
+ draw()
77
+ input.resume()
78
+ } catch (error) {
79
+ finish(error)
80
+ }
81
+ })
82
+ }
@@ -1,9 +1,11 @@
1
+ import { registerLocal } from "./local-registration.mjs"
1
2
  import { spawn, spawnSync } from "node:child_process"
2
3
  import {
3
4
  cp,
4
5
  mkdir,
5
6
  mkdtemp,
6
7
  readFile,
8
+ readdir,
7
9
  writeFile,
8
10
  rename,
9
11
  rm,
@@ -43,13 +45,49 @@ export function probe(tool, executable) {
43
45
  args: ["plugin", "--help"],
44
46
  }
45
47
  }
48
+
49
+ async function claudeDesktopExecutables(home) {
50
+ const root = join(home, "Library/Application Support/Claude/claude-code")
51
+ const versions = (await readdir(root, { withFileTypes: true }).catch(() => []))
52
+ .filter((entry) => entry.isDirectory() && /^\d+\.\d+\.\d+$/.test(entry.name))
53
+ .sort((a, b) => b.name.localeCompare(a.name, "en", { numeric: true }))
54
+ const executables = []
55
+ for (const version of versions) {
56
+ const directory = join(root, version.name)
57
+ const builds = await readdir(directory, { withFileTypes: true }).catch(() => [])
58
+ for (const entry of builds) {
59
+ if (entry.isDirectory() && /^[a-f0-9]+$/i.test(entry.name))
60
+ executables.push(
61
+ join(directory, entry.name, "claude.app/Contents/MacOS/claude")
62
+ )
63
+ }
64
+ }
65
+ return executables
66
+ }
67
+
46
68
  export async function detect(tool, explicit) {
47
69
  const info = probe(tool, explicit)
70
+ const home = homedir()
48
71
  const candidates = explicit
49
72
  ? [explicit]
50
- : [info.executable, join(homedir(), ".local/bin", info.executable)]
73
+ : [info.executable, join(home, ".local/bin", info.executable)]
51
74
  if (tool === "Antigravity" && !explicit)
52
- candidates.push(join(homedir(), ".antigravity/antigravity/bin/agy"))
75
+ candidates.push(join(home, ".antigravity/antigravity/bin/agy"))
76
+ if (!explicit && process.platform === "darwin") {
77
+ if (tool === "Codex") {
78
+ for (const applications of ["/Applications", join(home, "Applications")]) {
79
+ candidates.push(
80
+ join(applications, "Codex.app/Contents/Resources/codex"),
81
+ join(
82
+ applications,
83
+ "ChatGPT.app/Contents/Resources/codex-cli/CodexCLI.app/Contents/MacOS/codex"
84
+ )
85
+ )
86
+ }
87
+ }
88
+ if (tool === "Claude Code")
89
+ candidates.push(...(await claudeDesktopExecutables(home)))
90
+ }
53
91
  for (const executable of candidates) {
54
92
  const result = spawnSync(executable, info.args, {
55
93
  encoding: "utf8",
@@ -142,7 +180,9 @@ export async function run(command, args, cwd) {
142
180
  }
143
181
 
144
182
  function pluginRoot(tool, home) {
145
- return tool === "Cursor"
183
+ return tool === "Antigravity"
184
+ ? join(home, ".gemini/config/plugins/acent")
185
+ : tool === "Cursor"
146
186
  ? join(home, ".cursor/plugins/local/acent")
147
187
  : join(home, ".local/share/acent/plugins", keys[tool])
148
188
  }
@@ -160,7 +200,12 @@ export async function isManagedInstallation(tool, home = homedir()) {
160
200
  if (error.code !== "ENOENT") throw error
161
201
  return null
162
202
  })
163
- return (await readInstallation(root, info))?.owner === "acent-cli"
203
+ if ((await readInstallation(root, info))?.owner === "acent-cli") return true
204
+ if (tool === "Antigravity") {
205
+ const legacy = join(home, ".local/share/acent/plugins/antigravity")
206
+ return (await readInstallation(legacy, await lstat(legacy).catch(() => null)))?.owner === "acent-cli"
207
+ }
208
+ return false
164
209
  }
165
210
 
166
211
  // Plugin code is separate from grants and queues. Never replace an unowned folder.
@@ -173,6 +218,7 @@ export async function installPlugin(
173
218
  home = homedir(),
174
219
  execute = run,
175
220
  source = packageRoot,
221
+ register = registerLocal,
176
222
  } = {}
177
223
  ) {
178
224
  const root = pluginRoot(tool, home)
@@ -193,7 +239,12 @@ export async function installPlugin(
193
239
  if (error.code !== "ENOENT") throw error
194
240
  return null
195
241
  })
196
- const previous = await readInstallation(root, info)
242
+ let previous = await readInstallation(root, info)
243
+ if (!info && tool === "Antigravity") {
244
+ const legacy = join(home, ".local/share/acent/plugins/antigravity")
245
+ const record = await readInstallation(legacy, await lstat(legacy).catch(() => null))
246
+ if (record?.owner === "acent-cli") previous = record
247
+ }
197
248
  if (info && previous?.owner !== "acent-cli")
198
249
  throw new Error(
199
250
  `Existing plugin at ${root} is not managed by the Acent CLI. Keep it intact and remove or relocate it through your tool before installing.`
@@ -215,6 +266,15 @@ export async function installPlugin(
215
266
  recursive: true,
216
267
  })
217
268
  }
269
+ // The installer knows Node's real executable and the final plugin location.
270
+ // Pin local MCP launches so desktop apps need neither Node nor a host CLI on PATH.
271
+ const nested = tool === "Codex" || tool === "Claude Code"
272
+ const configName = { Codex: "mcp-codex.json", "Claude Code": "mcp-claude.json", Cursor: "mcp-cursor.json", Antigravity: "mcp_config.json" }[tool]
273
+ const mcpPath = join(payload, ...(nested ? ["acent"] : []), configName)
274
+ const mcp = JSON.parse(await readFile(mcpPath, "utf8"))
275
+ mcp.mcpServers.acent.command = process.execPath
276
+ mcp.mcpServers.acent.args[0] = join(root, ...(nested ? ["acent"] : []), "scripts/mcp-proxy.mjs")
277
+ await writeFile(mcpPath, JSON.stringify(mcp, null, 2) + "\n")
218
278
  const version = JSON.parse(
219
279
  await readFile(join(source, "package.json"), "utf8")
220
280
  ).version
@@ -229,13 +289,7 @@ export async function installPlugin(
229
289
  await rename(payload, root)
230
290
  replaced = true
231
291
  try {
232
- for (const [program, argv] of installationCommands(
233
- tool,
234
- root,
235
- executable,
236
- Boolean(previous)
237
- ))
238
- await execute(program, argv, folder)
292
+ await register(tool, root, home)
239
293
  } catch (error) {
240
294
  await rm(root, { recursive: true, force: true })
241
295
  replaced = false
@@ -244,7 +298,7 @@ export async function installPlugin(
244
298
  backup = undefined
245
299
  }
246
300
  throw new Error(
247
- `${error.message} Previous local files restored. Host registration may need repair; retry acent install. Your connection and queued data were not changed.`
301
+ `${error.message} Previous local files restored. Retry acent install after resolving the settings error. Your connection and queued data were not changed.`
248
302
  )
249
303
  }
250
304
  return { root, version }
@@ -0,0 +1,49 @@
1
+ import { homedir } from "node:os"
2
+ import { parse, stringify } from "smol-toml"
3
+ import { readFile, writeFile, mkdir, rename, rm } from "node:fs/promises"
4
+ import { dirname, join } from "node:path"
5
+
6
+ // One shared settings file per host. Lock it and replace atomically; never overwrite
7
+ // malformed settings or another plugin's entry. Leave host-owned caches alone.
8
+ export async function registerLocal(tool, root, home) {
9
+ if (tool !== "Codex" && tool !== "Claude Code") return
10
+ const path = tool === "Codex"
11
+ ? join(home === homedir() && process.env.CODEX_HOME || join(home, ".codex"), "config.toml")
12
+ : join(home === homedir() && process.env.CLAUDE_CONFIG_DIR || join(home, ".claude"), "settings.json")
13
+ await mkdir(dirname(path), { recursive: true })
14
+ const lock = `${path}.acent-lock`
15
+ await mkdir(lock).catch(() => { throw new Error(`Settings are busy: ${path}. Retry after the other installer finishes.`) })
16
+ const temp = join(lock, "settings.json")
17
+ try {
18
+ const raw = await readFile(path, "utf8").catch(error => { if (error.code === "ENOENT") return null; throw error })
19
+ const data = raw === null ? {} : (tool === "Codex" ? parse(raw) : JSON.parse(raw))
20
+ if (!data || typeof data !== "object" || Array.isArray(data)) throw new Error(`Invalid settings: ${path}`)
21
+ if (tool === "Codex") {
22
+ for (const key of ["marketplaces", "plugins"]) {
23
+ if (data[key] !== undefined && (!data[key] || typeof data[key] !== "object" || Array.isArray(data[key]))) throw new Error(`Invalid ${key}`)
24
+ data[key] ||= {}
25
+ }
26
+ const existing = data.marketplaces.acent
27
+ if (existing && (existing.source_type !== "local" || existing.source !== root)) throw new Error("A different Acent marketplace is already configured; existing settings preserved.")
28
+ data.marketplaces.acent = existing || { source_type: "local", source: root }
29
+ data.plugins["acent@acent"] ||= { enabled: true }
30
+ } else {
31
+ for (const key of ["extraKnownMarketplaces", "enabledPlugins"]) {
32
+ if (data[key] !== undefined && (!data[key] || typeof data[key] !== "object" || Array.isArray(data[key]))) throw new Error(`Invalid ${key}`)
33
+ data[key] ||= {}
34
+ }
35
+ const existing = data.extraKnownMarketplaces.acent
36
+ if (existing && (existing.source?.source !== "directory" || existing.source?.path !== root)) throw new Error("A different Acent marketplace is already configured; existing settings preserved.")
37
+ data.extraKnownMarketplaces.acent = existing || { source: { source: "directory", path: root } }
38
+ // Preserve an explicit user decision to disable the plugin.
39
+ data.enabledPlugins["acent@acent"] ??= true
40
+ }
41
+ await writeFile(temp, (tool === "Codex" ? stringify(data) : JSON.stringify(data, null, 2) + "\n"), { mode: 0o600 })
42
+ // Detect concurrent edits by the app before replacing its settings.
43
+ const current = await readFile(path, "utf8").catch(error => { if (error.code === "ENOENT") return null; throw error })
44
+ if (current !== raw) throw new Error("Settings changed during installation; retry. Existing settings preserved.")
45
+ await rename(temp, path)
46
+ } finally {
47
+ await rm(lock, { recursive: true, force: true })
48
+ }
49
+ }