Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ claude-code-working-diary.tar.gz

# /diary-notion 임시 JSON (Claude가 cwd에 작성 → CLI가 자동 삭제 / 부분 실패 시 보존)
.diary-notion-*.json

# Local v2 diary-notion run artifacts
.codefleet/runs/
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- **Working Diary OS 비전 문서**: Structure → Views → Operations → Intelligence → Multi-project OS로 확장하는 최고모델 설계, 최소 명령 원칙, 전날 todo 기반 `today-plan`, schema/view conflict drift 관리 방향 추가
- **2차 View 설계 문서**: `working-diary diary-notion ensure`, `--year`, `--dry-run`과 Core Views 5개, operating views 5개, `Work Period`와 `Sub-items` 기반 schema v7 방향, 하위 항목 데이터 구조, sub-item UI best-effort/fallback, partial failure/exit code 정책 정리
- **`working-diary diary-notion ensure` 구현**: schema v7 `Work Period`, native sub-item relation, Priority/Blocked/Review 운영 컬럼 보장, Core Views 5개와 Operating Views 5개 생성/검증/update, `--year`, `--dry-run`, required setting repair 지원
- **`working-diary diary-notion ops` 구현**: Notion Entries DB를 읽기 전용으로 조회해 blocked/review/next action/stale/work days/today-plan 후보/task group/project/parent progress/부모 상태 제안 운영 신호를 요약
- **Phase 3 ensure diagnostics**: schema/view conflict reason을 `missing_filter`, `missing_property`, `subitem_missing`, `permission_or_auth`, `api_failure`로 분류하고 repair plan/action/apply 가능 여부를 출력
- **`claude-diary write --input <file>`**: Codex skill이 생성한 JSON으로 수동 Markdown 일지 작성
- **`lib/notion_cache.py`**: 연도 페이지/DB/행 ID 캐시 (root_page_id 변경 시 자동 무효화)
- **`lib/git_info.py` 확장**: `get_branch_for_commit`, `get_head_branch`, `get_commit_info`, `get_diff_stat_for_commits`
Expand Down
3 changes: 3 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ working-diary write
working-diary diary-notion init
working-diary diary-notion ensure
working-diary diary-notion ensure --dry-run
working-diary diary-notion ops
working-diary diary-notion push --input .diary-notion-<id>.json
working-diary notion push --input .diary-notion-<id>.json
```
Expand Down Expand Up @@ -407,6 +408,7 @@ $OutputEncoding = [System.Text.UTF8Encoding]::new()
- Secret scanning and masking
- Search index
- Notion work log: `working-diary diary-notion init` -> `working-diary diary-notion ensure`
- Notion operations report: `working-diary diary-notion ops` for blocked/review/next action/stale/work days/today-plan candidates/parent status signals
- Slack, Discord, Obsidian, GitHub exporters: `working-diary config --add-exporter <name>`
- HTML dashboard: `working-diary dashboard` or `working-diary dashboard --serve --port 8787`
- Audit log and source checksum verification
Expand Down Expand Up @@ -438,6 +440,7 @@ This README focuses on currently usable functionality. Detailed design and plann
| Area | Status |
|------|--------|
| Stable now | Claude Code Stop Hook, Codex skills, Markdown diaries, Notion task row push, schema/view ensure |
| Phase 3 started | `working-diary diary-notion ops` read-only operations report, parent/task group progress, ensure conflict classification and repair plans |
| Next | Windows install/output experience, Notion sub-item guidance, incremental CI/lint expansion |
| Under review | SQLite search index, Cursor/Windsurf/VS Code integration |

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ working-diary write
working-diary diary-notion init
working-diary diary-notion ensure
working-diary diary-notion ensure --dry-run
working-diary diary-notion ops
working-diary diary-notion push --input .diary-notion-<id>.json
working-diary notion push --input .diary-notion-<id>.json
```
Expand Down Expand Up @@ -411,6 +412,7 @@ $OutputEncoding = [System.Text.UTF8Encoding]::new()
- secret scan과 masking
- 검색 인덱스
- Notion 업무일지: `working-diary diary-notion init` -> `working-diary diary-notion ensure`
- Notion 운영 진단: `working-diary diary-notion ops`로 blocked/review/next action/stale/work days/today-plan 후보/부모 상태 제안 확인
- Slack, Discord, Obsidian, GitHub exporter: `working-diary config --add-exporter <name>`
- HTML dashboard: `working-diary dashboard` 또는 `working-diary dashboard --serve --port 8787`
- audit log와 source checksum 검증
Expand Down Expand Up @@ -442,6 +444,7 @@ python -m ruff check .
| 구분 | 내용 |
|------|------|
| 현재 안정화 | Claude Code Stop Hook, Codex skill, Markdown 일지, Notion task row push, schema/view ensure |
| Phase 3 진입 | `working-diary diary-notion ops` 읽기 전용 운영 진단, parent/task group 진행률, ensure conflict 분류와 repair plan |
| 다음 개선 | Windows 설치/출력 경험 정리, Notion sub-item 안내 개선, CI/lint 범위 점진 확대 |
| 검토 중 | SQLite 기반 검색 인덱스, Cursor/Windsurf/VS Code 같은 다른 AI IDE 연동 |

