pi-odd-worktree 3.12.4 → 3.14.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 +5 -4
- package/extensions/odd-worktree-tools.ts +164 -29
- package/lib/odd-rail-section.js +21 -0
- package/lib/odd-view.js +85 -21
- package/lib/session-auto-name.js +144 -160
- package/lib/user-identity.js +236 -0
- package/lib/user-prompt-card.js +49 -28
- package/package.json +1 -1
- package/tools/commands.test.js +4 -3
- package/tools/files-bridge.test.js +2 -2
- package/tools/files-command.test.js +2 -2
- package/tools/odd-panel-wiring.test.js +78 -35
- package/tools/odd-rail-section.test.js +66 -4
- package/tools/odd-view.test.js +119 -31
- package/tools/package-surface.test.js +7 -6
- package/tools/session-auto-name-wiring.test.js +159 -0
- package/tools/session-auto-name.test.js +342 -0
- package/tools/user-identity.test.js +503 -0
- package/tools/user-prompt-card.test.js +73 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// identity-command (S1-S4): the user's own name, in ONE persisted document, read by the prompt card
|
|
3
|
+
// and appended to the orchestrator's prompt as a single line.
|
|
4
|
+
//
|
|
5
|
+
// WHERE IT LIVES (D1). The bridge's own store, the same one `lib/modules.js` writes: plugin id
|
|
6
|
+
// `odd-worktree` → document key `identity` → `{ schema: 1, name: "<name>" }`. It is persisted (a
|
|
7
|
+
// stored name survives a restart of Pi) and read SYNCHRONOUSLY through the bridge's published
|
|
8
|
+
// object (`bridgeApi()` from `lib/file-card-resolver.js`), which is exactly what lets a paint read
|
|
9
|
+
// it. A missing, malformed, wrong-version or unreadable document is NO NAME: never a guess and
|
|
10
|
+
// never a throw. Clearing overwrites that one document and touches no other key, so the `modules`
|
|
11
|
+
// document in the same store is never disturbed.
|
|
12
|
+
//
|
|
13
|
+
// WHAT A NAME MAY BE (D2). Trimmed, internal whitespace runs collapsed to one space, C0/C1 control
|
|
14
|
+
// characters dropped, 1 to 40 CODE POINTS after that. The name reaches a system prompt, so it stays
|
|
15
|
+
// one printable line; a value that does not normalize is refused, never repaired.
|
|
16
|
+
//
|
|
17
|
+
// WHERE IT IS INJECTED (D4). `systemPromptOptions.appendSystemPrompt`, append-only, with the same
|
|
18
|
+
// guards the `## ODD worktrees` section follows (`lib/odd-worktrees-prompt.js`): a
|
|
19
|
+
// `GENTLE_PI_AGENTS_CHILD=1` session and a named-agent event get nothing, because this line is the
|
|
20
|
+
// orchestrator's. There is no environment switch: the stored name itself is the switch.
|
|
21
|
+
//
|
|
22
|
+
// The store name is the literal `lib/modules.js` owns (that module keeps the one store name for this
|
|
23
|
+
// package), repeated here with this comment rather than exported from there.
|
|
24
|
+
|
|
25
|
+
const { bridgeApi } = require('./file-card-resolver.js');
|
|
26
|
+
|
|
27
|
+
const OWN_STORE = 'odd-worktree';
|
|
28
|
+
const IDENTITY_KEY = 'identity';
|
|
29
|
+
const IDENTITY_SCHEMA = 1;
|
|
30
|
+
/** The heading the prompt card wears when no name is stored. */
|
|
31
|
+
const IDENTITY_TITLE = 'You';
|
|
32
|
+
/** The heading is the identity of the block, so an already-injected section is never added twice. */
|
|
33
|
+
const SECTION_MARKER = '## User identity';
|
|
34
|
+
const MAX_NAME_LENGTH = 40;
|
|
35
|
+
|
|
36
|
+
// C0 and C1 controls, DEL included: a name is one printable line and nothing else.
|
|
37
|
+
const CONTROL_CHARS = /[\u0000-\u001F\u007F-\u009F]/g;
|
|
38
|
+
// The controls that are ALSO whitespace (tab, LF, VT, FF, CR, NEL). They keep the separator they
|
|
39
|
+
// stood for, so a pasted `"Jona\t\nSoto"` is `Jona Soto` and not one run-together word; every other
|
|
40
|
+
// control is dropped, and the runs collapse AFTER the drop, so a dropped control never leaves the
|
|
41
|
+
// double space of a broken run behind either.
|
|
42
|
+
const CONTROL_WHITESPACE = /[\u0009-\u000D\u0085]/g;
|
|
43
|
+
const WHITESPACE_RUN = /\s+/g;
|
|
44
|
+
// A markdown heading run. Every prompt block this package appends is found by its own
|
|
45
|
+
// `## <heading>` marker, so a name that could form one would make an older block disappear from
|
|
46
|
+
// the next append; a name may not carry the run. A `#` with no `## ` after it is still a name
|
|
47
|
+
// (`C#`, `#designer`), because no block begins that way.
|
|
48
|
+
const HEADING_RUN = '## ';
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The name a command may store, or `undefined` when the value is not one. Never throws.
|
|
52
|
+
*
|
|
53
|
+
* Trimmed, internal runs collapsed to one space, controls dropped in the order stated above, no
|
|
54
|
+
* markdown heading run, and the length counted in CODE POINTS, so an emoji is one character and
|
|
55
|
+
* not two.
|
|
56
|
+
*/
|
|
57
|
+
function normalizeIdentityName(value) {
|
|
58
|
+
if (typeof value !== 'string') return undefined;
|
|
59
|
+
const cleaned = value
|
|
60
|
+
.replace(CONTROL_WHITESPACE, ' ')
|
|
61
|
+
.replace(CONTROL_CHARS, '')
|
|
62
|
+
.replace(WHITESPACE_RUN, ' ')
|
|
63
|
+
.trim();
|
|
64
|
+
if (cleaned.length === 0) return undefined;
|
|
65
|
+
if (cleaned.includes(HEADING_RUN)) return undefined;
|
|
66
|
+
return [...cleaned].length > MAX_NAME_LENGTH ? undefined : cleaned;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// The store `lib/modules.js` creates, or `null` when the api cannot make one.
|
|
70
|
+
function storeOf(api) {
|
|
71
|
+
if (api === null || typeof api !== 'object' || typeof api.createStore !== 'function') return null;
|
|
72
|
+
return api.createStore(OWN_STORE);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// The `identity` document, or `undefined` for every shape that is not an object.
|
|
76
|
+
function storedDocument(store) {
|
|
77
|
+
const stored = store.get(IDENTITY_KEY, undefined);
|
|
78
|
+
return stored !== null && typeof stored === 'object' && !Array.isArray(stored) ? stored : undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The stored name, normalized, or `undefined` when nothing usable is stored. Never throws. */
|
|
82
|
+
function readIdentityName(api) {
|
|
83
|
+
try {
|
|
84
|
+
const store = storeOf(api);
|
|
85
|
+
if (store === null) return undefined;
|
|
86
|
+
const document = storedDocument(store);
|
|
87
|
+
if (document === undefined || document.schema !== IDENTITY_SCHEMA) return undefined;
|
|
88
|
+
return normalizeIdentityName(document.name);
|
|
89
|
+
} catch {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Persist one name, keeping every other document of the store. Answers `true` when it wrote and
|
|
96
|
+
* `false` for a refused name or an api with no store, so a caller never promises a write that did
|
|
97
|
+
* not happen. Never throws.
|
|
98
|
+
*/
|
|
99
|
+
function writeIdentityName(api, value) {
|
|
100
|
+
try {
|
|
101
|
+
const name = normalizeIdentityName(value);
|
|
102
|
+
if (name === undefined) return false;
|
|
103
|
+
const store = storeOf(api);
|
|
104
|
+
if (store === null) return false;
|
|
105
|
+
store.set(IDENTITY_KEY, { schema: IDENTITY_SCHEMA, name });
|
|
106
|
+
return true;
|
|
107
|
+
} catch {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Remove the stored name, keeping every other document of the store, and answer whether anything
|
|
114
|
+
* was removed (nothing stored is nothing to clear). Never throws.
|
|
115
|
+
*
|
|
116
|
+
* The published store has `get` and `set` only — gentle-shell-bridge's `Store` has no `delete` —
|
|
117
|
+
* so the document is normally OVERWRITTEN with the cleared shape `{ schema: 1, name: null }`, which
|
|
118
|
+
* the strict read above refuses: no name survives it. A store that does publish a `delete` (a fake,
|
|
119
|
+
* or a later bridge) is asked for it instead, so nothing at all survives the clear.
|
|
120
|
+
*/
|
|
121
|
+
function clearIdentityName(api) {
|
|
122
|
+
try {
|
|
123
|
+
const store = storeOf(api);
|
|
124
|
+
if (store === null) return false;
|
|
125
|
+
// Nothing USABLE is nothing to clear: a document that already holds no name (the cleared
|
|
126
|
+
// shape a previous clear wrote, a malformed one, another schema) is not written again.
|
|
127
|
+
if (readIdentityName(api) === undefined) return false;
|
|
128
|
+
if (typeof store.delete === 'function') {
|
|
129
|
+
store.delete(IDENTITY_KEY);
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
store.set(IDENTITY_KEY, { schema: IDENTITY_SCHEMA, name: null });
|
|
133
|
+
return true;
|
|
134
|
+
} catch {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The name the running process has stored right now, or `undefined`. Never throws. */
|
|
140
|
+
function currentIdentityName() {
|
|
141
|
+
try {
|
|
142
|
+
return readIdentityName(bridgeApi());
|
|
143
|
+
} catch {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** The one sentence the block states, or `''` for a value that is not a name (never a broken one). */
|
|
149
|
+
function identityLine(name) {
|
|
150
|
+
const normalized = normalizeIdentityName(name);
|
|
151
|
+
return normalized === undefined ? '' : `The user's name is ${normalized}.`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** The block: the marker heading, a blank line, then exactly one sentence. `''` for no name. */
|
|
155
|
+
function identitySection(name) {
|
|
156
|
+
const line = identityLine(name);
|
|
157
|
+
return line === '' ? '' : `${SECTION_MARKER}\n\n${line}`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// The names a named-agent event may carry, copied from `lib/odd-worktrees-prompt.js`: `agent` itself
|
|
161
|
+
// is listed because a plain string there is a named agent too, and an object is read through `.name`.
|
|
162
|
+
function namedAgentOf(event) {
|
|
163
|
+
if (!event || typeof event !== 'object') return null;
|
|
164
|
+
const candidates = [
|
|
165
|
+
event.agentName,
|
|
166
|
+
event.agent,
|
|
167
|
+
event.name,
|
|
168
|
+
event.agent && typeof event.agent === 'object' ? event.agent.name : undefined,
|
|
169
|
+
event.subagent && typeof event.subagent === 'object' ? event.subagent.name : undefined,
|
|
170
|
+
];
|
|
171
|
+
for (const candidate of candidates) {
|
|
172
|
+
if (typeof candidate === 'string' && candidate.length > 0) return candidate;
|
|
173
|
+
}
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// The separator the existing text needs before the block starts, as the ODD section does it.
|
|
178
|
+
function separatorFor(existing) {
|
|
179
|
+
if (existing.endsWith('\n\n')) return '';
|
|
180
|
+
if (existing.endsWith('\n')) return '\n';
|
|
181
|
+
return '\n\n';
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// The heading a block is found by, as a LINE of its own: prose that merely mentions the heading
|
|
185
|
+
// is not the block, so it never suppresses the line a stored name states.
|
|
186
|
+
const SECTION_MARKER_LINE = new RegExp(`^${SECTION_MARKER.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`, 'm');
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Append the block for this session to `event.systemPromptOptions.appendSystemPrompt`. Returns
|
|
190
|
+
* nothing: the mutation is the whole contract. `deps.api` is the store seam (the published bridge
|
|
191
|
+
* when it is absent) and `deps.env` the environment the session runs with. Append-only: every
|
|
192
|
+
* existing byte stays the prefix of the new value. Never throws.
|
|
193
|
+
*/
|
|
194
|
+
function appendUserIdentitySection(event, deps = {}) {
|
|
195
|
+
try {
|
|
196
|
+
const effectiveDeps = deps || {};
|
|
197
|
+
const env = effectiveDeps.env || process.env;
|
|
198
|
+
// A child and a named-agent event get none of it.
|
|
199
|
+
if (env.GENTLE_PI_AGENTS_CHILD === '1') return;
|
|
200
|
+
if (namedAgentOf(event) !== null) return;
|
|
201
|
+
|
|
202
|
+
const name = effectiveDeps.api !== undefined
|
|
203
|
+
? readIdentityName(effectiveDeps.api)
|
|
204
|
+
: currentIdentityName();
|
|
205
|
+
const section = identitySection(name);
|
|
206
|
+
// No stored name, no block: the name itself is the switch.
|
|
207
|
+
if (section === '') return;
|
|
208
|
+
|
|
209
|
+
const options = event && event.systemPromptOptions;
|
|
210
|
+
if (!options || typeof options !== 'object') return;
|
|
211
|
+
const existing = typeof options.appendSystemPrompt === 'string' ? options.appendSystemPrompt : '';
|
|
212
|
+
if (SECTION_MARKER_LINE.test(existing)) return;
|
|
213
|
+
options.appendSystemPrompt = existing.length === 0
|
|
214
|
+
? section
|
|
215
|
+
: `${existing}${separatorFor(existing)}${section}`;
|
|
216
|
+
} catch {
|
|
217
|
+
// The prompt block must never break session start.
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
module.exports = {
|
|
222
|
+
OWN_STORE,
|
|
223
|
+
IDENTITY_KEY,
|
|
224
|
+
IDENTITY_SCHEMA,
|
|
225
|
+
IDENTITY_TITLE,
|
|
226
|
+
SECTION_MARKER,
|
|
227
|
+
MAX_NAME_LENGTH,
|
|
228
|
+
appendUserIdentitySection,
|
|
229
|
+
clearIdentityName,
|
|
230
|
+
currentIdentityName,
|
|
231
|
+
identityLine,
|
|
232
|
+
identitySection,
|
|
233
|
+
normalizeIdentityName,
|
|
234
|
+
readIdentityName,
|
|
235
|
+
writeIdentityName,
|
|
236
|
+
};
|
package/lib/user-prompt-card.js
CHANGED
|
@@ -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 `✿
|
|
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`).
|
|
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
|
-
// `✿
|
|
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
|
|
48
|
-
// THE CARD ACTUALLY DRAWS. The gate asks the bridge's reader on every paint —
|
|
49
|
-
// queries the selection store on every call, and that read is what makes the flip
|
|
50
|
-
// it is never cached. Any answer but this package's design returns BEFORE
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
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
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
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,
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
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 `✿
|
|
354
|
-
// separator and the clock in `muted`
|
|
355
|
-
|
|
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.
|
|
3
|
+
"version": "3.14.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
|
@@ -620,8 +620,9 @@ describe('S8 (T6): the naming observer’s git probes', () => {
|
|
|
620
620
|
});
|
|
621
621
|
|
|
622
622
|
// PRESERVE: the filter above must not stop the naming it filters FOR. A write
|
|
623
|
-
// of an `odd/tasks/*.md` document still names the session after that document
|
|
624
|
-
//
|
|
623
|
+
// of an `odd/tasks/*.md` document still names the session after that document —
|
|
624
|
+
// the behaviour the observer existed for — and the name is the ODD's OWN file name
|
|
625
|
+
// (not the heading inside it, and with no branch suffix).
|
|
625
626
|
test('a write of an odd/tasks document still names the session', async () => {
|
|
626
627
|
const repo = makeRepo();
|
|
627
628
|
const created = await tools.get('worktree_create').execute(
|
|
@@ -647,7 +648,7 @@ describe('S8 (T6): the naming observer’s git probes', () => {
|
|
|
647
648
|
const out = handler({ toolName: 'write', input: { path: documentPath }, toolResults: [] }, ctx);
|
|
648
649
|
if (out && typeof out.then === 'function') await out;
|
|
649
650
|
}
|
|
650
|
-
assert.equal(name, 'Named
|
|
651
|
+
assert.equal(name, 'Named', 'the write still names the session after its document');
|
|
651
652
|
});
|
|
652
653
|
|
|
653
654
|
test('a checkout created moments ago is still seen by the next naming step', async () => { const repo = makeRepo();
|
|
@@ -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
|
|
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
|
|
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');
|