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
package/dist/src/notes/policy.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { NoteError } from "./errors.js";
|
|
2
|
-
export const DEFAULT_NOTE_BUDGET =
|
|
2
|
+
export const DEFAULT_NOTE_BUDGET = 8192;
|
|
3
|
+
export const DEFAULT_CHEATSHEET_BUDGET = 4096;
|
|
3
4
|
export const MAX_PINNED_NOTES = 5;
|
|
5
|
+
export const WARNING_OPEN_TAG = "<notesoup:warning>";
|
|
6
|
+
export const WARNING_CLOSE_TAG = "</notesoup:warning>";
|
|
7
|
+
/** Boot index truncates descriptions past this code-point cap; longer values still save with a warning. */
|
|
8
|
+
export const MAX_DESCRIPTION_CHARS = 160;
|
|
4
9
|
/** Defaults and ordering live here; no other layer assigns behavior by page name. */
|
|
5
10
|
const DEFAULT_PINNED_PAGES = ["CHEATSHEET.md"];
|
|
6
11
|
export function validateNotePolicy(fields) {
|
|
@@ -9,7 +14,7 @@ export function validateNotePolicy(fields) {
|
|
|
9
14
|
throw new NoteError("invalid_policy", `${key} must be a boolean.`);
|
|
10
15
|
}
|
|
11
16
|
if (fields.budget !== undefined && (!Number.isSafeInteger(fields.budget) || fields.budget <= 0)) {
|
|
12
|
-
throw new NoteError("invalid_policy", "budget must be a positive
|
|
17
|
+
throw new NoteError("invalid_policy", "budget must be a positive integer.");
|
|
13
18
|
}
|
|
14
19
|
}
|
|
15
20
|
/** Only root default pages are pinned implicitly; an explicit false always wins. */
|
|
@@ -18,7 +23,7 @@ export function effectiveNotePolicy(fields, path) {
|
|
|
18
23
|
const defaultPage = DEFAULT_PINNED_PAGES.some(page => page === path);
|
|
19
24
|
return {
|
|
20
25
|
pinned: fields.pinned ?? defaultPage,
|
|
21
|
-
budget: fields.budget ?? (defaultPage ?
|
|
26
|
+
budget: fields.budget ?? (defaultPage ? DEFAULT_CHEATSHEET_BUDGET : DEFAULT_NOTE_BUDGET),
|
|
22
27
|
readonly: fields.readonly ?? false,
|
|
23
28
|
};
|
|
24
29
|
}
|
|
@@ -26,9 +31,45 @@ export function pinnedPageOrder(path) {
|
|
|
26
31
|
const index = DEFAULT_PINNED_PAGES.findIndex(page => page === path);
|
|
27
32
|
return index === -1 ? DEFAULT_PINNED_PAGES.length : index;
|
|
28
33
|
}
|
|
34
|
+
export function truncateToUtf8Bytes(text, maxBytes) {
|
|
35
|
+
if (Buffer.byteLength(text, "utf8") <= maxBytes)
|
|
36
|
+
return { text, shownChars: 0, totalChars: 0, truncated: false };
|
|
37
|
+
const chars = Array.from(text);
|
|
38
|
+
let bytes = 0;
|
|
39
|
+
let shown = 0;
|
|
40
|
+
for (const char of chars) {
|
|
41
|
+
const size = Buffer.byteLength(char, "utf8");
|
|
42
|
+
if (bytes + size > maxBytes)
|
|
43
|
+
break;
|
|
44
|
+
bytes += size;
|
|
45
|
+
shown++;
|
|
46
|
+
}
|
|
47
|
+
return { text: chars.slice(0, shown).join(""), shownChars: shown, totalChars: chars.length, truncated: true };
|
|
48
|
+
}
|
|
49
|
+
export function renderWarnings(warnings) {
|
|
50
|
+
if (warnings.length === 0)
|
|
51
|
+
return "";
|
|
52
|
+
if (warnings.length === 1)
|
|
53
|
+
return `${WARNING_OPEN_TAG}${warnings[0]}${WARNING_CLOSE_TAG}`;
|
|
54
|
+
return `${WARNING_OPEN_TAG}\n${warnings.join("\n")}\n${WARNING_CLOSE_TAG}`;
|
|
55
|
+
}
|
|
29
56
|
export function noteBudgetWarnings(body, policy) {
|
|
30
|
-
const
|
|
31
|
-
|
|
57
|
+
const bytes = Buffer.byteLength(body, "utf8");
|
|
58
|
+
if (bytes <= policy.budget)
|
|
59
|
+
return [];
|
|
60
|
+
const action = policy.pinned ? "boot truncates it to budget — trim, split, or unpin." : "trim or split it.";
|
|
61
|
+
return [`note body is ${bytes} bytes (budget ${policy.budget}); ${action}`];
|
|
62
|
+
}
|
|
63
|
+
export function noteDescriptionWarnings(description) {
|
|
64
|
+
if (description === undefined)
|
|
65
|
+
return [];
|
|
66
|
+
const count = Array.from(description).length;
|
|
67
|
+
return count > MAX_DESCRIPTION_CHARS
|
|
68
|
+
? [`description is ${count} chars (max ${MAX_DESCRIPTION_CHARS}); boot index truncates it.`]
|
|
69
|
+
: [];
|
|
70
|
+
}
|
|
71
|
+
export function noteWarnings(body, policy, description) {
|
|
72
|
+
return [...noteBudgetWarnings(body, policy), ...noteDescriptionWarnings(description)];
|
|
32
73
|
}
|
|
33
74
|
export function assertNoteUnlocked(fields, unlock) {
|
|
34
75
|
if (fields.readonly === true && unlock !== false)
|
|
@@ -4,6 +4,17 @@ import { type Scope } from "./paths.js";
|
|
|
4
4
|
import { type ProjectReceipt } from "./project-namespace.js";
|
|
5
5
|
import { type NotePolicyFields } from "./policy.js";
|
|
6
6
|
export type { NoteMeta, Origin, Scope };
|
|
7
|
+
export declare function compareNoteRows(a: {
|
|
8
|
+
address: string;
|
|
9
|
+
meta: {
|
|
10
|
+
updatedAt: number;
|
|
11
|
+
};
|
|
12
|
+
}, b: {
|
|
13
|
+
address: string;
|
|
14
|
+
meta: {
|
|
15
|
+
updatedAt: number;
|
|
16
|
+
};
|
|
17
|
+
}): number;
|
|
7
18
|
export type NoteRow = {
|
|
8
19
|
address: string;
|
|
9
20
|
scope: Scope;
|
|
@@ -28,6 +39,7 @@ export type NoteSearchRow = {
|
|
|
28
39
|
export type EditOperation = {
|
|
29
40
|
oldText: string;
|
|
30
41
|
newText: string;
|
|
42
|
+
replaceAll?: boolean;
|
|
31
43
|
};
|
|
32
44
|
export type WriteOptions = NotePolicyFields & {
|
|
33
45
|
origin?: Origin;
|
package/dist/src/notes/store.js
CHANGED
|
@@ -7,10 +7,13 @@ import { isFilesystemError } from "./fs-error.js";
|
|
|
7
7
|
import { snapshotNotesIdentity } from "./identity.js";
|
|
8
8
|
import { NoteError } from "./errors.js";
|
|
9
9
|
import { MAX_NOTE_BYTES, MAX_NOTE_PATH_BYTES } from "./constants.js";
|
|
10
|
-
import { collapseDescription, isOrigin, localIso,
|
|
10
|
+
import { collapseDescription, isOrigin, localIso, parseNote, serializeNote, stripLeadingFrontmatter } from "./frontmatter.js";
|
|
11
11
|
import { namespaceSlugs, noteFileName, physicalPath, scopeDir, isSessionId, SLUG_PATTERN } from "./paths.js";
|
|
12
12
|
import { projectReceipt } from "./project-namespace.js";
|
|
13
|
-
import { applyNotePolicy, assertNoteUnlocked, effectiveNotePolicy, MAX_PINNED_NOTES,
|
|
13
|
+
import { applyNotePolicy, assertNoteUnlocked, effectiveNotePolicy, MAX_PINNED_NOTES, noteWarnings, validateNotePolicy } from "./policy.js";
|
|
14
|
+
export function compareNoteRows(a, b) {
|
|
15
|
+
return b.meta.updatedAt - a.meta.updatedAt || a.address.localeCompare(b.address);
|
|
16
|
+
}
|
|
14
17
|
// Recency sorts tie-break by address, so two writes sharing one Date.now() tick would silently invert the recent-first contract. Write stamps are strictly increasing per process.
|
|
15
18
|
let lastWriteStamp = 0;
|
|
16
19
|
function writeStamp() {
|
|
@@ -154,16 +157,6 @@ function assertOrigin(value) {
|
|
|
154
157
|
throw new NoteError("invalid_origin", `origin must be one of user, self, external (got ${JSON.stringify(value)})`);
|
|
155
158
|
return value;
|
|
156
159
|
}
|
|
157
|
-
/** A description is one normalized line; empty clears it. Only the authored value is refused, never read. */
|
|
158
|
-
function normalizeDescription(value) {
|
|
159
|
-
const collapsed = collapseDescription(value);
|
|
160
|
-
if (collapsed === undefined)
|
|
161
|
-
return undefined;
|
|
162
|
-
const count = Array.from(collapsed).length;
|
|
163
|
-
if (count > MAX_DESCRIPTION_CHARS)
|
|
164
|
-
throw new NoteError("invalid_description", `description is ${count} characters; limit is ${MAX_DESCRIPTION_CHARS}.`);
|
|
165
|
-
return collapsed;
|
|
166
|
-
}
|
|
167
160
|
function assertWho(value, scope) {
|
|
168
161
|
if (typeof value !== "string" || !(scope === "session" ? isSessionId(value) : SLUG_PATTERN.test(value))) {
|
|
169
162
|
throw new NoteError("invalid_scope", scope === "session" ? "session id must be a safe single directory component" : "who must be a canonical lowercase slug");
|
|
@@ -293,7 +286,7 @@ export function createNotesStore(input) {
|
|
|
293
286
|
async function write(address, content, options = {}) {
|
|
294
287
|
const stableOptions = { ...options };
|
|
295
288
|
validateNotePolicy(stableOptions);
|
|
296
|
-
const description = stableOptions.description === undefined ? undefined :
|
|
289
|
+
const description = stableOptions.description === undefined ? undefined : collapseDescription(stableOptions.description);
|
|
297
290
|
const destination = assertAddress(address);
|
|
298
291
|
assertWritablePath(destination.path);
|
|
299
292
|
const scope = destination.scope;
|
|
@@ -338,7 +331,7 @@ export function createNotesStore(input) {
|
|
|
338
331
|
assertSerializedSize(serialized);
|
|
339
332
|
await assertPinAdmission(root, noteFileName(destination.path), meta, previous);
|
|
340
333
|
await atomicWrite(path, serialized);
|
|
341
|
-
return { meta, outcome, warnings:
|
|
334
|
+
return { meta, outcome, warnings: noteWarnings(cleanBody, effectiveNotePolicy(meta, noteFileName(destination.path)), meta.description) };
|
|
342
335
|
}));
|
|
343
336
|
}
|
|
344
337
|
async function read(address) {
|
|
@@ -364,7 +357,7 @@ export function createNotesStore(input) {
|
|
|
364
357
|
const operations = edits === undefined ? [] : edits.map((operation) => ({ ...operation }));
|
|
365
358
|
const stableOptions = { ...options };
|
|
366
359
|
validateNotePolicy(stableOptions);
|
|
367
|
-
const description = stableOptions.description === undefined ? undefined :
|
|
360
|
+
const description = stableOptions.description === undefined ? undefined : collapseDescription(stableOptions.description);
|
|
368
361
|
const from = assertAddress(address);
|
|
369
362
|
const destination = stableOptions.renameTo === undefined ? from : assertAddress(stableOptions.renameTo);
|
|
370
363
|
assertWritablePath(destination.path);
|
|
@@ -421,16 +414,19 @@ export function createNotesStore(input) {
|
|
|
421
414
|
throw new NoteError("invalid_edit", `edits[${index}].oldText must be a non-empty string.`, { editIndex: index });
|
|
422
415
|
if (typeof newText !== "string")
|
|
423
416
|
throw new NoteError("invalid_edit", `edits[${index}].newText must be a string.`, { editIndex: index });
|
|
417
|
+
if (operation.replaceAll !== undefined && typeof operation.replaceAll !== "boolean")
|
|
418
|
+
throw new NoteError("invalid_edit", `edits[${index}].replaceAll must be a boolean.`, { editIndex: index });
|
|
419
|
+
const replaceAll = operation.replaceAll ?? stableOptions.replaceAll ?? false;
|
|
424
420
|
const lines = matchLineNumbers(next, oldText);
|
|
425
421
|
if (lines.length === 0)
|
|
426
422
|
throw new NoteError("no_match", `edits[${index}].oldText isn't in the note${index > 0 ? " (after the earlier edits)" : ""}. Nothing was saved.`, { editIndex: index });
|
|
427
|
-
if (lines.length > 1 && !
|
|
423
|
+
if (lines.length > 1 && !replaceAll) {
|
|
428
424
|
throw new NoteError("ambiguous_edit", `edits[${index}].oldText appears ${lines.length} times (${anchorLines(lines)}); add surrounding text to pick one, or set replace_all. Nothing was saved.`, { lineNumbers: lines, editIndex: index });
|
|
429
425
|
}
|
|
430
426
|
if (oldText !== newText)
|
|
431
427
|
applied++;
|
|
432
428
|
// Positional splicing preserves user replacement text byte-for-byte.
|
|
433
|
-
if (
|
|
429
|
+
if (replaceAll)
|
|
434
430
|
next = next.split(oldText).join(newText);
|
|
435
431
|
else {
|
|
436
432
|
const matchIndex = next.indexOf(oldText);
|
|
@@ -467,7 +463,7 @@ export function createNotesStore(input) {
|
|
|
467
463
|
await atomicWrite(sameFile ? sourceReal : path, serialized);
|
|
468
464
|
if (moved)
|
|
469
465
|
await rm(fromPath, { force: true });
|
|
470
|
-
return { meta, warnings:
|
|
466
|
+
return { meta, warnings: noteWarnings(next, effectiveNotePolicy(meta, noteFileName(destination.path)), meta.description), applied, resolvedScope: scope, change, moved, replacedCrumpledTarget: moved && targetRaw !== undefined };
|
|
471
467
|
};
|
|
472
468
|
return withPathQueues([fromRoot, root], () => withPathQueues([fromPath, path], mutate));
|
|
473
469
|
}
|
|
@@ -547,7 +543,7 @@ export function createNotesStore(input) {
|
|
|
547
543
|
for await (const row of scan(stableOptions, status)) {
|
|
548
544
|
rows.push({ ...row, sizeBytes: Buffer.byteLength(row.body, "utf8") });
|
|
549
545
|
}
|
|
550
|
-
rows.sort(
|
|
546
|
+
rows.sort(compareNoteRows);
|
|
551
547
|
return { rows, status: status ?? { namespacesUnavailable: [] } };
|
|
552
548
|
}
|
|
553
549
|
function listWithStatus(options = {}) {
|
|
@@ -562,7 +558,7 @@ export function createNotesStore(input) {
|
|
|
562
558
|
const rows = [];
|
|
563
559
|
for await (const note of scan(stableOptions, status)) {
|
|
564
560
|
const { address, path, scope, meta, body } = note;
|
|
565
|
-
const warnings =
|
|
561
|
+
const warnings = noteWarnings(body, effectiveNotePolicy(meta, path), meta.description);
|
|
566
562
|
if (stableQueries.length === 0) {
|
|
567
563
|
rows.push({ address, path, scope, meta, warnings, matches: [] });
|
|
568
564
|
continue;
|
package/dist/src/text-match.d.ts
CHANGED
|
@@ -6,8 +6,17 @@ export declare class InvalidQueryError extends Error {
|
|
|
6
6
|
export declare function searchQueries(query: unknown): string[];
|
|
7
7
|
/** Longest fitting code-point prefix, without inserted markers. Callers report omissions. */
|
|
8
8
|
export declare function prefixFit(text: string, fits: (content: string) => boolean): string;
|
|
9
|
+
/** Compile literal Unicode case-insensitive patterns once per search operation. */
|
|
10
|
+
export declare function compileSearchQueries(queries: readonly string[]): RegExp[];
|
|
11
|
+
/** Count Unicode code points in `text.slice(0, utf16End)` without allocating an array. */
|
|
12
|
+
export declare function codePointCount(text: string, utf16End?: number): number;
|
|
13
|
+
/** Slice `[start, start + limit)` code points without splitting the entire string into an array. */
|
|
14
|
+
export declare function sliceCodePoints(text: string, start: number, limit: number): {
|
|
15
|
+
text: string;
|
|
16
|
+
truncated: boolean;
|
|
17
|
+
};
|
|
9
18
|
/**
|
|
10
19
|
* Code-point offset of the earliest case-insensitive literal match, or -1 when
|
|
11
20
|
* none occurs. Match against the original text so Unicode casing cannot shift offsets.
|
|
12
21
|
*/
|
|
13
|
-
export declare function earliestMatchOffsetChars(text: string, queries: string[]): number;
|
|
22
|
+
export declare function earliestMatchOffsetChars(text: string, queries: readonly (string | RegExp)[]): number;
|
package/dist/src/text-match.js
CHANGED
|
@@ -32,6 +32,45 @@ export function prefixFit(text, fits) {
|
|
|
32
32
|
}
|
|
33
33
|
return chars.slice(0, low).join("");
|
|
34
34
|
}
|
|
35
|
+
/** Compile literal Unicode case-insensitive patterns once per search operation. */
|
|
36
|
+
export function compileSearchQueries(queries) {
|
|
37
|
+
return queries.map((query) => new RegExp(query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "iu"));
|
|
38
|
+
}
|
|
39
|
+
/** Count Unicode code points in `text.slice(0, utf16End)` without allocating an array. */
|
|
40
|
+
export function codePointCount(text, utf16End = text.length) {
|
|
41
|
+
let count = utf16End;
|
|
42
|
+
for (let i = 0; i < utf16End - 1; i++) {
|
|
43
|
+
const code = text.charCodeAt(i);
|
|
44
|
+
if (code >= 0xd800 && code <= 0xdbff) {
|
|
45
|
+
const next = text.charCodeAt(i + 1);
|
|
46
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
47
|
+
count--;
|
|
48
|
+
i++;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return count;
|
|
53
|
+
}
|
|
54
|
+
/** Slice `[start, start + limit)` code points without splitting the entire string into an array. */
|
|
55
|
+
export function sliceCodePoints(text, start, limit) {
|
|
56
|
+
const len = text.length;
|
|
57
|
+
let utf16Start = 0;
|
|
58
|
+
let cp = 0;
|
|
59
|
+
while (cp < start && utf16Start < len) {
|
|
60
|
+
const code = text.charCodeAt(utf16Start);
|
|
61
|
+
utf16Start += code >= 0xd800 && code <= 0xdbff && utf16Start + 1 < len && text.charCodeAt(utf16Start + 1) >= 0xdc00 && text.charCodeAt(utf16Start + 1) <= 0xdfff ? 2 : 1;
|
|
62
|
+
cp++;
|
|
63
|
+
}
|
|
64
|
+
let utf16End = utf16Start;
|
|
65
|
+
let taken = 0;
|
|
66
|
+
while (taken < limit && utf16End < len) {
|
|
67
|
+
const code = text.charCodeAt(utf16End);
|
|
68
|
+
utf16End += code >= 0xd800 && code <= 0xdbff && utf16End + 1 < len && text.charCodeAt(utf16End + 1) >= 0xdc00 && text.charCodeAt(utf16End + 1) <= 0xdfff ? 2 : 1;
|
|
69
|
+
taken++;
|
|
70
|
+
}
|
|
71
|
+
const truncated = start > 0 || utf16End < len;
|
|
72
|
+
return { text: truncated ? text.slice(utf16Start, utf16End) : text, truncated };
|
|
73
|
+
}
|
|
35
74
|
/**
|
|
36
75
|
* Code-point offset of the earliest case-insensitive literal match, or -1 when
|
|
37
76
|
* none occurs. Match against the original text so Unicode casing cannot shift offsets.
|
|
@@ -39,12 +78,12 @@ export function prefixFit(text, fits) {
|
|
|
39
78
|
export function earliestMatchOffsetChars(text, queries) {
|
|
40
79
|
let earliest = -1;
|
|
41
80
|
for (const query of queries) {
|
|
42
|
-
const
|
|
43
|
-
const index =
|
|
81
|
+
const pattern = typeof query === "string" ? new RegExp(query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "iu") : query;
|
|
82
|
+
const index = pattern.exec(text)?.index ?? -1;
|
|
44
83
|
if (index < 0)
|
|
45
84
|
continue;
|
|
46
85
|
if (earliest < 0 || index < earliest)
|
|
47
86
|
earliest = index;
|
|
48
87
|
}
|
|
49
|
-
return earliest < 0 ? -1 :
|
|
88
|
+
return earliest < 0 ? -1 : codePointCount(text, earliest);
|
|
50
89
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Type, type Static } from "typebox";
|
|
2
|
-
import { type NotesIdentity } from "../notes/index.js";
|
|
2
|
+
import { noteIdentity, type NotesIdentity } from "../notes/index.js";
|
|
3
|
+
import { type ProjectReceipt } from "../notes/project-namespace.js";
|
|
3
4
|
import { type Outcome } from "../result.js";
|
|
5
|
+
import { type ListedFile, type Snapshot } from "./notes.js";
|
|
6
|
+
import { type NotesToolContext } from "./notes-context.js";
|
|
4
7
|
/** The one open dream per session; the host owns where it lives. */
|
|
5
8
|
type DreamOpening = {
|
|
6
9
|
project: string;
|
|
@@ -18,123 +21,49 @@ export declare function abandonDream(state: DreamState): void;
|
|
|
18
21
|
/** The identity a store uses while `state` holds an open dream. */
|
|
19
22
|
export declare function dreamingIdentity(identity: NotesIdentity, state: DreamState): NotesIdentity;
|
|
20
23
|
export declare const dreamBeginParameters: Type.TObject<{
|
|
21
|
-
|
|
24
|
+
cwd: Type.TOptional<Type.TString>;
|
|
22
25
|
}>;
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
project:
|
|
27
|
-
baseline:
|
|
28
|
-
|
|
29
|
-
last_accessed: Type.TString;
|
|
30
|
-
updated_at: Type.TString;
|
|
31
|
-
crumpled_at: Type.TOptional<Type.TString>;
|
|
32
|
-
description: Type.TOptional<Type.TString>;
|
|
33
|
-
warnings: Type.TArray<Type.TString>;
|
|
34
|
-
pinned: Type.TBoolean;
|
|
35
|
-
budget: Type.TInteger;
|
|
36
|
-
readonly: Type.TBoolean;
|
|
37
|
-
project_root: Type.TOptional<Type.TString>;
|
|
38
|
-
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
39
|
-
name: Type.TString;
|
|
40
|
-
path: Type.TString;
|
|
41
|
-
}>>>;
|
|
42
|
-
address: Type.TString;
|
|
43
|
-
project_key: Type.TOptional<Type.TString>;
|
|
44
|
-
}>>;
|
|
45
|
-
}>;
|
|
46
|
-
export type DreamBeginData = Static<typeof DreamBeginDataSchema>;
|
|
26
|
+
export type DreamBeginData = Snapshot<ListedFile & {
|
|
27
|
+
last_accessed: string;
|
|
28
|
+
}> & {
|
|
29
|
+
project: string;
|
|
30
|
+
baseline: string;
|
|
31
|
+
} & ProjectReceipt;
|
|
47
32
|
export declare const dreamBegin: {
|
|
48
33
|
readonly name: "dream_begin";
|
|
49
34
|
readonly label: "Dream begin";
|
|
50
|
-
readonly description: "
|
|
35
|
+
readonly description: "Open a project's notes and its session notes for consolidation after committing a Git baseline; unlocks writes until `dream_end`.";
|
|
51
36
|
readonly parameters: Type.TObject<{
|
|
52
|
-
|
|
37
|
+
cwd: Type.TOptional<Type.TString>;
|
|
53
38
|
}>;
|
|
54
|
-
readonly
|
|
55
|
-
more: Type.TInteger;
|
|
56
|
-
namespaces_unavailable: Type.TArray<Type.TString>;
|
|
57
|
-
project: Type.TString;
|
|
58
|
-
baseline: Type.TString;
|
|
59
|
-
files: Type.TArray<Type.TObject<{
|
|
60
|
-
last_accessed: Type.TString;
|
|
61
|
-
updated_at: Type.TString;
|
|
62
|
-
crumpled_at: Type.TOptional<Type.TString>;
|
|
63
|
-
description: Type.TOptional<Type.TString>;
|
|
64
|
-
warnings: Type.TArray<Type.TString>;
|
|
65
|
-
pinned: Type.TBoolean;
|
|
66
|
-
budget: Type.TInteger;
|
|
67
|
-
readonly: Type.TBoolean;
|
|
68
|
-
project_root: Type.TOptional<Type.TString>;
|
|
69
|
-
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
70
|
-
name: Type.TString;
|
|
71
|
-
path: Type.TString;
|
|
72
|
-
}>>>;
|
|
73
|
-
address: Type.TString;
|
|
74
|
-
project_key: Type.TOptional<Type.TString>;
|
|
75
|
-
}>>;
|
|
76
|
-
}>, Type.TObject<{
|
|
77
|
-
error: Type.TString;
|
|
78
|
-
code: Type.TString;
|
|
79
|
-
}>]>;
|
|
80
|
-
readonly execute: (params: Static<typeof dreamBeginParameters>, identity: NotesIdentity, state: DreamState) => Promise<Outcome<DreamBeginData>>;
|
|
39
|
+
readonly execute: (params: Static<typeof dreamBeginParameters>, context: NotesToolContext, state: DreamState) => Promise<Outcome<DreamBeginData>>;
|
|
81
40
|
readonly render: (result: Outcome<DreamBeginData>) => string;
|
|
82
41
|
};
|
|
83
42
|
export declare const dreamForgetParameters: Type.TObject<{
|
|
84
43
|
address: Type.TString;
|
|
85
44
|
}>;
|
|
86
|
-
export
|
|
87
|
-
project_root: Type.TOptional<Type.TString>;
|
|
88
|
-
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
89
|
-
name: Type.TString;
|
|
90
|
-
path: Type.TString;
|
|
91
|
-
}>>>;
|
|
92
|
-
address: Type.TString;
|
|
93
|
-
project_key: Type.TOptional<Type.TString>;
|
|
94
|
-
}>;
|
|
95
|
-
export type DreamForgetData = Static<typeof DreamForgetDataSchema>;
|
|
45
|
+
export type DreamForgetData = ReturnType<typeof noteIdentity>;
|
|
96
46
|
export declare const dreamForget: {
|
|
97
47
|
readonly name: "dream_forget";
|
|
98
48
|
readonly label: "Dream forget";
|
|
99
|
-
readonly description: "
|
|
49
|
+
readonly description: "Permanently delete a crumpled note in the open dream.";
|
|
100
50
|
readonly parameters: Type.TObject<{
|
|
101
51
|
address: Type.TString;
|
|
102
52
|
}>;
|
|
103
|
-
readonly outputSchema: Type.TUnion<[Type.TObject<{
|
|
104
|
-
project_root: Type.TOptional<Type.TString>;
|
|
105
|
-
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
106
|
-
name: Type.TString;
|
|
107
|
-
path: Type.TString;
|
|
108
|
-
}>>>;
|
|
109
|
-
address: Type.TString;
|
|
110
|
-
project_key: Type.TOptional<Type.TString>;
|
|
111
|
-
}>, Type.TObject<{
|
|
112
|
-
error: Type.TString;
|
|
113
|
-
code: Type.TString;
|
|
114
|
-
}>]>;
|
|
115
53
|
readonly execute: (params: Static<typeof dreamForgetParameters>, identity: NotesIdentity, state: DreamState) => Promise<Outcome<DreamForgetData>>;
|
|
116
54
|
readonly render: (result: Outcome<DreamForgetData>) => string;
|
|
117
55
|
};
|
|
118
56
|
export declare const dreamEndParameters: Type.TObject<{}>;
|
|
119
|
-
export
|
|
120
|
-
project:
|
|
121
|
-
commit
|
|
122
|
-
audit_error
|
|
123
|
-
}
|
|
124
|
-
export type DreamEndData = Static<typeof DreamEndDataSchema>;
|
|
57
|
+
export type DreamEndData = {
|
|
58
|
+
project: string;
|
|
59
|
+
commit?: string;
|
|
60
|
+
audit_error?: string;
|
|
61
|
+
};
|
|
125
62
|
export declare const dreamEnd: {
|
|
126
63
|
readonly name: "dream_end";
|
|
127
64
|
readonly label: "Dream end";
|
|
128
|
-
readonly description: "
|
|
65
|
+
readonly description: "Commit dream changes to the notes Git repo and close the open dream.";
|
|
129
66
|
readonly parameters: Type.TObject<{}>;
|
|
130
|
-
readonly outputSchema: Type.TUnion<[Type.TObject<{
|
|
131
|
-
project: Type.TString;
|
|
132
|
-
commit: Type.TOptional<Type.TString>;
|
|
133
|
-
audit_error: Type.TOptional<Type.TString>;
|
|
134
|
-
}>, Type.TObject<{
|
|
135
|
-
error: Type.TString;
|
|
136
|
-
code: Type.TString;
|
|
137
|
-
}>]>;
|
|
138
67
|
readonly execute: (_params: Static<typeof dreamEndParameters>, identity: NotesIdentity, state: DreamState) => Promise<Outcome<DreamEndData>>;
|
|
139
68
|
readonly render: (result: Outcome<DreamEndData>) => string;
|
|
140
69
|
};
|
package/dist/src/tools/dream.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { Type } from "typebox";
|
|
4
4
|
import { localIso } from "../notes/frontmatter.js";
|
|
5
|
-
import { createNotesStore, noteIdentity } from "../notes/index.js";
|
|
6
|
-
import {
|
|
5
|
+
import { compareNoteRows, createNotesStore, noteIdentity } from "../notes/index.js";
|
|
6
|
+
import { projectReceipt } from "../notes/project-namespace.js";
|
|
7
7
|
import { gitCommit } from "../dream/git.js";
|
|
8
8
|
import { trySqliteLock } from "../sqlite-lock.js";
|
|
9
9
|
import { failure, success } from "../result.js";
|
|
10
|
-
import { renderOutcome
|
|
11
|
-
import { failureOf, listedFile,
|
|
10
|
+
import { renderOutcome } from "./result.js";
|
|
11
|
+
import { failureOf, listedFile, renderListData, snapshot } from "./notes.js";
|
|
12
|
+
import { notesIdentityForCall } from "./notes-context.js";
|
|
12
13
|
function currentOpening(state, opening) {
|
|
13
14
|
return state.pending === opening && state.generation === opening.generation;
|
|
14
15
|
}
|
|
@@ -43,29 +44,31 @@ export function dreamingIdentity(identity, state) {
|
|
|
43
44
|
}
|
|
44
45
|
const NOT_DREAMING = "No dream is open; call dream_begin first.";
|
|
45
46
|
export const dreamBeginParameters = Type.Object({
|
|
46
|
-
|
|
47
|
-
}, { additionalProperties: false });
|
|
48
|
-
export const DreamBeginDataSchema = Type.Object({
|
|
49
|
-
project: Type.String(), baseline: Type.String(),
|
|
50
|
-
files: Type.Array(Type.Object({ ...ListedFileSchema.properties, last_accessed: Type.String() }, { additionalProperties: false })),
|
|
51
|
-
...SnapshotSchema,
|
|
47
|
+
cwd: Type.Optional(Type.String({ minLength: 1, description: "Treat this directory's project as current." })),
|
|
52
48
|
}, { additionalProperties: false });
|
|
53
49
|
function renderBeginData(data) {
|
|
54
|
-
|
|
50
|
+
const header = `dreaming over ${data.project} (baseline ${data.baseline}${data.project_root === undefined ? "" : `, project_root ${data.project_root}`})`;
|
|
51
|
+
const siblings = data.project_siblings === undefined ? "" : `\n Same-basename projects: ${data.project_siblings.map(sibling => `${sibling.name} (${sibling.path})`).join(", ")}`;
|
|
52
|
+
return `${header}${siblings}\n${renderListData(data, undefined, { omitNamedProjectContext: true })}`;
|
|
55
53
|
}
|
|
56
54
|
export const dreamBegin = {
|
|
57
55
|
name: "dream_begin", label: "Dream begin",
|
|
58
|
-
description: "
|
|
59
|
-
parameters: dreamBeginParameters,
|
|
60
|
-
async execute(params,
|
|
56
|
+
description: "Open a project's notes and its session notes for consolidation after committing a Git baseline; unlocks writes until `dream_end`.",
|
|
57
|
+
parameters: dreamBeginParameters,
|
|
58
|
+
async execute(params, context, state) {
|
|
61
59
|
if (state.project !== undefined || state.pending !== undefined) {
|
|
62
60
|
const project = state.project ?? state.pending?.project;
|
|
63
61
|
return failure("already_dreaming", `Already dreaming over ${project}; call dream_end before opening another project.`);
|
|
64
62
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
let identity;
|
|
64
|
+
try {
|
|
65
|
+
identity = notesIdentityForCall(context, params.cwd);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
return failureOf(error);
|
|
68
69
|
}
|
|
70
|
+
const project = identity.projectKey;
|
|
71
|
+
const receipt = projectReceipt(identity.home, project);
|
|
69
72
|
const release = trySqliteLock(join(identity.home, ".dream.lock.sqlite"), 0);
|
|
70
73
|
if (!release)
|
|
71
74
|
return failure("already_dreaming", "Another dream is open in this notes home.");
|
|
@@ -85,8 +88,10 @@ export const dreamBegin = {
|
|
|
85
88
|
unavailable.push(...result.status.namespacesUnavailable);
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
|
-
rows.sort(
|
|
89
|
-
const listed = snapshot(rows.map(row => ({ ...listedFile(row, identity), last_accessed: localIso(row.meta.lastAccessed) })), undefined, { namespacesUnavailable: unavailable },
|
|
91
|
+
rows.sort(compareNoteRows);
|
|
92
|
+
const listed = snapshot(rows.map(row => ({ ...listedFile(row, identity), last_accessed: localIso(row.meta.lastAccessed) })), undefined, { namespacesUnavailable: unavailable },
|
|
93
|
+
// Reserve the header before committing; Git object IDs are at most 64 hex digits.
|
|
94
|
+
(data) => renderBeginData({ ...data, project, baseline: "0".repeat(64), ...receipt }));
|
|
90
95
|
if (!listed.ok) {
|
|
91
96
|
releaseOpening(state, opening);
|
|
92
97
|
return listed;
|
|
@@ -103,7 +108,7 @@ export const dreamBegin = {
|
|
|
103
108
|
state.project = opening.project;
|
|
104
109
|
state.release = opening.release;
|
|
105
110
|
delete state.pending;
|
|
106
|
-
return success({ project, baseline: baseline.commit, ...listed.data });
|
|
111
|
+
return success({ project, baseline: baseline.commit, ...receipt, ...listed.data });
|
|
107
112
|
}
|
|
108
113
|
catch (error) {
|
|
109
114
|
if (!currentOpening(state, opening))
|
|
@@ -114,12 +119,11 @@ export const dreamBegin = {
|
|
|
114
119
|
},
|
|
115
120
|
render: (result) => renderOutcome(result, renderBeginData),
|
|
116
121
|
};
|
|
117
|
-
export const dreamForgetParameters = Type.Object({ address: Type.String({ description: "
|
|
118
|
-
export const DreamForgetDataSchema = Type.Object({ ...NoteIdentitySchema }, { additionalProperties: false });
|
|
122
|
+
export const dreamForgetParameters = Type.Object({ address: Type.String({ description: "Address of the crumpled note to delete." }) }, { additionalProperties: false });
|
|
119
123
|
export const dreamForget = {
|
|
120
124
|
name: "dream_forget", label: "Dream forget",
|
|
121
|
-
description: "
|
|
122
|
-
parameters: dreamForgetParameters,
|
|
125
|
+
description: "Permanently delete a crumpled note in the open dream.",
|
|
126
|
+
parameters: dreamForgetParameters,
|
|
123
127
|
async execute(params, identity, state) {
|
|
124
128
|
if (state.project === undefined)
|
|
125
129
|
return failure("not_dreaming", NOT_DREAMING);
|
|
@@ -135,11 +139,10 @@ export const dreamForget = {
|
|
|
135
139
|
render: (result) => renderOutcome(result, data => `forgot ${data.address}`),
|
|
136
140
|
};
|
|
137
141
|
export const dreamEndParameters = Type.Object({}, { additionalProperties: false });
|
|
138
|
-
export const DreamEndDataSchema = Type.Object({ project: Type.String(), commit: Type.Optional(Type.String()), audit_error: Type.Optional(Type.String()) }, { additionalProperties: false });
|
|
139
142
|
export const dreamEnd = {
|
|
140
143
|
name: "dream_end", label: "Dream end",
|
|
141
|
-
description: "
|
|
142
|
-
parameters: dreamEndParameters,
|
|
144
|
+
description: "Commit dream changes to the notes Git repo and close the open dream.",
|
|
145
|
+
parameters: dreamEndParameters,
|
|
143
146
|
async execute(_params, identity, state) {
|
|
144
147
|
const project = state.project;
|
|
145
148
|
if (project === undefined)
|
|
@@ -1,41 +1,48 @@
|
|
|
1
|
-
/** Host-neutral history operations:
|
|
1
|
+
/** Host-neutral history operations: bounded plain-text output. */
|
|
2
2
|
import { Type, type Static } from "typebox";
|
|
3
|
-
import { type Operation } from "./result.js";
|
|
3
|
+
import { type TextWindow, type Operation } from "./result.js";
|
|
4
4
|
import { type HistoryPage } from "../history/query.js";
|
|
5
5
|
import { type HistoryContext } from "../history/corpus.js";
|
|
6
|
+
import { type HistoryRole, type NestedCallSummary, type ToolSummary } from "../history/history.js";
|
|
6
7
|
/** One read: identity, tool summary and a flat document slice. */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
session
|
|
20
|
-
|
|
21
|
-
seq: Type.TInteger;
|
|
22
|
-
role: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"assistant">, Type.TLiteral<"tool">, Type.TLiteral<"context">]>;
|
|
23
|
-
created_at: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
24
|
-
}>;
|
|
25
|
-
type HistoryReadData = Static<typeof HistoryReadDataSchema>;
|
|
8
|
+
type HistoryReadData = ToolSummary & TextWindow & {
|
|
9
|
+
session?: string;
|
|
10
|
+
notice?: string;
|
|
11
|
+
seq: number;
|
|
12
|
+
role: HistoryRole;
|
|
13
|
+
created_at: string | null;
|
|
14
|
+
nested_calls?: NestedCallSummary;
|
|
15
|
+
};
|
|
16
|
+
type TimelinePage = HistoryPage & {
|
|
17
|
+
paging: Omit<Static<typeof historyListParameters>, "after" | "before">;
|
|
18
|
+
};
|
|
19
|
+
type SearchPage = HistoryPage & {
|
|
20
|
+
session?: string;
|
|
21
|
+
};
|
|
26
22
|
/** Pure host decoration, measured during selection and applied unchanged by the caller at delivery. */
|
|
27
23
|
export type HistoryTextWrapper = (text: string) => string;
|
|
28
24
|
export declare const historyListParameters: Type.TObject<{
|
|
29
25
|
session: Type.TOptional<Type.TString>;
|
|
30
|
-
roles: Type.TOptional<Type.TArray<Type.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
roles: Type.TOptional<Type.TArray<Type.TUnsafe<"user" | "assistant" | "tool" | "context">>>;
|
|
27
|
+
after: Type.TOptional<Type.TInteger>;
|
|
28
|
+
before: Type.TOptional<Type.TInteger>;
|
|
29
|
+
since: Type.TOptional<Type.TString>;
|
|
30
|
+
until: Type.TOptional<Type.TString>;
|
|
31
|
+
limit: Type.TOptional<Type.TInteger>;
|
|
32
|
+
max_chars_per_item: Type.TOptional<Type.TInteger>;
|
|
33
|
+
}>;
|
|
34
|
+
export declare const historyList: Operation<typeof historyListParameters, TimelinePage | SearchPage, [HistoryContext, HistoryTextWrapper?]>;
|
|
35
|
+
export declare const historySearchParameters: Type.TObject<{
|
|
36
|
+
session: Type.TOptional<Type.TString>;
|
|
37
|
+
query: Type.TUnion<[Type.TString, Type.TArray<Type.TString>]>;
|
|
38
|
+
since: Type.TOptional<Type.TString>;
|
|
39
|
+
until: Type.TOptional<Type.TString>;
|
|
40
|
+
roles: Type.TOptional<Type.TArray<Type.TUnsafe<"user" | "assistant" | "tool" | "context">>>;
|
|
34
41
|
context: Type.TOptional<Type.TInteger>;
|
|
35
42
|
limit: Type.TOptional<Type.TInteger>;
|
|
36
43
|
max_chars_per_item: Type.TOptional<Type.TInteger>;
|
|
37
44
|
}>;
|
|
38
|
-
export declare const
|
|
45
|
+
export declare const historySearch: Operation<typeof historySearchParameters, SearchPage, [HistoryContext, HistoryTextWrapper?]>;
|
|
39
46
|
export declare const historyReadParameters: Type.TObject<{
|
|
40
47
|
offset_chars: Type.TOptional<Type.TInteger>;
|
|
41
48
|
max_chars: Type.TOptional<Type.TInteger>;
|