sphica 0.6.37 → 0.6.39
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 +16 -2
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +4 -3
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/dist/deliver.js +46 -19
- package/dist/mcp.js +17 -3
- 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.39",
|
|
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",
|
|
@@ -16,5 +16,19 @@
|
|
|
16
16
|
"decisions",
|
|
17
17
|
"sqlite"
|
|
18
18
|
],
|
|
19
|
-
"mcpServers": "./mcp/claude.json"
|
|
19
|
+
"mcpServers": "./mcp/claude.json",
|
|
20
|
+
"userConfig": {
|
|
21
|
+
"review_commands": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"title": "Review commands",
|
|
24
|
+
"description": "Your own review commands whose names do not contain \"review\", comma-separated. Each gets the decisions your local change touches. When empty, SPHICA_REVIEW_COMMANDS is used",
|
|
25
|
+
"default": ""
|
|
26
|
+
},
|
|
27
|
+
"auto_trace": {
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"title": "Automatic trace",
|
|
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
|
+
"default": true
|
|
32
|
+
}
|
|
33
|
+
}
|
|
20
34
|
}
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ The database is a single SQLite file on your machine.
|
|
|
20
20
|
|
|
21
21
|
- **Automatic recording.** Sphica keeps your prompts, the agent's final reply for each turn, and the paths of the files a turn changed (by the edit tools, or seen in `git status` at the turn's end).
|
|
22
22
|
- **Records with their sources.** `/sphica:trace` turns a session into records: decisions with the options rejected and why, constraints, implementations, findings, dead ends, and open questions. Every record quotes the exact words it came from. A decision counts as adopted in two ways: you said so (your decision), or the agent decided it itself in that session and its reply says so (an AI's decision). An AI's decision is shown as one, never replaces yours, and is never used for public interfaces, security and permissions, releases, or forgetting.
|
|
23
|
-
- **Traced without asking (Claude Code).** When you start a new session and sessions from the last 14 days wait to be traced, the agent is asked to trace up to two of them, oldest first, after your request is done. Run `/sphica:trace` yourself to keep something right away, and `/sphica:trace pending` for older sessions. To turn the automatic trace off, set `"SPHICA_AUTO_TRACE": "off"` under `env` in Claude Code's `settings.json`; recording and your own `/sphica:trace` keep working.
|
|
23
|
+
- **Traced without asking (Claude Code).** When you start a new session and sessions from the last 14 days wait to be traced, the agent is asked to trace up to two of them, oldest first, after your request is done. Run `/sphica:trace` yourself to keep something right away, and `/sphica:trace pending` for older sessions. To turn the automatic trace off, set the plugin's `auto_trace` option to false in `/config` (Claude Code 2.1.269 or later), or set `"SPHICA_AUTO_TRACE": "off"` under `env` in Claude Code's `settings.json`; recording and your own `/sphica:trace` keep working. Either one off keeps it off, so to turn it back on, clear both.
|
|
24
24
|
- **Pull requests too.** `/sphica:harvest <number>` keeps a GitHub pull request (body, comments, reviews, review comments, commits, and up to five issues the body says it closes) and records what it decided. A reviewer's suggestion stays a proposal unless the owner or a maintainer adopted it; a merge alone adopts nothing.
|
|
25
25
|
- **Evidence found later.** `/sphica:glean` adds evidence and corrections to existing records. It asks you for the source (an issue URL, the file and line, meeting notes) before saving; a claim without one is kept only as unsourced and never used as fact.
|
|
26
26
|
- **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 (if another session is reading the database, it asks you to run it again to finish clearing the bytes). Records that cited them are judged again and leave active when nothing else supports them; a record's own text stays as it was.
|
|
@@ -111,8 +111,9 @@ Without being asked, Sphica adds a few past records to what the agent sees, each
|
|
|
111
111
|
- At session start: the current work and project-wide constraints, and in Claude Code, when earlier sessions wait to be traced, a request to trace them after your request is done.
|
|
112
112
|
- On a prompt that names a recorded code symbol, file path, or option.
|
|
113
113
|
- 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.
|
|
114
|
-
- Before a review (Claude Code only). When you run your own review command (any name containing `review`, or a name listed in the
|
|
115
|
-
environment variable
|
|
114
|
+
- Before a review (Claude Code only). When you run your own review command (any name containing `review`, or a name listed, comma-separated, in the plugin's
|
|
115
|
+
`review_commands` option in `/config` (Claude Code 2.1.269 or later) or the `SPHICA_REVIEW_COMMANDS` environment variable), it gets the decisions your local
|
|
116
|
+
change touches. When `review_commands` names any command, `SPHICA_REVIEW_COMMANDS` is not read. `/sphica:review` checks them itself.
|
|
116
117
|
|
|
117
118
|
In Codex the same happens at session start, on a prompt, before an `apply_patch` edit, and before a shell command that names such a file (Codex reads files through shell commands, so this covers reads).
|
|
118
119
|
There is no review hook in Codex: run `$sphica:review`.
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -83,7 +83,7 @@ This file is generated by `node scripts/third-party-notices.mjs`. Do not edit it
|
|
|
83
83
|
| path-key | 3.1.1 | MIT |
|
|
84
84
|
| path-to-regexp | 8.4.2 | MIT |
|
|
85
85
|
| pkce-challenge | 5.0.1 | MIT |
|
|
86
|
-
| proxy-addr | 2.0.
|
|
86
|
+
| proxy-addr | 2.0.8 | MIT |
|
|
87
87
|
| qs | 6.16.0 | BSD-3-Clause |
|
|
88
88
|
| range-parser | 1.3.0 | MIT |
|
|
89
89
|
| raw-body | 3.0.2 | MIT |
|
|
@@ -2511,7 +2511,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
2511
2511
|
SOFTWARE.
|
|
2512
2512
|
```
|
|
2513
2513
|
|
|
2514
|
-
## proxy-addr 2.0.
|
|
2514
|
+
## proxy-addr 2.0.8
|
|
2515
2515
|
|
|
2516
2516
|
SPDX: MIT
|
|
2517
2517
|
Source: jshttp/proxy-addr
|
package/dist/deliver.js
CHANGED
|
@@ -11552,6 +11552,17 @@ function sqliteCode(e) {
|
|
|
11552
11552
|
const x = e;
|
|
11553
11553
|
return x?.code === "ERR_SQLITE_ERROR" && typeof x.errcode === "number" ? x.errcode & 255 : null;
|
|
11554
11554
|
}
|
|
11555
|
+
function byUnit(rows) {
|
|
11556
|
+
const out = new Map;
|
|
11557
|
+
for (const r of rows) {
|
|
11558
|
+
const list = out.get(r.unit_id);
|
|
11559
|
+
if (list)
|
|
11560
|
+
list.push(r);
|
|
11561
|
+
else
|
|
11562
|
+
out.set(r.unit_id, [r]);
|
|
11563
|
+
}
|
|
11564
|
+
return out;
|
|
11565
|
+
}
|
|
11555
11566
|
|
|
11556
11567
|
// server/src/db-write.ts
|
|
11557
11568
|
import { constants as C2, DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
@@ -12901,12 +12912,15 @@ async function selectForReview(db, projectId2, files) {
|
|
|
12901
12912
|
because: `anchored to ${a.path}${a.symbol ? ` ${a.symbol}` : ""}`
|
|
12902
12913
|
});
|
|
12903
12914
|
const added = files.flatMap((f) => f.added.map((l) => ({ path: f.path, text: l.normalize("NFKC").toLowerCase() })));
|
|
12904
|
-
const
|
|
12905
|
-
const
|
|
12915
|
+
const locationFree = live.where("u.stance", "in", ["dont", "defer"]).where(({ not, exists, selectFrom }) => not(exists(selectFrom("unit_anchor as a").select("a.id").whereRef("a.unit_id", "=", "u.id").where("a.retired_at", "is", null))));
|
|
12916
|
+
const [free, options] = await Promise.all([
|
|
12917
|
+
locationFree.select(["u.id", "u.revision", "u.key", "u.kind", "u.stance", "u.text"]).execute(),
|
|
12918
|
+
db.selectFrom("unit_option").select(["unit_id", "text"]).where("unit_id", "in", locationFree.select("u.id")).orderBy("id").execute().then(byUnit)
|
|
12919
|
+
]);
|
|
12906
12920
|
for (const u of free) {
|
|
12907
12921
|
if (out.has(u.id))
|
|
12908
12922
|
continue;
|
|
12909
|
-
for (const o of options.filter((x) => x.
|
|
12923
|
+
for (const o of (options.get(u.id) ?? []).filter((x) => x.text.trim().length >= 3)) {
|
|
12910
12924
|
const name = o.text.normalize("NFKC").toLowerCase();
|
|
12911
12925
|
const hit = added.find((l) => l.text.includes(name));
|
|
12912
12926
|
if (hit) {
|
|
@@ -12949,7 +12963,9 @@ function reviewCall(input) {
|
|
|
12949
12963
|
const lower = name.toLowerCase();
|
|
12950
12964
|
if (lower === "sphica:review")
|
|
12951
12965
|
return null;
|
|
12952
|
-
const
|
|
12966
|
+
const names = (list) => (list ?? "").split(",").map((n) => n.trim().toLowerCase()).filter((n) => NAME.test(n));
|
|
12967
|
+
const option = names(process.env.CLAUDE_PLUGIN_OPTION_REVIEW_COMMANDS);
|
|
12968
|
+
const named = option.length > 0 ? option : names(process.env.SPHICA_REVIEW_COMMANDS);
|
|
12953
12969
|
if (!named.includes(lower) && !lower.includes("review"))
|
|
12954
12970
|
return null;
|
|
12955
12971
|
return { name, args: typeof args === "string" ? args.slice(0, 1000) : "" };
|
|
@@ -13258,27 +13274,38 @@ async function namedInCommand(db, projectId2, root, cwd, command) {
|
|
|
13258
13274
|
}
|
|
13259
13275
|
return [...out];
|
|
13260
13276
|
};
|
|
13261
|
-
return paths.map((r) => r.path).filter((p) => forms(p).some((t) => new RegExp(`(?:^|[${edge}])${esc(t)}(?:$|[${edge}:])`).test(command)));
|
|
13277
|
+
return paths.map((r) => r.path).filter((p) => command.includes(p.slice(p.lastIndexOf("/") + 1)) && forms(p).some((t) => command.includes(t) && new RegExp(`(?:^|[${edge}])${esc(t)}(?:$|[${edge}:])`).test(command)));
|
|
13262
13278
|
}
|
|
13263
13279
|
function pathNamed(prompt, root, rel) {
|
|
13264
13280
|
const steps = (p) => p.split(/[\\/]/).map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("[\\\\/]");
|
|
13265
13281
|
return new RegExp(`(?<![A-Za-z0-9_$.\\-/\\\\])(?:(?:\\.[\\\\/])?${steps(rel)}|${steps(path8.join(root, rel))})(?![A-Za-z0-9_$\\-/\\\\]|\\.[A-Za-z0-9_$])`).test(prompt);
|
|
13266
13282
|
}
|
|
13283
|
+
function once(f) {
|
|
13284
|
+
const seen = new Map;
|
|
13285
|
+
return (k) => {
|
|
13286
|
+
if (!seen.has(k))
|
|
13287
|
+
seen.set(k, f(k));
|
|
13288
|
+
return seen.get(k);
|
|
13289
|
+
};
|
|
13290
|
+
}
|
|
13267
13291
|
async function onPrompt(db, projectId2, root, prompt) {
|
|
13268
13292
|
const text = prompt.normalize("NFKC");
|
|
13269
13293
|
const lower = text.toLowerCase();
|
|
13270
|
-
const word = (w, s) => new RegExp(`(?<![\\p{L}\\p{N}_$])${w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\p{L}\\p{N}_$])`, "u").test(s);
|
|
13271
|
-
const named2 = (symbol) => symbol.length >= 3 && (/[^a-z]/.test(symbol) ? word(symbol, text) : text.includes(`${symbol}(`) || text.includes(`\`${symbol}\``));
|
|
13272
|
-
const
|
|
13273
|
-
const
|
|
13274
|
-
const
|
|
13275
|
-
|
|
13276
|
-
|
|
13277
|
-
|
|
13294
|
+
const word = (w, s) => s.includes(w) && new RegExp(`(?<![\\p{L}\\p{N}_$])${w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\p{L}\\p{N}_$])`, "u").test(s);
|
|
13295
|
+
const named2 = once((symbol) => symbol.length >= 3 && (/[^a-z]/.test(symbol) ? word(symbol, text) : text.includes(`${symbol}(`) || text.includes(`\`${symbol}\``)));
|
|
13296
|
+
const slashed = prompt.replaceAll("\\", "/");
|
|
13297
|
+
const pathIn = once((rel) => slashed.includes(rel) && pathNamed(prompt, root, rel));
|
|
13298
|
+
const optionIn = once((option) => option.length >= 3 && word(option.normalize("NFKC").toLowerCase(), lower));
|
|
13299
|
+
const units = await deliverable(db, projectId2).select(["u.id", "u.key", "u.kind", "u.stance", "u.text"]).orderBy("u.kind").orderBy("u.id").execute();
|
|
13300
|
+
const ids = deliverable(db, projectId2).select("u.id");
|
|
13301
|
+
const [anchors, options] = await Promise.all([
|
|
13302
|
+
db.selectFrom("unit_anchor").select(["unit_id", "path", "symbol"]).where("unit_id", "in", ids).where("retired_at", "is", null).orderBy("id").execute().then(byUnit),
|
|
13303
|
+
db.selectFrom("unit_option").select(["unit_id", "text", "outcome"]).where("unit_id", "in", ids).orderBy("id").execute().then(byUnit)
|
|
13304
|
+
]);
|
|
13278
13305
|
const hits = [];
|
|
13279
13306
|
for (const u of units) {
|
|
13280
|
-
const a = anchors.find((x) => x.
|
|
13281
|
-
const o = options.find((x) =>
|
|
13307
|
+
const a = anchors.get(u.id)?.find((x) => x.symbol && named2(x.symbol) || pathIn(x.path));
|
|
13308
|
+
const o = options.get(u.id)?.find((x) => optionIn(x.text));
|
|
13282
13309
|
if (a)
|
|
13283
13310
|
hits.push({ u, why: ` [names ${a.symbol && named2(a.symbol) ? a.symbol : a.path}]` });
|
|
13284
13311
|
else if (o)
|
|
@@ -13385,12 +13412,12 @@ async function beforeReview(db, projectId2, root, call) {
|
|
|
13385
13412
|
const base = inline(change.base);
|
|
13386
13413
|
if (!n)
|
|
13387
13414
|
return said(`Sphica: no local change against ${base} to check against past decisions.`, "no change");
|
|
13388
|
-
const
|
|
13415
|
+
const once2 = `${change.base}\x00${change.digest}`;
|
|
13389
13416
|
const live = new Set((await deliverable(db, projectId2).select("u.id").execute()).map((r) => r.id));
|
|
13390
13417
|
const rows = (await selectForReview(db, projectId2, change.files)).filter((a) => live.has(a.id));
|
|
13391
13418
|
const checked = `checked ${n} changed path${n === 1 ? "" : "s"} against ${base}`;
|
|
13392
13419
|
if (!rows.length)
|
|
13393
|
-
return { ...said(`Sphica ${checked}: no active recorded decision applies.`, null), once };
|
|
13420
|
+
return { ...said(`Sphica ${checked}: no active recorded decision applies.`, null), once: once2 };
|
|
13394
13421
|
const shown = rows.slice(0, LIMITS.review.units);
|
|
13395
13422
|
const ai = await aiDecided(db, shown.map((u) => u.id));
|
|
13396
13423
|
const f = fitMarked(shown.map((u) => line(u, ` [${inline(u.because)}]`, ai.has(u.id))), LIMITS.review.chars, `Sphica: past decisions that apply to this change (${checked}). ${NOTE}; compare the change against each:`, ai, shown.map((u) => u.id));
|
|
@@ -13402,7 +13429,7 @@ async function beforeReview(db, projectId2, root, call) {
|
|
|
13402
13429
|
omitted,
|
|
13403
13430
|
path: null,
|
|
13404
13431
|
reason: null,
|
|
13405
|
-
once
|
|
13432
|
+
once: once2
|
|
13406
13433
|
};
|
|
13407
13434
|
}
|
|
13408
13435
|
function toldBefore(session, key) {
|
|
@@ -13531,7 +13558,7 @@ async function deliver(input, host = "claude-code", file = dbFile()) {
|
|
|
13531
13558
|
key: place.key,
|
|
13532
13559
|
host,
|
|
13533
13560
|
subagent: name === "SubagentStart",
|
|
13534
|
-
auto: host === "claude-code" && name === "SessionStart" && input.source === "startup" && process.env.CLAUDE_CODE_ENTRYPOINT === "cli" && !
|
|
13561
|
+
auto: host === "claude-code" && name === "SessionStart" && input.source === "startup" && process.env.CLAUDE_CODE_ENTRYPOINT === "cli" && ![process.env.CLAUDE_PLUGIN_OPTION_AUTO_TRACE, process.env.SPHICA_AUTO_TRACE].some((v) => AUTO_TRACE_OFF.has((v ?? "").trim().toLowerCase())) ? session : null,
|
|
13535
13562
|
owner: name !== "SubagentStart" && isOwnerTurn(input, undefined, undefined, host === "codex" ? process.env.CODEX_THREAD_ID : undefined)
|
|
13536
13563
|
}),
|
|
13537
13564
|
reason: name === "SubagentStart" ? "subagent" : input.source && START_SOURCES.has(input.source) ? input.source : null
|
package/dist/mcp.js
CHANGED
|
@@ -46105,6 +46105,17 @@ function kyselyOn(connect) {
|
|
|
46105
46105
|
function openReader(file2 = dbFile()) {
|
|
46106
46106
|
return kyselyOn(() => connectReader(file2));
|
|
46107
46107
|
}
|
|
46108
|
+
function byUnit(rows) {
|
|
46109
|
+
const out = new Map;
|
|
46110
|
+
for (const r of rows) {
|
|
46111
|
+
const list = out.get(r.unit_id);
|
|
46112
|
+
if (list)
|
|
46113
|
+
list.push(r);
|
|
46114
|
+
else
|
|
46115
|
+
out.set(r.unit_id, [r]);
|
|
46116
|
+
}
|
|
46117
|
+
return out;
|
|
46118
|
+
}
|
|
46108
46119
|
|
|
46109
46120
|
// server/src/knowledge.ts
|
|
46110
46121
|
var UNIT_KINDS = [
|
|
@@ -47924,12 +47935,15 @@ async function selectForReview(db, projectId2, files) {
|
|
|
47924
47935
|
because: `anchored to ${a.path}${a.symbol ? ` ${a.symbol}` : ""}`
|
|
47925
47936
|
});
|
|
47926
47937
|
const added = files.flatMap((f) => f.added.map((l) => ({ path: f.path, text: l.normalize("NFKC").toLowerCase() })));
|
|
47927
|
-
const
|
|
47928
|
-
const
|
|
47938
|
+
const locationFree = live.where("u.stance", "in", ["dont", "defer"]).where(({ not, exists, selectFrom }) => not(exists(selectFrom("unit_anchor as a").select("a.id").whereRef("a.unit_id", "=", "u.id").where("a.retired_at", "is", null))));
|
|
47939
|
+
const [free, options] = await Promise.all([
|
|
47940
|
+
locationFree.select(["u.id", "u.revision", "u.key", "u.kind", "u.stance", "u.text"]).execute(),
|
|
47941
|
+
db.selectFrom("unit_option").select(["unit_id", "text"]).where("unit_id", "in", locationFree.select("u.id")).orderBy("id").execute().then(byUnit)
|
|
47942
|
+
]);
|
|
47929
47943
|
for (const u of free) {
|
|
47930
47944
|
if (out.has(u.id))
|
|
47931
47945
|
continue;
|
|
47932
|
-
for (const o of options.filter((x) => x.
|
|
47946
|
+
for (const o of (options.get(u.id) ?? []).filter((x) => x.text.trim().length >= 3)) {
|
|
47933
47947
|
const name = o.text.normalize("NFKC").toLowerCase();
|
|
47934
47948
|
const hit = added.find((l) => l.text.includes(name));
|
|
47935
47949
|
if (hit) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sphica",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.39",
|
|
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",
|