@cirtium/acent-connect 0.0.0-stage → 0.2.3

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 (39) hide show
  1. package/.agents/plugins/marketplace.json +10 -0
  2. package/.claude-plugin/marketplace.json +5 -0
  3. package/README.md +109 -2
  4. package/acent/.claude-plugin/plugin.json +7 -0
  5. package/acent/.codex-plugin/plugin.json +32 -0
  6. package/acent/.cursor-plugin/plugin.json +13 -0
  7. package/acent/README.md +35 -0
  8. package/acent/assets/logo-dark.svg +7 -0
  9. package/acent/assets/logo.svg +7 -0
  10. package/acent/hooks/claude.json +26 -0
  11. package/acent/hooks/codex.json +26 -0
  12. package/acent/hooks/cursor.json +15 -0
  13. package/acent/mcp-claude.json +12 -0
  14. package/acent/mcp-codex.json +11 -0
  15. package/acent/mcp-cursor.json +15 -0
  16. package/acent/scripts/acent-connect.mjs +440 -0
  17. package/acent/scripts/antigravity-capture.mjs +105 -0
  18. package/acent/scripts/antigravity-hook.mjs +26 -0
  19. package/acent/scripts/capture-attachments.mjs +112 -0
  20. package/acent/scripts/capture-images.mjs +106 -0
  21. package/acent/scripts/clarification.mjs +105 -0
  22. package/acent/scripts/codex-capture.mjs +38 -0
  23. package/acent/scripts/connection-context.mjs +76 -0
  24. package/acent/scripts/connection-result.mjs +30 -0
  25. package/acent/scripts/extract-attachment.swift +19 -0
  26. package/acent/scripts/hook.mjs +32 -0
  27. package/acent/scripts/mcp-proxy.mjs +258 -0
  28. package/acent/scripts/memory-instructions.mjs +14 -0
  29. package/acent/scripts/provide-diff.mjs +200 -0
  30. package/acent/skills/acent-connect/SKILL.md +14 -0
  31. package/acent/skills/acent-memory/SKILL.md +49 -0
  32. package/antigravity/README.md +25 -0
  33. package/antigravity/build.mjs +49 -0
  34. package/antigravity/mcp-local.example.json +12 -0
  35. package/antigravity/mcp.example.json +1 -0
  36. package/antigravity/plugin.json +15 -0
  37. package/package.json +24 -4
  38. package/scripts/acent.mjs +156 -0
  39. package/scripts/install-plugin.mjs +267 -0
