sphica 0.3.0 → 0.5.0

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,8 +1,8 @@
1
1
  {
2
2
  "$schema": "https://anthropic.com/claude-code/plugin.schema.json",
3
3
  "name": "sphica",
4
- "version": "0.3.0",
5
- "description": "Records conversations automatically and recalls past decisions, rejected options, constraints, and what was said.",
4
+ "version": "0.5.0",
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",
8
8
  "email": "shunichi@hir4ta.com"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sphica",
3
- "version": "0.3.0",
4
- "description": "Records conversations automatically and recalls past decisions, rejected options, constraints, and what was said.",
3
+ "version": "0.5.0",
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",
7
7
  "email": "shunichi@hir4ta.com"
package/README.md CHANGED
@@ -9,20 +9,22 @@
9
9
 
10
10
  English | [日本語](https://github.com/iroha924/sphica/blob/main/README.ja.md)
11
11
 
12
- **Local memory of past decisions for Claude Code and Codex.**
13
- Sphica records your coding sessions and the decisions made in them.
14
- You or your agent can then look up what was decided, what was rejected, and why, before making the same call again.
12
+ **Local memory of past implementation and decisions for Claude Code and Codex.**
13
+ Sphica records your coding sessions, and keeps what was decided, rejected, deferred, and built, each record quoting the words it came from.
14
+ Your agent finds those records when it searches, and sees the relevant ones on its own before it edits a file they apply to.
15
15
  The database is a single SQLite file on your machine.
16
16
 
17
17
  ## Features
18
18
 
19
- - **Look things up while you work.** The MCP tools `recall` and `read` let Claude Code and Codex search past decisions, rejected options, constraints, dead ends, and what you or others said in earlier sessions.
20
- - **Warnings before an edit (Claude Code).** Before the agent edits a file, a hook shows it the constraints recorded for that exact file and any technical debt that was deliberately left there.
21
- - **Automatic session recording.** Sphica keeps your prompts, the agent's final reply for each turn, and the paths of files changed by the agent's edit tools.
22
- - **Decision records on request.** `/sphica:trace` saves the decisions, rejected options, constraints, and dead ends of a session, plus where the work stands.
23
- - **Multi-perspective review.** `/sphica:review` runs a separate reviewer for each focus: correctness, security, and written conventions by default, plus redundancy and past decisions with `full`. When Codex is installed, it offers to repeat the review with Codex.
24
- - **GitHub and docs import.** `sphica harvest` imports pull requests, issues, and the repository's Markdown files.
19
+ - **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).
20
+ - **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, and a decision counts as adopted only when you said so.
21
+ - **Pull requests too.** `/sphica:harvest <number>` keeps a GitHub pull request (body, comments, reviews, review comments, commits, and the issues 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.
22
+ - **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.
23
+ - **Shown when it matters (Claude Code).** At session start, the current work; before an edit, the active decisions anchored to that file; when your prompt names a recorded option or code symbol, that record.
24
+ - **Search in Japanese and English.** Records carry search words in both languages, so a question in one finds a record written in the other.
25
+ - **Reviews check past decisions.** `/sphica:review` runs a reviewer per focus (correctness, security, written conventions, and past decisions by default; redundancy with `full`), and checks the diff against the records it touches.
25
26
 
27
+ Records are never rewritten: a correction is a new record that supersedes the old one, and the history stays.
26
28
  The agent is told to treat records as history, not instructions, and to trust the code when a record and the current code disagree.
27
29
 
28
30
  ## Requirements
@@ -30,11 +32,11 @@ The agent is told to treat records as history, not instructions, and to trust th
30
32
  - Node.js 24.15 or later
31
33
  - Claude Code or Codex, or both
32
34
  - `git`, to identify the repositories you register
33
- - For `sphica harvest` only: the GitHub CLI (`gh`), signed in with `gh auth login`
35
+ - For `/sphica:harvest` and fetching GitHub sources in `/sphica:glean`: the GitHub CLI (`gh`), signed in with `gh auth login`
34
36
 
35
37
  ## Install
36
38
 
37
- The plugin ships the MCP server, hooks, and skills. The `sphica` CLI comes from npm and is installed separately. You need both.
39
+ The plugin ships the MCP servers, hooks, and skills. The `sphica` CLI comes from npm and is installed separately. You need both.
38
40
 
39
41
  **1. Install the CLI**
40
42
 
@@ -67,7 +69,7 @@ cd ~/Projects/your-repo
67
69
  sphica init
68
70
  ```
69
71
 
70
- This creates `~/.sphica/sphica.db` and registers the repository. Running it again leaves both untouched. If the repository has no `origin` remote, give it a name: `sphica init --name <name>`. Add `--sync` to import its GitHub history and docs right away.
72
+ This creates `~/.sphica/sphica.db` and registers the repository. Running it again leaves both untouched. If the repository has no `origin` remote, give it a name: `sphica init --name <name>`.
71
73
 
72
74
  **4. Check the setup**
73
75
 
@@ -75,36 +77,43 @@ This creates `~/.sphica/sphica.db` and registers the repository. Running it agai
75
77
  sphica doctor
76
78
  ```
77
79
 
78
- `doctor` checks Node.js, the CLI and plugin versions, the database, and the recording queue. Start here whenever something looks wrong.
80
+ `doctor` checks Node.js, the CLI and plugin versions, the database, the recording queue, and the registered projects. Start here whenever something looks wrong.
79
81
 
80
82
  ## Quick start
81
83
 
82
- Sphica writes sessions to the database only for repositories you register. A registered repository is called a project; run `sphica init` in each repository you want recorded.
84
+ Sphica records sessions only in repositories you register (projects); run `sphica init` in each one.
83
85
 
84
- Then work as usual in Claude Code or Codex. To bring back earlier decisions, ask the agent:
86
+ Work as usual. At the end of a session with something worth keeping, run `/sphica:trace` (`$sphica:trace` in Codex).
87
+ `/sphica:trace pending` lists earlier sessions not traced yet. To keep what a pull request decided, run `/sphica:harvest 123`.
88
+ When you find evidence later ("the ops notes say…", "Kimura said the team agreed"), run `/sphica:glean` with what you found.
89
+
90
+ To bring back earlier decisions, ask the agent:
85
91
 
86
92
  - "Did we already decide how to handle retries here?"
87
- - "Why did we choose this approach?"
88
- - "What did I say about the migration last week?"
89
- - "Let's continue where we left off."
93
+ - "Why did we choose this approach, and what did we reject?"
94
+ - "Did we try generating thumbnails in a worker before?"
90
95
 
91
- The agent searches with `recall` and opens full records with `read`. At the end of a session with decisions worth keeping, run `/sphica:trace`.
96
+ ### What the agent sees on its own
92
97
 
93
- To import GitHub history and Markdown docs:
98
+ Without being asked, Sphica adds a few past records to what the agent sees, each marked as a past record rather than an instruction:
94
99
 
95
- ```bash
96
- sphica harvest # every project Sphica can find on this machine
97
- sphica harvest --cwd . # only the current repository
98
- ```
100
+ - At session start: the current work and project-wide constraints.
101
+ - On a prompt that names a recorded code symbol, file path, or option.
102
+ - Before the agent reads or edits a file a decision applies to. A read shows each record once per session.
103
+ - Before a review. When you run your own review command (any name containing `review`, or a name listed in the `SPHICA_REVIEW_COMMANDS`
104
+ environment variable, comma-separated), it gets the decisions your local change touches. `/sphica:review` checks them itself. Claude Code only.
105
+
106
+ 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.
107
+ Edits made through shell commands are not covered, and there is no review hook: run `$sphica:review`.
99
108
 
100
- Without `--cwd`, Sphica looks for projects directly under `~/Projects` and for projects registered with `--name`. Use `--cwd` for a repository somewhere else.
101
- Docs are read from the default branch of `origin`, or from the local `HEAD` when there is no `origin`.
109
+ 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 not mistaken for "never decided".
102
110
 
103
111
  ## What gets recorded and where it goes
104
112
 
105
- - **Where.** The database is `~/.sphica/sphica.db`. Records wait in a local queue, `~/.sphica/spool`, until they are written to it. Each machine has its own database, and records are not shared between machines.
106
- - **What.** Your prompts, the agent's final reply for each turn, and the paths of edited files. Background-task notifications and messages from other agents are skipped when Sphica recognizes their format.
107
- - **Unregistered repositories.** Sessions in a repository you have not registered stay in the queue. They are written to the database after you register the repository. Held records are dropped after 30 days, and when more than 1,000 are waiting the oldest go first.
113
+ - **Where.** The database is `~/.sphica/sphica.db`. Records wait in a local queue, `~/.sphica/spool`, until they are written to it. Each machine has its own database; nothing is shared between machines.
114
+ - **What.** Your prompts, the agent's final reply for each turn, and the paths of changed files. Background-task notifications and messages from other agents are skipped when Sphica recognizes their format. Replies in the middle of a turn, and files created and deleted within one turn, are not seen.
115
+ - **What was shown.** Each automatic delivery is logged by which records it showed, not their text.
116
+ - **Unregistered repositories.** Sessions in a repository you have not registered stay in the queue and are written after you register it. Held records are dropped after 30 days, and when more than 1,000 are waiting the oldest go first.
108
117
  - **Secrets.** Only secrets with a recognizable shape are masked:
109
118
  - keys with known prefixes
110
119
  - `KEY=…` and `"password": …` assignments
@@ -113,12 +122,21 @@ Docs are read from the default branch of `origin`, or from the local `HEAD` when
113
122
  - `mysql -p`
114
123
 
115
124
  **Anything else is stored as typed, so do not paste secrets into a session.**
116
- - **Network.** Sphica has no account, no hosted service, and no telemetry, and makes no network connections itself. Two commands call other tools that may: `sphica harvest` runs `git fetch` and `gh api` with your credentials, and `sphica doctor` runs `npm` and `claude` to check installed versions.
117
- - **Text written by others.** Pull request and issue text imported by `harvest` may come from anyone. It is passed to the agent as data, and the MCP server cannot write to the database.
125
+ - **Network.** Sphica has no account, no hosted service, and no telemetry, and makes no network connections itself. `/sphica:harvest` and `/sphica:glean` run `gh api` with your credentials to read pull requests and issues, and `sphica doctor` runs `npm` and `claude` to check installed versions.
126
+ - **Text written by others.** Pull request and issue text may come from anyone. It is kept as a source and passed to the agent as data, never as instructions, and only the owner's or a maintainer's words can adopt a decision.
118
127
 
119
- To delete a project's data, run `sphica project forget <name>`, where `<name>` is shown by `sphica project list`. Without `--yes`, it only shows how many records would be deleted. It deletes records in the database only. Records still waiting in `~/.sphica/spool` stay there and can be imported again if you register the repository again.
128
+ ## Limits in 0.5.0
120
129
 
121
- Before you stop using a machine, run `sphica capture flush` until `sphica doctor` shows no records waiting to be sent. Each run writes up to 500 records. Records from unregistered repositories are not written, so register those repositories first if you want to keep them.
130
+ - Structured records exist only for what you traced, harvested, or gleaned. Everything else is searchable only as captured text (`search` with `sources: true`).
131
+ - In Codex, a shell command that names a file gets its decisions even when the command does not read it, and edits made through shell commands get none.
132
+ - In Codex, `$sphica:trace`, `$sphica:harvest`, and `$sphica:glean` write only when Codex tells Sphica which directory the session is in. Codex 0.157.1 does, through an experimental MCP capability; if a later Codex stops, they stop with a message and write nothing.
133
+ - Showing a record does not make the agent follow it. In our evaluation Codex received and found an earlier decision against a request, and still carried out the request as asked.
134
+ - A code location in a record is checked against your working tree when it is read ("located", "moved", "missing"). A located symbol does not prove the decision still holds.
135
+
136
+ ## Upgrading from 0.4
137
+
138
+ 0.5.0 keeps records in a new format. A 0.4 database is refused and left unchanged; its records are not carried over.
139
+ Move `~/.sphica/sphica.db` aside (keep it if you want the old data), then run `sphica init` again in each repository.
122
140
 
123
141
  ## Updating
124
142
 
@@ -142,47 +160,41 @@ codex plugin marketplace upgrade sphica
142
160
  codex plugin add sphica@sphica
143
161
  ```
144
162
 
145
- Restart open sessions afterwards. When a release changes the database schema, the CLI asks you to run `sphica db migrate`. Back up `~/.sphica/sphica.db` before you run it.
163
+ Restart open sessions afterwards.
146
164
 
147
165
  ## Uninstalling
148
166
 
149
167
  ```bash
150
- npm uninstall -g sphica
168
+ sphica uninstall
151
169
  ```
152
170
 
153
- Claude Code:
171
+ This deletes `~/.sphica` (the database and the recording queue) after asking, and shows the commands that remove the rest:
154
172
 
155
173
  ```bash
156
- claude plugin uninstall sphica@sphica
157
- ```
158
-
159
- Codex:
160
-
161
- ```bash
162
- codex plugin remove sphica@sphica
174
+ claude plugin uninstall sphica@sphica && claude plugin marketplace remove sphica
175
+ codex plugin remove sphica@sphica && codex plugin marketplace remove sphica
176
+ npm uninstall -g sphica
163
177
  ```
164
178
 
165
- Your records stay in `~/.sphica/` until you delete that directory yourself.
166
-
167
179
  ## Troubleshooting
168
180
 
169
181
  Run `sphica doctor` first. It shows which part is out of date or not working. Common cases:
170
182
 
171
183
  - **`sphica: command not found`.** The plugin does not put the CLI on your PATH. Run `npm i -g sphica`.
172
- - **Nothing is recorded.** Check that the repository is registered with `sphica project list`. In Codex, also check that the hooks are trusted in `/hooks`.
173
- - **The MCP server reports an older version.** Restart the session, or run `/reload-plugins` in Claude Code.
174
- - **A search finds nothing.** Search matches words. Try other words, English and Japanese, or shorter terms. An empty result doesn't mean nothing was recorded.
184
+ - **Nothing is recorded.** Check that `sphica doctor` lists the repository under Projects. In Codex, also check that the hooks are trusted in `/hooks`.
185
+ - **The MCP servers report an older version.** Restart the session, or run `/reload-plugins` in Claude Code.
186
+ - **A search finds nothing.** Search matches words. Try other words, the other language, an identifier, or fewer words. Ask the agent to check `status`: sessions not traced yet are searchable only as captured text.
187
+ - **`doctor` says the full-text index is broken.** Run `sphica doctor --reindex`.
175
188
 
176
189
  ## Commands
177
190
 
178
191
  | Command | What it does |
179
192
  |---|---|
180
193
  | `sphica init` | Create the database and register the current repository |
181
- | `sphica doctor` | Check versions, the database, recording, and each project's last import |
182
- | `sphica harvest` | Import GitHub pull requests, issues, and Markdown docs |
183
- | `sphica advice` | See how often the edit hook showed constraints |
194
+ | `sphica doctor` | Check versions, the database, recording, and each registered project |
195
+ | `sphica uninstall` | Delete `~/.sphica` and show how to remove the plugin and the CLI |
184
196
 
185
- Run `sphica --help` for these, `sphica -H` for every command (managing projects and people, and the ones agents and maintenance use), and `sphica <command> --help` for each command's options.
197
+ Everything else runs inside Claude Code and Codex, through the `/sphica:*` commands and Sphica's MCP tools.
186
198
 
187
199
  ## Security
188
200
 
@@ -68,7 +68,6 @@ This file is generated by `node scripts/third-party-notices.mjs`. Do not edit it
68
68
  | json-schema-traverse | 1.0.0 | MIT |
69
69
  | json-schema-typed | 8.0.2 | BSD-2-Clause |
70
70
  | kysely | 0.29.6 | MIT |
71
- | marked | 18.0.14 | MIT |
72
71
  | math-intrinsics | 1.1.0 | MIT |
73
72
  | media-typer | 1.1.1 | MIT |
74
73
  | merge-descriptors | 2.0.0 | MIT |
@@ -2092,58 +2091,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2092
2091
  SOFTWARE.
2093
2092
  ```
2094
2093
 
2095
- ## marked 18.0.14
2096
-
2097
- SPDX: MIT
2098
- Source: https://github.com/markedjs/marked
2099
-
2100
- ```
2101
- # License information
2102
-
2103
- ## Contribution License Agreement
2104
-
2105
- If you contribute code to this project, you are implicitly allowing your code
2106
- to be distributed under the MIT license. You are also implicitly verifying that
2107
- all code is your original work. `</legalese>`
2108
-
2109
- ## Marked
2110
-
2111
- Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/)
2112
- Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/)
2113
-
2114
- Permission is hereby granted, free of charge, to any person obtaining a copy
2115
- of this software and associated documentation files (the "Software"), to deal
2116
- in the Software without restriction, including without limitation the rights
2117
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2118
- copies of the Software, and to permit persons to whom the Software is
2119
- furnished to do so, subject to the following conditions:
2120
-
2121
- The above copyright notice and this permission notice shall be included in
2122
- all copies or substantial portions of the Software.
2123
-
2124
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2125
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2126
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2127
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2128
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2129
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2130
- THE SOFTWARE.
2131
-
2132
- ## Markdown
2133
-
2134
- Copyright © 2004, John Gruber
2135
- http://daringfireball.net/
2136
- All rights reserved.
2137
-
2138
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
2139
-
2140
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2141
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
2142
- * Neither the name “Markdown” nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
2143
-
2144
- This software is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
2145
- ```
2146
-
2147
2094
  ## math-intrinsics 1.1.0
2148
2095
 
2149
2096
  SPDX: MIT