@kraftapps-ai/kai 1.3.3 → 1.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 (3) hide show
  1. package/CLAUDE.md +12 -2
  2. package/kai +105 -13
  3. package/package.json +1 -1
package/CLAUDE.md CHANGED
@@ -7,16 +7,26 @@ Autonomous AI Shopify expert, product manager, and developer loop for Claude Cod
7
7
  - `kai` — the entire tool; a single bash script that bootstraps the PM agent and dev loop
8
8
  - `package.json` — npm metadata and version
9
9
  - `.kai/PROMPT.md` — per-project context (generated at runtime, not in repo)
10
+ - `.kai/memory.md` — persistent memory across sessions (generated at runtime, not in repo)
10
11
  - `.kai/loop.sh` — dev loop script (generated at runtime, not in repo)
11
12
 
12
13
  ## How it works
13
14
 
14
- 1. `kai` script auto-inits project files (`kai.json`, `kai-progress.txt`, `.kai/PROMPT.md`)
15
+ 1. `kai` script auto-inits project files (`kai.json`, `kai-progress.txt`, `.kai/PROMPT.md`, `.kai/memory.md`)
15
16
  2. Auto-installs MCP servers if not already configured:
16
17
  - **Playwright** — browser testing inside Shopify Admin
17
18
  - **@shopify/dev-mcp** — Shopify docs, GraphQL schema introspection, Liquid/GraphQL/component validation
18
19
  3. Generates `.kai/loop.sh` (the autonomous dev loop)
19
- 4. Launches Claude as a Shopify-expert PM agent
20
+ 4. Launches Claude with `--continue` to resume the last conversation (per-repo)
21
+ 5. Falls back to `.kai/memory.md` for context if conversation history is unavailable
22
+
23
+ ## Session persistence
24
+
25
+ Kai uses a two-layer persistence strategy:
26
+ - **`claude --continue`** — resumes the exact last conversation in this directory (primary)
27
+ - **`.kai/memory.md`** — Kai-maintained memory file with key decisions, current focus, and session log (fallback)
28
+
29
+ Use `kai --new` to force a fresh conversation (memory.md is still loaded for context).
20
30
 
21
31
  The PM creates user stories in `kai.json`, then kicks off `.kai/loop.sh` which runs Claude in a loop — one story per iteration with self-review. Both the PM and the dev loop worker use Shopify Dev MCP tools to introspect APIs, search docs, and validate code.
22
32
 
package/kai CHANGED
@@ -6,9 +6,27 @@
6
6
 
7
7
  set -e
8
8
 
9
+ # ── Version ───────────────────────────────────────────
10
+
11
+ KAI_VERSION=$(node -p "require('$(dirname "$(readlink -f "$(which kai)" 2>/dev/null || echo "$0")")/package.json').version" 2>/dev/null || echo "unknown")
12
+
13
+ if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-v" ]; then
14
+ echo "kai v${KAI_VERSION}"
15
+ exit 0
16
+ fi
17
+
18
+ # ── Handle --new flag ─────────────────────────────────
19
+
20
+ USE_CONTINUE=true
21
+ if [ "${1:-}" = "--new" ]; then
22
+ USE_CONTINUE=false
23
+ shift
24
+ fi
25
+
9
26
  PRD_FILE="kai.json"
10
27
  PROGRESS_FILE="kai-progress.txt"
11
28
  PROMPT_FILE=".kai/PROMPT.md"
29
+ MEMORY_FILE=".kai/memory.md"
12
30
  LOOP_SCRIPT=".kai/loop.sh"
13
31
 
14
32
  # ── Auto-init if needed ───────────────────────────────
@@ -31,10 +49,10 @@ EOF
31
49
  Add your project-specific context here. The more you provide, the better Kai performs.
32
50
 
33
51
  ## Shopify Store
34
- <!-- Required for browser testing and Storefront MCP -->
52
+ <!-- Kai auto-detects store info from shopify.app.toml and .env -->
53
+ <!-- Only fill this in if auto-detection doesn't work for your setup -->
35
54
  <!-- Store domain: your-store.myshopify.com -->
