@howaboua/pi-notes-compaction 0.0.12 → 0.0.14

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/PCC-INTEGRATION.md +3 -1
  3. package/README.md +36 -22
  4. package/package.json +4 -6
  5. package/src/agent-identity.ts +112 -10
  6. package/src/attachment-sharing.ts +37 -6
  7. package/src/attachment-snapshot.ts +16 -6
  8. package/src/context-sharing.ts +15 -1
  9. package/src/extension-hooks.ts +15 -2
  10. package/src/extension-sharing.ts +25 -11
  11. package/src/fresh-checkpoint.ts +30 -4
  12. package/src/fresh-notes.ts +44 -33
  13. package/src/history-search.ts +1 -1
  14. package/src/history-windows.ts +12 -2
  15. package/src/history.ts +7 -1
  16. package/src/index.ts +5 -19
  17. package/src/integrations.ts +26 -26
  18. package/src/lifecycle.ts +26 -10
  19. package/src/model-role-config.ts +10 -30
  20. package/src/model-role-screen.ts +48 -32
  21. package/src/model-roles.ts +177 -315
  22. package/src/note-result.ts +70 -0
  23. package/src/note-save-marker.ts +23 -9
  24. package/src/notes-lookup.ts +5 -2
  25. package/src/notes.ts +8 -3
  26. package/src/query-executor.ts +34 -15
  27. package/src/query-input.ts +12 -1
  28. package/src/remote.ts +26 -7
  29. package/src/rollover.ts +17 -5
  30. package/src/saved-session.ts +1 -0
  31. package/src/saved-sharing-records.ts +18 -9
  32. package/src/settings-command.ts +1 -1
  33. package/src/shared-notes.ts +49 -20
  34. package/src/shared-session-reader.ts +8 -4
  35. package/src/sharing-service.ts +25 -8
  36. package/src/task-boundary.ts +1 -1
  37. package/src/tool-contracts.ts +50 -58
  38. package/src/tools.ts +34 -50
  39. package/src/window-message.ts +19 -8
  40. package/src/windows.ts +2 -2
  41. package/changelog.ts +0 -337
  42. package/src/model-role-editor.ts +0 -40
@@ -1,4 +1,3 @@
1
- import { randomUUID } from "node:crypto";
2
1
  import { isDeepStrictEqual } from "node:util";
