notesoup 0.51.9 → 0.52.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.
- package/README.md +3 -10
- package/dist/plugins/claude/src/history.js +3 -7
- package/dist/plugins/pi/notes/tools.d.ts +1 -1
- package/dist/plugins/pi/notes/tools.js +26 -7
- package/dist/plugins/pi/tool-result.d.ts +3 -2
- package/dist/plugins/pi/tool-result.js +3 -1
- package/dist/src/dream/git.d.ts +2 -3
- package/dist/src/dream/git.js +3 -8
- package/dist/src/dream/lock.d.ts +10 -27
- package/dist/src/dream/lock.js +16 -79
- package/dist/src/notes/errors.d.ts +1 -1
- package/dist/src/notes/identity.d.ts +2 -0
- package/dist/src/notes/identity.js +3 -1
- package/dist/src/notes/store.d.ts +2 -0
- package/dist/src/notes/store.js +40 -4
- package/dist/src/tools/dream.d.ts +113 -0
- package/dist/src/tools/dream.js +112 -0
- package/dist/src/tools/notes.d.ts +15 -1
- package/dist/src/tools/notes.js +4 -4
- package/dist/test/claude-history.test.js +18 -2
- package/dist/test/claude-mod.test.js +115 -30
- package/dist/test/dependencies.test.js +3 -6
- package/dist/test/dream-skill.test.js +2 -3
- package/dist/test/dream-tools.test.js +67 -0
- package/docs/claude-code-mod.md +1 -1
- package/docs/notes-library.md +1 -1
- package/docs/skills.md +12 -15
- package/package.json +2 -5
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +30 -22
- package/plugins/claude/hooks/register.ts +52 -33
- package/plugins/claude/src/history.ts +3 -6
- package/plugins/pi/notes/tools.ts +25 -8
- package/plugins/pi/tool-result.ts +4 -1
- package/src/dream/git.ts +3 -8
- package/src/dream/lock.ts +18 -66
- package/src/notes/errors.ts +1 -1
- package/src/notes/identity.ts +4 -1
- package/src/notes/store.ts +37 -4
- package/src/tools/dream.ts +112 -0
- package/src/tools/notes.ts +4 -4
- package/dist/plugins/pi/dream/cli.d.ts +0 -10
- package/dist/plugins/pi/dream/cli.js +0 -173
- package/dist/plugins/pi/dream/runner.d.ts +0 -27
- package/dist/plugins/pi/dream/runner.js +0 -91
- package/dist/plugins/pi/dream/settings.d.ts +0 -7
- package/dist/plugins/pi/dream/settings.js +0 -17
- package/dist/src/dream/doctor.d.ts +0 -2
- package/dist/src/dream/doctor.js +0 -161
- package/dist/src/dream/gates.d.ts +0 -10
- package/dist/src/dream/gates.js +0 -26
- package/dist/src/dream/jail.d.ts +0 -11
- package/dist/src/dream/jail.js +0 -71
- package/dist/src/dream/report.d.ts +0 -7
- package/dist/src/dream/report.js +0 -34
- package/dist/src/dream/result.d.ts +0 -9
- package/dist/src/dream/settings.d.ts +0 -9
- package/dist/src/dream/settings.js +0 -16
- package/dist/test/doctor.test.d.ts +0 -1
- package/dist/test/doctor.test.js +0 -37
- package/dist/test/dream.test.d.ts +0 -1
- package/dist/test/dream.test.js +0 -150
- package/plugins/pi/dream/cli.ts +0 -118
- package/plugins/pi/dream/runner.ts +0 -92
- package/plugins/pi/dream/settings.ts +0 -17
- package/src/dream/doctor.ts +0 -118
- package/src/dream/gates.ts +0 -26
- package/src/dream/jail.ts +0 -62
- package/src/dream/report.ts +0 -32
- package/src/dream/result.ts +0 -2
- package/src/dream/settings.ts +0 -19
- /package/dist/{src/dream/result.js → test/dream-tools.test.d.ts} +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/** Dream operations: open one project's notes for consolidation, delete crumpled notes, close. */
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
import { createNotesStore, noteIdentity } from "../notes/index.js";
|
|
4
|
+
import { projectHomes } from "../notes/project-home.js";
|
|
5
|
+
import { gitCommit } from "../dream/git.js";
|
|
6
|
+
import { acquireDreamLock, dreamLockPath, releaseDreamLock } from "../dream/lock.js";
|
|
7
|
+
import { failure, renderOutcome, resultSchema, success } from "./result.js";
|
|
8
|
+
import { failureOf, listedFile, NotesListDataSchema, renderListData, snapshot } from "./notes.js";
|
|
9
|
+
/** Drop an open dream without an end commit, e.g. when its session shuts down. */
|
|
10
|
+
export function abandonDream(state) {
|
|
11
|
+
if (state.lock)
|
|
12
|
+
releaseDreamLock(state.lock);
|
|
13
|
+
delete state.project;
|
|
14
|
+
delete state.lock;
|
|
15
|
+
}
|
|
16
|
+
/** The identity a store uses while `state` holds an open dream. */
|
|
17
|
+
export function dreamingIdentity(identity, state) {
|
|
18
|
+
return state.project === undefined ? identity : { ...identity, dreaming: state.project };
|
|
19
|
+
}
|
|
20
|
+
const NOT_DREAMING = "No dream is open; call dream_begin first.";
|
|
21
|
+
export const dreamBeginParameters = Type.Object({
|
|
22
|
+
project: Type.Optional(Type.String({ description: "(optional, default this project) Project name, as in @projects/<name>/." })),
|
|
23
|
+
}, { additionalProperties: false });
|
|
24
|
+
export const DreamBeginDataSchema = Type.Object({ project: Type.String(), baseline: Type.String(), ...NotesListDataSchema.properties }, { additionalProperties: false });
|
|
25
|
+
function renderBeginData(data) {
|
|
26
|
+
return `dreaming over ${data.project} (baseline ${data.baseline})\n${renderListData(data)}`;
|
|
27
|
+
}
|
|
28
|
+
export const dreamBegin = {
|
|
29
|
+
name: "dream_begin", label: "Dream begin",
|
|
30
|
+
description: "Dream: open one project's notes for consolidation, one project at a time. Lists its @projects/<name>/ notes and every session note born in it, crumpled ones included. Until dream_end, notes_write/notes_update can edit those addresses and reads leave no access stamp. Takes the project's dream lock and commits a Git baseline of the notes home.",
|
|
31
|
+
parameters: dreamBeginParameters, outputSchema: resultSchema(DreamBeginDataSchema),
|
|
32
|
+
async execute(params, identity, state) {
|
|
33
|
+
if (state.project !== undefined)
|
|
34
|
+
return failure("already_dreaming", `Already dreaming over ${state.project}; call dream_end before opening another project.`);
|
|
35
|
+
const project = params.project ?? identity.projectKey;
|
|
36
|
+
if (project !== identity.projectKey && !projectHomes(identity.home).some(home => home.name === project)) {
|
|
37
|
+
return failure("not_found", `No project named ${JSON.stringify(project)}; notes_list with glob @projects/*/** shows the names.`);
|
|
38
|
+
}
|
|
39
|
+
const lock = acquireDreamLock(dreamLockPath(identity.home, project));
|
|
40
|
+
if (!lock)
|
|
41
|
+
return failure("already_dreaming", `Another dream holds ${dreamLockPath(identity.home, project)}. If none is running, delete that file by hand.`);
|
|
42
|
+
try {
|
|
43
|
+
const store = createNotesStore({ ...identity, dreaming: project });
|
|
44
|
+
const rows = [];
|
|
45
|
+
const unavailable = [];
|
|
46
|
+
for (const crumpled of [false, true]) {
|
|
47
|
+
for (const glob of [`@projects/${project}/**`, "@sessions/*/**"]) {
|
|
48
|
+
const result = await store.listWithStatus({ glob, crumpled });
|
|
49
|
+
rows.push(...result.rows.filter(row => row.scope === "project" || row.meta.project === project));
|
|
50
|
+
unavailable.push(...result.status.homesUnavailable);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
rows.sort((a, b) => b.meta.updatedAt - a.meta.updatedAt || a.address.localeCompare(b.address));
|
|
54
|
+
const listed = snapshot(rows.map(row => listedFile(row, identity)), undefined, { homesUnavailable: unavailable }, renderListData);
|
|
55
|
+
if (!listed.ok) {
|
|
56
|
+
releaseDreamLock(lock);
|
|
57
|
+
return listed;
|
|
58
|
+
}
|
|
59
|
+
const baseline = gitCommit(identity.home, `dream baseline ${project}`);
|
|
60
|
+
if (!baseline.ok) {
|
|
61
|
+
releaseDreamLock(lock);
|
|
62
|
+
return failure("audit_failed", `Couldn't commit the Git baseline, so nothing could be rolled back; no dream was opened: ${baseline.error}`);
|
|
63
|
+
}
|
|
64
|
+
Object.assign(state, { project, lock });
|
|
65
|
+
return success({ project, baseline: baseline.commit, ...listed.data });
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
releaseDreamLock(lock);
|
|
69
|
+
return failureOf(error);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
render: (result) => renderOutcome(result, renderBeginData),
|
|
73
|
+
};
|
|
74
|
+
export const dreamForgetParameters = Type.Object({ address: Type.String() }, { additionalProperties: false });
|
|
75
|
+
export const DreamForgetDataSchema = Type.Object({ address: Type.String(), project_key: Type.Optional(Type.String()) }, { additionalProperties: false });
|
|
76
|
+
export const dreamForget = {
|
|
77
|
+
name: "dream_forget", label: "Dream forget",
|
|
78
|
+
description: "Dream: permanently delete one crumpled note in the project being dreamed over, or in @human/, @self/, @model/. Crumple it first; live notes refuse.",
|
|
79
|
+
parameters: dreamForgetParameters, outputSchema: resultSchema(DreamForgetDataSchema),
|
|
80
|
+
async execute(params, identity, state) {
|
|
81
|
+
if (state.project === undefined)
|
|
82
|
+
return failure("not_dreaming", NOT_DREAMING);
|
|
83
|
+
try {
|
|
84
|
+
const dreaming = dreamingIdentity(identity, state);
|
|
85
|
+
await createNotesStore(dreaming).forget(params.address);
|
|
86
|
+
return success(noteIdentity(dreaming, params.address));
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
return failureOf(error);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
render: (result) => renderOutcome(result, data => `forgot ${data.address}`),
|
|
93
|
+
};
|
|
94
|
+
export const dreamEndParameters = Type.Object({}, { additionalProperties: false });
|
|
95
|
+
export const DreamEndDataSchema = Type.Object({ project: Type.String(), commit: Type.Optional(Type.String()), audit_error: Type.Optional(Type.String()) }, { additionalProperties: false });
|
|
96
|
+
export const dreamEnd = {
|
|
97
|
+
name: "dream_end", label: "Dream end",
|
|
98
|
+
description: "Dream: close the open dream. Commits the dream's changes to the notes home's Git and releases the lock; the project's notes are read-only again and reads stamp access again.",
|
|
99
|
+
parameters: dreamEndParameters, outputSchema: resultSchema(DreamEndDataSchema),
|
|
100
|
+
async execute(_params, identity, state) {
|
|
101
|
+
const project = state.project;
|
|
102
|
+
if (project === undefined)
|
|
103
|
+
return failure("not_dreaming", NOT_DREAMING);
|
|
104
|
+
// The dream closes even when the audit commit fails; the uncommitted changes stay in the work tree.
|
|
105
|
+
const audit = gitCommit(identity.home, `dream ${project}`);
|
|
106
|
+
abandonDream(state);
|
|
107
|
+
return success(audit.ok ? { project, commit: audit.commit } : { project, audit_error: audit.error });
|
|
108
|
+
},
|
|
109
|
+
render: (result) => renderOutcome(result, data => data.commit !== undefined
|
|
110
|
+
? `woke from ${data.project} (commit ${data.commit})`
|
|
111
|
+
: `woke from ${data.project}; the Git commit failed, changes are uncommitted: ${data.audit_error}`),
|
|
112
|
+
};
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { NotesIdentity } from "../notes/identity.js";
|
|
2
2
|
import { Type, type Static } from "typebox";
|
|
3
|
-
import { type NoteChange } from "../notes/index.js";
|
|
3
|
+
import { type NoteChange, type NoteQueryStatus, type NoteRow } from "../notes/index.js";
|
|
4
4
|
import { type Outcome } from "./result.js";
|
|
5
|
+
/**
|
|
6
|
+
* Typed refusal. Every fact a caller needs is already in the message; there is no separate context.
|
|
7
|
+
* Convert expected refusals; unexpected errors propagate unchanged.
|
|
8
|
+
*/
|
|
9
|
+
export declare function failureOf(error: unknown): Outcome<never>;
|
|
5
10
|
export declare const NoteMetadataSchema: Type.TObject<{
|
|
6
11
|
origin: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"self">, Type.TLiteral<"external">]>;
|
|
7
12
|
created_at: Type.TString;
|
|
@@ -83,6 +88,14 @@ export declare const NotesSearchDataSchema: Type.TObject<{
|
|
|
83
88
|
}>>;
|
|
84
89
|
}>;
|
|
85
90
|
export type NotesSearchData = Static<typeof NotesSearchDataSchema>;
|
|
91
|
+
type Snapshot<T> = Omit<NotesListData, "files"> & {
|
|
92
|
+
files: T[];
|
|
93
|
+
};
|
|
94
|
+
/** Keep identities intact. Only search previews may shrink to make the first row fit. */
|
|
95
|
+
export declare function snapshot<T extends {
|
|
96
|
+
address: string;
|
|
97
|
+
}>(rows: T[], limit: number | undefined, status: NoteQueryStatus, renderData: (data: Snapshot<T>) => string, shrink?: (item: T, fits: (candidate: T) => boolean) => T): Outcome<Snapshot<T>>;
|
|
98
|
+
export declare function listedFile(row: Pick<NoteRow, "address" | "meta">, identity: NotesIdentity): NotesListData["files"][number];
|
|
86
99
|
export declare const notesWriteParameters: Type.TObject<{
|
|
87
100
|
address: Type.TString;
|
|
88
101
|
content: Type.TString;
|
|
@@ -197,6 +210,7 @@ export declare const notesListParameters: Type.TObject<{
|
|
|
197
210
|
limit: Type.TOptional<Type.TInteger>;
|
|
198
211
|
crumpled: Type.TOptional<Type.TBoolean>;
|
|
199
212
|
}>;
|
|
213
|
+
export declare function renderListData(data: NotesListData): string;
|
|
200
214
|
export declare const notesList: {
|
|
201
215
|
readonly name: "notes_list";
|
|
202
216
|
readonly label: "Notes list";
|
package/dist/src/tools/notes.js
CHANGED
|
@@ -19,7 +19,7 @@ const ADDRESS_DESCRIPTION = "Addresses: a bare path is this session's note; `@pr
|
|
|
19
19
|
* Typed refusal. Every fact a caller needs is already in the message; there is no separate context.
|
|
20
20
|
* Convert expected refusals; unexpected errors propagate unchanged.
|
|
21
21
|
*/
|
|
22
|
-
function failureOf(error) {
|
|
22
|
+
export function failureOf(error) {
|
|
23
23
|
if (error instanceof NoteError)
|
|
24
24
|
return failure(error.code, error.message);
|
|
25
25
|
// Address, glob, and query guards raise declared types; nothing else is converted.
|
|
@@ -150,7 +150,7 @@ export const NotesSearchDataSchema = Type.Object({
|
|
|
150
150
|
...SnapshotSchema,
|
|
151
151
|
}, { additionalProperties: false });
|
|
152
152
|
/** Keep identities intact. Only search previews may shrink to make the first row fit. */
|
|
153
|
-
function snapshot(rows, limit, status, renderData, shrink) {
|
|
153
|
+
export function snapshot(rows, limit, status, renderData, shrink) {
|
|
154
154
|
const files = [];
|
|
155
155
|
const data = (selected) => ({ files: selected, more: rows.length - selected.length, homes_unavailable: status.homesUnavailable });
|
|
156
156
|
const render = (outcome) => renderOutcome(outcome, renderData);
|
|
@@ -172,7 +172,7 @@ function snapshot(rows, limit, status, renderData, shrink) {
|
|
|
172
172
|
const outcome = success(data(files));
|
|
173
173
|
return fitsResult(outcome, render) ? outcome : failure("output_too_large", `The list of unreachable homes is itself over ${TOOL_OUTPUT_LIMIT}; narrow \`glob\` to fewer homes.`);
|
|
174
174
|
}
|
|
175
|
-
function listedFile(row, identity) {
|
|
175
|
+
export function listedFile(row, identity) {
|
|
176
176
|
return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }) };
|
|
177
177
|
}
|
|
178
178
|
export const notesWriteParameters = Type.Object({ address: Type.String(), content: Type.String(), origin: ORIGIN }, { additionalProperties: false });
|
|
@@ -275,7 +275,7 @@ export const notesRead = {
|
|
|
275
275
|
render: (result) => renderOutcome(result, renderReadData),
|
|
276
276
|
};
|
|
277
277
|
export const notesListParameters = Type.Object({ glob: GLOB_PARAMETER, limit: FILE_LIMIT_PARAMETER, crumpled: CRUMPLED_LIST_PARAMETER }, { additionalProperties: false });
|
|
278
|
-
function renderListData(data) {
|
|
278
|
+
export function renderListData(data) {
|
|
279
279
|
const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
|
|
280
280
|
for (const file of data.files) {
|
|
281
281
|
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
@@ -52,6 +52,20 @@ test("Claude append and result arrival preserve call addresses and use the share
|
|
|
52
52
|
assert.ok(search.ok);
|
|
53
53
|
assert.deepEqual(search.data.items.map((item) => "seq" in item ? item.seq : -1), [3]);
|
|
54
54
|
});
|
|
55
|
+
test("Claude file-history deltas do not become events or change history addresses", () => {
|
|
56
|
+
const rows = [user("u", null, "hello"), assistant("a", "u", [{ type: "text", text: "reply" }])];
|
|
57
|
+
const delta = { type: "file-history-delta", messageId: "u", snapshotMessageId: "u", trackingPath: "private-file.txt",
|
|
58
|
+
backup: { backupFileName: "private-backup", version: 1, backupTime: "2026-01-01T00:00:00Z", realParentDir: "/private" }, timestamp: "2026-01-01T00:00:00Z" };
|
|
59
|
+
const baseline = project(rows, "a");
|
|
60
|
+
assert.deepEqual(project([delta, rows[0], delta, rows[1], delta], "a"), baseline);
|
|
61
|
+
assert.equal(baseline.highestSeq, 2);
|
|
62
|
+
});
|
|
63
|
+
test("Claude skips unknown record types unless selected ancestry requires them", () => {
|
|
64
|
+
const u = user("u", null, "hello"), a = assistant("a", "u", [{ type: "text", text: "reply" }]);
|
|
65
|
+
const unknown = { type: "future-record", uuid: "future", parentUuid: "not-on-disk", content: "private metadata" };
|
|
66
|
+
assert.deepEqual(project([unknown, u, unknown, a, unknown], "a"), project([u, a], "a"));
|
|
67
|
+
assert.throws(() => project([u, unknown, { ...a, parentUuid: "future" }], "a"), /missing Claude transcript ancestor: future/);
|
|
68
|
+
});
|
|
55
69
|
test("Claude duplicate UUID records do not allocate again or move addresses on reload", () => {
|
|
56
70
|
const u = user("u", null, "hello"), a = assistant("a", "u", [call("one")]);
|
|
57
71
|
const original = project([u, a], "a");
|
|
@@ -154,7 +168,6 @@ test("Claude tolerates only the uncommitted JSONL tail, not malformed committed
|
|
|
154
168
|
assert.deepEqual(claudeHistoryFromJsonl(`${text}{\"type\":\"user\"`, { sessionId, headUuid: "u" }), project([user("u", null, "first")], "u"));
|
|
155
169
|
assert.equal(claudeHistoryFromJsonl(text.trimEnd(), { sessionId, headUuid: "u" }).highestSeq, 1);
|
|
156
170
|
assert.throws(() => claudeHistoryFromJsonl(`${text}{broken}\n`, { sessionId, headUuid: "u" }), /malformed.*line 2/);
|
|
157
|
-
assert.throws(() => project([user("u", null, "first"), { type: "new-message-schema", uuid: "unknown" }], "u"), /unsupported.*record type/);
|
|
158
171
|
assert.throws(() => project([row("u", null, "user", [{ type: "new-block-schema" }])], "u"), /unsupported.*content block/);
|
|
159
172
|
assert.throws(() => project([row("u", null, "user", { type: "text", text: "not an array" })], "u"), /message content/);
|
|
160
173
|
assert.throws(() => project([user("u", null, "first"), user("u", null, "conflict")], "u"), /conflicting.*duplicate UUID/);
|
|
@@ -165,7 +178,10 @@ test("Claude helper history tools reuse shared schemas, outcomes and text render
|
|
|
165
178
|
const root = mkdtempSync(join(tmpdir(), "claude-history-"));
|
|
166
179
|
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
167
180
|
const transcriptPath = join(root, "transcript.jsonl"), rows = [user("u", null, "remember this"), assistant("a", "u", [call("one")]), row("r", "a", "user", [result("one", "recorded output")])];
|
|
168
|
-
writeFileSync(transcriptPath, jsonl(rows
|
|
181
|
+
writeFileSync(transcriptPath, jsonl([...rows,
|
|
182
|
+
{ type: "file-history-delta", messageId: "r", snapshotMessageId: "u", trackingPath: "file.txt", backup: null, timestamp: "2026-01-01T00:00:00Z" },
|
|
183
|
+
{ type: "future-record", content: "private metadata" },
|
|
184
|
+
]));
|
|
169
185
|
const identity = { home: join(root, "notes"), sessionId, cwd: root, agent: "claude", model: "claude" };
|
|
170
186
|
const history = { sessionId, transcriptPath, headUuid: "r" };
|
|
171
187
|
const projection = await readClaudeHistory(history);
|
|
@@ -36,7 +36,13 @@ async function loadHookModule(t) {
|
|
|
36
36
|
t.after(() => rmSync(loaded, { recursive: true, force: true }));
|
|
37
37
|
const module = join(loaded, "register.mjs");
|
|
38
38
|
writeFileSync(module, transpiled.outputFiles[0].text);
|
|
39
|
-
|
|
39
|
+
const hooks = await import(pathToFileURL(module).href);
|
|
40
|
+
return { register: (on) => hooks.register((event, matcherOrHandler, handler) => {
|
|
41
|
+
if (typeof matcherOrHandler === "function")
|
|
42
|
+
on(event, matcherOrHandler);
|
|
43
|
+
else
|
|
44
|
+
on(event, ($, e, next) => Object.entries(matcherOrHandler).every(([key, value]) => e[key] === value) ? handler($, e, next) : next(e));
|
|
45
|
+
}) };
|
|
40
46
|
}
|
|
41
47
|
/** An engine that answers the hook by running the real helper against a throwaway notes home. */
|
|
42
48
|
function fakeEngine(home) {
|
|
@@ -331,6 +337,43 @@ test("Claude Mod with NOTESOUP_DISABLED registers nothing and passes every event
|
|
|
331
337
|
const measured = await handlers.get("session.measure")(host, {}, async () => ({ marks: true }));
|
|
332
338
|
assert.deepEqual(measured, { marks: true }, "session.measure passes through without a reset");
|
|
333
339
|
assert.equal(helperCalls, 0, "the helper never runs while disabled");
|
|
340
|
+
const event = { text: "continue", context: ["upstream"] };
|
|
341
|
+
assert.equal(await handlers.get("prompt.submit")(host, event, async (e) => e), event);
|
|
342
|
+
const tool = { result: "upstream" };
|
|
343
|
+
assert.equal(await handlers.get("tool.call")(host, { tool: "Read" }, async () => tool), tool);
|
|
344
|
+
assert.equal(helperCalls, 0, "disabled warning routes are transparent too");
|
|
345
|
+
});
|
|
346
|
+
test("Claude Mod omits context_management always and memory unless kept; disabled passes through", async (t) => {
|
|
347
|
+
for (const mode of ["default", "keep", "disabled"]) {
|
|
348
|
+
await t.test(mode, async (t) => {
|
|
349
|
+
const home = mkdtempSync(join(tmpdir(), "claude-context-section-"));
|
|
350
|
+
t.after(() => rmSync(home, { recursive: true, force: true }));
|
|
351
|
+
const { host } = fakeEngine(home);
|
|
352
|
+
const readEnv = host.env.get;
|
|
353
|
+
host.env.get = async (name) => name === "NOTESOUP_KEEP_MEMORY" ? (mode === "keep" ? " YES " : undefined)
|
|
354
|
+
: name === "NOTESOUP_DISABLED" && mode === "disabled" ? "1" : readEnv(name);
|
|
355
|
+
const handlers = new Map(), sections = [];
|
|
356
|
+
(await loadHookModule(t)).register((event, handler) => event === "prompt.section" ? sections.push(handler) : handlers.set(event, handler));
|
|
357
|
+
await handlers.get("session.start")(host, { cwd: home, isInteractive: true }, async () => ({}));
|
|
358
|
+
for (const name of ["context_management", "memory"]) {
|
|
359
|
+
const event = { name, text: `engine ${name}` };
|
|
360
|
+
const upstream = { text: event.text };
|
|
361
|
+
let calls = 0;
|
|
362
|
+
const next = async (e) => { assert.equal(e, event); calls++; return upstream; };
|
|
363
|
+
// Chain the section hooks as the engine does; each matcher passes other names along.
|
|
364
|
+
const result = await sections.reduceRight((rest, handler) => (e) => handler(host, e, rest), next)(event);
|
|
365
|
+
const kept = mode === "disabled" || (mode === "keep" && name === "memory");
|
|
366
|
+
if (kept) {
|
|
367
|
+
assert.equal(result, upstream);
|
|
368
|
+
assert.equal(calls, 1);
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
assert.deepEqual(result, { text: null });
|
|
372
|
+
assert.equal(calls, 0);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
334
377
|
});
|
|
335
378
|
test("Claude Mod boot failure preserves fallback with available, absent, or failing notifications", async (t) => {
|
|
336
379
|
for (const mode of ["available", "no ui", "no toast", "throws", "rejects"]) {
|
|
@@ -500,6 +543,8 @@ test("Claude Mod headless detection skips compaction and logs once", async (t) =
|
|
|
500
543
|
assert.equal(notifications.length, 1);
|
|
501
544
|
const boot = await handlers.get("prompt.context")(host, {}, async () => ({ blocks: [] }));
|
|
502
545
|
assert.match(boot.blocks[0].text, /Current context window id: claude:hook-session:0/);
|
|
546
|
+
const event = { text: "continue" };
|
|
547
|
+
assert.equal(await handlers.get("prompt.submit")(host, event, async (e) => e), event, "headless prompts never warn");
|
|
503
548
|
});
|
|
504
549
|
test("Claude Mod keeps its window numbering from a boot written before the tag rename", async (t) => {
|
|
505
550
|
const home = mkdtempSync(join(tmpdir(), "claude-legacy-boot-"));
|
|
@@ -602,33 +647,65 @@ test("Claude Mod manual reset uses one hidden close-out turn, then recovers its
|
|
|
602
647
|
assert.equal(prompts.length, 1, "a busy manual request reuses the current turn instead of submitting another");
|
|
603
648
|
assert.match(kept[0].text, /Current context window id: claude:hook-session:2/);
|
|
604
649
|
});
|
|
605
|
-
test("Claude Mod
|
|
606
|
-
const
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
const handlers = new Map();
|
|
610
|
-
(await loadHookModule(t)).register((event, handler) => handlers.set(event, handler));
|
|
611
|
-
const invoke = (name, e = {}) => handlers.get(name)(host, e, async () => ({}));
|
|
612
|
-
let tokens = 142_423;
|
|
650
|
+
test("Claude Mod delivers one warning per window through main tools or prompt submission, never boot", async (t) => {
|
|
651
|
+
const { host, invoke, context } = await retainedFixture(t);
|
|
652
|
+
const texts = await dispatch({ op: "texts" });
|
|
653
|
+
let tokens = CLAUDE_200K.warn - 1;
|
|
613
654
|
host.session.usage = async () => ({ context: { tokens, window: 200_000 } });
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
const
|
|
621
|
-
assert.
|
|
622
|
-
assert.equal(
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
await
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
assert.deepEqual(
|
|
631
|
-
assert.equal(
|
|
655
|
+
const foreign = { result: "upstream result", context: ["upstream context"], ref: 1 };
|
|
656
|
+
const tool = (event = { tool: "Read" }, result = foreign) => invoke("tool.call", event, result);
|
|
657
|
+
const submit = () => invoke("prompt.submit", { text: "continue", context: ["earlier plugin"] }, {}, async (e) => e);
|
|
658
|
+
assert.equal(await tool(), foreign, "below the warn point the result passes through untouched");
|
|
659
|
+
tokens++;
|
|
660
|
+
assert.deepEqual((await context()).blocks, [], "prompt.context never delivers a warning, even above the runway");
|
|
661
|
+
const denied = { deny: "upstream refusal" };
|
|
662
|
+
assert.equal(await tool({ tool: "Read" }, denied), denied, "deny stays unchanged and does not consume the warning");
|
|
663
|
+
assert.equal(await invoke("tool.call", { tool: "Read", agentId: "child" }, foreign), foreign, "subagent results do not warn");
|
|
664
|
+
const own = await tool({ tool: "mcp__notesoup__notes_list" });
|
|
665
|
+
assert.equal(typeof own.result, "string", "a self-registered result still carries its original text");
|
|
666
|
+
assert.deepEqual(own.context, [texts.warning]);
|
|
667
|
+
assert.equal(await tool(), foreign, "another tool cannot warn twice in the same window");
|
|
668
|
+
assert.deepEqual((await submit()).context, ["earlier plugin"], "tool delivery also consumes the prompt route");
|
|
669
|
+
const reset = () => invoke("session.compact", { trigger: "auto", messages: [] });
|
|
670
|
+
await reset();
|
|
671
|
+
assert.deepEqual(await tool(), { ...foreign, context: [...foreign.context, texts.warning] }, "a new window can warn through a next() tool result");
|
|
672
|
+
assert.equal(await tool(), foreign);
|
|
673
|
+
await reset();
|
|
674
|
+
assert.deepEqual((await submit()).context, ["earlier plugin", texts.warning], "prompt submission preserves earlier context and warns once");
|
|
675
|
+
assert.deepEqual((await submit()).context, ["earlier plugin"]);
|
|
676
|
+
assert.equal(await tool(), foreign, "prompt delivery wins over the later tool route");
|
|
677
|
+
assert.deepEqual((await context()).blocks, [], "no notesoup:warning block is ever added to prompt context");
|
|
678
|
+
});
|
|
679
|
+
test("Claude Mod consumes a warning only after an accepted delivery and ignores stale generations", async (t) => {
|
|
680
|
+
const { host, invoke } = await retainedFixture(t);
|
|
681
|
+
const texts = await dispatch({ op: "texts" });
|
|
682
|
+
host.session.usage = async () => ({ context: { tokens: CLAUDE_200K.warn, window: 200_000 } });
|
|
683
|
+
const event = { text: "continue", context: ["upstream"] };
|
|
684
|
+
const drop = { drop: "another plugin refused" };
|
|
685
|
+
assert.equal(await invoke("prompt.submit", event, drop), drop);
|
|
686
|
+
await assert.rejects(invoke("prompt.submit", event, {}, async () => { throw new Error("submission failed"); }), /submission failed/);
|
|
687
|
+
assert.deepEqual(await invoke("prompt.submit", event, event), event, "a downstream context rewrite does not count as delivery");
|
|
688
|
+
let entered, release;
|
|
689
|
+
const ready = new Promise((resolve) => { entered = resolve; });
|
|
690
|
+
const held = new Promise((resolve) => { release = resolve; });
|
|
691
|
+
const pending = invoke("prompt.submit", event, {}, async (e) => {
|
|
692
|
+
assert.deepEqual(e.context, [...event.context, texts.warning]);
|
|
693
|
+
entered();
|
|
694
|
+
await held;
|
|
695
|
+
return e;
|
|
696
|
+
});
|
|
697
|
+
await ready;
|
|
698
|
+
const result = { result: "tool while prompt enters" };
|
|
699
|
+
assert.equal(await invoke("tool.call", { tool: "Read" }, result), result, "an in-flight accepted route reserves this window against duplicate tool delivery");
|
|
700
|
+
await invoke("session.end", { reason: "clear" });
|
|
701
|
+
host.session.id = async () => "next-session";
|
|
702
|
+
host.session.messages = async () => [];
|
|
703
|
+
await invoke("prompt.context", {}, { blocks: [] });
|
|
704
|
+
release();
|
|
705
|
+
await pending;
|
|
706
|
+
const delivered = await invoke("prompt.submit", event, {}, async (e) => e);
|
|
707
|
+
assert.deepEqual(delivered.context, [...event.context, texts.warning], "an old delivery cannot mark the new generation warned");
|
|
708
|
+
assert.equal(await invoke("prompt.submit", event, event), event, "only an accepted delivery consumes the new window");
|
|
632
709
|
});
|
|
633
710
|
test("Claude Mod moves the reset point to the hard window when auto-compact is off", async (t) => {
|
|
634
711
|
const home = mkdtempSync(join(tmpdir(), "claude-off-home-"));
|
|
@@ -677,6 +754,8 @@ test("Claude Mod stops the automatic reset and the manual command under DISABLE_
|
|
|
677
754
|
await invoke("session.measure");
|
|
678
755
|
assert.equal(compactions, 0, "the automatic reset is off and does not retry");
|
|
679
756
|
assert.equal(notifications.length, 1, "detection logs once, not per turn");
|
|
757
|
+
const upstream = { result: "upstream", context: ["other plugin"] };
|
|
758
|
+
assert.equal(await handlers.get("tool.call")(host, { tool: "Read" }, async () => upstream), upstream, "DISABLE_COMPACT also suppresses warnings");
|
|
680
759
|
});
|
|
681
760
|
test("Claude Mod skips the automatic reset when thresholds cannot be resolved", async (t) => {
|
|
682
761
|
const home = mkdtempSync(join(tmpdir(), "claude-nolimits-home-"));
|
|
@@ -829,7 +908,7 @@ test("Claude session.end gives /clear, /resume and /branch a fresh boot and iden
|
|
|
829
908
|
await t.test(action, async (t) => {
|
|
830
909
|
const { host, invoke, context } = await retainedFixture(t);
|
|
831
910
|
host.session.usage = async () => ({ context: { tokens: 142_424, window: 200_000 } });
|
|
832
|
-
assert.
|
|
911
|
+
assert.deepEqual((await invoke("prompt.submit", { text: "continue" }, {}, async (e) => e)).context, [CLAUDE_WARNING_PROMPT], "the old window has already warned");
|
|
833
912
|
await invoke("turn.start");
|
|
834
913
|
await invoke("command.run", { command: "empty" });
|
|
835
914
|
const ended = { sentinel: action };
|
|
@@ -842,7 +921,8 @@ test("Claude session.end gives /clear, /resume and /branch a fresh boot and iden
|
|
|
842
921
|
await invoke("turn.complete");
|
|
843
922
|
assert.equal(compactions, 0, "the old queued reset cannot spill into the new session");
|
|
844
923
|
const fresh = await context();
|
|
845
|
-
assert.deepEqual(fresh.blocks.map((block) => block.name), ["notesoup:boot"
|
|
924
|
+
assert.deepEqual(fresh.blocks.map((block) => block.name), ["notesoup:boot"]);
|
|
925
|
+
assert.deepEqual((await invoke("prompt.submit", { text: "continue" }, {}, async (e) => e)).context, [CLAUDE_WARNING_PROMPT], "the new session can warn again");
|
|
846
926
|
assert.match(fresh.blocks[0].text, new RegExp(`Current context window id: claude:after-${action}:0`));
|
|
847
927
|
assert.doesNotMatch(fresh.blocks[0].text, /claude:hook-session:/);
|
|
848
928
|
const requests = [];
|
|
@@ -941,7 +1021,12 @@ test("Claude identity uses the documented current model and cwd, with a safe mod
|
|
|
941
1021
|
host.session.cwd = async () => cwd;
|
|
942
1022
|
const seen = [];
|
|
943
1023
|
const run = host.process.run;
|
|
944
|
-
host.process.run = async (argv, init) => {
|
|
1024
|
+
host.process.run = async (argv, init) => {
|
|
1025
|
+
const request = JSON.parse(init.stdin);
|
|
1026
|
+
if (request.op === "tool")
|
|
1027
|
+
seen.push(request);
|
|
1028
|
+
return run(argv, init);
|
|
1029
|
+
};
|
|
945
1030
|
const write = (address, content) => invoke("tool.call", { tool: "mcp__notesoup__notes_write", tool_use_id: "model-call", address, content });
|
|
946
1031
|
assert.equal((await write("@model/model.md", "opus")).result, "created @model/model.md");
|
|
947
1032
|
assert.equal(seen.at(-1).identity.model, "claude-opus-4-6");
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
-
import { execFileSync } from "node:child_process";
|
|
3
2
|
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
4
3
|
import { tmpdir } from "node:os";
|
|
5
4
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -149,7 +148,7 @@ test("the core entry is host-neutral and the Pi plugin entry owns the extension"
|
|
|
149
148
|
assert.equal(pi.createNotesoup, createNotesoup);
|
|
150
149
|
assert.equal(typeof createNotesoup(), "function");
|
|
151
150
|
});
|
|
152
|
-
test("the configured extension source
|
|
151
|
+
test("the configured extension source is the executable current entry", async () => {
|
|
153
152
|
const root = repository();
|
|
154
153
|
const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
155
154
|
assert.deepEqual(manifest.pi.extensions, ["./plugins/pi/index.ts"], "Pi loads the plugin entry from TypeScript source");
|
|
@@ -163,11 +162,9 @@ test("the configured extension source and the moved dream CLI are executable cur
|
|
|
163
162
|
registerTool(tool) { tools.push(tool); },
|
|
164
163
|
registerCommand(name) { commands.push(name); },
|
|
165
164
|
});
|
|
166
|
-
assert.deepEqual(tools.map((tool) => tool.name).sort(), ["empty_brain", "get_context_remaining", "history_list", "history_read", "history_windows", "notes_list", "notes_read", "notes_search", "notes_update", "notes_write"]);
|
|
165
|
+
assert.deepEqual(tools.map((tool) => tool.name).sort(), ["dream_begin", "dream_end", "dream_forget", "empty_brain", "get_context_remaining", "history_list", "history_read", "history_windows", "notes_list", "notes_read", "notes_search", "notes_update", "notes_write"]);
|
|
166
|
+
assert.deepEqual(tools.filter((tool) => tool.exposure === "deferred").map((tool) => tool.name).sort(), ["dream_begin", "dream_end", "dream_forget"], "dream tools stay hidden until searched");
|
|
167
167
|
assert.deepEqual(commands.sort(), ["empty", "fresh-window", "notesoup"]);
|
|
168
|
-
const help = execFileSync(process.execPath, [resolve(root, manifest.bin.dream), "--help"], { cwd: root, encoding: "utf8" });
|
|
169
|
-
assert.ok(help.startsWith("dream doctor [--notes-home <dir>]"));
|
|
170
|
-
assert.ok(help.includes("Default playbook: <installed package root>/playbook.md"));
|
|
171
168
|
});
|
|
172
169
|
test("NOTESOUP_DISABLED turns the Pi extension fully off", async () => {
|
|
173
170
|
const built = await import(pathToFileURL(resolve(repository(), "dist/plugins/pi/index.js")).href);
|
|
@@ -24,12 +24,12 @@ function discoverSkill(skillsDir, name) {
|
|
|
24
24
|
assert.ok(skill.description.length > 0);
|
|
25
25
|
return skill;
|
|
26
26
|
}
|
|
27
|
-
test("dream skill is publicly discoverable and resolves the
|
|
27
|
+
test("dream skill is publicly discoverable and resolves the shared playbook", () => {
|
|
28
28
|
const root = packageRoot();
|
|
29
29
|
const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
30
30
|
assert.deepEqual(manifest.pi.skills, ["./skills"]);
|
|
31
31
|
assert.deepEqual(manifest.pi.extensions, ["./plugins/pi/index.ts"]);
|
|
32
|
-
assert.equal(manifest.bin
|
|
32
|
+
assert.equal(manifest.bin, undefined, "the dream CLI is gone; dreams run through the dream_* tools");
|
|
33
33
|
assert.ok(manifest.files.includes("skills"));
|
|
34
34
|
discoverSkill(join(root, "skills"), "memory");
|
|
35
35
|
const skill = discoverSkill(join(root, "skills"), "dream");
|
|
@@ -53,7 +53,6 @@ test("npm tarball keeps the skill's relative playbook path portable after extrac
|
|
|
53
53
|
assert.ok(packedPaths.includes("skills/memory/SKILL.md"));
|
|
54
54
|
assert.ok(packedPaths.includes("playbook.md"));
|
|
55
55
|
assert.ok(packedPaths.includes("plugins/pi/index.ts"));
|
|
56
|
-
assert.ok(packedPaths.includes("dist/plugins/pi/dream/cli.js"));
|
|
57
56
|
const extracted = join(fixture, "extracted");
|
|
58
57
|
execFileSync("mkdir", ["-p", extracted]);
|
|
59
58
|
execFileSync("tar", ["-xzf", join(fixture, packed.filename), "-C", extracted]);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
import { execFileSync } from "node:child_process";
|
|
7
|
+
import { createNotesStore } from "../src/notes/index.js";
|
|
8
|
+
import { dreamBegin, dreamEnd, dreamForget, dreamingIdentity } from "../src/tools/dream.js";
|
|
9
|
+
import { notesRead, notesUpdate, notesWrite } from "../src/tools/notes.js";
|
|
10
|
+
function fixture(t) {
|
|
11
|
+
const home = mkdtempSync(join(tmpdir(), "dream-tools-"));
|
|
12
|
+
t.after(() => rmSync(home, { recursive: true, force: true }));
|
|
13
|
+
const mark = (name) => {
|
|
14
|
+
mkdirSync(join(home, "project", name), { recursive: true });
|
|
15
|
+
writeFileSync(join(home, "project", name, ".project"), JSON.stringify({ id: name, path: `/work/${name}` }));
|
|
16
|
+
};
|
|
17
|
+
mark("alpha");
|
|
18
|
+
mark("beta");
|
|
19
|
+
const as = (sessionId, projectKey) => ({ home, sessionId, projectKey, agent: "root", model: "m" });
|
|
20
|
+
return { home, as };
|
|
21
|
+
}
|
|
22
|
+
test("a dream opens one other project, writes its notes, deletes only crumpled ones, then closes", async (t) => {
|
|
23
|
+
const { home, as } = fixture(t);
|
|
24
|
+
// Seed: beta's project note and two beta sessions, plus one alpha session.
|
|
25
|
+
await createNotesStore(as("b1", "beta")).write("@project/rule", "keep");
|
|
26
|
+
await createNotesStore(as("b1", "beta")).write("checkpoint", "old");
|
|
27
|
+
await createNotesStore(as("b2", "beta")).write("trash", "x");
|
|
28
|
+
await createNotesStore(as("b2", "beta")).update("trash", undefined, { crumpled: true });
|
|
29
|
+
await createNotesStore(as("a1", "alpha")).write("mine", "alpha only");
|
|
30
|
+
const me = as("now", "alpha");
|
|
31
|
+
const state = {};
|
|
32
|
+
const ident = () => dreamingIdentity(me, state);
|
|
33
|
+
// Closed: named homes are read-only and forget refuses.
|
|
34
|
+
assert.equal((await notesWrite.execute({ address: "@projects/beta/rule", content: "x" }, ident())).ok, false);
|
|
35
|
+
assert.equal((await dreamForget.execute({ address: "@sessions/b2/trash" }, me, state)).ok, false);
|
|
36
|
+
const begun = await dreamBegin.execute({ project: "beta" }, me, state);
|
|
37
|
+
assert.ok(begun.ok);
|
|
38
|
+
assert.deepEqual(begun.data.files.map(f => f.address).sort(), ["@projects/beta/rule.md", "@sessions/b1/checkpoint.md", "@sessions/b2/trash.md"]);
|
|
39
|
+
assert.equal((await dreamBegin.execute({}, me, state)).ok, false, "only one dream at a time");
|
|
40
|
+
assert.ok(existsSync(join(home, ".dream.lock.beta")), "the project lock is held");
|
|
41
|
+
assert.equal((await dreamBegin.execute({ project: "beta" }, as("other", "alpha"), {})).ok, false, "another session can't dream the same project");
|
|
42
|
+
assert.ok((await notesWrite.execute({ address: "@projects/beta/rule", content: "merged" }, ident())).ok);
|
|
43
|
+
assert.ok((await notesUpdate.execute({ address: "@sessions/b1/checkpoint", edits: [{ oldText: "old", newText: "new" }] }, ident(), () => "")).ok);
|
|
44
|
+
assert.equal((await notesWrite.execute({ address: "@sessions/a1/mine", content: "x" }, ident())).ok, false, "another project's session stays read-only");
|
|
45
|
+
assert.equal((await notesWrite.execute({ address: "@projects/alpha/x", content: "x" }, ident())).ok, false, "other projects stay read-only");
|
|
46
|
+
const read = await notesRead.execute({ address: "@human/none" }, ident());
|
|
47
|
+
assert.equal(read.ok, false);
|
|
48
|
+
await createNotesStore(me).write("@human/pref", "p");
|
|
49
|
+
const before = (await createNotesStore(me).list({ glob: "@human/**" }))[0].meta.accessCount;
|
|
50
|
+
assert.ok((await notesRead.execute({ address: "@human/pref" }, ident())).ok);
|
|
51
|
+
assert.equal((await createNotesStore(me).list({ glob: "@human/**" }))[0].meta.accessCount, before, "dream reads leave no stamp");
|
|
52
|
+
assert.equal((await dreamForget.execute({ address: "@sessions/b1/checkpoint" }, me, state)).ok, false, "live notes refuse");
|
|
53
|
+
assert.ok((await dreamForget.execute({ address: "@sessions/b2/trash" }, me, state)).ok);
|
|
54
|
+
assert.equal(existsSync(join(home, "pi", "session", "b2", "trash.md")), false);
|
|
55
|
+
const ended = await dreamEnd.execute({}, me, state);
|
|
56
|
+
assert.ok(ended.ok && ended.data.commit && ended.data.commit !== begun.data.baseline, "dream_end commits the changes");
|
|
57
|
+
assert.equal(existsSync(join(home, ".dream.lock.beta")), false, "the lock is released");
|
|
58
|
+
assert.equal(execFileSync("git", ["status", "--porcelain"], { cwd: home, encoding: "utf8" }), "", "the audit leaves a clean tree");
|
|
59
|
+
assert.equal((await notesWrite.execute({ address: "@projects/beta/rule", content: "x" }, ident())).ok, false, "closed again");
|
|
60
|
+
assert.equal((await dreamEnd.execute({}, me, state)).ok, false);
|
|
61
|
+
});
|
|
62
|
+
test("dream_begin refuses an unknown project", async (t) => {
|
|
63
|
+
const { as } = fixture(t);
|
|
64
|
+
const state = {};
|
|
65
|
+
assert.equal((await dreamBegin.execute({ project: "nope" }, as("s", "alpha"), state)).ok, false);
|
|
66
|
+
assert.equal(state.project, undefined);
|
|
67
|
+
});
|
package/docs/claude-code-mod.md
CHANGED
|
@@ -22,7 +22,7 @@ The notes tools also serve subagent calls, using the same session identity and s
|
|
|
22
22
|
|
|
23
23
|
The active head comes from the main loop's successful `session.append` result UUID, including attachments and notices. On startup/resume, before such an append, the public API supplies no authoritative selected leaf: history explicitly refuses instead of assuming the last file row or `last-prompt.leafUuid` is current. The append result means the engine kept a row, but its disk write may lag; a head missing on disk is a retryable refusal, not permission to switch branches. Session end clears the binding; a new classic start rebinds it.
|
|
24
24
|
|
|
25
|
-
Seqs are allocated over first-occurrence persisted append order, before active-branch filtering: one address per logical message/attachment/notice and additional addresses for each tool use/result. Repeated UUID records do not allocate again. Results pair by `tool_use_id`; pending calls remain unfinished, and a paired result's seq redirects to its call. Only text blocks and recorded attachment renderings become visible text; thinking and raw, unrendered attachment payloads are never exposed.
|
|
25
|
+
Seqs are allocated over first-occurrence persisted append order, before active-branch filtering: one address per logical message/attachment/notice and additional addresses for each tool use/result. Repeated UUID records do not allocate again. Results pair by `tool_use_id`; pending calls remain unfinished, and a paired result's seq redirects to its call. Only text blocks and recorded attachment renderings become visible text; thinking and raw, unrendered attachment payloads are never exposed. Record types other than user, assistant, system and attachment are ignored, including future metadata, without allocating addresses or exposing payloads. If the selected branch requires a skipped record as an ancestor, history refuses with the missing ancestor UUID. Invalid supported message/block schemas and malformed committed JSONL lines still refuse explicitly. An incomplete final unterminated write is tolerated. Valid forward parent references are resolved after reading the snapshot, without reallocating addresses.
|
|
26
26
|
|
|
27
27
|
The selected tree follows the latest native `parentUuid` links. Compact boundaries also join their `logicalParentUuid` and recorded preserved segments through original ancestry, retaining old events instead of presenting only retained inference context. Auxiliary preservation UUIDs that were never persisted are skipped. Windows use `claude:<sessionId>:<ordinal>`, matching the boot: native compact boundaries advance the ordinal, and retained notesoup boot markers name that same ordinal rather than advancing it again. Preserved duplicate rows keep their original window; new children of their rewritten versions inherit the new window. `@previous` resolves through this oldest-first window list. A missing required ancestor is an explicit refusal.
|
|
28
28
|
|
package/docs/notes-library.md
CHANGED
|
@@ -26,7 +26,7 @@ const files = await notes.list({ glob: "@project/**" });
|
|
|
26
26
|
const matches = await notes.search(["library"]);
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
`/notes` ships JavaScript and TypeScript declarations. It does not import Pi or read `PI_*` environment variables. Pi packages are optional peers: a notes-only installation does not install them. Using the Pi plugin
|
|
29
|
+
`/notes` ships JavaScript and TypeScript declarations. It does not import Pi or read `PI_*` environment variables. Pi packages are optional peers: a notes-only installation does not install them. Using the Pi plugin or the dsh rows (`notesoup/dsh`) still requires its host. This is a filesystem library for Node, not a browser storage API.
|
|
30
30
|
|
|
31
31
|
## API and identity
|
|
32
32
|
|