@polymorphism-tech/morph-spec 7.2.0 → 7.3.0

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.
Files changed (61) hide show
  1. package/README.md +2 -2
  2. package/claude-plugin.json +1 -1
  3. package/docs/CHEATSHEET.md +1 -1
  4. package/docs/QUICKSTART.md +1 -1
  5. package/framework/CLAUDE.md +1 -1
  6. package/framework/commands/morph-apply.md +1 -1
  7. package/framework/commands/morph-proposal.md +1 -1
  8. package/framework/hooks/README.md +1 -1
  9. package/framework/hooks/claude-code/core/validate-completion.js +136 -136
  10. package/framework/phases.json +1 -1
  11. package/framework/skills/README.md +1 -1
  12. package/framework/skills/core/morph-apply/SKILL.md +1 -1
  13. package/framework/skills/core/morph-brainstorming/SKILL.md +1 -1
  14. package/framework/skills/core/morph-eval/SKILL.md +1 -1
  15. package/framework/skills/core/morph-implement/SKILL.md +1 -1
  16. package/framework/skills/core/morph-plan/SKILL.md +1 -1
  17. package/framework/skills/core/morph-proposal/SKILL.md +1 -1
  18. package/framework/skills/core/morph-review/SKILL.md +1 -1
  19. package/framework/skills/core/morph-stack-scan/SKILL.md +1 -1
  20. package/framework/skills/core/morph-standards/SKILL.md +1 -1
  21. package/framework/templates/README.md +708 -709
  22. package/framework/templates/REGISTRY.json +1 -20
  23. package/framework/templates/context/CONTEXT-FEATURE.md +276 -276
  24. package/framework/templates/docs/proposal.md +171 -171
  25. package/framework/templates/feature/recap.md +145 -145
  26. package/package.json +1 -1
  27. package/src/commands/project/doctor.js +941 -946
  28. package/src/commands/project/status.js +373 -376
  29. package/src/commands/validation/validate-feature.js +315 -287
  30. package/src/core/state/state-manager.js +900 -934
  31. package/src/dashboard/app/App.jsx +29 -31
  32. package/src/dashboard/app/components/Sidebar.jsx +44 -45
  33. package/src/dashboard/scanner/index.js +20 -21
  34. package/src/lib/context/context-builder.js +3 -3
  35. package/src/lib/generators/context-generator.js +2 -3
  36. package/src/lib/generators/mandate-generator.js +48 -92
  37. package/src/lib/generators/metadata-extractor.js +385 -386
  38. package/src/lib/generators/recap-generator.js +285 -285
  39. package/src/lib/validators/content/content-validator.js +89 -286
  40. package/src/lib/validators/content/index.js +0 -1
  41. package/framework/templates/feature/tasks.md +0 -199
  42. package/framework/workflows/README.md +0 -1041
  43. package/framework/workflows/configs/fast-track.json +0 -46
  44. package/framework/workflows/configs/full.json +0 -64
  45. package/framework/workflows/configs/quick.json +0 -32
  46. package/framework/workflows/configs/standard.json +0 -57
  47. package/framework/workflows/docs/STORY-DRIVEN-DEVELOPMENT.md +0 -392
  48. package/framework/workflows/docs/design-impl.md +0 -37
  49. package/framework/workflows/docs/enforcement-pipeline.md +0 -668
  50. package/framework/workflows/docs/fast-track.md +0 -29
  51. package/framework/workflows/docs/full-morph.md +0 -69
  52. package/framework/workflows/docs/standard.md +0 -49
  53. package/framework/workflows/docs/ui-refresh.md +0 -39
  54. package/src/commands/state/index.js +0 -7
  55. package/src/core/workflows/workflow-detector.js +0 -586
  56. package/src/core/workflows/workflow-router.js +0 -204
  57. package/src/dashboard/app/pages/Workflows.jsx +0 -346
  58. package/src/dashboard/scanner/workflows-scanner.js +0 -18
  59. package/src/lib/phase-chain/phase-validator.js +0 -359
  60. package/src/lib/validators/content/cross-phase-validator.js +0 -281
  61. package/src/lib/validators/spec-validator.js +0 -312
