@blulotus/trellis-core 0.7.0 → 0.7.2
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/mem/context.js +2 -2
- package/dist/mem/context.js.map +1 -1
- package/dist/mem/index.d.ts +1 -2
- package/dist/mem/index.d.ts.map +1 -1
- package/dist/mem/index.js +1 -2
- package/dist/mem/index.js.map +1 -1
- package/dist/mem/internal/paths.d.ts +0 -19
- package/dist/mem/internal/paths.d.ts.map +1 -1
- package/dist/mem/internal/paths.js +0 -79
- package/dist/mem/internal/paths.js.map +1 -1
- package/dist/mem/projects.d.ts.map +1 -1
- package/dist/mem/projects.js +1 -5
- package/dist/mem/projects.js.map +1 -1
- package/dist/mem/sessions.d.ts +6 -6
- package/dist/mem/sessions.d.ts.map +1 -1
- package/dist/mem/sessions.js +29 -81
- package/dist/mem/sessions.js.map +1 -1
- package/dist/mem/types.d.ts +2 -2
- package/dist/mem/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/mem/adapters/grok.d.ts +0 -41
- package/dist/mem/adapters/grok.d.ts.map +0 -1
- package/dist/mem/adapters/grok.js +0 -202
- package/dist/mem/adapters/grok.js.map +0 -1
- package/dist/mem/adapters/opencode.d.ts +0 -19
- package/dist/mem/adapters/opencode.d.ts.map +0 -1
- package/dist/mem/adapters/opencode.js +0 -25
- package/dist/mem/adapters/opencode.js.map +0 -1
- package/dist/mem/adapters/pi.d.ts +0 -24
- package/dist/mem/adapters/pi.d.ts.map +0 -1
- package/dist/mem/adapters/pi.js +0 -290
- package/dist/mem/adapters/pi.js.map +0 -1
- package/dist/mem/adapters/zcode.d.ts +0 -76
- package/dist/mem/adapters/zcode.d.ts.map +0 -1
- package/dist/mem/adapters/zcode.js +0 -434
- package/dist/mem/adapters/zcode.js.map +0 -1
- package/dist/mem/internal/sqlite-readonly.d.ts +0 -77
- package/dist/mem/internal/sqlite-readonly.d.ts.map +0 -1
- package/dist/mem/internal/sqlite-readonly.js +0 -797
- package/dist/mem/internal/sqlite-readonly.js.map +0 -1
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ZCode (Zhipu) persisted-session reader.
|
|
3
|
-
*
|
|
4
|
-
* ZCode stores sessions in a SQLite database at `~/.zcode/cli/db/db.sqlite`
|
|
5
|
-
* (WAL mode). The three tables this adapter reads are:
|
|
6
|
-
*
|
|
7
|
-
* - `session` — id / title / directory (workspace cwd) / time_created /
|
|
8
|
-
* time_updated / task_type
|
|
9
|
-
* - `message` — id / session_id / time_created / data (JSON: {role, ...})
|
|
10
|
-
* - `part` — message_id / time_created / data (JSON: {type, text|tool, ...})
|
|
11
|
-
* plus compaction markers that replace earlier dialogue with
|
|
12
|
-
* a summary message.
|
|
13
|
-
*
|
|
14
|
-
* The older `~/.zcode/v2/sessions/*.json` layout is abandoned by current ZCode,
|
|
15
|
-
* and `~/.zcode/cli/rollout/*.jsonl` is a non-persistent model-IO stream that
|
|
16
|
-
* gets cleaned up periodically — neither is read here. SQLite is the single
|
|
17
|
-
* complete source of truth (see `docs-hlaia/06-...` for the investigation).
|
|
18
|
-
*
|
|
19
|
-
* SQLite access is via the zero-dependency parser in `internal/sqlite-readonly.ts`
|
|
20
|
-
* — `better-sqlite3` was rejected because its native build chain broke npm
|
|
21
|
-
* install on Windows for the OpenCode adapter.
|
|
22
|
-
*/
|
|
23
|
-
import type { DialogueTurn, MemFilter, MemSessionInfo, MemWarning, SearchHit, TaskPyEvent } from "../types.js";
|
|
24
|
-
interface ZcodeTextPart {
|
|
25
|
-
type?: string;
|
|
26
|
-
text?: string;
|
|
27
|
-
}
|
|
28
|
-
interface ZcodeToolPart {
|
|
29
|
-
type?: string;
|
|
30
|
-
tool?: string;
|
|
31
|
-
state?: {
|
|
32
|
-
input?: {
|
|
33
|
-
command?: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
export declare function prepareZcodeSessionStore(dbPath: string, warnings: MemWarning[]): void;
|
|
38
|
-
export declare function releaseZcodeSessionStore(): void;
|
|
39
|
-
export declare function zcodeListSessions(f: MemFilter, warnings?: MemWarning[]): MemSessionInfo[];
|
|
40
|
-
/**
|
|
41
|
-
* Build cleaned dialogue turns from a session's messages + parts. Each message
|
|
42
|
-
* is one turn; its text is the concatenation of its `text`-typed parts after
|
|
43
|
-
* injection-tag stripping. Messages with no surviving text are dropped.
|
|
44
|
-
*/
|
|
45
|
-
export declare function zcodeExtractDialogue(s: MemSessionInfo, warnings?: MemWarning[]): DialogueTurn[];
|
|
46
|
-
export declare function zcodeSearch(s: MemSessionInfo, kw: string, warnings?: MemWarning[]): SearchHit;
|
|
47
|
-
/**
|
|
48
|
-
* Single pass over messages + parts. Emits both the cleaned dialogue turns and
|
|
49
|
-
* the list of `task.py create|start` invocations found in `Bash` tool parts
|
|
50
|
-
* (`{type:"tool", tool:"Bash", state:{input:{command:"..."}}}`). `turnIndex`
|
|
51
|
-
* for each event is the turn count at the time the tool ran.
|
|
52
|
-
*
|
|
53
|
-
* Compaction: ZCode writes a summary message with a `compaction` part carrying
|
|
54
|
-
* `tail_start_id` / `compactBoundary`. The summarized messages remain in the
|
|
55
|
-
* database, so they stay in the turn pool and the summary message becomes a
|
|
56
|
-
* boundary marker — `task.py` boundaries from before a compaction keep pointing
|
|
57
|
-
* at turns that are still there.
|
|
58
|
-
*
|
|
59
|
-
* turnIndex note (differs slightly from claude/codex): in ZCode a message's
|
|
60
|
-
* text parts and tool parts are siblings within one message. This loop pushes
|
|
61
|
-
* the message's text turn *before* recording its tool events, so a tool event
|
|
62
|
-
* on message M has turnIndex = (turns including M's text). claude/codex
|
|
63
|
-
* instead record the event before pushing the text, so their turnIndex is one
|
|
64
|
-
* less. Both are internally self-consistent for brainstorm-window slicing
|
|
65
|
-
* (create and start use the same convention within a platform), so phase
|
|
66
|
-
* boundaries compute correctly. The ZCode ordering reflects real time order
|
|
67
|
-
* (the assistant writes, then the tool runs). Do not "align" this without also
|
|
68
|
-
* adjusting the test expectations.
|
|
69
|
-
*/
|
|
70
|
-
export declare function collectZcodeTurnsAndEvents(s: MemSessionInfo, warnings?: MemWarning[]): {
|
|
71
|
-
turns: DialogueTurn[];
|
|
72
|
-
events: TaskPyEvent[];
|
|
73
|
-
};
|
|
74
|
-
/** Re-exported so callers needing loose shapes can import from one place. */
|
|
75
|
-
export type { ZcodeTextPart, ZcodeToolPart };
|
|
76
|
-
//# sourceMappingURL=zcode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zcode.d.ts","sourceRoot":"","sources":["../../../src/mem/adapters/zcode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAmBH,OAAO,KAAK,EAEV,YAAY,EACZ,SAAS,EACT,cAAc,EACd,UAAU,EACV,SAAS,EACT,WAAW,EACZ,MAAM,aAAa,CAAC;AAQrB,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CAC1C;AAkND,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,UAAU,EAAE,GACrB,IAAI,CAEN;AAED,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C;AA2ID,wBAAgB,iBAAiB,CAC/B,CAAC,EAAE,SAAS,EACZ,QAAQ,GAAE,UAAU,EAAO,GAC1B,cAAc,EAAE,CA4DlB;AAUD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,CAAC,EAAE,cAAc,EACjB,QAAQ,GAAE,UAAU,EAAO,GAC1B,YAAY,EAAE,CAehB;AAED,wBAAgB,WAAW,CACzB,CAAC,EAAE,cAAc,EACjB,EAAE,EAAE,MAAM,EACV,QAAQ,GAAE,UAAU,EAAO,GAC1B,SAAS,CAEX;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,0BAA0B,CACxC,CAAC,EAAE,cAAc,EACjB,QAAQ,GAAE,UAAU,EAAO,GAC1B;IACD,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB,CAyCA;AAED,6EAA6E;AAC7E,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ZCode (Zhipu) persisted-session reader.
|
|
3
|
-
*
|
|
4
|
-
* ZCode stores sessions in a SQLite database at `~/.zcode/cli/db/db.sqlite`
|
|
5
|
-
* (WAL mode). The three tables this adapter reads are:
|
|
6
|
-
*
|
|
7
|
-
* - `session` — id / title / directory (workspace cwd) / time_created /
|
|
8
|
-
* time_updated / task_type
|
|
9
|
-
* - `message` — id / session_id / time_created / data (JSON: {role, ...})
|
|
10
|
-
* - `part` — message_id / time_created / data (JSON: {type, text|tool, ...})
|
|
11
|
-
* plus compaction markers that replace earlier dialogue with
|
|
12
|
-
* a summary message.
|
|
13
|
-
*
|
|
14
|
-
* The older `~/.zcode/v2/sessions/*.json` layout is abandoned by current ZCode,
|
|
15
|
-
* and `~/.zcode/cli/rollout/*.jsonl` is a non-persistent model-IO stream that
|
|
16
|
-
* gets cleaned up periodically — neither is read here. SQLite is the single
|
|
17
|
-
* complete source of truth (see `docs-hlaia/06-...` for the investigation).
|
|
18
|
-
*
|
|
19
|
-
* SQLite access is via the zero-dependency parser in `internal/sqlite-readonly.ts`
|
|
20
|
-
* — `better-sqlite3` was rejected because its native build chain broke npm
|
|
21
|
-
* install on Windows for the OpenCode adapter.
|
|
22
|
-
*/
|
|
23
|
-
import * as fs from "node:fs";
|
|
24
|
-
import { compactionBoundaryTurn, stripInjectionTags, isBootstrapTurn, } from "../dialogue.js";
|
|
25
|
-
import { inRangeOverlap, sameProject } from "../filter.js";
|
|
26
|
-
import { openSqliteReadOnly, SqliteParseError, SqliteSnapshotUnstableError, } from "../internal/sqlite-readonly.js";
|
|
27
|
-
import { ZCODE_DB } from "../internal/paths.js";
|
|
28
|
-
import { parseTaskPyCommandsAll } from "../phase.js";
|
|
29
|
-
import { searchInDialogue } from "../search.js";
|
|
30
|
-
function parseDialogueRole(v) {
|
|
31
|
-
return v === "user" || v === "assistant" ? v : undefined;
|
|
32
|
-
}
|
|
33
|
-
/** Safely parse the JSON stored in a `data` column. Returns null on failure. */
|
|
34
|
-
function parseDataJson(raw) {
|
|
35
|
-
if (typeof raw !== "string")
|
|
36
|
-
return null;
|
|
37
|
-
try {
|
|
38
|
-
const v = JSON.parse(raw);
|
|
39
|
-
return v && typeof v === "object" && !Array.isArray(v)
|
|
40
|
-
? v
|
|
41
|
-
: null;
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const ZCODE_DB_UNREADABLE_WARNING_CODE = "zcode-db-unreadable";
|
|
48
|
-
const ZCODE_DB_SNAPSHOT_UNSTABLE_WARNING_CODE = "zcode-db-snapshot-unstable";
|
|
49
|
-
function emptySessionStore() {
|
|
50
|
-
return { messagesBySession: new Map(), partsByMsg: new Map() };
|
|
51
|
-
}
|
|
52
|
-
function pushDbWarning(warnings, dbPath, error) {
|
|
53
|
-
const isSnapshotUnstable = error instanceof SqliteSnapshotUnstableError;
|
|
54
|
-
const code = isSnapshotUnstable
|
|
55
|
-
? ZCODE_DB_SNAPSHOT_UNSTABLE_WARNING_CODE
|
|
56
|
-
: ZCODE_DB_UNREADABLE_WARNING_CODE;
|
|
57
|
-
if (warnings.some((warning) => warning.code === code))
|
|
58
|
-
return;
|
|
59
|
-
warnings.push({
|
|
60
|
-
code,
|
|
61
|
-
message: isSnapshotUnstable
|
|
62
|
-
? `ZCode 正在写入,请重试。 (${dbPath})`
|
|
63
|
-
: `cannot read ZCode session database (${dbPath}): ${error.message}`,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
function requireTables(db, names) {
|
|
67
|
-
const available = new Set(db.listTables().map((table) => table.name));
|
|
68
|
-
const missing = names.filter((name) => !available.has(name));
|
|
69
|
-
if (missing.length > 0) {
|
|
70
|
-
throw new SqliteParseError(`ZCode database schema is missing table(s): ${missing.join(", ")}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function requireTableColumns(db, tableName, names) {
|
|
74
|
-
const table = db.listTables().find((item) => item.name === tableName);
|
|
75
|
-
if (!table) {
|
|
76
|
-
throw new SqliteParseError(`ZCode database schema is missing table: ${tableName}`);
|
|
77
|
-
}
|
|
78
|
-
const missing = names.filter((name) => {
|
|
79
|
-
const pattern = new RegExp(`(?:\\(|,)\\s*["\`\\[]?${name}(?:["\`\\]]|\\b)`, "i");
|
|
80
|
-
return !pattern.test(table.sql);
|
|
81
|
-
});
|
|
82
|
-
if (missing.length > 0) {
|
|
83
|
-
throw new SqliteParseError(`ZCode table ${tableName} is missing column(s): ${missing.join(", ")}`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function requireRowColumns(rows, tableName, names) {
|
|
87
|
-
const first = rows[0];
|
|
88
|
-
if (!first)
|
|
89
|
-
return;
|
|
90
|
-
const missing = names.filter((name) => !(name in first));
|
|
91
|
-
if (missing.length > 0) {
|
|
92
|
-
throw new SqliteParseError(`ZCode table ${tableName} is missing column(s): ${missing.join(", ")}`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function buildSessionStore(allMessages, allParts) {
|
|
96
|
-
const messagesBySession = new Map();
|
|
97
|
-
for (const row of allMessages) {
|
|
98
|
-
const sessionId = typeof row.session_id === "string" ? row.session_id : "";
|
|
99
|
-
if (!sessionId)
|
|
100
|
-
continue;
|
|
101
|
-
const data = parseDataJson(row.data);
|
|
102
|
-
const role = parseDialogueRole(data?.role);
|
|
103
|
-
if (!role)
|
|
104
|
-
continue;
|
|
105
|
-
const tc = typeof row.time_created === "number" ? row.time_created : 0;
|
|
106
|
-
const id = typeof row.id === "string" ? row.id : "";
|
|
107
|
-
if (!id)
|
|
108
|
-
continue;
|
|
109
|
-
const list = messagesBySession.get(sessionId) ?? [];
|
|
110
|
-
list.push({ id, time_created: tc, role });
|
|
111
|
-
messagesBySession.set(sessionId, list);
|
|
112
|
-
}
|
|
113
|
-
for (const list of messagesBySession.values()) {
|
|
114
|
-
list.sort((a, b) => a.time_created - b.time_created);
|
|
115
|
-
}
|
|
116
|
-
const partsByMsg = new Map();
|
|
117
|
-
for (const row of allParts) {
|
|
118
|
-
const msgId = typeof row.message_id === "string" ? row.message_id : "";
|
|
119
|
-
if (!msgId)
|
|
120
|
-
continue;
|
|
121
|
-
const data = parseDataJson(row.data);
|
|
122
|
-
if (!data)
|
|
123
|
-
continue;
|
|
124
|
-
const tc = typeof row.time_created === "number" ? row.time_created : 0;
|
|
125
|
-
const list = partsByMsg.get(msgId) ?? [];
|
|
126
|
-
list.push({ message_id: msgId, time_created: tc, data });
|
|
127
|
-
partsByMsg.set(msgId, list);
|
|
128
|
-
}
|
|
129
|
-
for (const list of partsByMsg.values()) {
|
|
130
|
-
list.sort((a, b) => a.time_created - b.time_created);
|
|
131
|
-
}
|
|
132
|
-
return { messagesBySession, partsByMsg };
|
|
133
|
-
}
|
|
134
|
-
/** Search-scoped whole-db store. It is explicitly prepared/released by the
|
|
135
|
-
* orchestrator; one-session extract/context calls never populate it. */
|
|
136
|
-
let preparedStore = null;
|
|
137
|
-
/** Load a full-db search store for `dbPath`. Returns a degraded empty store
|
|
138
|
-
* when the db is missing/corrupt so callers never crash. */
|
|
139
|
-
function loadSessionStore(dbPath, warnings) {
|
|
140
|
-
if (!fs.existsSync(dbPath))
|
|
141
|
-
return emptySessionStore();
|
|
142
|
-
let allMessages;
|
|
143
|
-
let allParts;
|
|
144
|
-
try {
|
|
145
|
-
const db = openSqliteReadOnly(dbPath);
|
|
146
|
-
try {
|
|
147
|
-
requireTables(db, ["message", "part"]);
|
|
148
|
-
requireTableColumns(db, "message", ["id", "session_id", "data"]);
|
|
149
|
-
requireTableColumns(db, "part", ["message_id", "data"]);
|
|
150
|
-
allMessages = db.scanTable("message");
|
|
151
|
-
allParts = db.scanTable("part");
|
|
152
|
-
requireRowColumns(allMessages, "message", ["id", "session_id", "data"]);
|
|
153
|
-
requireRowColumns(allParts, "part", ["message_id", "data"]);
|
|
154
|
-
}
|
|
155
|
-
finally {
|
|
156
|
-
db.close();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
catch (e) {
|
|
160
|
-
if (e instanceof SqliteParseError) {
|
|
161
|
-
pushDbWarning(warnings, dbPath, e);
|
|
162
|
-
return emptySessionStore();
|
|
163
|
-
}
|
|
164
|
-
throw e;
|
|
165
|
-
}
|
|
166
|
-
return buildSessionStore(allMessages, allParts);
|
|
167
|
-
}
|
|
168
|
-
export function prepareZcodeSessionStore(dbPath, warnings) {
|
|
169
|
-
preparedStore = { dbPath, store: loadSessionStore(dbPath, warnings) };
|
|
170
|
-
}
|
|
171
|
-
export function releaseZcodeSessionStore() {
|
|
172
|
-
preparedStore = null;
|
|
173
|
-
}
|
|
174
|
-
/** Read one session with row filtering unless a search-scoped whole-db store
|
|
175
|
-
* has been prepared by the orchestrator. */
|
|
176
|
-
function readSessionMessages(dbPath, sessionId, warnings) {
|
|
177
|
-
if (preparedStore?.dbPath === dbPath) {
|
|
178
|
-
return {
|
|
179
|
-
messages: preparedStore.store.messagesBySession.get(sessionId) ?? [],
|
|
180
|
-
partsByMsg: preparedStore.store.partsByMsg,
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
if (!fs.existsSync(dbPath))
|
|
184
|
-
return { messages: [], partsByMsg: new Map() };
|
|
185
|
-
let store;
|
|
186
|
-
try {
|
|
187
|
-
const db = openSqliteReadOnly(dbPath);
|
|
188
|
-
try {
|
|
189
|
-
requireTables(db, ["message", "part"]);
|
|
190
|
-
requireTableColumns(db, "message", ["id", "session_id", "data"]);
|
|
191
|
-
requireTableColumns(db, "part", ["message_id", "data"]);
|
|
192
|
-
const messages = db.scanTable("message", (row) => row.session_id === sessionId);
|
|
193
|
-
const messageIds = new Set(messages
|
|
194
|
-
.map((row) => row.id)
|
|
195
|
-
.filter((id) => typeof id === "string"));
|
|
196
|
-
const parts = db.scanTable("part", (row) => typeof row.message_id === "string" && messageIds.has(row.message_id));
|
|
197
|
-
requireRowColumns(messages, "message", ["id", "session_id", "data"]);
|
|
198
|
-
requireRowColumns(parts, "part", ["message_id", "data"]);
|
|
199
|
-
store = buildSessionStore(messages, parts);
|
|
200
|
-
}
|
|
201
|
-
finally {
|
|
202
|
-
db.close();
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
catch (error) {
|
|
206
|
-
if (error instanceof SqliteParseError) {
|
|
207
|
-
pushDbWarning(warnings, dbPath, error);
|
|
208
|
-
return { messages: [], partsByMsg: new Map() };
|
|
209
|
-
}
|
|
210
|
-
throw error;
|
|
211
|
-
}
|
|
212
|
-
return {
|
|
213
|
-
messages: store.messagesBySession.get(sessionId) ?? [],
|
|
214
|
-
partsByMsg: store.partsByMsg,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
function isRecord(value) {
|
|
218
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
219
|
-
}
|
|
220
|
-
function isCompactionSummaryPart(data) {
|
|
221
|
-
return (data.type === "compaction" &&
|
|
222
|
-
(typeof data.tail_start_id === "string" || isRecord(data.compactBoundary)));
|
|
223
|
-
}
|
|
224
|
-
function compactionMarkerSummaryId(data) {
|
|
225
|
-
return data.type === "compaction" &&
|
|
226
|
-
data.replace === true &&
|
|
227
|
-
typeof data.summaryMessageId === "string"
|
|
228
|
-
? data.summaryMessageId
|
|
229
|
-
: undefined;
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* ZCode compaction writes two markers:
|
|
233
|
-
* - an assistant marker with `replace: true` and `summaryMessageId`
|
|
234
|
-
* - a summary message carrying text plus a `compaction` part with
|
|
235
|
-
* `tail_start_id` / `compactBoundary`
|
|
236
|
-
*
|
|
237
|
-
* Those say where ZCode cut its own context. The summarized messages are still
|
|
238
|
-
* rows in the same database, so extraction keeps them and renders each summary
|
|
239
|
-
* message as a boundary marker in place.
|
|
240
|
-
*/
|
|
241
|
-
function compactSummaryMessageIds(messages, partsByMsg) {
|
|
242
|
-
const summaryIds = new Set();
|
|
243
|
-
const markerSummaryIds = new Set();
|
|
244
|
-
for (const msg of messages) {
|
|
245
|
-
if (markerSummaryIds.has(msg.id))
|
|
246
|
-
summaryIds.add(msg.id);
|
|
247
|
-
for (const part of partsByMsg.get(msg.id) ?? []) {
|
|
248
|
-
const markerSummaryId = compactionMarkerSummaryId(part.data);
|
|
249
|
-
if (markerSummaryId)
|
|
250
|
-
markerSummaryIds.add(markerSummaryId);
|
|
251
|
-
if (isCompactionSummaryPart(part.data)) {
|
|
252
|
-
summaryIds.add(msg.id);
|
|
253
|
-
break;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return summaryIds;
|
|
258
|
-
}
|
|
259
|
-
function buildTextTurn(msg, parts, compactSummaryIds) {
|
|
260
|
-
const collected = [];
|
|
261
|
-
let totalRaw = 0;
|
|
262
|
-
for (const part of parts) {
|
|
263
|
-
const pd = part.data;
|
|
264
|
-
if (pd.type !== "text")
|
|
265
|
-
continue;
|
|
266
|
-
const txt = typeof pd.text === "string" ? pd.text : "";
|
|
267
|
-
if (!txt)
|
|
268
|
-
continue;
|
|
269
|
-
totalRaw += txt.length;
|
|
270
|
-
collected.push(stripInjectionTags(txt));
|
|
271
|
-
}
|
|
272
|
-
if (!collected.length)
|
|
273
|
-
return null;
|
|
274
|
-
const merged = collected.join("\n\n");
|
|
275
|
-
if (compactSummaryIds.has(msg.id)) {
|
|
276
|
-
return compactionBoundaryTurn("context compacted here; the turns above are still in the ZCode database", merged);
|
|
277
|
-
}
|
|
278
|
-
if (isBootstrapTurn(merged, totalRaw))
|
|
279
|
-
return null;
|
|
280
|
-
return merged.trim() ? { role: msg.role, text: merged } : null;
|
|
281
|
-
}
|
|
282
|
-
// ---------- list ----------
|
|
283
|
-
export function zcodeListSessions(f, warnings = []) {
|
|
284
|
-
if (!fs.existsSync(ZCODE_DB))
|
|
285
|
-
return [];
|
|
286
|
-
let rows;
|
|
287
|
-
try {
|
|
288
|
-
const db = openSqliteReadOnly(ZCODE_DB);
|
|
289
|
-
try {
|
|
290
|
-
requireTables(db, ["session"]);
|
|
291
|
-
requireTableColumns(db, "session", [
|
|
292
|
-
"id",
|
|
293
|
-
"directory",
|
|
294
|
-
"time_created",
|
|
295
|
-
"time_updated",
|
|
296
|
-
]);
|
|
297
|
-
rows = db.scanTable("session");
|
|
298
|
-
requireRowColumns(rows, "session", [
|
|
299
|
-
"id",
|
|
300
|
-
"directory",
|
|
301
|
-
"time_created",
|
|
302
|
-
"time_updated",
|
|
303
|
-
]);
|
|
304
|
-
}
|
|
305
|
-
finally {
|
|
306
|
-
db.close();
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
catch (e) {
|
|
310
|
-
if (e instanceof SqliteParseError) {
|
|
311
|
-
pushDbWarning(warnings, ZCODE_DB, e);
|
|
312
|
-
return [];
|
|
313
|
-
}
|
|
314
|
-
throw e;
|
|
315
|
-
}
|
|
316
|
-
const out = [];
|
|
317
|
-
for (const row of rows) {
|
|
318
|
-
// `subagent_child` sessions are sub-agent conversations (Explore/research
|
|
319
|
-
// dispatches). Exclude them from the default list — they are noise for
|
|
320
|
-
// daily-review workflows, which care about the user's interactive sessions.
|
|
321
|
-
// They are excluded across list/search/extract; relax this filter if a
|
|
322
|
-
// future workflow needs to inspect sub-agent runs.
|
|
323
|
-
const taskType = typeof row.task_type === "string" ? row.task_type : "";
|
|
324
|
-
if (taskType === "subagent_child")
|
|
325
|
-
continue;
|
|
326
|
-
const directory = typeof row.directory === "string" ? row.directory : undefined;
|
|
327
|
-
if (f.cwd && !sameProject(directory, f.cwd))
|
|
328
|
-
continue;
|
|
329
|
-
const created = toIso(row.time_created);
|
|
330
|
-
const updated = toIso(row.time_updated) ?? created;
|
|
331
|
-
if (!inRangeOverlap(created, updated, f))
|
|
332
|
-
continue;
|
|
333
|
-
out.push({
|
|
334
|
-
platform: "zcode",
|
|
335
|
-
id: typeof row.id === "string" ? row.id : "",
|
|
336
|
-
title: typeof row.title === "string" ? row.title : undefined,
|
|
337
|
-
cwd: directory,
|
|
338
|
-
created,
|
|
339
|
-
updated,
|
|
340
|
-
filePath: ZCODE_DB,
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
return out;
|
|
344
|
-
}
|
|
345
|
-
function toIso(epochMs) {
|
|
346
|
-
return typeof epochMs === "number" && epochMs > 0
|
|
347
|
-
? new Date(epochMs).toISOString()
|
|
348
|
-
: undefined;
|
|
349
|
-
}
|
|
350
|
-
// ---------- extract ----------
|
|
351
|
-
/**
|
|
352
|
-
* Build cleaned dialogue turns from a session's messages + parts. Each message
|
|
353
|
-
* is one turn; its text is the concatenation of its `text`-typed parts after
|
|
354
|
-
* injection-tag stripping. Messages with no surviving text are dropped.
|
|
355
|
-
*/
|
|
356
|
-
export function zcodeExtractDialogue(s, warnings = []) {
|
|
357
|
-
const { messages, partsByMsg } = readSessionMessages(s.filePath, s.id, warnings);
|
|
358
|
-
const summaryIds = compactSummaryMessageIds(messages, partsByMsg);
|
|
359
|
-
const turns = [];
|
|
360
|
-
for (const msg of messages) {
|
|
361
|
-
const parts = partsByMsg.get(msg.id) ?? [];
|
|
362
|
-
const turn = buildTextTurn(msg, parts, summaryIds);
|
|
363
|
-
if (turn)
|
|
364
|
-
turns.push(turn);
|
|
365
|
-
}
|
|
366
|
-
return turns;
|
|
367
|
-
}
|
|
368
|
-
export function zcodeSearch(s, kw, warnings = []) {
|
|
369
|
-
return searchInDialogue(zcodeExtractDialogue(s, warnings), kw);
|
|
370
|
-
}
|
|
371
|
-
// ---------- phase slicing (task.py boundary detection) ----------
|
|
372
|
-
/**
|
|
373
|
-
* Single pass over messages + parts. Emits both the cleaned dialogue turns and
|
|
374
|
-
* the list of `task.py create|start` invocations found in `Bash` tool parts
|
|
375
|
-
* (`{type:"tool", tool:"Bash", state:{input:{command:"..."}}}`). `turnIndex`
|
|
376
|
-
* for each event is the turn count at the time the tool ran.
|
|
377
|
-
*
|
|
378
|
-
* Compaction: ZCode writes a summary message with a `compaction` part carrying
|
|
379
|
-
* `tail_start_id` / `compactBoundary`. The summarized messages remain in the
|
|
380
|
-
* database, so they stay in the turn pool and the summary message becomes a
|
|
381
|
-
* boundary marker — `task.py` boundaries from before a compaction keep pointing
|
|
382
|
-
* at turns that are still there.
|
|
383
|
-
*
|
|
384
|
-
* turnIndex note (differs slightly from claude/codex): in ZCode a message's
|
|
385
|
-
* text parts and tool parts are siblings within one message. This loop pushes
|
|
386
|
-
* the message's text turn *before* recording its tool events, so a tool event
|
|
387
|
-
* on message M has turnIndex = (turns including M's text). claude/codex
|
|
388
|
-
* instead record the event before pushing the text, so their turnIndex is one
|
|
389
|
-
* less. Both are internally self-consistent for brainstorm-window slicing
|
|
390
|
-
* (create and start use the same convention within a platform), so phase
|
|
391
|
-
* boundaries compute correctly. The ZCode ordering reflects real time order
|
|
392
|
-
* (the assistant writes, then the tool runs). Do not "align" this without also
|
|
393
|
-
* adjusting the test expectations.
|
|
394
|
-
*/
|
|
395
|
-
export function collectZcodeTurnsAndEvents(s, warnings = []) {
|
|
396
|
-
const { messages, partsByMsg } = readSessionMessages(s.filePath, s.id, warnings);
|
|
397
|
-
const summaryIds = compactSummaryMessageIds(messages, partsByMsg);
|
|
398
|
-
const turns = [];
|
|
399
|
-
const events = [];
|
|
400
|
-
for (const msg of messages) {
|
|
401
|
-
const parts = partsByMsg.get(msg.id) ?? [];
|
|
402
|
-
// First emit any text the message produced (so turnIndex reflects turns
|
|
403
|
-
// accumulated so far before tool events are recorded).
|
|
404
|
-
const turn = buildTextTurn(msg, parts, summaryIds);
|
|
405
|
-
if (turn)
|
|
406
|
-
turns.push(turn);
|
|
407
|
-
// Then scan for Bash tool parts carrying task.py commands.
|
|
408
|
-
for (const part of parts) {
|
|
409
|
-
const pd = part.data;
|
|
410
|
-
if (pd.type !== "tool")
|
|
411
|
-
continue;
|
|
412
|
-
if (pd.tool !== "Bash" && pd.tool !== "bash")
|
|
413
|
-
continue;
|
|
414
|
-
const cmd = pd.state?.input?.command;
|
|
415
|
-
if (typeof cmd !== "string" || !cmd)
|
|
416
|
-
continue;
|
|
417
|
-
const parsedAll = parseTaskPyCommandsAll(cmd);
|
|
418
|
-
const ts = toIso(part.time_created) ?? "";
|
|
419
|
-
for (const parsed of parsedAll) {
|
|
420
|
-
const ev = {
|
|
421
|
-
action: parsed.action,
|
|
422
|
-
timestamp: ts,
|
|
423
|
-
turnIndex: turns.length,
|
|
424
|
-
...(parsed.action === "create"
|
|
425
|
-
? { slug: parsed.slug }
|
|
426
|
-
: { taskDir: parsed.taskDir }),
|
|
427
|
-
};
|
|
428
|
-
events.push(ev);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
return { turns, events };
|
|
433
|
-
}
|
|
434
|
-
//# sourceMappingURL=zcode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zcode.js","sourceRoot":"","sources":["../../../src/mem/adapters/zcode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,2BAA2B,GAE5B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAA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E;oBACb,SAAS,EAAE,KAAK,CAAC,MAAM;oBACvB,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ;wBAC5B,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;wBACvB,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;iBACjC,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zero-dependency read-only SQLite file parser.
|
|
3
|
-
*
|
|
4
|
-
* `@blulotus/trellis-core` is intentionally free of runtime dependencies —
|
|
5
|
-
* `better-sqlite3` was tried for the OpenCode adapter and reverted because its
|
|
6
|
-
* native build chain broke `npm install` on Windows + restricted networks. This
|
|
7
|
-
* parser is the minimum viable reader needed by the ZCode `mem` adapter: list
|
|
8
|
-
* tables, full-scan one table, return rows as `{ [columnName]: value }`. It is
|
|
9
|
-
* NOT a SQL engine: no WHERE pushdown, no index lookup, no writes.
|
|
10
|
-
*
|
|
11
|
-
* Scope:
|
|
12
|
-
* - Database header (page size, db size, text encoding, WAL flag)
|
|
13
|
-
* - Table b-tree leaf (0x0d) + interior (0x05) traversal
|
|
14
|
-
* - Record decode for TEXT / INTEGER / NULL / float64 / BLOB(serial only)
|
|
15
|
-
* - Overflow page chains (long TEXT rows like ZCode `message.data`)
|
|
16
|
-
* - WAL replay: stable main/WAL snapshot, WAL-index `mxFrame` end mark, and
|
|
17
|
-
* cumulative header/frame checksum verification.
|
|
18
|
-
*
|
|
19
|
-
* Out of scope:
|
|
20
|
-
* - WITHOUT ROWID tables (return [] — their rows live in index b-trees,
|
|
21
|
-
* which this parser doesn't walk). ZCode's tables are normal rowid tables.
|
|
22
|
-
*
|
|
23
|
-
* Format references:
|
|
24
|
-
* - https://www.sqlite.org/fileformat2.html
|
|
25
|
-
* - https://www.sqlite.org/walformat.html
|
|
26
|
-
*
|
|
27
|
-
* All multi-byte integers are big-endian (SQLite's native byte order).
|
|
28
|
-
*/
|
|
29
|
-
/** One row from `scanTable`, keyed by column name. Values are decoded JS
|
|
30
|
-
* primitives. NULL → null, INTEGER → number, TEXT → string, BLOB →
|
|
31
|
-
* Uint8Array, float → number. Columns are keyed by the CREATE TABLE column
|
|
32
|
-
* order; if the column-name parse failed, keys fall back to `col0`, `col1`... */
|
|
33
|
-
export type SqliteRow = Record<string, unknown>;
|
|
34
|
-
export interface SqliteTableInfo {
|
|
35
|
-
name: string;
|
|
36
|
-
rootPgno: number;
|
|
37
|
-
/** The raw `CREATE TABLE` SQL (used to recover column names). */
|
|
38
|
-
sql: string;
|
|
39
|
-
}
|
|
40
|
-
export interface SqliteReadOnly {
|
|
41
|
-
/** List user tables (type='table') from sqlite_master. */
|
|
42
|
-
listTables(): SqliteTableInfo[];
|
|
43
|
-
/** Full-scan a table by name, yielding rows. Returns [] when the table is
|
|
44
|
-
* missing. Throws `SqliteParseError` on structural corruption. */
|
|
45
|
-
scanTable(tableName: string, predicate?: (row: SqliteRow) => boolean): SqliteRow[];
|
|
46
|
-
/** The db file path this reader was opened against. */
|
|
47
|
-
readonly dbPath: string;
|
|
48
|
-
close(): void;
|
|
49
|
-
}
|
|
50
|
-
/** Thrown when the SQLite file is structurally invalid. Adapters are expected
|
|
51
|
-
* to catch this and degrade to an empty result rather than crash the CLI. */
|
|
52
|
-
export declare class SqliteParseError extends Error {
|
|
53
|
-
readonly cause?: unknown | undefined;
|
|
54
|
-
constructor(message: string, cause?: unknown | undefined);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Thrown when the database files do not remain stable across all snapshot
|
|
58
|
-
* capture attempts. This is deliberately distinct from a malformed database:
|
|
59
|
-
* callers must not parse a snapshot whose consistency they could not verify.
|
|
60
|
-
*/
|
|
61
|
-
export declare class SqliteSnapshotUnstableError extends SqliteParseError {
|
|
62
|
-
constructor(mainPath: string);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Open a SQLite database file for read-only access. Automatically loads the
|
|
66
|
-
* sibling `<db>-wal` file when present so active WAL-mode databases (e.g.
|
|
67
|
-
* ZCode's running store) return their latest committed data.
|
|
68
|
-
*
|
|
69
|
-
* Throws `SqliteParseError` if `mainPath` is not a SQLite file or is too
|
|
70
|
-
* corrupted to read the header. Adapters should catch and degrade.
|
|
71
|
-
*/
|
|
72
|
-
export declare function openSqliteReadOnly(mainPath: string): SqliteReadOnly;
|
|
73
|
-
/** Convenience: open + scan + close in one call. Returns [] on any parse error
|
|
74
|
-
* or missing table, never throws. Useful for adapters that already decided to
|
|
75
|
-
* degrade silently. */
|
|
76
|
-
export declare function scanTableSafe(mainPath: string, tableName: string): SqliteRow[];
|
|
77
|
-
//# sourceMappingURL=sqlite-readonly.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-readonly.d.ts","sourceRoot":"","sources":["../../../src/mem/internal/sqlite-readonly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH;;;iFAGiF;AACjF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,cAAc;IAC7B,0DAA0D;IAC1D,UAAU,IAAI,eAAe,EAAE,CAAC;IAChC;sEACkE;IAClE,SAAS,CACP,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,GACtC,SAAS,EAAE,CAAC;IACf,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,KAAK,IAAI,IAAI,CAAC;CACf;AAID;6EAC6E;AAC7E,qBAAa,gBAAiB,SAAQ,KAAK;IAGvC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO;gBADxB,OAAO,EAAE,MAAM,EACN,KAAK,CAAC,EAAE,OAAO,YAAA;CAK3B;AAED;;;;GAIG;AACH,qBAAa,2BAA4B,SAAQ,gBAAgB;gBACnD,QAAQ,EAAE,MAAM;CAM7B;AAyxBD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CA2HnE;AAED;;uBAEuB;AACvB,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,SAAS,EAAE,CAWb"}
|