Skip to content
Merged
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
26 changes: 22 additions & 4 deletions .STATUS
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,29 @@
## Type: zsh-plugin
## Status: active
## Focus: --help
## Phase: Released (v7.11.0)
## Phase: Release Pending (v7.13.0)
## Priority: 2
## Progress: 100

## Current Session (2026-06-19) — flow claude check docs + merge cleanup ✅ COMPLETE
## Current Session (2026-06-19) — v7.13.0 Release Pipeline 🚀

**Session activity:**
- **Bumped** version to v7.13.0 (flow.plugin.zsh, package.json, CLAUDE.md, man pages)
- **Updated** CHANGELOG.md + docs/CHANGELOG.md with 7.13.0 release date (2026-06-19)
- **Inserted** 7.12.0 entry in docs/CHANGELOG.md (was missing)
- **Updated** docs/reference/MASTER-DISPATCHER-GUIDE.md version footer
- **Docs:** `docs/commands/claude.md` + `docs/tutorials/49-flow-claude-check.md` updated for C7-C11 + watch daemon (v7.13.0)
- **PR:** In progress — gh pr create --base main --head dev

## Previous Session (2026-06-19) — v7.12.0 SHIPPED [main + Homebrew] ✅

**Session activity:**
- **Fixed** `_flow_claude_fix_c1`: replaced `sed -i ''` (BSD-only) with portable temp-file approach for GNU sed compat (Linux CI)
- **Merged** PR #474 (Release v7.12.0) — both CI checks green (ZSH Plugin Tests + Full Test Suite)
- **Tagged** v7.12.0 → GitHub release → Homebrew auto-updated (7.11.0 → 7.12.0) ✅
- **CI:** All green (main + Version Guard + Homebrew Release + Deploy Documentation)

## Previous Session (2026-06-19) — flow claude check docs + merge cleanup ✅ COMPLETE

**Session activity:**
- **Merged** PR #473 (`feature/flow-claude` → dev) — `flow claude check` C1–C6 + `--fix` + tutorial 49 + command ref
Expand Down Expand Up @@ -403,7 +421,7 @@

