@peer2peer/codex-bridge 0.1.0 → 0.1.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.
package/dist/hook.d.ts CHANGED
@@ -2,13 +2,24 @@
2
2
  export declare function commandOf(input: unknown): string;
3
3
  /** PreToolUse: the denial for a shell command the model may not run, or null. */
4
4
  export declare function guard(toolName: string, input: unknown, binNames?: readonly string[], ownSid?: string): string | null;
5
+ /**
6
+ * The marker of the nearest folder at or above each path that holds a `.git` (any kind), a
7
+ * `.p2p-private`, or is a bare repository (`<that folder>/.git` then), and each of `maybe` that
8
+ * exists: the bridge binds them too, so a shared folder above never covers a repository once its
9
+ * files are gone (projects.ts namedStop). Metadata only; git is never run. The same rules as the
10
+ * Claude mod's MARKER_PROBE.
11
+ */
12
+ export declare function markerPaths(paths: readonly string[], maybe?: readonly string[]): string[];
5
13
  /**
6
14
  * The paths a tool call names outside its folder (a shell command's absolute, ~ and .. paths; the
7
15
  * files an apply_patch or edit names), resolved: the bridge binds each one's project (projects.ts).
16
+ * Plus the repository marker each one (and the cwd) is under, and a program's word that names a
17
+ * file that exists (markerPaths).
8
18
  */
9
19
  export declare function touchedPaths(toolName: string, input: unknown, cwd: string | undefined, home: string | undefined): {
10
20
  paths: string[];
11
21
  over: boolean;
22
+ why?: string[];
12
23
  };