Expand Down
93 changes: 62 additions & 31 deletions skills/diary-notion/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,47 @@ Split the current Codex session into task-sized entries and push them to Notion.
## Current Implementation Contract

- `$diary-notion` is a row push workflow only. Do not run schema/view ensure unless the user explicitly asks for it.
- `working-diary diary-notion ensure` is the separate maintenance command that guarantees schema v7, native sub-items, 5 core views, and 5 operating views.
- `working-diary diary-notion ensure` is the separate maintenance command that guarantees schema v8, native sub-items, 5 core views, and 5 operating views.
- Use Notion native sub-items for containment by setting `parent_index`. If the native relation is not enabled in Notion, still push the rows and report that sub-item activation is needed.
- Treat legacy `Parent Task` / `Sub-items` as compatibility data only. Do not target them directly in JSON.
- Use `Depends On` only for prerequisite links between large top-level main tasks. Never use dependencies for child tasks.
- Never write `"unknown"` as `project`; omit it or leave it blank so the CLI falls back to the command cwd folder name.
- Page bodies render as compact executive bodies: top summary, result checklist, work-at-a-glance table, impact, verification, risks/next action, and appendix.
- Page bodies render as compact work reports: summary, results, work table, decisions, issues/risks, next actions/support, and appendix toggles.
- Notion is the report surface; raw logs, long diffs, and bulky evidence belong in local artifact files and should be referenced by path/hash instead of pasted.
- `diary-notion push` writes local run artifacts under `.codefleet/runs` by default: `input.json`, `git-diff.patch`, `preview.md`, and `manifest.json`. Use `--preview-file` for an extra Markdown preview path or `--no-artifacts` to disable local artifact writes.
- For testing, QA, review, validation, or verification sessions, create a row even without code changes; keep `verification` short and place the meaningful prompt-result document in `prompt_outputs` or `verification_artifacts` so it renders inside a toggle.

## Workflow

