@astralyn/pi 0.84.2 → 0.84.3
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 +17 -0
- package/dist/cli/args.js +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +2 -3
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +3 -5
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -1
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -25
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +29 -408
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction-controller.d.ts +89 -0
- package/dist/core/compaction-controller.d.ts.map +1 -0
- package/dist/core/compaction-controller.js +428 -0
- package/dist/core/compaction-controller.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.js +3 -3
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +1 -15
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/provider-attribution.js +2 -2
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/telemetry.d.ts +1 -1
- package/dist/core/telemetry.d.ts.map +1 -1
- package/dist/core/telemetry.js +1 -1
- package/dist/core/telemetry.js.map +1 -1
- package/dist/extensions/deepwiki/index.d.ts.map +1 -1
- package/dist/extensions/deepwiki/index.js +23 -1
- package/dist/extensions/deepwiki/index.js.map +1 -1
- package/dist/extensions/deepwiki/render.d.ts +1 -1
- package/dist/extensions/deepwiki/render.d.ts.map +1 -1
- package/dist/extensions/deepwiki/render.js +4 -2
- package/dist/extensions/deepwiki/render.js.map +1 -1
- package/dist/extensions/question/index.d.ts.map +1 -1
- package/dist/extensions/question/index.js +0 -1
- package/dist/extensions/question/index.js.map +1 -1
- package/dist/extensions/subagent/index.d.ts.map +1 -1
- package/dist/extensions/subagent/index.js +20 -2
- package/dist/extensions/subagent/index.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +0 -2
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +1 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-chrome.d.ts +28 -0
- package/dist/modes/interactive/components/tool-chrome.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-chrome.js +81 -0
- package/dist/modes/interactive/components/tool-chrome.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +0 -3
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +11 -108
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +35 -52
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/bundled/extensions/subagent.md +1 -1
- package/docs/bundled/tool-presentation.md +2 -2
- package/docs/extensions.md +6 -23
- package/docs/settings.md +1 -1
- package/docs/usage.md +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/utils/coalescing-terminal.d.ts +0 -132
- package/dist/utils/coalescing-terminal.d.ts.map +0 -1
- package/dist/utils/coalescing-terminal.js +0 -292
- package/dist/utils/coalescing-terminal.js.map +0 -1
|
@@ -10,7 +10,7 @@ import * as TuiLayouts from "@earendil-works/pi-tui";
|
|
|
10
10
|
import { CombinedAutocompleteProvider, Container, fuzzyFilter, Markdown, matchesKey, ProcessTerminal, Spacer, setKeybindings, Text, TruncatedText, TuiAltScreen, TuiMainScreen, visibleWidth, } from "@earendil-works/pi-tui";
|
|
11
11
|
import chalk from "chalk";
|
|
12
12
|
import { spawn, spawnSync } from "child_process";
|
|
13
|
-
import { APP_NAME, APP_TITLE, CONFIG_DIR_NAME, getAgentDir, getAuthPath, getDebugLogPath, getDocsPath, getShareViewerUrl, VERSION, } from "../../config.js";
|
|
13
|
+
import { APP_NAME, APP_TITLE, CONFIG_DIR_NAME, getAgentDir, getAuthPath, getDebugLogPath, getDocsPath, getShareViewerUrl, INSTALL_TELEMETRY_URL, UPDATE_CHANGELOG_HINT, VERSION, } from "../../config.js";
|
|
14
14
|
import { parseSkillBlock } from "../../core/agent-session.js";
|
|
15
15
|
import { SessionImportFileNotFoundError } from "../../core/agent-session-runtime.js";
|
|
16
16
|
import { CACHE_TTL_MS, collectCacheMisses, computeCacheWaste, detectCacheMiss, } from "../../core/cache-stats.js";
|
|
@@ -24,15 +24,16 @@ import { DefaultPackageManager } from "../../core/package-manager.js";
|
|
|
24
24
|
import { formatMissingSessionCwdPrompt, MissingSessionCwdError } from "../../core/session-cwd.js";
|
|
25
25
|
import { SessionManager, sessionEntryToContextMessages } from "../../core/session-manager.js";
|
|
26
26
|
import { BUILTIN_SLASH_COMMANDS } from "../../core/slash-commands.js";
|
|
27
|
+
import { isInstallTelemetryEnabled } from "../../core/telemetry.js";
|
|
27
28
|
import { hasTrustRequiringProjectResources, ProjectTrustStore } from "../../core/trust-manager.js";
|
|
28
29
|
import { getUsageCostBreakdown } from "../../core/usage-totals.js";
|
|
29
30
|
import { getChangelogPath, getNewEntries, normalizeChangelogLinks, parseChangelog } from "../../utils/changelog.js";
|
|
30
31
|
import { copyToClipboard, readClipboardText } from "../../utils/clipboard.js";
|
|
31
32
|
import { extensionForImageMimeType, readClipboardImage } from "../../utils/clipboard-image.js";
|
|
32
|
-
import { CoalescingTerminal } from "../../utils/coalescing-terminal.js";
|
|
33
33
|
import { parseGitUrl } from "../../utils/git.js";
|
|
34
34
|
import { openBrowser } from "../../utils/open-browser.js";
|
|
35
35
|
import { getCwdRelativePath } from "../../utils/paths.js";
|
|
36
|
+
import { getPiUserAgent } from "../../utils/pi-user-agent.js";
|
|
36
37
|
import { killTrackedDetachedChildren } from "../../utils/shell.js";
|
|
37
38
|
import { ensureTool } from "../../utils/tools-manager.js";
|
|
38
39
|
import { checkForNewPiVersion } from "../../utils/version-check.js";
|
|
@@ -205,6 +206,10 @@ export function createInteractiveTuiReference(getTui) {
|
|
|
205
206
|
getPrototypeOf: () => Reflect.getPrototypeOf(getTui()),
|
|
206
207
|
});
|
|
207
208
|
}
|
|
209
|
+
/** Chat children that host tool presentation and share image display settings. */
|
|
210
|
+
function isToolChatComponent(child) {
|
|
211
|
+
return child instanceof ToolExecutionComponent || child instanceof ToolGroupComponent;
|
|
212
|
+
}
|
|
208
213
|
export class InteractiveMode {
|
|
209
214
|
// Convenience accessors
|
|
210
215
|
get session() {
|
|
@@ -300,24 +305,13 @@ export class InteractiveMode {
|
|
|
300
305
|
await this.rebindCurrentSession({ renderBeforeBind: true });
|
|
301
306
|
});
|
|
302
307
|
this.version = VERSION;
|
|
303
|
-
const terminal = new CoalescingTerminal();
|
|
304
|
-
this.coalescingTerminal = terminal;
|
|
305
308
|
this.renderer = createInteractiveTui({
|
|
306
309
|
tuiMode,
|
|
307
310
|
showHardwareCursor: this.settingsManager.getShowHardwareCursor(),
|
|
308
311
|
logDirectory: getAgentDir(),
|
|
309
|
-
terminal,
|
|
310
312
|
onRightClickPaste: this.onRightClickPaste,
|
|
311
313
|
});
|
|
312
314
|
this.ui = createInteractiveTuiReference(() => this.renderer);
|
|
313
|
-
// Lets full-redraw rewrites scroll grown content into scrollback
|
|
314
|
-
// instead of dropping the lines pushed above the screen. The render
|
|
315
|
-
// state comes from pi-tui's public captureRenderState(); pi-tui
|
|
316
|
-
// writes each full-redraw frame before updating its bookkeeping, so
|
|
317
|
-
// the wrapper observes the pre-frame viewport top. Fullscreen
|
|
318
|
-
// renderers return undefined (their frames do not match the rewrite
|
|
319
|
-
// shape anyway), falling back to the bottom-anchored repaint.
|
|
320
|
-
terminal.setViewportTopProvider(() => this.renderer instanceof TuiMainScreen ? this.renderer.captureRenderState().previousViewportTop : undefined);
|
|
321
315
|
this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());
|
|
322
316
|
this.headerContainer = new Container();
|
|
323
317
|
this.loadedResourcesContainer = new Container();
|
|
@@ -867,17 +861,38 @@ export class InteractiveMode {
|
|
|
867
861
|
const changelogPath = getChangelogPath();
|
|
868
862
|
const entries = parseChangelog(changelogPath);
|
|
869
863
|
if (!lastVersion) {
|
|
870
|
-
// Fresh install - record the version
|
|
864
|
+
// Fresh install - record the version, send telemetry, don't show changelog
|
|
871
865
|
this.settingsManager.setLastChangelogVersion(VERSION);
|
|
866
|
+
this.reportInstallTelemetry(VERSION);
|
|
872
867
|
return undefined;
|
|
873
868
|
}
|
|
874
869
|
const newEntries = getNewEntries(entries, lastVersion);
|
|
875
870
|
if (newEntries.length > 0) {
|
|
876
871
|
this.settingsManager.setLastChangelogVersion(VERSION);
|
|
872
|
+
this.reportInstallTelemetry(VERSION);
|
|
877
873
|
return newEntries.map((e) => normalizeChangelogLinks(e.content, e)).join("\n\n");
|
|
878
874
|
}
|
|
879
875
|
return undefined;
|
|
880
876
|
}
|
|
877
|
+
reportInstallTelemetry(version) {
|
|
878
|
+
if (!INSTALL_TELEMETRY_URL) {
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
if (process.env.PI_OFFLINE) {
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
if (!isInstallTelemetryEnabled(this.settingsManager)) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
void fetch(`${INSTALL_TELEMETRY_URL}?version=${encodeURIComponent(version)}`, {
|
|
888
|
+
headers: {
|
|
889
|
+
"User-Agent": getPiUserAgent(version),
|
|
890
|
+
},
|
|
891
|
+
signal: AbortSignal.timeout(5000),
|
|
892
|
+
})
|
|
893
|
+
.then(() => undefined)
|
|
894
|
+
.catch(() => undefined);
|
|
895
|
+
}
|
|
881
896
|
getMarkdownThemeWithSettings() {
|
|
882
897
|
return {
|
|
883
898
|
...getMarkdownTheme(),
|
|
@@ -1374,7 +1389,6 @@ export class InteractiveMode {
|
|
|
1374
1389
|
if (result.cancelled) {
|
|
1375
1390
|
return { cancelled: true };
|
|
1376
1391
|
}
|
|
1377
|
-
this.coalescingTerminal.passNextFullRedraw();
|
|
1378
1392
|
this.clearChat();
|
|
1379
1393
|
this.renderInitialMessages();
|
|
1380
1394
|
if (result.editorText && !this.editor.getText().trim()) {
|
|
@@ -1463,11 +1477,9 @@ export class InteractiveMode {
|
|
|
1463
1477
|
}
|
|
1464
1478
|
disposeChatToolComponents() {
|
|
1465
1479
|
for (const child of this.chatContainer.children) {
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
child instanceof DaxnutsComponent) {
|
|
1470
|
-
child.dispose();
|
|
1480
|
+
const disposable = child;
|
|
1481
|
+
if (typeof disposable.dispose === "function") {
|
|
1482
|
+
disposable.dispose();
|
|
1471
1483
|
}
|
|
1472
1484
|
}
|
|
1473
1485
|
}
|
|
@@ -1482,10 +1494,6 @@ export class InteractiveMode {
|
|
|
1482
1494
|
this.pendingTools.clear();
|
|
1483
1495
|
}
|
|
1484
1496
|
renderCurrentSessionState() {
|
|
1485
|
-
// Resuming, forking, or starting a new session rebuilds the transcript
|
|
1486
|
-
// at the user's request; the rebuild's full redraw keeps the clean
|
|
1487
|
-
// wipe-and-replay even if preservation is still windowed on.
|
|
1488
|
-
this.coalescingTerminal.passNextFullRedraw();
|
|
1489
1497
|
this.loadedResourcesContainer.clear();
|
|
1490
1498
|
this.clearChat();
|
|
1491
1499
|
this.pendingMessagesContainer.clear();
|
|
@@ -1928,7 +1936,6 @@ export class InteractiveMode {
|
|
|
1928
1936
|
tui: this.ui,
|
|
1929
1937
|
timeout: opts?.timeout,
|
|
1930
1938
|
subtitle: opts?.subtitle,
|
|
1931
|
-
cancelHint: opts?.cancelHint,
|
|
1932
1939
|
onToggleToolsExpanded: () => this.toggleToolOutputExpansion(),
|
|
1933
1940
|
});
|
|
1934
1941
|
this.disposeActiveSelector();
|
|
@@ -2507,9 +2514,6 @@ export class InteractiveMode {
|
|
|
2507
2514
|
this.footer.invalidate();
|
|
2508
2515
|
switch (event.type) {
|
|
2509
2516
|
case "agent_start":
|
|
2510
|
-
// Opens the scrollback-preservation window; the terminal
|
|
2511
|
-
// closes it on the user's next input after the run settles.
|
|
2512
|
-
this.coalescingTerminal.setAgentRunActive(true);
|
|
2513
2517
|
this.clearPendingTools();
|
|
2514
2518
|
if (this.settingsManager.getShowTerminalProgress()) {
|
|
2515
2519
|
this.ui.terminal.setProgress(true);
|
|
@@ -2683,10 +2687,6 @@ export class InteractiveMode {
|
|
|
2683
2687
|
this.ui.requestRender();
|
|
2684
2688
|
break;
|
|
2685
2689
|
case "agent_settled":
|
|
2686
|
-
// Preservation itself stays on until the next user input; the
|
|
2687
|
-
// run's trailing reflow frames may land after this event while
|
|
2688
|
-
// the reader is still scrolled up.
|
|
2689
|
-
this.coalescingTerminal.setAgentRunActive(false);
|
|
2690
2690
|
await this.checkShutdownRequested();
|
|
2691
2691
|
break;
|
|
2692
2692
|
case "compaction_start": {
|
|
@@ -2721,7 +2721,6 @@ export class InteractiveMode {
|
|
|
2721
2721
|
}
|
|
2722
2722
|
else {
|
|
2723
2723
|
if (event.result) {
|
|
2724
|
-
this.clearChat();
|
|
2725
2724
|
this.rebuildChatFromMessages();
|
|
2726
2725
|
this.addMessageToChat(createCompactionSummaryMessage(event.result.summary, event.result.tokensBefore, new Date().toISOString()));
|
|
2727
2726
|
this.footer.invalidate();
|
|
@@ -3330,11 +3329,6 @@ export class InteractiveMode {
|
|
|
3330
3329
|
if (expanded === this.toolOutputExpanded)
|
|
3331
3330
|
return;
|
|
3332
3331
|
this.toolOutputExpanded = expanded;
|
|
3333
|
-
// An explicit toggle prefers upstream's clean wipe-and-replay even
|
|
3334
|
-
// mid-run: the user just pressed the key, so they are interacting at
|
|
3335
|
-
// the bottom, and a full replay leaves scrollback as the exact new
|
|
3336
|
-
// transcript instead of preservation's stale seams.
|
|
3337
|
-
this.coalescingTerminal.passNextFullRedraw();
|
|
3338
3332
|
const activeHeader = this.customHeader ?? this.builtInHeader;
|
|
3339
3333
|
if (isExpandable(activeHeader)) {
|
|
3340
3334
|
activeHeader.setExpanded(expanded);
|
|
@@ -3351,10 +3345,7 @@ export class InteractiveMode {
|
|
|
3351
3345
|
toggleThinkingBlockVisibility() {
|
|
3352
3346
|
this.hideThinkingBlock = !this.hideThinkingBlock;
|
|
3353
3347
|
this.settingsManager.setHideThinkingBlock(this.hideThinkingBlock);
|
|
3354
|
-
// Same reasoning as setToolsExpanded.
|
|
3355
|
-
this.coalescingTerminal.passNextFullRedraw();
|
|
3356
3348
|
// Rebuild chat from session messages
|
|
3357
|
-
this.clearChat();
|
|
3358
3349
|
this.rebuildChatFromMessages();
|
|
3359
3350
|
// If streaming, re-add the streaming component with updated visibility and re-render
|
|
3360
3351
|
if (this.streamingComponent && this.streamingMessage) {
|
|
@@ -3402,7 +3393,7 @@ export class InteractiveMode {
|
|
|
3402
3393
|
showNewVersionNotification(release) {
|
|
3403
3394
|
const action = theme.fg("accent", `${APP_NAME} update`);
|
|
3404
3395
|
const updateInstruction = theme.fg("muted", `New version ${release.version} is available. Run `) + action;
|
|
3405
|
-
const changelogLine = theme.fg("muted",
|
|
3396
|
+
const changelogLine = theme.fg("muted", UPDATE_CHANGELOG_HINT);
|
|
3406
3397
|
const note = release.note?.trim();
|
|
3407
3398
|
this.chatContainer.addChild(new Spacer(1));
|
|
3408
3399
|
this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
|
|
@@ -3682,7 +3673,7 @@ export class InteractiveMode {
|
|
|
3682
3673
|
onShowImagesChange: (enabled) => {
|
|
3683
3674
|
this.settingsManager.setShowImages(enabled);
|
|
3684
3675
|
for (const child of this.chatContainer.children) {
|
|
3685
|
-
if (child
|
|
3676
|
+
if (isToolChatComponent(child)) {
|
|
3686
3677
|
child.setShowImages(enabled);
|
|
3687
3678
|
}
|
|
3688
3679
|
}
|
|
@@ -3690,7 +3681,7 @@ export class InteractiveMode {
|
|
|
3690
3681
|
onImageWidthCellsChange: (width) => {
|
|
3691
3682
|
this.settingsManager.setImageWidthCells(width);
|
|
3692
3683
|
for (const child of this.chatContainer.children) {
|
|
3693
|
-
if (child
|
|
3684
|
+
if (isToolChatComponent(child)) {
|
|
3694
3685
|
child.setImageWidthCells(width);
|
|
3695
3686
|
}
|
|
3696
3687
|
}
|
|
@@ -3738,7 +3729,6 @@ export class InteractiveMode {
|
|
|
3738
3729
|
child.setHideThinkingBlock(hidden);
|
|
3739
3730
|
}
|
|
3740
3731
|
}
|
|
3741
|
-
this.clearChat();
|
|
3742
3732
|
this.rebuildChatFromMessages();
|
|
3743
3733
|
},
|
|
3744
3734
|
onMermaidRenderingModeChange: (mode) => {
|
|
@@ -4239,9 +4229,6 @@ export class InteractiveMode {
|
|
|
4239
4229
|
this.showStatus("Navigation cancelled");
|
|
4240
4230
|
return;
|
|
4241
4231
|
}
|
|
4242
|
-
// User-committed tree navigation rebuilds the transcript; its
|
|
4243
|
-
// full redraw bypasses scrollback preservation.
|
|
4244
|
-
this.coalescingTerminal.passNextFullRedraw();
|
|
4245
4232
|
// Update UI
|
|
4246
4233
|
this.clearChat();
|
|
4247
4234
|
this.renderInitialMessages();
|
|
@@ -4814,10 +4801,6 @@ export class InteractiveMode {
|
|
|
4814
4801
|
}
|
|
4815
4802
|
this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();
|
|
4816
4803
|
this.outputPad = this.settingsManager.getOutputPad();
|
|
4817
|
-
// The user asked for this rebuild; its full redraw keeps the
|
|
4818
|
-
// upstream wipe-and-replay even if preservation is still windowed
|
|
4819
|
-
// on from the previous run.
|
|
4820
|
-
this.coalescingTerminal.passNextFullRedraw();
|
|
4821
4804
|
this.rebuildChatFromMessages();
|
|
4822
4805
|
chatRestoredBeforeSessionStart = true;
|
|
4823
4806
|
};
|