@howaboua/pi-notes-compaction 0.0.13 → 0.0.15

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 (43) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/PCC-INTEGRATION.md +3 -1
  3. package/README.md +3 -1
  4. package/package.json +7 -7
  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/bridge.ts +1 -0
  9. package/src/context-sharing.ts +30 -1
  10. package/src/extension-hooks.ts +15 -2
  11. package/src/extension-sharing.ts +26 -11
  12. package/src/fresh-checkpoint.ts +30 -4
  13. package/src/fresh-notes.ts +44 -33
  14. package/src/history-search.ts +1 -1
  15. package/src/history-windows.ts +12 -2
  16. package/src/history.ts +7 -1
  17. package/src/index.ts +3 -0
  18. package/src/integrations.ts +24 -24
  19. package/src/model-roles.ts +28 -4
  20. package/src/note-result.ts +70 -0
  21. package/src/note-save-marker.ts +23 -9
  22. package/src/notes-lookup.ts +5 -2
  23. package/src/notes.ts +8 -3
  24. package/src/query-executor.ts +58 -19
  25. package/src/query-input.ts +12 -1
  26. package/src/remote.ts +26 -7
  27. package/src/saved-session-access.ts +117 -0
  28. package/src/saved-session-index.mjs +83 -0
  29. package/src/saved-session.mjs +241 -0
  30. package/src/saved-session.ts +37 -154
  31. package/src/saved-sharing-records.ts +41 -9
  32. package/src/shared-notes.ts +219 -69
  33. package/src/shared-session-reader.ts +35 -19
  34. package/src/sharing-service.ts +57 -9
  35. package/src/store.ts +10 -0
  36. package/src/task-boundary.ts +1 -1
  37. package/src/tool-contracts.ts +40 -27
  38. package/src/tools.ts +21 -7
  39. package/src/tree-archive-manifest.mjs +27 -0
  40. package/src/tree-archive.ts +6 -26
  41. package/src/window-message.ts +19 -8
  42. package/src/windows.ts +2 -2
  43. package/changelog.ts +0 -337
package/src/store.ts CHANGED
@@ -132,6 +132,16 @@ export class NotesStore {
132
132
  ?.prepare("UPDATE sessions SET file_path = ? WHERE id = ?")
133
133
  .run(session.file, session.id);
134
134
  }
135
+ /** Exact native thread lookup only. The JSONL header and binding remain authoritative. */
136
+ sessionFile(threadId: string): string | undefined {
137
+ return (
138
+ this.open()
139
+ ?.prepare<[string], { file_path: string | null }>(
140
+ "SELECT file_path FROM sessions WHERE id = ?",
141
+ )
142
+ .get(threadId)?.file_path ?? undefined
143
+ );
144
+ }
135
145
  cache(session: SessionRef, responses: readonly CachedResponse[]): void {
136
146
  if (!responses.length) return;
137
147
  for (const response of responses) {
@@ -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,14 +23,12 @@ 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()]));
@@ -38,7 +37,8 @@ export const NOTES_SCHEMA = Type.Object(
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,11 +55,26 @@ export const NOTES_SCHEMA = Type.Object(
55
55
  },
56
56
  { additionalProperties: false },
57
57
  );
58
- export const NEW_CONTEXT_SCHEMA = Type.Object(
59
- { role: Type.Optional(Type.String({ minLength: 1 })) },
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
+ },
60
68
  { additionalProperties: false },
61
69
  );
62
70
 
