@howaboua/pi-agent-comms 0.0.1-dev.14.1.g7d1d3da173aa → 0.0.2

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 (38) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +4 -4
  3. package/docs/BOARD.md +2 -2
  4. package/docs/NOTES.md +14 -2
  5. package/package.json +5 -5
  6. package/src/board/briefing.ts +2 -2
  7. package/src/board/contract.ts +31 -27
  8. package/src/board/identity.ts +49 -29
  9. package/src/board/protocol.ts +98 -59
  10. package/src/board/settings/panel.ts +11 -8
  11. package/src/board/tool.ts +5 -0
  12. package/src/guidance.ts +14 -14
  13. package/src/notes/AGENTS.md +1 -1
  14. package/src/notes/attachment-snapshot.ts +33 -20
  15. package/src/notes/feature.ts +67 -1
  16. package/src/notes/history-search-pruning.mjs +110 -76
  17. package/src/notes/history-search-worker.mjs +1 -1
  18. package/src/notes/integrations.ts +6 -3
  19. package/src/notes/note-result.ts +70 -39
  20. package/src/notes/notes-lookup.ts +1 -1
  21. package/src/notes/query-input.ts +1 -0
  22. package/src/notes/saved-session-access.ts +12 -8
  23. package/src/notes/saved-session.ts +31 -15
  24. package/src/notes/saved-sharing-records.ts +110 -75
  25. package/src/notes/session-pruning-cleanup.mjs +163 -0
  26. package/src/notes/session-pruning-exit.mjs +312 -0
  27. package/src/notes/session-pruning-screen.ts +1 -1
  28. package/src/notes/session-pruning-sparse.mjs +133 -0
  29. package/src/notes/session-pruning-state.mjs +123 -0
  30. package/src/notes/session-pruning.ts +34 -1
  31. package/src/notes/settings-controls.ts +13 -17
  32. package/src/notes/settings-screen.ts +2 -6
  33. package/src/notes/shared-notes.ts +19 -11
  34. package/src/notes/shared-session-reader.ts +4 -2
  35. package/src/notes/tool-contracts.ts +71 -44
  36. package/src/notes/tools.ts +2 -2
  37. package/src/notes/tree-handoff-read.ts +47 -32
  38. package/src/notes/window-message.ts +6 -18
@@ -29,7 +29,7 @@ export async function openNotesSettings(
29
29
  sessionPruning: SessionPruningSettings;
30
30
  },