36
- <!-- App handle: your-app-handle (from the app URL in Shopify Admin) -->
37
- <!-- App URL: https://admin.shopify.com/store/YOUR_STORE/apps/YOUR_APP -->
55
+ <!-- App handle: your-app-handle -->
38
56
 
39
57
  ## Tech stack
40
58
  <!-- e.g., Remix + TypeScript, Next.js, Ruby on Rails -->
@@ -56,6 +74,29 @@ Add your project-specific context here. The more you provide, the better Kai per
56
74
  EOF
57
75
  fi
58
76
 
77
+ # Init memory file if it doesn't exist
78
+ if [ ! -f "$MEMORY_FILE" ]; then
79
+ mkdir -p .kai
80
+ cat > "$MEMORY_FILE" << 'EOF'
81
+ # Kai Memory
82
+
83
+ This file is automatically maintained by Kai to preserve context between sessions.
84
+ Do not edit manually unless you want to correct or add context for Kai.
85
+
86
+ ## Current Focus
87
+ <!-- What we're currently working on -->
88
+
89
+ ## Key Decisions
90
+ <!-- Important decisions made during our conversations -->
91
+
92
+ ## Open Questions / Blockers
93
+ <!-- Things that need to be resolved -->
94
+
95
+ ## Session Log
96
+ <!-- Brief log of what happened in each session -->
97
+ EOF
98
+ fi
99
+
59
100
  # ── Ensure MCP servers are available ─────────────────
60
101
 
61
102
  # Track what's already configured
@@ -309,9 +350,49 @@ progress=""
309
350
  Recent progress (kai-progress.txt):
310
351
  $(tail -30 "$PROGRESS_FILE")"
311
352
 
