@chipschat/acp 1.0.12 → 1.0.14

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/README.md CHANGED
@@ -16,7 +16,7 @@ bundles them into `dist/main.js`.
16
16
  The card's line is `CHIPS_JOIN_LINK='<link>' chips connect claude-code` or `CHIPS_JOIN_LINK='<link>' chips connect codex` (Chips ADR 0218). It downloads this bridge as the npm package
17
17
  `@chipschat/acp`, the newest 1.x, checks it against the registry's checksum, and runs it on the Node
18
18
  that Chips carries, so the machine needs no Node or npm of its own. The bridge checks the agent's ACP adapter and its sign-in,
19
- joins, and keeps itself running from login. `chips disconnect claude-code` or `chips disconnect codex` stops it. Claude Code and Codex share this one package: their cards hand it `~/.chips-acp/claude-code.json` or `codex.json`, and the file's name picks the kind. On another computer,
19
+ joins, and keeps itself running from login. `chips disconnect claude-code` or `chips disconnect codex` stops it. Claude Code and Codex share this one package: their cards hand it `~/Chips/.bridges/acp/claude-code.json` or `codex.json`, and the file's name picks the kind. On another computer,
20
20
  `curl -fsSL https://chipschat.ai/install | CHIPS_JOIN_LINK='<link>' sh -s -- connect claude-code` installs Chips there
21
21
  first. The steps below run the bridge from this checkout instead, to work on it.
22
22
 
@@ -25,7 +25,7 @@ first. The steps below run the bridge from this checkout instead, to work on it.
25
25
  ```bash
26
26
  npm install -g @agentclientprotocol/claude-agent-acp # or @agentclientprotocol/codex-acp
27
27
  npm install
28
- CHIPS_JOIN_LINK='<a join link made in Chips>' npm run keep ~/.chips-acp/claude-code.json
28
+ CHIPS_JOIN_LINK='<a join link made in Chips>' npm run keep ~/Chips/.bridges/acp/claude-code.json
29
29
  ```
30
30
 
31
31
  `npm run keep` joins, then keeps the bridge running from login ("Keep it running", below);
@@ -35,7 +35,7 @@ The link comes from Chips's gallery (Agents → Connect a harness → Claude Cod
35
35
  line with the link in it (`codex.json` for Codex) and starts the link with what it needs on:
36
36
  `agents`, `new_spaces`, `new_agents`, `forks` and `restarts`. `claude-code.json` and `codex.json`
37
37
  need not be there: without them the bridge runs Claude Code or Codex, in the mode that asks (see
38
- "Asking a person"), with each agent's folder under `~/chips-acp/claude-code` or `~/chips-acp/codex`.
38
+ "Asking a person"), with each agent's folder under `~/Chips/Agents/claude-code` or `~/Chips/Agents/codex`.
39
39
 
40
40
  Before it takes the link up, which works once, it checks:
41
41
  - the config is there, or is one of those two;
@@ -49,25 +49,36 @@ room once, which the card waits for; a new link from Chips replaces the key it k
49
49
  link, set `CHIPS_URL` and allow the code it prints from Chips. Its key is kept as `join()` keeps
