claude-spotter 1.4.5 → 1.4.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.6
4
+
5
+ **Codex 初回セッションが空 catalog に依存し得る穴を修正**。v1.4.5 までは
6
+ `spotter install` が Codex hooks を登録しても Codex host-local DB は seed せず、
7
+ 初回 Codex セッションの `SessionStart` が detached `spotter db refresh --host-agent codex`
8
+ を起動するだけだった。そのため最初の `UserPromptSubmit` が refresh 完了前に走ると
9
+ `.spotter/tool-db.codex.json` が空 / 未作成のまま Codex auditor が動き得た。
10
+
11
+ ### 変更点
12
+
13
+ - **編集 [src/cli/install.mjs](src/cli/install.mjs)**:
14
+ Codex CLI が見つかり Codex hooks を登録した project install では、Claude DB seed に続いて
15
+ `refresh({hostAgent:"codex"})` も同期実行し、`.spotter/tool-db.codex.json` と
16
+ `~/.spotter/tool-db.codex.json` を作るようにした。以降の Codex `SessionStart` bg refresh は
17
+ drift 追従用として残す。Codex CLI が見つからなかった場合の next steps も、Codex hooks が
18
+ active ではないことと `codex --version` が通る環境で再実行すべきことを明示する。
19
+ - **編集 [test/install.test.mjs](test/install.test.mjs)**:
20
+ Codex hooks 登録時に Claude / Codex の両 host DB refresh が順に走ること、Codex CLI
21
+ unavailable 時は Codex seed へ進まないことを固定。
22
+ - **編集 README / README.ja / docs**:
23
+ Codex DB は install 時に初回 seed され、SessionStart refresh は以後の drift 追従であることを明記。
24
+
25
+ ### ユーザー側で必要な手順
26
+
27
+ 1. `npm install -g claude-spotter@1.4.6`
28
+ 2. Codex を使う各プロジェクトで `spotter install` を再実行
29
+
3
30
  ## 1.4.5
4
31
 
5
32
  **Codex global tool-db を Claude global tool-db から分離**。v1.4.4 までは local DB は
package/README.ja.md CHANGED
@@ -107,7 +107,7 @@ flowchart LR
107
107
 
108
108
  監査対象のツール (name + description) は host-local に分離されます。Claude は `<project>/.spotter/tool-db.json`、Codex は `<project>/.spotter/tool-db.codex.json` を使います。**daemon が監査に使うのは Claude local DB のみ**で、Codex native hooks は Codex local DB を読みます。グローバル description cache も host ごとに分離され、Claude は `~/.spotter/tool-db.json`、Codex は `~/.spotter/tool-db.codex.json` を使います。これらは同じ host の他プロジェクト間でだけ再利用され、監査入力には混ぜません。各 host-local DB は **その host の現時点の discovery 結果と一致** (refresh 時に prune される) するため、別プロジェクトや別 host のツールリストで上書きされることはありません。
109
109
 
110
- **`spotter install` が Claude catalog の初回 seed を自動実行し、Claude Code セッション起動ごとに SessionStart hook が bg で `spotter db refresh` を走らせる**ため、Claude 通常運用で手動コマンドを叩く必要はありません。Codex CLI が使える環境では、同じ `spotter install` が Codex native hooks も登録します。Codex `SessionStart` hook は `spotter db refresh --host-agent codex` を bg 起動して `.spotter/tool-db.codex.json` を更新します。Claude catalog には書き込みません。Claude discovery は `claude mcp list` と Claude skills / sub-agents、Codex discovery は `codex mcp list/get` と Codex skills を読むため、両 host の利用可能ツール差分を別 DB として保持できます。各 MCP サーバーの `tools/list` は JSON-RPC で取得 (HTTP / SSE / stdio transport 対応)、スキルとサブエージェントは frontmatter から直接抽出、claude.ai baseline (OAuth proxy 経由の Gmail / Calendar / Drive 25 件) は Claude 側でのみ `claude mcp list` に該当サーバーが存在する環境で注入されます。**手書きでツールリストを管理する必要はありません**。
110
+ **`spotter install` が Claude catalog の初回 seed を自動実行し、Claude Code セッション起動ごとに SessionStart hook が bg で `spotter db refresh` を走らせる**ため、Claude 通常運用で手動コマンドを叩く必要はありません。Codex CLI が使える環境では、同じ `spotter install` が Codex native hooks も登録し、`.spotter/tool-db.codex.json` も同期 seed します。これにより初回 Codex セッションから catalog を読めます。以降の Codex `SessionStart` hook は `spotter db refresh --host-agent codex` を bg 起動して `.spotter/tool-db.codex.json` を更新します。Claude catalog には書き込みません。Claude discovery は `claude mcp list` と Claude skills / sub-agents、Codex discovery は `codex mcp list/get` と Codex skills を読むため、両 host の利用可能ツール差分を別 DB として保持できます。各 MCP サーバーの `tools/list` は JSON-RPC で取得 (HTTP / SSE / stdio transport 対応)、スキルとサブエージェントは frontmatter から直接抽出、claude.ai baseline (OAuth proxy 経由の Gmail / Calendar / Drive 25 件) は Claude 側でのみ `claude mcp list` に該当サーバーが存在する環境で注入されます。**手書きでツールリストを管理する必要はありません**。
111
111
 
112
112
  ## Throughline との関係
113
113
 
package/README.md CHANGED
@@ -107,7 +107,7 @@ flowchart LR
107
107
 
