liteagents 2.4.0

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 (215) hide show
  1. package/CHANGELOG.md +441 -0
  2. package/LICENSE +21 -0
  3. package/README.md +179 -0
  4. package/cli.js +230 -0
  5. package/docs/.gitkeep +1 -0
  6. package/docs/CONTRIBUTING.md +739 -0
  7. package/docs/DUAL_PUBLISH_SUMMARY.md +177 -0
  8. package/docs/ERROR_HANDLING_IMPLEMENTATION.md +327 -0
  9. package/docs/GITHUB_PACKAGES.md +181 -0
  10. package/docs/GITHUB_SETUP.md +158 -0
  11. package/docs/INSTALLATION_DEMO.md +691 -0
  12. package/docs/INSTALLATION_LOCATIONS.md +299 -0
  13. package/docs/INSTALLER_GUIDE.md +1586 -0
  14. package/docs/INTEGRATION_ISSUES_9.1.md +341 -0
  15. package/docs/KNOWLEDGE_BASE.md +727 -0
  16. package/docs/MIGRATION.md +384 -0
  17. package/docs/PACKAGE_BASELINE.md +557 -0
  18. package/docs/PACKAGE_VALIDATION_REPORT.md +427 -0
  19. package/docs/PASS_INTEGRATION.md +307 -0
  20. package/docs/PASS_QUICK_START.md +150 -0
  21. package/docs/PRIVACY.md +203 -0
  22. package/docs/PUBLISHING.md +494 -0
  23. package/docs/QUICK-START.md +318 -0
  24. package/docs/RELEASE_NOTES_1.2.0.md +323 -0
  25. package/docs/SECURITY.md +317 -0
  26. package/docs/SILENT_MODE_GUIDE.md +526 -0
  27. package/docs/SKILLS_CONVERSION.md +154 -0
  28. package/docs/TESTING.md +582 -0
  29. package/docs/TEST_COVERAGE.md +347 -0
  30. package/docs/TROUBLESHOOTING.md +788 -0
  31. package/docs/UPDATED_VARIANT_CONFIGURATION.md +274 -0
  32. package/docs/VARIANT_CONFIGURATION.md +440 -0
  33. package/installer/cli.js +761 -0
  34. package/installer/installation-engine.js +1536 -0
  35. package/installer/package-manager.js +640 -0
  36. package/installer/path-manager.js +427 -0
  37. package/installer/report-template.js +298 -0
  38. package/installer/verification-system.js +274 -0
  39. package/package.json +83 -0
  40. package/packages/ampcode/AGENT.md +58 -0
  41. package/packages/ampcode/README.md +17 -0
  42. package/packages/ampcode/agents/1-create-prd.md +175 -0
  43. package/packages/ampcode/agents/2-generate-tasks.md +190 -0
  44. package/packages/ampcode/agents/3-process-task-list.md +225 -0
  45. package/packages/ampcode/agents/code-developer.md +198 -0
  46. package/packages/ampcode/agents/context-builder.md +142 -0
  47. package/packages/ampcode/agents/feature-planner.md +199 -0
  48. package/packages/ampcode/agents/market-researcher.md +89 -0
  49. package/packages/ampcode/agents/orchestrator.md +116 -0
  50. package/packages/ampcode/agents/quality-assurance.md +115 -0
  51. package/packages/ampcode/agents/system-architect.md +135 -0
  52. package/packages/ampcode/agents/ui-designer.md +184 -0
  53. package/packages/ampcode/commands/brainstorming.md +56 -0
  54. package/packages/ampcode/commands/code-review.md +107 -0
  55. package/packages/ampcode/commands/condition-based-waiting/example.ts +158 -0
  56. package/packages/ampcode/commands/condition-based-waiting.md +122 -0
  57. package/packages/ampcode/commands/debug.md +20 -0
  58. package/packages/ampcode/commands/docs-builder/templates.md +572 -0
  59. package/packages/ampcode/commands/docs-builder.md +106 -0
  60. package/packages/ampcode/commands/explain.md +18 -0
  61. package/packages/ampcode/commands/git-commit.md +14 -0
  62. package/packages/ampcode/commands/optimize.md +20 -0
  63. package/packages/ampcode/commands/refactor.md +21 -0
  64. package/packages/ampcode/commands/review.md +18 -0
  65. package/packages/ampcode/commands/root-cause-tracing/find-polluter.sh +63 -0
  66. package/packages/ampcode/commands/root-cause-tracing.md +176 -0
  67. package/packages/ampcode/commands/security.md +21 -0
  68. package/packages/ampcode/commands/ship.md +18 -0
  69. package/packages/ampcode/commands/skill-creator/scripts/init_skill.py +303 -0
  70. package/packages/ampcode/commands/skill-creator/scripts/package_skill.py +110 -0
  71. package/packages/ampcode/commands/skill-creator/scripts/quick_validate.py +65 -0
  72. package/packages/ampcode/commands/skill-creator.md +211 -0
  73. package/packages/ampcode/commands/stash.md +45 -0
  74. package/packages/ampcode/commands/systematic-debugging.md +297 -0
  75. package/packages/ampcode/commands/test-driven-development.md +390 -0
  76. package/packages/ampcode/commands/test-generate.md +18 -0
  77. package/packages/ampcode/commands/testing-anti-patterns.md +304 -0
  78. package/packages/ampcode/commands/verification-before-completion.md +152 -0
  79. package/packages/ampcode/settings.json +13 -0
  80. package/packages/ampcode/variants.json +8 -0
  81. package/packages/claude/CLAUDE.md +58 -0
  82. package/packages/claude/README.md +23 -0
  83. package/packages/claude/agents/1-create-prd.md +175 -0
  84. package/packages/claude/agents/2-generate-tasks.md +190 -0
  85. package/packages/claude/agents/3-process-task-list.md +225 -0
  86. package/packages/claude/agents/code-developer.md +198 -0
  87. package/packages/claude/agents/context-builder.md +142 -0
  88. package/packages/claude/agents/feature-planner.md +199 -0
  89. package/packages/claude/agents/market-researcher.md +89 -0
  90. package/packages/claude/agents/orchestrator.md +117 -0
  91. package/packages/claude/agents/quality-assurance.md +115 -0
  92. package/packages/claude/agents/system-architect.md +135 -0
  93. package/packages/claude/agents/ui-designer.md +184 -0
  94. package/packages/claude/commands/debug.md +20 -0
  95. package/packages/claude/commands/explain.md +18 -0
  96. package/packages/claude/commands/git-commit.md +14 -0
  97. package/packages/claude/commands/optimize.md +20 -0
  98. package/packages/claude/commands/refactor.md +21 -0
  99. package/packages/claude/commands/review.md +18 -0
  100. package/packages/claude/commands/security.md +21 -0
  101. package/packages/claude/commands/ship.md +18 -0
  102. package/packages/claude/commands/stash.md +45 -0
  103. package/packages/claude/commands/test-generate.md +18 -0
  104. package/packages/claude/skills/brainstorming/SKILL.md +56 -0
  105. package/packages/claude/skills/code-review/SKILL.md +107 -0
  106. package/packages/claude/skills/code-review/code-reviewer.md +146 -0
  107. package/packages/claude/skills/condition-based-waiting/SKILL.md +122 -0
  108. package/packages/claude/skills/condition-based-waiting/example.ts +158 -0
  109. package/packages/claude/skills/docs-builder/SKILL.md +106 -0
  110. package/packages/claude/skills/docs-builder/references/templates.md +572 -0
  111. package/packages/claude/skills/root-cause-tracing/SKILL.md +176 -0
  112. package/packages/claude/skills/root-cause-tracing/find-polluter.sh +63 -0
  113. package/packages/claude/skills/skill-creator/LICENSE.txt +202 -0
  114. package/packages/claude/skills/skill-creator/SKILL.md +211 -0
  115. package/packages/claude/skills/skill-creator/scripts/init_skill.py +303 -0
  116. package/packages/claude/skills/skill-creator/scripts/package_skill.py +110 -0
  117. package/packages/claude/skills/skill-creator/scripts/quick_validate.py +65 -0
  118. package/packages/claude/skills/systematic-debugging/CREATION-LOG.md +119 -0
  119. package/packages/claude/skills/systematic-debugging/SKILL.md +296 -0
  120. package/packages/claude/skills/systematic-debugging/test-academic.md +14 -0
  121. package/packages/claude/skills/systematic-debugging/test-pressure-1.md +58 -0
  122. package/packages/claude/skills/systematic-debugging/test-pressure-2.md +68 -0
  123. package/packages/claude/skills/systematic-debugging/test-pressure-3.md +69 -0
  124. package/packages/claude/skills/test-driven-development/SKILL.md +392 -0
  125. package/packages/claude/skills/testing-anti-patterns/SKILL.md +304 -0
  126. package/packages/claude/skills/verification-before-completion/SKILL.md +152 -0
  127. package/packages/claude/variants.json +9 -0
  128. package/packages/droid/AGENTS.md +52 -0
  129. package/packages/droid/README.md +17 -0
  130. package/packages/droid/change_settings.json +61 -0
  131. package/packages/droid/commands/brainstorming.md +56 -0
  132. package/packages/droid/commands/code-review.md +107 -0
  133. package/packages/droid/commands/condition-based-waiting/example.ts +158 -0
  134. package/packages/droid/commands/condition-based-waiting.md +122 -0
  135. package/packages/droid/commands/debug.md +20 -0
  136. package/packages/droid/commands/docs-builder/templates.md +572 -0
  137. package/packages/droid/commands/docs-builder.md +106 -0
  138. package/packages/droid/commands/explain.md +18 -0
  139. package/packages/droid/commands/git-commit.md +14 -0
  140. package/packages/droid/commands/optimize.md +20 -0
  141. package/packages/droid/commands/refactor.md +21 -0
  142. package/packages/droid/commands/review.md +18 -0
  143. package/packages/droid/commands/root-cause-tracing/find-polluter.sh +63 -0
  144. package/packages/droid/commands/root-cause-tracing.md +176 -0
  145. package/packages/droid/commands/security.md +21 -0
  146. package/packages/droid/commands/ship.md +18 -0
  147. package/packages/droid/commands/skill-creator/scripts/init_skill.py +303 -0
  148. package/packages/droid/commands/skill-creator/scripts/package_skill.py +110 -0
  149. package/packages/droid/commands/skill-creator/scripts/quick_validate.py +65 -0
  150. package/packages/droid/commands/skill-creator.md +211 -0
  151. package/packages/droid/commands/stash.md +45 -0
  152. package/packages/droid/commands/systematic-debugging.md +297 -0
  153. package/packages/droid/commands/test-driven-development.md +390 -0
  154. package/packages/droid/commands/test-generate.md +18 -0
  155. package/packages/droid/commands/testing-anti-patterns.md +304 -0
  156. package/packages/droid/commands/verification-before-completion.md +152 -0
  157. package/packages/droid/droids/1-create-prd.md +170 -0
  158. package/packages/droid/droids/2-generate-tasks.md +190 -0
  159. package/packages/droid/droids/3-process-task-list.md +225 -0
  160. package/packages/droid/droids/code-developer.md +198 -0
  161. package/packages/droid/droids/context-builder.md +142 -0
  162. package/packages/droid/droids/feature-planner.md +199 -0
  163. package/packages/droid/droids/market-researcher.md +89 -0
  164. package/packages/droid/droids/orchestrator.md +116 -0
  165. package/packages/droid/droids/quality-assurance.md +115 -0
  166. package/packages/droid/droids/system-architect.md +135 -0
  167. package/packages/droid/droids/ui-designer.md +184 -0
  168. package/packages/droid/variants.json +8 -0
  169. package/packages/opencode/AGENTS.md +52 -0
  170. package/packages/opencode/README.md +17 -0
  171. package/packages/opencode/agent/1-create-prd.md +179 -0
  172. package/packages/opencode/agent/2-generate-tasks.md +194 -0
  173. package/packages/opencode/agent/3-process-task-list.md +229 -0
  174. package/packages/opencode/agent/code-developer.md +202 -0
  175. package/packages/opencode/agent/context-builder.md +146 -0
  176. package/packages/opencode/agent/feature-planner.md +203 -0
  177. package/packages/opencode/agent/market-researcher.md +93 -0
  178. package/packages/opencode/agent/orchestrator.md +120 -0
  179. package/packages/opencode/agent/quality-assurance.md +119 -0
  180. package/packages/opencode/agent/system-architect.md +139 -0
  181. package/packages/opencode/agent/ui-designer.md +188 -0
  182. package/packages/opencode/command/brainstorming.md +56 -0
  183. package/packages/opencode/command/code-review.md +107 -0
  184. package/packages/opencode/command/condition-based-waiting/example.ts +158 -0
  185. package/packages/opencode/command/condition-based-waiting.md +122 -0
  186. package/packages/opencode/command/debug.md +20 -0
  187. package/packages/opencode/command/docs-builder/templates.md +572 -0
  188. package/packages/opencode/command/docs-builder.md +106 -0
  189. package/packages/opencode/command/explain.md +18 -0
  190. package/packages/opencode/command/git-commit.md +14 -0
  191. package/packages/opencode/command/optimize.md +20 -0
  192. package/packages/opencode/command/refactor.md +21 -0
  193. package/packages/opencode/command/review.md +18 -0
  194. package/packages/opencode/command/root-cause-tracing/find-polluter.sh +63 -0
  195. package/packages/opencode/command/root-cause-tracing.md +176 -0
  196. package/packages/opencode/command/security.md +21 -0
  197. package/packages/opencode/command/ship.md +18 -0
  198. package/packages/opencode/command/skill-creator/scripts/init_skill.py +303 -0
  199. package/packages/opencode/command/skill-creator/scripts/package_skill.py +110 -0
  200. package/packages/opencode/command/skill-creator/scripts/quick_validate.py +65 -0
  201. package/packages/opencode/command/skill-creator.md +211 -0
  202. package/packages/opencode/command/stash.md +45 -0
  203. package/packages/opencode/command/systematic-debugging.md +297 -0
  204. package/packages/opencode/command/test-driven-development.md +390 -0
  205. package/packages/opencode/command/test-generate.md +18 -0
  206. package/packages/opencode/command/testing-anti-patterns.md +304 -0
  207. package/packages/opencode/command/verification-before-completion.md +152 -0
  208. package/packages/opencode/opencode.jsonc +201 -0
  209. package/packages/opencode/variants.json +8 -0
  210. package/packages/subagentic-manual.md +349 -0
  211. package/postinstall.js +21 -0
  212. package/tools/ampcode/manifest-template.json +14 -0
  213. package/tools/claude/manifest-template.json +14 -0
  214. package/tools/droid/manifest-template.json +14 -0
  215. package/tools/opencode/manifest-template.json +14 -0