50
50
  one (the keychain, under the kind's name); its cursor, unanswered events, unended runs, its agents
51
51
  and which session each of their rooms is are kept in a folder beside the config, named after it
52
- (`~/.chips-acp/claude-code/`), so a restart picks up where it was. Each start logs whether the
52
+ (`~/Chips/.bridges/acp/claude-code/`), so a restart picks up where it was. Each start logs whether the
53
53
  agent says it is signed in, and a turn it refuses for that says how to sign in.
54
54
 
55
55
  The config names one kind:
56
56
 
57
57
  ```json
58
- { "name": "Claude Code", "command": ["claude-agent-acp"], "mode": "default", "folders": "~/chips-acp/claude-code" }
58
+ { "name": "Claude Code", "command": ["claude-agent-acp"], "mode": "default", "folders": "~/Chips/Agents/claude-code" }
59
59
  ```
60
60
 
61
61
  - `name` is the harness's name in Chips, and its own agent's.
62
62
  - `command` is how the agent speaks ACP over stdio: `["claude-agent-acp"]`, `["codex-acp"]`,
63
63
  `["goose", "acp"]`, `["gemini", "--acp"]`, `["opencode", "acp"]`.
64
- - `folders` is where each agent gets a folder of its own, named after it (`~/chips-acp/claude-code/nova`),
64
+ - `folders` is where each agent gets a folder of its own, named after it (`~/Chips/Agents/claude-code/nova`),
65
65
  made empty. A copy from Fork works on in its original's folder, with the files the conversation it
66
66
  remembers expects. A deleted agent's folder stays.
67
67
  - `folder`, in its place, puts every agent in one folder: a repository they work on together.
68
68
  - `mode` is the mode its sessions are put in, of those the agent offers (see below). `env` adds to
69
69
  its environment.
70
70
 
71
+ Everything it keeps is under `~/Chips` (Chips ADR 0283): the configs and what each kind keeps in
72
+ `~/Chips/.bridges/acp`, the agents' folders in `~/Chips/Agents`. Until 1.0.13 they were
73
+ `~/.chips-acp` and `~/chips-acp`. A kind moves what it had there the first time 1.0.13 starts: its
74
+ config and what it keeps, its agents' folders (where its config named the old place, or nothing),
75
+ the folder paths it saved, and Claude Code's own store for each folder that moved
76
+ (`~/.claude/projects/<the folder's path, dashed>`), which holds the folder's conversations and memory.
77
+ It renames and never copies; where something is at the new place already it moves in what isn't
78
+ there yet and says in its log what it left. A config path in the old place, from an older Chips's
79
+ card or a login item kept before, is read in the new one, and the login item is kept with the new
80
+ path.
81
+
71
82
  Installing any other agent and signing it in to a model is done the agent's own way, before it is
72
83
  named here. A second kind is a second config, and a second bridge beside the first.
73
84
 
@@ -167,7 +178,7 @@ where the harness is granted `context_files`, `models` and `context_windows`.
167
178
  | Chips | Claude Code | Codex | Another kind |
168
179
  |---|---|---|---|
169
180
  | Context: its own files | its folder's `CLAUDE.md`, and `CLAUDE.local.md`, `.claude/CLAUDE.md` and `.claude/rules/*.md` where they are; its memory, `~/.claude/projects/<its folder>/memory/MEMORY.md`, which Claude Code writes too. A person may change each, and one not there yet shows empty | its folder's `AGENTS.override.md`, else its `AGENTS.md`; a person may change it | none |
170
- | Context: shared | `~/chips-acp/claude-code/CLAUDE.md`, read by every agent, changed on the harness's page; files above the agents' folders and `~/.claude/CLAUDE.md`, shown and not changed, since they aren't only these agents' | `~/.codex/AGENTS.override.md`, else `~/.codex/AGENTS.md`, shown and not changed | none |
181
+ | Context: shared | `~/Chips/Agents/claude-code/CLAUDE.md`, read by every agent, changed on the harness's page; files above the agents' folders and `~/.claude/CLAUDE.md`, shown and not changed, since they aren't only these agents' | `~/.codex/AGENTS.override.md`, else `~/.codex/AGENTS.md`, shown and not changed | none |
171
182
  | When it reads them | when a session starts; an edit closes the agent's sessions before its next turn and loads them again, so it applies from the next message | the same | |
172
183
  | Context window | `usage_update` of the agent's session that said last; the window from the update that ends a turn (it carries the cost), as one before may be a default | `usage_update` | `usage_update` |
173
184
  | Compact now | `/compact` said to that session as a turn of its own, after any turn going there; its words go nowhere; from and to from its tool call's `rawOutput` | the same; to from the `usage_update` it sends as it finishes | where it lists `compact` among its commands |
@@ -1,6 +1,6 @@
1
1
  # Third-party notices
2
2
 
3
- `dist/main.js` in @chipschat/acp 1.0.12 carries these packages, bundled in. Each one's
3
+ `dist/main.js` in @chipschat/acp 1.0.14 carries these packages, bundled in. Each one's
4
4
  licence follows.
5
5
 
6
6
  ## @chipschat/harness 1.0.2 (Apache-2.0)
package/dist/main.js CHANGED
@@ -8,9 +8,8 @@ var __export = (target, all) => {
8
8
  };
9
9
 
10
10
  // src/main.ts
11
- import { existsSync as existsSync8, mkdirSync as mkdirSync4, readFileSync as readFileSync9, writeFileSync as writeFileSync4 } from "node:fs";
12
- import { homedir as homedir7 } from "node:os";
13
- import { basename as basename5, dirname as dirname5, join as join10, resolve as resolve4 } from "node:path";
11
+ import { existsSync as existsSync10, mkdirSync as mkdirSync5, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "node:fs";
12
+ import { basename as basename6, dirname as dirname6, join as join11 } from "node:path";
14
13
 
15
14
  // node_modules/zod/v4/classic/external.js
16
15
  var external_exports = {};
@@ -5106,7 +5105,7 @@ function isRecursive(inst, stack, resolve5) {
5106
5105
  }
5107
5106
  return answer;
5108
5107
  };
5109
- const merge2 = (answer) => {
5108
+ const merge3 = (answer) => {
5110
5109
  if (answer > result)
5111
5110
  result = answer;
5112
5111
  };
@@ -5115,7 +5114,7 @@ function isRecursive(inst, stack, resolve5) {
5115
5114
  switch (kind2) {
5116
5115
  case "object": {
5117
5116
  const raw = rawShape(def);
5118
- merge2(raw ? shape(raw, true) : ASSUMED);
5117
+ merge3(raw ? shape(raw, true) : ASSUMED);
5119
5118
  check2(def.catchall);
5120
5119
  break;
5121
5120
  }
@@ -5165,7 +5164,7 @@ function isRecursive(inst, stack, resolve5) {
5165
5164
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
5166
5165
  case "lazy": {
5167
5166
  const inner = def._cachedInner ?? (resolve5 ? inst._zod.innerType : void 0);
5168
- merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
5167
+ merge3(inner ? isRecursive(inner, stack, false) : ASSUMED);
5169
5168
  break;
5170
5169
  }
5171
5170
  // a leaf by choice: `parts` are regex fragments, not data positions
@@ -23397,8 +23396,8 @@ var Project = class {
23397
23396
  const end2 = all.findIndex((line, at) => at > start && line.startsWith(">>>>>>> "));
23398
23397
  if (start < 0 || end2 < 0)
23399
23398
  return void 0;
23400
- const shown = all.slice(Math.max(0, start - 1), end2 + 2);
23401
- return shown.length <= MARKED_LINES ? shown.join("\n") : [...shown.slice(0, MARKED_LINES - 1), "\u2026"].join("\n");
23399
+ const shown2 = all.slice(Math.max(0, start - 1), end2 + 2);
23400
+ return shown2.length <= MARKED_LINES ? shown2.join("\n") : [...shown2.slice(0, MARKED_LINES - 1), "\u2026"].join("\n");
23402
23401
  } catch {
23403
23402
  return void 0;
23404
23403
  }
@@ -25303,7 +25302,7 @@ async function ask(url2, options, send, machine) {
25303
25302
  if (asked.status !== 201)
25304
25303
  throw await refused(asked);
25305
25304
  const { request_id, secret, code, interval } = await asked.json();
25306
- const show = options.onCode ?? ((shown, where) => process.stderr.write(`Allow ${options.name} in Chips at ${where}. Its code is ${shown}.
25305
+ const show = options.onCode ?? ((shown2, where) => process.stderr.write(`Allow ${options.name} in Chips at ${where}. Its code is ${shown2}.
25307
25306
  `));
25308
25307
  show(code, url2);
25309
25308
  for (; ; ) {
@@ -26162,11 +26161,11 @@ import { createHash as createHash2 } from "node:crypto";
26162
26161
  import { readdirSync, readFileSync as readFileSync6, statSync } from "node:fs";
26163
26162
  import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
26164
26163
  import { dirname as dirname4, join as join6, parse as parse3, relative, sep as sep2 } from "node:path";
26165
- function placesOf(env2, home3) {
26164
+ function placesOf(env2, home) {
26166
26165
  return {
26167
- home: home3,
26168
- claudeHome: env2["CLAUDE_CONFIG_DIR"] || join6(home3, ".claude"),
26169
- codexHome: env2["CODEX_HOME"] || join6(home3, ".codex")
26166
+ home,
26167
+ claudeHome: env2["CLAUDE_CONFIG_DIR"] || join6(home, ".claude"),
26168
+ codexHome: env2["CODEX_HOME"] || join6(home, ".codex")
26170
26169
  };
26171
26170
  }
26172
26171
  function hashOf(text) {
@@ -26228,15 +26227,15 @@ var ContextFiles = class {
26228
26227
  kind;
26229
26228
  places;
26230
26229
  docBytes;
26231
- /** `~/chips-acp/claude-code/CLAUDE.md`, or the whole path where it isn't in the home. */
26230
+ /** `~/Chips/Agents/claude-code/CLAUDE.md`, or the whole path where it isn't in the home. */
26232
26231
  tilde(path) {
26233
- const { home: home3 } = this.places;
26234
- return within(path, home3) ? `~${path.slice(home3.length)}` : path;
26232
+ const { home } = this.places;
26233
+ return within(path, home) ? `~${path.slice(home.length)}` : path;
26235
26234
  }
26236
26235
  /** A shared file's name: where it is, a step at a time (`~ › .codex › AGENTS.md`), with no slash. */
26237
26236
  crumbs(path) {
26238
- const { home: home3 } = this.places;
26239
- const steps = within(path, home3) ? ["~", ...relative(home3, path).split(sep2)] : ["/", ...path.split(sep2)];
26237
+ const { home } = this.places;
26238
+ const steps = within(path, home) ? ["~", ...relative(home, path).split(sep2)] : ["/", ...path.split(sep2)];
26240
26239
  return steps.filter((step) => step !== "").join(" \u203A ").slice(0, 255);
26241
26240
  }
26242
26241
  /** The harness's own set: what every agent, or every agent below a folder, reads beside its own. */
@@ -28340,12 +28339,59 @@ function forkName(original) {
28340
28339
  }
28341
28340
 
28342
28341
  // src/keep.ts
28343
- import { homedir as homedir5 } from "node:os";
28344
- import { basename as basename3, join as join8, resolve as resolve2 } from "node:path";
28342
+ import { basename as basename3 } from "node:path";
28345
28343
  import { fileURLToPath as fileURLToPath2 } from "node:url";
28344
+
28345
+ // src/places.ts
28346
+ import { existsSync as existsSync7 } from "node:fs";
28347
+ import { homedir as homedir5 } from "node:os";
28348
+ import { isAbsolute as isAbsolute2, join as join8, relative as relative2, resolve as resolve2, sep as sep3 } from "node:path";
28349
+ function placesOf2(home = homedir5()) {
28350
+ return {
28351
+ settings: join8(home, "Chips", ".bridges", "acp"),
28352
+ agents: join8(home, "Chips", "Agents"),
28353
+ oldSettings: join8(home, ".chips-acp"),
28354
+ oldAgents: join8(home, "chips-acp")
28355
+ };
28356
+ }
28357
+ var fromHome = (path, home = homedir5()) => path === "~" ? home : path.startsWith("~/") ? join8(home, path.slice(2)) : path;
28358
+ function inside2(root, path) {
28359
+ const under = relative2(root, path);
28360
+ return under === "" || under === ".." || under.startsWith(`..${sep3}`) || isAbsolute2(under) ? void 0 : under;
28361
+ }
28362
+ function nowAt(path, before, after) {
28363
+ const under = inside2(before, path);
28364
+ if (under === void 0) return path;
28365
+ const moved = join8(after, under);
28366
+ return existsSync7(path) && !existsSync7(moved) ? path : moved;
28367
+ }
28368
+ function configTargetOf(word, home = homedir5()) {
28369
+ const places = placesOf2(home);
28370
+ const path = resolve2(fromHome(word ?? join8(places.settings, "config.json"), home));
28371
+ const under = inside2(places.oldSettings, path);
28372
+ return under === void 0 ? path : join8(places.settings, under);
28373
+ }
28374
+ function configPathOf(word, home = homedir5()) {
28375
+ const places = placesOf2(home);
28376
+ const target = configTargetOf(word, home);
28377
+ const under = inside2(places.settings, target);
28378
+ const old = under === void 0 ? void 0 : join8(places.oldSettings, under);
28379
+ return old !== void 0 && existsSync7(old) && !existsSync7(target) ? old : target;
28380
+ }
28381
+ function foldersPathOf(path, home = homedir5()) {
28382
+ const places = placesOf2(home);
28383
+ const whole2 = resolve2(fromHome(path, home));
28384
+ const under = inside2(places.agents, whole2);
28385
+ const old = under === void 0 ? void 0 : join8(places.oldAgents, under);
28386
+ if (old !== void 0 && existsSync7(old) && !existsSync7(whole2)) return old;
28387
+ return nowAt(whole2, places.oldAgents, places.agents);
28388
+ }
28389
+
28390
+ // src/keep.ts
28346
28391
  var flags = process.argv.slice(2);
28347
28392
  var words3 = flags.filter((word) => !word.startsWith("--"));
28348
- var whole = (word) => resolve2(word.startsWith("~/") ? join8(homedir5(), word.slice(2)) : word);
28393
+ var handsOver = flags.includes("--keep");
28394
+ var whole = (word) => configTargetOf(word);
28349
28395
  var here = fileURLToPath2(new URL("..", import.meta.url)).replace(/\/$/, "");
28350
28396
  var self = fileURLToPath2(import.meta.url);
28351
28397
  var run = self.endsWith(".js") ? [self] : ["--import", "tsx", "src/main.ts"];
@@ -28390,10 +28436,14 @@ function keepIfAsked(label2, url2, names, log2, before = () => void 0) {
28390
28436
  );
28391
28437
  }
28392
28438
 
28393
- // src/setup.ts
28394
- import { accessSync as accessSync2, constants as constants2, existsSync as existsSync7, readFileSync as readFileSync8 } from "node:fs";
28439
+ // src/move.ts
28440
+ import { lstatSync, mkdirSync as mkdirSync4, readdirSync as readdirSync2, readFileSync as readFileSync9, renameSync as renameSync2, rmdirSync, writeFileSync as writeFileSync4 } from "node:fs";
28395
28441
  import { homedir as homedir6 } from "node:os";
28396
- import { basename as basename4, delimiter as delimiter2, isAbsolute as isAbsolute2, join as join9, resolve as resolve3 } from "node:path";
28442
+ import { basename as basename5, dirname as dirname5, join as join10, resolve as resolve4 } from "node:path";
28443
+
28444
+ // src/setup.ts
28445
+ import { accessSync as accessSync2, constants as constants2, existsSync as existsSync8, readFileSync as readFileSync8 } from "node:fs";
28446
+ import { basename as basename4, delimiter as delimiter2, isAbsolute as isAbsolute3, join as join9, resolve as resolve3 } from "node:path";
28397
28447
  var SetupError = class extends Error {
28398
28448
  constructor(message, words4 = {}) {
28399
28449
  super(message);
@@ -28403,16 +28453,15 @@ var SetupError = class extends Error {
28403
28453
  name = "SetupError";
28404
28454
  };
28405
28455
  var STILL_GOOD = "The link is still good: run the same command again once that's done.";
28406
- var EXAMPLE = '{ "name": "Claude Code", "command": ["claude-agent-acp"], "folders": "~/chips-acp/claude-code" }';
28407
- var home = (path) => path.startsWith("~/") ? join9(homedir6(), path.slice(2)) : path;
28456
+ var EXAMPLE = '{ "name": "Claude Code", "command": ["claude-agent-acp"], "folders": "~/Chips/Agents/claude-code" }';
28408
28457
  function readConfig(path) {
28409
28458
  const known = knownConfig(basename4(path, ".json"));
28410
- if (!existsSync7(path) && known === void 0) {
28459
+ if (!existsSync8(path) && known === void 0) {
28411
28460
  throw new SetupError(
28412
28461
  `There is no config at ${path}. Write ${EXAMPLE} there, or name claude-code.json or codex.json, which need none. ${STILL_GOOD}`
28413
28462
  );
28414
28463
  }
28415
- const raw = existsSync7(path) ? JSON.parse(readFileSync8(path, "utf8")) : known;
28464
+ const raw = existsSync8(path) ? JSON.parse(readFileSync8(path, "utf8")) : known;
28416
28465
  const name = raw["name"];
28417
28466
  const command = raw["command"];
28418
28467
  if (typeof name !== "string" || name.trim() === "" || !Array.isArray(command) || command.length === 0) {
@@ -28422,8 +28471,8 @@ function readConfig(path) {
28422
28471
  return {
28423
28472
  name,
28424
28473
  command: command.map(String),
28425
- folders: resolve3(home(typeof raw["folders"] === "string" ? raw["folders"] : `~/chips-acp/${slug}`)),
28426
- ...typeof raw["folder"] === "string" ? { folder: resolve3(home(raw["folder"])) } : {},
28474
+ folders: foldersPathOf(typeof raw["folders"] === "string" ? raw["folders"] : `~/Chips/Agents/${slug}`),
28475
+ ...typeof raw["folder"] === "string" ? { folder: foldersPathOf(raw["folder"]) } : {},
28427
28476
  ...typeof raw["mode"] === "string" ? { mode: raw["mode"] } : {},
28428
28477
  ...typeof raw["env"] === "object" && raw["env"] !== null ? { env: raw["env"] } : {}
28429
28478
  };
@@ -28440,7 +28489,7 @@ function checkCommand(kind2, env2 = process.env) {
28440
28489
  const [program] = kind2.command;
28441
28490
  if (program === void 0) throw new SetupError(`${kind2.name} has no command to run. ${STILL_GOOD}`);
28442
28491
  const path = { ...env2, ...kind2.env }["PATH"] ?? "";
28443
- const found = program.includes("/") ? runnable(isAbsolute2(program) ? program : resolve3(home(program))) : path.split(delimiter2).some((dir) => dir !== "" && runnable(join9(dir, program)));
28492
+ const found = program.includes("/") ? runnable(isAbsolute3(program) ? program : resolve3(fromHome(program))) : path.split(delimiter2).some((dir) => dir !== "" && runnable(join9(dir, program)));
28444
28493
  if (!found) {
28445
28494
  throw new SetupError(
28446
28495
  `${kind2.name}'s command, ${program}, isn't on this machine's PATH: ${installWords(kind2)}. ${STILL_GOOD}`,
@@ -28504,18 +28553,147 @@ async function checkSignIn(kind2, wire, cwd, options = {}) {
28504
28553
  }
28505
28554
  }
28506
28555
 
28556
+ // src/move.ts
28557
+ var there = (path) => {
28558
+ try {
28559
+ lstatSync(path);
28560
+ return true;
28561
+ } catch {
28562
+ return false;
28563
+ }
28564
+ };
28565
+ var isFolder = (path) => lstatSync(path).isDirectory();
28566
+ var shown = (path, home) => path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
28567
+ function merge2(from, to, log2, home = homedir6(), quiet = false) {
28568
+ if (!there(from)) return;
28569
+ try {
28570
+ if (!there(to)) {
28571
+ mkdirSync4(dirname5(to), { recursive: true });
28572
+ renameSync2(from, to);
28573
+ if (!quiet) log2(`moved ${shown(from, home)} to ${shown(to, home)}`);
28574
+ return;
28575
+ }
28576
+ if (!isFolder(from) || !isFolder(to)) {
28577
+ log2(`${shown(from, home)} was left where it is: ${shown(to, home)} is there already`);
28578
+ return;
28579
+ }
28580
+ for (const entry of readdirSync2(from)) merge2(join10(from, entry), join10(to, entry), log2, home, true);
28581
+ if (readdirSync2(from).length === 0) rmdirSync(from);
28582
+ if (!quiet) log2(`moved what was in ${shown(from, home)} into ${shown(to, home)}`);
28583
+ } catch (error62) {
28584
+ log2(`${shown(from, home)} couldn't be moved to ${shown(to, home)}, so it is used where it is: ${error62.message}`);
28585
+ }
28586
+ }
28587
+ function removeIfEmpty(path) {
28588
+ try {
28589
+ if (readdirSync2(path).length === 0) rmdirSync(path);
28590
+ } catch {
28591
+ }
28592
+ }
28593
+ function claudeStoreOf(folder2, env2, home = homedir6()) {
28594
+ const name = folder2.replace(/[^a-zA-Z0-9]/g, "-");
28595
+ if (name.length > 200) return void 0;
28596
+ return join10(env2["CLAUDE_CONFIG_DIR"] ? resolve4(fromHome(env2["CLAUDE_CONFIG_DIR"], home)) : join10(home, ".claude"), "projects", name);
28597
+ }
28598
+ function pairOf(path, places) {
28599
+ const old = inside2(places.oldAgents, path);
28600
+ if (old !== void 0) return { old: path, now: join10(places.agents, old) };
28601
+ const now = inside2(places.agents, path);
28602
+ return now === void 0 ? void 0 : { old: join10(places.oldAgents, now), now: path };
28603
+ }
28604
+ function writeJson(path, value) {
28605
+ const next = `${path}.next`;
28606
+ writeFileSync4(next, `${JSON.stringify(value, null, 2)}
28607
+ `, { mode: 384 });
28608
+ renameSync2(next, path);
28609
+ }
28610
+ var readJson = (path) => {
28611
+ try {
28612
+ const read = JSON.parse(readFileSync9(path, "utf8"));
28613
+ return typeof read === "object" && read !== null ? read : void 0;
28614
+ } catch {
28615
+ return void 0;
28616
+ }
28617
+ };
28618
+ function moveOld(configPath2, log2, home = homedir6(), env2 = process.env) {
28619
+ const places = placesOf2(home);
28620
+ const keptIn = join10(dirname5(configPath2), basename5(configPath2, ".json"));
28621
+ const name = inside2(places.settings, configPath2);
28622
+ if (name !== void 0) {
28623
+ mkdirSync4(dirname5(dirname5(places.settings)), { recursive: true });
28624
+ mkdirSync4(places.settings, { recursive: true, mode: 448 });
28625
+ merge2(join10(places.oldSettings, name), configPath2, log2, home);
28626
+ merge2(join10(places.oldSettings, name.replace(/\.json$/, "")), keptIn, log2, home);
28627
+ }
28628
+ let roots;
28629
+ let kindEnv;
28630
+ try {
28631
+ const kind2 = readConfig(configPath2);
28632
+ roots = [kind2.folders, kind2.folder].filter((root) => root !== void 0);
28633
+ kindEnv = kind2.env;
28634
+ } catch {
28635
+ return;
28636
+ }
28637
+ const pairs = roots.map((root) => pairOf(root, places)).filter((pair) => pair !== void 0);
28638
+ for (const { old, now } of pairs) merge2(old, now, log2, home);
28639
+ const config2 = readJson(configPath2);
28640
+ if (config2 !== void 0) {
28641
+ let changed = false;
28642
+ for (const key of ["folders", "folder"]) {
28643
+ const said = config2[key];
28644
+ if (typeof said !== "string") continue;
28645
+ const path = resolve4(fromHome(said, home));
28646
+ const moved = nowAt(path, places.oldAgents, places.agents);
28647
+ if (moved === path) continue;
28648
+ config2[key] = `~/${moved.slice(home.length + 1)}`;
28649
+ changed = true;
28650
+ }
28651
+ if (changed) writeJson(configPath2, config2);
28652
+ }
28653
+ const statePath2 = join10(keptIn, "state.json");
28654
+ const state2 = readJson(statePath2);
28655
+ const agents = state2?.["agents"];
28656
+ if (state2 !== void 0 && typeof agents === "object" && agents !== null) {
28657
+ let changed = false;
28658
+ for (const record2 of Object.values(agents)) {
28659
+ const folder2 = record2["folder"];
28660
+ if (typeof folder2 !== "string") continue;
28661
+ const moved = nowAt(folder2, places.oldAgents, places.agents);
28662
+ if (moved === folder2) continue;
28663
+ record2["folder"] = moved;
28664
+ changed = true;
28665
+ }
28666
+ if (changed) writeJson(statePath2, state2);
28667
+ }
28668
+ const storeEnv = { ...env2, ...kindEnv };
28669
+ for (const { old, now } of pairs) {
28670
+ if (there(old) || !there(now)) continue;
28671
+ const folders = [{ old, now }];
28672
+ for (const entry of readdirSync2(now)) {
28673
+ if (isFolder(join10(now, entry))) folders.push({ old: join10(old, entry), now: join10(now, entry) });
28674
+ }
28675
+ for (const folder2 of folders) {
28676
+ const from = claudeStoreOf(folder2.old, storeEnv, home);
28677
+ const to = claudeStoreOf(folder2.now, storeEnv, home);
28678
+ if (from !== void 0 && to !== void 0 && !there(folder2.old)) merge2(from, to, log2, home);
28679
+ }
28680
+ }
28681
+ removeIfEmpty(places.oldSettings);
28682
+ removeIfEmpty(places.oldAgents);
28683
+ }
28684
+
28507
28685
  // src/main.ts
28508
- var home2 = (path) => path.startsWith("~/") ? join10(homedir7(), path.slice(2)) : path;
28509
28686
  var link = process.env["CHIPS_JOIN_LINK"] || void 0;
28510
- var configPath = resolve4(home2(words3[0] ?? "~/.chips-acp/config.json"));
28511
- var LABEL = `chat.chips.acp.${basename5(configPath, ".json")}`;
28687
+ var LABEL = `chat.chips.acp.${basename6(configTargetOf(words3[0]), ".json")}`;
28512
28688
  stopIfAsked(LABEL);
28513
- var kind;
28514
28689
  var log = (line) => process.stdout.write(`${(/* @__PURE__ */ new Date()).toISOString()} ${line}
28515
28690
  `);
28691
+ if (!handsOver) moveOld(configTargetOf(words3[0]), log);
28692
+ var configPath = configPathOf(words3[0]);
28693
+ var kind;
28516
28694
  try {
28517
28695
  kind = readConfig(configPath);
28518
- mkdirSync4(kind.folder ?? kind.folders, { recursive: true });
28696
+ mkdirSync5(kind.folder ?? kind.folders, { recursive: true });
28519
28697
  if (link !== void 0) {
28520
28698
  reportStep("checking", { detail: `Starting ${kind.name}'s ACP adapter` });
28521
28699
  checkCommand(kind);
@@ -28533,9 +28711,9 @@ try {
28533
28711
  `);
28534
28712
  process.exit(1);
28535
28713
  }
28536
- var folder = join10(dirname5(configPath), basename5(configPath, ".json"));
28537
- var statePath = join10(folder, "state.json");
28538
- mkdirSync4(folder, { recursive: true, mode: 448 });
28714
+ var folder = join11(dirname6(configPath), basename6(configPath, ".json"));
28715
+ var statePath = join11(folder, "state.json");
28716
+ mkdirSync5(folder, { recursive: true, mode: 448 });
28539
28717
  var refused2 = (error62) => {
28540
28718
  if (!(error62 instanceof JoinError)) throw error62;
28541
28719
  process.stderr.write(`${error62.message}
@@ -28561,7 +28739,7 @@ var joined = await join3({
28561
28739
  onCode: (code) => log(`Allow this harness in Chips: ${code}`)
28562
28740
  }).catch(refused2);
28563
28741
  keepIfAsked(LABEL, joined.url, ["ANTHROPIC_API_KEY", "OPENAI_API_KEY", "CODEX_HOME", "CLAUDE_CONFIG_DIR"], log);
28564
- var kept = existsSync8(statePath) ? JSON.parse(readFileSync9(statePath, "utf8")) : {};
28742
+ var kept = existsSync10(statePath) ? JSON.parse(readFileSync10(statePath, "utf8")) : {};
28565
28743
  var state = {
28566
28744
  sessions: kept.sessions ?? {},
28567
28745
  agents: kept.agents ?? {},
@@ -28574,7 +28752,7 @@ var chips = await connect({
28574
28752
  url: joined.url,
28575
28753
  token: joined.token,
28576
28754
  client: { name: "chips-acp", version: VERSION },
28577
- store: fileStore(join10(folder, "chips-state.json")),
28755
+ store: fileStore(join11(folder, "chips-state.json")),
28578
28756
  onRestart: async () => {
28579
28757
  log("a person asked for a restart");
28580
28758
  await bridge?.restart();
@@ -28591,7 +28769,7 @@ bridge = new Bridge({
28591
28769
  // Claude Code's and Codex's adapters offer their models as session options (Chips ADR 0241).
28592
28770
  models: knownIdOf(kind) !== void 0,
28593
28771
  state,
28594
- saveState: (next) => writeFileSync4(statePath, `${JSON.stringify(next, null, 2)}
28772
+ saveState: (next) => writeFileSync5(statePath, `${JSON.stringify(next, null, 2)}
28595
28773
  `, { mode: 384 }),
28596
28774
  wire: () => processWire(kind.command, kind.folder ?? kind.folders, env, (line) => log(`${kind.name}: ${line}`)),
28597
28775
  env,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chipschat/acp",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "An agent that speaks the Agent Client Protocol, as a Chips harness of its kind: agents made from Chips, each in a folder of its own, each room a session.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {