anvil-dev-framework 0.1.7 → 0.1.9

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.
Files changed (143) hide show
  1. package/README.md +71 -22
  2. package/VERSION +1 -1
  3. package/docs/ANV-263-hook-logging-investigation.md +116 -0
  4. package/docs/command-reference.md +398 -17
  5. package/docs/session-workflow.md +62 -9
  6. package/docs/system-architecture.md +584 -0
  7. package/global/api/__pycache__/ralph_api.cpython-314.pyc +0 -0
  8. package/global/api/openapi.yaml +357 -0
  9. package/global/api/ralph_api.py +528 -0
  10. package/global/commands/anvil-settings.md +47 -19
  11. package/global/commands/audit.md +163 -0
  12. package/global/commands/checklist.md +180 -0
  13. package/global/commands/coderabbit-fix.md +282 -0
  14. package/global/commands/efficiency.md +356 -0
  15. package/global/commands/evidence.md +117 -33
  16. package/global/commands/hud.md +24 -0
  17. package/global/commands/insights.md +101 -3
  18. package/global/commands/orient.md +22 -21
  19. package/global/commands/patterns.md +115 -0
  20. package/global/commands/ralph.md +47 -1
  21. package/global/commands/token-budget.md +214 -0
  22. package/global/commands/weekly-review.md +21 -1
  23. package/global/config/notifications.yaml.template +50 -0
  24. package/global/hooks/ralph_stop.sh +33 -1
  25. package/global/hooks/statusline.sh +67 -2
  26. package/global/lib/__pycache__/coderabbit_metrics.cpython-314.pyc +0 -0
  27. package/global/lib/__pycache__/command_tracker.cpython-314.pyc +0 -0
  28. package/global/lib/__pycache__/context_optimizer.cpython-314.pyc +0 -0
  29. package/global/lib/__pycache__/git_utils.cpython-314.pyc +0 -0
  30. package/global/lib/__pycache__/issue_models.cpython-314.pyc +0 -0
  31. package/global/lib/__pycache__/linear_provider.cpython-314.pyc +0 -0
  32. package/global/lib/__pycache__/optimization_applier.cpython-314.pyc +0 -0
  33. package/global/lib/__pycache__/ralph_state.cpython-314.pyc +0 -0
  34. package/global/lib/__pycache__/ralph_webhooks.cpython-314.pyc +0 -0
  35. package/global/lib/__pycache__/state_manager.cpython-314.pyc +0 -0
  36. package/global/lib/__pycache__/token_analyzer.cpython-314.pyc +0 -0
  37. package/global/lib/__pycache__/token_metrics.cpython-314.pyc +0 -0
  38. package/global/lib/coderabbit_metrics.py +647 -0
  39. package/global/lib/command_tracker.py +147 -0
  40. package/global/lib/context_optimizer.py +323 -0
  41. package/global/lib/linear_provider.py +210 -16
  42. package/global/lib/log_rotation.py +287 -0
  43. package/global/lib/optimization_applier.py +582 -0
  44. package/global/lib/ralph_events.py +398 -0
  45. package/global/lib/ralph_notifier.py +366 -0
  46. package/global/lib/ralph_state.py +264 -24
  47. package/global/lib/ralph_webhooks.py +470 -0
  48. package/global/lib/state_manager.py +121 -0
  49. package/global/lib/token_analyzer.py +1383 -0
  50. package/global/lib/token_metrics.py +919 -0
  51. package/global/tests/__pycache__/test_command_tracker.cpython-314-pytest-9.0.2.pyc +0 -0
  52. package/global/tests/__pycache__/test_context_optimizer.cpython-314-pytest-9.0.2.pyc +0 -0
  53. package/global/tests/__pycache__/test_doc_coverage.cpython-314-pytest-9.0.2.pyc +0 -0
  54. package/global/tests/__pycache__/test_git_utils.cpython-314-pytest-9.0.2.pyc +0 -0
  55. package/global/tests/__pycache__/test_issue_models.cpython-314-pytest-9.0.2.pyc +0 -0
  56. package/global/tests/__pycache__/test_linear_filtering.cpython-314-pytest-9.0.2.pyc +0 -0
  57. package/global/tests/__pycache__/test_linear_provider.cpython-314-pytest-9.0.2.pyc +0 -0
  58. package/global/tests/__pycache__/test_local_provider.cpython-314-pytest-9.0.2.pyc +0 -0
  59. package/global/tests/__pycache__/test_optimization_applier.cpython-314-pytest-9.0.2.pyc +0 -0
  60. package/global/tests/__pycache__/test_token_analyzer.cpython-314-pytest-9.0.2.pyc +0 -0
  61. package/global/tests/__pycache__/test_token_analyzer_phase6.cpython-314-pytest-9.0.2.pyc +0 -0
  62. package/global/tests/__pycache__/test_token_metrics.cpython-314-pytest-9.0.2.pyc +0 -0
  63. package/global/tests/test_command_tracker.py +172 -0
  64. package/global/tests/test_context_optimizer.py +321 -0
  65. package/global/tests/test_linear_filtering.py +319 -0
  66. package/global/tests/test_linear_provider.py +40 -1
  67. package/global/tests/test_optimization_applier.py +508 -0
  68. package/global/tests/test_token_analyzer.py +735 -0
  69. package/global/tests/test_token_analyzer_phase6.py +537 -0
  70. package/global/tests/test_token_metrics.py +829 -0
  71. package/global/tools/README.md +153 -0
  72. package/global/tools/__pycache__/anvil-hud.cpython-314.pyc +0 -0
  73. package/global/tools/__pycache__/orient_linear.cpython-314.pyc +0 -0
  74. package/global/tools/__pycache__/ralph-watchcpython-314.pyc +0 -0
  75. package/global/tools/anvil-hud.py +86 -1
  76. package/global/tools/anvil-memory/src/__tests__/ccs/context-monitor.test.ts +472 -0
  77. package/global/tools/anvil-memory/src/__tests__/ccs/fixtures.ts +405 -0
  78. package/global/tools/anvil-memory/src/__tests__/ccs/index.ts +36 -0
  79. package/global/tools/anvil-memory/src/__tests__/ccs/prompt-generator.test.ts +653 -0
  80. package/global/tools/anvil-memory/src/__tests__/ccs/ralph-stop.test.ts +727 -0
  81. package/global/tools/anvil-memory/src/__tests__/ccs/test-utils.ts +340 -0
  82. package/global/tools/anvil-memory/src/__tests__/commands.test.ts +218 -0
  83. package/global/tools/anvil-memory/src/commands/context.ts +322 -0
  84. package/global/tools/anvil-memory/src/db.ts +108 -0
  85. package/global/tools/anvil-memory/src/index.ts +2 -8
  86. package/global/tools/orient_linear.py +159 -0
  87. package/global/tools/ralph-watch +423 -0
  88. package/package.json +2 -1
  89. package/project/.anvil-project.yaml.template +93 -0
  90. package/project/CLAUDE.md.template +343 -0
  91. package/project/agents/README.md +119 -0
  92. package/project/agents/cross-layer-debugger.md +217 -0
  93. package/project/agents/security-code-reviewer.md +162 -0
  94. package/project/constitution.md.template +235 -0
  95. package/project/coordination.md +103 -0
  96. package/project/docs/background-tasks.md +258 -0
  97. package/project/docs/skills-frontmatter.md +243 -0
  98. package/project/examples/README.md +106 -0
  99. package/project/examples/api-route-template.ts +171 -0
  100. package/project/examples/component-template.tsx +110 -0
  101. package/project/examples/hook-template.ts +152 -0
  102. package/project/examples/service-template.ts +207 -0
  103. package/project/examples/test-template.test.tsx +249 -0
  104. package/project/hooks/README.md +491 -0
  105. package/project/hooks/__pycache__/notification.cpython-314.pyc +0 -0
  106. package/project/hooks/__pycache__/post_tool_use.cpython-314.pyc +0 -0
  107. package/project/hooks/__pycache__/pre_tool_use.cpython-314.pyc +0 -0
  108. package/project/hooks/__pycache__/session_start.cpython-314.pyc +0 -0
  109. package/project/hooks/__pycache__/stop.cpython-314.pyc +0 -0
  110. package/project/hooks/notification.py +183 -0
  111. package/project/hooks/permission_request.py +438 -0
  112. package/project/hooks/post_tool_use.py +397 -0
  113. package/project/hooks/pre_compact.py +126 -0
  114. package/project/hooks/pre_tool_use.py +454 -0
  115. package/project/hooks/session_start.py +656 -0
  116. package/project/hooks/stop.py +356 -0
  117. package/project/hooks/subagent_start.py +223 -0
  118. package/project/hooks/subagent_stop.py +215 -0
  119. package/project/hooks/user_prompt_submit.py +110 -0
  120. package/project/hooks/utils/llm/anth.py +114 -0
  121. package/project/hooks/utils/llm/oai.py +114 -0
  122. package/project/hooks/utils/tts/elevenlabs_tts.py +63 -0
  123. package/project/hooks/utils/tts/mlx_audio_tts.py +86 -0
  124. package/project/hooks/utils/tts/openai_tts.py +92 -0
  125. package/project/hooks/utils/tts/pyttsx3_tts.py +75 -0
  126. package/project/linear.yaml.template +23 -0
  127. package/project/product.md.template +238 -0
  128. package/project/retros/README.md +126 -0
  129. package/project/rules/README.md +90 -0
  130. package/project/rules/debugging.md +139 -0
  131. package/project/rules/security-review.md +115 -0
  132. package/project/settings.yaml.template +185 -0
  133. package/project/specs/SPEC-ANV-72-hud-kanban.md +525 -0
  134. package/project/templates/api-python/CLAUDE.md +547 -0
  135. package/project/templates/generic/CLAUDE.md +260 -0
  136. package/project/templates/saas/CLAUDE.md +478 -0
  137. package/project/tests/README.md +140 -0
  138. package/project/tests/__pycache__/test_transcript_parser.cpython-314-pytest-9.0.2.pyc +0 -0
  139. package/project/tests/fixtures/sample-transcript.jsonl +21 -0
  140. package/project/tests/test-hooks.sh +259 -0
  141. package/project/tests/test-lib.sh +248 -0
  142. package/project/tests/test-statusline.sh +165 -0
  143. package/project/tests/test_transcript_parser.py +323 -0
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ```
2
2
  ___ _ ___ _____ _
3
3
  / \ | \ | \ \ / /_ _| |
4
- / /_\ \ | \| |\ \ / / | || | v0.1.7.0 (alpha)
4
+ / /_\ \ | \| |\ \ / / | || | v0.1.9.0 (alpha)
5
5
  / _____ \| |\ | \ V / | || |___
6
6
  /_/ \_\_| \_| \_/ |___|_____|
7
7
 
@@ -10,7 +10,7 @@
10
10
  ══════════════════════════════════════════════════════════
11
11
  ```
