@astrosheep/pi-context 0.25.1 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -7
- package/dist/build-info.json +2 -2
- package/dist/extension.js +616 -370
- package/dist/src/context/boot.d.ts +24 -0
- package/dist/src/context/boot.js +33 -24
- package/dist/src/context/budget.d.ts +9 -0
- package/dist/src/context/budget.js +19 -15
- package/dist/src/context/context-window.d.ts +41 -0
- package/dist/src/context/context-window.js +16 -1
- package/dist/src/context/prompts.d.ts +20 -0
- package/dist/src/context/prompts.js +1 -1
- package/dist/src/context/reset-artifacts.d.ts +26 -0
- package/dist/src/context/reset-artifacts.js +18 -17
- package/dist/src/context/reset-lifecycle.d.ts +89 -0
- package/dist/src/context/reset-lifecycle.js +103 -75
- package/dist/src/context/runtime.d.ts +3 -0
- package/dist/src/context/runtime.js +53 -21
- package/dist/src/context/thresholds.d.ts +33 -0
- package/dist/src/context/thresholds.js +1 -1
- package/dist/src/dream/cli.d.ts +10 -0
- package/dist/src/dream/cli.js +1 -1
- package/dist/src/dream/doctor.d.ts +2 -0
- package/dist/src/dream/doctor.js +6 -2
- package/dist/src/dream/gates.d.ts +10 -0
- package/dist/src/dream/git.d.ts +21 -0
- package/dist/src/dream/lock.d.ts +31 -0
- package/dist/src/dream/runner.d.ts +30 -0
- package/dist/src/dream/settings.d.ts +16 -0
- package/dist/src/history/history-tools.d.ts +2 -0
- package/dist/src/history/history.d.ts +57 -0
- package/dist/src/index.d.ts +39 -0
- package/dist/src/index.js +4 -4
- package/dist/src/notes/address.d.ts +26 -0
- package/dist/src/notes/address.js +8 -14
- package/dist/src/notes/constants.d.ts +3 -0
- package/dist/src/notes/constants.js +3 -0
- package/dist/src/notes/context.d.ts +10 -0
- package/dist/src/notes/context.js +33 -0
- package/dist/src/notes/frontmatter.d.ts +46 -0
- package/dist/src/notes/frontmatter.js +10 -5
- package/dist/src/notes/index.d.ts +4 -0
- package/dist/src/notes/index.js +2 -0
- package/dist/src/notes/paths.d.ts +21 -0
- package/dist/src/notes/paths.js +72 -76
- package/dist/src/notes/store.d.ts +94 -0
- package/dist/src/notes/store.js +298 -242
- package/dist/src/pi/notes/adapter.d.ts +12 -0
- package/dist/src/pi/notes/adapter.js +39 -0
- package/dist/src/pi/notes/session-replay.d.ts +16 -0
- package/dist/src/{notes → pi/notes}/session-replay.js +2 -2
- package/dist/src/pi/notes/snapshot.d.ts +33 -0
- package/dist/src/{notes/notes-snapshot.js → pi/notes/snapshot.js} +11 -3
- package/dist/src/pi/notes/tools.d.ts +2 -0
- package/dist/src/{notes → pi/notes}/tools.js +24 -21
- package/dist/src/protocol.d.ts +41 -0
- package/dist/src/protocol.js +4 -6
- package/dist/src/session-reader.d.ts +5 -0
- package/dist/src/settings.d.ts +6 -0
- package/dist/src/tool-output.d.ts +101 -0
- package/dist/src/tool-schema.d.ts +17 -0
- package/dist/test/agent-loop.test.d.ts +1 -0
- package/dist/test/agent-loop.test.js +318 -19
- package/dist/test/boot.integration.test.d.ts +1 -0
- package/dist/test/boot.integration.test.js +55 -29
- package/dist/test/budget-settings.integration.test.d.ts +1 -0
- package/dist/test/budget-settings.integration.test.js +8 -7
- package/dist/test/doctor.test.d.ts +1 -0
- package/dist/test/doctor.test.js +10 -2
- package/dist/test/dream-skill.test.d.ts +1 -0
- package/dist/test/dream-skill.test.js +69 -0
- package/dist/test/dream.test.d.ts +1 -0
- package/dist/test/helpers/extension.d.ts +115 -0
- package/dist/test/helpers/extension.js +6 -6
- package/dist/test/helpers/notes.d.ts +6 -0
- package/dist/test/helpers/notes.js +13 -0
- package/dist/test/history.integration.test.d.ts +1 -0
- package/dist/test/notes-library.test.d.ts +1 -0
- package/dist/test/notes-library.test.js +111 -0
- package/dist/test/notes.integration.test.d.ts +1 -0
- package/dist/test/notes.integration.test.js +22 -24
- package/dist/test/notes.test.d.ts +1 -0
- package/dist/test/notes.test.js +137 -7
- package/dist/test/reset-lifecycle.test.d.ts +1 -0
- package/dist/test/reset-lifecycle.test.js +142 -85
- package/docs/architecture.md +8 -8
- package/docs/reset-lifecycle.md +63 -79
- package/package.json +35 -2
- package/playbook.md +33 -32
- package/skills/dream/SKILL.md +12 -0
- package/src/context/boot.ts +44 -25
- package/src/context/budget.ts +25 -17
- package/src/context/context-window.ts +16 -1
- package/src/context/prompts.ts +2 -2
- package/src/context/reset-artifacts.ts +26 -24
- package/src/context/reset-lifecycle.ts +117 -111
- package/src/context/runtime.ts +50 -22
- package/src/context/thresholds.ts +1 -1
- package/src/dream/cli.ts +1 -1
- package/src/dream/doctor.ts +5 -2
- package/src/index.ts +4 -4
- package/src/notes/address.ts +9 -15
- package/src/notes/constants.ts +3 -0
- package/src/notes/context.ts +40 -0
- package/src/notes/frontmatter.ts +18 -12
- package/src/notes/index.ts +22 -0
- package/src/notes/paths.ts +64 -78
- package/src/notes/store.ts +308 -244
- package/src/pi/notes/adapter.ts +44 -0
- package/src/{notes → pi/notes}/session-replay.ts +3 -3
- package/src/{notes/notes-snapshot.ts → pi/notes/snapshot.ts} +13 -4
- package/src/{notes → pi/notes}/tools.ts +25 -23
- package/src/protocol.ts +5 -6
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type NotesContext } from "./context.js";
|
|
2
|
+
import { type NoteMeta, type NoteStatus, type Origin } from "./frontmatter.js";
|
|
3
|
+
import { type Scope } from "./paths.js";
|
|
4
|
+
export type { NoteMeta, NoteStatus, Origin, Scope };
|
|
5
|
+
export type NoteErrorCode = "not_found" | "ambiguous_edit" | "no_match" | "nothing_to_do" | "too_large" | "invalid_scope" | "invalid_origin";
|
|
6
|
+
/** Typed store refusal. Edit locations are exposed in camelCase. */
|
|
7
|
+
export declare class NoteError extends Error {
|
|
8
|
+
readonly code: NoteErrorCode;
|
|
9
|
+
readonly lineNumbers?: number[];
|
|
10
|
+
readonly editIndex?: number;
|
|
11
|
+
constructor(code: NoteErrorCode, message: string, extra?: {
|
|
12
|
+
lineNumbers?: number[];
|
|
13
|
+
editIndex?: number;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export type NoteRow = {
|
|
17
|
+
address: string;
|
|
18
|
+
scope: Scope;
|
|
19
|
+
path: string;
|
|
20
|
+
meta: NoteMeta;
|
|
21
|
+
body: string;
|
|
22
|
+
sizeBytes: number;
|
|
23
|
+
};
|
|
24
|
+
export type NoteMatch = {
|
|
25
|
+
line: number;
|
|
26
|
+
text: string;
|
|
27
|
+
offsetChars: number;
|
|
28
|
+
};
|
|
29
|
+
export type NoteSearchRow = {
|
|
30
|
+
address: string;
|
|
31
|
+
scope: Scope;
|
|
32
|
+
path: string;
|
|
33
|
+
meta: NoteMeta;
|
|
34
|
+
matches: NoteMatch[];
|
|
35
|
+
};
|
|
36
|
+
export type EditOperation = {
|
|
37
|
+
oldText: string;
|
|
38
|
+
newText: string;
|
|
39
|
+
};
|
|
40
|
+
export type WriteOptions = {
|
|
41
|
+
origin?: Origin;
|
|
42
|
+
stale?: boolean;
|
|
43
|
+
};
|
|
44
|
+
export type EditOptions = {
|
|
45
|
+
origin?: Origin;
|
|
46
|
+
stale?: boolean;
|
|
47
|
+
replaceAll?: boolean;
|
|
48
|
+
};
|
|
49
|
+
export type NotesQuery = ({
|
|
50
|
+
scope?: undefined;
|
|
51
|
+
who?: never;
|
|
52
|
+
} | {
|
|
53
|
+
scope: "session" | "project" | "human";
|
|
54
|
+
who?: never;
|
|
55
|
+
} | {
|
|
56
|
+
scope: "agent" | "model";
|
|
57
|
+
who?: string;
|
|
58
|
+
}) & {
|
|
59
|
+
pattern?: string;
|
|
60
|
+
};
|
|
61
|
+
export type NoteReadResult = {
|
|
62
|
+
meta: NoteMeta;
|
|
63
|
+
body: string;
|
|
64
|
+
text: string;
|
|
65
|
+
resolvedScope: Scope;
|
|
66
|
+
};
|
|
67
|
+
export type NoteWriteResult = {
|
|
68
|
+
meta: NoteMeta;
|
|
69
|
+
};
|
|
70
|
+
export type NoteChange = {
|
|
71
|
+
kind: "none";
|
|
72
|
+
before: "";
|
|
73
|
+
after: "";
|
|
74
|
+
} | {
|
|
75
|
+
kind: "body" | "metadata" | "file";
|
|
76
|
+
before: string;
|
|
77
|
+
after: string;
|
|
78
|
+
};
|
|
79
|
+
export type NoteEditResult = {
|
|
80
|
+
meta: NoteMeta;
|
|
81
|
+
applied: number;
|
|
82
|
+
resolvedScope: Scope;
|
|
83
|
+
change: NoteChange;
|
|
84
|
+
};
|
|
85
|
+
/** Host-neutral, filesystem-backed notes API. */
|
|
86
|
+
export interface NotesStore {
|
|
87
|
+
write(address: string, content: string, options?: WriteOptions): Promise<NoteWriteResult>;
|
|
88
|
+
read(address: string): Promise<NoteReadResult | undefined>;
|
|
89
|
+
edit(address: string, edits?: EditOperation[], options?: EditOptions): Promise<NoteEditResult>;
|
|
90
|
+
list(options?: NotesQuery): Promise<NoteRow[]>;
|
|
91
|
+
search(queries: string[], options?: NotesQuery): Promise<NoteSearchRow[]>;
|
|
92
|
+
}
|
|
93
|
+
/** Create a store over one validated, immutable snapshot of the supplied explicit identity. */
|
|
94
|
+
export declare function createNotesStore(input: NotesContext): NotesStore;
|