71
+ export function newContextSchema(roleIds: string[]) {
72
+ return Type.Object(
73
+ roleIds.length ? { role: Type.Optional(StringEnum(roleIds)) } : {},
74
+ { additionalProperties: false },
75
+ );
76
+ }
77
+
63
78
  export function prepareNewContextArguments(input: unknown) {
64
79
  const args = input ?? {};
65
80
  if (!Check(NEW_CONTEXT_SCHEMA, args))
@@ -72,7 +87,7 @@ export const HISTORY_SCHEMA = Type.Object(
72
87
  {
73
88
  action: Type.Optional(StringEnum(HISTORY_ACTIONS)),
74
89
  agent_name: Type.Optional(Type.Union([Type.String(), Type.Null()])),
75
- item_id: STRING,
90
+ item_id: Type.Optional(Type.String()),
76
91
  window_id: Type.Optional(
77
92
  Type.Union([Type.String(), Type.Null()], {
78
93
  description: "Required with item_id for read",
@@ -194,7 +209,6 @@ export function result(payload: unknown): AgentToolResult<unknown> {
194
209
  export function queryHelp(
195
210
  namespace: LookupQuery["namespace"],
196
211
  input: unknown,
197
- rankedHistory = false,
198
212
  gpt = false,
199
213
  ): AgentToolResult<unknown> | undefined {
200
214
  const params = input === undefined ? {} : input;
@@ -208,7 +222,10 @@ export function queryHelp(
208
222
  if (entries.some(([key]) => key !== "action"))
209
223
  throw new Error("Help accepts only action: help");
210
224
  const actions = namespace === "notes" ? NOTES_ACTIONS : HISTORY_ACTIONS;
211
- return result({
225
+ return (namespace === "notes" ? noteResult : result)({
226
+ ...(namespace === "notes"
227
+ ? { results: "read: file.content; write/append: file.path" }
228
+ : {}),
212
229
  actions: Object.fromEntries(
213
230
  actions.map((action) => [
214
231
  action,
@@ -230,27 +247,23 @@ export function queryHelp(
230
247
  ? "write=replace; append=add"
231
248
  : "write replaces; append adds",
232
249
  paths: gpt
233
- ? "Relative=current agent; cross-agent=<agent>/notes[/path]"
234
- : "Relative uses current agent; cross-agent uses <agent>/notes[/path]",
235
- 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"}',
236
253
  ranges: gpt
237
254
  ? "start_line/stop_line=1-based inclusive; negative=from end; 0/null/omitted=first/last; out-of-range→clamp; reversed→empty"
238
- : "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",
239
256
  defaults: gpt
240
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"
241
- : "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",
242
259
  }
243
260
  : {
244
261
  usage: gpt
245
- ? "Earlierconversation→search≠browse; returned IDs unchanged"
246
- : "Search earlier conversation, don't browse it. Pass returned IDs unchanged",
247
- search: rankedHistory
248
- ? gpt
249
- ? "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"
250
- : "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"
251
- : gpt
252
- ? "Case-sensitive literal substring; recent_first=true→newest first"
253
- : "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",
254
267
  }),
255
268
  });
256
269
  }
package/src/tools.ts CHANGED
@@ -9,14 +9,16 @@ 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
- NEW_CONTEXT_SCHEMA,
18
18
  NOTES_DESCRIPTION,
19
+ NOTES_ROUTING_GUIDELINE,
19
20
  NOTES_SCHEMA,
21
+ newContextSchema,
20
22
  prepareHistoryArguments,
21
23
  prepareNewContextArguments,
22
24
  prepareNotesArguments,
@@ -63,12 +65,14 @@ export function createTools(
63
65
  );
64
66
  };
65
67
  const queries = createQueryExecutor(pi, store, lifecycle, search);
66
- return [
68
+ const tools: ToolDefinition[] = [
67
69
  {
68
70
  name: "notes",
69
71
  label: "notes",
70
72
  description: NOTES_DESCRIPTION,
73
+ promptGuidelines: [NOTES_ROUTING_GUIDELINE],
71
74
  parameters: NOTES_SCHEMA,
75
+ outputSchema: NOTES_OUTPUT_SCHEMA,
72
76
  executionMode: "sequential",
73
77
  prepareArguments: prepareNotesArguments,
74
78
  execute: (callId, input, signal, _update, ctx) =>
@@ -77,7 +81,7 @@ export function createTools(
77
81
  {
78
82
  name: "history",
79
83
  label: "history",
80
- description: "Search earlier conversation",
84
+ description: "Search past chat",
81
85
  parameters: HISTORY_SCHEMA,
82
86
  prepareArguments(args) {
83
87
  return prepareHistoryArguments(args);
@@ -89,7 +93,7 @@ export function createTools(
89
93
  name: "new_context",
90
94
  label: "new_context",
91
95
  description: NEW_CONTEXT_DESCRIPTION,
92
- parameters: NEW_CONTEXT_SCHEMA,
96
+ parameters: newContextSchema([]),
93
97
  prepareArguments: prepareNewContextArguments,
94
98
  exposure: "model-only",
95
99
  executionMode: "sequential",
@@ -107,9 +111,9 @@ export function createTools(
107
111
  started,
108
112
  message: started
109
113
  ? lifecycle.newWindowRequests === "pi-limits"
110
- ? "Window request queued. Pi will check whether enough history can be compacted"
111
- : "A new window will open after this run settles"
112
- : "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",
113
117
  }),
114
118
  ...(started ? { terminate: true } : {}),
115
119
  };
@@ -131,4 +135,14 @@ export function createTools(
131
135
  },
132
136
  },
133
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;
134
148
  }
@@ -0,0 +1,27 @@
1
+ /** @typedef {import("./tree-archive.js").TreeArchiveManifestData} TreeArchiveManifestData */
2
+ export const TREE_ARCHIVE_ENTRY_TYPE = "codex-context-tree-archive";
3
+ const TREE_ARCHIVE_PROTOCOL = 1;
4
+ export const MAX_ARCHIVE_DEPTH = 50_000;
5
+
6
+ /** @param {unknown} value @returns {value is TreeArchiveManifestData} */
7
+ export function isTreeArchiveManifestData(value) {
8
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
9
+ const manifest = /** @type {Record<string, unknown>} */ (value);
10
+ return (
11
+ manifest["protocol"] === TREE_ARCHIVE_PROTOCOL &&
12
+ manifest["strategy"] === "codex-context-tree" &&
13
+ nonEmptyString(manifest["windowId"]) &&
14
+ nonEmptyString(manifest["boundaryEntryId"]) &&
15
+ nonEmptyString(manifest["summaryEntryId"]) &&
16
+ nonEmptyString(manifest["archivedLeafId"]) &&
17
+ (manifest["compactionEntryId"] === undefined ||
18
+ nonEmptyString(manifest["compactionEntryId"])) &&
19
+ (manifest["branchBaseId"] === null ||
20
+ nonEmptyString(manifest["branchBaseId"]))
21
+ );
22
+ }
23
+
24
+ /** @param {unknown} value @returns {value is string} */
25
+ function nonEmptyString(value) {
26
+ return typeof value === "string" && value !== "";
27
+ }
@@ -2,11 +2,14 @@ import type {
2
2
  BranchSummaryEntry,
3
3
  SessionEntry,
4
4
  } from "@earendil-works/pi-coding-agent";
5
+ import {
6
+ isTreeArchiveManifestData,
7
+ MAX_ARCHIVE_DEPTH,
8
+ TREE_ARCHIVE_ENTRY_TYPE,
9
+ } from "./tree-archive-manifest.mjs";
5
10
  import { windowDetails } from "./windows.js";
6
11
 
7
- export const TREE_ARCHIVE_ENTRY_TYPE = "codex-context-tree-archive";
8
- const TREE_ARCHIVE_PROTOCOL = 1;
9
- export const MAX_ARCHIVE_DEPTH = 50_000;
12
+ export { TREE_ARCHIVE_ENTRY_TYPE } from "./tree-archive-manifest.mjs";
10
13
 
11
14
  export interface TreeArchiveManifestData {
12
15
  protocol: 1;
@@ -112,29 +115,6 @@ function archivedPath(
112
115
  return reverse.reverse();
113
116
  }
114
117
 
115
- export function isTreeArchiveManifestData(
116
- value: unknown,
117
- ): value is TreeArchiveManifestData {
118
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
119
- const manifest = value as Record<string, unknown>;
120
- return (
121
- manifest["protocol"] === TREE_ARCHIVE_PROTOCOL &&
122
- manifest["strategy"] === "codex-context-tree" &&
123
- nonEmptyString(manifest["windowId"]) &&
124
- nonEmptyString(manifest["boundaryEntryId"]) &&
125
- nonEmptyString(manifest["summaryEntryId"]) &&
126
- nonEmptyString(manifest["archivedLeafId"]) &&
127
- (manifest["compactionEntryId"] === undefined ||
128
- nonEmptyString(manifest["compactionEntryId"])) &&
129
- (manifest["branchBaseId"] === null ||
130
- nonEmptyString(manifest["branchBaseId"]))
131
- );
132
- }
133
-
134
- function nonEmptyString(value: unknown): value is string {
135
- return typeof value === "string" && value !== "";
136
- }
137
-
138
118
  export function hasTreeArchiveSuccessor(
139
119
  entries: readonly SessionEntry[],
140
120
  windowId: string,
@@ -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,