pi-odd-worktree 3.12.3 → 3.13.0

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.
@@ -11,12 +11,16 @@
11
11
  // from Pi, so a stub class is enough to exercise all of it.
12
12
  //
13
13
  // WHAT IT DRAWS, and what it never touches:
14
- // * THE HEADING is `✿ You · 14:32`: the mark and the name in the theme's `accent` role (the
14
+ // * THE HEADING is `✿ Jona · 14:32`: the mark and the name in the theme's `accent` role (the
15
15
  // card's `titleRole`), then the substrate's `SEPARATOR` and the prompt's clock in `muted`
16
- // (the subtitle path `lib/shell-card.js` already has, `SUBTITLE_ROLE`). The clock is the
16
+ // (the subtitle path `lib/shell-card.js` already has, `SUBTITLE_ROLE`). THE NAME IS THE USER'S
17
+ // OWN — the `identity` document `lib/user-identity.js` reads from the bridge's store — and it
18
+ // falls back to `You` when nothing usable is stored (S1/S2 of identity-command): it is read on
19
+ // every paint, so a name set or cleared while the transcript is on screen repaints the prompts
20
+ // already there, and no invalidation call exists. The clock is the
17
21
  // host's own `timestamp` when it set one, else the moment of the card's FIRST paint, held
18
22
  // per component so a live prompt does not drift frame by frame; with neither, the heading is
19
- // `✿ You` alone and nothing is invented. The whole closed box still wears the `accent` role
23
+ // `✿ Jona` alone and nothing is invented. The whole closed box still wears the `accent` role
20
24
  // (`railRole`) — corners, lead, rule, sides, rail and bottom. That one role around the entire
21
25
  // frame is what tells this card apart from the tool cards, which paint their tone.
22
26
  // No glyph override is made (the `✿` is the substrate's default mark).
@@ -44,16 +48,17 @@
44
48
  // UNLIKE the file cards, this one fails CLOSED: an absent bridge, an absent reader, a
45
49
  // reader that throws, any other answer and a width too small to draw a frame all hand
46
50
  // the host's own rows back — the very array `render` returned — byte for byte (S6).
47
- // * THE COST, stated honestly, per PAINT: ONE GATE READ ALWAYS, PLUS ONE STYLE READ ONLY WHILE
48
- // THE CARD ACTUALLY DRAWS. The gate asks the bridge's reader on every paint — its reader
49
- // queries the selection store on every call, and that read is what makes the flip live, so
50
- // it is never cached. Any answer but this package's design returns BEFORE the style is
51
- // asked, so a native frame pays the gate read alone; a frame that does draw then pays one
52
- // more live read, `floatRows` asking the shell's style through `lib/card-style.js` (the live
53
- // slot Gentle Shell writes, or `<home>/card-style.json` when nothing is published there).
54
- // Both are deliberate. The memo below covers only the DRAWING (the Markdown rows and the
55
- // composed frame parts), keyed on width, paint and rendered rows, so a steady frame
56
- // recomposes nothing.
51
+ // * THE COST, stated honestly, per PAINT: ONE GATE READ ALWAYS, PLUS ONE STORE READ AND ONE STYLE
52
+ // READ ONLY WHILE THE CARD ACTUALLY DRAWS. The gate asks the bridge's reader on every paint —
53
+ // its reader queries the selection store on every call, and that read is what makes the flip
54
+ // live, so it is never cached. Any answer but this package's design returns BEFORE anything
55
+ // else is read, so a native frame pays the gate read alone; a frame that does draw then pays
56
+ // the `identity` document read (`lib/user-identity.js`, one synchronous `get` through the same
57
+ // published store) and one more live read, `floatRows` asking the shell's style through
58
+ // `lib/card-style.js` (the live slot Gentle Shell writes, or `<home>/card-style.json` when
59
+ // nothing is published there). All are deliberate. The memo below covers only the DRAWING (the
60
+ // Markdown rows and the composed frame parts), keyed on width, paint, the name and the rendered
61
+ // rows, so a steady frame recomposes nothing while a changed name still does.
57
62
  //
58
63
  // The wrapper never throws: any error on this side answers the original rows. `uninstall()`
59
64
  // restores the original `render`, and the extension calls it on `session_shutdown`.
@@ -68,10 +73,14 @@ const {
68
73
  } = require('./shell-card.js');
69
74
  const { ACTIVITY_DESIGN_ID, bridgeApi } = require('./file-card-resolver.js');
