@zaganjade/pi-multi-skill 1.0.0 → 1.3.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.
package/README.md CHANGED
@@ -1,48 +1,448 @@
1
1
  # pi-multi-skill
2
2
 
3
- Load multiple skills at once in [pi](https://github.com/earendil-works/pi-mono) via the `/skills` command.
3
+ Load multiple skills at once in [pi](https://github.com/earendil-works/pi-mono) via the `/skills` command — with preset bundles, token-efficient load modes, BMAD auto-routing, and Claude Code-style orchestration.
4
+
5
+ **Version 1.3.0** — skill chaining, bundle presets, conflict resolution, parallel dispatch, activation stats, `/skills-last`, `/skills-setup`, and bundle attribution in pi-usage.
4
6
 
5
7
  ## Why?
6
8
 
7
- Pi's built-in `/skill:name` only loads one skill at a time. When you need multiple skills working together (e.g. `frontend-design` + `motion-design` + `test-driven-development`), you'd have to invoke them one by one. This extension lets you chain them in a single command.
9
+ Pi's built-in `/skill:name` loads one skill at a time. When you need several skills working together (e.g. `bmad-master` + `analyst` + `pm`, or `systematic-debugging` + `test-driven-development`), invoking them one by one is slow and easy to forget.
10
+
11
+ This extension chains skills in a **single command** with:
12
+
13
+ - Preset **bundles** (`@bmad-planning`, `@debug`, …)
14
+ - **Smart ordering** (process → planning → implementation)
15
+ - **Load modes** to control token cost (`--meta`, `--lazy`, `--full`)
16
+ - **Universal discovery** including Claude Code plugin skills and Cursor skills
17
+ - **BMAD `--auto`** phase routing from workflow status files
18
+
19
+ ---
20
+
21
+ ## Quick start
22
+
23
+ ```
24
+ /skills @debug --meta Fix the failing auth tests
25
+ /skills @bmad-planning --meta Buat PRD untuk fitur notifikasi
26
+ /skills bmad-master,developer Implement user story US-042
27
+ /skills bmad-master /workflow-status
28
+ /skills @bmad-planning --auto
29
+ /skills @cc-feature --parallel Build API | Write tests | Update docs
30
+ /skills-stats → activation statistics
31
+ /skills-last → repeat last activation
32
+ /skills-setup → bundle install guide
33
+ /skills → help + list all skills & bundles
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Commands
39
+
40
+ | Command | Description |
41
+ |---------|-------------|
42
+ | `/skills` | Chain skills/bundles — flags, embedded commands, `--auto`, `--parallel` |
43
+ | `/skills-stats` | Activation statistics (`~/.pi/agent/multi-skill-stats.json`) |
44
+ | `/skills-last` | Repeat last activation (optional `--meta` / `--lazy` / `--full` / `--parallel`) |
45
+ | `/skills-setup` | Bundle readiness on this machine + BMAD/Superpowers install guide |
46
+
47
+ ---
48
+
49
+ ## Features
50
+
51
+ ### v1.3.0
52
+
53
+ | Feature | Description |
54
+ |---------|-------------|
55
+ | **`/skills-last`** | Replay the previous `/skills` line; flags can override load mode |
56
+ | **BMAD status inject** | `<bmad_status>` preloaded for `/workflow-status`, `--auto`, `bmad-master` |
57
+ | **Bundle attribution** | Sets `bundles="@name"` on `<manually_attached_skills>` for pi-usage tracking |
58
+ | **`/skills-setup`** | Reports which preset bundles are usable + how to install missing skills |
59
+
60
+ ### Skill chaining
61
+
62
+ | Feature | Description |
63
+ |---------|-------------|
64
+ | **Comma-separated skills** | `/skills skill1,skill2,skill3 [instructions]` |
65
+ | **Preset bundles** | `/skills @bundle-name` expands to a curated skill set |
66
+ | **Mixed input** | Combine bundles and individual skills: `/skills @debug,frontend-design` |
67
+ | **Inline instructions** | Text after the skill list is passed inside `<user_query>` |
68
+ | **Legacy formats** | `/skills:a,b` (colon + comma) and `/skill:a+b` (colon + plus) still work |
69
+
70
+ ### Load modes (token efficiency)
71
+
72
+ | Flag | What gets sent | Best for |
73
+ |------|----------------|----------|
74
+ | `--meta` | Name, description, available commands only | Exploration, planning, large bundles |
75
+ | `--lazy` | Short intro + commands + “load references on demand” | Implementation workflows |
76
+ | `--full` | Complete `SKILL.md` body (default) | Rigid skills (TDD, debugging) |
77
+
78
+ Bundles can set a default mode (e.g. `@bmad-planning` defaults to `--meta`).
79
+
80
+ ### Smart ordering
81
+
82
+ Skills are sorted automatically before injection:
83
+
84
+ 1. **Process** — `using-superpowers`, `brainstorming`, `systematic-debugging`, `bmad-master`, …
85
+ 2. **Planning** — `analyst`, `pm`, `architect`, `ux-designer`, …
86
+ 3. **Implementation** — domain and execution skills
87
+
88
+ User instructions always take precedence over skill guidance. Skills with conflicting `conflicts_with` frontmatter are deduplicated automatically (lower-priority skill skipped).
89
+
90
+ ### Parallel dispatch (v1.2)
91
+
92
+ When `--parallel` is used with `pi-subagents` installed, the message includes a `<parallel_dispatch>` block with a ready-to-use JSON template for the `subagent` tool:
93
+
94
+ ```
95
+ /skills @cc-feature --parallel Build API | Write tests | Update docs
96
+ ```
97
+
98
+ Pipe-separated tasks (`|`) become independent parallel subagent jobs. Without `pi-subagents`, a fallback notice prompts sequential execution.
99
+
100
+ ### Skill conflict resolution (v1.2)
101
+
102
+ Skills can declare `conflicts_with` in frontmatter. After smart ordering, conflicting skills are skipped with an info notification:
103
+
104
+ ```
105
+ Skipped test-driven-development (conflicts with systematic-debugging)
106
+ ```
107
+
108
+ ### Per-skill token budget (v1.2)
109
+
110
+ Skills can set `token_budget: meta|lazy|full` in frontmatter. When a bundle uses `--lazy`, individual skills can still override to `--full` (e.g. rigid TDD/debug skills).
111
+
112
+ ### Activation stats (v1.2)
113
+
114
+ Every `/skills` activation is recorded to `~/.pi/agent/multi-skill-stats.json`. View with:
115
+
116
+ ```
117
+ /skills-stats
118
+ ```
119
+
120
+ Tracks load modes, top bundles, skills-per-activation buckets, and recent history.
121
+
122
+ ### Command passthrough
123
+
124
+ Embed a slash command after the skill list — it is wrapped in `<embedded_command>` and the agent runs that workflow after loading the skill:
125
+
126
+ ```
127
+ /skills bmad-master /workflow-status
128
+ /skills developer /dev-story STORY-042
129
+ /skills analyst /product-brief
130
+ ```
131
+
132
+ After typing the skill name and a space, autocomplete suggests commands from the skill's **Available Commands** section (e.g. `/workflow-status`, `/dev-story`).
133
+
134
+ > **Note:** BMAD commands like `/workflow-status` are **skill workflows** executed by the agent — not separate Pi slash commands. You will see a notification (`Loading bmad-master → /workflow-status`) and the agent turn starts with the skill + embedded command injected.
135
+
136
+ ### BMAD `--auto`
137
+
138
+ Reads `docs/bmm-workflow-status.yaml` (and `bmad/config.yaml` for project level) and loads skills for the current phase:
139
+
140
+ | Detected phase | Skills loaded |
141
+ |----------------|---------------|
142
+ | Analysis | bmad-master, analyst |
143
+ | Planning | bmad-master, analyst, pm |
144
+ | Solutioning | bmad-master, architect, ux-designer |
145
+ | Implementation | bmad-master, developer, scrum-master |
146
+
147
+ ```
148
+ /skills --auto
149
+ /skills @bmad-planning --auto
150
+ ```
151
+
152
+ ### Universal skill discovery
153
+
154
+ Skills are found from **all** of these sources (merged, deduplicated by name):
155
+
156
+ | Source | Path / mechanism |
157
+ |--------|------------------|
158
+ | Pi registered skills | `pi.getCommands()` (`source: "skill"`) |
159
+ | Pi defaults | `~/.pi/agent/skills`, `.pi/skills` |
160
+ | Settings skill paths | `"skills"` array in `~/.pi/agent/settings.json` |
161
+ | Claude Code plugins | `~/.claude/plugins/cache/**/skills/` (Superpowers, etc.) |
162
+ | Cursor skills | `~/.cursor/skills-cursor/` |
163
+
164
+ This means bundles like `@debug` and `@cc-feature` work even when Superpowers skills live in the Claude plugin cache rather than `~/.claude/skills`.
165
+
166
+ ### Claude Code-style message wrapper
167
+
168
+ Combined output uses a structured wrapper (similar to Cursor `manually_attached_skills`):
169
+
170
+ ```xml
171
+ <manually_attached_skills count="3">
172
+ …priority rules…
173
+ <skill name="…" mode="meta">…</skill>
174
+ <embedded_command>/workflow-status</embedded_command>
175
+ <user_query>Your instructions here</user_query>
176
+ </manually_attached_skills>
177
+ ```
178
+
179
+ ### Session hints
180
+
181
+ After each user turn, the extension may suggest a relevant bundle (non-blocking `info` notification):
182
+
183
+ | Keywords detected | Suggested bundle |
184
+ |-------------------|------------------|
185
+ | failing tests, bug, error | `@debug` |
186
+ | PRD, tech spec | `@bmad-planning` |
187
+ | architecture, API design | `@bmad-solutioning` |
188
+ | implement, user story | `@bmad-build` |
189
+ | new feature, build component | `@cc-feature` |
190
+
191
+ ### Skill registry
192
+
193
+ On every `session_start`, rebuilds `~/.pi/agent/skill-index.json` with metadata (name, type, module, commands, location) for all discovered skills.
194
+
195
+ ### Deduplication
196
+
197
+ When combining skills that share content (e.g. multiple skills with `<SUBAGENT-STOP>` or Superpowers skill-check rules), duplicate sections are stripped automatically.
198
+
199
+ ### pi-usage integration
200
+
201
+ Works with [**pi-usage**](../usage/README.md):
202
+
203
+ - Every skill in a multi-skill activation appears separately in **Skills**
204
+ - Preset bundles (`@debug`, `@bmad-planning`, …) appear in **Bundles** when `bundles="@name"` is set on the wrapper
205
+ - Tool and plugin breakdowns unchanged — independent characteristics like Claude Code
206
+
207
+ ---
208
+
209
+ ## Preset bundles
210
+
211
+ Built-in bundles are **optional presets** — they require BMAD and/or Superpowers skills to be installed separately. Run `/skills-setup` to check what's available on your machine.
212
+
213
+ Expand with `@name`:
214
+
215
+ | Bundle | Skills | Default mode | Requires |
216
+ |--------|--------|--------------|----------|
217
+ | `@bmad-planning` | bmad-master, analyst, pm | `--meta` | BMAD Method |
218
+ | `@bmad-solutioning` | bmad-master, architect, ux-designer | `--meta` | BMAD Method |
219
+ | `@bmad-build` | bmad-master, developer, scrum-master | `--lazy` | BMAD Method |
220
+ | `@cc-feature` | using-superpowers, brainstorming, … | `--lazy` | Superpowers |
221
+ | `@debug` | systematic-debugging, test-driven-development | `--full` | Superpowers |
8
222
 
9
- ## Usage
223
+ Autocomplete shows coverage per bundle, e.g. `(2/3)` or `(0/3 — install required)`.
224
+
225
+ ### Without BMAD or Superpowers
226
+
227
+ You can still use pi-multi-skill:
10
228
 
11
229
  ```
12
- /skills frontend-design,motion-design Create an animated landing page
13
- /skills test-driven-development,systematic-debugging Fix the failing tests
14
- /skills → show help + list available skills
230
+ /skills frontend-design,motion-design Build landing page
231
+ /skills-setup → check bundle status + install guide
232
+ ```
233
+
234
+ Create your own bundles with **only skills you have**:
235
+
236
+ ```json
237
+ {
238
+ "bundles": {
239
+ "my-stack": {
240
+ "description": "Skills I actually installed",
241
+ "skills": ["frontend-design", "create-rule"],
242
+ "default_mode": "meta"
243
+ }
244
+ }
245
+ }
15
246
  ```
16
247
 
17
- - **Comma-separated** skill names after `/skills`
18
- - **Optional instructions** after the skill list (passed to the agent alongside the skill content)
19
- - **Autocomplete** — typing `/skills ` shows all available skills with descriptions, and selecting one appends it with a comma for chaining
248
+ Save as `~/.pi/agent/skill-bundles.json` then use `/skills @my-stack`.
249
+
250
+ ---
20
251
 
21
- ### Legacy formats (also supported)
252
+ ## Custom bundles
22
253
 
254
+ Create `~/.pi/agent/skill-bundles.json`, `.pi/skill-bundles.json`, or the YAML equivalents (`skill-bundles.yaml` / `.pi/skill-bundles.yaml`):
255
+
256
+ ```json
257
+ {
258
+ "bundles": {
259
+ "my-team-planning": {
260
+ "description": "Custom team planning workflow",
261
+ "skills": ["bmad-master", "analyst", "pm"],
262
+ "order": "process-first",
263
+ "default_mode": "meta"
264
+ }
265
+ }
266
+ }
23
267
  ```
24
- /skills:frontend-design,motion-design [args] (colon + comma)
25
- /skill:frontend-design+motion-design [args] (colon + plus)
268
+
269
+ YAML format (same fields):
270
+
271
+ ```yaml
272
+ bundles:
273
+ my-team-planning:
274
+ description: Custom team planning workflow
275
+ skills:
276
+ - bmad-master
277
+ - analyst
278
+ - pm
279
+ order: process-first
280
+ default_mode: meta
26
281
  ```
27
282
 
283
+ | Field | Values | Description |
284
+ |-------|--------|-------------|
285
+ | `description` | string | Shown in `/skills` help and autocomplete |
286
+ | `skills` | string[] | Skill names to load when bundle is expanded |
287
+ | `order` | `process-first` · `explicit` · `alpha` | Sort order (default: `process-first`) |
288
+ | `default_mode` | `meta` · `lazy` · `full` | Applied when no `--meta`/`--lazy`/`--full` flag is passed |
289
+
290
+ See [skill-bundles.example.json](./skill-bundles.example.json) and [skill-bundles.example.yaml](./skill-bundles.example.yaml).
291
+
292
+ Custom bundles **merge** with built-in presets; same name overrides the preset.
293
+
294
+ ---
295
+
296
+ ## Flags reference
297
+
298
+ | Flag | Description |
299
+ |------|-------------|
300
+ | `--meta` | Minimal content — name, description, commands |
301
+ | `--lazy` | Summary + on-demand reference loading |
302
+ | `--full` | Full SKILL.md body (default) |
303
+ | `--auto` | BMAD phase detection from workflow status |
304
+ | `--parallel` | Parallel subagent dispatch — pipe-separated tasks: `Task A \| Task B` |
305
+ | `/skills-stats` | Show activation statistics (modes, bundles, recent history) |
306
+ | `/skills-last` | Repeat last `/skills` activation |
307
+ | `/skills-setup` | Bundle prerequisites and install guide |
308
+
309
+ ---
310
+
28
311
  ## Install
29
312
 
313
+ Use **`pi install`**, not plain `npm install`. Pi registers packages in `settings.json` under `"packages"` and loads extensions from the `pi.extensions` manifest.
314
+
315
+ ```bash
316
+ pi install npm:@zaganjade/pi-multi-skill
317
+ /reload
318
+ ```
319
+
320
+ Quick test without persisting to settings:
321
+
322
+ ```bash
323
+ pi -e npm:@zaganjade/pi-multi-skill
324
+ ```
325
+
326
+ From GitHub (monorepo):
327
+
30
328
  ```bash
31
- pi install git:github.com/ZaganJade/pi-multi-skill
329
+ pi install git:github.com/ZaganJade/pi-extension
32
330
  ```
33
331
 
34
- Or from a local path:
332
+ Local development:
35
333
 
36
334
  ```bash
37
335
  pi install ./multi-skill
336
+ /reload
337
+ ```
338
+
339
+ Verify:
340
+
341
+ ```bash
342
+ pi list
343
+ # should show: npm:@zaganjade/pi-multi-skill
38
344
  ```
39
345
 
346
+ ---
347
+
348
+ ## Troubleshooting
349
+
350
+ | Symptom | Fix |
351
+ |---------|-----|
352
+ | `/skills` not in autocomplete | Run `pi install npm:@zaganjade/pi-multi-skill`, then `/reload` |
353
+ | `No skills found for: …` | Ensure skill exists in a discovery path (see table above). Superpowers skills are found via Claude plugin cache automatically. |
354
+ | Bundle skill missing | Run `/skills` with no args — check skill appears in list. Add custom path to `"skills"` in settings if needed. |
355
+ | Installed with `npm install -g` but pi ignores it | Use `pi install npm:@zaganjade/pi-multi-skill` instead |
356
+ | Added `npm:...` to `"extensions"` in settings | Wrong key for npm packages — use `"packages"`, or run `pi install` |
357
+ | Command shows as `/skills:2` | Two copies loaded (local + npm). Remove duplicate from `extensions` or `packages` |
358
+ | Extension listed but disabled | Run `pi config` and enable the extension resource |
359
+ | `--auto` loads wrong skills | Ensure `docs/bmm-workflow-status.yaml` exists and reflects current phase |
360
+
361
+ ---
362
+
40
363
  ## How it works
41
364
 
42
- The extension discovers all available skills via `pi.getCommands()` (covers user-level, project-level, and package-installed skills), reads each selected skill's `SKILL.md`, strips frontmatter, wraps it in `<skill>` blocks, and sends the combined content as a user message to trigger agent processing.
365
+ ```mermaid
366
+ flowchart LR
367
+ CMD["/skills @bundle --meta /cmd"]
368
+ DISC["discover.ts"]
369
+ PARSE["parse-args.ts + bundles.ts"]
370
+ ORDER["metadata.ts sort"]
371
+ BUILD["build.ts"]
372
+ SEND["sendUserMessage()"]
373
+
374
+ CMD --> PARSE --> DISC --> ORDER --> BUILD --> SEND
375
+ ```
376
+
377
+ 1. **Parse** — extract skill names, flags, embedded command, instructions
378
+ 2. **Expand** — resolve `@bundle` → skill name list; `--auto` → BMAD phase skills
379
+ 3. **Discover** — merge skills from pi, settings paths, Claude plugins, Cursor
380
+ 4. **Order** — sort by process → planning → implementation priority
381
+ 5. **Build** — render each skill in the chosen load mode; deduplicate shared sections
382
+ 6. **Send** — inject `<manually_attached_skills>` wrapper via `pi.sendUserMessage()`
43
383
 
44
- ## Files
384
+ ---
385
+
386
+ ## Module layout
45
387
 
46
388
  | File | Purpose |
47
389
  |------|---------|
48
- | `src/index.ts` | Entry point registers `/skills` command, autocomplete, and input handler |
390
+ | `src/index.ts` | `/skills`, `/skills-stats`, `/skills-last`, `/skills-setup`; events; orchestration |
391
+ | `src/discover.ts` | Universal skill discovery (pi + Claude plugins + Cursor) |
392
+ | `src/bundles.ts` | Built-in presets + user JSON/YAML bundle config |
393
+ | `src/bundle-status.ts` | Bundle readiness assessment + setup report |
394
+ | `src/metadata.ts` | Frontmatter parsing (via pi), priority sorting |
395
+ | `src/build.ts` | Message builder — load modes, deduplication, parallel dispatch, `bundles=` attr |
396
+ | `src/conflicts.ts` | `conflicts_with` resolution |
397
+ | `src/subagents.ts` | pi-subagents detection + `<parallel_dispatch>` template |
398
+ | `src/stats.ts` | Activation tracking → `multi-skill-stats.json` |
399
+ | `src/yaml-bundles.ts` | Minimal YAML parser for bundle config |
400
+ | `src/bmad-auto.ts` | BMAD `--auto` phase routing |
401
+ | `src/bmad-status.ts` | BMAD workflow status block for status/auto/master |
402
+ | `src/completions.ts` | Slash autocomplete for skills, bundles, embedded commands |
403
+ | `src/parse-args.ts` | Flag parsing, embedded command extraction |
404
+ | `src/registry.ts` | `~/.pi/agent/skill-index.json` persistence |
405
+ | `src/suggestions.ts` | Context-aware bundle hints on `turn_end` |
406
+ | `src/types.ts` | Shared TypeScript types |
407
+ | `skill-bundles.example.json` | Example custom bundle config (JSON) |
408
+ | `skill-bundles.example.yaml` | Example custom bundle config (YAML) |
409
+
410
+ ---
411
+
412
+ ## Changelog
413
+
414
+ ### v1.3.0
415
+
416
+ - `/skills-last` — repeat last activation (optional `--meta`/`--lazy`/`--full`/`--parallel` override)
417
+ - BMAD status pre-inject — `<bmad_status>` block for `/workflow-status`, `--auto`, and `bmad-master`
418
+ - Bundle attribution in pi-usage — `bundles="@name"` on `<manually_attached_skills>`
419
+
420
+ ### v1.2.0
421
+
422
+ - Skill conflict resolution via `conflicts_with` frontmatter
423
+ - Per-skill `token_budget` override in frontmatter
424
+ - Structured `<parallel_dispatch>` block with JSON template for `pi-subagents`
425
+ - Pipe-separated parallel tasks: `--parallel Task A | Task B`
426
+ - Activation stats (`/skills-stats`, `multi-skill-stats.json`)
427
+ - YAML bundle config (`skill-bundles.yaml`)
428
+ - Richer skill index (pairsWith, conflictsWith, tokenBudget)
429
+
430
+ ### v1.1.0
431
+
432
+ - Preset bundles (`@bmad-planning`, `@debug`, `@cc-feature`, …)
433
+ - Load modes: `--meta`, `--lazy`, `--full`
434
+ - Smart skill ordering (Superpowers priority)
435
+ - BMAD `--auto` phase routing
436
+ - Command passthrough (`/skills bmad-master /workflow-status`)
437
+ - Universal discovery (Claude plugin cache + Cursor skills)
438
+ - `<manually_attached_skills>` message wrapper
439
+ - Session bundle suggestions on `turn_end`
440
+ - Skill registry (`skill-index.json`)
441
+ - Content deduplication across combined skills
442
+ - Multi-skill attribution in pi-usage
443
+
444
+ ### v1.0.x
445
+
446
+ - Comma-separated `/skills a,b,c [instructions]`
447
+ - Autocomplete with descriptions
448
+ - Legacy `/skills:` and `/skill:+` formats
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@zaganjade/pi-multi-skill",
3
- "version": "1.0.0",
4
- "description": "Load multiple skills at once via /skills command. Supports comma-separated skill names with autocomplete and instructions.",
3
+ "version": "1.3.0",
4
+ "description": "Chain multiple skills via /skills bundles (JSON/YAML), load modes, BMAD --auto, /skills-last, /skills-setup, conflict resolution, parallel dispatch, activation stats, bundle attribution for pi-usage.",
5
+ "type": "module",
5
6
  "keywords": [
6
7
  "pi-package"
7
8
  ],
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
8
12
  "license": "MIT",
9
13
  "author": "ZaganJade <tipstrik81@gmail.com>",
10
14
  "homepage": "https://github.com/ZaganJade/pi-extension/tree/main/multi-skill",
@@ -20,7 +24,9 @@
20
24
  "files": [
21
25
  "src/",
22
26
  "README.md",
23
- "LICENSE"
27
+ "LICENSE",
28
+ "skill-bundles.example.json",
29
+ "skill-bundles.example.yaml"
24
30
  ],
25
31
  "pi": {
26
32
  "extensions": [
@@ -0,0 +1,17 @@
1
+ {
2
+ "bundles": {
3
+ "my-stack": {
4
+ "description": "Only skills installed on this machine — no BMAD required",
5
+ "skills": ["frontend-design", "create-rule"],
6
+ "order": "explicit",
7
+ "default_mode": "meta"
8
+ },
9
+ "my-team-planning": {
10
+ "description": "Custom team planning workflow (requires BMAD)",
11
+ "skills": ["bmad-master", "analyst", "pm"],
12
+ "order": "process-first",
13
+ "default_mode": "meta",
14
+ "requires": "BMAD Method"
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,9 @@
1
+ bundles:
2
+ my-team-planning:
3
+ description: Custom team planning workflow
4
+ skills:
5
+ - bmad-master
6
+ - analyst
7
+ - pm
8
+ order: process-first
9
+ default_mode: meta
@@ -0,0 +1,99 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+
4
+ const PHASE_SKILLS: Record<string, string[]> = {
5
+ analysis: ["bmad-master", "analyst"],
6
+ planning: ["bmad-master", "analyst", "pm"],
7
+ solutioning: ["bmad-master", "architect", "ux-designer"],
8
+ implementation: ["bmad-master", "developer", "scrum-master"],
9
+ };
10
+
11
+ function readText(path: string): string | null {
12
+ try {
13
+ return readFileSync(path, "utf-8");
14
+ } catch {
15
+ return null;
16
+ }
17
+ }
18
+
19
+ function workflowStatus(content: string, key: string): string | null {
20
+ const patterns = [
21
+ new RegExp(`${key}:\\s*\\n[\\s\\S]*?status:\\s*([\\w-]+)`, "i"),
22
+ new RegExp(`${key}:[\\s\\S]*?status:\\s*([\\w\\s-]+)`, "i"),
23
+ ];
24
+ for (const re of patterns) {
25
+ const match = content.match(re);
26
+ if (match) return match[1].trim().toLowerCase().replace(/\s+/g, "-");
27
+ }
28
+ return null;
29
+ }
30
+
31
+ function isIncomplete(status: string | null): boolean {
32
+ if (!status) return true;
33
+ return /not-started|not_started|pending|required|in-progress|in_progress|started/.test(
34
+ status,
35
+ );
36
+ }
37
+
38
+ function detectPhase(content: string): keyof typeof PHASE_SKILLS {
39
+ const checks: Array<[string, keyof typeof PHASE_SKILLS]> = [
40
+ ["product-brief", "analysis"],
41
+ ["brainstorm", "analysis"],
42
+ ["research", "analysis"],
43
+ ["prd", "planning"],
44
+ ["tech-spec", "planning"],
45
+ ["tech_spec", "planning"],
46
+ ["architecture", "solutioning"],
47
+ ["ux-design", "solutioning"],
48
+ ["sprint-planning", "implementation"],
49
+ ["dev-story", "implementation"],
50
+ ["create-story", "implementation"],
51
+ ];
52
+
53
+ for (const [key, phase] of checks) {
54
+ if (isIncomplete(workflowStatus(content, key))) return phase;
55
+ }
56
+
57
+ if (/implementation|phase:\s*4/i.test(content)) return "implementation";
58
+ if (/solutioning|phase:\s*3/i.test(content)) return "solutioning";
59
+ if (/planning|phase:\s*2/i.test(content)) return "planning";
60
+ return "analysis";
61
+ }
62
+
63
+ function projectLevel(cwd: string): number {
64
+ const configPath = join(cwd, "bmad", "config.yaml");
65
+ const content = readText(configPath);
66
+ if (!content) return 1;
67
+ const match = content.match(/project_level:\s*(\d)/i);
68
+ return match ? Number.parseInt(match[1], 10) : 1;
69
+ }
70
+
71
+ export function resolveBmadAutoSkills(cwd: string): string[] {
72
+ const statusPath = join(cwd, "docs", "bmm-workflow-status.yaml");
73
+ const content = readText(statusPath);
74
+
75
+ if (!content) {
76
+ const level = projectLevel(cwd);
77
+ if (level <= 1) return ["bmad-master", "pm"];
78
+ return ["bmad-master", "analyst"];
79
+ }
80
+
81
+ const phase = detectPhase(content);
82
+ const skills = [...(PHASE_SKILLS[phase] ?? ["bmad-master"])];
83
+
84
+ const level = projectLevel(cwd);
85
+ if (level <= 1 && phase === "planning" && !skills.includes("pm")) {
86
+ skills.push("pm");
87
+ }
88
+
89
+ return [...new Set(skills)];
90
+ }
91
+
92
+ export function bmadAutoHint(cwd: string): string | null {
93
+ const statusPath = join(cwd, "docs", "bmm-workflow-status.yaml");
94
+ if (!existsSync(statusPath)) {
95
+ return "BMAD status not found — loaded bmad-master with planning defaults";
96
+ }
97
+ const phase = detectPhase(readText(statusPath) ?? "");
98
+ return `BMAD --auto detected phase: ${phase}`;
99
+ }