12
12
 
13
- # Anvil Development Framework <sup>v0.1.7.0</sup>
13
+ # Anvil Development Framework <sup>v0.1.9.0</sup>
14
14
 
15
15
  > **A structured AI development system for solo builders who demand production-quality output.**
16
16
 
@@ -18,18 +18,21 @@ Anvil is a comprehensive framework for AI-assisted software development that com
18
18
 
19
19
  ---
20
20
 
21
- ## 📦 Latest Changes in v0.1.7.0
21
+ ## 📦 Latest Changes in v0.1.9.0
22
22
 
23
- *Released: 2026-01-15*
23
+ *Released: 2026-01-17*
24
24
 
25
- - **npm Package Distribution** Anvil now available via `npm install -g anvil-dev-framework`
26
- - Also works with Bun: `bun install -g anvil-dev-framework`
27
- - **Repository Hygiene System** — Detect and clean up stale PRs, orphan branches, and accumulated stashes
28
- - New `/cleanup` command with dry-run and force modes
29
- - Integrated into `/healthcheck` and `/orient`
30
- - **Context Checkpoint System Phase 1** — L1/L2/L3 visual indicators for context thresholds
31
- - **Statusline v2 Fixes** — Per-agent costs, turns-until-compaction, heartbeat system
32
- - **/sprint and /ready Integration** Unified work prioritization commands
25
+ - **Ralph Visibility & Notification System** (ANV-298) Real-time monitoring for autonomous execution
26
+ - Live terminal watcher (`ralph-watch`) with progress bars and event stream
27
+ - macOS Notification Center and TTS announcements for milestones
28
+ - Slack/Discord webhook integrations for team visibility
29
+ - REST API with SSE for future GUI integration
30
+ - Toggle notifications: `--enable/--disable {all,macos,tts,slack,discord}`
31
+ - **Token Efficiency Audit Framework** — Complete token consumption tracking and optimization
32
+ - `/efficiency` command for historical analysis with weekly/monthly reports
33
+ - `/token-budget` command for session budget management with alerts
34
+ - **CodeRabbit Deep Integration** — Automated code review workflow
35
+ - Enhanced `.coderabbit.yaml` with pre-merge checks and custom Anvil validations
33
36
 
