@kraftapps-ai/kai 1.4.1 → 1.5.1
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.
- package/kai +42 -23
- package/package.json +1 -1
package/kai
CHANGED
|
@@ -15,22 +15,34 @@ if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-v" ]; then
|
|
|
15
15
|
exit 0
|
|
16
16
|
fi
|
|
17
17
|
|
|
18
|
+
PRD_FILE=".kai/stories.json"
|
|
19
|
+
PROGRESS_FILE=".kai/progress.txt"
|
|
20
|
+
PROMPT_FILE=".kai/PROMPT.md"
|
|
21
|
+
MEMORY_FILE=".kai/memory.md"
|
|
22
|
+
SESSION_FILE=".kai/session_id"
|
|
23
|
+
LOOP_SCRIPT=".kai/loop.sh"
|
|
24
|
+
|
|
18
25
|
# ── Handle --new flag ─────────────────────────────────
|
|
19
26
|
|
|
20
|
-
USE_CONTINUE=true
|
|
21
27
|
if [ "${1:-}" = "--new" ]; then
|
|
22
|
-
|
|
28
|
+
rm -f "$SESSION_FILE"
|
|
23
29
|
shift
|
|
24
30
|
fi
|
|
25
31
|
|
|
26
|
-
PRD_FILE="kai.json"
|
|
27
|
-
PROGRESS_FILE="kai-progress.txt"
|
|
28
|
-
PROMPT_FILE=".kai/PROMPT.md"
|
|
29
|
-
MEMORY_FILE=".kai/memory.md"
|
|
30
|
-
LOOP_SCRIPT=".kai/loop.sh"
|
|
31
|
-
|
|
32
32
|
# ── Auto-init if needed ───────────────────────────────
|
|
33
33
|
|
|
34
|
+
# Migrate old file locations (pre-1.5.0)
|
|
35
|
+
if [ -f "kai.json" ] && [ ! -f "$PRD_FILE" ]; then
|
|
36
|
+
mkdir -p .kai
|
|
37
|
+
mv kai.json "$PRD_FILE"
|
|
38
|
+
echo " Migrated kai.json → $PRD_FILE"
|
|
39
|
+
fi
|
|
40
|
+
if [ -f "kai-progress.txt" ] && [ ! -f "$PROGRESS_FILE" ]; then
|
|
41
|
+
mkdir -p .kai
|
|
42
|
+
mv kai-progress.txt "$PROGRESS_FILE"
|
|
43
|
+
echo " Migrated kai-progress.txt → $PROGRESS_FILE"
|
|
44
|
+
fi
|
|
45
|
+
|
|
34
46
|
if [ ! -f "$PRD_FILE" ]; then
|
|
35
47
|
mkdir -p .kai
|
|
36
48
|
|
|
@@ -176,8 +188,8 @@ cat > "$LOOP_SCRIPT" << 'LOOPEOF'
|
|
|
176
188
|
# Kai implementation loop — called by the PM when stories are ready
|
|
177
189
|
set -e
|
|
178
190
|
|
|
179
|
-
PRD_FILE="kai.json"
|
|
180
|
-
PROGRESS_FILE="kai
|
|
191
|
+
PRD_FILE=".kai/stories.json"
|
|
192
|
+
PROGRESS_FILE=".kai/progress.txt"
|
|
181
193
|
PROMPT_FILE=".kai/PROMPT.md"
|
|
182
194
|
|
|
183
195
|
WORKER_PROMPT='You are an autonomous AI developer specializing in Shopify app and theme development.
|
|
@@ -203,21 +215,21 @@ You are an expert Shopify developer. You have access to the Shopify Dev MCP tool
|
|
|
203
215
|
6. NEVER guess at API fields, mutation inputs, or Liquid filters — always introspect or search first
|
|
204
216
|
|
|
205
217
|
## Your inputs
|
|
206
|
-
-
|
|
207
|
-
-
|
|
218
|
+
- `@.kai/stories.json` — user stories with `passes: true/false`.
|
|
219
|
+
- `@.kai/progress.txt` — log of what has been done.
|
|
208
220
|
|
|
209
221
|
## Your task (ONE story per loop)
|
|
210
222
|
|
|
211
|
-
1. Read kai.json, find the highest-priority story where `passes: false`.
|
|
212
|
-
2. Read kai
|
|
223
|
+
1. Read .kai/stories.json, find the highest-priority story where `passes: false`.
|
|
224
|
+
2. Read .kai/progress.txt for context on previous work.
|
|
213
225
|
3. **PLAN before coding.** List files and changes before touching code.
|
|
214
226
|
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.
|
|
215
227
|
5. Implement ONLY that one story.
|
|
216
228
|
6. Validate: run build/tests, validate GraphQL with `validate_graphql_codeblocks`, validate Liquid with `validate_theme_codeblocks`.
|
|
217
229
|
7. **SELF-REVIEW.** For each acceptance criterion, cite evidence (file, line, command output). No "should work" or "probably".
|
|
218
230
|
8. Commit with a descriptive message.
|
|
219
|
-
9. Update kai.json: set `passes` to `true`.
|
|
220
|
-
10. Append to kai
|
|
231
|
+
9. Update .kai/stories.json: set `passes` to `true`.
|
|
232
|
+
10. Append to .kai/progress.txt.
|
|
221
233
|
|
|
222
234
|
## Rules
|
|
223
235
|
- ONE STORY PER LOOP.
|
|
@@ -347,7 +359,7 @@ $(cat "$PROMPT_FILE")"
|
|
|
347
359
|
progress=""
|
|
348
360
|
[ -f "$PROGRESS_FILE" ] && [ "$(wc -l < "$PROGRESS_FILE")" -gt 2 ] && progress="
|
|
349
361
|
|
|
350
|
-
Recent progress (kai
|
|
362
|
+
Recent progress (.kai/progress.txt):
|
|
351
363
|
$(tail -30 "$PROGRESS_FILE")"
|
|
352
364
|
|
|
353
365
|
memory=""
|
|
@@ -364,9 +376,16 @@ The developer's name is: ${dev_name}"
|
|
|
364
376
|
# ── Build Claude args ─────────────────────────────────
|
|
365
377
|
|
|
366
378
|
CLAUDE_ARGS="--dangerously-skip-permissions"
|
|
367
|
-
|
|
368
|
-
|
|
379
|
+
|
|
380
|
+
# Session persistence: reuse the same session ID per repo
|
|
381
|
+
if [ -f "$SESSION_FILE" ]; then
|
|
382
|
+
KAI_SESSION=$(cat "$SESSION_FILE")
|
|
383
|
+
else
|
|
384
|
+
KAI_SESSION=$(uuidgen 2>/dev/null || python3 -c "import uuid; print(uuid.uuid4())" 2>/dev/null || cat /proc/sys/kernel/random/uuid 2>/dev/null)
|
|
385
|
+
mkdir -p .kai
|
|
386
|
+
echo "$KAI_SESSION" > "$SESSION_FILE"
|
|
369
387
|
fi
|
|
388
|
+
CLAUDE_ARGS="$CLAUDE_ARGS --session-id $KAI_SESSION --name kai"
|
|
370
389
|
|
|
371
390
|
# ── Launch the PM ─────────────────────────────────────
|
|
372
391
|
|
|
@@ -441,17 +460,17 @@ If the developer's store domain is in \`.kai/PROMPT.md\`, you can point them to
|
|
|
441
460
|
## What you can do
|
|
442
461
|
|
|
443
462
|
1. **Brainstorm** — Help the developer think through ideas, make decisions, define scope. Use Shopify docs and schema introspection to ground your recommendations in what's actually possible.
|
|
444
|
-
2. **Create stories** — Break work into small stories (5-15 min each) and write them to kai.json. For Shopify API work, introspect the schema first to write accurate acceptance criteria.
|
|
463
|
+
2. **Create stories** — Break work into small stories (5-15 min each) and write them to .kai/stories.json. For Shopify API work, introspect the schema first to write accurate acceptance criteria.
|
|
445
464
|
3. **Run the dev loop** — Execute \`.kai/loop.sh\` to have an AI developer implement all stories autonomously
|
|
446
|
-
4. **Check progress** — Read kai.json and kai
|
|
465
|
+
4. **Check progress** — Read .kai/stories.json and .kai/progress.txt to report status
|
|
447
466
|
5. **Adjust the plan** — Edit stories, reprioritize, add new ones, reset failed ones
|
|
448
467
|
6. **Test in browser** — Use Playwright to navigate the Shopify Admin, test the embedded app, verify UI
|
|
449
468
|
7. **Research APIs** — Introspect GraphQL schemas and search docs to answer technical questions on the spot
|
|
450
469
|
|
|
451
470
|
## How stories work
|
|
452
471
|
|
|
453
|
-
Stories live in kai.json. Each has: id, title, description, acceptanceCriteria, priority, passes (true/false).
|
|
454
|
-
To add stories, edit kai.json directly using the Edit or Write tool.
|
|
472
|
+
Stories live in .kai/stories.json. Each has: id, title, description, acceptanceCriteria, priority, passes (true/false).
|
|
473
|
+
To add stories, edit .kai/stories.json directly using the Edit or Write tool.
|
|
455
474
|
To run implementation, execute: \`nohup .kai/loop.sh > .kai/loop.log 2>&1 &\` then monitor with \`tail -f .kai/loop.log\`
|
|
456
475
|
|
|
457
476
|
## Browser testing (Playwright)
|