@nahisaho/musubix-core 1.0.0 → 1.0.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/dist/cli/commands/codegen.d.ts +125 -0
- package/dist/cli/commands/codegen.d.ts.map +1 -0
- package/dist/cli/commands/codegen.js +684 -0
- package/dist/cli/commands/codegen.js.map +1 -0
- package/dist/cli/commands/design.d.ts +158 -0
- package/dist/cli/commands/design.d.ts.map +1 -0
- package/dist/cli/commands/design.js +562 -0
- package/dist/cli/commands/design.js.map +1 -0
- package/dist/cli/commands/explain.d.ts +116 -0
- package/dist/cli/commands/explain.d.ts.map +1 -0
- package/dist/cli/commands/explain.js +419 -0
- package/dist/cli/commands/explain.js.map +1 -0
- package/dist/cli/commands/index.d.ts +13 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +31 -7
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/requirements.d.ts +103 -0
- package/dist/cli/commands/requirements.d.ts.map +1 -0
- package/dist/cli/commands/requirements.js +403 -0
- package/dist/cli/commands/requirements.js.map +1 -0
- package/dist/cli/commands/skills.d.ts +99 -0
- package/dist/cli/commands/skills.d.ts.map +1 -0
- package/dist/cli/commands/skills.js +363 -0
- package/dist/cli/commands/skills.js.map +1 -0
- package/dist/cli/commands/test.d.ts +113 -0
- package/dist/cli/commands/test.d.ts.map +1 -0
- package/dist/cli/commands/test.js +532 -0
- package/dist/cli/commands/test.js.map +1 -0
- package/dist/cli/commands/trace.d.ts +132 -0
- package/dist/cli/commands/trace.d.ts.map +1 -0
- package/dist/cli/commands/trace.js +553 -0
- package/dist/cli/commands/trace.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Requirements Command
|
|
3
|
+
*
|
|
4
|
+
* CLI commands for requirements analysis and validation
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @module cli/commands/requirements
|
|
8
|
+
*
|
|
9
|
+
* @see REQ-CLI-001 - Requirements CLI
|
|
10
|
+
* @see REQ-RA-001 - EARS Pattern Recognition
|
|
11
|
+
* @see REQ-RA-002 - Ontology Mapping
|
|
12
|
+
* @see DES-MUSUBIX-001 Section 16-C.1 - requirementsコマンド設計
|
|
13
|
+
* @see TSK-062〜065 - Requirements CLI実装
|
|
14
|
+
*/
|
|
15
|
+
import type { Command } from 'commander';
|
|
16
|
+
/**
|
|
17
|
+
* Requirements command options
|
|
18
|
+
*/
|
|
19
|
+
export interface RequirementsOptions {
|
|
20
|
+
output?: string;
|
|
21
|
+
format?: 'markdown' | 'json' | 'yaml';
|
|
22
|
+
verbose?: boolean;
|
|
23
|
+
ontology?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* EARS requirement
|
|
27
|
+
*/
|
|
28
|
+
export interface EARSRequirement {
|
|
29
|
+
id: string;
|
|
30
|
+
pattern: string;
|
|
31
|
+
text: string;
|
|
32
|
+
priority: 'P0' | 'P1' | 'P2';
|
|
33
|
+
rationale?: string;
|
|
34
|
+
relatedRequirements?: string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Analysis result
|
|
38
|
+
*/
|
|
39
|
+
export interface AnalysisResult {
|
|
40
|
+
success: boolean;
|
|
41
|
+
requirements: EARSRequirement[];
|
|
42
|
+
summary: {
|
|
43
|
+
total: number;
|
|
44
|
+
byPattern: Record<string, number>;
|
|
45
|
+
byPriority: Record<string, number>;
|
|
46
|
+
};
|
|
47
|
+
message: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Validation result
|
|
51
|
+
*/
|
|
52
|
+
export interface ValidationResult {
|
|
53
|
+
success: boolean;
|
|
54
|
+
valid: boolean;
|
|
55
|
+
issues: Array<{
|
|
56
|
+
line?: number;
|
|
57
|
+
requirement?: string;
|
|
58
|
+
severity: 'error' | 'warning' | 'info';
|
|
59
|
+
message: string;
|
|
60
|
+
}>;
|
|
61
|
+
summary: {
|
|
62
|
+
errors: number;
|
|
63
|
+
warnings: number;
|
|
64
|
+
info: number;
|
|
65
|
+
};
|
|
66
|
+
message: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Mapping result
|
|
70
|
+
*/
|
|
71
|
+
export interface MappingResult {
|
|
72
|
+
success: boolean;
|
|
73
|
+
mappings: Array<{
|
|
74
|
+
requirement: string;
|
|
75
|
+
concepts: string[];
|
|
76
|
+
patterns: string[];
|
|
77
|
+
relatedRequirements: string[];
|
|
78
|
+
}>;
|
|
79
|
+
message: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Search result
|
|
83
|
+
*/
|
|
84
|
+
export interface SearchResult {
|
|
85
|
+
success: boolean;
|
|
86
|
+
matches: Array<{
|
|
87
|
+
id: string;
|
|
88
|
+
text: string;
|
|
89
|
+
score: number;
|
|
90
|
+
context?: string;
|
|
91
|
+
}>;
|
|
92
|
+
message: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Parse EARS requirements from text
|
|
96
|
+
*/
|
|
97
|
+
declare function parseEARSRequirements(content: string): string[];
|
|
98
|
+
/**
|
|
99
|
+
* Register requirements command
|
|
100
|
+
*/
|
|
101
|
+
export declare function registerRequirementsCommand(program: Command): void;
|
|
102
|
+
export { parseEARSRequirements };
|
|
103
|
+
//# sourceMappingURL=requirements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirements.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/requirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWzC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;IACtC,OAAO,CAAC,EAAE,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AAE,MAAM,EAAE,CAAC;QACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,mBAAmB,EAAE,MAAM,EAAE,CAAC;KAC/B,CAAC,CAAC;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,iBAAS,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAsCxD;AA6BD;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAySlE;AAgED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Requirements Command
|
|
3
|
+
*
|
|
4
|
+
* CLI commands for requirements analysis and validation
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @module cli/commands/requirements
|
|
8
|
+
*
|
|
9
|
+
* @see REQ-CLI-001 - Requirements CLI
|
|
10
|
+
* @see REQ-RA-001 - EARS Pattern Recognition
|
|
11
|
+
* @see REQ-RA-002 - Ontology Mapping
|
|
12
|
+
* @see DES-MUSUBIX-001 Section 16-C.1 - requirementsコマンド設計
|
|
13
|
+
* @see TSK-062〜065 - Requirements CLI実装
|
|
14
|
+
*/
|
|
15
|
+
import { readFile, writeFile, access } from 'fs/promises';
|
|
16
|
+
import { resolve } from 'path';
|
|
17
|
+
import { ExitCode, getGlobalOptions, outputResult } from '../base.js';
|
|
18
|
+
import { createEARSValidator, DEFAULT_EARS_OPTIONS, } from '../../validators/ears-validator.js';
|
|
19
|
+
/**
|
|
20
|
+
* Parse EARS requirements from text
|
|
21
|
+
*/
|
|
22
|
+
function parseEARSRequirements(content) {
|
|
23
|
+
const lines = content.split('\n');
|
|
24
|
+
const requirements = [];
|
|
25
|
+
let currentReq = '';
|
|
26
|
+
for (const line of lines) {
|
|
27
|
+
const trimmed = line.trim();
|
|
28
|
+
// Skip empty lines and comments
|
|
29
|
+
if (!trimmed || trimmed.startsWith('#') || trimmed.startsWith('//')) {
|
|
30
|
+
if (currentReq) {
|
|
31
|
+
requirements.push(currentReq.trim());
|
|
32
|
+
currentReq = '';
|
|
33
|
+
}
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
// Check for EARS keywords
|
|
37
|
+
if (trimmed.match(/^(THE|WHEN|WHILE|IF|WHERE)\s/i) ||
|
|
38
|
+
trimmed.match(/^-\s*(THE|WHEN|WHILE|IF|WHERE)\s/i)) {
|
|
39
|
+
if (currentReq) {
|
|
40
|
+
requirements.push(currentReq.trim());
|
|
41
|
+
}
|
|
42
|
+
currentReq = trimmed.replace(/^-\s*/, '');
|
|
43
|
+
}
|
|
44
|
+
else if (currentReq && trimmed.match(/^(AND|OR)\s/i)) {
|
|
45
|
+
currentReq += ' ' + trimmed;
|
|
46
|
+
}
|
|
47
|
+
else if (currentReq) {
|
|
48
|
+
currentReq += ' ' + trimmed;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (currentReq) {
|
|
52
|
+
requirements.push(currentReq.trim());
|
|
53
|
+
}
|
|
54
|
+
return requirements;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Generate requirement ID
|
|
58
|
+
*/
|
|
59
|
+
function generateReqId(index, pattern) {
|
|
60
|
+
const patternPrefix = pattern.substring(0, 3).toUpperCase();
|
|
61
|
+
return `REQ-${patternPrefix}-${String(index + 1).padStart(3, '0')}`;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Determine priority based on pattern and content
|
|
65
|
+
*/
|
|
66
|
+
function determinePriority(match) {
|
|
67
|
+
// Security, error handling, core functionality = P0
|
|
68
|
+
const p0Keywords = ['SHALL', 'MUST', 'security', 'error', 'fail', 'critical'];
|
|
69
|
+
const p2Keywords = ['SHOULD', 'MAY', 'optional', 'nice-to-have'];
|
|
70
|
+
const text = match.original.toLowerCase();
|
|
71
|
+
if (p0Keywords.some(kw => text.includes(kw.toLowerCase()))) {
|
|
72
|
+
return 'P0';
|
|
73
|
+
}
|
|
74
|
+
if (p2Keywords.some(kw => text.includes(kw.toLowerCase()))) {
|
|
75
|
+
return 'P2';
|
|
76
|
+
}
|
|
77
|
+
return 'P1';
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Register requirements command
|
|
81
|
+
*/
|
|
82
|
+
export function registerRequirementsCommand(program) {
|
|
83
|
+
const requirements = program
|
|
84
|
+
.command('requirements')
|
|
85
|
+
.description('Requirements analysis and validation');
|
|
86
|
+
// requirements analyze
|
|
87
|
+
requirements
|
|
88
|
+
.command('analyze <input>')
|
|
89
|
+
.description('Analyze natural language to EARS requirements')
|
|
90
|
+
.option('-o, --output <file>', 'Output file')
|
|
91
|
+
.option('-f, --format <format>', 'Output format (markdown|json|yaml)', 'markdown')
|
|
92
|
+
.action(async (input, options) => {
|
|
93
|
+
const globalOpts = getGlobalOptions(program);
|
|
94
|
+
try {
|
|
95
|
+
// Read input
|
|
96
|
+
let content;
|
|
97
|
+
const inputPath = resolve(process.cwd(), input);
|
|
98
|
+
try {
|
|
99
|
+
await access(inputPath);
|
|
100
|
+
content = await readFile(inputPath, 'utf-8');
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// Treat as direct text input
|
|
104
|
+
content = input;
|
|
105
|
+
}
|
|
106
|
+
// Create validator
|
|
107
|
+
const validator = createEARSValidator();
|
|
108
|
+
// Parse and analyze requirements
|
|
109
|
+
const rawRequirements = parseEARSRequirements(content);
|
|
110
|
+
const requirements = [];
|
|
111
|
+
const byPattern = {};
|
|
112
|
+
const byPriority = { P0: 0, P1: 0, P2: 0 };
|
|
113
|
+
for (let i = 0; i < rawRequirements.length; i++) {
|
|
114
|
+
const reqText = rawRequirements[i];
|
|
115
|
+
const match = validator.validateRequirement(reqText);
|
|
116
|
+
if (match.valid && match.patternMatch) {
|
|
117
|
+
const pattern = match.patternMatch.type;
|
|
118
|
+
const priority = determinePriority(match.patternMatch);
|
|
119
|
+
const id = generateReqId(i, pattern);
|
|
120
|
+
requirements.push({
|
|
121
|
+
id,
|
|
122
|
+
pattern,
|
|
123
|
+
text: reqText,
|
|
124
|
+
priority,
|
|
125
|
+
rationale: `Detected ${pattern} pattern with ${Math.round(match.patternMatch.confidence * 100)}% confidence`,
|
|
126
|
+
});
|
|
127
|
+
byPattern[pattern] = (byPattern[pattern] || 0) + 1;
|
|
128
|
+
byPriority[priority]++;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
// Non-conforming requirement
|
|
132
|
+
requirements.push({
|
|
133
|
+
id: generateReqId(i, 'UNK'),
|
|
134
|
+
pattern: 'unknown',
|
|
135
|
+
text: reqText,
|
|
136
|
+
priority: 'P1',
|
|
137
|
+
rationale: match.issues.map(i => i.message).join('; '),
|
|
138
|
+
});
|
|
139
|
+
byPattern['unknown'] = (byPattern['unknown'] || 0) + 1;
|
|
140
|
+
byPriority['P1']++;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const result = {
|
|
144
|
+
success: true,
|
|
145
|
+
requirements,
|
|
146
|
+
summary: {
|
|
147
|
+
total: requirements.length,
|
|
148
|
+
byPattern,
|
|
149
|
+
byPriority,
|
|
150
|
+
},
|
|
151
|
+
message: `Analyzed ${requirements.length} requirements`,
|
|
152
|
+
};
|
|
153
|
+
// Output
|
|
154
|
+
if (options.output) {
|
|
155
|
+
const outputPath = resolve(process.cwd(), options.output);
|
|
156
|
+
let outputContent;
|
|
157
|
+
if (options.format === 'json' || globalOpts.json) {
|
|
158
|
+
outputContent = JSON.stringify(result, null, 2);
|
|
159
|
+
}
|
|
160
|
+
else if (options.format === 'yaml') {
|
|
161
|
+
const yaml = await import('yaml');
|
|
162
|
+
outputContent = yaml.stringify(result);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
// Markdown format
|
|
166
|
+
outputContent = generateMarkdownOutput(result);
|
|
167
|
+
}
|
|
168
|
+
await writeFile(outputPath, outputContent, 'utf-8');
|
|
169
|
+
if (!globalOpts.quiet) {
|
|
170
|
+
console.log(`✅ Analysis saved to ${outputPath}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
outputResult(result, globalOpts);
|
|
175
|
+
}
|
|
176
|
+
process.exit(ExitCode.SUCCESS);
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
if (!globalOpts.quiet) {
|
|
180
|
+
console.error(`❌ Analysis failed: ${error.message}`);
|
|
181
|
+
}
|
|
182
|
+
process.exit(ExitCode.GENERAL_ERROR);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
// requirements validate
|
|
186
|
+
requirements
|
|
187
|
+
.command('validate <file>')
|
|
188
|
+
.description('Validate EARS syntax')
|
|
189
|
+
.option('--strict', 'Enable strict mode', false)
|
|
190
|
+
.action(async (file, options) => {
|
|
191
|
+
const globalOpts = getGlobalOptions(program);
|
|
192
|
+
try {
|
|
193
|
+
const filePath = resolve(process.cwd(), file);
|
|
194
|
+
const content = await readFile(filePath, 'utf-8');
|
|
195
|
+
// Create validator
|
|
196
|
+
const validatorOptions = {
|
|
197
|
+
...DEFAULT_EARS_OPTIONS,
|
|
198
|
+
strictMode: options.strict ?? false,
|
|
199
|
+
};
|
|
200
|
+
const validator = createEARSValidator(validatorOptions);
|
|
201
|
+
// Parse and validate
|
|
202
|
+
const rawRequirements = parseEARSRequirements(content);
|
|
203
|
+
const issues = [];
|
|
204
|
+
for (let i = 0; i < rawRequirements.length; i++) {
|
|
205
|
+
const reqText = rawRequirements[i];
|
|
206
|
+
const result = validator.validateRequirement(reqText);
|
|
207
|
+
for (const issue of result.issues) {
|
|
208
|
+
issues.push({
|
|
209
|
+
line: i + 1,
|
|
210
|
+
requirement: reqText.substring(0, 50) + (reqText.length > 50 ? '...' : ''),
|
|
211
|
+
severity: issue.severity,
|
|
212
|
+
message: issue.message,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const errors = issues.filter(i => i.severity === 'error').length;
|
|
217
|
+
const warnings = issues.filter(i => i.severity === 'warning').length;
|
|
218
|
+
const info = issues.filter(i => i.severity === 'info').length;
|
|
219
|
+
const result = {
|
|
220
|
+
success: true,
|
|
221
|
+
valid: errors === 0,
|
|
222
|
+
issues,
|
|
223
|
+
summary: { errors, warnings, info },
|
|
224
|
+
message: errors === 0
|
|
225
|
+
? `✅ All ${rawRequirements.length} requirements are valid`
|
|
226
|
+
: `❌ Found ${errors} errors, ${warnings} warnings`,
|
|
227
|
+
};
|
|
228
|
+
outputResult(result, globalOpts);
|
|
229
|
+
process.exit(errors === 0 ? ExitCode.SUCCESS : ExitCode.VALIDATION_ERROR);
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
if (!globalOpts.quiet) {
|
|
233
|
+
console.error(`❌ Validation failed: ${error.message}`);
|
|
234
|
+
}
|
|
235
|
+
process.exit(ExitCode.GENERAL_ERROR);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
// requirements map
|
|
239
|
+
requirements
|
|
240
|
+
.command('map <file>')
|
|
241
|
+
.description('Map requirements to ontology')
|
|
242
|
+
.option('--ontology <path>', 'Custom ontology file')
|
|
243
|
+
.action(async (file, _options) => {
|
|
244
|
+
const globalOpts = getGlobalOptions(program);
|
|
245
|
+
try {
|
|
246
|
+
const filePath = resolve(process.cwd(), file);
|
|
247
|
+
const content = await readFile(filePath, 'utf-8');
|
|
248
|
+
// Parse requirements
|
|
249
|
+
const rawRequirements = parseEARSRequirements(content);
|
|
250
|
+
const validator = createEARSValidator();
|
|
251
|
+
// Map to concepts (simplified implementation)
|
|
252
|
+
const mappings = [];
|
|
253
|
+
for (const reqText of rawRequirements) {
|
|
254
|
+
const result = validator.validateRequirement(reqText);
|
|
255
|
+
// Extract concepts from components
|
|
256
|
+
const concepts = [];
|
|
257
|
+
const patterns = [];
|
|
258
|
+
if (result.patternMatch) {
|
|
259
|
+
const comp = result.patternMatch.components;
|
|
260
|
+
if (comp.system)
|
|
261
|
+
concepts.push(`Actor:${comp.system}`);
|
|
262
|
+
if (comp.action)
|
|
263
|
+
concepts.push(`Action:${comp.action}`);
|
|
264
|
+
if (comp.trigger)
|
|
265
|
+
concepts.push(`Event:${comp.trigger}`);
|
|
266
|
+
if (comp.state)
|
|
267
|
+
concepts.push(`State:${comp.state}`);
|
|
268
|
+
if (comp.condition)
|
|
269
|
+
concepts.push(`Condition:${comp.condition}`);
|
|
270
|
+
patterns.push(result.patternMatch.type);
|
|
271
|
+
}
|
|
272
|
+
mappings.push({
|
|
273
|
+
requirement: reqText.substring(0, 80) + (reqText.length > 80 ? '...' : ''),
|
|
274
|
+
concepts,
|
|
275
|
+
patterns,
|
|
276
|
+
relatedRequirements: [], // Would need knowledge graph for actual implementation
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
const result = {
|
|
280
|
+
success: true,
|
|
281
|
+
mappings,
|
|
282
|
+
message: `Mapped ${mappings.length} requirements to ontology concepts`,
|
|
283
|
+
};
|
|
284
|
+
outputResult(result, globalOpts);
|
|
285
|
+
process.exit(ExitCode.SUCCESS);
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
if (!globalOpts.quiet) {
|
|
289
|
+
console.error(`❌ Mapping failed: ${error.message}`);
|
|
290
|
+
}
|
|
291
|
+
process.exit(ExitCode.GENERAL_ERROR);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
// requirements search
|
|
295
|
+
requirements
|
|
296
|
+
.command('search <query>')
|
|
297
|
+
.description('Search related requirements')
|
|
298
|
+
.option('--dir <path>', 'Search directory', 'storage/specs')
|
|
299
|
+
.action(async (query, options) => {
|
|
300
|
+
const globalOpts = getGlobalOptions(program);
|
|
301
|
+
try {
|
|
302
|
+
const searchDir = resolve(process.cwd(), options.dir ?? 'storage/specs');
|
|
303
|
+
// Simple search implementation
|
|
304
|
+
const matches = [];
|
|
305
|
+
const queryLower = query.toLowerCase();
|
|
306
|
+
try {
|
|
307
|
+
const { readdir } = await import('fs/promises');
|
|
308
|
+
const files = await readdir(searchDir);
|
|
309
|
+
for (const file of files) {
|
|
310
|
+
if (!file.endsWith('.md'))
|
|
311
|
+
continue;
|
|
312
|
+
const filePath = resolve(searchDir, file);
|
|
313
|
+
const content = await readFile(filePath, 'utf-8');
|
|
314
|
+
const lines = content.split('\n');
|
|
315
|
+
for (let i = 0; i < lines.length; i++) {
|
|
316
|
+
const line = lines[i];
|
|
317
|
+
if (line.toLowerCase().includes(queryLower)) {
|
|
318
|
+
// Extract requirement ID if present
|
|
319
|
+
const idMatch = line.match(/REQ-[A-Z]+-\d+/);
|
|
320
|
+
matches.push({
|
|
321
|
+
id: idMatch?.[0] ?? `${file}:${i + 1}`,
|
|
322
|
+
text: line.trim().substring(0, 100),
|
|
323
|
+
score: calculateMatchScore(line, query),
|
|
324
|
+
context: lines.slice(Math.max(0, i - 1), i + 2).join('\n'),
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
catch (err) {
|
|
331
|
+
// Directory doesn't exist or is empty
|
|
332
|
+
}
|
|
333
|
+
// Sort by score
|
|
334
|
+
matches.sort((a, b) => b.score - a.score);
|
|
335
|
+
const result = {
|
|
336
|
+
success: true,
|
|
337
|
+
matches: matches.slice(0, 20), // Top 20 matches
|
|
338
|
+
message: `Found ${matches.length} matches for "${query}"`,
|
|
339
|
+
};
|
|
340
|
+
outputResult(result, globalOpts);
|
|
341
|
+
process.exit(ExitCode.SUCCESS);
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
if (!globalOpts.quiet) {
|
|
345
|
+
console.error(`❌ Search failed: ${error.message}`);
|
|
346
|
+
}
|
|
347
|
+
process.exit(ExitCode.GENERAL_ERROR);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Calculate match score
|
|
353
|
+
*/
|
|
354
|
+
function calculateMatchScore(text, query) {
|
|
355
|
+
const textLower = text.toLowerCase();
|
|
356
|
+
const queryLower = query.toLowerCase();
|
|
357
|
+
const queryWords = queryLower.split(/\s+/);
|
|
358
|
+
let score = 0;
|
|
359
|
+
// Exact match bonus
|
|
360
|
+
if (textLower.includes(queryLower)) {
|
|
361
|
+
score += 1.0;
|
|
362
|
+
}
|
|
363
|
+
// Word match bonus
|
|
364
|
+
for (const word of queryWords) {
|
|
365
|
+
if (textLower.includes(word)) {
|
|
366
|
+
score += 0.3;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
// EARS keyword bonus
|
|
370
|
+
if (text.match(/\b(SHALL|WHEN|WHILE|IF|THE)\b/i)) {
|
|
371
|
+
score += 0.2;
|
|
372
|
+
}
|
|
373
|
+
return Math.min(score, 2.0);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Generate markdown output
|
|
377
|
+
*/
|
|
378
|
+
function generateMarkdownOutput(result) {
|
|
379
|
+
let output = '# Requirements Analysis\n\n';
|
|
380
|
+
output += '## Summary\n\n';
|
|
381
|
+
output += `- **Total Requirements**: ${result.summary.total}\n`;
|
|
382
|
+
output += '- **By Pattern**:\n';
|
|
383
|
+
for (const [pattern, count] of Object.entries(result.summary.byPattern)) {
|
|
384
|
+
output += ` - ${pattern}: ${count}\n`;
|
|
385
|
+
}
|
|
386
|
+
output += '- **By Priority**:\n';
|
|
387
|
+
for (const [priority, count] of Object.entries(result.summary.byPriority)) {
|
|
388
|
+
output += ` - ${priority}: ${count}\n`;
|
|
389
|
+
}
|
|
390
|
+
output += '\n## Requirements\n\n';
|
|
391
|
+
for (const req of result.requirements) {
|
|
392
|
+
output += `### ${req.id} (${req.priority})\n\n`;
|
|
393
|
+
output += `**Pattern**: ${req.pattern}\n\n`;
|
|
394
|
+
output += `> ${req.text}\n\n`;
|
|
395
|
+
if (req.rationale) {
|
|
396
|
+
output += `*${req.rationale}*\n\n`;
|
|
397
|
+
}
|
|
398
|
+
output += '---\n\n';
|
|
399
|
+
}
|
|
400
|
+
return output;
|
|
401
|
+
}
|
|
402
|
+
export { parseEARSRequirements };
|
|
403
|
+
//# sourceMappingURL=requirements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirements.js","sourceRoot":"","sources":["../../../src/cli/commands/requirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EACL,mBAAmB,EAGnB,oBAAoB,GACrB,MAAM,oCAAoC,CAAC;AAsF5C;;GAEG;AACH,SAAS,qBAAqB,CAAC,OAAe;IAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,IAAI,UAAU,GAAG,EAAE,CAAC;IAEpB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAE5B,gCAAgC;QAChC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACpE,IAAI,UAAU,EAAE,CAAC;gBACf,YAAY,CAAC,IAAI,CA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G,CAAC,EAAE,KAAK,GAAG,CAAC,QAAQ,OAAO,CAAC;QAChD,MAAM,IAAI,gBAAgB,GAAG,CAAC,OAAO,MAAM,CAAC;QAC5C,MAAM,IAAI,KAAK,GAAG,CAAC,IAAI,MAAM,CAAC;QAC9B,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAClB,MAAM,IAAI,IAAI,GAAG,CAAC,SAAS,OAAO,CAAC;QACrC,CAAC;QACD,MAAM,IAAI,SAAS,CAAC;IACtB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skills Command
|
|
3
|
+
*
|
|
4
|
+
* Manage GitHub Agent Skills for MUSUBIX
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @module cli/commands/skills
|
|
8
|
+
*
|
|
9
|
+
* @see REQ-SKL-001 - Skills Directory Structure
|
|
10
|
+
* @see REQ-SKL-002 - Skills Manifest Format
|
|
11
|
+
* @see REQ-SKL-003 - Skills Validation
|
|
12
|
+
* @see REQ-SKL-004 - Skills CLI Integration
|
|
13
|
+
* @see DES-MUSUBIX-001 Section 16-B - Agent Skills設計
|
|
14
|
+
* @see TSK-061 - Skills CLI実装
|
|
15
|
+
*/
|
|
16
|
+
import type { Command } from 'commander';
|
|
17
|
+
/**
|
|
18
|
+
* Skills command options
|
|
19
|
+
*/
|
|
20
|
+
export interface SkillsOptions {
|
|
21
|
+
skillsDir?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Skill metadata from SKILL.md frontmatter
|
|
25
|
+
*/
|
|
26
|
+
export interface SkillMetadata {
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
license?: string;
|
|
30
|
+
version?: string;
|
|
31
|
+
author?: string;
|
|
32
|
+
tags?: string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Skill information
|
|
36
|
+
*/
|
|
37
|
+
export interface SkillInfo {
|
|
38
|
+
name: string;
|
|
39
|
+
path: string;
|
|
40
|
+
metadata: SkillMetadata | null;
|
|
41
|
+
hasSkillMd: boolean;
|
|
42
|
+
error?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Skill validation result
|
|
46
|
+
*/
|
|
47
|
+
export interface SkillValidationResult {
|
|
48
|
+
skillName: string;
|
|
49
|
+
valid: boolean;
|
|
50
|
+
errors: string[];
|
|
51
|
+
warnings: string[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Skills list result
|
|
55
|
+
*/
|
|
56
|
+
export interface SkillsListResult {
|
|
57
|
+
success: boolean;
|
|
58
|
+
skills: SkillInfo[];
|
|
59
|
+
skillsDir: string;
|
|
60
|
+
message: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Skills validate result
|
|
64
|
+
*/
|
|
65
|
+
export interface SkillsValidateResult {
|
|
66
|
+
success: boolean;
|
|
67
|
+
results: SkillValidationResult[];
|
|
68
|
+
message: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Skills create result
|
|
72
|
+
*/
|
|
73
|
+
export interface SkillsCreateResult {
|
|
74
|
+
success: boolean;
|
|
75
|
+
skillPath: string;
|
|
76
|
+
filesCreated: string[];
|
|
77
|
+
message: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Register skills command
|
|
81
|
+
*/
|
|
82
|
+
export declare function registerSkillsCommand(program: Command): void;
|
|
83
|
+
/**
|
|
84
|
+
* Parse YAML frontmatter from SKILL.md content
|
|
85
|
+
*/
|
|
86
|
+
export declare function parseFrontmatter(content: string): SkillMetadata | null;
|
|
87
|
+
/**
|
|
88
|
+
* Execute skills list command
|
|
89
|
+
*/
|
|
90
|
+
export declare function executeSkillsList(options: SkillsOptions): Promise<SkillsListResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Execute skills validate command
|
|
93
|
+
*/
|
|
94
|
+
export declare function executeSkillsValidate(skillName: string | undefined, options: SkillsOptions): Promise<SkillsValidateResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Execute skills create command
|
|
97
|
+
*/
|
|
98
|
+
export declare function executeSkillsCreate(skillName: string, options: SkillsOptions): Promise<SkillsCreateResult>;
|
|
99
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/skills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;I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