notesoup 0.55.1 → 0.56.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/dist/plugins/pi/budget.d.ts +4 -0
- package/dist/plugins/pi/budget.js +6 -1
- package/dist/src/history/query.d.ts +0 -2
- package/dist/src/history/query.js +2 -4
- package/dist/src/notes/store.d.ts +0 -2
- package/dist/src/notes/store.js +2 -2
- package/dist/src/tools/dream.d.ts +6 -6
- package/dist/src/tools/dream.js +8 -3
- package/dist/src/tools/notes.d.ts +18 -8
- package/dist/src/tools/notes.js +6 -11
- package/dist/test/budget-settings.integration.test.js +18 -0
- package/dist/test/dream-tools.test.js +26 -7
- package/dist/test/notes-library.test.js +1 -1
- package/dist/test/notes.test.js +5 -4
- package/dist/test/pi-render.test.js +2 -2
- package/docs/tool-results.md +2 -2
- package/package.json +1 -1
- package/playbook.md +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +8 -12
- package/plugins/claude/playbook.md +1 -1
- package/plugins/codex/dist/codex/notesoup.js +8 -12
- package/plugins/paseo/OVERVIEW.md +1 -1
- package/plugins/paseo/client/brain-empty-card.tsx +28 -9
- package/plugins/paseo/client/brain-empty-transformer.ts +5 -1
- package/plugins/paseo/client/markdown.tsx +14 -13
- package/plugins/paseo/client/notes-op-card.tsx +5 -5
- package/plugins/paseo/client/paper-card.tsx +5 -3
- package/plugins/paseo/client/paper-palette.ts +12 -11
- package/plugins/paseo/shared/brain-empty.ts +1 -0
- package/plugins/paseo/test/brain-empty.test.ts +8 -0
- package/plugins/paseo/test/paper-palette.test.ts +3 -3
- package/plugins/pi/budget.ts +7 -1
- package/src/history/query.ts +2 -4
- package/src/notes/store.ts +3 -4
- package/src/tools/dream.ts +8 -3
- package/src/tools/notes.ts +7 -12
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { Type } from "@earendil-works/pi-ai";
|
|
1
2
|
import { type ExtensionAPI, type ExtensionContext, type SessionBoundaryDraft, type SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
export declare const ContextRemainingOutputSchema: Type.TObject<{
|
|
4
|
+
remaining_tokens: Type.TUnion<[Type.TInteger, Type.TNull]>;
|
|
5
|
+
}>;
|
|
2
6
|
export declare function registerBudget(pi: ExtensionAPI, isEnabled: () => boolean, settingsManager?: SettingsManager): {
|
|
3
7
|
automaticResetEnabled: (ctx: ExtensionContext) => boolean;
|
|
4
8
|
hardReserveDue: (ctx: ExtensionContext) => boolean;
|
|
@@ -9,6 +9,9 @@ import { currentWindowId, hasWindowMessage, windowUsage } from "./window.js";
|
|
|
9
9
|
import { tokenBudgetGuidance } from "../../src/budget/text.js";
|
|
10
10
|
import { arrangeAnchoredReminders } from "./anchored.js";
|
|
11
11
|
import { output } from "./tool-result.js";
|
|
12
|
+
export const ContextRemainingOutputSchema = Type.Object({
|
|
13
|
+
remaining_tokens: Type.Union([Type.Integer({ minimum: 0 }), Type.Null()]),
|
|
14
|
+
}, { additionalProperties: false });
|
|
12
15
|
/** Remaining tokens in the provider's active window, or null without a usable estimate. */
|
|
13
16
|
function remainingTokens(ctx) {
|
|
14
17
|
const usage = windowUsage(ctx);
|
|
@@ -125,10 +128,12 @@ export function registerBudget(pi, isEnabled, settingsManager) {
|
|
|
125
128
|
label: "Get context remaining",
|
|
126
129
|
description: "Check how much room your brain has left before it gets forcibly emptied. Returns null when unknown.",
|
|
127
130
|
parameters: Type.Object({}, { additionalProperties: false }),
|
|
131
|
+
outputSchema: ContextRemainingOutputSchema,
|
|
128
132
|
async execute(_id, _params, _signal, _update, ctx) {
|
|
129
133
|
// Report room to the hard-reserve wipe, including the warning runway.
|
|
130
134
|
const remaining = remainingTokens(ctx);
|
|
131
|
-
|
|
135
|
+
const value = { remaining_tokens: remainingBudget(remaining, thresholdsFor(ctx).reserve) };
|
|
136
|
+
return { ...output(value), structuredContent: value };
|
|
132
137
|
},
|
|
133
138
|
}));
|
|
134
139
|
return {
|
|
@@ -18,12 +18,10 @@ export type HistorySelection = HistoryFilter & {
|
|
|
18
18
|
until?: string;
|
|
19
19
|
max_chars_per_item?: number;
|
|
20
20
|
};
|
|
21
|
-
/** The params to merge into the previous call to continue toward older events. */
|
|
22
21
|
export declare const HistoryOlderSchema: Type.TObject<{
|
|
23
22
|
session: Type.TOptional<Type.TString>;
|
|
24
23
|
before_seq: Type.TInteger;
|
|
25
24
|
}>;
|
|
26
|
-
/** The params to merge into the previous call to continue toward newer events. */
|
|
27
25
|
export declare const HistoryNewerSchema: Type.TObject<{
|
|
28
26
|
session: Type.TOptional<Type.TString>;
|
|
29
27
|
after_seq: Type.TInteger;
|
|
@@ -28,12 +28,10 @@ function resolveTimeBounds(params) {
|
|
|
28
28
|
}
|
|
29
29
|
return success({ ...(since.data === undefined ? {} : { sinceMs: since.data }), ...(until.data === undefined ? {} : { untilMs: until.data }) });
|
|
30
30
|
}
|
|
31
|
-
/** The params to merge into the previous call to continue toward older events. */
|
|
32
31
|
export const HistoryOlderSchema = Type.Object({
|
|
33
32
|
session: Type.Optional(Type.String()),
|
|
34
33
|
before_seq: Type.Integer({ minimum: 1 }),
|
|
35
34
|
}, { additionalProperties: false });
|
|
36
|
-
/** The params to merge into the previous call to continue toward newer events. */
|
|
37
35
|
export const HistoryNewerSchema = Type.Object({
|
|
38
36
|
session: Type.Optional(Type.String()),
|
|
39
37
|
after_seq: Type.Integer({ minimum: 1 }),
|
|
@@ -42,8 +40,8 @@ export const HistoryNewerSchema = Type.Object({
|
|
|
42
40
|
export const HistoryPageSchema = Type.Object({
|
|
43
41
|
notice: Type.Optional(Type.String()),
|
|
44
42
|
items: Type.Array(Type.Union([HistoryPageItemSchema, HistoryFoldedRowSchema])),
|
|
45
|
-
page_older: Type.Union([HistoryOlderSchema, Type.Null()]),
|
|
46
|
-
page_newer: Type.Union([HistoryNewerSchema, Type.Null()]),
|
|
43
|
+
page_older: Type.Union([HistoryOlderSchema, Type.Null()], { description: "Args to merge into `history_list` for older events." }),
|
|
44
|
+
page_newer: Type.Union([HistoryNewerSchema, Type.Null()], { description: "Args to merge into `history_list` for newer events." }),
|
|
47
45
|
}, { additionalProperties: false });
|
|
48
46
|
/** Shorten preview text first; omit an oversized tool name rather than invent a partial name. */
|
|
49
47
|
function truncateHistoryItem(item, fits) {
|
|
@@ -44,12 +44,10 @@ 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. */
|
|
48
47
|
export type NoteReadResult = {
|
|
49
48
|
meta: NoteMeta;
|
|
50
49
|
body: string;
|
|
51
50
|
resolvedScope: Scope;
|
|
52
|
-
accessedBefore: number;
|
|
53
51
|
};
|
|
54
52
|
export type NoteWriteResult = {
|
|
55
53
|
meta: NoteMeta;
|
package/dist/src/notes/store.js
CHANGED
|
@@ -300,11 +300,11 @@ export function createNotesStore(input) {
|
|
|
300
300
|
const parsed = parseNote(raw, now);
|
|
301
301
|
// Named notebooks, and every read during a dream, leave no access stamp.
|
|
302
302
|
if (identity.dreaming !== undefined || ((scope === "project" || scope === "session") && destination.who !== undefined))
|
|
303
|
-
return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope
|
|
303
|
+
return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope };
|
|
304
304
|
// A read records its own access, exactly as a write records an edit.
|
|
305
305
|
const meta = { ...parsed.meta, scope, lastAccessed: now, accessCount: (typeof parsed.meta.accessCount === "number" ? parsed.meta.accessCount : 0) + 1 };
|
|
306
306
|
await atomicWrite(path, serializeNote(meta, parsed.body));
|
|
307
|
-
return { meta, body: parsed.body, resolvedScope: scope
|
|
307
|
+
return { meta, body: parsed.body, resolvedScope: scope };
|
|
308
308
|
});
|
|
309
309
|
}
|
|
310
310
|
async function update(address, edits, options = {}) {
|
|
@@ -25,9 +25,11 @@ export declare const dreamBeginParameters: Type.TObject<{
|
|
|
25
25
|
export declare const DreamBeginDataSchema: Type.TObject<{
|
|
26
26
|
more: Type.TInteger;
|
|
27
27
|
namespaces_unavailable: Type.TArray<Type.TString>;
|
|
28
|
+
project: Type.TString;
|
|
29
|
+
baseline: Type.TString;
|
|
28
30
|
files: Type.TArray<Type.TObject<{
|
|
29
|
-
updated_at: Type.TString;
|
|
30
31
|
last_accessed: Type.TString;
|
|
32
|
+
updated_at: Type.TString;
|
|
31
33
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
32
34
|
project_root: Type.TOptional<Type.TString>;
|
|
33
35
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
@@ -37,8 +39,6 @@ export declare const DreamBeginDataSchema: Type.TObject<{
|
|
|
37
39
|
address: Type.TString;
|
|
38
40
|
project_key: Type.TOptional<Type.TString>;
|
|
39
41
|
}>>;
|
|
40
|
-
project: Type.TString;
|
|
41
|
-
baseline: Type.TString;
|
|
42
42
|
}>;
|
|
43
43
|
export type DreamBeginData = Static<typeof DreamBeginDataSchema>;
|
|
44
44
|
export declare const dreamBegin: {
|
|
@@ -51,9 +51,11 @@ export declare const dreamBegin: {
|
|
|
51
51
|
readonly outputSchema: Type.TUnion<[Type.TObject<{
|
|
52
52
|
more: Type.TInteger;
|
|
53
53
|
namespaces_unavailable: Type.TArray<Type.TString>;
|
|
54
|
+
project: Type.TString;
|
|
55
|
+
baseline: Type.TString;
|
|
54
56
|
files: Type.TArray<Type.TObject<{
|
|
55
|
-
updated_at: Type.TString;
|
|
56
57
|
last_accessed: Type.TString;
|
|
58
|
+
updated_at: Type.TString;
|
|
57
59
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
58
60
|
project_root: Type.TOptional<Type.TString>;
|
|
59
61
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
@@ -63,8 +65,6 @@ export declare const dreamBegin: {
|
|
|
63
65
|
address: Type.TString;
|
|
64
66
|
project_key: Type.TOptional<Type.TString>;
|
|
65
67
|
}>>;
|
|
66
|
-
project: Type.TString;
|
|
67
|
-
baseline: Type.TString;
|
|
68
68
|
}>, Type.TObject<{
|
|
69
69
|
error: Type.TString;
|
|
70
70
|
code: Type.TString;
|
package/dist/src/tools/dream.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/** Dream operations: open one project's notes for consolidation, delete crumpled notes, close. */
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
+
import { localIso } from "../notes/frontmatter.js";
|
|
3
4
|
import { createNotesStore, noteIdentity } from "../notes/index.js";
|
|
4
5
|
import { projectNamespaces } from "../notes/project-namespace.js";
|
|
5
6
|
import { gitCommit } from "../dream/git.js";
|
|
6
7
|
import { acquireDreamLock, dreamLockPath, releaseDreamLock } from "../dream/lock.js";
|
|
7
8
|
import { failure, renderOutcome, resultSchema, success } from "./result.js";
|
|
8
|
-
import { failureOf, listedFile,
|
|
9
|
+
import { failureOf, listedFile, ListedFileSchema, NoteIdentitySchema, renderListData, snapshot, SnapshotSchema } from "./notes.js";
|
|
9
10
|
function currentOpening(state, opening) {
|
|
10
11
|
return state.pending === opening && state.generation === opening.generation;
|
|
11
12
|
}
|
|
@@ -44,7 +45,11 @@ const NOT_DREAMING = "No dream is open; call dream_begin first.";
|
|
|
44
45
|
export const dreamBeginParameters = Type.Object({
|
|
45
46
|
project: Type.Optional(Type.String({ description: "(optional, default this project) Project name, as in @projects/<name>/." })),
|
|
46
47
|
}, { additionalProperties: false });
|
|
47
|
-
export const DreamBeginDataSchema = Type.Object({
|
|
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,
|
|
52
|
+
}, { additionalProperties: false });
|
|
48
53
|
function renderBeginData(data) {
|
|
49
54
|
return `dreaming over ${data.project} (baseline ${data.baseline})\n${renderListData(data)}`;
|
|
50
55
|
}
|
|
@@ -81,7 +86,7 @@ export const dreamBegin = {
|
|
|
81
86
|
}
|
|
82
87
|
}
|
|
83
88
|
rows.sort((a, b) => b.meta.updatedAt - a.meta.updatedAt || a.address.localeCompare(b.address));
|
|
84
|
-
const listed = snapshot(rows.map(row => listedFile(row, identity)), undefined, { namespacesUnavailable: unavailable }, renderListData);
|
|
89
|
+
const listed = snapshot(rows.map(row => ({ ...listedFile(row, identity), last_accessed: localIso(row.meta.lastAccessed) })), undefined, { namespacesUnavailable: unavailable }, renderListData);
|
|
85
90
|
if (!listed.ok) {
|
|
86
91
|
releaseOpening(state, opening);
|
|
87
92
|
return listed;
|
|
@@ -12,7 +12,6 @@ export declare const NoteMetadataSchema: Type.TObject<{
|
|
|
12
12
|
origin: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"self">, Type.TLiteral<"external">]>;
|
|
13
13
|
created_at: Type.TString;
|
|
14
14
|
updated_at: Type.TString;
|
|
15
|
-
last_accessed: Type.TString;
|
|
16
15
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
17
16
|
project: Type.TOptional<Type.TString>;
|
|
18
17
|
extra: Type.TRecord<"^.*$", Type.TUnknown>;
|
|
@@ -36,6 +35,21 @@ export declare const NoteIdentitySchema: {
|
|
|
36
35
|
address: Type.TString;
|
|
37
36
|
project_key: Type.TOptional<Type.TString>;
|
|
38
37
|
};
|
|
38
|
+
export declare const ListedFileSchema: Type.TObject<{
|
|
39
|
+
updated_at: Type.TString;
|
|
40
|
+
crumpled_at: Type.TOptional<Type.TString>;
|
|
41
|
+
project_root: Type.TOptional<Type.TString>;
|
|
42
|
+
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
43
|
+
name: Type.TString;
|
|
44
|
+
path: Type.TString;
|
|
45
|
+
}>>>;
|
|
46
|
+
address: Type.TString;
|
|
47
|
+
project_key: Type.TOptional<Type.TString>;
|
|
48
|
+
}>;
|
|
49
|
+
export declare const SnapshotSchema: {
|
|
50
|
+
more: Type.TInteger;
|
|
51
|
+
namespaces_unavailable: Type.TArray<Type.TString>;
|
|
52
|
+
};
|
|
39
53
|
export declare const NotesWriteDataSchema: Type.TObject<{
|
|
40
54
|
outcome: Type.TUnion<[Type.TLiteral<"created">, Type.TLiteral<"overwrote">, Type.TLiteral<"uncrumpled">]>;
|
|
41
55
|
project_root: Type.TOptional<Type.TString>;
|
|
@@ -67,7 +81,6 @@ export declare const NotesReadDataSchema: Type.TObject<{
|
|
|
67
81
|
origin: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"self">, Type.TLiteral<"external">]>;
|
|
68
82
|
created_at: Type.TString;
|
|
69
83
|
updated_at: Type.TString;
|
|
70
|
-
last_accessed: Type.TString;
|
|
71
84
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
72
85
|
project: Type.TOptional<Type.TString>;
|
|
73
86
|
extra: Type.TRecord<"^.*$", Type.TUnknown>;
|
|
@@ -86,7 +99,6 @@ export declare const NotesListDataSchema: Type.TObject<{
|
|
|
86
99
|
namespaces_unavailable: Type.TArray<Type.TString>;
|
|
87
100
|
files: Type.TArray<Type.TObject<{
|
|
88
101
|
updated_at: Type.TString;
|
|
89
|
-
last_accessed: Type.TString;
|
|
90
102
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
91
103
|
project_root: Type.TOptional<Type.TString>;
|
|
92
104
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
@@ -108,7 +120,6 @@ export declare const NotesSearchDataSchema: Type.TObject<{
|
|
|
108
120
|
offset_chars: Type.TInteger;
|
|
109
121
|
}>>;
|
|
110
122
|
updated_at: Type.TString;
|
|
111
|
-
last_accessed: Type.TString;
|
|
112
123
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
113
124
|
project_root: Type.TOptional<Type.TString>;
|
|
114
125
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
@@ -231,7 +242,6 @@ export declare const notesRead: {
|
|
|
231
242
|
origin: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"self">, Type.TLiteral<"external">]>;
|
|
232
243
|
created_at: Type.TString;
|
|
233
244
|
updated_at: Type.TString;
|
|
234
|
-
last_accessed: Type.TString;
|
|
235
245
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
236
246
|
project: Type.TOptional<Type.TString>;
|
|
237
247
|
extra: Type.TRecord<"^.*$", Type.TUnknown>;
|
|
@@ -256,7 +266,9 @@ export declare const notesListParameters: Type.TObject<{
|
|
|
256
266
|
crumpled: Type.TOptional<Type.TBoolean>;
|
|
257
267
|
cwd: Type.TOptional<Type.TString>;
|
|
258
268
|
}>;
|
|
259
|
-
export declare function renderListData(data: NotesListData
|
|
269
|
+
export declare function renderListData(data: Snapshot<NotesListData["files"][number] & {
|
|
270
|
+
last_accessed?: string;
|
|
271
|
+
}>): string;
|
|
260
272
|
export declare const notesList: {
|
|
261
273
|
readonly name: "notes_list";
|
|
262
274
|
readonly label: "Notes list";
|
|
@@ -272,7 +284,6 @@ export declare const notesList: {
|
|
|
272
284
|
namespaces_unavailable: Type.TArray<Type.TString>;
|
|
273
285
|
files: Type.TArray<Type.TObject<{
|
|
274
286
|
updated_at: Type.TString;
|
|
275
|
-
last_accessed: Type.TString;
|
|
276
287
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
277
288
|
project_root: Type.TOptional<Type.TString>;
|
|
278
289
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
|
@@ -321,7 +332,6 @@ export declare const notesSearch: {
|
|
|
321
332
|
offset_chars: Type.TInteger;
|
|
322
333
|
}>>;
|
|
323
334
|
updated_at: Type.TString;
|
|
324
|
-
last_accessed: Type.TString;
|
|
325
335
|
crumpled_at: Type.TOptional<Type.TString>;
|
|
326
336
|
project_root: Type.TOptional<Type.TString>;
|
|
327
337
|
project_siblings: Type.TOptional<Type.TArray<Type.TObject<{
|
package/dist/src/tools/notes.js
CHANGED
|
@@ -42,7 +42,6 @@ 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(),
|
|
46
45
|
crumpled_at: Type.Optional(Type.String()),
|
|
47
46
|
project: Type.Optional(Type.String()),
|
|
48
47
|
extra: Type.Record(Type.String(), Type.Unknown()),
|
|
@@ -74,7 +73,6 @@ function noteMetadata(meta) {
|
|
|
74
73
|
origin: meta.origin,
|
|
75
74
|
created_at: localIso(meta.createdAt),
|
|
76
75
|
updated_at: localIso(meta.updatedAt),
|
|
77
|
-
last_accessed: localIso(meta.lastAccessed),
|
|
78
76
|
...(typeof meta.crumpledAt === "string" ? { crumpled_at: meta.crumpledAt } : {}),
|
|
79
77
|
...(typeof meta.project === "string" ? { project: meta.project } : {}),
|
|
80
78
|
extra,
|
|
@@ -85,7 +83,6 @@ function renderMetadata(metadata) {
|
|
|
85
83
|
`origin ${metadata.origin}`,
|
|
86
84
|
`created ${metadata.created_at}`,
|
|
87
85
|
`updated ${metadata.updated_at}`,
|
|
88
|
-
`accessed ${metadata.last_accessed}`,
|
|
89
86
|
...(metadata.crumpled_at === undefined ? [] : [`crumpled ${metadata.crumpled_at}`]),
|
|
90
87
|
...(metadata.project === undefined ? [] : [`project ${metadata.project}`]),
|
|
91
88
|
];
|
|
@@ -114,10 +111,9 @@ export const NoteIdentitySchema = {
|
|
|
114
111
|
project_key: Type.Optional(Type.String()),
|
|
115
112
|
...ProjectReceiptSchema,
|
|
116
113
|
};
|
|
117
|
-
const ListedFileSchema = Type.Object({
|
|
114
|
+
export const ListedFileSchema = Type.Object({
|
|
118
115
|
...NoteIdentitySchema,
|
|
119
116
|
updated_at: Type.String(),
|
|
120
|
-
last_accessed: Type.String(),
|
|
121
117
|
crumpled_at: Type.Optional(Type.String()),
|
|
122
118
|
}, { additionalProperties: false });
|
|
123
119
|
const MatchSchema = Type.Object({
|
|
@@ -129,9 +125,9 @@ const SearchedFileSchema = Type.Object({
|
|
|
129
125
|
...ListedFileSchema.properties,
|
|
130
126
|
matches: Type.Array(MatchSchema),
|
|
131
127
|
}, { additionalProperties: false });
|
|
132
|
-
const SnapshotSchema = {
|
|
128
|
+
export const SnapshotSchema = {
|
|
133
129
|
more: Type.Integer({ description: "How many more were left out." }),
|
|
134
|
-
namespaces_unavailable: Type.Array(Type.String()),
|
|
130
|
+
namespaces_unavailable: Type.Array(Type.String(), { description: "Unreadable notebooks or notes." }),
|
|
135
131
|
};
|
|
136
132
|
export const NotesWriteDataSchema = Type.Object({
|
|
137
133
|
...NoteIdentitySchema,
|
|
@@ -179,7 +175,7 @@ export function snapshot(rows, limit, status, renderData, shrink) {
|
|
|
179
175
|
return fitsResult(outcome, render) ? outcome : failure("output_too_large", `The list of unreachable notebooks is itself over ${TOOL_OUTPUT_LIMIT}; narrow \`glob\` to fewer notebooks.`);
|
|
180
176
|
}
|
|
181
177
|
export function listedFile(row, identity) {
|
|
182
|
-
return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt),
|
|
178
|
+
return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }) };
|
|
183
179
|
}
|
|
184
180
|
export const notesWriteParameters = Type.Object({ address: Type.String(), content: Type.String(), origin: ORIGIN, cwd: CWD_PARAMETER }, { additionalProperties: false });
|
|
185
181
|
function renderWriteData(data) {
|
|
@@ -255,8 +251,7 @@ export const notesRead = {
|
|
|
255
251
|
const totalChars = Array.from(note.body).length;
|
|
256
252
|
if (params.offset_chars !== undefined && params.offset_chars > totalChars)
|
|
257
253
|
return failure("invalid_offset", `This note ends at char ${totalChars}; offset_chars ${params.offset_chars} is past the last word.`);
|
|
258
|
-
|
|
259
|
-
const metadata = noteMetadata({ ...note.meta, lastAccessed: note.accessedBefore });
|
|
254
|
+
const metadata = noteMetadata(note.meta);
|
|
260
255
|
return readTextWindow(note.body, params.offset_chars, params.max_chars, (window) => ({ ...resolved, metadata, ...window }), (result) => renderOutcome(result, renderReadData));
|
|
261
256
|
}
|
|
262
257
|
catch (error) {
|
|
@@ -269,7 +264,7 @@ export const notesListParameters = Type.Object({ glob: GLOB_PARAMETER, limit: FI
|
|
|
269
264
|
export function renderListData(data) {
|
|
270
265
|
const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
|
|
271
266
|
for (const file of data.files) {
|
|
272
|
-
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at} | accessed ${file.last_accessed}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
267
|
+
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at}${file.last_accessed === undefined ? "" : ` | accessed ${file.last_accessed}`}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
273
268
|
}
|
|
274
269
|
if (data.more > 0)
|
|
275
270
|
lines.push(`${data.more} more matching notes omitted; narrow with glob`);
|
|
@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import test from "node:test";
|
|
4
4
|
import { SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import { Check } from "typebox/value";
|
|
5
6
|
import { DEFAULT_REMINDER_MARGIN_TOKENS, DEFAULT_RESERVE_TOKENS } from "../src/budget/constants.js";
|
|
6
7
|
import { GUIDANCE_TYPE, RESET_MARKER_TYPE, WARNING_TYPE } from "../plugins/pi/entries.js";
|
|
7
8
|
import { deriveThresholds } from "../src/budget/policy.js";
|
|
@@ -115,6 +116,23 @@ test("early guidance stays silent and the final warning notifies immediately onc
|
|
|
115
116
|
await runHandlers(captured, "agent_settled", {}, final);
|
|
116
117
|
assert.equal(noticesOf(final).filter((notice) => notice.message === "🥣 Brain almost full").length, 1, "repeated injection and commit do not notify again");
|
|
117
118
|
});
|
|
119
|
+
test("get_context_remaining declares its output and returns matching structured and text values", async () => {
|
|
120
|
+
const fixture = settingsFixture({ reserveTokens: 16_384 });
|
|
121
|
+
const sm = manager();
|
|
122
|
+
const captured = makeExtension(sm);
|
|
123
|
+
const schema = captured.tools.get("get_context_remaining")?.outputSchema;
|
|
124
|
+
assert.ok(schema, "the registered tool declares an output schema");
|
|
125
|
+
for (const [tokens, expected] of [[72_563, 111_053], [null, null]]) {
|
|
126
|
+
const ctx = context(sm, undefined, { tokens, contextWindow: 200_000, percent: tokens === null ? null : tokens / 2000 }, true, fixture.cwd);
|
|
127
|
+
const result = await call(captured, "get_context_remaining", {}, ctx);
|
|
128
|
+
assert.deepEqual(result.structuredContent, { remaining_tokens: expected });
|
|
129
|
+
assert.deepEqual(result.structuredContent, resultJson(result));
|
|
130
|
+
assert.equal(Check(schema, result.structuredContent), true);
|
|
131
|
+
const text = result.content[0];
|
|
132
|
+
assert.ok(text && text.type === "text");
|
|
133
|
+
assert.equal(text.text, JSON.stringify(result.structuredContent));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
118
136
|
test("the reported room ends at the hard reserve, clamps at zero, and preserves unknown usage", async () => {
|
|
119
137
|
const fixture = settingsFixture({
|
|
120
138
|
reserveTokens: 16_384,
|
|
@@ -132,18 +132,37 @@ test("baseline failure releases pending ownership and permits a retry", async (t
|
|
|
132
132
|
assert.ok((await dreamBegin.execute({}, me, state)).ok);
|
|
133
133
|
assert.ok((await dreamEnd.execute({}, me, state)).ok);
|
|
134
134
|
});
|
|
135
|
-
test("
|
|
135
|
+
test("dream_begin reports the stored access, and dream reads do not refresh it", async (t) => {
|
|
136
136
|
const { home, as } = fixture(t);
|
|
137
137
|
const me = as("s", "alpha");
|
|
138
|
+
const state = {};
|
|
138
139
|
const old = "2026-01-01T08:00:00.000+08:00";
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const first = await notesRead.execute({ address: "@human/stale" }, notesToolContext(me, "/work/alpha"));
|
|
140
|
+
writeFileSync(join(home, "project", "alpha", "stale.md"), `---\norigin: self\ncreatedAt: ${old}\nupdatedAt: ${old}\nlastAccessed: ${old}\naccessCount: 0\n---\n\nbody`);
|
|
141
|
+
const first = await dreamBegin.execute({}, me, state);
|
|
142
142
|
assert.ok(first.ok);
|
|
143
|
-
assert.equal(
|
|
144
|
-
const
|
|
143
|
+
assert.equal(Check(dreamBegin.outputSchema, first.data), true);
|
|
144
|
+
const row = first.data.files[0];
|
|
145
|
+
assert.equal(row.address, "@projects/alpha/stale.md");
|
|
146
|
+
assert.equal(Date.parse(row.last_accessed), Date.parse(old), "the dream shows the pre-dream access");
|
|
147
|
+
assert.ok(dreamBegin.render(first).includes(` | accessed ${row.last_accessed}`));
|
|
148
|
+
const read = await notesRead.execute({ address: "@project/stale" }, notesToolContext(dreamingIdentity(me, state), "/work/alpha"));
|
|
149
|
+
assert.ok(read.ok && read.data.text === "body");
|
|
150
|
+
const during = (await createNotesStore(me).list({ glob: "@project/**" }))[0];
|
|
151
|
+
assert.equal(during.meta.lastAccessed, Date.parse(old));
|
|
152
|
+
assert.equal(during.meta.accessCount, 0, "dream reads leave storage untouched");
|
|
153
|
+
assert.ok((await dreamEnd.execute({}, me, state)).ok);
|
|
154
|
+
const second = await dreamBegin.execute({}, me, state);
|
|
145
155
|
assert.ok(second.ok);
|
|
146
|
-
assert.
|
|
156
|
+
assert.equal(second.data.files[0].last_accessed, row.last_accessed, "a later dream sees the same pre-dream access");
|
|
157
|
+
assert.ok((await dreamEnd.execute({}, me, state)).ok);
|
|
158
|
+
assert.ok((await notesRead.execute({ address: "@project/stale" }, notesToolContext(me, "/work/alpha"))).ok);
|
|
159
|
+
const after = (await createNotesStore(me).list({ glob: "@project/**" }))[0];
|
|
160
|
+
assert.equal(after.meta.accessCount, 1, "ordinary reads still stamp storage");
|
|
161
|
+
const third = await dreamBegin.execute({}, me, state);
|
|
162
|
+
assert.ok(third.ok);
|
|
163
|
+
assert.equal(Date.parse(third.data.files[0].last_accessed), after.meta.lastAccessed);
|
|
164
|
+
assert.ok(after.meta.lastAccessed > Date.parse(old));
|
|
165
|
+
assert.ok((await dreamEnd.execute({}, me, state)).ok);
|
|
147
166
|
});
|
|
148
167
|
test("dream_begin refuses an unknown project", async (t) => {
|
|
149
168
|
const { as } = fixture(t);
|
|
@@ -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(), ["
|
|
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");
|
|
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
|
@@ -222,7 +222,9 @@ legacy body`);
|
|
|
222
222
|
assert.equal(parsed.meta.createdAt, Date.parse("2026-02-01T00:00:00Z"), "missing canonical timestamp takes the normal default");
|
|
223
223
|
assert.equal(parsed.meta.created_at, "2026-01-01T00:00:00.000+00:00", "unrecognized fields remain ordinary extras");
|
|
224
224
|
assert.equal((await listNotes(ctx))[0]?.address, "legacy.md");
|
|
225
|
-
|
|
225
|
+
const legacyRead = await call(captured, "notes_read", { address: "legacy.md" }, ctx);
|
|
226
|
+
assert.match(resultRead(legacyRead).content, /legacy body$/);
|
|
227
|
+
assert.equal(resultData(legacyRead).metadata.extra.last_accessed, parsed.meta.last_accessed, "a literal legacy last_accessed remains ordinary extra frontmatter");
|
|
226
228
|
await call(captured, "notes_update", { address: "legacy.md", edits: [{ oldText: "legacy body", newText: "edited body" }] }, ctx);
|
|
227
229
|
await call(captured, "notes_write", { address: "legacy.md", content: "overwritten body" }, ctx);
|
|
228
230
|
const rewritten = parseNote(readFileSync(legacyFile, "utf8"));
|
|
@@ -434,9 +436,8 @@ test("list and search merge scopes and carry addresses; the path jail rejects es
|
|
|
434
436
|
await call(captured, "notes_write", { address: "@human/three.md", content: "needle three" }, ctx);
|
|
435
437
|
const listed = resultData(await call(captured, "notes_list", {}, ctx));
|
|
436
438
|
assert.deepEqual([...listed.files].map((file) => file.address).sort(), ["@human/three.md", "@project/two.md", "one.md"], "every merged row carries its full address");
|
|
437
|
-
for (const row of listed.files)
|
|
438
|
-
assert.
|
|
439
|
-
}
|
|
439
|
+
for (const row of listed.files)
|
|
440
|
+
assert.equal(typeof row.updated_at, "string");
|
|
440
441
|
const scoped = resultData(await call(captured, "notes_list", { glob: "@human/**" }, ctx));
|
|
441
442
|
assert.deepEqual(scoped.files.map((file) => file.address), ["@human/three.md"], "an address glob filter narrows the set");
|
|
442
443
|
const searched = resultData(await call(captured, "notes_search", { query: "needle" }, ctx));
|
|
@@ -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",
|
|
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 }));
|
|
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",
|
|
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 }));
|
|
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/docs/tool-results.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The seven notes/history tools have one business result model. Pi exposes compact results as `structuredContent` to codemode and renders them as `content` for ordinary model calls. Claude uses the same business handlers and text rendering. Neither host re-runs a query, truncates a different page, or parses formatted text to recover data.
|
|
4
4
|
|
|
5
|
-
This is a breaking tool protocol change: successes no longer have `ok/data` wrappers, errors are flat, and read fields no longer sit under `window`. History execution details live once in the pageable document. Stored notes and raw Pi session entries are not deleted or rewritten by this change. `
|
|
5
|
+
This is a breaking tool protocol change: successes no longer have `ok/data` wrappers, errors are flat, and read fields no longer sit under `window`. History execution details live once in the pageable document. Stored notes and raw Pi session entries are not deleted or rewritten by this change. In Pi, `get_context_remaining` independently declares `{ remaining_tokens }` as its output schema; `empty_brain` remains outside this protocol.
|
|
6
6
|
|
|
7
7
|
## Results
|
|
8
8
|
|
|
@@ -38,7 +38,7 @@ Both read operations return these fields at the result root, alongside identity
|
|
|
38
38
|
|
|
39
39
|
Positions count Unicode code points, not UTF-16 units or UTF-8 bytes. The returned text is a contiguous unmodified prefix of the requested range, without ellipsis markers. `next_offset_chars` names the first undelivered character, or is null at the true end. A negative input offset selects a tail; the delivered window does not echo the offset it resolved.
|
|
40
40
|
|
|
41
|
-
- `notes_read`: `address`, optional `project_key`, and `metadata` accompany the text fields. Positions address only the note **body**. Access counts and last-access times remain stored
|
|
41
|
+
- `notes_read`: `address`, optional `project_key`, and `metadata` accompany the text fields. Positions address only the note **body**. Access counts and last-access times remain stored; only `dream_begin` rows report last access.
|
|
42
42
|
- `history_read`: `seq`, `role`, `created_at`, and a tool summary accompany the text fields. Explicit session targeting also carries canonical `session`. Positions address one deterministic document derived from the event's facts. Query matches address that same document, not its decorated presentation.
|
|
43
43
|
|
|
44
44
|
Repeated note reads observe the current file; this is not a retained snapshot service. A concurrent body edit can change positions. History reflects the active branch and recorded facts, including a result that may arrive after a pending call was first observed.
|
package/package.json
CHANGED
package/playbook.md
CHANGED
|
@@ -22,7 +22,7 @@ Durable notes hold decisions, constraints, and lessons that stay true after the
|
|
|
22
22
|
|
|
23
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
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.
|
|
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. `dream_begin` lists each note's last access; reads during a dream leave no stamp, so reviewing a note does not make it look fresh.
|
|
26
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
27
|
5. **Relocate misfiled notes.** When a standing ruling or the note's own MAP already names its proper notebook, move it there, preserving its metadata, and update both notebooks' maps. Do it, don't propose it. Propose only when the destination notebook itself is unclear.
|
|
28
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.
|
|
@@ -8601,10 +8601,10 @@ function createNotesStore(input) {
|
|
|
8601
8601
|
if (raw === void 0) return void 0;
|
|
8602
8602
|
const now = Date.now();
|
|
8603
8603
|
const parsed = parseNote(raw, now);
|
|
8604
|
-
if (identity2.dreaming !== void 0 || (scope === "project" || scope === "session") && destination.who !== void 0) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope
|
|
8604
|
+
if (identity2.dreaming !== void 0 || (scope === "project" || scope === "session") && destination.who !== void 0) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope };
|
|
8605
8605
|
const meta = { ...parsed.meta, scope, lastAccessed: now, accessCount: (typeof parsed.meta.accessCount === "number" ? parsed.meta.accessCount : 0) + 1 };
|
|
8606
8606
|
await atomicWrite(path, serializeNote(meta, parsed.body));
|
|
8607
|
-
return { meta, body: parsed.body, resolvedScope: scope
|
|
8607
|
+
return { meta, body: parsed.body, resolvedScope: scope };
|
|
8608
8608
|
});
|
|
8609
8609
|
}
|
|
8610
8610
|
async function update(address, edits, options = {}) {
|
|
@@ -9102,7 +9102,6 @@ var NoteMetadataSchema = typebox_exports.Object({
|
|
|
9102
9102
|
origin: typebox_exports.Union([...ORIGIN_VALUES]),
|
|
9103
9103
|
created_at: typebox_exports.String(),
|
|
9104
9104
|
updated_at: typebox_exports.String(),
|
|
9105
|
-
last_accessed: typebox_exports.String(),
|
|
9106
9105
|
crumpled_at: typebox_exports.Optional(typebox_exports.String()),
|
|
9107
9106
|
project: typebox_exports.Optional(typebox_exports.String()),
|
|
9108
9107
|
extra: typebox_exports.Record(typebox_exports.String(), typebox_exports.Unknown())
|
|
@@ -9128,7 +9127,6 @@ function noteMetadata(meta) {
|
|
|
9128
9127
|
origin: meta.origin,
|
|
9129
9128
|
created_at: localIso(meta.createdAt),
|
|
9130
9129
|
updated_at: localIso(meta.updatedAt),
|
|
9131
|
-
last_accessed: localIso(meta.lastAccessed),
|
|
9132
9130
|
...typeof meta.crumpledAt === "string" ? { crumpled_at: meta.crumpledAt } : {},
|
|
9133
9131
|
...typeof meta.project === "string" ? { project: meta.project } : {},
|
|
9134
9132
|
extra
|
|
@@ -9139,7 +9137,6 @@ function renderMetadata(metadata) {
|
|
|
9139
9137
|
`origin ${metadata.origin}`,
|
|
9140
9138
|
`created ${metadata.created_at}`,
|
|
9141
9139
|
`updated ${metadata.updated_at}`,
|
|
9142
|
-
`accessed ${metadata.last_accessed}`,
|
|
9143
9140
|
...metadata.crumpled_at === void 0 ? [] : [`crumpled ${metadata.crumpled_at}`],
|
|
9144
9141
|
...metadata.project === void 0 ? [] : [`project ${metadata.project}`]
|
|
9145
9142
|
];
|
|
@@ -9166,7 +9163,6 @@ var NoteIdentitySchema = {
|
|
|
9166
9163
|
var ListedFileSchema = typebox_exports.Object({
|
|
9167
9164
|
...NoteIdentitySchema,
|
|
9168
9165
|
updated_at: typebox_exports.String(),
|
|
9169
|
-
last_accessed: typebox_exports.String(),
|
|
9170
9166
|
crumpled_at: typebox_exports.Optional(typebox_exports.String())
|
|
9171
9167
|
}, { additionalProperties: false });
|
|
9172
9168
|
var MatchSchema = typebox_exports.Object({
|
|
@@ -9180,7 +9176,7 @@ var SearchedFileSchema = typebox_exports.Object({
|
|
|
9180
9176
|
}, { additionalProperties: false });
|
|
9181
9177
|
var SnapshotSchema = {
|
|
9182
9178
|
more: typebox_exports.Integer({ description: "How many more were left out." }),
|
|
9183
|
-
namespaces_unavailable: typebox_exports.Array(typebox_exports.String())
|
|
9179
|
+
namespaces_unavailable: typebox_exports.Array(typebox_exports.String(), { description: "Unreadable notebooks or notes." })
|
|
9184
9180
|
};
|
|
9185
9181
|
var NotesWriteDataSchema = typebox_exports.Object({
|
|
9186
9182
|
...NoteIdentitySchema,
|
|
@@ -9225,7 +9221,7 @@ function snapshot(rows, limit, status, renderData, shrink) {
|
|
|
9225
9221
|
return fitsResult(outcome, render) ? outcome : failure("output_too_large", `The list of unreachable notebooks is itself over ${TOOL_OUTPUT_LIMIT}; narrow \`glob\` to fewer notebooks.`);
|
|
9226
9222
|
}
|
|
9227
9223
|
function listedFile(row, identity2) {
|
|
9228
|
-
return { ...noteIdentity(identity2, row.address), updated_at: localIso(row.meta.updatedAt),
|
|
9224
|
+
return { ...noteIdentity(identity2, row.address), updated_at: localIso(row.meta.updatedAt), ...row.meta.crumpledAt === void 0 ? {} : { crumpled_at: row.meta.crumpledAt } };
|
|
9229
9225
|
}
|
|
9230
9226
|
var notesWriteParameters = typebox_exports.Object({ address: typebox_exports.String(), content: typebox_exports.String(), origin: ORIGIN, cwd: CWD_PARAMETER }, { additionalProperties: false });
|
|
9231
9227
|
function renderWriteData(data) {
|
|
@@ -9305,7 +9301,7 @@ var notesRead = {
|
|
|
9305
9301
|
if (!note) return failure("not_found", `No note at ${resolved.address}.`);
|
|
9306
9302
|
const totalChars = Array.from(note.body).length;
|
|
9307
9303
|
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.`);
|
|
9308
|
-
const metadata = noteMetadata(
|
|
9304
|
+
const metadata = noteMetadata(note.meta);
|
|
9309
9305
|
return readTextWindow(note.body, params.offset_chars, params.max_chars, (window) => ({ ...resolved, metadata, ...window }), (result) => renderOutcome(result, renderReadData));
|
|
9310
9306
|
} catch (error) {
|
|
9311
9307
|
return failureOf(error);
|
|
@@ -9317,7 +9313,7 @@ var notesListParameters = typebox_exports.Object({ glob: GLOB_PARAMETER, limit:
|
|
|
9317
9313
|
function renderListData(data) {
|
|
9318
9314
|
const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
|
|
9319
9315
|
for (const file of data.files) {
|
|
9320
|
-
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at} | accessed ${file.last_accessed}${file.crumpled_at === void 0 ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
9316
|
+
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at}${file.last_accessed === void 0 ? "" : ` | accessed ${file.last_accessed}`}${file.crumpled_at === void 0 ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
9321
9317
|
}
|
|
9322
9318
|
if (data.more > 0) lines.push(`${data.more} more matching notes omitted; narrow with glob`);
|
|
9323
9319
|
for (const namespace of data.namespaces_unavailable) lines.push(`${namespace} could not be read`);
|
|
@@ -9418,8 +9414,8 @@ var HistoryNewerSchema = typebox_exports.Object({
|
|
|
9418
9414
|
var HistoryPageSchema = typebox_exports.Object({
|
|
9419
9415
|
notice: typebox_exports.Optional(typebox_exports.String()),
|
|
9420
9416
|
items: typebox_exports.Array(typebox_exports.Union([HistoryPageItemSchema, HistoryFoldedRowSchema])),
|
|
9421
|
-
page_older: typebox_exports.Union([HistoryOlderSchema, typebox_exports.Null()]),
|
|
9422
|
-
page_newer: typebox_exports.Union([HistoryNewerSchema, typebox_exports.Null()])
|
|
9417
|
+
page_older: typebox_exports.Union([HistoryOlderSchema, typebox_exports.Null()], { description: "Args to merge into `history_list` for older events." }),
|
|
9418
|
+
page_newer: typebox_exports.Union([HistoryNewerSchema, typebox_exports.Null()], { description: "Args to merge into `history_list` for newer events." })
|
|
9423
9419
|
}, { additionalProperties: false });
|
|
9424
9420
|
function truncateHistoryItem(item, fits) {
|
|
9425
9421
|
if (fits(item)) return item;
|
|
@@ -22,7 +22,7 @@ Durable notes hold decisions, constraints, and lessons that stay true after the
|
|
|
22
22
|
|
|
23
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
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.
|
|
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. `dream_begin` lists each note's last access; reads during a dream leave no stamp, so reviewing a note does not make it look fresh.
|
|
26
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
27
|
5. **Relocate misfiled notes.** When a standing ruling or the note's own MAP already names its proper notebook, move it there, preserving its metadata, and update both notebooks' maps. Do it, don't propose it. Propose only when the destination notebook itself is unclear.
|
|
28
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.
|
|
@@ -25576,10 +25576,10 @@ function createNotesStore(input) {
|
|
|
25576
25576
|
if (raw === void 0) return void 0;
|
|
25577
25577
|
const now = Date.now();
|
|
25578
25578
|
const parsed = parseNote(raw, now);
|
|
25579
|
-
if (identity.dreaming !== void 0 || (scope === "project" || scope === "session") && destination.who !== void 0) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope
|
|
25579
|
+
if (identity.dreaming !== void 0 || (scope === "project" || scope === "session") && destination.who !== void 0) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope };
|
|
25580
25580
|
const meta2 = { ...parsed.meta, scope, lastAccessed: now, accessCount: (typeof parsed.meta.accessCount === "number" ? parsed.meta.accessCount : 0) + 1 };
|
|
25581
25581
|
await atomicWrite(path, serializeNote(meta2, parsed.body));
|
|
25582
|
-
return { meta: meta2, body: parsed.body, resolvedScope: scope
|
|
25582
|
+
return { meta: meta2, body: parsed.body, resolvedScope: scope };
|
|
25583
25583
|
});
|
|
25584
25584
|
}
|
|
25585
25585
|
async function update(address, edits, options = {}) {
|
|
@@ -26077,7 +26077,6 @@ var NoteMetadataSchema = typebox_exports.Object({
|
|
|
26077
26077
|
origin: typebox_exports.Union([...ORIGIN_VALUES]),
|
|
26078
26078
|
created_at: typebox_exports.String(),
|
|
26079
26079
|
updated_at: typebox_exports.String(),
|
|
26080
|
-
last_accessed: typebox_exports.String(),
|
|
26081
26080
|
crumpled_at: typebox_exports.Optional(typebox_exports.String()),
|
|
26082
26081
|
project: typebox_exports.Optional(typebox_exports.String()),
|
|
26083
26082
|
extra: typebox_exports.Record(typebox_exports.String(), typebox_exports.Unknown())
|
|
@@ -26103,7 +26102,6 @@ function noteMetadata(meta2) {
|
|
|
26103
26102
|
origin: meta2.origin,
|
|
26104
26103
|
created_at: localIso(meta2.createdAt),
|
|
26105
26104
|
updated_at: localIso(meta2.updatedAt),
|
|
26106
|
-
last_accessed: localIso(meta2.lastAccessed),
|
|
26107
26105
|
...typeof meta2.crumpledAt === "string" ? { crumpled_at: meta2.crumpledAt } : {},
|
|
26108
26106
|
...typeof meta2.project === "string" ? { project: meta2.project } : {},
|
|
26109
26107
|
extra
|
|
@@ -26114,7 +26112,6 @@ function renderMetadata(metadata) {
|
|
|
26114
26112
|
`origin ${metadata.origin}`,
|
|
26115
26113
|
`created ${metadata.created_at}`,
|
|
26116
26114
|
`updated ${metadata.updated_at}`,
|
|
26117
|
-
`accessed ${metadata.last_accessed}`,
|
|
26118
26115
|
...metadata.crumpled_at === void 0 ? [] : [`crumpled ${metadata.crumpled_at}`],
|
|
26119
26116
|
...metadata.project === void 0 ? [] : [`project ${metadata.project}`]
|
|
26120
26117
|
];
|
|
@@ -26141,7 +26138,6 @@ var NoteIdentitySchema = {
|
|
|
26141
26138
|
var ListedFileSchema = typebox_exports.Object({
|
|
26142
26139
|
...NoteIdentitySchema,
|
|
26143
26140
|
updated_at: typebox_exports.String(),
|
|
26144
|
-
last_accessed: typebox_exports.String(),
|
|
26145
26141
|
crumpled_at: typebox_exports.Optional(typebox_exports.String())
|
|
26146
26142
|
}, { additionalProperties: false });
|
|
26147
26143
|
var MatchSchema = typebox_exports.Object({
|
|
@@ -26155,7 +26151,7 @@ var SearchedFileSchema = typebox_exports.Object({
|
|
|
26155
26151
|
}, { additionalProperties: false });
|
|
26156
26152
|
var SnapshotSchema = {
|
|
26157
26153
|
more: typebox_exports.Integer({ description: "How many more were left out." }),
|
|
26158
|
-
namespaces_unavailable: typebox_exports.Array(typebox_exports.String())
|
|
26154
|
+
namespaces_unavailable: typebox_exports.Array(typebox_exports.String(), { description: "Unreadable notebooks or notes." })
|
|
26159
26155
|
};
|
|
26160
26156
|
var NotesWriteDataSchema = typebox_exports.Object({
|
|
26161
26157
|
...NoteIdentitySchema,
|
|
@@ -26200,7 +26196,7 @@ function snapshot(rows, limit, status, renderData, shrink) {
|
|
|
26200
26196
|
return fitsResult(outcome, render) ? outcome : failure2("output_too_large", `The list of unreachable notebooks is itself over ${TOOL_OUTPUT_LIMIT}; narrow \`glob\` to fewer notebooks.`);
|
|
26201
26197
|
}
|
|
26202
26198
|
function listedFile(row, identity) {
|
|
26203
|
-
return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt),
|
|
26199
|
+
return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt), ...row.meta.crumpledAt === void 0 ? {} : { crumpled_at: row.meta.crumpledAt } };
|
|
26204
26200
|
}
|
|
26205
26201
|
var notesWriteParameters = typebox_exports.Object({ address: typebox_exports.String(), content: typebox_exports.String(), origin: ORIGIN, cwd: CWD_PARAMETER }, { additionalProperties: false });
|
|
26206
26202
|
function renderWriteData(data) {
|
|
@@ -26280,7 +26276,7 @@ var notesRead = {
|
|
|
26280
26276
|
if (!note) return failure2("not_found", `No note at ${resolved.address}.`);
|
|
26281
26277
|
const totalChars = Array.from(note.body).length;
|
|
26282
26278
|
if (params.offset_chars !== void 0 && params.offset_chars > totalChars) return failure2("invalid_offset", `This note ends at char ${totalChars}; offset_chars ${params.offset_chars} is past the last word.`);
|
|
26283
|
-
const metadata = noteMetadata(
|
|
26279
|
+
const metadata = noteMetadata(note.meta);
|
|
26284
26280
|
return readTextWindow(note.body, params.offset_chars, params.max_chars, (window) => ({ ...resolved, metadata, ...window }), (result) => renderOutcome(result, renderReadData));
|
|
26285
26281
|
} catch (error2) {
|
|
26286
26282
|
return failureOf(error2);
|
|
@@ -26292,7 +26288,7 @@ var notesListParameters = typebox_exports.Object({ glob: GLOB_PARAMETER, limit:
|
|
|
26292
26288
|
function renderListData(data) {
|
|
26293
26289
|
const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
|
|
26294
26290
|
for (const file of data.files) {
|
|
26295
|
-
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at} | accessed ${file.last_accessed}${file.crumpled_at === void 0 ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
26291
|
+
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at}${file.last_accessed === void 0 ? "" : ` | accessed ${file.last_accessed}`}${file.crumpled_at === void 0 ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
26296
26292
|
}
|
|
26297
26293
|
if (data.more > 0) lines.push(`${data.more} more matching notes omitted; narrow with glob`);
|
|
26298
26294
|
for (const namespace of data.namespaces_unavailable) lines.push(`${namespace} could not be read`);
|
|
@@ -26393,8 +26389,8 @@ var HistoryNewerSchema = typebox_exports.Object({
|
|
|
26393
26389
|
var HistoryPageSchema = typebox_exports.Object({
|
|
26394
26390
|
notice: typebox_exports.Optional(typebox_exports.String()),
|
|
26395
26391
|
items: typebox_exports.Array(typebox_exports.Union([HistoryPageItemSchema, HistoryFoldedRowSchema])),
|
|
26396
|
-
page_older: typebox_exports.Union([HistoryOlderSchema, typebox_exports.Null()]),
|
|
26397
|
-
page_newer: typebox_exports.Union([HistoryNewerSchema, typebox_exports.Null()])
|
|
26392
|
+
page_older: typebox_exports.Union([HistoryOlderSchema, typebox_exports.Null()], { description: "Args to merge into `history_list` for older events." }),
|
|
26393
|
+
page_newer: typebox_exports.Union([HistoryNewerSchema, typebox_exports.Null()], { description: "Args to merge into `history_list` for newer events." })
|
|
26398
26394
|
}, { additionalProperties: false });
|
|
26399
26395
|
function truncateHistoryItem(item, fits) {
|
|
26400
26396
|
if (fits(item)) return item;
|
|
@@ -8,7 +8,7 @@ Notes cards start collapsed; update cards also show the sentence just added. The
|
|
|
8
8
|
|
|
9
9
|
Notes cards use the same projection for Pi live events and replayed history; Claude supplies its receipt text under the adapter's `output` field and its edits under `input.edits`. The UI does not depend on Pi's live-only `structuredContent`. Failed calls also read the adapter's error content (string or text blocks) or transport message when no result is available.
|
|
10
10
|
|
|
11
|
-
`empty_brain` (including `mcp__notesoup__empty_brain`) becomes a divider for running, completed and failed calls. Pi's JSON rollover outcomes are preserved. Claude's plain acknowledgement only completes the tool call; it does not invent a Pi outcome or assert that the deferred reset has committed.
|
|
11
|
+
`empty_brain` (including `mcp__notesoup__empty_brain`) becomes a divider for running, completed and failed calls. Pi's JSON rollover outcomes are preserved. A successful `brain emptied` divider with a `last_word` argument opens a selectable last-word modal when clicked. Claude's plain acknowledgement only completes the tool call; it does not invent a Pi outcome or assert that the deferred reset has committed.
|
|
12
12
|
|
|
13
13
|
Automated tests check transformer payloads with source-derived adapter fixtures, not a live Paseo UI session.
|
|
14
14
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PluginTimelineItemProps } from "@getpaseo/plugin/client";
|
|
2
|
-
import {
|
|
2
|
+
import { Modal } from "@getpaseo/plugin/client/react-native";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Pressable, Text, View } from "react-native";
|
|
3
5
|
import type { BrainEmpty } from "../shared/brain-empty.ts";
|
|
4
6
|
|
|
5
7
|
function label(data: BrainEmpty): string {
|
|
@@ -23,18 +25,35 @@ function CutLine({ color }: { color: string }) {
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export function BrainEmptyDivider({ item, theme }: PluginTimelineItemProps<BrainEmpty>) {
|
|
28
|
+
const [lastWordOpen, setLastWordOpen] = useState(false);
|
|
26
29
|
const data = item.data;
|
|
27
30
|
const refused = data.error !== undefined || data.status === "failed";
|
|
28
31
|
const color = refused ? theme.colors.statusDanger : theme.colors.foregroundMuted;
|
|
32
|
+
const hasLastWord = data.outcome === "rollover_requested" && data.lastWord !== undefined;
|
|
29
33
|
return (
|
|
30
|
-
<View style={{ paddingVertical: 6
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
<View style={{ paddingVertical: 6 }}>
|
|
35
|
+
<Pressable
|
|
36
|
+
accessibilityRole={hasLastWord ? "button" : undefined}
|
|
37
|
+
accessibilityLabel={hasLastWord ? "Show last word" : undefined}
|
|
38
|
+
disabled={!hasLastWord}
|
|
39
|
+
onPress={hasLastWord ? () => setLastWordOpen(true) : undefined}
|
|
40
|
+
style={({ pressed }) => ({ gap: 3, opacity: pressed ? 0.7 : 1 })}
|
|
41
|
+
>
|
|
42
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 10 }}>
|
|
43
|
+
<CutLine color={color} />
|
|
44
|
+
<Text style={{ color, fontSize: 11.5, letterSpacing: 0.3 }}>{label(data)}</Text>
|
|
45
|
+
<CutLine color={color} />
|
|
46
|
+
</View>
|
|
47
|
+
{data.error !== undefined && (
|
|
48
|
+
<Text selectable style={{ color: theme.colors.statusDanger, fontSize: 12, textAlign: "center" }}>{data.error}</Text>
|
|
49
|
+
)}
|
|
50
|
+
</Pressable>
|
|
51
|
+
{hasLastWord && (
|
|
52
|
+
<Modal title="Last word" open={lastWordOpen} onOpenChange={setLastWordOpen}>
|
|
53
|
+
<Modal.Content style={{ backgroundColor: theme.colors.surface2 }}>
|
|
54
|
+
<Text selectable style={{ color: theme.colors.foreground, fontSize: 14, lineHeight: 21 }}>{data.lastWord}</Text>
|
|
55
|
+
</Modal.Content>
|
|
56
|
+
</Modal>
|
|
38
57
|
)}
|
|
39
58
|
</View>
|
|
40
59
|
);
|
|
@@ -20,11 +20,15 @@ function resultJson(output: unknown): Record<string, unknown> | undefined {
|
|
|
20
20
|
|
|
21
21
|
function brainEmptyData(item: ToolCallItem): BrainEmpty | undefined {
|
|
22
22
|
if (item.detail.type !== "unknown") return undefined;
|
|
23
|
+
const input = isRecord(item.detail.input) ? item.detail.input : undefined;
|
|
24
|
+
const rawLastWord = input?.last_word;
|
|
25
|
+
const lastWord = typeof rawLastWord === "string" ? rawLastWord.trim() : "";
|
|
26
|
+
const base = lastWord ? { lastWord } : {};
|
|
23
27
|
if (item.status === "running") return { status: "running" };
|
|
24
28
|
const wire = resultJson(item.detail.output);
|
|
25
29
|
if (wire && typeof wire.error === "string") return { status: item.status === "failed" ? "failed" : "completed", error: wire.error };
|
|
26
30
|
if (item.status === "failed") return { status: "failed", error: resultError(item.detail.output, item.error) };
|
|
27
|
-
if (wire && typeof wire.status === "string") return { status: "completed", outcome: wire.status };
|
|
31
|
+
if (wire && typeof wire.status === "string") return { status: "completed", outcome: wire.status, ...(wire.status === "rollover_requested" ? base : {}) };
|
|
28
32
|
return { status: "completed" };
|
|
29
33
|
}
|
|
30
34
|
|
|
@@ -15,25 +15,25 @@ type Styles = {
|
|
|
15
15
|
|
|
16
16
|
function markdownStyles(paper: PaperPalette): Styles {
|
|
17
17
|
return {
|
|
18
|
-
block: { gap:
|
|
19
|
-
text: { color: paper.ink, fontSize:
|
|
20
|
-
muted: { color: paper.inkMuted, fontSize:
|
|
21
|
-
strong: { fontWeight: "
|
|
18
|
+
block: { gap: 8 },
|
|
19
|
+
text: { color: paper.ink, fontSize: 12, lineHeight: 19 },
|
|
20
|
+
muted: { color: paper.inkMuted, fontSize: 12, lineHeight: 19 },
|
|
21
|
+
strong: { fontWeight: "600" },
|
|
22
22
|
em: { color: paper.inkMuted, fontStyle: "italic" },
|
|
23
23
|
del: { color: paper.inkMuted, textDecorationLine: "line-through" },
|
|
24
|
-
codespan: { fontFamily: MONO },
|
|
24
|
+
codespan: { fontFamily: MONO, fontSize: 12, backgroundColor: paper.crumpled },
|
|
25
25
|
link: { color: paper.added, textDecorationLine: "underline" },
|
|
26
|
-
heading: { fontWeight: "
|
|
27
|
-
quote: { borderLeftWidth: 2, borderLeftColor: paper.edge, paddingLeft:
|
|
28
|
-
quoteText: { color: paper.inkMuted, fontSize:
|
|
26
|
+
heading: { fontWeight: "600" },
|
|
27
|
+
quote: { borderLeftWidth: 2, borderLeftColor: paper.edge, paddingLeft: 10, gap: 4, marginTop: 4 },
|
|
28
|
+
quoteText: { color: paper.inkMuted, fontSize: 12, lineHeight: 19 },
|
|
29
29
|
code: {
|
|
30
|
-
fontFamily: MONO, fontSize:
|
|
30
|
+
fontFamily: MONO, fontSize: 12, lineHeight: 18, color: paper.ink,
|
|
31
31
|
backgroundColor: paper.crumpled, borderRadius: 3, paddingVertical: 6, paddingHorizontal: 8,
|
|
32
32
|
},
|
|
33
33
|
hr: { height: StyleSheet.hairlineWidth, backgroundColor: paper.edge },
|
|
34
|
-
list: { gap:
|
|
35
|
-
listItem: { flexDirection: "row"
|
|
36
|
-
marker: { color: paper.inkMuted, minWidth: 14 },
|
|
34
|
+
list: { gap: 8 },
|
|
35
|
+
listItem: { flexDirection: "row" },
|
|
36
|
+
marker: { color: paper.inkMuted, minWidth: 14, paddingRight: 4 },
|
|
37
37
|
table: { gap: 2 },
|
|
38
38
|
tableRow: { flexDirection: "row", gap: 8 },
|
|
39
39
|
tableCell: { flex: 1 },
|
|
@@ -93,7 +93,8 @@ function renderBlocks(tokens: Token[] | undefined, styles: Styles, keyPrefix: st
|
|
|
93
93
|
case "code":
|
|
94
94
|
return <Text key={key} selectable style={styles.code}>{token.text}</Text>;
|
|
95
95
|
case "heading":
|
|
96
|
-
return <Text key={key} selectable style={[textStyle, styles.heading
|
|
96
|
+
return <Text key={key} selectable style={[textStyle, styles.heading,
|
|
97
|
+
{ marginTop: index === 0 ? 2 : token.depth === 1 ? 2 : 6 }]}>{renderInlines(token.tokens, styles, key)}</Text>;
|
|
97
98
|
case "blockquote":
|
|
98
99
|
return <View key={key} style={styles.quote}>{renderBlocks(token.tokens, styles, key, styles.quoteText)}</View>;
|
|
99
100
|
case "list": {
|
|
@@ -51,10 +51,10 @@ export function NotesOpCard({ item, layout, theme }: PluginTimelineItemProps<Not
|
|
|
51
51
|
style={({ pressed }) => ({ gap: 4, opacity: pressed && hasBody ? 0.7 : 1 })}
|
|
52
52
|
>
|
|
53
53
|
<View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
54
|
-
<Text style={{ color: paper.inkMuted, fontSize:
|
|
54
|
+
<Text style={{ color: paper.inkMuted, fontSize: 12 }}>
|
|
55
55
|
{data.crumpled ? "crumpled" : title}{data.status === "running" ? " …" : ""}
|
|
56
56
|
</Text>
|
|
57
|
-
<Text numberOfLines={1} style={{ color: data.crumpled ? paper.inkMuted : paper.ink, fontSize:
|
|
57
|
+
<Text numberOfLines={1} style={{ color: data.crumpled ? paper.inkMuted : paper.ink, fontSize: 12, flex: 1, textDecorationLine: data.crumpled ? "line-through" : "none" }}>
|
|
58
58
|
{data.address}
|
|
59
59
|
</Text>
|
|
60
60
|
{hasBody && <Icon name={expanded ? "ChevronUp" : "ChevronDown"} size={16} color={paper.inkMuted} />}
|
|
@@ -67,14 +67,14 @@ export function NotesOpCard({ item, layout, theme }: PluginTimelineItemProps<Not
|
|
|
67
67
|
numberOfLines={2}
|
|
68
68
|
/>
|
|
69
69
|
)}
|
|
70
|
-
{data.error !== undefined && <Text selectable style={{ color: paper.removed, fontSize:
|
|
70
|
+
{data.error !== undefined && <Text selectable style={{ color: paper.removed, fontSize: 12, lineHeight: 18 }}>{data.error}</Text>}
|
|
71
71
|
</Pressable>
|
|
72
72
|
{expanded && hasBody && (
|
|
73
73
|
<ScrollView style={{ maxHeight: layout.compact ? 280 : 400, marginTop: 2, borderTopWidth: 1, borderTopColor: paper.edge }} contentContainerStyle={{ gap: 5, paddingTop: 8 }} nestedScrollEnabled>
|
|
74
74
|
{data.text !== undefined && <NoteMarkdown text={outputPreview(data.text)} paper={paper} />}
|
|
75
|
-
{data.preview !== undefined && <NoteMarkdown text={outputPreview(data.preview)} paper={paper}
|
|
75
|
+
{data.preview !== undefined && <NoteMarkdown text={outputPreview(data.preview)} paper={paper} />}
|
|
76
76
|
{data.diff !== undefined && <DiffBody diff={outputPreview(data.diff)} paper={paper} />}
|
|
77
|
-
{data.renamedFrom !== undefined && <Text style={{ color: paper.inkMuted, fontSize:
|
|
77
|
+
{data.renamedFrom !== undefined && <Text style={{ color: paper.inkMuted, fontSize: 12 }}>renamed from {data.renamedFrom}</Text>}
|
|
78
78
|
</ScrollView>
|
|
79
79
|
)}
|
|
80
80
|
</PaperCard>
|
|
@@ -25,13 +25,15 @@ export function PaperCard({ paper, compact, crumpled = false, children }: {
|
|
|
25
25
|
<Tape paper={paper} />
|
|
26
26
|
<View style={{
|
|
27
27
|
paddingVertical: compact ? 8 : 9,
|
|
28
|
-
paddingHorizontal:
|
|
29
|
-
gap:
|
|
28
|
+
paddingHorizontal: 12,
|
|
29
|
+
gap: 6,
|
|
30
30
|
minWidth: 0,
|
|
31
|
-
borderRadius:
|
|
31
|
+
borderRadius: 4,
|
|
32
32
|
borderWidth: StyleSheet.hairlineWidth,
|
|
33
33
|
borderColor: paper.edge,
|
|
34
34
|
backgroundColor: crumpled ? paper.crumpled : paper.background,
|
|
35
|
+
position: "relative",
|
|
36
|
+
overflow: "hidden",
|
|
35
37
|
}}>
|
|
36
38
|
{children}
|
|
37
39
|
</View>
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
import type { PluginTheme } from "@getpaseo/plugin";
|
|
2
2
|
|
|
3
3
|
const LIGHT_PAPER = {
|
|
4
|
-
background: "#
|
|
5
|
-
edge: "#
|
|
4
|
+
background: "#faf7f0",
|
|
5
|
+
edge: "#e2d9c8",
|
|
6
|
+
ink: "#26221b",
|
|
7
|
+
inkMuted: "#827866",
|
|
8
|
+
added: "#2b6e3c",
|
|
9
|
+
removed: "#ad3e34",
|
|
10
|
+
crumpled: "#efeae0",
|
|
6
11
|
tape: "rgba(224, 206, 148, 0.62)",
|
|
7
12
|
tapeEdge: "rgba(165, 145, 86, 0.16)",
|
|
8
|
-
ink: "#2c281e",
|
|
9
|
-
inkMuted: "#7d735d",
|
|
10
|
-
added: "#2f743e",
|
|
11
|
-
removed: "#b3463b",
|
|
12
|
-
crumpled: "#f1ead8",
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export type PaperPalette = typeof LIGHT_PAPER;
|
|
16
16
|
|
|
17
17
|
const DARK_PAPER: PaperPalette = {
|
|
18
|
+
// Manila tape, not orange-brown: hue held near 50°, never the 30–40° brown that reads red.
|
|
18
19
|
background: "#26231d",
|
|
19
20
|
edge: "#463f31",
|
|
20
|
-
tape: "rgba(182, 160, 104, 0.38)",
|
|
21
|
-
tapeEdge: "rgba(218, 195, 134, 0.16)",
|
|
22
21
|
ink: "#ece5d5",
|
|
23
22
|
inkMuted: "#a89e86",
|
|
24
|
-
added: "#
|
|
25
|
-
removed: "#
|
|
23
|
+
added: "#8cbf98",
|
|
24
|
+
removed: "#dc8f80",
|
|
26
25
|
crumpled: "#1e1b16",
|
|
26
|
+
tape: "rgba(182, 160, 104, 0.38)",
|
|
27
|
+
tapeEdge: "rgba(218, 195, 134, 0.16)",
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
/** Paseo theme colors are hex (#RGB, #RRGGBB or #RRGGBBAA). */
|
|
@@ -7,6 +7,7 @@ export const brainEmptySchema = z.object({
|
|
|
7
7
|
status: z.enum(["running", "completed", "failed"]),
|
|
8
8
|
// completed: rollover_requested | rollover_already_pending
|
|
9
9
|
outcome: z.string().optional(),
|
|
10
|
+
lastWord: z.string().optional(),
|
|
10
11
|
error: z.string().optional(),
|
|
11
12
|
});
|
|
12
13
|
export type BrainEmpty = z.infer<typeof brainEmptySchema>;
|
|
@@ -24,6 +24,14 @@ test("a successful call is a completed divider with the rollover outcome", () =>
|
|
|
24
24
|
assert.deepEqual(brainEmptySchema.parse(result!.items[0]!.data), { status: "completed", outcome: "rollover_requested" });
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
+
test("a successful call carries its last word for the divider modal", () => {
|
|
28
|
+
const detail = jsonOut({ status: "rollover_requested" });
|
|
29
|
+
const result = transform({ detail: { ...detail, input: { last_word: " remember the shoe " } } });
|
|
30
|
+
assert.deepEqual(brainEmptySchema.parse(result!.items[0]!.data), {
|
|
31
|
+
status: "completed", outcome: "rollover_requested", lastWord: "remember the shoe",
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
27
35
|
test("an in-flight call shows as running from the call alone", () => {
|
|
28
36
|
const result = transform({ status: "running", detail: { type: "unknown", input: { last_word: "bye" }, output: null } });
|
|
29
37
|
assert.deepEqual(brainEmptySchema.parse(result!.items[0]!.data), { status: "running" });
|
|
@@ -30,8 +30,8 @@ test("paper follows the host theme and preserves the light palette when switchin
|
|
|
30
30
|
const light = theme("#ffffff", "#18181b");
|
|
31
31
|
const dark = theme("#18181b", "#fafafa");
|
|
32
32
|
const paper = paperPalette(light);
|
|
33
|
-
assert.equal(paper.background, "#
|
|
34
|
-
assert.equal(paper.ink, "#
|
|
33
|
+
assert.equal(paper.background, "#faf7f0");
|
|
34
|
+
assert.equal(paper.ink, "#26221b");
|
|
35
35
|
assert.ok(luminance(paperPalette(dark).background) < 0.05);
|
|
36
36
|
assert.notDeepEqual(paperPalette(dark), paper);
|
|
37
37
|
assert.deepEqual(paperPalette(light), paper);
|
|
@@ -41,7 +41,7 @@ test("host hex shorthand and alpha colors select the same dark paper", () => {
|
|
|
41
41
|
const paper = paperPalette(theme("#000000", "#ffffff"));
|
|
42
42
|
assert.deepEqual(paperPalette(theme("#000", "#fff")), paper);
|
|
43
43
|
assert.deepEqual(paperPalette(theme("#000000ff", "#ffffffff")), paper);
|
|
44
|
-
assert.equal(paperPalette(theme("#fff", "#000")).background, "#
|
|
44
|
+
assert.equal(paperPalette(theme("#fff", "#000")).background, "#faf7f0");
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
test("dark text, muted labels, additions and errors remain readable on normal and crumpled paper", () => {
|
package/plugins/pi/budget.ts
CHANGED
|
@@ -10,6 +10,10 @@ import { tokenBudgetGuidance } from "../../src/budget/text.js";
|
|
|
10
10
|
import { arrangeAnchoredReminders, type AnchorDetails } from "./anchored.js";
|
|
11
11
|
import { output } from "./tool-result.js";
|
|
12
12
|
|
|
13
|
+
export const ContextRemainingOutputSchema = Type.Object({
|
|
14
|
+
remaining_tokens: Type.Union([Type.Integer({ minimum: 0 }), Type.Null()]),
|
|
15
|
+
}, { additionalProperties: false });
|
|
16
|
+
|
|
13
17
|
/** Remaining tokens in the provider's active window, or null without a usable estimate. */
|
|
14
18
|
function remainingTokens(ctx: Pick<ExtensionContext, "sessionManager" | "getContextUsage" | "model">): number | null {
|
|
15
19
|
const usage = windowUsage(ctx);
|
|
@@ -122,10 +126,12 @@ export function registerBudget(
|
|
|
122
126
|
label: "Get context remaining",
|
|
123
127
|
description: "Check how much room your brain has left before it gets forcibly emptied. Returns null when unknown.",
|
|
124
128
|
parameters: Type.Object({}, { additionalProperties: false }),
|
|
129
|
+
outputSchema: ContextRemainingOutputSchema,
|
|
125
130
|
async execute(_id, _params, _signal, _update, ctx) {
|
|
126
131
|
// Report room to the hard-reserve wipe, including the warning runway.
|
|
127
132
|
const remaining = remainingTokens(ctx);
|
|
128
|
-
|
|
133
|
+
const value = { remaining_tokens: remainingBudget(remaining, thresholdsFor(ctx as ExtensionContext).reserve) };
|
|
134
|
+
return { ...output(value), structuredContent: value };
|
|
129
135
|
},
|
|
130
136
|
}));
|
|
131
137
|
|
package/src/history/query.ts
CHANGED
|
@@ -50,12 +50,10 @@ function resolveTimeBounds(params: HistorySelection): Outcome<{ sinceMs?: number
|
|
|
50
50
|
return success({ ...(since.data === undefined ? {} : { sinceMs: since.data }), ...(until.data === undefined ? {} : { untilMs: until.data }) });
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/** The params to merge into the previous call to continue toward older events. */
|
|
54
53
|
export const HistoryOlderSchema = Type.Object({
|
|
55
54
|
session: Type.Optional(Type.String()),
|
|
56
55
|
before_seq: Type.Integer({ minimum: 1 }),
|
|
57
56
|
}, { additionalProperties: false });
|
|
58
|
-
/** The params to merge into the previous call to continue toward newer events. */
|
|
59
57
|
export const HistoryNewerSchema = Type.Object({
|
|
60
58
|
session: Type.Optional(Type.String()),
|
|
61
59
|
after_seq: Type.Integer({ minimum: 1 }),
|
|
@@ -65,8 +63,8 @@ export const HistoryNewerSchema = Type.Object({
|
|
|
65
63
|
export const HistoryPageSchema = Type.Object({
|
|
66
64
|
notice: Type.Optional(Type.String()),
|
|
67
65
|
items: Type.Array(Type.Union([HistoryPageItemSchema, HistoryFoldedRowSchema])),
|
|
68
|
-
page_older: Type.Union([HistoryOlderSchema, Type.Null()]),
|
|
69
|
-
page_newer: Type.Union([HistoryNewerSchema, Type.Null()]),
|
|
66
|
+
page_older: Type.Union([HistoryOlderSchema, Type.Null()], { description: "Args to merge into `history_list` for older events." }),
|
|
67
|
+
page_newer: Type.Union([HistoryNewerSchema, Type.Null()], { description: "Args to merge into `history_list` for newer events." }),
|
|
70
68
|
}, { additionalProperties: false });
|
|
71
69
|
|
|
72
70
|
/** One whole page payload, before it becomes an outcome. */
|
package/src/notes/store.ts
CHANGED
|
@@ -33,8 +33,7 @@ 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
|
-
|
|
37
|
-
export type NoteReadResult = { meta: NoteMeta; body: string; resolvedScope: Scope; accessedBefore: number };
|
|
36
|
+
export type NoteReadResult = { meta: NoteMeta; body: string; resolvedScope: Scope };
|
|
38
37
|
export type NoteWriteResult = { meta: NoteMeta; outcome: "created" | "overwrote" | "uncrumpled" };
|
|
39
38
|
export type NoteChange =
|
|
40
39
|
| { kind: "none"; before: ""; after: "" }
|
|
@@ -332,11 +331,11 @@ export function createNotesStore(input: NotesIdentity): NotesStore {
|
|
|
332
331
|
const now = Date.now();
|
|
333
332
|
const parsed = parseNote(raw, now);
|
|
334
333
|
// Named notebooks, and every read during a dream, leave no access stamp.
|
|
335
|
-
if (identity.dreaming !== undefined || ((scope === "project" || scope === "session") && destination.who !== undefined)) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope
|
|
334
|
+
if (identity.dreaming !== undefined || ((scope === "project" || scope === "session") && destination.who !== undefined)) return { meta: { ...parsed.meta, scope }, body: parsed.body, resolvedScope: scope };
|
|
336
335
|
// A read records its own access, exactly as a write records an edit.
|
|
337
336
|
const meta: NoteMeta = { ...parsed.meta, scope, lastAccessed: now, accessCount: (typeof parsed.meta.accessCount === "number" ? parsed.meta.accessCount : 0) + 1 };
|
|
338
337
|
await atomicWrite(path, serializeNote(meta, parsed.body));
|
|
339
|
-
return { meta, body: parsed.body, resolvedScope: scope
|
|
338
|
+
return { meta, body: parsed.body, resolvedScope: scope };
|
|
340
339
|
});
|
|
341
340
|
}
|
|
342
341
|
|
package/src/tools/dream.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/** Dream operations: open one project's notes for consolidation, delete crumpled notes, close. */
|
|
2
2
|
import { Type, type Static } from "typebox";
|
|
3
|
+
import { localIso } from "../notes/frontmatter.js";
|
|
3
4
|
import { createNotesStore, noteIdentity, type NoteRow, type NotesIdentity } from "../notes/index.js";
|
|
4
5
|
import { projectNamespaces } from "../notes/project-namespace.js";
|
|
5
6
|
import { gitCommit } from "../dream/git.js";
|
|
6
7
|
import { acquireDreamLock, dreamLockPath, releaseDreamLock, type DreamLock } from "../dream/lock.js";
|
|
7
8
|
import { failure, renderOutcome, resultSchema, success, type Outcome } from "./result.js";
|
|
8
|
-
import { failureOf, listedFile,
|
|
9
|
+
import { failureOf, listedFile, ListedFileSchema, NoteIdentitySchema, renderListData, snapshot, SnapshotSchema } from "./notes.js";
|
|
9
10
|
|
|
10
11
|
/** The one open dream per session; the host owns where it lives. */
|
|
11
12
|
type DreamOpening = { project: string; lock: DreamLock; generation: number };
|
|
@@ -54,7 +55,11 @@ export const dreamBeginParameters = Type.Object({
|
|
|
54
55
|
project: Type.Optional(Type.String({ description: "(optional, default this project) Project name, as in @projects/<name>/." })),
|
|
55
56
|
}, { additionalProperties: false });
|
|
56
57
|
|
|
57
|
-
export const DreamBeginDataSchema = Type.Object({
|
|
58
|
+
export const DreamBeginDataSchema = Type.Object({
|
|
59
|
+
project: Type.String(), baseline: Type.String(),
|
|
60
|
+
files: Type.Array(Type.Object({ ...ListedFileSchema.properties, last_accessed: Type.String() }, { additionalProperties: false })),
|
|
61
|
+
...SnapshotSchema,
|
|
62
|
+
}, { additionalProperties: false });
|
|
58
63
|
export type DreamBeginData = Static<typeof DreamBeginDataSchema>;
|
|
59
64
|
|
|
60
65
|
function renderBeginData(data: DreamBeginData): string {
|
|
@@ -92,7 +97,7 @@ export const dreamBegin = {
|
|
|
92
97
|
}
|
|
93
98
|
}
|
|
94
99
|
rows.sort((a, b) => b.meta.updatedAt - a.meta.updatedAt || a.address.localeCompare(b.address));
|
|
95
|
-
const listed = snapshot(rows.map(row => listedFile(row, identity)), undefined, { namespacesUnavailable: unavailable }, renderListData);
|
|
100
|
+
const listed = snapshot(rows.map(row => ({ ...listedFile(row, identity), last_accessed: localIso(row.meta.lastAccessed) })), undefined, { namespacesUnavailable: unavailable }, renderListData);
|
|
96
101
|
if (!listed.ok) {
|
|
97
102
|
releaseOpening(state, opening);
|
|
98
103
|
return listed;
|
package/src/tools/notes.ts
CHANGED
|
@@ -44,7 +44,6 @@ export const NoteMetadataSchema = Type.Object({
|
|
|
44
44
|
origin: Type.Union([...ORIGIN_VALUES]),
|
|
45
45
|
created_at: Type.String(),
|
|
46
46
|
updated_at: Type.String(),
|
|
47
|
-
last_accessed: Type.String(),
|
|
48
47
|
crumpled_at: Type.Optional(Type.String()),
|
|
49
48
|
project: Type.Optional(Type.String()),
|
|
50
49
|
extra: Type.Record(Type.String(), Type.Unknown()),
|
|
@@ -76,7 +75,6 @@ function noteMetadata(meta: NoteMeta): NoteMetadata {
|
|
|
76
75
|
origin: meta.origin,
|
|
77
76
|
created_at: localIso(meta.createdAt),
|
|
78
77
|
updated_at: localIso(meta.updatedAt),
|
|
79
|
-
last_accessed: localIso(meta.lastAccessed),
|
|
80
78
|
...(typeof meta.crumpledAt === "string" ? { crumpled_at: meta.crumpledAt } : {}),
|
|
81
79
|
...(typeof meta.project === "string" ? { project: meta.project } : {}),
|
|
82
80
|
extra,
|
|
@@ -88,7 +86,6 @@ function renderMetadata(metadata: NoteMetadata): string {
|
|
|
88
86
|
`origin ${metadata.origin}`,
|
|
89
87
|
`created ${metadata.created_at}`,
|
|
90
88
|
`updated ${metadata.updated_at}`,
|
|
91
|
-
`accessed ${metadata.last_accessed}`,
|
|
92
89
|
...(metadata.crumpled_at === undefined ? [] : [`crumpled ${metadata.crumpled_at}`]),
|
|
93
90
|
...(metadata.project === undefined ? [] : [`project ${metadata.project}`]),
|
|
94
91
|
];
|
|
@@ -118,10 +115,9 @@ export const NoteIdentitySchema = {
|
|
|
118
115
|
...ProjectReceiptSchema,
|
|
119
116
|
};
|
|
120
117
|
|
|
121
|
-
const ListedFileSchema = Type.Object({
|
|
118
|
+
export const ListedFileSchema = Type.Object({
|
|
122
119
|
...NoteIdentitySchema,
|
|
123
120
|
updated_at: Type.String(),
|
|
124
|
-
last_accessed: Type.String(),
|
|
125
121
|
crumpled_at: Type.Optional(Type.String()),
|
|
126
122
|
}, { additionalProperties: false });
|
|
127
123
|
|
|
@@ -136,9 +132,9 @@ const SearchedFileSchema = Type.Object({
|
|
|
136
132
|
matches: Type.Array(MatchSchema),
|
|
137
133
|
}, { additionalProperties: false });
|
|
138
134
|
|
|
139
|
-
const SnapshotSchema = {
|
|
135
|
+
export const SnapshotSchema = {
|
|
140
136
|
more: Type.Integer({ description: "How many more were left out." }),
|
|
141
|
-
namespaces_unavailable: Type.Array(Type.String()),
|
|
137
|
+
namespaces_unavailable: Type.Array(Type.String(), { description: "Unreadable notebooks or notes." }),
|
|
142
138
|
};
|
|
143
139
|
|
|
144
140
|
export const NotesWriteDataSchema = Type.Object({
|
|
@@ -204,7 +200,7 @@ export function snapshot<T extends { address: string }>(
|
|
|
204
200
|
}
|
|
205
201
|
|
|
206
202
|
export function listedFile(row: Pick<NoteRow, "address" | "meta">, identity: NotesIdentity): NotesListData["files"][number] {
|
|
207
|
-
return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt),
|
|
203
|
+
return { ...noteIdentity(identity, row.address), updated_at: localIso(row.meta.updatedAt), ...(row.meta.crumpledAt === undefined ? {} : { crumpled_at: row.meta.crumpledAt }) };
|
|
208
204
|
}
|
|
209
205
|
|
|
210
206
|
export const notesWriteParameters = Type.Object({ address: Type.String(), content: Type.String(), origin: ORIGIN, cwd: CWD_PARAMETER }, { additionalProperties: false });
|
|
@@ -281,8 +277,7 @@ export const notesRead = {
|
|
|
281
277
|
if (!note) return failure("not_found", `No note at ${resolved.address}.`);
|
|
282
278
|
const totalChars = Array.from(note.body).length;
|
|
283
279
|
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.`);
|
|
284
|
-
|
|
285
|
-
const metadata = noteMetadata({ ...note.meta, lastAccessed: note.accessedBefore });
|
|
280
|
+
const metadata = noteMetadata(note.meta);
|
|
286
281
|
return readTextWindow(note.body, params.offset_chars, params.max_chars, (window) => ({ ...resolved, metadata, ...window }), (result) => renderOutcome(result, renderReadData));
|
|
287
282
|
} catch (error) { return failureOf(error); }
|
|
288
283
|
},
|
|
@@ -291,10 +286,10 @@ export const notesRead = {
|
|
|
291
286
|
|
|
292
287
|
export const notesListParameters = Type.Object({ glob: GLOB_PARAMETER, limit: FILE_LIMIT_PARAMETER, crumpled: CRUMPLED_LIST_PARAMETER, cwd: CWD_PARAMETER }, { additionalProperties: false });
|
|
293
288
|
|
|
294
|
-
export function renderListData(data: NotesListData): string {
|
|
289
|
+
export function renderListData(data: Snapshot<NotesListData["files"][number] & { last_accessed?: string }>): string {
|
|
295
290
|
const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
|
|
296
291
|
for (const file of data.files) {
|
|
297
|
-
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at} | accessed ${file.last_accessed}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
292
|
+
lines.push(`- ${renderIdentity(file)} | updated ${file.updated_at}${file.last_accessed === undefined ? "" : ` | accessed ${file.last_accessed}`}${file.crumpled_at === undefined ? "" : ` | crumpled ${file.crumpled_at}`}`);
|
|
298
293
|
}
|
|
299
294
|
if (data.more > 0) lines.push(`${data.more} more matching notes omitted; narrow with glob`);
|
|
300
295
|
for (const namespace of data.namespaces_unavailable) lines.push(`${namespace} could not be read`);
|