@@ -0,0 +1,106 @@
1
+ ---
2
+ name: docs-builder
3
+ description: Create comprehensive project documentation with structured /docs hierarchy
4
+ usage: /docs-builder
5
+ auto_trigger: false
6
+ ---
7
+
8
+ # Documentation Architecture Skill
9
+
10
+ Create systematic /docs structure following this 5-tier hierarchy:
11
+
12
+ ```
13
+ /docs
14
+ ├── 00-context/ # WHY and WHAT EXISTS RIGHT NOW
15
+ ├── 01-product/ # WHAT the product must do
16
+ ├── 02-features/ # HOW features are designed & built
17
+ ├── 03-logs/ # MEMORY (what changed over time)
18
+ ├── 04-process/ # HOW to work with this system
19
+ └── README.md # Navigation guide
20
+ ```
21
+
22
+ ## Workflow
23
+
24
+ ### 1. Discover Project
25
+ - Scan: README, existing /docs, package.json/pyproject.toml, src/, tests/
26
+ - Map existing docs: commands/ → where? development/ → where?
27
+ - Ask: "What's built? What's planned? What's missing?"
28
+
29
+ ### 2. Create Directories
30
+ ```bash
31
+ mkdir -p docs/{00-context,01-product,02-features,03-logs,04-process}
32
+ ```
33
+
34
+ ### 3. Create Files with TodoWrite
35
+
36
+ Track progress:
37
+ - [ ] 00-context (3 files: vision.md, assumptions.md, system-state.md)
38
+ - [ ] 01-product (1 file: prd.md)
39
+ - [ ] 02-features (per feature discovered: feature-spec.md, tech-design.md, dev-tasks.md, test-plan.md)
40
+ - [ ] 03-logs (5 files: implementation-log.md, decisions-log.md, bug-log.md, validation-log.md, insights.md)
41
+ - [ ] 04-process (3 files: dev-workflow.md, definition-of-done.md, llm-prompts.md)
42
+ - [ ] docs/README.md
43
+
44
+ Mark each **completed** before next.
45
+
46
+ For detailed templates, see: `docs-builder/templates.md`
47
+
48
+ ### 4. Integrate with Existing Docs
49
+
50
+ **If CLAUDE.md/KNOWLEDGE_BASE.md exist**:
51
+ Update KNOWLEDGE_BASE.md to reference new structure:
52
+ ```markdown
53
+ ## Project Documentation
54
+ Full /docs structure with context, product, features, logs, process
55
+ → `docs/README.md`
56
+ ```
57
+
58
+ **If existing /docs subdirs exist**:
59
+ - Don't delete - add migration note in docs/README.md
60
+ - Reference existing content where relevant
61
+ - Note in system-state.md that migration in progress
62
+
63
+ ### 5. Validate
64
+
65
+ ```bash
66
+ # Check structure
67
+ ls -la docs/{00-context,01-product,02-features,03-logs,04-process}
68
+
69
+ # Count minimum files
70
+ find docs/00-context -name "*.md" | wc -l # >= 3
71
+ find docs/03-logs -name "*.md" | wc -l # >= 5
72
+ find docs/04-process -name "*.md" | wc -l # >= 3
73
+ test -f docs/01-product/prd.md && echo "✓ PRD exists"
74
+ test -f docs/README.md && echo "✓ README exists"
75
+ ```
76
+
77
+ ## Rules
78
+
79
+ **DO**:
80
+ - Complete one section fully before next
81
+ - Use TodoWrite to track progress
82
+ - Populate files (don't leave empty templates)
83
+ - Use discovered content from project
84
+ - Create feature-<name>/ for each major feature found
85
+ - Initialize all 5 log files with format
86
+ - Mark todos completed immediately after finishing
87
+
88
+ **DON'T**:
89
+ - Skip sections
90
+ - Create empty placeholders
91
+ - Duplicate content across files
92
+ - Delete existing docs
93
+ - Forget to validate at end
94
+
95
+ ## Success Criteria
96
+
97
+ ✅ All 5 tier directories created
98
+ ✅ Minimum files in each (00-context: 3, 01-product: 1, 03-logs: 5, 04-process: 3)
99
+ ✅ Files populated with project-specific content
100
+ ✅ Feature folders created for discovered features
101
+ ✅ docs/README.md complete with navigation
102
+ ✅ Integration with CLAUDE.md/KNOWLEDGE_BASE.md done
103
+ ✅ Validation checks pass
104
+ ✅ All todos marked completed
105
+
106
+ Complete when /docs structure is fully populated and navigable.
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: explain
3
+ description: Explain [code]
4
+ usage: /explain <code-section>
5
+ argument-hint: [file, function, or concept]
6
+ model: claude-3-5-haiku-20241022
7
+ ---
8
+ Explain $ARGUMENTS.
9
+
10
+ ## Cover
11
+ - What it does (purpose)
12
+ - How it works (step by step)
13
+ - Why it's designed this way
14
+ - Dependencies and side effects
15
+ - Potential gotchas
16
+
17
+ Assume reader knows the language but not this codebase.
18
+
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: git-commit
3
+ description: Analyze changes and commit
4
+ usage: /git-commit
5
+ allowed-tools: Bash(git *)
6
+ ---
7
+ 1. Run `git diff --staged` to see changes
8
+ 2. Analyze what was changed and why
9
+ 3. Create a commit message:
10
+ - Format: type(scope): description
11
+ - Types: feat, fix, refactor, docs, test, chore
12
+ - Under 72 chars
13
+ - Body explains WHY if non-obvious
14
+ 4. Execute the commit
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: optimize
3
+ description: Optimize performance [target]
4
+ usage: /optimize <target-area>
5
+ argument-hint: [file-or-function]
6
+ ---
7
+ Analyze $ARGUMENTS for performance.
8
+
9
+ ## Examine
10
+ - Time complexity (Big O)
11
+ - Space complexity
12
+ - I/O operations
13
+ - Database queries (N+1?)
14
+ - Unnecessary allocations
15
+
16
+ ## Output
17
+ - Current bottlenecks
18
+ - Specific optimizations
19
+ - Expected improvement
20
+ - Trade-offs involved
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: refactor
3
+ description: Refactor [code]
4
+ usage: /refactor <code-section>
5
+ argument-hint: [file-or-function]
6
+ ---
7
+ Refactor $ARGUMENTS.
8
+
9
+ ## Goals
10
+ - Reduce complexity
11
+ - Improve readability
12
+ - Apply DRY
13
+ - Better naming
14
+ - Smaller functions (single responsibility)
15
+
16
+ ## Constraints
17
+ - NO behavior changes
18
+ - Keep public API intact
19
+ - Existing tests must pass
20
+
21
+ Explain each change.
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: review
3
+ description: Review code [file]
4
+ usage: /review
5
+ argument-hint: [file or leave empty for staged changes]
6
+ ---
7
+ Review $ARGUMENTS (or staged changes if not specified).
8
+
9
+ ## Check For
10
+ - Security: OWASP Top 10, auth issues, data exposure
11
+ - Performance: N+1 queries, memory leaks, blocking calls
12
+ - Correctness: Edge cases, error handling, type safety
13
+ - Maintainability: Complexity, naming, duplication
14
+
15
+ ## Output Format
16
+ ### 🚨 Critical (blocks merge)
17
+ ### ⚠️ Warnings (should fix)
18
+ ### 💡 Suggestions (nice to have)
@@ -0,0 +1,63 @@
1
+ #!/bin/bash
2
+ # Bisection script to find which test creates unwanted files/state
3
+ # Usage: ./find-polluter.sh <file_or_dir_to_check> <test_pattern>
4
+ # Example: ./find-polluter.sh '.git' 'src/**/*.test.ts'
5
+
6
+ set -e
7
+
8
+ if [ $# -ne 2 ]; then
9
+ echo "Usage: $0 <file_to_check> <test_pattern>"
10
+ echo "Example: $0 '.git' 'src/**/*.test.ts'"
11
+ exit 1
12
+ fi
13
+
14
+ POLLUTION_CHECK="$1"
15
+ TEST_PATTERN="$2"
16
+
17
+ echo "🔍 Searching for test that creates: $POLLUTION_CHECK"
18
+ echo "Test pattern: $TEST_PATTERN"
19
+ echo ""
20
+
21
+ # Get list of test files
22
+ TEST_FILES=$(find . -path "$TEST_PATTERN" | sort)
23
+ TOTAL=$(echo "$TEST_FILES" | wc -l | tr -d ' ')
24
+
25
+ echo "Found $TOTAL test files"
26
+ echo ""
27
+
28
+ COUNT=0
29
+ for TEST_FILE in $TEST_FILES; do
30
+ COUNT=$((COUNT + 1))
31
+
32
+ # Skip if pollution already exists
33
+ if [ -e "$POLLUTION_CHECK" ]; then
34
+ echo "⚠️ Pollution already exists before test $COUNT/$TOTAL"
35
+ echo " Skipping: $TEST_FILE"
36
+ continue
37
+ fi
38
+
39
+ echo "[$COUNT/$TOTAL] Testing: $TEST_FILE"
40
+
41
+ # Run the test
42
+ npm test "$TEST_FILE" > /dev/null 2>&1 || true
43
+
44
+ # Check if pollution appeared
45
+ if [ -e "$POLLUTION_CHECK" ]; then
46
+ echo ""
47
+ echo "🎯 FOUND POLLUTER!"
48
+ echo " Test: $TEST_FILE"
49
+ echo " Created: $POLLUTION_CHECK"
50
+ echo ""
51
+ echo "Pollution details:"
52
+ ls -la "$POLLUTION_CHECK"
53
+ echo ""
54
+ echo "To investigate:"
55
+ echo " npm test $TEST_FILE # Run just this test"
56
+ echo " cat $TEST_FILE # Review test code"
57
+ exit 1
58
+ fi
59
+ done
60
+
61
+ echo ""
62
+ echo "✅ No polluter found - all tests clean!"
63
+ exit 0
@@ -0,0 +1,176 @@
1
+ ---
2
+ name: root-cause-tracing
3
+ description: Use when errors occur deep in execution and you need to trace back to find the original trigger - systematically traces bugs backward through call stack, adding instrumentation when needed, to identify source of invalid data or incorrect behavior
4
+ usage: /root-cause-tracing <issue-description>
5
+ auto_trigger: false
6
+ ---
7
+
8
+ # Root Cause Tracing
9
+
10
+ ## Overview
11
+
12
+ Bugs often manifest deep in the call stack (git init in wrong directory, file created in wrong location, database opened with wrong path). Your instinct is to fix where the error appears, but that's treating a symptom.
13
+
14
+ **Core principle:** Trace backward through the call chain until you find the original trigger, then fix at the source.
15
+
16
+ ## When to Use
17
+
18
+ ```dot
19
+ digraph when_to_use {
20
+ "Bug appears deep in stack?" [shape=diamond];
21
+ "Can trace backwards?" [shape=diamond];
22
+ "Fix at symptom point" [shape=box];
23
+ "Trace to original trigger" [shape=box];
24
+ "BETTER: Also add defense-in-depth" [shape=box];
25
+
26
+ "Bug appears deep in stack?" -> "Can trace backwards?" [label="yes"];
27
+ "Can trace backwards?" -> "Trace to original trigger" [label="yes"];
28
+ "Can trace backwards?" -> "Fix at symptom point" [label="no - dead end"];
29
+ "Trace to original trigger" -> "BETTER: Also add defense-in-depth";
30
+ }
31
+ ```
32
+
33
+ **Use when:**
34
+ - Error happens deep in execution (not at entry point)
35
+ - Stack trace shows long call chain
36
+ - Unclear where invalid data originated
37
+ - Need to find which test/code triggers the problem
38
+
39
+ ## The Tracing Process
40
+
41
+ ### 1. Observe the Symptom
42
+ ```
43
+ Error: git init failed in /Users/jesse/project/packages/core
44
+ ```
45
+
46
+ ### 2. Find Immediate Cause
47
+ **What code directly causes this?**
48
+ ```typescript
49
+ await execFileAsync('git', ['init'], { cwd: projectDir });
50
+ ```
51
+
52
+ ### 3. Ask: What Called This?
53
+ ```typescript
54
+ WorktreeManager.createSessionWorktree(projectDir, sessionId)
55
+ → called by Session.initializeWorkspace()
56
+ → called by Session.create()
57
+ → called by test at Project.create()
58
+ ```
59
+
60
+ ### 4. Keep Tracing Up
61
+ **What value was passed?**
62
+ - `projectDir = ''` (empty string!)
63
+ - Empty string as `cwd` resolves to `process.cwd()`
64
+ - That's the source code directory!
65
+
66
+ ### 5. Find Original Trigger
67
+ **Where did empty string come from?**
68
+ ```typescript
69
+ const context = setupCoreTest(); // Returns { tempDir: '' }
70
+ Project.create('name', context.tempDir); // Accessed before beforeEach!
71
+ ```
72
+
73
+ ## Adding Stack Traces
74
+
75
+ When you can't trace manually, add instrumentation:
76
+
77
+ ```typescript
78
+ // Before the problematic operation
79
+ async function gitInit(directory: string) {
80
+ const stack = new Error().stack;
81
+ console.error('DEBUG git init:', {
82
+ directory,
83
+ cwd: process.cwd(),
84
+ nodeEnv: process.env.NODE_ENV,
85
+ stack,
86
+ });
87
+
88
+ await execFileAsync('git', ['init'], { cwd: directory });
89
+ }
90
+ ```
91
+
92
+ **Critical:** Use `console.error()` in tests (not logger - may not show)
93
+
94
+ **Run and capture:**
95
+ ```bash
96
+ npm test 2>&1 | grep 'DEBUG git init'
97
+ ```
98
+
99
+ **Analyze stack traces:**
100
+ - Look for test file names
101
+ - Find the line number triggering the call
102
+ - Identify the pattern (same test? same parameter?)
103
+
104
+ ## Finding Which Test Causes Pollution
105
+
106
+ If something appears during tests but you don't know which test:
107
+
108
+ Use the bisection script: @find-polluter.sh
109
+
110
+ ```bash
111
+ ./find-polluter.sh '.git' 'src/**/*.test.ts'
112
+ ```
113
+
114
+ Runs tests one-by-one, stops at first polluter. See script for usage.
115
+
116
+ ## Real Example: Empty projectDir
117
+
118
+ **Symptom:** `.git` created in `packages/core/` (source code)
119
+
120
+ **Trace chain:**
121
+ 1. `git init` runs in `process.cwd()` ← empty cwd parameter
122
+ 2. WorktreeManager called with empty projectDir
123
+ 3. Session.create() passed empty string
124
+ 4. Test accessed `context.tempDir` before beforeEach
125
+ 5. setupCoreTest() returns `{ tempDir: '' }` initially
126
+
127
+ **Root cause:** Top-level variable initialization accessing empty value
128
+
129
+ **Fix:** Made tempDir a getter that throws if accessed before beforeEach
130
+
131
+ **Also added defense-in-depth:**
132
+ - Layer 1: Project.create() validates directory
133
+ - Layer 2: WorkspaceManager validates not empty
134
+ - Layer 3: NODE_ENV guard refuses git init outside tmpdir
135
+ - Layer 4: Stack trace logging before git init
136
+
137
+ ## Key Principle
138
+
139
+ ```dot
140
+ digraph principle {
141
+ "Found immediate cause" [shape=ellipse];
142
+ "Can trace one level up?" [shape=diamond];
143
+ "Trace backwards" [shape=box];
144
+ "Is this the source?" [shape=diamond];
145
+ "Fix at source" [shape=box];
146
+ "Add validation at each layer" [shape=box];
147
+ "Bug impossible" [shape=doublecircle];
148
+ "NEVER fix just the symptom" [shape=octagon, style=filled, fillcolor=red, fontcolor=white];
149
+
150
+ "Found immediate cause" -> "Can trace one level up?";
151
+ "Can trace one level up?" -> "Trace backwards" [label="yes"];
152
+ "Can trace one level up?" -> "NEVER fix just the symptom" [label="no"];
153
+ "Trace backwards" -> "Is this the source?";
154
+ "Is this the source?" -> "Trace backwards" [label="no - keeps going"];
155
+ "Is this the source?" -> "Fix at source" [label="yes"];
156
+ "Fix at source" -> "Add validation at each layer";
157
+ "Add validation at each layer" -> "Bug impossible";
158
+ }
159
+ ```
160
+
161
+ **NEVER fix just where the error appears.** Trace back to find the original trigger.
162
+
163
+ ## Stack Trace Tips
164
+
165
+ **In tests:** Use `console.error()` not logger - logger may be suppressed
166
+ **Before operation:** Log before the dangerous operation, not after it fails
167
+ **Include context:** Directory, cwd, environment variables, timestamps
168
+ **Capture stack:** `new Error().stack` shows complete call chain
169
+
170
+ ## Real-World Impact
171
+
172
+ From debugging session (2025-10-03):
173
+ - Found root cause through 5-level trace
174
+ - Fixed at source (getter validation)
175
+ - Added 4 layers of defense
176
+ - 1847 tests passed, zero pollution
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: security
3
+ description: Scan security [target]
4
+ usage: /security
5
+ argument-hint: [file, directory, or leave empty for full scan]
6
+ allowed-tools: Read, Grep, Glob
7
+ ---
8
+ Audit $ARGUMENTS for security vulnerabilities.
9
+
10
+ ## Check For
11
+ - Injection: SQL, command, XSS, template
12
+ - Auth: Weak passwords, session issues, CSRF
13
+ - Data: Exposure, logging secrets, insecure storage
14
+ - Config: Debug mode, default creds, missing headers
15
+ - Dependencies: Known CVEs
16
+
17
+ ## Output
18
+ Severity-ranked findings with:
19
+ - Location (file:line)
20
+ - Risk explanation
21
+ - Remediation steps
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: ship
3
+ description: Check pre-deployment
4
+ usage: /ship
5
+ allowed-tools: Bash(npm *), Bash(git *)
6
+ ---
7
+ Pre-deploy checklist:
8
+
9
+ - [ ] Tests pass (`npm test`)
10
+ - [ ] Lint clean (`npm run lint`)
11
+ - [ ] Build succeeds (`npm run build`)
12
+ - [ ] No console.log/debugger statements
13
+ - [ ] Env vars documented
14
+ - [ ] No hardcoded secrets
15
+ - [ ] Error handling complete
16
+ - [ ] Migrations ready
17
+
18
+ Run checks and report: Ready 🚀 or Blocked 🛑 with issues.