@polymorphism-tech/morph-spec 11.1.0 → 11.2.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 +1 -1
- package/bin/morph-spec.js +9 -19
- package/docs/CHEATSHEET.md +3 -3
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +2 -0
- package/framework/MORPH.md +7 -2
- package/framework/agents.json +3 -3
- package/framework/docs/CLI.md +14 -12
- package/framework/evals/review-checklist.md +9 -16
- package/framework/hooks/README.md +15 -9
- package/framework/hooks/claude-code/core/README.md +2 -2
- package/framework/hooks/claude-code/core/chain.js +9 -25
- package/framework/hooks/claude-code/core/comment-guard.js +3 -9
- package/framework/hooks/claude-code/core/conventional-commit.js +3 -3
- package/framework/hooks/claude-code/core/graph-refresh-kick.js +4 -4
- package/framework/hooks/claude-code/core/masked-exit.js +4 -3
- package/framework/hooks/claude-code/core/pre-bash-denylist.js +2 -2
- package/framework/hooks/claude-code/core/protect-spec-files.js +2 -4
- package/framework/hooks/claude-code/core/stack-changed.js +5 -4
- package/framework/hooks/claude-code/core/validate-completion.js +15 -12
- package/framework/hooks/shared/contract.js +22 -1
- package/framework/hooks/shared/git-paths.js +6 -0
- package/framework/hooks/shared/graph-freshness.js +3 -3
- package/framework/hooks/shared/graph-refresh.js +5 -10
- package/framework/hooks/shared/hook-response.js +1 -18
- package/framework/hooks/shared/payload-utils.js +12 -1
- package/framework/hooks/shared/phase-utils.js +4 -52
- package/framework/hooks/shared/report-progress.js +1 -1
- package/framework/mcp/registry.json +1 -17
- package/framework/rules/dotnet-templates.md +32 -33
- package/framework/rules/infrastructure-standards.md +9 -9
- package/framework/rules/neon-standards.md +4 -4
- package/framework/rules/nextjs-templates.md +10 -11
- package/framework/rules/ui-design.md +2 -2
- package/framework/schemas/config.schema.json +4 -0
- 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 +5 -4
- package/framework/skills/core/morph-plan/SKILL.md +1 -1
- package/framework/skills/core/morph-uiux/SKILL.md +5 -5
- package/framework/standards/integration/mcp/mcp-tools.md +2 -2
- package/framework/templates/REGISTRY.json +1 -75
- package/framework/templates/docs/plan.md +1 -1
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Morph.AiKit.Tests.csproj +1 -1
- package/framework/templates/infrastructure/docker/docker-compose.template.yml +15 -16
- package/package.json +6 -15
- package/src/commands/graph/build.js +2 -2
- package/src/commands/mcp/mcp-setup.js +6 -4
- package/src/commands/project/doctor.js +42 -126
- package/src/commands/project/env.js +2 -1
- package/src/commands/project/init.js +28 -170
- package/src/commands/project/stack-set.js +3 -1
- package/src/commands/project/update.js +50 -154
- package/src/commands/scaffold/scaffold.js +21 -4
- package/src/commands/validation/check.js +12 -10
- package/src/commands/validation/prove-red.js +61 -22
- package/src/core/paths/output-schema.js +8 -37
- package/src/core/templates/template-registry.js +8 -43
- package/src/core/templates/template-renderer.js +3 -200
- package/src/lib/ai/ai-checks.js +1 -1
- package/src/lib/ai/ai-project-scan.js +1 -1
- package/src/lib/ai/code-audit.js +2 -2
- package/src/lib/check/signals.js +25 -7
- package/src/lib/contract/defaults.js +2 -2
- package/src/lib/detectors/claude-config-detector.js +0 -52
- package/src/lib/detectors/index.js +5 -30
- package/src/lib/diff/diff-lines.js +3 -3
- package/src/lib/generators/scaffold-generator.js +5 -17
- package/src/lib/git/default-branch.js +5 -48
- package/src/lib/graph/graph-health.js +1 -1
- package/src/lib/graph/graphifyignore.js +3 -4
- package/src/lib/graph/sanitize.js +2 -2
- package/src/lib/installers/effects.js +0 -13
- package/src/lib/installers/mcp-installer.js +5 -17
- package/src/lib/installers/memory-installer.js +5 -8
- package/src/lib/installers/stack-assets.js +33 -7
- package/src/lib/installers/stack-sync.js +4 -4
- package/src/lib/plan/checks.js +1 -1
- package/src/lib/plan/media.js +3 -3
- package/src/lib/plan/plan-parser.js +1 -1
- package/src/lib/review-reports.js +8 -14
- package/src/lib/scan/worktree-dirs.js +1 -3
- package/src/lib/specs/adr-index.js +4 -4
- package/src/lib/specs/revocations.js +3 -3
- package/src/lib/stack/stack-scan.js +3 -3
- package/src/lib/standards/registry.js +1 -1
- package/src/lib/standards/verified-against.js +2 -2
- package/src/lib/tests-audit/audit.js +2 -2
- package/src/scripts/global-install.js +41 -19
- package/src/scripts/setup-infra.js +57 -165
- package/src/utils/agents-installer.js +8 -30
- package/src/utils/claude-settings-manager.js +29 -27
- package/src/utils/hooks-installer.js +30 -44
- package/src/utils/version-checker.js +2 -31
- package/CLAUDE.md +0 -118
- package/framework/commands/create-umbraco-lp.md +0 -37
- package/framework/commands/migrate-lp-to-umbraco.md +0 -35
- package/framework/commands/morph-apply.md +0 -14
- package/framework/hooks/shared/spawn-command.js +0 -23
- package/framework/templates/CLAUDE.md.core.guide.md +0 -29
- package/framework/templates/CLAUDE.md.core.template +0 -22
- package/framework/templates/context/ARCHITECTURE.md +0 -106
- package/src/commands/context/context-refresh.js +0 -63
- package/src/lib/generators/architecture-scanner.js +0 -543
- package/src/lib/generators/settings-generator.js +0 -97
- package/src/lib/graph/god-nodes.js +0 -65
|
@@ -4,7 +4,7 @@ import { existsSync, readFileSync } from 'fs';
|
|
|
4
4
|
import { contractExists } from '../../shared/contract.js';
|
|
5
5
|
import { isFeaturePath, extractFeatureName, getBasename } from '../../shared/phase-utils.js';
|
|
6
6
|
import { blockResult, runStandalone } from '../../shared/hook-response.js';
|
|
7
|
-
import { getFilePath, getToolName, resolveMorphRoot, resolveTargetPath } from '../../shared/payload-utils.js';
|
|
7
|
+
import { applyEdit, getFilePath, getToolName, resolveMorphRoot, resolveTargetPath } from '../../shared/payload-utils.js';
|
|
8
8
|
import { ERRATA_HEADING, errataViolation } from '../../shared/errata.js';
|
|
9
9
|
import { SESSION_MARK } from '../../shared/owner-words.js';
|
|
10
10
|
|
|
@@ -15,9 +15,7 @@ function proposedText(payload, toolName, original) {
|
|
|
15
15
|
const oldStr = payload?.tool_input?.old_string;
|
|
16
16
|
const newStr = payload?.tool_input?.new_string;
|
|
17
17
|
if (typeof oldStr !== 'string' || typeof newStr !== 'string') return null;
|
|
18
|
-
return payload?.tool_input?.replace_all
|
|
19
|
-
? original.split(oldStr).join(newStr)
|
|
20
|
-
: original.replace(oldStr, newStr);
|
|
18
|
+
return applyEdit(original, oldStr, newStr, payload?.tool_input?.replace_all === true) ?? original;
|
|
21
19
|
}
|
|
22
20
|
const content = payload?.tool_input?.content;
|
|
23
21
|
return typeof content === 'string' ? content : null;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { execFileSync } from 'child_process';
|
|
4
|
-
import {
|
|
4
|
+
import { sessionContractRoot } from '../../shared/contract.js';
|
|
5
5
|
import { contextResult, runStandalone } from '../../shared/hook-response.js';
|
|
6
6
|
import { gitInvocations } from '../../shared/command-tokens.js';
|
|
7
|
+
import { SHELL_TOOLS } from '../../shared/payload-utils.js';
|
|
7
8
|
import { SESSION_MARK } from '../../shared/owner-words.js';
|
|
8
9
|
|
|
9
10
|
export const STACK_MANIFEST = /(^|\/)(package\.json|pyproject\.toml|requirements(-[\w-]+)?\.txt|[^/]+\.csproj|[^/]+\.slnx?|Directory\.Packages\.props|(docker-)?compose(\.[\w-]+)?\.ya?ml)$/i;
|
|
@@ -15,11 +16,11 @@ function committedFiles(cwd) {
|
|
|
15
16
|
|
|
16
17
|
export async function run(payload, deps = {}) {
|
|
17
18
|
try {
|
|
18
|
-
if (payload?.tool_name
|
|
19
|
+
if (!SHELL_TOOLS.has(payload?.tool_name)) return null;
|
|
19
20
|
const command = payload.tool_input?.command;
|
|
20
21
|
if (typeof command !== 'string' || !gitInvocations(command).some(({ sub }) => sub === 'commit')) return null;
|
|
21
|
-
const cwd = payload
|
|
22
|
-
if (!
|
|
22
|
+
const cwd = sessionContractRoot(payload);
|
|
23
|
+
if (!cwd) return null;
|
|
23
24
|
const touched = (deps.committedFiles ?? committedFiles)(cwd).filter((f) => STACK_MANIFEST.test(f));
|
|
24
25
|
if (!touched.length) return null;
|
|
25
26
|
return contextResult(
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
import { createHash } from 'crypto';
|
|
6
|
-
import {
|
|
6
|
+
import { contractRoot } from '../../shared/contract.js';
|
|
7
7
|
import { featureFromBranch } from '../../shared/feature-slug.js';
|
|
8
|
+
import { morphStateDir } from '../../shared/git-paths.js';
|
|
8
9
|
import { contextResult, runStandalone } from '../../shared/hook-response.js';
|
|
9
10
|
import { implementProgress } from '../../shared/report-progress.js';
|
|
10
11
|
import { scenarioLabel, SESSION_MARK } from '../../shared/owner-words.js';
|
|
@@ -16,28 +17,30 @@ export function unprovenScenarios(featurePath) {
|
|
|
16
17
|
.map((c) => `${scenarioLabel(c)} está marcado feito sem prova (o teste, a linha de código ou o passo que mostra que funciona).`);
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
// Every Stop runs the audit; only a changed warning set is said again.
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
// Every Stop runs the audit; only a changed warning set is said again. The memory lives in the
|
|
21
|
+
// git common dir, never in the project tree: without one, the warning repeats.
|
|
22
|
+
function changed(stateDir, slug, warnings) {
|
|
23
|
+
const hash = warnings.length ? createHash('sha1').update(warnings.join('\n')).digest('hex') : null;
|
|
24
|
+
if (!stateDir) return Boolean(hash);
|
|
25
|
+
const path = join(stateDir, 'warned-hashes.json');
|
|
22
26
|
let seen = {};
|
|
23
27
|
try { if (existsSync(path)) seen = JSON.parse(readFileSync(path, 'utf-8')); } catch { /* start fresh */ }
|
|
24
|
-
|
|
25
|
-
if (seen[slug] === hash) return false;
|
|
28
|
+
if ((seen[slug] ?? null) === hash) return false;
|
|
26
29
|
if (hash) seen[slug] = hash; else delete seen[slug];
|
|
27
|
-
try { mkdirSync(
|
|
30
|
+
try { mkdirSync(stateDir, { recursive: true }); writeFileSync(path, JSON.stringify(seen, null, 2)); } catch { /* fail-open */ }
|
|
28
31
|
return Boolean(hash);
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
export async function run() {
|
|
32
35
|
try {
|
|
33
|
-
const
|
|
34
|
-
if (!
|
|
35
|
-
const slug = featureFromBranch(
|
|
36
|
+
const root = contractRoot(process.env.CLAUDE_PROJECT_DIR || process.cwd());
|
|
37
|
+
if (!root) return null;
|
|
38
|
+
const slug = featureFromBranch(root);
|
|
36
39
|
if (!slug) return null;
|
|
37
|
-
const featurePath = join(
|
|
40
|
+
const featurePath = join(root, '.morph', 'features', slug);
|
|
38
41
|
if (!existsSync(featurePath)) return null;
|
|
39
42
|
const warnings = unprovenScenarios(featurePath);
|
|
40
|
-
if (!changed(
|
|
43
|
+
if (!changed(morphStateDir(root), slug, warnings)) return null;
|
|
41
44
|
return contextResult([
|
|
42
45
|
'MORPH-SPEC — relatório da construção:',
|
|
43
46
|
...warnings.map((w) => ` • ${w}`),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
3
|
|
|
4
4
|
export const CONTRACT_FILE = join('.morph', 'config', 'config.json');
|
|
5
5
|
|
|
@@ -12,3 +12,24 @@ export function contractExists(projectPath) {
|
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
/** The closest directory at or above `start` that holds the contract, or `null`. */
|
|
17
|
+
export function contractRoot(start) {
|
|
18
|
+
try {
|
|
19
|
+
let dir = resolve(start || process.cwd());
|
|
20
|
+
for (;;) {
|
|
21
|
+
if (existsSync(join(dir, CONTRACT_FILE))) return dir;
|
|
22
|
+
const parent = dirname(dir);
|
|
23
|
+
if (parent === dir) return null;
|
|
24
|
+
dir = parent;
|
|
25
|
+
}
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// A shell `cd` moves `payload.cwd` below the root, or out of the project: the session's project still counts.
|
|
32
|
+
export function sessionContractRoot(payload) {
|
|
33
|
+
return contractRoot(payload?.cwd)
|
|
34
|
+
?? (process.env.CLAUDE_PROJECT_DIR ? contractRoot(process.env.CLAUDE_PROJECT_DIR) : null);
|
|
35
|
+
}
|
|
@@ -66,6 +66,12 @@ export function resolveGitCommonDir(startDir) {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
/** Where morph-spec keeps machine state: inside the common git dir, shared by every worktree and never in the tree. */
|
|
70
|
+
export function morphStateDir(startDir) {
|
|
71
|
+
const common = startDir ? resolveGitCommonDir(startDir) : null;
|
|
72
|
+
return common ? join(common, 'morph-spec') : null;
|
|
73
|
+
}
|
|
74
|
+
|
|
69
75
|
const SHA = /^[0-9a-f]{40}(?:[0-9a-f]{24})?$/;
|
|
70
76
|
|
|
71
77
|
/** `null` for every shape it does not read (linked worktree, reftable, unborn branch): the caller asks git. */
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
renameSync, unlinkSync, writeFileSync,
|
|
10
10
|
} from 'fs';
|
|
11
11
|
import { basename, dirname, join, resolve } from 'path';
|
|
12
|
-
import { resolveGitCommonDir } from './git-paths.js';
|
|
12
|
+
import { morphStateDir, resolveGitCommonDir } from './git-paths.js';
|
|
13
13
|
|
|
14
14
|
export const GRAPH_DIR = 'graphify-out';
|
|
15
15
|
export const GRAPHIFY_IGNORE = '.graphifyignore';
|
|
@@ -114,8 +114,8 @@ export function treeKey(tree) {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
export function refreshStatePath(dir) {
|
|
117
|
-
const
|
|
118
|
-
return
|
|
117
|
+
const state = morphStateDir(dir);
|
|
118
|
+
return state ? join(state, STATE_FILE) : null;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
function readState(path) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Só a raiz: o worker destacado nasce com `cwd` no git common dir, porque no win32
|
|
2
|
-
// um diretório em uso não se apaga e
|
|
2
|
+
// um diretório em uso não se apaga e remover a worktree falharia no meio.
|
|
3
3
|
// A worktree anda por `morph-spec graph refresh`, em primeiro plano.
|
|
4
4
|
|
|
5
5
|
import { spawn, spawnSync } from 'child_process';
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { dirname, join, resolve } from 'path';
|
|
11
11
|
import { homedir } from 'os';
|
|
12
12
|
import { fileURLToPath } from 'url';
|
|
13
|
-
import { readPrimaryHead, resolveGitCommonDir, workTreeTop } from './git-paths.js';
|
|
13
|
+
import { morphStateDir, readPrimaryHead, resolveGitCommonDir, workTreeTop } from './git-paths.js';
|
|
14
14
|
import { findFirstOnPath, quoteForCmd } from './morph-cli.js';
|
|
15
15
|
import { backgroundArgs } from './background-spawn.js';
|
|
16
16
|
import { ensureCommonExclude } from './git-exclude.js';
|
|
@@ -43,18 +43,13 @@ export function isPrimaryTree(dir) {
|
|
|
43
43
|
return Boolean(top && primary && treeKey(top) === treeKey(primary));
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
function stateDir(dir) {
|
|
47
|
-
const common = resolveGitCommonDir(dir);
|
|
48
|
-
return common ? join(common, 'morph-spec') : null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
46
|
export function refreshLockPath(dir) {
|
|
52
|
-
const d =
|
|
47
|
+
const d = morphStateDir(dir);
|
|
53
48
|
return d ? join(d, 'graph-refresh.lock') : null;
|
|
54
49
|
}
|
|
55
50
|
|
|
56
51
|
function refreshLogPath(dir) {
|
|
57
|
-
const d =
|
|
52
|
+
const d = morphStateDir(dir);
|
|
58
53
|
return d ? join(d, 'graph-refresh.log') : null;
|
|
59
54
|
}
|
|
60
55
|
|
|
@@ -182,7 +177,7 @@ export function runGraphify(tree, args, { env = process.env, timeout = GRAPHIFY_
|
|
|
182
177
|
}
|
|
183
178
|
|
|
184
179
|
// O registro da semente copia só o que se SABE do grafo da raiz; `graphify-out/`
|
|
185
|
-
// vai para o exclude do common dir, senão a worktree fica suja para
|
|
180
|
+
// vai para o exclude do common dir, senão a worktree fica suja para quem for removê-la.
|
|
186
181
|
export function seedGraphFromRoot(tree, root) {
|
|
187
182
|
if (!tree || !root || treeKey(tree) === treeKey(root)) return { seeded: false, reason: 'is-root' };
|
|
188
183
|
if (existsSync(graphFile(tree))) return { seeded: false, reason: 'present' };
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
// A top-level `additionalContext` is NOT honored for any event: it must be nested
|
|
2
2
|
// under `hookSpecificOutput` (https://code.claude.com/docs/en/hooks.md).
|
|
3
3
|
|
|
4
|
-
export function block(reason) {
|
|
5
|
-
console.log(JSON.stringify({ decision: 'block', reason }));
|
|
6
|
-
process.exit(0);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function approve(context) {
|
|
10
|
-
if (context) {
|
|
11
|
-
console.log(JSON.stringify({ decision: 'approve', additionalContext: context }));
|
|
12
|
-
}
|
|
13
|
-
process.exit(0);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
4
|
export function injectContext(text, eventName) {
|
|
17
5
|
console.log(JSON.stringify({
|
|
18
6
|
hookSpecificOutput: { hookEventName: eventName, additionalContext: text },
|
|
@@ -20,12 +8,7 @@ export function injectContext(text, eventName) {
|
|
|
20
8
|
process.exit(0);
|
|
21
9
|
}
|
|
22
10
|
|
|
23
|
-
|
|
24
|
-
process.exit(0);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// `run()` returns these instead of exiting: chain.js runs several hooks in one
|
|
28
|
-
// process. Same JSON shapes as block()/approve()/injectContext() above.
|
|
11
|
+
// `run()` returns these instead of exiting: chain.js runs several hooks in one process.
|
|
29
12
|
export function blockResult(reason) {
|
|
30
13
|
return { decision: 'block', reason };
|
|
31
14
|
}
|
|
@@ -29,10 +29,21 @@ export function resolveTargetPath(filePath, fallbackCwd) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export function getFilePath(payload) {
|
|
32
|
-
const raw = payload?.tool_input?.file_path ||
|
|
32
|
+
const raw = payload?.tool_input?.file_path || '';
|
|
33
33
|
return raw.replace(/\\/g, '/');
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/** The tools whose `tool_input.command` is a shell line; also the matcher of the shell hook groups. */
|
|
37
|
+
export const SHELL_TOOLS = new Set(['Bash', 'PowerShell']);
|
|
38
|
+
|
|
39
|
+
/** What the Edit tool writes, or `null` when `oldString` is absent. Splices: `String.replace` would expand `$&` in the new text. */
|
|
40
|
+
export function applyEdit(original, oldString, newString, replaceAll = false) {
|
|
41
|
+
if (replaceAll) return original.split(oldString).join(newString);
|
|
42
|
+
const at = original.indexOf(oldString);
|
|
43
|
+
if (at < 0) return null;
|
|
44
|
+
return original.slice(0, at) + newString + original.slice(at + oldString.length);
|
|
45
|
+
}
|
|
46
|
+
|
|
36
47
|
export function getToolName(payload) {
|
|
37
48
|
return payload?.tool_name || 'unknown';
|
|
38
49
|
}
|
|
@@ -1,62 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
// Source of truth: src/core/paths/output-schema.js
|
|
3
|
-
// Regenerate with: node scripts/generate-refs.js
|
|
4
|
-
|
|
5
|
-
export const PHASE_DIRS = {
|
|
6
|
-
plan: '2-plan',
|
|
7
|
-
uiux: '1-design',
|
|
8
|
-
implement: '3-implement',
|
|
9
|
-
review: '4-review',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const OUTPUT_PHASE_MAP = {
|
|
13
|
-
plan: 'plan',
|
|
14
|
-
checks: 'plan',
|
|
15
|
-
planCritique: 'plan',
|
|
16
|
-
uiMockups: 'uiux',
|
|
17
|
-
implementReport: 'implement',
|
|
18
|
-
evidencias: 'implement',
|
|
19
|
-
verifierReport: 'review',
|
|
20
|
-
reviewerReport: 'review',
|
|
21
|
-
securityReport: 'review',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const FILENAME_TO_OUTPUT = {
|
|
25
|
-
'plan.md': 'plan',
|
|
26
|
-
'checks.json': 'checks',
|
|
27
|
-
'critica.md': 'planCritique',
|
|
28
|
-
'mockups.md': 'uiMockups',
|
|
29
|
-
'report.md': 'implementReport',
|
|
30
|
-
'verifier.md': 'verifierReport',
|
|
31
|
-
'reviewer.md': 'reviewerReport',
|
|
32
|
-
'security.md': 'securityReport',
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const PROTECTED_SPEC_FILES = {
|
|
36
|
-
'plan.md': 'plan',
|
|
37
|
-
'checks.json': 'plan',
|
|
38
|
-
'mockups.md': 'uiux',
|
|
39
|
-
};
|
|
40
|
-
|
|
1
|
+
const posix = (filePath) => filePath.replace(/\\/g, '/');
|
|
41
2
|
|
|
42
3
|
export function extractFeatureName(filePath) {
|
|
43
|
-
const
|
|
44
|
-
const match = normalized.match(/\.morph\/features\/([^/]+)\//);
|
|
45
|
-
return match ? match[1] : null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function extractPhaseDir(filePath) {
|
|
49
|
-
const normalized = filePath.replace(/\\/g, '/');
|
|
50
|
-
const match = normalized.match(/\.morph\/features\/[^/]+\/(\d+-[^/]+)\//);
|
|
4
|
+
const match = posix(filePath).match(/\.morph\/features\/([^/]+)\//);
|
|
51
5
|
return match ? match[1] : null;
|
|
52
6
|
}
|
|
53
7
|
|
|
54
8
|
export function isFeaturePath(filePath) {
|
|
55
|
-
|
|
56
|
-
return normalized.includes('.morph/features/');
|
|
9
|
+
return posix(filePath).includes('.morph/features/');
|
|
57
10
|
}
|
|
58
11
|
|
|
59
12
|
export function getBasename(filePath) {
|
|
60
|
-
|
|
61
|
-
return normalized.split('/').pop();
|
|
13
|
+
return posix(filePath).split('/').pop();
|
|
62
14
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "4.0.0",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "MCP registry: stack relevance and install configuration",
|
|
4
4
|
"mcps": {
|
|
5
5
|
"context7": {
|
|
6
|
-
"phases": ["plan", "implement"],
|
|
7
6
|
"tools": ["resolve-library-id", "query-docs"],
|
|
8
7
|
"serverNames": ["context7", "plugin_context7_context7"],
|
|
9
8
|
"detection": "enabledPlugins includes context7 or mcpServers includes context7",
|
|
@@ -32,7 +31,6 @@
|
|
|
32
31
|
}
|
|
33
32
|
},
|
|
34
33
|
"playwright": {
|
|
35
|
-
"phases": ["uiux", "implement"],
|
|
36
34
|
"tools": ["browser_navigate", "browser_snapshot", "browser_take_screenshot", "browser_console_messages", "browser_click", "browser_resize"],
|
|
37
35
|
"serverNames": ["playwright", "plugin_playwright_playwright"],
|
|
38
36
|
"detection": "mcpServers includes playwright or enabledPlugins includes playwright",
|
|
@@ -61,7 +59,6 @@
|
|
|
61
59
|
}
|
|
62
60
|
},
|
|
63
61
|
"vercel": {
|
|
64
|
-
"phases": ["implement"],
|
|
65
62
|
"tools": ["search_docs", "list_projects", "get_deployments", "get_deployment_logs", "manage_env_vars"],
|
|
66
63
|
"detection": "mcpServers includes vercel",
|
|
67
64
|
"fallback": "Bash `vercel` CLI commands",
|
|
@@ -88,7 +85,6 @@
|
|
|
88
85
|
}
|
|
89
86
|
},
|
|
90
87
|
"asaas": {
|
|
91
|
-
"phases": ["plan", "implement"],
|
|
92
88
|
"tools": ["enumerate_endpoints", "get_endpoint_schema", "generate_code_example", "execute_api_call", "search_docs"],
|
|
93
89
|
"detection": "mcpServers includes asaas",
|
|
94
90
|
"fallback": "WebFetch https://docs.asaas.com for API documentation",
|
|
@@ -115,7 +111,6 @@
|
|
|
115
111
|
}
|
|
116
112
|
},
|
|
117
113
|
"shadcn": {
|
|
118
|
-
"phases": ["uiux", "implement"],
|
|
119
114
|
"tools": ["get_project_registries", "list_items_in_registries", "search_items_in_registries", "view_items_in_registries", "get_item_examples_from_registries", "get_add_command_for_items", "get_audit_checklist"],
|
|
120
115
|
"serverNames": ["shadcn"],
|
|
121
116
|
"detection": "mcpServers includes shadcn",
|
|
@@ -156,7 +151,6 @@
|
|
|
156
151
|
}
|
|
157
152
|
},
|
|
158
153
|
"morph-assets": {
|
|
159
|
-
"phases": ["uiux", "implement"],
|
|
160
154
|
"tools": ["generate_image", "edit_image", "continue_editing", "generate_video", "generate_loop_video", "get_video", "media_tool", "list_models", "library", "usage"],
|
|
161
155
|
"serverNames": ["morph-assets"],
|
|
162
156
|
"detection": "mcpServers includes morph-assets",
|
|
@@ -204,7 +198,6 @@
|
|
|
204
198
|
}
|
|
205
199
|
},
|
|
206
200
|
"graphify": {
|
|
207
|
-
"phases": ["plan", "implement", "review"],
|
|
208
201
|
"tools": ["query_graph", "get_node", "get_neighbors", "get_community", "god_nodes", "graph_stats", "shortest_path", "list_prs", "get_pr_impact", "triage_prs"],
|
|
209
202
|
"detection": "graphify-out/graph.json exists in the project root (written by morph-spec graph build, or by the graphify post-commit hook)",
|
|
210
203
|
"fallback": "Comportamento atual: Grep/Glob/Read. O grafo é um subconjunto estrito do grep — no eval não encontrou um único arquivo que o grep perderia — então cair para grep não perde recall, só devolve mais ruído",
|
|
@@ -239,7 +232,6 @@
|
|
|
239
232
|
}
|
|
240
233
|
},
|
|
241
234
|
"neon": {
|
|
242
|
-
"phases": ["plan", "implement"],
|
|
243
235
|
"tools": ["list_projects", "describe_table_schema", "get_database_tables", "run_sql", "explain_sql_statement", "prepare_database_migration", "complete_database_migration", "compare_database_schema", "create_branch", "list_branches", "get_connection_string", "list_slow_queries", "prepare_query_tuning", "complete_query_tuning", "create_snapshot", "search_docs", "get_doc"],
|
|
244
236
|
"serverNames": ["neon", "Neon"],
|
|
245
237
|
"detection": "mcpServers includes neon (case-insensitive)",
|
|
@@ -267,7 +259,6 @@
|
|
|
267
259
|
}
|
|
268
260
|
},
|
|
269
261
|
"microsoft-learn": {
|
|
270
|
-
"phases": ["plan", "implement"],
|
|
271
262
|
"tools": ["microsoft_docs_search", "microsoft_docs_fetch", "microsoft_code_sample_search"],
|
|
272
263
|
"serverNames": ["microsoft-learn", "plugin_microsoft-docs_microsoft-learn"],
|
|
273
264
|
"detection": "mcpServers includes microsoft-learn or enabledPlugins includes microsoft-docs",
|
|
@@ -296,12 +287,5 @@
|
|
|
296
287
|
"setupGuide": "Run: claude mcp add --transport http microsoft-learn https://learn.microsoft.com/api/mcp"
|
|
297
288
|
}
|
|
298
289
|
}
|
|
299
|
-
},
|
|
300
|
-
"_phaseMatrixNote": "Keys must be the v5 phases from framework/phases.json. The v4 keys 'design' and 'tasks' both collapsed into 'plan'; 'review' was absent entirely, so a project in review resolved to undefined. Stack-scoped MCPs (asaas, neon, microsoft-learn) stay out of this matrix on purpose — only universal ones are listed.",
|
|
301
|
-
"phaseMatrix": {
|
|
302
|
-
"plan": ["context7", "graphify"],
|
|
303
|
-
"uiux": ["playwright", "context7", "morph-assets"],
|
|
304
|
-
"implement": ["context7", "playwright", "vercel", "morph-assets", "graphify"],
|
|
305
|
-
"review": ["playwright", "context7", "graphify"]
|
|
306
290
|
}
|
|
307
291
|
}
|
|
@@ -8,8 +8,7 @@ stacks:
|
|
|
8
8
|
|
|
9
9
|
# .NET Code Templates
|
|
10
10
|
|
|
11
|
-
When implementing .NET features, use these templates as reference patterns.
|
|
12
|
-
Read the template file to see the exact pattern, then generate code following it.
|
|
11
|
+
When implementing .NET features, use these templates as reference patterns. They live in the morph-spec package, not in the project: `morph-spec scaffold show <id>` prints one.
|
|
13
12
|
|
|
14
13
|
## Scaffold (preferred for new slices)
|
|
15
14
|
|
|
@@ -30,58 +29,58 @@ morph-spec scaffold dotnet book get-all-books
|
|
|
30
29
|
|
|
31
30
|
Generates 7 files: endpoint, handler, request, response, validator + entity, errors (shared at feature level). Entity/errors auto-skipped if they already exist.
|
|
32
31
|
|
|
33
|
-
**Adding a single file to an existing slice:**
|
|
32
|
+
**Adding a single file to an existing slice:** print its template (`morph-spec scaffold show <id>`, ids below) and write the file following it — `scaffold dotnet` generates whole slices only.
|
|
34
33
|
|
|
35
34
|
## VSA Feature Templates (Vertical Slice Architecture)
|
|
36
35
|
|
|
37
36
|
For each new feature slice, follow the patterns in these templates:
|
|
38
37
|
|
|
39
|
-
| Template |
|
|
38
|
+
| Template | Id | Purpose |
|
|
40
39
|
|----------|------|---------|
|
|
41
|
-
| Endpoint |
|
|
42
|
-
| Handler |
|
|
43
|
-
| Request |
|
|
44
|
-
| Response |
|
|
45
|
-
| Validator |
|
|
46
|
-
| Entity |
|
|
47
|
-
| Errors |
|
|
40
|
+
| Endpoint | `dotnet-feature-endpoint` | IApiEndpoint with MapEndpoint() |
|
|
41
|
+
| Handler | `dotnet-feature-handler` | IHandler<TRequest, TResponse> |
|
|
42
|
+
| Request | `dotnet-feature-request` | record DTO |
|
|
43
|
+
| Response | `dotnet-feature-response` | record DTO |
|
|
44
|
+
| Validator | `dotnet-feature-validator` | FluentValidation AbstractValidator |
|
|
45
|
+
| Entity | `dotnet-feature-entity` | Domain entity |
|
|
46
|
+
| Errors | `dotnet-feature-errors` | Error factory |
|
|
48
47
|
|
|
49
48
|
## Base Abstractions (read once per project setup)
|
|
50
49
|
|
|
51
|
-
| Template |
|
|
50
|
+
| Template | Id | Purpose |
|
|
52
51
|
|----------|------|---------|
|
|
53
|
-
| IHandler |
|
|
54
|
-
| Result<T> |
|
|
55
|
-
| Error |
|
|
56
|
-
| IApiEndpoint |
|
|
52
|
+
| IHandler | `dotnet-abstractions-handler` | Handler interface |
|
|
53
|
+
| Result<T> | `dotnet-abstractions-result` | Railway-oriented result |
|
|
54
|
+
| Error | `dotnet-abstractions-error` | Error types |
|
|
55
|
+
| IApiEndpoint | `dotnet-abstractions-api-endpoint` | Endpoint interface |
|
|
57
56
|
|
|
58
57
|
## Extensions & Pipeline (read once per project setup)
|
|
59
58
|
|
|
60
|
-
| Template |
|
|
59
|
+
| Template | Id | Purpose |
|
|
61
60
|
|----------|------|---------|
|
|
62
|
-
| Handler Registration |
|
|
63
|
-
| Map Endpoints |
|
|
64
|
-
| Result Extensions |
|
|
65
|
-
| Database Config |
|
|
66
|
-
| Health Checks |
|
|
67
|
-
| Validation Decorator |
|
|
68
|
-
| Logging Decorator |
|
|
69
|
-
| Exception Handler |
|
|
70
|
-
| API Tags |
|
|
61
|
+
| Handler Registration | `dotnet-extensions-handler-registration` | Scrutor auto-discovery |
|
|
62
|
+
| Map Endpoints | `dotnet-extensions-map-endpoints` | IApiEndpoint discovery |
|
|
63
|
+
| Result Extensions | `dotnet-extensions-result-extensions` | Match() pattern |
|
|
64
|
+
| Database Config | `dotnet-extensions-database` | EF Core + Npgsql |
|
|
65
|
+
| Health Checks | `dotnet-extensions-health-checks` | Health endpoints |
|
|
66
|
+
| Validation Decorator | `dotnet-pipelines-validation-decorator` | FluentValidation pipeline |
|
|
67
|
+
| Logging Decorator | `dotnet-pipelines-logging-decorator` | Duration tracking |
|
|
68
|
+
| Exception Handler | `dotnet-exceptions-handler` | ProblemDetails |
|
|
69
|
+
| API Tags | `dotnet-constants-api-tags` | Scalar/Swagger groups |
|
|
71
70
|
|
|
72
71
|
## Specialized Templates
|
|
73
72
|
|
|
74
|
-
| Template |
|
|
73
|
+
| Template | Id | Purpose |
|
|
75
74
|
|----------|------|---------|
|
|
76
|
-
| Migration |
|
|
77
|
-
| Hangfire Job |
|
|
78
|
-
| MAF Agent |
|
|
79
|
-
| Unit Test |
|
|
80
|
-
| Contracts VSA |
|
|
75
|
+
| Migration | `dotnet-database-migration` | EF Core migration |
|
|
76
|
+
| Hangfire Job | `dotnet-jobs-hangfire` | Background job |
|
|
77
|
+
| MAF Agent | `dotnet-jobs-agent` | MS Agent Framework |
|
|
78
|
+
| Unit Test | `dotnet-backend-test` | xUnit AAA test |
|
|
79
|
+
| Contracts VSA | `dotnet-contracts-vsa` | Full slice contracts |
|
|
81
80
|
|
|
82
81
|
## Usage
|
|
83
82
|
|
|
84
|
-
1. **
|
|
83
|
+
1. **Print the template** (`morph-spec scaffold show <id>`) to see the exact pattern
|
|
85
84
|
2. **Generate code following the same structure** (naming, namespaces, imports)
|
|
86
85
|
3. Or scaffold a whole VSA slice from the templates at once:
|
|
87
86
|
`morph-spec scaffold dotnet <feature> <slice-name>`
|
|
@@ -19,14 +19,14 @@ stacks:
|
|
|
19
19
|
|
|
20
20
|
## Infrastructure Templates
|
|
21
21
|
|
|
22
|
-
| Template |
|
|
22
|
+
| Template | Id | Purpose |
|
|
23
23
|
|----------|------|---------|
|
|
24
|
-
| .NET API Dockerfile |
|
|
25
|
-
| Next.js Dockerfile |
|
|
26
|
-
| Docker Compose |
|
|
27
|
-
| Coolify Config |
|
|
28
|
-
| .NET Build CI |
|
|
29
|
-
| Docker Push CI |
|
|
30
|
-
| Deploy Coolify |
|
|
24
|
+
| .NET API Dockerfile | `docker-dockerfile-api` | Multi-stage .NET |
|
|
25
|
+
| Next.js Dockerfile | `docker-dockerfile-web` | Multi-stage Next.js |
|
|
26
|
+
| Docker Compose | `docker-compose` | Local dev env — one isolated stack per worktree (ports from the block, no `container_name`) |
|
|
27
|
+
| Coolify Config | `coolify-config` | Deployment config |
|
|
28
|
+
| .NET Build CI | `github-workflow-dotnet-build` | CI workflow |
|
|
29
|
+
| Docker Push CI | `github-workflow-docker-build-push` | Build & push |
|
|
30
|
+
| Deploy Coolify | `github-workflow-deploy-coolify` | CD via SSH |
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Templates live in the morph-spec package, not in the project: print one with `morph-spec scaffold show <id>` and adapt it to your project structure.
|
|
@@ -19,9 +19,9 @@ stacks:
|
|
|
19
19
|
|
|
20
20
|
## SQL Templates
|
|
21
21
|
|
|
22
|
-
| Template |
|
|
22
|
+
| Template | Id | Purpose |
|
|
23
23
|
|----------|------|---------|
|
|
24
|
-
| PostgreSQL Migration |
|
|
25
|
-
| PostgreSQL RLS Policy |
|
|
24
|
+
| PostgreSQL Migration | `sql-postgresql-migration` | Database migration |
|
|
25
|
+
| PostgreSQL RLS Policy | `sql-rls-policy` | Row-level security |
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
Templates live in the morph-spec package, not in the project: print one with `morph-spec scaffold show <id>` and adapt it to your project structure.
|
|
@@ -8,8 +8,7 @@ stacks:
|
|
|
8
8
|
|
|
9
9
|
# Next.js Code Templates
|
|
10
10
|
|
|
11
|
-
When implementing Next.js features, use these templates as reference patterns.
|
|
12
|
-
Read the template file to see the exact pattern, then generate code following it.
|
|
11
|
+
When implementing Next.js features, use these templates as reference patterns. They live in the morph-spec package, not in the project: `morph-spec scaffold show <id>` prints one.
|
|
13
12
|
|
|
14
13
|
## Scaffold (preferred for new features)
|
|
15
14
|
|
|
@@ -27,14 +26,14 @@ morph-spec scaffold nextjs user-profile
|
|
|
27
26
|
|
|
28
27
|
Generates 4 files: page (Server Component), list component, form component, TanStack Query hook.
|
|
29
28
|
|
|
30
|
-
**Adding a single file to an existing feature:**
|
|
29
|
+
**Adding a single file to an existing feature:** print its template (`morph-spec scaffold show <id>`, ids below) and write the file following it — `scaffold nextjs` generates whole features only.
|
|
31
30
|
|
|
32
|
-
| Template |
|
|
31
|
+
| Template | Id | Purpose |
|
|
33
32
|
|----------|------|---------|
|
|
34
|
-
| Server Page |
|
|
35
|
-
| Client Component |
|
|
36
|
-
| Feature Form |
|
|
37
|
-
| Custom Hook |
|
|
38
|
-
| Env Config |
|
|
39
|
-
| TypeScript Config |
|
|
40
|
-
| Dockerfile |
|
|
33
|
+
| Server Page | `nextjs-page` | App Router server component |
|
|
34
|
+
| Client Component | `nextjs-client-component` | `'use client'` component |
|
|
35
|
+
| Feature Form | `nextjs-feature-form` | react-hook-form + Zod + shadcn |
|
|
36
|
+
| Custom Hook | `nextjs-use-feature` | TanStack Query hook |
|
|
37
|
+
| Env Config | `nextjs-env-mjs` | T3 Env validation |
|
|
38
|
+
| TypeScript Config | `nextjs-tsconfig` | Path aliases |
|
|
39
|
+
| Dockerfile | `nextjs-dockerfile` | Multi-stage build |
|