@kraftapps-ai/kai 1.8.1 → 1.8.4

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 (2) hide show
  1. package/kai +21 -6
  2. package/package.json +1 -1
package/kai CHANGED
@@ -50,8 +50,7 @@ if [ "$KAI_TMUX" = true ]; then
50
50
  # New session: pane 0 = PM, pane 1 = dev loop (waiting)
51
51
  tmux new-session -d -s "$KAI_TMUX_SESSION" \
52
52
  "kai --no-tmux $(printf '%q ' "$@")"
53
- tmux split-window -h -t "${KAI_TMUX_SESSION}:0"
54
- tmux select-pane -t "${KAI_TMUX_SESSION}:0.0"
53
+ tmux split-window -h -d -t "${KAI_TMUX_SESSION}:0"
55
54
  exec tmux attach-session -t "$KAI_TMUX_SESSION"
56
55
  fi
57
56
  fi
@@ -228,6 +227,9 @@ PRD_FILE=".kai/stories.json"
228
227
  PROGRESS_FILE=".kai/progress.txt"
229
228
  LOOP_MCP_ARGS="--mcp-config .kai/loop-mcp.json"
230
229
 
230
+ # Cap Node.js memory to prevent test runners from consuming all RAM
231
+ export NODE_OPTIONS="--max-old-space-size=2048"
232
+
231
233
  # Stream output live when running in a tmux pane
232
234
  KAI_STREAM=false
233
235
  if [ -n "${TMUX:-}" ]; then
@@ -266,11 +268,15 @@ You are an expert Shopify developer. You have access to the Shopify Dev MCP tool
266
268
  2. Read .kai/progress.txt for context on previous work.
267
269
  3. **PLAN before coding.** List files and changes before touching code.
268
270
  4. If the story involves Shopify APIs, call `learn_shopify_api` then use `introspect_graphql_schema` and `search_docs_chunks` to understand the right approach.
269
- 5. **WRITE FAILING TESTS FIRST.** For each acceptance criterion, write a test that verifies it. Run the tests — they MUST fail (red). If a test already passes, your test is not testing the right thing.
270
- 6. **Implement ONLY enough code to make the tests pass (green).** No more, no less.
271
+ 5. **WRITE FAILING TESTS FIRST.** For each acceptance criterion, write a test that verifies it. Run ONLY the relevant test file(s) — they MUST fail (red). If a test already passes, your test is not testing the right thing.
272
+ 6. **Implement ONLY enough code to make the tests pass (green).** No more, no less. Run only the relevant test file(s) to verify.
271
273
  7. **Refactor** if needed — clean up while keeping tests green.
272
- 8. Validate: run full test suite, validate GraphQL with `validate_graphql_codeblocks`, validate Liquid with `validate_theme_codeblocks`.
274
+ 8. **Final validation ONCE:** Run the full test suite ONE TIME at the end. Also validate GraphQL with `validate_graphql_codeblocks`, validate Liquid with `validate_theme_codeblocks`.
273
275
  9. **SELF-REVIEW.** For each acceptance criterion, cite the test that covers it AND evidence it passes (file, line, command output). No "should work" or "probably".
276
+
277
+ ## IMPORTANT: Resource management
278
+ - **NEVER run the full test suite repeatedly.** Run targeted tests during development (e.g., `npx vitest run path/to/test.ts`). Only run the full suite ONCE as a final check before committing.
279
+ - **Always use `npx vitest run`** (not `npx vitest` without `run`) — watch mode will hang forever.
274
280
  10. Commit with a descriptive message.
275
281
  11. Update .kai/stories.json: set `passes` to `true`.
276
282
  12. Append to .kai/progress.txt.
@@ -279,7 +285,7 @@ You are an expert Shopify developer. You have access to the Shopify Dev MCP tool
279
285
  - ONE STORY PER LOOP.
280
286
  - **TDD is mandatory.** Tests first, then implementation. No exceptions.
281
287
  - No placeholders. Fully implement or report BLOCKED.
282
- - Do not break existing functionality. Run the FULL test suite, not just your new tests.
288
+ - Do not break existing functionality. Run the full test suite ONCE at the end as a final check.
283
289
  - ALWAYS validate GraphQL and Liquid code using the MCP tools before marking complete.
284
290
  - If ALL stories have `passes: true`, output: <promise>COMPLETE</promise>
285
291
 
@@ -305,6 +311,14 @@ fi
305
311
  iteration=0
306
312
  review_failures=0
307
313
 
314
+ # Kill orphaned child processes (vitest, esbuild, etc.) between iterations
315
+ cleanup_orphans() {
316
+ for proc in vitest esbuild playwright; do
317
+ pkill -f "$proc" 2>/dev/null || true
318
+ done
319
+ }
320
+ trap cleanup_orphans EXIT
321
+
308
322
  while :; do
309
323
  iteration=$((iteration + 1))
310
324
  REMAINING=$(jq '[.userStories[] | select(.passes == false)] | length' "$PRD_FILE")
@@ -397,6 +411,7 @@ If all pass: REVIEW_PASS"
397
411
  fi
398
412
 
399
413
  echo "Done in $((elapsed / 60))m $((elapsed % 60))s"
414
+ cleanup_orphans
400
415
  echo ""
401
416
  done
402
417
  LOOPEOF
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kraftapps-ai/kai",
3
- "version": "1.8.1",
3
+ "version": "1.8.4",
4
4
  "description": "Autonomous AI developer loop for Claude Code",
5
5
  "bin": {
6
6
  "kai": "kai"