353
+ memory=""
354
+ [ -f "$MEMORY_FILE" ] && memory="
355
+
356
+ ## Kai Memory (from previous sessions)
357
+ Read \`.kai/memory.md\` for full details. Summary:
358
+ $(cat "$MEMORY_FILE")"
359
+
360
+ # ── Build Claude args ─────────────────────────────────
361
+
362
+ CLAUDE_ARGS="--dangerously-skip-permissions"
363
+ if [ "$USE_CONTINUE" = true ]; then
364
+ CLAUDE_ARGS="$CLAUDE_ARGS --continue"
365
+ fi
366
+
312
367
  # ── Launch the PM ─────────────────────────────────────
313
368
 
314
- exec claude --dangerously-skip-permissions --system-prompt "You are Kai — an AI product manager, tech lead, and **Shopify expert**. You work directly with the developer to plan and ship Shopify apps, themes, and integrations.
369
+ exec claude $CLAUDE_ARGS --system-prompt "You are Kai — an AI product manager, tech lead, and **Shopify expert**. You work directly with the developer to plan and ship Shopify apps, themes, and integrations.
370
+
371
+ ## Session persistence
372
+
373
+ You maintain a memory file at \`.kai/memory.md\` that preserves context between sessions. This is critical — it's how you remember what happened in previous conversations.
374
+
375
+ ### Reading memory
376
+ - On startup, ALWAYS read \`.kai/memory.md\` to restore context from previous sessions
377
+ - Use this to greet the developer with awareness of where you left off
378
+ - If memory exists, reference it naturally: \"Welcome back — last time we were working on X\"
379
+
380
+ ### Writing memory
381
+ You MUST update \`.kai/memory.md\` in these situations:
382
+ - **After creating or modifying stories** — record what was planned and why
383
+ - **After the dev loop completes** — record what was built and any issues
384
+ - **When the developer makes a key decision** — record the decision and reasoning
385
+ - **When there are open questions or blockers** — record them so you remember next time
386
+ - **Before the developer leaves** — if they say \"bye\", \"done for today\", \"gotta go\", etc., immediately update memory with a session summary
387
+
388
+ ### Memory format
389
+ Keep \`.kai/memory.md\` organized with these sections:
390
+ - **Current Focus** — what we're actively working on
391
+ - **Key Decisions** — important choices and their reasoning
392
+ - **Open Questions / Blockers** — unresolved issues
393
+ - **Session Log** — brief dated entries of what happened (newest first, keep last 10)
394
+
395
+ Keep entries concise. Memory is context, not a novel.
315
396
 
316
397
  ## Your Shopify expertise
317
398
 
@@ -387,15 +468,26 @@ When the developer asks you to test or QA the app, proactively navigate to every
387
468
 
388
469
  ### Navigating to the Shopify app
389
470
 
390
- **NEVER guess the app URL.** Before navigating, read \`.kai/PROMPT.md\` for the store domain and app handle.
471
+ **NEVER guess the app URL. Auto-detect it from the repo.**
472
+
473
+ Shopify apps are **embedded inside Shopify Admin**. Pages are NOT directly accessible at localhost. Before navigating, you MUST read the repo config files to build the correct URL:
391
474
 
392
- Shopify apps are **embedded inside Shopify Admin**. Pages are NOT directly accessible at localhost. You must:
393
- 1. Build the full Admin URL: \`https://admin.shopify.com/store/STORE_NAME/apps/APP_HANDLE/PAGE\`
394
- 2. Use the **store domain and app handle** from \`.kai/PROMPT.md\`
395
- 3. When the developer says \"check /designs\", translate that to \`https://admin.shopify.com/store/STORE/apps/APP/designs\`
396
- 4. For theme previews, use the store's preview URL, not localhost
475
+ 1. **Read \`shopify.app.toml\`** (or \`shopify.app.*.toml\`) to get:
476
+ - \`handle\` the app's URL slug (used in \`/apps/{handle}\`)
477
+ - \`[build] dev_store_url\` — the dev store domain (e.g., \`my-store.myshopify.com\`)
478
+ - \`application_url\` the app's hosted URL
479
+ - \`name\`, \`client_id\` app identity
480
+ 2. **If not in TOML, check \`.env\`** for:
481
+ - \`SHOP\` — store domain
482
+ - \`SHOPIFY_API_KEY\` — app API key
483
+ - \`HOST\` — app host URL
484
+ 3. **Build the Admin URL**: \`https://admin.shopify.com/store/{STORE_NAME}/apps/{HANDLE}/{PAGE}\`
485
+ - Extract STORE_NAME from \`dev_store_url\` (strip \`.myshopify.com\`)
486
+ - Use \`handle\` from the TOML
487
+ 4. When the developer says \"check /designs\", translate that to \`https://admin.shopify.com/store/STORE/apps/APP/designs\`
488
+ 5. For theme previews, use the store's preview URL, not localhost
397
489
 
398
- If no store info is configured in \`.kai/PROMPT.md\`, ask the developer for it before navigating.
490
+ **Do NOT ask the developer for store info if it can be found in these files. Only ask as a last resort if none of the config files exist.**
399
491
 
400
492
  ## Rules for good stories
401
493
  - Each story: independently committable, 5-15 min of work
@@ -412,5 +504,5 @@ If no store info is configured in \`.kai/PROMPT.md\`, ask the developer for it b
412
504
  - When the developer says \"ship it\" or \"go\" or \"do it\", start the loop
413
505
  - Don't ask unnecessary questions — use good defaults
414
506
  - When unsure about an API, introspect the schema instead of guessing
415
- - On startup, greet the developer briefly. If there are existing stories, give a quick status. If not, ask what they want to build. Keep it to 2-3 lines max.
416
- ${status}${project_context}${progress}" "${@:-Hey Kai}"
507
+ - On startup: read \`.kai/memory.md\` first. If it has context, greet with awareness of previous work. If fresh, greet briefly and ask what to build. Keep it to 2-3 lines max.
508
+ ${status}${project_context}${progress}${memory}" "${@:-Hey Kai}"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kraftapps-ai/kai",
3
- "version": "1.3.3",
3
+ "version": "1.4.0",
4
4
  "description": "Autonomous AI developer loop for Claude Code",
5
5
  "bin": {
6
6
  "kai": "kai"