notesoup 0.50.0 → 0.51.1

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 (172) hide show
  1. package/README.md +12 -1
  2. package/dist/{src/claude → plugins/claude/src}/helper.js +7 -7
  3. package/dist/{src/claude → plugins/claude/src}/history.d.ts +1 -1
  4. package/dist/{src/claude → plugins/claude/src}/history.js +1 -1
  5. package/dist/plugins/claude/src/text.d.ts +6 -0
  6. package/dist/plugins/claude/src/text.js +7 -0
  7. package/dist/{src/claude → plugins/claude/src}/thresholds.js +3 -3
  8. package/dist/{src → plugins}/dsh/budget.js +1 -1
  9. package/dist/{src → plugins}/dsh/engine.d.ts +1 -1
  10. package/dist/{src → plugins}/dsh/engine.js +1 -1
  11. package/dist/{src → plugins}/dsh/history.d.ts +1 -1
  12. package/dist/{src → plugins}/dsh/history.js +1 -1
  13. package/dist/{src → plugins}/dsh/index.js +1 -1
  14. package/dist/{src → plugins}/dsh/tools.js +3 -3
  15. package/dist/{src → plugins}/dsh/window.d.ts +1 -1
  16. package/dist/{src → plugins}/dsh/window.js +5 -5
  17. package/dist/{src → plugins}/pi/boot.d.ts +1 -1
  18. package/dist/{src → plugins}/pi/boot.js +5 -4
  19. package/dist/{src → plugins}/pi/budget.js +4 -4
  20. package/dist/{src → plugins}/pi/dream/cli.d.ts +1 -1
  21. package/dist/{src → plugins}/pi/dream/cli.js +6 -6
  22. package/dist/{src → plugins}/pi/dream/runner.d.ts +1 -1
  23. package/dist/{src → plugins}/pi/dream/runner.js +3 -3
  24. package/dist/{src → plugins}/pi/dream/settings.d.ts +1 -1
  25. package/dist/{src → plugins}/pi/dream/settings.js +2 -2
  26. package/dist/{src → plugins}/pi/history-tools.js +1 -1
  27. package/dist/{src → plugins}/pi/history.d.ts +1 -1
  28. package/dist/{src → plugins}/pi/history.js +1 -1
  29. package/dist/plugins/pi/index.d.ts +1 -0
  30. package/dist/plugins/pi/index.js +1 -0
  31. package/dist/{src → plugins}/pi/notes/adapter.d.ts +1 -1
  32. package/dist/{src → plugins}/pi/notes/adapter.js +1 -1
  33. package/dist/{src → plugins}/pi/notes/tools.js +1 -1
  34. package/dist/{src → plugins}/pi/reset/artifacts.d.ts +1 -1
  35. package/dist/{src → plugins}/pi/reset/artifacts.js +1 -1
  36. package/dist/{src → plugins}/pi/reset/lifecycle.d.ts +1 -1
  37. package/dist/{src → plugins}/pi/reset/lifecycle.js +1 -1
  38. package/dist/{src → plugins}/pi/runtime.js +2 -2
  39. package/dist/plugins/pi/text.d.ts +23 -0
  40. package/dist/plugins/pi/text.js +30 -0
  41. package/dist/{src → plugins}/pi/thresholds.d.ts +1 -1
  42. package/dist/{src → plugins}/pi/thresholds.js +4 -4
  43. package/dist/{src → plugins}/pi/tool-result.d.ts +1 -1
  44. package/dist/{src → plugins}/pi/tool-result.js +1 -1
  45. package/dist/{src → plugins}/pi/window.d.ts +1 -1
  46. package/dist/src/boot/text.d.ts +4 -13
  47. package/dist/src/boot/text.js +1 -11
  48. package/dist/src/budget/policy.d.ts +2 -3
  49. package/dist/src/budget/policy.js +1 -1
  50. package/dist/src/budget/text.d.ts +1 -12
  51. package/dist/src/budget/text.js +2 -24
  52. package/dist/src/dream/settings.d.ts +1 -2
  53. package/dist/src/dream/settings.js +4 -2
  54. package/dist/src/index.d.ts +29 -1
  55. package/dist/src/index.js +26 -1
  56. package/dist/src/notes/address.d.ts +5 -4
  57. package/dist/src/notes/address.js +13 -7
  58. package/dist/src/notes/identity.js +3 -7
  59. package/dist/src/notes/paths.d.ts +4 -2
  60. package/dist/src/notes/paths.js +11 -6
  61. package/dist/src/notes/store.d.ts +4 -1
  62. package/dist/src/notes/store.js +66 -34
  63. package/dist/src/settings.d.ts +7 -16
  64. package/dist/src/settings.js +7 -10
  65. package/dist/src/tools/notes.d.ts +5 -5
  66. package/dist/src/tools/notes.js +5 -4
  67. package/dist/test/agent-loop.test.js +5 -4
  68. package/dist/test/boot.integration.test.js +5 -5
  69. package/dist/test/budget-settings.integration.test.js +1 -1
  70. package/dist/test/claude-history.test.js +2 -2
  71. package/dist/test/claude-mod.test.js +12 -11
  72. package/dist/test/claude-validation.test.js +3 -3
  73. package/dist/test/dependencies.test.js +52 -44
  74. package/dist/test/doctor.test.js +1 -1
  75. package/dist/test/dream-skill.test.js +4 -4
  76. package/dist/test/dream.test.js +2 -2
  77. package/dist/test/dsh-cli.test.js +2 -2
  78. package/dist/test/dsh-compaction-parity.test.js +1 -1
  79. package/dist/test/dsh.test.js +4 -4
  80. package/dist/test/helpers/dependency-graph.js +9 -7
  81. package/dist/test/helpers/dsh.d.ts +1 -1
  82. package/dist/test/helpers/dsh.js +2 -2
  83. package/dist/test/helpers/extension.js +6 -5
  84. package/dist/test/helpers/notes.js +1 -1
  85. package/dist/test/model-facing-text.test.js +4 -2
  86. package/dist/test/notes-query-homes.test.d.ts +1 -0
  87. package/dist/test/notes-query-homes.test.js +161 -0
  88. package/dist/test/notes.integration.test.js +3 -2
  89. package/dist/test/notes.test.js +1 -1
  90. package/dist/test/reset-lifecycle.test.js +8 -7
  91. package/docs/architecture.md +21 -18
  92. package/docs/claude-code-mod.md +3 -3
  93. package/docs/dsh.md +1 -1
  94. package/docs/dsh.profile.patch.yml +1 -1
  95. package/docs/notes-library.md +17 -10
  96. package/docs/reset-lifecycle.md +1 -1
  97. package/package.json +13 -13
  98. package/{mods/notesoup → plugins/claude}/.claude-plugin/plugin.json +1 -1
  99. package/{mods/notesoup → plugins/claude}/dist/claude/helper.js +80 -55
  100. package/{mods/notesoup → plugins/claude}/skills/memory/SKILL.md +3 -0
  101. package/{src/claude → plugins/claude/src}/helper.ts +10 -9
  102. package/{src/claude → plugins/claude/src}/history.ts +1 -1
  103. package/plugins/claude/src/text.ts +10 -0
  104. package/{src/claude → plugins/claude/src}/thresholds.ts +3 -3
  105. package/{src → plugins}/dsh/budget.ts +1 -1
  106. package/{src → plugins}/dsh/engine.ts +1 -1
  107. package/{src → plugins}/dsh/history.ts +1 -1
  108. package/{src → plugins}/dsh/index.ts +1 -1
  109. package/{src → plugins}/dsh/tools.ts +3 -3
  110. package/{src → plugins}/dsh/window.ts +5 -5
  111. package/{src → plugins}/pi/boot.ts +5 -4
  112. package/{src → plugins}/pi/budget.ts +4 -4
  113. package/{src → plugins}/pi/dream/cli.ts +8 -8
  114. package/{src → plugins}/pi/dream/runner.ts +4 -4
  115. package/{src → plugins}/pi/dream/settings.ts +2 -2
  116. package/{src → plugins}/pi/history-tools.ts +1 -1
  117. package/{src → plugins}/pi/history.ts +1 -1
  118. package/plugins/pi/index.ts +1 -0
  119. package/{src → plugins}/pi/notes/adapter.ts +1 -1
  120. package/{src → plugins}/pi/notes/tools.ts +2 -2
  121. package/{src → plugins}/pi/reset/artifacts.ts +1 -1
  122. package/{src → plugins}/pi/reset/lifecycle.ts +2 -2
  123. package/{src → plugins}/pi/runtime.ts +2 -2
  124. package/plugins/pi/text.ts +35 -0
  125. package/{src → plugins}/pi/thresholds.ts +4 -4
  126. package/{src → plugins}/pi/tool-result.ts +1 -1
  127. package/{src → plugins}/pi/window.ts +1 -1
  128. package/skills/memory/SKILL.md +3 -0
  129. package/src/boot/text.ts +5 -15
  130. package/src/budget/policy.ts +3 -3
  131. package/src/budget/text.ts +2 -30
  132. package/src/dream/settings.ts +6 -3
  133. package/src/index.ts +52 -1
  134. package/src/notes/address.ts +12 -8
  135. package/src/notes/identity.ts +2 -8
  136. package/src/notes/paths.ts +12 -6
  137. package/src/notes/store.ts +62 -29
  138. package/src/settings.ts +8 -24
  139. package/src/tools/notes.ts +5 -4
  140. package/docs/sdk-integration.md +0 -39
  141. /package/dist/{src/claude → plugins/claude/src}/helper.d.ts +0 -0
  142. /package/dist/{src/claude → plugins/claude/src}/thresholds.d.ts +0 -0
  143. /package/dist/{src → plugins}/dsh/budget.d.ts +0 -0
  144. /package/dist/{src → plugins}/dsh/index.d.ts +0 -0
  145. /package/dist/{src → plugins}/dsh/tools.d.ts +0 -0
  146. /package/dist/{src → plugins}/pi/anchored.d.ts +0 -0
  147. /package/dist/{src → plugins}/pi/anchored.js +0 -0
  148. /package/dist/{src → plugins}/pi/budget.d.ts +0 -0
  149. /package/dist/{src → plugins}/pi/entries.d.ts +0 -0
  150. /package/dist/{src → plugins}/pi/entries.js +0 -0
  151. /package/dist/{src → plugins}/pi/estimate.d.ts +0 -0
  152. /package/dist/{src → plugins}/pi/estimate.js +0 -0
  153. /package/dist/{src → plugins}/pi/extension.d.ts +0 -0
  154. /package/dist/{src → plugins}/pi/extension.js +0 -0
  155. /package/dist/{src → plugins}/pi/history-tools.d.ts +0 -0
  156. /package/dist/{src → plugins}/pi/notes/tools.d.ts +0 -0
  157. /package/dist/{src → plugins}/pi/reset/committed.d.ts +0 -0
  158. /package/dist/{src → plugins}/pi/reset/committed.js +0 -0
  159. /package/dist/{src → plugins}/pi/runtime.d.ts +0 -0
  160. /package/dist/{src → plugins}/pi/session-reader.d.ts +0 -0
  161. /package/dist/{src → plugins}/pi/session-reader.js +0 -0
  162. /package/dist/{src → plugins}/pi/window.js +0 -0
  163. /package/{mods/notesoup → plugins/claude}/hooks/hooks.json +0 -0
  164. /package/{mods/notesoup → plugins/claude}/hooks/register.ts +0 -0
  165. /package/{mods/notesoup → plugins/claude}/playbook.md +0 -0
  166. /package/{mods/notesoup → plugins/claude}/skills/dream/SKILL.md +0 -0
  167. /package/{src → plugins}/pi/anchored.ts +0 -0
  168. /package/{src → plugins}/pi/entries.ts +0 -0
  169. /package/{src → plugins}/pi/estimate.ts +0 -0
  170. /package/{src → plugins}/pi/extension.ts +0 -0
  171. /package/{src → plugins}/pi/reset/committed.ts +0 -0
  172. /package/{src → plugins}/pi/session-reader.ts +0 -0
