feat(deepwork): permissionMode 別バケットで集計#3
Merged
Conversation
ディープワーク累積を Claude Code の permissionMode(manual / auto / bypass) 別に分配する。「自分が判断していた時間」と「automode/bypass で AI に丸投げ していた時間」を分けて見たい、というユーザー要望が出発点。 主な変更: - DeepWorkAccumulator: バケット別 ms を date 毎に保持、feed(state, at, bucket) - observers/claude_code: JSONL から現行 permissionMode を正規化して取得 - watch: tick 毎にモード判定して accum に渡す。status 行に内訳とモードを表示 - advise: cap 判定は manual バケットのみで行い、auto/bypass は除外 - MCP deepwork resource: payload に manual/auto/bypass 内訳を同梱 永続化は schema=1 を維持し、byDate(合計 ms)に並走させる形で byDateBuckets(バケット別 ms)を追加。旧バージョンの cogsync は byDate のみ 読めば従来通り動くので、npm 公開済みクライアントを壊さない。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
akihidem
added a commit
that referenced
this pull request
May 11, 2026
permissionMode 別バケット集計 (#3) を含む alpha リリース。 旧 alpha.0 と state.json は互換(byDate を読めば従来通り動作)。 Co-authored-by: akihidem <akihidem@gmail.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
なぜ
「自分が判断していた時間」と「automode / bypass で AI に丸投げしていた時間」を区別して見たい、という要望から。今は両者が混ざって dailyDeepWorkCapMin に当たり、
stop_for_today推奨が早く出すぎる(実体感と乖離する)。何を
ディープワーク累積を Claude Code の permissionMode 別に 3 バケット (manual / auto / bypass) に分配。watch のステータス行と MCP
cogsync://state/deepworkリソースに内訳を出し、cap 判定は manual バケット単独で行う。主な変更ファイル:
src/infer/work_state.ts—DeepWorkAccumulatorをバケット別 ms に拡張、todayBreakdown()追加src/observers/claude_code.ts—normalizePermissionMode()とfindActiveSession()から現行 permissionMode を返却src/watch.ts— tick 毎にモード判定 →accum.feed(state, at, bucket)、status 行にdw=Nm(M:x/A:y/B:z) | mode=...を表示src/coach/advise.ts— cap はdeepWorkManualMinで判定し auto/bypass は除外src/mcp/{resources,tools,server}.ts— payload に manual/auto/bypass を同梱src/state/store.ts— schema=1 維持、byDate(合計 ms)+byDateBuckets(バケット別 ms)の並走形式設計判断
byDate(number) を残したままbyDateBuckets(object) を並走させる。schema=2 に bump すると既に npm 公開済みの旧バージョンが state.json を読めなくなるので避けた。旧バージョンはbyDateのみ読めば従来通り動く。bypassPermissions→bypass、auto/acceptEdits/plan→auto、未設定 →manual。プラン系も「AI が回し切る系」として auto バケット側に寄せた。スコープ外
dailyAutoCapMin等) の追加。要望が出てから。検証方法
npm run typecheckクリアnpm test— 16/16 pass(tests/deepwork-accumulator.test.tsを新規追加)npx tsx src/index.ts watch --onceで status 行にdw=Nm(M:x/A:y/B:z) | mode=...が出ることを確認cogsync://state/deepworkが問題なく返ることを確認(byDate のみで動作)依存
なし。
🤖 Generated with Claude Code