@polymorphism-tech/morph-spec 7.2.0 → 7.4.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 (74) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +4 -2
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +2 -2
  8. package/framework/MORPH.md +29 -12
  9. package/framework/agents.json +132 -132
  10. package/framework/commands/morph-apply.md +1 -1
  11. package/framework/commands/morph-proposal.md +1 -1
  12. package/framework/evals/rubrics/README.md +9 -8
  13. package/framework/hooks/README.md +3 -1
  14. package/framework/hooks/claude-code/core/gate-guard.js +160 -0
  15. package/framework/hooks/claude-code/core/state-sync.js +15 -3
  16. package/framework/hooks/claude-code/core/validate-completion.js +241 -136
  17. package/framework/hooks/shared/state-reader.js +236 -221
  18. package/framework/phases.json +1 -1
  19. package/framework/skills/README.md +2 -2
  20. package/framework/skills/core/morph-apply/SKILL.md +63 -21
  21. package/framework/skills/core/morph-brainstorming/SKILL.md +5 -1
  22. package/framework/skills/core/morph-eval/SKILL.md +4 -5
  23. package/framework/skills/core/morph-implement/SKILL.md +47 -19
  24. package/framework/skills/core/morph-plan/SKILL.md +8 -2
  25. package/framework/skills/core/morph-proposal/SKILL.md +1 -1
  26. package/framework/skills/core/morph-review/SKILL.md +13 -6
  27. package/framework/skills/core/morph-stack-scan/SKILL.md +1 -1
  28. package/framework/skills/core/morph-standards/SKILL.md +1 -1
  29. package/framework/standards/ai-agents/setup.md +258 -244
  30. package/framework/templates/README.md +708 -709
  31. package/framework/templates/REGISTRY.json +1 -20
  32. package/framework/templates/context/CONTEXT-FEATURE.md +276 -276
  33. package/framework/templates/docs/proposal.md +171 -171
  34. package/framework/templates/feature/recap.md +145 -145
  35. package/package.json +1 -1
  36. package/src/commands/project/doctor.js +941 -946
  37. package/src/commands/project/init.js +517 -515
  38. package/src/commands/project/status.js +373 -376
  39. package/src/commands/state/approve.js +251 -213
  40. package/src/commands/validation/validate-feature.js +356 -287
  41. package/src/core/state/state-manager.js +910 -934
  42. package/src/dashboard/app/App.jsx +29 -31
  43. package/src/dashboard/app/components/Sidebar.jsx +44 -45
  44. package/src/dashboard/scanner/index.js +20 -21
  45. package/src/lib/context/context-builder.js +3 -3
  46. package/src/lib/generators/context-generator.js +2 -3
  47. package/src/lib/generators/mandate-generator.js +48 -92
  48. package/src/lib/generators/metadata-extractor.js +385 -386
  49. package/src/lib/generators/recap-generator.js +285 -285
  50. package/src/lib/risk-detector.js +2 -2
  51. package/src/lib/validators/content/content-validator.js +89 -286
  52. package/src/lib/validators/content/index.js +0 -1
  53. package/src/utils/hooks-installer.js +527 -516
  54. package/framework/templates/feature/tasks.md +0 -199
  55. package/framework/workflows/README.md +0 -1041
  56. package/framework/workflows/configs/fast-track.json +0 -46
  57. package/framework/workflows/configs/full.json +0 -64
  58. package/framework/workflows/configs/quick.json +0 -32
  59. package/framework/workflows/configs/standard.json +0 -57
  60. package/framework/workflows/docs/STORY-DRIVEN-DEVELOPMENT.md +0 -392
  61. package/framework/workflows/docs/design-impl.md +0 -37
  62. package/framework/workflows/docs/enforcement-pipeline.md +0 -668
  63. package/framework/workflows/docs/fast-track.md +0 -29
  64. package/framework/workflows/docs/full-morph.md +0 -69
  65. package/framework/workflows/docs/standard.md +0 -49
  66. package/framework/workflows/docs/ui-refresh.md +0 -39
  67. package/src/commands/state/index.js +0 -7
  68. package/src/core/workflows/workflow-detector.js +0 -586
  69. package/src/core/workflows/workflow-router.js +0 -204
  70. package/src/dashboard/app/pages/Workflows.jsx +0 -346
  71. package/src/dashboard/scanner/workflows-scanner.js +0 -18
  72. package/src/lib/phase-chain/phase-validator.js +0 -359
  73. package/src/lib/validators/content/cross-phase-validator.js +0 -281
  74. 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';