sphica 0.6.41 → 0.6.42

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.
@@ -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.41",
4
+ "version": "0.6.42",
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",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sphica",
3
- "version": "0.6.41",
3
+ "version": "0.6.42",
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
  "author": {
6
6
  "name": "iroha924",
@@ -10,7 +10,7 @@ This file is generated by `node scripts/third-party-notices.mjs`. Do not edit it
10
10
  | @clack/core | 1.5.1 | MIT |
11
11
  | @clack/prompts | 1.8.1 | MIT |
12
12
  | @hono/node-server | 2.1.1 | MIT |
13
- | @modelcontextprotocol/sdk | 1.30.0 | MIT |
13
+ | @modelcontextprotocol/sdk | 1.31.0 | MIT |
14
14
  | @stricli/core | 1.3.0 | Apache-2.0 |
15
15
  | accepts | 2.0.0 | MIT |
16
16
  | ajv | 8.20.0 | MIT |
@@ -174,7 +174,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
174
174
  SOFTWARE.
175
175
  ```
176
176
 
177
- ## @modelcontextprotocol/sdk 1.30.0
177
+ ## @modelcontextprotocol/sdk 1.31.0
178
178
 
179
179
  SPDX: MIT
180
180
  Source: https://github.com/modelcontextprotocol/typescript-sdk
package/dist/deliver.js CHANGED
@@ -12803,6 +12803,11 @@ if (process.argv[1] && /capture\.(ts|js)$/.test(process.argv[1])) {
12803
12803
  main().catch(() => {});
12804
12804
  }
12805
12805
 
12806
+ // server/src/read.ts
12807
+ var READ_BUDGET = 32 * 1024;
12808
+ var CONTROL_SEQUENCE = /(?:\u001b\[|\u009b)[0-?]*[ -/]*[@-~]?/;
12809
+ var HIDDEN = new RegExp(`${STRING_SEQUENCE.source}|${CONTROL_SEQUENCE.source}`, "g");
12810
+
12806
12811
  // server/src/review.ts
12807
12812
  var ESCAPES = { a: 7, b: 8, t: 9, n: 10, v: 11, f: 12, r: 13, '"': 34, "\\": 92 };
12808
12813
  function gitPath(token, prefix) {
@@ -12913,7 +12918,8 @@ async function selectForReview(db, projectId2, files) {
12913
12918
  kind: a.kind,
12914
12919
  stance: a.stance,
12915
12920
  text: a.text,
12916
- because: `anchored to ${a.path}${a.symbol ? ` ${a.symbol}` : ""}`
12921
+ because: `anchored to ${a.path}${a.symbol ? ` ${a.symbol}` : ""}`,
12922
+ why: { path: a.path, symbol: a.symbol }
12917
12923
  });
12918
12924
  const added = files.flatMap((f) => f.added.map((l) => ({ path: f.path, text: l.normalize("NFKC").toLowerCase() })));
12919
12925
  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))));
@@ -12935,7 +12941,8 @@ async function selectForReview(db, projectId2, files) {
12935
12941
  kind: u.kind,
12936
12942
  stance: u.stance,
12937
12943
  text: u.text,
12938
- because: `an added line in ${hit.path} names the option ${o.text}`
12944
+ because: `an added line in ${hit.path} names the option ${o.text}`,
12945
+ why: { path: hit.path, option: o.text }
12939
12946
  });
12940
12947
  break;
12941
12948
  }
package/dist/mcp.js CHANGED
@@ -47728,21 +47728,31 @@ async function liveOverview(db, projectId, after) {
47728
47728
  const n = Number(total?.n ?? 0);
47729
47729
  if (!shown.length)
47730
47730
  return after === null ? "No active decision or constraint is recorded for this project. status says whether sessions are still untraced." : `No active decision or constraint after id ${after}. ${n} in all.`;
47731
- const groups = [...new Set(shown.map((s) => s.group))].sort((a, b) => a === PROJECT_WIDE ? 1 : b === PROJECT_WIDE ? -1 : a.localeCompare(b));
47732
- const last = shown.at(-1)?.id ?? 0;
47733
- const more = rows.length > shown.length;
47734
- return [
47735
- ...groups.flatMap((g) => [
47736
- `## ${head(inline(g), OVERVIEW_LIMITS.heading)}`,
47737
- ...shown.filter((s) => s.group === g).map((s) => s.line),
47738
- ""
47739
- ]),
47740
- `${shown.length} shown of ${n} active decisions and constraints${after === null ? "" : ` (ids after ${after})`}.`,
47741
- more ? `More follow: call overview again with after: ${last}. Pages are read at different times: a record that became active in between, with a lower id, is not on a later page.` : "That is the end of the list.",
47742
- "Read a record by its key or u<id> before relying on it.",
47743
- ...shown.some((x) => whose.get(x.id) === "agent") ? [AI_DECIDED] : []
47744
- ].join(`
47731
+ const page = (taken) => {
47732
+ const groups = [...new Set(taken.map((s) => s.group))].sort((a, b) => a === PROJECT_WIDE ? 1 : b === PROJECT_WIDE ? -1 : a.localeCompare(b));
47733
+ const last = taken.at(-1)?.id ?? 0;
47734
+ return [
47735
+ ...groups.flatMap((g) => [
47736
+ `## ${head(inline(g), OVERVIEW_LIMITS.heading)}`,
47737
+ ...taken.filter((s) => s.group === g).map((s) => s.line),
47738
+ ""
47739
+ ]),
47740
+ `${taken.length} shown of ${n} active decisions and constraints${after === null ? "" : ` (ids after ${after})`}.`,
47741
+ rows.length > taken.length ? `More follow: call overview again with after: ${last}. Pages are read at different times: a record that became active in between, with a lower id, is not on a later page.` : "That is the end of the list.",
47742
+ "Read a record by its key or u<id> before relying on it.",
47743
+ ...taken.some((x) => whose.get(x.id) === "agent") ? [AI_DECIDED] : []
47744
+ ].join(`
47745
47745
  `);
