@aiwg/cli 2026.10.16 → 2026.10.19
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/agentic/code/providers/capability-matrix.yaml +51 -0
- package/agentic/code/providers/flue/README.md +62 -0
- package/agentic/code/providers/flue/templates/aiwg/tools.ts +120 -0
- package/agentic/code/providers/model-capabilities.v1.json +23 -0
- package/agentic/code/providers/model-catalog.v1.json +9 -0
- package/dist/src/artifacts/corpus-tools/resolve.js +28 -6
- package/dist/src/artifacts/query-engine-corpus.js +217 -0
- package/dist/src/artifacts/query-engine-discover-output.js +229 -0
- package/dist/src/artifacts/query-engine-discover.js +285 -0
- package/dist/src/artifacts/query-engine-entries.js +188 -0
- package/dist/src/artifacts/query-engine-index.js +249 -0
- package/dist/src/artifacts/query-engine-matching.js +143 -0
- package/dist/src/artifacts/query-engine-options.js +2 -0
- package/dist/src/artifacts/query-engine-rules.js +202 -0
- package/dist/src/artifacts/query-engine-scoring.js +436 -0
- package/dist/src/artifacts/query-engine-show-card.js +194 -0
- package/dist/src/artifacts/query-engine-show-load.js +211 -0
- package/dist/src/artifacts/query-engine-show.js +300 -0
- package/dist/src/artifacts/query-engine.js +7 -2576
- package/dist/src/cli/handlers/help.js +1 -1
- package/dist/src/cli/handlers/init.js +1 -0
- package/dist/src/cli/handlers/mc-agents.js +111 -0
- package/dist/src/cli/handlers/mc-args.js +54 -0
- package/dist/src/cli/handlers/mc-control.js +227 -0
- package/dist/src/cli/handlers/mc-dispatch.js +203 -0
- package/dist/src/cli/handlers/mc-help.js +171 -0
- package/dist/src/cli/handlers/mc-run.js +343 -0
- package/dist/src/cli/handlers/mc-session.js +138 -0
- package/dist/src/cli/handlers/mc-status.js +258 -0
- package/dist/src/cli/handlers/mc-summary.js +43 -0
- package/dist/src/cli/handlers/mc-types.js +3 -0
- package/dist/src/cli/handlers/mc-worker.js +205 -0
- package/dist/src/cli/handlers/mc.js +12 -1665
- package/dist/src/cli/handlers/models-refusal.js +13 -0
- package/dist/src/cli/handlers/models.js +2 -1
- package/dist/src/cli/handlers/remove-bundled.js +133 -0
- package/dist/src/cli/handlers/remove-options.js +31 -0
- package/dist/src/cli/handlers/remove-user.js +174 -0
- package/dist/src/cli/handlers/remove.js +201 -0
- package/dist/src/cli/handlers/subcommands-bundles.js +257 -0
- package/dist/src/cli/handlers/subcommands-discovery.js +165 -0
- package/dist/src/cli/handlers/subcommands-list-format.js +129 -0
- package/dist/src/cli/handlers/subcommands-list.js +250 -0
- package/dist/src/cli/handlers/subcommands-plugins.js +213 -0
- package/dist/src/cli/handlers/subcommands-quickref.js +58 -0
- package/dist/src/cli/handlers/subcommands-rlm.js +113 -0
- package/dist/src/cli/handlers/subcommands-services.js +66 -0
- package/dist/src/cli/handlers/subcommands-storage.js +259 -0
- package/dist/src/cli/handlers/subcommands.js +18 -1984
- package/dist/src/cli/handlers/use.js +11 -5
- package/dist/src/cli/scope-resolver.js +1 -142
- package/dist/src/cli/services/deployment-verification.js +3 -0
- package/dist/src/cli/user-scope-mirror.js +173 -0
- package/dist/src/config/dispatch-host-thresholds.js +2 -0
- package/dist/src/config/dispatch-thresholds-runtime.mjs +4 -0
- package/dist/src/config/host-resource-report.d.mts +5 -0
- package/dist/src/config/host-resource-report.mjs +36 -6
- package/dist/src/config/host-resource-runtime.d.mts +3 -0
- package/dist/src/config/host-resource-runtime.mjs +9 -6
- package/dist/src/decision/ensemble-study/artifacts.js +7 -0
- package/dist/src/decision/ensemble-study/gate-policy.js +58 -0
- package/dist/src/decision/ensemble-study/gates.js +78 -0
- package/dist/src/decision/ensemble-study/protocol.js +18 -21
- package/dist/src/decision/ensemble-study/score.js +3 -2
- package/dist/src/decision/ensemble-study/statistics.js +7 -26
- package/dist/src/decision/sensitivity/comparative-gates.js +135 -0
- package/dist/src/decision/sensitivity/comparative.js +18 -41
- package/dist/src/extensions/claude-hooks-installer.js +18 -0
- package/dist/src/gates/evaluate.js +2 -358
- package/dist/src/gates/observations.js +363 -0
- package/dist/src/gates/pack-composition.js +270 -0
- package/dist/src/gates/pack-tightening.js +197 -0
- package/dist/src/gates/pack-validation.js +262 -0
- package/dist/src/gates/registry-error.js +5 -0
- package/dist/src/gates/registry.js +13 -685
- package/dist/src/mcp/json-document.mjs +29 -0
- package/dist/src/mcp/muse-native-config.mjs +1 -28
- package/dist/src/memory/provider-memory-adapter.js +1 -0
- package/dist/src/mission-protocol/worker-review-gate.js +7 -0
- package/dist/src/models/model-capabilities.v1.json +23 -0
- package/dist/src/models/model-catalog.v1.json +9 -0
- package/dist/src/models/policy-resources.js +1 -1
- package/dist/src/models/worker-plan.js +5 -5
- package/dist/src/plugin/command-ownership.js +34 -0
- package/dist/src/plugin/skill-command-frontmatter.js +197 -0
- package/dist/src/plugin/skill-command-translator.js +6 -232
- package/dist/src/providers/capability-matrix.yaml +51 -0
- package/dist/src/providers/context-output-ownership.js +26 -0
- package/dist/src/providers/deployment-ownership.d.mts +20 -0
- package/dist/src/providers/deployment-ownership.mjs +236 -0
- package/dist/src/providers/deployment-removal.js +222 -0
- package/dist/src/providers/provider-context-contracts.js +8 -0
- package/dist/src/providers/provider-definition-schema.js +1 -0
- package/dist/src/providers/provider-definitions.js +1 -0
- package/dist/src/providers/provider-seeds-3.js +18 -0
- package/dist/src/providers/removal-transaction.js +86 -0
- package/dist/src/providers/settings-document.d.mts +3 -0
- package/dist/src/providers/settings-document.mjs +47 -0
- package/dist/src/providers/settings-removal.js +190 -0
- package/dist/src/providers/skill-ownership.d.mts +20 -2
- package/dist/src/providers/skill-ownership.mjs +12 -4
- package/dist/src/providers/transformation-receipt-integration.js +15 -271
- package/dist/src/providers/transformation-receipt-outputs.js +99 -0
- package/dist/src/providers/transformation-receipt-source.js +194 -0
- package/dist/src/research/identity.js +8 -2
- package/dist/src/research/reference-match.js +66 -8
- package/dist/src/rules/activation.mjs +15 -6
- package/dist/src/rules/core-startup.mjs +2 -2
- package/dist/src/serve/mission-conductor.js +4 -0
- package/dist/src/serve/mission-summary.js +56 -0
- package/dist/src/skills/deployment-ownership.js +2 -2
- package/dist/src/skills/deployment-policy.js +9 -0
- package/dist/src/smiths/context-pipeline/aiwg-md.js +23 -0
- package/dist/src/smiths/context-pipeline/context-file-safety.js +3 -0
- package/dist/src/smiths/context-pipeline/flue-context.js +25 -0
- package/dist/src/smiths/context-pipeline/generator.js +7 -2
- package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +9 -7
- package/dist/src/smiths/hook-bridge/index.js +9 -0
- package/package.json +5 -1
- package/schemas/decision/D17StudyProtocol.v1.schema.json +39 -67
- package/tools/agents/deploy-agents.mjs +21 -680
- package/tools/agents/deploy-command-mirrors.mjs +229 -0
- package/tools/agents/deploy-options.mjs +267 -0
- package/tools/agents/deploy-support.mjs +165 -0
- package/tools/agents/providers/base-addon-discovery.mjs +139 -0
- package/tools/agents/providers/base-behaviors.mjs +168 -0
- package/tools/agents/providers/base-context.mjs +205 -0
- package/tools/agents/providers/base-contract.mjs +116 -0
- package/tools/agents/providers/base-files.mjs +252 -0
- package/tools/agents/providers/base-flat-artifacts.mjs +233 -0
- package/tools/agents/providers/base-framework-discovery.mjs +309 -0
- package/tools/agents/providers/base-frontmatter.mjs +196 -0
- package/tools/agents/providers/base-inventory.mjs +269 -0
- package/tools/agents/providers/base-kernel-skills.mjs +354 -0
- package/tools/agents/providers/base-migrations.mjs +258 -0
- package/tools/agents/providers/base-models-platforms.mjs +273 -0
- package/tools/agents/providers/base-rule-index.mjs +450 -0
- package/tools/agents/providers/base-runtime.mjs +60 -0
- package/tools/agents/providers/base-skill-copy.mjs +273 -0
- package/tools/agents/providers/base.mjs +16 -3364
- package/tools/agents/providers/claude-post-deploy.mjs +10 -2
- package/tools/agents/providers/flue-project.mjs +79 -0
- package/tools/agents/providers/flue-specialists.mjs +64 -0
- package/tools/agents/providers/flue.mjs +50 -0
- package/tools/agents/providers/hermes-startup.mjs +0 -5
- package/tools/agents/providers/muse.mjs +7 -2
- package/tools/agents/providers/rule-delivery-surface.mjs +33 -5
- package/tools/agents/providers/rule-deployment-commit.mjs +19 -15
- package/tools/agents/providers/rule-deployment-prepare.mjs +13 -3
- package/tools/agents/providers/rule-projection.mjs +3 -0
- package/tools/agents/providers/rule-startup.mjs +3 -3
- package/tools/agents/use-rule-selection.mjs +17 -0
- package/tools/ralph-external/lib/worker-invocation-processes.mjs +4 -2
- package/tools/ralph-external/lib/worker-termination.mjs +15 -8
- package/vscode-extension/schemas/aiwg.config.v1.json +2 -4
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
// Shared provider framework discovery utilities.
|
|
2
|
+
import { classifyModelRole, fs, path } from './base-runtime.mjs';
|
|
3
|
+
import { parseFrontmatter } from './base-frontmatter.mjs';
|
|
4
|
+
import { listMdFiles, listMdFilesRecursive, listSkillDirs, listSoulFiles } from './base-files.mjs';
|
|
5
|
+
import { getRulesIndexPath, isAlwaysOnRule } from './base-rule-index.mjs';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Agent Filtering
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Check if an agent should be deployed based on filter options
|
|
14
|
+
* @param {string} agentPath - Path to agent file
|
|
15
|
+
* @param {object} metadata - Parsed frontmatter metadata
|
|
16
|
+
* @param {object} opts - Options including filter and filterRole
|
|
17
|
+
* @returns {boolean} - True if agent should be deployed
|
|
18
|
+
*/
|
|
19
|
+
export function shouldDeployAgent(agentPath, metadata, opts) {
|
|
20
|
+
const { filter, filterRole } = opts;
|
|
21
|
+
|
|
22
|
+
// No filters - deploy everything
|
|
23
|
+
if (!filter && !filterRole) return true;
|
|
24
|
+
|
|
25
|
+
// Filter by role (model tier)
|
|
26
|
+
if (filterRole) {
|
|
27
|
+
const role = classifyModelRole(metadata.model, { defaultRole: 'coding' });
|
|
28
|
+
if (role !== filterRole.toLowerCase()) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Filter by glob pattern
|
|
34
|
+
if (filter) {
|
|
35
|
+
const agentName = path.basename(agentPath, '.md');
|
|
36
|
+
if (!matchesGlob(agentName, filter)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Simple glob pattern matching
|
|
47
|
+
* Supports * (match any characters) and ? (match single character)
|
|
48
|
+
* @param {string} str - String to match
|
|
49
|
+
* @param {string} pattern - Glob pattern
|
|
50
|
+
* @returns {boolean} - True if matches
|
|
51
|
+
*/
|
|
52
|
+
export function matchesGlob(str, pattern) {
|
|
53
|
+
// Convert glob to regex
|
|
54
|
+
const regexPattern = pattern
|
|
55
|
+
.replace(/[.+^${}()|[\]\\]/g, '\\$&') // Escape regex special chars except * and ?
|
|
56
|
+
.replace(/\*/g, '.*') // * matches any characters
|
|
57
|
+
.replace(/\?/g, '.'); // ? matches single character
|
|
58
|
+
|
|
59
|
+
const regex = new RegExp(`^${regexPattern}$`, 'i');
|
|
60
|
+
return regex.test(str);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Filter a list of agent files based on filter options
|
|
66
|
+
* @param {string[]} files - List of file paths
|
|
67
|
+
* @param {object} opts - Options including filter and filterRole
|
|
68
|
+
* @returns {string[]} - Filtered list of file paths
|
|
69
|
+
*/
|
|
70
|
+
export function filterAgentFiles(files, opts) {
|
|
71
|
+
const { filter, filterRole } = opts;
|
|
72
|
+
|
|
73
|
+
// No filters - return all
|
|
74
|
+
if (!filter && !filterRole) return files;
|
|
75
|
+
|
|
76
|
+
return files.filter(filePath => {
|
|
77
|
+
// Read and parse frontmatter to get metadata
|
|
78
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
79
|
+
const { metadata } = parseFrontmatter(content);
|
|
80
|
+
return shouldDeployAgent(filePath, metadata, opts);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
// ============================================================================
|
|
86
|
+
// Framework Discovery
|
|
87
|
+
// ============================================================================
|
|
88
|
+
|
|
89
|
+
export const MODE_ALIASES = {
|
|
90
|
+
writing: 'general',
|
|
91
|
+
mmk: 'marketing'
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
export const LEGACY_FRAMEWORK_MODE_ALIASES = {
|
|
96
|
+
'sdlc-complete': ['sdlc'],
|
|
97
|
+
'media-marketing-kit': ['marketing', 'mmk'],
|
|
98
|
+
'media-curator': ['media-curator'],
|
|
99
|
+
'research-complete': ['research']
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
export const DEFAULT_FRAMEWORK_SUBDIRS = {
|
|
104
|
+
'sdlc-complete': ['repo', 'projects', 'working', 'archive'],
|
|
105
|
+
'media-marketing-kit': ['repo', 'campaigns', 'working', 'archive'],
|
|
106
|
+
'media-curator': ['repo', 'library', 'working', 'archive'],
|
|
107
|
+
'research-complete': ['repo', 'corpus', 'working', 'archive']
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
export function normalizePathSegment(segment) {
|
|
112
|
+
return String(segment || '')
|
|
113
|
+
.replace(/^\/+/, '')
|
|
114
|
+
.replace(/\/+$/, '');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
export function ensureStringArray(value) {
|
|
119
|
+
if (!value) return [];
|
|
120
|
+
return Array.isArray(value) ? value.map(v => String(v)) : [String(value)];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
export function uniqueLower(values) {
|
|
125
|
+
const seen = new Set();
|
|
126
|
+
const out = [];
|
|
127
|
+
for (const raw of values) {
|
|
128
|
+
const v = String(raw || '').trim().toLowerCase();
|
|
129
|
+
if (!v || seen.has(v)) continue;
|
|
130
|
+
seen.add(v);
|
|
131
|
+
out.push(v);
|
|
132
|
+
}
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
export function normalizeDeploymentMode(mode = 'all') {
|
|
138
|
+
const normalized = String(mode || 'all').toLowerCase();
|
|
139
|
+
return MODE_ALIASES[normalized] || normalized;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
export function resolveFrameworkComponentDir(frameworkPath, manifest, component) {
|
|
144
|
+
const entry = manifest?.entry?.[component];
|
|
145
|
+
const relPath = normalizePathSegment(entry || component);
|
|
146
|
+
return path.join(frameworkPath, relPath);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Discover framework roots under agentic/code/frameworks.
|
|
152
|
+
* Framework metadata is loaded from root manifest.json when present.
|
|
153
|
+
*/
|
|
154
|
+
export function discoverFrameworks(srcRoot) {
|
|
155
|
+
const frameworksRoot = path.join(srcRoot, 'agentic', 'code', 'frameworks');
|
|
156
|
+
if (!fs.existsSync(frameworksRoot)) return [];
|
|
157
|
+
|
|
158
|
+
const frameworks = [];
|
|
159
|
+
const entries = fs.readdirSync(frameworksRoot, { withFileTypes: true })
|
|
160
|
+
.filter(e => e.isDirectory())
|
|
161
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
162
|
+
|
|
163
|
+
for (const entry of entries) {
|
|
164
|
+
const frameworkPath = path.join(frameworksRoot, entry.name);
|
|
165
|
+
const manifestPath = path.join(frameworkPath, 'manifest.json');
|
|
166
|
+
let manifest = {};
|
|
167
|
+
|
|
168
|
+
if (fs.existsSync(manifestPath)) {
|
|
169
|
+
try {
|
|
170
|
+
manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
171
|
+
} catch (e) {
|
|
172
|
+
console.warn(`Warning: Could not parse framework manifest for ${entry.name}: ${e.message}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const id = String(manifest.id || manifest.framework || entry.name);
|
|
177
|
+
const aliases = uniqueLower([
|
|
178
|
+
id,
|
|
179
|
+
entry.name,
|
|
180
|
+
...ensureStringArray(manifest.modeAliases),
|
|
181
|
+
...ensureStringArray(manifest.aliases),
|
|
182
|
+
...(LEGACY_FRAMEWORK_MODE_ALIASES[id] || [])
|
|
183
|
+
]);
|
|
184
|
+
|
|
185
|
+
const workspaceSubdirs = ensureStringArray(
|
|
186
|
+
manifest.workspace?.subdirs || manifest.workspace?.directories
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
const agentsDir = resolveFrameworkComponentDir(frameworkPath, manifest, 'agents');
|
|
190
|
+
const commandsDir = resolveFrameworkComponentDir(frameworkPath, manifest, 'commands');
|
|
191
|
+
const skillsDir = resolveFrameworkComponentDir(frameworkPath, manifest, 'skills');
|
|
192
|
+
const rulesDir = resolveFrameworkComponentDir(frameworkPath, manifest, 'rules');
|
|
193
|
+
|
|
194
|
+
frameworks.push({
|
|
195
|
+
id,
|
|
196
|
+
name: manifest.name || entry.name,
|
|
197
|
+
path: frameworkPath,
|
|
198
|
+
manifest,
|
|
199
|
+
aliases,
|
|
200
|
+
workspaceSubdirs: workspaceSubdirs.length > 0
|
|
201
|
+
? workspaceSubdirs
|
|
202
|
+
: (DEFAULT_FRAMEWORK_SUBDIRS[id] || ['repo', 'working', 'archive']),
|
|
203
|
+
components: {
|
|
204
|
+
agents: { path: agentsDir, exists: fs.existsSync(agentsDir) },
|
|
205
|
+
commands: { path: commandsDir, exists: fs.existsSync(commandsDir) },
|
|
206
|
+
skills: { path: skillsDir, exists: fs.existsSync(skillsDir) },
|
|
207
|
+
rules: { path: rulesDir, exists: fs.existsSync(rulesDir) }
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return frameworks;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Select frameworks for a deployment mode.
|
|
218
|
+
*/
|
|
219
|
+
export function getFrameworksForMode(srcRoot, mode) {
|
|
220
|
+
const normalizedMode = normalizeDeploymentMode(mode);
|
|
221
|
+
const frameworks = discoverFrameworks(srcRoot);
|
|
222
|
+
|
|
223
|
+
if (normalizedMode === 'all') return frameworks;
|
|
224
|
+
if (normalizedMode === 'general') return [];
|
|
225
|
+
if (normalizedMode === 'both') {
|
|
226
|
+
return frameworks.filter(fw => fw.aliases.includes('sdlc'));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return frameworks.filter(fw =>
|
|
230
|
+
fw.id.toLowerCase() === normalizedMode || fw.aliases.includes(normalizedMode)
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Collect framework artifacts for a deployment mode.
|
|
237
|
+
* @param {string} srcRoot - Source root directory
|
|
238
|
+
* @param {string} mode - Deployment mode
|
|
239
|
+
* @param {object} options - Collection options
|
|
240
|
+
* @param {boolean} options.includeAgents - Include agents
|
|
241
|
+
* @param {boolean} options.includeCommands - Include commands
|
|
242
|
+
* @param {boolean} options.includeSkills - Include skills
|
|
243
|
+
* @param {boolean} options.includeRules - Include rules
|
|
244
|
+
* @param {boolean} options.recursiveCommands - Use recursive command listing
|
|
245
|
+
* @param {boolean} options.consolidatedSdlcRules - Use RULES-INDEX for SDLC when available
|
|
246
|
+
* @returns {{frameworks: Array, agents: string[], commands: string[], skills: string[], rules: string[]}}
|
|
247
|
+
*/
|
|
248
|
+
export function collectFrameworkArtifacts(srcRoot, mode, options = {}) {
|
|
249
|
+
const {
|
|
250
|
+
includeAgents = true,
|
|
251
|
+
includeCommands = true,
|
|
252
|
+
includeSkills = true,
|
|
253
|
+
includeRules = true,
|
|
254
|
+
recursiveCommands = true,
|
|
255
|
+
consolidatedSdlcRules = true
|
|
256
|
+
} = options;
|
|
257
|
+
|
|
258
|
+
const frameworks = getFrameworksForMode(srcRoot, mode);
|
|
259
|
+
const artifacts = {
|
|
260
|
+
frameworks,
|
|
261
|
+
agents: [],
|
|
262
|
+
souls: [],
|
|
263
|
+
commands: [],
|
|
264
|
+
skills: [],
|
|
265
|
+
rules: []
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
for (const framework of frameworks) {
|
|
269
|
+
if (includeAgents && framework.components.agents.exists) {
|
|
270
|
+
artifacts.agents.push(...listMdFiles(framework.components.agents.path));
|
|
271
|
+
artifacts.souls.push(...listSoulFiles(framework.components.agents.path));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (includeCommands && framework.components.commands.exists) {
|
|
275
|
+
const commandFiles = recursiveCommands
|
|
276
|
+
? listMdFilesRecursive(framework.components.commands.path)
|
|
277
|
+
: listMdFiles(framework.components.commands.path);
|
|
278
|
+
artifacts.commands.push(...commandFiles);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (includeSkills && framework.components.skills.exists) {
|
|
282
|
+
artifacts.skills.push(...listSkillDirs(framework.components.skills.path));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (includeRules && framework.components.rules.exists) {
|
|
286
|
+
if (consolidatedSdlcRules && framework.id === 'sdlc-complete') {
|
|
287
|
+
const indexPath = getRulesIndexPath(srcRoot);
|
|
288
|
+
if (indexPath) {
|
|
289
|
+
artifacts.rules.push(indexPath);
|
|
290
|
+
// PUW-016 (#1117): also include individual rule files referenced
|
|
291
|
+
// by the index. RULES-INDEX.md links to per-rule files; if those
|
|
292
|
+
// files don't ship the links resolve to nowhere. Filter the
|
|
293
|
+
// index file itself out of listMdFiles so it isn't pushed twice.
|
|
294
|
+
const indexBase = indexPath.split('/').pop();
|
|
295
|
+
artifacts.rules.push(
|
|
296
|
+
...listMdFiles(framework.components.rules.path)
|
|
297
|
+
.filter((f) => !f.endsWith(indexBase))
|
|
298
|
+
.filter(isAlwaysOnRule) // tier gate (#1673)
|
|
299
|
+
);
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// tier gate (#1673): inline only always-on (CRITICAL/HIGH) rules
|
|
304
|
+
artifacts.rules.push(...listMdFiles(framework.components.rules.path).filter(isAlwaysOnRule));
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return artifacts;
|
|
309
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// Shared provider frontmatter utilities.
|
|
2
|
+
import { path } from './base-runtime.mjs';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parse YAML frontmatter from markdown content
|
|
7
|
+
* Returns { frontmatter: string, body: string, metadata: object }
|
|
8
|
+
*/
|
|
9
|
+
export function parseFrontmatter(content) {
|
|
10
|
+
const fmMatch = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
11
|
+
if (!fmMatch) {
|
|
12
|
+
return { frontmatter: null, body: content, metadata: {} };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const [, frontmatter, body] = fmMatch;
|
|
16
|
+
|
|
17
|
+
// Parse simple YAML key-value pairs
|
|
18
|
+
const metadata = {};
|
|
19
|
+
for (const line of frontmatter.split('\n')) {
|
|
20
|
+
const match = line.match(/^(\w+):\s*(.+)$/);
|
|
21
|
+
if (match) {
|
|
22
|
+
metadata[match[1]] = match[2].trim();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return { frontmatter, body, metadata };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Create frontmatter string from metadata object
|
|
32
|
+
*/
|
|
33
|
+
export function stringifyFrontmatter(metadata, body) {
|
|
34
|
+
const lines = ['---'];
|
|
35
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
36
|
+
if (value !== undefined && value !== null) {
|
|
37
|
+
lines.push(`${key}: ${value}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
lines.push('---');
|
|
41
|
+
return lines.join('\n') + '\n\n' + body.trim();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// ============================================================================
|
|
46
|
+
// String Utilities
|
|
47
|
+
// ============================================================================
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Convert a string to kebab-case
|
|
51
|
+
* "Technical Researcher" -> "technical-researcher"
|
|
52
|
+
*/
|
|
53
|
+
export function toKebabCase(str) {
|
|
54
|
+
if (!str) return str;
|
|
55
|
+
return str
|
|
56
|
+
.toLowerCase()
|
|
57
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
58
|
+
.replace(/^-+|-+$/g, '');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Strip JSON comments (JSONC) for parsing. Used by the Factory and Muse
|
|
64
|
+
* settings and hooks merges, which write the parsed document back, so the
|
|
65
|
+
* scanner tracks string literals: `//` in a URL or a slash-star sequence in
|
|
66
|
+
* a glob matcher is data, not a comment. A regex-only stripper collapsed glob
|
|
67
|
+
* matchers inside strings and rejected any settings file containing a URL.
|
|
68
|
+
*/
|
|
69
|
+
export function stripJsonComments(jsonc) {
|
|
70
|
+
const text = String(jsonc);
|
|
71
|
+
let out = '';
|
|
72
|
+
let i = 0;
|
|
73
|
+
while (i < text.length) {
|
|
74
|
+
const ch = text[i];
|
|
75
|
+
if (ch === '"') {
|
|
76
|
+
let j = i + 1;
|
|
77
|
+
while (j < text.length && text[j] !== '"') j += text[j] === '\\' ? 2 : 1;
|
|
78
|
+
out += text.slice(i, j + 1);
|
|
79
|
+
i = j + 1;
|
|
80
|
+
} else if (ch === '/' && text[i + 1] === '/') {
|
|
81
|
+
while (i < text.length && text[i] !== '\n') i++;
|
|
82
|
+
} else if (ch === '/' && text[i + 1] === '*') {
|
|
83
|
+
const end = text.indexOf('*/', i + 2);
|
|
84
|
+
i = end === -1 ? text.length : end + 2;
|
|
85
|
+
} else {
|
|
86
|
+
out += ch;
|
|
87
|
+
i++;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
// ============================================================================
|
|
95
|
+
// Agent Category Inference
|
|
96
|
+
// ============================================================================
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Infer agent category from name and body content
|
|
100
|
+
* Returns: 'analysis', 'documentation', 'planning', or 'implementation'
|
|
101
|
+
*/
|
|
102
|
+
export function inferAgentCategory(name, body) {
|
|
103
|
+
const normalizedName = (name || '').toLowerCase();
|
|
104
|
+
const normalizedBody = (body || '').toLowerCase();
|
|
105
|
+
|
|
106
|
+
// Analysis agents (read-only)
|
|
107
|
+
if (normalizedName.includes('security') || normalizedName.includes('review') ||
|
|
108
|
+
normalizedName.includes('analyst') || normalizedName.includes('auditor')) {
|
|
109
|
+
return 'analysis';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Documentation agents
|
|
113
|
+
if (normalizedName.includes('writer') || normalizedName.includes('document') ||
|
|
114
|
+
normalizedName.includes('archivist')) {
|
|
115
|
+
return 'documentation';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Planning agents
|
|
119
|
+
if (normalizedName.includes('architect') || normalizedName.includes('planner') ||
|
|
120
|
+
normalizedName.includes('requirements') || normalizedName.includes('designer')) {
|
|
121
|
+
return 'planning';
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Implementation agents (full access)
|
|
125
|
+
if (normalizedName.includes('implement') || normalizedName.includes('engineer') ||
|
|
126
|
+
normalizedName.includes('developer') || normalizedName.includes('test')) {
|
|
127
|
+
return 'implementation';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Default to implementation for most flexibility
|
|
131
|
+
return 'implementation';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
// ============================================================================
|
|
136
|
+
// Tool Parsing
|
|
137
|
+
// ============================================================================
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Parse tools string into array
|
|
141
|
+
*/
|
|
142
|
+
export function parseTools(toolsString) {
|
|
143
|
+
if (!toolsString) return [];
|
|
144
|
+
|
|
145
|
+
if (toolsString.startsWith('[')) {
|
|
146
|
+
try {
|
|
147
|
+
return JSON.parse(toolsString);
|
|
148
|
+
} catch (e) {
|
|
149
|
+
return toolsString.replace(/[\[\]"']/g, '').split(/[,\s]+/).filter(Boolean);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return toolsString.split(/[,\s]+/).filter(Boolean);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
// ============================================================================
|
|
157
|
+
// Skill-Command Collision Detection
|
|
158
|
+
// ============================================================================
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Filter out commands that share a name with a skill.
|
|
162
|
+
* Skills are the richer format (triggers, NL routing, behavior spec) and take precedence.
|
|
163
|
+
*
|
|
164
|
+
* @param {string[]} commandFiles - Array of command file paths
|
|
165
|
+
* @param {string[]} skillDirs - Array of skill directory paths
|
|
166
|
+
* @returns {string[]} Filtered command files with collisions removed
|
|
167
|
+
*/
|
|
168
|
+
export function filterCommandsAgainstSkills(commandFiles, skillDirs) {
|
|
169
|
+
if (!skillDirs.length || !commandFiles.length) return commandFiles;
|
|
170
|
+
|
|
171
|
+
// Build set of skill names (directory basenames, without extension)
|
|
172
|
+
const skillNames = new Set(skillDirs.map(d => path.basename(d)));
|
|
173
|
+
|
|
174
|
+
const filtered = [];
|
|
175
|
+
for (const f of commandFiles) {
|
|
176
|
+
// Command name is the filename without extension
|
|
177
|
+
const commandName = path.basename(f).replace(/\.\w+$/, '');
|
|
178
|
+
if (skillNames.has(commandName)) {
|
|
179
|
+
console.log(`skip (skill precedence): command "${commandName}" — skill with same name takes precedence`);
|
|
180
|
+
} else {
|
|
181
|
+
filtered.push(f);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return filtered;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
export function shouldReportDeployCollisions(opts = {}) {
|
|
190
|
+
if (opts.reportCollisions === true) return true;
|
|
191
|
+
if (opts.reportCollisions === false) return false;
|
|
192
|
+
if (process.env.AIWG_REPORT_DEPLOY_COLLISIONS === '1') return true;
|
|
193
|
+
if (process.env.VITEST) return false;
|
|
194
|
+
if (process.env.NODE_ENV === 'test') return false;
|
|
195
|
+
return true;
|
|
196
|
+
}
|