@polymorphism-tech/morph-spec 4.10.9 → 4.10.10
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/CLAUDE.md +3 -3
- package/LICENSE +71 -71
- package/README.md +2 -2
- package/bin/morph-spec.js +22 -0
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/agents/README.md +14 -14
- package/framework/agents/architecture/standards-architect.md +159 -159
- package/framework/agents/infrastructure/azure-architect.md +149 -149
- package/framework/agents/infrastructure/infra-architect.md +48 -48
- package/framework/hooks/README.md +204 -204
- package/framework/hooks/shared/phase-utils.js +139 -139
- package/framework/rules/csharp-standards.md +13 -13
- package/framework/rules/frontend-standards.md +13 -13
- package/framework/rules/infrastructure-standards.md +16 -16
- package/framework/rules/testing-standards.md +14 -14
- package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +254 -254
- package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +38 -0
- package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-setup/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +14 -0
- package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
- package/framework/standards/STANDARDS.json +2338 -2041
- package/framework/standards/frontend/nextjs/nextjs-patterns.md +17 -17
- package/framework/standards/infrastructure/supabase/supabase-custom-jwt.md +206 -0
- package/framework/templates/.idea/morph-templates.xml +92 -0
- package/framework/templates/.vscode/morph-templates.code-snippets +186 -0
- package/framework/templates/README.md +814 -814
- package/framework/templates/code/dotnet/contracts/Commands.cs +74 -74
- package/framework/templates/code/dotnet/contracts/Entities.cs +25 -25
- package/framework/templates/code/dotnet/contracts/Queries.cs +74 -74
- package/framework/templates/code/dotnet/contracts/README.md +74 -74
- package/framework/templates/code/dotnet/contracts/api-contracts.cs +173 -173
- package/framework/templates/code/dotnet/frontend/component.razor +239 -239
- package/framework/templates/code/dotnet/jobs/agent.cs +163 -163
- package/framework/templates/code/dotnet/jobs/job.cs +171 -171
- package/framework/templates/code/dotnet/test.cs +239 -239
- package/framework/templates/code/sql/rls-policy.sql +57 -57
- package/framework/templates/code/sql/supabase-migration.sql +100 -100
- package/framework/templates/code/sql/supabase-migration.template.sql +113 -113
- package/framework/templates/code/typescript/contracts.ts +168 -168
- package/framework/templates/context/CONTEXT.md +181 -181
- package/framework/templates/docs/proposal.md +182 -182
- package/framework/templates/docs/user-stories.md +34 -34
- package/framework/templates/examples/design-system-examples.md +357 -357
- package/framework/templates/examples/spec-examples.md +90 -90
- package/framework/templates/feature/decisions.md +187 -187
- package/framework/templates/feature/recap.md +146 -146
- package/framework/templates/feature/tasks.md +199 -199
- package/framework/templates/infrastructure/azure/README.md +286 -286
- package/framework/templates/infrastructure/azure/deploy-checklist.md +426 -426
- package/framework/templates/infrastructure/azure/parameters.dev.json +29 -29
- package/framework/templates/infrastructure/azure/parameters.prod.json +29 -29
- package/framework/templates/infrastructure/azure/parameters.staging.json +29 -29
- package/framework/templates/infrastructure/docker/docker-compose.template.yml +67 -67
- package/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +38 -38
- package/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +48 -48
- package/framework/templates/infrastructure/docker/easypanel.template.json +54 -54
- package/package.json +1 -1
- package/src/commands/agents/dispatch-agents.js +17 -0
- package/src/commands/agents/index.js +13 -13
- package/src/commands/agents/project-metrics.js +74 -0
- package/src/commands/project/install-plugin-cmd.js +28 -28
- package/src/commands/project/setup-infra-cmd.js +12 -12
- package/src/commands/standards/context-budget.js +89 -0
- package/src/commands/tasks/index.js +4 -4
- package/src/commands/templates/index.js +5 -5
- package/src/commands/utils/index.js +3 -3
- package/src/commands/validation/index.js +4 -4
- package/src/core/state/phase-state-machine.js +217 -217
- package/src/lib/agents/metrics-aggregator.js +56 -0
- package/src/lib/generators/design-system-generator.js +298 -298
- package/src/lib/generators/index.js +10 -10
- package/src/lib/generators/metadata-extractor.js +387 -387
- package/src/lib/stack-filter.js +65 -65
- package/src/lib/standards/digest-builder.js +57 -3
- package/src/lib/standards/index.js +7 -7
- package/src/lib/standards/standards-context-injector.js +302 -302
- package/src/lib/validators/architecture/architecture-validator.js +387 -387
- package/src/lib/validators/architecture/index.js +7 -7
- package/src/lib/validators/blazor/blazor-concurrency-analyzer.js +316 -316
- package/src/lib/validators/blazor/blazor-state-validator.js +279 -279
- package/src/lib/validators/blazor/blazor-validator.js +369 -369
- package/src/lib/validators/blazor/index.js +9 -9
- package/src/lib/validators/content/content-validator.js +287 -287
- package/src/lib/validators/content/index.js +7 -7
- package/src/lib/validators/contracts/index.js +7 -7
- package/src/lib/validators/css/css-validator.js +352 -352
- package/src/lib/validators/css/index.js +7 -7
- package/src/lib/validators/design-system/design-system-validator.js +231 -231
- package/src/lib/validators/design-system/index.js +7 -7
- package/src/lib/validators/nextjs/index.js +6 -6
- package/src/lib/validators/nextjs/next-component-validator.js +183 -183
- package/src/lib/validators/packages/index.js +7 -7
- package/src/lib/validators/packages/package-validator.js +360 -360
- package/src/lib/validators/shared/index.js +12 -12
- package/src/lib/validators/shared/issue-counter.js +18 -18
- package/src/lib/validators/shared/result-formatter.js +124 -124
- package/src/lib/validators/ui/index.js +7 -7
- package/src/lib/validators/ui/ui-contrast-validator.js +422 -422
- package/src/scripts/global-install.js +58 -58
- package/src/scripts/install-plugin.js +126 -126
- package/src/utils/claude-md-injector.js +90 -90
- package/src/utils/file-copier.js +200 -200
- package/src/utils/logger.js +32 -32
- package/src/utils/skills-installer.js +178 -178
- package/src/utils/version-checker.js +175 -175
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* project-metrics — Project-level metrics aggregation CLI
|
|
3
|
+
*
|
|
4
|
+
* Aggregates feature data from state.json into a project-wide summary.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* morph-spec project-metrics [--json] [--save]
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { writeFileSync, existsSync, mkdirSync } from 'fs';
|
|
11
|
+
import { join } from 'path';
|
|
12
|
+
import { loadState, stateExists } from '../../core/state/state-manager.js';
|
|
13
|
+
import { aggregateProjectMetrics } from '../../lib/agents/metrics-aggregator.js';
|
|
14
|
+
import chalk from 'chalk';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* CLI command: morph-spec project-metrics [--json] [--save]
|
|
18
|
+
*/
|
|
19
|
+
export async function projectMetricsCommand(options = {}) {
|
|
20
|
+
if (!stateExists()) {
|
|
21
|
+
console.error(chalk.red('No state.json found. Run morph-spec state init first.'));
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const state = loadState(false);
|
|
27
|
+
if (!state) {
|
|
28
|
+
console.error(chalk.red('Failed to load state.json.'));
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const metrics = aggregateProjectMetrics(state);
|
|
33
|
+
|
|
34
|
+
if (options.save) {
|
|
35
|
+
const morphDir = join(process.cwd(), '.morph');
|
|
36
|
+
if (!existsSync(morphDir)) {
|
|
37
|
+
mkdirSync(morphDir, { recursive: true });
|
|
38
|
+
}
|
|
39
|
+
const outPath = join(morphDir, 'metrics.json');
|
|
40
|
+
writeFileSync(outPath, JSON.stringify(metrics, null, 2) + '\n', 'utf8');
|
|
41
|
+
console.log(chalk.green(`Metrics saved to ${outPath}`));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (options.json) {
|
|
45
|
+
console.log(JSON.stringify(metrics, null, 2));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Human-readable table
|
|
50
|
+
const s = metrics.summary;
|
|
51
|
+
console.log(chalk.bold('\n Project Metrics'));
|
|
52
|
+
console.log(' ' + '─'.repeat(50));
|
|
53
|
+
console.log(` Features: ${s.totalFeatures} (${s.completedFeatures} completed)`);
|
|
54
|
+
console.log(` Tasks: ${s.completedTasks}/${s.totalTasks} (${s.completionRate}%)`);
|
|
55
|
+
console.log(` Avg tasks/feat: ${s.avgTasksPerFeature}`);
|
|
56
|
+
console.log(` Dispatches: ${s.totalDispatches}`);
|
|
57
|
+
|
|
58
|
+
if (metrics.features.length > 0) {
|
|
59
|
+
console.log(chalk.bold('\n Features:'));
|
|
60
|
+
console.log(` ${'Name'.padEnd(24)} ${'Phase'.padEnd(14)} ${'Tasks'.padEnd(10)} Dispatches`);
|
|
61
|
+
console.log(' ' + '─'.repeat(60));
|
|
62
|
+
for (const f of metrics.features) {
|
|
63
|
+
const taskStr = `${f.completedTasks}/${f.taskCount}`;
|
|
64
|
+
console.log(
|
|
65
|
+
` ${f.name.padEnd(24)} ${chalk.cyan(f.phase.padEnd(14))} ${taskStr.padEnd(10)} ${f.dispatchCount}`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
console.log();
|
|
70
|
+
} catch (err) {
|
|
71
|
+
console.error(chalk.red(`Error: ${err.message}`));
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
// src/commands/project/install-plugin-cmd.js
|
|
2
|
-
import { installPlugin } from '../../scripts/install-plugin.js';
|
|
3
|
-
import { logger } from '../../utils/logger.js';
|
|
4
|
-
|
|
5
|
-
export async function installPluginCommand(pluginName, _options) {
|
|
6
|
-
if (!pluginName) {
|
|
7
|
-
logger.error('Plugin name required. Usage: morph-spec install-plugin <name>');
|
|
8
|
-
logger.dim(' Available: superpowers, context7');
|
|
9
|
-
process.exit(1);
|
|
10
|
-
}
|
|
11
|
-
try {
|
|
12
|
-
const result = await installPlugin(pluginName);
|
|
13
|
-
if (result.alreadyInstalled) {
|
|
14
|
-
logger.dim(` ✓ ${pluginName} already installed (${result.version})`);
|
|
15
|
-
} else {
|
|
16
|
-
logger.success(` ✓ ${pluginName} installed (${result.version})`);
|
|
17
|
-
logger.dim(' Restart Claude Code to activate.');
|
|
18
|
-
}
|
|
19
|
-
} catch (err) {
|
|
20
|
-
logger.error(`Failed to install plugin "${pluginName}": ${err.message}`);
|
|
21
|
-
logger.blank();
|
|
22
|
-
logger.warn('Manual installation:');
|
|
23
|
-
logger.dim(' 1. Claude Code → Settings (Cmd/Ctrl+,) → Extensions');
|
|
24
|
-
logger.dim(` 2. Browse → search "${pluginName}" → Install`);
|
|
25
|
-
logger.dim(' 3. Restart Claude Code');
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
// src/commands/project/install-plugin-cmd.js
|
|
2
|
+
import { installPlugin } from '../../scripts/install-plugin.js';
|
|
3
|
+
import { logger } from '../../utils/logger.js';
|
|
4
|
+
|
|
5
|
+
export async function installPluginCommand(pluginName, _options) {
|
|
6
|
+
if (!pluginName) {
|
|
7
|
+
logger.error('Plugin name required. Usage: morph-spec install-plugin <name>');
|
|
8
|
+
logger.dim(' Available: superpowers, context7');
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const result = await installPlugin(pluginName);
|
|
13
|
+
if (result.alreadyInstalled) {
|
|
14
|
+
logger.dim(` ✓ ${pluginName} already installed (${result.version})`);
|
|
15
|
+
} else {
|
|
16
|
+
logger.success(` ✓ ${pluginName} installed (${result.version})`);
|
|
17
|
+
logger.dim(' Restart Claude Code to activate.');
|
|
18
|
+
}
|
|
19
|
+
} catch (err) {
|
|
20
|
+
logger.error(`Failed to install plugin "${pluginName}": ${err.message}`);
|
|
21
|
+
logger.blank();
|
|
22
|
+
logger.warn('Manual installation:');
|
|
23
|
+
logger.dim(' 1. Claude Code → Settings (Cmd/Ctrl+,) → Extensions');
|
|
24
|
+
logger.dim(` 2. Browse → search "${pluginName}" → Install`);
|
|
25
|
+
logger.dim(' 3. Restart Claude Code');
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { setupInfra } from '../../scripts/setup-infra.js';
|
|
2
|
-
import { logger } from '../../utils/logger.js';
|
|
3
|
-
|
|
4
|
-
export async function setupInfraCommand(options) {
|
|
5
|
-
const targetPath = options.path || process.cwd();
|
|
6
|
-
try {
|
|
7
|
-
await setupInfra(targetPath);
|
|
8
|
-
} catch (err) {
|
|
9
|
-
logger.error(`setup-infra failed: ${err.message}`);
|
|
10
|
-
process.exit(1);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
import { setupInfra } from '../../scripts/setup-infra.js';
|
|
2
|
+
import { logger } from '../../utils/logger.js';
|
|
3
|
+
|
|
4
|
+
export async function setupInfraCommand(options) {
|
|
5
|
+
const targetPath = options.path || process.cwd();
|
|
6
|
+
try {
|
|
7
|
+
await setupInfra(targetPath);
|
|
8
|
+
} catch (err) {
|
|
9
|
+
logger.error(`setup-infra failed: ${err.message}`);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* context-budget — Token budget tracking for standards context
|
|
3
|
+
*
|
|
4
|
+
* Shows estimated token usage for agent briefings built from STANDARDS.json digests.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* morph-spec context-budget [--phase <phase>] [--json]
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { readFileSync, existsSync } from 'fs';
|
|
11
|
+
import { join, dirname } from 'path';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
import { buildAgentBriefing, estimateTokens, clearCache } from '../../lib/standards/digest-builder.js';
|
|
14
|
+
import chalk from 'chalk';
|
|
15
|
+
|
|
16
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const AGENTS_JSON_PATH = join(__dirname, '../../../framework/agents.json');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* CLI command: morph-spec context-budget [--phase <phase>] [--json]
|
|
21
|
+
*/
|
|
22
|
+
export async function contextBudgetCommand(options = {}) {
|
|
23
|
+
const phase = options.phase || 'implement';
|
|
24
|
+
|
|
25
|
+
if (!existsSync(AGENTS_JSON_PATH)) {
|
|
26
|
+
console.error(chalk.red('framework/agents.json not found.'));
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
clearCache();
|
|
32
|
+
const agentsData = JSON.parse(readFileSync(AGENTS_JSON_PATH, 'utf8'));
|
|
33
|
+
const allAgents = agentsData.agents || {};
|
|
34
|
+
|
|
35
|
+
const results = [];
|
|
36
|
+
|
|
37
|
+
for (const [agentId, agentData] of Object.entries(allAgents)) {
|
|
38
|
+
if (agentId.startsWith('_comment')) continue;
|
|
39
|
+
if (!agentData.standards || agentData.standards.length === 0) continue;
|
|
40
|
+
|
|
41
|
+
const briefing = buildAgentBriefing(agentId, phase);
|
|
42
|
+
if (!briefing) continue;
|
|
43
|
+
|
|
44
|
+
const tokens = estimateTokens(briefing);
|
|
45
|
+
results.push({
|
|
46
|
+
agentId,
|
|
47
|
+
tier: agentData.tier,
|
|
48
|
+
standardsCount: agentData.standards.length,
|
|
49
|
+
tokens,
|
|
50
|
+
overBudget: tokens > 8000,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Sort by tokens descending
|
|
55
|
+
results.sort((a, b) => b.tokens - a.tokens);
|
|
56
|
+
|
|
57
|
+
const totalTokens = results.reduce((sum, r) => sum + r.tokens, 0);
|
|
58
|
+
const overBudget = results.filter(r => r.overBudget);
|
|
59
|
+
|
|
60
|
+
if (options.json) {
|
|
61
|
+
console.log(JSON.stringify({ phase, totalTokens, overBudgetCount: overBudget.length, agents: results }, null, 2));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Human-readable
|
|
66
|
+
console.log(chalk.bold(`\n Context Budget — phase: ${phase}`));
|
|
67
|
+
console.log(' ' + '─'.repeat(62));
|
|
68
|
+
console.log(` ${'Agent'.padEnd(32)} ${'Tier'.padEnd(6)} ${'Stds'.padEnd(6)} Tokens`);
|
|
69
|
+
console.log(' ' + '─'.repeat(62));
|
|
70
|
+
|
|
71
|
+
for (const r of results) {
|
|
72
|
+
const tokenStr = r.overBudget ? chalk.red(String(r.tokens)) : String(r.tokens);
|
|
73
|
+
const flag = r.overBudget ? ' ⚠' : '';
|
|
74
|
+
console.log(
|
|
75
|
+
` ${r.agentId.padEnd(32)} ${String(r.tier).padEnd(6)} ${String(r.standardsCount).padEnd(6)} ${tokenStr}${flag}`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log(' ' + '─'.repeat(62));
|
|
80
|
+
console.log(` Total: ${results.length} agents, ${totalTokens} tokens`);
|
|
81
|
+
if (overBudget.length > 0) {
|
|
82
|
+
console.log(chalk.yellow(` ⚠ ${overBudget.length} agent(s) exceed 8000 token threshold`));
|
|
83
|
+
}
|
|
84
|
+
console.log();
|
|
85
|
+
} catch (err) {
|
|
86
|
+
console.error(chalk.red(`Error: ${err.message}`));
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Task Management Commands
|
|
3
|
-
*/
|
|
4
|
-
export { taskCommand } from './task.js';
|
|
1
|
+
/**
|
|
2
|
+
* Task Management Commands
|
|
3
|
+
*/
|
|
4
|
+
export { taskCommand } from './task.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Template Commands
|
|
3
|
-
*/
|
|
4
|
-
export { templateRenderCommand } from './template-render.js';
|
|
5
|
-
export { generateContractsCommand, parseSchemaAnalysisMd } from './generate-contracts.js';
|
|
1
|
+
/**
|
|
2
|
+
* Template Commands
|
|
3
|
+
*/
|
|
4
|
+
export { templateRenderCommand } from './template-render.js';
|
|
5
|
+
export { generateContractsCommand, parseSchemaAnalysisMd } from './generate-contracts.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility Commands — no active commands after CLI simplification
|
|
3
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* Utility Commands — no active commands after CLI simplification
|
|
3
|
+
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validation Commands
|
|
3
|
-
*/
|
|
4
|
-
export { validateFeatureCommand } from './validate-feature.js';
|
|
1
|
+
/**
|
|
2
|
+
* Validation Commands
|
|
3
|
+
*/
|
|
4
|
+
export { validateFeatureCommand } from './validate-feature.js';
|