sphica 0.6.59 → 0.6.60
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/.claude-plugin/plugin.json +1 -7
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +3 -6
- package/dist/deliver.js +28 -387
- package/hooks/codex.json +0 -11
- package/hooks/hooks.json +0 -28
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://anthropic.com/claude-code/plugin.schema.json",
|
|
3
3
|
"name": "sphica",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.60",
|
|
5
5
|
"description": "Records Claude Code and Codex sessions on your machine and keeps past implementation and decisions, with their sources, for your agent to find.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "iroha924",
|
|
@@ -29,12 +29,6 @@
|
|
|
29
29
|
"title": "Automatic trace",
|
|
30
30
|
"description": "At the start of a new session, ask the agent to trace earlier sessions that wait to be traced. SPHICA_AUTO_TRACE=off keeps it off either way",
|
|
31
31
|
"default": true
|
|
32
|
-
},
|
|
33
|
-
"shell_write_delivery": {
|
|
34
|
-
"type": "boolean",
|
|
35
|
-
"title": "Records after shell writes (trial)",
|
|
36
|
-
"description": "After a shell command changes a file that past decisions apply to, show those decisions right away. SPHICA_SHELL_WRITE_DELIVERY=on or off overrides it",
|
|
37
|
-
"default": false
|
|
38
32
|
}
|
|
39
33
|
}
|
|
40
34
|
}
|
package/README.md
CHANGED
|
@@ -32,7 +32,6 @@ The database is a single SQLite file on your machine.
|
|
|
32
32
|
- **Forget what should not have been kept.** `/sphica:forget` removes the messages, pull request items, or file excerpts you pick, with their search entries and the bytes left in the database file, after you confirm in a dialog. Records that cited them are judged again and leave active when nothing else supports them; a record's own text stays as it was.
|
|
33
33
|
- **Shown when it matters.** At session start, the current work; before the agent reads or edits a file, or runs a shell command that names it, the decisions tied to that file; when your prompt names a recorded option or code symbol, that record. An AI's decision is marked as one, with a note that the agent may depart from it for a stated reason.
|
|
34
34
|
- **A command that failed before is stopped once.** When a dead end is recorded with the command it is about (such as `pnpm test --watch`), the first shell call in a conversation that runs that command is stopped, with the dead end as the reason. The agent checks the record and takes another way, or runs the call again, which then goes through.
|
|
35
|
-
- **Shown after a shell command changes a file (trial, off by default).** A script or command that rewrites a file without naming it gets past the delivery before the command. With the `shell_write_delivery` setting on, Sphica compares the content of the files your decisions apply to before and after each shell command, and right after the command shows the decisions on the files whose content changed and that the agent has not seen in this conversation. [Settings](https://github.com/iroha924/sphica#settings) says how to turn it on.
|
|
36
35
|
- **Search in Japanese and English.** Records are made with search words in both languages, so a question in either language is more likely to find them.
|
|
37
36
|
- **Find what you asked before.** Ask the agent whether you asked something like this before: `search` with `asked: true` shows your earlier messages in other sessions, the records that quote them (with what replaced them), and says "no recorded decision" when none was recorded, including a matter you raised in several sessions.
|
|
38
37
|
- **See how a decision changed, and what held at a past time.** Ask the agent how a decision came to be: `read` with `timeline: true` shows the decisions it replaced or was replaced by, when each change took effect and why, and the findings, dead ends, and questions saved by the same trace or harvest or tied to the same code, oldest first. Ask what was decided as of a time: `search` with `as_of` (a time with its offset, such as `2026-10-01T09:00:00+09:00`) searches the records as Sphica held them then, by the states and replacements of that time, and names apart the ones saved later that match now (oldest first, up to ten, then a count). The time is when Sphica saved a record, not when the words were said, so a session traced late or a pull request harvested late counts from the day it was saved.
|
|
@@ -121,11 +120,10 @@ Without being asked, Sphica adds a few past records to what the agent sees, each
|
|
|
121
120
|
- At session start: the current work and project-wide constraints, and, when earlier sessions wait to be traced, a request to trace them after your request is done.
|
|
122
121
|
- On a prompt that names a recorded code symbol, file path, or option.
|
|
123
122
|
- Before the agent reads or edits a file a decision applies to, and before a shell command that names such a file (naming it is not proof the command reads it). A read shows each record once per session.
|
|
124
|
-
- After a shell command that changed the content of such a file, when the `shell_write_delivery` setting is on (off by default): the decisions on it the agent has not seen in this conversation.
|
|
125
123
|
- Before a shell command that runs the command a recorded dead end is about: the call is stopped, with the dead end as the reason. A dead end stops a conversation once (once more after a compaction or `/clear`), and a conversation is stopped at most three times. Running the call again goes through. Past three stops, or for a dead end the conversation has already seen, the dead end is shown without stopping, within the read limit.
|
|
126
124
|
- Before a review. When you run your own review command (any name containing `review`, or a name listed in the review commands [setting](https://github.com/iroha924/sphica#settings)), it gets the decisions your local change touches. `/sphica:review` checks them itself.
|
|
127
125
|
|
|
128
|
-
In Codex the same happens at session start, on a prompt, before an `apply_patch` edit, before a shell command that names such a file (Codex reads files through shell commands, so this covers reads), before a shell command that runs a dead end's command (stopped once, as in Claude Code)
|
|
126
|
+
In Codex the same happens at session start, on a prompt, before an `apply_patch` edit, before a shell command that names such a file (Codex reads files through shell commands, so this covers reads), and before a shell command that runs a dead end's command (stopped once, as in Claude Code).
|
|
129
127
|
Before a review, Codex gets the same decisions in three cases: its built-in review (`/review`, `codex review`), a review skill you name in the prompt (`$my-review`), and a review skill the agent picks itself, when it prints the skill's file with one plain command such as `cat <path>/SKILL.md`. A skill is a review when its name contains `review` or is listed in `SPHICA_REVIEW_COMMANDS`. `$sphica:review` checks them itself.
|
|
130
128
|
|
|
131
129
|
The agent searches with Sphica's `search` and opens full records with `read`. `status` tells it how much of the history has been traced, so an empty search is less likely to be mistaken for "never decided".
|
|
@@ -135,17 +133,16 @@ The agent searches with Sphica's `search` and opens full records with `read`. `s
|
|
|
135
133
|
| Setting | Default | Claude Code option | Environment variable |
|
|
136
134
|
|---|---|---|---|
|
|
137
135
|
| Automatic trace | on | `auto_trace` | `SPHICA_AUTO_TRACE` (`off`) |
|
|
138
|
-
| Delivery after a shell command changes a file (trial) | off | `shell_write_delivery` | `SPHICA_SHELL_WRITE_DELIVERY` (`on` or `off`) |
|
|
139
136
|
| Your own review commands whose names do not contain `review`, comma-separated | none | `review_commands` | `SPHICA_REVIEW_COMMANDS` |
|
|
140
137
|
|
|
141
|
-
- **Claude Code.** Set the plugin's options in `/config` (Claude Code 2.1.269 or later), or set the variables in the environment Claude Code starts from; for the automatic trace, `"SPHICA_AUTO_TRACE": "off"` under `env` in `settings.json` works too. The automatic trace stays off when either the option or the variable says off, so to turn it back on, turn the option on and unset the variable.
|
|
138
|
+
- **Claude Code.** Set the plugin's options in `/config` (Claude Code 2.1.269 or later), or set the variables in the environment Claude Code starts from; for the automatic trace, `"SPHICA_AUTO_TRACE": "off"` under `env` in `settings.json` works too. The automatic trace stays off when either the option or the variable says off, so to turn it back on, turn the option on and unset the variable. When `review_commands` names any command, `SPHICA_REVIEW_COMMANDS` is not read.
|
|
142
139
|
- **Codex.** Codex plugins have no options page, so the settings are the environment variables. In a session that runs through Codex's background server (the terminal does by default), Sphica's hooks see the environment that server started with, not the terminal you open later: a value you set afterwards takes effect the next time the server starts (`codex app-server daemon restart` starts it again; work running in Codex may be interrupted). `codex exec` does not use that server, so its hooks see the environment it was started from. A background server started from inside an agent's shell (for example `! codex` in Claude Code) keeps that agent's variables too: Sphica then takes every session that runs through it for that agent's child and records nothing until the server starts again.
|
|
143
140
|
|
|
144
141
|
## What gets recorded and where it goes
|
|
145
142
|
|
|
146
143
|
- **Where.** The database is `~/.sphica/sphica.db`. Captured sessions wait in a local queue, `~/.sphica/spool`, until they are written to it. Each machine has its own database; nothing is shared between machines.
|
|
147
144
|
- **What.** Your prompts, the agent's final reply for each turn, and the paths of changed files. In Codex, a session is recorded only when Codex's own session log shows the messages come from the session's own thread: what Codex's built-in review is asked (its instructions, the subject of the commit it names) is not recorded, and neither is a `codex exec --ephemeral` run, which keeps no log. When Sphica cannot confirm a session, it records nothing of it; Codex's terminal shows Sphica's notice once, and `codex exec` shows none. Background-task notifications and messages from other agents are skipped when Sphica recognizes their format. Replies in the middle of a turn are not kept, nor are files created and deleted within one turn without the edit tools.
|
|
148
|
-
- **What was shown.** Each automatic delivery is logged by which records it showed, not their text.
|
|
145
|
+
- **What was shown.** Each automatic delivery is logged by which records it showed, not their text.
|
|
149
146
|
- **Unregistered repositories.** Sessions in a repository you have not registered stay in the queue and are written after you register it. Held sessions are dropped after 30 days, and when more than 1,000 are waiting the oldest go first.
|
|
150
147
|
- **Secrets.** In your prompts, pull request text, and the file lines `/sphica:glean` cites, only secrets with a recognizable shape are masked:
|
|
151
148
|
- keys with known prefixes
|
package/dist/deliver.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// server/src/deliver.ts
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import fs10 from "node:fs";
|
|
5
|
+
import path11 from "node:path";
|
|
6
6
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7
7
|
|
|
8
8
|
// server/node_modules/kysely/dist/util/object-utils.js
|
|
@@ -13423,225 +13423,6 @@ function untrackedFiles(root, rels, until) {
|
|
|
13423
13423
|
return { files, read };
|
|
13424
13424
|
}
|
|
13425
13425
|
|
|
13426
|
-
// server/src/shell-state.ts
|
|
13427
|
-
import { createHash } from "node:crypto";
|
|
13428
|
-
import fs10 from "node:fs";
|
|
13429
|
-
import path11 from "node:path";
|
|
13430
|
-
var READS = 3;
|
|
13431
|
-
var SNAPSHOT_LIFE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
13432
|
-
var dir = (...parts) => path11.join(sphicaHome(), "shell-state", ...parts);
|
|
13433
|
-
var sha = (s) => createHash("sha256").update(s).digest("hex");
|
|
13434
|
-
var signature = (st) => ({
|
|
13435
|
-
dev: String(st.dev),
|
|
13436
|
-
ino: String(st.ino),
|
|
13437
|
-
size: String(st.size),
|
|
13438
|
-
mtimeNs: String(st.mtimeNs),
|
|
13439
|
-
ctimeNs: String(st.ctimeNs)
|
|
13440
|
-
});
|
|
13441
|
-
var same = (a, b) => a.dev === b.dev && a.ino === b.ino && a.size === b.size && a.mtimeNs === b.mtimeNs && a.ctimeNs === b.ctimeNs;
|
|
13442
|
-
function inside(root, rel) {
|
|
13443
|
-
const real = fs10.realpathSync.native(root);
|
|
13444
|
-
const file = path11.resolve(root, rel);
|
|
13445
|
-
if (leaves2(path11.relative(root, file)))
|
|
13446
|
-
return null;
|
|
13447
|
-
let probe = file;
|
|
13448
|
-
while (!fs10.existsSync(probe)) {
|
|
13449
|
-
const up = path11.dirname(probe);
|
|
13450
|
-
if (up === probe)
|
|
13451
|
-
return null;
|
|
13452
|
-
probe = up;
|
|
13453
|
-
}
|
|
13454
|
-
return leaves2(path11.relative(real, fs10.realpathSync.native(probe))) ? null : file;
|
|
13455
|
-
}
|
|
13456
|
-
var leaves2 = (rel) => rel === ".." || rel.startsWith(`..${path11.sep}`) || path11.isAbsolute(rel);
|
|
13457
|
-
var cacheFile = (root) => dir("cache", `${sha(fs10.realpathSync.native(root))}.json`);
|
|
13458
|
-
function loadCache(root) {
|
|
13459
|
-
try {
|
|
13460
|
-
const raw = JSON.parse(fs10.readFileSync(cacheFile(root), "utf8"));
|
|
13461
|
-
const out = new Map;
|
|
13462
|
-
if (raw && typeof raw === "object" && !Array.isArray(raw))
|
|
13463
|
-
for (const [k, v] of Object.entries(raw)) {
|
|
13464
|
-
const e = v;
|
|
13465
|
-
if (e?.sig && typeof e.hash === "string" && /^[0-9a-f]{64}$/.test(e.hash) && validSig(e.sig))
|
|
13466
|
-
out.set(k, { sig: e.sig, hash: e.hash });
|
|
13467
|
-
}
|
|
13468
|
-
return out;
|
|
13469
|
-
} catch {
|
|
13470
|
-
return new Map;
|
|
13471
|
-
}
|
|
13472
|
-
}
|
|
13473
|
-
var validSig = (s) => !!s && typeof s === "object" && ["dev", "ino", "size"].every((k) => /^\d+$/.test(String(s[k]))) && ["mtimeNs", "ctimeNs"].every((k) => /^-?\d+$/.test(String(s[k])));
|
|
13474
|
-
function publish(file, text3) {
|
|
13475
|
-
fs10.mkdirSync(path11.dirname(file), { recursive: true });
|
|
13476
|
-
const tmp = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
13477
|
-
fs10.writeFileSync(tmp, text3);
|
|
13478
|
-
fs10.renameSync(tmp, file);
|
|
13479
|
-
}
|
|
13480
|
-
function saveCache(root, cache, watched) {
|
|
13481
|
-
try {
|
|
13482
|
-
const kept = watched.flatMap((rel) => {
|
|
13483
|
-
const e = cache.get(rel);
|
|
13484
|
-
return e ? [[rel, e]] : [];
|
|
13485
|
-
});
|
|
13486
|
-
publish(cacheFile(root), JSON.stringify(Object.fromEntries(kept)));
|
|
13487
|
-
} catch {}
|
|
13488
|
-
}
|
|
13489
|
-
function readHash(fd, deadline) {
|
|
13490
|
-
const h = createHash("sha256");
|
|
13491
|
-
const buf = Buffer.allocUnsafe(1 << 20);
|
|
13492
|
-
for (let n = fs10.readSync(fd, buf, 0, buf.length, null);n > 0; n = fs10.readSync(fd, buf, 0, buf.length, null)) {
|
|
13493
|
-
h.update(buf.subarray(0, n));
|
|
13494
|
-
if (Date.now() >= deadline)
|
|
13495
|
-
return "deadline";
|
|
13496
|
-
}
|
|
13497
|
-
return h.digest("hex");
|
|
13498
|
-
}
|
|
13499
|
-
var failed = (e) => {
|
|
13500
|
-
const code = e.code;
|
|
13501
|
-
return code === "ENOENT" || code === "ENOTDIR" ? { kind: "missing" } : { kind: "unreadable", reason: String(code) };
|
|
13502
|
-
};
|
|
13503
|
-
function readOpened(root, file, fd, sig, deadline) {
|
|
13504
|
-
const opened = fs10.fstatSync(fd, { bigint: true });
|
|
13505
|
-
if (!same(sig, signature(opened)))
|
|
13506
|
-
return "again";
|
|
13507
|
-
const real = fs10.realpathSync.native(file);
|
|
13508
|
-
if (leaves2(path11.relative(fs10.realpathSync.native(root), real)))
|
|
13509
|
-
return { kind: "unreadable", reason: "outside the checkout" };
|
|
13510
|
-
const there = fs10.lstatSync(real, { bigint: true });
|
|
13511
|
-
if (there.dev !== opened.dev || there.ino !== opened.ino)
|
|
13512
|
-
return "again";
|
|
13513
|
-
const hash = readHash(fd, deadline);
|
|
13514
|
-
if (hash === "deadline")
|
|
13515
|
-
return { kind: "unknown", reason: "deadline" };
|
|
13516
|
-
if (!same(sig, signature(fs10.fstatSync(fd, { bigint: true }))))
|
|
13517
|
-
return "again";
|
|
13518
|
-
if (!same(sig, signature(fs10.lstatSync(file, { bigint: true }))))
|
|
13519
|
-
return "again";
|
|
13520
|
-
return { kind: "ok", sig, hash };
|
|
13521
|
-
}
|
|
13522
|
-
function stateOf(root, rel, cache, deadline) {
|
|
13523
|
-
for (let i = 0;i < READS; i++) {
|
|
13524
|
-
if (Date.now() >= deadline)
|
|
13525
|
-
return { kind: "unknown", reason: "deadline" };
|
|
13526
|
-
let file;
|
|
13527
|
-
let before;
|
|
13528
|
-
try {
|
|
13529
|
-
file = inside(root, rel);
|
|
13530
|
-
if (!file)
|
|
13531
|
-
return { kind: "unreadable", reason: "outside the checkout" };
|
|
13532
|
-
before = fs10.lstatSync(file, { bigint: true });
|
|
13533
|
-
if (before.isSymbolicLink()) {
|
|
13534
|
-
file = fs10.realpathSync.native(file);
|
|
13535
|
-
if (leaves2(path11.relative(fs10.realpathSync.native(root), file)))
|
|
13536
|
-
return { kind: "unreadable", reason: "outside the checkout" };
|
|
13537
|
-
before = fs10.lstatSync(file, { bigint: true });
|
|
13538
|
-
}
|
|
13539
|
-
} catch (e) {
|
|
13540
|
-
return failed(e);
|
|
13541
|
-
}
|
|
13542
|
-
if (!before.isFile())
|
|
13543
|
-
return { kind: "unreadable", reason: "not a regular file" };
|
|
13544
|
-
const sig = signature(before);
|
|
13545
|
-
const cached = cache.get(rel);
|
|
13546
|
-
if (cached && same(cached.sig, sig))
|
|
13547
|
-
return { kind: "ok", sig, hash: cached.hash };
|
|
13548
|
-
let fd;
|
|
13549
|
-
try {
|
|
13550
|
-
fd = fs10.openSync(file, "r");
|
|
13551
|
-
} catch (e) {
|
|
13552
|
-
if (e.code === "ENOENT")
|
|
13553
|
-
continue;
|
|
13554
|
-
return failed(e);
|
|
13555
|
-
}
|
|
13556
|
-
let outcome;
|
|
13557
|
-
try {
|
|
13558
|
-
outcome = readOpened(root, file, fd, sig, deadline);
|
|
13559
|
-
} catch (e) {
|
|
13560
|
-
outcome = e.code === "ENOENT" ? "again" : failed(e);
|
|
13561
|
-
} finally {
|
|
13562
|
-
fs10.closeSync(fd);
|
|
13563
|
-
}
|
|
13564
|
-
if (outcome === "again")
|
|
13565
|
-
continue;
|
|
13566
|
-
if (outcome.kind === "ok")
|
|
13567
|
-
cache.set(rel, { sig, hash: outcome.hash });
|
|
13568
|
-
return outcome;
|
|
13569
|
-
}
|
|
13570
|
-
return { kind: "unknown", reason: "changed while read" };
|
|
13571
|
-
}
|
|
13572
|
-
function takeStates(root, rels, cache, deadline) {
|
|
13573
|
-
const out = Object.create(null);
|
|
13574
|
-
for (const rel of rels)
|
|
13575
|
-
out[rel] = stateOf(root, rel, cache, deadline);
|
|
13576
|
-
return out;
|
|
13577
|
-
}
|
|
13578
|
-
function compare(before, after) {
|
|
13579
|
-
const changed2 = [];
|
|
13580
|
-
const unknown = [];
|
|
13581
|
-
for (const rel of new Set([...Object.keys(before), ...Object.keys(after)])) {
|
|
13582
|
-
const a = before[rel];
|
|
13583
|
-
const b = after[rel];
|
|
13584
|
-
if (!a || !b || a.kind === "unknown" || a.kind === "unreadable" || b.kind === "unknown" || b.kind === "unreadable") {
|
|
13585
|
-
unknown.push(rel);
|
|
13586
|
-
continue;
|
|
13587
|
-
}
|
|
13588
|
-
if (a.kind === "missing" && b.kind === "missing")
|
|
13589
|
-
continue;
|
|
13590
|
-
if (a.kind !== b.kind || a.kind === "ok" && b.kind === "ok" && a.hash !== b.hash)
|
|
13591
|
-
changed2.push(rel);
|
|
13592
|
-
}
|
|
13593
|
-
return { changed: changed2.sort(), unknown: unknown.sort() };
|
|
13594
|
-
}
|
|
13595
|
-
var snapshotKey = (host, session, agent, call) => sha(JSON.stringify([host, session, agent ?? "", call]));
|
|
13596
|
-
var snapshotFile = (key) => dir("calls", `${key}.json`);
|
|
13597
|
-
function writeSnapshot(s) {
|
|
13598
|
-
publish(snapshotFile(s.key), JSON.stringify(s));
|
|
13599
|
-
}
|
|
13600
|
-
function takeSnapshot(key) {
|
|
13601
|
-
const file = snapshotFile(key);
|
|
13602
|
-
let raw;
|
|
13603
|
-
try {
|
|
13604
|
-
raw = JSON.parse(fs10.readFileSync(file, "utf8"));
|
|
13605
|
-
} catch {
|
|
13606
|
-
return null;
|
|
13607
|
-
}
|
|
13608
|
-
fs10.rmSync(file, { force: true });
|
|
13609
|
-
const s = raw;
|
|
13610
|
-
if (s?.v !== 1 || s.key !== key || typeof s.root !== "string" || typeof s.project !== "string" || typeof s.at !== "string" || !s.paths || typeof s.paths !== "object" || Array.isArray(s.paths) || Number.isNaN(Date.parse(s.at)))
|
|
13611
|
-
return null;
|
|
13612
|
-
if (Date.now() - Date.parse(s.at) > SNAPSHOT_LIFE_MS)
|
|
13613
|
-
return "expired";
|
|
13614
|
-
for (const v of Object.values(s.paths)) {
|
|
13615
|
-
const st = v;
|
|
13616
|
-
if (!st || !["ok", "missing", "unreadable", "unknown"].includes(st.kind))
|
|
13617
|
-
return null;
|
|
13618
|
-
if (st.kind === "ok" && (!validSig(st.sig) || !/^[0-9a-f]{64}$/.test(st.hash)))
|
|
13619
|
-
return null;
|
|
13620
|
-
}
|
|
13621
|
-
return s;
|
|
13622
|
-
}
|
|
13623
|
-
function pruneSnapshots(now = Date.now(), deadline = Number.POSITIVE_INFINITY) {
|
|
13624
|
-
let removed = 0;
|
|
13625
|
-
let names2;
|
|
13626
|
-
try {
|
|
13627
|
-
names2 = fs10.readdirSync(dir("calls"));
|
|
13628
|
-
} catch {
|
|
13629
|
-
return 0;
|
|
13630
|
-
}
|
|
13631
|
-
for (const n of names2) {
|
|
13632
|
-
if (Date.now() >= deadline)
|
|
13633
|
-
break;
|
|
13634
|
-
const file = dir("calls", n);
|
|
13635
|
-
try {
|
|
13636
|
-
if (now - fs10.statSync(file).mtimeMs > SNAPSHOT_LIFE_MS) {
|
|
13637
|
-
fs10.rmSync(file, { force: true });
|
|
13638
|
-
removed++;
|
|
13639
|
-
}
|
|
13640
|
-
} catch {}
|
|
13641
|
-
}
|
|
13642
|
-
return removed;
|
|
13643
|
-
}
|
|
13644
|
-
|
|
13645
13426
|
// server/src/trace.ts
|
|
13646
13427
|
var PENDING_DAYS = 14;
|
|
13647
13428
|
var pendingCutoff = (now) => new Date(now.getTime() - PENDING_DAYS * 86400000).toISOString();
|
|
@@ -13685,7 +13466,6 @@ async function pendingCount(db, projectId2, now = new Date, o = {}) {
|
|
|
13685
13466
|
|
|
13686
13467
|
// server/src/deliver.ts
|
|
13687
13468
|
var CONFIRM = "If, after checking a record below against the current code and its full text (Sphica's read), what you were asked to do is a change it rejected or rules out, do not make that change yet: tell the user which record and reason it conflicts with, and ask whether to go ahead.";
|
|
13688
|
-
var AFTER_CHANGE = "If, after checking a record below against the current code and its full text (Sphica's read), what this call changed is a change it rejected or rules out, tell the user which record and reason it conflicts with, and ask whether to keep or undo it.";
|
|
13689
13469
|
var CONFIRM_GOLD = CONFIRM.replace("its full text (Sphica's read)", "the record text given here");
|
|
13690
13470
|
var ASK = CONFIRM.length + 1;
|
|
13691
13471
|
var AI_ROOM = AI_DECIDED.length + 1;
|
|
@@ -13804,11 +13584,6 @@ function fit2(lines, chars, lead, free = []) {
|
|
|
13804
13584
|
};
|
|
13805
13585
|
}
|
|
13806
13586
|
var anchoredTo = (db, projectId2, rels) => deliverable(db, projectId2).innerJoin("unit_anchor as a", "a.unit_id", "u.id").where("a.path", "in", rels).where("a.role", "=", "applies_to").where("a.retired_at", "is", null).select(["u.id", "u.key", "u.kind", "u.stance", "u.text"]).groupBy("u.id").orderBy("u.id", "desc");
|
|
13807
|
-
async function anchoredRules(db, projectId2, rels) {
|
|
13808
|
-
const wanted = new Set(rels);
|
|
13809
|
-
const anchors = await deliverable(db, projectId2).innerJoin("unit_anchor as a", "a.unit_id", "u.id").where("a.role", "=", "applies_to").where("a.retired_at", "is", null).where("u.kind", "in", ["decision", "constraint"]).select(["u.id", "a.path"]).execute();
|
|
13810
|
-
return [...new Set(anchors.filter((a) => wanted.has(a.path)).map((a) => a.id))].sort((a, b) => b - a);
|
|
13811
|
-
}
|
|
13812
13587
|
var named = (rels) => rels.length <= 3 ? rels.map(inline).join(", ") : `${rels.slice(0, 3).map(inline).join(", ")} and ${rels.length - 3} more`;
|
|
13813
13588
|
async function beforeEdit(db, projectId2, rels) {
|
|
13814
13589
|
const rows = await anchoredTo(db, projectId2, rels).execute();
|
|
@@ -13836,25 +13611,6 @@ async function sinceRestart(db, session, agent) {
|
|
|
13836
13611
|
const sent = await db.selectFrom("delivery as d").innerJoin("delivery_unit as x", "x.delivery_id", "d.id").where("d.session_id", "=", session).where(sameAgent(agent)).where("d.id", ">", since).where("d.outcome", "=", "emitted").select(["x.unit_id", "d.event", "d.reason"]).execute();
|
|
13837
13612
|
return { since, sent };
|
|
13838
13613
|
}
|
|
13839
|
-
async function afterShellWrite(db, projectId2, rels, session, agent) {
|
|
13840
|
-
const { sent } = await sinceRestart(db, session, agent);
|
|
13841
|
-
const seen = new Set(sent.map((r) => r.unit_id));
|
|
13842
|
-
const ids = (await anchoredRules(db, projectId2, rels)).filter((id) => !seen.has(id));
|
|
13843
|
-
const top2 = ids.slice(0, LIMITS2.pre_edit.units);
|
|
13844
|
-
const shown = top2.length ? await db.selectFrom("unit as u").where("u.id", "in", top2).select(["u.id", "u.key", "u.kind", "u.stance", "u.text"]).orderBy("u.id", "desc").execute() : [];
|
|
13845
|
-
const why = await reasons(db, shown.map((u) => u.id));
|
|
13846
|
-
const ai = await aiDecided(db, shown.map((u) => u.id));
|
|
13847
|
-
const f = fitMarked(shown.map((u) => why.has(u.id) ? [line(u, why.get(u.id), ai.has(u.id)), line(u, "", ai.has(u.id))] : line(u, "", ai.has(u.id))), LIMITS2.pre_edit.chars - ASK + AFTER_CHANGE.length + 1, `Active decisions applying to ${named(rels)}, files whose content changed between before and after this call (current code relevance unverified). ${AFTER_CHANGE} ${NOTE}:`, ai, shown.map((u) => u.id));
|
|
13848
|
-
const omitted = ids.length - shown.length + f.omitted;
|
|
13849
|
-
return {
|
|
13850
|
-
...noted(f.text, f.lead, [leftOut(omitted)]),
|
|
13851
|
-
units: f.kept.flatMap((i) => shown[i]?.id ?? []),
|
|
13852
|
-
eligible: ids.length,
|
|
13853
|
-
omitted,
|
|
13854
|
-
path: head(rels.join(" "), 500),
|
|
13855
|
-
reason: SHELL_WRITE
|
|
13856
|
-
};
|
|
13857
|
-
}
|
|
13858
13614
|
var STOPPED = "command";
|
|
13859
13615
|
var COMMAND_CONTEXT = "command_context";
|
|
13860
13616
|
var STOPS = 3;
|
|
@@ -13956,15 +13712,15 @@ async function namedInCommand(db, projectId2, root, cwd, command) {
|
|
|
13956
13712
|
const edge = `\\s'"=(){}<>|;&,`;
|
|
13957
13713
|
const esc = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
13958
13714
|
const forms = (p) => {
|
|
13959
|
-
const abs =
|
|
13960
|
-
const fromCwd =
|
|
13715
|
+
const abs = path11.join(root, p);
|
|
13716
|
+
const fromCwd = path11.relative(cwd, abs);
|
|
13961
13717
|
const out = new Set;
|
|
13962
13718
|
for (const f of [p, abs, leaves(fromCwd) ? "" : fromCwd])
|
|
13963
13719
|
if (f)
|
|
13964
13720
|
for (const sep of ["/", "\\"]) {
|
|
13965
13721
|
const t = f.split(/[\\/]/).join(sep);
|
|
13966
13722
|
out.add(t);
|
|
13967
|
-
if (!
|
|
13723
|
+
if (!path11.isAbsolute(f))
|
|
13968
13724
|
out.add(`.${sep}${t}`);
|
|
13969
13725
|
}
|
|
13970
13726
|
return [...out];
|
|
@@ -14008,7 +13764,7 @@ function holds(commands, anchor) {
|
|
|
14008
13764
|
}
|
|
14009
13765
|
function pathNamed(prompt, root, rel) {
|
|
14010
13766
|
const steps = (p) => p.split(/[\\/]/).map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("[\\\\/]");
|
|
14011
|
-
return new RegExp(`(?<![A-Za-z0-9_$.\\-/\\\\])(?:(?:\\.[\\\\/])?${steps(rel)}|${steps(
|
|
13767
|
+
return new RegExp(`(?<![A-Za-z0-9_$.\\-/\\\\])(?:(?:\\.[\\\\/])?${steps(rel)}|${steps(path11.join(root, rel))})(?![A-Za-z0-9_$\\-/\\\\]|\\.[A-Za-z0-9_$])`).test(prompt);
|
|
14012
13768
|
}
|
|
14013
13769
|
function once(f) {
|
|
14014
13770
|
const seen = new Map;
|
|
@@ -14070,41 +13826,7 @@ async function onPrompt(db, projectId2, root, prompt) {
|
|
|
14070
13826
|
reason: null
|
|
14071
13827
|
};
|
|
14072
13828
|
}
|
|
14073
|
-
var SHELL_WRITE = "shell_write";
|
|
14074
|
-
var SNAPSHOT_MS = 3500;
|
|
14075
13829
|
var REVIEW_MS = 3500;
|
|
14076
|
-
var SHELL_WRITE_ON = new Set(["on", "1", "true", "yes"]);
|
|
14077
|
-
var TRIAL_CAP = 10 * 1024 * 1024;
|
|
14078
|
-
function shellWriteDelivery() {
|
|
14079
|
-
const env = (process.env.SPHICA_SHELL_WRITE_DELIVERY ?? "").trim().toLowerCase();
|
|
14080
|
-
if (AUTO_TRACE_OFF.has(env))
|
|
14081
|
-
return false;
|
|
14082
|
-
if (SHELL_WRITE_ON.has(env))
|
|
14083
|
-
return true;
|
|
14084
|
-
return SHELL_WRITE_ON.has((process.env.CLAUDE_PLUGIN_OPTION_SHELL_WRITE_DELIVERY ?? "").trim().toLowerCase());
|
|
14085
|
-
}
|
|
14086
|
-
function trialLog(line2) {
|
|
14087
|
-
try {
|
|
14088
|
-
const file = path12.join(sphicaHome(), "shell-state", "trial.jsonl");
|
|
14089
|
-
fs11.mkdirSync(path12.dirname(file), { recursive: true });
|
|
14090
|
-
if ((fs11.statSync(file, { throwIfNoEntry: false })?.size ?? 0) >= TRIAL_CAP)
|
|
14091
|
-
rotateTrial(path12.dirname(file), file);
|
|
14092
|
-
fs11.appendFileSync(file, `${JSON.stringify({ at: iso(Date.now()), ...line2 })}
|
|
14093
|
-
`);
|
|
14094
|
-
} catch {}
|
|
14095
|
-
}
|
|
14096
|
-
function rotateTrial(dir2, file) {
|
|
14097
|
-
try {
|
|
14098
|
-
fs11.renameSync(file, path12.join(dir2, `trial.${Date.now()}.${process.pid}.jsonl`));
|
|
14099
|
-
const archives = fs11.readdirSync(dir2).filter((n) => /^trial\.\d+\.\d+\.jsonl$/.test(n)).sort((a, b) => Number(b.split(".")[1]) - Number(a.split(".")[1]));
|
|
14100
|
-
let kept = 0;
|
|
14101
|
-
for (const n of archives) {
|
|
14102
|
-
kept += fs11.statSync(path12.join(dir2, n), { throwIfNoEntry: false })?.size ?? 0;
|
|
14103
|
-
if (kept > 2 * TRIAL_CAP)
|
|
14104
|
-
fs11.rmSync(path12.join(dir2, n), { force: true });
|
|
14105
|
-
}
|
|
14106
|
-
} catch {}
|
|
14107
|
-
}
|
|
14108
13830
|
var AUTO_TRACE_OFF = new Set(["off", "0", "false", "no"]);
|
|
14109
13831
|
var AUTO_TRACE = (n, skill) => `- ${n} earlier session${n === 1 ? "" : "s"} of this project ${n === 1 ? "waits" : "wait"} to be traced. After the user's request is done, ${skill ? `read \`${skill}\` and run it` : "run the trace Skill"} on your own for the oldest (at most 2), as its "On your own" section says, without asking the user.`;
|
|
14110
13832
|
function codexInteractive(input) {
|
|
@@ -14112,13 +13834,13 @@ function codexInteractive(input) {
|
|
|
14112
13834
|
return ownThread(input, thread) && thread?.originator === "codex-tui";
|
|
14113
13835
|
}
|
|
14114
13836
|
var namable = (file) => Buffer.byteLength(file) <= 1000 && !/[\p{Cc}`]/u.test(file) ? file : null;
|
|
14115
|
-
var skillFile = (skill, here2) => [
|
|
14116
|
-
function traceSkill(here2 =
|
|
13837
|
+
var skillFile = (skill, here2) => [path11.join(here2, ".."), path11.join(here2, "..", "..", "plugin")].map((root) => path11.join(root, "skills", skill, "SKILL.md")).find((f) => fs10.existsSync(f));
|
|
13838
|
+
function traceSkill(here2 = path11.dirname(fileURLToPath2(import.meta.url))) {
|
|
14117
13839
|
const file = skillFile("trace", here2);
|
|
14118
13840
|
return file ? namable(file) : null;
|
|
14119
13841
|
}
|
|
14120
13842
|
var ownReview = () => [
|
|
14121
|
-
...new Set([
|
|
13843
|
+
...new Set([path11.dirname(fileURLToPath2(import.meta.url)), path11.dirname(path11.resolve(process.argv[1] ?? ""))].flatMap((here2) => skillFile("review", here2) ?? []))
|
|
14122
13844
|
];
|
|
14123
13845
|
async function waiting(db, projectId2, place) {
|
|
14124
13846
|
if (!place.owner)
|
|
@@ -14130,7 +13852,7 @@ async function waiting(db, projectId2, place) {
|
|
|
14130
13852
|
});
|
|
14131
13853
|
if (!total)
|
|
14132
13854
|
return "";
|
|
14133
|
-
if (!markOnce("auto-trace", `${
|
|
13855
|
+
if (!markOnce("auto-trace", `${path11.resolve(place.file)}\x00${place.key}\x00${place.host}\x00${place.auto}`))
|
|
14134
13856
|
return "";
|
|
14135
13857
|
return AUTO_TRACE(total, place.skill);
|
|
14136
13858
|
}
|
|
@@ -14138,7 +13860,7 @@ async function waiting(db, projectId2, place) {
|
|
|
14138
13860
|
if (!n)
|
|
14139
13861
|
return "";
|
|
14140
13862
|
const day = new Date().toLocaleDateString("sv-SE");
|
|
14141
|
-
if (!markOnce("pending", `${
|
|
13863
|
+
if (!markOnce("pending", `${path11.resolve(place.file)}\x00${place.key}\x00${day}`))
|
|
14142
13864
|
return "";
|
|
14143
13865
|
const trace = place.host === "codex" ? "$sphica:trace" : "/sphica:trace";
|
|
14144
13866
|
return `- ${n} session${n === 1 ? "" : "s"} waiting to be traced: run ${trace} pending.`;
|
|
@@ -14286,13 +14008,13 @@ async function beforeShell(file, e, db, rels, shell, session, agent) {
|
|
|
14286
14008
|
let plans = null;
|
|
14287
14009
|
try {
|
|
14288
14010
|
await inTransaction(cap, async (trx) => {
|
|
14289
|
-
const
|
|
14290
|
-
if (
|
|
14291
|
-
await write2(trx, e,
|
|
14292
|
-
const run3 = await beforeCommand(db, await commandsRun(db, e.projectId, shell), session, agent,
|
|
14011
|
+
const path13 = await named2();
|
|
14012
|
+
if (path13?.text)
|
|
14013
|
+
await write2(trx, e, path13);
|
|
14014
|
+
const run3 = await beforeCommand(db, await commandsRun(db, e.projectId, shell), session, agent, path13, true);
|
|
14293
14015
|
if (run3.text)
|
|
14294
14016
|
await write2(trx, e, run3);
|
|
14295
|
-
plans = [
|
|
14017
|
+
plans = [path13, run3];
|
|
14296
14018
|
});
|
|
14297
14019
|
} catch {
|
|
14298
14020
|
plans = null;
|
|
@@ -14304,78 +14026,12 @@ async function beforeShell(file, e, db, rels, shell, session, agent) {
|
|
|
14304
14026
|
return { stop: [done[1].text, done[0]?.text].filter(Boolean).join(`
|
|
14305
14027
|
|
|
14306
14028
|
`) };
|
|
14307
|
-
const
|
|
14308
|
-
const run2 = done ? done[1] : await beforeCommand(db, await commandsRun(db, e.projectId, shell), session, agent,
|
|
14309
|
-
return [run2.text,
|
|
14029
|
+
const path12 = done ? done[0] : await named2();
|
|
14030
|
+
const run2 = done ? done[1] : await beforeCommand(db, await commandsRun(db, e.projectId, shell), session, agent, path12, false);
|
|
14031
|
+
return [run2.text, path12?.text].filter(Boolean).join(`
|
|
14310
14032
|
|
|
14311
14033
|
`);
|
|
14312
14034
|
}
|
|
14313
|
-
async function snapshotCall(db, projectId2, place, host, input, who, started) {
|
|
14314
|
-
const paths = await deliverablePaths(db, projectId2);
|
|
14315
|
-
const cache = loadCache(place.root);
|
|
14316
|
-
const states = takeStates(place.root, paths, cache, started + SNAPSHOT_MS);
|
|
14317
|
-
saveCache(place.root, cache, paths);
|
|
14318
|
-
const expired = pruneSnapshots(Date.now(), started + SNAPSHOT_MS);
|
|
14319
|
-
if (expired)
|
|
14320
|
-
trialLog({ host, event: "snapshot_expired", count: expired });
|
|
14321
|
-
const key = snapshotKey(host, String(input.session_id), who, String(input.tool_use_id));
|
|
14322
|
-
writeSnapshot({ v: 1, key, at: iso(started), root: place.root, project: place.key, paths: states });
|
|
14323
|
-
}
|
|
14324
|
-
async function afterShell(input, host, agent, file, started) {
|
|
14325
|
-
if (!shellWriteDelivery() || !input.session_id || !input.tool_use_id)
|
|
14326
|
-
return "";
|
|
14327
|
-
const base = { host, session: input.session_id, agent, call: input.tool_use_id };
|
|
14328
|
-
let line2 = { ...base, event: "post_shell" };
|
|
14329
|
-
let db = null;
|
|
14330
|
-
try {
|
|
14331
|
-
const before = takeSnapshot(snapshotKey(host, input.session_id, agent, input.tool_use_id));
|
|
14332
|
-
if (before === "expired" || !before) {
|
|
14333
|
-
if (!before && !identify(input.cwd ?? process.cwd()))
|
|
14334
|
-
return "";
|
|
14335
|
-
trialLog({ ...base, event: before ? "snapshot_expired" : "snapshot_missing" });
|
|
14336
|
-
return "";
|
|
14337
|
-
}
|
|
14338
|
-
const cache = loadCache(before.root);
|
|
14339
|
-
for (const [rel, st] of Object.entries(before.paths))
|
|
14340
|
-
if (st.kind === "ok")
|
|
14341
|
-
cache.set(rel, { sig: st.sig, hash: st.hash });
|
|
14342
|
-
const after = takeStates(before.root, Object.keys(before.paths), cache, started + SNAPSHOT_MS);
|
|
14343
|
-
saveCache(before.root, cache, Object.keys(before.paths));
|
|
14344
|
-
const { changed: changed2, unknown } = compare(before.paths, after);
|
|
14345
|
-
line2 = { ...line2, paths: Object.keys(before.paths).length, changed: changed2, unknown };
|
|
14346
|
-
if (!changed2.length) {
|
|
14347
|
-
trialLog({ ...line2, delivered: [] });
|
|
14348
|
-
return "";
|
|
14349
|
-
}
|
|
14350
|
-
if (!fs11.existsSync(file))
|
|
14351
|
-
throw new Error(`no database at ${file}`);
|
|
14352
|
-
db = openReader(file);
|
|
14353
|
-
const pid = await projectId(db, before.project);
|
|
14354
|
-
if (pid === null)
|
|
14355
|
-
throw new Error("the project is not registered");
|
|
14356
|
-
const reader = db;
|
|
14357
|
-
const entry = {
|
|
14358
|
-
projectId: pid,
|
|
14359
|
-
host,
|
|
14360
|
-
external: input.session_id,
|
|
14361
|
-
agent,
|
|
14362
|
-
event: "pre_edit",
|
|
14363
|
-
branch: branchOf(before.root)
|
|
14364
|
-
};
|
|
14365
|
-
let logged = false;
|
|
14366
|
-
const plan = await lockedPlan(file, entry, () => afterShellWrite(reader, pid, changed2, sessionId(pid, host, input.session_id), agent), (p) => Boolean(p.text), (w) => {
|
|
14367
|
-
logged = w;
|
|
14368
|
-
});
|
|
14369
|
-
const keys = plan.units.length ? (await reader.selectFrom("unit").select("key").where("id", "in", plan.units).execute()).map((u) => u.key) : [];
|
|
14370
|
-
trialLog({ ...line2, delivered: keys, logged: plan.text ? logged : null });
|
|
14371
|
-
return plan.text;
|
|
14372
|
-
} catch (e) {
|
|
14373
|
-
trialLog({ ...line2, delivered: [], error: head(reason(e), 200) });
|
|
14374
|
-
return "";
|
|
14375
|
-
} finally {
|
|
14376
|
-
await db?.destroy().catch(() => {});
|
|
14377
|
-
}
|
|
14378
|
-
}
|
|
14379
14035
|
async function deliver(input, host = "claude-code", file = dbFile(), started = Date.now()) {
|
|
14380
14036
|
const r = await respond(input, host, file, started);
|
|
14381
14037
|
return typeof r === "string" ? r : r.stop;
|
|
@@ -14384,13 +14040,13 @@ async function respond(input, host = "claude-code", file = dbFile(), started = D
|
|
|
14384
14040
|
const thread = host === "codex" && !agentOf(input) ? codexThread(input) : null;
|
|
14385
14041
|
const who = agentOf(input) ?? childThread(input, thread);
|
|
14386
14042
|
if (host !== "codex")
|
|
14387
|
-
return deliverOne(input, host, file,
|
|
14043
|
+
return deliverOne(input, host, file, who, reviewCall(input));
|
|
14388
14044
|
const call = codexReviewCall(input, thread, input.hook_event_name === "PreToolUse" ? ownReview() : []);
|
|
14389
14045
|
if (!call)
|
|
14390
|
-
return deliverOne(input, host, file,
|
|
14046
|
+
return deliverOne(input, host, file, who, null);
|
|
14391
14047
|
const place = identify(input.cwd ?? process.cwd());
|
|
14392
|
-
const rest = await deliverOne(input, host, file,
|
|
14393
|
-
const review = await deliverOne(input, host, file,
|
|
14048
|
+
const rest = await deliverOne(input, host, file, who, null, { place });
|
|
14049
|
+
const review = await deliverOne(input, host, file, who, call, {
|
|
14394
14050
|
place,
|
|
14395
14051
|
reviewUntil: started + REVIEW_MS
|
|
14396
14052
|
});
|
|
@@ -14399,11 +14055,8 @@ async function respond(input, host = "claude-code", file = dbFile(), started = D
|
|
|
14399
14055
|
`);
|
|
14400
14056
|
return typeof rest === "string" ? text3 : { stop: text3 };
|
|
14401
14057
|
}
|
|
14402
|
-
async function deliverOne(input, host, file,
|
|
14058
|
+
async function deliverOne(input, host, file, who, call, known = {}) {
|
|
14403
14059
|
const name = input.hook_event_name;
|
|
14404
|
-
if ((name === "PostToolUse" || name === "PostToolUseFailure") && SHELL_TOOLS.has(input.tool_name ?? ""))
|
|
14405
|
-
return afterShell(input, host, who, file, started);
|
|
14406
|
-
const snap = !call && name === "PreToolUse" && SHELL_TOOLS.has(input.tool_name ?? "") && Boolean(input.tool_use_id) && shellWriteDelivery();
|
|
14407
14060
|
const event = call ? "review" : name === "SessionStart" || name === "SubagentStart" ? "session_start" : name === "UserPromptSubmit" ? "prompt" : name === "PreToolUse" ? input.tool_name === "Read" || SHELL_TOOLS.has(input.tool_name ?? "") && !(host === "codex" && shellPatch(input)) ? "pre_read" : "pre_edit" : null;
|
|
14408
14061
|
if (!event || !input.session_id)
|
|
14409
14062
|
return "";
|
|
@@ -14416,33 +14069,22 @@ async function deliverOne(input, host, file, started, who, call, known = {}) {
|
|
|
14416
14069
|
const shell = !call && SHELL_TOOLS.has(input.tool_name ?? "") && !patch && typeof ti.command === "string" ? ti.command : null;
|
|
14417
14070
|
const targets = patch ? patchPaths2(patch) : [ti.file_path, ti.notebook_path].filter((p) => typeof p === "string").slice(0, 1);
|
|
14418
14071
|
const onPath = event === "pre_edit" || event === "pre_read";
|
|
14419
|
-
if (onPath && !shell &&
|
|
14072
|
+
if (onPath && !shell && (!(event === "pre_read" || patch || EDIT_TOOLS.has(input.tool_name ?? "")) || !targets.length))
|
|
14420
14073
|
return "";
|
|
14421
14074
|
const place = known.place !== undefined ? known.place : identify(input.cwd ?? process.cwd());
|
|
14422
14075
|
if (!place)
|
|
14423
14076
|
return "";
|
|
14424
|
-
let rels = targets.map((t) =>
|
|
14425
|
-
if (onPath && !shell && !
|
|
14077
|
+
let rels = targets.map((t) => path11.relative(place.root, path11.resolve(input.cwd ?? place.root, t))).filter((r) => r && !leaves(r)).map((r) => r.split(path11.sep).join("/"));
|
|
14078
|
+
if (onPath && !shell && !rels.length)
|
|
14426
14079
|
return "";
|
|
14427
14080
|
let db = null;
|
|
14428
14081
|
try {
|
|
14429
|
-
if (!
|
|
14082
|
+
if (!fs10.existsSync(file))
|
|
14430
14083
|
throw new Error(`no database at ${file}`);
|
|
14431
14084
|
db = openReader(file);
|
|
14432
14085
|
const pid = await projectId(db, place.key);
|
|
14433
14086
|
if (pid === null)
|
|
14434
14087
|
return "";
|
|
14435
|
-
if (snap)
|
|
14436
|
-
await snapshotCall(db, pid, place, host, input, who, started).catch((e) => trialLog({
|
|
14437
|
-
host,
|
|
14438
|
-
session: input.session_id,
|
|
14439
|
-
agent: who,
|
|
14440
|
-
call: input.tool_use_id,
|
|
14441
|
-
event: "snapshot_failed",
|
|
14442
|
-
error: head(reason(e), 200)
|
|
14443
|
-
}));
|
|
14444
|
-
if (onPath && !shell && !rels.length)
|
|
14445
|
-
return "";
|
|
14446
14088
|
let ran = [];
|
|
14447
14089
|
if (shell) {
|
|
14448
14090
|
rels = await namedInCommand(db, pid, place.root, input.cwd ?? place.root, shell);
|
|
@@ -14527,7 +14169,6 @@ export {
|
|
|
14527
14169
|
CONFIRM_GOLD,
|
|
14528
14170
|
RAN,
|
|
14529
14171
|
STOP2 as STOP,
|
|
14530
|
-
anchoredRules,
|
|
14531
14172
|
codexInteractive,
|
|
14532
14173
|
deliver,
|
|
14533
14174
|
deliverableIds,
|
package/hooks/codex.json
CHANGED
|
@@ -59,17 +59,6 @@
|
|
|
59
59
|
"timeout": 10
|
|
60
60
|
}
|
|
61
61
|
]
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"matcher": "^Bash$",
|
|
65
|
-
"hooks": [
|
|
66
|
-
{
|
|
67
|
-
"type": "command",
|
|
68
|
-
"command": "node \"${PLUGIN_ROOT}/dist/deliver.js\" codex",
|
|
69
|
-
"commandWindows": "powershell.exe -NoProfile -NonInteractive -EncodedCommand JgAgAG4AbwBkAGUAIAAiACQAZQBuAHYAOgBQAEwAVQBHAEkATgBfAFIATwBPAFQALwBkAGkAcwB0AC8AZABlAGwAaQB2AGUAcgAuAGoAcwAiACAAYwBvAGQAZQB4ADsAIABpAGYAIAAoACQAbgB1AGwAbAAgAC0AZQBxACAAJABMAEEAUwBUAEUAWABJAFQAQwBPAEQARQApACAAewAgAGUAeABpAHQAIAAxACAAfQA7ACAAZQB4AGkAdAAgACQATABBAFMAVABFAFgASQBUAEMATwBEAEUA",
|
|
70
|
-
"timeout": 5
|
|
71
|
-
}
|
|
72
|
-
]
|
|
73
62
|
}
|
|
74
63
|
],
|
|
75
64
|
"Stop": [
|
package/hooks/hooks.json
CHANGED
|
@@ -79,19 +79,6 @@
|
|
|
79
79
|
"async": true
|
|
80
80
|
}
|
|
81
81
|
]
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"matcher": "Bash|PowerShell",
|
|
85
|
-
"hooks": [
|
|
86
|
-
{
|
|
87
|
-
"type": "command",
|
|
88
|
-
"command": "node",
|
|
89
|
-
"args": [
|
|
90
|
-
"${CLAUDE_PLUGIN_ROOT}/dist/deliver.js"
|
|
91
|
-
],
|
|
92
|
-
"timeout": 5
|
|
93
|
-
}
|
|
94
|
-
]
|
|
95
82
|
}
|
|
96
83
|
],
|
|
97
84
|
"Stop": [
|
|
@@ -149,21 +136,6 @@
|
|
|
149
136
|
}
|
|
150
137
|
]
|
|
151
138
|
}
|
|
152
|
-
],
|
|
153
|
-
"PostToolUseFailure": [
|
|
154
|
-
{
|
|
155
|
-
"matcher": "Bash|PowerShell",
|
|
156
|
-
"hooks": [
|
|
157
|
-
{
|
|
158
|
-
"type": "command",
|
|
159
|
-
"command": "node",
|
|
160
|
-
"args": [
|
|
161
|
-
"${CLAUDE_PLUGIN_ROOT}/dist/deliver.js"
|
|
162
|
-
],
|
|
163
|
-
"timeout": 5
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
}
|
|
167
139
|
]
|
|
168
140
|
}
|
|
169
141
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sphica",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.60",
|
|
4
4
|
"description": "Records Claude Code and Codex sessions on your machine and keeps past implementation and decisions, with their sources, for your agent to find.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|