pi-odd-worktree 3.6.1 → 3.6.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/README.md CHANGED
@@ -14,7 +14,6 @@ Two agent tools, four panels, one background-explorer command, one sidebar secti
14
14
  | `/odd` | panel | Reads this checkout's `odd/tasks/*.md`: list on the left, styled markdown on the right. |
15
15
  | `/files` | panel | Browses one checkout's files with a live, language-coloured preview: `enter` pastes the chosen paths into your prompt, `ctrl+e` opens the file in `$EDITOR`. |
16
16
  | `/issues` | panel | Reads this checkout's GitHub issues — the three scoped tabs on open, every open issue behind `g` — and, when your role allows it, edits them. |
17
- | `/depth` | command | Takes a request you type and starts one background `gentle-ai-explore` on it: what a top professional would do that you did not ask for, the raw material, the methods, and what outside the model would prove the result. The handoff — your request verbatim, how it was understood, a `path:line` map, proposals kept apart from the request, how it would be verified — arrives in the session. Edit its instructions in `lib/depth-prompt/depth.md`. |
18
17
  | `GITHUB` rail section | sidebar section | Lists the open issues of this checkout's repository assigned to you, seven at a time plus a count of the rest; a click opens that issue in `/issues` on `Assigned` and the overflow row opens `/issues`. Needs `gh` and gentle-shell-bridge with its rail; without `gh` on `PATH` it is never added to the rail at all. |
19
18
  | `activity` tags design | design on the bridge's `Card tags` line | Optional: `/gentle:customize` → `Cards` → `Card tags`, with `default` (the host's own card) and `activity`, which is selected for you on the first run. It covers `bash`, the read-only shell tools `grep`, `find`, `ls`, and `read`, `write` and `edit`: a bash card's heading names what the command does, each family in its own theme colour (`⌕ exploring`, `✓ checking`, …; an unnamed command reads `$ bash`), those three are always `⌕ exploring`, and a `read` — which runs no shell command — is left exactly as the host drew it. `read`, `write` and `edit` are covered so that the file card can ask about them too, `write` and `edit` through a scope limited to skill and ODD paths (gentle-shell-bridge 0.9.0): the design draws nothing of its own for any of the three, so a read, a write or an edit on a skill or an ODD artifact is the file card's row and everything else stays the host's. A finished call shows its duration on the closing rule and the frame turns `warning` while the call runs and `error` when it fails. Needs gentle-shell-bridge 0.6.0 or newer for the one `Card tags` row over the six tools, and 0.9.0 for `edit` and the scope that claims a write or an edit; on 0.5.0 the row is `Card bash`, covers bash alone and keeps everything above for bash cards. Registered through gentle-shell-bridge's `registerToolDesign`; the bridge owns the choice, remembers it and repaints cards already on screen. |
20
19
  | `color` diff design | design on the bridge's `Card diff` line | Optional: `/gentle:customize` → `Cards` → `Card diff`, with `default` (the host's own card) and `color`, which is selected for you on the first run. It covers `write` and `edit` and redraws them as an IDE pane: a write's content behind a line-number gutter, and an edit's diff, both in the active theme's own syntax roles from Pi's highlighter — the same one `/files` previews with. A write or an edit on a skill or an ODD artifact stays the file card's row, because the `Card tags` line claims exactly those calls and a specific claim wins over this generic one. Needs gentle-shell-bridge 0.9.0 or newer; on anything older nothing is registered and `Card diff` never appears. |
@@ -50,7 +49,7 @@ gentle-shell install npm:pi-odd-worktree
50
49
 
51
50
  From a local clone, `pi install .` installs the working copy, and `gentle-shell install .` does the same from inside a Gentle Shell session.
52
51
 
53
- Expected result: `/warp`, `/odd`, `/files`, `/issues` and `/depth` are available as commands — `/issues` only where `gh` is on `PATH` — the agent is offered `worktree_create` and `worktree_list`, a Gentle Shell whose `gentle-shell-bridge` is installed and whose rail is drawn shows a `GITHUB` section for this checkout, and its `/gentle:customize` → `Cards` page offers `activity` on its `Card tags` line — `Card bash` on a bridge older than 0.6.0.
52
+ Expected result: `/warp`, `/odd`, `/files` and `/issues` are available as commands — `/issues` only where `gh` is on `PATH` — the agent is offered `worktree_create` and `worktree_list`, a Gentle Shell whose `gentle-shell-bridge` is installed and whose rail is drawn shows a `GITHUB` section for this checkout, and its `/gentle:customize` → `Cards` page offers `activity` on its `Card tags` line — `Card bash` on a bridge older than 0.6.0.
54
53
 
55
54
  ## Core Workflow
56
55
 
@@ -6816,32 +6816,6 @@ function registerOddCommand(pi) {
6816
6816
  }
6817
6817
 
6818
6818
  // ---------------------------------------------------------------------------
6819
- // `/depth <request>` (depth-command S1-S8): the fifth command. It starts ONE background
6820
- // `gentle-ai-explore` through the host's own `subagent_run` tool, with the Depth
6821
- // instructions of `lib/depth-prompt/depth.md` and the request verbatim, and answers with
6822
- // one notice. Everything after the start is gentle-agents' — the progress, the cancel and
6823
- // the handoff that lands in the session — so the command draws nothing, keeps no state,
6824
- // registers no key and spawns no child of its own (`lib/depth-launch.js`).
6825
- // ---------------------------------------------------------------------------
6826
-
6827
- function registerDepthCommand(pi) {
6828
- if (typeof pi?.registerCommand !== "function") return;
6829
- pi.registerCommand("depth", {
6830
- description: "Understand a request in depth and explore it in the background; the handoff arrives in this session",
6831
- handler: async (args, ctx) => {
6832
- let outcome;
6833
- try {
6834
- outcome = await libRequire("depth-launch.js").launchDepth(typeof args === "string" ? args : "", ctx);
6835
- } catch (error) {
6836
- outcome = { level: "error", message: `/depth failed: ${error instanceof Error ? error.message : String(error)}` };
6837
- }
6838
- try {
6839
- if (ctx && ctx.ui && typeof ctx.ui.notify === "function") ctx.ui.notify(outcome.message, outcome.level);
6840
- } catch {}
6841
- },
6842
- });
6843
- }
6844
-
6845
6819
  // ---------------------------------------------------------------------------
6846
6820
  // `/files` (T7: S9, S14, S17): the file picker over one checkout of this clone.
6847
6821
  //