70
75
  const { themeFor } = require('./file-card.js');
71
-
72
- // The one heading this card wears: the mark is the substrate's default `✿`, the name is the
73
- // person, and the role is the accent for the name and for the whole closed box. The clock is NOT
74
- // part of it — it belongs to the component being drawn, so `cardParts` adds it per paint (S1).
76
+ // The user's own name, read from the bridge's store on every paint (identity-command S2): the
77
+ // heading is the person, so a name set or cleared mid-session repaints instead of being cached.
78
+ const { currentIdentityName } = require('./user-identity.js');
79
+
80
+ // The one heading this card wears when no name is stored: the mark is the substrate's default `✿`,
81
+ // the name is the person (`IDENTITY.title` is the fallback, the stored name replaces it), and the
82
+ // role is the accent for the name and for the whole closed box. The clock is NOT part of it — it
83
+ // belongs to the component being drawn, so `cardParts` adds it per paint (S1).
75
84
  const IDENTITY = Object.freeze({
76
85
  title: 'You',
77
86
  tone: CARD_TONE.INFO,
@@ -296,7 +305,8 @@ function clockText(at) {
296
305
  *
297
306
  * The memo is keyed on the SOURCE, so the formatting runs once per component (or once per
298
307
  * `timestamp` the host sets) and every later paint reads the string it already made — a steady
299
- * frame formats nothing and reads no file, no store and no bridge.
308
+ * frame formats nothing here, and the only per-paint reads a card pays are the gate's, the stored
309
+ * name's (`paintPrompt`) and the style's.
300
310
  */
301
311
  function headingClock(self) {
302
312
  const field = asObject(self).timestamp;
@@ -327,12 +337,13 @@ function headingClock(self) {
327
337
  * chrome in force is decided by the requested width and the style `floatRows` resolved for it
328
338
  * (`floatOpener(theme, tone, target)`), so `target` and `inner` are both keyed: a style at the
329
339
  * same inner width therefore always recomposes. The paint is keyed because the roles are the
330
- * theme's, and the rendered rows because the body is Pi's own Markdown. A steady frame only
331
- * compares the fields and hands the same parts back. No file, no child process and no store is
332
- * read in here. A paint's live reads are the gate's selection read (always, above) and, only
333
- * while the card actually draws, the shell's style read `floatRows` makes.
340
+ * theme's, `name` because the heading IS the person — `You` is only the fallback, so a name set
341
+ * or cleared under a transcript has to recompose the head already on screen — and the rendered
342
+ * rows because the body is Pi's own Markdown. A steady frame only compares the fields and hands
343
+ * the same parts back. NOTHING IS READ IN HERE: the name arrives already read ONCE by
344
+ * `paintPrompt`, so a card paint pays that one document read once and not once per `inner`.
334
345
  */
335
- function cardParts(self, markdown, target, inner, paint, metrics) {
346
+ function cardParts(self, markdown, target, inner, paint, metrics, name) {
336
347
  const width = cardInnerWidth(inner);
337
348
  const rows = renderedRows(markdown, width);
338
349
  if (rows === undefined) return undefined;
@@ -348,11 +359,14 @@ function cardParts(self, markdown, target, inner, paint, metrics) {
348
359
  && remembered.inner === inner
349
360
  && remembered.paint === paint
350
361
  && remembered.clock === clock
362
+ && remembered.name === name
351
363
  && sameRows(remembered.rows, rows)
352
364
  ) return remembered.parts;
353
- // The clock rides the substrate's subtitle path: the heading states `✿ You`, then the
354
- // separator and the clock in `muted` (`SUBTITLE_ROLE`). No clock, no subtitle at all.
355
- const card = clock === undefined ? { ...IDENTITY } : { ...IDENTITY, subtitle: clock };
365
+ // The clock rides the substrate's subtitle path: the heading states `✿ Jona` — the stored name,
366
+ // or `You` when nothing usable is stored — then the separator and the clock in `muted`
367
+ // (`SUBTITLE_ROLE`). No clock, no subtitle at all.
368
+ const title = name === undefined || name === null ? IDENTITY.title : name;
369
+ const card = clock === undefined ? { ...IDENTITY, title } : { ...IDENTITY, title, subtitle: clock };
356
370
  const parts = {
357
371
  head: cardTopRows(card, paint, inner, undefined, metrics),
358
372
  // The body is never clipped: a prompt is not a preview, so every row is drawn.
@@ -360,7 +374,7 @@ function cardParts(self, markdown, target, inner, paint, metrics) {
360
374
  // No content rides the closing rule: the prompt's clock belongs to the heading alone.
361
375
  bottom: cardBottom(IDENTITY.tone, paint, inner, undefined, metrics),
362
376
  };
363
- cardMemo.set(self, { markdown, target, inner, paint, clock, rows, parts });
377
+ cardMemo.set(self, { markdown, target, inner, paint, clock, name, rows, parts });
364
378
  return parts;
365
379
  }
366
380
 
@@ -387,6 +401,12 @@ function zoneRows(rows) {
387
401
  * The rows one paint answers: the host's own rows for every answer but the activity design,
388
402
  * the card for it. `rows` is exactly what the original `render` returned, so every refusal is
389
403
  * byte for byte (S6).
404
+ *
405
+ * The stored name is read ONCE here, after the gate and the width floor have already refused
406
+ * anything that is not a card: a native frame, a tiny width and an unreadable body pay no store
407
+ * read at all, and a card that does draw pays exactly one — never one per `inner` the style asks
408
+ * for. The read is live on every paint (never cached), which is what makes a name set or cleared
409
+ * while the transcript is on screen reach the prompts already on it without any invalidation.
390
410
  */
391
411
  function paintPrompt(self, rows, width, seams) {
392
412
  if (!Array.isArray(rows) || rows.length === 0) return rows;
@@ -400,9 +420,10 @@ function paintPrompt(self, rows, width, seams) {
400
420
  const paint = themeFor(readTheme(seams.theme), PLAIN_THEME);
401
421
  const markdown = componentMarkdown(self, paint);
402
422
  if (markdown === undefined) return rows;
423
+ const name = currentIdentityName();
403
424
  try {
404
425
  const drawn = floatRows(IDENTITY.tone, paint, target, (inner) => {
405
- const parts = cardParts(self, markdown, target, inner, paint, metrics);
426
+ const parts = cardParts(self, markdown, target, inner, paint, metrics, name);
406
427
  // A body that draws nothing is no card: the host's own rows are the honest answer,
407
428
  // and the throw below is how that leaves `floatRows` untouched.
408
429
  if (parts === undefined) throw new TypeError('the user prompt drew no row');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-odd-worktree",
3
- "version": "3.12.3",
3
+ "version": "3.13.0",
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",
@@ -87,16 +87,16 @@ test('neither sentence ends in ", if it applies" any more (S3)', async () => {
87
87
  }
88
88
  });
89
89
 
90
- test('an explore agent gets the native wording, every other child the MCP one', async () => {
90
+ test('a child gets no reminder: its own rule text already says it and it lives a message or two', async () => {
91
91
  const child = (agent, tools) => setup({
92
92
  env: { GENTLE_PI_AGENTS_CHILD: '1', GENTLE_PI_AGENTS_REQUESTED_TOOLS: tools },
93
93
  argv: ['node', `/tmp/gentle-pi-subagent-${agent}-a1b2c3/bin.js`],
94
94
  tools: [],
95
95
  });
96
96
  const explorer = child('gentle-ai-explore', 'read,bash,codegraph');
97
- assert.equal(await explorer.guard.onToolResult(bash('cat src/a.ts'), explorer.ctx), NATIVE);
97
+ assert.equal(await explorer.guard.onToolResult(bash('cat src/a.ts'), explorer.ctx), undefined);
98
98
  const worker = child('gentle-ai-worker', 'read,bash,mcp__codegraph__codegraph_explore');
99
- assert.equal(await worker.guard.onToolResult(bash('cat src/a.ts'), worker.ctx), MCP);
99
+ assert.equal(await worker.guard.onToolResult(bash('cat src/a.ts'), worker.ctx), undefined);
100
100
  });
101
101
 
102
102
  // ---- who gets which guard (S1, S2) ----
@@ -36,7 +36,12 @@ describe('the seven texts on disk', () => {
36
36
  for (const binary of ['fd', 'find', 'rg', 'grep', 'read', 'cat']) {
37
37
  assert.ok(text.includes(`\`${binary}\``), `${variant} names ${binary}`);
38
38
  }
39
- assert.match(text, /other tools stay|may skip it/, `${variant} leaves the other tools available`);
39
+ // S1: the primary and the generic texts carry no permission sentence; the five role texts keep theirs.
40
+ if (variant === 'orchestrator' || variant === 'generic') {
41
+ assert.doesNotMatch(text, /other tools stay|rather than a lookup|answer is a map|not proof/i, `${variant} has no escape hatch`);
42
+ } else {
43
+ assert.match(text, /other tools stay|may skip it/, `${variant} leaves the other tools available`);
44
+ }
40
45
  }
41
46
  });
42
47
 
@@ -81,9 +86,10 @@ describe('the orchestrator and explore texts stay inside their role', () => {
81
86
 
82
87
  test('the orchestrator calls the graph first for a where/who/how/what-reaches question, with one exemption and one literal call', () => {
83
88
  const text = prose('orchestrator');
84
- assert.match(text, /to answer where code lives, who calls it, how it works, or what a change reaches, call CodeGraph first/, text);
89
+ assert.match(text, /to answer where code lives, who calls it, how it works, or what a change reaches, your first call is CodeGraph/, text);
85
90
  assert.match(text, /`codegraph` with `operation: "explore"` and `query: "<symbols or the question>"`/, 'the literal call');
86
- assert.match(text, /Skip it only for an exact string or a file path the user gave you/, 'one exemption');
91
+ assert.match(text, /The one exemption is an exact string or a file path the user gave you/, 'one exemption');
92
+ assert.equal((text.match(/exemption|skip/gi) || []).length, 1, 'and only one');
87
93
  assert.match(text, /what scope, size and any handoff depend on/, 'the sizing use is kept');
88
94
  });
89
95
 
@@ -338,6 +338,16 @@ test('a code read in the session checkout gets one reminder part appended, and t
338
338
  assert.deepEqual(patch.structuredContent, { output: 'source' }, 'the structured content of the result is kept');
339
339
  });
340
340
 
341
+ test('a child is not reminded', async () => {
342
+ const { run } = setup({
343
+ toplevel: checkoutMap(),
344
+ env: { GENTLE_PI_AGENTS_CHILD: '1', GENTLE_PI_AGENTS_REQUESTED_TOOLS: 'read,grep,mcp__codegraph__codegraph_explore' },
345
+ argv: ['node', '/tmp/gentle-pi-subagent-gentle-ai-worker-ab12cd/instructions.md'],
346
+ });
347
+ await run('before_agent_start', { systemPromptOptions: { selectedTools: [] } });
348
+ assert.equal(await run('tool_result', readEvent('src/a.ts')), undefined);
349
+ });
350
+
341
351
  test('ODD_WORKTREE_PROMPT=0 silences the reminders too, because they cite the rule that variable suppresses', async () => {
342
352
  const { run } = setup({ toplevel: checkoutMap(), env: { ODD_WORKTREE_PROMPT: '0' } });
343
353
  await run('before_agent_start', SESSION_TOOLS);
@@ -400,14 +410,14 @@ test('a new request re-arms the one reminder of the checkout (S3, S7)', async ()
400
410
  assert.equal(next.content[1].text, NATIVE_REMINDER, 'the first search of the next request hears it again');
401
411
  });
402
412
 
403
- test('a worker child is told to call the MCP tool, and a review agent is told nothing', async () => {
413
+ test('a worker child and a review agent are told nothing', async () => {
404
414
  const worker = setup({
405
415
  env: { GENTLE_PI_AGENTS_CHILD: '1', GENTLE_PI_AGENTS_REQUESTED_TOOLS: 'read,bash,mcp__codegraph__codegraph_explore' },
406
416
  argv: ['node', '/tmp/gentle-pi-subagent-gentle-ai-worker-a1b2c3/bin.js'],
407
417
  toplevel: checkoutMap(),
408
418
  });
409
419
  const workerPatch = await worker.run('tool_result', readEvent('src/a.ts'));
410
- assert.equal(workerPatch.content[1].text, MCP_REMINDER);
420
+ assert.equal(workerPatch, undefined);
411
421
 
412
422
  const reviewer = setup({
413
423
  env: { GENTLE_PI_AGENTS_CHILD: '1', GENTLE_PI_AGENTS_REQUESTED_TOOLS: 'read,bash,mcp__codegraph__codegraph_explore' },
@@ -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(), ['files', 'issues', 'odd', 'prs', 'warp'],
437
- 'the five commands arrive with the bridge');
436
+ assert.deepEqual([...loaded.commands.keys()].sort(), ['files', 'identity', 'issues', 'odd', 'prs', 'warp'],
437
+ 'the six 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'],
@@ -251,9 +251,9 @@ const agentStub = {
251
251
  };
252
252
 
253
253
  describe('/files registration (S17)', () => {
254
- test('the file picker is registered beside the other three panels', async () => {
254
+ test('the file picker is registered beside the other panels', async () => {
255
255
  const { commands } = await loadExtension({});
256
- assert.deepEqual([...commands.keys()].sort(), ['files', 'issues', 'odd', 'prs', 'warp']);
256
+ assert.deepEqual([...commands.keys()].sort(), ['files', 'identity', 'issues', 'odd', 'prs', 'warp']);
257
257
  const files = commands.get('files');
258
258
  assert.equal(typeof files.handler, 'function', 'the command carries its handler');
259
259
  assert.ok(files.description.includes('files'), 'the description says what it browses');
@@ -1567,8 +1567,13 @@ test('F3 preserve: a standard single-root repository still paints plain document
1567
1567
  const pending = doOdd(e, '', ctxFor(repo, host, []));
1568
1568
  try {
1569
1569
  await waitFor(() => host.mounts.length === 1, 'the panel mounts');
1570
- assert.deepEqual(rowLabels(host.mounts[0].component), ['main-two', 'main-one'],
1571
- 'unique names keep their exact plain text, in the recency order the panel always used');
1570
+ // The fixture's mtimes are deliberately the OPPOSITE of its rank (T16 depends on that),
1571
+ // and the panel can paint the cheap mtime scan before the ranked listing lands, so the
1572
+ // frame read here has to be the settled one: wait for the rank, then assert it.
1573
+ await waitFor(() => rowLabels(host.mounts[0].component).join('|') === 'main-one|main-two',
1574
+ 'the settled frame is the ranked listing');
1575
+ assert.deepEqual(rowLabels(host.mounts[0].component), ['main-one', 'main-two'],
1576
+ 'unique names keep their exact plain text, in the rank the panel reads');
1572
1577
  } finally {
1573
1578
  await closePanel(host, pending);
1574
1579
  }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
- // S4 surface: the standalone package always registers /warp, /odd, /files
3
- // and /issues plus the TWO agent worktree tools (S3/S4: `worktree_delete` and
2
+ // S4 surface: the standalone package always registers /warp, /odd, /files,
3
+ // /issues and /identity plus the TWO agent worktree tools (S3/S4: `worktree_delete` and
4
4
  // `worktree_warp` are not registered, so `/warp` is the only front that moves
5
5
  // the session and the panel's ctrl+d the only one that removes a checkout),
6
6
  // loads in plain Pi with git as its only external dependency, and ships none of
@@ -13,9 +13,10 @@
13
13
  // worktree↔issue association.
14
14
  //
15
15
  // The bash activity is not a preference here: it is a design on gentle-shell-bridge's
16
- // own `Card activity` line, so the shipped surface is exactly five commands, two tools, TWO
16
+ // own `Card activity` line, so the shipped surface is exactly six commands, two tools, TWO
17
17
  // sidebar sections, one tools design and the one `Cards` row group the two file-card
18
- // switches carry.
18
+ // switches carry. `/identity` is the name the person stores for their own prompt card and
19
+ // the orchestrator prompt: transversal like `/files`, so no module switch gates it.
19
20
  //
20
21
  // Everything here reads the observable surface: the registered command and
21
22
  // tool objects, the manifest, the files on disk. No internal state is read.
@@ -85,11 +86,11 @@ describe('manifest', () => {
85
86
  });
86
87
 
87
88
  describe('registration', () => {
88
- test('registers /warp, /odd, /files, /issues, /prs and the two worktree tools', async () => {
89
+ test('registers /warp, /odd, /files, /issues, /prs, /identity and the two worktree tools', async () => {
89
90
  delete process.env.GENTLE_WORKTREE_THREAD;
90
91
  const { commands, tools, messageRenderers } = await loadExtension({});
91
92
  const registered = [...commands.keys()].sort();
92
- assert.deepEqual(registered, ['files', 'issues', 'odd', 'prs', 'warp'], 'the command list is exactly the five panels');
93
+ assert.deepEqual(registered, ['files', 'identity', 'issues', 'odd', 'prs', 'warp'], 'the command list is exactly the six panels');
93
94
  assert.deepEqual([...tools.keys()].sort(), ['worktree_create', 'worktree_list'], 'exactly two agent tools');
94
95
  assert.deepEqual([...messageRenderers.keys()], ['worktree-warp']);
95
96
  });