notesoup 0.45.0 → 0.45.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 (59) hide show
  1. package/dist/src/boot/text.d.ts +7 -0
  2. package/dist/src/boot/text.js +7 -0
  3. package/dist/src/claude/helper.js +3 -8
  4. package/dist/src/dsh/engine.d.ts +6 -0
  5. package/dist/src/dsh/engine.js +34 -1
  6. package/dist/src/dsh/index.js +1 -1
  7. package/dist/src/dsh/tools.d.ts +1 -1
  8. package/dist/src/dsh/tools.js +2 -2
  9. package/dist/src/dsh/window.d.ts +1 -1
  10. package/dist/src/dsh/window.js +4 -6
  11. package/dist/src/notes/index.d.ts +4 -2
  12. package/dist/src/notes/index.js +4 -1
  13. package/dist/src/notes/paths.d.ts +0 -1
  14. package/dist/src/notes/paths.js +0 -1
  15. package/dist/src/pi/boot.d.ts +0 -5
  16. package/dist/src/pi/boot.js +4 -30
  17. package/dist/src/pi/budget.js +3 -3
  18. package/dist/src/pi/notes/adapter.d.ts +1 -1
  19. package/dist/src/pi/notes/adapter.js +1 -1
  20. package/dist/src/pi/runtime.js +28 -3
  21. package/dist/src/pi/tool-result.d.ts +9 -0
  22. package/dist/src/pi/tool-result.js +4 -0
  23. package/dist/src/tools/notes.d.ts +1 -1
  24. package/dist/src/tools/notes.js +1 -1
  25. package/dist/src/tools/output.d.ts +1 -14
  26. package/dist/src/tools/output.js +1 -9
  27. package/dist/test/dependencies.test.js +53 -17
  28. package/dist/test/dsh.test.js +1 -1
  29. package/dist/test/helpers/dependency-graph.d.ts +3 -3
  30. package/dist/test/helpers/dependency-graph.js +64 -14
  31. package/dist/test/helpers/extension.js +2 -2
  32. package/dist/test/host-neutral.test.js +5 -0
  33. package/dist/test/notes.integration.test.js +4 -4
  34. package/dist/test/notes.test.js +1 -1
  35. package/mods/notesoup/.claude-plugin/plugin.json +1 -1
  36. package/mods/notesoup/dist/claude/helper.js +649 -651
  37. package/package.json +1 -1
  38. package/src/boot/text.ts +8 -0
  39. package/src/claude/helper.ts +3 -10
  40. package/src/dsh/engine.ts +27 -1
  41. package/src/dsh/index.ts +1 -1
  42. package/src/dsh/tools.ts +2 -3
  43. package/src/dsh/window.ts +4 -6
  44. package/src/notes/index.ts +4 -2
  45. package/src/notes/paths.ts +0 -1
  46. package/src/pi/boot.ts +4 -33
  47. package/src/pi/budget.ts +3 -3
  48. package/src/pi/notes/adapter.ts +1 -2
  49. package/src/pi/notes/tools.ts +1 -1
  50. package/src/pi/runtime.ts +31 -3
  51. package/src/pi/tool-result.ts +5 -0
  52. package/src/tools/notes.ts +1 -1
  53. package/src/tools/output.ts +1 -10
  54. package/dist/src/dsh/preflight.d.ts +0 -8
  55. package/dist/src/dsh/preflight.js +0 -35
  56. package/dist/src/pi/tool-names.d.ts +0 -7
  57. package/dist/src/pi/tool-names.js +0 -7
  58. package/src/dsh/preflight.ts +0 -29
  59. package/src/pi/tool-names.ts +0 -9
@@ -3,9 +3,23 @@ import { readFileSync, realpathSync } from "node:fs";
3
3
  import { relative, resolve, sep } from "node:path";
4
4
  import ts from "typescript";
5
5
  const builtins = new Set(builtinModules.map((name) => name.replace(/^node:/, "")));