@@ -9797,8 +9771,6 @@ function registerOddWorktreeSurfaceEntries(pi) {
9797
9771
  // picker's — bound after its command exists, and therefore never when the
9798
9772
  // `gh`-absent gate left that command unregistered.
9799
9773
  bindIssuesShortcut(pi);
9800
- // depth-command S6: the fifth command, `/depth`.
9801
- registerDepthCommand(pi);
9802
9774
  pi.registerTool(worktreeCreateTool);
9803
9775
  pi.registerTool(worktreeListTool);
9804
9776
  if (typeof pi?.on !== "function") return;
@@ -93,16 +93,28 @@ const CHECKING_COMMANDS = [
93
93
  /^node\s+\S*(test|check|lint|typecheck)[\w-]*\.m?[jt]s\b/,
94
94
  /^((npx|pnpx|bunx)\s+|(pnpm|yarn)\s+exec\s+)?(vitest|jest|mocha|tsc|pytest)\b/,
95
95
  /^python(3(\.\d+)?)?\s+-m\s+(pytest|unittest)\b/,
96
+ // Every ecosystem names its verification with a subcommand, and that recipe is the check
97
+ // whatever toolchain builds the project. The recipe is a whole argument: `gradle
98
+ // test-fixtures:publish` runs a recipe that only starts with the word `test`.
99
+ /^(mix|dotnet)\s+test(?=\s|$)/,
100
+ /^(gradlew|gradle|mvn|mvnw)\s+test(?=\s|$)/,
96
101
  /^go\s+(test|build|vet)\b/,
97
102
  /^cargo\s+(test|build|check|clippy|nextest)\b/,
98
103
  // `cargo fmt` rewrites code, so only the check form verifies anything.
99
104
  /^cargo\s+fmt\b.*\s--check\b/,
100
105
  /^ruff\s+format\s+--check\b/,
106
+ // `ruff format` rewrites unless told to report, and the runner's form reads the same.
107
+ /^(uv|poetry)\s+run\s+ruff\s+format\s+--check\b/,
101
108
  /^deno\s+(test|check)\b/,
102
109
  /^deno\s+fmt\s+--check\b/,
103
110
  /^deno\s+task\s+(test|typecheck|lint|build|check)\b/,
104
111
  // eslint verifies work whatever write flag it carries, quoted or not.
105
112
  /^((npx|pnpx|bunx)\s+|(pnpm|yarn|npm)\s+(exec|run)\s+)?eslint\b/,
113
+ // A project runner supplies the environment and then hands the segment to the program it
114
+ // names, so a checker behind `uv run`/`poetry run` is the check the bare checker already
115
+ // is. Only a checker is read: `uv run python x.py` names nothing, and `ruff format` is a
116
+ // rewrite no check form covers.
117
+ /^(uv|poetry)\s+run\s+(pytest|vitest|jest|mypy|tsc|eslint)(?=\s|$)/,
106
118
  // Waiting on or reading CI results verifies work; it is not exploration.
107
119
  /^gh\s+pr\s+checks\b/,
108
120
  /^gh\s+run\s+(view|watch|list)\b/,
@@ -121,6 +133,7 @@ const CHECKING_COMMANDS = [
121
133
  // linters beside it only report.
122
134
  const FIXABLE_CHECKING_COMMANDS = [
123
135
  /^ruff\s+check\b/,
136
+ /^(uv|poetry)\s+run\s+ruff\s+check(?=\s|$)/,
124
137
  /^deno\s+lint\b/,
125
138
  /^((npx|pnpx|bunx)\s+)?biome\s+(check|ci|lint)\b/,
126
139
  /^((npx|pnpx|bunx)\s+)?(shellcheck|actionlint|yamllint|hadolint|tflint|mypy|pyright|flake8|pylint)\b/,
@@ -212,6 +225,9 @@ const PREPARING_COMMANDS = [
212
225
  /^uv\s+(pip\s+install|sync|add|init)\b/,
213
226
  /^poetry\s+(install|add)\b/,
214
227
  /^(bundle\s+install|gem\s+install|composer\s+install)\b/,
228
+ // A container image the call builds is one this machine now has, the same build-up a
229
+ // dependency install is; running, pulling or just listing one names nothing here.
230
+ /^docker\s+build\b/,
215
231
  /^(brew|port)\s+install\b/,
216
232
  /^(apt|apt-get|dnf|yum|zypper)\s+(install|add)\b/,
217
233
  /^apk\s+add\b/,
@@ -281,6 +297,9 @@ const VERSIONING_COMMANDS = [
281
297
  /^gh\s+pr\s+checkout\b/,
282
298
  // A stack's local half creates and rebases branches; it publishes nothing.
283
299
  /^gh\s+stack\s+(init|add|rebase)\b/,
300
+ // A package manager's own version bump rewrites the manifest and the tag this machine
301
+ // keeps. The bare form and `--version` only print, and the version probes read them first.
302
+ /^(npm|pnpm|yarn|bun)\s+version\s+[^-\s]/,
284
303
  ];
285
304
 
286
305
  // Remote writes: they create or move something on GitHub, including the label,
@@ -296,6 +315,11 @@ const PUBLISHING_COMMANDS = [
296
315
  // Rerunning or cancelling a CI run moves work on the remote, beside `gh pr` and
297
316
  // `gh workflow`, which already name their own writes.
298
317
  /^gh\s+run\s+(rerun|cancel)\b/,
318
+ // Running a workflow, or enabling and disabling one, moves work on the remote the same
319
+ // way; listing and viewing a workflow are the reads the exploring table names.
320
+ /^gh\s+workflow\s+(run|enable|disable)\b/,
321
+ // A package manager's `publish` uploads the package to a registry.
322
+ /^(npm|pnpm|yarn|bun)\s+publish\b/,
299
323
  ];
300
324
 
301
325
  // `--help` prints a program's usage and stops, so it is a query on any command family.
@@ -389,6 +413,9 @@ const EXPLORING_COMMANDS = [
389
413
  // Version probes: the universal `--version`/`-V`, and each runtime's own `-v`/`version`.
390
414
  /^[\w./+-]+\s+(--version|-V)\s*$/,
391
415
  /^(node|python3?(\.\d+)?|ruby|php|java|npm|pnpm|yarn|bun|deno|rustc|cargo|go|gcc|clang|make|git|docker|uv|pip3?|ffmpeg|jq|nvim|tmux)\s+(-v|version)\s*$/,
416
+ // `npm version --version` asks the tool for its own version and bumps nothing; the form
417
+ // that takes a non-flag argument is the history change the versioning table names.
418
+ /^(npm|pnpm|yarn|bun)\s+version\s+--version\s*$/,
392
419
  // What the shell hands its children, and the state the kernel and the daemons report.
393
420
  /^env\s*$/,
394
421
  /^ss\b(?!.*\s(-\w*K\w*|--kill)\b)/,
@@ -586,7 +613,9 @@ function segmentActivity(segment) {
586
613
  if (isInPlaceEdit(words)) return 'preparing';
587
614
  if (isPreparingSegment(text)) return 'preparing';
588
615
  if (matchesAny(VERSIONING_COMMANDS, text)) return 'versioning';
589
- if (matchesAny(PUBLISHING_COMMANDS, text)) return 'publishing';
616
+ // `gh api` names its write from the words it passes — a method, a field, an input body —
617
+ // so a pattern in the table cannot read it; the plain GET is the read above.
618
+ if (matchesAny(PUBLISHING_COMMANDS, text) || isGhApiWrite(text)) return 'publishing';
590
619
  return undefined;
591
620
  }
592
621
 
@@ -1124,13 +1153,33 @@ function isSeparator(command, i) {
1124
1153
  function findSubstitutionEnd(command, start) {
1125
1154
  let depth = 1;
1126
1155
  let quote;
1156
+ // The heredoc whose header line is still being read: its body begins at the newline that
1157
+ // ends that line. Only the body is data — the header line is still the shell's own text, so
1158
+ // a `)` on it counts and its quotes are read normally.
1159
+ let body;
1127
1160
  for (let i = start; i < command.length; i += 1) {
1161
+ if (body !== undefined && i >= body.newline) {
1162
+ i = body.end - 1;
1163
+ body = undefined;
1164
+ continue;
1165
+ }
1128
1166
  const char = command[i];
1129
1167
  if (quote) {
1130
1168
  if (char === quote) quote = undefined;
1131
1169
  else if (char === '\\' && quote === '"') i += 1;
1132
1170
  } else if (char === '\\') i += 1;
1133
- else if (char === "'" || char === '"') quote = char;
1171
+ else if (char === '<' && command[i + 1] === '<' && command[i + 2] !== '<' && command[i - 1] !== '<') {
1172
+ // A heredoc body is data the shell hands over, never text it acts on: a quote or a
1173
+ // parenthesis inside one cannot close the substitution that wraps it, so the scan
1174
+ // resumes past the body. Without this, one apostrophe in a PR body hid the `)` of the
1175
+ // `$( … )` around it, and the body — backticks and all — stayed in the segment as text
1176
+ // the shell acts on. `<<<` is a herestring, not a header, so both `<` are refused. A
1177
+ // header this reader cannot delimit stays the plain text it is.
1178
+ const end = heredocEnd(command, i);
1179
+ const header = HEREDOC_HEADER.exec(command.slice(i));
1180
+ const newline = header === null ? -1 : command.indexOf('\n', i + header[0].length);
1181
+ if (body === undefined && end !== undefined && header !== null && newline >= 0 && newline < end) body = { newline, end };
1182
+ } else if (char === "'" || char === '"') quote = char;
1134
1183
  else if (char === '(') depth += 1;
1135
1184
  else if (char === ')' && (depth -= 1) === 0) return i;
1136
1185
  }
@@ -1465,6 +1514,52 @@ function isGhApiRead(segment) {
1465
1514
  return !words.slice(2).some((word) => GH_API_WRITE_FLAGS.has(word.split('=')[0] === undefined ? '' : word.split('=')[0]) || /^-[XfF]./.test(word));
1466
1515
  }
1467
1516
 
1517
+ /**
1518
+ * The other half of that reading: the `gh api` call that writes creates or moves something
1519
+ * on the remote, so it publishes. A method the call spells out decides by itself — `-X GET`
1520
+ * is the same query without the flag, quoted or not, and no field riding beside it proves a
1521
+ * payload — while a field or an input body that CARRIES one is the payload a write sends,
1522
+ * glued to its flag (`-fkey=value`) or written after it. A header's value is that header's,
1523
+ * never a flag of its own.
1524
+ */
1525
+ function isGhApiWrite(segment) {
1526
+ const words = shellWords(segment);
1527
+ if (words[0] !== 'gh' || words[1] !== 'api') return false;
1528
+ let method;
1529
+ let payload = false;
1530
+ for (let index = 2; index < words.length; index += 1) {
1531
+ const word = words[index] === undefined ? '' : words[index];
1532
+ const equals = word.indexOf('=');
1533
+ const flag = equals < 0 ? word : word.slice(0, equals);
1534
+ const attached = equals < 0 ? undefined : word.slice(equals + 1);
1535
+ // The method is attached in `-XPOST`/`--method=PUT` and the next word otherwise; the
1536
+ // shell dropped any quoting, so `-X "GET"` and `--method='HEAD'` are the reads they spell.
1537
+ const gluedMethod = /^-X./.exec(word);
1538
+ if (flag === '-X' || flag === '--method' || gluedMethod !== null) {
1539
+ // `-XPOST` and `--method=PUT` carry the value; `-X POST` writes it as the next word.
1540
+ let value = word.slice(2);
1541
+ if (gluedMethod === null) {
1542
+ value = attached === undefined ? words[index + 1] : attached;
1543
+ if (attached === undefined) index += 1;
1544
+ }
1545
+ if (value !== undefined && value !== '') method = value;
1546
+ continue;
1547
+ }
1548
+ // A header's value is not a flag this call passes: `-H "X: -filename"` sends a header.
1549
+ if (flag === '-H' || flag === '--header' || /^-H./.test(word)) {
1550
+ if (attached === undefined && !/^-H./.test(word)) index += 1;
1551
+ continue;
1552
+ }
1553
+ if (!GH_API_WRITE_FLAGS.has(flag) && !/^-[fF]/.test(word)) continue;
1554
+ // A field flag with no value hands the remote no payload at all.
1555
+ const value = attached === undefined ? words[index + 1] : attached;
1556
+ if (attached === undefined) index += 1;
1557
+ if (value !== undefined && value !== '') payload = true;
1558
+ }
1559
+ // A method that reads says so whatever rides beside it; a payload with no method writes.
1560
+ return method === undefined ? payload : !/^(GET|HEAD)$/i.test(method);
1561
+ }
1562
+
1468
1563
  /**
1469
1564
  * `go env` reports the Go configuration, but `-w` stores a value in the env config file
1470
1565
  * and `-u` unsets one: both write, so neither is inspection.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-odd-worktree",
3
- "version": "3.6.1",
3
+ "version": "3.6.3",
4
4
  "description": "Pi package for odd-worktree: the Git worktree tools a Pi session uses (create and list the checkouts the agent works in), the /warp worktree panel, the /odd ODD viewer, and the /issues GitHub issue reader. Needs only Pi and git: no companion app, no extra service.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -172,6 +172,69 @@ test('a verification runner names the checking activity', () => {
172
172
  }
173
173
  });
174
174
 
175
+ // The runners the table did not read yet: each ecosystem names its verification with a
176
+ // subcommand, and that subcommand is the check whatever builds the project.
177
+ test('the remaining ecosystem runners name the checking activity', () => {
178
+ for (const command of [
179
+ 'mix test',
180
+ 'mix test test/app_test.exs',
181
+ 'dotnet test',
182
+ './gradlew test',
183
+ 'gradlew test',
184
+ 'gradle test',
185
+ 'mvn test',
186
+ ]) {
187
+ assert.equal(inferBashActivity(command), 'checking', command);
188
+ }
189
+ // The neighbours beside them build or prepare, and `mix format` rewrites, so none of
190
+ // them is a check.
191
+ for (const command of ['dotnet build', 'gradle build', 'mvn package']) {
192
+ assert.notEqual(inferBashActivity(command), 'checking', command);
193
+ }
194
+ assert.equal(inferBashActivity('mix format'), 'formatting');
195
+ });
196
+
197
+ // A test recipe must be a whole argument: `gradle test-fixtures:publish` runs a recipe whose
198
+ // name merely starts with `test`, and a prefix is not the check.
199
+ test('a recipe whose name starts with test is not the test recipe', () => {
200
+ for (const command of ['gradle test-fixtures:publish', 'mvn test-report:publish', 'mix test-helper', 'dotnet test-tools:run']) {
201
+ assert.equal(inferBashActivity(command), undefined, command);
202
+ }
203
+ });
204
+
205
+ // A project runner hands the segment to the tool it names after supplying the
206
+ // environment, so a checker behind `uv run` or `poetry run` is the check the bare
207
+ // checker already is; a program the tables never called a check still names nothing.
208
+ test('a project runner naming a checker names the checking activity', () => {
209
+ for (const command of [
210
+ 'uv run pytest',
211
+ 'uv run pytest -q tests/',
212
+ 'uv run vitest run',
213
+ 'uv run jest',
214
+ 'uv run ruff check .',
215
+ 'uv run mypy src',
216
+ 'uv run tsc --noEmit',
217
+ 'uv run eslint .',
218
+ 'poetry run pytest',
219
+ 'poetry run mypy .',
220
+ // `ruff format --check` reports, so the wrapped form verifies like the bare one.
221
+ 'uv run ruff format --check .',
222
+ ]) {
223
+ assert.equal(inferBashActivity(command), 'checking', command);
224
+ }
225
+ for (const command of ['uv run python x.py', 'poetry run python x.py', 'uv run ruff format .']) {
226
+ assert.equal(inferBashActivity(command), undefined, command);
227
+ }
228
+ });
229
+
230
+ // The wrapped checker must be a whole argument too: `uv run pytest-deploy` runs a program
231
+ // whose name starts with a checker's, so it names nothing.
232
+ test('a program whose name starts with a checker is not the checker', () => {
233
+ for (const command of ['uv run pytest-deploy', 'poetry run jest-reporter', 'uv run mypy-extensions', 'poetry run tsc-watch']) {
234
+ assert.equal(inferBashActivity(command), undefined, command);
235
+ }
236
+ });
237
+
175
238
  // A monorepo flags the workspace before the script, and every value option's value
176
239
  // must be read as the value it is, or `npm --prefix pkg test` would look like the
177
240
  // script `pkg`.
@@ -390,6 +453,20 @@ test('installations, scaffolding and stored configuration name the preparing act
390
453
  }
391
454
  });
392
455
 
456
+ // A container image the call builds is one this machine now has, the build-up `docker`
457
+ // shares with the installers; running, pulling or just looking at one names nothing.
458
+ test('a container image build prepares the machine', () => {
459
+ for (const command of ['docker build .', 'docker build -t app:dev .', 'docker build --file Dockerfile.dev .']) {
460
+ assert.equal(inferBashActivity(command), 'preparing', command);
461
+ }
462
+ for (const command of ['docker ps', 'docker images', 'docker version']) {
463
+ assert.equal(inferBashActivity(command), 'exploring', command);
464
+ }
465
+ for (const command of ['docker run app:dev', 'docker pull app:dev']) {
466
+ assert.equal(inferBashActivity(command), undefined, command);
467
+ }
468
+ });
469
+
393
470
  // An installer told to report prepares nothing: `cargo install --list` lists what is
394
471
  // already installed and `--dry-run` resolves a tree without writing it, so neither
395
472
  // names an identity — and a report-shaped argument never hides the writing form.
@@ -484,6 +561,39 @@ test('remote writes name the publishing activity', () => {
484
561
  }
485
562
  });
486
563
 
564
+ // A package manager's `version` subcommand does two different things: given a bump or a
565
+ // version it rewrites the manifest and the tag, while the bare form and `--version`
566
+ // only print. Only the rewriting form is local history.
567
+ test('a package version bump names the versioning activity while the printing forms inspect', () => {
568
+ for (const command of [
569
+ 'npm version patch',
570
+ 'npm version minor',
571
+ 'npm version major',
572
+ 'npm version 1.2.3',
573
+ 'npm version patch --no-git-tag-version',
574
+ 'pnpm version patch',
575
+ 'yarn version minor',
576
+ 'bun version 1.2.3',
577
+ ]) {
578
+ assert.equal(inferBashActivity(command), 'versioning', command);
579
+ }
580
+ for (const command of ['npm version', 'pnpm version', 'yarn version', 'bun version', 'npm version --version', 'pnpm version --version']) {
581
+ assert.equal(inferBashActivity(command), 'exploring', command);
582
+ }
583
+ });
584
+
585
+ // Publishing a package uploads it to a registry: a remote write from the package
586
+ // manager's own subcommand position, whatever flags the registry needs. Installing
587
+ // and testing beside it keep the families they already wear.
588
+ test('a package publish names the publishing activity', () => {
589
+ for (const command of ['npm publish', 'pnpm publish', 'yarn publish', 'bun publish', 'npm publish --access public', 'yarn publish --tag next']) {
590
+ assert.equal(inferBashActivity(command), 'publishing', command);
591
+ }
592
+ for (const command of ['npm install', 'npm test']) {
593
+ assert.notEqual(inferBashActivity(command), 'publishing', command);
594
+ }
595
+ });
596
+
487
597
  // Moving between branches, aliasing a command and the rest of the stack subcommands
488
598
  // publish nothing and read nothing, so they name no activity at all; viewing a stack
489
599
  // is inspection.
@@ -527,28 +637,57 @@ test('reading or waiting on CI results names the checking activity', () => {
527
637
  }
528
638
  });
529
639
 
530
- // `gh api` writes whenever it is given a method, a field, or an input body, so only
531
- // the plain GET form is a query — and every writing form is a name this classifier
532
- // will not guess at, which leaves the card generic rather than claiming an identity.
533
- test('a gh api call that writes names nothing while the plain GET inspects', () => {
640
+ // `gh api` writes whenever it is given a writing method, a field, or an input body, so
641
+ // only the plain GET form is a query: the writing forms are the remote write they
642
+ // perform, and the GET the call spells out with `-X` reads nothing either way.
643
+ test('a gh api call that writes names the publishing activity while the plain GET inspects', () => {
534
644
  for (const command of [
535
645
  'gh api repos/owner/name/pulls',
536
646
  'gh api --paginate repos/owner/name/commits',
647
+ 'gh api repos/o/n --jq .state',
537
648
  ]) {
538
649
  assert.equal(inferBashActivity(command), 'exploring', command);
539
650
  }
540
651
  for (const command of [
541
652
  'gh api repos/o/n -X POST',
542
653
  'gh api repos/o/n --method POST',
654
+ 'gh api --method=PUT repos/o/n/merge',
655
+ 'gh api repos/o/n -X DELETE',
543
656
  'gh api repos/o/n/issues -f title=x',
544
657
  'gh api repos/o/n/issues --raw-field title=x',
545
658
  'gh api graphql -F query=@q.graphql',
546
659
  'gh api repos/o/n/issues --input body.json',
660
+ ]) {
661
+ assert.equal(inferBashActivity(command), 'publishing', command);
662
+ }
663
+ });
664
+
665
+ // A `gh api` argument that proves no payload is not a write: a method that reads, spelled
666
+ // with quotes or with an `=`; a field flag with no value; and a header VALUE that merely
667
+ // looks like the `-f` flag. None of them may claim the remote write.
668
+ test('a gh api argument that proves no payload stays unnamed', () => {
669
+ for (const command of [
670
+ 'gh api repos/x/y -X "GET"',
671
+ "gh api repos/x/y --method='HEAD'",
672
+ 'gh api repos/x/y -X GET -f per_page=1',
673
+ 'gh api repos/x/y -H "X-Custom: -filename"',
674
+ 'gh api repos/x/y -f',
547
675
  ]) {
548
676
  assert.equal(inferBashActivity(command), undefined, command);
549
677
  }
550
678
  });
551
679
 
680
+ // Running a workflow, or enabling and disabling one, moves work on the remote; listing
681
+ // and viewing one only reads it.
682
+ test('a workflow run or toggle names the publishing activity', () => {
683
+ for (const command of ['gh workflow run ci.yml', 'gh workflow run ci.yml --ref main', 'gh workflow enable ci.yml', 'gh workflow disable ci.yml']) {
684
+ assert.equal(inferBashActivity(command), 'publishing', command);
685
+ }
686
+ for (const command of ['gh workflow list', 'gh workflow view ci.yml']) {
687
+ assert.equal(inferBashActivity(command), 'exploring', command);
688
+ }
689
+ });
690
+
552
691
  // Metadata probes answer "what is here?" without resolving, building or mutating
553
692
  // anything; `go env` writes its configuration with `-w` and `-u`, so those are no
554
693
  // probe, and the writing form is the build-up the next family names.
@@ -1451,6 +1590,91 @@ test('a quoted heredoc body is data, whatever characters it carries', () => {
1451
1590
  assert.equal(inferBashActivity("git commit -F - <<'MSG' > out.txt\nfix\nMSG"), undefined);
1452
1591
  });
1453
1592
 
1593
+ // A `--body` written from a quoted heredoc hands the program the body as data: the
1594
+ // backticks inside it are the prose the PR carries, never a substitution this reader has
1595
+ // to follow, so the call is the remote write it performs.
1596
+ test('a PR body written from a quoted heredoc names the publishing activity', () => {
1597
+ const command = `gh pr create --base main --head feat/jobs-activity-card --title "feat(cards): draw background-job tools in the active card style" --body "$(cat <<'EOF'\n## What\n- \`bash_background\`, \`monitor\`, \`job_stop\` and \`job_list\` are now drawn on the card.\nEOF\n)" 2>&1 | tail -3`;
1598
+ assert.equal(inferBashActivity(command), 'publishing');
1599
+ });
1600
+
1601
+ // The audit's own real command (a session's `gh pr create` with a 20-line body): the body of
1602
+ // a quoted heredoc nested inside `$( … )` is data, and an apostrophe in it is not the shell's
1603
+ // own quote. The scan that finds the end of a substitution reads quotes but not heredoc
1604
+ // bodies, so an ODD number of body apostrophes left it inside a quote and it never found the
1605
+ // `)` that closes the substitution: the gh segment stayed one piece of text with the body
1606
+ // (backticks and all) still in it, and the hidden-substitution veto made the call generic.
1607
+ test('the audit\'s real PR command names the publishing activity', () => {
1608
+ const command = `cd /home/jona/dev/projects/odd-worktree-worktrees/jobs-activity-card && git push -q origin feat/jobs-activity-card 2>&1 | tail -3; gh pr create --base main --head feat/jobs-activity-card --title "feat(cards): draw background-job tools in the active card style" --body "$(cat <<'EOF'
1609
+ ## What
1610
+
1611
+ \`bash_background\`, \`monitor\`, \`job_stop\` and \`job_list\` are registered with no renderer of their own, so Pi draws them in a plain box and neither \`neon\` nor \`float\` ever reaches them. While the bridge's \`Card tags\` line answers with this package's \`activity\` design for the tool, they are now drawn on the card substrate in the shell's chosen style.
1612
+
1613
+ - Call: the tool's mark and word (\`⧗ background\`, \`◉ monitor\`, \`■ stop\`, \`≡ jobs\`) plus the job's label, else the first line of its command; the whole command when expanded.
1614
+ - Result: the job's own answer, first rows collapsed and everything expanded, closing the frame with the call's duration.
1615
+ - \`minimal\`: the call alone while collapsed; a failure still says why.
1616
+ - Any other answer on \`Card tags\` — \`native\`, \`not-covered\`, \`missing\`, another plugin's design, no bridge, a bridge older than the reader — leaves Pi's own drawing untouched.
1617
+
1618
+ The four tools are declared on the \`tags\` line so the bridge can answer for them; the activity design itself returns their rows exactly as drawn.
1619
+
1620
+ ## Limitation
1621
+
1622
+ The gate is read when a job card is built, not on every paint: these tools have no host renderer to forward to, so a switch made mid-session reaches the next job card.
1623
+
1624
+ ## Tests
1625
+
1626
+ \`node --test tools/*.test.js\` → 2561 pass, 0 fail (2547 before, 14 new).
1627
+
1628
+ \`chore(release): 3.4.0\` is in this PR, as the release commit the tag will be cut from.
1629
+ EOF
1630
+ )" 2>&1 | tail -3`;
1631
+ assert.equal(inferBashActivity(command), 'publishing');
1632
+ // The same call as the card reads it when only the `gh` side is replayed, which is how
1633
+ // the audit found it: one segment, body included.
1634
+ assert.equal(inferBashActivity(command.slice(command.indexOf('gh pr create'))), 'publishing');
1635
+ });
1636
+
1637
+ // `<<<` is a herestring, not a heredoc: its second `<` opens no header, so nothing after it
1638
+ // is a body this reader may skip. Reading it as one ate the `)` that closes the `$( … )`,
1639
+ // left the call unsplit and named the write it only wrapped.
1640
+ test('a herestring is not a heredoc header', () => {
1641
+ const command = 'gh pr create --body "$(cat <<<date)" && ./unclassified.sh\ndate';
1642
+ assert.equal(inferBashActivity(command), undefined);
1643
+ assert.equal(inferBashActivity('gh pr create --body "$(cat <<<date)"'), 'publishing');
1644
+ });
1645
+
1646
+ // A heredoc's header line is still text the shell acts on: the `)` that closes the inner
1647
+ // subshell sits on it, and only the body after the newline is data. Skipping to the body's
1648
+ // end ate that `)` and left the substitution unclosed, so the whole call was named after
1649
+ // the text it could not split.
1650
+ test('a heredoc header line is text the shell acts on', () => {
1651
+ const command = "gh pr create --body \"$( (cat <<'X')\nplain\nX\n)\" && ./unclassified.sh";
1652
+ assert.equal(inferBashActivity(command), undefined);
1653
+ assert.equal(inferBashActivity("gh pr create --body \"$( (cat <<'X')\nplain\nX\n)\""), 'publishing');
1654
+ });
1655
+
1656
+ // The substitution veto is not weakened: a command hidden where this reader cannot follow
1657
+ // it — a backtick in the text the shell acts on, a `<(...)` process substitution, a heredoc
1658
+ // whose delimiter is UNQUOTED and therefore expands its body — still keeps the whole card
1659
+ // generic. A `$(...)` is a different shape: the segmenter DOES follow it, so
1660
+ // `--body "$(git log --oneline -1)"` is read as the `git log` it runs beside the
1661
+ // `gh pr create` write, and names that write.
1662
+ test('a substitution the reader cannot follow still keeps the call generic', () => {
1663
+ for (const command of [
1664
+ 'gh pr create --body "see `date` now"',
1665
+ 'gh pr create --body <(date)',
1666
+ 'gh pr create --title "`git rev-parse HEAD`" --body x',
1667
+ // A real backtick beside a named write still leaves the whole call unnamed.
1668
+ 'git push && cat `ls`',
1669
+ 'echo "a `b` c"',
1670
+ // An unquoted delimiter expands its body, so a substitution there may run anything.
1671
+ "gh pr create --body \"$(cat <<EOF\nsee `date`\nEOF\n)\"",
1672
+ ]) {
1673
+ assert.equal(inferBashActivity(command), undefined, command);
1674
+ }
1675
+ assert.equal(inferBashActivity('gh pr create --body "$(git log --oneline -1)"'), 'publishing');
1676
+ });
1677
+
1454
1678
  // A redirect that only CREATES a file from a read or from text is the build-up the
1455
1679
  // `preparing` family already names for `mkdir`, `touch` and `cp`; it is never a mutation
1456
1680
  // of anything else, so a mutating command beside a redirect stays generic.
@@ -433,8 +433,8 @@ test('S18/S19 (T14): the ready announcement registers the whole surface, exactly
433
433
  const bridge = installBridge();
434
434
  for (const entry of ready) entry.handler();
435
435
 
436
- assert.deepEqual([...loaded.commands.keys()].sort(), ['depth', 'files', 'issues', 'odd', 'warp'],
437
- 'the five commands arrive with the bridge');
436
+ assert.deepEqual([...loaded.commands.keys()].sort(), ['files', 'issues', 'odd', 'warp'],
437
+ 'the four commands arrive with the bridge');
438
438
  assert.deepEqual([...loaded.tools.keys()].sort(), ['worktree_create', 'worktree_list'], 'the two tools');
439
439
  assert.deepEqual([...loaded.messageRenderers.keys()], ['worktree-warp'], 'the message renderer');
440
440
  assert.deepEqual([...loaded.entryRenderers.keys()].sort(), ['odd-worktree-issues-refusal', 'odd-worktree-warp-queue'],
@@ -244,7 +244,7 @@ const agentStub = {
244
244
  describe('/files registration (S17)', () => {
245
245
  test('the file picker is registered beside the other three panels', async () => {
246
246
  const { commands } = await loadExtension({});
247
- assert.deepEqual([...commands.keys()].sort(), ['depth', 'files', 'issues', 'odd', 'warp']);
247
+ assert.deepEqual([...commands.keys()].sort(), ['files', 'issues', 'odd', 'warp']);
248
248
  const files = commands.get('files');
249
249
  assert.equal(typeof files.handler, 'function', 'the command carries its handler');
250
250
  assert.ok(files.description.includes('files'), 'the description says what it browses');
@@ -83,11 +83,11 @@ describe('manifest', () => {
83
83
  });
84
84
 
85
85
  describe('registration', () => {
86
- test('registers /warp, /odd, /files, /issues, /depth and the two worktree tools', async () => {
86
+ test('registers /warp, /odd, /files, /issues and the two worktree tools', async () => {
87
87
  delete process.env.GENTLE_WORKTREE_THREAD;
88
88
  const { commands, tools, messageRenderers } = await loadExtension({});
89
89
  const registered = [...commands.keys()].sort();
90
- assert.deepEqual(registered, ['depth', 'files', 'issues', 'odd', 'warp'], 'the command list is exactly the four panels and /depth');
90
+ assert.deepEqual(registered, ['files', 'issues', 'odd', 'warp'], 'the command list is exactly the four panels');
91
91
  assert.deepEqual([...tools.keys()].sort(), ['worktree_create', 'worktree_list'], 'exactly two agent tools');
92
92
  assert.deepEqual([...messageRenderers.keys()], ['worktree-warp']);
93
93
  });
@@ -1,70 +0,0 @@
1
- 'use strict';
2
- // `/depth`'s launch (S4, S5, S8): ONE background `gentle-ai-explore`, started through the host's own `subagent_run` tool
3
- // with the Depth task of `lib/depth-task.js` and nothing else.
4
- //
5
- // Everything after the start belongs to gentle-agents, which this package never imports: it draws the progress, owns the
6
- // cancel and, when the explorer finishes, sends its answer to the session as a message that starts a turn. So this module
7
- // has no widget, no timer and no message of its own. It decides whether the launch can happen and answers in one sentence
8
- // what did or did not.
9
- //
10
- // The host API is `ctx.executeTool(name, args)`, which never rejects for a tool failure — an unknown tool, a refused call
11
- // and a thrown error all come back as `isError: true` — and `ctx.tools`, which lists what it can call (the same contract
12
- // `lib/session-worktree-register.js` documents). `subagent_run` rejects any key outside its schema, so the arguments are
13
- // exactly `agent`, `task`, `label` and `mode`.
14
- //
15
- // Never throws, never rejects.
16
-
17
- const { buildDepthTask, depthLabel } = require('./depth-task.js');
18
-
19
- const DEPTH_AGENT = 'gentle-ai-explore';
20
- const DEPTH_TOOL = 'subagent_run';
21
-
22
- function refuse(message) {
23
- return { ok: false, level: 'error', message };
24
- }
25
-
26
- function toolAvailable(ctx) {
27
- try {
28
- if (!ctx || typeof ctx.executeTool !== 'function') return false;
29
- const tools = ctx.tools;
30
- return Array.isArray(tools) && tools.some((tool) => tool && tool.name === DEPTH_TOOL);
31
- } catch {
32
- return false;
33
- }
34
- }
35
-
36
- // The words the host tool answered with, so a refusal reads in its own sentence.
37
- function outcomeText(outcome) {
38
- const parts = outcome && Array.isArray(outcome.content) ? outcome.content : [];
39
- return parts
40
- .map((part) => (part && part.type === 'text' && typeof part.text === 'string' ? part.text.trim() : ''))
41
- .filter((text) => text.length > 0)
42
- .join(' ');
43
- }
44
-
45
- function couldNotStart(detail) {
46
- return refuse(`/depth couldn't start the explorer: ${detail}`);
47
- }
48
-
49
- async function launchDepth(request, ctx) {
50
- const task = buildDepthTask(request);
51
- if (task === null) {
52
- return refuse('/depth needs a request: /depth <request>. The explorer does not see this chat, so put everything it needs in the request.');
53
- }
54
- if (!toolAvailable(ctx)) {
55
- return refuse(`/depth starts a ${DEPTH_AGENT} subagent through the ${DEPTH_TOOL} tool, and this session does not offer it.`);
56
- }
57
- const label = depthLabel(request);
58
- let outcome;
59
- try {
60
- outcome = await ctx.executeTool(DEPTH_TOOL, { agent: DEPTH_AGENT, task, label, mode: 'background' });
61
- } catch (error) {
62
- return couldNotStart(error instanceof Error ? error.message : String(error));
63
- }
64
- if (!outcome || outcome.isError === true) {
65
- return couldNotStart(outcomeText(outcome) || `the ${DEPTH_TOOL} tool reported an error.`);
66
- }
67
- return { ok: true, level: 'info', message: `Exploring in the background (${label}). The handoff arrives in this session when it finishes.` };
68
- }
69
-
70
- module.exports = { DEPTH_AGENT, DEPTH_TOOL, launchDepth };
@@ -1,53 +0,0 @@
1
- You are doing a Depth pass on the request in `## Request`, the last section of this task. You are read-only, you have no chat history, and you cannot ask the human anything: the request is everything they said. First find and read the code, files, docs and logs it touches, so every answer rests on them.
2
-
3
- I want a deeper version of this request, not a bigger one. Answer these four questions from what you found, not from what a request like this usually needs:
4
-
5
- (1) What would a top professional in this field do here that the request does not ask for?
6
- (2) What is the rawest material they would start from, instead of what has already been digested?
7
- (3) What specific methods and tools would they use?
8
- (4) What, other than you or the human, would show the result is right?
9
-
10
- Take the professional's method, not their voice: do what they do, do not write like them.
11
-
12
- ## How to work
13
-
14
- 1. Read the source, not summaries of it, whenever the source is reachable. Search the project and the paths the request names.
15
- 2. Match the effort to the request. A small, specific request gets a short handoff, a line per section. A section with nothing to say says `none`.
16
- 3. You cannot run commands. Where the raw material needs something to be run (a test, a reproduction, a log), give the exact command and say it was not run. Never claim a result you did not observe.
17
- 4. For (4), name only oracles that something outside you can execute: an existing test, a command, a type check, a file to compare. Cite `path:line` where one exists. "Review it" and "double-check it" are not oracles.
18
- 5. Everything the request does not ask for, which is most of (1) to (3), goes only under `## Not requested`. Tag each item `[evidencia: path:line]` when you found its basis in the project, or `[inferido]` when it is your judgement. These are proposals for the human to accept or drop: never a requirement, and never part of `## Understood`.
19
- 6. `## Understood` adds nothing the request does not say. If the request can reasonably be read two materially different ways, do not pick one silently: say which reading you used there, and put the questions for the human under `## Questions`. Otherwise `## Questions` says `none`.
20
-
21
- Never carry the request out. Do not edit files or start work; you only read and report.
22
-
23
- ## Return
24
-
25
- Reply in the language of the request, in at most ~2k tokens. Start with this line, unchanged:
26
-
27
- **/depth handoff: read-only exploration, nothing was implemented.**
28
-
29
- Then give exactly these headings, in this order, each alone on its line. Copy each heading character for character: the names stay in English whatever the language of the request, and translating one is an error. Do not drop a section; a section with nothing to say says `none`. The last section, `## For the parent`, is required: without it the main session may start implementing.
30
-
31
- ## Original request
32
- The text under `## Request`, copied unchanged.
33
-
34
- ## Understood
35
- The request as you read it, from what you found. Nothing the request does not say.
36
-
37
- ## Questions
38
- Questions for the human, or `none`.
39
-
40
- ## Map
41
- The relevant files, symbols and how they relate, each with `path:line`. No file contents.
42
-
43
- ## Not requested
44
- What a top professional would add or do differently, from (1) to (3), each tagged as rule 5 says.
45
-
46
- ## How it would be verified
47
- From (4): the external oracles, by rule 4.
48
-
49
- ## Uncertainty
50
- What you could not settle, and what you did not read.
51
-
52
- ## For the parent
53
- Copy this paragraph unchanged: Do not implement this request. If `## Questions` is not `none`, ask the human those questions first. Show `## Not requested` to the human and wait for them to accept or drop each item before anything is added to a spec.
package/lib/depth-task.js DELETED
@@ -1,76 +0,0 @@
1
- 'use strict';
2
- // The task `/depth` hands the `gentle-ai-explore` subagent (S1, S3, S4, S8).
3
- //
4
- // The text is the instructions in `lib/depth-prompt/depth.md` — one Markdown file, so it can be read and edited as
5
- // prose — followed by the request exactly as the person typed it. The explorer starts with no chat, so the request is
6
- // the only thing it will ever know of the person's words; the instructions make it the first section of the handoff.
7
- //
8
- // The file is read on every call, so an edit applies to the next `/depth` with no reload. A missing or empty file falls
9
- // back to a short built-in task that still names every return section, the way the prompt blocks of this package fall
10
- // back to their heading: the command never fails because prose could not be read. Pure apart from that one read, and
11
- // it never throws.
12
-
13
- const fs = require('node:fs');
14
- const path = require('node:path');
15
-
16
- const DEPTH_FILE = path.join(__dirname, 'depth-prompt', 'depth.md');
17
- const REQUEST_HEADING = '## Request';
18
-
19
- // The handoff's sections in order. The parent reads this contract, so the names are fixed and in English whatever the
20
- // language of the request; `tools/depth-task.test.js` holds the shipped file to them.
21
- const DEPTH_RETURN_HEADINGS = Object.freeze([
22
- '## Original request',
23
- '## Understood',
24
- '## Questions',
25
- '## Map',
26
- '## Not requested',
27
- '## How it would be verified',
28
- '## Uncertainty',
29
- '## For the parent',
30
- ]);
31
-
32
- // The two lines that keep the parent from implementing. The parent wakes on the handoff alone, so the opening line and the
33
- // closing paragraph both ask for it; `lib/depth-prompt/depth.md` carries the same text and the suite holds the two in step.
34
- const DEPTH_BANNER = '**/depth handoff: read-only exploration, nothing was implemented.**';
35
- const DEPTH_FOR_PARENT = 'Do not implement this request. If `## Questions` is not `none`, ask the human those questions first. Show `## Not requested` to the human and wait for them to accept or drop each item before anything is added to a spec.';
36
-
37
- const FALLBACK = [
38
- 'Do a Depth pass on the request in `## Request`: find and read what it touches, then say what a top professional would do that it does not ask for, the rawest material they would start from, their methods and tools, and what outside you would show the result is right. A deeper version, not a bigger one.',
39
- 'Never carry the request out. You only read and report.',
40
- `Start your reply with this line, unchanged:\n\n${DEPTH_BANNER}`,
41
- `Then give exactly these headings, in this order, copied character for character:\n\n${DEPTH_RETURN_HEADINGS.join('\n\n')}`,
42
- `Under \`## For the parent\`, copy this paragraph unchanged: ${DEPTH_FOR_PARENT}`,
43
- ].join('\n\n');
44
-
45
- function readDepthFile() {
46
- return fs.readFileSync(DEPTH_FILE, 'utf8');
47
- }
48
-
49
- function instructions(read) {
50
- try {
51
- const text = read();
52
- return typeof text === 'string' && text.trim().length > 0 ? text.trim() : FALLBACK;
53
- } catch {
54
- return FALLBACK;
55
- }
56
- }
57
-
58
- // The task for one request, or `null` when there is no request to explore.
59
- function buildDepthTask(request, { read = readDepthFile } = {}) {
60
- if (typeof request !== 'string' || request.trim().length === 0) return null;
61
- return `${instructions(read)}\n\n${REQUEST_HEADING}\n\n${request.trim()}`;
62
- }
63
-
64
- const LABEL_PREFIX = 'depth: ';
65
- const LABEL_MAX = 60;
66
-
67
- // The one-line name the agents card shows for the task.
68
- function depthLabel(request) {
69
- if (typeof request !== 'string') return 'depth';
70
- const first = request.split('\n').map((line) => line.replace(/\s+/g, ' ').trim()).find((line) => line.length > 0);
71
- if (first === undefined) return 'depth';
72
- const room = LABEL_MAX - LABEL_PREFIX.length;
73
- return `${LABEL_PREFIX}${first.length > room ? `${first.slice(0, room - 1)}…` : first}`;
74
- }
75
-
76
- module.exports = { DEPTH_FILE, DEPTH_RETURN_HEADINGS, DEPTH_BANNER, DEPTH_FOR_PARENT, buildDepthTask, depthLabel };
@@ -1,66 +0,0 @@
1
- 'use strict';
2
- // `/depth` through the registered command (S4, S5, S6): the extension's one new command starts the explorer by itself,
3
- // through the host's `subagent_run` tool, and answers with one notice. The launch rules are in tools/depth-launch.test.js;
4
- // this suite proves the command is wired to them in the loaded extension, behind the same gate as the others.
5
- const { test } = require('node:test');
6
- const assert = require('node:assert/strict');
7
- const { loadExtension } = require('./fixtures/load-extension.js');
8
-
9
- function makeCtx({ tools = [{ name: 'subagent_run' }], outcome = { content: [{ type: 'text', text: 'Started gentle-ai-explore in the background as task t-1.' }] } } = {}) {
10
- const calls = [];
11
- const notes = [];
12
- const ctx = {
13
- tools,
14
- executeTool: async (name, args) => {
15
- calls.push({ name, args });
16
- return outcome;
17
- },
18
- ui: { notify: (message, level) => notes.push({ message, level }) },
19
- };
20
- return { ctx, calls, notes };
21
- }
22
-
23
- test('/depth is a registered command that says what it does', async () => {
24
- const { commands } = await loadExtension({});
25
- const depth = commands.get('depth');
26
- assert.ok(depth, '/depth is registered');
27
- assert.equal(typeof depth.handler, 'function');
28
- assert.match(depth.description, /background/);
29
- });
30
-
31
- test('/depth <request> starts one background explorer with the request verbatim and says so', async () => {
32
- const { commands } = await loadExtension({});
33
- const { ctx, calls, notes } = makeCtx();
34
- await commands.get('depth').handler(' make the error messages clearer ', ctx);
35
-
36
- assert.equal(calls.length, 1);
37
- assert.equal(calls[0].name, 'subagent_run');
38
- assert.equal(calls[0].args.agent, 'gentle-ai-explore');
39
- assert.equal(calls[0].args.mode, 'background');
40
- assert.ok(calls[0].args.task.endsWith('## Request\n\nmake the error messages clearer'));
41
- assert.deepEqual(notes, [
42
- { message: 'Exploring in the background (depth: make the error messages clearer). The handoff arrives in this session when it finishes.', level: 'info' },
43
- ]);
44
- });
45
-
46
- test('/depth with no request starts nothing and shows the usage as an error', async () => {
47
- const { commands } = await loadExtension({});
48
- const { ctx, calls, notes } = makeCtx();
49
- await commands.get('depth').handler('', ctx);
50
- assert.equal(calls.length, 0);
51
- assert.equal(notes.length, 1);
52
- assert.equal(notes[0].level, 'error');
53
- assert.match(notes[0].message, /^\/depth needs a request: \/depth <request>\./);
54
- });
55
-
56
- test('/depth without the host tool says so, and a context with no ui does not throw', async () => {
57
- const { commands } = await loadExtension({});
58
- const { ctx, calls, notes } = makeCtx({ tools: [] });
59
- await commands.get('depth').handler('fix the login', ctx);
60
- assert.equal(calls.length, 0);
61
- assert.match(notes[0].message, /subagent_run/);
62
- assert.equal(notes[0].level, 'error');
63
-
64
- await assert.doesNotReject(commands.get('depth').handler('fix the login', { tools: [], executeTool: async () => ({}) }));
65
- await assert.doesNotReject(commands.get('depth').handler(undefined, undefined));
66
- });
@@ -1,123 +0,0 @@
1
- 'use strict';
2
- // `/depth`'s launch (S4, S5, S8): the command starts ONE background `gentle-ai-explore` through the host's own
3
- // `subagent_run` tool, with the Depth task and nothing else. Progress, cancellation and the delivery of the handoff are
4
- // gentle-agents', so this module has no widget, no timer and no message of its own; it only decides whether the launch can
5
- // happen and says in one sentence what did or did not.
6
- const { test } = require('node:test');
7
- const assert = require('node:assert/strict');
8
- const { launchDepth, DEPTH_AGENT, DEPTH_TOOL } = require('../lib/depth-launch.js');
9
- const { DEPTH_RETURN_HEADINGS } = require('../lib/depth-task.js');
10
-
11
- const STARTED = {
12
- content: [{ type: 'text', text: 'Started gentle-ai-explore in the background as task abc-1.' }],
13
- details: {},
14
- };
15
-
16
- function host({ outcome = STARTED, tools = [{ name: 'subagent_run' }, { name: 'job_list' }], throws } = {}) {
17
- const calls = [];
18
- const ctx = {
19
- tools,
20
- executeTool: async (name, args) => {
21
- calls.push({ name, args });
22
- if (throws) throw throws;
23
- return outcome;
24
- },
25
- };
26
- return { ctx, calls };
27
- }
28
-
29
- test('the names the launch depends on are the host agent and tool', () => {
30
- assert.equal(DEPTH_AGENT, 'gentle-ai-explore');
31
- assert.equal(DEPTH_TOOL, 'subagent_run');
32
- });
33
-
34
- test('it starts one background explorer, with exactly the arguments the host tool accepts', async () => {
35
- const { ctx, calls } = host();
36
- const request = 'make the error messages clearer\n\n- keep «exactly» this';
37
- const result = await launchDepth(request, ctx);
38
-
39
- assert.equal(calls.length, 1);
40
- assert.equal(calls[0].name, 'subagent_run');
41
- // `subagent_run` rejects any other key (additionalProperties: false), so the set is closed.
42
- assert.deepEqual(Object.keys(calls[0].args).sort(), ['agent', 'label', 'mode', 'task']);
43
- assert.equal(calls[0].args.agent, 'gentle-ai-explore');
44
- assert.equal(calls[0].args.mode, 'background');
45
- assert.equal(calls[0].args.label, 'depth: make the error messages clearer');
46
- assert.ok(calls[0].args.task.endsWith(`## Request\n\n${request}`), 'the request goes in verbatim, last');
47
- for (const heading of DEPTH_RETURN_HEADINGS) assert.ok(calls[0].args.task.includes(heading), heading);
48
-
49
- assert.deepEqual(result, {
50
- ok: true,
51
- level: 'info',
52
- message: 'Exploring in the background (depth: make the error messages clearer). The handoff arrives in this session when it finishes.',
53
- });
54
- });
55
-
56
- test('a blank request starts nothing and says how to use the command', async () => {
57
- for (const blank of ['', ' \n', undefined, null]) {
58
- const { ctx, calls } = host();
59
- const result = await launchDepth(blank, ctx);
60
- assert.equal(calls.length, 0);
61
- assert.equal(result.ok, false);
62
- assert.equal(result.level, 'error');
63
- assert.match(result.message, /^\/depth needs a request: \/depth <request>\./);
64
- assert.match(result.message, /does not see this chat/);
65
- }
66
- });
67
-
68
- test('without the host tool nothing starts, and the sentence names the tool', async () => {
69
- const noTool = { executeTool: async () => assert.fail('must not be called') };
70
- const cases = [
71
- { ...noTool },
72
- { ...noTool, tools: [] },
73
- { ...noTool, tools: [{ name: 'job_list' }] },
74
- { ...noTool, tools: 'subagent_run' },
75
- { tools: [{ name: 'subagent_run' }] },
76
- undefined,
77
- null,
78
- ];
79
- for (const ctx of cases) {
80
- const result = await launchDepth('fix the login', ctx);
81
- assert.equal(result.ok, false);
82
- assert.equal(result.level, 'error');
83
- assert.match(result.message, /subagent_run/);
84
- assert.match(result.message, /does not offer it/);
85
- }
86
- });
87
-
88
- test('a refusal from the host tool is shown with its own words', async () => {
89
- const { ctx, calls } = host({ outcome: { isError: true, content: [{ type: 'text', text: 'Background subagents need an interactive session.' }] } });
90
- const result = await launchDepth('fix the login', ctx);
91
- assert.equal(calls.length, 1);
92
- assert.deepEqual(result, {
93
- ok: false,
94
- level: 'error',
95
- message: "/depth couldn't start the explorer: Background subagents need an interactive session.",
96
- });
97
- });
98
-
99
- test('a refusal with no text, a thrown error and an empty answer each become one sentence', async () => {
100
- const silent = await launchDepth('x', host({ outcome: { isError: true, content: [] } }).ctx);
101
- assert.equal(silent.message, "/depth couldn't start the explorer: the subagent_run tool reported an error.");
102
-
103
- const thrown = await launchDepth('x', host({ throws: new Error('boom') }).ctx);
104
- assert.equal(thrown.ok, false);
105
- assert.equal(thrown.message, "/depth couldn't start the explorer: boom");
106
-
107
- // `null`, not `undefined`: the double's default parameter would turn `undefined` into a successful start.
108
- const empty = await launchDepth('x', host({ outcome: null }).ctx);
109
- assert.equal(empty.ok, false);
110
- assert.match(empty.message, /^\/depth couldn't start the explorer:/);
111
- });
112
-
113
- test('a hostile context never makes it throw', async () => {
114
- const hostile = {
115
- get tools() {
116
- throw new Error('no tools for you');
117
- },
118
- executeTool: async () => STARTED,
119
- };
120
- const result = await launchDepth('fix the login', hostile);
121
- assert.equal(result.ok, false);
122
- assert.match(result.message, /subagent_run/);
123
- });
@@ -1,76 +0,0 @@
1
- 'use strict';
2
- // The task `/depth` hands the explorer: the instructions of `lib/depth-prompt/depth.md`, then the request exactly as the
3
- // person typed it (S1, S3, S8). The explorer has no chat, so the request is the only thing it will ever know of the
4
- // person's words, and it comes back first in the handoff (S8, L8).
5
- const { test } = require('node:test');
6
- const assert = require('node:assert/strict');
7
- const { buildDepthTask, depthLabel, DEPTH_RETURN_HEADINGS, DEPTH_BANNER, DEPTH_FOR_PARENT } = require('../lib/depth-task.js');
8
-
9
- const REQUEST = 'make the error messages clearer\n\n- keep «exactly» this: `/x failed:`\n- no retries';
10
-
11
- test('the task is the instructions, then the request exactly as typed', () => {
12
- const task = buildDepthTask(REQUEST, { read: () => 'INSTRUCTIONS' });
13
- assert.ok(task.startsWith('INSTRUCTIONS'), 'the instructions lead');
14
- assert.ok(task.endsWith(`## Request\n\n${REQUEST}`), 'the request closes the task, byte for byte');
15
- assert.equal(task.split('## Request').length - 1, 1, 'one request section');
16
- });
17
-
18
- test('only the ends of the request are trimmed, never its inside', () => {
19
- const task = buildDepthTask('\n a\n\n b \n\n', { read: () => 'I' });
20
- assert.ok(task.endsWith('## Request\n\na\n\n b'));
21
- });
22
-
23
- test('a blank or non-string request builds no task', () => {
24
- for (const blank of ['', ' ', '\n\t\n', undefined, null, 5, {}]) {
25
- assert.equal(buildDepthTask(blank, { read: () => 'I' }), null);
26
- }
27
- });
28
-
29
- test('a missing or empty instructions file still gives a task that names every section', () => {
30
- const unreadable = () => {
31
- throw new Error('ENOENT');
32
- };
33
- for (const read of [unreadable, () => '', () => ' \n', () => undefined]) {
34
- const task = buildDepthTask(REQUEST, { read });
35
- assert.ok(task.endsWith(`## Request\n\n${REQUEST}`));
36
- for (const heading of DEPTH_RETURN_HEADINGS) assert.ok(task.includes(heading), `fallback names ${heading}`);
37
- assert.match(task, /Never carry the request out/);
38
- }
39
- });
40
-
41
- test('the shipped instructions name the return sections in order, and the parent closes them', () => {
42
- const task = buildDepthTask('x');
43
- let at = -1;
44
- for (const heading of DEPTH_RETURN_HEADINGS) {
45
- const next = task.indexOf(`\n${heading}\n`, at + 1);
46
- assert.ok(next > at, `${heading} appears after the previous section`);
47
- at = next;
48
- }
49
- assert.equal(DEPTH_RETURN_HEADINGS[0], '## Original request', 'the verbatim request leads the handoff');
50
- assert.equal(DEPTH_RETURN_HEADINGS.at(-1), '## For the parent', 'the line for the parent closes it');
51
- assert.match(task, /Do not implement/);
52
- });
53
-
54
- test('the label is one short line that starts with the command', () => {
55
- assert.equal(depthLabel('fix the login'), 'depth: fix the login');
56
- const long = depthLabel(`${'x'.repeat(200)}\nsecond line`);
57
- assert.ok(long.startsWith('depth: xxx') && long.endsWith('…') && !long.includes('\n'));
58
- assert.ok(long.length <= 60, `short enough, got ${long.length}`);
59
- assert.equal(depthLabel('first\nsecond'), 'depth: first');
60
- for (const blank of ['', ' ', undefined, 5]) assert.equal(depthLabel(blank), 'depth');
61
- });
62
-
63
- test('the parent is guarded at both ends: an opening line and the closing paragraph, in the shipped file and in the fallback', () => {
64
- // The parent wakes on the handoff alone and may start implementing, so the instruction not to must not depend on one
65
- // section a cheap model can drop (a real run dropped `## For the parent` and translated the headings).
66
- assert.equal(typeof DEPTH_BANNER, 'string');
67
- assert.equal(typeof DEPTH_FOR_PARENT, 'string');
68
- assert.match(DEPTH_BANNER, /nothing was implemented/);
69
- assert.match(DEPTH_FOR_PARENT, /^Do not implement this request\./);
70
- for (const read of [undefined, () => '']) {
71
- const task = buildDepthTask('x', read === undefined ? {} : { read });
72
- assert.ok(task.includes(DEPTH_BANNER), 'the opening line is asked for');
73
- assert.ok(task.includes(DEPTH_FOR_PARENT), 'the closing paragraph is given');
74
- assert.match(task, /character for character/);
75
- }
76
- });