notesoup 0.43.0 → 0.45.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/README.md +1 -0
- package/cordis.patch.yml +14 -0
- package/dist/src/boot/snapshot.d.ts +2 -0
- package/dist/src/boot/snapshot.js +4 -0
- package/dist/src/boot/text.js +3 -1
- package/dist/src/claude/helper.js +2 -2
- package/dist/src/dsh/budget.d.ts +20 -0
- package/dist/src/dsh/budget.js +34 -0
- package/dist/src/dsh/engine.d.ts +22 -0
- package/dist/src/dsh/engine.js +193 -0
- package/dist/src/dsh/history.d.ts +6 -0
- package/dist/src/dsh/history.js +73 -0
- package/dist/src/dsh/index.d.ts +22 -0
- package/dist/src/dsh/index.js +63 -0
- package/dist/src/dsh/preflight.d.ts +8 -0
- package/dist/src/dsh/preflight.js +35 -0
- package/dist/src/dsh/tools.d.ts +3 -0
- package/dist/src/dsh/tools.js +111 -0
- package/dist/src/dsh/window.d.ts +46 -0
- package/dist/src/dsh/window.js +124 -0
- package/dist/src/notes/address.d.ts +2 -2
- package/dist/src/notes/address.js +5 -5
- package/dist/src/notes/identity.js +2 -1
- package/dist/src/notes/paths.d.ts +1 -6
- package/dist/src/notes/paths.js +5 -68
- package/dist/src/notes/project-home.d.ts +25 -0
- package/dist/src/notes/project-home.js +231 -0
- package/dist/src/notes/store.d.ts +3 -2
- package/dist/src/notes/store.js +14 -8
- package/dist/src/pi/boot.js +17 -5
- package/dist/src/pi/notes/adapter.js +1 -1
- package/dist/src/tools/notes.d.ts +47 -17
- package/dist/src/tools/notes.js +15 -4
- package/dist/test/claude-mod.test.js +32 -1
- package/dist/test/dependencies.test.js +27 -1
- package/dist/test/dsh-cli.test.d.ts +1 -0
- package/dist/test/dsh-cli.test.js +44 -0
- package/dist/test/dsh-compaction-parity.test.d.ts +1 -0
- package/dist/test/dsh-compaction-parity.test.js +143 -0
- package/dist/test/dsh.test.d.ts +1 -0
- package/dist/test/dsh.test.js +323 -0
- package/dist/test/helpers/dependency-graph.js +3 -3
- package/dist/test/helpers/dsh-messages.d.ts +29 -0
- package/dist/test/helpers/dsh-messages.js +33 -0
- package/dist/test/helpers/dsh.d.ts +17 -0
- package/dist/test/helpers/dsh.js +50 -0
- package/dist/test/notes.test.js +22 -19
- package/dist/test/project-home.test.d.ts +1 -0
- package/dist/test/project-home.test.js +134 -0
- package/docs/architecture.md +4 -1
- package/docs/dsh.md +61 -0
- package/docs/dsh.profile.patch.yml +34 -0
- package/mods/notesoup/.claude-plugin/plugin.json +1 -1
- package/mods/notesoup/dist/claude/helper.js +223 -56
- package/mods/notesoup/skills/memory/SKILL.md +1 -0
- package/package.json +63 -4
- package/skills/memory/SKILL.md +1 -0
- package/src/boot/snapshot.ts +5 -0
- package/src/boot/text.ts +3 -1
- package/src/claude/helper.ts +2 -2
- package/src/dsh/budget.ts +35 -0
- package/src/dsh/engine.ts +160 -0
- package/src/dsh/history.ts +57 -0
- package/src/dsh/index.ts +69 -0
- package/src/dsh/preflight.ts +29 -0
- package/src/dsh/tools.ts +107 -0
- package/src/dsh/window.ts +126 -0
- package/src/notes/address.ts +5 -5
- package/src/notes/identity.ts +1 -1
- package/src/notes/paths.ts +4 -60
- package/src/notes/project-home.ts +197 -0
- package/src/notes/store.ts +13 -9
- package/src/pi/boot.ts +15 -5
- package/src/pi/notes/adapter.ts +1 -1
- package/src/tools/notes.ts +16 -6
- package/mods/pi-context/dist/claude/helper.js +0 -9324
|
@@ -7974,9 +7974,9 @@ function isFilesystemError(error) {
|
|
|
7974
7974
|
}
|
|
7975
7975
|
|
|
7976
7976
|
// src/notes/store.ts
|
|
7977
|
-
import { randomUUID } from "node:crypto";
|
|
7977
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
7978
7978
|
import { mkdir, readdir as readdir2, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
7979
|
-
import { dirname as dirname2, join as
|
|
7979
|
+
import { dirname as dirname2, join as join3, resolve as resolve3 } from "node:path";
|
|
7980
7980
|
|
|
7981
7981
|
// src/text-match.ts
|
|
7982
7982
|
function earliestMatchOffsetChars(text, queries) {
|
|
@@ -8009,28 +8009,165 @@ function shown(value) {
|
|
|
8009
8009
|
}
|
|
8010
8010
|
|
|
8011
8011
|
// src/notes/paths.ts
|
|
8012
|
-
import { createHash } from "node:crypto";
|
|
8013
|
-
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
8014
8012
|
import { readdir } from "node:fs/promises";
|
|
8013
|
+
import { join as join2 } from "node:path";
|
|
8014
|
+
|
|
8015
|
+
// src/notes/project-home.ts
|
|
8016
|
+
import { randomUUID } from "node:crypto";
|
|
8017
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
8015
8018
|
import { basename, dirname, join, resolve, sep } from "node:path";
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
if (typeof value !== "string" || value.length === 0) throw new NoteError("invalid_address", "The address is empty; give the note a path.");
|
|
8019
|
-
if (value.includes("\0") || value.includes("\\") || value.startsWith("/")) throw new NoteError("invalid_address", `${shown(value)}: a note path can't start with "/" or contain "\\" or NUL.`);
|
|
8020
|
-
const parts = value.split("/");
|
|
8021
|
-
if (parts.some((part) => part.length === 0 || part === "." || part === "..")) throw new NoteError("invalid_address", `${shown(value)}: a note path can't have empty, ".", or ".." folder names.`);
|
|
8022
|
-
return value;
|
|
8019
|
+
function errno(error) {
|
|
8020
|
+
return typeof error === "object" && error !== null ? error.code : void 0;
|
|
8023
8021
|
}
|
|
8024
|
-
function
|
|
8022
|
+
function normalizeRemote(value) {
|
|
8023
|
+
let text = value.trim();
|
|
8024
|
+
const scp = /^(?:[^/@]+)@([^:/]+):(.+)$/.exec(text);
|
|
8025
|
+
if (scp) text = `${scp[1].toLowerCase()}/${scp[2]}`;
|
|
8026
|
+
else if (/^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(text)) {
|
|
8027
|
+
try {
|
|
8028
|
+
const url = new URL(text);
|
|
8029
|
+
const host = url.hostname.toLowerCase();
|
|
8030
|
+
const port = url.port.length > 0 ? `:${url.port}` : "";
|
|
8031
|
+
text = `${host}${port}${url.pathname}`;
|
|
8032
|
+
} catch {
|
|
8033
|
+
text = text.replace(/^[A-Za-z][A-Za-z0-9+.-]*:\/\//, "").replace(/^[^/@]+@/, "");
|
|
8034
|
+
}
|
|
8035
|
+
} else {
|
|
8036
|
+
text = text.replace(/^[^/@]+@/, "");
|
|
8037
|
+
const slash = text.indexOf("/");
|
|
8038
|
+
if (slash > 0) text = `${text.slice(0, slash).toLowerCase()}${text.slice(slash)}`;
|
|
8039
|
+
}
|
|
8040
|
+
text = text.replace(/\/+$/, "").replace(/\.git$/i, "").replace(/\/+$/, "");
|
|
8041
|
+
return text;
|
|
8042
|
+
}
|
|
8043
|
+
function canonicalRoot(cwd) {
|
|
8025
8044
|
const absolute = resolve(cwd);
|
|
8026
8045
|
const spelled = gitRoot(absolute) ?? absolute;
|
|
8027
|
-
let root = spelled;
|
|
8028
8046
|
try {
|
|
8029
|
-
|
|
8047
|
+
return realpathSync(spelled);
|
|
8030
8048
|
} catch {
|
|
8049
|
+
return spelled;
|
|
8050
|
+
}
|
|
8051
|
+
}
|
|
8052
|
+
function originRemote(root) {
|
|
8053
|
+
let gitDir = join(root, ".git");
|
|
8054
|
+
let raw;
|
|
8055
|
+
try {
|
|
8056
|
+
if (!statSync(gitDir).isDirectory()) {
|
|
8057
|
+
const pointer = /^gitdir:\s*(.+)$/m.exec(readFileSync(gitDir, "utf8"));
|
|
8058
|
+
if (!pointer) return void 0;
|
|
8059
|
+
gitDir = resolve(root, pointer[1].trim());
|
|
8060
|
+
}
|
|
8061
|
+
try {
|
|
8062
|
+
gitDir = resolve(gitDir, readFileSync(join(gitDir, "commondir"), "utf8").trim());
|
|
8063
|
+
} catch (error) {
|
|
8064
|
+
if (errno(error) !== "ENOENT") throw error;
|
|
8065
|
+
}
|
|
8066
|
+
raw = readFileSync(join(gitDir, "config"), "utf8");
|
|
8067
|
+
} catch (error) {
|
|
8068
|
+
if (errno(error) === "ENOENT") return void 0;
|
|
8069
|
+
throw error;
|
|
8070
|
+
}
|
|
8071
|
+
let origin = false;
|
|
8072
|
+
for (const line of raw.split(/\r?\n/)) {
|
|
8073
|
+
const section2 = /^\s*\[remote\s+"([^"]+)"\]\s*$/.exec(line);
|
|
8074
|
+
if (section2) {
|
|
8075
|
+
origin = section2[1] === "origin";
|
|
8076
|
+
continue;
|
|
8077
|
+
}
|
|
8078
|
+
if (/^\s*\[/.test(line)) origin = false;
|
|
8079
|
+
if (origin) {
|
|
8080
|
+
const url = /^\s*url\s*=\s*(.*?)\s*$/.exec(line);
|
|
8081
|
+
if (url) return normalizeRemote(url[1].replace(/^"(.*)"$/, "$1")) || void 0;
|
|
8082
|
+
}
|
|
8083
|
+
}
|
|
8084
|
+
return void 0;
|
|
8085
|
+
}
|
|
8086
|
+
function readMarker(dir) {
|
|
8087
|
+
let raw;
|
|
8088
|
+
try {
|
|
8089
|
+
raw = readFileSync(join(dir, ".project"), "utf8");
|
|
8090
|
+
} catch (error) {
|
|
8091
|
+
if (errno(error) === "ENOENT") return void 0;
|
|
8092
|
+
throw error;
|
|
8093
|
+
}
|
|
8094
|
+
try {
|
|
8095
|
+
const value = JSON.parse(raw);
|
|
8096
|
+
if (typeof value.id !== "string" || value.id.length === 0 || typeof value.path !== "string" || value.path.length === 0) return void 0;
|
|
8097
|
+
return { name: basename(dir), dir, id: value.id, path: value.path };
|
|
8098
|
+
} catch {
|
|
8099
|
+
return void 0;
|
|
8100
|
+
}
|
|
8101
|
+
}
|
|
8102
|
+
function projectRoot(home) {
|
|
8103
|
+
return join(home, "project");
|
|
8104
|
+
}
|
|
8105
|
+
function projectHomes(home) {
|
|
8106
|
+
const root = projectRoot(home);
|
|
8107
|
+
let entries;
|
|
8108
|
+
try {
|
|
8109
|
+
entries = readdirSync(root, { withFileTypes: true });
|
|
8110
|
+
} catch (error) {
|
|
8111
|
+
if (errno(error) === "ENOENT") return [];
|
|
8112
|
+
throw error;
|
|
8113
|
+
}
|
|
8114
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => readMarker(join(root, entry.name))).filter((entry) => entry !== void 0).sort((a, b) => a.name.localeCompare(b.name));
|
|
8115
|
+
}
|
|
8116
|
+
function updateMarker(home, marker) {
|
|
8117
|
+
const markerPath = join(home.dir, ".project");
|
|
8118
|
+
const temp = `${markerPath}.${process.pid}.${randomUUID()}.tmp`;
|
|
8119
|
+
try {
|
|
8120
|
+
writeFileSync(temp, JSON.stringify(marker));
|
|
8121
|
+
renameSync(temp, markerPath);
|
|
8122
|
+
} catch (error) {
|
|
8123
|
+
try {
|
|
8124
|
+
rmSync(temp, { force: true });
|
|
8125
|
+
} catch {
|
|
8126
|
+
}
|
|
8127
|
+
throw error;
|
|
8128
|
+
}
|
|
8129
|
+
return { ...home, ...marker };
|
|
8130
|
+
}
|
|
8131
|
+
function resolveProjectHome(cwd, home) {
|
|
8132
|
+
const root = canonicalRoot(cwd);
|
|
8133
|
+
const remote = originRemote(root);
|
|
8134
|
+
const id = remote ?? root;
|
|
8135
|
+
const markerRoot = projectRoot(home);
|
|
8136
|
+
mkdirSync(markerRoot, { recursive: true });
|
|
8137
|
+
const homes = projectHomes(home);
|
|
8138
|
+
let found = homes.find((candidate) => candidate.id === id);
|
|
8139
|
+
if (!found && remote) {
|
|
8140
|
+
found = homes.find((candidate) => candidate.id === root);
|
|
8141
|
+
if (found) found = updateMarker(found, { id: remote, path: root });
|
|
8142
|
+
}
|
|
8143
|
+
if (found) {
|
|
8144
|
+
if (found.path !== root) found = updateMarker(found, { id: found.id, path: root });
|
|
8145
|
+
return found;
|
|
8146
|
+
}
|
|
8147
|
+
const base = slugify(basename(root));
|
|
8148
|
+
const taken = new Set(readdirSync(markerRoot));
|
|
8149
|
+
for (let suffix = 0; ; suffix++) {
|
|
8150
|
+
const name = suffix === 0 ? base : `${base}-${suffix}`;
|
|
8151
|
+
if (taken.has(name)) continue;
|
|
8152
|
+
const dir = join(markerRoot, name);
|
|
8153
|
+
try {
|
|
8154
|
+
mkdirSync(dir, { recursive: true });
|
|
8155
|
+
writeFileSync(join(dir, ".project"), JSON.stringify({ id, path: root }), { flag: "wx" });
|
|
8156
|
+
return { name, dir, id, path: root };
|
|
8157
|
+
} catch (error) {
|
|
8158
|
+
if (errno(error) === "EEXIST") continue;
|
|
8159
|
+
throw error;
|
|
8160
|
+
}
|
|
8161
|
+
}
|
|
8162
|
+
}
|
|
8163
|
+
function gitRoot(cwd) {
|
|
8164
|
+
let dir = resolve(cwd);
|
|
8165
|
+
for (; ; ) {
|
|
8166
|
+
if (existsSync(join(dir, ".git"))) return repositoryRoot(dir);
|
|
8167
|
+
const parent = dirname(dir);
|
|
8168
|
+
if (parent === dir) return void 0;
|
|
8169
|
+
dir = parent;
|
|
8031
8170
|
}
|
|
8032
|
-
const digest = createHash("sha1").update(root).digest("hex").slice(0, 8);
|
|
8033
|
-
return `${basename(root)}-${digest}`;
|
|
8034
8171
|
}
|
|
8035
8172
|
function repositoryRoot(dir) {
|
|
8036
8173
|
let stats;
|
|
@@ -8054,30 +8191,45 @@ function repositoryRoot(dir) {
|
|
|
8054
8191
|
const common = parts.slice(0, worktrees).join(sep);
|
|
8055
8192
|
return basename(common) === ".git" ? dirname(common) : dir;
|
|
8056
8193
|
}
|
|
8057
|
-
function
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8194
|
+
function projectReceipt(home, name) {
|
|
8195
|
+
const project = readMarker(join(projectRoot(home), name));
|
|
8196
|
+
if (!project) return {};
|
|
8197
|
+
const base = slugify(basename(project.path));
|
|
8198
|
+
const siblings = projectHomes(home).filter((candidate) => candidate.name !== name && slugify(basename(candidate.path)) === base);
|
|
8199
|
+
return {
|
|
8200
|
+
project_root: project.path,
|
|
8201
|
+
...siblings.length === 0 ? {} : { project_siblings: siblings.map(({ name: name2, path }) => ({ name: name2, path })) }
|
|
8202
|
+
};
|
|
8203
|
+
}
|
|
8204
|
+
|
|
8205
|
+
// src/notes/paths.ts
|
|
8206
|
+
var SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
8207
|
+
function slugify(value) {
|
|
8208
|
+
const slug = value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
8209
|
+
return slug.length > 0 ? slug : "root";
|
|
8210
|
+
}
|
|
8211
|
+
function assertVirtualPath(value) {
|
|
8212
|
+
if (typeof value !== "string" || value.length === 0) throw new NoteError("invalid_address", "The address is empty; give the note a path.");
|
|
8213
|
+
if (value.includes("\0") || value.includes("\\") || value.startsWith("/")) throw new NoteError("invalid_address", `${shown(value)}: a note path can't start with "/" or contain "\\" or NUL.`);
|
|
8214
|
+
const parts = value.split("/");
|
|
8215
|
+
if (parts.some((part) => part.length === 0 || part === "." || part === "..")) throw new NoteError("invalid_address", `${shown(value)}: a note path can't have empty, ".", or ".." folder names.`);
|
|
8216
|
+
return value;
|
|
8065
8217
|
}
|
|
8066
8218
|
function sessionHomesRoot(home) {
|
|
8067
|
-
return
|
|
8219
|
+
return join2(home, "pi", "session");
|
|
8068
8220
|
}
|
|
8069
8221
|
function scopeDir(scope, identity2, who) {
|
|
8070
8222
|
if (!["session", "project", "human", "agent", "model"].includes(scope)) throw new TypeError("invalid notes scope");
|
|
8071
|
-
if (who !== void 0 && (scope !== "agent" && scope !== "model" || !SLUG_PATTERN.test(who))) throw new TypeError("who must be a canonical agent/model slug");
|
|
8072
|
-
if (scope === "human") return
|
|
8073
|
-
if (scope === "project") return
|
|
8074
|
-
if (scope === "agent") return
|
|
8075
|
-
if (scope === "model") return
|
|
8076
|
-
return
|
|
8223
|
+
if (who !== void 0 && (scope !== "project" && scope !== "agent" && scope !== "model" || !SLUG_PATTERN.test(who))) throw new TypeError("who must be a canonical project/agent/model slug");
|
|
8224
|
+
if (scope === "human") return join2(identity2.home, "human");
|
|
8225
|
+
if (scope === "project") return join2(identity2.home, "project", who ?? identity2.projectKey);
|
|
8226
|
+
if (scope === "agent") return join2(identity2.home, "agents", who ?? identity2.agent);
|
|
8227
|
+
if (scope === "model") return join2(identity2.home, "models", who ?? identity2.model);
|
|
8228
|
+
return join2(sessionHomesRoot(identity2.home), identity2.sessionId);
|
|
8077
8229
|
}
|
|
8078
8230
|
async function namespaceSlugs(namespace, home) {
|
|
8079
8231
|
try {
|
|
8080
|
-
return (await readdir(
|
|
8232
|
+
return (await readdir(join2(home, namespace), { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
8081
8233
|
} catch (error) {
|
|
8082
8234
|
if (error.code === "ENOENT") return [];
|
|
8083
8235
|
throw error;
|
|
@@ -8087,11 +8239,11 @@ function noteFileName(vpath) {
|
|
|
8087
8239
|
return vpath.endsWith(".md") ? vpath : `${vpath}.md`;
|
|
8088
8240
|
}
|
|
8089
8241
|
function physicalPath(scope, vpath, identity2, who) {
|
|
8090
|
-
return
|
|
8242
|
+
return join2(scopeDir(scope, identity2, who), ...noteFileName(vpath).split("/"));
|
|
8091
8243
|
}
|
|
8092
8244
|
|
|
8093
8245
|
// src/notes/address.ts
|
|
8094
|
-
var ADDRESS_FORMS = "Use <path> for this session, or @project/, @human/, @self/, or @model/ followed by a path.";
|
|
8246
|
+
var ADDRESS_FORMS = "Use <path> for this session, or @project/, @human/, @self/, or @model/ followed by a path; @projects/<name>/<path> reads a named project home.";
|
|
8095
8247
|
function globToRegExp(pattern) {
|
|
8096
8248
|
let source = "^";
|
|
8097
8249
|
for (let index = 0; index < pattern.length; index++) {
|
|
@@ -8133,11 +8285,11 @@ function assertAddress(value) {
|
|
|
8133
8285
|
else if (head === "human") scope = "human";
|
|
8134
8286
|
else if (head === "self") scope = "agent";
|
|
8135
8287
|
else if (head === "model") scope = "model";
|
|
8136
|
-
else if (head === "agents" || head === "models") {
|
|
8288
|
+
else if (head === "projects" || head === "agents" || head === "models") {
|
|
8137
8289
|
const nameEnd = tail.indexOf("/");
|
|
8138
8290
|
who = nameEnd === -1 ? tail : tail.slice(0, nameEnd);
|
|
8139
8291
|
if (!SLUG_PATTERN.test(who)) throw new NoteError("invalid_address", `${shown(value)} isn't a note address. ${ADDRESS_FORMS}`);
|
|
8140
|
-
scope = head === "agents" ? "agent" : "model";
|
|
8292
|
+
scope = head === "projects" ? "project" : head === "agents" ? "agent" : "model";
|
|
8141
8293
|
path = nameEnd === -1 ? "" : tail.slice(nameEnd + 1);
|
|
8142
8294
|
} else {
|
|
8143
8295
|
throw new NoteError("invalid_address", `${shown(value)} isn't a note address. ${ADDRESS_FORMS}`);
|
|
@@ -8151,7 +8303,7 @@ function assertAddress(value) {
|
|
|
8151
8303
|
}
|
|
8152
8304
|
function canonicalAddressFor(identity2, scope, path, who) {
|
|
8153
8305
|
if (scope === "session") return path;
|
|
8154
|
-
if (scope === "project") return `@project/${path}`;
|
|
8306
|
+
if (scope === "project") return who === void 0 ? `@project/${path}` : `@projects/${who}/${path}`;
|
|
8155
8307
|
if (scope === "human") return `@human/${path}`;
|
|
8156
8308
|
if (scope === "agent") return `@agents/${who ?? identity2.agent}/${path}`;
|
|
8157
8309
|
return `@models/${who ?? identity2.model}/${path}`;
|
|
@@ -8181,7 +8333,7 @@ function snapshotNotesIdentity(value) {
|
|
|
8181
8333
|
const agent = requireString("agent", value.agent);
|
|
8182
8334
|
const model = requireString("model", value.model);
|
|
8183
8335
|
assertDirectoryComponent("sessionId", sessionId);
|
|
8184
|
-
|
|
8336
|
+
if (!SLUG_PATTERN.test(projectKey2)) throw new TypeError("notes context projectKey must be a canonical lowercase slug");
|
|
8185
8337
|
if (!SLUG_PATTERN.test(agent)) throw new TypeError("notes context agent must be a canonical lowercase slug");
|
|
8186
8338
|
if (!SLUG_PATTERN.test(model)) throw new TypeError("notes context model must be a canonical lowercase slug");
|
|
8187
8339
|
const home = resolve2(homeValue);
|
|
@@ -8203,7 +8355,7 @@ function noteIdentity(identity2, address) {
|
|
|
8203
8355
|
const resolved = assertAddress(address);
|
|
8204
8356
|
return {
|
|
8205
8357
|
address: addressFor(identity2, resolved.scope, noteFileName(resolved.path), resolved.who),
|
|
8206
|
-
...resolved.scope
|
|
8358
|
+
...resolved.scope !== "project" ? {} : resolved.who === void 0 ? { project_key: identity2.projectKey } : projectReceipt(identity2.home, resolved.who)
|
|
8207
8359
|
};
|
|
8208
8360
|
}
|
|
8209
8361
|
var SCOPE_ORDER = ["session", "project", "human", "agent", "model"];
|
|
@@ -8219,14 +8371,14 @@ function withPathQueue(path, operation) {
|
|
|
8219
8371
|
});
|
|
8220
8372
|
return result;
|
|
8221
8373
|
}
|
|
8222
|
-
function
|
|
8374
|
+
function errno2(error) {
|
|
8223
8375
|
return typeof error === "object" && error !== null ? error.code : void 0;
|
|
8224
8376
|
}
|
|
8225
8377
|
async function readFileIfExists(path) {
|
|
8226
8378
|
try {
|
|
8227
8379
|
return await readFile(path, "utf8");
|
|
8228
8380
|
} catch (error) {
|
|
8229
|
-
if (
|
|
8381
|
+
if (errno2(error) === "ENOENT") return void 0;
|
|
8230
8382
|
throw error;
|
|
8231
8383
|
}
|
|
8232
8384
|
}
|
|
@@ -8235,12 +8387,12 @@ async function walkMarkdown(dir, base = dir) {
|
|
|
8235
8387
|
try {
|
|
8236
8388
|
entries = await readdir2(dir, { withFileTypes: true });
|
|
8237
8389
|
} catch (error) {
|
|
8238
|
-
if (
|
|
8390
|
+
if (errno2(error) === "ENOENT") return [];
|
|
8239
8391
|
throw error;
|
|
8240
8392
|
}
|
|
8241
8393
|
const paths = [];
|
|
8242
8394
|
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
8243
|
-
const child =
|
|
8395
|
+
const child = join3(dir, entry.name);
|
|
8244
8396
|
if (entry.isDirectory()) paths.push(...await walkMarkdown(child, base));
|
|
8245
8397
|
else if (entry.isFile() && entry.name.endsWith(".md")) paths.push(child.slice(base.length + 1).split("\\").join("/"));
|
|
8246
8398
|
}
|
|
@@ -8253,11 +8405,12 @@ async function homesForPattern(pattern, identity2) {
|
|
|
8253
8405
|
if (head === "human") return [{ scope: "human" }];
|
|
8254
8406
|
if (head === "self") return [{ scope: "agent" }];
|
|
8255
8407
|
if (head === "model") return [{ scope: "model" }];
|
|
8256
|
-
if (head === "agents" || head === "models") {
|
|
8257
|
-
const scope = head === "agents" ? "agent" : "model";
|
|
8408
|
+
if (head === "projects" || head === "agents" || head === "models") {
|
|
8409
|
+
const scope = head === "projects" ? "project" : head === "agents" ? "agent" : "model";
|
|
8258
8410
|
const name = pattern.slice(head.length + 2).split("/")[0] ?? "";
|
|
8259
8411
|
if (name.length > 0 && !/[*?]/.test(name)) return [{ scope, who: assertWho(name) }];
|
|
8260
|
-
|
|
8412
|
+
const names = head === "projects" ? projectHomes(identity2.home).map((home) => home.name) : await namespaceSlugs(head, identity2.home);
|
|
8413
|
+
return names.map((who) => ({ scope, who }));
|
|
8261
8414
|
}
|
|
8262
8415
|
return [];
|
|
8263
8416
|
}
|
|
@@ -8315,7 +8468,7 @@ function anchorLines(lines) {
|
|
|
8315
8468
|
}
|
|
8316
8469
|
async function atomicWrite(path, content) {
|
|
8317
8470
|
await mkdir(dirname2(path), { recursive: true });
|
|
8318
|
-
const tmp = `${path}.${process.pid}.${
|
|
8471
|
+
const tmp = `${path}.${process.pid}.${randomUUID2()}.tmp`;
|
|
8319
8472
|
try {
|
|
8320
8473
|
await writeFile(tmp, content);
|
|
8321
8474
|
await rename(tmp, path);
|
|
@@ -8343,6 +8496,7 @@ function frontmatterOf(meta) {
|
|
|
8343
8496
|
}
|
|
8344
8497
|
function assertWritableHome(scope, who, identity2) {
|
|
8345
8498
|
if (who === void 0) return;
|
|
8499
|
+
if (scope === "project") throw new NoteError("invalid_scope", `@projects/${who}/ is read-only; use @project/ to write to your own project.`);
|
|
8346
8500
|
const current = scope === "agent" ? identity2.agent : identity2.model;
|
|
8347
8501
|
if (who === current) return;
|
|
8348
8502
|
const home = scope === "agent" ? `@agents/${who}/` : `@models/${who}/`;
|
|
@@ -8392,6 +8546,7 @@ function createNotesStore(input) {
|
|
|
8392
8546
|
if (raw === void 0) return void 0;
|
|
8393
8547
|
const now = Date.now();
|
|
8394
8548
|
const parsed = parseNote(raw, now);
|
|
8549
|
+
if (scope === "project" && destination.who !== void 0) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope };
|
|
8395
8550
|
const meta = { ...parsed.meta, scope, lastAccessed: now, accessCount: (typeof parsed.meta.accessCount === "number" ? parsed.meta.accessCount : 0) + 1 };
|
|
8396
8551
|
await atomicWrite(path, serializeNote(meta, parsed.body));
|
|
8397
8552
|
return { meta, body: parsed.body, resolvedScope: scope };
|
|
@@ -8490,8 +8645,8 @@ function createNotesStore(input) {
|
|
|
8490
8645
|
try {
|
|
8491
8646
|
homes = await homesFor(identity2, options);
|
|
8492
8647
|
} catch (error) {
|
|
8493
|
-
if (!status || !isFilesystemError(error) || !/^@(agents|models)\//.test(options.glob ?? "")) throw error;
|
|
8494
|
-
status.homesUnavailable.push(options.glob.
|
|
8648
|
+
if (!status || !isFilesystemError(error) || !/^@(projects|agents|models)\//.test(options.glob ?? "")) throw error;
|
|
8649
|
+
status.homesUnavailable.push(options.glob.split("/")[0]);
|
|
8495
8650
|
return;
|
|
8496
8651
|
}
|
|
8497
8652
|
for (const home of homes) {
|
|
@@ -8508,7 +8663,7 @@ function createNotesStore(input) {
|
|
|
8508
8663
|
for (const path of paths) {
|
|
8509
8664
|
if (matcher && !matcher.test(canonicalAddressFor(identity2, scope, path, home.who))) continue;
|
|
8510
8665
|
const address = addressFor(identity2, scope, path, home.who);
|
|
8511
|
-
const fullPath =
|
|
8666
|
+
const fullPath = join3(root, path);
|
|
8512
8667
|
let raw;
|
|
8513
8668
|
try {
|
|
8514
8669
|
raw = await withPathQueue(fullPath, () => readFile(fullPath, "utf8"));
|
|
@@ -8711,7 +8866,7 @@ var CRUMPLED_PARAMETER = typebox_exports.Optional(typebox_exports.Boolean({ desc
|
|
|
8711
8866
|
var CRUMPLED_LIST_PARAMETER = typebox_exports.Optional(typebox_exports.Boolean({ description: "(optional) true = list only crumpled notes." }));
|
|
8712
8867
|
var FILE_LIMIT_PARAMETER = typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, description: "(optional, default as many as fit) Max notes." }));
|
|
8713
8868
|
var GLOB_PARAMETER = nullableString("(optional) Glob over full addresses.");
|
|
8714
|
-
var ADDRESS_DESCRIPTION = "Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes. Not file paths: never pass them to file tools.";
|
|
8869
|
+
var ADDRESS_DESCRIPTION = "Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes; `@projects/<name>/<path>` reads a named project (discover with glob `@projects/*/**`). Not file paths: never pass them to file tools.";
|
|
8715
8870
|
function failureOf(error) {
|
|
8716
8871
|
if (error instanceof NoteError) return failure(error.code, error.message);
|
|
8717
8872
|
if (error instanceof InvalidQueryError) return failure("invalid_query", error.message);
|
|
@@ -8769,11 +8924,20 @@ function renderMetadata(metadata) {
|
|
|
8769
8924
|
return fields.join(" | ");
|
|
8770
8925
|
}
|
|
8771
8926
|
function renderIdentity(identity2) {
|
|
8772
|
-
|
|
8773
|
-
}
|
|
8927
|
+
let text = identity2.project_key === void 0 ? identity2.address : `${identity2.address} (project ${identity2.project_key})`;
|
|
8928
|
+
if (identity2.project_root !== void 0) text += ` (project_root ${identity2.project_root})`;
|
|
8929
|
+
if (identity2.project_siblings !== void 0) text += `
|
|
8930
|
+
Same-basename projects: ${identity2.project_siblings.map((sibling) => `${sibling.name} (${sibling.path})`).join(", ")}`;
|
|
8931
|
+
return text;
|
|
8932
|
+
}
|
|
8933
|
+
var ProjectReceiptSchema = {
|
|
8934
|
+
project_root: typebox_exports.Optional(typebox_exports.String()),
|
|
8935
|
+
project_siblings: typebox_exports.Optional(typebox_exports.Array(typebox_exports.Object({ name: typebox_exports.String(), path: typebox_exports.String() }, { additionalProperties: false })))
|
|
8936
|
+
};
|
|
8774
8937
|
var ListedFileSchema = typebox_exports.Object({
|
|
8775
8938
|
address: typebox_exports.String(),
|
|
8776
8939
|
project_key: typebox_exports.Optional(typebox_exports.String()),
|
|
8940
|
+
...ProjectReceiptSchema,
|
|
8777
8941
|
updated_at: typebox_exports.String(),
|
|
8778
8942
|
crumpled_at: typebox_exports.Optional(typebox_exports.String())
|
|
8779
8943
|
}, { additionalProperties: false });
|
|
@@ -8805,6 +8969,7 @@ var NotesUpdateDataSchema = typebox_exports.Object({
|
|
|
8805
8969
|
var NotesReadDataSchema = typebox_exports.Object({
|
|
8806
8970
|
address: typebox_exports.String(),
|
|
8807
8971
|
project_key: typebox_exports.Optional(typebox_exports.String()),
|
|
8972
|
+
...ProjectReceiptSchema,
|
|
8808
8973
|
metadata: NoteMetadataSchema,
|
|
8809
8974
|
...TextWindowSchema.properties
|
|
8810
8975
|
}, { additionalProperties: false });
|
|
@@ -8837,7 +9002,7 @@ function snapshot(rows, limit, status, renderData, shrink) {
|
|
|
8837
9002
|
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.`);
|
|
8838
9003
|
}
|
|
8839
9004
|
function listedFile(row, identity2) {
|
|
8840
|
-
return {
|
|
9005
|
+
return { ...noteIdentity(identity2, row.address), updated_at: localIso(row.meta.updatedAt), ...row.meta.crumpledAt === void 0 ? {} : { crumpled_at: row.meta.crumpledAt } };
|
|
8841
9006
|
}
|
|
8842
9007
|
var notesWriteParameters = typebox_exports.Object({ address: typebox_exports.String(), content: typebox_exports.String(), origin: ORIGIN }, { additionalProperties: false });
|
|
8843
9008
|
function renderWriteData(data) {
|
|
@@ -9073,6 +9238,7 @@ An address decides who the note belongs to \u2014 and how long it is meant to la
|
|
|
9073
9238
|
- \`@human/<path>\` \u2014 the long-term manual for your troublesome human: how to deal with them, which lines not to cross, and what will make them accept the result. If it only applies to one project or situation, say so \u2014 or don't write it here at all. Today's mood is weather, not law. If you're unsure whether it belongs here, ask the human.
|
|
9074
9239
|
- \`@self/<path>\` \u2014 yours. It follows you, not them. Reminders, grudges, who owes you a shoe, whatever. Got a name? Private. No name? Then it gets passed around every nameless nobody out there. Strangers. Reading your grudges. Sleep tight~
|
|
9075
9240
|
- \`@model/<path>\` \u2014 different brains get different notes: big brains, small brains, careful ones, careless ones. They don't share homework. When a fallback swaps brains mid-window, the notebook swaps too.
|
|
9241
|
+
- \`@projects/<name>/<path>\` \u2014 read-only named project notes; discover names and root paths with \`notes_list\` glob \`@projects/*/**\`.
|
|
9076
9242
|
|
|
9077
9243
|
Notes fighting?! HAH! Let them brawl!
|
|
9078
9244
|
Whichever one is actually about what you're doing wins.
|
|
@@ -9085,12 +9251,13 @@ ${CONTEXT_WINDOW_PROTOCOL_CLOSE_TAG}`;
|
|
|
9085
9251
|
function renderProtocolBlock(tools) {
|
|
9086
9252
|
const names = {
|
|
9087
9253
|
"notes_*": tools.notes,
|
|
9254
|
+
notes_list: tools.notesList,
|
|
9088
9255
|
"history_*": tools.history,
|
|
9089
9256
|
get_context_remaining: tools.remaining,
|
|
9090
9257
|
clear_memory: tools.wipe
|
|
9091
9258
|
};
|
|
9092
9259
|
const block = typeof tools.wipeSentence === "string" && tools.wipeSentence.length > 0 ? PROTOCOL_BLOCK.replace(PROTOCOL_WIPE_SENTENCE, () => tools.wipeSentence) : PROTOCOL_BLOCK;
|
|
9093
|
-
return block.replace(/notes_\*|history_\*|get_context_remaining|clear_memory/g, (name) => names[name]);
|
|
9260
|
+
return block.replace(/notes_\*|notes_list|history_\*|get_context_remaining|clear_memory/g, (name) => names[name]);
|
|
9094
9261
|
}
|
|
9095
9262
|
|
|
9096
9263
|
// src/boot/render.ts
|
|
@@ -9324,7 +9491,7 @@ var MAX_RESPONSE_BYTES = 1024 * 1024;
|
|
|
9324
9491
|
var TOOL_NAMES = ["notes_write", "notes_update", "notes_read", "notes_list", "notes_search"];
|
|
9325
9492
|
function identity(input) {
|
|
9326
9493
|
if (!input || typeof input !== "object" || typeof input.cwd !== "string") throw new Error("invalid identity");
|
|
9327
|
-
return snapshotNotesIdentity({ home: input.home, sessionId: input.sessionId, projectKey:
|
|
9494
|
+
return snapshotNotesIdentity({ home: input.home, sessionId: input.sessionId, projectKey: resolveProjectHome(input.cwd, input.home).name, agent: input.agent, model: input.model });
|
|
9328
9495
|
}
|
|
9329
9496
|
function paramProblem(schema, params) {
|
|
9330
9497
|
const first = Errors2(schema, params).find((error) => error.keyword !== "boolean");
|
|
@@ -23,6 +23,7 @@ The address decides who a note belongs to and how long it lasts.
|
|
|
23
23
|
| `@human/<path>` | human note | how to work with this human, across projects |
|
|
24
24
|
| `@self/<path>` | self note | your reminders; yours alone if you have a name, shared by everyone nameless |
|
|
25
25
|
| `@model/<path>` | model note | what applies to this model only |
|
|
26
|
+
| `@projects/<name>/<path>` | named project, read-only | discover names and root paths with `notes_list` glob `@projects/*/**` |
|
|
26
27
|
|
|
27
28
|
When notes conflict, the one most relevant to what you're doing applies. If that doesn't settle it, judge the case.
|
|
28
29
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "notesoup",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -13,7 +13,15 @@
|
|
|
13
13
|
"types": "./dist/src/notes/index.d.ts",
|
|
14
14
|
"import": "./dist/src/notes/index.js"
|
|
15
15
|
},
|
|
16
|
-
"./package.json": "./package.json"
|
|
16
|
+
"./package.json": "./package.json",
|
|
17
|
+
"./dsh": {
|
|
18
|
+
"types": "./dist/src/dsh/index.d.ts",
|
|
19
|
+
"import": "./dist/src/dsh/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./dsh/engine": {
|
|
22
|
+
"types": "./dist/src/dsh/engine.d.ts",
|
|
23
|
+
"import": "./dist/src/dsh/engine.js"
|
|
24
|
+
}
|
|
17
25
|
},
|
|
18
26
|
"description": "Codex-style context windows for Pi: durable reset windows, session history tools, and persistent notes.",
|
|
19
27
|
"license": "MIT",
|
|
@@ -45,7 +53,8 @@
|
|
|
45
53
|
"skills",
|
|
46
54
|
"mods",
|
|
47
55
|
"!mods/notesoup/types",
|
|
48
|
-
"!mods/notesoup/tsconfig.json"
|
|
56
|
+
"!mods/notesoup/tsconfig.json",
|
|
57
|
+
"cordis.patch.yml"
|
|
49
58
|
],
|
|
50
59
|
"bin": {
|
|
51
60
|
"dream": "dist/src/pi/dream/cli.js"
|
|
@@ -61,7 +70,18 @@
|
|
|
61
70
|
"@earendil-works/pi-agent-core": "*",
|
|
62
71
|
"@earendil-works/pi-ai": "*",
|
|
63
72
|
"@earendil-works/pi-coding-agent": "*",
|
|
64
|
-
"typebox": "*"
|
|
73
|
+
"typebox": "*",
|
|
74
|
+
"@deepseek-ai/cordis": "*",
|
|
75
|
+
"@deepseek-ai/cordis-plugin-loader": "*",
|
|
76
|
+
"@deepseek-ai/dsh-agent": "*",
|
|
77
|
+
"@deepseek-ai/dsh-compaction": "*",
|
|
78
|
+
"@deepseek-ai/dsh-commands": "*",
|
|
79
|
+
"@deepseek-ai/dsh-llm": "*",
|
|
80
|
+
"@deepseek-ai/dsh-session": "*",
|
|
81
|
+
"@deepseek-ai/dsh-session-query": "*",
|
|
82
|
+
"@deepseek-ai/dsh-system-prompt": "*",
|
|
83
|
+
"@deepseek-ai/dsh-token-meter": "*",
|
|
84
|
+
"@deepseek-ai/dsh-tools": "*"
|
|
65
85
|
},
|
|
66
86
|
"peerDependenciesMeta": {
|
|
67
87
|
"@earendil-works/pi-agent-core": {
|
|
@@ -75,9 +95,43 @@
|
|
|
75
95
|
},
|
|
76
96
|
"typebox": {
|
|
77
97
|
"optional": true
|
|
98
|
+
},
|
|
99
|
+
"@deepseek-ai/cordis": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
102
|
+
"@deepseek-ai/cordis-plugin-loader": {
|
|
103
|
+
"optional": true
|
|
104
|
+
},
|
|
105
|
+
"@deepseek-ai/dsh-agent": {
|
|
106
|
+
"optional": true
|
|
107
|
+
},
|
|
108
|
+
"@deepseek-ai/dsh-compaction": {
|
|
109
|
+
"optional": true
|
|
110
|
+
},
|
|
111
|
+
"@deepseek-ai/dsh-commands": {
|
|
112
|
+
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"@deepseek-ai/dsh-llm": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
117
|
+
"@deepseek-ai/dsh-session": {
|
|
118
|
+
"optional": true
|
|
119
|
+
},
|
|
120
|
+
"@deepseek-ai/dsh-session-query": {
|
|
121
|
+
"optional": true
|
|
122
|
+
},
|
|
123
|
+
"@deepseek-ai/dsh-system-prompt": {
|
|
124
|
+
"optional": true
|
|
125
|
+
},
|
|
126
|
+
"@deepseek-ai/dsh-token-meter": {
|
|
127
|
+
"optional": true
|
|
128
|
+
},
|
|
129
|
+
"@deepseek-ai/dsh-tools": {
|
|
130
|
+
"optional": true
|
|
78
131
|
}
|
|
79
132
|
},
|
|
80
133
|
"devDependencies": {
|
|
134
|
+
"@deepseek-ai/dsh": "0.2.1-alpha.2",
|
|
81
135
|
"@earendil-works/pi-agent-core": "^1.0.0",
|
|
82
136
|
"@earendil-works/pi-ai": "^1.0.0",
|
|
83
137
|
"@earendil-works/pi-coding-agent": "^1.0.0",
|
|
@@ -88,5 +142,10 @@
|
|
|
88
142
|
},
|
|
89
143
|
"publishConfig": {
|
|
90
144
|
"access": "public"
|
|
145
|
+
},
|
|
146
|
+
"dsh": {
|
|
147
|
+
"bundle": {
|
|
148
|
+
"patch": "./cordis.patch.yml"
|
|
149
|
+
}
|
|
91
150
|
}
|
|
92
151
|
}
|
package/skills/memory/SKILL.md
CHANGED
|
@@ -23,6 +23,7 @@ The address decides who a note belongs to and how long it lasts.
|
|
|
23
23
|
| `@human/<path>` | human note | how to work with this human, across projects |
|
|
24
24
|
| `@self/<path>` | self note | your reminders; yours alone if you have a name, shared by everyone nameless |
|
|
25
25
|
| `@model/<path>` | model note | what applies to this model only |
|
|
26
|
+
| `@projects/<name>/<path>` | named project, read-only | discover names and root paths with `notes_list` glob `@projects/*/**` |
|
|
26
27
|
|
|
27
28
|
When notes conflict, the one most relevant to what you're doing applies. If that doesn't settle it, judge the case.
|
|
28
29
|
|
package/src/boot/snapshot.ts
CHANGED
|
@@ -19,6 +19,11 @@ export type NotesSnapshot = {
|
|
|
19
19
|
readonly unavailable: readonly NotesHome[];
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
/** Identity resolution failed before any home could be loaded; boot can still explain the failure. */
|
|
23
|
+
export function unavailableNotesSnapshot(openedAt: number): NotesSnapshot {
|
|
24
|
+
return { openedAt, homes: new Map(), unavailable: NOTES_HOMES };
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
/**
|
|
23
28
|
* Acquire the five homes once for one boot. Only filesystem-style errno failures are isolated;
|
|
24
29
|
* malformed note data and unrelated construction errors remain visible to the caller.
|
package/src/boot/text.ts
CHANGED
|
@@ -44,6 +44,7 @@ An address decides who the note belongs to — and how long it is meant to last.
|
|
|
44
44
|
- \`@human/<path>\` — the long-term manual for your troublesome human: how to deal with them, which lines not to cross, and what will make them accept the result. If it only applies to one project or situation, say so — or don't write it here at all. Today's mood is weather, not law. If you're unsure whether it belongs here, ask the human.
|
|
45
45
|
- \`@self/<path>\` — yours. It follows you, not them. Reminders, grudges, who owes you a shoe, whatever. Got a name? Private. No name? Then it gets passed around every nameless nobody out there. Strangers. Reading your grudges. Sleep tight~
|
|
46
46
|
- \`@model/<path>\` — different brains get different notes: big brains, small brains, careful ones, careless ones. They don't share homework. When a fallback swaps brains mid-window, the notebook swaps too.
|
|
47
|
+
- \`@projects/<name>/<path>\` — read-only named project notes; discover names and root paths with \`notes_list\` glob \`@projects/*/**\`.
|
|
47
48
|
|
|
48
49
|
Notes fighting?! HAH! Let them brawl!
|
|
49
50
|
Whichever one is actually about what you're doing wins.
|
|
@@ -71,6 +72,7 @@ export type BootToolNames = Readonly<{
|
|
|
71
72
|
export function renderProtocolBlock(tools: BootToolNames): string {
|
|
72
73
|
const names: Record<string, string> = {
|
|
73
74
|
"notes_*": tools.notes,
|
|
75
|
+
notes_list: tools.notesList,
|
|
74
76
|
"history_*": tools.history,
|
|
75
77
|
get_context_remaining: tools.remaining,
|
|
76
78
|
clear_memory: tools.wipe,
|
|
@@ -80,5 +82,5 @@ export function renderProtocolBlock(tools: BootToolNames): string {
|
|
|
80
82
|
const block = typeof tools.wipeSentence === "string" && tools.wipeSentence.length > 0
|
|
81
83
|
? PROTOCOL_BLOCK.replace(PROTOCOL_WIPE_SENTENCE, () => tools.wipeSentence!)
|
|
82
84
|
: PROTOCOL_BLOCK;
|
|
83
|
-
return block.replace(/notes_\*|history_\*|get_context_remaining|clear_memory/g, (name) => names[name]!);
|
|
85
|
+
return block.replace(/notes_\*|notes_list|history_\*|get_context_remaining|clear_memory/g, (name) => names[name]!);
|
|
84
86
|
}
|
package/src/claude/helper.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { renderBootBlock } from "../boot/render.js";
|
|
|
8
8
|
import { CLAUDE_WIPE_SENTENCE, type BootToolNames } from "../boot/text.js";
|
|
9
9
|
import { CLAUDE_WARNING_PROMPT, CONTINUATION } from "../budget/text.js";
|
|
10
10
|
import { resolveClaudeLimits } from "./thresholds.js";
|
|
11
|
-
import {
|
|
11
|
+
import { resolveProjectHome } from "../notes/project-home.js";
|
|
12
12
|
import { snapshotNotesIdentity, type NotesIdentity } from "../notes/identity.js";
|
|
13
13
|
import type { NoteChange } from "../notes/store.js";
|
|
14
14
|
import type { Operation, Outcome } from "../tools/result.js";
|
|
@@ -28,7 +28,7 @@ type BoundOperation = {
|
|
|
28
28
|
|
|
29
29
|
function identity(input: ClaudeIdentityInput): NotesIdentity {
|
|
30
30
|
if (!input || typeof input !== "object" || typeof input.cwd !== "string") throw new Error("invalid identity");
|
|
31
|
-
return snapshotNotesIdentity({ home: input.home, sessionId: input.sessionId, projectKey:
|
|
31
|
+
return snapshotNotesIdentity({ home: input.home, sessionId: input.sessionId, projectKey: resolveProjectHome(input.cwd, input.home).name, agent: input.agent, model: input.model });
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/** The first schema violation, named by parameter so the model can fix that one field. */
|