1. Review the current conversation, tool calls, git branch, and relevant git commits.
2. Split work into task-sized database rows. Branch changes are hard task boundaries; within a branch, split by semantic work unit.
- Create a row for work that has its own status, evidence, code/test output, or can block another task
- Create a row for verification-only work even when the session produced no file changes or commits
- Keep tiny check items, raw notes, long SQL/JS snippets, and reference links inside the page body evidence instead of making them separate rows
- Create a separate row only when the work has an independent status, verification/evidence, code change, commit, blocker, or follow-up owner
- For tester/verification sessions, summarize the final state in `verification` and put each meaningful pass, fail, blocker, skipped check, regression, defect, and follow-up in the prompt-output artifact fields
- Use `parent_index` for containment hierarchy and Notion sub-items; do not model subtasks with dependencies
- Use `depends_on_indices` only for prerequisite links between large top-level tasks
- Mark continued work from an earlier day/session as a new row with the same `task_group` and `carryover=true` when it is still unfinished
3. For each task, produce:
- Prefer schema v2 normalized fields: `summary`, `work`, `decisions`, `risks`, `next_actions`, `support_needed`, and `appendix`.
- Legacy flat fields are still accepted by the CLI, but new agent output should use v2 unless compatibility with an older installed version is required.
- Language policy:
- Write `title`, `body_intro`, `summary_hints`, `key_changes`, `work_context`, `work_scope`, `approach`, `outcome`, `impact`, `decisions`, `implementation_notes`, `verification`, `risks`, `next_steps`, `support_needed`, `next_action`, and `block_reason` in Korean
- Write `title`, `summary`, `work`, `decisions`, `risks`, `next_actions`, `support_needed`, `appendix`, `next_action`, and `block_reason` narrative values in Korean
- Keep `status` and `purpose` as the exact English enum values below
- Preserve file paths, commands, branches, commit hashes, code identifiers, function names, and class names as written
- Preserve `user_prompts` in the user's original wording as evidence
- `title`: concise Korean noun phrase, no prefix or period
- `body_intro`: 1-3 factual Korean sentences based only on observed work
- Write it like a Notion task database record: compact top summary, structured relations in DB properties, and raw evidence hidden in the page body appendix
- Body rendering policy:
- Use `body_intro` as the only top summary callout
- Treat `summary_hints` as checked result items, not repeated callouts
- Keep `work_context`, `work_scope`, `approach`, and `outcome` short because they render as a compact "work at a glance" table
- Put final verification state in `verification`; move intermediate command history to appendix evidence
- Keep risks concise; multiple risks are combined into one warning callout
- Use `summary.intro` as the only top summary callout
- Treat `summary.outcomes`, `summary.verification`, and `summary.remaining` as the compact results checklist
- Keep `work.context`, `work.scope`, `work.approach`, and `work.state` short because they render as a compact work table
- Put settled choices in `decisions`; put unresolved external asks in `support_needed`
- Keep `risks` concise as issue/risk bullets, not raw logs
- Put developer evidence, prompt outputs, original requests, and command/file/commit evidence in `appendix` toggles
- For tester/verification sessions, keep `summary.verification` to 1-3 summary items and put the meaningful prompt-result document in `appendix.prompt_outputs` or `appendix.verification_artifacts`; summarize long raw logs instead of pasting them
- `summary_hints`: up to 3 outcome-focused result items that explain what changed and why it matters
- `key_changes`: up to 3 major behavior/schema/workflow changes a developer can understand without opening the diff
- `work_context`: 0-1 bullet explaining why this work started
Expand All @@ -55,12 +64,16 @@ Split the current Codex session into task-sized entries and push them to Notion.
- Include changes to behavior, schema, CLI flow, user workflow, or verification scope
- `decisions`: 0-3 decisions or tradeoffs made by the user or settled during implementation
- `implementation_notes`: 0-4 constraints, compatibility notes, migrations, or details that do not fit code highlights
- `verification`: 0-3 tests/checks run, results, or explicit reasons checks were not run
- `verification`: 0-3 summary tests/checks run, final results, or explicit reasons checks were not run
- `prompt_outputs`: 0-15 meaningful prompt-result items for tester/verification sessions; include distinct pass/fail/blocker/skipped/regression/defect/follow-up results, not raw logs
- `verification_artifacts`: 0-15 structured verification artifact items when the prompt output is better grouped as a generated test report or review document
- `appendix.artifacts`: 0-5 local artifact references with `path`, `kind`, `summary`, and optional `sha256`; use this for stdout/stderr/diff/raw-log evidence
- `risks`: 0-2 cautions, remaining risks, or usage/operation notes
- `next_steps`: 0-2 remaining follow-ups
- `support_needed`: 0-1 decisions or support needed from others
- `status`: `Discussion`, `Design`, `Implementation`, `Testing`, or `Deployed`
- `purpose`: `Feature`, `Bugfix`, `Refactor`, `Docs`, `Test`, `Infra`, `Planning`, `Research`, `Review`, `Release`, `Support`, `Maintenance`, or `General`
- Use `Test` for tester, QA, validation, and verification-only sessions unless another enum is clearly more accurate
- `work_period`: actual work period; use today's `YYYY-MM-DD` by default, or `{"start":"YYYY-MM-DD","end":"YYYY-MM-DD"}` for a range
- `priority`: one of `P0`, `P1`, `P2`, `P3`; use `P0` for urgent/blocking work, `P1` for today's highest priority, `P2` for normal follow-up, and `P3` for low priority
- `next_action`: 0-1 concrete Korean action that can be started next
Expand All @@ -81,24 +94,46 @@ Split the current Codex session into task-sized entries and push them to Notion.
```json
{
"session_id": "<current session id or codex-manual>",
"schema_version": 2,
"tasks": [
{
"title": "...",
"body_intro": "...",
"summary_hints": ["..."],
"key_changes": ["..."],
"work_context": ["..."],
"work_scope": ["..."],
"approach": ["..."],
"outcome": ["..."],
"impact": ["..."],
"code_change_highlights": ["..."],
"summary": {
"intro": "...",
"outcomes": ["..."],
"verification": ["..."],
"remaining": ["..."]
},
"work": {
"context": "...",
"scope": "...",
"approach": "...",
"state": "..."
},
"decisions": ["..."],
"implementation_notes": ["..."],
"verification": ["..."],
"risks": ["..."],
"next_steps": ["..."],
"next_actions": ["..."],
"support_needed": ["..."],
"appendix": {
"key_changes": ["..."],
"implementation_notes": ["..."],
"prompt_outputs": ["..."],
"verification_artifacts": ["..."],
"user_prompts": ["..."],
"files_modified": ["..."],
"files_created": ["..."],
"commands_run": ["..."],
"commit_hashes": ["..."],
"errors": ["..."],
"artifacts": [
{
"kind": "stdout",
"path": ".codefleet/runs/<run-id>/stdout.log",
"summary": "raw command output",
"sha256": "..."
}
]
},
"status": "Implementation",
"purpose": "Feature",
"work_period": "2026-06-02",
Expand All @@ -113,20 +148,16 @@ Split the current Codex session into task-sized entries and push them to Notion.
"parent_index": null,
"depends_on_indices": [],
"categories": ["feature"],
"project": "<cwd folder name>",
"user_prompts": ["..."],
"files_modified": ["..."],
"files_created": ["..."],
"commands_run": ["..."],
"commit_hashes": ["..."],
"errors": ["..."]
"project": "<cwd folder name>"
}
]
}
```

