notesoup 0.61.0 → 0.63.0
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.
- package/.agents/plugins/marketplace.json +15 -0
- package/README.md +14 -11
- package/dist/plugins/antigravity/src/cli.d.ts +1 -0
- package/dist/plugins/antigravity/src/cli.js +23 -0
- package/dist/plugins/antigravity/src/hooks.d.ts +18 -0
- package/dist/plugins/antigravity/src/hooks.js +53 -0
- package/dist/plugins/antigravity/src/identity.d.ts +26 -0
- package/dist/plugins/antigravity/src/identity.js +129 -0
- package/dist/plugins/claude/src/helper.js +24 -5
- package/dist/plugins/claude/src/text.d.ts +7 -0
- package/dist/plugins/claude/src/text.js +12 -1
- package/dist/plugins/codex/src/hooks.js +1 -0
- package/dist/plugins/codex/src/identity.d.ts +6 -1
- package/dist/plugins/codex/src/identity.js +13 -1
- package/dist/plugins/codex/src/mcp.d.ts +35 -7
- package/dist/plugins/codex/src/mcp.js +26 -88
- package/dist/plugins/codex/src/text.js +3 -3
- package/dist/plugins/dsh/tools.js +8 -4
- package/dist/plugins/mcp/operations.d.ts +15 -0
- package/dist/plugins/mcp/operations.js +43 -0
- package/dist/plugins/mcp/server.d.ts +14 -0
- package/dist/plugins/mcp/server.js +13 -0
- package/dist/plugins/pi/budget.d.ts +4 -1
- package/dist/plugins/pi/budget.js +35 -8
- package/dist/plugins/pi/entries.d.ts +2 -0
- package/dist/plugins/pi/entries.js +2 -0
- package/dist/plugins/pi/history-tools.js +2 -1
- package/dist/plugins/pi/history.js +18 -1
- package/dist/plugins/pi/notes/tools.js +7 -3
- package/dist/plugins/pi/render.d.ts +7 -1
- package/dist/plugins/pi/render.js +2 -2
- package/dist/plugins/pi/reset/artifacts.d.ts +1 -1
- package/dist/plugins/pi/reset/artifacts.js +4 -4
- package/dist/plugins/pi/reset/lifecycle.d.ts +9 -2
- package/dist/plugins/pi/reset/lifecycle.js +109 -31
- package/dist/plugins/pi/runtime.js +104 -63
- package/dist/plugins/pi/tool-result.js +7 -7
- package/dist/plugins/pi/window.d.ts +25 -3
- package/dist/plugins/pi/window.js +219 -9
- package/dist/src/boot/render.js +18 -15
- package/dist/src/boot/text.d.ts +3 -1
- package/dist/src/boot/text.js +22 -20
- package/dist/src/budget/text.d.ts +7 -3
- package/dist/src/budget/text.js +24 -15
- package/dist/src/history/claude.d.ts +2 -0
- package/dist/src/history/claude.js +46 -0
- package/dist/src/history/codex-transcript.js +7 -5
- package/dist/src/history/codex.js +3 -0
- package/dist/src/history/corpus.d.ts +28 -1
- package/dist/src/history/corpus.js +40 -0
- package/dist/src/history/history.d.ts +37 -46
- package/dist/src/history/history.js +21 -40
- package/dist/src/history/local.js +67 -32
- package/dist/src/history/pi.d.ts +2 -1
- package/dist/src/history/pi.js +122 -48
- package/dist/src/history/prefilter.js +76 -19
- package/dist/src/history/query.d.ts +28 -49
- package/dist/src/history/query.js +83 -68
- package/dist/src/history/summary-cache.d.ts +8 -1
- package/dist/src/history/summary-cache.js +138 -12
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/notes/errors.d.ts +1 -1
- package/dist/src/notes/frontmatter.d.ts +0 -2
- package/dist/src/notes/frontmatter.js +0 -2
- package/dist/src/notes/index.d.ts +1 -1
- package/dist/src/notes/index.js +1 -1
- package/dist/src/notes/policy.d.ts +15 -1
- package/dist/src/notes/policy.js +46 -5
- package/dist/src/notes/store.d.ts +12 -0
- package/dist/src/notes/store.js +16 -20
- package/dist/src/text-match.d.ts +10 -1
- package/dist/src/text-match.js +42 -3
- package/dist/src/tools/dream.d.ts +22 -93
- package/dist/src/tools/dream.js +30 -27
- package/dist/src/tools/history.d.ts +33 -26
- package/dist/src/tools/history.js +257 -163
- package/dist/src/tools/notes.d.ts +51 -163
- package/dist/src/tools/notes.js +146 -100
- package/dist/src/tools/output.d.ts +2 -1
- package/dist/src/tools/output.js +2 -1
- package/dist/src/tools/result.d.ts +4 -7
- package/dist/src/tools/result.js +8 -9
- package/dist/src/tools/schema.d.ts +4 -1
- package/dist/src/tools/schema.js +25 -1
- package/dist/test/agent-loop.test.js +394 -56
- package/dist/test/antigravity-live.test.d.ts +1 -0
- package/dist/test/antigravity-live.test.js +142 -0
- package/dist/test/antigravity-plugin.test.d.ts +1 -0
- package/dist/test/antigravity-plugin.test.js +101 -0
- package/dist/test/boot.integration.test.js +156 -15
- package/dist/test/budget-settings.integration.test.js +4 -4
- package/dist/test/claude-history.test.js +14 -13
- package/dist/test/claude-mod.test.js +199 -16
- package/dist/test/claude-validation.test.js +69 -2
- package/dist/test/codex-history.test.js +15 -3
- package/dist/test/codex-plugin.test.js +76 -38
- package/dist/test/dependencies.test.js +7 -3
- package/dist/test/dream-skill.test.js +3 -3
- package/dist/test/dream-tools.test.js +101 -56
- package/dist/test/dsh.test.js +34 -19
- package/dist/test/helpers/dependency-graph.js +2 -2
- package/dist/test/helpers/extension.d.ts +68 -3
- package/dist/test/helpers/extension.js +74 -5
- package/dist/test/history-corpus.test.js +79 -77
- package/dist/test/history-summary-cache.test.js +97 -9
- package/dist/test/history.integration.test.js +234 -168
- package/dist/test/host-neutral.test.js +69 -19
- package/dist/test/marker.test.js +1 -1
- package/dist/test/model-facing-text.test.js +13 -3
- package/dist/test/note-policy.test.js +96 -77
- package/dist/test/notes.integration.test.js +212 -94
- package/dist/test/notes.test.js +184 -113
- package/dist/test/pi-render.test.js +20 -12
- package/dist/test/project-namespace.test.js +3 -2
- package/dist/test/reset-lifecycle.test.js +12 -2
- package/docs/antigravity.md +44 -0
- package/docs/architecture.md +6 -4
- package/docs/claude-code-mod.md +7 -7
- package/docs/codex.md +36 -38
- package/docs/dsh.md +3 -3
- package/docs/history-sessions.md +28 -50
- package/docs/notes-library.md +4 -4
- package/docs/reset-lifecycle.md +1 -1
- package/docs/skills.md +3 -3
- package/docs/tool-results.md +47 -28
- package/package.json +3 -2
- package/playbook.md +1 -1
- package/plugins/antigravity/dist/antigravity/notesoup.js +26886 -0
- package/plugins/antigravity/hooks.json +7 -0
- package/plugins/antigravity/mcp_config.json +8 -0
- package/plugins/antigravity/plugin.json +6 -0
- package/plugins/antigravity/src/cli.ts +22 -0
- package/plugins/antigravity/src/hooks.ts +51 -0
- package/plugins/antigravity/src/identity.ts +127 -0
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +1108 -539
- package/plugins/claude/hooks/register.ts +202 -62
- package/plugins/claude/playbook.md +1 -1
- package/plugins/claude/skills/dream/SKILL.md +1 -1
- package/plugins/claude/skills/notesoup-guide/SKILL.md +92 -0
- package/plugins/claude/src/helper.ts +24 -5
- package/plugins/claude/src/text.ts +14 -1
- package/plugins/codex/.codex-plugin/plugin.json +8 -0
- package/plugins/codex/.mcp.json +11 -0
- package/plugins/codex/README.md +5 -21
- package/plugins/codex/dist/codex/notesoup.js +18480 -17946
- package/plugins/codex/src/hooks.ts +1 -0
- package/plugins/codex/src/identity.ts +14 -1
- package/plugins/codex/src/mcp.ts +28 -98
- package/plugins/codex/src/text.ts +3 -3
- package/plugins/dsh/tools.ts +8 -4
- package/plugins/mcp/operations.ts +50 -0
- package/plugins/mcp/server.ts +23 -0
- package/plugins/paseo/README.md +5 -10
- package/plugins/paseo/client/brain-empty-card.tsx +3 -3
- package/plugins/paseo/client/markdown.tsx +50 -38
- package/plugins/paseo/client/notes-op-card.tsx +12 -9
- package/plugins/paseo/client/paper-card.tsx +6 -5
- package/plugins/paseo/client/paper-palette.ts +2 -9
- package/plugins/paseo/client/sticky-card.tsx +2 -2
- package/plugins/paseo/client/tool-result.ts +7 -14
- package/plugins/paseo/package-lock.json +3406 -0
- package/plugins/paseo/package.json +1 -0
- package/plugins/paseo/test/markdown-core.test.ts +73 -66
- package/plugins/pi/budget.ts +31 -8
- package/plugins/pi/entries.ts +2 -0
- package/plugins/pi/history-tools.ts +2 -1
- package/plugins/pi/history.ts +30 -1
- package/plugins/pi/notes/tools.ts +7 -3
- package/plugins/pi/render.ts +6 -6
- package/plugins/pi/reset/artifacts.ts +4 -3
- package/plugins/pi/reset/lifecycle.ts +125 -32
- package/plugins/pi/runtime.ts +98 -62
- package/plugins/pi/tool-result.ts +8 -8
- package/plugins/pi/window.ts +210 -10
- package/skills/dream/SKILL.md +1 -1
- package/skills/notesoup-guide/SKILL.md +92 -0
- package/src/boot/render.ts +18 -15
- package/src/boot/text.ts +23 -19
- package/src/budget/text.ts +27 -15
- package/src/history/claude.ts +41 -0
- package/src/history/codex-transcript.ts +6 -4
- package/src/history/codex.ts +2 -0
- package/src/history/corpus.ts +51 -2
- package/src/history/history.ts +35 -44
- package/src/history/local.ts +67 -27
- package/src/history/pi.ts +113 -35
- package/src/history/prefilter.ts +73 -15
- package/src/history/query.ts +93 -73
- package/src/history/summary-cache.ts +142 -17
- package/src/index.ts +2 -2
- package/src/notes/errors.ts +1 -1
- package/src/notes/frontmatter.ts +0 -3
- package/src/notes/index.ts +1 -1
- package/src/notes/policy.ts +44 -5
- package/src/notes/store.ts +17 -20
- package/src/text-match.ts +46 -4
- package/src/tools/dream.ts +29 -31
- package/src/tools/history.ts +249 -142
- package/src/tools/notes.ts +145 -113
- package/src/tools/output.ts +2 -1
- package/src/tools/result.ts +12 -11
- package/src/tools/schema.ts +24 -1
- package/plugins/claude/skills/memory/SKILL.md +0 -69
- package/plugins/codex/mcp.json +0 -10
- package/plugins/codex/plugin.json +0 -6
- package/plugins/paseo/client/markdown-core.tsx +0 -189
- package/plugins/paseo/client/typography.ts +0 -24
- package/skills/memory/SKILL.md +0 -69
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
-
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import { syncBuiltinESMExports } from "node:module";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
@@ -7,25 +7,32 @@ import { join } from "node:path";
|
|
|
7
7
|
import test from "node:test";
|
|
8
8
|
import { once } from "node:events";
|
|
9
9
|
import { execFileSync, spawn } from "node:child_process";
|
|
10
|
-
import { Check } from "typebox/value";
|
|
11
10
|
import { createNotesStore, projectKey } from "../src/notes/index.js";
|
|
12
11
|
import { abandonDream, dreamBegin, dreamEnd, dreamForget, dreamingIdentity } from "../src/tools/dream.js";
|
|
13
12
|
import { notesRead, notesUpdate, notesWrite } from "../src/tools/notes.js";
|
|
14
13
|
import { notesToolContext } from "../src/tools/notes-context.js";
|
|
14
|
+
import { TOOL_OUTPUT_MAX_BYTES } from "../src/tools/output.js";
|
|
15
15
|
function fixture(t) {
|
|
16
16
|
const home = mkdtempSync(join(tmpdir(), "dream-tools-"));
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const work = realpathSync(mkdtempSync(join(tmpdir(), "dream-work-")));
|
|
18
|
+
t.after(() => {
|
|
19
|
+
rmSync(home, { recursive: true, force: true });
|
|
20
|
+
rmSync(work, { recursive: true, force: true });
|
|
21
|
+
});
|
|
22
|
+
const dir = (rel) => {
|
|
23
|
+
const path = join(work, rel);
|
|
24
|
+
mkdirSync(path, { recursive: true });
|
|
25
|
+
return path;
|
|
21
26
|
};
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
const alphaDir = dir("alpha");
|
|
28
|
+
const betaDir = dir("beta");
|
|
29
|
+
assert.equal(projectKey(alphaDir, home), "alpha");
|
|
30
|
+
assert.equal(projectKey(betaDir, home), "beta");
|
|
24
31
|
const as = (sessionId, projectKey) => ({ home, sessionId, projectKey, agent: "root", model: "m" });
|
|
25
|
-
return { home, as };
|
|
32
|
+
return { home, work, alphaDir, betaDir, dir, as };
|
|
26
33
|
}
|
|
27
34
|
test("a dream opens one other project, writes its notes, deletes only crumpled ones, then closes", async (t) => {
|
|
28
|
-
const { home, as } = fixture(t);
|
|
35
|
+
const { home, alphaDir, betaDir, as } = fixture(t);
|
|
29
36
|
// Seed: beta's project note and two beta sessions, plus one alpha session.
|
|
30
37
|
await createNotesStore(as("b1", "beta")).write("@project/rule", "keep");
|
|
31
38
|
await createNotesStore(as("b1", "beta")).write("checkpoint", "old");
|
|
@@ -34,17 +41,21 @@ test("a dream opens one other project, writes its notes, deletes only crumpled o
|
|
|
34
41
|
await createNotesStore(as("a1", "alpha")).write("mine", "alpha only");
|
|
35
42
|
const me = as("now", "alpha");
|
|
36
43
|
const state = {};
|
|
37
|
-
const ident = () => notesToolContext(dreamingIdentity(me, state),
|
|
44
|
+
const ident = () => notesToolContext(dreamingIdentity(me, state), alphaDir);
|
|
38
45
|
// Closed: named notebooks are read-only and forget refuses.
|
|
39
46
|
assert.equal((await notesWrite.execute({ address: "@projects/beta/rule", content: "x" }, ident())).ok, false);
|
|
40
47
|
assert.equal((await dreamForget.execute({ address: "@sessions/b2/trash" }, me, state)).ok, false);
|
|
41
|
-
const begun = await dreamBegin.execute({
|
|
48
|
+
const begun = await dreamBegin.execute({ cwd: betaDir }, notesToolContext(me, alphaDir), state);
|
|
42
49
|
assert.ok(begun.ok);
|
|
43
50
|
assert.deepEqual(begun.data.files.map(f => f.address).sort(), ["@projects/beta/rule.md", "@sessions/b1/checkpoint.md", "@sessions/b2/trash.md"]);
|
|
44
51
|
assert.ok(begun.data.files.every(f => typeof f.last_accessed === "string"), "the dream's list shows each note's last access");
|
|
45
|
-
|
|
46
|
-
assert.
|
|
47
|
-
assert.
|
|
52
|
+
const beganText = dreamBegin.render(begun);
|
|
53
|
+
assert.match(beganText, /\| accessed /);
|
|
54
|
+
assert.match(beganText, new RegExp(`^dreaming over beta \\(baseline [0-9a-f]+, project_root ${betaDir.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\)`));
|
|
55
|
+
assert.equal(beganText.split(betaDir).length - 1, 1, "the project root is printed once in the header, not on every row");
|
|
56
|
+
assert.doesNotMatch(beganText, /pinned false|budget 4096|readonly false/, "path-default policy adds no row noise");
|
|
57
|
+
assert.equal((await dreamBegin.execute({}, notesToolContext(me, alphaDir), state)).ok, false, "only one dream at a time");
|
|
58
|
+
assert.equal((await dreamBegin.execute({ cwd: betaDir }, notesToolContext(as("other", "alpha"), alphaDir), {})).ok, false, "another session can't dream the same project");
|
|
48
59
|
assert.ok((await notesWrite.execute({ address: "@projects/beta/rule", content: "merged" }, ident())).ok);
|
|
49
60
|
assert.ok((await notesUpdate.execute({ address: "@sessions/b1/checkpoint", edits: [{ oldText: "old", newText: "new" }] }, ident())).ok);
|
|
50
61
|
assert.equal((await notesWrite.execute({ address: "@sessions/a1/mine", content: "x" }, ident())).ok, false, "another project's session stays read-only");
|
|
@@ -65,24 +76,24 @@ test("a dream opens one other project, writes its notes, deletes only crumpled o
|
|
|
65
76
|
assert.equal((await dreamEnd.execute({}, me, state)).ok, false);
|
|
66
77
|
});
|
|
67
78
|
test("pending openings exclude concurrent begins and stale cleanup preserves a newer generation", async (t) => {
|
|
68
|
-
const { as } = fixture(t);
|
|
79
|
+
const { alphaDir, betaDir, as } = fixture(t);
|
|
69
80
|
const me = as("s", "alpha");
|
|
70
81
|
const state = {};
|
|
71
|
-
const old = dreamBegin.execute({}, me, state);
|
|
82
|
+
const old = dreamBegin.execute({}, notesToolContext(me, alphaDir), state);
|
|
72
83
|
const pending = state.pending;
|
|
73
84
|
assert.ok(pending, "ownership is visible before the first await");
|
|
74
85
|
assert.equal(state.project, undefined, "opening does not publish dream permissions yet");
|
|
75
86
|
assert.equal(dreamingIdentity(me, state), me);
|
|
76
|
-
const concurrent = await dreamBegin.execute({
|
|
87
|
+
const concurrent = await dreamBegin.execute({ cwd: betaDir }, notesToolContext(me, alphaDir), state);
|
|
77
88
|
assert.ok(!concurrent.ok && concurrent.error.code === "already_dreaming");
|
|
78
89
|
assert.equal(state.pending, pending);
|
|
79
90
|
abandonDream(state);
|
|
80
|
-
const newer = dreamBegin.execute({
|
|
91
|
+
const newer = dreamBegin.execute({ cwd: betaDir }, notesToolContext(me, alphaDir), state);
|
|
81
92
|
const newerPending = state.pending;
|
|
82
93
|
assert.ok(newerPending && newerPending.generation > pending.generation);
|
|
83
94
|
const cancelled = await old;
|
|
84
95
|
assert.ok(!cancelled.ok && cancelled.error.code === "cancelled");
|
|
85
|
-
const refused = await dreamBegin.execute({}, me, {});
|
|
96
|
+
const refused = await dreamBegin.execute({}, notesToolContext(me, alphaDir), {});
|
|
86
97
|
assert.ok(!refused.ok && refused.error.code === "already_dreaming");
|
|
87
98
|
const begun = await newer;
|
|
88
99
|
assert.ok(begun.ok);
|
|
@@ -102,13 +113,13 @@ test("a thrown scan releases pending ownership before propagating the defect", a
|
|
|
102
113
|
});
|
|
103
114
|
syncBuiltinESMExports();
|
|
104
115
|
t.after(() => { t.mock.restoreAll(); syncBuiltinESMExports(); });
|
|
105
|
-
await assert.rejects(dreamBegin.execute({}, as("s", "alpha"), state), error => error === sentinel);
|
|
116
|
+
await assert.rejects(dreamBegin.execute({}, notesToolContext(as("s", "alpha"), "/work/alpha"), state), error => error === sentinel);
|
|
106
117
|
assert.equal(state.pending, undefined);
|
|
107
118
|
assert.equal(state.project, undefined);
|
|
108
119
|
assert.equal(state.release, undefined);
|
|
109
120
|
t.mock.restoreAll();
|
|
110
121
|
syncBuiltinESMExports();
|
|
111
|
-
assert.ok((await dreamBegin.execute({}, as("s", "alpha"), state)).ok, "the same state can retry after a failed scan");
|
|
122
|
+
assert.ok((await dreamBegin.execute({}, notesToolContext(as("s", "alpha"), "/work/alpha"), state)).ok, "the same state can retry after a failed scan");
|
|
112
123
|
assert.ok((await dreamEnd.execute({}, as("s", "alpha"), state)).ok);
|
|
113
124
|
});
|
|
114
125
|
test("baseline failure releases pending ownership and permits a retry", async (t) => {
|
|
@@ -116,7 +127,7 @@ test("baseline failure releases pending ownership and permits a retry", async (t
|
|
|
116
127
|
const me = as("s", "alpha");
|
|
117
128
|
const state = {};
|
|
118
129
|
writeFileSync(join(home, ".git"), "not a Git repository");
|
|
119
|
-
const failed = await dreamBegin.execute({}, me, state);
|
|
130
|
+
const failed = await dreamBegin.execute({}, notesToolContext(me, "/work/alpha"), state);
|
|
120
131
|
assert.ok(!failed.ok && failed.error.code === "audit_failed");
|
|
121
132
|
assert.equal(state.pending, undefined);
|
|
122
133
|
assert.equal(state.project, undefined);
|
|
@@ -124,7 +135,7 @@ test("baseline failure releases pending ownership and permits a retry", async (t
|
|
|
124
135
|
const ended = await dreamEnd.execute({}, me, state);
|
|
125
136
|
assert.ok(!ended.ok && ended.error.code === "not_dreaming");
|
|
126
137
|
rmSync(join(home, ".git"));
|
|
127
|
-
assert.ok((await dreamBegin.execute({}, me, state)).ok);
|
|
138
|
+
assert.ok((await dreamBegin.execute({}, notesToolContext(me, "/work/alpha"), state)).ok);
|
|
128
139
|
assert.ok((await dreamEnd.execute({}, me, state)).ok);
|
|
129
140
|
});
|
|
130
141
|
test("dream_begin reports the stored access, and dream reads do not refresh it", async (t) => {
|
|
@@ -133,9 +144,8 @@ test("dream_begin reports the stored access, and dream reads do not refresh it",
|
|
|
133
144
|
const state = {};
|
|
134
145
|
const old = "2026-01-01T08:00:00.000+08:00";
|
|
135
146
|
writeFileSync(join(home, "project", "alpha", "stale.md"), `---\norigin: self\ncreatedAt: ${old}\nupdatedAt: ${old}\nlastAccessed: ${old}\naccessCount: 0\n---\n\nbody`);
|
|
136
|
-
const first = await dreamBegin.execute({}, me, state);
|
|
147
|
+
const first = await dreamBegin.execute({}, notesToolContext(me, "/work/alpha"), state);
|
|
137
148
|
assert.ok(first.ok);
|
|
138
|
-
assert.equal(Check(dreamBegin.outputSchema, first.data), true);
|
|
139
149
|
const row = first.data.files[0];
|
|
140
150
|
assert.equal(row.address, "@projects/alpha/stale.md");
|
|
141
151
|
assert.equal(Date.parse(row.last_accessed), Date.parse(old), "the dream shows the pre-dream access");
|
|
@@ -146,27 +156,59 @@ test("dream_begin reports the stored access, and dream reads do not refresh it",
|
|
|
146
156
|
assert.equal(during.meta.lastAccessed, Date.parse(old));
|
|
147
157
|
assert.equal(during.meta.accessCount, 0, "dream reads leave storage untouched");
|
|
148
158
|
assert.ok((await dreamEnd.execute({}, me, state)).ok);
|
|
149
|
-
const second = await dreamBegin.execute({}, me, state);
|
|
159
|
+
const second = await dreamBegin.execute({}, notesToolContext(me, "/work/alpha"), state);
|
|
150
160
|
assert.ok(second.ok);
|
|
151
161
|
assert.equal(second.data.files[0].last_accessed, row.last_accessed, "a later dream sees the same pre-dream access");
|
|
152
162
|
assert.ok((await dreamEnd.execute({}, me, state)).ok);
|
|
153
163
|
assert.ok((await notesRead.execute({ address: "@project/stale" }, notesToolContext(me, "/work/alpha"))).ok);
|
|
154
164
|
const after = (await createNotesStore(me).list({ glob: "@project/**" }))[0];
|
|
155
165
|
assert.equal(after.meta.accessCount, 1, "ordinary reads still stamp storage");
|
|
156
|
-
const third = await dreamBegin.execute({}, me, state);
|
|
166
|
+
const third = await dreamBegin.execute({}, notesToolContext(me, "/work/alpha"), state);
|
|
157
167
|
assert.ok(third.ok);
|
|
158
168
|
assert.equal(Date.parse(third.data.files[0].last_accessed), after.meta.lastAccessed);
|
|
159
169
|
assert.ok(after.meta.lastAccessed > Date.parse(old));
|
|
160
170
|
assert.ok((await dreamEnd.execute({}, me, state)).ok);
|
|
161
171
|
});
|
|
162
|
-
test("dream_begin
|
|
163
|
-
const { as } = fixture(t);
|
|
172
|
+
test("dream_begin bounds the complete rendered snapshot, not JSON", async (t) => {
|
|
173
|
+
const { alphaDir, as } = fixture(t);
|
|
174
|
+
const me = as("s", "alpha"), state = {};
|
|
175
|
+
t.after(() => abandonDream(state));
|
|
176
|
+
const store = createNotesStore(me);
|
|
177
|
+
for (let i = 0; i < 120; i++)
|
|
178
|
+
await store.write(`@project/note-${i}`, "body", { description: "\\".repeat(160) });
|
|
179
|
+
const result = await dreamBegin.execute({}, notesToolContext(me, alphaDir), state);
|
|
180
|
+
assert.ok(result.ok);
|
|
181
|
+
const text = dreamBegin.render(result);
|
|
182
|
+
assert.ok(Buffer.byteLength(text) <= TOOL_OUTPUT_MAX_BYTES);
|
|
183
|
+
assert.ok(Buffer.byteLength(JSON.stringify(result.data)) > TOOL_OUTPUT_MAX_BYTES, "JSON is not charged");
|
|
184
|
+
assert.ok(result.data.more > 0);
|
|
185
|
+
assert.equal(result.data.files.length + result.data.more, 120);
|
|
186
|
+
assert.match(text, new RegExp(`^dreaming over alpha \\(baseline [0-9a-f]+, project_root ${alphaDir.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\)`));
|
|
187
|
+
assert.match(text, /more matching notes omitted/);
|
|
188
|
+
});
|
|
189
|
+
test("dream_begin rejects invalid directory arguments before locking", async (t) => {
|
|
190
|
+
const { home, alphaDir, as } = fixture(t);
|
|
191
|
+
const me = as("s", "alpha");
|
|
192
|
+
const context = notesToolContext(me, alphaDir);
|
|
164
193
|
const state = {};
|
|
165
|
-
|
|
166
|
-
|
|
194
|
+
const file = join(home, "file");
|
|
195
|
+
writeFileSync(file, "not a directory");
|
|
196
|
+
for (const params of [
|
|
197
|
+
{ cwd: join(home, "missing") },
|
|
198
|
+
{ cwd: file },
|
|
199
|
+
]) {
|
|
200
|
+
const result = await dreamBegin.execute(params, context, state);
|
|
201
|
+
assert.ok(!result.ok && result.error.code === "invalid_cwd");
|
|
202
|
+
assert.deepEqual(state, {});
|
|
203
|
+
assert.equal(existsSync(join(home, ".dream.lock.sqlite")), false);
|
|
204
|
+
}
|
|
205
|
+
assert.ok((await dreamBegin.execute({}, context, state)).ok);
|
|
206
|
+
const already = await dreamBegin.execute({ cwd: file }, context, state);
|
|
207
|
+
assert.ok(!already.ok && already.error.code === "already_dreaming");
|
|
208
|
+
assert.ok((await dreamEnd.execute({}, me, state)).ok);
|
|
167
209
|
});
|
|
168
210
|
test("dream_forget resolves address aliases before authorizing deletion", async (t) => {
|
|
169
|
-
const { home, as } = fixture(t);
|
|
211
|
+
const { home, alphaDir, betaDir, as } = fixture(t);
|
|
170
212
|
const alpha = as("alpha-session", "alpha");
|
|
171
213
|
await createNotesStore(alpha).write("@project/precious", "keep alpha");
|
|
172
214
|
await createNotesStore(alpha).update("@project/precious", undefined, { crumpled: true });
|
|
@@ -175,7 +217,7 @@ test("dream_forget resolves address aliases before authorizing deletion", async
|
|
|
175
217
|
await createNotesStore(as("beta-session", "beta")).write("@project/trash", "delete beta");
|
|
176
218
|
await createNotesStore(as("beta-session", "beta")).update("@project/trash", undefined, { crumpled: true });
|
|
177
219
|
const state = {};
|
|
178
|
-
assert.ok((await dreamBegin.execute({
|
|
220
|
+
assert.ok((await dreamBegin.execute({ cwd: betaDir }, notesToolContext(alpha, alphaDir), state)).ok);
|
|
179
221
|
for (const address of ["@projects/alpha/precious", "@project/precious", "local"]) {
|
|
180
222
|
const refused = await dreamForget.execute({ address }, alpha, state);
|
|
181
223
|
assert.equal(refused.ok, false, `${address} is outside the beta dream`);
|
|
@@ -188,39 +230,42 @@ test("dream_forget resolves address aliases before authorizing deletion", async
|
|
|
188
230
|
assert.ok((await dreamEnd.execute({}, alpha, state)).ok);
|
|
189
231
|
});
|
|
190
232
|
test("named-project mutation receipts carry their project metadata and fit their own schemas", async (t) => {
|
|
191
|
-
const { home, as } = fixture(t);
|
|
233
|
+
const { home, alphaDir, betaDir, dir, as } = fixture(t);
|
|
192
234
|
// A same-basename checkout makes the dreamed notebook carry a sibling hint.
|
|
193
|
-
|
|
194
|
-
|
|
235
|
+
const betaTwoDir = dir(join("two", "beta"));
|
|
236
|
+
assert.equal(projectKey(betaTwoDir, home), "beta-1");
|
|
195
237
|
const me = as("now", "alpha");
|
|
196
238
|
const state = {};
|
|
197
|
-
const ident = () => notesToolContext(dreamingIdentity(me, state),
|
|
239
|
+
const ident = () => notesToolContext(dreamingIdentity(me, state), alphaDir);
|
|
198
240
|
assert.equal((await notesWrite.execute({ address: "@projects/beta-1/rule", content: "x" }, ident())).ok, false, "named projects stay read-only outside a dream");
|
|
199
|
-
|
|
241
|
+
const begun = await dreamBegin.execute({ cwd: betaTwoDir }, notesToolContext(me, alphaDir), state);
|
|
242
|
+
assert.ok(begun.ok);
|
|
243
|
+
const header = dreamBegin.render(begun);
|
|
244
|
+
const esc = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
245
|
+
assert.match(header, new RegExp(`^dreaming over beta-1 \\(baseline [0-9a-f]+, project_root ${esc(betaTwoDir)}\\)\\n Same-basename projects: beta \\(${esc(betaDir)}\\)\\n`));
|
|
246
|
+
assert.doesNotMatch(header, /\(project_root/, "rows never repeat the header's project context");
|
|
200
247
|
const written = await notesWrite.execute({ address: "@projects/beta-1/rule", content: "merged" }, ident());
|
|
201
248
|
assert.ok(written.ok);
|
|
202
|
-
assert.equal(written.data.project_root,
|
|
203
|
-
assert.deepEqual(written.data.project_siblings, [{ name: "beta", path:
|
|
204
|
-
assert.equal(Check(notesWrite.outputSchema, written.data), true, "notes_write accepts its own named-project receipt");
|
|
249
|
+
assert.equal(written.data.project_root, betaTwoDir);
|
|
250
|
+
assert.deepEqual(written.data.project_siblings, [{ name: "beta", path: betaDir }]);
|
|
205
251
|
const updated = await notesUpdate.execute({ address: "@projects/beta-1/rule", edits: [{ oldText: "merged", newText: "done" }] }, ident());
|
|
206
252
|
assert.ok(updated.ok);
|
|
207
|
-
assert.equal(updated.data.project_root,
|
|
208
|
-
assert.deepEqual(updated.data.project_siblings, [{ name: "beta", path:
|
|
209
|
-
assert.equal(Check(notesUpdate.outputSchema, updated.data), true, "notes_update accepts its own named-project receipt");
|
|
253
|
+
assert.equal(updated.data.project_root, betaTwoDir);
|
|
254
|
+
assert.deepEqual(updated.data.project_siblings, [{ name: "beta", path: betaDir }]);
|
|
210
255
|
assert.ok((await notesUpdate.execute({ address: "@projects/beta-1/rule", crumpled: true }, ident())).ok);
|
|
211
256
|
const forgotten = await dreamForget.execute({ address: "@projects/beta-1/rule" }, me, state);
|
|
212
257
|
assert.ok(forgotten.ok);
|
|
213
|
-
assert.equal(forgotten.data.project_root,
|
|
214
|
-
assert.deepEqual(forgotten.data.project_siblings, [{ name: "beta", path:
|
|
215
|
-
assert.equal(Check(dreamForget.outputSchema, forgotten.data), true, "dream_forget accepts its own named-project receipt");
|
|
258
|
+
assert.equal(forgotten.data.project_root, betaTwoDir);
|
|
259
|
+
assert.deepEqual(forgotten.data.project_siblings, [{ name: "beta", path: betaDir }]);
|
|
216
260
|
assert.ok((await dreamEnd.execute({}, me, state)).ok);
|
|
217
261
|
});
|
|
218
262
|
test("a killed dream releases its lock without blocking project claims or note writes", { timeout: 20_000 }, async (t) => {
|
|
219
263
|
const { as } = fixture(t);
|
|
220
264
|
const script = `
|
|
221
265
|
import { dreamBegin } from ${JSON.stringify(new URL("../src/tools/dream.js", import.meta.url).href)};
|
|
266
|
+
import { notesToolContext } from ${JSON.stringify(new URL("../src/tools/notes-context.js", import.meta.url).href)};
|
|
222
267
|
globalThis.dream = {};
|
|
223
|
-
const result = await dreamBegin.execute({}, JSON.parse(process.argv[1]), globalThis.dream);
|
|
268
|
+
const result = await dreamBegin.execute({}, notesToolContext(JSON.parse(process.argv[1]), "/work/alpha"), globalThis.dream);
|
|
224
269
|
if (!result.ok) throw new Error(result.error.message);
|
|
225
270
|
process.send("open");
|
|
226
271
|
setInterval(() => {}, 60000);
|
|
@@ -231,18 +276,18 @@ test("a killed dream releases its lock without blocking project claims or note w
|
|
|
231
276
|
assert.equal(await Promise.race([once(child, "message").then(([message]) => message), exit]), "open");
|
|
232
277
|
const next = as("next", "beta");
|
|
233
278
|
const state = {};
|
|
234
|
-
const refused = await dreamBegin.execute({}, next, state);
|
|
279
|
+
const refused = await dreamBegin.execute({}, notesToolContext(next, "/work/alpha"), state);
|
|
235
280
|
assert.ok(!refused.ok && refused.error.code === "already_dreaming");
|
|
236
281
|
assert.equal(projectKey("/work/another", next.home), "another");
|
|
237
282
|
await createNotesStore(next).write("@project/live", "still writable");
|
|
238
283
|
assert.ok(child.kill("SIGKILL"));
|
|
239
284
|
assert.deepEqual(await exit, [null, "SIGKILL"]);
|
|
240
|
-
assert.ok((await dreamBegin.execute({}, next, state)).ok);
|
|
285
|
+
assert.ok((await dreamBegin.execute({}, notesToolContext(next, "/work/alpha"), state)).ok);
|
|
241
286
|
assert.equal((await createNotesStore(next).read("@project/live"))?.body, "still writable");
|
|
242
287
|
assert.ok((await dreamEnd.execute({}, next, state)).ok);
|
|
243
288
|
});
|
|
244
289
|
test("a notes-home lock prevents interleaved dream Git audits", async (t) => {
|
|
245
|
-
const { home, as } = fixture(t);
|
|
290
|
+
const { home, alphaDir, betaDir, as } = fixture(t);
|
|
246
291
|
const alpha = as("alpha-session", "alpha"), beta = as("beta-session", "beta");
|
|
247
292
|
await createNotesStore(alpha).write("@project/note", "before alpha");
|
|
248
293
|
await createNotesStore(beta).write("@project/note", "before beta");
|
|
@@ -251,10 +296,10 @@ test("a notes-home lock prevents interleaved dream Git audits", async (t) => {
|
|
|
251
296
|
writeFileSync(join(staged, ".project"), "{}");
|
|
252
297
|
projectKey("/work/another", home);
|
|
253
298
|
const alphaState = {}, betaState = {};
|
|
254
|
-
const begun = await dreamBegin.execute({
|
|
299
|
+
const begun = await dreamBegin.execute({}, notesToolContext(alpha, alphaDir), alphaState);
|
|
255
300
|
assert.ok(begun.ok);
|
|
256
|
-
assert.ok((await notesWrite.execute({ address: "@project/note", content: "after alpha" }, notesToolContext(dreamingIdentity(alpha, alphaState),
|
|
257
|
-
const refused = await dreamBegin.execute({
|
|
301
|
+
assert.ok((await notesWrite.execute({ address: "@project/note", content: "after alpha" }, notesToolContext(dreamingIdentity(alpha, alphaState), alphaDir))).ok);
|
|
302
|
+
const refused = await dreamBegin.execute({}, notesToolContext(beta, betaDir), betaState);
|
|
258
303
|
assert.equal(refused.ok, false, "a different project cannot share the home's Git audit");
|
|
259
304
|
assert.ok(!refused.ok && refused.error.code === "already_dreaming");
|
|
260
305
|
assert.deepEqual(betaState, {}, "a refused dream publishes no state");
|
|
@@ -269,6 +314,6 @@ test("a notes-home lock prevents interleaved dream Git audits", async (t) => {
|
|
|
269
314
|
assert.match(changed, /project\/alpha\/note\.md/);
|
|
270
315
|
assert.doesNotMatch(changed, /project\/beta\/note\.md/);
|
|
271
316
|
assert.equal(execFileSync("git", ["status", "--porcelain"], { cwd: home, encoding: "utf8" }), "");
|
|
272
|
-
assert.ok((await dreamBegin.execute({
|
|
317
|
+
assert.ok((await dreamBegin.execute({}, notesToolContext(beta, betaDir), betaState)).ok, "the next dream can start after the home lock is released");
|
|
273
318
|
assert.ok((await dreamEnd.execute({}, beta, betaState)).ok);
|
|
274
319
|
});
|
package/dist/test/dsh.test.js
CHANGED
|
@@ -9,7 +9,7 @@ import { join } from "node:path";
|
|
|
9
9
|
import { resolveProjectNamespace } from "../src/notes/project-namespace.js";
|
|
10
10
|
import { WINDOW_IDENTITY_CLOSE_TAG, WINDOW_IDENTITY_OPEN_TAG } from "../src/boot/text.js";
|
|
11
11
|
import { notesList, notesRead, notesUpdate, notesWrite } from "../src/tools/notes.js";
|
|
12
|
-
import { historyList, historyRead } from "../src/tools/history.js";
|
|
12
|
+
import { historyList, historySearch, historyRead } from "../src/tools/history.js";
|
|
13
13
|
import { notesToolContext } from "../src/tools/notes-context.js";
|
|
14
14
|
import { success } from "../src/result.js";
|
|
15
15
|
import { createNotesStore } from "../src/notes/index.js";
|
|
@@ -27,9 +27,13 @@ function system(request) { return typeof request.system === "string" ? request.s
|
|
|
27
27
|
function code(expected) { return (error) => error?.code === expected; }
|
|
28
28
|
test("dsh preserves shared tool and parameter descriptions verbatim", async (t) => {
|
|
29
29
|
const { ctx } = await dshFixture(t);
|
|
30
|
-
for (const operation of [notesWrite, notesUpdate, notesRead, notesList, historyList, historyRead]) {
|
|
30
|
+
for (const operation of [notesWrite, notesUpdate, notesRead, notesList, historyList, historySearch, historyRead]) {
|
|
31
31
|
const registered = ctx.tools.get(operation.name);
|
|
32
32
|
assert.equal(registered.description, operation.description);
|
|
33
|
+
if (operation.name === "notes_read")
|
|
34
|
+
assert.notDeepEqual(registered.output?.schema, { type: "string" });
|
|
35
|
+
else
|
|
36
|
+
assert.deepEqual(registered.output?.schema, { type: "string" });
|
|
33
37
|
const properties = registered.parameters.properties;
|
|
34
38
|
for (const [name, parameter] of Object.entries(operation.parameters.properties)) {
|
|
35
39
|
assert.equal(properties[name].description, parameter.description, `${operation.name}.${name}`);
|
|
@@ -45,19 +49,21 @@ test("dsh registered tools query other DSH sessions and foreign Pi files through
|
|
|
45
49
|
const reader = await create(undefined, "reader"), target = await create(undefined, "target");
|
|
46
50
|
target.session.append("user/message", prompt("DSH needle"), { surfaceOp: "append" });
|
|
47
51
|
const invoke = (name, args) => ctx.tools.execute({ name, arguments: args, agent: reader, callId: ToolCallId("cross-session"), signal: new AbortController().signal });
|
|
48
|
-
const listed = await invoke("
|
|
52
|
+
const listed = await invoke("history_search", { session: "dsh:tar", query: "needle" });
|
|
49
53
|
assert.equal(listed.isError, false, JSON.stringify(listed));
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
assert.equal(typeof listed.value, "string");
|
|
55
|
+
const header = /^=== session dsh:target ===\nseq (\d+) \| user(?: \|[^\n]*)?$/m.exec(listed.value);
|
|
56
|
+
assert.ok(header);
|
|
57
|
+
const read = await invoke("history_read", { session: "dsh:target", seq: Number(header[1]) });
|
|
53
58
|
assert.equal(read.isError, false);
|
|
54
|
-
assert.
|
|
59
|
+
assert.match(read.value, /\n\nDSH needle$/);
|
|
55
60
|
const foreign = await invoke("history_read", { session: "pi:foreign", seq: 1 });
|
|
56
61
|
assert.equal(foreign.isError, false);
|
|
57
|
-
assert.
|
|
58
|
-
const across = await invoke("
|
|
62
|
+
assert.match(foreign.value, /^session pi:foreign-pi \| seq 1 \| user/);
|
|
63
|
+
const across = await invoke("history_search", { session: "*", query: "needle" });
|
|
59
64
|
assert.equal(across.isError, false, JSON.stringify(across));
|
|
60
|
-
assert.
|
|
65
|
+
assert.match(across.value, /^=== session dsh:target ===\nseq /m);
|
|
66
|
+
assert.match(across.value, /^=== session pi:foreign-pi ===\nseq /m);
|
|
61
67
|
});
|
|
62
68
|
test("dsh boot freezes across note writes, rotates before the next wire request, and keeps raw history", async (t) => {
|
|
63
69
|
const { ctx, engine, create, mock } = await dshFixture(t);
|
|
@@ -149,10 +155,12 @@ test("dsh native fork rebinds boot and notes tools to the child without changing
|
|
|
149
155
|
assert.equal(read.isError, false);
|
|
150
156
|
if (!read.isError)
|
|
151
157
|
assert.equal(read.value.text, "child-only recovery");
|
|
152
|
-
const history = await ctx.tools.execute({ name: "
|
|
158
|
+
const history = await ctx.tools.execute({ name: "history_search", arguments: { query: "inherited conversation before reset", roles: ["user"] }, agent: child, callId: ToolCallId("fork-history"), signal: new AbortController().signal });
|
|
153
159
|
assert.equal(history.isError, false);
|
|
154
|
-
if (!history.isError)
|
|
155
|
-
assert.
|
|
160
|
+
if (!history.isError) {
|
|
161
|
+
assert.match(history.value, /inherited conversation before reset/);
|
|
162
|
+
assert.equal((history.value.match(/^seq \d+ \| user(?: \| [^|\n]+)?$/gm) ?? []).length, 1);
|
|
163
|
+
}
|
|
156
164
|
await run(child, "continue in child");
|
|
157
165
|
assert.ok(system(mock.requests.at(-1)).includes(snapshot.boot));
|
|
158
166
|
assert.equal(engine.windows.get(parent.session).snapshot, parentSnapshot);
|
|
@@ -365,15 +373,20 @@ test("dsh explicit resets survive auto:false; shared tool reads and expected err
|
|
|
365
373
|
assert.equal(engine.windows.get(agent.session).snapshot.window, 1);
|
|
366
374
|
assert.equal(engine.automaticListenerPresent, true);
|
|
367
375
|
const call = (name, args) => ctx.tools.execute({ name, arguments: args, agent, callId: ToolCallId(`test-${name}`), signal: new AbortController().signal });
|
|
368
|
-
const list = await call("
|
|
376
|
+
const list = await call("history_search", { query: "keep raw", roles: ["user"] });
|
|
369
377
|
assert.equal(list.isError, false);
|
|
370
378
|
if (!list.isError) {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
379
|
+
assert.equal(typeof list.value, "string");
|
|
380
|
+
const text = list.value;
|
|
381
|
+
assert.match(text, /keep raw history/);
|
|
382
|
+
const headers = [...text.matchAll(/^seq (\d+) \| user(?: \| [^|\n]+)?$/gm)];
|
|
383
|
+
assert.equal(headers.length, 1);
|
|
384
|
+
const read = await call("history_read", { seq: Number(headers[0][1]), offset_chars: 5, max_chars: 3 });
|
|
374
385
|
assert.equal(read.isError, false);
|
|
375
|
-
if (!read.isError)
|
|
376
|
-
assert.equal(read.value
|
|
386
|
+
if (!read.isError) {
|
|
387
|
+
assert.equal(typeof read.value, "string");
|
|
388
|
+
assert.match(read.value, /\n\nraw\n\n\[truncated at \d+\/\d+ chars; continue at offset_chars=8\]/);
|
|
389
|
+
}
|
|
377
390
|
}
|
|
378
391
|
const invalidHistory = await call("history_list", { limit: 0 });
|
|
379
392
|
assert.equal(invalidHistory.isError, true);
|
|
@@ -385,6 +398,8 @@ test("dsh explicit resets survive auto:false; shared tool reads and expected err
|
|
|
385
398
|
assert.equal(invalid.error.info?.code, "INVALID_PARAMS");
|
|
386
399
|
const written = await call("notes_write", { address: "@project/decision", content: "the decision" });
|
|
387
400
|
assert.equal(written.isError, false);
|
|
401
|
+
if (!written.isError)
|
|
402
|
+
assert.match(written.value, /@project\/decision/);
|
|
388
403
|
const note = await call("notes_read", { address: "@project/decision", offset_chars: 4, max_chars: 8 });
|
|
389
404
|
assert.equal(note.isError, false);
|
|
390
405
|
if (!note.isError)
|
|
@@ -59,7 +59,7 @@ export function dependencyViolations(root, entries, options, runtimeDependencies
|
|
|
59
59
|
const local = (file) => file.startsWith(sourceRoot + sep) || file.startsWith(pluginRoot + sep);
|
|
60
60
|
const adapter = (file) => {
|
|
61
61
|
const path = display(file);
|
|
62
|
-
return /^plugins\/(pi|claude|dsh|codex)\//.exec(path)?.[1]
|
|
62
|
+
return /^plugins\/(pi|claude|dsh|codex|antigravity|mcp)\//.exec(path)?.[1]
|
|
63
63
|
?? packageAdapter(file.split(sep).join("/").split("/node_modules/").at(-1));
|
|
64
64
|
};
|
|
65
65
|
const walk = (file, chain, fromHistory = false) => {
|
|
@@ -93,7 +93,7 @@ export function dependencyViolations(root, entries, options, runtimeDependencies
|
|
|
93
93
|
const target = realpathSync(resolution.resolvedFileName);
|
|
94
94
|
const targetOwner = adapter(target);
|
|
95
95
|
if ((history && target.startsWith(toolsRoot + sep)) ||
|
|
96
|
-
(targetOwner && targetOwner !== owner) ||
|
|
96
|
+
(targetOwner && targetOwner !== owner && !(targetOwner === "mcp" && (owner === "codex" || owner === "antigravity"))) ||
|
|
97
97
|
(owner && target.startsWith(notesRoot + sep) && target !== notesEntry) ||
|
|
98
98
|
(owner === "dsh" && target.startsWith(resolve(sourceRoot, "dream") + sep)) ||
|
|
99
99
|
(!owner && target.startsWith(pluginRoot + sep))) {
|
|
@@ -43,6 +43,10 @@ export type SentMessage = {
|
|
|
43
43
|
triggerTurn?: boolean;
|
|
44
44
|
} | undefined;
|
|
45
45
|
};
|
|
46
|
+
export type CapturedEvents = {
|
|
47
|
+
on(channel: string, handler: (data: unknown) => void): () => void;
|
|
48
|
+
emit(channel: string, data: unknown): void;
|
|
49
|
+
};
|
|
46
50
|
export type Captured = {
|
|
47
51
|
tools: Map<string, ToolDefinition>;
|
|
48
52
|
handlers: Map<string, EventHandler[]>;
|
|
@@ -50,6 +54,8 @@ export type Captured = {
|
|
|
50
54
|
sent: SentMessage[];
|
|
51
55
|
contextMessages: unknown[];
|
|
52
56
|
flags: string[];
|
|
57
|
+
flagValues: Map<string, boolean | string>;
|
|
58
|
+
events: CapturedEvents;
|
|
53
59
|
};
|
|
54
60
|
export type CommandOptions = Omit<RegisteredCommand, "name" | "sourceInfo">;
|
|
55
61
|
export type CompactionHookResult = {
|
|
@@ -68,7 +74,9 @@ export declare function objectSchema(tool: ToolDefinition | undefined): {
|
|
|
68
74
|
required?: string[];
|
|
69
75
|
} | undefined;
|
|
70
76
|
export declare function manager(persisted?: boolean): SessionManager;
|
|
71
|
-
export declare function makeExtension(sessionManager: SessionManager, settingsManager?: SettingsManager
|
|
77
|
+
export declare function makeExtension(sessionManager: SessionManager, settingsManager?: SettingsManager, options?: {
|
|
78
|
+
flags?: Record<string, boolean | string>;
|
|
79
|
+
}): Captured;
|
|
72
80
|
/** Compare boot addresses to the host projection, without freezing its prose. */
|
|
73
81
|
export declare function assertBootHistory(body: string, projection: HistoryProjection): void;
|
|
74
82
|
export declare function explicitBoot(ctx: ExtensionContext, currentWindowId: string, previousWindowId: string | undefined): Promise<string>;
|
|
@@ -92,7 +100,11 @@ export declare function call(captured: Captured, name: string, params: Record<st
|
|
|
92
100
|
export declare function toolContext(ctx: ExtensionContext, callable?: readonly AgentTool[]): ExtensionToolContext;
|
|
93
101
|
/** Decoded JSON of a tool that has not moved to structured outcomes: reset and budget tools only. */
|
|
94
102
|
export declare function resultJson<T>(result: AgentToolResult<unknown>): T;
|
|
95
|
-
/**
|
|
103
|
+
/** Plain-text operation success, with no structured wire payload. */
|
|
104
|
+
export declare function resultText(result: AgentToolResult<unknown>): string;
|
|
105
|
+
/** Plain-text operation refusal, preserving its error code and message. */
|
|
106
|
+
export declare function resultTextError(result: AgentToolResult<unknown>): OperationError;
|
|
107
|
+
/** Data of a successful notes_read outcome, asserting both the structured success and the non-error result. */
|
|
96
108
|
export declare function resultData<T>(result: AgentToolResult<unknown>): T;
|
|
97
109
|
/** The typed refusal of a failed outcome, asserting the error result and the refusal shape. */
|
|
98
110
|
export declare function resultError(result: AgentToolResult<unknown>): OperationError;
|
|
@@ -113,13 +125,66 @@ export declare function resultRead<T extends object = ReadIdentity>(result: Agen
|
|
|
113
125
|
export declare function assertWithinBudget(result: AgentToolResult<unknown>, message: string): void;
|
|
114
126
|
export declare function runManualCompact(captured: Captured, ctx: ExtensionContext): Promise<CompactionHookResult>;
|
|
115
127
|
export declare function runHandlers(captured: Captured, name: string, event: unknown, ctx: ExtensionContext): Promise<void>;
|
|
128
|
+
export type InputFixture = {
|
|
129
|
+
type: "input";
|
|
130
|
+
text: string;
|
|
131
|
+
source: string;
|
|
132
|
+
streamingBehavior?: "steer" | "followUp";
|
|
133
|
+
images?: unknown[];
|
|
134
|
+
};
|
|
135
|
+
/** Run every registered input handler in order, as Pi does before appending the prompt. */
|
|
136
|
+
export declare function runInput(captured: Captured, ctx: ExtensionContext, event?: InputFixture): Promise<void>;
|
|
137
|
+
export type BeforeAgentStartFixture = {
|
|
138
|
+
type: "before_agent_start";
|
|
139
|
+
messageType: "user" | "custom";
|
|
140
|
+
prompt?: string;
|
|
141
|
+
message?: {
|
|
142
|
+
role: "custom";
|
|
143
|
+
customType: string;
|
|
144
|
+
content: string;
|
|
145
|
+
display: boolean;
|
|
146
|
+
timestamp: number;
|
|
147
|
+
};
|
|
148
|
+
systemPrompt: string;
|
|
149
|
+
systemPromptOptions: {
|
|
150
|
+
sections: Record<string, string>;
|
|
151
|
+
skills: Array<{
|
|
152
|
+
name: string;
|
|
153
|
+
description: string;
|
|
154
|
+
filePath: string;
|
|
155
|
+
baseDir: string;
|
|
156
|
+
sourceInfo: Record<string, unknown>;
|
|
157
|
+
disableModelInvocation: boolean;
|
|
158
|
+
}>;
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
/** Run before_agent_start with an event shaped like Pi's, returning the handler's result and the mutated event. */
|
|
162
|
+
export declare function runBeforeAgentStart(captured: Captured, ctx: ExtensionContext, options?: {
|
|
163
|
+
messageType?: "user" | "custom";
|
|
164
|
+
message?: {
|
|
165
|
+
customType: string;
|
|
166
|
+
};
|
|
167
|
+
skills?: Array<{
|
|
168
|
+
name: string;
|
|
169
|
+
filePath: string;
|
|
170
|
+
}>;
|
|
171
|
+
}): Promise<{
|
|
172
|
+
event: BeforeAgentStartFixture;
|
|
173
|
+
result: {
|
|
174
|
+
message?: {
|
|
175
|
+
customType?: string;
|
|
176
|
+
};
|
|
177
|
+
} | undefined;
|
|
178
|
+
}>;
|
|
116
179
|
export declare function runCommand(captured: Captured, name: string, args: string, ctx: ExtensionContext): Promise<Notice[]>;
|
|
117
180
|
export type ContextHookResult = {
|
|
118
181
|
messages: unknown[];
|
|
119
182
|
} | undefined;
|
|
120
183
|
export declare function runContextHook(captured: Captured, ctx: ExtensionContext, eventOverride?: Record<string, unknown>): Promise<ContextHookResult>;
|
|
121
184
|
export declare function runContextWithSystemHook(captured: Captured, ctx: ExtensionContext, messages: unknown[]): Promise<ContextHookResult>;
|
|
122
|
-
export declare function commitTurnEndBoundary(captured: Captured, sessionManager: SessionManager, ctx: ExtensionContext
|
|
185
|
+
export declare function commitTurnEndBoundary(captured: Captured, sessionManager: SessionManager, ctx: ExtensionContext, options?: {
|
|
186
|
+
stopReason?: "stop" | "toolUse";
|
|
187
|
+
}): Promise<{
|
|
123
188
|
entries: SessionBoundaryDraft[];
|
|
124
189
|
continue: boolean;
|
|
125
190
|
}>;
|