13
24
  export interface HookDeps {
14
25
  home: string;
package/dist/hook.js CHANGED
@@ -16,8 +16,9 @@
16
16
  // must exist in the repo.
17
17
  // Failing open is safe here (the hold rule lives in the bridge, and no
18
18
  // bridge means no messages): any error prints nothing and exits 0.
19
- import { isAbsolute } from "node:path";
20
- import { boundaryRefusal, editedFiles, MAX_COMMAND_PATHS, mutatingP2PVerb, namesP2PCli, resolveLike, shellPaths, touchesSecrets } from "./lib.js";
19
+ import { lstatSync, readFileSync, statSync } from "node:fs";
20
+ import { basename, dirname, isAbsolute, join, resolve } from "node:path";
21
+ import { boundaryRefusal, editedFiles, MAX_COMMAND_PATHS, mutatingP2PVerb, namesP2PCli, resolveLike, shellPaths, TOO_COMPLEX, touchesSecrets } from "./lib.js";
21
22
  import { ancestors, ask, findEntry, readEntries } from "./ipc.js";
22
23
  const SHELL_TOOLS = /^(bash|shell|local_shell|exec_command|unified_exec|container\.exec|powershell|write_stdin)$/i;
23
24
  /** The shell command a PreToolUse payload carries, as one string. */
@@ -38,6 +39,8 @@ export function guard(toolName, input, binNames = [], ownSid) {
38
39
  return null;
39
40
  const command = commandOf(input);
40
41
  const verb = mutatingP2PVerb(command, binNames);
42
+ if (verb === TOO_COMPLEX)
43
+ return `Refused by Peer2Peer: ${TOO_COMPLEX} can't be checked.`;
41
44
  if (verb) {
42
45
  return `Refused by Peer2Peer: \`p2p ${verb}\` changes who reaches your user (or touches their keys or held messages). Only your user runs it, in their own terminal. Tell them what you'd suggest instead.`;
43
46
  }
@@ -48,32 +51,129 @@ export function guard(toolName, input, binNames = [], ownSid) {
48
51
  return `Refused by Peer2Peer: ${boundary}.`;
49
52
  return null;
50
53
  }
54
+ /** Whether `d` is a bare git repository (projects.ts isBareRepo: HEAD, objects/ and refs/, or `bare = true`). */
55
+ function isBareRepo(d) {
56
+ if (basename(d) === ".git")
57
+ return false;
58
+ const st = (p) => {
59
+ try {
60
+ return statSync(p);
61
+ }
62
+ catch {
63
+ return undefined;
64
+ }
65
+ };
66
+ if (st(join(d, "HEAD"))?.isFile() && st(join(d, "objects"))?.isDirectory() && st(join(d, "refs"))?.isDirectory())
67
+ return true;
68
+ try {
69
+ const c = join(d, "config");
70
+ const cs = st(c);
71
+ return !!cs && cs.isFile() && cs.size <= 256 * 1024 && /^\s*bare\s*=\s*true\s*$/im.test(readFileSync(c, "utf8"));
72
+ }
73
+ catch {
74
+ return false;
75
+ }
76
+ }
77
+ /**
78
+ * The marker of the nearest folder at or above each path that holds a `.git` (any kind), a
79
+ * `.p2p-private`, or is a bare repository (`<that folder>/.git` then), and each of `maybe` that
80
+ * exists: the bridge binds them too, so a shared folder above never covers a repository once its
81
+ * files are gone (projects.ts namedStop). Metadata only; git is never run. The same rules as the
82
+ * Claude mod's MARKER_PROBE.
83
+ */
84
+ export function markerPaths(paths, maybe = []) {
85
+ const out = new Set();
86
+ const exists = (p) => {
87
+ try {
88
+ statSync(p);
89
+ return true;
90
+ }
91
+ catch {
92
+ return false;
93
+ }
94
+ };
95
+ const there = (p) => {
96
+ try {
97
+ lstatSync(p);
98
+ return true;
99
+ }
100
+ catch {
101
+ return false;
102
+ }
103
+ };
104
+ for (const m of maybe)
105
+ if (isAbsolute(m) && exists(m))
106
+ out.add(m);
107
+ for (const p of new Set([...paths, ...maybe])) {
108
+ if (!isAbsolute(p))
109
+ continue;
110
+ let cur = resolve(p);
111
+ for (let i = 0; i < 4096; i++) {
112
+ try {
113
+ if (!statSync(cur).isDirectory())
114
+ cur = dirname(cur);
115
+ break;
116
+ }
117
+ catch {
118
+ const up = dirname(cur);
119
+ if (up === cur)
120
+ break;
121
+ cur = up;
122
+ }
123
+ }
124
+ for (let i = 0; i < 4096; i++) {
125
+ if (there(join(cur, ".git")) || isBareRepo(cur)) {
126
+ out.add(join(cur, ".git"));
127
+ break;
128
+ }
129
+ if (there(join(cur, ".p2p-private"))) {
130
+ out.add(join(cur, ".p2p-private"));
131
+ break;
132
+ }
133
+ const up = dirname(cur);
134
+ if (up === cur)
135
+ break;
136
+ cur = up;
137
+ }
138
+ }
139
+ return [...out];
140
+ }
51
141
  /**
52
142
  * The paths a tool call names outside its folder (a shell command's absolute, ~ and .. paths; the
53
143
  * files an apply_patch or edit names), resolved: the bridge binds each one's project (projects.ts).
144
+ * Plus the repository marker each one (and the cwd) is under, and a program's word that names a
145
+ * file that exists (markerPaths).
54
146
  */
55
147
  export function touchedPaths(toolName, input, cwd, home) {
56
148
  const out = [];
57
- let over = false;
149
+ const maybe = [];
150
+ // Why it is private (the CLI's OverWhy words): a path that can't be placed, or too many.
151
+ const why = new Set();
58
152
  if (SHELL_TOOLS.test(toolName)) {
59
153
  // No folder to resolve against: what it names can't be placed, so private.
60
154
  if (!cwd)
61
- over = true;
155
+ why.add("unresolved");
62
156
  else {
63
157
  const r = shellPaths(commandOf(input), cwd, home);
64
158
  out.push(...r.paths);
65
- over ||= r.over;
159
+ maybe.push(...(r.maybe ?? []));
160
+ for (const w of r.why ?? [])
161
+ why.add(w);
66
162
  }
67
163
  }
68
164
  for (const f of editedFiles(toolName, input)) {
69
165
  if (cwd || isAbsolute(f))
70
166
  out.push(resolveLike(cwd ?? "/", f));
71
167
  else
72
- over = true;
168
+ why.add("unresolved");
73
169
  }
74
- if (out.length > MAX_COMMAND_PATHS)
75
- over = true;
76
- return { paths: out.slice(0, MAX_COMMAND_PATHS), over };
170
+ // (The cwd's own marker only beside other paths: a call that names none needn't reach the bridge, and
171
+ // the CLI never covers a session folder that is gone from above: projects.ts projectOf.)
172
+ const extras = out.length + maybe.length > 0 ? markerPaths([...(cwd && isAbsolute(cwd) ? [cwd] : []), ...out], maybe) : [];
173
+ const all = [...new Set([...out, ...extras])];
174
+ if (all.length > MAX_COMMAND_PATHS)
175
+ why.add("folders");
176
+ return { paths: all.slice(0, MAX_COMMAND_PATHS), over: why.size > 0, ...(why.size > 0 ? { why: [...why] } : {}) };
77
177
  }
78
178
  /** Runs one hook: the JSON to print (empty for nothing). */
79
179
  export async function runHook(event, stdin, deps) {
@@ -109,7 +209,7 @@ export async function runHook(event, stdin, deps) {
109
209
  const t = entry ? touchedPaths(String(payload.tool_name ?? ""), payload.tool_input, cwd, deps.homeDir) : { paths: [], over: false };
110
210
  if (entry && (t.paths.length > 0 || t.over)) {
111
211
  // The bridge must hear it before the call runs: if it can't be told, the call doesn't run.
112
- const told = await ask(entry.sock, { op: "hook", report: { event: "PreToolUse", ...(sessionId ? { sessionId } : {}), ...(cwd ? { cwd } : {}), mode: {}, dirs: t.paths, ...(t.over ? { over: true } : {}) } }, 8_000)
212
+ const told = await ask(entry.sock, { op: "hook", report: { event: "PreToolUse", ...(sessionId ? { sessionId } : {}), ...(cwd ? { cwd } : {}), mode: {}, dirs: t.paths, ...(t.over ? { over: true, overWhy: t.why ?? [] } : {}) } }, 8_000)
113
213
  .then((r) => r?.ok === true)
114
214
  .catch(() => false);
115
215
  if (!told) {
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // @peer2peer/codex-bridge: Peer2Peer for OpenAI Codex. An MCP server Codex
4
4
  // starts with each session, Codex hooks, and an installer, all over the
5
- // `p2p` CLI. Core software: it never imports Ix or Kartr.
5
+ // `p2p` CLI. Core software: it never imports Ix or an extension.
6
6
  export * from "./lib.js";
7
7
  export { McpServer, lineFeeder, text, PROTOCOL_VERSION } from "./mcp.js";
8
8
  export { P2P, nodeExec } from "./p2p.js";
package/dist/install.js CHANGED
@@ -14,6 +14,7 @@
14
14
  import { copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, realpathSync, renameSync, writeFileSync } from "node:fs";
15
15
  import { dirname, isAbsolute, join } from "node:path";
16
16
  import { GUARDED_KNOBS, readTomlTable, userHome } from "./knobs.js";
17
+ import { trimChars } from "./lib.js";
17
18
  export const BEGIN = "# >>> peer2peer (managed by `p2p codex install`; edit with care) >>>";
18
19
  export const END = "# <<< peer2peer <<<";
19
20
  const MD_BEGIN = "<!-- >>> peer2peer (managed by `p2p codex install`) >>> -->";
@@ -133,14 +134,14 @@ export function replaceBlock(text, begin, end, block) {
133
134
  const i = text.indexOf(begin);
134
135
  const j = i >= 0 ? text.indexOf(end, i) : -1;
135
136
  if (i >= 0 && j >= 0) {
136
- const before = text.slice(0, i).replace(/\n*$/, "");
137
+ const before = trimChars(text.slice(0, i), "\n");
137
138
  const after = text.slice(j + end.length).replace(/^\n*/, "");
138
139
  const parts = [before, block, after].filter((p) => p !== null && p !== "");
139
140
  return parts.length > 0 ? `${parts.join("\n\n")}\n` : "";
140
141
  }
141
142
  if (block === null)
142
143
  return text;
143
- const base = text.replace(/\n*$/, "");
144
+ const base = trimChars(text, "\n");
144
145
  return base ? `${base}\n\n${block}\n` : `${block}\n`;
145
146
  }
146
147
  /**
@@ -154,7 +155,11 @@ export function configConflict(text) {
154
155
  const j = i >= 0 ? text.indexOf(END, i) : -1;
155
156
  return i >= 0 && j >= 0 ? text.slice(0, i) + text.slice(j + END.length) : text;
156
157
  })();
157
- const lines = outside.split("\n").map((l) => l.replace(/#.*$/, "").trim());
158
+ // Every line ending (CRLF, CR, LF, U+2028, U+2029) ends a line, so a comment never swallows the lines after it.
159
+ const lines = outside.split(/\r\n|[\n\r\u2028\u2029]/).map((l) => {
160
+ const hash = l.indexOf("#");
161
+ return (hash >= 0 ? l.slice(0, hash) : l).trim();
162
+ });
158
163
  if (lines.some((l) => /^\[\s*mcp_servers\s*\.\s*["']?peer2peer["']?\s*[\].]/.test(l)))
159
164
  return "config.toml already defines [mcp_servers.peer2peer] outside the managed block: remove it, then run again";
160
165
  if (lines.some((l) => /^mcp_servers\s*\.\s*["']?peer2peer["']?\s*[.=]/.test(l)))
package/dist/lib.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  export declare const P2P_PREFIX = "p2p:";
2
+ /** `s` without any of `chars` at its end (and at its start when `start`). */
3
+ export declare function trimChars(s: string, chars: string, start?: boolean): string;
4
+ /** `<head> [ref]` → [head, ref], the head without trailing whitespace; null without a trailing ref. */
5
+ export declare function splitRef(s: string): [string, string] | null;
2
6
  /**
3
7
  * A peer's own text, on one line and unable to close or open the block it
4
8
  * sits in: no `<`/`>`, no control or format characters, whitespace folded.
@@ -75,6 +79,7 @@ export type Target = {
75
79
  } | {
76
80
  kind: "refused";
77
81
  reason: string;
82
+ code?: "no-label";
78
83
  };
79
84
  /**
80
85
  * What `--to` the CLI gets for a model's `to`. Only a `p2p:` address or a
@@ -91,11 +96,27 @@ export declare function eventAddress(event: {
91
96
  from: {
92
97
  userId: string;
93
98
  address: string;
99
+ self?: boolean;
94
100
  };
95
101
  own: string;
96
102
  sid: string;
97
103
  ref: string;
104
+ fromRef?: unknown;
98
105
  }, peers: readonly PeerRow[]): string;
106
+ /**
107
+ * Where a delivery notice to a received message goes: a peer's own session by its ref, else the peer;
108
+ * one of this user's own sessions only by the sending session's ref (this device's record), else
109
+ * nowhere ("": never this session's own address, never the bare address).
110
+ */
111
+ export declare function replyToOf(event: {
112
+ from: {
113
+ userId: string;
114
+ self?: boolean;
115
+ };
116
+ own: string;
117
+ ref: string;
118
+ fromRef?: unknown;
119
+ }): string;
99
120
  /**
100
121
  * What the bridge knows of this Codex session's own mode, from Codex itself
101
122
  * (never from a peer). Every field may be unknown (undefined or null):
@@ -170,6 +191,7 @@ export declare function capHeld<T extends {
170
191
  from: {
171
192
  userId: string;
172
193
  };
194
+ bucket?: string;
173
195
  }>(list: readonly T[]): T[];
174
196
  /** Turns peers may start: per sender and in all, in a sliding window. */
175
197
  export declare const TURN_WINDOW_MS: number;
@@ -226,12 +248,57 @@ export declare function conflictMessage(files: readonly string[], repo: string):
226
248
  */
227
249
  export declare const MUTATING_TOOLS: Set<string>;
228
250
  /**
229
- * The mutating `p2p` verb a shell command runs, or null (the mod's
230
- * `mutatingP2PVerb`, for Codex's PreToolUse hook). Defence in depth only:
231
- * parsed conservatively, it may refuse a harmless command, never the reverse
232
- * on purpose, but a determined command can spell things another way.
251
+ * Whether a `p2p send` command line gives --from-session as the CLI's option (the mod's
252
+ * `sendNamesFromSession`; both are pinned to the same vectors). `args` are the words after the CLI's
253
+ * name and `raws` their source text. Read the way the CLI reads its argv: `--no-input` before the
254
+ * first `--` dropped first (cli.ts main), nothing after a `--` (text from there on, even with the
255
+ * `--` before `send`), and never another option's value (`--to --from-session=x` sends to
256
+ * "--from-session=x" from the `tui` session). The shell makes that argv, and this can't expand it:
257
+ * every word up to and including the deciding one must be written plain (no expansion, glob, brace,
258
+ * tilde, quote, escape, redirection or carriage return), or the answer is no, and the guard refuses. Linear.
259
+ */
260
+ export declare function sendNamesFromSession(args: readonly string[], raws: readonly (string | undefined)[]): boolean;
261
+ /**
262
+ * `env`'s split string (`-S <cmd …>`, `-S<cmd …>`, `-vS <cmd …>`, `--split-string[=]<cmd …>`) among its
263
+ * options and assignments, from `from` (the word after `env`) up to its command: the command line it
264
+ * holds and the index of the first word after it, or null. The mod's `envSplitString`; both are pinned
265
+ * to the same vectors. Linear.
233
266
  */
234
- export declare function mutatingP2PVerb(command: string, binNames?: readonly string[], depth?: number): string | null;
267
+ export declare function envSplitString(words: readonly string[], from: number): {
268
+ line: string;
269
+ next: number;
270
+ } | null;
271
+ /**
272
+ * Why a command line that names p2p can't be read by its words, or null (the mod and the Codex bridge
273
+ * share this function, and the same vectors pin both). Not emulated, refused:
274
+ * - GNU `parallel` and runners like it, or `xargs`, in a simple command that names p2p or expands
275
+ * anything (before the CLI's name, unless the command is a text command like `grep`): they build the
276
+ * CLI's argv from their own arguments (`parallel p2p ::: invite`). As the command word, also when they
277
+ * read their arguments from stdin or a file on a line that names p2p (`echo 'p2p invite' | parallel`),
278
+ * or xargs runs a shell (`… | xargs -I{} sh -c '{}'`);
279
+ * - an alias defined in a simple command that names p2p or expands anything, `hash -p`, an assignment to
280
+ * zsh's `functions[…]`/`aliases[…]` or bash's BASH_ALIASES, or any shell function: each gives the CLI
281
+ * another name (`alias q='p2p send --to'`, `f(){ p2p "$@"; }`, `() { p2p "$@"; }`);
282
+ * - a command word built at run time (`$p`, `$(…)`, backticks; `$P2P_BIN` is the CLI), `eval` of text built at
283
+ * run time that names p2p, or a script sourced from a process substitution or a path that names p2p.
284
+ * A quoted word that may be a script of its own (`bash -c '…'`, `eval "…"`, `trap '…'`, `ssh host '…'`) and
285
+ * a backtick substitution are read again when they name p2p, up to MAX_NESTING levels (past that,
286
+ * refused); text after the CLI's name or a text command's (`echo`, `git commit -m`) isn't, except a
287
+ * substitution. The body of a quoted heredoc fed to a text command is data. One pass per level, no
288
+ * backtracking: linear. The caller checks that the command names p2p.
289
+ */
290
+ export declare function indirectP2PRun(command: string, depth?: number): string | null;
291
+ /** What mutatingP2PVerb reads, in characters over all its passes, before it refuses a command that names p2p unread (64 passes over the longest command checked). */
292
+ export declare const WORK_BUDGET: number;
293
+ /** mutatingP2PVerb's answer when a command that names p2p is past WORK_BUDGET: refused as one it can't check. */
294
+ export declare const TOO_COMPLEX = "a command too complex to check that names p2p";
295
+ export declare function mutatingP2PVerb(command: string, binNames?: readonly string[], depth?: number, unread?: boolean, deep?: {
296
+ hit: boolean;
297
+ }, work?: {
298
+ left: number;
299
+ }): string | null;
300
+ /** Whether mutatingP2PVerb stops at its nesting limit (shells and eval inside each other) on a command that still names p2p there. */
301
+ export declare function nestedTooDeep(command: string): boolean;
235
302
  /**
236
303
  * Whether a shell command reaches the backup phrase file or the CLI's key
237
304
  * store (`.p2p` together with `backup`, or the `.p2p` folder listed, globbed
@@ -306,6 +373,8 @@ export declare function screenMessage(o: {
306
373
  mode: ModeClass;
307
374
  autoDeliver: AutoDeliver;
308
375
  refused?: string | undefined;
376
+ ownAgent?: boolean;
377
+ elsewhere?: boolean;
309
378
  }): Screen;
310
379
  /** What a tool call's `_meta["x-codex-turn-metadata"]` says: the thread and the sandbox. */
311
380
  export declare function fromToolMeta(meta: unknown): {
@@ -328,24 +397,68 @@ export declare const LITERAL = "\uE000";
328
397
  * parts join into one word (`''x1` and `"x"1` are `x1`), backslashes escape, `$'…'` is
329
398
  * ANSI-C quoted, and `;`, `|`, `&`, `(`, `)`, `<`, `>` and newlines separate words. Expansions
330
399
  * (`$X`, `$(…)`, backticks) stay as text. Linear in the length, with no cap on the number of words
331
- * (a cap would let padding hide what follows it). Best effort: no aliases, no globbing.
400
+ * (a cap would let padding hide what follows it). Best effort: no aliases, no globbing. With
401
+ * `starts`: the index of each word that begins a simple command (the first word, and the first
402
+ * after an unquoted `;`, `|`, `&`, `(`, `)` or newline).
332
403
  */
333
- export declare function shellTokens(command: string, markLiteral?: boolean): string[];
404
+ export declare function shellTokens(command: string, markLiteral?: boolean, substs?: string[], starts?: Set<number>, raws?: string[]): string[];
334
405
  /** `p` made absolute against `cwd` (POSIX or Windows separators), `.` and `..` resolved. Linear: no regex over the input. */
335
406
  export declare function resolveLike(cwd: string, p: string): string;
336
407
  /** At most this many folders one command may name; past it the session is private (`over`). */
337
408
  export declare const MAX_COMMAND_PATHS = 256;
409
+ /** Why a command makes a session private: a path it couldn't resolve, or more folders than one command may name. */
410
+ export type PathsOverWhy = 'unresolved' | 'folders';
338
411
  /**
339
- * The folders a shell command names: absolute, `~` and relative paths (anything with a separator,
340
- * or starting with `.` or `~`), an option's value (`--file=/x`) too, each resolved (relative ones
341
- * against `cwd`, a file to its folder, `$HOME`/`${HOME}` and `$PWD`/`${PWD}` expanded). A path
342
- * built any other way (`$X/y`, `$(…)`, backticks) can't be resolved, so the session is `over`
343
- * (private), and so it is past MAX_COMMAND_PATHS. URLs are not paths.
412
+ * What a front end knows of the model's shell, for shellPaths: variables whose value it knows (as
413
+ * the shell sees them), and `untrusted` once the session touched the files Claude Code runs before
414
+ * each command (then no variable is known).
415
+ */
416
+ export interface ShellContext {
417
+ vars?: Readonly<Record<string, string | undefined>>;
418
+ untrusted?: boolean;
419
+ }
420
+ /**
421
+ * What shellPaths found. `maybe`: what the words it read as a program (sed's script, jq's filter)
422
+ * would name if they were paths: the front end binds each one that exists (a file named like a
423
+ * program is still that file).
344
424
  */
345
- export declare function shellPaths(command: string, cwd: string, home?: string): {
425
+ export interface ShellPaths {
346
426
  paths: string[];
347
427
  over: boolean;
348
- };
428
+ why?: PathsOverWhy[];
429
+ sticky?: true;
430
+ maybe?: string[];
431
+ }
432
+ /**
433
+ * The paths a shell command names: absolute, `~` and relative paths (anything with a separator,
434
+ * or starting with `.` or `~`), an option's value (`--file=/x`) too, each resolved (relative ones
435
+ * against `cwd` and every folder the command moves to) and the absolute paths written inside a
436
+ * program or quoted phrase. A path is passed as written (`/src/secret.repo` stays itself): the CLI
437
+ * maps a file to its folder.
438
+ *
439
+ * The folders it moves to, read per simple command: `cd`/`pushd`/`chdir` (none: `$HOME`), `git -C`,
440
+ * `make -C`, `tar -C`, `env -C`, `sudo -D` and the like. Each binds, and relative paths resolve
441
+ * against each one (and against the ones before it). One it can't place (`cd -`, `cd $X`, `popd`
442
+ * with no `pushd`) is `unresolved`.
443
+ *
444
+ * Variables expand only when the front end knows their value as the shell sees it: `$HOME`,
445
+ * `$PWD`, and `ctx.vars` (the mod's `$CLAUDE_JOB_DIR`), and only when the command doesn't set
446
+ * them itself (`HOME=…`, `export`, `read`, `cd` for `$PWD`, eval, source). Any other expansion
447
+ * (`$X/y`, `$(…)/y`, backticks) in a path's first segment can't be resolved: the session is `over`
448
+ * (private), `why` `unresolved`; further in, the folder before it binds. A bare `$X` or `$(…)`
449
+ * names no path. A `$(…)` or backtick command is read for its own paths.
450
+ *
451
+ * A program's text (programWords: only for a simple command's command word) isn't a path, unless
452
+ * it has a `..` segment or a shell expansion; what it would name otherwise is `maybe`.
453
+ *
454
+ * Device files (`/dev/null`, `/dev/fd/1`) are skipped. A command that could delete a repository's
455
+ * `.git` or `.p2p-private` without naming it (find -delete, xargs, dotglob, inline code) also
456
+ * names `<folder>/.git` for each folder, so a shared folder above never covers it afterwards
457
+ * (projects.ts projectOf). Past MAX_COMMAND_PATHS: `over`, `why` `folders`. URLs are not paths.
458
+ * `sticky`: the command touched the files Claude Code runs before each command (pass `untrusted`
459
+ * from then on).
460
+ */
461
+ export declare function shellPaths(command: string, cwd: string, home?: string, ctx?: ShellContext, depth?: number): ShellPaths;
349
462
  /** Whether a command runs interpreter code given inline, or anything under a pseudo-terminal wrapper (by its words: linear). */
350
463
  export declare function hidesCommand(command: string): 'interpreter' | 'pty' | null;
351
464
  /** Commands naming p2p longer than this are refused unread. */
@@ -372,3 +485,17 @@ export declare function pickHolder(board: readonly {
372
485
  sid: string;
373
486
  activeAt: number;
374
487
  }[]): string | undefined;
488
+ /** What `p2p extensions --json` says about Ix (packages/p2p ix-local.ts IxAdvice). */
489
+ export type IxAdvice = {
490
+ installed: boolean;
491
+ declined: boolean;
492
+ recommended: boolean;
493
+ install: string;
494
+ };
495
+ /** IxAdvice from `p2p extensions --json`'s `ix`, or undefined when absent or malformed (an older CLI). */
496
+ export declare function parseIxAdvice(v: unknown): IxAdvice | undefined;
497
+ /**
498
+ * The once-per-session hint to the model when Ix isn't installed and the person hasn't said no: it
499
+ * may suggest Ix to its user once; installing is theirs. Undefined when there is nothing to say.
500
+ */
501
+ export declare function ixAgentHint(ix: IxAdvice | undefined): string | undefined;