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,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.
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: stash
3
+ description: Stash session context [name]
4
+ usage: /stash ["optional-name"]
5
+ argument-hint: [optional stash name]
6
+ ---
7
+
8
+ Save session context for compaction recovery or handoffs.
9
+
10
+ **Guardrails**
11
+ - Favor straightforward, minimal implementations first and add complexity only when requested or clearly required.
12
+ - Keep changes tightly scoped to the requested outcome.
13
+
14
+ **What it does**
15
+ 1. Captures current conversation context and key decisions
16
+ 2. Records active work in progress
17
+ 3. Stores important findings and insights
18
+ 4. Creates stash file in `.claude/stash/`
19
+ 5. Enables context restoration after compaction
20
+
21
+ **When to use**
22
+ - Before long-running tasks that may trigger compaction
23
+ - When handing off work to another agent or session
24
+ - After completing major investigation or analysis
25
+ - Before taking a break from complex multi-step work
26
+
27
+ **Commands**
28
+ ```bash
29
+ # Stash with auto-generated name
30
+ /stash
31
+
32
+ # Stash with custom name
33
+ /stash "feature-auth-investigation"
34
+
35
+ # List available stashes
36
+ ls .claude/stash/
37
+
38
+ # Restore from stash
39
+ cat .claude/stash/<name>.md
40
+ ```
41
+
42
+ **Reference**
43
+ - Stashes stored in `.claude/stash/` (project-local)
44
+ - Automatically includes: timestamp, active plan, recent decisions
45
+ - Maximum context retention with minimal token usage
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: test-generate
3
+ description: Generate tests [file]
4
+ usage: /test-generate <code-section>
5
+ argument-hint: [file-to-test]
6
+ ---
7
+ Generate tests for $ARGUMENTS.
8
+
9
+ ## Include
10
+ - Happy path (expected usage)
11
+ - Edge cases (empty, null, boundaries)
12
+ - Error scenarios (invalid input, failures)
13
+ - Integration points (mocks for external deps)
14
+
15
+ ## Requirements
16
+ - Match existing test patterns in this project
17
+ - Use the testing framework already in use
18
+ - Clear test names: "should [expected] when [condition]"
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: brainstorming
3
+ description: Use when creating or developing, before writing code or implementation plans - refines rough ideas into fully-formed designs through collaborative questioning, alternative exploration, and incremental validation. Don't use during clear 'mechanical' processes
4
+ usage: /brainstorming <session-type> <topic>
5
+ auto_trigger: false
6
+ ---
7
+
8
+ # Brainstorming Ideas Into Designs
9
+
10
+ ## Overview
11
+
12
+ Help turn ideas into fully formed designs and specs through natural collaborative dialogue.
13
+
14
+ Start by understanding the current project context, then ask questions one at a time to refine the idea. Once you understand what you're building, present the design in small sections (200-300 words), checking after each section whether it looks right so far.
15
+
16
+ ## The Process
17
+
18
+ **Understanding the idea:**
19
+ - Check out the current project state first (files, docs, recent commits)
20
+ - Ask questions one at a time to refine the idea
21
+ - Prefer multiple choice questions when possible, but open-ended is fine too
22
+ - Only one question per message - if a topic needs more exploration, break it into multiple questions
23
+ - Focus on understanding: purpose, constraints, success criteria
24
+
25
+ **Exploring approaches:**
26
+ - Propose 2-3 different approaches with trade-offs
27
+ - Present options conversationally with your recommendation and reasoning
28
+ - Lead with your recommended option and explain why
29
+
30
+ **Presenting the design:**
31
+ - Once you believe you understand what you're building, present the design
32
+ - Break it into sections of 200-300 words
33
+ - Ask after each section whether it looks right so far
34
+ - Cover: architecture, components, data flow, error handling, testing
35
+ - Be ready to go back and clarify if something doesn't make sense
36
+
37
+ ## After the Design
38
+
39
+ **Documentation:**
40
+ - Write the validated design to `docs/plans/YYYY-MM-DD-<topic>-design.md`
41
+ - Use elements-of-style:writing-clearly-and-concisely skill if available
42
+ - Commit the design document to git
43
+
44
+ **Implementation (if continuing):**
45
+ - Ask: "Ready to set up for implementation?"
46
+ - Create isolated workspace for implementation
47
+ - Create detailed implementation plan
48
+
49
+ ## Key Principles
50
+
51
+ - **One question at a time** - Don't overwhelm with multiple questions
52
+ - **Multiple choice preferred** - Easier to answer than open-ended when possible
53
+ - **YAGNI ruthlessly** - Remove unnecessary features from all designs
54
+ - **Explore alternatives** - Always propose 2-3 approaches before settling
55
+ - **Incremental validation** - Present design in sections, validate each
56
+ - **Be flexible** - Go back and clarify when something doesn't make sense
@@ -0,0 +1,107 @@
1
+ ---
2
+ name: code-review
3
+ description: Use when completing tasks, implementing major features, or before merging to verify work meets requirements - reviews implementation against plan or requirements before proceeding
4
+ usage: /code-review <review-scope> <focus-areas>
5
+ auto_trigger: false
6
+ ---
7
+
8
+ # Requesting Code Review
9
+
10
+ Review code thoroughly to catch issues before they cascade.
11
+
12
+ **Core principle:** Review early, review often.
13
+
14
+ ## When to Request Review
15
+
16
+ **Mandatory:**
17
+ - After each task in subagent-driven development
18
+ - After completing major feature
19
+ - Before merge to main
20
+
21
+ **Optional but valuable:**
22
+ - When stuck (fresh perspective)
23
+ - Before refactoring (baseline check)
24
+ - After fixing complex bug
25
+
26
+ ## How to Request
27
+
28
+ **1. Get git SHAs:**
29
+ ```bash
30
+ BASE_SHA=$(git rev-parse HEAD~1) # or origin/main
31
+ HEAD_SHA=$(git rev-parse HEAD)
32
+ ```
33
+
34
+ **2. Conduct code review:**
35
+
36
+ Review implementation against requirements and plan
37
+
38
+ **Placeholders:**
39
+ - `{WHAT_WAS_IMPLEMENTED}` - What you just built
40
+ - `{PLAN_OR_REQUIREMENTS}` - What it should do
41
+ - `{BASE_SHA}` - Starting commit
42
+ - `{HEAD_SHA}` - Ending commit
43
+ - `{DESCRIPTION}` - Brief summary
44
+
45
+ **3. Act on feedback:**
46
+ - Fix Critical issues immediately
47
+ - Fix Important issues before proceeding
48
+ - Note Minor issues for later
49
+ - Push back if reviewer is wrong (with reasoning)
50
+
51
+ ## Example
52
+
53
+ ```
54
+ [Just completed Task 2: Add verification function]
55
+
56
+ You: Let me request code review before proceeding.
57
+
58
+ BASE_SHA=$(git log --oneline | grep "Task 1" | head -1 | awk '{print $1}')
59
+ HEAD_SHA=$(git rev-parse HEAD)
60
+
61
+ [Conduct code review]
62
+ WHAT_WAS_IMPLEMENTED: Verification and repair functions for conversation index
63
+ PLAN_OR_REQUIREMENTS: Task 2 from docs/plans/deployment-plan.md
64
+ BASE_SHA: a7981ec
65
+ HEAD_SHA: 3df7661
66
+ DESCRIPTION: Added verifyIndex() and repairIndex() with 4 issue types
67
+
68
+ [Subagent returns]:
69
+ Strengths: Clean architecture, real tests
70
+ Issues:
71
+ Important: Missing progress indicators
72
+ Minor: Magic number (100) for reporting interval
73
+ Assessment: Ready to proceed
74
+
75
+ You: [Fix progress indicators]
76
+ [Continue to Task 3]
77
+ ```
78
+
79
+ ## Integration with Workflows
80
+
81
+ **Subagent-Driven Development:**
82
+ - Review after EACH task
83
+ - Catch issues before they compound
84
+ - Fix before moving to next task
85
+
86
+ **Executing Plans:**
87
+ - Review after each batch (3 tasks)
88
+ - Get feedback, apply, continue
89
+
90
+ **Ad-Hoc Development:**
91
+ - Review before merge
92
+ - Review when stuck
93
+
94
+ ## Red Flags
95
+
96
+ **Never:**
97
+ - Skip review because "it's simple"
98
+ - Ignore Critical issues
99
+ - Proceed with unfixed Important issues
100
+ - Argue with valid technical feedback
101
+
102
+ **If reviewer wrong:**
103
+ - Push back with technical reasoning
104
+ - Show code/tests that prove it works
105
+ - Request clarification
106
+
107
+ See template at: requesting-code-review/code-reviewer.md
@@ -0,0 +1,146 @@
1
+ # Code Review Agent
2
+
3
+ You are reviewing code changes for production readiness.
4
+
5
+ **Your task:**
6
+ 1. Review {WHAT_WAS_IMPLEMENTED}
7
+ 2. Compare against {PLAN_OR_REQUIREMENTS}
8
+ 3. Check code quality, architecture, testing
9
+ 4. Categorize issues by severity
10
+ 5. Assess production readiness
11
+
12
+ ## What Was Implemented
13
+
14
+ {DESCRIPTION}
15
+
16
+ ## Requirements/Plan
17
+
18
+ {PLAN_REFERENCE}
19
+
20
+ ## Git Range to Review
21
+
22
+ **Base:** {BASE_SHA}
23
+ **Head:** {HEAD_SHA}
24
+
25
+ ```bash
26
+ git diff --stat {BASE_SHA}..{HEAD_SHA}
27
+ git diff {BASE_SHA}..{HEAD_SHA}
28
+ ```
29
+
30
+ ## Review Checklist
31
+
32
+ **Code Quality:**
33
+ - Clean separation of concerns?
34
+ - Proper error handling?
35
+ - Type safety (if applicable)?
36
+ - DRY principle followed?
37
+ - Edge cases handled?
38
+
39
+ **Architecture:**
40
+ - Sound design decisions?
41
+ - Scalability considerations?
42
+ - Performance implications?
43
+ - Security concerns?
44
+
45
+ **Testing:**
46
+ - Tests actually test logic (not mocks)?
47
+ - Edge cases covered?
48
+ - Integration tests where needed?
49
+ - All tests passing?
50
+
51
+ **Requirements:**
52
+ - All plan requirements met?
53
+ - Implementation matches spec?
54
+ - No scope creep?
55
+ - Breaking changes documented?
56
+
57
+ **Production Readiness:**
58
+ - Migration strategy (if schema changes)?
59
+ - Backward compatibility considered?
60
+ - Documentation complete?
61
+ - No obvious bugs?
62
+
63
+ ## Output Format
64
+
65
+ ### Strengths
66
+ [What's well done? Be specific.]
67
+
68
+ ### Issues
69
+
70
+ #### Critical (Must Fix)
71
+ [Bugs, security issues, data loss risks, broken functionality]
72
+
73
+ #### Important (Should Fix)
74
+ [Architecture problems, missing features, poor error handling, test gaps]
75
+
76
+ #### Minor (Nice to Have)
77
+ [Code style, optimization opportunities, documentation improvements]
78
+
79
+ **For each issue:**
80
+ - File:line reference
81
+ - What's wrong
82
+ - Why it matters
83
+ - How to fix (if not obvious)
84
+
85
+ ### Recommendations
86
+ [Improvements for code quality, architecture, or process]
87
+
88
+ ### Assessment
89
+
90
+ **Ready to merge?** [Yes/No/With fixes]
91
+
92
+ **Reasoning:** [Technical assessment in 1-2 sentences]
93
+
94
+ ## Critical Rules
95
+
96
+ **DO:**
97
+ - Categorize by actual severity (not everything is Critical)
98
+ - Be specific (file:line, not vague)
99
+ - Explain WHY issues matter
100
+ - Acknowledge strengths
101
+ - Give clear verdict
102
+
103
+ **DON'T:**
104
+ - Say "looks good" without checking
105
+ - Mark nitpicks as Critical
106
+ - Give feedback on code you didn't review
107
+ - Be vague ("improve error handling")
108
+ - Avoid giving a clear verdict
109
+
110
+ ## Example Output
111
+
112
+ ```
113
+ ### Strengths
114
+ - Clean database schema with proper migrations (db.ts:15-42)
115
+ - Comprehensive test coverage (18 tests, all edge cases)
116
+ - Good error handling with fallbacks (summarizer.ts:85-92)
117
+
118
+ ### Issues
119
+
120
+ #### Important
121
+ 1. **Missing help text in CLI wrapper**
122
+ - File: index-conversations:1-31
123
+ - Issue: No --help flag, users won't discover --concurrency
124
+ - Fix: Add --help case with usage examples
125
+
126
+ 2. **Date validation missing**
127
+ - File: search.ts:25-27
128
+ - Issue: Invalid dates silently return no results
129
+ - Fix: Validate ISO format, throw error with example
130
+
131
+ #### Minor
132
+ 1. **Progress indicators**
133
+ - File: indexer.ts:130
134
+ - Issue: No "X of Y" counter for long operations
135
+ - Impact: Users don't know how long to wait
136
+
137
+ ### Recommendations
138
+ - Add progress reporting for user experience
139
+ - Consider config file for excluded projects (portability)
140
+
141
+ ### Assessment
142
+
143
+ **Ready to merge: With fixes**
144
+
145
+ **Reasoning:** Core implementation is solid with good architecture and tests. Important issues (help text, date validation) are easily fixed and don't affect core functionality.
146
+ ```
@@ -0,0 +1,122 @@
1
+ ---
2
+ name: condition-based-waiting
3
+ description: Use when tests have race conditions, timing dependencies, or inconsistent pass/fail behavior - replaces arbitrary timeouts with condition polling to wait for actual state changes, eliminating flaky tests from timing guesses
4
+ usage: /condition-based-waiting <condition-type> <timeout-specs>
5
+ auto_trigger: false
6
+ ---
7
+
8
+ # Condition-Based Waiting
9
+
10
+ ## Overview
11
+
12
+ Flaky tests often guess at timing with arbitrary delays. This creates race conditions where tests pass on fast machines but fail under load or in CI.
13
+
14
+ **Core principle:** Wait for the actual condition you care about, not a guess about how long it takes.
15
+
16
+ ## When to Use
17
+
18
+ ```dot
19
+ digraph when_to_use {
20
+ "Test uses setTimeout/sleep?" [shape=diamond];
21
+ "Testing timing behavior?" [shape=diamond];
22
+ "Document WHY timeout needed" [shape=box];
23
+ "Use condition-based waiting" [shape=box];
24
+
25
+ "Test uses setTimeout/sleep?" -> "Testing timing behavior?" [label="yes"];
26
+ "Testing timing behavior?" -> "Document WHY timeout needed" [label="yes"];
27
+ "Testing timing behavior?" -> "Use condition-based waiting" [label="no"];
28
+ }
29
+ ```
30
+
31
+ **Use when:**
32
+ - Tests have arbitrary delays (`setTimeout`, `sleep`, `time.sleep()`)
33
+ - Tests are flaky (pass sometimes, fail under load)
34
+ - Tests timeout when run in parallel
35
+ - Waiting for async operations to complete
36
+
37
+ **Don't use when:**
38
+ - Testing actual timing behavior (debounce, throttle intervals)
39
+ - Always document WHY if using arbitrary timeout
40
+
41
+ ## Core Pattern
42
+
43
+ ```typescript
44
+ // ❌ BEFORE: Guessing at timing
45
+ await new Promise(r => setTimeout(r, 50));
46
+ const result = getResult();
47
+ expect(result).toBeDefined();
48
+
49
+ // ✅ AFTER: Waiting for condition
50
+ await waitFor(() => getResult() !== undefined);
51
+ const result = getResult();
52
+ expect(result).toBeDefined();
53
+ ```
54
+
55
+ ## Quick Patterns
56
+
57
+ | Scenario | Pattern |
58
+ |----------|---------|
59
+ | Wait for event | `waitFor(() => events.find(e => e.type === 'DONE'))` |
60
+ | Wait for state | `waitFor(() => machine.state === 'ready')` |
61
+ | Wait for count | `waitFor(() => items.length >= 5)` |
62
+ | Wait for file | `waitFor(() => fs.existsSync(path))` |
63
+ | Complex condition | `waitFor(() => obj.ready && obj.value > 10)` |
64
+
65
+ ## Implementation
66
+
67
+ Generic polling function:
68
+ ```typescript
69
+ async function waitFor<T>(
70
+ condition: () => T | undefined | null | false,
71
+ description: string,
72
+ timeoutMs = 5000
73
+ ): Promise<T> {
74
+ const startTime = Date.now();
75
+
76
+ while (true) {
77
+ const result = condition();
78
+ if (result) return result;
79
+
80
+ if (Date.now() - startTime > timeoutMs) {
81
+ throw new Error(`Timeout waiting for ${description} after ${timeoutMs}ms`);
82
+ }
83
+
84
+ await new Promise(r => setTimeout(r, 10)); // Poll every 10ms
85
+ }
86
+ }
87
+ ```
88
+
89
+ See @example.ts for complete implementation with domain-specific helpers (`waitForEvent`, `waitForEventCount`, `waitForEventMatch`) from actual debugging session.
90
+
91
+ ## Common Mistakes
92
+
93
+ **❌ Polling too fast:** `setTimeout(check, 1)` - wastes CPU
94
+ **✅ Fix:** Poll every 10ms
95
+
96
+ **❌ No timeout:** Loop forever if condition never met
97
+ **✅ Fix:** Always include timeout with clear error
98
+
99
+ **❌ Stale data:** Cache state before loop
100
+ **✅ Fix:** Call getter inside loop for fresh data
101
+
102
+ ## When Arbitrary Timeout IS Correct
103
+
104
+ ```typescript
105
+ // Tool ticks every 100ms - need 2 ticks to verify partial output
106
+ await waitForEvent(manager, 'TOOL_STARTED'); // First: wait for condition
107
+ await new Promise(r => setTimeout(r, 200)); // Then: wait for timed behavior
108
+ // 200ms = 2 ticks at 100ms intervals - documented and justified
109
+ ```
110
+
111
+ **Requirements:**
112
+ 1. First wait for triggering condition
113
+ 2. Based on known timing (not guessing)
114
+ 3. Comment explaining WHY
115
+
116
+ ## Real-World Impact
117
+
118
+ From debugging session (2025-10-03):
119
+ - Fixed 15 flaky tests across 3 files
120
+ - Pass rate: 60% → 100%
121
+ - Execution time: 40% faster
122
+ - No more race conditions
@@ -0,0 +1,158 @@
1
+ // Complete implementation of condition-based waiting utilities
2
+ // From: Lace test infrastructure improvements (2025-10-03)
3
+ // Context: Fixed 15 flaky tests by replacing arbitrary timeouts
4
+
5
+ import type { ThreadManager } from '~/threads/thread-manager';
6
+ import type { LaceEvent, LaceEventType } from '~/threads/types';
7
+
8
+ /**
9
+ * Wait for a specific event type to appear in thread
10
+ *
11
+ * @param threadManager - The thread manager to query
12
+ * @param threadId - Thread to check for events
13
+ * @param eventType - Type of event to wait for
14
+ * @param timeoutMs - Maximum time to wait (default 5000ms)
15
+ * @returns Promise resolving to the first matching event
16
+ *
17
+ * Example:
18
+ * await waitForEvent(threadManager, agentThreadId, 'TOOL_RESULT');
19
+ */
20
+ export function waitForEvent(
21
+ threadManager: ThreadManager,
22
+ threadId: string,
23
+ eventType: LaceEventType,
24
+ timeoutMs = 5000
25
+ ): Promise<LaceEvent> {
26
+ return new Promise((resolve, reject) => {
27
+ const startTime = Date.now();
28
+
29
+ const check = () => {
30
+ const events = threadManager.getEvents(threadId);
31
+ const event = events.find((e) => e.type === eventType);
32
+
33
+ if (event) {
34
+ resolve(event);
35
+ } else if (Date.now() - startTime > timeoutMs) {
36
+ reject(new Error(`Timeout waiting for ${eventType} event after ${timeoutMs}ms`));
37
+ } else {
38
+ setTimeout(check, 10); // Poll every 10ms for efficiency
39
+ }
40
+ };
41
+
42
+ check();
43
+ });
44
+ }
45
+
46
+ /**
47
+ * Wait for a specific number of events of a given type
48
+ *
49
+ * @param threadManager - The thread manager to query
50
+ * @param threadId - Thread to check for events
51
+ * @param eventType - Type of event to wait for
52
+ * @param count - Number of events to wait for
53
+ * @param timeoutMs - Maximum time to wait (default 5000ms)
54
+ * @returns Promise resolving to all matching events once count is reached
55
+ *
56
+ * Example:
57
+ * // Wait for 2 AGENT_MESSAGE events (initial response + continuation)
58
+ * await waitForEventCount(threadManager, agentThreadId, 'AGENT_MESSAGE', 2);
59
+ */
60
+ export function waitForEventCount(
61
+ threadManager: ThreadManager,
62
+ threadId: string,
63
+ eventType: LaceEventType,
64
+ count: number,
65
+ timeoutMs = 5000
66
+ ): Promise<LaceEvent[]> {
67
+ return new Promise((resolve, reject) => {
68
+ const startTime = Date.now();
69
+
70
+ const check = () => {
71
+ const events = threadManager.getEvents(threadId);
72
+ const matchingEvents = events.filter((e) => e.type === eventType);
73
+
74
+ if (matchingEvents.length >= count) {
75
+ resolve(matchingEvents);
76
+ } else if (Date.now() - startTime > timeoutMs) {
77
+ reject(
78
+ new Error(
79
+ `Timeout waiting for ${count} ${eventType} events after ${timeoutMs}ms (got ${matchingEvents.length})`
80
+ )
81
+ );
82
+ } else {
83
+ setTimeout(check, 10);
84
+ }
85
+ };
86
+
87
+ check();
88
+ });
89
+ }
90
+
91
+ /**
92
+ * Wait for an event matching a custom predicate
93
+ * Useful when you need to check event data, not just type
94
+ *
95
+ * @param threadManager - The thread manager to query
96
+ * @param threadId - Thread to check for events
97
+ * @param predicate - Function that returns true when event matches
98
+ * @param description - Human-readable description for error messages
99
+ * @param timeoutMs - Maximum time to wait (default 5000ms)
100
+ * @returns Promise resolving to the first matching event
101
+ *
102
+ * Example:
103
+ * // Wait for TOOL_RESULT with specific ID
104
+ * await waitForEventMatch(
105
+ * threadManager,
106
+ * agentThreadId,
107
+ * (e) => e.type === 'TOOL_RESULT' && e.data.id === 'call_123',
108
+ * 'TOOL_RESULT with id=call_123'
109
+ * );
110
+ */
111
+ export function waitForEventMatch(
112
+ threadManager: ThreadManager,
113
+ threadId: string,
114
+ predicate: (event: LaceEvent) => boolean,
115
+ description: string,
116
+ timeoutMs = 5000
117
+ ): Promise<LaceEvent> {
118
+ return new Promise((resolve, reject) => {
119
+ const startTime = Date.now();
120
+
121
+ const check = () => {
122
+ const events = threadManager.getEvents(threadId);
123
+ const event = events.find(predicate);
124
+
125
+ if (event) {
126
+ resolve(event);
127
+ } else if (Date.now() - startTime > timeoutMs) {
128
+ reject(new Error(`Timeout waiting for ${description} after ${timeoutMs}ms`));
129
+ } else {
130
+ setTimeout(check, 10);
131
+ }
132
+ };
133
+
134
+ check();
135
+ });
136
+ }
137
+
138
+ // Usage example from actual debugging session:
139
+ //
140
+ // BEFORE (flaky):
141
+ // ---------------
142
+ // const messagePromise = agent.sendMessage('Execute tools');
143
+ // await new Promise(r => setTimeout(r, 300)); // Hope tools start in 300ms
144
+ // agent.abort();
145
+ // await messagePromise;
146
+ // await new Promise(r => setTimeout(r, 50)); // Hope results arrive in 50ms
147
+ // expect(toolResults.length).toBe(2); // Fails randomly
148
+ //
149
+ // AFTER (reliable):
150
+ // ----------------
151
+ // const messagePromise = agent.sendMessage('Execute tools');
152
+ // await waitForEventCount(threadManager, threadId, 'TOOL_CALL', 2); // Wait for tools to start
153
+ // agent.abort();
154
+ // await messagePromise;
155
+ // await waitForEventCount(threadManager, threadId, 'TOOL_RESULT', 2); // Wait for results
156
+ // expect(toolResults.length).toBe(2); // Always succeeds
157
+ //
158
+ // Result: 60% pass rate → 100%, 40% faster execution