@notrico/pi-fold 3.0.5 → 3.1.1
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/docs/compatibility-testing.md +17 -0
- package/docs/implementation.md +1 -1
- package/docs/renderer-reference.md +1 -1
- package/index.ts +37 -23
- package/package.json +3 -2
- package/scripts/compatibility-check.mjs +40 -0
- package/scripts/compatibility-cli-smoke.mjs +41 -0
- package/scripts/preview-scroll.mjs +9 -0
- package/scripts/preview-work-strip.mjs +15 -1
- package/scripts/test.mjs +2 -2
- package/src/action-intent.ts +5 -1
- package/src/display-card.ts +2 -1
- package/src/fold-command.ts +7 -3
- package/src/fullscreen-overlays.ts +13 -11
- package/src/inspection.ts +19 -12
- package/src/modern-native-tools.ts +13 -7
- package/src/modern-prompts-adapter.ts +9 -7
- package/src/modern-skill-prompts.ts +17 -10
- package/src/modern-subagent-messages.ts +16 -7
- package/src/modern-subagent-spacing.ts +8 -6
- package/src/modern-thinking-adapter.ts +13 -9
- package/src/modern-thinking.ts +1 -1
- package/src/modern-tool-images.ts +8 -6
- package/src/modern-tools.ts +74 -30
- package/src/modern-workflows.ts +12 -7
- package/src/permission-presentation.ts +2 -1
- package/src/runtime-compatibility.ts +53 -14
- package/src/work-strip.ts +11 -9
- package/tests/action-intent.test.mjs +2 -0
- package/tests/codemode-wheel.test.mjs +111 -0
- package/tests/codemode.test.mjs +1 -1
- package/tests/compatibility-fallbacks.test.mjs +99 -0
- package/tests/display-cache-lifecycle.test.mjs +3 -3
- package/tests/fold-command.test.mjs +4 -4
- package/tests/fullscreen-overlays.test.mjs +4 -2
- package/tests/inspection.test.mjs +1 -1
- package/tests/modern-prompts.test.mjs +2 -2
- package/tests/modern-subagent-messages.test.mjs +2 -2
- package/tests/modern-thinking.test.mjs +2 -2
- package/tests/modern-tools.test.mjs +17 -8
- package/tests/modern-workflows.test.mjs +2 -2
- package/tests/ordinary-prompts.test.mjs +0 -1
- package/tests/preview-example.test.mjs +2 -2
- package/tests/runtime-compatibility.test.mjs +48 -21
- package/tests/subagent-spacing.test.mjs +1 -1
- package/tests/work-strip-hierarchy.test.mjs +0 -1
- package/tests/work-strip.test.mjs +13 -0
package/src/work-strip.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { supportsPiVersion } from './runtime-compatibility.ts';
|
|
2
1
|
import type { DisplayMode } from './display-mode.ts';
|
|
3
|
-
import { AssistantMessageComponent, CustomMessageComponent, InteractiveMode, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent,
|
|
2
|
+
import { AssistantMessageComponent, CustomMessageComponent, InteractiveMode, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, type ExtensionAPI } from '@earendil-works/pi-coding-agent';
|
|
4
3
|
import { Container, Spacer, matchesKey } from '@earendil-works/pi-tui';
|
|
5
4
|
import { chainNativeMethod } from './native-method-chain.ts';
|
|
6
5
|
import { ToolPane } from './modern-tool-pane.ts';
|
|
@@ -66,11 +65,11 @@ export interface WorkStripControls {
|
|
|
66
65
|
|
|
67
66
|
/** Pi 1.3 display seam. The native tree, transcript, execution and Fleet remain
|
|
68
67
|
* authoritative. Only chatContainer's rendered child list is projected. */
|
|
69
|
-
export function registerWorkStrip(pi: ExtensionAPI, mode: DisplayMode, version
|
|
68
|
+
export function registerWorkStrip(pi: ExtensionAPI, mode: DisplayMode, version?: string, unavailable?: (reason: string) => void): WorkStripControls {
|
|
70
69
|
const owner = Symbol.for('compact-renderer:work-registration:v1'), shared = globalThis as any;
|
|
71
70
|
shared[owner]?.();
|
|
72
71
|
const proto = InteractiveMode.prototype as any;
|
|
73
|
-
if (!
|
|
72
|
+
if (!['addMessageToChat', 'handleEvent', 'renderSessionItems'].every(k => typeof proto?.[k] === 'function')) return { dispose() {}, setExpanded: () => false, isShortcutEnabled: () => false, setShortcutEnabled() {} };
|
|
74
73
|
let disposed = false, ctx: any, host: any, attached: any, detachChat: (() => void) | undefined;
|
|
75
74
|
let turns = new Map<any, Turn>(), sources = new WeakMap<any, any>(), hooks = new Map<any, ToolPane>();
|
|
76
75
|
let selected: WorkStripHeader | ToolPane | undefined, input: (() => void) | undefined, timer: ReturnType<typeof setTimeout> | undefined;
|
|
@@ -254,23 +253,26 @@ export function registerWorkStrip(pi: ExtensionAPI, mode: DisplayMode, version =
|
|
|
254
253
|
return output;
|
|
255
254
|
};
|
|
256
255
|
const attach = (candidate: any) => {
|
|
257
|
-
if (disposed
|
|
256
|
+
if (disposed) return false;
|
|
257
|
+
if (!(candidate?.chatContainer instanceof Container) || !Array.isArray(candidate.chatContainer.children) || typeof candidate.chatContainer.render !== 'function' || !candidate.ui) { unavailable?.('native chat container changed'); return false; }
|
|
258
258
|
if (host !== candidate) { detachChat?.(); host = candidate; attached = undefined; }
|
|
259
|
-
if (attached) return;
|
|
259
|
+
if (attached) return true;
|
|
260
260
|
const chat = candidate.chatContainer;
|
|
261
261
|
detachChat = chainNativeMethod(chat, 'render', function(native, width) {
|
|
262
|
-
if (disposed || !ctx || !mode.isEnabled()) { delete this[projectedChildren]; return native.call(this, width); }
|
|
262
|
+
if (disposed || !ctx || !mode.isEnabled() || !Array.isArray(this.children)) { delete this[projectedChildren]; return native.call(this, width); }
|
|
263
263
|
const canonical = this.children;
|
|
264
264
|
this[projectedChildren] = project(canonical);
|
|
265
265
|
this.children = this[projectedChildren];
|
|
266
266
|
try { return native.call(this, width); } finally { this.children = canonical; }
|
|
267
267
|
});
|
|
268
268
|
attached = chat;
|
|
269
|
+
return true;
|
|
269
270
|
};
|
|
270
271
|
const detachAdd = chainNativeMethod(proto, 'addMessageToChat', function(native, message, ...args) {
|
|
271
|
-
attach(this)
|
|
272
|
+
if (!attach(this)) return native.call(this, message, ...args);
|
|
273
|
+
const before = this.chatContainer.children.length;
|
|
272
274
|
const result = native.call(this, message, ...args);
|
|
273
|
-
for (const row of this.chatContainer?.children.slice(before)
|
|
275
|
+
for (const row of (Array.isArray(this.chatContainer?.children) ? this.chatContainer.children.slice(before) : [])) if (!(row instanceof Spacer)) sources.set(row, message);
|
|
274
276
|
if (!replaying && running && message.role === 'user') liveStarts.set(message, Date.now());
|
|
275
277
|
return result;
|
|
276
278
|
});
|
|
@@ -33,6 +33,8 @@ assert.equal(actionIntent('unknown\u001b[31m\u202e', { label: 'Reveal SECRET', d
|
|
|
33
33
|
assert.equal(actionIntent('bash', { command: 'gh pr merge 19' }), 'Run shell commands', 'do not call a write operation a check');
|
|
34
34
|
assert.equal(actionIntent('bash', { command: 'git reset --hard' }), 'Run shell commands');
|
|
35
35
|
assert.equal(actionIntent('bash', { command: 'find . -delete' }), 'Run shell commands');
|
|
36
|
+
assert.equal(groupIntent([{ name: 'custom', args: {} }, bash('git status'), bash('npm test'), bash('rg term')], 'brief'),
|
|
37
|
+
'Check Git changes and run checks', 'keep a short recorded intent before the tool counts');
|
|
36
38
|
assert.equal(groupIntent([]), 'Run tool actions');
|
|
37
39
|
assert.equal(groupIntent(Array.from({ length: 65 }, () => ({ name: 'read', args: {} }))), 'Read files; and other actions');
|
|
38
40
|
let reads = 0;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { createWorkStripPreview } from '../scripts/preview-work-strip.mjs';
|
|
3
|
+
|
|
4
|
+
// Replay only invented text. This fixture does not execute tools or contact a model.
|
|
5
|
+
const preview = await createWorkStripPreview({ inspection: true, standaloneCode: true });
|
|
6
|
+
const terminal = { columns: 110, rows: 45, kittyProtocolActive: false, start() {}, stop() {}, async drainInput() {} };
|
|
7
|
+
for (const name of ['write', 'moveBy', 'hideCursor', 'showCursor', 'clearLine', 'clearFromCursor', 'clearScreen', 'setTitle', 'setProgress', 'setProgramStatus']) terminal[name] = () => {};
|
|
8
|
+
const plain = value => value.replace(/\x1b\][^\x07]*(?:\x07|\x1b\\)|\x1b\[[0-?]*[ -/]*[@-~]/g, '');
|
|
9
|
+
let ui;
|
|
10
|
+
try {
|
|
11
|
+
ui = new preview.core.InteractiveMode(preview.runtime, { tuiMode: 'fullscreen', terminal });
|
|
12
|
+
await ui.init();
|
|
13
|
+
const runner = preview.runtime.session.extensionRunner;
|
|
14
|
+
await runner.getCommand('fold').handler('expand', runner.createContext());
|
|
15
|
+
const renderer = ui.renderer, scroll = renderer.getPrimaryScrollView();
|
|
16
|
+
renderer.renderNow();
|
|
17
|
+
const row = ui.chatContainer.children.find(row => row.toolCallId === 'standalone-wheel-code');
|
|
18
|
+
assert.ok(row, 'native replay creates the standalone codemode');
|
|
19
|
+
const pane = row.callRendererComponent.owner.code;
|
|
20
|
+
const screen = () => renderer.getScreenLines().map(plain);
|
|
21
|
+
const send = data => { renderer.handleTerminalInput(data); renderer.renderNow(); };
|
|
22
|
+
// Distinct gestures must not become native double-click word selections.
|
|
23
|
+
const clickAt = async (x, y) => { await new Promise(resolve => setTimeout(resolve, 550)); send(`\x1b[<0;${x + 1};${y + 1}M`); send(`\x1b[<0;${x + 1};${y + 1}m`); };
|
|
24
|
+
const wheelAt = (x, y, down) => send(`\x1b[<${down ? 65 : 64};${x + 1};${y + 1}M`);
|
|
25
|
+
const positionPane = atEnd => {
|
|
26
|
+
scroll.scrollToEnd(); renderer.renderNow();
|
|
27
|
+
if (!atEnd) { scroll.scrollTo(Math.max(0, scroll.scrollTop - 3), { disableFollow: true }); renderer.renderNow(); }
|
|
28
|
+
const y = screen().findIndex(line => /▾ codemode/.test(line));
|
|
29
|
+
assert.ok(y >= 0, 'standalone header is visible at its native rendered width');
|
|
30
|
+
return y;
|
|
31
|
+
};
|
|
32
|
+
for (const width of [110, 72, 160]) {
|
|
33
|
+
terminal.columns = width; renderer.requestRender(true); renderer.renderNow();
|
|
34
|
+
pane.collapse(); row.invalidate(); renderer.renderNow();
|
|
35
|
+
scroll.scrollToEnd(); renderer.renderNow();
|
|
36
|
+
const headerY = screen().findIndex(line => /▸ codemode/.test(line));
|
|
37
|
+
assert.ok(headerY >= 0);
|
|
38
|
+
const headerX = screen()[headerY].indexOf('▸ codemode');
|
|
39
|
+
await clickAt(headerX + 2, headerY);
|
|
40
|
+
assert.equal(pane.open, true, 'terminal SGR click expands codemode without /inspect');
|
|
41
|
+
assert.equal(pane.focused, false);
|
|
42
|
+
for (const inspected of [false, true]) {
|
|
43
|
+
for (const atEnd of [true, false]) {
|
|
44
|
+
if (inspected) {
|
|
45
|
+
const choices = [];
|
|
46
|
+
preview.eventBus.emit('compact-renderer:inspect:v1', { add: choice => choices.push(choice) });
|
|
47
|
+
const choice = choices.find(choice => /codemode.*3 nested calls/.test(choice.label));
|
|
48
|
+
assert.ok(choice); choice.focus(); renderer.renderNow();
|
|
49
|
+
await new Promise(resolve => setTimeout(resolve, 50)); renderer.renderNow();
|
|
50
|
+
}
|
|
51
|
+
pane.offset = 0; renderer.renderNow();
|
|
52
|
+
const y = positionPane(atEnd), top = scroll.scrollTop;
|
|
53
|
+
const before = pane.offset;
|
|
54
|
+
wheelAt(headerX + 2, y + 2, true);
|
|
55
|
+
assert.ok(pane.offset > before, `wheel advances body: width=${width}, inspected=${inspected}, atEnd=${atEnd}`);
|
|
56
|
+
assert.equal(scroll.scrollTop, top, 'body wheel does not move transcript');
|
|
57
|
+
const moreY = screen().findIndex((line, index) => index > y && index < y + 21 && /more ↓/.test(line));
|
|
58
|
+
assert.ok(moreY > y);
|
|
59
|
+
const beforeClick = pane.offset;
|
|
60
|
+
await clickAt(screen()[moreY].indexOf('more ↓') + 2, moreY);
|
|
61
|
+
assert.ok(pane.offset > beforeClick, `terminal SGR more click advances settled codemode: width=${width}, inspected=${inspected}, atEnd=${atEnd}, before=${beforeClick}, after=${pane.offset}, footer=${moreY}, header=${y}, row=${screen()[moreY]}`);
|
|
62
|
+
assert.equal(scroll.scrollTop, top, 'more click does not move transcript');
|
|
63
|
+
let iterations = 0;
|
|
64
|
+
while (screen().some(line => /more ↓/.test(line)) && iterations++ < 400) {
|
|
65
|
+
const footerY = screen().findIndex((line, index) => index > y && index < y + 21 && /more ↓/.test(line));
|
|
66
|
+
if (footerY < 0) break;
|
|
67
|
+
wheelAt(headerX + 2, footerY, true);
|
|
68
|
+
assert.equal(scroll.scrollTop, top, 'footer wheel does not move transcript');
|
|
69
|
+
}
|
|
70
|
+
const footerY = screen().findIndex((line, index) => index > y && index < y + 21 && /more ↑/.test(line));
|
|
71
|
+
assert.ok(footerY >= 0, 'repeated native wheel reaches the final footer');
|
|
72
|
+
assert.ok(screen().some(line => line.includes('FINAL_OUTPUT_SENTINEL')), 'full escaped JSON output is reachable');
|
|
73
|
+
const endOffset = pane.offset;
|
|
74
|
+
wheelAt(headerX + 2, footerY, false);
|
|
75
|
+
assert.ok(pane.offset < endOffset, 'upward wheel reveals earlier output');
|
|
76
|
+
assert.equal(renderer.getFocusedComponent(), ui.defaultEditor);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const promptJump = renderer.getMountedRoots()[0]?.[Symbol.for('notrico/sticky-prompt-strip/owner')];
|
|
81
|
+
if (process.env.PI_PROMPT_JUMP_PATH) {
|
|
82
|
+
assert.ok(promptJump?.mounted, 'Prompt Jump candidate is mounted');
|
|
83
|
+
const beforeSnapshot = pane.offset;
|
|
84
|
+
const anchors = promptJump.prompts();
|
|
85
|
+
assert.equal(pane.offset, beforeSnapshot, 'collecting prompt-list anchors preserves the code viewport');
|
|
86
|
+
const index = anchors.findIndex(anchor => anchor.text.startsWith('独立代码输出滚动测试'));
|
|
87
|
+
assert.ok(index >= 0, 'prompt list includes the standalone fixture');
|
|
88
|
+
assert.equal(promptJump.jumpTo(index), true); renderer.renderNow();
|
|
89
|
+
assert.ok(screen().some(line => line.includes('独立代码输出滚动测试')), 'prompt navigation reveals its native prompt');
|
|
90
|
+
}
|
|
91
|
+
const fold = async action => { await runner.getCommand('fold').handler(action, runner.createContext()); renderer.renderNow(); };
|
|
92
|
+
const projected = () => ui.chatContainer[Symbol.for('compact-renderer:projected-children:v1')];
|
|
93
|
+
await fold('off');
|
|
94
|
+
assert.equal(row.callRendererComponent.owner, undefined, 'Fold off restores the native tool renderer');
|
|
95
|
+
await fold('on');
|
|
96
|
+
assert.equal(row.callRendererComponent.owner.code, pane, 'Fold on restores the same codemode owner');
|
|
97
|
+
await fold('collapse');
|
|
98
|
+
assert.ok(!projected().some(view => view.children?.[0] === row), 'collapse hides the completed work row');
|
|
99
|
+
await fold('expand');
|
|
100
|
+
assert.ok(projected().some(view => view.children?.[0] === row), 'expand restores the work row');
|
|
101
|
+
pane.open = true; pane.offset = 0; renderer.renderNow();
|
|
102
|
+
const reopenedY = positionPane(true), reopenedOffset = pane.offset;
|
|
103
|
+
wheelAt(8, reopenedY + 2, true);
|
|
104
|
+
assert.ok(pane.offset > reopenedOffset, 'wheel still advances after Fold mode and disclosure changes');
|
|
105
|
+
const reopenedMoreY = screen().findIndex((line, index) => index > reopenedY && index < reopenedY + 21 && /more ↓/.test(line));
|
|
106
|
+
assert.ok(reopenedMoreY > reopenedY);
|
|
107
|
+
const beforeReopenedClick = pane.offset;
|
|
108
|
+
await clickAt(screen()[reopenedMoreY].indexOf('more ↓') + 2, reopenedMoreY);
|
|
109
|
+
assert.ok(pane.offset > beforeReopenedClick, 'more click still advances after Fold mode and disclosure changes');
|
|
110
|
+
console.log('Standalone codemode: native SGR click/wheel, escaped JSON/Chinese, widths, inspection and scroll boundaries passed');
|
|
111
|
+
} finally { ui?.stop(); await preview.cleanup(); }
|
package/tests/codemode.test.mjs
CHANGED
|
@@ -26,7 +26,7 @@ const pi = {
|
|
|
26
26
|
events: { on(name, fn) { bus.set(name, fn); return () => bus.delete(name); }, emit(name, data) { bus.get(name)?.(data); } },
|
|
27
27
|
};
|
|
28
28
|
const originalToolRender=ToolExecutionComponent.prototype.render;
|
|
29
|
-
|
|
29
|
+
{ const cleanup = installModernToolImages('1.5.0'); assert.equal(typeof cleanup, 'function'); cleanup(); }
|
|
30
30
|
assert.equal(ToolExecutionComponent.prototype.render,originalToolRender);
|
|
31
31
|
const mode = createDisplayMode(), dispose = registerModernTools(pi, mode);
|
|
32
32
|
const ctx = { hasUI: true, sessionManager: { getBranch: () => [] }, ui: { onTerminalInput(fn) { input = fn; return () => { input = undefined; }; } } };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { core, tui, loadSource, loadAgent, stripAnsi } from './test-runtime.mjs';
|
|
3
|
+
|
|
4
|
+
const { inspectRuntime } = await loadSource('runtime-compatibility.ts');
|
|
5
|
+
const { registerModernTools } = await loadSource('modern-tools.ts');
|
|
6
|
+
const { SubagentProjection } = await loadSource('modern-subagent-groups.ts');
|
|
7
|
+
const { ToolExecutionComponent } = await loadAgent('modes/interactive/components/tool-execution.js');
|
|
8
|
+
const plain = component => stripAnsi(component.render(100).join('\n'));
|
|
9
|
+
|
|
10
|
+
function fixture(entries = []) {
|
|
11
|
+
const hooks = new Map(), events = new Map();
|
|
12
|
+
let resolver;
|
|
13
|
+
const on = (map, name, callback) => {
|
|
14
|
+
const list = map.get(name) || [];
|
|
15
|
+
map.set(name, [...list, callback]);
|
|
16
|
+
return () => map.set(name, (map.get(name) || []).filter(item => item !== callback));
|
|
17
|
+
};
|
|
18
|
+
const pi = {
|
|
19
|
+
on: (name, callback) => on(hooks, name, callback),
|
|
20
|
+
registerCommand() {}, registerMarkdownTransformer() {}, getCommands: () => [], appendEntry() {},
|
|
21
|
+
registerToolRenderer(callback) { resolver = callback; },
|
|
22
|
+
events: {
|
|
23
|
+
on: (name, callback) => on(events, name, callback),
|
|
24
|
+
emit(name, value) { for (const callback of events.get(name) || []) callback(value); },
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const context = { hasUI: true, sessionManager: { getBranch: () => entries }, ui: { onTerminalInput: () => () => {} } };
|
|
28
|
+
return {
|
|
29
|
+
pi, hooks,
|
|
30
|
+
mode: { isEnabled: () => true, onChange: () => () => {} },
|
|
31
|
+
start() { for (const callback of hooks.get('session_start') || []) callback({}, context); },
|
|
32
|
+
create(name, id, args, stock) {
|
|
33
|
+
const component = new ToolExecutionComponent(name, id, args, { showImages: false, outputPad: 0 }, resolver(name, () => stock), { requestRender() {} }, '/synthetic');
|
|
34
|
+
component.setArgsComplete();
|
|
35
|
+
return component;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// This sequence would hide the tool behind a custom-message group leader.
|
|
41
|
+
// A missing resolver must leave that tool available in its own card.
|
|
42
|
+
{
|
|
43
|
+
const receipt = { role: 'toolResult', toolCallId: 'status-1', toolName: 'subagent', content: [{ type: 'text', text: 'Exact visible status receipt' }], details: { agent: 'worker' }, timestamp: 3 };
|
|
44
|
+
const entries = [
|
|
45
|
+
{ type: 'custom_message', id: 'notice-1', customType: 'subagent-notify', content: 'Exact native completion notice', details: { runs: [{ agent: 'worker', status: 'completed' }] }, display: true, timestamp: 1 },
|
|
46
|
+
{ type: 'message', id: 'call-1', message: { role: 'assistant', content: [{ type: 'toolCall', id: receipt.toolCallId, name: 'subagent', arguments: { agent: 'worker', action: 'status' } }], timestamp: 2 } },
|
|
47
|
+
{ type: 'message', id: 'result-1', message: receipt },
|
|
48
|
+
];
|
|
49
|
+
const projection = new SubagentProjection();
|
|
50
|
+
projection.rebuild(entries);
|
|
51
|
+
assert.equal(projection.viewTool(receipt.toolCallId).hidden, true, 'fixture exercises a hidden tool follower');
|
|
52
|
+
const f = fixture(entries);
|
|
53
|
+
const report = inspectRuntime(f.pi, { ...core, ExtensionRunner: undefined }, tui);
|
|
54
|
+
assert.equal(report.available('subagents'), false);
|
|
55
|
+
assert.equal(report.available('tools'), true);
|
|
56
|
+
const dispose = registerModernTools(f.pi, f.mode, { images: report.available('images'), subagents: report.available('subagents') });
|
|
57
|
+
try {
|
|
58
|
+
f.start();
|
|
59
|
+
const component = f.create('subagent', receipt.toolCallId, { agent: 'worker', action: 'status' }, {
|
|
60
|
+
renderCall: () => new tui.Text('Native status call', 0, 0),
|
|
61
|
+
renderResult: () => new tui.Text('Native status result', 0, 0),
|
|
62
|
+
});
|
|
63
|
+
component.updateResult(receipt);
|
|
64
|
+
component.setExpanded(true);
|
|
65
|
+
assert.match(plain(component), /Exact visible status receipt/);
|
|
66
|
+
assert.equal(f.hooks.get('message_update')?.length, undefined, 'disabled grouping acquires no shared projection listener');
|
|
67
|
+
const choices = [];
|
|
68
|
+
f.pi.events.emit('compact-renderer:inspect:v1', { add: choice => choices.push(choice) });
|
|
69
|
+
assert.equal(choices.length, 1, 'standalone subagent tool remains inspectable');
|
|
70
|
+
} finally { dispose(); }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// The result can introduce an image after the compact call component exists.
|
|
74
|
+
// Both native renderer shell contracts must retain their complete output.
|
|
75
|
+
for (const self of [false, true]) {
|
|
76
|
+
const f = fixture();
|
|
77
|
+
const nativeRender = ToolExecutionComponent.prototype.render;
|
|
78
|
+
const dispose = registerModernTools(f.pi, f.mode, { images: false, subagents: false });
|
|
79
|
+
try {
|
|
80
|
+
assert.equal(ToolExecutionComponent.prototype.render, nativeRender, 'disabled images install no prototype hook');
|
|
81
|
+
f.start();
|
|
82
|
+
const component = f.create('read', `image-fallback-${self}`, { path: '/synthetic/image.png' }, {
|
|
83
|
+
...(self ? { renderShell: 'self' } : {}),
|
|
84
|
+
renderCall: () => new tui.Text('STOCK CALL', 0, 0),
|
|
85
|
+
renderResult: () => new tui.Text('STOCK IMAGE RESULT', 0, 0),
|
|
86
|
+
});
|
|
87
|
+
component.render(100);
|
|
88
|
+
component.updateResult({ content: [{ type: 'image', data: 'synthetic', mimeType: 'image/png' }], details: {} });
|
|
89
|
+
const output = plain(component);
|
|
90
|
+
assert.match(output, /STOCK CALL/);
|
|
91
|
+
assert.match(output, /STOCK IMAGE RESULT/);
|
|
92
|
+
assert.doesNotMatch(output, /▸ read/);
|
|
93
|
+
const choices = [];
|
|
94
|
+
f.pi.events.emit('compact-renderer:inspect:v1', { add: choice => choices.push(choice) });
|
|
95
|
+
assert.equal(choices.length, 0, 'native image fallback is absent from Pi Fold inspection');
|
|
96
|
+
} finally { dispose(); }
|
|
97
|
+
assert.equal(ToolExecutionComponent.prototype.render, nativeRender);
|
|
98
|
+
}
|
|
99
|
+
console.log('compatibility fallbacks: missing subagent resolver preserves tool output; disabled images preserve native shells and cleanup');
|
|
@@ -30,13 +30,13 @@ const pi = {
|
|
|
30
30
|
for (const fn of [...bus.get(event) || []]) fn(data);
|
|
31
31
|
} },
|
|
32
32
|
registerToolRenderer() {}, registerMarkdownTransformer() {}, registerCommand() {},
|
|
33
|
-
registerShortcut() {}, getCommands: () => [], getAllTools: () => [],
|
|
33
|
+
registerShortcut() {}, appendEntry() {}, getCommands: () => [], getAllTools: () => [],
|
|
34
34
|
};
|
|
35
35
|
const ctx = { mode: 'none', hasUI: false, ui: {}, sessionManager: { getBranch: () => [], buildContextEntries: () => [] } };
|
|
36
36
|
const emit = event => { for (const fn of [...hooks.get(event) || []]) fn({}, ctx); };
|
|
37
37
|
try {
|
|
38
38
|
expectCold();
|
|
39
|
-
register(pi);
|
|
39
|
+
await register(pi);
|
|
40
40
|
expectCold(); // Registration also removes text retained by a previous load.
|
|
41
41
|
for (const event of ['session_start', 'session_tree', 'session_compact', 'session_before_switch', 'session_shutdown']) {
|
|
42
42
|
emit(event); expectCold();
|
|
@@ -46,7 +46,7 @@ try {
|
|
|
46
46
|
probe();
|
|
47
47
|
assert.equal(formats, before, 'disposed root callbacks do not clear a later cache');
|
|
48
48
|
// A registration failure before any feature starts must still release shared text.
|
|
49
|
-
assert.
|
|
49
|
+
await assert.rejects(() => register({ ...pi, on() { probe(); throw new Error('registration fixture'); } }), /registration fixture/);
|
|
50
50
|
expectCold();
|
|
51
51
|
console.log('Shared display cache lifecycle: registration, session transitions, shutdown, stale callbacks and failed startup passed');
|
|
52
52
|
} finally {
|
|
@@ -131,16 +131,16 @@ function fixture(hasUI = true) {
|
|
|
131
131
|
on: (event, fn) => subscribe(hooks, event, fn),
|
|
132
132
|
events: { on: (event, fn) => subscribe(bus, event, fn), emit(event, data) { for (const fn of [...bus.get(event) || []]) fn(data); } },
|
|
133
133
|
registerCommand(name, command) { assert.ok(!commands.has(name), `no duplicate /${name}`); commands.set(name, command); },
|
|
134
|
-
registerToolRenderer() {}, registerMarkdownTransformer() {}, registerShortcut() {}, getCommands: () => [], getAllTools: () => [],
|
|
134
|
+
registerToolRenderer() {}, registerMarkdownTransformer() {}, registerShortcut() {}, appendEntry() {}, getCommands: () => [], getAllTools: () => [],
|
|
135
135
|
};
|
|
136
136
|
const ctx = { mode: 'none', hasUI: false, ui: { notify: message => notices.push(message) }, sessionManager: { getBranch: () => [], buildContextEntries: () => [] } };
|
|
137
137
|
const emit = event => { for (const fn of [...hooks.get(event) || []]) fn({}, ctx); };
|
|
138
138
|
try {
|
|
139
|
-
register(pi); emit('session_start');
|
|
139
|
+
await register(pi); emit('session_start');
|
|
140
140
|
assert.ok(commands.has('fold'));
|
|
141
141
|
assert.ok(!commands.has('work')); assert.ok(!commands.has('compact-rendering'), 'old aliases are absent from actual root registration');
|
|
142
|
-
await commands.get('fold').handler('off', ctx); assert.
|
|
143
|
-
await commands.get('fold').handler('on', ctx); assert.
|
|
142
|
+
await commands.get('fold').handler('off', ctx); assert.match(notices.at(-1), /^Pi Fold off\nCompatibility: full/);
|
|
143
|
+
await commands.get('fold').handler('on', ctx); assert.match(notices.at(-1), /^Pi Fold on\nCompatibility: full/);
|
|
144
144
|
emit('session_shutdown'); const count = notices.length;
|
|
145
145
|
await commands.get('fold').handler('toggle', ctx);
|
|
146
146
|
assert.equal(notices.length, count, 'root disposal disables stale command callbacks');
|
|
@@ -115,8 +115,10 @@ for (const overrides of [
|
|
|
115
115
|
}
|
|
116
116
|
const future = fixture().screen;
|
|
117
117
|
const futureOriginal = future.compositeOverlays;
|
|
118
|
-
installFullscreenOverlayGuard(future, 'future')
|
|
119
|
-
assert.
|
|
118
|
+
const futureCleanup = installFullscreenOverlayGuard(future, 'future');
|
|
119
|
+
assert.notEqual(future.compositeOverlays, futureOriginal, 'compatible future runtimes use the same seam');
|
|
120
|
+
futureCleanup();
|
|
121
|
+
assert.equal(future.compositeOverlays, futureOriginal);
|
|
120
122
|
|
|
121
123
|
const switched = fixture();
|
|
122
124
|
const regular = new tui.TuiMainScreen(switched.screen.terminal, false);
|
|
@@ -20,7 +20,7 @@ assert.equal(scroll.scrollTop, before.render(80).length, 'selected opaque native
|
|
|
20
20
|
assert.equal(scroll.isFollowingEnd, false);
|
|
21
21
|
const frame = renderLayoutFrame(root, 80, 24, () => {});
|
|
22
22
|
assert.ok(frame.lines.map(stripAnsi).join('\n').includes('Selected block'));
|
|
23
|
-
assert.equal(revealInspection(host, component => component === inner, '9.0.0'),
|
|
23
|
+
assert.equal(revealInspection(host, component => component === inner, '9.0.0'), true);
|
|
24
24
|
assert.equal(revealInspection({}, () => true), false);
|
|
25
25
|
const previous = scroll.scrollTop;
|
|
26
26
|
assert.equal(revealInspection(host, () => false), false); assert.equal(scroll.scrollTop, previous);
|
|
@@ -74,8 +74,8 @@ try{
|
|
|
74
74
|
dispose=registerModernPrompts(pi,mode);emit('session_start',{type:'session_start',reason:'startup'});assert.match(plain(card),/prompt · \/fixture/);
|
|
75
75
|
const staleDispose=dispose;dispose=registerModernPrompts(pi,mode);assert.equal(terminal.size,0,'replacement registration disposes the prior input listener');emit('session_start',{type:'session_start',reason:'startup'});assert.equal(terminal.size,1);staleDispose();assert.equal(terminal.size,1);
|
|
76
76
|
assert.match(plain(card),/prompt · \/fixture/);dispose();
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
{ const cleanup = installModernPromptAdapter({render(){},mouse(){}},'1.1.0'); assert.equal(typeof cleanup, 'function'); cleanup(); }
|
|
78
|
+
{ const cleanup = installModernPromptAdapter({render(){},mouse(){}},'9.0.0'); assert.equal(typeof cleanup, 'function'); cleanup(); }
|
|
79
79
|
const templates=modernPromptTemplates(commands);assert.equal(matchingModernPrompt(original,templates),'fixture');assert.equal(matchingModernPrompt('Unrelated prompt',templates),undefined);
|
|
80
80
|
assert.equal(modernPromptTemplates([...commands,{source:'extension',name:'fixture'}]).length,0);
|
|
81
81
|
assert.equal(modernPromptTemplates([{...commands[0],sourceInfo:{path:join(dir,'missing')}}]).length,0);
|
|
@@ -129,8 +129,8 @@ try {
|
|
|
129
129
|
emit('session_shutdown'); assert.equal(terminal.size, 0);
|
|
130
130
|
dispose(); dispose(); assert.equal(core.ExtensionRunner.prototype.getMessageRenderer, originalMethods.message); assert.equal(core.ExtensionRunner.prototype.getEntryRenderer, originalMethods.entry);
|
|
131
131
|
assert.match(plain(largeCard.render(60)), /native message/);
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
{ const cleanup = installSubagentMessageAdapter(() => {}, '9.0.0'); assert.equal(typeof cleanup, 'function'); cleanup(); }
|
|
133
|
+
{ const cleanup = installSubagentMessageAdapter(() => {}, '1.1.0'); assert.equal(typeof cleanup, 'function'); cleanup(); }
|
|
134
134
|
dispose = registerModernSubagentMessages(pi, mode); emit('session_start');
|
|
135
135
|
const staleDispose = dispose; dispose = registerModernSubagentMessages(pi, mode); assert.equal(terminal.size, 0); emit('session_start'); staleDispose(); assert.equal(terminal.size, 1);
|
|
136
136
|
console.log('modern subagent messages: native resolution, exact fallback, replies, lifecycle, inspection and bounded content passed');
|
|
@@ -191,8 +191,8 @@ try {
|
|
|
191
191
|
dispose=registerModernThinking(pi,mode);emit('session_start',{type:'session_start',reason:'startup'});assert.equal(terminal.size,1);
|
|
192
192
|
const staleDispose=dispose;dispose=registerModernThinking(pi,mode);assert.equal(terminal.size,0,'replacement registration disposes the prior input listener');emit('session_start',{type:'session_start',reason:'startup'});assert.equal(terminal.size,1);staleDispose();assert.equal(terminal.size,1);dispose();
|
|
193
193
|
assert.equal(JSON.stringify(rounds.flatMap((m,i)=>[entry(m),entry(result(i+1))])),originalBranch,'transcript objects remain exact');
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
{ const cleanup = installModernThinkingAdapter({clear(){},associate(){},render(){},mouse(){}},'1.1.0'); assert.equal(typeof cleanup, 'function'); cleanup(); }
|
|
195
|
+
{ const cleanup = installModernThinkingAdapter({clear(){},associate(){},render(){},mouse(){}},'9.0.0'); assert.equal(typeof cleanup, 'function'); cleanup(); }
|
|
196
196
|
const pane=new RecordedTextPane();const huge='Large exact recorded line 行🙂\n'.repeat(100000);pane.setSources([huge]);pane.open=true;
|
|
197
197
|
const first=pane.view(60,9);assert.equal(first.length,9);assert.ok(pane.visitedCharacters<1000,'first paint visits only viewport and one lookahead');
|
|
198
198
|
const visits=pane.visitedCharacters;for(let i=0;i<50;i++)pane.view(60,9);assert.equal(pane.visitedCharacters,visits,'stable paints do not reprocess source');
|
|
@@ -91,7 +91,8 @@ assert.ok(shell.render(100)[1].includes(themeModule.theme.getFgAnsi('mdLink')),
|
|
|
91
91
|
assert.ok(shell.render(100)[1].includes(themeModule.theme.getFgAnsi('muted')), 'running intent and metadata use muted text');
|
|
92
92
|
assert.doesNotMatch(paint(read), /Alt\+G/, 'unfocused collapsed cards omit repeated key hints');
|
|
93
93
|
shell.updateResult(result('hello', { exitCode: 0 }));
|
|
94
|
-
assert.match(paint(read), /2 actions/);
|
|
94
|
+
assert.match(paint(read), /2 actions · Read files and run shell commands · read ×1 · bash ×1/);
|
|
95
|
+
assert.match(paint(read, 34), /2 actions · Read files/, 'intent precedes the tool counts even at narrow widths');
|
|
95
96
|
assert.ok(read.render(100)[1].includes(themeModule.theme.getFgAnsi('mdLink')), 'completed action group heading uses native blue');
|
|
96
97
|
assert.ok(read.render(100)[1].includes(themeModule.theme.getFgAnsi('muted')), 'group intent uses muted text');
|
|
97
98
|
assert.equal(paint(shell), '');
|
|
@@ -174,17 +175,25 @@ try {
|
|
|
174
175
|
const fail = make('bash', 'c', { command: 'false' });
|
|
175
176
|
fail.updateResult({ ...result('failure', { exitCode: 1 }), isError: true });
|
|
176
177
|
const after = make('read', 'd', { path: '/tmp/after.txt' }); after.updateResult(result('after'));
|
|
177
|
-
assert.match(paint(fail), /bash · false · ✗
|
|
178
|
+
assert.match(paint(fail), /bash · false · ✗ Exit code 1/); assert.match(paint(after), /read · \/tmp\/after\.txt/);
|
|
178
179
|
assert.equal(paint(fail).split('\n').filter(line => line.includes('bash · false')).length, 1, 'failure uses one exceptional header');
|
|
179
|
-
assert.match(paint(fail),
|
|
180
|
+
assert.match(paint(fail), /✗ Exit code 1/, 'header includes a bounded recorded failure excerpt');
|
|
180
181
|
assert.match(fail.render(120).map(stripAnsi)[1], /^ ▸ bash · /, 'failure status does not shift the tool name');
|
|
181
182
|
capture('Single failed action collapsed with status after command', fail);
|
|
182
|
-
const failedHeader = fail.render(120).find(line => stripAnsi(line).includes('
|
|
183
|
+
const failedHeader = fail.render(120).find(line => stripAnsi(line).includes('✗ Exit code 1'));
|
|
183
184
|
assert.ok(failedHeader.includes(themeModule.theme.getFgAnsi('error')), 'failed header uses native error color');
|
|
184
185
|
assertNeutral([failedHeader]);
|
|
186
|
+
fail.updateResult({ ...result('synthetic details', { failureReason: 'precondition_failed', status: 'unknown', code: 'commit_receipt_missing' }), isError: true });
|
|
187
|
+
assert.match(paint(fail), /✗ Precondition failed · commit unconfirmed/);
|
|
188
|
+
capture('Structured failure with an unconfirmed commit', fail);
|
|
189
|
+
fail.updateResult({ ...result('ETIMEDOUT', { status: 'unknown', code: 'commit_receipt_missing' }), isError: true });
|
|
190
|
+
assert.match(paint(fail), /✗ Timed out · commit unconfirmed/);
|
|
191
|
+
fail.updateResult({ ...result('synthetic details', { failureReason: 'postcondition_failed', status: 'unknown' }), isError: true });
|
|
192
|
+
assert.match(paint(fail), /✗ Postcondition failed · outcome unknown/);
|
|
193
|
+
capture('Structured failure with an unknown outcome', fail);
|
|
185
194
|
const partialFailureOutput = 'partial failure output\nexact second failure line';
|
|
186
195
|
fail.updateResult({ ...result(partialFailureOutput, { error: 'Recorded denial: ' + 'x'.repeat(5000) }), isError: true }, true);
|
|
187
|
-
assert.match(paint(fail),
|
|
196
|
+
assert.match(paint(fail), /✗ Failed(?! · Tool failed)/, 'partial errors remain visible as exceptional cards');
|
|
188
197
|
assert.equal(paint(fail).split('\n').filter(line => line.includes('bash · false')).length, 1);
|
|
189
198
|
assert.ok(paint(fail, 500).split('\n').map(row => row.trim()).join('').length < 400, 'collapsed failure reason has a bounded length before the full-width card gutter');
|
|
190
199
|
const failureMouse = (y) => fail.handleMouse({ type: 'click', button: 'left', x: 2, y, screenX: 2, screenY: y, width: 120, height: fail.render(120).length, shift: false, alt: false, ctrl: false });
|
|
@@ -454,7 +463,7 @@ clickSingle(densityWriteA, 2);
|
|
|
454
463
|
assert.match(paint(densityWriteA), /Content alpha/);
|
|
455
464
|
assert.doesNotMatch(paint(densityWriteA), /Successfully wrote|Arguments|Output|content:/);
|
|
456
465
|
const densityChoices = []; pi.events.emit('compact-renderer:inspect:v1', { add: choice => densityChoices.push(choice) });
|
|
457
|
-
densityChoices.find(choice => choice.label.includes('
|
|
466
|
+
densityChoices.find(choice => choice.label.includes('write ×2 · read ×2')).focus();
|
|
458
467
|
input('\t');
|
|
459
468
|
let detailsRows = densityWriteA.render(120);
|
|
460
469
|
assert.match(stripAnsi(detailsRows.at(-1)), /Enter expand Details · Tab action/);
|
|
@@ -517,7 +526,7 @@ const laterHeadingRow = earlierLarge.render(120).findIndex(row => stripAnsi(row)
|
|
|
517
526
|
clickSingle(earlierLarge, laterHeadingRow);
|
|
518
527
|
inlinePane.expanded.add('density-earlier-large'); inlinePane.reset(); // Simulate another independently open sibling before the clicked action.
|
|
519
528
|
const laterChoices = []; pi.events.emit('compact-renderer:inspect:v1', { add: choice => laterChoices.push(choice) });
|
|
520
|
-
laterChoices.find(choice => choice.label === '2 actions · Read files' && choice.id === laterChoices.at(-1).id).focus();
|
|
529
|
+
laterChoices.find(choice => choice.label === '2 actions · Read files · read ×2' && choice.id === laterChoices.at(-1).id).focus();
|
|
521
530
|
input('\t');
|
|
522
531
|
assert.match(paint(earlierLarge), /later small output[\s\S]*▸ Details/);
|
|
523
532
|
assert.doesNotMatch(paint(earlierLarge), /primary first line/, 'Tab anchors at the mouse-selected sibling');
|
|
@@ -562,7 +571,7 @@ const exactError = `Error: ENAMETOOLONG: name too long, lstat '${'\"/fixture/ver
|
|
|
562
571
|
const scriptFailure = make('bash', 'script-failure', { command: nodeScripts[0] });
|
|
563
572
|
const failureRecording = { ...result(exactError, { error: exactError, exitCode: 1 }), isError: true };
|
|
564
573
|
scriptFailure.updateResult(failureRecording);
|
|
565
|
-
assert.equal(paint(scriptFailure).trim(), '▸ bash · Run Node.js script · ✗
|
|
574
|
+
assert.equal(paint(scriptFailure).trim(), '▸ bash · Run Node.js script · ✗ Path too long');
|
|
566
575
|
assert.ok(paint(scriptFailure, 500).trim().length < 100);
|
|
567
576
|
scriptFailure.setExpanded(true);
|
|
568
577
|
assert.doesNotMatch(paint(scriptFailure), /name too long, lstat/);
|
|
@@ -137,7 +137,7 @@ try {
|
|
|
137
137
|
dispose(); disposeThinking(); assert.deepEqual({ render: AssistantMessageComponent.prototype.render, mouse: AssistantMessageComponent.prototype.handleMouse, update: AssistantMessageComponent.prototype.updateContent }, native);
|
|
138
138
|
assert.equal(JSON.stringify(branch), exactMessage, 'recorded assistant message and transcript stay exact');
|
|
139
139
|
assert.deepEqual(readReplyWorkflowScript(sessionManager, 'workflow-call'), scriptBefore, 'installed workflow executor reads the same original script after display interactions');
|
|
140
|
-
const unsupported = registerModernWorkflows(pi, mode, '9.0.0'); assert.
|
|
140
|
+
const unsupported = registerModernWorkflows(pi, mode, '9.0.0'); assert.notEqual(AssistantMessageComponent.prototype.render, native.render); unsupported(); assert.equal(AssistantMessageComponent.prototype.render, native.render);
|
|
141
141
|
// The opposite disposal order also restores the complete native method chain.
|
|
142
142
|
const reverseThinking = registerModernThinking(pi, mode), reverseWorkflow = registerModernWorkflows(pi, mode);
|
|
143
143
|
emit('session_start'); card.render(100); reverseThinking(); reverseWorkflow();
|
|
@@ -148,7 +148,7 @@ try {
|
|
|
148
148
|
ctx.hasUI = true; ctx.ui.setWidget = () => {}; ctx.ui.setStatus = () => {};
|
|
149
149
|
const nativeContainerRender = tui.Container.prototype.render;
|
|
150
150
|
for (let run = 0; run < 2; run++) {
|
|
151
|
-
piFold(pi); emit('session_start');
|
|
151
|
+
await piFold(pi); emit('session_start');
|
|
152
152
|
for (const event of ['session_tree', 'session_compact', 'session_start']) { emit(event); assert.match(plain(card.render(100)), /Subagent workflow/); }
|
|
153
153
|
emit('session_shutdown');
|
|
154
154
|
assert.equal(terminal.size, 0);
|
|
@@ -5,7 +5,6 @@ const { registerModernPrompts } = await loadSource('./modern-prompts.ts');
|
|
|
5
5
|
const { createDisplayMode } = await loadSource('./display-mode.ts');
|
|
6
6
|
const { SkillInvocationMessageComponent } = await loadAgent('modes/interactive/components/skill-invocation-message.js');
|
|
7
7
|
const { UserMessageComponent, VERSION } = core;
|
|
8
|
-
assert.ok(['1.3.0', '1.4.0'].includes(VERSION), 'prompt seam uses a verified native runtime');
|
|
9
8
|
const nativeRender = UserMessageComponent.prototype.render;
|
|
10
9
|
const listeners = new Map(), bus = new Map(), terminal = new Set(), transformers = [];
|
|
11
10
|
const subscribe = (map, event, fn) => {
|
|
@@ -98,10 +98,10 @@ try {
|
|
|
98
98
|
scripts[1].handleMouse({ type: 'click', button: 'left', x: 3, y: exactErrorRow, width: 100, height: scripts[1].render(100).length });
|
|
99
99
|
assert.match(paint(scripts[1]), /ENAMETOOLONG: name too long, lstat/);
|
|
100
100
|
const fourGroup = ui.chatContainer.children.find(item => item instanceof core.ToolExecutionComponent && item.toolName === 'read' && item.args?.path === '/fixture/source.js');
|
|
101
|
-
assert.match(paint(fourGroup), /4 actions · Read files and edit files
|
|
101
|
+
assert.match(paint(fourGroup), /4 actions · Read files and edit files · read ×2 · edit ×1 · bash ×1/);
|
|
102
102
|
assert.doesNotMatch(paint(fourGroup), /successful|Completed|✓/);
|
|
103
103
|
const densityGroup = ui.chatContainer.children.find(item => item instanceof core.ToolExecutionComponent && item.toolName === 'write' && item.args?.path === '/fixture/sample-a.txt');
|
|
104
|
-
assert.match(paint(densityGroup), /4 actions · Edit files and read files/);
|
|
104
|
+
assert.match(paint(densityGroup), /4 actions · Edit files and read files · write ×2 · read ×2/);
|
|
105
105
|
densityGroup.setExpanded(true);
|
|
106
106
|
assert.equal(densityGroup.render(100).length, 6, 'four tight sibling headings plus header and native spacer');
|
|
107
107
|
const densityPane = densityGroup.resultRendererComponent.owner.group.pane;
|
|
@@ -1,23 +1,50 @@
|
|
|
1
1
|
import assert from 'node:assert/strict';
|
|
2
|
-
import { core, loadSource } from './test-runtime.mjs';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
assert.equal(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
assert.equal(notices.length, 6, 'headless startup does not require a UI');
|
|
2
|
+
import { core, tui, loadSource } from './test-runtime.mjs';
|
|
3
|
+
import { mkdtempSync, mkdirSync, copyFileSync, writeFileSync, rmSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { spawnSync } from 'node:child_process';
|
|
7
|
+
const { inspectRuntime } = await loadSource('runtime-compatibility.ts');
|
|
8
|
+
const fn = () => {};
|
|
9
|
+
const pi = { on: fn, registerCommand: fn, events: { on: fn, emit: fn }, registerToolRenderer: fn, registerMarkdownTransformer: fn, getCommands: fn, appendEntry: fn };
|
|
10
|
+
for (const version of [core.VERSION, '1.5.0', '9.0.0']) {
|
|
11
|
+
const report = inspectRuntime(pi, { ...core, VERSION: version }, tui);
|
|
12
|
+
assert.equal(report.state, 'full', `${version} with compatible interfaces works`);
|
|
13
|
+
}
|
|
14
|
+
for (const [symbol, feature] of [['UserMessageComponent','prompts'], ['ExtensionRunner','subagents'], ['InteractiveMode','work'], ['ToolExecutionComponent','images']]) {
|
|
15
|
+
const report = inspectRuntime(pi, { ...core, [symbol]: undefined }, tui);
|
|
16
|
+
assert.equal(report.state, 'partial');
|
|
17
|
+
assert.equal(report.available(feature), false);
|
|
18
|
+
assert.equal(report.available('tools'), true, 'independent tool cards remain available');
|
|
19
|
+
assert.match(report.describe(), new RegExp(symbol));
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const report = inspectRuntime(pi);
|
|
22
|
+
report.disable('inspection', 'ui.select missing');
|
|
23
|
+
assert.equal(report.available('reveal'), false);
|
|
24
|
+
assert.equal(report.available('overlays'), false);
|
|
25
|
+
assert.equal(report.available('work'), true);
|
|
26
|
+
assert.equal(inspectRuntime(pi, {}, {}).state, 'unavailable');
|
|
27
|
+
|
|
28
|
+
// Use the native ESM loader with optional exports genuinely absent. Jiti can
|
|
29
|
+
// otherwise mask missing named exports. No feature module should load here.
|
|
30
|
+
const fixture = mkdtempSync(path.join(tmpdir(), 'fold-missing-exports-'));
|
|
31
|
+
try {
|
|
32
|
+
mkdirSync(path.join(fixture, 'src'));
|
|
33
|
+
for (const file of ['index.ts', 'src/runtime-compatibility.ts', 'src/display-mode.ts', 'src/fold-command.ts']) copyFileSync(new URL('../' + file, import.meta.url), path.join(fixture, file));
|
|
34
|
+
writeFileSync(path.join(fixture, 'package.json'), '{"type":"module"}');
|
|
35
|
+
for (const name of ['pi-coding-agent', 'pi-tui']) {
|
|
36
|
+
const folder = path.join(fixture, 'node_modules/@earendil-works', name); mkdirSync(folder, { recursive: true });
|
|
37
|
+
writeFileSync(path.join(folder, 'package.json'), '{"type":"module","exports":"./index.js"}');
|
|
38
|
+
writeFileSync(path.join(folder, 'index.js'), 'export const VERSION = "9.0.0";');
|
|
39
|
+
}
|
|
40
|
+
writeFileSync(path.join(fixture, 'check.mjs'), `import register from './index.ts';
|
|
41
|
+
const commands = new Map(), hooks = new Map(), notices = [];
|
|
42
|
+
await register({on(name,fn){hooks.set(name,fn)},events:{on(){},emit(){}},registerCommand(name,command){commands.set(name,command)}});
|
|
43
|
+
await commands.get('fold').handler('on',{hasUI:false,ui:{notify(message){notices.push(message)}}});
|
|
44
|
+
if (!notices[0]?.includes('Compatibility: unavailable') || notices[0].includes('Pi Fold on')) throw new Error(notices.join('\\n'));
|
|
45
|
+
hooks.get('session_shutdown')();
|
|
46
|
+
console.log('missing exports: native fallback');`);
|
|
47
|
+
const result = spawnSync(process.execPath, ['--experimental-strip-types', path.join(fixture, 'check.mjs')], { encoding: 'utf8' });
|
|
48
|
+
assert.equal(result.status, 0, result.stderr + result.stdout);
|
|
49
|
+
} finally { rmSync(fixture, { recursive: true, force: true }); }
|
|
50
|
+
console.log(`Pi ${core.VERSION}: capability probes, partial support and missing-export native startup passed`);
|
|
@@ -26,7 +26,7 @@ try {
|
|
|
26
26
|
dispose(); dispose();
|
|
27
27
|
assert.equal(tui.Container.prototype.render, original);
|
|
28
28
|
assert.deepEqual(message.render(80), ['']);
|
|
29
|
-
|
|
29
|
+
{ const cleanup = installSubagentSpacingAdapter('future'); assert.equal(typeof cleanup, 'function'); cleanup(); }
|
|
30
30
|
const first = installSubagentSpacingAdapter(), second = installSubagentSpacingAdapter();
|
|
31
31
|
first(); assert.deepEqual(message.render(80), [], 'stale cleanup cannot remove a newer owner');
|
|
32
32
|
second(); assert.equal(tui.Container.prototype.render, original);
|
|
@@ -5,7 +5,6 @@ const { registerWorkStrip } = await loadSource('./work-strip.ts');
|
|
|
5
5
|
const { registerFoldCommand } = await loadSource('./fold-command.ts');
|
|
6
6
|
const { createDisplayMode } = await loadSource('./display-mode.ts');
|
|
7
7
|
const { projectedChildren, workEvidenceType, recordedWorkEvidence } = await loadSource('./work-strip-view.ts');
|
|
8
|
-
assert.ok(['1.3.0', '1.4.0'].includes(core.VERSION), 'hierarchy integration runs against a verified native runtime');
|
|
9
8
|
|
|
10
9
|
function fixture() {
|
|
11
10
|
const hooks = new Map(), bus = new Map(), commands = new Map(), shortcuts = new Map(), inputs = new Set(), notices = [];
|