musubix 1.0.1 → 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.
@@ -0,0 +1,304 @@
1
+ # MUSUBIX Validate Command
2
+
3
+ Validate constitutional compliance and requirements coverage.
4
+
5
+ ---
6
+
7
+ ## Instructions for AI Agent
8
+
9
+ You are executing the `musubix validate [feature-name]` command to validate constitutional compliance.
10
+
11
+ ### Command Format
12
+
13
+ ```bash
14
+ npx musubix validate authentication
15
+ npx musubix trace validate
16
+ npx musubix trace matrix
17
+ ```
18
+
19
+ ### Your Task
20
+
21
+ Perform comprehensive validation of the feature implementation against:
22
+
23
+ 1. 9 Constitutional Articles
24
+ 2. Requirements coverage (100% traceability)
25
+ 3. Code quality standards
26
+ 4. Test coverage
27
+
28
+ ---
29
+
30
+ ## Process
31
+
32
+ ### 1. Read All Documentation
33
+
34
+ ```bash
35
+ # Requirements and Design
36
+ storage/specs/REQ-{{FEATURE}}-001.md
37
+ storage/specs/DES-{{FEATURE}}-001.md
38
+ storage/specs/TSK-{{FEATURE}}-001.md
39
+
40
+ # Steering Context
41
+ steering/structure.ja.md
42
+ steering/tech.ja.md
43
+ steering/rules/constitution.md
44
+
45
+ # Source Code
46
+ packages/core/src/{{feature}}/**/*.ts
47
+ packages/core/__tests__/**/*.test.ts
48
+ packages/mcp-server/src/tools/**/*.ts
49
+ ```
50
+
51
+ ---
52
+
53
+ ### 2. Constitutional Validation
54
+
55
+ Validate each of the 9 Constitutional Articles:
56
+
57
+ #### Article I: Library-First Principle
58
+
59
+ **Requirement**: Features as independent packages
60
+
61
+ **Validation**:
62
+ - [ ] Feature in `packages/` directory
63
+ - [ ] Has `package.json` (monorepo workspace)
64
+ - [ ] Exports public API via `index.ts`
65
+ - [ ] No circular dependencies
66
+
67
+ ```markdown
68
+ ### Article I: Library-First Principle
69
+
70
+ **Status**: ✅ PASS / ❌ FAIL
71
+
72
+ **Evidence**:
73
+ - Location: `packages/core/src/{{feature}}/`
74
+ - Public API: `packages/core/src/{{feature}}/index.ts`
75
+ - Exports: {{Feature}}Service, {{Feature}}Options
76
+ ```
77
+
78
+ ---
79
+
80
+ #### Article II: CLI Interface Mandate
81
+
82
+ **Requirement**: CLI interface for all libraries
83
+
84
+ **Validation**:
85
+ - [ ] CLI command exists in `packages/core/src/cli/commands/`
86
+ - [ ] `--help` flag works
87
+ - [ ] Documented in CLI help
88
+
89
+ ```markdown
90
+ ### Article II: CLI Interface Mandate
91
+
92
+ **Status**: ✅ PASS / ❌ FAIL
93
+
94
+ **Evidence**:
95
+ - CLI: `npx musubix {{feature}}`
96
+ - Help: `npx musubix {{feature}} --help`
97
+ - Registered: packages/core/src/cli/index.ts
98
+ ```
99
+
100
+ ---
101
+
102
+ #### Article III: Test-First Imperative
103
+
104
+ **Requirement**: Tests before implementation (Red-Green-Blue)
105
+
106
+ **Validation**:
107
+ - [ ] Tests in `packages/core/__tests__/unit/`
108
+ - [ ] Tests cover all requirements
109
+ - [ ] Coverage ≥ 80%
110
+
111
+ ```bash
112
+ npm run test:coverage
113
+ ```
114
+
115
+ ```markdown
116
+ ### Article III: Test-First Imperative
117
+
118
+ **Status**: ✅ PASS / ❌ FAIL
119
+
120
+ **Coverage**: XX%
121
+ **Test Files**:
122
+ - packages/core/__tests__/unit/{{feature}}.test.ts
123
+ - packages/core/__tests__/integration/{{feature}}.integration.test.ts
124
+ ```
125
+
126
+ ---
127
+
128
+ #### Article IV: EARS Requirements Format
129
+
130
+ **Requirement**: All requirements in EARS format
131
+
132
+ **Validation**:
133
+ - [ ] All requirements use EARS patterns
134
+ - [ ] Each has unique ID (REQ-XXX-NNN)
135
+ - [ ] Each has acceptance criteria
136
+
137
+ ```markdown
138
+ ### Article IV: EARS Requirements Format
139
+
140
+ **Status**: ✅ PASS / ❌ FAIL
141
+
142
+ **Requirements Checked**: X
143
+ **EARS Patterns Used**:
144
+ - Ubiquitous: X
145
+ - Event-driven: X
146
+ - State-driven: X
147
+ - Unwanted: X
148
+ - Optional: X
149
+ ```
150
+
151
+ ---
152
+
153
+ #### Article V: Traceability Mandate
154
+
155
+ **Requirement**: 100% traceability REQ↔DES↔TSK↔CODE↔TEST
156
+
157
+ **Validation**:
158
+
159
+ ```markdown
160
+ ### Article V: Traceability Mandate
161
+
162
+ **Status**: ✅ PASS / ❌ FAIL
163
+
164
+ **Traceability Matrix**:
165
+
166
+ | Requirement | Design | Task | Code | Test |
167
+ |-------------|--------|------|------|------|
168
+ | REQ-XXX-001 | DES-XXX-001 | TSK-XXX-001 | {{feature}}/service.ts | {{feature}}.test.ts |
169
+
170
+ **Coverage**: 100%
171
+ **Unmapped Requirements**: None
172
+ ```
173
+
174
+ ---
175
+
176
+ #### Article VI: Project Memory (Steering)
177
+
178
+ **Requirement**: Consult steering before decisions
179
+
180
+ **Validation**:
181
+ - [ ] Design references steering files
182
+ - [ ] Tech stack matches `steering/tech.ja.md`
183
+ - [ ] Architecture matches `steering/structure.ja.md`
184
+
185
+ ---
186
+
187
+ #### Article VII: Design Patterns
188
+
189
+ **Requirement**: Document pattern applications
190
+
191
+ **Validation**:
192
+ - [ ] Patterns documented in design
193
+ - [ ] ADRs created for decisions
194
+
195
+ ---
196
+
197
+ #### Article VIII: Decision Records
198
+
199
+ **Requirement**: All decisions as ADRs
200
+
201
+ **Validation**:
202
+ - [ ] ADRs in design document
203
+ - [ ] Each ADR has: Status, Context, Decision, Consequences
204
+
205
+ ---
206
+
207
+ #### Article IX: Quality Gates
208
+
209
+ **Requirement**: Validate before phase transitions
210
+
211
+ **Validation**:
212
+ - [ ] Requirements validated before design
213
+ - [ ] Design validated before implementation
214
+ - [ ] Tests pass before deployment
215
+
216
+ ---
217
+
218
+ ### 3. Generate Validation Report
219
+
220
+ ```markdown
221
+ # Validation Report: {{FEATURE_NAME}}
222
+
223
+ **Date**: {{DATE}}
224
+ **Validator**: AI Agent
225
+
226
+ ## Summary
227
+
228
+ | Article | Status | Score |
229
+ |---------|--------|-------|
230
+ | I. Library-First | ✅ | 100% |
231
+ | II. CLI Interface | ✅ | 100% |
232
+ | III. Test-First | ✅ | 85% |
233
+ | IV. EARS Format | ✅ | 100% |
234
+ | V. Traceability | ✅ | 100% |
235
+ | VI. Project Memory | ✅ | 100% |
236
+ | VII. Design Patterns | ✅ | 100% |
237
+ | VIII. Decision Records | ✅ | 100% |
238
+ | IX. Quality Gates | ✅ | 100% |
239
+
240
+ **Overall Compliance**: ✅ PASS (97%)
241
+
242
+ ## Test Coverage
243
+
244
+ - Unit Tests: XX%
245
+ - Integration Tests: XX%
246
+ - Total: XX%
247
+
248
+ ## Traceability Coverage
249
+
250
+ - Requirements → Design: 100%
251
+ - Design → Tasks: 100%
252
+ - Tasks → Code: 100%
253
+ - Code → Tests: 100%
254
+
255
+ ## Issues Found
256
+
257
+ ### Critical (P0)
258
+ None
259
+
260
+ ### High (P1)
261
+ None
262
+
263
+ ### Medium (P2)
264
+ - [Issue description]
265
+
266
+ ## Recommendations
267
+
268
+ 1. [Recommendation 1]
269
+ 2. [Recommendation 2]
270
+ ```
271
+
272
+ ---
273
+
274
+ ### 4. MCP Tool Integration
275
+
276
+ Use MUSUBIX MCP tools:
277
+
278
+ ```
279
+ sdd_validate_constitution - Validate constitutional compliance
280
+ sdd_validate_traceability - Validate traceability matrix
281
+ ```
282
+
283
+ ---
284
+
285
+ ### 5. Validation Commands
286
+
287
+ ```bash
288
+ # Run all validations
289
+ npm test
290
+ npm run typecheck
291
+ npm run lint
292
+
293
+ # Check coverage
294
+ npm run test:coverage
295
+
296
+ # Traceability
297
+ npx musubix trace matrix
298
+ npx musubix trace validate
299
+ ```
300
+
301
+ ---
302
+
303
+ **MUSUBIX**: https://github.com/nahisaho/MUSUBIX
304
+ **Version**: 1.0.0
@@ -0,0 +1,229 @@
1
+ ---
2
+ name: musubix-code-generation
3
+ description: Guide for generating code from design specifications using MUSUBIX. Use this when asked to generate code, implement features, or create components following design documents.
4
+ license: MIT
5
+ ---
6
+
7
+ # MUSUBIX Code Generation Skill
8
+
9
+ This skill guides you through generating code from design specifications following MUSUBIX methodology.
10
+
11
+ ## Prerequisites
12
+
13
+ Before generating code:
14
+
15
+ 1. Verify design document exists (`DES-*`)
16
+ 2. Verify requirements are traceable (`REQ-*`)
17
+ 3. Check `steering/tech.ja.md` for technology stack
18
+
19
+ ## Supported Languages
20
+
21
+ | Language | Extension | Features |
22
+ |----------|-----------|----------|
23
+ | TypeScript | `.ts` | Full support with types |
24
+ | JavaScript | `.js` | ES6+ modules |
25
+ | Python | `.py` | Type hints support |
26
+ | Java | `.java` | Interface/Class generation |
27
+ | Go | `.go` | Struct/Interface generation |
28
+ | Rust | `.rs` | Trait/Struct generation |
29
+ | C# | `.cs` | Interface/Class generation |
30
+
31
+ ## Code Generation Workflow
32
+
33
+ ### Step 1: Read Design Document
34
+
35
+ ```bash
36
+ # Generate code from design
37
+ npx musubix codegen generate <design-file>
38
+ ```
39
+
40
+ ### Step 2: Generate with Traceability
41
+
42
+ Always include requirement references:
43
+
44
+ ```typescript
45
+ /**
46
+ * UserService - Handles user operations
47
+ *
48
+ * @see REQ-INT-001 - Neuro-Symbolic Integration
49
+ * @see DES-INT-001 - Integration Layer Design
50
+ */
51
+ export class UserService {
52
+ // Implementation
53
+ }
54
+ ```
55
+
56
+ ### Step 3: Follow Test-First (Article III)
57
+
58
+ 1. **Write test first**:
59
+ ```typescript
60
+ describe('UserService', () => {
61
+ it('should create user', async () => {
62
+ const service = new UserService();
63
+ const user = await service.create({ name: 'Test' });
64
+ expect(user.id).toBeDefined();
65
+ });
66
+ });
67
+ ```
68
+
69
+ 2. **Implement minimal code**:
70
+ ```typescript
71
+ export class UserService {
72
+ async create(data: CreateUserDto): Promise<User> {
73
+ return { id: generateId(), ...data };
74
+ }
75
+ }
76
+ ```
77
+
78
+ 3. **Refactor**
79
+
80
+ ## Design Pattern Templates
81
+
82
+ ### Singleton Pattern
83
+ ```typescript
84
+ /**
85
+ * @see REQ-DES-001 - Pattern Detection
86
+ * @pattern Singleton
87
+ */
88
+ export class ConfigManager {
89
+ private static instance: ConfigManager;
90
+
91
+ private constructor() {}
92
+
93
+ static getInstance(): ConfigManager {
94
+ if (!ConfigManager.instance) {
95
+ ConfigManager.instance = new ConfigManager();
96
+ }
97
+ return ConfigManager.instance;
98
+ }
99
+ }
100
+ ```
101
+
102
+ ### Factory Pattern
103
+ ```typescript
104
+ /**
105
+ * @see REQ-DES-001 - Pattern Detection
106
+ * @pattern Factory
107
+ */
108
+ export interface ServiceFactory {
109
+ create(type: string): Service;
110
+ }
111
+
112
+ export class DefaultServiceFactory implements ServiceFactory {
113
+ create(type: string): Service {
114
+ switch (type) {
115
+ case 'auth': return new AuthService();
116
+ case 'user': return new UserService();
117
+ default: throw new Error(`Unknown service: ${type}`);
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### Repository Pattern
124
+ ```typescript
125
+ /**
126
+ * @see REQ-COD-001 - Code Generation
127
+ * @pattern Repository
128
+ */
129
+ export interface Repository<T> {
130
+ findById(id: string): Promise<T | null>;
131
+ findAll(): Promise<T[]>;
132
+ save(entity: T): Promise<T>;
133
+ delete(id: string): Promise<void>;
134
+ }
135
+
136
+ export class UserRepository implements Repository<User> {
137
+ async findById(id: string): Promise<User | null> {
138
+ // Implementation
139
+ }
140
+ // ... other methods
141
+ }
142
+ ```
143
+
144
+ ## CLI Commands
145
+
146
+ ```bash
147
+ # Generate code from design
148
+ npx musubix codegen generate <design-file>
149
+
150
+ # Analyze existing code
151
+ npx musubix codegen analyze <file>
152
+
153
+ # Security scan
154
+ npx musubix codegen security <path>
155
+ ```
156
+
157
+ ## Quality Checks (Article IX)
158
+
159
+ Before committing code:
160
+
161
+ - [ ] **Type Safety**: No `any` types (TypeScript)
162
+ - [ ] **Traceability**: All classes/functions have `@see` references
163
+ - [ ] **Tests**: Test coverage ≥ 80%
164
+ - [ ] **Linting**: `npm run lint` passes
165
+ - [ ] **Build**: `npm run build` succeeds
166
+
167
+ ## Neuro-Symbolic Integration (REQ-INT-002)
168
+
169
+ When generating code that involves decision-making:
170
+
171
+ ```typescript
172
+ /**
173
+ * @see REQ-INT-002 - Confidence Evaluation
174
+ */
175
+ async function integrateResults(
176
+ neuralResult: NeuralResult,
177
+ symbolicResult: SymbolicResult
178
+ ): Promise<FinalResult> {
179
+ // Decision rules from REQ-INT-002
180
+ if (symbolicResult.status === 'invalid') {
181
+ return rejectNeural(neuralResult);
182
+ }
183
+
184
+ if (neuralResult.confidence >= 0.8) {
185
+ return adoptNeural(neuralResult);
186
+ }
187
+
188
+ return prioritizeSymbolic(symbolicResult);
189
+ }
190
+ ```
191
+
192
+ ## File Structure Convention
193
+
194
+ ```
195
+ packages/
196
+ ├── core/
197
+ │ └── src/
198
+ │ ├── [feature]/
199
+ │ │ ├── index.ts # Public exports
200
+ │ │ ├── [feature].ts # Main implementation
201
+ │ │ ├── types.ts # Type definitions
202
+ │ │ └── __tests__/ # Tests
203
+ │ └── index.ts # Package exports
204
+ ```
205
+
206
+ ## Error Handling Pattern
207
+
208
+ ```typescript
209
+ /**
210
+ * @see REQ-ERR-001 - Graceful Degradation
211
+ */
212
+ export class MuSubixError extends Error {
213
+ constructor(
214
+ message: string,
215
+ public code: string,
216
+ public recoverable: boolean = true
217
+ ) {
218
+ super(message);
219
+ this.name = 'MuSubixError';
220
+ }
221
+ }
222
+
223
+ // Usage
224
+ throw new MuSubixError(
225
+ 'Failed to connect to YATA',
226
+ 'YATA_CONNECTION_ERROR',
227
+ true // Can retry
228
+ );
229
+ ```
@@ -0,0 +1,161 @@
1
+ ---
2
+ name: musubix-ears-validation
3
+ description: Guide for validating and creating EARS-format requirements. Use this when asked to write requirements, validate requirement syntax, or convert natural language to EARS format.
4
+ license: MIT
5
+ ---
6
+
7
+ # MUSUBIX EARS Validation Skill
8
+
9
+ This skill helps you create and validate requirements using EARS (Easy Approach to Requirements Syntax) format.
10
+
11
+ ## EARS Pattern Reference
12
+
13
+ ### 1. Ubiquitous Pattern
14
+ **Use for**: Requirements that must always be satisfied.
15
+
16
+ **Syntax**:
17
+ ```
18
+ THE [system name] SHALL [requirement]
19
+ ```
20
+
21
+ **Example**:
22
+ ```markdown
23
+ THE AuthService SHALL authenticate users with valid credentials.
24
+ ```
25
+
26
+ ### 2. Event-Driven Pattern
27
+ **Use for**: Requirements triggered by specific events.
28
+
29
+ **Syntax**:
30
+ ```
31
+ WHEN [trigger event], THE [system name] SHALL [response]
32
+ ```
33
+
34
+ **Example**:
35
+ ```markdown
36
+ WHEN a user submits login credentials, THE AuthService SHALL validate the credentials within 2 seconds.
37
+ ```
38
+
39
+ ### 3. State-Driven Pattern
40
+ **Use for**: Requirements that apply while in a specific state.
41
+
42
+ **Syntax**:
43
+ ```
44
+ WHILE [system state], THE [system name] SHALL [behavior]
45
+ ```
46
+
47
+ **Example**:
48
+ ```markdown
49
+ WHILE the system is in maintenance mode, THE API SHALL return 503 Service Unavailable.
50
+ ```
51
+
52
+ ### 4. Unwanted Behavior Pattern
53
+ **Use for**: Behaviors that must be prevented.
54
+
55
+ **Syntax**:
56
+ ```
57
+ THE [system name] SHALL NOT [unwanted behavior]
58
+ ```
59
+
60
+ **Example**:
61
+ ```markdown
62
+ THE AuthService SHALL NOT store passwords in plain text.
63
+ ```
64
+
65
+ ### 5. Optional Pattern
66
+ **Use for**: Conditional requirements.
67
+
68
+ **Syntax**:
69
+ ```
70
+ IF [condition], THEN THE [system name] SHALL [response]
71
+ ```
72
+
73
+ **Example**:
74
+ ```markdown
75
+ IF two-factor authentication is enabled, THEN THE AuthService SHALL require a verification code.
76
+ ```
77
+
78
+ ## Validation Checklist
79
+
80
+ When validating EARS requirements, check:
81
+
82
+ - [ ] **Pattern Compliance**: Does it follow one of the 5 EARS patterns?
83
+ - [ ] **System Name**: Is the system/component clearly identified?
84
+ - [ ] **SHALL Keyword**: Is "SHALL" used for mandatory requirements?
85
+ - [ ] **Measurable**: Is the requirement testable and measurable?
86
+ - [ ] **Atomic**: Does it describe a single requirement?
87
+ - [ ] **No Ambiguity**: Is the language clear and unambiguous?
88
+
89
+ ## CLI Commands
90
+
91
+ ```bash
92
+ # Validate EARS syntax
93
+ npx musubix requirements validate <file>
94
+
95
+ # Convert natural language to EARS
96
+ npx musubix requirements analyze <file>
97
+
98
+ # Map to ontology
99
+ npx musubix requirements map <file>
100
+ ```
101
+
102
+ ## Conversion Examples
103
+
104
+ ### Natural Language → EARS
105
+
106
+ **Input**: "Users should be able to login"
107
+
108
+ **Output**:
109
+ ```markdown
110
+ THE AuthenticationModule SHALL authenticate users with valid credentials.
111
+ ```
112
+
113
+ **Input**: "Show error when password is wrong"
114
+
115
+ **Output**:
116
+ ```markdown
117
+ WHEN invalid credentials are provided, THE AuthenticationModule SHALL display an error message.
118
+ ```
119
+
120
+ **Input**: "Don't allow SQL injection"
121
+
122
+ **Output**:
123
+ ```markdown
124
+ THE InputValidator SHALL NOT accept input containing SQL injection patterns.
125
+ ```
126
+
127
+ ## Priority Levels
128
+
129
+ | Priority | Description | Usage |
130
+ |----------|-------------|-------|
131
+ | **P0** | 必須 (Must Have) | Release blocker |
132
+ | **P1** | 重要 (Should Have) | Implement if possible |
133
+ | **P2** | 任意 (Nice to Have) | Time permitting |
134
+
135
+ ## Requirement Document Template
136
+
137
+ ```markdown
138
+ ### REQ-[CATEGORY]-[NUMBER]: [Title]
139
+
140
+ **種別**: [UBIQUITOUS|EVENT-DRIVEN|STATE-DRIVEN|UNWANTED|OPTIONAL]
141
+ **優先度**: [P0|P1|P2]
142
+
143
+ **要件**:
144
+ [EARS形式の要件文]
145
+
146
+ **検証方法**: [Unit Test|Integration Test|E2E Test|Manual]
147
+ **受入基準**:
148
+ - [ ] Criterion 1
149
+ - [ ] Criterion 2
150
+
151
+ **トレーサビリティ**: DES-XXX, TEST-XXX
152
+ **憲法準拠**: Article IV (EARS Format)
153
+ ```
154
+
155
+ ## Common Mistakes to Avoid
156
+
157
+ 1. ❌ Using "should" instead of "SHALL"
158
+ 2. ❌ Combining multiple requirements in one statement
159
+ 3. ❌ Vague or unmeasurable criteria
160
+ 4. ❌ Missing system name
161
+ 5. ❌ Using implementation details in requirements