notesoup 0.39.0 → 0.41.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.
Files changed (91) hide show
  1. package/README.md +5 -2
  2. package/dist/src/boot/render.js +2 -2
  3. package/dist/src/boot/text.d.ts +0 -4
  4. package/dist/src/boot/text.js +18 -14
  5. package/dist/src/budget/policy.js +1 -1
  6. package/dist/src/budget/text.js +1 -1
  7. package/dist/src/dream/doctor.js +2 -1
  8. package/dist/src/dream/git.js +2 -1
  9. package/dist/src/dream/report.js +3 -2
  10. package/dist/src/error-message.d.ts +2 -0
  11. package/dist/src/error-message.js +4 -0
  12. package/dist/src/history/history.d.ts +23 -18
  13. package/dist/src/history/history.js +37 -20
  14. package/dist/src/history/query.d.ts +37 -49
  15. package/dist/src/history/query.js +114 -56
  16. package/dist/src/notes/store.d.ts +3 -4
  17. package/dist/src/notes/store.js +12 -16
  18. package/dist/src/pi/anchored.d.ts +16 -0
  19. package/dist/src/pi/anchored.js +55 -0
  20. package/dist/src/pi/budget.d.ts +1 -1
  21. package/dist/src/pi/budget.js +33 -28
  22. package/dist/src/pi/dream/cli.js +3 -2
  23. package/dist/src/pi/dream/runner.js +2 -1
  24. package/dist/src/pi/history-tools.d.ts +1 -1
  25. package/dist/src/pi/history-tools.js +2 -3
  26. package/dist/src/pi/reset/lifecycle.d.ts +1 -1
  27. package/dist/src/pi/reset/lifecycle.js +4 -3
  28. package/dist/src/pi/reset/text.d.ts +3 -3
  29. package/dist/src/pi/reset/text.js +2 -2
  30. package/dist/src/pi/runtime.js +12 -15
  31. package/dist/src/pi/thresholds.js +2 -1
  32. package/dist/src/pi/tool-names.d.ts +0 -4
  33. package/dist/src/pi/tool-names.js +0 -4
  34. package/dist/src/tools/history.d.ts +24 -33
  35. package/dist/src/tools/history.js +57 -98
  36. package/dist/src/tools/notes.d.ts +26 -58
  37. package/dist/src/tools/notes.js +85 -103
  38. package/dist/src/tools/result.d.ts +16 -13
  39. package/dist/src/tools/result.js +24 -50
  40. package/dist/src/tools/schema.d.ts +2 -2
  41. package/dist/src/tools/schema.js +3 -3
  42. package/dist/test/agent-loop.test.js +79 -29
  43. package/dist/test/boot.integration.test.js +6 -6
  44. package/dist/test/budget-settings.integration.test.js +9 -8
  45. package/dist/test/claude-mod.test.js +11 -11
  46. package/dist/test/dependencies.test.js +1 -1
  47. package/dist/test/helpers/extension.js +2 -3
  48. package/dist/test/history.integration.test.js +200 -123
  49. package/dist/test/host-neutral.test.js +32 -58
  50. package/dist/test/notes-library.test.js +8 -8
  51. package/dist/test/notes.integration.test.js +75 -57
  52. package/dist/test/notes.test.js +44 -42
  53. package/dist/test/reset-lifecycle.test.js +2 -2
  54. package/docs/architecture.md +3 -3
  55. package/docs/notes-library.md +6 -6
  56. package/docs/tool-results.md +15 -25
  57. package/mods/notesoup/.claude-plugin/plugin.json +1 -1
  58. package/mods/notesoup/dist/claude/helper.js +128 -179
  59. package/mods/notesoup/hooks/register.ts +19 -25
  60. package/mods/notesoup/playbook.md +10 -10
  61. package/mods/notesoup/skills/dream/SKILL.md +1 -1
  62. package/package.json +1 -1
  63. package/playbook.md +10 -10
  64. package/skills/dream/SKILL.md +1 -1
  65. package/skills/memory/SKILL.md +11 -9
  66. package/src/boot/render.ts +2 -2
  67. package/src/boot/text.ts +18 -18
  68. package/src/budget/policy.ts +1 -1
  69. package/src/budget/text.ts +1 -1
  70. package/src/dream/doctor.ts +2 -1
  71. package/src/dream/git.ts +2 -1
  72. package/src/dream/report.ts +3 -2
  73. package/src/error-message.ts +4 -0
  74. package/src/history/history.ts +36 -20
  75. package/src/history/query.ts +130 -55
  76. package/src/notes/store.ts +15 -18
  77. package/src/pi/anchored.ts +62 -0
  78. package/src/pi/budget.ts +27 -26
  79. package/src/pi/dream/cli.ts +3 -2
  80. package/src/pi/dream/runner.ts +2 -1
  81. package/src/pi/history-tools.ts +2 -3
  82. package/src/pi/reset/lifecycle.ts +5 -4
  83. package/src/pi/reset/text.ts +2 -2
  84. package/src/pi/runtime.ts +12 -15
  85. package/src/pi/thresholds.ts +2 -1
  86. package/src/pi/tool-names.ts +0 -4
  87. package/src/tools/history.ts +61 -100
  88. package/src/tools/notes.ts +84 -97
  89. package/src/tools/result.ts +24 -49
  90. package/src/tools/schema.ts +3 -3
  91. package/mods/pi-context/dist/claude/helper.js +0 -9324
