@quandev104/pi-style 0.1.5 → 0.1.7

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.
@@ -1,6 +1,14 @@
1
1
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
2
  import type { StatusSnapshot } from "../domain/status.js";
3
3
  import { closeActiveBatch } from "../features/tools/boxed/batch.js";
4
+ import {
5
+ beginAgentRun,
6
+ finishAgentRun,
7
+ invalidateTurnMembers,
8
+ rebuildTurnRegistryFromEntries,
9
+ registerTurnFromMessage,
10
+ } from "../features/tools/boxed/turn-summary.js";
11
+ import { requestToolPresentationRender } from "../features/tools/index.js";
4
12
  import { registerPiStyleCommand } from "./commands.js";
5
13
  import { type CompatibilityTestHooks, createPiStyleSessionCoordinator } from "./session-coordinator.js";
6
14
  import { usageFromSession } from "./session-usage.js";
@@ -40,8 +48,9 @@ export function __setCompatibilityTestHooks(hooks: CompatibilityTestHooks): () =
40
48
 
41
49
  /** Thin Pi adapter: register flags, commands, and forward lifecycle events. */
42
50
  export default function piStyleExtension(pi: ExtensionAPI): void {
43
- // The core/message/tool surfaces are default-on (safe: fingerprint-certified against
44
- // exact Pi 0.83.0, fail-closed elsewhere, conflict-preserving). The OFF switch is the
51
+ // The core/message/tool surfaces are default-on (identity-certified per surface by
52
+ // name/arity/source fingerprint, graceful native fallback for any surface whose
53
+ // runtime identity is not recorded, conflict-preserving). The OFF switch is the
45
54
  // product gate `compatibility.allowCorePatches: false` (or `enabled: false`) in config.
46
55
  for (const [name, description] of [
47
56
  ["pi-style-core-patches", "Enable pi-style message/tool core patches"],
@@ -65,7 +74,12 @@ export default function piStyleExtension(pi: ExtensionAPI): void {
65
74
  }
66
75
  await coordinator.start(event, ctx);
67
76
  });
68
- pi.on("agent_start", () => coordinator.app.runtime.current?.dismissStartup());
77
+ pi.on("agent_start", () => {
78
+ coordinator.app.runtime.current?.dismissStartup();
79
+ // Turn summary (ADR 0007): a summary group spans the whole agent run
80
+ // (user request → agent_end), not pi's per-message turn_end.
81
+ beginAgentRun();
82
+ });
69
83
  pi.on("input", (event, _ctx) => {
70
84
  coordinator.app.runtime.current?.dismissStartup();
71
85
  // Bare `!`/`!!` submit guard: Pi treats `!`-prefixed input as a direct bash
@@ -110,9 +124,30 @@ export default function piStyleExtension(pi: ExtensionAPI): void {
110
124
  // message/turn boundaries, mirroring Pi's native footer; per-chunk updates
111
125
  // stay usage-free to keep streaming cheap.
112
126
  pi.on("message_end", (_event, ctx) => coordinator.app.update({ ...usagePatch(ctx) }, "coalesced"));
113
- pi.on("turn_end", (_event, ctx) => coordinator.app.update({ ...usagePatch(ctx) }, "deferred"));
127
+ pi.on("turn_end", (event, ctx) => {
128
+ // Append the finalized assistant message's tool batch to the current run.
129
+ registerTurnFromMessage(event.message, event.toolResults);
130
+ coordinator.app.update({ ...usagePatch(ctx) }, "deferred");
131
+ });
132
+ pi.on("agent_end", () => {
133
+ // The run is complete: collapse its tool blocks into one summary line.
134
+ // Pi only re-invokes the tool renderer selectors from updateDisplay(), so
135
+ // the captured per-block invalidate callbacks force the collapse and the
136
+ // captured Tui repaints. Interrupted runs (a call without a result) stay
137
+ // expanded.
138
+ const run = finishAgentRun();
139
+ if (run) {
140
+ invalidateTurnMembers(run);
141
+ requestToolPresentationRender();
142
+ }
143
+ });
114
144
  pi.on("agent_settled", (_event, ctx) => coordinator.app.update({ ...usagePatch(ctx) }, "coalesced"));
115
- pi.on("session_tree", (_event, ctx) => coordinator.app.update({ ...usagePatch(ctx) }, "deferred"));
145
+ pi.on("session_tree", (_event, ctx) => {
146
+ // Rebuild the turn registry from session content so restored/branched
147
+ // history renders collapsed consistently (no in-process turn_end events).
148
+ rebuildTurnRegistryFromEntries(ctx.sessionManager.getEntries());
149
+ coordinator.app.update({ ...usagePatch(ctx) }, "deferred");
150
+ });
116
151
  pi.on("session_compact", (_event, ctx) => coordinator.app.update({ ...usagePatch(ctx) }, "deferred"));
117
152
  pi.on("tool_result", (event, ctx) => {
118
153
  if (["write", "edit", "bash"].includes(event.toolName)) {
@@ -13,6 +13,7 @@ import {
13
13
  stopAllElapsedTickers,
14
14
  type ToolsRenderConfig,
15
15
  } from "../features/tools/boxed/session-config.js";
16
+ import { rebuildTurnRegistryFromEntries, resetTurnRegistry } from "../features/tools/boxed/turn-summary.js";
16
17
  import { createCompatibilityCoordinator } from "./compatibility-coordinator.js";
17
18
  import {
18
19
  type CompatibilityCleanupResult,
@@ -175,6 +176,11 @@ export function createPiStyleSessionCoordinator(pi: ExtensionAPI, hooks: Compati
175
176
  resetBatchRegistry();
176
177
  resetGrepRegistry();
177
178
  resetBashTreeRegistry();
179
+ // Turn summaries (ADR 0007): rebuild the registry from session content so
180
+ // restored/forked history renders collapsed before the first render pass
181
+ // (deterministic; no in-process turn_end events needed).
182
+ resetTurnRegistry();
183
+ rebuildTurnRegistryFromEntries(ctx.sessionManager.getEntries());
178
184
  // Stop any 1s elapsed re-render ticker left by a tool that was still
179
185
  // running when the session ended.
180
186
  stopAllElapsedTickers();
@@ -247,6 +253,7 @@ export function createPiStyleSessionCoordinator(pi: ExtensionAPI, hooks: Compati
247
253
  resetBatchRegistry();
248
254
  resetGrepRegistry();
249
255
  resetBashTreeRegistry();
256
+ resetTurnRegistry();
250
257
  stopAllElapsedTickers();
251
258
  app.sessionShutdown();
252
259
  // Tier C prototype patches stay installed across session switches. Pi renders
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quandev104/pi-style",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "A native-layout, cohesive visual style package for Pi.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -42,18 +42,18 @@
42
42
  "check": "npm run typecheck && npm run lint && npm run depcruise && npm run test && npm run build && npm run package:smoke"
43
43
  },
44
44
  "peerDependencies": {
45
- "@earendil-works/pi-agent-core": ">=0.83.0 <0.84.0",
46
- "@earendil-works/pi-ai": ">=0.83.0 <0.84.0",
47
- "@earendil-works/pi-coding-agent": ">=0.83.0 <0.84.0",
48
- "@earendil-works/pi-tui": ">=0.83.0 <0.84.0",
45
+ "@earendil-works/pi-agent-core": ">=0.83.0 <0.85.0",
46
+ "@earendil-works/pi-ai": ">=0.83.0 <0.85.0",
47
+ "@earendil-works/pi-coding-agent": ">=0.83.0 <0.85.0",
48
+ "@earendil-works/pi-tui": ">=0.83.0 <0.85.0",
49
49
  "typebox": ">=1.3.9 <2.0.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@biomejs/biome": "^2.5.0",
53
- "@earendil-works/pi-agent-core": "^0.83.0",
54
- "@earendil-works/pi-ai": "^0.83.0",
55
- "@earendil-works/pi-coding-agent": "^0.83.0",
56
- "@earendil-works/pi-tui": "^0.83.0",
53
+ "@earendil-works/pi-agent-core": "^0.84.0",
54
+ "@earendil-works/pi-ai": "^0.84.0",
55
+ "@earendil-works/pi-coding-agent": "^0.84.0",
56
+ "@earendil-works/pi-tui": "^0.84.0",
57
57
  "@types/node": "^24.0.0",
58
58
  "dependency-cruiser": "^17.4.3",
59
59
  "git-cliff": "^2.13.1",