@cirtium/acent-connect 1.3.0 → 1.3.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.
package/scripts/acent.mjs CHANGED
@@ -17,7 +17,7 @@ export { installationCommands } from "./install-plugin.mjs"
17
17
 
18
18
  const choose = () => chooseTool(tools)
19
19
 
20
- async function applyPlugin(tool, command, settings, folder, execute, dependencies) {
20
+ async function applyPlugin(tool, command, folder, execute, dependencies) {
21
21
  const installed = await (dependencies.install || installPlugin)(tool, {
22
22
  command,
23
23
  folder,
@@ -26,14 +26,14 @@ async function applyPlugin(tool, command, settings, folder, execute, dependencie
26
26
  const action = command === "update" ? "files and settings updated" : "files and settings prepared"
27
27
  console.error(`\nAcent ${installed.version} ${action} for ${tool}.\n`)
28
28
  console.error(installationGuidance(tool) + "\n")
29
- if (command === "install" || command === "update") {
30
- try {
31
- await (dependencies.offerPermission || offerBridgePermission)(tool)
32
- } catch (error) {
33
- console.error(`Bridge permission for ${tool} was not updated: ${error.message}`)
34
- }
29
+ }
30
+
31
+ async function offerPermission(hosts, folder, dependencies) {
32
+ try {
33
+ await (dependencies.offerPermission || offerBridgePermission)(hosts, { folder })
34
+ } catch (error) {
35
+ console.error(`Could not finish updating Bridge permissions: ${error.message}`)
35
36
  }
36
- return true
37
37
  }
38
38
 
39
39
  async function applyAll(command, settings, execute, dependencies) {
@@ -42,23 +42,22 @@ async function applyAll(command, settings, execute, dependencies) {
42
42
  throw new Error("Choose an existing directory.")
43
43
  const updating = command === "update"
44
44
  const failures = []
45
- let completed = 0
45
+ const completed = []
46
46
  for (const tool of tools) {
47
47
  try {
48
48
  if (updating && !(await (dependencies.isManaged || isManagedInstallation)(tool))) continue
49
- const applied = await applyPlugin(
50
- tool, command, { skipUnavailable: !updating }, folder, execute, dependencies
51
- )
52
- if (applied) completed++
49
+ await applyPlugin(tool, command, folder, execute, dependencies)
50
+ completed.push(tool)
53
51
  } catch (error) {
54
52
  failures.push(`${tool}: ${error.message}`)
55
53
  }
56
54
  }
55
+ if (completed.length) await offerPermission(completed, folder, dependencies)
57
56
  if (failures.length)
58
57
  throw new Error(`Acent could not ${command} for every tool:\n${failures.join("\n")}`)
59
- if (!completed && !updating)
58
+ if (!completed.length && !updating)
60
59
  throw new Error("No plugins were installed.")
61
- if (!completed) console.error("No Acent plugins installed by this CLI were found.")
60
+ if (!completed.length) console.error("No Acent plugins installed by this CLI were found.")
62
61
  }
63
62
 
64
63
  export async function main(
@@ -71,7 +70,7 @@ export async function main(
71
70
  if (args.includes("--help") || args[0] === "help") {
72
71
  console.log(
73
72
  [
74
- "Usage\n\n acent [connect|install|update|disconnect|flush]\n [--tool codex|claude|cursor|antigravity] [--folder PATH]",
73
+ "Usage\n\n acent [connect|install|update|disconnect|flush|status]\n [--tool codex|claude|cursor|antigravity] [--folder PATH]",
75
74
  "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
75
  "Connect\n\n acent connect\n\n Run in your project folder. Running acent without a command also starts connection.",
77
76
  "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 +82,9 @@ export async function main(
83
82
  const command =
84
83
  !args.length || args[0].startsWith("--") ? "connect" : args.shift()
85
84
  if (
86
- !["connect", "install", "update", "disconnect", "flush"].includes(command)
85
+ !["connect", "install", "update", "disconnect", "flush", "status"].includes(command)
87
86
  )
88
- throw new Error("Use connect, install, update, disconnect, or flush")
87
+ throw new Error("Use connect, install, update, disconnect, flush, or status")
89
88
  const settings = {}
90
89
  let all = false
91
90
  for (let i = 0; i < args.length; i++) {
@@ -127,8 +126,9 @@ export async function main(
127
126
  if (!(await stat(config.folder)).isDirectory())
128
127
  throw new Error("Open an existing project folder before connecting.")
129
128
  if (["connect", "install", "update"].includes(command))
130
- await applyPlugin(tool, command, settings, config.folder, execute, dependencies)
131
- if (!["install", "update"].includes(command)) await connect(adapterArgs)
129
+ await applyPlugin(tool, command, config.folder, execute, dependencies)
130
+ if (["install", "update"].includes(command)) await offerPermission(tool, config.folder, dependencies)
131
+ else await connect(adapterArgs)
132
132
  }
133
133
  if (
134
134
  process.argv[1] &&
@@ -1,6 +1,8 @@
1
1
  import { homedir } from "node:os"
2
2
  import { join } from "node:path"
3
3
  import { createInterface } from "node:readline/promises"
4
+ import { bridgeTargets } from "../acent/scripts/bridge-runners.mjs"
5
+ import { bridgeProject, newProjectCodeGrant } from "../acent/scripts/bridge-project-permissions.mjs"
4
6
  import { editSettings } from "./local-registration.mjs"
5
7
 
6
8
  const bridgeTool = "acent_bridge_start"
@@ -13,13 +15,7 @@ function addRule(object, key, rule) {
13
15
  return true
14
16
  }
15
17
 
16
- export async function offerBridgePermission(tool, {
17
- home = homedir(),
18
- input = process.stdin,
19
- output = process.stderr,
20
- ask,
21
- } = {}) {
22
- if (!ask && !input.isTTY) return
18
+ async function allowHost(tool, home, confirm) {
23
19
  const codex = tool === "Codex"
24
20
  const claude = tool === "Claude Code"
25
21
  const cursor = tool === "Cursor"
@@ -45,6 +41,27 @@ export async function offerBridgePermission(tool, {
45
41
  ? `mcp__plugin_acent_acent__${bridgeTool}`
46
42
  : `mcp(acent/${bridgeTool})`)
47
43
  }
44
+ let decision
45
+ await editSettings(path, codex, async data => {
46
+ if (!change(data)) return false
47
+ const allowed = await confirm()
48
+ decision = allowed ? "allowed" : "skipped"
49
+ return allowed
50
+ })
51
+ return decision
52
+ }
53
+
54
+ export async function offerBridgePermission(tool, {
55
+ folder,
56
+ home = homedir(),
57
+ input = process.stdin,
58
+ output = process.stderr,
59
+ ask,
60
+ } = {}) {
61
+ if (!ask && !input.isTTY) return
62
+ const hosts = Array.isArray(tool) ? tool : [tool]
63
+ if (!hosts.length) return
64
+ const hostLabel = host => host === "Antigravity" ? "Antigravity CLI" : host
48
65
  const select = ask ?? (async question => {
49
66
  const prompt = createInterface({ input, output })
50
67
  try {
@@ -54,15 +71,35 @@ export async function offerBridgePermission(tool, {
54
71
  }
55
72
  })
56
73
  const decisionPath = join(home, ".local", "share", "acent", "bridge-host-permissions.json")
74
+ const project = await bridgeProject(folder, home)
57
75
  await editSettings(decisionPath, false, async decisions => {
58
- if (decisions[tool] !== undefined) return false
59
- await editSettings(path, codex, async data => {
60
- if (!change(data)) return false
61
- const host = tool === "Antigravity" ? "Antigravity CLI" : tool
62
- const allowed = await select(`Always allow Acent Bridge to start in ${host} across projects? [y/N] `)
63
- decisions[tool] = allowed ? "allowed" : "skipped"
64
- return allowed
65
- })
66
- return decisions[tool] !== undefined
76
+ let combined
77
+ if (project) {
78
+ await editSettings(project.path, false, async grant => {
79
+ if (grant.status !== undefined) return false
80
+ const destinations = bridgeTargets.map(hostLabel).join(", ")
81
+ const installedHosts = hosts.map(hostLabel).join(", ")
82
+ combined = await select([
83
+ "Allow Acent Bridge to start without a tool prompt where host policy permits?",
84
+ `Host tool permission across projects: ${installedHosts}`,
85
+ `Project code sharing: ${JSON.stringify(project.root)}`,
86
+ `Destinations for this project's scoped files: ${destinations}`,
87
+ "Allow future code handoffs for implementation, review, and diagnosis in this project.",
88
+ "Other data and broader file scopes still need approval. [y/N] ",
89
+ ].join("\n"))
90
+ Object.assign(grant, combined ? newProjectCodeGrant() : { status: "skipped" })
91
+ })
92
+ }
93
+ let changed = false
94
+ for (const host of hosts) {
95
+ if (decisions[host] !== undefined && !(combined && decisions[host] === "skipped")) continue
96
+ const decision = await allowHost(host, home, () => combined ?? select(
97
+ `Always allow Acent Bridge to start in ${hostLabel(host)} across projects? [y/N] `
98
+ ))
99
+ if (!decision) continue
100
+ decisions[host] = decision
101
+ changed = true
102
+ }
103
+ return changed
67
104
  })
68
105
  }