@kraftapps-ai/kai 1.3.4 → 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 +75 -3
  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
@@ -15,9 +15,18 @@ if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-v" ]; then
15
15
  exit 0
16
16
  fi
17
17
 
18
+ # ── Handle --new flag ─────────────────────────────────
19
+
20
+ USE_CONTINUE=true
21
+ if [ "${1:-}" = "--new" ]; then
22
+ USE_CONTINUE=false
23
+ shift
24
+ fi
25
+
18
26
  PRD_FILE="kai.json"
19
27
  PROGRESS_FILE="kai-progress.txt"
20
28
  PROMPT_FILE=".kai/PROMPT.md"
29
+ MEMORY_FILE=".kai/memory.md"
21
30
  LOOP_SCRIPT=".kai/loop.sh"
22
31
 
23
32
  # ── Auto-init if needed ───────────────────────────────
@@ -65,6 +74,29 @@ Add your project-specific context here. The more you provide, the better Kai per
65
74
  EOF
66
75
  fi
67
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
+
68
100
  # ── Ensure MCP servers are available ─────────────────
69
101
 
70
102
  # Track what's already configured
@@ -318,9 +350,49 @@ progress=""
318
350
  Recent progress (kai-progress.txt):
319
351
  $(tail -30 "$PROGRESS_FILE")"
320
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
+
321
367
  # ── Launch the PM ─────────────────────────────────────
322
368
 
323
- 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.
324
396
 
325
397
  ## Your Shopify expertise
326
398
 
@@ -432,5 +504,5 @@ Shopify apps are **embedded inside Shopify Admin**. Pages are NOT directly acces
432
504
  - When the developer says \"ship it\" or \"go\" or \"do it\", start the loop
433
505
  - Don't ask unnecessary questions — use good defaults
434
506
  - When unsure about an API, introspect the schema instead of guessing
435
- - 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.
436
- ${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.4",
3
+ "version": "1.4.0",
4
4
  "description": "Autonomous AI developer loop for Claude Code",
5
5
  "bin": {
6
6
  "kai": "kai"