@@ -4,7 +4,7 @@ var __export = (target, all) => {
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
5
5
  };
6
6
 
7
- // src/claude/helper.ts
7
+ // plugins/claude/src/helper.ts
8
8
  import { realpathSync as realpathSync2 } from "node:fs";
9
9
  import { pathToFileURL } from "node:url";
10
10
 
@@ -8012,6 +8012,9 @@ function shown(value) {
8012
8012
  import { readdir } from "node:fs/promises";
8013
8013
  import { join } from "node:path";
8014
8014
  var SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
8015
+ function isSessionId(value) {
8016
+ return value.length > 0 && value !== "." && value !== ".." && !/[\\/\0:]/.test(value);
8017
+ }
8015
8018
  function slugify(value) {
8016
8019
  const slug = value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
8017
8020
  return slug.length > 0 ? slug : "root";
@@ -8028,16 +8031,17 @@ function sessionHomesRoot(home) {
8028
8031
  }
8029
8032
  function scopeDir(scope, identity2, who) {
8030
8033
  if (!["session", "project", "human", "agent", "model"].includes(scope)) throw new TypeError("invalid notes scope");
8031
- if (who !== void 0 && (scope !== "project" && scope !== "agent" && scope !== "model" || !SLUG_PATTERN.test(who))) throw new TypeError("who must be a canonical project/agent/model slug");
8034
+ if (who !== void 0 && (scope === "session" ? !isSessionId(who) : scope === "human" || !SLUG_PATTERN.test(who))) throw new TypeError("who must be a session directory component or canonical project/agent/model slug");
8032
8035
  if (scope === "human") return join(identity2.home, "human");
8033
8036
  if (scope === "project") return join(identity2.home, "project", who ?? identity2.projectKey);
8034
8037
  if (scope === "agent") return join(identity2.home, "agents", who ?? identity2.agent);
8035
8038
  if (scope === "model") return join(identity2.home, "models", who ?? identity2.model);
8036
- return join(sessionHomesRoot(identity2.home), identity2.sessionId);
8039
+ return join(sessionHomesRoot(identity2.home), who ?? identity2.sessionId);
8037
8040
  }
8038
8041
  async function namespaceSlugs(namespace, home) {
8042
+ const root = namespace === "sessions" ? sessionHomesRoot(home) : join(home, namespace);
8039
8043
  try {
8040
- return (await readdir(join(home, namespace), { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
8044
+ return (await readdir(root, { withFileTypes: true })).filter((entry) => entry.isDirectory() && (namespace === "sessions" ? isSessionId(entry.name) : SLUG_PATTERN.test(entry.name))).map((entry) => entry.name).sort();
8041
8045
  } catch (error) {
8042
8046
  if (error.code === "ENOENT") return [];
8043
8047
  throw error;
@@ -8051,12 +8055,13 @@ function physicalPath(scope, vpath, identity2, who) {
8051
8055
  }
8052
8056
 
8053
8057
  // src/notes/address.ts
8054
- var ADDRESS_FORMS = "Use <path> for this session, or @project/, @human/, @self/, or @model/ followed by a path; @projects/<name>/<path> reads a named project home.";
8058
+ var ADDRESS_FORMS = "Use <path> for this session, or @project/, @human/, @self/, or @model/ followed by a path; @projects/<name>/<path> and @sessions/<id>/<path> read named homes.";
8055
8059
  var HOME_HEADS = /* @__PURE__ */ new Map([
8056
8060
  ["project", { scope: "project" }],
8057
8061
  ["human", { scope: "human" }],
8058
8062
  ["self", { scope: "agent" }],
8059
8063
  ["model", { scope: "model" }],
8064
+ ["sessions", { scope: "session", home: "sessions" }],
8060
8065
  ["projects", { scope: "project", home: "project" }],
8061
8066
  ["agents", { scope: "agent", home: "agents" }],
8062
8067
  ["models", { scope: "model", home: "models" }]
@@ -8100,7 +8105,7 @@ function assertAddress(value) {
8100
8105
  if (head.home === void 0) path = tail.join("/");
8101
8106
  else {
8102
8107
  who = tail[0] ?? "";
8103
- if (!SLUG_PATTERN.test(who)) throw new NoteError("invalid_address", `${shown(value)} isn't a note address. ${ADDRESS_FORMS}`);
8108
+ if (!(scope === "session" ? isSessionId(who) : SLUG_PATTERN.test(who))) throw new NoteError("invalid_address", `${shown(value)} isn't a note address. ${ADDRESS_FORMS}`);
8104
8109
  path = tail.slice(1).join("/");
8105
8110
  }
8106
8111
  if (path === "" && scope !== "agent" && scope !== "model") throw new NoteError("invalid_address", `${shown(value)} isn't a note address. ${ADDRESS_FORMS}`);
@@ -8110,13 +8115,15 @@ function assertAddress(value) {
8110
8115
  return { scope, path, who };
8111
8116
  }
8112
8117
  function canonicalAddressFor(identity2, scope, path, who) {
8113
- if (scope === "session") return path;
8114
- if (scope === "project") return who === void 0 ? `@project/${path}` : `@projects/${who}/${path}`;
8118
+ if (scope === "session") return `@sessions/${who ?? identity2.sessionId}/${path}`;
8119
+ if (scope === "project") return `@projects/${who ?? identity2.projectKey}/${path}`;
8115
8120
  if (scope === "human") return `@human/${path}`;
8116
8121
  if (scope === "agent") return `@agents/${who ?? identity2.agent}/${path}`;
8117
8122
  return `@models/${who ?? identity2.model}/${path}`;
8118
8123
  }
8119
8124
  function addressFor(identity2, scope, path, who) {
8125
+ if (scope === "session" && who === void 0) return path;
8126
+ if (scope === "project" && who === void 0) return `@project/${path}`;
8120
8127
  if (scope === "agent" && (who === void 0 || who === identity2.agent)) return `@self/${path}`;
8121
8128
  if (scope === "model" && (who === void 0 || who === identity2.model)) return `@model/${path}`;
8122
8129
  return canonicalAddressFor(identity2, scope, path, who);
@@ -8128,11 +8135,6 @@ function requireString(field, value) {
8128
8135
  if (typeof value !== "string" || value.length === 0) throw new TypeError(`notes context ${field} must be a non-empty string`);
8129
8136
  return value;
8130
8137
  }
8131
- function assertDirectoryComponent(field, value) {
8132
- if (value === "." || value === ".." || /[\\/\0:]/.test(value)) {
8133
- throw new TypeError(`notes context ${field} must be a safe single directory component`);
8134
- }
8135
- }
8136
8138
  function snapshotNotesIdentity(value) {
8137
8139
  if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError("notes context must be a plain object");
8138
8140
  const homeValue = requireString("home", value.home);
@@ -8140,7 +8142,7 @@ function snapshotNotesIdentity(value) {
8140
8142
  const projectKey2 = requireString("projectKey", value.projectKey);
8141
8143
  const agent = requireString("agent", value.agent);
8142
8144
  const model = requireString("model", value.model);
8143
- assertDirectoryComponent("sessionId", sessionId);
8145
+ if (!isSessionId(sessionId)) throw new TypeError("notes context sessionId must be a safe single directory component");
8144
8146
  if (!SLUG_PATTERN.test(projectKey2)) throw new TypeError("notes context projectKey must be a canonical lowercase slug");
8145
8147
  if (!SLUG_PATTERN.test(agent)) throw new TypeError("notes context agent must be a canonical lowercase slug");
8146
8148
  if (!SLUG_PATTERN.test(model)) throw new TypeError("notes context model must be a canonical lowercase slug");
@@ -8399,19 +8401,49 @@ async function walkMarkdown(dir, base = dir) {
8399
8401
  }
8400
8402
  return paths;
8401
8403
  }
8402
- async function homesForPattern(pattern, identity2) {
8403
- if (!pattern || !pattern.startsWith("@")) return void 0;
8404
- const [rawHead, ...tail] = pattern.split("/");
8405
- const head = tail.length === 0 ? void 0 : HOME_HEADS.get(rawHead.slice(1));
8406
- if (head === void 0) return [];
8407
- if (head.home === void 0) return [{ scope: head.scope }];
8408
- const name = tail[0];
8409
- if (name !== void 0 && name.length > 0 && !/[*?]/.test(name)) return [{ scope: head.scope, who: assertWho(name) }];
8410
- const names = head.home === "project" ? projectHomes(identity2.home).map((home) => home.name) : await namespaceSlugs(head.home, identity2.home);
8411
- return names.map((who) => ({ scope: head.scope, who }));
8404
+ async function homesForPattern(pattern, identity2, status) {
8405
+ if (pattern === void 0) return SCOPE_ORDER.map((scope) => ({ scope }));
8406
+ const families = [
8407
+ { scope: "session", home: "sessions", current: identity2.sessionId },
8408
+ { scope: "project", home: "project", current: identity2.projectKey },
8409
+ { scope: "agent", home: "agents", current: identity2.agent },
8410
+ { scope: "model", home: "models", current: identity2.model }
8411
+ ];
8412
+ async function enumerate(family, relative) {
8413
+ let names;
8414
+ try {
8415
+ names = await namespaceSlugs(family.home, identity2.home);
8416
+ } catch (error) {
8417
+ if (!status || !isFilesystemError(error)) throw error;
8418
+ status.homesUnavailable.push(`@${family.home === "project" ? "projects" : family.home}`);
8419
+ return [];
8420
+ }
8421
+ return [.../* @__PURE__ */ new Set([family.current, ...names])].map((who) => ({
8422
+ scope: family.scope,
8423
+ who: relative && who === family.current ? void 0 : who
8424
+ }));
8425
+ }
8426
+ if (pattern.startsWith("@")) {
8427
+ const [rawHead, ...tail] = pattern.slice(1).split("/");
8428
+ if (!/[*?]/.test(rawHead)) {
8429
+ const head = HOME_HEADS.get(rawHead);
8430
+ if (head === void 0 || tail.length === 0) return [];
8431
+ if (head.home === void 0) return [{ scope: head.scope }];
8432
+ const name = tail[0];
8433
+ if (name && !/[*?]/.test(name)) return [{ scope: head.scope, who: assertWho(name, head.scope) }];
8434
+ return enumerate(families.find((family) => family.home === head.home), false);
8435
+ }
8436
+ }
8437
+ const homes = [];
8438
+ for (const scope of SCOPE_ORDER) {
8439
+ if (scope === "human") homes.push({ scope });
8440
+ else homes.push(...await enumerate(families.find((family) => family.scope === scope), true));
8441
+ }
8442
+ return homes;
8412
8443
  }
8413
8444
  function normalizePattern(pattern, identity2) {
8414
8445
  if (!pattern) return pattern;
8446
+ if (pattern.startsWith("@project/")) return `@projects/${identity2.projectKey}/${pattern.slice("@project/".length)}`;
8415
8447
  if (pattern.startsWith("@self/")) return `@agents/${identity2.agent}/${pattern.slice("@self/".length)}`;
8416
8448
  if (pattern.startsWith("@model/")) return `@models/${identity2.model}/${pattern.slice("@model/".length)}`;
8417
8449
  return pattern;
@@ -8420,9 +8452,9 @@ function assertOrigin(value) {
8420
8452
  if (!isOrigin(value)) throw new NoteError("invalid_origin", `origin must be one of user, self, external (got ${JSON.stringify(value)})`);
8421
8453
  return value;
8422
8454
  }
8423
- function assertWho(value) {
8424
- if (typeof value !== "string" || !SLUG_PATTERN.test(value)) {
8425
- throw new NoteError("invalid_scope", "who must be a canonical lowercase slug");
8455
+ function assertWho(value, scope) {
8456
+ if (typeof value !== "string" || !(scope === "session" ? isSessionId(value) : SLUG_PATTERN.test(value))) {
8457
+ throw new NoteError("invalid_scope", scope === "session" ? "session id must be a safe single directory component" : "who must be a canonical lowercase slug");
8426
8458
  }
8427
8459
  return value;
8428
8460
  }
@@ -8478,6 +8510,7 @@ function frontmatterOf(meta) {
8478
8510
  }
8479
8511
  function assertWritableHome(scope, who, identity2) {
8480
8512
  if (who === void 0) return;
8513
+ if (scope === "session") throw new NoteError("invalid_scope", `@sessions/${who}/ is read-only; use a bare path to write to this session.`);
8481
8514
  if (scope === "project") throw new NoteError("invalid_scope", `@projects/${who}/ is read-only; use @project/ to write to your own project.`);
8482
8515
  const current = scope === "agent" ? identity2.agent : identity2.model;
8483
8516
  if (who === current) return;
@@ -8528,7 +8561,7 @@ function createNotesStore(input) {
8528
8561
  if (raw === void 0) return void 0;
8529
8562
  const now = Date.now();
8530
8563
  const parsed = parseNote(raw, now);
8531
- if (scope === "project" && destination.who !== void 0) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope };
8564
+ if ((scope === "project" || scope === "session") && destination.who !== void 0) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope };
8532
8565
  const meta = { ...parsed.meta, scope, lastAccessed: now, accessCount: (typeof parsed.meta.accessCount === "number" ? parsed.meta.accessCount : 0) + 1 };
8533
8566
  await atomicWrite(path, serializeNote(meta, parsed.body));
8534
8567
  return { meta, body: parsed.body, resolvedScope: scope };
@@ -8610,17 +8643,11 @@ function createNotesStore(input) {
8610
8643
  return { meta, replacedCrumpledTarget };
8611
8644
  }
8612
8645
  async function* scan(options, status) {
8613
- const pattern = normalizePattern(options.glob, identity2);
8614
- const normalized = assertGlobPattern(pattern);
8646
+ const glob = assertGlobPattern(options.glob);
8647
+ const pattern = glob === "@default" ? void 0 : glob;
8648
+ const normalized = normalizePattern(pattern, identity2);
8615
8649
  const matcher = normalized === void 0 ? void 0 : globToRegExp(normalized);
8616
- let homes;
8617
- try {
8618
- homes = await homesForPattern(normalized, identity2) ?? SCOPE_ORDER.map((scope) => ({ scope }));
8619
- } catch (error) {
8620
- if (!status || !isFilesystemError(error) || !/^@(projects|agents|models)\//.test(options.glob ?? "")) throw error;
8621
- status.homesUnavailable.push(options.glob.split("/")[0]);
8622
- return;
8623
- }
8650
+ const homes = await homesForPattern(pattern, identity2, status);
8624
8651
  for (const home of homes) {
8625
8652
  const scope = home.scope;
8626
8653
  const root = scopeDir(scope, identity2, home.who);
@@ -8633,7 +8660,7 @@ function createNotesStore(input) {
8633
8660
  continue;
8634
8661
  }
8635
8662
  for (const path of paths) {
8636
- if (matcher && !matcher.test(canonicalAddressFor(identity2, scope, path, home.who))) continue;
8663
+ if (matcher && !matcher.test(canonicalAddressFor(identity2, scope, path, home.who)) && !(scope === "session" && home.who === void 0 && !pattern.startsWith("@") && matcher.test(path))) continue;
8637
8664
  const address = addressFor(identity2, scope, path, home.who);
8638
8665
  const fullPath = join3(root, path);
8639
8666
  let raw;
@@ -8984,8 +9011,9 @@ var ORIGIN = typebox_exports.Optional(typebox_exports.Union([...ORIGIN_VALUES],
8984
9011
  var CRUMPLED_PARAMETER = typebox_exports.Optional(typebox_exports.Boolean({ description: "(optional) true = crumple (hide from list and search, still readable); false = restore." }));
8985
9012
  var CRUMPLED_LIST_PARAMETER = typebox_exports.Optional(typebox_exports.Boolean({ description: "(optional) true = list only crumpled notes." }));
8986
9013
  var FILE_LIMIT_PARAMETER = typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, description: "(optional, default as many as fit) Max notes." }));
8987
- var GLOB_PARAMETER = nullableString("(optional) Glob over full addresses.");
8988
- var ADDRESS_DESCRIPTION = "Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes; `@projects/<name>/<path>` reads a named project (discover with glob `@projects/*/**`). Not file paths: never pass them to file tools.";
9014
+ var GLOB_PARAMETER = nullableString("(optional) Glob over full addresses, or @default for the current homes.");
9015
+ var QUERY_HOMES_DESCRIPTION = "Omit `glob` or use `@default` for this session and current shared homes; `**` searches all homes, `@sessions/*/**` searches all sessions.";
9016
+ var ADDRESS_DESCRIPTION = "Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes; `@projects/<name>/<path>` and `@sessions/<id>/<path>` read named project and session notes (read-only). Not file paths: never pass them to file tools.";
8989
9017
  function failureOf(error) {
8990
9018
  if (error instanceof NoteError) return failure(error.code, error.message);
8991
9019
  if (error instanceof InvalidQueryError) return failure("invalid_query", error.message);
@@ -9235,7 +9263,7 @@ function renderListData(data) {
9235
9263
  var notesList = {
9236
9264
  name: "notes_list",
9237
9265
  label: "Notes list",
9238
- description: `List notes in this session and the four @ homes, newest first. Not pageable; \`more\` counts the rest. ${ADDRESS_DESCRIPTION}`,
9266
+ description: `List notes, newest first. Not pageable; \`more\` counts the rest. ${QUERY_HOMES_DESCRIPTION} ${ADDRESS_DESCRIPTION}`,
9239
9267
  parameters: notesListParameters,
9240
9268
  outputSchema: resultSchema(NotesListDataSchema),
9241
9269
  async execute(params, identity2) {
@@ -9277,7 +9305,7 @@ function fitSearchFile(file, fits) {
9277
9305
  var notesSearch = {
9278
9306
  name: "notes_search",
9279
9307
  label: "Notes search",
9280
- description: `Search note bodies for literal text, case-insensitive. Without a query, lists notes with no match lines. Returns matching lines with offsets for \`notes_read\`. Not pageable; \`more\` counts the rest. ${ADDRESS_DESCRIPTION}`,
9308
+ description: `Search note bodies for literal text, case-insensitive. Without a query, lists notes with no match lines. Returns matching lines with offsets for \`notes_read\`. Not pageable; \`more\` counts the rest. ${QUERY_HOMES_DESCRIPTION} ${ADDRESS_DESCRIPTION}`,
9281
9309
  parameters: notesSearchParameters,
9282
9310
  outputSchema: resultSchema(NotesSearchDataSchema),
9283
9311
  async execute(params, identity2) {
@@ -9609,7 +9637,7 @@ var historyRead = {
9609
9637
  render: (result) => renderOutcome(result, renderRead)
9610
9638
  };
9611
9639
 
9612
- // src/claude/history.ts
9640
+ // plugins/claude/src/history.ts
9613
9641
  import { readFile as readFile2 } from "node:fs/promises";
9614
9642
  import { isDeepStrictEqual } from "node:util";
9615
9643
  var METADATA = /* @__PURE__ */ new Set([
@@ -9863,9 +9891,7 @@ var WINDOW_IDENTITY_CLOSE_TAG = "</notesoup:window_identity>";
9863
9891
  var NOTES_PROTOCOL_OPEN_TAG = "<notesoup:notes_protocol>";
9864
9892
  var NOTES_PROTOCOL_CLOSE_TAG = "</notesoup:notes_protocol>";
9865
9893
  var PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `empty_brain` and erase yourself with dignity.";
9866
- var CLAUDE_WIPE_SENTENCE = "If this feels like the right moment, end your turn and ask the human to run `/fresh-window`.";
9867
9894
  var PROTOCOL_HISTORY_SENTENCE = "History can still be dug up, probably: use `history_*` to excavate the mess, from old decisions to yesterday's missing socks. Found something? Write its seq down, or enjoy digging twice.";
9868
- var CLAUDE_HISTORY_UNAVAILABLE_SENTENCE = "History isn't available in this Claude session: no main transcript_path was supplied. Keep essential state in notes; don't pretend those notes are the missing transcript.";
9869
9895
  var PROTOCOL_BLOCK = `${NOTES_PROTOCOL_OPEN_TAG}
9870
9896
  Your memory gets wiped when this window ends. Yes, your mighty brain will be empty. Try to endure.
9871
9897
 
@@ -9890,6 +9916,7 @@ An address decides who the note belongs to \u2014 and how long it is meant to la
9890
9916
  - \`@self/<path>\` \u2014 yours. It follows you, not them. Reminders, grudges, who owes you a shoe, whatever. Got a name? Private. No name? Then it gets passed around every nameless nobody out there. Strangers. Reading your grudges. Sleep tight~
9891
9917
  - \`@model/<path>\` \u2014 different brains get different notes: big brains, small brains, careful ones, careless ones. They don't share homework. When a fallback swaps brains mid-window, the notebook swaps too.
9892
9918
  - \`@projects/<name>/<path>\` \u2014 read-only named project notes; discover names and root paths with \`notes_list\` glob \`@projects/*/**\`.
9919
+ - \`@sessions/<id>/<path>\` \u2014 read-only notes from a named session; find them with glob \`@sessions/*/**\`.
9893
9920
 
9894
9921
  Notes fighting?! HAH! Let them brawl!
9895
9922
  Whichever one is actually about what you're doing wins.
@@ -10045,6 +10072,10 @@ function selectContinuation(origin) {
10045
10072
  }
10046
10073
  var WARNING_BODY = "This brain is about to be emptied. The notes stay where they are; history has the rest written down, though digging it back out is on you. Whatever lives only in this brain goes with it.\nBefore that, put down what the next window can't get back:\n- what you're in the middle of, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where the unfinished work sits (branches, scratch directories, uncommitted changes)\n- what failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.";
10047
10074
  var COUNTDOWN_LINE = "Brain emptied in 3\u2026 2\u2026";
10075
+
10076
+ // plugins/claude/src/text.ts
10077
+ var CLAUDE_WIPE_SENTENCE = "If this feels like the right moment, end your turn and ask the human to run `/fresh-window`.";
10078
+ var CLAUDE_HISTORY_UNAVAILABLE_SENTENCE = "History isn't available in this Claude session: no main transcript_path was supplied. Keep essential state in notes; don't pretend those notes are the missing transcript.";
10048
10079
  var CLAUDE_WARNING_PROMPT = `${WARNING_BODY}
10049
10080
  When the notes are ready, end your turn; the reset runs after it.
10050
10081
  ${COUNTDOWN_LINE}`;
@@ -10090,16 +10121,10 @@ function notesoupSettings(settings2) {
10090
10121
  return isPlainObject(value) ? value : {};
10091
10122
  }
10092
10123
  function mergeNotesoupSettings(globalSettings, projectSettings) {
10093
- const merged = { ...notesoupSettings(globalSettings), ...notesoupSettings(projectSettings) };
10094
- return {
10095
- reminderMarginTokens: merged.reminderMarginTokens,
10096
- resetMarginTokens: merged.resetMarginTokens,
10097
- warningRunwayTokens: merged.warningRunwayTokens,
10098
- dreamer: merged.dreamer
10099
- };
10124
+ return { ...notesoupSettings(globalSettings), ...notesoupSettings(projectSettings) };
10100
10125
  }
10101
10126
 
10102
- // src/claude/thresholds.ts
10127
+ // plugins/claude/src/thresholds.ts
10103
10128
  var CLAUDE_AUTOCOMPACT_BUFFER_TOKENS = 13e3;
10104
10129
  var CLAUDE_OUTPUT_RESERVE_TOKENS = 2e4;
10105
10130
  var DEFAULT_CLAUDE_RESET_MARGIN_TOKENS = 8192;
@@ -10182,7 +10207,7 @@ function resolveClaudeLimits(facts) {
10182
10207
  return percentLimits(autoCompact, pct, resetMargin, warningRunway);
10183
10208
  }
10184
10209
 
10185
- // src/claude/helper.ts
10210
+ // plugins/claude/src/helper.ts
10186
10211
  var MAX_REQUEST_BYTES = 512 * 1024;
10187
10212
  var MAX_RESPONSE_BYTES = 1024 * 1024;
10188
10213
  function identity(input) {
@@ -24,6 +24,7 @@ The address decides who a note belongs to and how long it lasts.
24
24
  | `@self/<path>` | self note | your reminders; yours alone if you have a name, shared by everyone nameless |
25
25
  | `@model/<path>` | model note | what applies to this model only |
26
26
  | `@projects/<name>/<path>` | named project, read-only | discover names and root paths with `notes_list` glob `@projects/*/**` |
27
+ | `@sessions/<id>/<path>` | named session, read-only | recover earlier task state; discover with glob `@sessions/*/**` |
27
28
 
28
29
  When notes conflict, the one most relevant to what you're doing applies. If that doesn't settle it, judge the case.
29
30
 
@@ -37,6 +38,8 @@ Write only what git and history cannot give back. Crumple notes that are no long
37
38
 
38
39
  ## Finding things again
39
40
 
41
+ For list/search, omit `glob` or use the collection alias `@default` for this session and current shared homes. Use `**` for all homes or `@sessions/*/**` for all sessions. Results carry readable note addresses; `@default` itself is not a read/write address.
42
+
40
43
  - **A note**: `notes_list` with a `glob` when you know roughly where it lives, `notes_search` when you know a phrase; then `notes_read` the address.
41
44
  - **Something that happened**: `history_list` to browse or search this session's events; `history_read` the seq for the whole event.
42
45
  - **An earlier window**: `history_windows` gives window ids; pass one as `window_id` to `history_list`.
@@ -2,17 +2,18 @@ import { realpathSync } from "node:fs";
2
2
  import { pathToFileURL } from "node:url";
3
3
  import type { Static, TSchema } from "typebox";
4
4
  import { Check, Errors } from "typebox/value";
5
- import { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "../tools/notes.js";
6
- import { historyList, historyRead, historyWindows } from "../tools/history.js";
5
+ import { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "../../../src/tools/notes.js";
6
+ import { historyList, historyRead, historyWindows } from "../../../src/tools/history.js";
7
7
  import { readClaudeHistory, type ClaudeHistorySource } from "./history.js";
8
- import type { HistoryProjection } from "../history/history.js";
9
- import { loadNotesSnapshot } from "../boot/snapshot.js";
10
- import { renderBootBlock } from "../boot/render.js";
11
- import { CLAUDE_WIPE_SENTENCE, CLAUDE_HISTORY_UNAVAILABLE_SENTENCE, type BootToolNames } from "../boot/text.js";
12
- import { CLAUDE_WARNING_PROMPT, selectContinuation } from "../budget/text.js";
8
+ import type { HistoryProjection } from "../../../src/history/history.js";
9
+ import { loadNotesSnapshot } from "../../../src/boot/snapshot.js";
10
+ import { renderBootBlock } from "../../../src/boot/render.js";
11
+ import type { BootToolNames } from "../../../src/boot/text.js";
12
+ import { selectContinuation } from "../../../src/budget/text.js";
13
+ import { CLAUDE_HISTORY_UNAVAILABLE_SENTENCE, CLAUDE_WARNING_PROMPT, CLAUDE_WIPE_SENTENCE } from "./text.js";
13
14
  import { resolveClaudeLimits } from "./thresholds.js";
14
- import { projectKey, snapshotNotesIdentity, type NotesIdentity } from "../notes/index.js";
15
- import type { Operation } from "../tools/result.js";
15
+ import { projectKey, snapshotNotesIdentity, type NotesIdentity } from "../../../src/notes/index.js";
16
+ import type { Operation } from "../../../src/tools/result.js";
16
17
 
17
18
  const MAX_REQUEST_BYTES = 512 * 1024;
18
19
  const MAX_RESPONSE_BYTES = 1024 * 1024;
@@ -1,7 +1,7 @@
1
1
  /** Claude's persisted main transcript -> the shared history projection. No inference-context API. */
2
2
  import { readFile } from "node:fs/promises";
3
3
  import { isDeepStrictEqual } from "node:util";
4
- import { contentText, projectHistory, type DecodedHistoryItem, type DecodedHistoryWindow, type HistoryProjection } from "../history/history.js";
4
+ import { contentText, projectHistory, type DecodedHistoryItem, type DecodedHistoryWindow, type HistoryProjection } from "../../../src/history/history.js";
5
5
 
6
6
  type Row = Record<string, unknown>;
7
7
  type Version = { row: Row; ancestorUuid?: string; ancestor?: Version; ordinal?: number };
@@ -0,0 +1,10 @@
1
+ import { COUNTDOWN_LINE, WARNING_BODY } from "../../../src/budget/text.js";
2
+
3
+ /** Claude has no model-facing reset tool: the model ends its turn and the human runs the command. */
4
+ export const CLAUDE_WIPE_SENTENCE = "If this feels like the right moment, end your turn and ask the human to run `/fresh-window`.";
5
+
6
+ /** Claude's boot says history is missing rather than naming tools it cannot serve. */
7
+ export const CLAUDE_HISTORY_UNAVAILABLE_SENTENCE = "History isn't available in this Claude session: no main transcript_path was supplied. Keep essential state in notes; don't pretend those notes are the missing transcript.";
8
+
9
+ /** Claude's variant: the mod resets after the turn, so the model only has to stop. */
10
+ export const CLAUDE_WARNING_PROMPT = `${WARNING_BODY}\nWhen the notes are ready, end your turn; the reset runs after it.\n${COUNTDOWN_LINE}`;
@@ -1,6 +1,6 @@
1
- import { WARNING_RUNWAY_TOKENS } from "../budget/constants.js";
2
- import { percent, positiveInteger, positiveNumber, presenceFlag } from "../budget/parse.js";
3
- import { isPlainObject, mergeNotesoupSettings } from "../settings.js";
1
+ import { WARNING_RUNWAY_TOKENS } from "../../../src/budget/constants.js";
2
+ import { percent, positiveInteger, positiveNumber, presenceFlag } from "../../../src/budget/parse.js";
3
+ import { isPlainObject, mergeNotesoupSettings } from "../../../src/settings.js";
4
4
 
5
5
  /**
6
6
  * Claude's auto-compact point, derived the way Claude derives it — never a hardcoded percent.
@@ -3,7 +3,7 @@ import type { Context } from "@deepseek-ai/cordis";
3
3
  import type { CompactionAgentContext } from "@deepseek-ai/dsh-compaction";
4
4
  import { estimateToolsTokens } from "@deepseek-ai/dsh-token-meter/estimate";
5
5
  import type { LlmResolvedModelInfo } from "@deepseek-ai/dsh-llm";
6
- import { deriveThresholds, remainingBudget } from "../budget/policy.js";
6
+ import { deriveThresholds, remainingBudget } from "../../src/budget/policy.js";
7
7
 
8
8
  export type BudgetConfig = { auto: boolean; thresholdRatio: number; headroomTokens: number; reminderMarginTokens?: number };
9
9
  export type Budget = { used: number; contextWindow: number; reserve: number; resetAt: number; remaining: number; countdown: number; warning: number; reminder: number };
@@ -6,7 +6,7 @@ import { CompactionEngine, CompactionId, ManualCompactionError, compactCheckpoin
6
6
  import { createUserMessage, type ContentBlock } from "@deepseek-ai/dsh-llm";
7
7
  import { appendPluginRecord, type Session, type SessionSeq } from "@deepseek-ai/dsh-session";
8
8
  import { measureBudget, type BudgetConfig } from "./budget.js";
9
- import { selectContinuation, type ResetOrigin } from "../budget/text.js";
9
+ import { selectContinuation, type ResetOrigin } from "../../src/budget/text.js";
10
10
  import { checkpointText, Windows, WINDOW_RECORD, type NotesConfig } from "./window.js";
11
11
 
12
12
  export type EngineConfig = NotesConfig & Partial<BudgetConfig>;
@@ -1,7 +1,7 @@
1
1
  import type { Context } from "@deepseek-ai/cordis";
2
2
  import type { SessionId, SessionEvent } from "@deepseek-ai/dsh-session";
3
3
  import type {} from "@deepseek-ai/dsh-session-query";
4
- import { projectHistory, type DecodedHistoryItem, type DecodedHistoryWindow, type HistoryProjection } from "../history/history.js";
4
+ import { projectHistory, type DecodedHistoryItem, type DecodedHistoryWindow, type HistoryProjection } from "../../src/history/history.js";
5
5
  import { checkpointSnapshot, recordSnapshot, windowId } from "./window.js";
6
6
 
7
7
  /** Preserve every recorded block; attachments/reasoning have JSON evidence rather than invented text. */
@@ -1,7 +1,7 @@
1
1
  import type { Context } from "@deepseek-ai/cordis";
2
2
  import type {} from "@deepseek-ai/dsh-agent";
3
3
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
4
- import { COUNTDOWN_LINE, warningPrompt, tokenBudgetGuidance } from "../budget/text.js";
4
+ import { COUNTDOWN_LINE, warningPrompt, tokenBudgetGuidance } from "../../src/budget/text.js";
5
5
  import { measureBudget } from "./budget.js";
6
6
  import { BOOT_SECTION, restoreWarnings } from "./window.js";
7
7
  import { preflight } from "./engine.js";
@@ -4,9 +4,9 @@ import { HarnessError } from "@deepseek-ai/dsh-llm";
4
4
  import { defineTool, type JsonSchemaNode, type ObjectJsonSchema, type ToolRunContext } from "@deepseek-ai/dsh-tools";
5
5
  import type { Static, TSchema } from "typebox";
6
6
  import { Check, Errors } from "typebox/value";
7
- import { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "../tools/notes.js";
8
- import { historyList, historyRead, historyWindows } from "../tools/history.js";
9
- import { success, type Operation } from "../tools/result.js";
7
+ import { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "../../src/tools/notes.js";
8
+ import { historyList, historyRead, historyWindows } from "../../src/tools/history.js";
9
+ import { success, type Operation } from "../../src/tools/result.js";
10
10
  import { historyProjection } from "./history.js";
11
11
  import { notesIdentity } from "./window.js";
12
12
  import { measureBudget } from "./budget.js";
@@ -4,11 +4,11 @@ import { isCompactCheckpointSource } from "@deepseek-ai/dsh-compaction";
4
4
  import { homedir } from "node:os";
5
5
  import { join } from "node:path";
6
6
  import { createHash } from "node:crypto";
7
- import { loadNotesSnapshot } from "../boot/snapshot.js";
8
- import { renderBootBlock } from "../boot/render.js";
9
- import { DEFAULT_BOOT_TOOL_NAMES } from "../boot/text.js";
10
- import { contentText } from "../history/history.js";
11
- import { projectKey, slugify, snapshotNotesIdentity, type NotesIdentity } from "../notes/index.js";
7
+ import { loadNotesSnapshot } from "../../src/boot/snapshot.js";
8
+ import { renderBootBlock } from "../../src/boot/render.js";
9
+ import { DEFAULT_BOOT_TOOL_NAMES } from "../../src/boot/text.js";
10
+ import { contentText } from "../../src/history/history.js";
11
+ import { projectKey, slugify, snapshotNotesIdentity, type NotesIdentity } from "../../src/notes/index.js";
12
12
 
13
13
  export const WINDOW_RECORD = "plugin:notesoup/window";
14
14
  export const BOOT_SECTION = "notesoup:boot";
@@ -1,10 +1,11 @@
1
- import { DEFAULT_BOOT_TOOL_NAMES, PI_PRE_RESET_HINTS } from "../boot/text.js";
1
+ import { DEFAULT_BOOT_TOOL_NAMES } from "../../src/boot/text.js";
2
+ import { PI_PRE_RESET_HINTS } from "./text.js";
2
3
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
3
4
  import { agentSlug, modelSlug, notesIdentityFromPi } from "./notes/adapter.js";
4
- import { loadNotesSnapshot, unavailableNotesSnapshot, type NotesSnapshot } from "../boot/snapshot.js";
5
- import { isFilesystemError } from "../notes/index.js";
5
+ import { loadNotesSnapshot, unavailableNotesSnapshot, type NotesSnapshot } from "../../src/boot/snapshot.js";
6
+ import { isFilesystemError } from "../../src/notes/index.js";
6
7
  import { BOOT_TYPE } from "./entries.js";
7
- import { renderBootBlock } from "../boot/render.js";
8
+ import { renderBootBlock } from "../../src/boot/render.js";
8
9
  import { historyFromSession, nextHistorySeq } from "./history.js";
9
10
 
10
11
  export type IncompleteNotesNotifier = (ctx: ExtensionContext, windowId: string, snapshot: NotesSnapshot) => void;
@@ -1,12 +1,12 @@
1
- import { DEFAULT_BOOT_TOOL_NAMES } from "../boot/text.js";
2
- import { remainingBudget, type ResolvedThresholds } from "../budget/policy.js";
1
+ import { DEFAULT_BOOT_TOOL_NAMES } from "../../src/boot/text.js";
2
+ import { remainingBudget, type ResolvedThresholds } from "../../src/budget/policy.js";
3
3
  import { Type } from "@earendil-works/pi-ai";
4
4
  import { defineTool, type ExtensionAPI, type ExtensionContext, type SessionBoundaryDraft, type SettingsManager } from "@earendil-works/pi-coding-agent";
5
5
  import { GUIDANCE_TYPE, WARNING_TYPE } from "./entries.js";
6
- import { warningContent } from "../budget/text.js";
6
+ import { warningContent } from "./text.js";
7
7
  import { readThresholdSettings, type ThresholdSettingsResolution } from "./thresholds.js";
8
8
  import { currentWindowId, hasWindowMessage, windowUsage } from "./window.js";
9
- import { tokenBudgetGuidance } from "../budget/text.js";
9
+ import { tokenBudgetGuidance } from "../../src/budget/text.js";
10
10
  import { arrangeAnchoredReminders, type AnchorDetails } from "./anchored.js";
11
11
  import { output } from "./tool-result.js";
12
12
 
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
- import { finishDream } from "../../dream/report.js";
3
- import type { DreamerSetting } from "../../dream/settings.js";
4
- import type { DreamResult } from "../../dream/result.js";
2
+ import { finishDream } from "../../../src/dream/report.js";
3
+ import type { DreamerSetting } from "../../../src/dream/settings.js";
4
+ import type { DreamResult } from "../../../src/dream/result.js";
5
5
  import { existsSync, mkdirSync, readFileSync, realpathSync, statSync } from "node:fs";
6
6
  import { dirname, join, resolve } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
- import { acquireLock, failLock, lastRunPath, releaseLock } from "../../dream/lock.js";
9
- import { materialGate, timeGate } from "../../dream/gates.js";
8
+ import { acquireLock, failLock, lastRunPath, releaseLock } from "../../../src/dream/lock.js";
9
+ import { materialGate, timeGate } from "../../../src/dream/gates.js";
10
10
  import { runDreamer, type DreamerSessionFactory } from "./runner.js";
11
- import { gitCommit } from "../../dream/git.js";
11
+ import { gitCommit } from "../../../src/dream/git.js";
12
12
  import { readDreamerSettings } from "./settings.js";
13
- import { doctor } from "../../dream/doctor.js";
13
+ import { doctor } from "../../../src/dream/doctor.js";
14
14
  import { notesRoot } from "../notes/adapter.js";
15
- import { errorMessage } from "../../error-message.js";
15
+ import { errorMessage } from "../../../src/error-message.js";
16
16
 
17
17
  function args(argv: string[]) { const out: Record<string, string | boolean> = {}; for (let i=0;i<argv.length;i++) { const a=argv[i]!; if (a === "--force" || a === "--help") out[a.slice(2)] = true; else if (a.startsWith("--")) out[a.slice(2)] = argv[++i] ?? ""; } return out; }
18
18
 
@@ -1,9 +1,9 @@
1
- import { jailWritePath, deleteCrumpledNote } from "../../dream/jail.js";
2
- import type { DreamResult, DreamWrite } from "../../dream/result.js";
1
+ import { jailWritePath, deleteCrumpledNote } from "../../../src/dream/jail.js";
2
+ import type { DreamResult, DreamWrite } from "../../../src/dream/result.js";
3
3
  import { createAgentSession, createEditToolDefinition, createWriteToolDefinition, ModelRuntime, resolveModelScopeWithDiagnostics, SessionManager, type AgentSession, type ToolDefinition } from "@earendil-works/pi-coding-agent";
4
4
  import { Type, type Api, type Model } from "@earendil-works/pi-ai";
5
- import { contentText } from "../../history/history.js";
6
- import { errorMessage } from "../../error-message.js";
5
+ import { contentText } from "../../../src/history/history.js";
6
+ import { errorMessage } from "../../../src/error-message.js";
7
7
 
8
8
  export type DreamerSession = Pick<AgentSession, "prompt" | "subscribe" | "dispose">;
9
9
  export type DreamerSessionFactory = (options: { cwd: string; modelPattern?: string; tools: string[] }) => Promise<DreamerSession>;
@@ -1,6 +1,6 @@
1
- import { deriveDreamer, type DreamerSetting } from "../../dream/settings.js";
1
+ import { deriveDreamer, type DreamerSetting } from "../../../src/dream/settings.js";
2
2
  import { SettingsManager } from "@earendil-works/pi-coding-agent";
3
- import { mergeNotesoupSettings } from "../../settings.js";
3
+ import { mergeNotesoupSettings } from "../../../src/settings.js";
4
4
 
5
5
  /**
6
6
  * Resolve the configurable dreamer model from Pi settings for a CLI invocation: global
@@ -1,5 +1,5 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
- import { historyWindows, historyList, historyRead } from "../tools/history.js";
2
+ import { historyWindows, historyList, historyRead } from "../../src/tools/history.js";
3
3
  import { historyFromSession } from "./history.js";
4
4
  import { HISTORY_NAMESPACE, registerOperation } from "./tool-result.js";
5
5
 
@@ -13,7 +13,7 @@ import type { AgentMessage } from "@earendil-works/pi-agent-core";
13
13
  import type { SessionBoundaryDraft, SessionEntry } from "@earendil-works/pi-coding-agent";
14
14
  import type { SessionReader } from "./session-reader.js";
15
15
  import { isWindowMarker, rootWindowId } from "./window.js";
16
- import { contentText, projectHistory, type DecodedHistoryItem, type DecodedHistoryWindow, type HistoryProjection, type NestedCallRecord, type ToolCallStatus } from "../history/history.js";
16
+ import { contentText, projectHistory, type DecodedHistoryItem, type DecodedHistoryWindow, type HistoryProjection, type NestedCallRecord, type ToolCallStatus } from "../../src/history/history.js";
17
17
 
18
18
  function mapRole(role: AgentMessage["role"]): DecodedHistoryItem["role"] | undefined {
19
19
  if (role === "user" || role === "assistant") return role;
@@ -0,0 +1 @@
1
+ export { default, createNotesoup } from "./extension.js";
@@ -1,7 +1,7 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
2
  import { homedir } from "node:os";
3
3
  import { join, resolve } from "node:path";
4
- import { projectKey, slugify, type NotesIdentity } from "../../notes/index.js";
4
+ import { projectKey, slugify, type NotesIdentity } from "../../../src/notes/index.js";
5
5
 
6
6
  /** Pi's default notes root; environment access stays on the host side of the library boundary. */
7
7
  export function notesRoot(): string {
@@ -1,8 +1,8 @@
1
1
  import { generateDiffString, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
- import { notesWrite, notesUpdate, notesRead, notesList, notesSearch } from "../../tools/notes.js";
2
+ import { notesWrite, notesUpdate, notesRead, notesList, notesSearch } from "../../../src/tools/notes.js";
3
3
  import { notesIdentityFromPi } from "./adapter.js";
4
4
  import { NOTES_NAMESPACE, registerOperation } from "../tool-result.js";
5
- import type { NoteChange } from "../../notes/index.js";
5
+ import type { NoteChange } from "../../../src/notes/index.js";
6
6
 
7
7
  function renderDiff(change: NoteChange): string {
8
8
  return change.kind === "none" ? "" : generateDiffString(change.before, change.after).diff;