@@ -0,0 +1,267 @@
1
+ import { spawn, spawnSync } from "node:child_process"
2
+ import {
3
+ cp,
4
+ mkdir,
5
+ mkdtemp,
6
+ readFile,
7
+ writeFile,
8
+ rename,
9
+ rm,
10
+ lstat,
11
+ stat,
12
+ } from "node:fs/promises"
13
+ import { homedir } from "node:os"
14
+ import { join, dirname } from "node:path"
15
+ import { fileURLToPath } from "node:url"
16
+ import { build } from "../antigravity/build.mjs"
17
+
18
+ export const packageRoot = fileURLToPath(new URL("../", import.meta.url))
19
+ export const tools = ["Codex", "Claude Code", "Cursor", "Antigravity"]
20
+ export const aliases = {
21
+ codex: "Codex",
22
+ claude: "Claude Code",
23
+ "claude-code": "Claude Code",
24
+ cursor: "Cursor",
25
+ antigravity: "Antigravity",
26
+ }
27
+ const keys = {
28
+ Codex: "codex",
29
+ "Claude Code": "claude",
30
+ Cursor: "cursor",
31
+ Antigravity: "antigravity",
32
+ }
33
+ const marker = ".acent-cli-install.json"
34
+
35
+ export function probe(tool, executable) {
36
+ if (tool === "Cursor") {
37
+ return { executable: executable || "cursor", args: ["--version"] }
38
+ }
39
+ return {
40
+ executable:
41
+ executable ||
42
+ { Codex: "codex", "Claude Code": "claude", Antigravity: "agy" }[tool],
43
+ args: ["plugin", "--help"],
44
+ }
45
+ }
46
+ export async function detect(tool, explicit) {
47
+ const info = probe(tool, explicit)
48
+ const candidates = explicit
49
+ ? [explicit]
50
+ : [info.executable, join(homedir(), ".local/bin", info.executable)]
51
+ if (tool === "Antigravity" && !explicit)
52
+ candidates.push(join(homedir(), ".antigravity/antigravity/bin/agy"))
53
+ for (const executable of candidates) {
54
+ const result = spawnSync(executable, info.args, {
55
+ encoding: "utf8",
56
+ timeout: 10000,
57
+ windowsHide: true,
58
+ })
59
+ const output = `${result.stdout || ""}\n${result.stderr || ""}`
60
+ if (
61
+ result.status === 0 &&
62
+ (tool === "Cursor" ||
63
+ /plugin.*(?:install|add)|(?:install|add).*plugin/is.test(output))
64
+ )
65
+ return executable
66
+ }
67
+ if (tool === "Cursor") {
68
+ const paths =
69
+ process.platform === "darwin"
70
+ ? [
71
+ "/Applications/Cursor.app",
72
+ join(homedir(), "Applications/Cursor.app"),
73
+ ]
74
+ : process.platform === "win32"
75
+ ? [
76
+ join(
77
+ process.env.LOCALAPPDATA || homedir(),
78
+ "Programs/cursor/Cursor.exe"
79
+ ),
80
+ ]
81
+ : ["/usr/share/cursor/cursor", "/opt/Cursor/cursor"]
82
+ for (const path of paths)
83
+ if (await stat(path).catch(() => null)) return "cursor"
84
+ }
85
+ return null
86
+ }
87
+ export function installationCommands(
88
+ tool,
89
+ root = packageRoot,
90
+ executable,
91
+ update = false
92
+ ) {
93
+ const command =
94
+ executable ||
95
+ { Codex: "codex", "Claude Code": "claude", Antigravity: "agy" }[tool]
96
+ if (tool === "Cursor") return []
97
+ if (tool === "Antigravity")
98
+ return [
99
+ [command, ["plugin", "validate", "--strict", root]],
100
+ [command, ["plugin", "install", root]],
101
+ ]
102
+ return [
103
+ ...(update
104
+ ? tool === "Claude Code"
105
+ ? [[command, ["plugin", "marketplace", "update", "acent"]]]
106
+ : []
107
+ : [[command, ["plugin", "marketplace", "add", root]]]),
108
+ [
109
+ command,
110
+ tool === "Codex"
111
+ ? ["plugin", "add", "acent@acent"]
112
+ : [
113
+ "plugin",
114
+ update ? "update" : "install",
115
+ "acent@acent",
116
+ "--scope",
117
+ "user",
118
+ ],
119
+ ],
120
+ ]
121
+ }
122
+ export async function run(command, args, cwd) {
123
+ await new Promise((resolve, reject) => {
124
+ const child = spawn(command, args, { cwd, stdio: "inherit", shell: false })
125
+ child.once("error", (error) =>
126
+ reject(
127
+ new Error(
128
+ `Cannot run ${command}: ${error.code || error.message}. Check the tool's CLI installation.`
129
+ )
130
+ )
131
+ )
132
+ child.once("exit", (code) =>
133
+ code === 0
134
+ ? resolve()
135
+ : reject(
136
+ new Error(
137
+ `${command} plugin setup failed (${code}). Connection was not started.`
138
+ )
139
+ )
140
+ )
141
+ })
142
+ }
143
+
144
+ function pluginRoot(tool, home) {
145
+ return tool === "Cursor"
146
+ ? join(home, ".cursor/plugins/local/acent")
147
+ : join(home, ".local/share/acent/plugins", keys[tool])
148
+ }
149
+
150
+ async function readInstallation(root, info) {
151
+ if (!info?.isDirectory()) return null
152
+ return readFile(join(root, marker), "utf8")
153
+ .then(JSON.parse)
154
+ .catch(() => null)
155
+ }
156
+
157
+ export async function isManagedInstallation(tool, home = homedir()) {
158
+ const root = pluginRoot(tool, home)
159
+ const info = await lstat(root).catch((error) => {
160
+ if (error.code !== "ENOENT") throw error
161
+ return null
162
+ })
163
+ return (await readInstallation(root, info))?.owner === "acent-cli"
164
+ }
165
+
166
+ // Plugin code is separate from grants and queues. Never replace an unowned folder.
167
+ export async function installPlugin(
168
+ tool,
169
+ {
170
+ command = "install",
171
+ executable,
172
+ folder,
173
+ home = homedir(),
174
+ execute = run,
175
+ source = packageRoot,
176
+ } = {}
177
+ ) {
178
+ const root = pluginRoot(tool, home)
179
+ await mkdir(dirname(root), { recursive: true })
180
+ const lock = `${root}.lock`
181
+ await mkdir(lock).catch((error) => {
182
+ if (error.code === "EEXIST")
183
+ throw new Error(
184
+ "Another Acent installation is running. Retry after it finishes."
185
+ )
186
+ throw error
187
+ })
188
+ let stage,
189
+ backup,
190
+ replaced = false
191
+ try {
192
+ const info = await lstat(root).catch((error) => {
193
+ if (error.code !== "ENOENT") throw error
194
+ return null
195
+ })
196
+ const previous = await readInstallation(root, info)
197
+ if (info && previous?.owner !== "acent-cli")
198
+ throw new Error(
199
+ `Existing plugin at ${root} is not managed by the Acent CLI. Keep it intact and remove or relocate it through your tool before installing.`
200
+ )
201
+ if (command === "update" && !previous)
202
+ throw new Error(
203
+ `Acent is not installed by this CLI for ${tool}. Run acent install first.`
204
+ )
205
+ stage = await mkdtemp(join(dirname(root), ".acent-stage-"))
206
+ const payload = join(stage, "payload")
207
+ if (tool === "Antigravity") await build({ output: payload })
208
+ else {
209
+ await mkdir(payload)
210
+ if (tool === "Cursor")
211
+ await cp(join(source, "acent"), payload, { recursive: true })
212
+ else
213
+ for (const entry of ["acent", ".agents", ".claude-plugin"])
214
+ await cp(join(source, entry), join(payload, entry), {
215
+ recursive: true,
216
+ })
217
+ }
218
+ const version = JSON.parse(
219
+ await readFile(join(source, "package.json"), "utf8")
220
+ ).version
221
+ await writeFile(
222
+ join(payload, marker),
223
+ JSON.stringify({ owner: "acent-cli", version, tool }) + "\n"
224
+ )
225
+ if (info) {
226
+ backup = join(stage, "previous")
227
+ await rename(root, backup)
228
+ }
229
+ await rename(payload, root)
230
+ replaced = true
231
+ try {
232
+ for (const [program, argv] of installationCommands(
233
+ tool,
234
+ root,
235
+ executable,
236
+ Boolean(previous)
237
+ ))
238
+ await execute(program, argv, folder)
239
+ } catch (error) {
240
+ await rm(root, { recursive: true, force: true })
241
+ replaced = false
242
+ if (backup) {
243
+ await rename(backup, root)
244
+ backup = undefined
245
+ }
246
+ 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.`
248
+ )
249
+ }
250
+ return { root, version }
251
+ } finally {
252
+ try {
253
+ if (backup && !replaced) {
254
+ try {
255
+ await rename(backup, root)
256
+ } catch {
257
+ throw new Error(
258
+ `Could not restore the plugin. Previous files remain at ${backup}; restore them before retrying.`
259
+ )
260
+ }
261
+ }
262
+ if (stage) await rm(stage, { recursive: true, force: true })
263
+ } finally {
264
+ await rm(lock, { recursive: true, force: true })
265
+ }
266
+ }
267
+ }