@notrico/pi-fold 3.0.4 → 3.0.5

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Release notes
2
2
 
3
+ ## 3.0.5 — Pi 1.4 compatibility
4
+
5
+ - Enable the verified renderer adapters on Pi 1.4.0. Retain Pi 1.3.0 support and checks for unfamiliar component layouts.
6
+ - Report unsupported Pi versions at startup and in `/fold` instead of showing “on” while native rendering remains active.
7
+ - Run the native preview against the selected core package, including installations separate from the extension dependency snapshot.
8
+
3
9
  ## 3.0.4 — Fullscreen overlays
4
10
 
5
11
  - Temporarily hide inline Kitty images while an overlay is visible in Pi 1.3.0 fullscreen mode. This keeps panel borders and text readable. Restore the images when the last overlay closes or hides, including with folding off.
package/README.md CHANGED
@@ -12,10 +12,10 @@ Replies without tool or subagent activity skip the work strip.
12
12
 
13
13
  ## Install
14
14
 
15
- Tested with **Pi 1.3.0** and **Node.js 22.19.0 or later**. Other Pi versions are not verified; version-sensitive features fall back to native rendering.
15
+ Tested with **Pi 1.3.0 and 1.4.0**, and **Node.js 22.19.0 or later**. Other Pi versions show a compatibility warning and use native rendering.
16
16
 
17
17
  ```sh
18
- pi install npm:@notrico/pi-fold@3.0.4
18
+ pi install npm:@notrico/pi-fold@3.0.5
19
19
  ```
20
20
 
21
21
  Restart Pi, or run `/reload` when the session and its background work are idle.
