notesoup 0.52.5 → 0.52.6
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/dist/src/notes/store.d.ts +2 -0
- package/dist/src/notes/store.js +2 -2
- package/dist/src/tools/dream.d.ts +2 -0
- package/dist/src/tools/notes.d.ts +7 -0
- package/dist/src/tools/notes.js +8 -3
- package/dist/test/dream-skill.test.js +5 -0
- package/dist/test/dream-tools.test.js +15 -0
- package/dist/test/notes-library.test.js +1 -1
- package/dist/test/notes.test.js +1 -1
- package/dist/test/pi-render.test.js +2 -2
- package/package.json +1 -1
- package/playbook.md +24 -13
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +9 -5
- package/plugins/claude/playbook.md +24 -13
- package/plugins/claude/skills/dream/SKILL.md +8 -0
- package/skills/dream/SKILL.md +8 -0
- package/src/notes/store.ts +4 -3
- package/src/tools/notes.ts +8 -3
|
@@ -44,10 +44,12 @@ export type NotesQuery = {
|
|
|
44
44
|
crumpled?: boolean;
|
|
45
45
|
};
|
|
46
46
|
/** A read exposes metadata and the pure body; the serialized frontmatter is never part of the body. */
|
|
47
|
+
/** `accessedBefore` is the last access before this read, so a read never hides how long a note sat unread. */
|
|
47
48
|
export type NoteReadResult = {
|
|
48
49
|
meta: NoteMeta;
|
|
49
50
|
body: string;
|
|
50
51
|
resolvedScope: Scope;
|
|
52
|
+
accessedBefore: number;
|
|
51
53
|
};
|
|
52
54
|
export type NoteWriteResult = {
|
|
53
55
|
meta: NoteMeta;
|
package/dist/src/notes/store.js
CHANGED
|
@@ -297,11 +297,11 @@ export function createNotesStore(input) {
|
|
|
297
297
|
const parsed = parseNote(raw, now);
|
|
298
298
|
// Named homes, and every read during a dream, leave no access stamp.
|
|
299
299
|
if (identity.dreaming !== undefined || ((scope === "project" || scope === "session") && destination.who !== undefined))
|
|
300
|
-
return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope };
|
|
300
|
+
return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope, accessedBefore: parsed.meta.lastAccessed };
|
|
301
301
|
// A read records its own access, exactly as a write records an edit.
|
|
302
302
|
const meta = { ...parsed.meta, scope, lastAccessed: now, accessCount: (typeof parsed.meta.accessCount === "number" ? parsed.meta.accessCount : 0) + 1 };
|
|
303
303
|
await atomicWrite(path, serializeNote(meta, parsed.body));
|
|
304
|
-
return { meta, body: parsed.body, resolvedScope: scope };
|
|
304
|
+
return { meta, body: parsed.body, resolvedScope: scope, accessedBefore: parsed.meta.lastAccessed };
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
307
|
async function update(address, edits, options = {}) {
|
|
@@ -20,6 +20,7 @@ export declare const DreamBeginDataSchema: Type.TObject<{
|
|
|
20
20
|
homes_unavailable: Type.TArray<Type.TString>;
|
|
21
21
|
files: Type.TArray<Type.TObject<{
|
|
22
22
|
updated_at: Type.TString;
|
|
23
|
+
last_accessed: Type.TString;
|
|
23
24
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
24
25
|
project_root: Type.TOptional<Type.TString>;
|
|
25
26
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
@@ -45,6 +46,7 @@ export declare const dreamBegin: {
|
|
|
45
46
|
homes_unavailable: Type.TArray<Type.TString>;
|
|
46
47
|
files: Type.TArray<Type.TObject<{
|
|
47
48
|
updated_at: Type.TString;
|
|
49
|
+
last_accessed: Type.TString;
|
|
48
50
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
49
51
|
project_root: Type.TOptional<Type.TString>;
|
|
50
52
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
@@ -11,6 +11,7 @@ export declare const NoteMetadataSchema: Type.TObject<{
|
|
|
11
11
|
origin: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"self">, Type.TLiteral<"external">]>;
|
|
12
12
|
created_at: Type.TString;
|
|
13
13
|
updated_at: Type.TString;
|
|
14
|
+
last_accessed: Type.TString;
|
|
14
15
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
15
16
|
project: Type.TOptional<Type.TString>;
|
|
16
17
|
extra: Type.TRecord<"^.*$", Type.TUnknown>;
|
|
@@ -38,6 +39,7 @@ export declare const NotesReadDataSchema: Type.TObject<{
|
|
|
38
39
|
origin: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"self">, Type.TLiteral<"external">]>;
|
|
39
40
|
created_at: Type.TString;
|
|
40
41
|
updated_at: Type.TString;
|
|
42
|
+
last_accessed: Type.TString;
|
|
41
43
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
42
44
|
project: Type.TOptional<Type.TString>;
|
|
43
45
|
extra: Type.TRecord<"^.*$", Type.TUnknown>;
|
|
@@ -56,6 +58,7 @@ export declare const NotesListDataSchema: Type.TObject<{
|
|
|
56
58
|
homes_unavailable: Type.TArray<Type.TString>;
|
|
57
59
|
files: Type.TArray<Type.TObject<{
|
|
58
60
|
updated_at: Type.TString;
|
|
61
|
+
last_accessed: Type.TString;
|
|
59
62
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
60
63
|
project_root: Type.TOptional<Type.TString>;
|
|
61
64
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
@@ -77,6 +80,7 @@ export declare const NotesSearchDataSchema: Type.TObject<{
|
|
|
77
80
|
offset_chars: Type.TInteger;
|
|
78
81
|
}>>;
|
|
79
82
|
updated_at: Type.TString;
|
|
83
|
+
last_accessed: Type.TString;
|
|
80
84
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
81
85
|
project_root: Type.TOptional<Type.TString>;
|
|
82
86
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
@@ -187,6 +191,7 @@ export declare const notesRead: {
|
|
|
187
191
|
origin: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"self">, Type.TLiteral<"external">]>;
|
|
188
192
|
created_at: Type.TString;
|
|
189
193
|
updated_at: Type.TString;
|
|
194
|
+
last_accessed: Type.TString;
|
|
190
195
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
191
196
|
project: Type.TOptional<Type.TString>;
|
|
192
197
|
extra: Type.TRecord<"^.*$", Type.TUnknown>;
|
|
@@ -225,6 +230,7 @@ export declare const notesList: {
|
|
|
225
230
|
homes_unavailable: Type.TArray<Type.TString>;
|
|
226
231
|
files: Type.TArray<Type.TObject<{
|
|
227
232
|
updated_at: Type.TString;
|
|
233
|
+
last_accessed: Type.TString;
|
|
228
234
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
229
235
|
project_root: Type.TOptional<Type.TString>;
|
|
230
236
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
@@ -271,6 +277,7 @@ export declare const notesSearch: {
|
|
|
271
277
|
offset_chars: Type.TInteger;
|
|
272
278
|
}>>;
|
|
273
279
|
updated_at: Type.TString;
|
|
280
|
+
last_accessed: Type.TString;
|
|
274
281
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
275
282
|
project_root: Type.TOptional<Type.TString>;
|
|
276
283
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
package/dist/src/tools/notes.js
CHANGED
|
@@ -40,6 +40,7 @@ export const NoteMetadataSchema = Type.Object({
|
|
|
40
40
|
origin: Type.Union([...ORIGIN_VALUES]),
|
|
41
41
|
created_at: Type.String(),
|
|
42
42
|
updated_at: Type.String(),
|
|
43
|
+
last_accessed: Type.String(),
|
|
43
44
|
crumpled_at: Type.Optional(Type.String()),
|
|
44
45
|
project: Type.Optional(Type.String()),
|
|
45
46
|
extra: Type.Record(Type.String(), Type.Unknown()),
|
|
@@ -71,6 +72,7 @@ function noteMetadata(meta) {
|
|
|
71
72
|
origin: meta.origin,
|
|
72
73
|
created_at: localIso(meta.createdAt),
|
|
73
74
|
updated_at: localIso(meta.updatedAt),
|
|
75
|
+
last_accessed: localIso(meta.lastAccessed),
|
|
74
76
|
...(typeof meta.crumpledAt === "string" ? { crumpled_at: meta.crumpledAt } : {}),
|
|
75
77
|
...(typeof meta.project === "string" ? { project: meta.project } : {}),
|
|
76
78
|
extra,
|
|
@@ -81,6 +83,7 @@ function renderMetadata(metadata) {
|
|
|
81
83
|
`origin ${metadata.origin}`,
|
|
82
84
|
`created ${metadata.created_at}`,
|
|
83
85
|
`updated ${metadata.updated_at}`,
|
|
86
|
+
`accessed ${metadata.last_accessed}`,
|
|
84
87
|
...(metadata.crumpled_at === undefined ? [] : [`crumpled ${metadata.crumpled_at}`]),
|
|
85
88
|
...(metadata.project === undefined ? [] : [`project ${metadata.project}`]),
|
|
86
89
|
];
|
|
@@ -107,6 +110,7 @@ const ListedFileSchema = Type.Object({
|
|
|
107
110
|
project_key: Type.Optional(Type.String()),
|
|
108
111
|
...ProjectReceiptSchema,
|
|
109
112
|
updated_at: Type.String(),
|
|
113
|
+
last_accessed: Type.String(),
|
|
110
114
|
crumpled_at: Type.Optional(Type.String()),
|
|
111
115
|
}, { additionalProperties: false });
|
|
112
116
|
const MatchSchema = Type.Object({
|
|
@@ -173,7 +177,7 @@ export function snapshot(rows, limit, status, renderData, shrink) {
|
|
|
173
177
|
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
178
|
}
|
|
175
179
|
export function listedFile(row, identity) {
|
|
176
|
-
return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }) };
|
|
180
|
+
return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt), last_accessed: localIso(row.meta.lastAccessed), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }) };
|
|
177
181
|
}
|
|
178
182
|
export const notesWriteParameters = Type.Object({ address: Type.String(), content: Type.String(), origin: ORIGIN }, { additionalProperties: false });
|
|
179
183
|
function renderWriteData(data) {
|
|
@@ -265,7 +269,8 @@ export const notesRead = {
|
|
|
265
269
|
const totalChars = Array.from(note.body).length;
|
|
266
270
|
if (params.offset_chars !== undefined && params.offset_chars > totalChars)
|
|
267
271
|
return failure("invalid_offset", `This note ends at char ${totalChars}; offset_chars ${params.offset_chars} is past the last word.`);
|
|
268
|
-
|
|
272
|
+
// Report the access before this one: the read itself must not make a long-unread note look fresh.
|
|
273
|
+
const metadata = noteMetadata({ ...note.meta, lastAccessed: note.accessedBefore });
|
|
269
274
|
return readTextWindow(note.body, params.offset_chars, params.max_chars, (window) => ({ ...resolved, metadata, ...window }), (result) => renderOutcome(result, renderReadData));
|
|
270
275
|
}
|
|
271
276
|
catch (error) {
|
|
@@ -278,7 +283,7 @@ export const notesListParameters = Type.Object({ glob: GLOB_PARAMETER, limit: FI
|
|
|
278
283
|
export function renderListData(data) {
|
|
279
284
|
const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
|
|
280
285
|
for (const file of data.files) {
|
|
281
|
-
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
286
|
+
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at} | accessed ${file.last_accessed}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
282
287
|
}
|
|
283
288
|
if (data.more > 0)
|
|
284
289
|
lines.push(`${data.more} more matching notes omitted; narrow with glob`);
|
|
@@ -38,6 +38,11 @@ test("dream skill is publicly discoverable and resolves the shared playbook", ()
|
|
|
38
38
|
assert.equal(skillPlaybook, packagePlaybook);
|
|
39
39
|
const playbook = readFileSync(packagePlaybook, "utf8");
|
|
40
40
|
assert.equal(readFileSync(skillPlaybook, "utf8"), playbook);
|
|
41
|
+
const instructions = readFileSync(join(skill.baseDir, "SKILL.md"), "utf8");
|
|
42
|
+
for (const name of ["dream_begin", "dream_forget", "dream_end"])
|
|
43
|
+
assert.ok(instructions.includes(name));
|
|
44
|
+
assert.match(instructions, /missing from the current tool list, search for them/);
|
|
45
|
+
assert.doesNotMatch(instructions, /tool_search|searchTools|codemode/);
|
|
41
46
|
});
|
|
42
47
|
test("npm tarball keeps the skill's relative playbook path portable after extraction", () => {
|
|
43
48
|
const root = packageRoot();
|
|
@@ -36,6 +36,8 @@ test("a dream opens one other project, writes its notes, deletes only crumpled o
|
|
|
36
36
|
const begun = await dreamBegin.execute({ project: "beta" }, me, state);
|
|
37
37
|
assert.ok(begun.ok);
|
|
38
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.ok(begun.data.files.every(f => typeof f.last_accessed === "string"), "the dream's list shows each note's last access");
|
|
40
|
+
assert.match(dreamBegin.render(begun), /\| accessed /);
|
|
39
41
|
assert.equal((await dreamBegin.execute({}, me, state)).ok, false, "only one dream at a time");
|
|
40
42
|
assert.ok(existsSync(join(home, ".dream.lock.beta")), "the project lock is held");
|
|
41
43
|
assert.equal((await dreamBegin.execute({ project: "beta" }, as("other", "alpha"), {})).ok, false, "another session can't dream the same project");
|
|
@@ -59,6 +61,19 @@ test("a dream opens one other project, writes its notes, deletes only crumpled o
|
|
|
59
61
|
assert.equal((await notesWrite.execute({ address: "@projects/beta/rule", content: "x" }, ident())).ok, false, "closed again");
|
|
60
62
|
assert.equal((await dreamEnd.execute({}, me, state)).ok, false);
|
|
61
63
|
});
|
|
64
|
+
test("notes_read reports the access before itself, so reading never makes an unread note look fresh", async (t) => {
|
|
65
|
+
const { home, as } = fixture(t);
|
|
66
|
+
const me = as("s", "alpha");
|
|
67
|
+
const old = "2026-01-01T08:00:00.000+08:00";
|
|
68
|
+
mkdirSync(join(home, "human"), { recursive: true });
|
|
69
|
+
writeFileSync(join(home, "human", "stale.md"), `---\norigin: self\ncreatedAt: ${old}\nupdatedAt: ${old}\nlastAccessed: ${old}\naccessCount: 0\n---\n\nbody`);
|
|
70
|
+
const first = await notesRead.execute({ address: "@human/stale" }, me);
|
|
71
|
+
assert.ok(first.ok);
|
|
72
|
+
assert.equal(Date.parse(first.data.metadata.last_accessed), Date.parse(old), "the first read shows the old access");
|
|
73
|
+
const second = await notesRead.execute({ address: "@human/stale" }, me);
|
|
74
|
+
assert.ok(second.ok);
|
|
75
|
+
assert.ok(Date.parse(second.data.metadata.last_accessed) > Date.parse(old), "the first read still counted as an access");
|
|
76
|
+
});
|
|
62
77
|
test("dream_begin refuses an unknown project", async (t) => {
|
|
63
78
|
const { as } = fixture(t);
|
|
64
79
|
const state = {};
|
|
@@ -139,7 +139,7 @@ test("search offsets address the body and never move when access metadata grows"
|
|
|
139
139
|
assert.equal(frontBody, "needle later");
|
|
140
140
|
assert.equal(frontMatch.offsetChars, 0, "frontmatter length is not part of the body offset");
|
|
141
141
|
assert.equal(Array.from(frontBody).slice(frontMatch.offsetChars).join(""), "needle later");
|
|
142
|
-
assert.deepEqual(Object.keys((await notes.read("counted.md"))).sort(), ["body", "meta", "resolvedScope"], "a read exposes metadata and the body, never a serialized rendering");
|
|
142
|
+
assert.deepEqual(Object.keys((await notes.read("counted.md"))).sort(), ["accessedBefore", "body", "meta", "resolvedScope"], "a read exposes metadata and the body, never a serialized rendering");
|
|
143
143
|
});
|
|
144
144
|
test("invalid addressing and failed edits leave stored bytes untouched without poisoning the queue", async (t) => {
|
|
145
145
|
const { home, context, notes } = fixture(t);
|
package/dist/test/notes.test.js
CHANGED
|
@@ -403,7 +403,7 @@ test("list and search merge scopes and carry addresses; the path jail rejects es
|
|
|
403
403
|
const listed = resultData(await call(captured, "notes_list", {}, ctx));
|
|
404
404
|
assert.deepEqual([...listed.files].map((file) => file.address).sort(), ["@human/three.md", "@project/two.md", "one.md"], "every merged row carries its full address");
|
|
405
405
|
for (const row of listed.files) {
|
|
406
|
-
assert.deepEqual(Object.keys(row).sort(), ["address", "updated_at", ...(row.address.startsWith("@project/") ? ["project_key"] : [])].sort());
|
|
406
|
+
assert.deepEqual(Object.keys(row).sort(), ["address", "updated_at", "last_accessed", ...(row.address.startsWith("@project/") ? ["project_key"] : [])].sort());
|
|
407
407
|
}
|
|
408
408
|
const scoped = resultData(await call(captured, "notes_list", { glob: "@human/**" }, ctx));
|
|
409
409
|
assert.deepEqual(scoped.files.map((file) => file.address), ["@human/three.md"], "an address glob filter narrows the set");
|
|
@@ -51,12 +51,12 @@ test("notes_update unchanged keeps quiet", () => {
|
|
|
51
51
|
assert.equal(lines(component), "unchanged a.md");
|
|
52
52
|
});
|
|
53
53
|
test("notes_read collapsed: size and a peek at the first line", () => {
|
|
54
|
-
const result = toolResult(success({ address: "@project/MAP.md", metadata: { origin: "self", created_at: "x", updated_at: "y", extra: {} }, text: "# MAP\n\nbody", total_chars: 11, next_offset_chars: null }));
|
|
54
|
+
const result = toolResult(success({ address: "@project/MAP.md", metadata: { origin: "self", created_at: "x", updated_at: "y", last_accessed: "z", extra: {} }, text: "# MAP\n\nbody", total_chars: 11, next_offset_chars: null }));
|
|
55
55
|
const component = notesReadRenderers.renderResult(result, { expanded: false }, flatTheme);
|
|
56
56
|
assert.equal(lines(component), "read @project/MAP.md · 11 chars — # MAP");
|
|
57
57
|
});
|
|
58
58
|
test("notes_read expanded: truncation points at the next offset", () => {
|
|
59
|
-
const result = toolResult(success({ address: "a.md", metadata: { origin: "self", created_at: "x", updated_at: "y", extra: {} }, text: "part", total_chars: 10, next_offset_chars: 4 }));
|
|
59
|
+
const result = toolResult(success({ address: "a.md", metadata: { origin: "self", created_at: "x", updated_at: "y", last_accessed: "z", extra: {} }, text: "part", total_chars: 10, next_offset_chars: 4 }));
|
|
60
60
|
const component = notesReadRenderers.renderResult(result, { expanded: true }, flatTheme);
|
|
61
61
|
assert.equal(lines(component), "read a.md · 10 chars · truncated — part\n\npart\n… continue at offset_chars=4");
|
|
62
62
|
});
|
package/package.json
CHANGED
package/playbook.md
CHANGED
|
@@ -4,31 +4,42 @@ I am reviewing my notes: keeping what is useful, connecting what belongs togethe
|
|
|
4
4
|
|
|
5
5
|
## Scope
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
A project dream draws from that project's material, project notes, and session notes identified as belonging to the project; it organizes only that project's notes. A store-wide dream may inspect across homes, but authorship and write permissions still apply. Unknown ownership is a coverage gap to report, not a reason to guess or repair ownership.
|
|
7
|
+
A dream covers one project: its `@project` notes and the session notes born in it. `@human`, `@self`, and `@model` are not part of a dream unless the human asks for them or the dream runs from inside the notes home itself. Do not broaden that scope while exploring; if a boundary is unclear, ask before crossing it. Unknown ownership is a coverage gap to report, not a reason to guess or repair ownership.
|
|
10
8
|
|
|
11
9
|
The homes serve different readers:
|
|
12
10
|
|
|
13
|
-
- Session notes (`<path>`, no `@`) are a trip's working record. Read them as sources
|
|
11
|
+
- Session notes (`<path>`, no `@`) are a trip's working record. Read them as sources; do not rewrite them. Only the wastebasket rule below may remove another session's notes.
|
|
14
12
|
- `@project` notes hold knowledge for whoever next works on that project.
|
|
15
13
|
- `@human` notes hold the human's cross-project preferences and standing rules. Do not turn project facts or your own conclusions into rules in the human's voice.
|
|
16
14
|
- `@self` notes belong to their author: private if the author has a name, one shared notebook for everyone nameless. Other named authors' notes are read-only unless the human authorizes revision.
|
|
17
15
|
- `@model` notes describe the substrate's behavior. Other models' notes are read-only unless the human authorizes revision.
|
|
18
16
|
|
|
17
|
+
## What a durable note holds
|
|
18
|
+
|
|
19
|
+
Durable notes hold decisions, constraints, and lessons that stay true after the current work ends. They are not diaries: commit hashes, test counts, dates, and the story of how something was reached belong to git and history. A session finding is worth promoting only when it meets this bar.
|
|
20
|
+
|
|
19
21
|
## Review and consolidate
|
|
20
22
|
|
|
21
|
-
1. **Leave stable notes alone.** Change a note to incorporate new evidence,
|
|
22
|
-
2. **Verify only what the proposed change depends on.** Before correcting or promoting a conclusion, check the relevant evidence as needed. Do not revalidate every stable note or turn dream into a source-code audit. An unavailable referent is unverified, not proof that it is dead
|
|
23
|
-
3. **
|
|
24
|
-
4. **
|
|
25
|
-
5. **
|
|
26
|
-
6. **
|
|
27
|
-
7. **Keep
|
|
28
|
-
8. **
|
|
23
|
+
1. **Leave stable notes alone.** Change a note to incorporate new evidence, fix a verified error, retire a stale claim, merge a genuine duplicate, trim diary content, or split an oversized file, not merely to shorten or rephrase it. No change is a valid outcome.
|
|
24
|
+
2. **Verify only what the proposed change depends on.** Before correcting, retiring, or promoting a conclusion, check the relevant evidence as needed. Do not revalidate every stable note or turn dream into a source-code audit. An unavailable referent is unverified, not proof that it is dead.
|
|
25
|
+
3. **Retire what is no longer true.** When evidence shows a durable note is stale, correct it in place; if nothing true remains, crumple it. Remove or fix its MAP line either way. A note's last access is a hint, not evidence: long-unread notes are candidates to check, not to crumple on sight. A read reports the access before itself, so reviewing a note does not make it look fresh.
|
|
26
|
+
4. **Merge only genuine duplicates.** Merge two notes only when they share a topic and kind (checkpoint, design, log). First carry every fact, condition, and exception unique to the absorbed note into the survivor, then crumple the absorbed note. Otherwise keep both and record any unresolved conflict.
|
|
27
|
+
5. **Relocate misfiled notes.** When a standing ruling or the note's own MAP already names its proper home, move it there, preserving its metadata, and update both homes' maps. Do it, don't propose it. Propose only when the destination home itself is unclear.
|
|
28
|
+
6. **Preserve meaning and provenance.** Keep facts, conditions, exceptions, uncertainty, authorship, and sources. When promoting a finding, cite its source. Do not relabel agent-authored material as human-authored. If its destination or authority is unclear, propose the promotion instead.
|
|
29
|
+
7. **Keep notes manageable.** Aim below about 200 lines / 8KB per note. Split oversized notes by topic with one-line cross-links.
|
|
30
|
+
8. **Keep maps useful.** Each writable home's MAP.md may include a Cheatsheet of rules that apply in every window; keep it short, about 5 lines. The rest stays the note index: durable notes' addresses and short gists, for lookup. Preserve standing rules, add promoted notes, and drop entries that no longer hold. Maps follow the same size budget.
|
|
31
|
+
|
|
32
|
+
## Deleting
|
|
33
|
+
|
|
34
|
+
Never physically delete a live note; crumple it first. Two cases allow deleting a crumpled note:
|
|
35
|
+
|
|
36
|
+
- **Your own session's notes** may be deleted once crumpled.
|
|
37
|
+
- **The wastebasket:** any note within the dream's reach that was crumpled more than 7 days ago may be deleted, whatever its home or session. Judge by its crumpled date; if none is readable, keep it and report it.
|
|
38
|
+
|
|
39
|
+
Where notes cannot be deleted, list the doomed addresses in the report instead of blanking them.
|
|
29
40
|
|
|
30
41
|
## Report
|
|
31
42
|
|
|
32
|
-
Give a concise report grouped by home: what you inspected, changed, promoted, deleted, and left unresolved. Mention coverage gaps and partial failures. If no notes changed, say so. Distinguish actual note changes from execution or audit artifacts; do not claim success for an incomplete run.
|
|
43
|
+
Give a concise report grouped by home: what you inspected, changed, retired, promoted, deleted, and left unresolved. Mention coverage gaps and partial failures. If no notes changed, say so. Distinguish actual note changes from execution or audit artifacts; do not claim success for an incomplete run.
|
|
33
44
|
|
|
34
45
|
Put skill ideas and unresolved questions in the final message as proposals for the human, not new skill files.
|
|
@@ -8569,10 +8569,10 @@ function createNotesStore(input) {
|
|
|
8569
8569
|
if (raw === void 0) return void 0;
|
|
8570
8570
|
const now = Date.now();
|
|
8571
8571
|
const parsed = parseNote(raw, now);
|
|
8572
|
-
if (identity2.dreaming !== void 0 || (scope === "project" || scope === "session") && destination.who !== void 0) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope };
|
|
8572
|
+
if (identity2.dreaming !== void 0 || (scope === "project" || scope === "session") && destination.who !== void 0) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope, accessedBefore: parsed.meta.lastAccessed };
|
|
8573
8573
|
const meta = { ...parsed.meta, scope, lastAccessed: now, accessCount: (typeof parsed.meta.accessCount === "number" ? parsed.meta.accessCount : 0) + 1 };
|
|
8574
8574
|
await atomicWrite(path, serializeNote(meta, parsed.body));
|
|
8575
|
-
return { meta, body: parsed.body, resolvedScope: scope };
|
|
8575
|
+
return { meta, body: parsed.body, resolvedScope: scope, accessedBefore: parsed.meta.lastAccessed };
|
|
8576
8576
|
});
|
|
8577
8577
|
}
|
|
8578
8578
|
async function update(address, edits, options = {}) {
|
|
@@ -9053,6 +9053,7 @@ var NoteMetadataSchema = typebox_exports.Object({
|
|
|
9053
9053
|
origin: typebox_exports.Union([...ORIGIN_VALUES]),
|
|
9054
9054
|
created_at: typebox_exports.String(),
|
|
9055
9055
|
updated_at: typebox_exports.String(),
|
|
9056
|
+
last_accessed: typebox_exports.String(),
|
|
9056
9057
|
crumpled_at: typebox_exports.Optional(typebox_exports.String()),
|
|
9057
9058
|
project: typebox_exports.Optional(typebox_exports.String()),
|
|
9058
9059
|
extra: typebox_exports.Record(typebox_exports.String(), typebox_exports.Unknown())
|
|
@@ -9078,6 +9079,7 @@ function noteMetadata(meta) {
|
|
|
9078
9079
|
origin: meta.origin,
|
|
9079
9080
|
created_at: localIso(meta.createdAt),
|
|
9080
9081
|
updated_at: localIso(meta.updatedAt),
|
|
9082
|
+
last_accessed: localIso(meta.lastAccessed),
|
|
9081
9083
|
...typeof meta.crumpledAt === "string" ? { crumpled_at: meta.crumpledAt } : {},
|
|
9082
9084
|
...typeof meta.project === "string" ? { project: meta.project } : {},
|
|
9083
9085
|
extra
|
|
@@ -9088,6 +9090,7 @@ function renderMetadata(metadata) {
|
|
|
9088
9090
|
`origin ${metadata.origin}`,
|
|
9089
9091
|
`created ${metadata.created_at}`,
|
|
9090
9092
|
`updated ${metadata.updated_at}`,
|
|
9093
|
+
`accessed ${metadata.last_accessed}`,
|
|
9091
9094
|
...metadata.crumpled_at === void 0 ? [] : [`crumpled ${metadata.crumpled_at}`],
|
|
9092
9095
|
...metadata.project === void 0 ? [] : [`project ${metadata.project}`]
|
|
9093
9096
|
];
|
|
@@ -9111,6 +9114,7 @@ var ListedFileSchema = typebox_exports.Object({
|
|
|
9111
9114
|
project_key: typebox_exports.Optional(typebox_exports.String()),
|
|
9112
9115
|
...ProjectReceiptSchema,
|
|
9113
9116
|
updated_at: typebox_exports.String(),
|
|
9117
|
+
last_accessed: typebox_exports.String(),
|
|
9114
9118
|
crumpled_at: typebox_exports.Optional(typebox_exports.String())
|
|
9115
9119
|
}, { additionalProperties: false });
|
|
9116
9120
|
var MatchSchema = typebox_exports.Object({
|
|
@@ -9174,7 +9178,7 @@ function snapshot(rows, limit, status, renderData, shrink) {
|
|
|
9174
9178
|
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.`);
|
|
9175
9179
|
}
|
|
9176
9180
|
function listedFile(row, identity2) {
|
|
9177
|
-
return { ...noteIdentity(identity2, row.address), updated_at: localIso(row.meta.updatedAt), ...row.meta.crumpledAt === void 0 ? {} : { crumpled_at: row.meta.crumpledAt } };
|
|
9181
|
+
return { ...noteIdentity(identity2, row.address), updated_at: localIso(row.meta.updatedAt), last_accessed: localIso(row.meta.lastAccessed), ...row.meta.crumpledAt === void 0 ? {} : { crumpled_at: row.meta.crumpledAt } };
|
|
9178
9182
|
}
|
|
9179
9183
|
var notesWriteParameters = typebox_exports.Object({ address: typebox_exports.String(), content: typebox_exports.String(), origin: ORIGIN }, { additionalProperties: false });
|
|
9180
9184
|
function renderWriteData(data) {
|
|
@@ -9267,7 +9271,7 @@ var notesRead = {
|
|
|
9267
9271
|
if (!note) return failure("not_found", `No note at ${resolved.address}.`);
|
|
9268
9272
|
const totalChars = Array.from(note.body).length;
|
|
9269
9273
|
if (params.offset_chars !== void 0 && params.offset_chars > totalChars) return failure("invalid_offset", `This note ends at char ${totalChars}; offset_chars ${params.offset_chars} is past the last word.`);
|
|
9270
|
-
const metadata = noteMetadata(note.meta);
|
|
9274
|
+
const metadata = noteMetadata({ ...note.meta, lastAccessed: note.accessedBefore });
|
|
9271
9275
|
return readTextWindow(note.body, params.offset_chars, params.max_chars, (window) => ({ ...resolved, metadata, ...window }), (result) => renderOutcome(result, renderReadData));
|
|
9272
9276
|
} catch (error) {
|
|
9273
9277
|
return failureOf(error);
|
|
@@ -9279,7 +9283,7 @@ var notesListParameters = typebox_exports.Object({ glob: GLOB_PARAMETER, limit:
|
|
|
9279
9283
|
function renderListData(data) {
|
|
9280
9284
|
const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
|
|
9281
9285
|
for (const file of data.files) {
|
|
9282
|
-
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at}${file.crumpled_at === void 0 ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
9286
|
+
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at} | accessed ${file.last_accessed}${file.crumpled_at === void 0 ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
9283
9287
|
}
|
|
9284
9288
|
if (data.more > 0) lines.push(`${data.more} more matching notes omitted; narrow with glob`);
|
|
9285
9289
|
for (const home of data.homes_unavailable) lines.push(`${home} could not be read`);
|
|
@@ -4,31 +4,42 @@ I am reviewing my notes: keeping what is useful, connecting what belongs togethe
|
|
|
4
4
|
|
|
5
5
|
## Scope
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
A project dream draws from that project's material, project notes, and session notes identified as belonging to the project; it organizes only that project's notes. A store-wide dream may inspect across homes, but authorship and write permissions still apply. Unknown ownership is a coverage gap to report, not a reason to guess or repair ownership.
|
|
7
|
+
A dream covers one project: its `@project` notes and the session notes born in it. `@human`, `@self`, and `@model` are not part of a dream unless the human asks for them or the dream runs from inside the notes home itself. Do not broaden that scope while exploring; if a boundary is unclear, ask before crossing it. Unknown ownership is a coverage gap to report, not a reason to guess or repair ownership.
|
|
10
8
|
|
|
11
9
|
The homes serve different readers:
|
|
12
10
|
|
|
13
|
-
- Session notes (`<path>`, no `@`) are a trip's working record. Read them as sources
|
|
11
|
+
- Session notes (`<path>`, no `@`) are a trip's working record. Read them as sources; do not rewrite them. Only the wastebasket rule below may remove another session's notes.
|
|
14
12
|
- `@project` notes hold knowledge for whoever next works on that project.
|
|
15
13
|
- `@human` notes hold the human's cross-project preferences and standing rules. Do not turn project facts or your own conclusions into rules in the human's voice.
|
|
16
14
|
- `@self` notes belong to their author: private if the author has a name, one shared notebook for everyone nameless. Other named authors' notes are read-only unless the human authorizes revision.
|
|
17
15
|
- `@model` notes describe the substrate's behavior. Other models' notes are read-only unless the human authorizes revision.
|
|
18
16
|
|
|
17
|
+
## What a durable note holds
|
|
18
|
+
|
|
19
|
+
Durable notes hold decisions, constraints, and lessons that stay true after the current work ends. They are not diaries: commit hashes, test counts, dates, and the story of how something was reached belong to git and history. A session finding is worth promoting only when it meets this bar.
|
|
20
|
+
|
|
19
21
|
## Review and consolidate
|
|
20
22
|
|
|
21
|
-
1. **Leave stable notes alone.** Change a note to incorporate new evidence,
|
|
22
|
-
2. **Verify only what the proposed change depends on.** Before correcting or promoting a conclusion, check the relevant evidence as needed. Do not revalidate every stable note or turn dream into a source-code audit. An unavailable referent is unverified, not proof that it is dead
|
|
23
|
-
3. **
|
|
24
|
-
4. **
|
|
25
|
-
5. **
|
|
26
|
-
6. **
|
|
27
|
-
7. **Keep
|
|
28
|
-
8. **
|
|
23
|
+
1. **Leave stable notes alone.** Change a note to incorporate new evidence, fix a verified error, retire a stale claim, merge a genuine duplicate, trim diary content, or split an oversized file, not merely to shorten or rephrase it. No change is a valid outcome.
|
|
24
|
+
2. **Verify only what the proposed change depends on.** Before correcting, retiring, or promoting a conclusion, check the relevant evidence as needed. Do not revalidate every stable note or turn dream into a source-code audit. An unavailable referent is unverified, not proof that it is dead.
|
|
25
|
+
3. **Retire what is no longer true.** When evidence shows a durable note is stale, correct it in place; if nothing true remains, crumple it. Remove or fix its MAP line either way. A note's last access is a hint, not evidence: long-unread notes are candidates to check, not to crumple on sight. A read reports the access before itself, so reviewing a note does not make it look fresh.
|
|
26
|
+
4. **Merge only genuine duplicates.** Merge two notes only when they share a topic and kind (checkpoint, design, log). First carry every fact, condition, and exception unique to the absorbed note into the survivor, then crumple the absorbed note. Otherwise keep both and record any unresolved conflict.
|
|
27
|
+
5. **Relocate misfiled notes.** When a standing ruling or the note's own MAP already names its proper home, move it there, preserving its metadata, and update both homes' maps. Do it, don't propose it. Propose only when the destination home itself is unclear.
|
|
28
|
+
6. **Preserve meaning and provenance.** Keep facts, conditions, exceptions, uncertainty, authorship, and sources. When promoting a finding, cite its source. Do not relabel agent-authored material as human-authored. If its destination or authority is unclear, propose the promotion instead.
|
|
29
|
+
7. **Keep notes manageable.** Aim below about 200 lines / 8KB per note. Split oversized notes by topic with one-line cross-links.
|
|
30
|
+
8. **Keep maps useful.** Each writable home's MAP.md may include a Cheatsheet of rules that apply in every window; keep it short, about 5 lines. The rest stays the note index: durable notes' addresses and short gists, for lookup. Preserve standing rules, add promoted notes, and drop entries that no longer hold. Maps follow the same size budget.
|
|
31
|
+
|
|
32
|
+
## Deleting
|
|
33
|
+
|
|
34
|
+
Never physically delete a live note; crumple it first. Two cases allow deleting a crumpled note:
|
|
35
|
+
|
|
36
|
+
- **Your own session's notes** may be deleted once crumpled.
|
|
37
|
+
- **The wastebasket:** any note within the dream's reach that was crumpled more than 7 days ago may be deleted, whatever its home or session. Judge by its crumpled date; if none is readable, keep it and report it.
|
|
38
|
+
|
|
39
|
+
Where notes cannot be deleted, list the doomed addresses in the report instead of blanking them.
|
|
29
40
|
|
|
30
41
|
## Report
|
|
31
42
|
|
|
32
|
-
Give a concise report grouped by home: what you inspected, changed, promoted, deleted, and left unresolved. Mention coverage gaps and partial failures. If no notes changed, say so. Distinguish actual note changes from execution or audit artifacts; do not claim success for an incomplete run.
|
|
43
|
+
Give a concise report grouped by home: what you inspected, changed, retired, promoted, deleted, and left unresolved. Mention coverage gaps and partial failures. If no notes changed, say so. Distinguish actual note changes from execution or audit artifacts; do not claim success for an incomplete run.
|
|
33
44
|
|
|
34
45
|
Put skill ideas and unresolved questions in the final message as proposals for the human, not new skill files.
|
|
@@ -10,3 +10,11 @@ Read `../../playbook.md` completely, resolving the path from this skill's direct
|
|
|
10
10
|
Dream in this agent's current session. Do not start another agent or model unless the human asks.
|
|
11
11
|
|
|
12
12
|
Work within the supplied readable and writable scope. If the scope or permission to write has not been established, ask rather than inventing it or setting up execution machinery yourself.
|
|
13
|
+
|
|
14
|
+
## Tools
|
|
15
|
+
|
|
16
|
+
Use `dream_begin`, `dream_forget`, and `dream_end` for the dream lifecycle. If any are missing from the current tool list, search for them before proceeding. If they remain unavailable, report that limitation rather than inventing a replacement backend.
|
|
17
|
+
|
|
18
|
+
- Every dream starts with `dream_begin`, before reading or editing any notes.
|
|
19
|
+
- Use `notes_*` to read and organize notes within the established scope. `dream_forget` permanently deletes a crumpled note when the playbook permits it; never delete a live note.
|
|
20
|
+
- `dream_end` closes the open dream. Close it when finished, and report any partial failures.
|
package/skills/dream/SKILL.md
CHANGED
|
@@ -10,3 +10,11 @@ Read `../../playbook.md` completely, resolving the path from this skill's direct
|
|
|
10
10
|
Dream in this agent's current session. Do not start another agent or model unless the human asks.
|
|
11
11
|
|
|
12
12
|
Work within the supplied readable and writable scope. If the scope or permission to write has not been established, ask rather than inventing it or setting up execution machinery yourself.
|
|
13
|
+
|
|
14
|
+
## Tools
|
|
15
|
+
|
|
16
|
+
Use `dream_begin`, `dream_forget`, and `dream_end` for the dream lifecycle. If any are missing from the current tool list, search for them before proceeding. If they remain unavailable, report that limitation rather than inventing a replacement backend.
|
|
17
|
+
|
|
18
|
+
- Every dream starts with `dream_begin`, before reading or editing any notes.
|
|
19
|
+
- Use `notes_*` to read and organize notes within the established scope. `dream_forget` permanently deletes a crumpled note when the playbook permits it; never delete a live note.
|
|
20
|
+
- `dream_end` closes the open dream. Close it when finished, and report any partial failures.
|
package/src/notes/store.ts
CHANGED
|
@@ -33,7 +33,8 @@ export type EditOptions = { origin?: Origin; crumpled?: boolean; replaceAll?: bo
|
|
|
33
33
|
*/
|
|
34
34
|
export type NotesQuery = { glob?: string | null; crumpled?: boolean };
|
|
35
35
|
/** A read exposes metadata and the pure body; the serialized frontmatter is never part of the body. */
|
|
36
|
-
|
|
36
|
+
/** `accessedBefore` is the last access before this read, so a read never hides how long a note sat unread. */
|
|
37
|
+
export type NoteReadResult = { meta: NoteMeta; body: string; resolvedScope: Scope; accessedBefore: number };
|
|
37
38
|
export type NoteWriteResult = { meta: NoteMeta; outcome: "created" | "overwrote" | "uncrumpled" };
|
|
38
39
|
export type NoteChange =
|
|
39
40
|
| { kind: "none"; before: ""; after: "" }
|
|
@@ -328,11 +329,11 @@ export function createNotesStore(input: NotesIdentity): NotesStore {
|
|
|
328
329
|
const now = Date.now();
|
|
329
330
|
const parsed = parseNote(raw, now);
|
|
330
331
|
// Named homes, and every read during a dream, leave no access stamp.
|
|
331
|
-
if (identity.dreaming !== undefined || ((scope === "project" || scope === "session") && destination.who !== undefined)) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope };
|
|
332
|
+
if (identity.dreaming !== undefined || ((scope === "project" || scope === "session") && destination.who !== undefined)) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope, accessedBefore: parsed.meta.lastAccessed };
|
|
332
333
|
// A read records its own access, exactly as a write records an edit.
|
|
333
334
|
const meta: NoteMeta = { ...parsed.meta, scope, lastAccessed: now, accessCount: (typeof parsed.meta.accessCount === "number" ? parsed.meta.accessCount : 0) + 1 };
|
|
334
335
|
await atomicWrite(path, serializeNote(meta, parsed.body));
|
|
335
|
-
return { meta, body: parsed.body, resolvedScope: scope };
|
|
336
|
+
return { meta, body: parsed.body, resolvedScope: scope, accessedBefore: parsed.meta.lastAccessed };
|
|
336
337
|
});
|
|
337
338
|
}
|
|
338
339
|
|
package/src/tools/notes.ts
CHANGED
|
@@ -42,6 +42,7 @@ export const NoteMetadataSchema = Type.Object({
|
|
|
42
42
|
origin: Type.Union([...ORIGIN_VALUES]),
|
|
43
43
|
created_at: Type.String(),
|
|
44
44
|
updated_at: Type.String(),
|
|
45
|
+
last_accessed: Type.String(),
|
|
45
46
|
crumpled_at: Type.Optional(Type.String()),
|
|
46
47
|
project: Type.Optional(Type.String()),
|
|
47
48
|
extra: Type.Record(Type.String(), Type.Unknown()),
|
|
@@ -73,6 +74,7 @@ function noteMetadata(meta: NoteMeta): NoteMetadata {
|
|
|
73
74
|
origin: meta.origin,
|
|
74
75
|
created_at: localIso(meta.createdAt),
|
|
75
76
|
updated_at: localIso(meta.updatedAt),
|
|
77
|
+
last_accessed: localIso(meta.lastAccessed),
|
|
76
78
|
...(typeof meta.crumpledAt === "string" ? { crumpled_at: meta.crumpledAt } : {}),
|
|
77
79
|
...(typeof meta.project === "string" ? { project: meta.project } : {}),
|
|
78
80
|
extra,
|
|
@@ -84,6 +86,7 @@ function renderMetadata(metadata: NoteMetadata): string {
|
|
|
84
86
|
`origin ${metadata.origin}`,
|
|
85
87
|
`created ${metadata.created_at}`,
|
|
86
88
|
`updated ${metadata.updated_at}`,
|
|
89
|
+
`accessed ${metadata.last_accessed}`,
|
|
87
90
|
...(metadata.crumpled_at === undefined ? [] : [`crumpled ${metadata.crumpled_at}`]),
|
|
88
91
|
...(metadata.project === undefined ? [] : [`project ${metadata.project}`]),
|
|
89
92
|
];
|
|
@@ -110,6 +113,7 @@ const ListedFileSchema = Type.Object({
|
|
|
110
113
|
project_key: Type.Optional(Type.String()),
|
|
111
114
|
...ProjectReceiptSchema,
|
|
112
115
|
updated_at: Type.String(),
|
|
116
|
+
last_accessed: Type.String(),
|
|
113
117
|
crumpled_at: Type.Optional(Type.String()),
|
|
114
118
|
}, { additionalProperties: false });
|
|
115
119
|
|
|
@@ -197,7 +201,7 @@ export function snapshot<T extends { address: string }>(
|
|
|
197
201
|
}
|
|
198
202
|
|
|
199
203
|
export function listedFile(row: Pick<NoteRow, "address" | "meta">, identity: NotesIdentity): NotesListData["files"][number] {
|
|
200
|
-
return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }) };
|
|
204
|
+
return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt), last_accessed: localIso(row.meta.lastAccessed), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }) };
|
|
201
205
|
}
|
|
202
206
|
|
|
203
207
|
export const notesWriteParameters = Type.Object({ address: Type.String(), content: Type.String(), origin: ORIGIN }, { additionalProperties: false });
|
|
@@ -291,7 +295,8 @@ export const notesRead = {
|
|
|
291
295
|
if (!note) return failure("not_found", `No note at ${resolved.address}.`);
|
|
292
296
|
const totalChars = Array.from(note.body).length;
|
|
293
297
|
if (params.offset_chars !== undefined && params.offset_chars > totalChars) return failure("invalid_offset", `This note ends at char ${totalChars}; offset_chars ${params.offset_chars} is past the last word.`);
|
|
294
|
-
|
|
298
|
+
// Report the access before this one: the read itself must not make a long-unread note look fresh.
|
|
299
|
+
const metadata = noteMetadata({ ...note.meta, lastAccessed: note.accessedBefore });
|
|
295
300
|
return readTextWindow(note.body, params.offset_chars, params.max_chars, (window) => ({ ...resolved, metadata, ...window }), (result) => renderOutcome(result, renderReadData));
|
|
296
301
|
} catch (error) { return failureOf(error); }
|
|
297
302
|
},
|
|
@@ -303,7 +308,7 @@ export const notesListParameters = Type.Object({ glob: GLOB_PARAMETER, limit: FI
|
|
|
303
308
|
export function renderListData(data: NotesListData): string {
|
|
304
309
|
const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
|
|
305
310
|
for (const file of data.files) {
|
|
306
|
-
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
311
|
+
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at} | accessed ${file.last_accessed}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
307
312
|
}
|
|
308
313
|
if (data.more > 0) lines.push(`${data.more} more matching notes omitted; narrow with glob`);
|
|
309
314
|
for (const home of data.homes_unavailable) lines.push(`${home} could not be read`);
|