@@ -2,8 +2,10 @@ import type { NotesIdentity } from "../notes/identity.js";
2
2
  import { Type, type Static } from "typebox";
3
3
  import { type NoteChange } from "../notes/index.js";
4
4
  import { type Outcome } from "./result.js";
5
- /** One unrecognized entry, and all of them together, are bounded; omissions are counted, never listed. */
5
+ /** One unrecognized entry, and the verbatim extras together, are bounded so `extra` cannot outgrow the read. */
6
6
  export declare const MAX_METADATA_ENTRY_BYTES = 1024;
7
+ /** An extra value that cannot be carried is named in place, never silently dropped. */
8
+ export declare const TOO_LARGE_EXTRA_VALUE = "[omitted: too large]";
7
9
  export declare const NoteMetadataSchema: Type.TObject<{
8
10
  origin: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"self">, Type.TLiteral<"external">]>;
9
11
  created_at: Type.TString;
@@ -11,11 +13,6 @@ export declare const NoteMetadataSchema: Type.TObject<{
11
13
  crumpled_at: Type.TOptional<Type.TString>;
12
14
  project: Type.TOptional<Type.TString>;
13
15
  extra: Type.TRecord<"^.*$", Type.TUnknown>;
14
- /** Values left in the file but too large to show, summarized so the summary cannot grow. */
15
- omitted_extra: Type.TOptional<Type.TObject<{
16
- keys: Type.TInteger;
17
- bytes: Type.TInteger;
18
- }>>;
19
16
  }>;
20
17
  export type NoteMetadata = Static<typeof NoteMetadataSchema>;