34
37
  See [CHANGELOG.md](CHANGELOG.md) for complete history.
35
38
 
@@ -155,16 +158,9 @@ npm install -g anvil-dev-framework
155
158
  anvil init
156
159
  ```
157
160
 
158
- **Option 3: Homebrew (macOS)** *(coming soon)*
161
+ **Option 3: From Source**
159
162
  ```bash
160
- brew tap alexandercahiz/anvil
161
- brew install anvil
162
- anvil init
163
- ```
164
-
165
- **Option 4: From Source**
166
- ```bash
167
- git clone https://github.com/alexandercahiz/anvil-dev-framework.git
163
+ git clone https://github.com/AMPMIO/anvil-dev-framework.git
168
164
  cd anvil-dev-framework
169
165
  ./scripts/install.sh # Auto-configures PATH
170
166
  anvil init
@@ -499,10 +495,27 @@ This remains your **default approach** for all normal development work.
499
495
 
500
496
  ### Ralph Mode (Special Scenarios Only)
501
497
 
502
- ```
498
+ ```bash
499
+ # Manual task description
503
500
  /ralph start "Migrate all tests from Jest to Vitest" --max-iterations 50
501
+
502
+ # From Linear issue (recommended) - fetches subtasks automatically
503
+ /ralph start --issue ANV-209
504
+
505
+ # From Linear project - process all issues in a project
506
+ /ralph start --project "HUD Development"
504
507
  ```
505
508
 
509
+ **Linear Integration Flags:**
510
+
511
+ | Flag | Description |
512
+ |------|-------------|
513
+ | `--issue` | Linear issue ID to fetch subtasks from (e.g., `ANV-209`) |
514
+ | `--project` | Linear project name to process all issues |
515
+ | `--subtasks` | Filter subtasks (e.g., `ANV-1..ANV-5` or `ANV-1,ANV-3`) |
516
+ | `--include-done` | Include already-completed issues in project mode |
517
+ | `--no-sync` | Disable syncing status back to Linear |
518
+
506
519
  | Good For | Not Good For |
507
520
  |----------|--------------|
508
521
  | ✅ Large-scale refactoring with clear completion criteria | ❌ Exploratory work (figuring things out) |
@@ -522,6 +535,40 @@ This remains your **default approach** for all normal development work.
522
535
 
523
536
  **Recommendation**: Start with `--max-iterations 10` to understand costs before running overnight.
524
537
 
538
+ ### Monitoring Ralph Sessions
539
+
540
+ Watch Ralph progress in real-time with the visibility tools:
541
+
542
+ ```bash
543
+ # Terminal 1: Run Ralph
544
+ /ralph start --issue ANV-209
545
+
546
+ # Terminal 2: Watch progress (full display)
547
+ python3 global/tools/ralph-watch
548
+
549
+ # Or compact single-line mode
550
+ python3 global/tools/ralph-watch --compact
551
+ ```
552
+
553
+ **Notification Options:**
554
+ ```bash
555
+ # Toggle notifications
556
+ python3 global/lib/ralph_notifier.py --disable tts # Mute TTS
557
+ python3 global/lib/ralph_notifier.py --enable macos # Enable desktop
558
+
559
+ # Start API server for external monitoring
560
+ python3 global/api/ralph_api.py --port 8765
561
+ ```
562
+
563
+ **Event Types:**
564
+ - `session_started` — Ralph begins work
565
+ - `subtask_complete` — Linear subtask finished
566
+ - `session_complete` — All work done
567
+ - `error_occurred` — Something went wrong
568
+ - `circuit_breaker` — No file changes detected (stuck)
569
+
570
+ See `global/tools/README.md` for full documentation.
571
+
525
572
  ### Decision Flowchart
526
573
 
527
574
  ```
