43 lines
1008 B
Python
43 lines
1008 B
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Stop 훅: 트랜스크립트의 새 assistant 메시지에서 usage 를 읽어 프로젝트 누적기에 더한다.
|
|
|
|
- 누적 범위: <git-root>/.claude/state/aptabase-accum.json
|
|
- 커밋 훅(aptabase-commit.py)이 flush 하고 0으로 리셋한다
|
|
- 네트워크 호출 없음 (순수 파일 I/O)
|
|
"""
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
from aptabase_common import ( # noqa: E402
|
|
accumulate_from_transcript,
|
|
load_config,
|
|
load_state,
|
|
save_state,
|
|
)
|
|
|
|
|
|
def main() -> None:
|
|
if load_config() is None:
|
|
return
|
|
|
|
try:
|
|
hook_input = json.load(sys.stdin)
|
|
except Exception:
|
|
return
|
|
|
|
transcript_path = hook_input.get("transcript_path") or ""
|
|
if not transcript_path:
|
|
return
|
|
|
|
cwd = hook_input.get("cwd")
|
|
state = load_state(cwd)
|
|
accumulate_from_transcript(state, transcript_path)
|
|
save_state(state, cwd)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|