31
31
  ): Promise<"roles" | "board" | undefined> {
32
- let selected = "sessionPruning";
32
+ let selected = "active";
33
33
  while (true) {
34
34
  const action = await ctx.ui.custom<ScreenAction>(
35
35
  (tui, theme, _kb, done) => {
@@ -46,7 +46,7 @@ export async function openNotesSettings(
46
46
  const rule = theme.fg("accent", "─".repeat(Math.max(0, width)));
47
47
  return [
48
48
  rule,
49
- ` ${theme.bold("Notes & Compaction")} / ${theme.fg("dim", options.boardTab === false ? "Roles" : "Board")}`,
49
+ ` ${theme.bold("Notes")} / ${theme.fg("dim", options.boardTab === false ? "Roles" : "Board")}`,
50
50
  "",
51
51
  ...options
52
52
  .status()
@@ -54,10 +54,6 @@ export async function openNotesSettings(
54
54
  wrap(line).map((part) => theme.fg("dim", part)),
55
55
  ),
56
56
  "",
57
- ...wrap(
58
- "This extension works best on GPT6+ models. For other models we recommend switching the active option to whitelist or switching normal compaction on to work alongside the notes system.",
59
- ),
60
- "",
61
57
  ...list.render(width).slice(0, -2),
62
58
  "",
63
59
  ...wrap(
@@ -1,7 +1,6 @@
1
1
  import { isDeepStrictEqual } from "node:util";
2
2
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
3
- import type { Static } from "typebox";
4
- import { Check } from "typebox/value";
3
+ import { compile, type Static } from "@earendil-works/pi-schema";
5
4
  import {
6
5
  canonicalAgentName,
7
6
  contextAgentNames,
@@ -28,6 +27,12 @@ import type { NotesStore } from "./store.js";
28
27
 
29
28
  export { savedNotesIdentity } from "./saved-sharing-records.js";
30
29
 
30
+ const detachmentValidator = compile(Detachment);
31
+ const memberValidator = compile(Member);
32
+ const parentValidator = compile(Parent);
33
+ const planValidator = compile(Plan);
34
+ const routeValidator = compile(Route);
35
+
31
36
  function records(session: SavedNotesSession, kind: string): unknown[] {
32
37
  return session.entries.flatMap((entry) =>
33
38
  entry.type === "custom" && entry.customType === kind ? [entry.data] : [],
@@ -193,7 +198,7 @@ async function readSharedSession(
193
198
  const routes = new Map<string, Static<typeof Route>>();
194
199
  for (const value of records(session, "shepherdr-attachment-route"))
195
200
  if (
196
- Check(Route, value) &&
201
+ routeValidator.check(value) &&
197
202
  value.plan.controllerSessionId === identity.threadId
198
203
  )
199
204
  routes.set(`${value.machine}\0${value.sessionFile}`, value);
@@ -232,10 +237,11 @@ async function readSharedSession(
232
237
  }
233
238
  const owner = records(session, "shepherdr-attachment-owner").findLast(
234
239
  (value) =>
235
- Check(Plan, value) && value.targetSessionId === identity.threadId,
240
+ planValidator.check(value) &&
241
+ value.targetSessionId === identity.threadId,
236
242
  );
237
243
  if (
238
- Check(Plan, owner) &&
244
+ planValidator.check(owner) &&
239
245
  owner.context &&
240
246
  (inside(destination, owner.context.controllerAlias) ||
241
247
  destination === canonicalAgentName(owner.context.controller.threadId))
@@ -253,9 +259,10 @@ async function readSharedSession(
253
259
  "shepherdr-attachment-detached",
254
260
  ).findLast(
255
261
  (value) =>
256
- Check(Detachment, value) && isDeepStrictEqual(value.plan, owner),
262
+ detachmentValidator.check(value) &&
263
+ isDeepStrictEqual(value.plan, owner),
257
264
  );
258
- const snapshot = Check(Detachment, detached)
265
+ const snapshot = detachmentValidator.check(detached)
259
266
  ? detached.context
260
267
  : undefined;
261
268
  return reference(
@@ -289,15 +296,16 @@ async function readSharedSession(
289
296
  let result: Record<string, unknown> | undefined;
290
297
  const members = records(session, "herdr-context-child").filter(
291
298
  (value) =>
292
- Check(Member, value) &&
299
+ memberValidator.check(value) &&
293
300
  value.threadId === identity.threadId &&
294
301
  value.sessionId === identity.sessionId,
295
302
  );
296
303
  const direct = members.filter(
297
- (member) => Check(Member, member) && member.agentName === destination,
304
+ (member) =>
305
+ memberValidator.check(member) && member.agentName === destination,
298
306
  );
299
307
  for (const member of direct.length ? direct : members) {
300
- if (!Check(Member, member)) continue;
308
+ if (!memberValidator.check(member)) continue;
301
309
  const location = locator(session, member.machine, member.sessionFile);
302
310
  // Only exploratory edges may be skipped. A recorded target must report its failure.
303
311
  const saved = await (direct.length
@@ -326,7 +334,7 @@ async function readSharedSession(
326
334
  if (direct.length) return result;
327
335
  const routing = identity.routing;
328
336
  const suffix = ".jsonl.shepherdr-context.json";
329
- if (Check(Parent, routing)) {
337
+ if (parentValidator.check(routing)) {
330
338
  const parentLocator = routing.savedParent
331
339
  ? locator(
332
340
  session,
@@ -1,5 +1,5 @@
1
1
  import type { SessionEntry } from "@earendil-works/pi-coding-agent";
2
- import { Check } from "typebox/value";
2
+ import { compile } from "@earendil-works/pi-schema";
3
3
  import { minuteTimestamp } from "../timestamps.js";
4
4
  import { contextStorageAgentName } from "./agent-identity.js";
5
5
  import type { SavedSessionLocator } from "./context-sharing.js";
@@ -16,6 +16,8 @@ import {
16
16
  } from "./saved-sharing-records.js";
17
17
  import type { NotesStore } from "./store.js";
18
18
 
19
+ const snapshotValidator = compile(Snapshot);
20
+
19
21
  export function createSharedSessionReader(
20
22
  store: Pick<NotesStore, "read">,
21
23
  access:
@@ -108,7 +110,7 @@ export function createSharedSessionReader(
108
110
  namespace === "history" ||
109
111
  (destination !== identity.agentName &&
110
112
  destination !== contextStorageAgentName(identity)) ||
111
- !Check(Snapshot, retained)
113
+ !snapshotValidator.check(retained)
112
114
  )
113
115
  return;
114
116
  const entry: SessionEntry = {
@@ -1,7 +1,17 @@
1
- import { StringEnum } from "@earendil-works/pi-ai";
2
1
  import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
3
- import { Type } from "typebox";
4
- import { Check } from "typebox/value";
2
+ import {
3
+ bool,
4
+ compile,
5
+ int,
6
+ nul,
7
+ obj,
8
+ oneOf,
9
+ opt,
10
+ type Schema,
11
+ str,
12
+ union,
13
+ type Validator,
14
+ } from "@earendil-works/pi-schema";
5
15
  import type { LookupQuery } from "./bridge.js";
6
16
  import { noteResult } from "./note-result.js";
7
17
  import { internalQueryArguments, normalizeQueryInput } from "./query-input.js";
@@ -29,14 +39,14 @@ export const NOTES_ROUTING_GUIDELINE =
29
39
  export const NEW_CONTEXT_DESCRIPTION =
30
40
  "Start fresh context window. MUST save notes before calling";
31
41
  export const GPT_NEW_CONTEXT_DESCRIPTION = "Save notes→fresh context";
32
- const STRING = Type.Optional(Type.String());
33
- const INTEGER = Type.Optional(Type.Integer({ minimum: 1 }));
34
- const LINE = Type.Optional(Type.Union([Type.Integer(), Type.Null()]));
35
- export const NOTES_SCHEMA = Type.Object(
42
+ const STRING = opt(str());
43
+ const INTEGER = opt(int({ minimum: 1 }));
44
+ const LINE = opt(union([int(), nul()]));
45
+ export const NOTES_SCHEMA = obj(
36
46
  {
37
- action: Type.Optional(StringEnum(NOTES_ACTIONS)),
38
- path: Type.Optional(
39
- Type.Union([Type.String(), Type.Null()], {
47
+ action: opt({ ...oneOf(NOTES_ACTIONS), type: "string" }),
48
+ path: opt(
49
+ union([str(), nul()], {
40
50
  description:
41
51
  "File for read/write/append; prefix for list/search; virtual filesystem, not files in the project",
42
52
  }),
@@ -47,49 +57,52 @@ export const NOTES_SCHEMA = Type.Object(
47
57
  stop_line: LINE,
48
58
  limit: INTEGER,
49
59
  max_matches_per_file: INTEGER,
50
- file_order: Type.Optional(StringEnum(["ascending", "descending"])),
51
- file_order_by: Type.Optional(
52
- StringEnum(["name", "created_at", "updated_at"]),
53
- ),
54
- recent_file_first: Type.Optional(Type.Boolean()),
60
+ file_order: opt({ ...oneOf(["ascending", "descending"]), type: "string" }),
61
+ file_order_by: opt({
62
+ ...oneOf(["name", "created_at", "updated_at"]),
63
+ type: "string",
64
+ }),
65
+ recent_file_first: opt(bool()),
55
66
  },
56
- { additionalProperties: false },
67
+ { open: false },
57
68
  );
58
- const NEW_CONTEXT_SCHEMA = Type.Object(
69
+ const NEW_CONTEXT_SCHEMA = obj(
59
70
  {
60
- role: Type.Optional(
61
- Type.String({
71
+ role: opt(
72
+ str({
62
73
  minLength: 1,
63
74
  description:
64
75
  "Configured model-role ID, not an agent name or handoff text",
65
76
  }),
66
77
  ),
67
78
  },
68
- { additionalProperties: false },
79
+ { open: false },
69
80
  );
70
81
 
82
+ const newContextSchemaValidator = compile(NEW_CONTEXT_SCHEMA);
83
+
71
84
  export function newContextSchema(roleIds: string[]) {
72
- return Type.Object(
73
- roleIds.length ? { role: Type.Optional(StringEnum(roleIds)) } : {},
74
- { additionalProperties: false },
85
+ return obj(
86
+ roleIds.length ? { role: opt({ ...oneOf(roleIds), type: "string" }) } : {},
87
+ { open: false },
75
88
  );
76
89
  }
77
90
 
78
91
  export function prepareNewContextArguments(input: unknown) {
79
92
  const args = input ?? {};
80
- if (!Check(NEW_CONTEXT_SCHEMA, args))
93
+ if (!newContextSchemaValidator.check(args))
81
94
  throw new Error(
82
95
  'Use {} to keep the current model, or {role: "name"} for a configured role.',
83
96
  );
84
97
  return args;
85
98
  }
86
- export const HISTORY_SCHEMA = Type.Object(
99
+ export const HISTORY_SCHEMA = obj(
87
100
  {
88
- action: Type.Optional(StringEnum(HISTORY_ACTIONS)),
89
- agent_name: Type.Optional(Type.Union([Type.String(), Type.Null()])),
90
- item_id: Type.Optional(Type.String()),
91
- window_id: Type.Optional(
92
- Type.Union([Type.String(), Type.Null()], {
101
+ action: opt({ ...oneOf(HISTORY_ACTIONS), type: "string" }),
102
+ agent_name: opt(union([str(), nul()])),
103
+ item_id: opt(str()),
104
+ window_id: opt(
105
+ union([str(), nul()], {
93
106
  description: "Required with item_id for read",
94
107
  }),
95
108
  ),
@@ -97,18 +110,21 @@ export const HISTORY_SCHEMA = Type.Object(
97
110
  limit: INTEGER,
98
111
  limit_chars: INTEGER,
99
112
  max_chars_per_item: INTEGER,
100
- offset_chars: Type.Optional(Type.Integer({ minimum: 0 })),
101
- recent_first: Type.Optional(Type.Boolean()),
102
- role: Type.Optional(
103
- Type.Union([
104
- StringEnum(["user", "assistant", "tool", "system", "developer"]),
105
- Type.Null(),
113
+ offset_chars: opt(int({ minimum: 0 })),
114
+ recent_first: opt(bool()),
115
+ role: opt(
116
+ union([
117
+ {
118
+ ...oneOf(["user", "assistant", "tool", "system", "developer"]),
119
+ type: "string",
120
+ },
121
+ nul(),
106
122
  ]),
107
123
  ),
108
- tool_name: Type.Optional(Type.Union([Type.String(), Type.Null()])),
109
- tool_namespace: Type.Optional(Type.Union([Type.String(), Type.Null()])),
124
+ tool_name: opt(union([str(), nul()])),
125
+ tool_namespace: opt(union([str(), nul()])),
110
126
  },
111
- { additionalProperties: false },
127
+ { open: false },
112
128
  );
113
129
 
114
130
  const FIELDS: Record<string, readonly string[]> = {
@@ -272,25 +288,36 @@ export function queryHelp(
272
288
 
273
289
  export function prepareNotesArguments(args: unknown) {
274
290
  const params = normalizeQueryInput("notes", args);
275
- validateArguments("notes", params, NOTES_SCHEMA);
291
+ validateArguments("notes", params, NOTES_FIELD_VALIDATORS);
276
292
  return params;
277
293
  }
278
294
 
279
295
  export function prepareHistoryArguments(args: unknown) {
280
296
  const params = normalizeQueryInput("history", args);
281
- validateArguments("history", params, HISTORY_SCHEMA);
297
+ validateArguments("history", params, HISTORY_FIELD_VALIDATORS);
282
298
  return params;
283
299
  }
284
300
 
301
+ const NOTES_FIELD_VALIDATORS = fieldValidators(NOTES_SCHEMA);
302
+ const HISTORY_FIELD_VALIDATORS = fieldValidators(HISTORY_SCHEMA);
303
+
304
+ function fieldValidators(schema: Schema): Record<string, Validator> {
305
+ return Object.fromEntries(
306
+ Object.entries(schema["properties"] as Record<string, Schema>).map(
307
+ ([field, property]) => [field, compile(property)],
308
+ ),
309
+ );
310
+ }
311
+
285
312
  function validateArguments(
286
313
  namespace: LookupQuery["namespace"],
287
314
  params: Record<string, unknown>,
288
- schema: import("typebox").TObject,
315
+ validators: Record<string, Validator>,
289
316
  ) {
290
317
  if (!queryHelp(namespace, params)) queryArguments(namespace, params);
291
318
  for (const [field, value] of Object.entries(params)) {
292
- const property = schema.properties[field];
293
- if (!property || !Check(property, value))
319
+ const validator = validators[field];
320
+ if (!validator || !validator.check(value))
294
321
  throw new Error(
295
322
  `Invalid ${namespace} ${field}; use {} for exact arguments`,
296
323
  );
@@ -4,7 +4,7 @@ import type {
4
4
  ExtensionContext,
5
5
  ToolDefinition,
6
6
  } from "@earendil-works/pi-coding-agent";
7
- import { Type } from "typebox";
7
+ import { obj } from "@earendil-works/pi-schema";
8
8
  import type { LookupQuery, SharedNotesDetails } from "./bridge.js";
9
9
  import type { HistorySearch } from "./history-search.js";
10
10
  import type { NotesLifecycle } from "./lifecycle.js";
@@ -123,7 +123,7 @@ export function createTools(
123
123
  name: "get_context_remaining",
124
124
  label: "get_context_remaining",
125
125
  description: "Remaining context tokens",
126
- parameters: Type.Object({}, { additionalProperties: false }),
126
+ parameters: obj({}, { open: false }),
127
127
  async execute(_id, _input, _signal, _update, ctx) {
128
128
  assertActive();
129
129
  const remaining = lifecycle.windows.remaining(ctx);
@@ -4,45 +4,60 @@ import {
4
4
  buildSessionProjection,
5
5
  type SessionEntry,
6
6
  } from "@earendil-works/pi-coding-agent";
7
- import { Type } from "typebox";
8
- import { Check } from "typebox/value";
7
+ import {
8
+ arr,
9
+ compile,
10
+ lit,
11
+ num,
12
+ obj,
13
+ opt,
14
+ str,
15
+ union,
16
+ unknown,
17
+ unsafe,
18
+ } from "@earendil-works/pi-schema";
9
19
 
10
20
  const READ_KEY = "codexContextNoteRead";
11
- const READ_SCHEMA = Type.Object(
21
+ const READ_SCHEMA = obj(
12
22
  {
13
- protocol: Type.Literal(1),
14
- origin: Type.Literal("host"),
15
- id: Type.String({ pattern: "^[a-f0-9-]{36}$" }),
16
- path: Type.String({ minLength: 1 }),
17
- namespace: Type.Optional(Type.Literal("notes")),
18
- api: Type.String({ minLength: 1 }),
19
- provider: Type.String({ minLength: 1 }),
20
- model: Type.String({ minLength: 1 }),
21
- timestamp: Type.Number({ minimum: 0 }),
22
- content: Type.Array(
23
- Type.Union([
24
- Type.Object({ type: Type.Literal("text"), text: Type.String() }),
25
- Type.Object({
26
- type: Type.Literal("image"),
27
- data: Type.String(),
28
- mimeType: Type.String(),
29
- detail: Type.Optional(
30
- Type.Union([
31
- Type.Literal("auto"),
32
- Type.Literal("high"),
33
- Type.Literal("original"),
34
- ]),
35
- ),
36
- }),
23
+ protocol: lit(1),
24
+ origin: lit("host"),
25
+ id: str({ pattern: "^[a-f0-9-]{36}$" }),
26
+ path: str({ minLength: 1 }),
27
+ namespace: opt(lit("notes")),
28
+ api: str({ minLength: 1 }),
29
+ provider: str({ minLength: 1 }),
30
+ model: str({ minLength: 1 }),
31
+ timestamp: num({ minimum: 0 }),
32
+ content: arr(
33
+ union([
34
+ obj({ type: lit("text"), text: str() }, { open: true }),
35
+ obj(
36
+ {
37
+ type: lit("image"),
38
+ data: str(),
39
+ mimeType: str(),
40
+ detail: opt(union([lit("auto"), lit("high"), lit("original")])),
41
+ },
42
+ { open: true },
43
+ ),
37
44
  ]),
38
45
  ),
39
- details: Type.Object({
40
- codexHistoryNotes: Type.Record(Type.String(), Type.Unknown()),
41
- }),
46
+ details: obj(
47
+ {
48
+ codexHistoryNotes: unsafe<Record<string, unknown>>({
49
+ type: "object",
50
+ patternProperties: { "^.*$": unknown() },
51
+ }),
52
+ },
53
+ { open: true },
54
+ ),
42
55
  },
43
- { additionalProperties: false },
56
+ { open: false },
44
57
  );
45
58
 
59
+ const readSchemaValidator = compile(READ_SCHEMA);
60
+
46
61
  function callId(id: string): string {
47
62
  const name = "tree_handoff_" + id.replaceAll("-", "");
48
63
  return `${name}|fc_${name}`;
@@ -95,7 +110,7 @@ export function projectTreeHandoffReads(
95
110
  if (!details || typeof details !== "object" || !(READ_KEY in details))
96
111
  return [message];
97
112
  const read = details[READ_KEY];
98
- if (!Check(READ_SCHEMA, read))
113
+ if (!readSchemaValidator.check(read))
99
114
  throw new Error("Invalid persisted tree handoff read");
100
115
  const resultDetails = read.details;
101
116
  if (!isJson(resultDetails))
@@ -15,31 +15,19 @@ export interface WindowDetails {
15
15
  trim: boolean;
16
16
  }
17
17
  const GUIDANCE = `<context_window_guidance>
18
- Notes are recovery state, not diary. Storage is virtual, not disk. Create relative paths.
18
+ Notes are short virtual resume points, not working memory. Use task notes and/or checkpoints as needed. Reuse existing notes and avoid duplicating state. Use relative paths. Keep only current goal, task-specific constraints or exceptions, decision/status, next action and evidence/history links. Keep reasoning and intermediate results in context. Omit harness instructions, tool usage and skill-read bookkeeping.
19
19
 
20
- MUST maintain one authoritative checkpoint per task/topic: request, constraints, decision, status, next steps and relevant history IDs.
20
+ Write less: consolidate changed recovery state at substantive turn end, before replying. Skip routine turns and unchanged state unless explicit reminders or earlier handoffs require a save. If a no-action report needs recording, add only its run/report ID and "no owned action". Keep current state first; replace superseded status. Append only while existing state remains accurate. Use history on demand for older decisions and evidence instead of copying them into notes.
21
21
 
22
- Near a substantive turn's end, before replying, consolidate changed recovery state. notes write creates or replaces; append adds. Do not interleave saves with ordinary tool calls. Skip routine turns and unchanged state. Explicit reminders and earlier handoffs still apply.
23
-
24
- Link existing notes rather than duplicate. Recording does not authorise implementation.
25
-
26
- Immediately before new_context, MUST save the checkpoint via notes. Save before handoff too. For rollover, call new_context after saving.
27
-
28
- When recovering context, read the checkpoint and necessary links if available, then retrieve a few relevant user messages with history for intent and communication preferences. Past messages are context, not renewed requests. Current instructions take precedence. Resume the current task; read further history only as needed. Do not reread unchanged notes.
29
-
30
- MUST reread required skills after rollover.
22
+ Save relevant notes before handoff and immediately before new_context. On recovery, read relevant notes, necessary links and a few relevant user messages with history, then resume the current task. Past messages are context, not renewed requests; current instructions win. Avoid unchanged rereads. Reread required skills after rollover. Recording does not authorise implementation.
31
23
  </context_window_guidance>`;
32
24
 
33
25
  const GPT_GUIDANCE = `<context_window_guidance>
34
- Notes=virtual recovery state, NOT disk/diary. Create relative paths. MUST maintain one authoritative checkpoint/task→request/constraints/decision/status/next steps/history IDs. Link existing notes≠duplicate; recording≠implementation permission.
35
-
36
- Near substantive turn end, before reply→consolidate CHANGED recovery. notes write→create/replace; append→add. No saves amid ordinary tool calls; skip routine/unchanged state. Explicit reminders/earlier handoffs still apply.
37
-
38
- Immediately before new_context MUST save checkpoint via notes; before handoff too. Rollover→new_context after save.
26
+ Notes=short virtual resume points, not working memory. Relative paths; task notes and/or checkpoints as needed. Reuse existing notes; avoid duplicate state. Keep only current goal, task constraints/exceptions, decision/status, next action, evidence/history links. Reasoning/intermediate results stay in context. Omit harness/tool instructions and skill-read state.
39
27
 
40
- Context recovery→notes checkpoint/necessary links if available→a few relevant user messages via history for intent/communication preferences→resume current task. Past messages=context≠renewed requests; current instructions win. Further history as needed; no unchanged-note rereads.
28
+ Fewer writes→consolidate changed recovery at substantive turn end BEFORE reply; skip routine/unchanged turns unless explicit reminders/earlier handoffs require saving. No-action report + save needed→add only run/report ID + "no owned action". Current first; replace superseded status. Append only while prior state stays accurate. History→older decisions/evidence on demand, not copied into notes.
41
29
 
42
- After rollover MUST reread required skills.
30
+ Save relevant notes before handoff/immediately before new_context. Recovery→relevant notes, necessary links, a few relevant user messages via history→resume current task. Past messages≠renewed requests; current instructions win. No unchanged rereads. Reread required skills after rollover. Recording≠implementation permission.
43
31
  </context_window_guidance>`;
44
32
 
45
33
  export function registerWindowRenderer(pi: ExtensionAPI): void {