| Worktree | Branch | Status |
|----------|--------|--------|
| Main repo | `dev` | v7.10.0 SHIPPED + CI full-suite gate MERGED (PR #465 → dev `b57c0d87`); both worktrees removed; no active worktrees. **Pending:** 3 squash-merged branches (manpage-refresh/tok-autosync/scholar-fix) await manual `git branch -D`; CI-gate **Phase 3** (promote `full-suite` to required check after dev soak). |
| `~/.git-worktrees/flow-cli/feature-flow-claude-v2` | `feature/flow-claude-v2` | ORCHESTRATE written — awaiting impl in new session |

---

Expand Down Expand Up @@ -440,4 +458,4 @@
**Status:** v7.10.2 SHIPPED (main + Homebrew tap) — docs polish + dep maintenance | full suite REQUIRED on main — 64 passed / 0 failed / 1 skipped | 14 dispatchers + at bridge | 216 test files | 12000+ test functions | 0 lint errors | 0 broken links
## wins: Fixed the regression bug (2026-06-19), --category fix squashed the bug (2026-06-19), fixed the bug (2026-06-19), Fixed the regression bug (2026-06-19), --category fix squashed the bug (2026-06-19)
## streak: 1
## last_active: 2026-06-19 08:50
## last_active: 2026-06-19 10:30
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [7.13.0] — 2026-06-19 — flow claude: C7-C11 checks + watch daemon

### Added

- **C4 two-tier threshold** (`commands/claude.zsh`): >100 lines → WARN "approaching 180-line limit"; >180 lines → ERROR "exceeds 180-line hard limit" (was a single >100 check)
- **C7 per-project CLAUDE.md audit**: scans `$FLOW_CLAUDE_PROJECTS_ROOT` (default: `~/projects`) up to depth 4; warns on files >180 lines or version refs that don't match `git describe --tags`; injectable via `FLOW_CLAUDE_PROJECTS_ROOT`
- **C8 orphaned memory dirs**: decodes `~/.claude/projects/` slug names back to filesystem paths (`/a-b-c` → `/a/b/c`); warns on stale dirs whose decoded path no longer exists
- **C9 rules drift**: checks that every `~/.claude/rules/*.md` stem is referenced in `~/.claude/CLAUDE.md`; warns on unreferenced rules
- **C10 missing hook files**: parses `settings.json` hook commands; errors on any absolute-path script that isn't present on disk
- **C11 plugin health**: checks `~/.claude/plugins/*/plugin.json` exists and is valid JSON (skips `cache/` subdir); warns on broken plugins
- **`flow claude watch [--interval N] [--stop] [--status]`**: background health watcher — runs `flow claude check` on a configurable interval (default: 30 min), writes state to `~/.flow/claude-health-state.json`, and fires a desktop notification via `terminal-notifier` when status changes between pass/warn/error; gracefully silent on Linux where `terminal-notifier` is absent

## [7.12.0] — 2026-06-19 — flow claude check: Claude Code environment health

### Added
Expand Down
10 changes: 5 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This file provides guidance to Claude Code when working with code in this reposi
**flow-cli** - Pure ZSH plugin for ADHD-optimized workflow management. Zero dependencies. Standalone (works without Oh-My-Zsh or any plugin manager).

- **Architecture:** Pure ZSH plugin (no Node.js runtime required)
- **Current Version:** v7.12.0
- **Current Version:** v7.13.0
- **Install:** Homebrew (recommended), or any plugin manager
- **Source:** `source /opt/homebrew/opt/flow-cli/flow.plugin.zsh` (via Homebrew)
- **Optional:** Atlas integration for enhanced state management
Expand Down Expand Up @@ -137,7 +137,7 @@ flow-cli/
├── docs/ # Documentation (MkDocs)
│ └── internal/ # Internal conventions & contributor templates
├── scripts/ # Standalone validators (check-math.zsh)
├── tests/ # 218 test files, 12000+ test functions
├── tests/ # 219 test files, 12000+ test functions
│ └── fixtures/demo-course/ # STAT-101 demo course for E2E
└── .archive/ # Archived Node.js CLI
```
Expand Down Expand Up @@ -182,7 +182,7 @@ flow-cli/

## Testing

**218 test files, 12000+ test functions.** Run: `./tests/run-all.sh` (66/66 passing, 1 expected interactive/tmux timeout) or individual suites in `tests/`.
**219 test files, 12000+ test functions.** Run: `./tests/run-all.sh` (67/67 passing, 1 expected interactive/tmux timeout) or individual suites in `tests/`.

See `docs/guides/TESTING.md` for patterns, mocks, assertions, TDD workflow.

Expand Down Expand Up @@ -216,8 +216,8 @@ export FLOW_FORCE_DISPATCHER_OBS=1 # Force-keep one dispatcher (FLOW_F

## Current Status

**Version:** v7.12.0 | **Tests:** 12000+ (66/66 suite, 1 interactive timeout) | **Docs:** https://Data-Wise.github.io/flow-cli/
**Version:** v7.13.0 | **Tests:** 12000+ (67/67 suite, 1 interactive timeout) | **Docs:** https://Data-Wise.github.io/flow-cli/

---

**Last Updated:** 2026-06-19 (v7.12.0)
**Last Updated:** 2026-06-19 (v7.13.0)
149 changes: 149 additions & 0 deletions ORCHESTRATE-flow-claude-v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# ORCHESTRATE: flow claude v2 — Extended Checks + Watch

**Branch:** `feature/flow-claude-v2`
**Spec:** `docs/specs/SPEC-flow-claude-v2.md`
**Target:** v7.13.0

---

## Objective

Extend `flow claude check` with C4 two-tier fix and new checks C7–C11, then
add `flow claude watch` background daemon with terminal-notifier alerts on
WARN/ERROR state change.

---

## Task List

### Wave 1 — Existing file changes (no new files)

- [ ] **1a. Fix C4 two-tier threshold** (`commands/claude.zsh`)
- Change single `if (( line_count > 100 ))` to two-tier:
- `> 100` → `_flow_log_warning` + `has_warn=1`
- `> 180` → `_flow_log_error` + `has_error=1`
- Update help text: `C4 CLAUDE.md length warns > 100 lines, errors > 180`
- Tests: 95 lines → pass, 150 → warn, 200 → error

- [ ] **1b. Add C8: Orphaned memory dirs** (`commands/claude.zsh`)
- After C7 block, iterate `${FLOW_CLAUDE_HOME:-$HOME/.claude}/projects/*/`
- Decode slug to path: `/${slug//-//}` (leading `-` → `/`)
- Flag if `[[ ! -d "$decoded_path" ]]`
- Injectable: `FLOW_CLAUDE_HOME` (already used by C1–C4)
- Tests: mock a slug for a nonexistent dir → warn; valid dir → pass

- [ ] **1c. Add C9: Rules drift** (`commands/claude.zsh`)
- Iterate `$claude_home/rules/*.md`
- Extract stem: `${rule_file:t:r}`
- Check `grep -qF "$stem" "$claude_home/CLAUDE.md"`
- Flag unreferenced stems
- Tests: rule file not cited in CLAUDE.md → warn; all cited → pass

- [ ] **1d. Add C10: Missing hook files** (`commands/claude.zsh`)
- Requires `jq` (guard same as C1)
- Extract from settings.json: `jq -r '(.hooks // {}) | to_entries[] | .value[] | .command'`
- For each command starting with `/` or `~`: check file exists
- Severity: ERROR (not WARN — missing hook = silent breakage)
- Tests: hook path missing → error; hook path present → pass; no hooks → pass

- [ ] **1e. Add C11: Plugin health** (`commands/claude.zsh`)
- Iterate `$claude_home/plugins/*/` (skip `cache/`)
- Check `plugin.json` exists + is valid JSON (`jq empty`)
- Severity: WARN
- Tests: missing plugin.json → warn; invalid JSON → warn; valid → pass

### Wave 2 — C7 (needs helper + git calls)

- [ ] **2a. Add `_flow_find_project_claude_mds` helper** (`commands/claude.zsh` or `lib/core.zsh`)
- `find "${FLOW_CLAUDE_PROJECTS_ROOT:-$HOME/projects}" -maxdepth 4 -name "CLAUDE.md" -not -path "*/.git/*" -not -path "*/node_modules/*"`
- Returns newline-separated paths via stdout

- [ ] **2b. Add C7: Per-project CLAUDE.md audit** (`commands/claude.zsh`)
- Call `_flow_find_project_claude_mds` → iterate paths
- C7a: `wc -l < "$file"` > 180 → warn
- C7b: `git -C "$proj_dir" describe --tags --abbrev=0 2>/dev/null` → if succeeds,
grep file for `v[0-9]+\.[0-9]+\.[0-9]+`, compare each match against tag;
mismatch → warn; no tags → skip silently
- Injectable: `FLOW_CLAUDE_PROJECTS_ROOT`
- Tests: fixture dir with 200-line CLAUDE.md → warn; mocked git tag mismatch → warn;
no tags → pass (no false positive)

### Wave 3 — Watch daemon

- [ ] **3a. Add `flow claude watch` routing** (`commands/claude.zsh`)
- Add `watch)` case to `flow_claude()` dispatch
- Parse `--stop`, `--status`, `--interval N` flags

- [ ] **3b. Implement `_flow_claude_watch_start`** (`commands/claude.zsh`)
- Stale PID check via `kill -0`
- Background loop: `_flow_claude_watch_run_check` → sleep → repeat
- Log rotation: keep last 50KB of `~/.flow/claude-watch.log`
- Write PID to `~/.flow/claude-watch.pid`
- `disown $!` after backgrounding

- [ ] **3c. Implement `_flow_claude_watch_run_check`** (`commands/claude.zsh`)
- Runs `_flow_claude_check` in a subshell, captures exit code
- Translates exit code to result string: 0=pass, 1=error, 2=warn
- Reads previous state from `~/.flow/claude-health-state.json`
- Calls `_flow_claude_watch_notify` on state change
- Writes new state JSON

- [ ] **3d. Implement `_flow_claude_watch_notify`** (`commands/claude.zsh`)
- Only notify if new/old state is warn or error (skip info/pass↔pass)
- `command -v terminal-notifier` guard — silent on Linux
- Call: `terminal-notifier -title "flow claude" -subtitle "..." -message "..." -sound default`

- [ ] **3e. Implement `--stop` and `--status`** (`commands/claude.zsh`)
- `--stop`: read PID file, `kill $pid`, remove pid file
- `--status`: read state JSON, show PID/interval/last-check/result

- [ ] **3f. Update `_flow_claude_help`** with watch subcommand docs

### Wave 4 — Tests

- [ ] **4a. Tests for C4 two-tier, C8, C9, C10, C11** (`tests/test-flow-claude.zsh`)
- Fixture dirs injected via `FLOW_CLAUDE_HOME` / `FLOW_CLAUDE_PROJECTS_ROOT`
- See full test list in `SPEC-flow-claude-v2.md`

- [ ] **4b. Tests for C7** (`tests/test-flow-claude.zsh`)
- Mock `git describe` via function override in test scope

- [ ] **4c. Tests for watch** (`tests/test-flow-claude.zsh`)
- Mock `_flow_claude_check` exit code
- Assert state file transitions
- Assert `--stop` removes pid file
- Assert `--status` doesn't crash when watcher is not running

### Wave 5 — Docs + completions

- [ ] **5a. Update `completions/_flow_claude`** — add `watch`, `--interval`, `--stop`, `--status`
- [ ] **5b. Update `man/man1/flow.1`** — document watch + new checks
- [ ] **5c. Update `CLAUDE.md`** — test count, suite count
- [ ] **5d. Update `TESTING.md`** — test count (3 locations)
- [ ] **5e. Update `CHANGELOG.md`** — Unreleased section

---

## Verification

After each wave:
```zsh
source flow.plugin.zsh
flow claude check
./tests/run-all.sh
```

Final gate before PR:
```zsh
./tests/run-all.sh # expect 66/66 suites passing (+ new test-flow-claude tests)
flow claude check # run against real ~/.claude — all checks should execute
flow claude watch --interval 1 # start 1-min watcher, verify state file written
flow claude watch --status # confirm output
flow claude watch --stop # confirm clean shutdown
```

---

## PR target

`gh pr create --base dev --title "feat(claude): C7-C11 checks + watch daemon (v7.13.0)"`
Loading