feat(core): add first-class Pi session indexing (#23)
Pi cannot be read as another linear JSONL stream. Its history is a tree with a durable leaf, orphan roots, branch summaries, and two compaction forms, so the active context is something the format states rather than something line order implies. The adapter keeps those semantics inside itself and projects the result into the existing canonical tables. Sessions are keyed by (normalized header cwd, header id) rather than by path, because Pi's --session-id lookup is project-local: two projects may reuse an id, while a move or an identical copy is still one session. Discovery covers both layouts Pi writes and fingerprints each file by mtime, ctime, size and inode, so a rewrite that preserves mtime is not read as unchanged. Abandoned branches are preserved rather than dropped. Visibility becomes three-state -- visible, inactive, hidden -- and helpers return only visible rows until includeInactive asks for the superseded path, labeling every row so a caller knows which it holds. Usage counts all three, because an abandoned call still spent tokens; message_count reports only the visible transcript. A committed MIT-licensed oracle transcribed from Pi 0.83.0 pins the context algorithms, and a fixed-seed differential runs 512 generated sessions against it on every test run. Schema changes are additive.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# Obelisk CLI
|
||||
|
||||
The local Obelisk runtime used by coding agents. It indexes Claude Code and
|
||||
Codex transcripts into `~/.obelisk/obelisk.sqlite` and exposes the stable
|
||||
`build`, `search`, `query`, and `attune` process interface.
|
||||
The local Obelisk runtime used by coding agents. It indexes Claude Code, Codex,
|
||||
Kimi Code, and Pi transcripts into `~/.obelisk/obelisk.sqlite` and exposes the
|
||||
stable `build`, `search`, `query`, and `attune` process interface.
|
||||
|
||||
```bash
|
||||
npm install --global @obelisk-apps/cli
|
||||
|
||||
@@ -32,7 +32,27 @@ async function main() {
|
||||
}
|
||||
if (args[0] === '--build') {
|
||||
try {
|
||||
buildIndex({ force: true });
|
||||
const result = buildIndex({ force: true });
|
||||
if (!('complete' in result) || result.complete !== true) {
|
||||
const reason = 'reason' in result && typeof result.reason === 'string'
|
||||
? result.reason
|
||||
: 'incomplete_snapshot';
|
||||
const issue = 'inventoryIssues' in result && Array.isArray(result.inventoryIssues)
|
||||
? result.inventoryIssues[0] as { provider?: unknown; path?: unknown; error?: unknown } | undefined
|
||||
: undefined;
|
||||
let detail = '';
|
||||
if ('error' in result && typeof result.error === 'string') {
|
||||
detail = ` (${result.error})`;
|
||||
} else if (
|
||||
issue
|
||||
&& typeof issue.provider === 'string'
|
||||
&& typeof issue.path === 'string'
|
||||
&& typeof issue.error === 'string'
|
||||
) {
|
||||
detail = ` (${issue.provider} at ${issue.path}: ${issue.error})`;
|
||||
}
|
||||
throw new Error(`Index rebuild was not published: ${reason}${detail}`);
|
||||
}
|
||||
process.stdout.write(JSON.stringify({ ok: true, db: DB_PATH }) + '\n');
|
||||
} catch (error) { fail(error); }
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user