47746
+ };
47747
+ const frame = bytes(framed(""));
47748
+ let best = page(shown.slice(0, 1));
47749
+ for (let k = 2;k <= shown.length; k++) {
47750
+ const candidate = page(shown.slice(0, k));
47751
+ if (frame + bytes(candidate) > READ_BUDGET)
47752
+ break;
47753
+ best = candidate;
47754
+ }
47755
+ return best;
47746
47756
  }
47747
47757
  var LOOK_LIMITS = { anchors: 2000, line: 2200, bytes: READ_BUDGET - 4 * 1024 };
47748
47758
  var CONDITION_ROWS = Math.ceil(LOOK_LIMITS.bytes / 28);
@@ -48162,7 +48172,8 @@ async function selectForReview(db, projectId2, files) {
48162
48172
  kind: a.kind,
48163
48173
  stance: a.stance,
48164
48174
  text: a.text,
48165
- because: `anchored to ${a.path}${a.symbol ? ` ${a.symbol}` : ""}`
48175
+ because: `anchored to ${a.path}${a.symbol ? ` ${a.symbol}` : ""}`,
48176
+ why: { path: a.path, symbol: a.symbol }
48166
48177
  });
48167
48178
  const added = files.flatMap((f) => f.added.map((l) => ({ path: f.path, text: l.normalize("NFKC").toLowerCase() })));
48168
48179
  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))));
@@ -48184,7 +48195,8 @@ async function selectForReview(db, projectId2, files) {
48184
48195
  kind: u.kind,
48185
48196
  stance: u.stance,
48186
48197
  text: u.text,
48187
- because: `an added line in ${hit.path} names the option ${o.text}`
48198
+ because: `an added line in ${hit.path} names the option ${o.text}`,
48199
+ why: { path: hit.path, option: o.text }
48188
48200
  });
48189
48201
  break;
48190
48202
  }
