pi-odd-worktree 3.11.1 → 3.12.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.
- package/README.md +6 -4
- package/extensions/odd-worktree-tools.ts +1205 -40
- package/lib/odd-group.js +655 -0
- package/lib/odd-listing.js +349 -0
- package/lib/odd-rail-model.js +150 -0
- package/lib/odd-rail-section.js +453 -0
- package/lib/odd-session.js +231 -0
- package/lib/odd-view.js +500 -46
- package/lib/user-prompt-card.js +68 -10
- package/package.json +1 -1
- package/tools/commands.test.js +58 -0
- package/tools/issues-command.test.js +13 -2
- package/tools/issues-open-guard.test.js +7 -1
- package/tools/issues-section.test.js +11 -2
- package/tools/odd-group.test.js +950 -0
- package/tools/odd-listing.test.js +504 -0
- package/tools/odd-panel-wiring.test.js +1868 -0
- package/tools/odd-rail-model.test.js +184 -0
- package/tools/odd-rail-section.test.js +524 -0
- package/tools/odd-rail-wiring.test.js +572 -0
- package/tools/odd-session-wiring.test.js +419 -0
- package/tools/odd-session.test.js +282 -0
- package/tools/odd-view.test.js +407 -1
- package/tools/package-surface.test.js +22 -6
- package/tools/prs-command.test.js +1 -1
- package/tools/user-prompt-card.test.js +173 -6
package/lib/user-prompt-card.js
CHANGED
|
@@ -11,11 +11,15 @@
|
|
|
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
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
14
|
+
// * THE HEADING is `✿ You · 14:32`: the mark and the name in the theme's `accent` role (the
|
|
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
|
|
17
|
+
// host's own `timestamp` when it set one, else the moment of the card's FIRST paint, held
|
|
18
|
+
// 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
|
|
20
|
+
// (`railRole`) — corners, lead, rule, sides, rail and bottom. That one role around the entire
|
|
21
|
+
// frame is what tells this card apart from the tool cards, which paint their tone.
|
|
22
|
+
// No glyph override is made (the `✿` is the substrate's default mark).
|
|
19
23
|
// * THE BODY is Pi's own rendering of the prompt. The component's Markdown child is
|
|
20
24
|
// rebuilt from its OWN constructor with the user message background dropped
|
|
21
25
|
// (`bgColor: undefined`), no side padding (the frame is the padding) and the host's own
|
|
@@ -66,8 +70,8 @@ const { ACTIVITY_DESIGN_ID, bridgeApi } = require('./file-card-resolver.js');
|
|
|
66
70
|
const { themeFor } = require('./file-card.js');
|
|
67
71
|
|
|
68
72
|
// The one heading this card wears: the mark is the substrate's default `✿`, the name is the
|
|
69
|
-
// person, and the role is the accent for the name and for the whole closed box.
|
|
70
|
-
//
|
|
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).
|
|
71
75
|
const IDENTITY = Object.freeze({
|
|
72
76
|
title: 'You',
|
|
73
77
|
tone: CARD_TONE.INFO,
|
|
@@ -265,6 +269,53 @@ const sameRows = (a, b) => a === b || (a.length === b.length && a.every((row, in
|
|
|
265
269
|
const cloneMemo = new WeakMap();
|
|
266
270
|
/** The per-component card memo: (requested width, drawn width, paint, rendered rows) in, parts out. */
|
|
267
271
|
const cardMemo = new WeakMap();
|
|
272
|
+
/** The per-component clock memo: the raw source read (`timestamp`, else `undefined`) and its `HH:MM`. */
|
|
273
|
+
const clockMemo = new WeakMap();
|
|
274
|
+
|
|
275
|
+
// ---- the heading's clock (S1) ----
|
|
276
|
+
|
|
277
|
+
/** Two digits, zero padded: the clock's only formatting rule. */
|
|
278
|
+
const twoDigits = (value) => String(value).padStart(2, '0');
|
|
279
|
+
|
|
280
|
+
/** One instant as local 24-hour `HH:MM`: no seconds, no date, no relative wording. */
|
|
281
|
+
function clockText(at) {
|
|
282
|
+
const instant = new Date(at);
|
|
283
|
+
return `${twoDigits(instant.getHours())}:${twoDigits(instant.getMinutes())}`;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The clock the heading carries for `self`, or `undefined` when there is none to state.
|
|
288
|
+
*
|
|
289
|
+
* The source, in this order (S1):
|
|
290
|
+
* 1. the component's OWN `timestamp` when it is a string — what Pi sets when it rebuilds a
|
|
291
|
+
* prompt from a session entry, so a restored transcript shows when the prompt was sent;
|
|
292
|
+
* 2. otherwise a clock captured ONCE, at the component's first paint, so a prompt sent live
|
|
293
|
+
* shows its arrival time too and a later frame never drifts;
|
|
294
|
+
* 3. with neither, nothing: the heading keeps `✿ You` and no time is invented (an unparseable
|
|
295
|
+
* `timestamp` is not a clock, and a host clock that answers no number is not one either).
|
|
296
|
+
*
|
|
297
|
+
* The memo is keyed on the SOURCE, so the formatting runs once per component (or once per
|
|
298
|
+
* `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.
|
|
300
|
+
*/
|
|
301
|
+
function headingClock(self) {
|
|
302
|
+
const field = asObject(self).timestamp;
|
|
303
|
+
const source = typeof field === 'string' ? field : undefined;
|
|
304
|
+
const key = self !== null && typeof self === 'object' ? self : undefined;
|
|
305
|
+
const remembered = key === undefined ? undefined : clockMemo.get(key);
|
|
306
|
+
if (remembered !== undefined && remembered.source === source) return remembered.clock;
|
|
307
|
+
let clock;
|
|
308
|
+
if (source !== undefined) {
|
|
309
|
+
const at = Date.parse(source);
|
|
310
|
+
if (Number.isFinite(at)) clock = clockText(at);
|
|
311
|
+
}
|
|
312
|
+
if (clock === undefined) {
|
|
313
|
+
const now = Date.now();
|
|
314
|
+
clock = Number.isFinite(now) ? clockText(now) : undefined;
|
|
315
|
+
}
|
|
316
|
+
if (key !== undefined) clockMemo.set(key, { source, clock });
|
|
317
|
+
return clock;
|
|
318
|
+
}
|
|
268
319
|
|
|
269
320
|
/**
|
|
270
321
|
* One component's card parts for one draw — `{ head, body, bottom }`, the shape `floatRows`
|
|
@@ -285,6 +336,10 @@ function cardParts(self, markdown, target, inner, paint, metrics) {
|
|
|
285
336
|
const width = cardInnerWidth(inner);
|
|
286
337
|
const rows = renderedRows(markdown, width);
|
|
287
338
|
if (rows === undefined) return undefined;
|
|
339
|
+
// The clock is part of the memo key ONLY as the string it formats to: it cannot change between
|
|
340
|
+
// paints except through the component's own `timestamp` or the theme, and a steady frame pays
|
|
341
|
+
// one memo read rather than a second format.
|
|
342
|
+
const clock = headingClock(self);
|
|
288
343
|
const remembered = cardMemo.get(self);
|
|
289
344
|
if (
|
|
290
345
|
remembered !== undefined
|
|
@@ -292,17 +347,20 @@ function cardParts(self, markdown, target, inner, paint, metrics) {
|
|
|
292
347
|
&& remembered.target === target
|
|
293
348
|
&& remembered.inner === inner
|
|
294
349
|
&& remembered.paint === paint
|
|
350
|
+
&& remembered.clock === clock
|
|
295
351
|
&& sameRows(remembered.rows, rows)
|
|
296
352
|
) return remembered.parts;
|
|
297
|
-
|
|
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 };
|
|
298
356
|
const parts = {
|
|
299
357
|
head: cardTopRows(card, paint, inner, undefined, metrics),
|
|
300
358
|
// The body is never clipped: a prompt is not a preview, so every row is drawn.
|
|
301
359
|
body: cardPaintedRows(rows, IDENTITY.tone, paint, inner, { expanded: true }, metrics),
|
|
302
|
-
// No content rides the closing rule: the
|
|
360
|
+
// No content rides the closing rule: the prompt's clock belongs to the heading alone.
|
|
303
361
|
bottom: cardBottom(IDENTITY.tone, paint, inner, undefined, metrics),
|
|
304
362
|
};
|
|
305
|
-
cardMemo.set(self, { markdown, target, inner, paint, rows, parts });
|
|
363
|
+
cardMemo.set(self, { markdown, target, inner, paint, clock, rows, parts });
|
|
306
364
|
return parts;
|
|
307
365
|
}
|
|
308
366
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-odd-worktree",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.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",
|
package/tools/commands.test.js
CHANGED
|
@@ -488,6 +488,64 @@ describe('/odd', () => {
|
|
|
488
488
|
await commands.get('odd').handler('nope', makeCtx(makeRepo()));
|
|
489
489
|
assert.deepEqual(notifications, [['error', 'Unknown option "nope". Use /odd.']]);
|
|
490
490
|
});
|
|
491
|
+
|
|
492
|
+
// S6 (T4): ONE optional target. An absolute `odd/tasks/*.md` and a bare ODD
|
|
493
|
+
// name that the scan knows are opened instead of refused; every other shape
|
|
494
|
+
// keeps the sentence above, verbatim. There is no overlay here (the ctx offers
|
|
495
|
+
// no `custom`), so an accepted target is observable as the absence of that
|
|
496
|
+
// sentence and the degraded menu's own one muted line.
|
|
497
|
+
test('an absolute target directly under odd/tasks is accepted', async () => {
|
|
498
|
+
const repo = makeRepo();
|
|
499
|
+
const target = path.join(repo, 'odd', 'tasks', 'feature.md');
|
|
500
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
501
|
+
fs.writeFileSync(target, '# Feature\n');
|
|
502
|
+
notifications.length = 0;
|
|
503
|
+
await commands.get('odd').handler(target, makeCtx(repo));
|
|
504
|
+
assert.deepEqual(notifications, [
|
|
505
|
+
['info', 'odd: 1 document(s) under odd/tasks/ (the viewer needs an interactive session)'],
|
|
506
|
+
]);
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
test('a bare ODD name that exists is accepted', async () => {
|
|
510
|
+
const repo = makeRepo();
|
|
511
|
+
fs.mkdirSync(path.join(repo, 'odd', 'tasks'), { recursive: true });
|
|
512
|
+
fs.writeFileSync(path.join(repo, 'odd', 'tasks', 'feature.md'), '# Feature\n');
|
|
513
|
+
notifications.length = 0;
|
|
514
|
+
await commands.get('odd').handler('feature', makeCtx(repo));
|
|
515
|
+
assert.deepEqual(notifications, [
|
|
516
|
+
['info', 'odd: 1 document(s) under odd/tasks/ (the viewer needs an interactive session)'],
|
|
517
|
+
]);
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
test('every shape that is not a target keeps the refusal verbatim', async () => {
|
|
521
|
+
const repo = makeRepo();
|
|
522
|
+
const tasks = path.join(repo, 'odd', 'tasks');
|
|
523
|
+
fs.mkdirSync(path.join(tasks, 'nested'), { recursive: true });
|
|
524
|
+
fs.writeFileSync(path.join(tasks, 'feature.md'), '# Feature\n');
|
|
525
|
+
fs.writeFileSync(path.join(tasks, 'nested', 'deep.md'), '# Deep\n');
|
|
526
|
+
fs.writeFileSync(path.join(tasks, 'notes.txt'), 'notes\n');
|
|
527
|
+
fs.writeFileSync(path.join(tasks, '.hidden.md'), '# Hidden\n');
|
|
528
|
+
const refused = [
|
|
529
|
+
// a flag is never a target
|
|
530
|
+
'--nope',
|
|
531
|
+
// a name the scan does not know
|
|
532
|
+
'missing-odd',
|
|
533
|
+
// relative, nested, another extension, a dotfile, a missing document
|
|
534
|
+
'odd/tasks/feature.md',
|
|
535
|
+
path.join(tasks, 'nested', 'deep.md'),
|
|
536
|
+
path.join(tasks, 'notes.txt'),
|
|
537
|
+
path.join(tasks, '.hidden.md'),
|
|
538
|
+
path.join(tasks, 'absent.md'),
|
|
539
|
+
// a real `.md` outside an `odd/tasks` directory
|
|
540
|
+
path.join(repo, 'README.md'),
|
|
541
|
+
path.join(repo, 'odd', 'README.md'),
|
|
542
|
+
];
|
|
543
|
+
for (const raw of refused) {
|
|
544
|
+
notifications.length = 0;
|
|
545
|
+
await commands.get('odd').handler(raw, makeCtx(repo));
|
|
546
|
+
assert.deepEqual(notifications, [['error', `Unknown option "${raw}". Use /odd.`]], raw);
|
|
547
|
+
}
|
|
548
|
+
});
|
|
491
549
|
});
|
|
492
550
|
|
|
493
551
|
// ---------------------------------------------------------------------------
|
|
@@ -1935,7 +1935,13 @@ describe('/issues opens from the rail cache (S8/T4)', () => {
|
|
|
1935
1935
|
schema: 'gentle-shell-bridge/api',
|
|
1936
1936
|
version: 1,
|
|
1937
1937
|
registerRows: () => {},
|
|
1938
|
-
|
|
1938
|
+
// T5 of odd-rail-section: the bridge carries TWO sections now, so this double
|
|
1939
|
+
// records the `GITHUB` one it is about. Every registration still receives a
|
|
1940
|
+
// disposer, so the `ODD` rail registers alongside rather than being refused.
|
|
1941
|
+
registerSection: (section) => {
|
|
1942
|
+
if (section && section.id === 'odd-worktree.issues') registered.push(section);
|
|
1943
|
+
return () => {};
|
|
1944
|
+
},
|
|
1939
1945
|
createStore: () => ({}),
|
|
1940
1946
|
requestRepaint: () => {},
|
|
1941
1947
|
};
|
|
@@ -2560,7 +2566,12 @@ describe('/issues reflects a self-assignment on the panel and the rail (S21/T17)
|
|
|
2560
2566
|
schema: 'gentle-shell-bridge/api',
|
|
2561
2567
|
version: 1,
|
|
2562
2568
|
registerRows: () => {},
|
|
2563
|
-
|
|
2569
|
+
// T5 of odd-rail-section: record the `GITHUB` section this case is about; the
|
|
2570
|
+
// `ODD` rail registers on the same double and is simply not what is read here.
|
|
2571
|
+
registerSection: (section) => {
|
|
2572
|
+
if (section && section.id === 'odd-worktree.issues') registered.push(section);
|
|
2573
|
+
return () => {};
|
|
2574
|
+
},
|
|
2564
2575
|
createStore: () => ({}),
|
|
2565
2576
|
requestRepaint: () => {},
|
|
2566
2577
|
};
|
|
@@ -287,7 +287,13 @@ function installBridge() {
|
|
|
287
287
|
schema: 'gentle-shell-bridge/api',
|
|
288
288
|
version: 1,
|
|
289
289
|
registerRows: () => {},
|
|
290
|
-
|
|
290
|
+
// T5 of odd-rail-section: the bridge carries TWO sections now, so this double
|
|
291
|
+
// records the `GITHUB` one it is about. Every registration still receives a
|
|
292
|
+
// disposer, so the `ODD` rail registers alongside rather than being refused.
|
|
293
|
+
registerSection: (section) => {
|
|
294
|
+
if (section && section.id === 'odd-worktree.issues') registered.push(section);
|
|
295
|
+
return () => {};
|
|
296
|
+
},
|
|
291
297
|
createStore: () => ({}),
|
|
292
298
|
requestRepaint: () => { repaints.push(1); },
|
|
293
299
|
};
|
|
@@ -1477,8 +1477,17 @@ function installBridge() {
|
|
|
1477
1477
|
version: 1,
|
|
1478
1478
|
registerRows: () => {},
|
|
1479
1479
|
registerSection: (section) => {
|
|
1480
|
-
|
|
1481
|
-
|
|
1480
|
+
// T5 of odd-rail-section: the bridge now carries TWO sidebar sections — this
|
|
1481
|
+
// package's `GITHUB` one and its `ODD` one — so a double that recorded every
|
|
1482
|
+
// registration would answer "two sections" to a suite that asserts exactly one
|
|
1483
|
+
// and would hand back the ODD rail wherever it reads the recorded section.
|
|
1484
|
+
// Only what this suite is about is recorded; every registration still receives
|
|
1485
|
+
// its own disposer, so the ODD rail registers and unregisters alongside.
|
|
1486
|
+
if (section && section.id === 'odd-worktree.issues') {
|
|
1487
|
+
registered.push(section);
|
|
1488
|
+
return () => { if (section && section.id === 'odd-worktree.issues') released.push(section); };
|
|
1489
|
+
}
|
|
1490
|
+
return () => {};
|
|
1482
1491
|
},
|
|
1483
1492
|
createStore: () => ({}),
|
|
1484
1493
|
requestRepaint: () => { repaints.push(1); },
|