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
@@ -0,0 +1,139 @@
1
+ # Debugging Rules
2
+
3
+ > Systematic approach for cross-layer debugging.
4
+
5
+ ---
6
+
7
+ ## Debugging Process
8
+
9
+ ### 1. Reproduce
10
+ - [ ] Can reproduce consistently
11
+ - [ ] Identified trigger conditions
12
+ - [ ] Documented reproduction steps
13
+ - [ ] Minimal reproduction case created
14
+
15
+ ### 2. Isolate
16
+ - [ ] Identified layer (UI/API/DB/External)
17
+ - [ ] Narrowed to specific component
18
+ - [ ] Traced data flow through system
19
+ - [ ] Identified last known good state
20
+
21
+ ### 3. Diagnose
22
+ - [ ] Read error messages/logs
23
+ - [ ] Checked recent changes
24
+ - [ ] Verified assumptions
25
+ - [ ] Tested hypotheses
26
+
27
+ ### 4. Fix
28
+ - [ ] Root cause addressed (not symptom)
29
+ - [ ] Fix is minimal and focused
30
+ - [ ] Side effects considered
31
+ - [ ] Regression test added
32
+
33
+ ---
34
+
35
+ ## Layer-Specific Checks
36
+
37
+ ### Frontend (React/Next.js)
38
+ - Console errors
39
+ - Network tab requests/responses
40
+ - Component state
41
+ - Props drilling issues
42
+ - Hydration mismatches
43
+
44
+ ### API Layer
45
+ - Request/response logging
46
+ - Middleware chain
47
+ - Authentication/authorization
48
+ - Error handling paths
49
+ - Rate limiting
50
+
51
+ ### Database
52
+ - Query execution plans
53
+ - Connection pool status
54
+ - Transaction isolation
55
+ - Index usage
56
+ - Lock contention
57
+
58
+ ### External Services
59
+ - API response codes
60
+ - Timeout handling
61
+ - Retry logic
62
+ - Circuit breaker state
63
+ - Rate limit status
64
+
65
+ ---
66
+
67
+ ## Common Patterns
68
+
69
+ ### Data Flow Issues
70
+ ```
71
+ Request → Middleware → Handler → Service → Database
72
+
73
+ Response ← Transform ← Error Handle ← Result
74
+ ```
75
+
76
+ Check each transition point for:
77
+ - Data shape changes
78
+ - Error swallowing
79
+ - Type coercion
80
+ - Null/undefined handling
81
+
82
+ ### Async Issues
83
+ - Race conditions
84
+ - Unhandled rejections
85
+ - Memory leaks (listeners)
86
+ - Stale closures
87
+ - Missing await
88
+
89
+ ### State Issues
90
+ - Stale state
91
+ - State mutations
92
+ - Re-render loops
93
+ - Context sync
94
+ - Cache invalidation
95
+
96
+ ---
97
+
98
+ ## Diagnostic Tools
99
+
100
+ | Layer | Tools |
101
+ |-------|-------|
102
+ | Frontend | React DevTools, Network tab |
103
+ | API | Request logging, Debug middleware |
104
+ | Database | Query analyzer, pg_stat_statements |
105
+ | General | Git bisect, Feature flags |
106
+
107
+ ---
108
+
109
+ ## Escalation Criteria
110
+
111
+ Escalate when:
112
+ 1. Reproduction requires production data
113
+ 2. Issue spans multiple services
114
+ 3. Suspected security vulnerability
115
+ 4. After 30 minutes without progress
116
+ 5. Fix requires architecture change
117
+
118
+ ---
119
+
120
+ ## Report Format
121
+
122
+ ```markdown
123
+ ## Bug Investigation: [Title]
124
+
125
+ ### Symptoms
126
+ [Observable behavior]
127
+
128
+ ### Root Cause
129
+ [Why it happens]
130
+
131
+ ### Affected Areas
132
+ [Components/services impacted]
133
+
134
+ ### Fix Applied
135
+ [What was changed]
136
+
137
+ ### Prevention
138
+ [How to prevent similar issues]
139
+ ```
@@ -0,0 +1,115 @@
1
+ # Security Review Rules
2
+
3
+ > Checklist and guidelines for security-focused code review.
4
+
5
+ ---
6
+
7
+ ## OWASP Top 10 Checklist
8
+
9
+ ### A01: Broken Access Control
10
+ - [ ] Authorization checked on every endpoint
11
+ - [ ] Direct object references validated
12
+ - [ ] No privilege escalation paths
13
+ - [ ] CORS properly configured
14
+
15
+ ### A02: Cryptographic Failures
16
+ - [ ] Sensitive data encrypted at rest
17
+ - [ ] TLS used for data in transit
18
+ - [ ] No hardcoded secrets
19
+ - [ ] Strong algorithms used (AES-256, bcrypt)
20
+
21
+ ### A03: Injection
22
+ - [ ] Parameterized queries for SQL
23
+ - [ ] Input validation on all user data
24
+ - [ ] Output encoding for XSS prevention
25
+ - [ ] Command injection prevented
26
+
27
+ ### A04: Insecure Design
28
+ - [ ] Threat modeling performed
29
+ - [ ] Security requirements defined
30
+ - [ ] Rate limiting implemented
31
+ - [ ] Input validation at boundaries
32
+
33
+ ### A05: Security Misconfiguration
34
+ - [ ] Security headers present
35
+ - [ ] Debug mode disabled
36
+ - [ ] Default credentials changed
37
+ - [ ] Unnecessary features disabled
38
+
39
+ ### A06: Vulnerable Components
40
+ - [ ] Dependencies up to date
41
+ - [ ] Known vulnerabilities checked
42
+ - [ ] Unused dependencies removed
43
+ - [ ] License compliance verified
44
+
45
+ ### A07: Authentication Failures
46
+ - [ ] Strong password policy
47
+ - [ ] MFA available
48
+ - [ ] Session management secure
49
+ - [ ] Brute force protection
50
+
51
+ ### A08: Integrity Failures
52
+ - [ ] Dependencies verified
53
+ - [ ] CI/CD pipeline secure
54
+ - [ ] Code signing in place
55
+ - [ ] Update mechanism secure
56
+
57
+ ### A09: Logging Failures
58
+ - [ ] Security events logged
59
+ - [ ] No sensitive data in logs
60
+ - [ ] Log integrity protected
61
+ - [ ] Alerting configured
62
+
63
+ ### A10: SSRF
64
+ - [ ] URL validation for user input
65
+ - [ ] Allow-list for external requests
66
+ - [ ] Internal services protected
67
+ - [ ] Metadata endpoints blocked
68
+
69
+ ---
70
+
71
+ ## Review Process
72
+
73
+ 1. **Static Analysis**: Check for obvious vulnerabilities
74
+ 2. **Authentication**: Verify auth flows
75
+ 3. **Authorization**: Trace permission checks
76
+ 4. **Data Flow**: Follow sensitive data
77
+ 5. **Dependencies**: Check for known issues
78
+ 6. **Configuration**: Review security settings
79
+
80
+ ---
81
+
82
+ ## Red Flags
83
+
84
+ - Hardcoded credentials or API keys
85
+ - SQL string concatenation
86
+ - `eval()` or `exec()` with user input
87
+ - Missing HTTPS enforcement
88
+ - Overly permissive CORS
89
+ - Debug endpoints in production
90
+ - Missing rate limiting
91
+ - Sensitive data in URLs
92
+
93
+ ---
94
+
95
+ ## Reporting Format
96
+
97
+ ```markdown
98
+ ## Finding: [Title]
99
+
100
+ **Severity**: Critical|High|Medium|Low
101
+ **Location**: [file:line]
102
+ **CWE**: CWE-XXX
103
+
104
+ ### Description
105
+ [What the vulnerability is]
106
+
107
+ ### Impact
108
+ [What could happen if exploited]
109
+
110
+ ### Recommendation
111
+ [How to fix it]
112
+
113
+ ### Code Reference
114
+ [Specific code that needs change]
115
+ ```
@@ -0,0 +1,185 @@
1
+ # =============================================================================
2
+ # Anvil Framework Configuration (.claude/settings.yaml)
3
+ # =============================================================================
4
+ #
5
+ # This file configures Claude Code behaviors for this project.
6
+ # All settings are optional - sensible defaults are used when not specified.
7
+ #
8
+ # Configuration priority (highest to lowest):
9
+ # 1. Project .claude/settings.yaml (this file)
10
+ # 2. User ~/.claude/settings.yaml
11
+ # 3. Built-in defaults
12
+ #
13
+
14
+ # =============================================================================
15
+ # Verification Configuration
16
+ # =============================================================================
17
+ #
18
+ # Controls the /verify command behavior for running tests, lint, and type checks
19
+ # with automatic iteration on failures.
20
+ #
21
+ # Usage:
22
+ # /verify - Run full verification suite
23
+ # /verify --quick - Skip type checking
24
+ # /verify --test-only - Run tests only
25
+ #
26
+
27
+ verification:
28
+ # Commands to run for each check type
29
+ # If not specified, auto-detected based on project type (package.json, pyproject.toml, etc.)
30
+ commands:
31
+ # test: "npm test" # Node.js default
32
+ # test: "pytest" # Python default
33
+ # test: "cargo test" # Rust default
34
+ # test: "go test ./..." # Go default
35
+
36
+ # lint: "npm run lint" # Node.js default
37
+ # lint: "ruff check ." # Python default
38
+ # lint: "cargo clippy" # Rust default
39
+ # lint: "golangci-lint run" # Go default
40
+
41
+ # types: "npm run typecheck" # Node.js default
42
+ # types: "mypy ." # Python default
43
+ # types: "cargo check" # Rust default
44
+
45
+ # Maximum automatic fix iterations before escalating
46
+ # After this many failed attempts, manual intervention is requested
47
+ max_iterations: 3
48
+
49
+ # Whether passing verification is required before commit/completion
50
+ # When true, stop hook will block exit if verification hasn't passed
51
+ required_for_completion: true
52
+
53
+ # Timeout for individual verification commands (seconds)
54
+ # Commands exceeding this will be killed and marked as failed
55
+ timeout_seconds: 300
56
+
57
+
58
+ # =============================================================================
59
+ # Stop Hook Configuration
60
+ # =============================================================================
61
+ #
62
+ # Controls exit gating based on verification state.
63
+ # Prevents accidental exits when work is incomplete.
64
+ #
65
+ # Hook Registration (add to .claude/settings.json):
66
+ # {
67
+ # "hooks": {
68
+ # "Stop": [{
69
+ # "type": "command",
70
+ # "command": "bash global/hooks/stop_gate.sh"
71
+ # }]
72
+ # }
73
+ # }
74
+ #
75
+ # Environment Variables:
76
+ # ANVIL_REQUIRE_VERIFICATION - Set to "false" to disable gate (default: true)
77
+ # ANVIL_FORCE_EXIT - Set to "true" to bypass gate
78
+ # ANVIL_STOP_GATE_LOG - Set to "true" to enable logging
79
+ #
80
+
81
+ stop_gate:
82
+ # Whether to require verification before allowing exit
83
+ require_verification: true
84
+
85
+ # Allow force exit with /force-exit command
86
+ allow_force_exit: true
87
+
88
+ # Minimum checks that must pass before allowing exit
89
+ required_checks:
90
+ - tests
91
+ - lint
92
+ # - types # Uncomment to also require type checks
93
+
94
+
95
+ # =============================================================================
96
+ # Ralph Wiggum Mode Configuration
97
+ # =============================================================================
98
+ #
99
+ # Long-running unattended execution mode settings.
100
+ # Uses completion promises and iteration loops for multi-hour autonomous sessions.
101
+ #
102
+
103
+ ralph:
104
+ # Maximum iterations before stopping (safety limit)
105
+ max_iterations: 50
106
+
107
+ # State file location for tracking progress
108
+ state_file: ".claude/ralph-state.json"
109
+
110
+ # Prompt template location
111
+ template_dir: "global/templates/ralph"
112
+
113
+
114
+ # =============================================================================
115
+ # PostToolUse Hook Configuration
116
+ # =============================================================================
117
+ #
118
+ # Automatic formatting after Edit/Write operations.
119
+ # Catches the "last 10%" of formatting issues that Claude often misses.
120
+ #
121
+ # Hook Registration (add to .claude/settings.json):
122
+ # {
123
+ # "hooks": {
124
+ # "PostToolUse": [{
125
+ # "matcher": "Edit|Write",
126
+ # "hooks": [{
127
+ # "type": "command",
128
+ # "command": "bash global/hooks/post_tool_format.sh"
129
+ # }]
130
+ # }]
131
+ # }
132
+ # }
133
+ #
134
+ # Environment Variables:
135
+ # CLAUDE_FILE_PATH - Path to file (set automatically by Claude)
136
+ # ANVIL_FORMAT_LOG - Set to "true" to enable logging
137
+ # ANVIL_FORMAT_TIMEOUT - Timeout in seconds (default: 5)
138
+ #
139
+ # Supported Formatters:
140
+ # JS/TS: prettier Python: black/ruff
141
+ # Go: gofmt Bash: shfmt
142
+ # Rust: rustfmt YAML: prettier
143
+ #
144
+
145
+ formatting:
146
+ # Enable auto-formatting after file edits
147
+ enabled: true
148
+
149
+ # Paths to exclude from auto-formatting
150
+ exclude_paths:
151
+ - "node_modules/**"
152
+ - ".git/**"
153
+ - "dist/**"
154
+ - "build/**"
155
+ - "*.lock"
156
+ - "package-lock.json"
157
+ - "yarn.lock"
158
+
159
+ # Maximum file size to format (bytes)
160
+ max_file_size: 1000000 # 1MB
161
+
162
+
163
+ # =============================================================================
164
+ # Project Detection
165
+ # =============================================================================
166
+ #
167
+ # Override automatic project type detection.
168
+ # Usually not needed - auto-detection works for most projects.
169
+ #
170
+
171
+ # project:
172
+ # type: "nodejs" # nodejs, python, rust, go
173
+ # root: "." # Project root relative to this file
174
+
175
+
176
+ # =============================================================================
177
+ # Documentation
178
+ # =============================================================================
179
+ #
180
+ # For full documentation on configuration options, see:
181
+ # - /verify command: global/commands/verify.md
182
+ # - Stop hook: global/hooks/stop_gate.sh
183
+ # - Ralph mode: global/commands/ralph.md
184
+ # - Formatting: global/hooks/post_tool_format.sh
185
+ #