6
- const hostPackage = /^(?:(?:@earendil-works|@mariozechner)\/pi-(?:ai|agent-core|coding-agent)|@deepseek-ai\/(?:dsh(?:-[^/]+)?|cordis(?:-[^/]+)?))(?:\/|$)/;
7
- /** AST edges include erased types and re-exports, not merely emitted runtime imports. */
8
- export function moduleReferences(source) {
6
+ function packageAdapter(specifier) {
7
+ if (/^@(?:earendil-works|mariozechner)\//.test(specifier))
8
+ return "pi";
9
+ if (/^@deepseek-ai\//.test(specifier))
10
+ return "dsh";
11
+ if (/^(?:claude-code|@anthropic-ai\/[^/]+)(?:\/|$)/.test(specifier))
12
+ return "claude";
13
+ return undefined;
14
+ }
15
+ /** All AST edges enforce boundaries; emitted edges alone determine runtime cycles. */
16
+ export function moduleReferences(source, runtimeOnly = false) {
17
+ if (runtimeOnly) {
18
+ if (source.isDeclarationFile)
19
+ return [];
20
+ const emitted = ts.transpileModule(source.text, { fileName: source.fileName, compilerOptions: { module: ts.ModuleKind.Preserve, target: ts.ScriptTarget.ES2022 } }).outputText;
21
+ source = ts.createSourceFile(source.fileName + ".js", emitted, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
22
+ }
9
23
  const references = new Set();
10
24
  const add = (node) => {
11
25
  if (node && ts.isStringLiteralLike(node))
@@ -28,31 +42,41 @@ export function moduleReferences(source) {
28
42
  function packageName(specifier) {
29
43
  return specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0];
30
44
  }
31
- /** Resolve every reachable edge with TypeScript, including local aliases and external declarations. */
45
+ /** Resolve reachable edges, preserving each importing module's core/adapter ownership. */
32
46
  export function dependencyViolations(root, entries, options, runtimeDependencies) {
33
47
  root = realpathSync(root);
34
48
  const violations = [];
35
49
  const visited = new Set();
50
+ const runtime = new Map();
36
51
  const cache = ts.createModuleResolutionCache(root, (path) => path, options);
37
52
  const sourceRoot = resolve(root, "src");
53
+ const rootEntry = resolve(sourceRoot, "index.ts");
54
+ const notesEntry = resolve(sourceRoot, "notes/index.ts");
38
55
  const display = (path) => relative(root, path).split(sep).join("/");
39
- const native = (path) => path === resolve(sourceRoot, "index.ts") || ["pi", "claude", "dsh"].some((adapter) => path.startsWith(resolve(sourceRoot, adapter) + sep)) || /node_modules\/(?:(?:@earendil-works|@mariozechner)\/pi-(?:ai|agent-core|coding-agent)|@deepseek-ai\/(?:dsh(?:-[^/]+)?|cordis(?:-[^/]+)?))(?:\/|$)/.test(path.split(sep).join("/"));
56
+ const local = (file) => file.startsWith(sourceRoot + sep) || file.startsWith(resolve(root, "mods/notesoup") + sep);
57
+ const adapter = (file) => {
58
+ const path = display(file);
59
+ return file === rootEntry ? "pi" : /^src\/(pi|claude|dsh)\//.exec(path)?.[1]
60
+ ?? (path.startsWith("mods/notesoup/") ? "claude" : packageAdapter(file.split(sep).join("/").split("/node_modules/").at(-1)));
61
+ };
40
62
  const walk = (file, chain) => {
41
63
  file = realpathSync(file);
42
- if (native(file)) {
43
- violations.push([...chain, display(file)].join(" -> "));
44
- return;
45
- }
46
64
  if (visited.has(file))
47
65
  return;
48
66
  visited.add(file);
49
67
  const here = [...chain, display(file)];
68
+ const owner = adapter(file);
50
69
  const source = ts.createSourceFile(file, readFileSync(file, "utf8"), ts.ScriptTarget.Latest, true);
70
+ const emitted = new Set(local(file) ? moduleReferences(source, true) : []);
71
+ if (local(file))
72
+ runtime.set(file, []);
51
73
  for (const specifier of moduleReferences(source)) {
52
74
  if (specifier.startsWith("node:") || builtins.has(specifier))
53
75
  continue;
54
- if (hostPackage.test(specifier)) {
55
- violations.push([...here, specifier].join(" -> "));
76
+ const sdk = packageAdapter(specifier);
77
+ if (sdk) {
78
+ if (owner !== sdk)
79
+ violations.push([...here, specifier].join(" -> "));
56
80
  continue;
57
81
  }
58
82
  const resolution = ts.resolveModuleName(specifier, file, options, ts.sys, cache).resolvedModule;
@@ -60,14 +84,40 @@ export function dependencyViolations(root, entries, options, runtimeDependencies
60
84
  violations.push([...here, `unresolved ${specifier}`].join(" -> "));
61
85
  continue;
62
86
  }
63
- // A shared dependency must be intentional, not accidentally supplied by a Pi peer/dev dependency.
64
- if (file.startsWith(sourceRoot + sep) && resolution.isExternalLibraryImport && !runtimeDependencies.has(packageName(specifier))) {
87
+ const target = realpathSync(resolution.resolvedFileName);
88
+ const targetOwner = adapter(target);
89
+ if (target === rootEntry || (targetOwner && targetOwner !== owner) ||
90
+ (owner && target.startsWith(resolve(sourceRoot, "notes") + sep) && target !== notesEntry) ||
91
+ (owner === "dsh" && target.startsWith(resolve(sourceRoot, "dream") + sep))) {
92
+ violations.push([...here, display(target)].join(" -> "));
93
+ continue;
94
+ }
95
+ // Core dependencies must be intentional, not accidentally supplied by a host.
96
+ if (!owner && file.startsWith(sourceRoot + sep) && resolution.isExternalLibraryImport && !runtimeDependencies.has(packageName(specifier))) {
65
97
  violations.push([...here, `undeclared runtime dependency ${specifier}`].join(" -> "));
66
98
  }
67
- walk(resolution.resolvedFileName, here);
99
+ if (emitted.has(specifier) && local(target))
100
+ runtime.get(file).push(target);
101
+ if (!targetOwner || local(target))
102
+ walk(target, here);
68
103
  }
69
104
  };
70
105
  for (const entry of entries)
71
106
  walk(resolve(root, entry), []);
107
+ const checked = new Set();
108
+ const cycles = (file, path) => {
109
+ const start = path.indexOf(file);
110
+ if (start >= 0) {
111
+ violations.push(`runtime cycle: ${[...path.slice(start), file].map(display).join(" -> ")}`);
112
+ return;
113
+ }
114
+ if (checked.has(file))
115
+ return;
116
+ checked.add(file);
117
+ for (const target of runtime.get(file) ?? [])
118
+ cycles(target, [...path, file]);
119
+ };
120
+ for (const file of runtime.keys())
121
+ cycles(file, []);
72
122
  return violations;
73
123
  }
@@ -1,5 +1,5 @@
1
1
  import { notesIdentityFromPi } from "../../src/pi/notes/adapter.js";
2
- import { PI_TOOL_NAMES } from "../../src/pi/tool-names.js";
2
+ import { DEFAULT_BOOT_TOOL_NAMES } from "../../src/boot/text.js";
3
3
  import assert from "node:assert/strict";
4
4
  import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
5
5
  import { tmpdir } from "node:os";
@@ -135,7 +135,7 @@ export function makeExtension(sessionManager, settingsManager) {
135
135
  }
136
136
  export async function explicitBoot(ctx, currentWindowId, previousWindowId) {
137
137
  return renderBootBlock({
138
- tools: PI_TOOL_NAMES,
138
+ tools: DEFAULT_BOOT_TOOL_NAMES,
139
139
  agentName: agentSlug(),
140
140
  modelName: modelSlug(ctx),
141
141
  firstWindowId: rootWindowId(ctx.sessionManager.getSessionId()),
@@ -191,6 +191,11 @@ test("shared note operations return canonical outcomes with a body-only read win
191
191
  }));
192
192
  assert.equal(updated.change_kind, "body");
193
193
  assert.equal(updated.diff, "caller-rendered-diff");
194
+ const defaultReceipt = data(await notesUpdate.execute({ address: "@project/test.md", edits: [{ oldText: "gamma", newText: "delta" }] }, notesIdentity));
195
+ assert.equal(defaultReceipt.diff, "note body");
196
+ const unchanged = data(await notesUpdate.execute({ address: "@project/test.md", edits: [{ oldText: "delta", newText: "delta" }] }, notesIdentity));
197
+ assert.equal(unchanged.change_kind, "none");
198
+ assert.equal(unchanged.diff, "");
194
199
  // Frontmatter is metadata, not body: the window addresses the body and counts only the body.
195
200
  const stored = await createNotesStore(notesIdentity).read("@project/test.md");
196
201
  assert.ok(stored, "the note is on disk");
@@ -1,5 +1,5 @@
1
1
  import { notesIdentityFromPi } from "../src/pi/notes/adapter.js";
2
- import { PI_TOOL_NAMES } from "../src/pi/tool-names.js";
2
+ import { DEFAULT_BOOT_TOOL_NAMES } from "../src/boot/text.js";
3
3
  import assert from "node:assert/strict";
4
4
  import { mkdirSync, rmSync, writeFileSync } from "node:fs";
5
5
  import { dirname } from "node:path";
@@ -179,7 +179,7 @@ test("boot note acquisition is one closed snapshot and isolates one or all faile
179
179
  });
180
180
  assert.deepEqual([...calls.entries()], [["session", 1], ["project", 1], ["human", 1], ["agent", 1], ["model", 1]], "each selected home is loaded exactly once");
181
181
  const renderData = {
182
- tools: PI_TOOL_NAMES,
182
+ tools: DEFAULT_BOOT_TOOL_NAMES,
183
183
  agentName: "root",
184
184
  modelName: "default",
185
185
  firstWindowId: "pcw:test:root",
@@ -237,7 +237,7 @@ test("boot note acquisition is one closed snapshot and isolates one or all faile
237
237
  });
238
238
  assert.deepEqual(oneFailed.unavailable.map((home) => home.label), ["@human"]);
239
239
  const oneFailedText = renderBootBlock({
240
- tools: PI_TOOL_NAMES,
240
+ tools: DEFAULT_BOOT_TOOL_NAMES,
241
241
  agentName: "root",
242
242
  modelName: "default",
243
243
  firstWindowId: "pcw:test:root",
@@ -252,7 +252,7 @@ test("boot note acquisition is one closed snapshot and isolates one or all faile
252
252
  });
253
253
  assert.equal(allFailed.unavailable.length, 5);
254
254
  const allFailedText = renderBootBlock({
255
- tools: PI_TOOL_NAMES,
255
+ tools: DEFAULT_BOOT_TOOL_NAMES,
256
256
  agentName: "root",
257
257
  modelName: "default",
258
258
  firstWindowId: "pcw:test:root",
@@ -13,7 +13,7 @@ import { join } from "node:path";
13
13
  import test from "node:test";
14
14
  import { Check } from "typebox/value";
15
15
  import { parseNote } from "../src/notes/frontmatter.js";
16
- import { projectKey } from "../src/notes/paths.js";
16
+ import { projectKey } from "../src/notes/index.js";
17
17
  import { globToRegExp } from "../src/notes/address.js";
18
18
  import { listNotes, physicalPath, scopeDir } from "./helpers/notes.js";
19
19
  import { notesList, notesSearch } from "../src/tools/notes.js";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.45.0",
3
+ "version": "0.45.1",
4
4
  "description": "Durable notes and a host-scoped notes boot section for Claude Code.",
5
5
  "author": {
6
6
  "name": "AstroSheep"