5. Run `working-diary diary-notion push --input .diary-notion-<8-random>.json`.
6. If `working-diary` is not available, run `claude-diary diary-notion push --input .diary-notion-<8-random>.json`.
7. Report pushed/skipped/failed tasks from the CLI output.
5. Run `working-diary diary-notion push --input .diary-notion-<8-random>.json --dry-run` to validate v2 input, write local artifacts, and preview the compact report body and appendix toggles without writing to Notion.
6. If the preview is structurally wrong, fix the JSON before pushing.
7. Run `working-diary diary-notion push --input .diary-notion-<8-random>.json`.
8. If `working-diary` is not available, run `claude-diary diary-notion push --input .diary-notion-<8-random>.json`.
9. Report pushed/skipped/failed tasks from the CLI output.

If there are no task-worthy changes, explain that and do not call the CLI.
19 changes: 16 additions & 3 deletions src/claude_diary/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from claude_diary.cli.notion_push import cmd_notion_push
from claude_diary.cli.notion_init import cmd_notion_init
from claude_diary.cli.notion_ensure import cmd_notion_ensure
from claude_diary.cli.notion_ops import cmd_notion_ops


def cmd_notion(args):
Expand All @@ -33,17 +34,29 @@ def cmd_notion(args):
cmd_notion_init(args)
elif args.action == "ensure":
cmd_notion_ensure(args)
elif args.action == "ops":
cmd_notion_ops(args)


def _add_diary_notion_parser(sub, name):
p_notion = sub.add_parser(name, help="Notion hierarchical work diary integration")
p_notion.add_argument("action", choices=["init", "push", "ensure"], help="Action to perform")
p_notion.add_argument("action", choices=["init", "push", "ensure", "ops"], help="Action to perform")
p_notion.add_argument("--input", help="JSON input file (push only)")
p_notion.add_argument("--force", action="store_true",
help="Archive prior rows for the session before pushing (push only)")
p_notion.add_argument("--year", type=int, help="Target year (ensure only)")
p_notion.add_argument("--year", type=int, help="Target year (ensure/ops only)")
p_notion.add_argument("--dry-run", action="store_true",
help="Print the Notion schema/view plan without writing (ensure only)")
help="Preview push body without writing, or print ensure plan")
p_notion.add_argument("--preview-file",
help="Write push dry-run/preview Markdown to this file")
p_notion.add_argument("--artifact-dir", default=".codefleet/runs",
help="Directory for local run artifacts (push only)")
p_notion.add_argument("--no-artifacts", action="store_true",
help="Do not write local run artifacts (push only)")
p_notion.add_argument("--stale-days", type=int, default=7,
help="Mark active rows stale after N days (ops only)")
p_notion.add_argument("--json", dest="json_output", action="store_true",
help="Output operations report as JSON (ops only)")


def main():
Expand Down
Loading
Loading