21
18
  export declare const NotesWriteDataSchema: Type.TObject<{
@@ -27,20 +24,15 @@ export type NotesWriteData = Static<typeof NotesWriteDataSchema>;
27
24
  export declare const NotesUpdateDataSchema: Type.TObject<{
28
25
  address: Type.TString;
29
26
  project_key: Type.TOptional<Type.TString>;
30
- applied: Type.TInteger;
31
- change_kind: Type.TUnion<[Type.TLiteral<"none">, Type.TLiteral<"body">, Type.TLiteral<"metadata">, Type.TLiteral<"file">]>;
27
+ change_kind: Type.TUnion<[Type.TLiteral<"none">, Type.TLiteral<"body">, Type.TLiteral<"metadata">, Type.TLiteral<"moved">]>;
32
28
  diff: Type.TString;
33
- diff_truncated: Type.TOptional<Type.TLiteral<true>>;
34
29
  rename_from: Type.TOptional<Type.TString>;
35
- replaced_crumpled_target: Type.TOptional<Type.TBoolean>;
36
30
  }>;
37
31
  export type NotesUpdateData = Static<typeof NotesUpdateDataSchema>;
38
32
  export declare const NotesReadDataSchema: Type.TObject<{
39
33
  text: Type.TString;
40
- offset_chars: Type.TInteger;
41
34
  total_chars: Type.TInteger;
42
35
  next_offset_chars: Type.TUnion<[Type.TInteger, Type.TNull]>;
43
- limited_by: Type.TUnion<[Type.TLiteral<"limit">, Type.TLiteral<"bytes">, Type.TNull]>;
44
36
  address: Type.TString;
45
37
  project_key: Type.TOptional<Type.TString>;
46
38
  metadata: Type.TObject<{
@@ -50,17 +42,11 @@ export declare const NotesReadDataSchema: Type.TObject<{
50
42
  crumpled_at: Type.TOptional<Type.TString>;
51
43
  project: Type.TOptional<Type.TString>;
52
44
  extra: Type.TRecord<"^.*$", Type.TUnknown>;
53
- /** Values left in the file but too large to show, summarized so the summary cannot grow. */
54
- omitted_extra: Type.TOptional<Type.TObject<{
55
- keys: Type.TInteger;
56
- bytes: Type.TInteger;
57
- }>>;
58
45
  }>;
59
46
  }>;
60
47
  export type NotesReadData = Static<typeof NotesReadDataSchema>;
61
48
  export declare const NotesListDataSchema: Type.TObject<{
62
49
  more: Type.TInteger;
63
- crumpled_excluded: Type.TInteger;
64
50
  homes_unavailable: Type.TArray<Type.TString>;
65
51
  files: Type.TArray<Type.TObject<{
66
52
  address: Type.TString;
@@ -72,14 +58,11 @@ export declare const NotesListDataSchema: Type.TObject<{
72
58
  export type NotesListData = Static<typeof NotesListDataSchema>;
73
59
  export declare const NotesSearchDataSchema: Type.TObject<{
74
60
  more: Type.TInteger;
75
- crumpled_excluded: Type.TInteger;
76
61
  homes_unavailable: Type.TArray<Type.TString>;
77
62
  files: Type.TArray<Type.TObject<{
78
- matches_total: Type.TInteger;
79
63
  matches: Type.TArray<Type.TObject<{
80
64
  line: Type.TInteger;
81
65
  text: Type.TString;
82
- truncated: Type.TBoolean;
83
66
  offset_chars: Type.TInteger;
84
67
  }>>;
85
68
  address: Type.TString;
@@ -97,7 +80,7 @@ export declare const notesWriteParameters: Type.TObject<{
97
80
  export declare const notesWrite: {
98
81
  readonly name: "notes_write";
99
82
  readonly label: "Notes write";
100
- readonly description: "Create or replace a note body, preserving metadata; uncrumples a crumpled note. Name it for its contents and when to use it. Store what git/history cannot recover. Addresses: <path> with no @ for this session; @project/, @human/, @self/, @model/ for durable homes (see /skill:memory). Never pass them to filesystem tools.";
83
+ readonly description: "Create or replace a note's body, keeping metadata; uncrumples a crumpled note. Name it for what it holds and when to use it. Store what git and history can't recover. Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes. Not file paths: never pass them to file tools.";
101
84
  readonly parameters: Type.TObject<{
102
85
  address: Type.TString;
103
86
  content: Type.TString;
@@ -110,7 +93,6 @@ export declare const notesWrite: {
110
93
  }>, Type.TObject<{
111
94
  error: Type.TString;
112
95
  code: Type.TString;
113
- details: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
114
96
  }>]>;
115
97
  readonly executionMode: "sequential";
116
98
  readonly execute: (params: Static<typeof notesWriteParameters>, identity: NotesIdentity) => Promise<Outcome<NotesWriteData>>;
@@ -128,10 +110,12 @@ export declare const notesUpdateParameters: Type.TObject<{
128
110
  rename_to: Type.TOptional<Type.TString>;
129
111
  }>;
130
112
  declare function renderUpdate(result: Outcome<NotesUpdateData>): string;
113
+ /** A shortened diff still says so in the receipt's own text, on both surfaces. */
114
+ export declare const DIFF_SHORTENED_MARKER = "[diff truncated; update applied]";
131
115
  export declare const notesUpdate: {
132
116
  readonly name: "notes_update";
133
117
  readonly label: "Notes update";
134
- readonly description: "Edit body text, change origin or crumpled state, or move a note. Each oldText must match once unless replace_all is true; edits cannot change frontmatter. Metadata-only updates need origin or crumpled. Returns applied changes and a bounded diff. Addresses: <path> with no @ for this session; @project/, @human/, @self/, @model/ for durable homes (see /skill:memory). Never pass them to filesystem tools.";
118
+ readonly description: "Edit a note's body, change its origin or crumpled state, or move it. Each `oldText` must match exactly once unless `replace_all` is true; frontmatter can't be edited. Returns a diff. Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes. Not file paths: never pass them to file tools.";
135
119
  readonly parameters: Type.TObject<{
136
120
  address: Type.TString;
137
121
  edits: Type.TOptional<Type.TArray<Type.TObject<{
@@ -146,41 +130,35 @@ export declare const notesUpdate: {
146
130
  readonly outputSchema: Type.TUnion<[Type.TObject<{
147
131
  address: Type.TString;
148
132
  project_key: Type.TOptional<Type.TString>;
149
- applied: Type.TInteger;
150
- change_kind: Type.TUnion<[Type.TLiteral<"none">, Type.TLiteral<"body">, Type.TLiteral<"metadata">, Type.TLiteral<"file">]>;
133
+ change_kind: Type.TUnion<[Type.TLiteral<"none">, Type.TLiteral<"body">, Type.TLiteral<"metadata">, Type.TLiteral<"moved">]>;
151
134
  diff: Type.TString;
152
- diff_truncated: Type.TOptional<Type.TLiteral<true>>;
153
135
  rename_from: Type.TOptional<Type.TString>;
154
- replaced_crumpled_target: Type.TOptional<Type.TBoolean>;
155
136
  }>, Type.TObject<{
156
137
  error: Type.TString;
157
138
  code: Type.TString;
158
- details: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
159
139
  }>]>;
160
140
  readonly executionMode: "sequential";
161
141
  readonly execute: (params: Static<typeof notesUpdateParameters>, identity: NotesIdentity, renderDiff: (change: NoteChange) => string) => Promise<Outcome<NotesUpdateData>>;
162
142
  readonly render: typeof renderUpdate;
163
143
  };
164
144
  export declare const notesReadParameters: Type.TObject<{
165
- address: Type.TString;
166
145
  offset_chars: Type.TOptional<Type.TInteger>;
167
- limit_chars: Type.TOptional<Type.TInteger>;
146
+ max_chars: Type.TOptional<Type.TInteger>;
147
+ address: Type.TString;
168
148
  }>;
169
149
  export declare const notesRead: {
170
150
  readonly name: "notes_read";
171
151
  readonly label: "Notes read";
172
- readonly description: "Read note metadata and a verbatim body slice, excluding frontmatter. Pass next_offset_chars as offset_chars until null. Addresses: <path> with no @ for this session; @project/, @human/, @self/, @model/ for durable homes (see /skill:memory). Never pass them to filesystem tools.";
152
+ readonly description: "Read a note's metadata and body, without frontmatter. Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes. Not file paths: never pass them to file tools.";
173
153
  readonly parameters: Type.TObject<{
174
- address: Type.TString;
175
154
  offset_chars: Type.TOptional<Type.TInteger>;
176
- limit_chars: Type.TOptional<Type.TInteger>;
155
+ max_chars: Type.TOptional<Type.TInteger>;
156
+ address: Type.TString;
177
157
  }>;
178
158
  readonly outputSchema: Type.TUnion<[Type.TObject<{
179
159
  text: Type.TString;
180
- offset_chars: Type.TInteger;
181
160
  total_chars: Type.TInteger;
182
161
  next_offset_chars: Type.TUnion<[Type.TInteger, Type.TNull]>;
183
- limited_by: Type.TUnion<[Type.TLiteral<"limit">, Type.TLiteral<"bytes">, Type.TNull]>;
184
162
  address: Type.TString;
185
163
  project_key: Type.TOptional<Type.TString>;
186
164
  metadata: Type.TObject<{
@@ -190,37 +168,30 @@ export declare const notesRead: {
190
168
  crumpled_at: Type.TOptional<Type.TString>;
191
169
  project: Type.TOptional<Type.TString>;
192
170
  extra: Type.TRecord<"^.*$", Type.TUnknown>;
193
- /** Values left in the file but too large to show, summarized so the summary cannot grow. */
194
- omitted_extra: Type.TOptional<Type.TObject<{
195
- keys: Type.TInteger;
196
- bytes: Type.TInteger;
197
- }>>;
198
171
  }>;
199
172
  }>, Type.TObject<{
200
173
  error: Type.TString;
201
174
  code: Type.TString;
202
- details: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
203
175
  }>]>;
204
176
  readonly execute: (params: Static<typeof notesReadParameters>, identity: NotesIdentity) => Promise<Outcome<NotesReadData>>;
205
177
  readonly render: (result: Outcome<NotesReadData>) => string;
206
178
  };
207
179
  export declare const notesListParameters: Type.TObject<{
208
- pattern: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
180
+ glob: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
209
181
  limit: Type.TOptional<Type.TInteger>;
210
- wastebasket: Type.TOptional<Type.TBoolean>;
182
+ crumpled: Type.TOptional<Type.TBoolean>;
211
183
  }>;
212
184
  export declare const notesList: {
213
185
  readonly name: "notes_list";
214
186
  readonly label: "Notes list";
215
- readonly description: "List notes in the session and the four @ homes, newest first. Snapshot, not pageable: more counts omitted files; pattern globs full addresses. Reports unavailable homes and how many crumpled notes were excluded. Addresses: <path> with no @ for this session; @project/, @human/, @self/, @model/ for durable homes (see /skill:memory). Never pass them to filesystem tools.";
187
+ readonly description: "List notes in this session and the four @ homes, newest first. Not pageable; `more` counts the rest. Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes. Not file paths: never pass them to file tools.";
216
188
  readonly parameters: Type.TObject<{
217
- pattern: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
189
+ glob: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
218
190
  limit: Type.TOptional<Type.TInteger>;
219
- wastebasket: Type.TOptional<Type.TBoolean>;
191
+ crumpled: Type.TOptional<Type.TBoolean>;
220
192
  }>;
221
193
  readonly outputSchema: Type.TUnion<[Type.TObject<{
222
194
  more: Type.TInteger;
223
- crumpled_excluded: Type.TInteger;
224
195
  homes_unavailable: Type.TArray<Type.TString>;
225
196
  files: Type.TArray<Type.TObject<{
226
197
  address: Type.TString;
@@ -231,39 +202,37 @@ export declare const notesList: {
231
202
  }>, Type.TObject<{
232
203
  error: Type.TString;
233
204
  code: Type.TString;
234
- details: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
235
205
  }>]>;
236
206
  readonly execute: (params: Static<typeof notesListParameters>, identity: NotesIdentity) => Promise<Outcome<NotesListData>>;
237
207
  readonly render: (result: Outcome<NotesListData>) => string;
238
208
  };
239
209
  export declare const notesSearchParameters: Type.TObject<{
240
210
  query: Type.TUnion<[Type.TString, Type.TArray<Type.TString>]>;
241
- pattern: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
211
+ glob: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
242
212
  limit: Type.TOptional<Type.TInteger>;
243
213
  max_matches_per_file: Type.TOptional<Type.TInteger>;
244
- wastebasket: Type.TOptional<Type.TBoolean>;
214
+ crumpled: Type.TOptional<Type.TBoolean>;
245
215
  }>;
216
+ /** A shortened match line still ends with a marker, so its own text says it was cut. */
217
+ export declare const MATCH_SHORTENED_MARKER = " [truncated]";
246
218
  export declare const notesSearch: {
247
219
  readonly name: "notes_search";
248
220
  readonly label: "Notes search";
249
- readonly description: "Search note bodies for case-insensitive literal queries (OR). Returns matching lines and body code-point offsets for notes_read. Snapshot, not pageable: more counts omitted files; matches_total is before per-file capping. pattern globs full addresses across the session and the four @ homes. Addresses: <path> with no @ for this session; @project/, @human/, @self/, @model/ for durable homes (see /skill:memory). Never pass them to filesystem tools.";
221
+ readonly description: "Search note bodies for literal text, case-insensitive. Returns matching lines with offsets for `notes_read`. Not pageable; `more` counts the rest. Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes. Not file paths: never pass them to file tools.";
250
222
  readonly parameters: Type.TObject<{
251
223
  query: Type.TUnion<[Type.TString, Type.TArray<Type.TString>]>;
252
- pattern: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
224
+ glob: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
253
225
  limit: Type.TOptional<Type.TInteger>;
254
226
  max_matches_per_file: Type.TOptional<Type.TInteger>;
255
- wastebasket: Type.TOptional<Type.TBoolean>;
227
+ crumpled: Type.TOptional<Type.TBoolean>;
256
228
  }>;
257
229
  readonly outputSchema: Type.TUnion<[Type.TObject<{
258
230
  more: Type.TInteger;
259
- crumpled_excluded: Type.TInteger;
260
231
  homes_unavailable: Type.TArray<Type.TString>;
261
232
  files: Type.TArray<Type.TObject<{
262
- matches_total: Type.TInteger;
263
233
  matches: Type.TArray<Type.TObject<{
264
234
  line: Type.TInteger;
265
235
  text: Type.TString;
266
- truncated: Type.TBoolean;
267
236
  offset_chars: Type.TInteger;
268
237
  }>>;
269
238
  address: Type.TString;
@@ -274,7 +243,6 @@ export declare const notesSearch: {
274
243
  }>, Type.TObject<{
275
244
  error: Type.TString;
276
245
  code: Type.TString;
277
- details: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
278
246
  }>]>;
279
247
  readonly execute: (params: Static<typeof notesSearchParameters>, identity: NotesIdentity) => Promise<Outcome<NotesSearchData>>;
280
248
  readonly render: (result: Outcome<NotesSearchData>) => string;