universal-dev-standards 6.15.0-beta.2 → 6.16.0-beta.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/bin/uds.js +2 -0
- package/bundled/locales/zh-CN/CHANGELOG.md +38 -4
- package/bundled/locales/zh-CN/CLAUDE.md +2 -2
- package/bundled/locales/zh-CN/README.md +17 -14
- package/bundled/locales/zh-CN/SECURITY.md +2 -2
- package/bundled/locales/zh-CN/docs/CHEATSHEET.md +1 -1
- package/bundled/locales/zh-CN/docs/CLI-INIT-OPTIONS.md +24 -2
- package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +3 -1
- package/bundled/locales/zh-TW/CHANGELOG.md +38 -4
- package/bundled/locales/zh-TW/CLAUDE.md +2 -2
- package/bundled/locales/zh-TW/README.md +17 -14
- package/bundled/locales/zh-TW/SECURITY.md +2 -2
- package/bundled/locales/zh-TW/docs/CHEATSHEET.md +1 -1
- package/bundled/locales/zh-TW/docs/CLI-INIT-OPTIONS.md +24 -2
- package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +3 -1
- package/bundled/skills/.claude-plugin/plugin.json +1 -1
- package/package.json +3 -3
- package/src/commands/skills.js +9 -0
- package/src/commands/update.js +223 -2
- package/src/reconciler/desired-state-calculator.js +11 -2
- package/src/utils/optional-skills-report.js +86 -0
- package/src/utils/optional-skills.js +20 -0
- package/src/utils/skill-selection.js +137 -0
- package/src/utils/skills-installer.js +11 -4
- package/standards-registry.json +7 -7
- package/src/core/agent-communication-protocol.js +0 -257
- package/src/flow/condition-evaluator.js +0 -86
- package/src/flow/flow-bundler.js +0 -80
- package/src/flow/flow-commands.js +0 -107
- package/src/flow/flow-engine.js +0 -154
- package/src/flow/flow-inheritance.js +0 -100
- package/src/flow/flow-parser.js +0 -104
- package/src/flow/flow-validator.js +0 -37
- package/src/flow/gate-checker.js +0 -82
- package/src/flow/gate-loader.js +0 -52
- package/src/missions/MissionManager.js +0 -533
- package/src/utils/e2e-analyzer.js +0 -471
- package/src/utils/e2e-detector.js +0 -132
- package/src/utils/hook-stats.js +0 -151
- package/src/utils/workflow-executor.js +0 -870
- package/src/utils/workflows-installer.js +0 -545
- package/src/vibe/auto-sweep.js +0 -349
|
@@ -1,545 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workflows Installer
|
|
3
|
-
*
|
|
4
|
-
* Provides installation and management of workflow definitions
|
|
5
|
-
* across all supported AI coding assistants.
|
|
6
|
-
*
|
|
7
|
-
* v1.1.0 - Added RLM context strategy support and parallel-agents step type
|
|
8
|
-
*
|
|
9
|
-
* @version 1.1.0
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { mkdirSync, writeFileSync, existsSync, readFileSync, readdirSync, statSync } from 'fs';
|
|
13
|
-
import { dirname, join, basename } from 'path';
|
|
14
|
-
import { fileURLToPath } from 'url';
|
|
15
|
-
import * as yaml from 'js-yaml';
|
|
16
|
-
import {
|
|
17
|
-
getAgentConfig,
|
|
18
|
-
getWorkflowsDirForAgent,
|
|
19
|
-
getWorkflowsSupportedAgents
|
|
20
|
-
} from '../config/ai-agent-paths.js';
|
|
21
|
-
import { computeFileHash } from './hasher.js';
|
|
22
|
-
|
|
23
|
-
// Get the CLI package root directory
|
|
24
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
25
|
-
const __dirname = dirname(__filename);
|
|
26
|
-
const CLI_ROOT = join(__dirname, '..', '..');
|
|
27
|
-
const BUNDLED_DIR = join(CLI_ROOT, 'bundled');
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Get the Workflows source directory.
|
|
31
|
-
* Prioritizes bundled directory (npm install), falls back to development path.
|
|
32
|
-
* @returns {string} Path to workflows source directory
|
|
33
|
-
*/
|
|
34
|
-
function getWorkflowsSourceDir() {
|
|
35
|
-
const bundledPath = join(BUNDLED_DIR, 'skills', 'workflows');
|
|
36
|
-
if (existsSync(bundledPath)) {
|
|
37
|
-
return bundledPath;
|
|
38
|
-
}
|
|
39
|
-
// Development environment fallback
|
|
40
|
-
return join(CLI_ROOT, '..', 'skills', 'workflows');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const WORKFLOWS_LOCAL_DIR = getWorkflowsSourceDir();
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Get list of available workflow names from local directory
|
|
47
|
-
* @returns {string[]} Array of workflow names (without .workflow.yaml extension)
|
|
48
|
-
*/
|
|
49
|
-
export function getAvailableWorkflowNames() {
|
|
50
|
-
if (!existsSync(WORKFLOWS_LOCAL_DIR)) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const NON_WORKFLOW_ITEMS = ['README.md', '.DS_Store', '.manifest.json'];
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
return readdirSync(WORKFLOWS_LOCAL_DIR)
|
|
58
|
-
.filter(file => {
|
|
59
|
-
if (NON_WORKFLOW_ITEMS.includes(file)) return false;
|
|
60
|
-
if (!file.endsWith('.workflow.yaml')) return false;
|
|
61
|
-
const itemPath = join(WORKFLOWS_LOCAL_DIR, file);
|
|
62
|
-
return statSync(itemPath).isFile();
|
|
63
|
-
})
|
|
64
|
-
.map(file => basename(file, '.workflow.yaml'));
|
|
65
|
-
} catch {
|
|
66
|
-
return [];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Get workflow definition content
|
|
72
|
-
* @param {string} workflowName - Workflow name (without extension)
|
|
73
|
-
* @returns {string|null} Workflow content or null if not found
|
|
74
|
-
*/
|
|
75
|
-
export function getWorkflowContent(workflowName) {
|
|
76
|
-
const sourcePath = join(WORKFLOWS_LOCAL_DIR, `${workflowName}.workflow.yaml`);
|
|
77
|
-
if (!existsSync(sourcePath)) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
return readFileSync(sourcePath, 'utf-8');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Parse workflow YAML to extract metadata
|
|
85
|
-
* @param {string} content - Workflow YAML content
|
|
86
|
-
* @returns {Object} Parsed workflow object
|
|
87
|
-
*/
|
|
88
|
-
export function parseWorkflow(content) {
|
|
89
|
-
try {
|
|
90
|
-
return yaml.load(content) || {};
|
|
91
|
-
} catch {
|
|
92
|
-
return {};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Valid step types for workflow validation
|
|
98
|
-
*/
|
|
99
|
-
const VALID_STEP_TYPES = ['agent', 'manual', 'conditional', 'parallel-agents'];
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Valid context modes for RLM-aware steps
|
|
103
|
-
* - minimal: Load only essential structure info
|
|
104
|
-
* - focused: Load current module/partition context
|
|
105
|
-
* - summary: Use summarized results from previous steps
|
|
106
|
-
*/
|
|
107
|
-
const VALID_CONTEXT_MODES = ['minimal', 'focused', 'summary'];
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Valid merge strategies for parallel-agents steps
|
|
111
|
-
*/
|
|
112
|
-
const VALID_MERGE_STRATEGIES = ['aggregate', 'sequential', 'summary'];
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Valid context inheritance modes
|
|
116
|
-
*/
|
|
117
|
-
const VALID_CONTEXT_INHERITANCE = ['full', 'selective', 'summary'];
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Validate a workflow definition
|
|
121
|
-
* @param {Object} workflow - Parsed workflow object
|
|
122
|
-
* @returns {Object} Validation result { valid: boolean, errors: string[], warnings: string[] }
|
|
123
|
-
*/
|
|
124
|
-
export function validateWorkflow(workflow) {
|
|
125
|
-
const errors = [];
|
|
126
|
-
const warnings = [];
|
|
127
|
-
|
|
128
|
-
// Required fields
|
|
129
|
-
if (!workflow.name) {
|
|
130
|
-
errors.push('Missing required field: name');
|
|
131
|
-
}
|
|
132
|
-
if (!workflow.version) {
|
|
133
|
-
errors.push('Missing required field: version');
|
|
134
|
-
}
|
|
135
|
-
if (!workflow.steps || !Array.isArray(workflow.steps)) {
|
|
136
|
-
errors.push('Missing or invalid field: steps (must be an array)');
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Validate steps
|
|
140
|
-
if (workflow.steps && Array.isArray(workflow.steps)) {
|
|
141
|
-
workflow.steps.forEach((step, index) => {
|
|
142
|
-
const stepId = step.id || `step[${index}]`;
|
|
143
|
-
|
|
144
|
-
// Required step fields
|
|
145
|
-
if (!step.id) {
|
|
146
|
-
warnings.push(`Step ${index}: missing 'id' field`);
|
|
147
|
-
}
|
|
148
|
-
if (!step.type) {
|
|
149
|
-
errors.push(`Step ${stepId}: missing required 'type' field`);
|
|
150
|
-
} else if (!VALID_STEP_TYPES.includes(step.type)) {
|
|
151
|
-
errors.push(`Step ${stepId}: invalid type '${step.type}'. Valid types: ${VALID_STEP_TYPES.join(', ')}`);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Type-specific validation
|
|
155
|
-
if (step.type === 'agent' || step.type === 'parallel-agents') {
|
|
156
|
-
if (!step.agent) {
|
|
157
|
-
errors.push(`Step ${stepId}: type '${step.type}' requires 'agent' field`);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Parallel-agents specific validation
|
|
162
|
-
if (step.type === 'parallel-agents') {
|
|
163
|
-
if (!step.foreach) {
|
|
164
|
-
errors.push(`Step ${stepId}: parallel-agents requires 'foreach' field`);
|
|
165
|
-
}
|
|
166
|
-
if (step['context-mode'] && !VALID_CONTEXT_MODES.includes(step['context-mode'])) {
|
|
167
|
-
errors.push(`Step ${stepId}: invalid context-mode '${step['context-mode']}'. Valid modes: ${VALID_CONTEXT_MODES.join(', ')}`);
|
|
168
|
-
}
|
|
169
|
-
if (step['merge-strategy'] && !VALID_MERGE_STRATEGIES.includes(step['merge-strategy'])) {
|
|
170
|
-
errors.push(`Step ${stepId}: invalid merge-strategy '${step['merge-strategy']}'. Valid strategies: ${VALID_MERGE_STRATEGIES.join(', ')}`);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Context mode validation for any step
|
|
175
|
-
if (step['context-mode'] && !VALID_CONTEXT_MODES.includes(step['context-mode'])) {
|
|
176
|
-
errors.push(`Step ${stepId}: invalid context-mode '${step['context-mode']}'`);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Validate context-strategy if present
|
|
182
|
-
if (workflow['context-strategy']) {
|
|
183
|
-
const cs = workflow['context-strategy'];
|
|
184
|
-
if (cs['context-inheritance'] && !VALID_CONTEXT_INHERITANCE.includes(cs['context-inheritance'])) {
|
|
185
|
-
errors.push(`context-strategy: invalid context-inheritance '${cs['context-inheritance']}'. Valid modes: ${VALID_CONTEXT_INHERITANCE.join(', ')}`);
|
|
186
|
-
}
|
|
187
|
-
if (cs['max-context-per-step'] && typeof cs['max-context-per-step'] !== 'number') {
|
|
188
|
-
warnings.push('context-strategy: max-context-per-step should be a number');
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return {
|
|
193
|
-
valid: errors.length === 0,
|
|
194
|
-
errors,
|
|
195
|
-
warnings
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Extract RLM features used in a workflow
|
|
201
|
-
* @param {Object} workflow - Parsed workflow object
|
|
202
|
-
* @returns {Object} Features used { hasRlm, hasParallelAgents, contextModes, mergeStrategies }
|
|
203
|
-
*/
|
|
204
|
-
export function getWorkflowFeatures(workflow) {
|
|
205
|
-
const features = {
|
|
206
|
-
hasRlm: false,
|
|
207
|
-
hasParallelAgents: false,
|
|
208
|
-
contextModes: new Set(),
|
|
209
|
-
mergeStrategies: new Set(),
|
|
210
|
-
stepTypes: new Set(),
|
|
211
|
-
agents: new Set()
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
// Check context-strategy
|
|
215
|
-
if (workflow['context-strategy']) {
|
|
216
|
-
features.hasRlm = workflow['context-strategy']['enable-rlm'] === true;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Analyze steps
|
|
220
|
-
if (workflow.steps && Array.isArray(workflow.steps)) {
|
|
221
|
-
for (const step of workflow.steps) {
|
|
222
|
-
if (step.type) {
|
|
223
|
-
features.stepTypes.add(step.type);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
if (step.type === 'parallel-agents') {
|
|
227
|
-
features.hasParallelAgents = true;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (step['context-mode']) {
|
|
231
|
-
features.contextModes.add(step['context-mode']);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (step['merge-strategy']) {
|
|
235
|
-
features.mergeStrategies.add(step['merge-strategy']);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (step.agent) {
|
|
239
|
-
features.agents.add(step.agent);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// Convert Sets to Arrays for easier consumption
|
|
245
|
-
return {
|
|
246
|
-
hasRlm: features.hasRlm,
|
|
247
|
-
hasParallelAgents: features.hasParallelAgents,
|
|
248
|
-
contextModes: Array.from(features.contextModes),
|
|
249
|
-
mergeStrategies: Array.from(features.mergeStrategies),
|
|
250
|
-
stepTypes: Array.from(features.stepTypes),
|
|
251
|
-
agents: Array.from(features.agents)
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Get workflow summary for display
|
|
257
|
-
* @param {string} workflowName - Workflow name
|
|
258
|
-
* @returns {Object|null} Workflow summary or null if not found
|
|
259
|
-
*/
|
|
260
|
-
export function getWorkflowSummary(workflowName) {
|
|
261
|
-
const content = getWorkflowContent(workflowName);
|
|
262
|
-
if (!content) {
|
|
263
|
-
return null;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
const workflow = parseWorkflow(content);
|
|
267
|
-
if (!workflow.name) {
|
|
268
|
-
return null;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const features = getWorkflowFeatures(workflow);
|
|
272
|
-
const validation = validateWorkflow(workflow);
|
|
273
|
-
|
|
274
|
-
return {
|
|
275
|
-
name: workflow.name,
|
|
276
|
-
version: workflow.version || '0.0.0',
|
|
277
|
-
description: workflow.description || '',
|
|
278
|
-
stepCount: workflow.steps?.length || 0,
|
|
279
|
-
category: workflow.metadata?.category || 'general',
|
|
280
|
-
difficulty: workflow.metadata?.difficulty || 'unknown',
|
|
281
|
-
features,
|
|
282
|
-
validation: {
|
|
283
|
-
valid: validation.valid,
|
|
284
|
-
errorCount: validation.errors.length,
|
|
285
|
-
warningCount: validation.warnings.length
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Install workflows for a specific AI tool
|
|
292
|
-
* @param {string} aiTool - AI tool identifier (e.g., 'claude-code', 'opencode')
|
|
293
|
-
* @param {string} level - 'user' or 'project'
|
|
294
|
-
* @param {string[]} workflowNames - Array of workflow names to install (null = all)
|
|
295
|
-
* @param {string} projectPath - Project root path (required for project level)
|
|
296
|
-
* @returns {Object} Installation result
|
|
297
|
-
*/
|
|
298
|
-
export async function installWorkflowsForTool(aiTool, level, workflowNames = null, projectPath = null) {
|
|
299
|
-
const config = getAgentConfig(aiTool);
|
|
300
|
-
const supportedTools = getWorkflowsSupportedAgents();
|
|
301
|
-
|
|
302
|
-
if (!config || !supportedTools.includes(aiTool)) {
|
|
303
|
-
return {
|
|
304
|
-
success: false,
|
|
305
|
-
aiTool,
|
|
306
|
-
level,
|
|
307
|
-
error: `AI tool '${aiTool}' does not support workflows installation`,
|
|
308
|
-
installed: [],
|
|
309
|
-
errors: []
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// Get target directory
|
|
314
|
-
const targetDir = getWorkflowsDirForAgent(aiTool, level, projectPath);
|
|
315
|
-
if (!targetDir) {
|
|
316
|
-
return {
|
|
317
|
-
success: false,
|
|
318
|
-
aiTool,
|
|
319
|
-
level,
|
|
320
|
-
error: `Could not determine target directory for ${aiTool} at ${level} level`,
|
|
321
|
-
installed: [],
|
|
322
|
-
errors: []
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// Ensure target directory exists
|
|
327
|
-
if (!existsSync(targetDir)) {
|
|
328
|
-
mkdirSync(targetDir, { recursive: true });
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// Get workflows to install
|
|
332
|
-
const availableWorkflows = getAvailableWorkflowNames();
|
|
333
|
-
const toInstall = workflowNames || availableWorkflows;
|
|
334
|
-
|
|
335
|
-
const results = {
|
|
336
|
-
success: true,
|
|
337
|
-
aiTool,
|
|
338
|
-
level,
|
|
339
|
-
targetDir,
|
|
340
|
-
installed: [],
|
|
341
|
-
errors: [],
|
|
342
|
-
fileHashes: {}
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
for (const workflowName of toInstall) {
|
|
346
|
-
const result = installSingleWorkflow(workflowName, targetDir);
|
|
347
|
-
if (result.success) {
|
|
348
|
-
results.installed.push(workflowName);
|
|
349
|
-
} else {
|
|
350
|
-
results.errors.push({ workflow: workflowName, error: result.error });
|
|
351
|
-
results.success = false;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// Write manifest
|
|
356
|
-
if (results.installed.length > 0) {
|
|
357
|
-
writeWorkflowsManifest(aiTool, level, targetDir, results.installed);
|
|
358
|
-
|
|
359
|
-
// Compute file hashes for tracking
|
|
360
|
-
const now = new Date().toISOString();
|
|
361
|
-
for (const workflowName of results.installed) {
|
|
362
|
-
const filePath = join(targetDir, `${workflowName}.workflow.yaml`);
|
|
363
|
-
const hashInfo = computeFileHash(filePath);
|
|
364
|
-
if (hashInfo) {
|
|
365
|
-
results.fileHashes[`${aiTool}/${workflowName}.workflow.yaml`] = {
|
|
366
|
-
...hashInfo,
|
|
367
|
-
installedAt: now
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
return results;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Install a single workflow to target directory
|
|
378
|
-
* @param {string} workflowName - Workflow name (without extension)
|
|
379
|
-
* @param {string} targetDir - Target directory
|
|
380
|
-
* @returns {Object} Result
|
|
381
|
-
*/
|
|
382
|
-
function installSingleWorkflow(workflowName, targetDir) {
|
|
383
|
-
const sourcePath = join(WORKFLOWS_LOCAL_DIR, `${workflowName}.workflow.yaml`);
|
|
384
|
-
const targetPath = join(targetDir, `${workflowName}.workflow.yaml`);
|
|
385
|
-
|
|
386
|
-
if (!existsSync(sourcePath)) {
|
|
387
|
-
return {
|
|
388
|
-
success: false,
|
|
389
|
-
workflow: workflowName,
|
|
390
|
-
error: `Workflow not found: ${workflowName}`
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
try {
|
|
395
|
-
const content = readFileSync(sourcePath, 'utf-8');
|
|
396
|
-
writeFileSync(targetPath, content);
|
|
397
|
-
return { success: true, workflow: workflowName, path: targetPath };
|
|
398
|
-
} catch (error) {
|
|
399
|
-
return {
|
|
400
|
-
success: false,
|
|
401
|
-
workflow: workflowName,
|
|
402
|
-
error: error.message
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* Write workflows manifest
|
|
409
|
-
* @param {string} aiTool - AI tool identifier
|
|
410
|
-
* @param {string} level - 'user' or 'project'
|
|
411
|
-
* @param {string} targetDir - Target directory
|
|
412
|
-
* @param {string[]} workflows - List of installed workflows
|
|
413
|
-
*/
|
|
414
|
-
function writeWorkflowsManifest(aiTool, level, targetDir, workflows) {
|
|
415
|
-
const manifestPath = join(targetDir, '.manifest.json');
|
|
416
|
-
const { version } = JSON.parse(
|
|
417
|
-
readFileSync(join(CLI_ROOT, 'package.json'), 'utf-8')
|
|
418
|
-
);
|
|
419
|
-
|
|
420
|
-
const manifest = {
|
|
421
|
-
version,
|
|
422
|
-
source: 'universal-dev-standards',
|
|
423
|
-
type: 'workflows',
|
|
424
|
-
aiTool,
|
|
425
|
-
level,
|
|
426
|
-
workflows,
|
|
427
|
-
installedDate: new Date().toISOString().split('T')[0]
|
|
428
|
-
};
|
|
429
|
-
|
|
430
|
-
writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* Get installed workflows info for an AI tool
|
|
435
|
-
* @param {string} aiTool - AI tool identifier
|
|
436
|
-
* @param {string} level - 'user' or 'project'
|
|
437
|
-
* @param {string} projectPath - Project root path (required for project level)
|
|
438
|
-
* @returns {Object|null} Installed workflows info or null
|
|
439
|
-
*/
|
|
440
|
-
export function getInstalledWorkflowsForTool(aiTool, level = 'project', projectPath = null) {
|
|
441
|
-
const targetDir = getWorkflowsDirForAgent(aiTool, level, projectPath);
|
|
442
|
-
if (!targetDir || !existsSync(targetDir)) {
|
|
443
|
-
return null;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
const manifestPath = join(targetDir, '.manifest.json');
|
|
447
|
-
|
|
448
|
-
// Count workflow files
|
|
449
|
-
let workflowFiles = [];
|
|
450
|
-
try {
|
|
451
|
-
workflowFiles = readdirSync(targetDir)
|
|
452
|
-
.filter(f => f.endsWith('.workflow.yaml'));
|
|
453
|
-
} catch {
|
|
454
|
-
return null;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
if (workflowFiles.length === 0) {
|
|
458
|
-
return null;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
const getWorkflowName = (filename) => basename(filename, '.workflow.yaml');
|
|
462
|
-
|
|
463
|
-
if (!existsSync(manifestPath)) {
|
|
464
|
-
return {
|
|
465
|
-
installed: true,
|
|
466
|
-
count: workflowFiles.length,
|
|
467
|
-
workflows: workflowFiles.map(getWorkflowName),
|
|
468
|
-
version: null,
|
|
469
|
-
aiTool,
|
|
470
|
-
level,
|
|
471
|
-
path: targetDir
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
try {
|
|
476
|
-
const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));
|
|
477
|
-
return {
|
|
478
|
-
installed: true,
|
|
479
|
-
count: workflowFiles.length,
|
|
480
|
-
workflows: manifest.workflows || workflowFiles.map(getWorkflowName),
|
|
481
|
-
version: manifest.version || null,
|
|
482
|
-
aiTool,
|
|
483
|
-
level,
|
|
484
|
-
path: targetDir,
|
|
485
|
-
installedDate: manifest.installedDate || null
|
|
486
|
-
};
|
|
487
|
-
} catch {
|
|
488
|
-
return {
|
|
489
|
-
installed: true,
|
|
490
|
-
count: workflowFiles.length,
|
|
491
|
-
workflows: workflowFiles.map(getWorkflowName),
|
|
492
|
-
version: null,
|
|
493
|
-
aiTool,
|
|
494
|
-
level,
|
|
495
|
-
path: targetDir
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* Install workflows to multiple AI tools at once
|
|
502
|
-
* @param {Array<{agent: string, level: string}>} installations - Array of installation targets
|
|
503
|
-
* @param {string[]} workflowNames - Workflows to install (null = all)
|
|
504
|
-
* @param {string} projectPath - Project root path
|
|
505
|
-
* @returns {Object} Combined results
|
|
506
|
-
*/
|
|
507
|
-
export async function installWorkflowsToMultipleTools(installations, workflowNames = null, projectPath = null) {
|
|
508
|
-
const results = {
|
|
509
|
-
success: true,
|
|
510
|
-
installations: [],
|
|
511
|
-
totalInstalled: 0,
|
|
512
|
-
totalErrors: 0,
|
|
513
|
-
allFileHashes: {}
|
|
514
|
-
};
|
|
515
|
-
|
|
516
|
-
for (const { agent, level } of installations) {
|
|
517
|
-
const result = await installWorkflowsForTool(agent, level, workflowNames, projectPath);
|
|
518
|
-
results.installations.push(result);
|
|
519
|
-
|
|
520
|
-
if (!result.success) {
|
|
521
|
-
results.success = false;
|
|
522
|
-
}
|
|
523
|
-
results.totalInstalled += result.installed.length;
|
|
524
|
-
results.totalErrors += result.errors.length;
|
|
525
|
-
|
|
526
|
-
// Merge file hashes from this installation
|
|
527
|
-
if (result.fileHashes) {
|
|
528
|
-
Object.assign(results.allFileHashes, result.fileHashes);
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
return results;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
export default {
|
|
536
|
-
installWorkflowsForTool,
|
|
537
|
-
getInstalledWorkflowsForTool,
|
|
538
|
-
installWorkflowsToMultipleTools,
|
|
539
|
-
getAvailableWorkflowNames,
|
|
540
|
-
getWorkflowContent,
|
|
541
|
-
parseWorkflow,
|
|
542
|
-
validateWorkflow,
|
|
543
|
-
getWorkflowFeatures,
|
|
544
|
-
getWorkflowSummary
|
|
545
|
-
};
|