@@ -66,7 +66,7 @@ Run `npm test`, `npm run preview:work`, or `npm run benchmark`. See the [rendere
66
66
  ## Uninstall
67
67
 
68
68
  ```sh
69
- pi remove npm:@notrico/pi-fold@3.0.4
69
+ pi remove npm:@notrico/pi-fold@3.0.5
70
70
  ```
71
71
 
72
72
  [MIT license](LICENSE) · [Report an issue](https://github.com/rrrrrrrrrricoxi/pi-fold/issues)
package/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { registerUnsupportedRuntime } from './src/runtime-compatibility.ts';
1
2
  import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
2
3
  import { clearDisplayLineCache } from './src/display-card.ts';
3
4
  import { createDisplayMode } from './src/display-mode.ts';
@@ -13,6 +14,7 @@ import { registerWorkStrip } from './src/work-strip.ts';
13
14
  import { registerFoldCommand } from './src/fold-command.ts';
14
15
 
15
16
  export default function piFold(pi: ExtensionAPI): void {
17
+ if (registerUnsupportedRuntime(pi)) return;
16
18
  clearDisplayLineCache();
17
19
  const mode = createDisplayMode();
18
20
  const disposers: Array<() => void> = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notrico/pi-fold",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "type": "module",
5
5
  "description": "Pi Fold: readable agent transcripts with collapsible work, inspectable details, and clear final replies",
6
6
  "license": "MIT",
@@ -10,7 +10,8 @@ const source = fileURLToPath(new URL('../', import.meta.url));
10
10
  export async function createPreview() {
11
11
  const hostHome = os.homedir();
12
12
  const runtimePath = path.resolve(process.env.PI_RUNTIME || path.join(hostHome, '.local/state/pi-config/current/runtime'));
13
- const tuiPath = createRequire(path.join(runtimePath, 'node_modules/@earendil-works/pi-coding-agent/package.json')).resolve('@earendil-works/pi-tui');
13
+ const agentRoot = path.resolve(process.env.PI_INSTALL_ROOT || path.join(runtimePath, 'node_modules/@earendil-works/pi-coding-agent'));
14
+ const tuiPath = createRequire(path.join(agentRoot, 'package.json')).resolve('@earendil-works/pi-tui');
14
15
  const promptJump = process.env.PI_PROMPT_JUMP_PATH ? path.resolve(process.env.PI_PROMPT_JUMP_PATH) : undefined;
15
16
  const questionCandidates = process.env.PI_QUESTIONS_PATH ? [path.resolve(process.env.PI_QUESTIONS_PATH)] : [
16
17
  path.join(hostHome, '.local/state/pi-config/current/packages/pi-questions/index.ts'),
@@ -42,7 +43,7 @@ export async function createPreview() {
42
43
  setEnv('HOME', temporary); setEnv('PI_CODING_AGENT_DIR', agentDir); setEnv('PI_OFFLINE', '1');
43
44
  for (const key of Object.keys(process.env)) if (/(?:API_KEY|ACCESS_TOKEN|AUTH_TOKEN)$/.test(key)) setEnv(key, undefined);
44
45
  globalThis.fetch = async () => { throw new Error('Network disabled in renderer preview'); };
45
- const core = await import(pathToFileURL(path.join(runtimePath, 'node_modules/@earendil-works/pi-coding-agent/dist/index.js')).href);
46
+ const core = await import(pathToFileURL(path.join(agentRoot, 'dist/index.js')).href);
46
47
  const template = 'This is an invented long prompt template used only to inspect display behavior. Review the recorded examples, expand the tool groups, and compare native display. No commands should run and no services should be contacted.';
47
48
  await fs.mkdir(path.join(agentDir, 'prompts'));
48
49
  await fs.writeFile(path.join(agentDir, 'prompts/fixture.md'), `---\ndescription: Inspect synthetic tool, question, and skill display examples.\n---\n${template}`);
@@ -220,7 +221,7 @@ export async function createPreview() {
220
221
  runtime = await core.createAgentSessionRuntime(factory, { cwd, agentDir, sessionManager: manager });
221
222
  const diagnostics = runtime.services.resourceLoader.getExtensions().errors;
222
223
  if (runtime.diagnostics.some(item => item.type === 'error') || diagnostics.length) throw new Error(JSON.stringify([...runtime.diagnostics, ...diagnostics]));
223
- return { core, runtime, manager, temporary, agentDir, cwd, runtimePath, tuiPath, questionsPath, eventBus, cleanup };
224
+ return { core, runtime, manager, temporary, agentDir, cwd, runtimePath, agentRoot, tuiPath, questionsPath, eventBus, cleanup };
224
225
  } catch (error) { await cleanup(); throw error; }
225
226
  }
226
227
 
package/scripts/test.mjs CHANGED
@@ -13,7 +13,7 @@ required.push('display-cache-lifecycle.test.mjs');
13
13
  required.push('fold-command.test.mjs', 'fold-shortcut.test.mjs');
14
14
  required.push('mixed-thinking.test.mjs', 'work-strip.test.mjs', 'work-strip-subagents.test.mjs', 'work-strip-preview.test.mjs', 'work-strip-spacing.test.mjs');
15
15
  required.push('mixed-action-groups.test.mjs', 'action-group-preview.test.mjs');
16
- required.push('fullscreen-overlays.test.mjs');
16
+ required.push('fullscreen-overlays.test.mjs', 'runtime-compatibility.test.mjs');
17
17
  for (const name of required) {
18
18
  if (!fs.existsSync(path.join(directory, name))) throw new Error(`Missing required regression suite: ${name}`);
19
19
  const result = spawnSync(process.execPath, [path.join(directory, name)], { cwd: directory, env: process.env, stdio: 'inherit' });
@@ -1,3 +1,4 @@
1
+ import { supportsPiVersion } from './runtime-compatibility.ts';
1
2
  import { VERSION } from '@earendil-works/pi-coding-agent';
2
3
  import { TuiAltScreen } from '@earendil-works/pi-tui';
3
4
  import { chainNativeMethod } from './native-method-chain.ts';
@@ -10,7 +11,7 @@ const promptZones = /\x1b\]133;[ABC](?:\x07|\x1b\\)/g;
10
11
  * and restoration work. Keep source rows, layout metadata, and settings intact.
11
12
  */
12
13
  export function installFullscreenOverlayGuard(tui: any, version = VERSION): () => void {
13
- if (version !== '1.3.0' || !['regular', 'fullscreen'].includes(tui?.mode) || typeof tui.compositeOverlays !== 'function'
14
+ if (!supportsPiVersion(version) || !['regular', 'fullscreen'].includes(tui?.mode) || typeof tui.compositeOverlays !== 'function'
14
15
  || typeof tui.hasOverlay !== 'function') return () => {};
15
16
  if (tui.mode === 'fullscreen' && typeof tui.prepareKittyScreen !== 'function') return () => {};
16
17
  // Extension UI handles are proxies with unstable method identities. Their
package/src/inspection.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { supportsPiVersion } from './runtime-compatibility.ts';
1
2
  import type { DisplayMode } from './display-mode.ts';
2
3
  import { VERSION, type ExtensionAPI } from '@earendil-works/pi-coding-agent';
3
4
  import { Container, ScrollView, isViewportTUI, type Component } from '@earendil-works/pi-tui';
@@ -10,7 +11,7 @@ const children = (component: any): Component[] => [...(Array.isArray(component?.
10
11
 
11
12
  /** Pi 1.3 viewport seam. Read the mounted tree; never replace its layout/root. */
12
13
  export function revealInspection(tui: any, target: Target, version = VERSION): boolean {
13
- if (version !== '1.3.0' || !tui || !isViewportTUI(tui) || typeof tui.getMountedRoots !== 'function') return false;
14
+ if (!supportsPiVersion(version) || !tui || !isViewportTUI(tui) || typeof tui.getMountedRoots !== 'function') return false;
14
15
  const scrolls: ScrollView[] = [], seen = new Set<Component>();
15
16
  const find = (component: Component) => {
16
17
  if (seen.has(component)) return; seen.add(component);
@@ -1,9 +1,10 @@
1
+ import { supportsPiVersion } from './runtime-compatibility.ts';
1
2
  import { VERSION, keyHint, type ToolRenderers } from "@earendil-works/pi-coding-agent";
2
3
  import { Box, Container, Text, stripTerminalSequences, type Component } from "@earendil-works/pi-tui";
3
4
 
4
5
  type Context = Parameters<NonNullable<ToolRenderers["renderCall"]>>[2];
5
6
  /** Native private-state knowledge is confined here. Unsupported Pi versions keep stock rendering. */
6
- export const nativeToolsSupported = VERSION === "1.3.0";
7
+ export const nativeToolsSupported = supportsPiVersion(VERSION);
7
8
  export const nativeToolContextSupported = (context: Context) => !!context && typeof context.toolCallId === "string" && typeof context.invalidate === "function" && !!context.state && typeof context.state === "object" && typeof context.cwd === "string" && typeof context.expanded === "boolean" && typeof context.executionStarted === "boolean" && typeof context.isPartial === "boolean";
8
9
  export function nativeTextFallback(result: any, theme?: any, options = { expanded: true }): Text {
9
10
  const text = (Array.isArray(result?.content) ? result.content : []).filter((block: any) => block?.type === "text").map((block: any) => String(block.text ?? "")).join("\n");
@@ -1,3 +1,4 @@
1
+ import { supportsPiVersion } from './runtime-compatibility.ts';
1
2
  import { UserMessageComponent, VERSION } from "@earendil-works/pi-coding-agent";
2
3
  import { Markdown } from "@earendil-works/pi-tui";
3
4
 
@@ -13,7 +14,7 @@ export function installModernPromptAdapter(hooks: {
13
14
  fallback?(component: any): void;
14
15
  }, version = VERSION): (() => void) | undefined {
15
16
  const proto = UserMessageComponent.prototype as any;
16
- if (version !== "1.3.0" || typeof proto.render !== "function" || typeof proto.rebuild !== "function") return;
17
+ if (!supportsPiVersion(version) || typeof proto.render !== "function" || typeof proto.rebuild !== "function") return;
17
18
  const owner = Symbol.for("compact-renderer:prompt-adapter:v1");
18
19
  proto[owner]?.();
19
20
  const render = proto.render, mouse = proto.handleMouse;
@@ -1,3 +1,4 @@
1
+ import { supportsPiVersion } from './runtime-compatibility.ts';
1
2
  import type { DisplayMode } from './display-mode.ts';
2
3
  import { InteractiveMode, SkillInvocationMessageComponent, UserMessageComponent, VERSION, type ExtensionAPI } from '@earendil-works/pi-coding-agent';
3
4
  import { Container, Markdown, MouseRegion, Spacer, Text, matchesKey, stripTerminalSequences, visibleWidth } from '@earendil-works/pi-tui';
@@ -14,7 +15,7 @@ export function registerModernSkillPrompts(pi: ExtensionAPI, mode: DisplayMode,
14
15
  const owner = Symbol.for('compact-renderer:skill-prompts:v1'), shared = globalThis as any;
15
16
  shared[owner]?.();
16
17
  const proto = InteractiveMode.prototype as any;
17
- if (version !== '1.3.0' || typeof proto.addMessageToChat !== 'function' || typeof SkillInvocationMessageComponent.prototype.setExpanded !== 'function') return () => {};
18
+ if (!supportsPiVersion(version) || typeof proto.addMessageToChat !== 'function' || typeof SkillInvocationMessageComponent.prototype.setExpanded !== 'function') return () => {};
18
19
  const cards = new Map<any, Card>(), users = new WeakMap<any, Card>();
19
20
  let active = false, disposed = false, ctx: any, host: any, input: (() => void) | undefined, selected: Card | undefined, rendering: Card | undefined;
20
21
  const redraw = () => host?.ui?.requestRender?.();
@@ -1,3 +1,4 @@
1
+ import { supportsPiVersion } from './runtime-compatibility.ts';
1
2
  import type { DisplayMode } from './display-mode.ts';
2
3
  import { ExtensionRunner, VERSION, type ExtensionAPI } from '@earendil-works/pi-coding-agent';
3
4
  import { matchesKey, truncateToWidth } from '@earendil-works/pi-tui';
@@ -56,7 +57,7 @@ export function subagentMessageSummary(source: any, entry = false): Summary | un
56
57
  * Registering another message renderer cannot delegate through Pi's first-match registry. */
57
58
  export function installSubagentMessageAdapter(wrap: (native: any, entry: boolean) => any, version = VERSION): (() => void) | undefined {
58
59
  const proto = ExtensionRunner.prototype as any;
59
- if (version !== '1.3.0' || !['getMessageRenderer', 'getEntryRenderer'].every(k => typeof proto[k] === 'function')) return;
60
+ if (!supportsPiVersion(version) || !['getMessageRenderer', 'getEntryRenderer'].every(k => typeof proto[k] === 'function')) return;
60
61
  const owner = Symbol.for('compact-renderer:subagent-message-adapter:v1');
61
62
  proto[owner]?.();
62
63
  const message = proto.getMessageRenderer, entry = proto.getEntryRenderer;
@@ -1,3 +1,4 @@
1
+ import { supportsPiVersion } from './runtime-compatibility.ts';
1
2
  import { CustomMessageComponent, VERSION } from '@earendil-works/pi-coding-agent';
2
3
  import { Container } from '@earendil-works/pi-tui';
3
4
 
@@ -9,7 +10,7 @@ const hidden = Symbol.for('compact-renderer:subagent-hidden:v1');
9
10
  * seam avoids importing private modules or replacing the transcript container. */
10
11
  export function installSubagentSpacingAdapter(version = VERSION): (() => void) | undefined {
11
12
  const proto = Container.prototype as any;
12
- if (version !== '1.3.0' || typeof proto.render !== 'function') return;
13
+ if (!supportsPiVersion(version) || typeof proto.render !== 'function') return;
13
14
  const owner = Symbol.for('compact-renderer:subagent-spacing:v1');
14
15
  proto[owner]?.();
15
16
  const original = proto.render;
@@ -1,3 +1,4 @@
1
+ import { supportsPiVersion } from './runtime-compatibility.ts';
1
2
  import { AssistantMessageComponent, VERSION } from "@earendil-works/pi-coding-agent";
2
3
  import { Markdown, MouseRegion, Spacer, Text } from "@earendil-works/pi-tui";
3
4
  import { chainNativeMethod } from "./native-method-chain.ts";
@@ -49,7 +50,7 @@ export function installModernThinkingAdapter(hooks: {
49
50
  clear(): void;
50
51
  }, version = VERSION): (() => void) | undefined {
51
52
  const proto = AssistantMessageComponent.prototype as any;
52
- if (version !== "1.3.0" || !["updateContent", "render", "setHideThinkingBlock"].every(key => typeof proto[key] === "function")) return;
53
+ if (!supportsPiVersion(version) || !["updateContent", "render", "setHideThinkingBlock"].every(key => typeof proto[key] === "function")) return;
53
54
  const owner = Symbol.for("compact-renderer:thinking-adapter:v1");
54
55
  proto[owner]?.();
55
56
  let disposed = false;
@@ -1,3 +1,4 @@
1
+ import { supportsPiVersion } from './runtime-compatibility.ts';
1
2
  import { ToolExecutionComponent, VERSION } from "@earendil-works/pi-coding-agent";
2
3
  import { getCapabilities, Image, imageFallback, truncateToWidth } from "@earendil-works/pi-tui";
3
4
  import { chainNativeMethod } from "./native-method-chain.ts";
@@ -10,7 +11,7 @@ export type ToolImageView = { open: boolean; count: number; bodyIndent: number;
10
11
  * objects during render only; never change image sources, settings or ownership. */
11
12
  export function installModernToolImages(version = VERSION): (() => void) | undefined {
12
13
  const proto = ToolExecutionComponent.prototype as any;
13
- if (version !== "1.3.0" || typeof proto.render !== "function" || typeof proto.updateDisplay !== "function") return;
14
+ if (!supportsPiVersion(version) || typeof proto.render !== "function" || typeof proto.updateDisplay !== "function") return;
14
15
  const owner = Symbol.for("compact-renderer:tool-image-adapter:v1");
15
16
  proto[owner]?.();
16
17
  let disposed = false;
@@ -1,3 +1,4 @@
1
+ import { supportsPiVersion } from './runtime-compatibility.ts';
1
2
  import type { DisplayMode } from './display-mode.ts';
2
3
  import { AssistantMessageComponent, VERSION, type ExtensionAPI } from '@earendil-works/pi-coding-agent';
3
4
  import { Container, Markdown, MouseRegion, Spacer, Text, matchesKey, truncateToWidth } from '@earendil-works/pi-tui';
@@ -107,7 +108,7 @@ export function registerModernWorkflows(pi: ExtensionAPI, mode: DisplayMode, ver
107
108
  const owner = Symbol.for('compact-renderer:workflow-registration:v1'), shared = globalThis as any;
108
109
  shared[owner]?.();
109
110
  const proto = AssistantMessageComponent.prototype as any;
110
- if (version !== '1.3.0' || typeof proto.render !== 'function' || typeof proto.updateContent !== 'function') return () => {};
111
+ if (!supportsPiVersion(version) || typeof proto.render !== 'function' || typeof proto.updateContent !== 'function') return () => {};
111
112
  const cards = new Map<any, Card>();
112
113
  let active = false, disposed = false, selected: WorkflowPane | undefined, uiTheme: any, nextCard = 0;
113
114
  let input: (() => void) | undefined, redraw: (() => void) | undefined;
@@ -0,0 +1,17 @@
1
+ import { VERSION, type ExtensionAPI } from '@earendil-works/pi-coding-agent';
2
+
3
+ // Exact versions verified by the native rendering suites. Shape checks still
4
+ // protect each private adapter; a new core version needs its own verification.
5
+ export const supportedPiVersions = ['1.3.0', '1.4.0'] as const;
6
+ export const supportsPiVersion = (version: string) => supportedPiVersions.some(supported => supported === version);
7
+
8
+ export function registerUnsupportedRuntime(pi: ExtensionAPI, version = VERSION): boolean {
9
+ if (supportsPiVersion(version)) return false;
10
+ const message = `Pi Fold is unavailable on Pi ${version}. Supported versions: ${supportedPiVersions.join(', ')}. Native display remains active. Update Pi Fold for support.`;
11
+ pi.registerCommand('fold', {
12
+ description: 'Show Pi Fold compatibility status',
13
+ async handler(_args, ctx) { ctx.ui.notify(message, 'warning'); },
14
+ });
15
+ pi.on('session_start', (_event, ctx) => { if (ctx.hasUI) ctx.ui.notify(message, 'warning'); });
16
+ return true;
17
+ }
package/src/work-strip.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { supportsPiVersion } from './runtime-compatibility.ts';
1
2
  import type { DisplayMode } from './display-mode.ts';
2
3
  import { AssistantMessageComponent, CustomMessageComponent, InteractiveMode, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, VERSION, type ExtensionAPI } from '@earendil-works/pi-coding-agent';
3
4
  import { Container, Spacer, matchesKey } from '@earendil-works/pi-tui';
@@ -69,7 +70,7 @@ export function registerWorkStrip(pi: ExtensionAPI, mode: DisplayMode, version =
69
70
  const owner = Symbol.for('compact-renderer:work-registration:v1'), shared = globalThis as any;
70
71
  shared[owner]?.();
71
72
  const proto = InteractiveMode.prototype as any;
72
- if (version !== '1.3.0' || !['addMessageToChat', 'handleEvent', 'renderSessionItems'].every(k => typeof proto[k] === 'function')) return { dispose() {}, setExpanded: () => false, isShortcutEnabled: () => false, setShortcutEnabled() {} };
73
+ if (!supportsPiVersion(version) || !['addMessageToChat', 'handleEvent', 'renderSessionItems'].every(k => typeof proto[k] === 'function')) return { dispose() {}, setExpanded: () => false, isShortcutEnabled: () => false, setShortcutEnabled() {} };
73
74
  let disposed = false, ctx: any, host: any, attached: any, detachChat: (() => void) | undefined;
74
75
  let turns = new Map<any, Turn>(), sources = new WeakMap<any, any>(), hooks = new Map<any, ToolPane>();
75
76
  let selected: WorkStripHeader | ToolPane | undefined, input: (() => void) | undefined, timer: ReturnType<typeof setTimeout> | undefined;
@@ -5,7 +5,7 @@ import { createWorkStripPreview } from '../scripts/preview-work-strip.mjs';
5
5
 
6
6
  const preview = await createWorkStripPreview({ actionGroups: true });
7
7
  const { core, runtime, manager } = preview;
8
- const { theme, initTheme } = await import(pathToFileURL(path.join(preview.runtimePath, 'node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js')));
8
+ const { theme, initTheme } = await import(pathToFileURL(path.join(preview.agentRoot, 'dist/modes/interactive/theme/theme.js')));
9
9
  initTheme('dark', false);
10
10
  const plain = value => value.replace(/\x1b\][^\x07]*(?:\x07|\x1b\\)|\x1b\[[0-?]*[ -/]*[@-~]/g, '');
11
11
  const errors = [];
@@ -5,7 +5,7 @@ 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.equal(VERSION, '1.3.0', 'prompt seam is verified against the actual supported runtime');
8
+ assert.ok(['1.3.0', '1.4.0'].includes(VERSION), 'prompt seam uses a verified native runtime');
9
9
  const nativeRender = UserMessageComponent.prototype.render;
10
10
  const listeners = new Map(), bus = new Map(), terminal = new Set(), transformers = [];
11
11
  const subscribe = (map, event, fn) => {
@@ -222,6 +222,7 @@ fullscreen.addChild(editorContainer);
222
222
  const nativeUI = Object.assign(Object.create(InteractiveMode.prototype), {
223
223
  ui: fullscreen, editor, editorContainer, keybindings: nativeKeys,
224
224
  extensionTerminalInputSubscriptions: new Set(),
225
+ extensionDialogs: [], programStatus: { setBlocked() {} },
225
226
  });
226
227
  const pipeline = fixture();
227
228
  const disposePipeline = registerPermissionPresentation(pipeline.pi, pipeline.mode);
@@ -6,8 +6,8 @@ import { createPreview } from '../scripts/preview.mjs';
6
6
 
7
7
  const hostHome = process.env.HOME, hostFetch = globalThis.fetch;
8
8
  const preview = await createPreview();
9
- const { core, runtime, manager, temporary, runtimePath, cwd } = preview;
10
- const load = file => import(pathToFileURL(path.join(runtimePath, 'node_modules/@earendil-works/pi-coding-agent/dist', file)).href);
9
+ const { core, runtime, manager, temporary, runtimePath, agentRoot, cwd } = preview;
10
+ const load = file => import(pathToFileURL(path.join(agentRoot, 'dist', file)).href);
11
11
  const { initTheme, theme } = await load('modes/interactive/theme/theme.js');
12
12
  const { codemodeRenderers } = await load('extensions/codemode/renderer.js');
13
13
  const { Text } = await import(pathToFileURL(preview.tuiPath).href);
@@ -0,0 +1,23 @@
1
+ import assert from 'node:assert/strict';
2
+ import { core, loadSource } from './test-runtime.mjs';
3
+ const { supportsPiVersion, registerUnsupportedRuntime } = await loadSource('runtime-compatibility.ts');
4
+ for (const version of ['1.3.0', '1.4.0']) assert.equal(supportsPiVersion(version), true);
5
+ for (const version of ['1.2.0', '1.4.1', '1.5.0', '1.4.0-beta.1', '']) {
6
+ const commands = new Map(), events = new Map(), notices = [];
7
+ const pi = { registerCommand: (name, command) => commands.set(name, command), on: (name, handler) => events.set(name, handler) };
8
+ assert.equal(registerUnsupportedRuntime(pi, version), true);
9
+ const ctx = { hasUI: true, ui: { notify: (message, tone) => notices.push({ message, tone }) } };
10
+ events.get('session_start')({}, ctx);
11
+ for (const choice of ['on', 'status', 'toggle', 'collapse', '']) await commands.get('fold').handler(choice, ctx);
12
+ assert.equal(notices.length, 6);
13
+ for (const notice of notices) {
14
+ assert.match(notice.message, /Pi Fold is unavailable/);
15
+ assert.match(notice.message, /Native display remains active/);
16
+ assert.equal(notice.tone, 'warning');
17
+ assert.doesNotMatch(notice.message, /Pi Fold on/);
18
+ }
19
+ events.get('session_start')({}, { hasUI: false });
20
+ assert.equal(notices.length, 6, 'headless startup does not require a UI');
21
+ }
22
+ assert.equal(registerUnsupportedRuntime({}, core.VERSION), false, 'verified runtime proceeds to normal renderer registration');
23
+ console.log(`Pi ${core.VERSION}: explicit compatibility and unsupported-mode reporting passed`);
@@ -5,7 +5,7 @@ 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.equal(core.VERSION, '1.3.0', 'hierarchy integration runs against the supported native runtime');
8
+ assert.ok(['1.3.0', '1.4.0'].includes(core.VERSION), 'hierarchy integration runs against a verified native runtime');
9
9
 
10
10
  function fixture() {
11
11
  const hooks = new Map(), bus = new Map(), commands = new Map(), shortcuts = new Map(), inputs = new Set(), notices = [];
@@ -5,7 +5,7 @@ import {createWorkStripPreview} from '../scripts/preview-work-strip.mjs';
5
5
  const preview=await createWorkStripPreview({stepMs:20});
6
6
  const {core,runtime,manager}=preview;
7
7
  const {visibleWidth}=await import(pathToFileURL(preview.tuiPath));
8
- const {theme,initTheme}=await import(pathToFileURL(path.join(preview.runtimePath,'node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js')));
8
+ const {theme,initTheme}=await import(pathToFileURL(path.join(preview.agentRoot,'dist/modes/interactive/theme/theme.js')));
9
9
  initTheme('dark',false);
10
10
  const strip=s=>s.replace(/\x1b\][^\x07]*(?:\x07|\x1b\\)|\x1b\[[0-?]*[ -/]*[@-~]/g,'');
11
11
  const errors=[];