3
2
  import type {
4
3
  ExtensionAPI,
@@ -6,7 +5,9 @@ import type {
6
5
  } from "@earendil-works/pi-coding-agent";
7
6
  import {
8
7
  CONTEXT_AGENT_ENTRY,
8
+ canonicalAgentName,
9
9
  contextAgentIdentity,
10
+ contextAgentNames,
10
11
  contextTargetAgent,
11
12
  parseContextAgentBinding,
12
13
  } from "./agent-identity.js";
@@ -79,8 +80,14 @@ export function registerContextSharingService(
79
80
  const parent = describe(ctx);
80
81
  if (!parent)
81
82
  throw new Error("Shared context requires notes-based continuity");
82
- if (!/^[a-zA-Z0-9_-]+$/.test(options.name))
83
- throw new Error("Invalid context agent name");
83
+ if (
84
+ options.threadId === parent.threadId ||
85
+ options.threadId === parent.sessionId
86
+ )
87
+ throw new Error(
88
+ "Child Pi session ID conflicts with its controller or family root; start a session with another ID",
89
+ );
90
+ const agentName = canonicalAgentName(options.threadId);
84
91
  if (!router || options.routing === undefined)
85
92
  throw new Error("Local sharing requires a registered context router");
86
93
 
@@ -91,7 +98,7 @@ export function registerContextSharingService(
91
98
  const binding = {
92
99
  protocol: 1 as const,
93
100
  sessionId: parent.sessionId,
94
- agentName: `${parent.agentName}/${options.name}-${randomUUID()}`,
101
+ agentName,
95
102
  storage: "session" as const,
96
103
  ...(parent.accountScope ? { accountScope: parent.accountScope } : {}),
97
104
  ...(parent.backendUrl ? { backendUrl: parent.backendUrl } : {}),
@@ -120,8 +127,18 @@ export function registerContextSharingService(
120
127
  },
121
128
  async bind(ctx, input, options) {
122
129
  const binding = parseContextAgentBinding(input);
123
- if (binding.agentName === "/root")
124
- throw new Error("Shared context binding requires a child agent path");
130
+ if (ctx.sessionManager.getSessionId() === binding.sessionId)
131
+ throw new Error(
132
+ "Child Pi session ID conflicts with its family root; start a session with another ID",
133
+ );
134
+ if (
135
+ binding.agentName !==
136
+ canonicalAgentName(ctx.sessionManager.getSessionId()) ||
137
+ binding.storageAgentName !== undefined
138
+ )
139
+ throw new Error(
140
+ "Shared context binding must use this Pi session identity",
141
+ );
125
142
  const identity = {
126
143
  ...binding,
127
144
  threadId: ctx.sessionManager.getSessionId(),
@@ -176,7 +193,7 @@ export function registerContextSharingService(
176
193
  if (
177
194
  !identity ||
178
195
  identity.sessionId !== request.sessionId ||
179
- identity.agentName !== request.agentName ||
196
+ !contextAgentNames(identity).includes(request.agentName) ||
180
197
  (request.namespace !== "notes" && request.namespace !== "history") ||
181
198
  !request.params ||
182
199
  typeof request.params !== "object" ||
@@ -185,7 +202,7 @@ export function registerContextSharingService(
185
202
  request.namespace,
186
203
  request.params,
187
204
  identity.agentName,
188
- ) !== identity.agentName
205
+ ) !== request.agentName
189
206
  )
190
207
  throw new Error("Shared context request does not belong to this agent");
191
208
  if (request.encryptedArguments)
@@ -6,7 +6,7 @@ export function renderTaskBoundaryReminder(
6
6
  ): string {
7
7
  if (gpt)
8
8
  return `<context_window_reminder>\nSuggested budget reached; ${remainingPercent}% left. Task sequence→finish current task→save notes→new_context before next; otherwise continue here.\n</context_window_reminder>`;
9
- return `<context_window_reminder>\nSuggested context budget reached; ${remainingPercent}% remains. For a sequence of tasks, finish the current task, save notes and call new_context before the next. Otherwise, continue here.\n</context_window_reminder>`;
9
+ return `<context_window_reminder>\nSuggested context budget reached; ${remainingPercent}% remains. For task sequences, finish current task, save notes and call new_context before next task. Otherwise continue here.\n</context_window_reminder>`;
10
10
  }
11
11
 
12
12
  export const TASK_BOUNDARY_PRESETS = [
@@ -3,6 +3,7 @@ import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
3
3
  import { Type } from "typebox";
4
4
  import { Check } from "typebox/value";
5
5
  import type { LookupQuery } from "./bridge.js";
6
+ import { noteResult } from "./note-result.js";
6
7
  import { internalQueryArguments, normalizeQueryInput } from "./query-input.js";
7
8
 
8
9
  const NOTES_ACTIONS = [
@@ -22,23 +23,22 @@ const HISTORY_ACTIONS = [
22
23
  ] as const;
23
24
  export const NOTES_USAGE = "await tools.notes()";
24
25
  export const HISTORY_USAGE = "await tools.history()";
25
- export const NOTES_DESCRIPTION =
26
- "Persistent notes for handing off task state between context windows";
27
- export const GPT_NOTES_DESCRIPTION =
28
- "Persistent notes: task state handoff between context windows";
26
+ export const NOTES_DESCRIPTION = "Virtual filesystem task checkpoints";
27
+ export const NOTES_ROUTING_GUIDELINE =
28
+ "notes: task checkpoints and internal handoffs. MUST revise via write/append actions. Paths are virtual: read/write only through notes, never shell/filesystem tools. MUST NOT store project files or deliverables";
29
29
  export const NEW_CONTEXT_DESCRIPTION =
30
- "Start fresh from saved notes; recover earlier conversation through history";
31
- export const GPT_NEW_CONTEXT_DESCRIPTION =
32
- "Saved notes→fresh context; earlier conversation→history";
30
+ "Start fresh context window. MUST save notes before calling";
31
+ export const GPT_NEW_CONTEXT_DESCRIPTION = "Save notes→fresh context";
33
32
  const STRING = Type.Optional(Type.String());
34
33
  const INTEGER = Type.Optional(Type.Integer({ minimum: 1 }));
35
34
  const LINE = Type.Optional(Type.Union([Type.Integer(), Type.Null()]));
36
- const NOTES_SCHEMA = Type.Object(
35
+ export const NOTES_SCHEMA = Type.Object(
37
36
  {
38
37
  action: Type.Optional(StringEnum(NOTES_ACTIONS)),
39
38
  path: Type.Optional(
40
39
  Type.Union([Type.String(), Type.Null()], {
41
- description: "File for read/write/append; prefix for list/search",
40
+ description:
41
+ "File for read/write/append; prefix for list/search; virtual filesystem, not files in the project",
42
42
  }),
43
43
  ),
44
44
  text: STRING,
@@ -55,36 +55,39 @@ const NOTES_SCHEMA = Type.Object(
55
55
  },
56
56
  { additionalProperties: false },
57
57
  );
58
- export function notesSchema(roles: boolean) {
59
- if (!roles) return NOTES_SCHEMA;
58
+ const NEW_CONTEXT_SCHEMA = Type.Object(
59
+ {
60
+ role: Type.Optional(
61
+ Type.String({
62
+ minLength: 1,
63
+ description:
64
+ "Configured model-role ID, not an agent name or handoff text",
65
+ }),
66
+ ),
67
+ },
68
+ { additionalProperties: false },
69
+ );
70
+
71
+ export function newContextSchema(roleIds: string[]) {
60
72
  return Type.Object(
61
- {
62
- ...NOTES_SCHEMA.properties,
63
- action: Type.Optional(
64
- StringEnum([...NOTES_ACTIONS, "roles", "recommend_handoff"]),
65
- ),
66
- role: STRING,
67
- reason: Type.Optional(
68
- Type.String({
69
- minLength: 1,
70
- description: "Conversation evidence this role fits better now",
71
- }),
72
- ),
73
- continuity: Type.Optional(
74
- Type.String({
75
- minLength: 1,
76
- description: "Goal, decisions, unfinished work and next step",
77
- }),
78
- ),
79
- },
73
+ roleIds.length ? { role: Type.Optional(StringEnum(roleIds)) } : {},
80
74
  { additionalProperties: false },
81
75
  );
82
76
  }
77
+
78
+ export function prepareNewContextArguments(input: unknown) {
79
+ const args = input ?? {};
80
+ if (!Check(NEW_CONTEXT_SCHEMA, args))
81
+ throw new Error(
82
+ 'Use {} to keep the current model, or {role: "name"} for a configured role.',
83
+ );
84
+ return args;
85
+ }
83
86
  export const HISTORY_SCHEMA = Type.Object(
84
87
  {
85
88
  action: Type.Optional(StringEnum(HISTORY_ACTIONS)),
86
89
  agent_name: Type.Optional(Type.Union([Type.String(), Type.Null()])),
87
- item_id: STRING,
90
+ item_id: Type.Optional(Type.String()),
88
91
  window_id: Type.Optional(
89
92
  Type.Union([Type.String(), Type.Null()], {
90
93
  description: "Required with item_id for read",
@@ -109,8 +112,6 @@ export const HISTORY_SCHEMA = Type.Object(
109
112
  );
110
113
 
111
114
  const FIELDS: Record<string, readonly string[]> = {
112
- roles: [],
113
- recommend_handoff: ["role", "reason", "continuity"],
114
115
  list_files_by_prefix: [
115
116
  "prefix",
116
117
  "file_order",
@@ -208,7 +209,6 @@ export function result(payload: unknown): AgentToolResult<unknown> {
208
209
  export function queryHelp(
209
210
  namespace: LookupQuery["namespace"],
210
211
  input: unknown,
211
- rankedHistory = false,
212
212
  gpt = false,
213
213
  ): AgentToolResult<unknown> | undefined {
214
214
  const params = input === undefined ? {} : input;
@@ -222,7 +222,10 @@ export function queryHelp(
222
222
  if (entries.some(([key]) => key !== "action"))
223
223
  throw new Error("Help accepts only action: help");
224
224
  const actions = namespace === "notes" ? NOTES_ACTIONS : HISTORY_ACTIONS;
225
- return result({
225
+ return (namespace === "notes" ? noteResult : result)({
226
+ ...(namespace === "notes"
227
+ ? { results: "read: file.content; write/append: file.path" }
228
+ : {}),
226
229
  actions: Object.fromEntries(
227
230
  actions.map((action) => [
228
231
  action,
@@ -244,43 +247,32 @@ export function queryHelp(
244
247
  ? "write=replace; append=add"
245
248
  : "write replaces; append adds",
246
249
  paths: gpt
247
- ? "Relative=current agent; cross-agent=<agent>/notes[/path]"
248
- : "Relative uses current agent; cross-agent uses <agent>/notes[/path]",
249
- usage: '{ "action": "read", "path": "checkpoint" }',
250
+ ? "Virtual≠disk; own list/search→omit path; relative=current agent; absolute=/<session ID>/notes[/path], not the agent ID alone"
251
+ : "Virtual note paths, not disk files. Omit path to list/search your notes. Relative paths use your agent; absolute paths require /<session ID>/notes[/path], not the agent ID alone",
252
+ usage: 'notes: {"action":"read","path":"checkpoint"}',
250
253
  ranges: gpt
251
254
  ? "start_line/stop_line=1-based inclusive; negative=from end; 0/null/omitted=first/last; out-of-range→clamp; reversed→empty"
252
- : "start_line/stop_line inclusive, 1-based; negative counts from end; 0/null/omitted uses first/last line; out-of-range clamps; reversed range returns empty content",
255
+ : "start_line/stop_line inclusive, 1-based; negative from end; 0/null/omitted uses first/last line; out-of-range clamps; reversed returns empty content",
253
256
  defaults: gpt
254
257
  ? "list limit=20; search limit/max_matches_per_file=20; limits clamp 1..100; list/search name ascending; recent_file_first→created_at descending"
255
- : "list limit 20; search limit/max_matches_per_file 20; limits clamp to 1..100; list name ascending; search name ascending, recent_file_first sorts created_at descending",
258
+ : "list limit 20; search limit/max_matches_per_file 20; limits clamp 1..100; list/search name ascending; recent_file_first sorts created_at descending",
256
259
  }
257
260
  : {
258
261
  usage: gpt
259
- ? "Earlierconversation→search≠browse; returned IDs unchanged"
260
- : "Search earlier conversation, don't browse it. Pass returned IDs unchanged",
261
- search: rankedHistory
262
- ? gpt
263
- ? "Own past user/assistant visible text: all keywords, case/accent-insensitive, BM25-ranked. Explicit live/tool/metadata/agent_name scopes→case-sensitive literal substring. list/read=full transcript; recent_first=true→newest first"
264
- : "Own earlier conversation: user/assistant visible text, all keywords, case/accent-insensitive, relevance order. Explicit live/tool/metadata scopes or agent_name: case-sensitive literal substring. list/read retain the full transcript. recent_first=true uses newest first"
265
- : gpt
266
- ? "Case-sensitive literal substring; recent_first=true→newest first"
267
- : "Case-sensitive literal substring. recent_first=true uses newest first",
262
+ ? "query→search default; past chat→search≠browse; returned IDs unchanged"
263
+ : "With query, action defaults to search. Search past chat, don't browse it. Pass returned IDs unchanged",
264
+ search: gpt
265
+ ? "recent_first=true→newest first"
266
+ : "recent_first=true uses newest first",
268
267
  }),
269
268
  });
270
269
  }
271
270
  return undefined;
272
271
  }
273
272
 
274
- export function prepareNotesArguments(args: unknown, roles = false) {
273
+ export function prepareNotesArguments(args: unknown) {
275
274
  const params = normalizeQueryInput("notes", args);
276
- if (
277
- !roles &&
278
- ["roles", "recommend_handoff"].includes(String(params["action"]))
279
- )
280
- throw new Error(
281
- "Role recommendations are off. The user can enable them with /roles",
282
- );
283
- validateArguments("notes", params, notesSchema(roles));
275
+ validateArguments("notes", params, NOTES_SCHEMA);
284
276
  return params;
285
277
  }
286
278
 
package/src/tools.ts CHANGED
@@ -9,14 +9,18 @@ import type { LookupQuery, SharedNotesDetails } from "./bridge.js";
9
9
  import type { HistorySearch } from "./history-search.js";
10
10
  import type { NotesLifecycle } from "./lifecycle.js";
11
11
  import type { createModelRoles } from "./model-roles.js";
12
+ import { NOTES_OUTPUT_SCHEMA } from "./note-result.js";
12
13
  import { createQueryExecutor } from "./query-executor.js";
13
14
  import type { NotesStore } from "./store.js";
14
15
  import {
15
16
  HISTORY_SCHEMA,
16
17
  NEW_CONTEXT_DESCRIPTION,
17
18
  NOTES_DESCRIPTION,
18
- notesSchema,
19
+ NOTES_ROUTING_GUIDELINE,
20
+ NOTES_SCHEMA,
21
+ newContextSchema,
19
22
  prepareHistoryArguments,
23
+ prepareNewContextArguments,
20
24
  prepareNotesArguments,
21
25
  result,
22
26
  } from "./tool-contracts.js";
@@ -61,58 +65,23 @@ export function createTools(
61
65
  );
62
66
  };
63
67
  const queries = createQueryExecutor(pi, store, lifecycle, search);
64
- return [
68
+ const tools: ToolDefinition[] = [
65
69
  {
66
70
  name: "notes",
67
71
  label: "notes",
68
72
  description: NOTES_DESCRIPTION,
69
- parameters: notesSchema(roles.enabled()),
73
+ promptGuidelines: [NOTES_ROUTING_GUIDELINE],
74
+ parameters: NOTES_SCHEMA,
75
+ outputSchema: NOTES_OUTPUT_SCHEMA,
70
76
  executionMode: "sequential",
71
- prepareArguments: (args) => prepareNotesArguments(args, roles.enabled()),
72
- execute: async (callId, input, signal, _update, ctx) => {
73
- const params = prepareNotesArguments(input, roles.enabled());
74
- if (
75
- params["action"] === "roles" ||
76
- params["action"] === "recommend_handoff"
77
- ) {
78
- assertActive();
79
- if (signal?.aborted)
80
- throw new Error("Handoff recommendation cancelled");
81
- if (params["action"] === "roles") return roles.query({}, ctx);
82
- const role = params["role"],
83
- reason = params["reason"],
84
- continuity = params["continuity"];
85
- if (
86
- typeof role !== "string" ||
87
- !role.trim() ||
88
- typeof reason !== "string" ||
89
- typeof continuity !== "string"
90
- )
91
- throw new Error(
92
- "recommend_handoff requires role, reason and continuity; use notes action=roles to discover preferences",
93
- );
94
- return roles.query({ role, reason, continuity }, ctx);
95
- }
96
- const output = await queries.notes(callId, params, signal, ctx);
97
- if (
98
- roles.enabled() &&
99
- (!params["action"] || params["action"] === "help")
100
- ) {
101
- const part = output.content[0];
102
- if (part?.type === "text") {
103
- const help = JSON.parse(part.text);
104
- help.actions.roles = "";
105
- help.actions.recommend_handoff = "role reason continuity";
106
- return result(help);
107
- }
108
- }
109
- return output;
110
- },
77
+ prepareArguments: prepareNotesArguments,
78
+ execute: (callId, input, signal, _update, ctx) =>
79
+ queries.notes(callId, input, signal, ctx),
111
80
  },
112
81
  {
113
82
  name: "history",
114
83
  label: "history",
115
- description: "Search earlier conversation",
84
+ description: "Search past chat",
116
85
  parameters: HISTORY_SCHEMA,
117
86
  prepareArguments(args) {
118
87
  return prepareHistoryArguments(args);
@@ -124,22 +93,27 @@ export function createTools(
124
93
  name: "new_context",
125
94
  label: "new_context",
126
95
  description: NEW_CONTEXT_DESCRIPTION,
127
- parameters: Type.Object({}, { additionalProperties: false }),
96
+ parameters: newContextSchema([]),
97
+ prepareArguments: prepareNewContextArguments,
128
98
  exposure: "model-only",
129
99
  executionMode: "sequential",
130
- async execute(id, _input, signal, _update, ctx) {
100
+ async execute(id, input, signal, _update, ctx) {
131
101
  assertActive();
132
102
  if (signal?.aborted) throw new Error("Rollover cancelled");
133
- const started = lifecycle.requestRollover(ctx, id);
103
+ const { role } = prepareNewContextArguments(input);
104
+ const handoff =
105
+ role === undefined ? undefined : await roles.prepare(role, ctx);
106
+ if (signal?.aborted) throw new Error("Rollover cancelled");
107
+ const started = lifecycle.requestRollover(ctx, id, handoff);
134
108
  if (started) ctx.abort();
135
109
  return {
136
110
  ...result({
137
111
  started,
138
112
  message: started
139
113
  ? lifecycle.newWindowRequests === "pi-limits"
140
- ? "Window request queued. Pi will check whether enough history can be compacted"
141
- : "A new window will open after this run settles"
142
- : "A checkpoint or rollover is already pending. Save notes and finish your response",
114
+ ? "Window request queued"
115
+ : "New window queued"
116
+ : "Checkpoint or rollover is already pending. Save notes and finish your response",
143
117
  }),
144
118
  ...(started ? { terminate: true } : {}),
145
119
  };
@@ -161,4 +135,14 @@ export function createTools(
161
135
  },
162
136
  },
163
137
  ];
138
+ const newContext = tools.find((tool) => tool.name === "new_context")!;
139
+ let advertisedRoles = "[]";
140
+ roles.onRoleIdsChanged((ids) => {
141
+ const key = JSON.stringify(ids);
142
+ if (key === advertisedRoles) return;
143
+ advertisedRoles = key;
144
+ newContext.parameters = newContextSchema(ids);
145
+ pi.registerTool(newContext);
146
+ });
147
+ return tools;
164
148
  }
@@ -3,7 +3,6 @@ import type {
3
3
  ExtensionAPI,
4
4
  SessionEntry,
5
5
  } from "@earendil-works/pi-coding-agent";
6
- import { keyHint } from "@earendil-works/pi-coding-agent";
7
6
  import { Box, Text, TruncatedText } from "@earendil-works/pi-tui";
8
7
  import type { WindowIdentity } from "./bridge.js";
9
8
 
@@ -16,25 +15,37 @@ export interface WindowDetails {
16
15
  trim: boolean;
17
16
  }
18
17
  const GUIDANCE = `<context_window_guidance>
19
- Notes are recovery state, not a diary. Write checkpoints and reports to relative paths in your own notes. Delegates do likewise and return their note paths. Keep one concise, authoritative note per task or topic at a stable path. Task checkpoints cover request, constraints, decisions, status, next steps and history IDs. Use write to replace stale state and mark completion. Link to existing notes instead of copying or summarising their contents. Recording isn't permission to implement.
18
+ Notes are recovery state, not diary. They use virtual storage, not disk filesystem. Use relative paths when creating.
20
19
 
21
- You must maintain a task checkpoint, updating it at each meaningful milestone and on completion or before switching substantive tasks, even with context room. Don't save every reply or intermediate step. Before new_context or handoff, save current state and wait for success; include the checkpoint path in handoffs. After rollover, read the checkpoint, then only needed links. Don't reread notes still in context unless they may have changed. Use history for missing details.
20
+ MUST maintain one authoritative checkpoint per task/topic with request, constraints, decision, status, next steps and relevant history IDs.
22
21
 
23
- Previous skill reads don’t carry into this window. Read the skills needed for the current task.
22
+ Use the notes tool write action to create or replace the checkpoint at milestones, task switches and completion. Use action append to add to it.
23
+
24
+ Subagents MUST maintain their own notes and return paths. For subagent handoffs, include the checkpoint path.
25
+
26
+ Link existing notes instead of duplicating content. Recording does not authorise implementation.
27
+
28
+ Before new_context or a handoff, MUST save the checkpoint with notes. For rollover, call new_context.
29
+
30
+ After rollover, use notes read action to recover the checkpoint, then read only necessary links. SHOULD NOT reread unchanged notes. Use the history tool for missing details.
31
+
32
+ Skill reads do not survive rollover. MUST reread required skills.
24
33
  </context_window_guidance>`;
25
34
 
26
35
  const GPT_GUIDANCE = `<context_window_guidance>
27
- Notes=recovery state≠diary. Checkpoints/reports→write relative paths in own notes. Delegates→same→return note paths. One concise authoritative note per task/topic, stable path. Task checkpoint=request/constraints/decisions/status/next steps/history IDs. write→replace stale state; mark completion. Existing notes→link≠copy/summarise. Recording≠implementation permission.
36
+ Notes=recovery stateNOTdiary. Virtual Notes storageNOTfilesystem. Create notes with relative paths. One authoritative checkpoint per task/topic→request/constraints/decision/status/next steps/history IDs. Existing notes→linkNOTduplicate. RecordingNOTimplementation permission.
37
+
38
+ MUST maintain task checkpoint→update@ milestones, task switches + completion. Notes tool: write→create/replace stale checkpoint; append→add content. Not every reply/step. Subagents MUST maintain own notes→return paths.
28
39
 
29
- Must maintain task checkpoint→update@each meaningful milestone + completion/before switching substantive tasks, even with context room. Not every reply/step. Before new_context/handoff: save current state→await success; handoff includes checkpoint path. Post-rollover: read checkpoint→needed links only. In-context notes: reread only if possibly changed. Missing details→history.
40
+ Before new_context/handoff: MUST save checkpoint via notes. Rollover→call new_context after save; subagent handoff→include checkpoint path. Post-rollover: notes read→checkpoint→necessary links only. SHOULD NOT reread unchanged notes. Missing details→history tool.
30
41
 
31
- Prior skill reads≠current context. Read task-relevant skills.
42
+ Prior skill reads≠current context. MUST reread required skills after rollover.
32
43
  </context_window_guidance>`;
33
44
 
34
45
  export function registerWindowRenderer(pi: ExtensionAPI): void {
35
46
  pi.registerMessageRenderer(
36
47
  WINDOW_MESSAGE,
37
- (message, { expanded, outputPad }, theme) => {
48
+ (message, { expanded, outputPad, keyHint }, theme) => {
38
49
  const details = parseWindowDetails(message.details);
39
50
  if (!details || typeof message.content !== "string") return undefined;
40
51
  const title =
package/src/windows.ts CHANGED
@@ -151,8 +151,8 @@ export class Windows {
151
151
  kind === "task-boundary"
152
152
  ? renderTaskBoundaryReminder(remainingPercent, gpt)
153
153
  : gpt
154
- ? `<context_window_reminder>\n${kind === "urgent" ? "Urgent: " : ""}${remainingPercent}% context left; save task state via notes→new_context ${kind === "urgent" ? "now, before other work" : "before continuing work"}.\n</context_window_reminder>`
155
- : `<context_window_reminder>\n${kind === "urgent" ? "Urgent: " : ""}${remainingPercent}% context remaining. Save the task state in notes, then call new_context ${kind === "urgent" ? "now, before other work" : "before continuing work"}.\n</context_window_reminder>`,
154
+ ? `<context_window_reminder>\n${kind === "urgent" ? "Urgent: " : ""}${remainingPercent}% context left; save checkpoint via notes→new_context ${kind === "urgent" ? "now, before other work" : "before continuing work"}.\n</context_window_reminder>`
155
+ : `<context_window_reminder>\n${kind === "urgent" ? "Urgent: " : ""}${remainingPercent}% context remaining. Save checkpoint with notes, then call new_context ${kind === "urgent" ? "now, before other work" : "before continuing work"}.\n</context_window_reminder>`,
156
156
  display: true,
157
157
  details: {
158
158
  protocol: 1,