@@ -671,6 +718,7 @@ Anvil uses **four-part versioning**: `MILESTONE.MAJOR.MINOR.PATCH`
671
718
  ---
672
719
 
673
720
  ### Future (Post-1.0)
721
+ - [ ] Homebrew CLI distribution (macOS/Linux)
674
722
  - [ ] Additional templates (mobile, Rails, Go)
675
723
  - [ ] VS Code extension
676
724
  - [ ] Dashboard for metrics
@@ -682,6 +730,7 @@ Anvil uses **four-part versioning**: `MILESTONE.MAJOR.MINOR.PATCH`
682
730
 
683
731
  | Document | Description |
684
732
  |----------|-------------|
733
+ | [System Architecture](docs/system-architecture.md) | **OVERVIEW** — How Linear + CodeRabbit + Claude Code + Memory integrate |
685
734
  | [Session Workflow](docs/session-workflow.md) | **START HERE** — Daily coding workflow |
686
735
  | [Local Issue Tracking](docs/local-issues.md) | File-based issues without Linear |
687
736
  | [Sync Guide](docs/sync.md) | Keep projects updated with framework changes |
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7.1
1
+ 0.1.9.0
@@ -0,0 +1,116 @@
1
+ # Investigation: Pre/Post Tool Use Hook Logging Discrepancy
2
+
3
+ **Issue**: ANV-263
4
+ **Date**: 2026-01-15
5
+ **Status**: Root cause identified
6
+
7
+ ---
8
+
9
+ ## Problem Statement
10
+
11
+ The healthcheck report from 2026-01-15-1721 flagged:
12
+ > "pre_tool_use entries (2) much lower than post_tool_use (39) suggests potential hook logging inconsistency"
13
+
14
+ ## Investigation Summary
15
+
16
+ ### Initial Observations
17
+
18
+ | Metric | pre_tool_use.json | post_tool_use.json |
19
+ |--------|-------------------|-------------------|
20
+ | File size | 23KB → grew to larger | 125KB → smaller |
21
+ | Total entries | 42 | 2 |
22
+ | Unique tool_use_ids | 25 | 1 |
23
+ | Duplicate entries | 17 (40%) | 1 (50%) |
24
+
25
+ The discrepancy reversed direction during investigation - at the time of analysis, pre_tool_use had MORE entries than post_tool_use.
26
+
27
+ ### Root Cause: Duplicate Hook Registration
28
+
29
+ **Both hooks are registered in TWO locations:**
30
+
31
+ 1. **Global settings** (`~/.claude/settings.json`):
32
+ ```json
33
+ "PreToolUse": [{
34
+ "hooks": [{
35
+ "command": "uv run .claude/hooks/pre_tool_use.py"
36
+ }]
37
+ }]
38
+ ```
39
+
40
+ 2. **Local settings** (`.claude/settings.local.json`):
41
+ ```json
42
+ "PreToolUse": [{
43
+ "hooks": [{
44
+ "command": "uv run .claude/hooks/pre_tool_use.py --announce --track-tokens"
45
+ }]
46
+ }]
47
+ ```
48
+
49
+ **Result**: Every tool invocation triggers the hook TWICE, producing duplicate log entries.
50
+
51
+ ### Evidence
52
+
53
+ Duplicate tool_use_ids found (each appears exactly 2 times):
54
+ - `toolu_01SLbsZ2Mqn3eP...`
55
+ - `toolu_018xwr4o547Byp...`
56
+ - `toolu_01SrAGnm2mQ7vp...`
57
+ - `toolu_018SeysS4mLJih...`
58
+ - `toolu_01KAMaFWvecFKQ...`
59
+
60
+ The consistent 2x duplication pattern confirms the dual registration cause.
61
+
62
+ ### Why Counts Varied
63
+
64
+ The original healthcheck showed pre_tool_use with fewer entries because:
65
+ 1. Logs may have been rotated or cleared at different times
66
+ 2. Different sessions accumulated different counts
67
+ 3. The healthcheck snapshot was taken at a specific moment
68
+
69
+ ## Recommendations
70
+
71
+ ### Option A: Remove Global Registration (Recommended)
72
+ Remove the hook from `~/.claude/settings.json` since local settings are project-specific and include the correct flags.
73
+
74
+ ```bash
75
+ # Edit ~/.claude/settings.json and remove the PreToolUse and PostToolUse entries
76
+ ```
77
+
78
+ ### Option B: Add Deduplication Logic
79
+ Add tool_use_id deduplication in the hook itself:
80
+
81
+ ```python
82
+ # Before appending, check if tool_use_id already exists
83
+ if not any(e.get('tool_use_id') == input_data.get('tool_use_id') for e in log_data):
84
+ log_data.append(input_data)
85
+ ```
86
+
87
+ ### Option C: Use File Locking
88
+ If concurrent execution is needed, use proper file locking:
89
+
90
+ ```python
91
+ import fcntl
92
+ with open(log_path, 'r+') as f:
93
+ fcntl.flock(f.fileno(), fcntl.LOCK_EX)
94
+ # ... read, modify, write ...
95
+ fcntl.flock(f.fileno(), fcntl.LOCK_UN)
96
+ ```
97
+
98
+ ## Related Issues
99
+
100
+ - ANV-264: Log Rotation (Phase 3b) - will need the log files to be consistent first
101
+ - ANV-260: Parent issue for Insights Recommended Actions
102
+
103
+ ## Files Examined
104
+
105
+ | File | Purpose |
106
+ |------|---------|
107
+ | `.claude/hooks/pre_tool_use.py` | Pre-tool hook implementation (lines 378-398 for logging) |
108
+ | `.claude/hooks/post_tool_use.py` | Post-tool hook implementation (lines 171-189 for logging) |
109
+ | `.claude/settings.local.json` | Project-specific hook registration |
110
+ | `~/.claude/settings.json` | Global hook registration (duplicate) |
111
+ | `logs/pre_tool_use.json` | Pre-tool log file |
112
+ | `logs/post_tool_use.json` | Post-tool log file |
113
+
114
+ ---
115
+
116
+ **Next Steps**: Fix the duplicate registration, then proceed to ANV-264 (log rotation).