@clfhhc/bmad-methods-skills 0.2.1 → 0.2.2
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/config.json +192 -34
- package/convert.js +3 -1
- package/docs/technical-reference.md +9 -14
- package/package.json +1 -1
- package/skills/enhance-bmad-skills/data/path-patterns.md +0 -1
- package/src/utils/path-rewriter.js +12 -265
- package/src/utils/skill-writer.js +10 -5
package/config.json
CHANGED
|
@@ -3,16 +3,9 @@
|
|
|
3
3
|
"bmadBranch": "main",
|
|
4
4
|
"outputDir": "./skills",
|
|
5
5
|
"tempDir": "./.temp/bmad-method",
|
|
6
|
-
"modules": [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
],
|
|
10
|
-
"agentPaths": [
|
|
11
|
-
"src/*/agents"
|
|
12
|
-
],
|
|
13
|
-
"workflowPaths": [
|
|
14
|
-
"src/*/workflows"
|
|
15
|
-
],
|
|
6
|
+
"modules": ["bmm", "core"],
|
|
7
|
+
"agentPaths": ["src/*/agents"],
|
|
8
|
+
"workflowPaths": ["src/*/workflows"],
|
|
16
9
|
"enhancements": {
|
|
17
10
|
"optional": {
|
|
18
11
|
"addExamples": true,
|
|
@@ -53,61 +46,226 @@
|
|
|
53
46
|
"isDirectory": true
|
|
54
47
|
}
|
|
55
48
|
],
|
|
49
|
+
"skillMap": {
|
|
50
|
+
"sourcePrefix": "\\{project-root\\}/_bmad/",
|
|
51
|
+
"dirLookahead": "(?=['\\s`]|$)",
|
|
52
|
+
"replacementPrefix": "{skill-root}"
|
|
53
|
+
},
|
|
56
54
|
"pathPatterns": [
|
|
57
55
|
{
|
|
58
|
-
"pattern": "\\{project-root\\}/_bmad/
|
|
59
|
-
"replacement": "{skill-root}
|
|
60
|
-
"description": "
|
|
56
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/workflows/workflow-status/init/workflow\\.(yaml|md)",
|
|
57
|
+
"replacement": "{skill-root}/bmm/init/SKILL.md",
|
|
58
|
+
"description": "Init nested workflow (must run before workflow-status dir)"
|
|
61
59
|
},
|
|
62
60
|
{
|
|
63
|
-
"pattern": "\\{project-root\\}/_bmad/
|
|
64
|
-
"replacement": "{skill-root}
|
|
65
|
-
"description": "
|
|
61
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/workflows/document-project/workflows",
|
|
62
|
+
"replacement": "{skill-root}/bmm/document-project",
|
|
63
|
+
"description": "document-project workflows dir"
|
|
66
64
|
},
|
|
67
65
|
{
|
|
68
|
-
"pattern": "\\{project-root\\}/_bmad/
|
|
69
|
-
"replacement": "{skill-root}/$1
|
|
70
|
-
"description": "
|
|
66
|
+
"pattern": "\\{project-root\\}/_bmad/core/workflows/([^/\\s'\"]+)/workflow\\.(yaml|md|xml)",
|
|
67
|
+
"replacement": "{skill-root}/core/$1/SKILL.md",
|
|
68
|
+
"description": "Core workflow files"
|
|
71
69
|
},
|
|
72
70
|
{
|
|
73
|
-
"pattern": "\\{project-root\\}/_bmad/
|
|
74
|
-
"replacement": "{
|
|
75
|
-
"description": "
|
|
71
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/workflows/(?:\\d-[^/]+/)?([^/\\s'\"]+)/workflow\\.(yaml|md|xml)",
|
|
72
|
+
"replacement": "{skill-root}/bmm/$1/SKILL.md",
|
|
73
|
+
"description": "BMM workflow files (incl. category folders)"
|
|
76
74
|
},
|
|
77
75
|
{
|
|
78
|
-
"pattern": "\\{project-root\\}/_bmad/
|
|
79
|
-
"replacement": "{
|
|
80
|
-
"description": "
|
|
76
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/(?:workflows/)?testarch/([^/\\s'\"]+)/workflow\\.(yaml|md|xml)",
|
|
77
|
+
"replacement": "{skill-root}/bmm/testarch-$1/SKILL.md",
|
|
78
|
+
"description": "Testarch workflow files"
|
|
81
79
|
},
|
|
82
80
|
{
|
|
83
|
-
"pattern": "\\{project-root\\}/
|
|
84
|
-
"replacement": "{
|
|
85
|
-
"description": "
|
|
81
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/workflows/excalidraw-diagrams/([^/\\s'\"]+)/workflow\\.(yaml|md|xml)",
|
|
82
|
+
"replacement": "{skill-root}/bmm/$1/SKILL.md",
|
|
83
|
+
"description": "Excalidraw-diagrams workflow files"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/workflows/bmad-quick-flow/([^/\\s'\"]+)/workflow\\.(yaml|md)",
|
|
87
|
+
"replacement": "{skill-root}/bmm/$1/SKILL.md",
|
|
88
|
+
"description": "bmad-quick-flow workflow files"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"pattern": "\\{project-root\\}/_bmad/core/tasks/workflow\\.xml",
|
|
92
|
+
"replacement": "{skill-root}/core/tasks/SKILL.md",
|
|
93
|
+
"description": "Core tasks workflow.xml"
|
|
86
94
|
},
|
|
87
95
|
{
|
|
88
|
-
"pattern": "\\{project-root\\}/_bmad/core/resources/excalidraw/([
|
|
96
|
+
"pattern": "\\{project-root\\}/_bmad/core/resources/excalidraw/([^/\\s'\"]+)",
|
|
89
97
|
"replacement": "{skill-root}/core/resources/excalidraw/$1",
|
|
90
98
|
"description": "Excalidraw helper resources"
|
|
91
99
|
},
|
|
92
100
|
{
|
|
93
|
-
"pattern": "\\{project-root\\}/_bmad/bmm/workflows/excalidraw-diagrams/_shared/([
|
|
101
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/workflows/excalidraw-diagrams/_shared/([^/\\s'\"]+)",
|
|
94
102
|
"replacement": "{skill-root}/bmm/excalidraw-diagrams/_shared/$1",
|
|
95
|
-
"description": "Excalidraw-diagrams _shared files
|
|
103
|
+
"description": "Excalidraw-diagrams _shared files"
|
|
96
104
|
},
|
|
97
105
|
{
|
|
98
106
|
"pattern": "\\{project-root\\}/_bmad/bmm/workflows/excalidraw-diagrams/_shared(?!/)",
|
|
99
107
|
"replacement": "{skill-root}/bmm/excalidraw-diagrams/_shared",
|
|
100
|
-
"description": "Excalidraw-diagrams _shared directory
|
|
108
|
+
"description": "Excalidraw-diagrams _shared directory"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"pattern": "\\{project-root\\}/_bmad/(core|bmm|bmb)/workflows/(?:\\d-[^/]+/)?([^/\\s'\"]+)/([^/\\s'\"]+\\.(md|csv|yaml|xml))",
|
|
112
|
+
"replacement": "{skill-root}/$1/$2/$3",
|
|
113
|
+
"description": "Files within workflow dirs"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"pattern": "\\{project-root\\}/_bmad/(core|bmm|bmb)/workflows/(?:\\d-[^/]+/)?([^/\\s'\"]+)/steps/([^/\\s'\"]+)",
|
|
117
|
+
"replacement": "{skill-root}/$1/$2/steps/$3",
|
|
118
|
+
"description": "Step files within workflows"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"pattern": "\\{project-root\\}/_bmad/bmb/workflows/([^/\\s'\"]+)/(steps-[^/]+)/([^/\\s'\"]+)",
|
|
122
|
+
"replacement": "{skill-root}/bmb/$1/$2/$3",
|
|
123
|
+
"description": "BMB workflow step files"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/workflows/\\d-[^/]+/([^/\\s'\"]+)(?=['\\s`])",
|
|
127
|
+
"replacement": "{skill-root}/bmm/$1",
|
|
128
|
+
"description": "BMM workflows dir with category"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/workflows/([a-z][-a-z0-9]+)(?=['\\s`])",
|
|
132
|
+
"replacement": "{skill-root}/bmm/$1",
|
|
133
|
+
"description": "BMM workflows dir (no category)"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/workflows/bmad-quick-flow/([^/\\s'\"]+)(?=['\\s`])",
|
|
137
|
+
"replacement": "{skill-root}/bmm/$1",
|
|
138
|
+
"description": "bmad-quick-flow directory refs"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/workflows/testarch/([^/\\s'\"]+)(?=['\\s`])",
|
|
142
|
+
"replacement": "{skill-root}/bmm/testarch-$1",
|
|
143
|
+
"description": "Testarch directory refs"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/workflows/workflow-status(?=['\\s`/])",
|
|
147
|
+
"replacement": "{skill-root}/bmm/workflow-status",
|
|
148
|
+
"description": "workflow-status directory"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"pattern": "\\{project-root\\}/_bmad/(bmm|bmb|core)/config\\.yaml",
|
|
152
|
+
"replacement": "{skill-root}/$1/config.yaml",
|
|
153
|
+
"description": "Module config files"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"pattern": "\\{project-root\\}/_bmad/_config/agent-manifest\\.csv",
|
|
157
|
+
"replacement": "{skill-root}/agent-manifest.csv",
|
|
158
|
+
"description": "Agent manifest"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/testarch/tea-index\\.csv",
|
|
162
|
+
"replacement": "{skill-root}/bmm/tea/tea-index.csv",
|
|
163
|
+
"description": "TEA tea-index.csv"
|
|
101
164
|
},
|
|
102
165
|
{
|
|
103
166
|
"pattern": "\\{project-root\\}/_bmad/bmm/testarch/knowledge/",
|
|
104
167
|
"replacement": "{skill-root}/bmm/tea/knowledge/",
|
|
105
168
|
"description": "TEA Knowledge Base (migrated)"
|
|
106
169
|
},
|
|
170
|
+
{
|
|
171
|
+
"pattern": "\\{project-root\\}/_bmad/bmm/data/documentation-standards\\.md",
|
|
172
|
+
"replacement": "{skill-root}/bmm/tech-writer/data/documentation-standards.md",
|
|
173
|
+
"description": "documentation-standards (migrated to tech-writer)"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"pattern": "\\{project-root\\}/_bmad/_memory/([^/\\s'\"]+)",
|
|
177
|
+
"replacement": "{runtime-memory}/$1",
|
|
178
|
+
"description": "Runtime memory"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"pattern": "\\{project-root\\}/_bmad/bmb-creations",
|
|
182
|
+
"replacement": "{output-folder}/bmb-creations",
|
|
183
|
+
"description": "bmb-creations output folder"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"pattern": "\\{project-root\\}/_bmad/core/tasks/([^/\\s'\"]+\\.xml)",
|
|
187
|
+
"replacement": "{skill-root}/core/tasks/$1",
|
|
188
|
+
"description": "Core tasks XML files"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"pattern": "\\{project-root\\}/_bmad/(bmm|bmb|core)/tasks/([^/\\s'\"]+)",
|
|
192
|
+
"replacement": "{skill-root}/$1/tasks/$2",
|
|
193
|
+
"description": "Module tasks"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"pattern": "\\{project-root\\}/_data/([^/\\s'\"]+)",
|
|
197
|
+
"replacement": "{project-data}/$1",
|
|
198
|
+
"description": "Project data files"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"pattern": "\\{project-root\\}/src/modules/(bmm|bmb|core)/workflows/(?:\\d-[^/]+/)?([^/\\s'\"]+)",
|
|
202
|
+
"replacement": "{skill-root}/$1/$2",
|
|
203
|
+
"description": "src/modules workflow refs"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"pattern": "\\{project-root\\}/src/modules/bmb/workflows/([^/\\s'\"]+)/(steps-[^/]+)/([^/\\s'\"]+)",
|
|
207
|
+
"replacement": "{skill-root}/bmb/$1/$2/$3",
|
|
208
|
+
"description": "src/modules BMB step refs"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"pattern": "\\{project-root\\}/_bmad/cis/workflows/([^/\\s'\"]+)/workflow\\.(yaml|md|xml)",
|
|
212
|
+
"replacement": "{skill-root}/cis/$1/SKILL.md",
|
|
213
|
+
"description": "CIS workflow files"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"pattern": "\\{project-root\\}/_bmad/(bmm|bmb|core|cis)/workflows/([a-z][-a-z0-9]+)(?=['\\s`]|$)",
|
|
217
|
+
"replacement": "{skill-root}/$1/$2",
|
|
218
|
+
"description": "Generic workflow fallback (only when no extra path segment)"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"pattern": "\\{project-root\\}/_bmad/\\{module-code\\}/workflows/",
|
|
222
|
+
"replacement": "{skill-root}/{module-code}/",
|
|
223
|
+
"description": "Template {module-code}"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"pattern": "\\{project-root\\}/_bmad/\\{module-id\\}/workflows/",
|
|
227
|
+
"replacement": "{skill-root}/{module-id}/",
|
|
228
|
+
"description": "Template {module-id}"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"pattern": "\\{project-root\\}/_bmad/\\{module\\}/",
|
|
232
|
+
"replacement": "{skill-root}/{module}/",
|
|
233
|
+
"description": "Template {module}"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"pattern": "\\{project-root\\}/_bmad/\\{module_code\\}/workflows/",
|
|
237
|
+
"replacement": "{skill-root}/{module_code}/",
|
|
238
|
+
"description": "Template {module_code}"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"pattern": "\\{project-root\\}/_bmad/\\[module\\]/",
|
|
242
|
+
"replacement": "{skill-root}/[module]/",
|
|
243
|
+
"description": "Template [module]"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"pattern": "\\{project-root\\}/_bmad/\\[module-path\\]/workflows/",
|
|
247
|
+
"replacement": "{skill-root}/[module-path]/",
|
|
248
|
+
"description": "Template [module-path]"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"pattern": "\\{project-root\\}/_bmad/\\[MODULE FOLDER\\]/",
|
|
252
|
+
"replacement": "{skill-root}/[MODULE FOLDER]/",
|
|
253
|
+
"description": "Template [MODULE FOLDER]"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"pattern": "\\{project-root\\}/\\.\\.\\./([^/\\s'\"]+)/workflow\\.(yaml|md|xml)",
|
|
257
|
+
"replacement": "{skill-root}/.../$1/SKILL.md",
|
|
258
|
+
"description": "Ellipsis workflow in docs"
|
|
259
|
+
},
|
|
107
260
|
{
|
|
108
261
|
"pattern": "\\{project-root\\}/_bmad/\\.\\.\\./",
|
|
109
262
|
"replacement": "{skill-root}/.../",
|
|
110
|
-
"description": "Ellipsis in documentation
|
|
263
|
+
"description": "Ellipsis in documentation"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"pattern": "\\{project-root\\}/_bmad/core/workflows/\\{workflow-name\\}/",
|
|
267
|
+
"replacement": "{skill-root}/core/{workflow-name}/",
|
|
268
|
+
"description": "Template {workflow-name}"
|
|
111
269
|
}
|
|
112
270
|
]
|
|
113
|
-
}
|
|
271
|
+
}
|
package/convert.js
CHANGED
|
@@ -53,7 +53,7 @@ output_folder: "_bmad-output"
|
|
|
53
53
|
/**
|
|
54
54
|
* Get module-specific config content
|
|
55
55
|
* Checks BMAD repo for config-template.yaml first, falls back to defaults
|
|
56
|
-
* @param {string} moduleName - Module name (core, bmm
|
|
56
|
+
* @param {string} moduleName - Module name (core, bmm)
|
|
57
57
|
* @param {string|null} bmadRoot - Optional path to BMAD repo for template lookup
|
|
58
58
|
* @returns {Promise<string>} YAML config content
|
|
59
59
|
*/
|
|
@@ -438,6 +438,7 @@ async function main() {
|
|
|
438
438
|
await writeSkill(outputDir, agent.module, agent.name, skillContent, {
|
|
439
439
|
skillMap,
|
|
440
440
|
pathPatterns: config.pathPatterns,
|
|
441
|
+
skillMapOptions: config.skillMap || {},
|
|
441
442
|
});
|
|
442
443
|
stats.agents.converted++;
|
|
443
444
|
console.log(` ✓ ${agent.module}/${agent.name}`);
|
|
@@ -482,6 +483,7 @@ async function main() {
|
|
|
482
483
|
workflowDir: workflow.workflowDir,
|
|
483
484
|
skillMap,
|
|
484
485
|
pathPatterns: config.pathPatterns,
|
|
486
|
+
skillMapOptions: config.skillMap || {},
|
|
485
487
|
}
|
|
486
488
|
);
|
|
487
489
|
stats.workflows.converted++;
|
|
@@ -97,20 +97,15 @@ Migrated resources are processed recursively. Any text-based files within these
|
|
|
97
97
|
|
|
98
98
|
## Path Rewriting
|
|
99
99
|
|
|
100
|
-
To make skills portable, path rewriting uses a dynamic map of
|
|
101
|
-
|
|
102
|
-
- **
|
|
103
|
-
- **
|
|
104
|
-
- **
|
|
105
|
-
- **
|
|
106
|
-
- **Skill
|
|
107
|
-
- **
|
|
108
|
-
- **
|
|
109
|
-
- Cross-Skill: `{skill-root}/{module}/{skill}/SKILL.md`
|
|
110
|
-
- Resources: `{skill-root}/{module}/{skill}/data/...`
|
|
111
|
-
- Excalidraw core: `{skill-root}/core/resources/excalidraw/...`
|
|
112
|
-
- Excalidraw shared: `{skill-root}/bmm/excalidraw-diagrams/_shared/...` (templates, library)
|
|
113
|
-
- **Migrated Resources**: Paths to migrated files are updated to their new locations.
|
|
100
|
+
To make skills portable, path rewriting uses **config-driven regex patterns** plus a dynamic map of discovered skills:
|
|
101
|
+
|
|
102
|
+
- **Source of truth**: All path-rewrite rules are defined in `config.json` under `pathPatterns`. Each entry has `pattern` (regex string), `replacement`, and optional `description`. Order in the array matters—specific rules (e.g. init, document-project) must come before generic ones.
|
|
103
|
+
- **skillMap options**: The dynamic skillMap block (exact file and directory rewrites from discovered agents/workflows) uses `config.skillMap`: `sourcePrefix` (regex fragment for `{project-root}/_bmad/`), `dirLookahead` (lookahead so directory matches don’t over-match, e.g. space/quote/backtick or end), and `replacementPrefix` (e.g. `{skill-root}`). Omit `skillMap` to use built-in defaults.
|
|
104
|
+
- **Pattern optimization**: Regexes are pre-compiled at startup for performance.
|
|
105
|
+
- **Exact skill resolution**: A `skillMap` of discovered agents/workflows is applied after `pathPatterns` to resolve exact source paths to destination skills.
|
|
106
|
+
- **Skill root variable**: Output uses `{skill-root}` instead of fragile relative paths.
|
|
107
|
+
- **Standardized paths** (from `pathPatterns`): Cross-skill `{skill-root}/{module}/{skill}/SKILL.md`; resources under `data/`; Excalidraw under `core/resources/excalidraw/` and `bmm/excalidraw-diagrams/_shared/`.
|
|
108
|
+
- **Migrated resources**: Paths inside files migrated via `auxiliaryResources` are rewritten using the same `pathPatterns`.
|
|
114
109
|
|
|
115
110
|
This ensures skills work correctly regardless of where the root `skills` directory is installed and that cross-skill references are robust.
|
|
116
111
|
|
package/package.json
CHANGED
|
@@ -90,6 +90,5 @@ Reference for detecting and transforming path patterns in BMAD-converted skills.
|
|
|
90
90
|
| BMAD Module | Skills Location | Notes |
|
|
91
91
|
|-------------|-----------------|-------|
|
|
92
92
|
| `bmm` | `skills/bmm/` | Main method modules |
|
|
93
|
-
| `bmb` | `skills/bmb/` | Builder modules |
|
|
94
93
|
| `core` | `skills/core/` | Core workflows |
|
|
95
94
|
| `cis` | N/A | Not converted - reference as external |
|
|
@@ -7,18 +7,22 @@
|
|
|
7
7
|
* Rewrite BMAD paths in content to relative skill paths
|
|
8
8
|
* @param {string} content - File content to process
|
|
9
9
|
* @param {Map|null} skillMap - Map of source paths to destination skill info
|
|
10
|
-
* @param {Array|null} pathPatterns - Array of {pattern,
|
|
10
|
+
* @param {Array|null} pathPatterns - Array of {pattern, replacement, description?} from config.json pathPatterns (source of truth for all regex rewrites)
|
|
11
|
+
* @param {Object} [skillMapOptions] - From config.json skillMap: { sourcePrefix, dirLookahead, replacementPrefix } for the dynamic skillMap block
|
|
11
12
|
* @returns {string} Content with rewritten paths
|
|
12
13
|
*/
|
|
13
14
|
export function rewriteBmadPaths(
|
|
14
15
|
content,
|
|
15
16
|
skillMap = null,
|
|
16
|
-
pathPatterns = null
|
|
17
|
+
pathPatterns = null,
|
|
18
|
+
skillMapOptions = {}
|
|
17
19
|
) {
|
|
18
20
|
let result = content;
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
+
const opts = skillMapOptions || {};
|
|
23
|
+
const sourcePrefix = opts.sourcePrefix ?? '\\{project-root\\}/_bmad/';
|
|
24
|
+
const dirLookahead = opts.dirLookahead ?? "(?=['\\s`]|$)";
|
|
25
|
+
const replacementPrefix = opts.replacementPrefix ?? '{skill-root}';
|
|
22
26
|
|
|
23
27
|
// === CONFIG-DRIVEN PATTERNS (Applied First) ===
|
|
24
28
|
if (pathPatterns && pathPatterns.length > 0) {
|
|
@@ -48,10 +52,10 @@ export function rewriteBmadPaths(
|
|
|
48
52
|
// Pattern: {project-root}/_bmad/{srcPath}
|
|
49
53
|
// srcPath is now normalized by convert.js
|
|
50
54
|
const escapedPath = srcPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
51
|
-
const regex = new RegExp(
|
|
55
|
+
const regex = new RegExp(`${sourcePrefix}${escapedPath}`, 'g');
|
|
52
56
|
result = result.replace(
|
|
53
57
|
regex,
|
|
54
|
-
`${
|
|
58
|
+
`${replacementPrefix}/${module}/${name}/SKILL.md`
|
|
55
59
|
);
|
|
56
60
|
}
|
|
57
61
|
|
|
@@ -64,271 +68,14 @@ export function rewriteBmadPaths(
|
|
|
64
68
|
for (const srcDir of sortedDirs) {
|
|
65
69
|
const { module, name } = dirMap.get(srcDir);
|
|
66
70
|
const escapedDir = srcDir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
67
|
-
// Look for directory path not followed by / (to avoid replacing parents of nested files that weren't caught?)
|
|
68
|
-
// Actually, if we replaced files first, the only things left starting with this dir are directory references or other files.
|
|
69
71
|
const regex = new RegExp(
|
|
70
|
-
|
|
72
|
+
`${sourcePrefix}${escapedDir}${dirLookahead}`,
|
|
71
73
|
'g'
|
|
72
74
|
);
|
|
73
|
-
result = result.replace(regex, `${
|
|
75
|
+
result = result.replace(regex, `${replacementPrefix}/${module}/${name}`);
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
// === SPECIFIC EXCEPTIONS (Must run before generic patterns) ===
|
|
78
|
-
|
|
79
|
-
// Rewrite init nested workflow references
|
|
80
|
-
// Must run BEFORE workflow-status directory rewrite
|
|
81
|
-
result = result.replace(
|
|
82
|
-
/\{project-root\}\/_bmad\/bmm\/workflows\/workflow-status\/init\/workflow\.(yaml|md)/g,
|
|
83
|
-
`${relativePrefix}/bmm/init/SKILL.md`
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// Rewrite document-project workflow references
|
|
87
|
-
result = result.replace(
|
|
88
|
-
/\{project-root\}\/_bmad\/bmm\/workflows\/document-project\/workflows/g,
|
|
89
|
-
`${relativePrefix}/bmm/document-project`
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
// Rewrite core workflow references
|
|
93
|
-
// {project-root}/_bmad/core/workflows/{name}/workflow.* -> ../../core/{name}/SKILL.md
|
|
94
|
-
result = result.replace(
|
|
95
|
-
/\{project-root\}\/_bmad\/core\/workflows\/([^/\s'"]+)\/workflow\.(yaml|md|xml)/g,
|
|
96
|
-
`${relativePrefix}/core/$1/SKILL.md`
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
// Rewrite bmm workflow references (handles nested category folders)
|
|
100
|
-
// {project-root}/_bmad/bmm/workflows/{category}/{name}/workflow.* -> ../../bmm/{name}/SKILL.md
|
|
101
|
-
// {project-root}/_bmad/bmm/workflows/{name}/workflow.* -> ../../bmm/{name}/SKILL.md
|
|
102
|
-
result = result.replace(
|
|
103
|
-
/\{project-root\}\/_bmad\/bmm\/workflows\/(?:\d-[^/]+\/)?([^/\s'"]+)\/workflow\.(yaml|md|xml)/g,
|
|
104
|
-
`${relativePrefix}/bmm/$1/SKILL.md`
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
// Rewrite bmb workflow references
|
|
108
|
-
// {project-root}/_bmad/bmb/workflows/{name}/workflow.* -> ../../bmb/{name}/SKILL.md
|
|
109
|
-
result = result.replace(
|
|
110
|
-
/\{project-root\}\/_bmad\/bmb\/workflows\/([^/\s'"]+)\/workflow\.(yaml|md|xml)/g,
|
|
111
|
-
`${relativePrefix}/bmb/$1/SKILL.md`
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
// Rewrite testarch workflow references (bmm/testarch/{name}/workflow.* or bmm/workflows/testarch/...)
|
|
115
|
-
result = result.replace(
|
|
116
|
-
/\{project-root\}\/_bmad\/bmm\/(?:workflows\/)?testarch\/([^/\s'"]+)\/workflow\.(yaml|md|xml)/g,
|
|
117
|
-
`${relativePrefix}/bmm/testarch-$1/SKILL.md`
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
// Rewrite excalidraw-diagrams workflow references
|
|
121
|
-
result = result.replace(
|
|
122
|
-
/\{project-root\}\/_bmad\/bmm\/workflows\/excalidraw-diagrams\/([^/\s'"]+)\/workflow\.(yaml|md|xml)/g,
|
|
123
|
-
`${relativePrefix}/bmm/$1/SKILL.md`
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
// Rewrite bmad-quick-flow workflow references
|
|
127
|
-
result = result.replace(
|
|
128
|
-
/\{project-root\}\/_bmad\/bmm\/workflows\/bmad-quick-flow\/([^/\s'"]+)\/workflow\.(yaml|md)/g,
|
|
129
|
-
`${relativePrefix}/bmm/$1/SKILL.md`
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
// Rewrite core tasks reference (special case)
|
|
133
|
-
// {project-root}/_bmad/core/tasks/workflow.xml -> ../../core/tasks/SKILL.md
|
|
134
|
-
result = result.replace(
|
|
135
|
-
/\{project-root\}\/_bmad\/core\/tasks\/workflow\.xml/g,
|
|
136
|
-
`${relativePrefix}/core/tasks/SKILL.md`
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
// Rewrite references to specific files within workflows
|
|
140
|
-
// {project-root}/_bmad/*/workflows/*/{file} -> ../../{module}/{name}/{file}
|
|
141
|
-
result = result.replace(
|
|
142
|
-
/\{project-root\}\/_bmad\/(core|bmm|bmb)\/workflows\/(?:\d-[^/]+\/)?([^/\s'"]+)\/([^/\s'"]+\.(md|csv|yaml|xml))/g,
|
|
143
|
-
`${relativePrefix}/$1/$2/$3`
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
// Rewrite step file references within workflows
|
|
147
|
-
// {project-root}/_bmad/*/workflows/*/steps/{file} -> ../../{module}/{name}/steps/{file}
|
|
148
|
-
result = result.replace(
|
|
149
|
-
/\{project-root\}\/_bmad\/(core|bmm|bmb)\/workflows\/(?:\d-[^/]+\/)?([^/\s'"]+)\/steps\/([^/\s'"]+)/g,
|
|
150
|
-
`${relativePrefix}/$1/$2/steps/$3`
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
// Rewrite bmb workflow step file references
|
|
154
|
-
// {project-root}/_bmad/bmb/workflows/{name}/steps-*/step-*.md -> ../../bmb/{name}/steps-*/{file}
|
|
155
|
-
result = result.replace(
|
|
156
|
-
/\{project-root\}\/_bmad\/bmb\/workflows\/([^/\s'"]+)\/(steps-[^/]+)\/([^/\s'"]+)/g,
|
|
157
|
-
`${relativePrefix}/bmb/$1/$2/$3`
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
// Rewrite directory references (without workflow.* at end)
|
|
161
|
-
// {project-root}/_bmad/bmm/workflows/{category}/{name} -> ../../bmm/{name}
|
|
162
|
-
result = result.replace(
|
|
163
|
-
/\{project-root\}\/_bmad\/bmm\/workflows\/\d-[^/]+\/([^/\s'"]+)(?=['\s`])/g,
|
|
164
|
-
`${relativePrefix}/bmm/$1`
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
// {project-root}/_bmad/bmm/workflows/{name} (without trailing /) -> ../../bmm/{name}
|
|
168
|
-
result = result.replace(
|
|
169
|
-
/\{project-root\}\/_bmad\/bmm\/workflows\/([a-z][-a-z0-9]+)(?=['\s`])/g,
|
|
170
|
-
`${relativePrefix}/bmm/$1`
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
// Rewrite bmad-quick-flow directory references
|
|
174
|
-
result = result.replace(
|
|
175
|
-
/\{project-root\}\/_bmad\/bmm\/workflows\/bmad-quick-flow\/([^/\s'"]+)(?=['\s`])/g,
|
|
176
|
-
`${relativePrefix}/bmm/$1`
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
// Rewrite testarch directory references
|
|
180
|
-
result = result.replace(
|
|
181
|
-
/\{project-root\}\/_bmad\/bmm\/workflows\/testarch\/([^/\s'"]+)(?=['\s`])/g,
|
|
182
|
-
`${relativePrefix}/bmm/testarch-$1`
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
// Rewrite workflow-status directory references
|
|
186
|
-
result = result.replace(
|
|
187
|
-
/\{project-root\}\/_bmad\/bmm\/workflows\/workflow-status(?=['\s`/])/g,
|
|
188
|
-
`${relativePrefix}/bmm/workflow-status`
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
// Rewrite config.yaml references (module-level config)
|
|
192
|
-
// {project-root}/_bmad/{module}/config.yaml -> {skill-root}/{module}/config.yaml
|
|
193
|
-
result = result.replace(
|
|
194
|
-
/\{project-root\}\/_bmad\/(bmm|bmb|core)\/config\.yaml/g,
|
|
195
|
-
'{skill-root}/$1/config.yaml'
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
// Rewrite agent manifest references
|
|
199
|
-
result = result.replace(
|
|
200
|
-
/\{project-root\}\/_bmad\/_config\/agent-manifest\.csv/g,
|
|
201
|
-
'{skill-root}/agent-manifest.csv'
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
// Rewrite testarch tea-index.csv references
|
|
205
|
-
result = result.replace(
|
|
206
|
-
/\{project-root\}\/_bmad\/bmm\/testarch\/tea-index\.csv/g,
|
|
207
|
-
`${relativePrefix}/bmm/tea/tea-index.csv`
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
// Rewrite documentation-standards.md references (migrated to tech-writer/data)
|
|
211
|
-
// {project-root}/_bmad/bmm/data/documentation-standards.md -> ../../bmm/tech-writer/data/documentation-standards.md
|
|
212
|
-
// But wait, if we are IN tech-writer, it should be ./data/documentation-standards.md
|
|
213
|
-
// The relativePrefix logic handles ../.. but we might prefer a direct replacement here
|
|
214
|
-
// since it's a specific file.
|
|
215
|
-
// Let's rely on the generic ../..bmm/tech-writer/data approach which works from anywhere.
|
|
216
|
-
result = result.replace(
|
|
217
|
-
/\{project-root\}\/_bmad\/bmm\/data\/documentation-standards\.md/g,
|
|
218
|
-
`${relativePrefix}/bmm/tech-writer/data/documentation-standards.md`
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
// Rewrite _memory sidecar references (these are runtime, mark as placeholder)
|
|
222
|
-
result = result.replace(
|
|
223
|
-
/\{project-root\}\/_bmad\/_memory\/([^/\s'"]+)/g,
|
|
224
|
-
'{runtime-memory}/$1'
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
// Rewrite bmb-creations references (these are output folders)
|
|
228
|
-
result = result.replace(
|
|
229
|
-
/\{project-root\}\/_bmad\/bmb-creations/g,
|
|
230
|
-
'{output-folder}/bmb-creations'
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
// Rewrite core tasks file references (specific XML files)
|
|
234
|
-
result = result.replace(
|
|
235
|
-
/\{project-root\}\/_bmad\/core\/tasks\/([^/\s'"]+\\.xml)/g,
|
|
236
|
-
`${relativePrefix}/core/tasks/$1`
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
// Rewrite tasks references (bmm/tasks/*, bmb/tasks/*)
|
|
240
|
-
result = result.replace(
|
|
241
|
-
/\{project-root\}\/_bmad\/(bmm|bmb|core)\/tasks\/([^/\s'"]+)/g,
|
|
242
|
-
`${relativePrefix}/$1/tasks/$2`
|
|
243
|
-
);
|
|
244
|
-
|
|
245
|
-
// Rewrite _data references (project data files)
|
|
246
|
-
result = result.replace(
|
|
247
|
-
/\{project-root\}\/_data\/([^/\s'"]+)/g,
|
|
248
|
-
'{project-data}/$1'
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
// Rewrite src/modules references (raw source paths)
|
|
252
|
-
result = result.replace(
|
|
253
|
-
/\{project-root\}\/src\/modules\/(bmm|bmb|core)\/workflows\/(?:\d-[^/]+\/)?([^/\s'"]+)/g,
|
|
254
|
-
`${relativePrefix}/$1/$2`
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
// Rewrite src/modules agent step references
|
|
258
|
-
result = result.replace(
|
|
259
|
-
/\{project-root\}\/src\/modules\/bmb\/workflows\/([^/\s'"]+)\/(steps-[^/]+)\/([^/\s'"]+)/g,
|
|
260
|
-
`${relativePrefix}/bmb/$1/$2/$3`
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
// Rewrite cis workflow references (if any)
|
|
264
|
-
result = result.replace(
|
|
265
|
-
/\{project-root\}\/_bmad\/cis\/workflows\/([^/\s'"]+)\/workflow\.(yaml|md|xml)/g,
|
|
266
|
-
`${relativePrefix}/cis/$1/SKILL.md`
|
|
267
|
-
);
|
|
268
|
-
|
|
269
|
-
// Generic fallback: Any remaining {project-root}/_bmad/{module}/workflows/{name}
|
|
270
|
-
result = result.replace(
|
|
271
|
-
/\{project-root\}\/_bmad\/(bmm|bmb|core|cis)\/workflows\/([a-z][-a-z0-9]+)/g,
|
|
272
|
-
`${relativePrefix}/$1/$2`
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
// === Template Placeholder Patterns ===
|
|
276
|
-
// These handle paths with template variables like {module}, {module-code}, [module], etc.
|
|
277
|
-
|
|
278
|
-
// Handle {project-root}/_bmad/{module-code}/workflows/...
|
|
279
|
-
result = result.replace(
|
|
280
|
-
/\{project-root\}\/_bmad\/\{module-code\}\/workflows\//g,
|
|
281
|
-
`${relativePrefix}/{module-code}/`
|
|
282
|
-
);
|
|
283
|
-
|
|
284
|
-
// Handle {project-root}/_bmad/{module-id}/workflows/...
|
|
285
|
-
result = result.replace(
|
|
286
|
-
/\{project-root\}\/_bmad\/\{module-id\}\/workflows\//g,
|
|
287
|
-
`${relativePrefix}/{module-id}/`
|
|
288
|
-
);
|
|
289
|
-
|
|
290
|
-
// Handle {project-root}/_bmad/{module}/... (generic module placeholder)
|
|
291
|
-
result = result.replace(
|
|
292
|
-
/\{project-root\}\/_bmad\/\{module\}\//g,
|
|
293
|
-
`${relativePrefix}/{module}/`
|
|
294
|
-
);
|
|
295
|
-
|
|
296
|
-
// Handle {project-root}/_bmad/{module_code}/workflows/...
|
|
297
|
-
result = result.replace(
|
|
298
|
-
/\{project-root\}\/_bmad\/\{module_code\}\/workflows\//g,
|
|
299
|
-
`${relativePrefix}/{module_code}/`
|
|
300
|
-
);
|
|
301
|
-
|
|
302
|
-
// Handle {project-root}/_bmad/[module]/... (bracket notation)
|
|
303
|
-
result = result.replace(
|
|
304
|
-
/\{project-root\}\/_bmad\/\[module\]\//g,
|
|
305
|
-
`${relativePrefix}/[module]/`
|
|
306
|
-
);
|
|
307
|
-
|
|
308
|
-
// Handle {project-root}/_bmad/[module-path]/workflows/...
|
|
309
|
-
result = result.replace(
|
|
310
|
-
/\{project-root\}\/_bmad\/\[module-path\]\/workflows\//g,
|
|
311
|
-
`${relativePrefix}/[module-path]/`
|
|
312
|
-
);
|
|
313
|
-
|
|
314
|
-
// Handle {project-root}/_bmad/[MODULE FOLDER]/...
|
|
315
|
-
result = result.replace(
|
|
316
|
-
/\{project-root\}\/_bmad\/\[MODULE FOLDER\]\//g,
|
|
317
|
-
`${relativePrefix}/[MODULE FOLDER]/`
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
// Handle {project-root}/.../ ellipsis patterns (documentation examples)
|
|
321
|
-
result = result.replace(
|
|
322
|
-
/\{project-root\}\/\.\.\.\/([^/\s'"]+)\/workflow\.(yaml|md|xml)/g,
|
|
323
|
-
`${relativePrefix}/.../$1/SKILL.md`
|
|
324
|
-
);
|
|
325
|
-
|
|
326
|
-
// Handle {project-root}/_bmad/core/workflows/{workflow-name}/...
|
|
327
|
-
result = result.replace(
|
|
328
|
-
/\{project-root\}\/_bmad\/core\/workflows\/\{workflow-name\}\//g,
|
|
329
|
-
`${relativePrefix}/core/{workflow-name}/`
|
|
330
|
-
);
|
|
331
|
-
|
|
332
79
|
return result;
|
|
333
80
|
}
|
|
334
81
|
|
|
@@ -50,7 +50,8 @@ export async function writeSkill(
|
|
|
50
50
|
const rewrittenContent = rewriteBmadPaths(
|
|
51
51
|
skillContent,
|
|
52
52
|
options.skillMap,
|
|
53
|
-
options.pathPatterns
|
|
53
|
+
options.pathPatterns,
|
|
54
|
+
options.skillMapOptions
|
|
54
55
|
);
|
|
55
56
|
|
|
56
57
|
// Write SKILL.md
|
|
@@ -64,7 +65,8 @@ export async function writeSkill(
|
|
|
64
65
|
skillDir,
|
|
65
66
|
module,
|
|
66
67
|
options.skillMap,
|
|
67
|
-
options.pathPatterns
|
|
68
|
+
options.pathPatterns,
|
|
69
|
+
options.skillMapOptions
|
|
68
70
|
);
|
|
69
71
|
} catch (copyError) {
|
|
70
72
|
console.warn(
|
|
@@ -95,7 +97,8 @@ async function copyDirectoryWithPathRewrite(
|
|
|
95
97
|
destDir,
|
|
96
98
|
module,
|
|
97
99
|
skillMap,
|
|
98
|
-
pathPatterns
|
|
100
|
+
pathPatterns,
|
|
101
|
+
skillMapOptions
|
|
99
102
|
) {
|
|
100
103
|
const entries = await fs.readdir(srcDir, { withFileTypes: true });
|
|
101
104
|
|
|
@@ -130,7 +133,8 @@ async function copyDirectoryWithPathRewrite(
|
|
|
130
133
|
destPath,
|
|
131
134
|
module,
|
|
132
135
|
skillMap,
|
|
133
|
-
pathPatterns
|
|
136
|
+
pathPatterns,
|
|
137
|
+
skillMapOptions
|
|
134
138
|
);
|
|
135
139
|
} else if (shouldRewritePaths(entry.name)) {
|
|
136
140
|
// Read, rewrite paths, and write text files
|
|
@@ -138,7 +142,8 @@ async function copyDirectoryWithPathRewrite(
|
|
|
138
142
|
const rewrittenContent = rewriteBmadPaths(
|
|
139
143
|
content,
|
|
140
144
|
skillMap,
|
|
141
|
-
pathPatterns
|
|
145
|
+
pathPatterns,
|
|
146
|
+
skillMapOptions
|
|
142
147
|
);
|
|
143
148
|
await fs.writeFile(destPath, rewrittenContent, 'utf-8');
|
|
144
149
|
} else {
|