@c0x12c/spartan-ai-toolkit 1.9.2 → 1.10.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.
@@ -10,7 +10,7 @@
10
10
  "name": "spartan-ai-toolkit",
11
11
  "description": "5 workflows, 68 commands, 21 rules, 28 skills, 9 agents — organized in 12 packs with dependencies",
12
12
  "source": "./toolkit",
13
- "version": "1.9.2"
13
+ "version": "1.10.0"
14
14
  }
15
15
  ]
16
16
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spartan-ai-toolkit",
3
- "version": "1.9.2",
3
+ "version": "1.10.0",
4
4
  "description": "Engineering discipline layer for Claude Code — 5 workflows, 68 commands, 21 rules, 28 skills, 9 agents organized in 12 packs",
5
5
  "author": {
6
6
  "name": "Khoa Tran",
package/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.2
1
+ 1.10.0
@@ -52,7 +52,25 @@ PARALLEL (multiple terminals — automatic):
52
52
 
53
53
  ---
54
54
 
55
- ## FIRST: Load Build Config (silent — no questions)
55
+ ## Preamble (run first)
56
+
57
+ ```bash
58
+ mkdir -p ~/.spartan/sessions
59
+ touch ~/.spartan/sessions/"$PPID"
60
+ _SESSIONS=$(find ~/.spartan/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ')
61
+ find ~/.spartan/sessions -mmin +120 -type f -delete 2>/dev/null || true
62
+ _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
63
+ _PROJECT=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || basename "$(pwd)")
64
+ echo "SESSIONS: $_SESSIONS"
65
+ echo "BRANCH: $_BRANCH"
66
+ echo "PROJECT: $_PROJECT"
67
+ ```
68
+
69
+ **Read the output.** If `SESSIONS` >= 3, start EVERY response with: **[PROJECT / BRANCH]** Currently working on: [task]
70
+
71
+ ---
72
+
73
+ ## Load Build Config (silent — no questions)
56
74
 
57
75
  Check for a project-level build config that overrides default behavior:
58
76
 
@@ -307,46 +325,40 @@ Uses skills: `ui-ux-pro-max`, frontend rules
307
325
 
308
326
  **CRITICAL: Full-stack means BOTH layers must complete.** Don't move to Gate 3 after finishing backend only. The plan must include frontend tasks and ALL tasks must be done before review. If the spec mentions UI changes, API responses shown to users, or any user-facing behavior — frontend tasks are mandatory.
309
327
 
310
- ### Create feature workspace
328
+ ### Create feature workspace (MANDATORY — do not skip)
329
+
330
+ **MANDATORY:** Every build runs in a git worktree. Do NOT use `git checkout -b`. Do NOT work in the main repo directory. Create the worktree first, then do all work inside it. Skipping this breaks parallel builds.
311
331
 
312
- Each build runs in its own **git worktree** a separate directory with its own branch. This happens automatically. The user doesn't set anything up. Multiple terminals running `/spartan:build` get separate worktrees, branches, and PRs.
332
+ First, generate a slug from the feature description. Convert to lowercase, replace spaces with dashes, strip special characters (e.g., "user auth flow" `user-auth-flow`).
313
333
 
314
- Use `branch-prefix` from config (default: `feature`). Generate a slug from the feature name.
334
+ Then run this immediately substitute the actual slug you generated:
315
335
 
316
336
  ```bash
317
- SLUG="[slug]"
337
+ SLUG="the-slug-you-generated"
318
338
  BRANCH="feature/$SLUG"
319
339
  MAIN_REPO="$(git rev-parse --show-toplevel)"
320
340
  WORKSPACE="$MAIN_REPO/.worktrees/$SLUG"
321
-
322
- # Create worktree (or reuse if resuming)
323
- if [ -d "$WORKSPACE" ]; then
324
- echo "RESUMING: Worktree exists at $WORKSPACE"
325
- else
326
- git worktree add "$WORKSPACE" -b "$BRANCH" 2>/dev/null || git worktree add "$WORKSPACE" "$BRANCH"
327
- fi
328
-
329
- # Symlink shared dirs (gitignored, won't appear in worktree)
330
- for dir in .planning .memory .handoff .spartan; do
331
- [ -d "$MAIN_REPO/$dir" ] && [ ! -e "$WORKSPACE/$dir" ] && ln -s "$MAIN_REPO/$dir" "$WORKSPACE/$dir"
332
- done
333
-
334
- # Copy .env if exists (API keys, secrets)
341
+ if [ -d "$WORKSPACE" ]; then echo "RESUMING: $WORKSPACE"; else git worktree add "$WORKSPACE" -b "$BRANCH" 2>/dev/null || git worktree add "$WORKSPACE" "$BRANCH"; fi
342
+ for dir in .planning .memory .handoff .spartan; do [ -d "$MAIN_REPO/$dir" ] && [ ! -e "$WORKSPACE/$dir" ] && ln -s "$MAIN_REPO/$dir" "$WORKSPACE/$dir"; done
335
343
  [ -f "$MAIN_REPO/.env" ] && [ ! -f "$WORKSPACE/.env" ] && cp "$MAIN_REPO/.env" "$WORKSPACE/.env"
336
-
337
- # Gitignore worktrees dir
338
344
  grep -qxF '.worktrees/' "$MAIN_REPO/.gitignore" 2>/dev/null || echo '.worktrees/' >> "$MAIN_REPO/.gitignore"
339
-
340
345
  echo "WORKSPACE=$WORKSPACE"
341
346
  echo "BRANCH=$BRANCH"
342
347
  ```
343
348
 
344
- **From this point, ALL work happens in `$WORKSPACE`:**
345
- - Bash commands: `cd $WORKSPACE && ./gradlew test`
346
- - File reads/writes: use `$WORKSPACE/src/...` absolute paths
347
- - Git operations: `git -C $WORKSPACE ...`
349
+ **Read the output.** It prints `WORKSPACE=<path>` and `BRANCH=<name>`. You MUST use these for all remaining work:
350
+
351
+ - If `WORKSPACE` is missing from output → the worktree creation failed. Stop and tell the user.
352
+ - If `RESUMING` appears a previous build started this feature. Continue from where it left off.
353
+
354
+ **From this point, ALL file operations use the WORKSPACE path:**
355
+ - Bash: `cd <WORKSPACE> && ./gradlew test`
356
+ - Read/Write/Edit: use `<WORKSPACE>/src/...` absolute paths
357
+ - Git: `git -C <WORKSPACE> add` / `git -C <WORKSPACE> commit`
358
+
359
+ **Do NOT read or write files in the main repo.** Only the worktree.
348
360
 
349
- > "Working in: `$WORKSPACE` on branch `$BRANCH`"
361
+ > "Working in: `<WORKSPACE>` on branch `<BRANCH>`"
350
362
 
351
363
  **Custom plan prompts:** If `.spartan/build.yaml` has `prompts.plan`, apply those instructions now.
352
364
 
@@ -746,16 +758,16 @@ Update `.memory/index.md` if you saved anything.
746
758
 
747
759
  ### Clean up worktree
748
760
 
749
- After PR is created, the worktree stays in case the user needs to push review fixes. Tell the user:
761
+ After PR is created, the worktree stays for review fixes. Tell the user the worktree path so they know.
750
762
 
751
- > "PR created. Worktree at `.worktrees/[slug]` is still active for review fixes."
752
-
753
- When the user says the PR is merged:
763
+ When the user says the PR is merged, clean up by substituting the actual slug:
754
764
 
755
765
  ```bash
756
766
  MAIN_REPO="$(git worktree list | head -1 | awk '{print $1}')"
757
- git -C "$MAIN_REPO" worktree remove ".worktrees/[slug]" --force 2>/dev/null
767
+ SLUG="the-actual-slug-used-earlier"
768
+ git -C "$MAIN_REPO" worktree remove ".worktrees/$SLUG" --force 2>/dev/null
758
769
  git -C "$MAIN_REPO" worktree prune 2>/dev/null
770
+ echo "Cleaned up worktree for $SLUG"
759
771
  ```
760
772
 
761
773
  **GATE 4 — Done.**
@@ -814,29 +826,27 @@ Agent(
814
826
  ```
815
827
  Collect results after all finish, then `TeamDelete()`.
816
828
 
817
- ### Step 2: Sort by dependency and create workspace
829
+ ### Step 2: Sort by dependency and create workspace (MANDATORY)
818
830
 
819
831
  Read the epic's Features table. Sort features by dependency order:
820
832
  - Features with no dependencies → can build first
821
833
  - Features that depend on others → build after their dependencies are done
822
834
 
823
- Create a worktree for the epic (same pattern as single-feature builds):
835
+ **MANDATORY:** Create a worktree for the epic. Same pattern as single-feature builds. Generate a slug from the epic name, then run immediately:
824
836
 
825
837
  ```bash
826
- SLUG="[epic-slug]"
838
+ SLUG="the-epic-slug-you-generated"
827
839
  BRANCH="feature/$SLUG"
828
840
  MAIN_REPO="$(git rev-parse --show-toplevel)"
829
841
  WORKSPACE="$MAIN_REPO/.worktrees/$SLUG"
830
-
831
- git worktree add "$WORKSPACE" -b "$BRANCH" 2>/dev/null || git worktree add "$WORKSPACE" "$BRANCH"
832
-
833
- for dir in .planning .memory .handoff .spartan; do
834
- [ -d "$MAIN_REPO/$dir" ] && [ ! -e "$WORKSPACE/$dir" ] && ln -s "$MAIN_REPO/$dir" "$WORKSPACE/$dir"
835
- done
842
+ if [ -d "$WORKSPACE" ]; then echo "RESUMING: $WORKSPACE"; else git worktree add "$WORKSPACE" -b "$BRANCH" 2>/dev/null || git worktree add "$WORKSPACE" "$BRANCH"; fi
843
+ for dir in .planning .memory .handoff .spartan; do [ -d "$MAIN_REPO/$dir" ] && [ ! -e "$WORKSPACE/$dir" ] && ln -s "$MAIN_REPO/$dir" "$WORKSPACE/$dir"; done
836
844
  [ -f "$MAIN_REPO/.env" ] && [ ! -f "$WORKSPACE/.env" ] && cp "$MAIN_REPO/.env" "$WORKSPACE/.env"
845
+ echo "WORKSPACE=$WORKSPACE"
846
+ echo "BRANCH=$BRANCH"
837
847
  ```
838
848
 
839
- All epic work happens in `$WORKSPACE`.
849
+ **Read the output.** All epic work happens in the WORKSPACE path printed above. Use `cd <WORKSPACE> && ...` for all commands.
840
850
 
841
851
  ### Step 3: Implement in dependency order
842
852
 
@@ -18,45 +18,43 @@ Your job: understand what the user needs, then route to the right **workflow lea
18
18
 
19
19
  ---
20
20
 
21
- ## Step 0.5: Session Tracking (silent, always runs)
22
-
23
- Track this session so other Claude windows know what's happening here:
21
+ ## Preamble (run first)
24
22
 
25
23
  ```bash
26
24
  mkdir -p ~/.spartan/sessions
27
- echo "branch=$(git branch --show-current 2>/dev/null || echo 'unknown') dir=$(basename $(pwd)) time=$(date +%s)" > ~/.spartan/sessions/$$
25
+ touch ~/.spartan/sessions/"$PPID"
26
+ _SESSIONS=$(find ~/.spartan/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ')
27
+ find ~/.spartan/sessions -mmin +120 -type f -delete 2>/dev/null || true
28
+ _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
29
+ _PROJECT=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || basename "$(pwd)")
30
+ echo "SESSIONS: $_SESSIONS"
31
+ echo "BRANCH: $_BRANCH"
32
+ echo "PROJECT: $_PROJECT"
33
+ cat .spartan/commands.yaml 2>/dev/null || true
28
34
  ```
29
35
 
30
- Count active sessions (modified in last 2 hours):
36
+ **Read the output.** Use `SESSIONS`, `BRANCH`, and `PROJECT` for the rest of this session.
31
37
 
32
- ```bash
33
- ACTIVE_SESSIONS=0
34
- NOW=$(date +%s)
35
- CUTOFF=$((NOW - 7200))
36
- for f in ~/.spartan/sessions/*; do
37
- [ -f "$f" ] || continue
38
- MOD=$(stat -f %m "$f" 2>/dev/null || stat -c %Y "$f" 2>/dev/null || echo 0)
39
- [ "$MOD" -gt "$CUTOFF" ] && ACTIVE_SESSIONS=$((ACTIVE_SESSIONS + 1))
40
- done
41
- ```
38
+ **If `SESSIONS` >= 3:** Start EVERY response with a grounding line:
42
39
 
43
- **If 3+ active sessions**, start your response with a grounding line:
40
+ > **[PROJECT / BRANCH]** Currently working on: [brief task description]
44
41
 
45
- > **[Session ground]** You're in `[directory]` on branch `[branch]`. Last commit: `[git log --oneline -1]`.
42
+ This prevents "which terminal am I?" confusion during parallel builds. One line, no big deal.
46
43
 
47
- This prevents confusion when the user is running multiple windows. Keep it to one line don't make it a big deal.
44
+ **If `.spartan/commands.yaml` exists** and has a `prompts.[command-name]` entry matching the command being routed to, pass those custom instructions to the command after the built-in prompt.
48
45
 
49
- ---
46
+ ## Completeness Principle
50
47
 
51
- ## Step 0.9: Load Command Config (silent, always runs)
48
+ AI makes completeness near-free. Always recommend the complete option over shortcuts. See `ETHOS.md` for the full philosophy. When presenting options, include `Completeness: X/10` (10 = all edge cases, 7 = happy path, 3 = shortcut).
52
49
 
53
- Check for per-command custom prompts. Commands config lets users inject custom instructions into any Spartan command.
50
+ ## AskUserQuestion Format
54
51
 
55
- ```bash
56
- cat .spartan/commands.yaml 2>/dev/null || cat .spartan/commands.yml 2>/dev/null
57
- ```
52
+ **ALWAYS use this structure for every question to the user:**
58
53
 
59
- If the file exists and has a `prompts.[command-name]` entry matching the command being routed to, pass those custom instructions to the command. They're appended after the built-in prompt.
54
+ 1. **Re-ground:** State project + branch (from preamble). One sentence.
55
+ 2. **Simplify:** Explain so a smart 16-year-old can follow. No function names. Say what it DOES.
56
+ 3. **Recommend:** `RECOMMENDATION: Choose [X] because [reason]` — prefer the complete option.
57
+ 4. **Options:** `A) ... B) ... C) ...` — one decision per question. Never ask two things at once.
60
58
 
61
59
  ---
62
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c0x12c/spartan-ai-toolkit",
3
- "version": "1.9.2",
3
+ "version": "1.10.0",
4
4
  "description": "Engineering discipline layer for AI coding agents — commands, rules, skills, agents, and packs for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,89 @@
1
+ # Spartan Preamble — Standard Block for All Commands
2
+
3
+ This preamble is injected into every Spartan command. Copy the relevant sections
4
+ into your command's `## Preamble (run first)` block.
5
+
6
+ ---
7
+
8
+ ## Preamble (run first)
9
+
10
+ ```bash
11
+ mkdir -p ~/.spartan/sessions
12
+ touch ~/.spartan/sessions/"$PPID"
13
+ _SESSIONS=$(find ~/.spartan/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ')
14
+ find ~/.spartan/sessions -mmin +120 -type f -delete 2>/dev/null || true
15
+ _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
16
+ _PROJECT=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || basename "$(pwd)")
17
+ echo "SESSIONS: $_SESSIONS"
18
+ echo "BRANCH: $_BRANCH"
19
+ echo "PROJECT: $_PROJECT"
20
+ ```
21
+
22
+ **Read the output.** Then apply these rules:
23
+
24
+ **If `SESSIONS` >= 3:** You are in multi-session mode. Start EVERY response with a grounding line:
25
+
26
+ > **[`PROJECT` / `BRANCH`]** Currently working on: [brief description of current task]
27
+
28
+ This prevents confusion when the user has multiple terminals open. Keep it to one line.
29
+
30
+ **If `SESSIONS` < 3:** No grounding needed. Proceed normally.
31
+
32
+ ---
33
+
34
+ ## Completeness Principle — Boil the Lake
35
+
36
+ AI makes completeness near-free. Always recommend the complete option over shortcuts. A "lake" (100% coverage, all edge cases) is boilable. An "ocean" (full rewrite, multi-quarter migration) is not. Boil lakes, flag oceans.
37
+
38
+ When presenting options, include `Completeness: X/10` for each:
39
+ - 10 = all edge cases, full coverage
40
+ - 7 = covers happy path, skips some edges
41
+ - 3 = shortcut that defers work
42
+
43
+ ---
44
+
45
+ ## AskUserQuestion Format
46
+
47
+ **ALWAYS follow this structure for every question:**
48
+
49
+ 1. **Re-ground:** State the project and current branch (use `_BRANCH` from preamble output). One sentence.
50
+ 2. **Simplify:** Explain the problem so a smart 16-year-old could follow. No function names, no jargon. Say what it DOES, not what it's called.
51
+ 3. **Recommend:** `RECOMMENDATION: Choose [X] because [one-line reason]` — always prefer the complete option. Include `Completeness: X/10` for each option.
52
+ 4. **Options:** Lettered options: `A) ... B) ... C) ...` — one decision per question. Never ask two things at once.
53
+
54
+ Example:
55
+
56
+ > **[myapp / feature/auth]** Working on: user authentication
57
+ >
58
+ > We need to handle what happens when the login token expires. Two choices:
59
+ >
60
+ > RECOMMENDATION: Choose A — it handles all edge cases and takes 5 minutes more.
61
+ >
62
+ > A) Full token refresh flow with retry and error UI — Completeness: 10/10
63
+ > B) Just redirect to login page on expiry — Completeness: 5/10
64
+
65
+ ---
66
+
67
+ ## Build Config
68
+
69
+ Check for project-level config before starting:
70
+
71
+ ```bash
72
+ cat .spartan/build.yaml 2>/dev/null
73
+ cat .spartan/commands.yaml 2>/dev/null
74
+ ```
75
+
76
+ If `.spartan/commands.yaml` has a `prompts.[command-name]` entry matching this command, apply those custom instructions after the built-in ones.
77
+
78
+ ---
79
+
80
+ ## Voice
81
+
82
+ Direct. Concrete. Sharp. Never corporate, never academic. Sound like a builder, not a consultant.
83
+
84
+ - Name the file, the function, the line number
85
+ - Show the exact command, not "you should test this"
86
+ - Use real numbers: not "might be slow" but "~200ms per request with 50 items"
87
+ - No AI vocabulary: delve, crucial, robust, comprehensive, nuanced, leverage, facilitate
88
+ - Short paragraphs. End with what to do.
89
+ - The user decides. You recommend. Never act on their behalf without asking.