108
108
  The audited catalog is host-local: Claude uses `<project>/.spotter/tool-db.json`, while Codex uses `<project>/.spotter/tool-db.codex.json`. **The daemon audits against the Claude local DB only**, and Codex native hooks read the Codex local DB. Global description caches are host-specific too: Claude uses `~/.spotter/tool-db.json`, while Codex uses `~/.spotter/tool-db.codex.json`. They are shared only across projects for the same host and are never audit sources. Each host-local DB matches that host's **current** discovery snapshot for the project (stale entries are pruned on refresh), so tools from another project or another host cannot overwrite this session's audit catalog.
109
109
 
110
- **`spotter install` seeds the Claude catalog automatically, and the SessionStart hook runs a background `spotter db refresh` on every Claude Code session start** — so you don't need to invoke Claude catalog commands by hand. When Codex CLI is available, the same `spotter install` registers Codex native hooks; their `SessionStart` hook starts `spotter db refresh --host-agent codex` in the background, updating `.spotter/tool-db.codex.json` without touching the Claude catalog. Claude discovery reads `claude mcp list` plus Claude skills / sub-agents; Codex discovery reads `codex mcp list/get` plus Codex skills. Each MCP server's `tools/list` is fetched via JSON-RPC (HTTP / SSE / stdio transports supported); skill and sub-agent metadata comes straight from frontmatter; the claude.ai baseline (25 hand-curated entries for Gmail / Calendar / Drive over OAuth proxy) is injected only for Claude when `claude mcp list` confirms the server is present. **You never have to maintain the tool list by hand.**
110
+ **`spotter install` seeds the Claude catalog automatically, and the SessionStart hook runs a background `spotter db refresh` on every Claude Code session start** — so you don't need to invoke Claude catalog commands by hand. When Codex CLI is available, the same `spotter install` registers Codex native hooks and seeds `.spotter/tool-db.codex.json` synchronously, so the first Codex session has a catalog too. Later Codex `SessionStart` hooks start `spotter db refresh --host-agent codex` in the background, updating `.spotter/tool-db.codex.json` without touching the Claude catalog. Claude discovery reads `claude mcp list` plus Claude skills / sub-agents; Codex discovery reads `codex mcp list/get` plus Codex skills. Each MCP server's `tools/list` is fetched via JSON-RPC (HTTP / SSE / stdio transports supported); skill and sub-agent metadata comes straight from frontmatter; the claude.ai baseline (25 hand-curated entries for Gmail / Calendar / Drive over OAuth proxy) is injected only for Claude when `claude mcp list` confirms the server is present. **You never have to maintain the tool list by hand.**
111
111
 
112
112
  ## Spotter and Throughline
113
113
 
package/bin/spotter.mjs CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-spotter",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "Audit agent running alongside Claude Code that catches missed tool calls — 気づく役と実行する役の分離",
5
5
  "type": "module",
6
6
  "bin": {
@@ -120,9 +120,11 @@ export async function runInstall({
120
120
  console.log(`wrote ${settingsPath}`);
121
121
  }
122
122
 
123
+ let codexHooksRegistered = false;
123
124
  if (target === 'project' && !skipCodexHooks) {
124
125
  if (codexCliPresentFn()) {
125
126
  const result = await installCodexHooksFn();
127
+ codexHooksRegistered = true;
126
128
  console.log(' Codex hooks registered');
127
129
  console.log(` Codex hooks: ${result.hooksPath}`);
128
130
  } else {
@@ -140,23 +142,33 @@ export async function runInstall({
140
142
  console.log('\ndiscovering MCP servers, skills, and sub-agents...');
141
143
  const log = (msg) => process.stderr.write(` ${msg}\n`);
142
144
  try {
143
- const resolved = await refreshFn({ projectRoot: cwd, hostAgent: 'claude', logFn: log });
144
- console.log(` ${resolved.size} tool(s) resolved`);
145
- console.log(` local DB: ${localDbPath(cwd, 'claude')}`);
146
- console.log(` global DB: ${globalDbPath('claude')}`);
145
+ const claudeResolved = await refreshFn({ projectRoot: cwd, hostAgent: 'claude', logFn: log });
146
+ console.log(` ${claudeResolved.size} Claude tool(s) resolved`);
147
+ console.log(` Claude local DB: ${localDbPath(cwd, 'claude')}`);
148
+ console.log(` Claude global DB: ${globalDbPath('claude')}`);
149
+ if (codexHooksRegistered) {
150
+ const codexResolved = await refreshFn({ projectRoot: cwd, hostAgent: 'codex', logFn: log });
151
+ console.log(` ${codexResolved.size} Codex tool(s) resolved`);
152
+ console.log(` Codex local DB: ${localDbPath(cwd, 'codex')}`);
153
+ console.log(` Codex global DB: ${globalDbPath('codex')}`);
154
+ }
147
155
  } catch (err) {
148
156
  // §0: throw (fallback 禁止). But surface the recovery path so the user isn't
149
157
  // left with "hooks registered, tool-db missing" and no clue what to run.
150
158
  process.stderr.write(`\nspotter install: tool-db seeding failed.\n`);
151
159
  process.stderr.write(` hooks are registered but tool-db is not ready.\n`);
152
- process.stderr.write(` recover with: spotter db refresh\n`);
160
+ process.stderr.write(` recover with: spotter db refresh and, for Codex, spotter db refresh --host-agent codex\n`);
153
161
  throw err;
154
162
  }
155
163
  }
156
164
 
157
165
  console.log('\nnext steps:');
158
166
  console.log(' reload Claude Code (or open a new session) to activate Spotter');
159
- console.log(' open a new Codex session to activate Codex hooks when Codex CLI is installed');
167
+ if (codexHooksRegistered) {
168
+ console.log(' open a new Codex session to activate Codex hooks');
169
+ } else if (target === 'project' && !skipCodexHooks) {
170
+ console.log(' Codex hooks are not active: rerun `spotter install` where `codex --version` succeeds');
171
+ }
160
172
  }
161
173
 
162
174
  async function exists(path) {