@@ -48213,13 +48225,57 @@ async function reviewBatch(db, projectId2, files, after, diff) {
48213
48225
  };
48214
48226
  }
48215
48227
  var AI_DEPARTURE = "A record marked decided by an AI was decided by an AI in an earlier session, not by the owner: a change that departs from it is a violation only when the change gives no reason for departing.";
48216
- async function selectedText(db, hits) {
48228
+ var SHOWN = { text: 300, path: 160, symbol: 80, option: 160 };
48229
+ var LEAST = 24;
48230
+ var NONE2 = { text: 0, path: 0, symbol: 0, option: 0 };
48231
+ var part = (value, max) => {
48232
+ if (!max)
48233
+ return "";
48234
+ const v = inline(value);
48235
+ return bytes(v) <= max ? v : `${head(v, max - 3)}…`;
48236
+ };
48237
+ async function selectedText(db, hits, room) {
48217
48238
  const whose = await authorityOf(db, hits.map((u) => u.id));
48218
- const ai = hits.some((u) => whose.get(u.id) === "agent");
48219
- return [
48220
- ...hits.map((u) => `- ${u.key} (${u.kind}${u.stance ? ` ${u.stance}` : ""}${whose.get(u.id) === "agent" ? ", decided by an AI" : ""}): ${head(inline(u.text), 300)} [${u.because}]`),
48221
- ...ai ? [AI_DEPARTURE] : []
48222
- ].join(`
48239
+ const marked = (u) => whose.get(u.id) === "agent" ? ", decided by an AI" : "";
48240
+ const tail = hits.some((u) => whose.get(u.id) === "agent") ? [AI_DEPARTURE] : [];
48241
+ const line = (u, c) => {
48242
+ const why = "option" in u.why ? `an added line in ${part(u.why.path, c.path)} names the option ${part(u.why.option, c.option)}` : `anchored to ${part(u.why.path, c.path)}${u.why.symbol ? ` ${part(u.why.symbol, c.symbol)}` : ""}`;
48243
+ return `- ${inline(u.key)} (u${u.id}, ${u.kind}${u.stance ? ` ${u.stance}` : ""}${marked(u)}): ${part(u.text, c.text)} [${why}]`;
48244
+ };
48245
+ const join = (lines2) => [...lines2, ...tail].join(`
48246
+ `);
48247
+ const each = Math.floor((room - bytes(join(hits.map((u) => line(u, NONE2))))) / Math.max(1, hits.length));
48248
+ if (each >= LEAST) {
48249
+ const text2 = join(hits.map((u) => {
48250
+ const t = Math.min(SHOWN.text, Math.floor(each / 2));
48251
+ const rest = each - t;
48252
+ const two = "option" in u.why || u.why.symbol;
48253
+ const path8 = Math.min(SHOWN.path, two ? Math.floor(rest / 2) : rest);
48254
+ return line(u, {
48255
+ text: t,
48256
+ path: path8,
48257
+ symbol: Math.min(SHOWN.symbol, rest - path8),
48258
+ option: Math.min(SHOWN.option, rest - path8)
48259
+ });
48260
+ }));
48261
+ if (bytes(text2) <= room)
48262
+ return { text: text2, byId: false };
48263
+ }
48264
+ return {
48265
+ text: join(hits.map((u) => `- u${u.id}${marked(u) ? ` (${marked(u).slice(2)})` : ""}`)),
48266
+ byId: true
48267
+ };
48268
+ }
48269
+ var BY_ID = "The keys are too long to show here: read each by u<id>, and pass the key read shows as the finding's unit.";
48270
+ async function selectReply(db, b, after) {
48271
+ const from = b.all.length - b.all.filter((u) => u.id > (after ?? 0)).length + 1;
48272
+ const lead = `Decision lane: checked. ${b.all.length} records apply. Batch ${b.k} of ${b.n} (records ${from}-${from + b.records.length - 1}), selection ${b.selection}; read each before judging it.`;
48273
+ const end = b.next === null ? "This is the last batch." : `Next batch: after checking this one, call review_select with after: ${b.next}.`;
48274
+ const room = READ_BUDGET - bytes(`${lead} ${BY_ID}
48275
+ ${framed("")}
48276
+ ${end}`);
48277
+ const s = await selectedText(db, b.records, room);
48278
+ return [s.byId ? `${lead} ${BY_ID}` : lead, framed(s.text), end].join(`
48223
48279
  `);
48224
48280
  }
48225
48281
 
@@ -48620,10 +48676,7 @@ server.registerTool("review_select", {
48620
48676
  return text2(`Decision lane: not checked. after ${a.after} is not where a batch ended: pass the after a batch gave, or none for the first batch.`, true);
48621
48677
  if (!b.records.length)
48622
48678
  return text2(`Decision lane: checked. No record after id ${a.after}: ${b.all.length} records apply in all (selection ${b.selection}).`);
48623
- const from = b.all.length - b.all.filter((u) => u.id > (a.after ?? 0)).length + 1;
48624
- return text2(`Decision lane: checked. ${b.all.length} records apply. Batch ${b.k} of ${b.n} (records ${from}-${from + b.records.length - 1}), selection ${b.selection}; read each before judging it.
48625
- ${framed(await selectedText(db, b.records))}
48626
- ${b.next === null ? "This is the last batch." : `Next batch: after checking this one, call review_select with after: ${b.next}.`}`);
48679
+ return text2(await selectReply(db, b, a.after ?? null));
48627
48680
  } catch (e) {
48628
48681
  return notChecked(e);
48629
48682
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sphica",
3
- "version": "0.6.41",
3
+ "version": "0.6.42",
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",
@@ -32,7 +32,7 @@ Pass the diff under review and the root of the repository under review (`cwd`) t
32
32
  |---|---|---|
33
33
  | The tool call fails, or it says "Decision lane: not checked" | MCP does not connect, the database is unreachable, or the project is not registered | **`blocked_unknown`** + the reason it gave |
34
34
  | "Decision lane: checked" with no record | No active record applies | Continue to Step 3; 0 records may be treated as a **grounded negative** |
35
- | "Decision lane: checked" with records | One batch of at most 50 records, `Batch k of n`, and a `selection`. Each record says why it applies (anchored to a changed path, or an added line names an option it rejected); an AI's decision is marked `decided by an AI` | Continue |
35
+ | "Decision lane: checked" with records | One batch of at most 50 records, `Batch k of n`, and a `selection`. Each record says why it applies (anchored to a changed path, or an added line names an option it rejected), cut short with `…` when long; an AI's decision is marked `decided by an AI`. A batch whose keys are too long to show lists `u<id>` alone and says so | Continue |
36
36
 
37
37
  **When returning `blocked_unknown`, state concretely what was missing.** Silently returning 0 results makes the caller read it as "no findings".
38
38
  **This step is deterministic and can claim coverage.** It selects only active records; candidates and superseded records never apply.
@@ -45,8 +45,10 @@ Changes to the working tree between batches (which code locations still exist) a
45
45
 
46
46
  ## Step 2 — Read every selected record
47
47
 
48
- `read([keys], cwd)` returns each record's text, its options, the exact words cited as evidence and adoption with who said them, what it
49
- superseded or conflicts with, and each code location checked in the working tree now. **Judge from this body, never from the key or the one line.**
48
+ Read them by the `u<id>` each line gives: `read(["u12", "u40"], cwd)`. A batch whose keys are too long to show names its records by
49
+ `u<id>` alone, and read shows each one's whole key, which its finding's `unit` takes. read returns each record's text, its options, the
50
+ exact words cited as evidence and adoption with who said them, what it superseded or conflicts with, and each code location checked in
51
+ the working tree now. **Judge from this body, never from the key or the one line**, which is cut short (`…`) to keep the batch whole.
50
52
  When a reply says some refs were not read or a record continues, call `read` again with exactly what it names until nothing is left.
51
53
 
52
54
  ## Step 3 — Search by the approach's meaning