@polymorphism-tech/morph-spec 8.2.1 → 8.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.
- package/README.md +73 -102
- package/bin/morph-spec.js +36 -1
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +77 -134
- package/docs/QUICKSTART.md +47 -57
- package/framework/CLAUDE.md +6 -3
- package/framework/MORPH.md +2 -2
- package/framework/agents.json +3 -1
- package/framework/commands/morph-hotfix.md +1 -1
- package/framework/hooks/README.md +3 -0
- package/framework/hooks/claude-code/core/state-sync.js +41 -9
- package/framework/hooks/claude-code/core/telemetry-log.js +102 -0
- package/framework/hooks/shared/state-writer.js +14 -3
- package/framework/hooks/shared/telemetry-logger.js +75 -0
- package/framework/rules/ai-agents-standards.md +1 -0
- package/framework/schemas/feature.schema.json +15 -7
- package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
- package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
- package/framework/skills/core/morph-apply/SKILL.md +1 -1
- package/framework/skills/core/morph-brainstorming/SKILL.md +1 -1
- package/framework/skills/core/morph-eval/SKILL.md +1 -1
- package/framework/skills/core/morph-hotfix/SKILL.md +3 -3
- package/framework/skills/core/morph-implement/SKILL.md +1 -1
- package/framework/skills/core/morph-plan/SKILL.md +1 -1
- package/framework/skills/core/morph-proposal/SKILL.md +4 -4
- package/framework/skills/core/morph-review/SKILL.md +1 -1
- package/framework/skills/core/morph-stack-scan/SKILL.md +1 -1
- package/framework/skills/core/morph-standards/SKILL.md +1 -1
- package/framework/standards/STANDARDS.json +43 -1
- package/framework/standards/ai-agents/observability-patterns.md +156 -0
- package/framework/standards/ai-agents/production.md +3 -47
- package/framework/templates/REGISTRY.json +0 -93
- package/package.json +1 -1
- package/src/commands/observability/telemetry.js +75 -0
- package/src/commands/project/doctor.js +28 -0
- package/src/commands/state/advance.js +17 -0
- package/src/commands/state/approve.js +13 -0
- package/src/commands/state/create.js +21 -1
- package/src/commands/state/delete.js +143 -0
- package/src/commands/state/list.js +110 -0
- package/src/core/state/feature-identity.js +36 -0
- package/src/core/state/gate-order.js +51 -0
- package/src/core/state/lifecycle-audit.js +79 -0
- package/src/core/state/state-manager.js +47 -140
- package/src/dashboard/app/pages/LiveState.jsx +0 -43
- package/src/lib/detectors/design-system-detector.js +0 -43
- package/src/lib/generators/index.js +0 -1
- package/src/lib/telemetry/telemetry-reader.js +103 -0
- package/src/lib/validators/validation-runner.js +9 -73
- package/src/utils/hooks-installer.js +27 -3
- package/framework/templates/context/CONTEXT-FEATURE.md +0 -269
- package/framework/templates/context/CONTEXT.md +0 -181
- package/src/lib/agents/metrics-aggregator.js +0 -56
- package/src/lib/agents/metrics-calculator.js +0 -125
- package/src/lib/generators/metadata-extractor.js +0 -385
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
# {{PROJECT_NAME}} - Project Context
|
|
2
|
-
|
|
3
|
-
> Auto-generated by MORPH-SPEC Framework
|
|
4
|
-
> Last updated: {{TIMESTAMP}}
|
|
5
|
-
|
|
6
|
-
## Project Overview
|
|
7
|
-
|
|
8
|
-
**Name:** {{PROJECT_NAME}}
|
|
9
|
-
**Type:** {{PROJECT_TYPE}}
|
|
10
|
-
**Repository:** {{REPOSITORY_URL}}
|
|
11
|
-
|
|
12
|
-
{{PROJECT_DESCRIPTION}}
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## Technology Stack
|
|
17
|
-
|
|
18
|
-
### Frontend
|
|
19
|
-
{{#if NEXTJS_ENABLED}}- **Next.js** {{NEXTJS_VERSION}}{{/if}}
|
|
20
|
-
{{#if UI_LIBRARY}}- **UI Library:** {{UI_LIBRARY}}{{/if}}
|
|
21
|
-
|
|
22
|
-
### Backend
|
|
23
|
-
- **.NET** {{DOTNET_VERSION}}
|
|
24
|
-
{{#if EF_VERSION}}- **Entity Framework Core** {{EF_VERSION}}{{/if}}
|
|
25
|
-
{{#if DAPPER_ENABLED}}- **Dapper** (Micro-ORM){{/if}}
|
|
26
|
-
{{#if HANGFIRE_ENABLED}}- **Hangfire** (Background Jobs){{/if}}
|
|
27
|
-
{{#if AGENT_FRAMEWORK_ENABLED}}- **Microsoft Agent Framework** (AI Agents){{/if}}
|
|
28
|
-
|
|
29
|
-
### Database
|
|
30
|
-
{{#if SQL_ENABLED}}- **Azure SQL** ({{SQL_SERVER}}/{{SQL_DATABASE}}){{/if}}
|
|
31
|
-
{{#if NEON_ENABLED}}- **Neon** (PostgreSQL + Connection Pooling)
|
|
32
|
-
- Project: {{NEON_PROJECT_ID}}
|
|
33
|
-
- Region: {{NEON_REGION}}
|
|
34
|
-
{{/if}}
|
|
35
|
-
|
|
36
|
-
### Infrastructure
|
|
37
|
-
{{#if AZURE_ENABLED}}- **Azure** ({{AZURE_LOCATION}})
|
|
38
|
-
{{#if CONTAINER_APPS_ENABLED}}- **Container Apps** ({{CONTAINER_ENV}}){{/if}}
|
|
39
|
-
{{#if OPENAI_ENABLED}}- **Azure OpenAI** ({{OPENAI_MODEL}}){{/if}}
|
|
40
|
-
{{#if MONITORING_ENABLED}}- **Application Insights** ({{APP_INSIGHTS}}){{/if}}
|
|
41
|
-
{{/if}}
|
|
42
|
-
|
|
43
|
-
{{#if COOLIFY_ENABLED}}- **Coolify** (Docker Deployment via SSH)
|
|
44
|
-
- Server: {{COOLIFY_SERVER}}
|
|
45
|
-
- App: {{COOLIFY_APP_URL}}
|
|
46
|
-
{{/if}}
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
## Active Features
|
|
51
|
-
|
|
52
|
-
{{#each ACTIVE_FEATURES}}
|
|
53
|
-
### {{name}} ({{phase}})
|
|
54
|
-
**Status:** {{status}}
|
|
55
|
-
**Complexity:** {{complexity}}
|
|
56
|
-
**Active Agents:** {{activeAgents}}
|
|
57
|
-
|
|
58
|
-
{{#if description}}{{description}}{{/if}}
|
|
59
|
-
|
|
60
|
-
**Progress:**
|
|
61
|
-
- Tasks: {{tasks.completed}}/{{tasks.total}}
|
|
62
|
-
- Outputs: {{outputs}}
|
|
63
|
-
|
|
64
|
-
{{/each}}
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
## Project Standards
|
|
69
|
-
|
|
70
|
-
### Coding Standards
|
|
71
|
-
{{#each PROJECT_STANDARDS}}
|
|
72
|
-
- [{{name}}]({{path}}){{#if description}} - {{description}}{{/if}}
|
|
73
|
-
{{/each}}
|
|
74
|
-
|
|
75
|
-
### Inferred Patterns
|
|
76
|
-
{{#if INFERRED_STANDARDS}}
|
|
77
|
-
{{INFERRED_STANDARDS}}
|
|
78
|
-
{{/if}}
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## Active Agents ({{AGENT_COUNT}})
|
|
83
|
-
|
|
84
|
-
### Tier 1: Orchestrators
|
|
85
|
-
{{#each TIER_1_AGENTS}}
|
|
86
|
-
- **{{title}}** (`{{id}}`) {{#if always_active}}[Always Active]{{/if}}
|
|
87
|
-
{{/each}}
|
|
88
|
-
|
|
89
|
-
### Tier 2: Domain Leaders
|
|
90
|
-
{{#each TIER_2_AGENTS}}
|
|
91
|
-
- **{{title}}** (`{{id}}`) - {{domains}}
|
|
92
|
-
{{/each}}
|
|
93
|
-
|
|
94
|
-
### Tier 3: Specialists
|
|
95
|
-
{{#each TIER_3_AGENTS}}
|
|
96
|
-
- **{{title}}** (`{{id}}`) - Reports to `{{reports_to}}`
|
|
97
|
-
{{/each}}
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
## Agent Teams Status
|
|
102
|
-
|
|
103
|
-
{{#if AGENT_TEAMS_ENABLED}}
|
|
104
|
-
✅ **Enabled** (Display Mode: {{AGENT_TEAMS_DISPLAY_MODE}})
|
|
105
|
-
|
|
106
|
-
**Spawn Thresholds:**
|
|
107
|
-
- Complexity: {{AGENT_TEAMS_THRESHOLDS.complexity}}
|
|
108
|
-
- Estimated Files: ≥ {{AGENT_TEAMS_THRESHOLDS.estimatedFiles}}
|
|
109
|
-
- Active Agents: ≥ {{AGENT_TEAMS_THRESHOLDS.activeAgents}}
|
|
110
|
-
- Multi-Domain: {{AGENT_TEAMS_THRESHOLDS.multiDomain}}
|
|
111
|
-
|
|
112
|
-
{{else}}
|
|
113
|
-
❌ **Disabled** - Use single session with subagents
|
|
114
|
-
{{/if}}
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
## Recent Checkpoints
|
|
119
|
-
|
|
120
|
-
{{#each RECENT_CHECKPOINTS}}
|
|
121
|
-
### {{timestamp}}
|
|
122
|
-
**Feature:** {{feature}}
|
|
123
|
-
**Phase:** {{phase}}
|
|
124
|
-
**Note:** {{note}}
|
|
125
|
-
|
|
126
|
-
{{#if validation}}
|
|
127
|
-
**Validation:** {{validation.passed}}/{{validation.total}} checks passed
|
|
128
|
-
{{/if}}
|
|
129
|
-
|
|
130
|
-
{{/each}}
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
{{#if DEVOPS_ENABLED}}
|
|
135
|
-
## DevOps Integration
|
|
136
|
-
|
|
137
|
-
**Organization:** {{DEVOPS_ORG}}
|
|
138
|
-
**Project:** {{DEVOPS_PROJECT}}
|
|
139
|
-
|
|
140
|
-
- **Boards:** {{#if DEVOPS_BOARDS_ENABLED}}Enabled ({{DEVOPS_AREA_PATH}}){{else}}Disabled{{/if}}
|
|
141
|
-
- **Wiki:** {{#if DEVOPS_WIKI_ENABLED}}Enabled ({{DEVOPS_WIKI_NAME}}){{else}}Disabled{{/if}}
|
|
142
|
-
- **Pipelines:** CI: {{DEVOPS_BUILD_PIPELINE}}, CD: {{DEVOPS_RELEASE_PIPELINE}}
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
{{/if}}
|
|
147
|
-
|
|
148
|
-
## Quick Reference
|
|
149
|
-
|
|
150
|
-
### Workflow Commands
|
|
151
|
-
```bash
|
|
152
|
-
# Check feature status and pending gates
|
|
153
|
-
morph-spec status {feature}
|
|
154
|
-
morph-spec approval-status {feature}
|
|
155
|
-
|
|
156
|
-
# Approve the current gate and scaffold the next phase folder in one step
|
|
157
|
-
morph-spec advance {feature}
|
|
158
|
-
|
|
159
|
-
# Validate feature outputs
|
|
160
|
-
morph-spec validate-feature {feature}
|
|
161
|
-
|
|
162
|
-
# Archive a finished feature (after Gate 3)
|
|
163
|
-
morph-spec archive {feature}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
> Feature work starts by asking Claude Code to implement something — the proposal
|
|
167
|
-
> phase is created for you. During the implement phase, task progress is tracked
|
|
168
|
-
> with the native `TaskCreate`/`TaskUpdate` tools and persisted by writing
|
|
169
|
-
> `tasks.json` (only `status`, `outputs`, `notes`); the recap is written by the
|
|
170
|
-
> implement skill. State syncs automatically via the `state-sync` hook.
|
|
171
|
-
|
|
172
|
-
### Key Paths
|
|
173
|
-
- **Outputs:** `.morph/features/{feature}/`
|
|
174
|
-
- **Standards:** `.morph/context/` (project overrides)
|
|
175
|
-
- **Config:** `.morph/config/config.json`
|
|
176
|
-
- **State:** `.morph/state.json`
|
|
177
|
-
- **Templates:** `.morph/framework/templates/`
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
*Generated by MORPH-SPEC Framework v{{MORPH_VERSION}}*
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Project-level metrics aggregator
|
|
3
|
-
*
|
|
4
|
-
* Aggregates feature-level data from state.json into a project-wide
|
|
5
|
-
* metrics summary. Pure computation — no I/O.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Aggregate project-level metrics from state.json data.
|
|
10
|
-
*
|
|
11
|
-
* @param {Object} state - Parsed state.json content
|
|
12
|
-
* @returns {Object} Aggregated metrics
|
|
13
|
-
*/
|
|
14
|
-
export function aggregateProjectMetrics(state) {
|
|
15
|
-
const features = state?.features || {};
|
|
16
|
-
const featureNames = Object.keys(features);
|
|
17
|
-
|
|
18
|
-
const featureMetrics = featureNames.map(name => {
|
|
19
|
-
const f = features[name];
|
|
20
|
-
const tasks = f.tasks || {};
|
|
21
|
-
const taskIds = Object.keys(tasks);
|
|
22
|
-
const completedTasks = taskIds.filter(id => tasks[id]?.status === 'completed').length;
|
|
23
|
-
const dispatchLog = f.dispatchLog || [];
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
name,
|
|
27
|
-
phase: f.phase || f.currentPhase || 'unknown',
|
|
28
|
-
taskCount: taskIds.length,
|
|
29
|
-
completedTasks,
|
|
30
|
-
dispatchCount: dispatchLog.length,
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const totalFeatures = featureMetrics.length;
|
|
35
|
-
const completedFeatures = featureMetrics.filter(f => f.phase === 'review').length;
|
|
36
|
-
const totalTasks = featureMetrics.reduce((sum, f) => sum + f.taskCount, 0);
|
|
37
|
-
const completedTasks = featureMetrics.reduce((sum, f) => sum + f.completedTasks, 0);
|
|
38
|
-
const totalDispatches = featureMetrics.reduce((sum, f) => sum + f.dispatchCount, 0);
|
|
39
|
-
const completionRate = totalTasks > 0 ? Math.round((completedTasks / totalTasks) * 100) : 0;
|
|
40
|
-
const avgTasksPerFeature = totalFeatures > 0 ? Math.round((totalTasks / totalFeatures) * 10) / 10 : 0;
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
version: state?.version || 'unknown',
|
|
44
|
-
updatedAt: new Date().toISOString(),
|
|
45
|
-
summary: {
|
|
46
|
-
totalFeatures,
|
|
47
|
-
completedFeatures,
|
|
48
|
-
avgTasksPerFeature,
|
|
49
|
-
totalTasks,
|
|
50
|
-
completedTasks,
|
|
51
|
-
completionRate,
|
|
52
|
-
totalDispatches,
|
|
53
|
-
},
|
|
54
|
-
features: featureMetrics,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Metrics Calculator — Pure computation, no I/O.
|
|
3
|
-
*
|
|
4
|
-
* Calculates per-agent performance metrics from dispatch log entries.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Calculate per-agent metrics from dispatch log entries.
|
|
9
|
-
* @param {Array} dispatchLog - Array of dispatch entries
|
|
10
|
-
* @returns {{ agents: Array, summary: Object }}
|
|
11
|
-
*/
|
|
12
|
-
export function calculateMetrics(dispatchLog) {
|
|
13
|
-
if (!Array.isArray(dispatchLog) || dispatchLog.length === 0) {
|
|
14
|
-
return {
|
|
15
|
-
agents: [],
|
|
16
|
-
summary: { totalDispatches: 0, totalTasks: 0, completedTasks: 0, completionRate: 0, avgTaskDurationMs: null }
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const agentMap = new Map();
|
|
21
|
-
|
|
22
|
-
for (const entry of dispatchLog) {
|
|
23
|
-
for (const agent of entry.agents || []) {
|
|
24
|
-
if (!agentMap.has(agent.id)) {
|
|
25
|
-
agentMap.set(agent.id, { dispatches: 0, tasksAssigned: 0, tasksCompleted: 0, durations: [] });
|
|
26
|
-
}
|
|
27
|
-
const acc = agentMap.get(agent.id);
|
|
28
|
-
acc.dispatches += 1;
|
|
29
|
-
acc.tasksAssigned += (agent.tasks || []).length;
|
|
30
|
-
acc.tasksCompleted += (agent.tasksCompleted || []).length;
|
|
31
|
-
|
|
32
|
-
if (agent.startedAt && agent.completedAt) {
|
|
33
|
-
const start = new Date(agent.startedAt).getTime();
|
|
34
|
-
const end = new Date(agent.completedAt).getTime();
|
|
35
|
-
if (!isNaN(start) && !isNaN(end) && end >= start) {
|
|
36
|
-
acc.durations.push(end - start);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const agents = [];
|
|
43
|
-
let totalDurationAll = 0;
|
|
44
|
-
let agentsWithDuration = 0;
|
|
45
|
-
|
|
46
|
-
for (const [id, acc] of agentMap) {
|
|
47
|
-
const totalDurationMs = acc.durations.length > 0
|
|
48
|
-
? acc.durations.reduce((s, d) => s + d, 0)
|
|
49
|
-
: null;
|
|
50
|
-
const avgDurationMs = acc.durations.length > 0
|
|
51
|
-
? Math.round(totalDurationMs / acc.durations.length)
|
|
52
|
-
: null;
|
|
53
|
-
|
|
54
|
-
if (totalDurationMs !== null) {
|
|
55
|
-
totalDurationAll += totalDurationMs;
|
|
56
|
-
agentsWithDuration++;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
agents.push({
|
|
60
|
-
id,
|
|
61
|
-
dispatches: acc.dispatches,
|
|
62
|
-
tasksAssigned: acc.tasksAssigned,
|
|
63
|
-
tasksCompleted: acc.tasksCompleted,
|
|
64
|
-
completionRate: acc.tasksAssigned > 0 ? acc.tasksCompleted / acc.tasksAssigned : 0,
|
|
65
|
-
avgDurationMs,
|
|
66
|
-
totalDurationMs
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
agents.sort((a, b) => b.tasksCompleted - a.tasksCompleted);
|
|
71
|
-
|
|
72
|
-
const totalTasks = agents.reduce((s, a) => s + a.tasksAssigned, 0);
|
|
73
|
-
const completedTasks = agents.reduce((s, a) => s + a.tasksCompleted, 0);
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
agents,
|
|
77
|
-
summary: {
|
|
78
|
-
totalDispatches: dispatchLog.length,
|
|
79
|
-
totalTasks,
|
|
80
|
-
completedTasks,
|
|
81
|
-
completionRate: totalTasks > 0 ? completedTasks / totalTasks : 0,
|
|
82
|
-
avgTaskDurationMs: completedTasks > 0 && totalDurationAll > 0
|
|
83
|
-
? Math.round(totalDurationAll / completedTasks)
|
|
84
|
-
: null
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Format milliseconds as human-readable duration.
|
|
91
|
-
* @param {number|null} ms
|
|
92
|
-
* @returns {string}
|
|
93
|
-
*/
|
|
94
|
-
export function formatDuration(ms) {
|
|
95
|
-
if (ms == null || ms < 0) return '\u2014';
|
|
96
|
-
if (ms === 0) return '0s';
|
|
97
|
-
|
|
98
|
-
const totalSeconds = Math.floor(ms / 1000);
|
|
99
|
-
const hours = Math.floor(totalSeconds / 3600);
|
|
100
|
-
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
101
|
-
const seconds = totalSeconds % 60;
|
|
102
|
-
|
|
103
|
-
if (hours > 0) return `${hours}h ${minutes}m`;
|
|
104
|
-
if (minutes > 0) return `${minutes}m`;
|
|
105
|
-
return `${seconds}s`;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Calculate cross-feature aggregated metrics.
|
|
110
|
-
* @param {Object} features - state.features object
|
|
111
|
-
* @returns {{ agents: Array, summary: Object, featureCount: number }}
|
|
112
|
-
*/
|
|
113
|
-
export function calculateAggregatedMetrics(features) {
|
|
114
|
-
const allEntries = [];
|
|
115
|
-
let featureCount = 0;
|
|
116
|
-
|
|
117
|
-
for (const feature of Object.values(features || {})) {
|
|
118
|
-
featureCount++;
|
|
119
|
-
const log = feature.dispatchLog || [];
|
|
120
|
-
allEntries.push(...log);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const result = calculateMetrics(allEntries);
|
|
124
|
-
return { ...result, featureCount };
|
|
125
|
-
}
|