@@ -1,286 +1,89 @@
1
- import { readFileSync, existsSync } from 'fs';
2
-
3
- /**
4
- * Content Validator - Validates structure and content of output files
5
- *
6
- * Ensures spec.md, tasks.json, and other outputs have required sections
7
- * and proper structure before allowing phase transitions.
8
- */
9
-
10
- /**
11
- * Validate spec.md structure
12
- * @param {string} specPath - Path to spec.md file
13
- * @returns {Object} Validation result
14
- */
15
- export function validateSpecContent(specPath) {
16
- if (!existsSync(specPath)) {
17
- return {
18
- valid: false,
19
- missing: ['File does not exist'],
20
- errors: ['Spec file not found at: ' + specPath]
21
- };
22
- }
23
-
24
- const content = readFileSync(specPath, 'utf8');
25
-
26
- // Required sections (flexible regex handles numbered variants like '## 1. Overview')
27
- const requiredSections = [
28
- { label: '## Overview', pattern: /^##\s+(?:\d+\.?\s+)?Overview/i },
29
- { label: '## Functional Requirements', pattern: /^##\s+(?:\d+\.?\s+)?Functional Requirements/i },
30
- { label: '## Technical', pattern: /^##\s+(?:\d+\.?\s+)?Technical/i },
31
- { label: '## Data Model', pattern: /^##\s+(?:\d+\.?\s+)?Data Model/i },
32
- ];
33
-
34
- const lines = content.split('\n');
35
- const missing = requiredSections.filter(s =>
36
- !lines.some(line => s.pattern.test(line))
37
- );
38
-
39
- // Additional quality checks
40
- const errors = [];
41
- const warnings = [];
42
-
43
- // Missing sections are warnings, not errors — not every spec needs all sections
44
- // (e.g., frontend-only features may not have Data Model, CLI tools may not have Technical Architecture)
45
- if (missing.length > 0) {
46
- missing.forEach(s => {
47
- warnings.push(`Missing recommended section: ${s.label}`);
48
- });
49
- }
50
-
51
- // Check minimum content length
52
- if (content.length < 500) {
53
- warnings.push('Spec seems very short (< 500 characters). Consider adding more detail.');
54
- }
55
-
56
- // Check for placeholder text that should be replaced
57
- const placeholders = ['TODO', 'TBD', 'PLACEHOLDER', '{{'];
58
- placeholders.forEach(placeholder => {
59
- if (content.includes(placeholder)) {
60
- warnings.push(`Spec contains "${placeholder}" - ensure all placeholders are replaced`);
61
- }
62
- });
63
-
64
- // Check for anti-patterns mentioned in the plan
65
- if (content.toLowerCase().includes('manual azure portal')) {
66
- errors.push(
67
- 'Spec mentions manual Azure portal creation. ' +
68
- 'All infrastructure must be defined in Bicep (Infrastructure as Code).'
69
- );
70
- }
71
-
72
- if (content.toLowerCase().includes('create resource manually')) {
73
- errors.push(
74
- 'Spec mentions manual resource creation. ' +
75
- 'Use IaC (Bicep) for all infrastructure resources.'
76
- );
77
- }
78
-
79
- return {
80
- valid: errors.length === 0,
81
- missing,
82
- errors,
83
- warnings,
84
- sections: {
85
- required: requiredSections.length,
86
- found: requiredSections.length - missing.length
87
- }
88
- };
89
- }
90
-
91
- /**
92
- * Validate tasks.md structure
93
- * @param {string} tasksPath - Path to tasks.md file
94
- * @returns {Object} Validation result
95
- */
96
- export function validateTasksContent(tasksPath) {
97
- if (!existsSync(tasksPath)) {
98
- return {
99
- valid: false,
100
- errors: ['Tasks file not found at: ' + tasksPath]
101
- };
102
- }
103
-
104
- const content = readFileSync(tasksPath, 'utf8');
105
- const errors = [];
106
- const warnings = [];
107
-
108
- // Extract task IDs from headings: ### T001 — title OR ### T001: title
109
- const taskRe = /^###\s+(T\d{3})\s*[—–:\-]\s*(.+)$/gm;
110
- const checkpointRe = /^###\s+(CHECKPOINT[_-]\d+)\s*[—–:\-]\s*(.+)$/gm;
111
-
112
- const tasks = [...content.matchAll(taskRe)];
113
- const checkpoints = [...content.matchAll(checkpointRe)];
114
-
115
- if (tasks.length === 0) {
116
- errors.push('No tasks found in tasks.md — expected headings like "### T001 — Title" or "### T001: Title"');
117
- return { valid: false, errors, warnings };
118
- }
119
-
120
- // Validate no duplicate IDs
121
- const ids = tasks.map(m => m[1]);
122
- const dupes = ids.filter((id, i) => ids.indexOf(id) !== i);
123
- dupes.forEach(id => errors.push(`Duplicate task ID: ${id}`));
124
-
125
- // Check for dependency references (look for "Dependencies: T###")
126
- const depRe = /\*\*Dependenc(?:y|ies):\*\*\s*([T\d, ]+)/gi;
127
- const allDepRefs = [...content.matchAll(depRe)]
128
- .flatMap(m => m[1].split(/[,\s]+/).filter(s => /^T\d{3}$/.test(s)));
129
-
130
- const idSet = new Set(ids);
131
- allDepRefs.forEach(depId => {
132
- if (!idSet.has(depId)) {
133
- warnings.push(`Dependency reference "${depId}" not found in task list`);
134
- }
135
- });
136
-
137
- return {
138
- valid: errors.length === 0,
139
- errors,
140
- warnings,
141
- stats: {
142
- totalTasks: tasks.length + checkpoints.length,
143
- regularTasks: tasks.length,
144
- checkpoints: checkpoints.length,
145
- },
146
- };
147
- }
148
-
149
- /**
150
- * Validate contracts file structure (C# contracts)
151
- * @param {string} contractsPath - Path to contracts file
152
- * @returns {Object} Validation result
153
- */
154
- export function validateContractsContent(contractsPath) {
155
- if (!existsSync(contractsPath)) {
156
- return {
157
- valid: false,
158
- errors: ['Contracts file not found at: ' + contractsPath]
159
- };
160
- }
161
-
162
- const content = readFileSync(contractsPath, 'utf8');
163
- const errors = [];
164
- const warnings = [];
165
-
166
- // Check for basic C# structure
167
- if (!content.includes('namespace')) {
168
- errors.push('Contracts file missing namespace declaration');
169
- }
170
-
171
- // Check for at least one interface or record
172
- const hasInterface = /interface\s+\w+/.test(content);
173
- const hasRecord = /record\s+\w+/.test(content);
174
- const hasClass = /class\s+\w+/.test(content);
175
-
176
- if (!hasInterface && !hasRecord && !hasClass) {
177
- errors.push('Contracts file should define at least one interface, record, or class');
178
- }
179
-
180
- // Check for common anti-patterns
181
- if (content.includes('// TODO') || content.includes('// PLACEHOLDER')) {
182
- warnings.push('Contracts contain TODO/PLACEHOLDER comments - ensure they are completed');
183
- }
184
-
185
- return {
186
- valid: errors.length === 0,
187
- errors,
188
- warnings,
189
- found: {
190
- hasNamespace: content.includes('namespace'),
191
- hasInterfaces: hasInterface,
192
- hasRecords: hasRecord,
193
- hasClasses: hasClass
194
- }
195
- };
196
- }
197
-
198
- /**
199
- * Validate proposal.md structure
200
- * @param {string} proposalPath - Path to proposal.md file
201
- * @returns {Object} Validation result
202
- */
203
- export function validateProposalContent(proposalPath) {
204
- if (!existsSync(proposalPath)) {
205
- return {
206
- valid: false,
207
- errors: ['Proposal file not found at: ' + proposalPath]
208
- };
209
- }
210
-
211
- const content = readFileSync(proposalPath, 'utf8');
212
- const errors = [];
213
- const warnings = [];
214
-
215
- // Required sections
216
- const requiredSections = [
217
- '## Problem Statement',
218
- '## Proposed Solution'
219
- ];
220
-
221
- const missing = requiredSections.filter(section => !content.includes(section));
222
- missing.forEach(section => errors.push(`Missing required section: ${section}`));
223
-
224
- // Check for minimum content
225
- if (content.length < 300) {
226
- warnings.push('Proposal seems very brief (< 300 characters)');
227
- }
228
-
229
- return {
230
- valid: errors.length === 0,
231
- errors,
232
- warnings,
233
- sections: {
234
- required: requiredSections.length,
235
- found: requiredSections.length - missing.length
236
- }
237
- };
238
- }
239
-
240
- /**
241
- * Validate all outputs for a feature comprehensively
242
- * @param {Object} featureState - Feature state object
243
- * @param {string} targetPhase - Target phase for validation
244
- * @returns {Object} Comprehensive validation result
245
- */
246
- export function validateFeatureOutputs(featureState, targetPhase) {
247
- const results = {
248
- valid: true,
249
- validations: []
250
- };
251
-
252
- // Validate based on target phase
253
- if (targetPhase === 'tasks' || targetPhase === 'implement') {
254
- // Spec is required
255
- if (featureState.outputs?.spec?.created) {
256
- const specResult = validateSpecContent(featureState.outputs.spec.path);
257
- results.validations.push({ type: 'spec', ...specResult });
258
- if (!specResult.valid) results.valid = false;
259
- } else {
260
- results.valid = false;
261
- results.validations.push({
262
- type: 'spec',
263
- valid: false,
264
- errors: ['Spec file not created']
265
- });
266
- }
267
- }
268
-
269
- if (targetPhase === 'implement') {
270
- // Tasks are required
271
- if (featureState.outputs?.tasks?.created) {
272
- const tasksResult = validateTasksContent(featureState.outputs.tasks.path);
273
- results.validations.push({ type: 'tasks', ...tasksResult });
274
- if (!tasksResult.valid) results.valid = false;
275
- } else {
276
- results.valid = false;
277
- results.validations.push({
278
- type: 'tasks',
279
- valid: false,
280
- errors: ['Tasks file not created']
281
- });
282
- }
283
- }
284
-
285
- return results;
286
- }
1
+ import { readFileSync, existsSync } from 'fs';
2
+
3
+ /**
4
+ * Content Validator - Validates structure and content of output files
5
+ *
6
+ * Ensures spec.md, tasks.json, and other outputs have required sections
7
+ * and proper structure before allowing phase transitions.
8
+ */
9
+
10
+ /**
11
+ * Validate spec.md structure
12
+ * @param {string} specPath - Path to spec.md file
13
+ * @returns {Object} Validation result
14
+ */
15
+ export function validateSpecContent(specPath) {
16
+ if (!existsSync(specPath)) {
17
+ return {
18
+ valid: false,
19
+ missing: ['File does not exist'],
20
+ errors: ['Spec file not found at: ' + specPath]
21
+ };
22
+ }
23
+
24
+ const content = readFileSync(specPath, 'utf8');
25
+
26
+ // Required sections (flexible regex handles numbered variants like '## 1. Overview')
27
+ const requiredSections = [
28
+ { label: '## Overview', pattern: /^##\s+(?:\d+\.?\s+)?Overview/i },
29
+ { label: '## Functional Requirements', pattern: /^##\s+(?:\d+\.?\s+)?Functional Requirements/i },
30
+ { label: '## Technical', pattern: /^##\s+(?:\d+\.?\s+)?Technical/i },
31
+ { label: '## Data Model', pattern: /^##\s+(?:\d+\.?\s+)?Data Model/i },
32
+ ];
33
+
34
+ const lines = content.split('\n');
35
+ const missing = requiredSections.filter(s =>
36
+ !lines.some(line => s.pattern.test(line))
37
+ );
38
+
39
+ // Additional quality checks
40
+ const errors = [];
41
+ const warnings = [];
42
+
43
+ // Missing sections are warnings, not errors — not every spec needs all sections
44
+ // (e.g., frontend-only features may not have Data Model, CLI tools may not have Technical Architecture)
45
+ if (missing.length > 0) {
46
+ missing.forEach(s => {
47
+ warnings.push(`Missing recommended section: ${s.label}`);
48
+ });
49
+ }
50
+
51
+ // Check minimum content length
52
+ if (content.length < 500) {
53
+ warnings.push('Spec seems very short (< 500 characters). Consider adding more detail.');
54
+ }
55
+
56
+ // Check for placeholder text that should be replaced
57
+ const placeholders = ['TODO', 'TBD', 'PLACEHOLDER', '{{'];
58
+ placeholders.forEach(placeholder => {
59
+ if (content.includes(placeholder)) {
60
+ warnings.push(`Spec contains "${placeholder}" - ensure all placeholders are replaced`);
61
+ }
62
+ });
63
+
64
+ // Check for anti-patterns mentioned in the plan
65
+ if (content.toLowerCase().includes('manual azure portal')) {
66
+ errors.push(
67
+ 'Spec mentions manual Azure portal creation. ' +
68
+ 'All infrastructure must be defined in Bicep (Infrastructure as Code).'
69
+ );
70
+ }
71
+
72
+ if (content.toLowerCase().includes('create resource manually')) {
73
+ errors.push(
74
+ 'Spec mentions manual resource creation. ' +
75
+ 'Use IaC (Bicep) for all infrastructure resources.'
76
+ );
77
+ }
78
+
79
+ return {
80
+ valid: errors.length === 0,
81
+ missing,
82
+ errors,
83
+ warnings,
84
+ sections: {
85
+ required: requiredSections.length,
86
+ found: requiredSections.length - missing.length
87
+ }
88
+ };
89
+ }
@@ -5,4 +5,3 @@
5
5
  */
6
6
 
7
7
  export * from './content-validator.js';
8
- export * from './cross-phase-validator.js';
@@ -1,199 +0,0 @@
1
- # Tasks - {{titleCase FEATURE_NAME}}
2
-
3
- > Implementation checklist for the feature.
4
- > Update status as you progress.
5
-
6
- | Task ID | Type | Title | Status |
7
- |---------|------|-------|--------|
8
- | T001 | {type} | {title} | Pending |
9
- | T002 | {type} | {title} | Pending |
10
- | T003 | {type} | {title} | In Progress |
11
- | T004 | {type} | {title} | Blocked |
12
- | T005 | {type} | {title} | Done |
13
-
14
- **Status Values:** `Pending | In Progress | Blocked | Done`
15
-
16
- ---
17
-
18
- ## Task Granularity
19
-
20
- ### Ideal Task
21
- - 15-60 minutes of implementation
22
- - 1-5 files modified
23
- - Testable in isolation
24
- - Independent commit possible
25
-
26
- ### Signs of Too Broad (Split)
27
- **Bad example:** "Implement feature"
28
- **Split into:**
29
- - T001: Define contracts and interfaces
30
- - T002: Implement data layer
31
- - T003: Implement business logic
32
- - T004: Create UI components
33
- - T005: Write tests
34
-
35
- ### Signs of Too Granular (Merge)
36
- **Bad example:** "Create field A", "Create field B", "Create field C"
37
- **Merge into:** "Create data model with all fields"
38
-
39
- ---
40
-
41
- ## Gates & Reviews
42
-
43
- | Task ID | Type | Description | Status |
44
- |---------|------|-------------|--------|
45
- | T003 | Review | Review contracts and data model | Pending |
46
- | T006 | Review | Review implementation | Pending |
47
- | T009 | Approval | Approve UI before testing | Pending |
48
-
49
- ---
50
-
51
- ## Phase 1: Contracts & Data Model
52
-
53
- ### T001: Define contracts and interfaces
54
- - **Type:** Contract
55
- - **Priority:** 1
56
- - **Estimate:** 30min
57
- - **Assigned:** {agent}
58
- - **Dependencies:** None
59
-
60
- **Description:**
61
-
62
- Define service interfaces and contracts.
63
-
64
- **Deliverables:**
65
- - [ ] Create: `{path-to-interface-file}`
66
-
67
- ---
68
-
69
- ### T002: Create data model
70
- - **Type:** {{#if (eq STACK "nextjs-neon")}}Database{{else}}Domain{{/if}}
71
- - **Priority:** 1
72
- - **Estimate:** 45min
73
- - **Assigned:** {agent}
74
- - **Dependencies:** None
75
-
76
- **Description:**
77
-
78
- Create data model {{#if (eq STACK "nextjs-neon")}}with migrations{{else}}with entities{{/if}}.
79
-
80
- **Deliverables:**
81
- - [ ] Create: `{path-to-model-file}`
82
-
83
- ---
84
-
85
- ## Phase 2: Implementation
86
-
87
- ### T003: Implement data layer
88
- - **Type:** {{#if (eq STACK "nextjs-neon")}}Repository{{else}}Infrastructure{{/if}}
89
- - **Priority:** 2
90
- - **Estimate:** 1h
91
- - **Assigned:** {agent}
92
- - **Dependencies:** T001, T002
93
-
94
- **Description:**
95
-
96
- Implement data access layer.
97
-
98
- **Deliverables:**
99
- - [ ] Create: `{path-to-repository-file}`
100
-
101
- ---
102
-
103
- ### T004: Implement business logic
104
- - **Type:** Service
105
- - **Priority:** 2
106
- - **Estimate:** 1h
107
- - **Assigned:** {agent}
108
- - **Dependencies:** T001, T003
109
-
110
- **Description:**
111
-
112
- Implement service layer with business logic.
113
-
114
- **Deliverables:**
115
- - [ ] Create: `{path-to-service-file}`
116
-
117
- ---
118
-
119
- ## Phase 3: UI Components
120
-
121
- ### T005: Create list component
122
- - **Type:** UI
123
- - **Priority:** 2
124
- - **Estimate:** 45min
125
- - **Assigned:** {agent}
126
- - **Dependencies:** T004
127
-
128
- **Description:**
129
-
130
- Create component to list items.
131
-
132
- **Deliverables:**
133
- - [ ] Create: `{path-to-component-file}`
134
-
135
- ---
136
-
137
- ### T006: Create form component
138
- - **Type:** UI
139
- - **Priority:** 2
140
- - **Estimate:** 1h
141
- - **Assigned:** {agent}
142
- - **Dependencies:** T005
143
-
144
- **Description:**
145
-
146
- Create component for create/edit.
147
-
148
- **Deliverables:**
149
- - [ ] Create: `{path-to-form-file}`
150
-
151
- ---
152
-
153
- ## Phase 4: Testing
154
-
155
- ### T007: Write unit tests
156
- - **Type:** Test
157
- - **Priority:** 2
158
- - **Estimate:** 1h
159
- - **Assigned:** {agent}
160
- - **Dependencies:** T004
161
-
162
- **Description:**
163
-
164
- Unit tests for service layer.
165
-
166
- **Deliverables:**
167
- - [ ] Create: `{path-to-test-file}`
168
-
169
- ---
170
-
171
- ### T008: Write integration tests
172
- - **Type:** Test
173
- - **Priority:** 3
174
- - **Estimate:** 1h
175
- - **Assigned:** {agent}
176
- - **Dependencies:** T007
177
-
178
- **Description:**
179
-
180
- Integration tests for {{#if (eq STACK "nextjs-neon")}}API and database{{else}}repository and API{{/if}}.
181
-
182
- **Deliverables:**
183
- - [ ] Create: `{path-to-integration-test-file}`
184
-
185
- ---
186
-
187
- ## Summary
188
-
189
- | Phase | Tasks | Estimate |
190
- |-------|-------|----------|
191
- | Phase 1 | T001-T002 | {X}h |
192
- | Phase 2 | T003-T004 | {X}h |
193
- | Phase 3 | T005-T006 | {X}h |
194
- | Phase 4 | T007-T008 | {X}h |
195
- | **Total** | **8 tasks** | **{X}h** |
196
-
197
- ---
198
-
199
- *Generated by MORPH Framework*