@polymorphism-tech/morph-spec 11.1.1 → 11.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.
- package/README.md +3 -2
- package/bin/morph-spec.js +13 -23
- package/docs/CHEATSHEET.md +3 -3
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +3 -1
- package/framework/MORPH.md +8 -3
- package/framework/agents.json +4 -4
- package/framework/docs/CLI.md +28 -18
- package/framework/evals/review-checklist.md +35 -18
- package/framework/hooks/README.md +18 -11
- 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 +6 -6
- 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 +16 -32
- package/framework/rules/ai-agents-standards.md +9 -1
- package/framework/rules/dotnet-templates.md +32 -33
- package/framework/rules/gsap-standards.md +8 -0
- package/framework/rules/infrastructure-standards.md +9 -9
- package/framework/rules/mcp-standards.md +10 -0
- 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 +11 -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 +6 -4
- package/framework/skills/core/morph-plan/SKILL.md +1 -1
- package/framework/skills/core/morph-uiux/SKILL.md +5 -5
- package/framework/standards/STANDARDS.json +8 -4
- package/framework/standards/STANDARDS.meta.json +1 -1
- package/framework/standards/ai-agents/agent-archetypes.md +1 -1
- package/framework/standards/ai-agents/middleware-patterns.md +0 -2
- package/framework/standards/ai-agents/prompt-sources.md +2 -2
- package/framework/standards/ai-agents/providers/model-registry.md +9 -12
- package/framework/standards/ai-agents/rag-custom-pgvector.md +2 -9
- package/framework/standards/frontend/design-system/ai-image-generation.md +1 -1
- package/framework/standards/infrastructure/docker/local-compose-isolation.md +2 -2
- package/framework/standards/integration/mcp/mcp-tools.md +125 -267
- package/framework/templates/README.md +52 -82
- package/framework/templates/REGISTRY.json +1 -281
- package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +3 -4
- package/framework/templates/context/design-system.md +1 -1
- package/framework/templates/docs/plan.md +2 -2
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/model-registry.v2.json +1 -1
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaDisclosureTests.cs +1 -1
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Morph.AiKit.Tests.csproj +3 -5
- package/framework/templates/frontend/nextjs/gsap-scroll-section.tsx.hbs +13 -17
- package/framework/templates/infrastructure/docker/docker-compose.template.yml +15 -16
- package/framework/templates/infrastructure/github/README.md +10 -13
- package/package.json +7 -16
- package/src/commands/graph/build.js +2 -2
- package/src/commands/mcp/manual-setup.js +95 -0
- package/src/commands/mcp/mcp-setup.js +26 -192
- package/src/commands/project/doctor.js +48 -142
- package/src/commands/project/env.js +2 -1
- package/src/commands/project/init-contract.js +2 -2
- package/src/commands/project/init.js +34 -294
- package/src/commands/project/stack-scan.js +6 -14
- package/src/commands/project/stack-set.js +3 -1
- package/src/commands/project/standards.js +1 -2
- package/src/commands/project/update.js +87 -205
- package/src/commands/scaffold/scaffold.js +43 -5
- 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 -27
- 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 +2 -5
- package/src/lib/ai/code-audit.js +3 -8
- package/src/lib/ai/registry-audit.js +2 -1
- package/src/lib/check/signals.js +25 -7
- package/src/lib/config/project-config.js +3 -2
- package/src/lib/contract/apply.js +2 -1
- package/src/lib/contract/defaults.js +2 -2
- package/src/lib/contract/merge.js +1 -0
- package/src/lib/contract/scan.js +5 -5
- package/src/lib/detectors/claude-config-detector.js +44 -98
- package/src/lib/detectors/mcp-config.js +2 -1
- package/src/lib/diff/diff-lines.js +4 -9
- package/src/lib/generators/scaffold-generator.js +5 -17
- package/src/lib/git/default-branch.js +5 -13
- package/src/lib/graph/graph-health.js +1 -1
- package/src/lib/graph/graph-loader.js +2 -1
- package/src/lib/graph/graphifyignore.js +5 -5
- package/src/lib/graph/sanitize.js +2 -2
- package/src/lib/installers/effects.js +0 -13
- package/src/lib/installers/install-manifest.js +56 -0
- package/src/lib/installers/mcp-installer.js +16 -19
- package/src/lib/installers/memory-installer.js +5 -8
- package/src/lib/installers/rules-installer.js +9 -15
- package/src/lib/installers/stack-assets.js +54 -7
- package/src/lib/installers/stack-sync.js +16 -16
- package/src/lib/installers/stack-tooling.js +4 -3
- package/src/lib/json-file.js +9 -0
- package/src/lib/plan/artifact-vocabulary.js +1 -1
- package/src/lib/plan/checks.js +4 -3
- package/src/lib/plan/media.js +6 -6
- package/src/lib/plan/plan-parser.js +6 -11
- package/src/lib/review-reports.js +13 -18
- 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 +4 -4
- package/src/lib/standards/registry.js +1 -1
- package/src/lib/standards/verified-against.js +3 -3
- package/src/lib/tests-audit/audit.js +3 -3
- package/src/lib/text.js +5 -0
- package/src/scripts/global-install.js +41 -19
- package/src/scripts/setup-infra.js +68 -187
- package/src/utils/agents-installer.js +21 -60
- package/src/utils/claude-md-injector.js +16 -50
- package/src/utils/claude-settings-manager.js +29 -27
- package/src/utils/file-copier.js +3 -4
- package/src/utils/hooks-installer.js +83 -62
- package/src/utils/skills-installer.js +18 -78
- 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/IDE-SNIPPETS.md +0 -262
- package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +0 -26
- package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +0 -28
- package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +0 -99
- package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +0 -40
- package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +0 -54
- package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +0 -53
- package/framework/templates/code/dotnet/contracts/README.md +0 -74
- package/framework/templates/code/dotnet/database/vector-entity.cs +0 -49
- package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +0 -91
- package/framework/templates/code/sql/postgresql-migration.template.sql +0 -108
- package/framework/templates/code/typescript/contracts.ts +0 -140
- package/framework/templates/context/ARCHITECTURE.md +0 -106
- package/framework/templates/examples/design-system-examples.md +0 -354
- package/framework/templates/infrastructure/docker/Dockerfile.template +0 -58
- package/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +0 -45
- package/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +0 -27
- package/framework/templates/integrations/asaas-client.cs +0 -332
- package/framework/templates/integrations/asaas-webhook.cs +0 -290
- package/framework/templates/integrations/neon-auth-config.cs +0 -170
- package/framework/templates/ui/design-system.css +0 -226
- package/src/commands/context/context-refresh.js +0 -63
- package/src/lib/detectors/index.js +0 -178
- 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
- package/src/lib/installers/templates-reconcile.js +0 -26
|
@@ -1,96 +1,36 @@
|
|
|
1
|
-
import { existsSync, readdirSync,
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'fs';
|
|
2
2
|
import { basename, join } from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
3
|
import { parseStacks, shouldInstall } from '../lib/stack-filter.js';
|
|
5
4
|
import { realEffects } from '../lib/installers/effects.js';
|
|
5
|
+
import { pruneOwned } from '../lib/installers/install-manifest.js';
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
const FRAMEWORK_SKILLS_DIR = join(__dirname, '..', '..', 'framework', 'skills');
|
|
9
|
-
|
|
10
|
-
const SKILL_LEVELS_TO_INSTALL = ['core'];
|
|
7
|
+
const CORE_SKILLS_DIR = join(import.meta.dirname, '..', '..', 'framework', 'skills', 'core');
|
|
11
8
|
|
|
12
9
|
export function shouldInstallSkill(skillContent, projectTags) {
|
|
13
10
|
return shouldInstall(parseStacks(skillContent), projectTags);
|
|
14
11
|
}
|
|
15
12
|
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function installSkillsFromDir(srcDir, destDir, projectTags, installedNow, fx) {
|
|
21
|
-
const entries = readdirSync(srcDir);
|
|
22
|
-
for (const entry of entries) {
|
|
23
|
-
const srcPath = join(srcDir, entry);
|
|
24
|
-
const stat = statSync(srcPath);
|
|
25
|
-
|
|
26
|
-
if (stat.isDirectory()) {
|
|
27
|
-
const skillMdPath = join(srcPath, 'SKILL.md');
|
|
28
|
-
if (existsSync(skillMdPath)) {
|
|
29
|
-
const content = readFileSync(skillMdPath, 'utf-8');
|
|
30
|
-
if (!shouldInstallSkill(content, projectTags)) continue;
|
|
31
|
-
const skillDestDir = join(destDir, entry);
|
|
32
|
-
copySkillDirectory(srcPath, skillDestDir, fx);
|
|
33
|
-
installedNow.add(entry);
|
|
34
|
-
} else {
|
|
35
|
-
installSkillsFromDir(srcPath, destDir, projectTags, installedNow, fx);
|
|
36
|
-
}
|
|
37
|
-
} else if (entry.endsWith('.md') && entry !== 'README.md') {
|
|
38
|
-
const content = readFileSync(srcPath, 'utf-8');
|
|
39
|
-
if (!shouldInstallSkill(content, projectTags)) continue;
|
|
40
|
-
const skillName = entry.slice(0, -3);
|
|
41
|
-
const skillDir = join(destDir, skillName);
|
|
42
|
-
fx.ensureDir(skillDir);
|
|
43
|
-
fx.copyFile(srcPath, join(skillDir, 'SKILL.md'));
|
|
44
|
-
installedNow.add(skillName);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function collectSourceSkillNames() {
|
|
50
|
-
const names = new Set();
|
|
51
|
-
for (const level of SKILL_LEVELS_TO_INSTALL) {
|
|
52
|
-
const levelDir = join(FRAMEWORK_SKILLS_DIR, level);
|
|
53
|
-
if (!existsSync(levelDir)) continue;
|
|
54
|
-
collectNamesFromDir(levelDir, names);
|
|
55
|
-
}
|
|
56
|
-
return names;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function collectNamesFromDir(dir, names) {
|
|
60
|
-
for (const entry of readdirSync(dir)) {
|
|
61
|
-
const fullPath = join(dir, entry);
|
|
62
|
-
if (!statSync(fullPath).isDirectory()) continue;
|
|
63
|
-
if (existsSync(join(fullPath, 'SKILL.md'))) {
|
|
64
|
-
names.add(entry);
|
|
65
|
-
} else {
|
|
66
|
-
collectNamesFromDir(fullPath, names);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
13
|
+
function sourceSkillNames() {
|
|
14
|
+
return readdirSync(CORE_SKILLS_DIR, { withFileTypes: true })
|
|
15
|
+
.filter((e) => e.isDirectory() && existsSync(join(CORE_SKILLS_DIR, e.name, 'SKILL.md')))
|
|
16
|
+
.map((e) => e.name);
|
|
69
17
|
}
|
|
70
18
|
|
|
71
|
-
|
|
19
|
+
/** `previous`: the skills the manifest records. `prune: false` when the caller already emptied `.claude/skills/`. */
|
|
20
|
+
export async function installSkills(projectDir, { projectTags = [], fx = realEffects(), previous = [], prune = true } = {}) {
|
|
72
21
|
const claudeSkillsDir = join(projectDir, '.claude', 'skills');
|
|
73
22
|
fx.ensureDir(claudeSkillsDir);
|
|
74
23
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
24
|
+
const shipped = sourceSkillNames();
|
|
25
|
+
const names = [];
|
|
26
|
+
for (const name of shipped) {
|
|
27
|
+
const src = join(CORE_SKILLS_DIR, name);
|
|
28
|
+
if (!shouldInstallSkill(readFileSync(join(src, 'SKILL.md'), 'utf-8'), projectTags)) continue;
|
|
29
|
+
fx.copyDir(src, join(claudeSkillsDir, name), { filter: (from) => basename(from) !== 'README.md' });
|
|
30
|
+
names.push(name);
|
|
82
31
|
}
|
|
83
32
|
|
|
84
|
-
|
|
85
|
-
// Silent in dryRun: the real update's cleanFrameworkDirs() already emptied the dir.
|
|
86
|
-
if (!fx.dryRun) {
|
|
87
|
-
const allSourceSkills = collectSourceSkillNames();
|
|
88
|
-
for (const entry of readdirSync(claudeSkillsDir)) {
|
|
89
|
-
if (!installedNow.has(entry) && allSourceSkills.has(entry)) {
|
|
90
|
-
fx.remove(join(claudeSkillsDir, entry));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
33
|
+
if (prune) pruneOwned(claudeSkillsDir, { previous, shipped, installed: names, fx });
|
|
94
34
|
|
|
95
|
-
return { installed:
|
|
35
|
+
return { installed: names.length, names };
|
|
96
36
|
}
|
|
@@ -16,7 +16,7 @@ export function getInstalledCLIVersion() {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
async function getLatestNPMVersion(packageName = '@polymorphism-tech/morph-spec') {
|
|
20
20
|
try {
|
|
21
21
|
const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`);
|
|
22
22
|
if (!response.ok) return null;
|
|
@@ -97,36 +97,7 @@ export function majorJump(installedVersion, targetVersion, { limit = MAJOR_JUMP_
|
|
|
97
97
|
return { refuse: false, reason: null, jump };
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
export
|
|
101
|
-
if (process.env.npm_execpath && process.env.npm_execpath.includes('npx')) {
|
|
102
|
-
return 'npx';
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const isGlobal = process.env.npm_config_global === 'true' ||
|
|
106
|
-
process.execPath.includes('node_modules');
|
|
107
|
-
|
|
108
|
-
if (isGlobal) {
|
|
109
|
-
return 'global';
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return 'unknown';
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export function getUpdateInstructions(method) {
|
|
116
|
-
switch (method) {
|
|
117
|
-
case 'global':
|
|
118
|
-
return [
|
|
119
|
-
'npm install -g @polymorphism-tech/morph-spec@latest --prefer-online',
|
|
120
|
-
'morph-spec update'
|
|
121
|
-
];
|
|
122
|
-
case 'npx':
|
|
123
|
-
default:
|
|
124
|
-
return [
|
|
125
|
-
'npm install -g @polymorphism-tech/morph-spec@latest --prefer-online',
|
|
126
|
-
'morph-spec update'
|
|
127
|
-
];
|
|
128
|
-
}
|
|
129
|
-
}
|
|
100
|
+
export const CLI_UPDATE_COMMAND = 'npm install -g @polymorphism-tech/morph-spec@latest --prefer-online';
|
|
130
101
|
|
|
131
102
|
export async function checkCLIOutdated() {
|
|
132
103
|
const current = getInstalledCLIVersion();
|
package/CLAUDE.md
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code when working with code in **this repository** (the morph-spec CLI source).
|
|
4
|
-
|
|
5
|
-
## What This Is
|
|
6
|
-
|
|
7
|
-
morph-spec is a harness CLI (`@polymorphism-tech/morph-spec`) that makes Claude Code write code well: a plan with scenarios `C1..Cn`, a red proof per scenario, review personas in fresh context, and a `## Resultado` an orchestrator reads. The CLI installs the harness (contract, skills, rules, personas, hooks) and owns the deterministic steps (`plan-check`, `prove-red`, `check`); Claude Code runs the flow from `framework/MORPH.md` and the core skills. It never orchestrates: worktrees, the Claude call and the PR belong to whoever runs it.
|
|
8
|
-
|
|
9
|
-
This repo is the **framework source code** — not a project that uses morph-spec.
|
|
10
|
-
|
|
11
|
-
**Do not run the morph-spec workflow here.** No `init`, `plan-check`, `prove-red`, `check` or `context refresh`, and no `/morph-plan` or `/morph-apply` as a process, even if a prompt starts with one: confirm first. Work here is ordinary: a normal branch, `npm test`, `npm run generate:check`, a PR. `framework/skills/` and `framework/CLAUDE.md` are source to edit, not instructions to follow. `/.morph/` is gitignored: this repo keeps no morph-spec state.
|
|
12
|
-
|
|
13
|
-
## Build & Test Commands
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
# Dev loop: only the test files the current change can reach (vs the merge-base with main)
|
|
17
|
-
npm run test:changed # add -- --list to see the selection and why
|
|
18
|
-
|
|
19
|
-
# Run all tests (files in parallel, cpus-1 at a time; ~6 min on a 16-core Windows box, bound by process/git contention)
|
|
20
|
-
# Not a step before a PR or release: the PR runs test:changed and the tag runs the whole wall before publishing
|
|
21
|
-
npm test
|
|
22
|
-
|
|
23
|
-
# A subtree or file (still parallel); --test-concurrency=1 to debug serially
|
|
24
|
-
node scripts/run-tests.mjs test/commands/check.test.js
|
|
25
|
-
|
|
26
|
-
# Coverage
|
|
27
|
-
npm run test:coverage
|
|
28
|
-
|
|
29
|
-
# Generate JSDoc API docs
|
|
30
|
-
npm run docs
|
|
31
|
-
|
|
32
|
-
# Regenerate derived reference files from output-schema.js
|
|
33
|
-
npm run generate
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
No build step — pure ESM JavaScript, runs directly via Node.js 22+.
|
|
37
|
-
|
|
38
|
-
## Architecture
|
|
39
|
-
|
|
40
|
-
### Module Layout
|
|
41
|
-
|
|
42
|
-
- **`bin/morph-spec.js`** — Commander.js CLI entry point: install/inspect commands (`init`, `update`, `setup-infra`, `doctor`, `standards`, `graph`, `stack-*`) and the deterministic steps of the loop (`plan-check`, `prove-red`, `check`, `env`).
|
|
43
|
-
- **`src/commands/`** — CLI command handlers by domain (project/, validation/, graph/, scaffold/, mcp/, context/, standards/).
|
|
44
|
-
- **`src/core/`** — `paths/output-schema.js` (**single source of truth** for the feature files: `plan`, `checks`, `implementReport`, the review reports, the `1-design/` docs) and `templates/` (Handlebars registry and renderer).
|
|
45
|
-
- **`src/lib/`** — `contract/` (scan → defaults → merge → apply of `.morph/config/config.json`, and `ports.js` for the branch-hash ports), `check/` (signals and attempts), `plan/` (the one `plan.md` parser and `checks.json` builder), `review-reports.js` (the one reader of the persona reports), `diff/`, `graph/`, `stack/`, `installers/`, `generators/`, `ai/` (`doctor --ai`), `stack-filter.js`.
|
|
46
|
-
- **`src/utils/`** — installers (agents, skills, hooks, claude-settings), logger, file-copier, version-checker.
|
|
47
|
-
- **`framework/`** — what `init` installs into target projects (read-only at runtime):
|
|
48
|
-
- `MORPH.md` — the NLH charter (≤ 8k chars, `resident-size` canary); `CLAUDE.md` — injected into the target's `.claude/CLAUDE.md` (≤ 3k chars)
|
|
49
|
-
- `agents.json` — the 3 review personas; `.claude/agents/morph-*.md` are generated from it
|
|
50
|
-
- `skills/core/` — `morph-plan`, `morph-apply`, `morph-uiux` (+ the Umbraco ones), listed in MORPH.md
|
|
51
|
-
- `rules/` — path-scoped stack rules (`paths:` + `stacks:`), no always-on rule
|
|
52
|
-
- `hooks/claude-code/core/` — fail-open guardrails; `hooks/shared/` — what hooks and `src/` both read
|
|
53
|
-
- `standards/` + `STANDARDS.json`, `templates/` + `REGISTRY.json`, `mcp/registry.json`, `schemas/`, `evals/review-checklist.md`
|
|
54
|
-
- `docs/CLI.md` — the CLI reference, one `###` per command, installed as `.morph/framework/CLI.md`
|
|
55
|
-
|
|
56
|
-
### Key Architectural Patterns
|
|
57
|
-
|
|
58
|
-
**NLH (Natural Language Harness):** behavior lives in `framework/MORPH.md` and the skills. JS hooks are silent guardrails, never orchestrators.
|
|
59
|
-
|
|
60
|
-
**The contract:** `.morph/config/config.json` (`project.stack`/`tags`, `tests[]` with `tier`, `risk` globs, `limits`), shape in `framework/schemas/config.schema.json`. `init` writes it from a scan and is idempotent (`_generated` fingerprints keep hand edits). Every hook and validation command starts from `contractExists()`: no contract, no-op (hooks) or exit 2.
|
|
61
|
-
|
|
62
|
-
**The feature is the branch:** `.morph/features/<slugOfBranch>/` (`framework/hooks/shared/feature-slug.js`). No state file, no phases, no gates: `plan.md` freezes once `checks.json` exists, progress is `3-implement/report.md` (`pendente`/`feito`/`bloqueado` per `Cn`), and `check --report` writes `## Resultado` (`pronto` | `precisa-humano` with the signals).
|
|
63
|
-
|
|
64
|
-
**Fail-open hooks:** every hook returns `null` on any error or without a contract. Hooks never throw and never write project state.
|
|
65
|
-
|
|
66
|
-
**Stack-aware filtering:** assets declare `stacks:` in frontmatter (or `stack` in `agents.json`); `getProjectTags` unites `project.stack`, `project.tags` and `integrations`, and only matching assets install.
|
|
67
|
-
|
|
68
|
-
**Review:** `agents.json` has the 3 read-only roles — `verifier` (runs each `Cn`), `reviewer` (plan.md + diff), `security` (sensitive diffs) — dispatched once, in fresh context, by the session that implemented. Their reports in `4-review/` feed the `sem-revisao`/`revisao-fix`/`nao-provado` signals of `check --report`.
|
|
69
|
-
|
|
70
|
-
## Testing Conventions
|
|
71
|
-
|
|
72
|
-
- **Framework:** Node.js native `node:test` — no Jest or Mocha
|
|
73
|
-
- **Concurrency:** files run in parallel (`scripts/run-tests.mjs`) — `node --test` gives each file its own process, so `process.chdir()` stays inside the file. A test never writes a tracked file of this repo: a script under test reads its root from `MORPH_REPO_ROOT`, and the test points it at `copyTrackedRepo()` (`test/helpers/repo-copy.js`, a temp git repo with the tracked files). The runner fails if a run changes the tracked tree. Each file has a 10-minute `--test-timeout` (it bounds the whole file under process isolation): a hang fails by name. A test that imports a hook sets `MORPH_HOOK_CHAINED=1` first, or the hook's `runStandalone` waits on stdin, which `node --test` never closes
|
|
74
|
-
- **Subprocesses:** drive the CLI through `test/helpers/cli.js` (`runCli`, no shell) and git through `test/helpers/git.js` (`git(cwd, ...args)`) — `execSync('git …')` pays a cmd.exe per call on Windows. Hooks that export `run(payload)` can be called in-process (see `test/hooks/loop-detect.test.js`); keep one spawn per hook for the standalone wiring
|
|
75
|
-
- **Temp dirs:** `createTempDir()` / `cleanupTempDir()` from `test/helpers/test-utils.js`
|
|
76
|
-
- **Home:** a suite that runs `setupInfra`/`updateCommand`/`initCommand` calls `isolateHome()` (test-utils) at the top — the installers write `~/.claude/settings.json` through `os.homedir()`. Canary: `test/meta/home-isolation.test.js`
|
|
77
|
-
- **Mock state:** `createMockState(overrides)` and `createStateFile(tempDir, state)` from test-utils
|
|
78
|
-
|
|
79
|
-
## Code Conventions
|
|
80
|
-
|
|
81
|
-
- **ESM only** — `import`/`export`, package.json `"type": "module"`
|
|
82
|
-
- **Output type normalization** — `normalizeOutputType()` auto-converts kebab-case to camelCase
|
|
83
|
-
- **Template helpers** — Handlebars v2.0: pascalCase, camelCase, snakeCase, kebabCase, pluralize, plus comparison/logic helpers
|
|
84
|
-
- **CLI structure** — Commands are thin wrappers; business logic in `src/core/` or `src/lib/`
|
|
85
|
-
- **Comentários** — o padrão é nenhum: nome, tipo e teste explicam o código. Só o porquê que o código não mostra (invariante, ordem que importa, quirk externo com link), em até 3 linhas. Sem história de processo (issue, PR, feature, "medido na 8.x") no código: isso vai no commit e na memória. JSDoc só em export que outro módulo consome e cujo contrato o nome não diz. **Não imite a densidade dos arquivos existentes**: boa parte do código legado deste repo é mais comentada do que esta regra. O hook `comment-guard` roda aqui também (`.claude/settings.json`)
|
|
86
|
-
|
|
87
|
-
## Framework Development Guardrails
|
|
88
|
-
|
|
89
|
-
When modifying framework components, verify the full scope of related files.
|
|
90
|
-
|
|
91
|
-
### Dependency Matrix
|
|
92
|
-
|
|
93
|
-
A matriz "mexeu em X → verifique Y" mora em `.claude/rules/matrix-*.md`, uma rule por área com `paths:`: o Claude Code a carrega só quando a sessão toca um arquivo daquela área. Linha nova entra na rule da área do arquivo-chave (a coluna da esquerda); área nova é rule nova, com seus `paths:`.
|
|
94
|
-
|
|
95
|
-
| Rule | Área |
|
|
96
|
-
| --- | --- |
|
|
97
|
-
| `.claude/rules/matrix-agents.md` | Personas (`agents.json`) e o installer delas |
|
|
98
|
-
| `.claude/rules/matrix-standards.md` | Standards, registro e seções |
|
|
99
|
-
| `.claude/rules/matrix-hooks.md` | Hooks e comment-guard |
|
|
100
|
-
| `.claude/rules/matrix-charter.md` | Carta NLH, skills e docs instaláveis |
|
|
101
|
-
| `.claude/rules/matrix-templates-ai.md` | Templates, ai-kit e CI |
|
|
102
|
-
| `.claude/rules/matrix-plan-review.md` | Plano, progresso, feature pelo branch e relatórios de revisão |
|
|
103
|
-
| `.claude/rules/matrix-check.md` | `check`, sinais e portas pelo branch |
|
|
104
|
-
| `.claude/rules/matrix-graph.md` | Grafo de codebase |
|
|
105
|
-
| `.claude/rules/matrix-platform.md` | MCP, installers e contrato |
|
|
106
|
-
|
|
107
|
-
### Test Coverage
|
|
108
|
-
|
|
109
|
-
Every `src/**/*.js` file should have a corresponding `test/**/*.test.js`.
|
|
110
|
-
|
|
111
|
-
## Framework vs Runtime Distinction
|
|
112
|
-
|
|
113
|
-
- **This repo** = the CLI source (installer)
|
|
114
|
-
- **`framework/`** = files installed into target projects via `morph-spec init`
|
|
115
|
-
- **`framework/CLAUDE.md`** = injected into target's `.claude/CLAUDE.md` (not for this repo)
|
|
116
|
-
- **`framework/MORPH.md`** = the NLH charter — every behavioral change lands here, not in JS hooks
|
|
117
|
-
|
|
118
|
-
When editing `framework/` files, you're changing what gets installed in user projects, not runtime behavior of the CLI itself.
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Cria uma nova landing page ponta-a-ponta a partir do template MORPH Umbraco genérico: coleta decisões, scaffolda com new-lp, sobe e valida, customiza branding e módulos.
|
|
3
|
-
argument-hint: [nome-do-projeto]
|
|
4
|
-
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion, Skill
|
|
5
|
-
stacks:
|
|
6
|
-
- umbraco
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# /create-umbraco-lp — Nova LP Umbraco
|
|
10
|
-
|
|
11
|
-
Cria um projeto de landing page novo a partir do template canônico `MORPH_Umbraco_LP_Template`.
|
|
12
|
-
|
|
13
|
-
**Implementação:** este slash command é um atalho. O agente deve invocar `Skill(create-umbraco-lp)` com o nome do projeto (se fornecido). A skill coleta decisões do usuário uma pergunta por vez, scaffolda via `new-lp.ps1` / `new-lp.sh`, valida o boot (Delivery API + Ping de leads) e apresenta o checklist de entrega.
|
|
14
|
-
|
|
15
|
-
## Argumentos
|
|
16
|
-
|
|
17
|
-
`[nome-do-projeto]` — nome do projeto/LP (opcional; se não fornecido, a skill pergunta).
|
|
18
|
-
|
|
19
|
-
## Pré-requisitos
|
|
20
|
-
|
|
21
|
-
- `gh` autenticado (ou credencial git) com acesso ao repositório **privado** `polymorphism-tech/MORPH_Umbraco_LP_Template` (branch `master`).
|
|
22
|
-
- .NET 10 SDK instalado (`dotnet --version` deve retornar `10.x`).
|
|
23
|
-
- Node.js 20+ e npm instalados.
|
|
24
|
-
- PowerShell 7+ (Windows) ou bash (Linux/macOS) para os scripts.
|
|
25
|
-
|
|
26
|
-
## Anti-padrões
|
|
27
|
-
|
|
28
|
-
- Não editar `backend/uSync/v17/` manualmente durante o setup — deixar o uSync importar no primeiro boot.
|
|
29
|
-
- Não commitar `.env` ou `frontend/.env.local` — contêm credenciais e secrets.
|
|
30
|
-
- Não reutilizar `UMBRACO_GLOBAL_ID` de outro projeto — o script gera um UUID único por execução.
|
|
31
|
-
|
|
32
|
-
## Referências
|
|
33
|
-
|
|
34
|
-
- `.claude/skills/create-umbraco-lp/SKILL.md`
|
|
35
|
-
- `references/umbraco-lp-patterns.md` (dentro da skill `create-umbraco-lp`)
|
|
36
|
-
|
|
37
|
-
**Projeto:** $ARGUMENTS
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Migra uma LP existente (React/Vite, Next.js estático ou HTML) para o template Umbraco-headless MORPH entregando a LP EXATAMENTE igual à origem (mesmo CSS, imagens, fontes e comportamento) + Umbraco — obtenção automática do template, lift-and-rewire verbatim de cada seção para módulo editável, conexão do formulário ao backend de leads e gate de paridade determinístico. Repo-agnóstica.
|
|
3
|
-
argument-hint: <projeto>
|
|
4
|
-
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, Agent, AskUserQuestion, Skill
|
|
5
|
-
stacks:
|
|
6
|
-
- umbraco
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# /migrate-lp-to-umbraco — Migração de LP para Umbraco Headless
|
|
10
|
-
|
|
11
|
-
Migra a LP de origem para o template `MORPH_Umbraco_LP_Template` de forma reproduzível, entregando a LP **exatamente igual** à origem com o Umbraco por cima.
|
|
12
|
-
|
|
13
|
-
**Implementação:** este slash command é um atalho. O agente deve invocar `Skill(migrate-lp-to-umbraco)` com o nome do projeto como argumento. A skill é **repo-agnóstica** — obtém o template sozinha e funciona mesmo sem template ou origem pré-baixados.
|
|
14
|
-
|
|
15
|
-
## Argumentos
|
|
16
|
-
|
|
17
|
-
`{projeto}` — nome do projeto em kebab-case (ex.: `reserva-das-flores`, `lp-imobiliaria`).
|
|
18
|
-
|
|
19
|
-
## Fluxo resumido
|
|
20
|
-
|
|
21
|
-
0. **Obter o template** — clone/cache de `polymorphism-tech/MORPH_Umbraco_LP_Template` (privado, branch `master`) via `gh repo clone` (fallback git HTTPS/SSH). Sempre garantido antes de qualquer passo.
|
|
22
|
-
1. **Analisar a origem (capturar para um lift)** — inventariar seções, markup/classes exatos, CSS/tema verbatim, assets byte-a-byte (com `sha256`), fontes e comportamentos. Origem por código-fonte local ou só URL (scrape). Produzir `docs/origem-inventario.md`.
|
|
23
|
-
2. **Mapear para módulos** — cada seção vira um módulo via **lift verbatim** (default) — reuso direto do template só quando o render já bate com a origem. Produzir `docs/mapeamento-modulos.md`.
|
|
24
|
-
3. **Scaffold via new-lp** — cópia fresca do template para o diretório do projeto, `git init`, `scripts/new-lp.sh`/`.ps1` com `--lead-integration`, smoke-boot com `docker compose up --build`.
|
|
25
|
-
4. **Lift verbatim** — copiar markup/CSS/classes/assets de cada seção verbatim para o componente do módulo, trocando só os literais por leitura do backoffice; uSync `.config`, `SeedContentHandler` idempotente, `globals.css` com o tema portado, registro em `moduleRegistry.ts`.
|
|
26
|
-
5. **Conectar formulário** — selecionar sink (`ghl`/`prospectpro`/`webhook`) no backoffice via nó `leadsConfig`; nunca colocar token em código ou env.
|
|
27
|
-
6. **Gate de paridade** — checks determinísticos (DOM+classes, estilo computado, checksum de assets, comportamento) como bloqueio + screenshot diff como corroboração secundária. A skill scaffolda `parity.spec.ts` e `compare-sections.mjs`.
|
|
28
|
-
|
|
29
|
-
## Referências
|
|
30
|
-
|
|
31
|
-
- `.claude/skills/migrate-lp-to-umbraco/SKILL.md` — playbook completo (passos 0-6, gate de paridade)
|
|
32
|
-
- `polymorphism-tech/MORPH_Umbraco_LP_Template` — template canônico (privado, branch `master`), obtido no passo 0
|
|
33
|
-
- `MORPH_Umbraco_LP_Template/scripts/new-lp.sh` / `new-lp.ps1` — scaffold
|
|
34
|
-
|
|
35
|
-
**Projeto:** $ARGUMENTS
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Implementa o plano validado inteiro nesta sessão, prova com o check, roda a revisão em contexto novo e grava o resultado.
|
|
3
|
-
argument-hint: [feature]
|
|
4
|
-
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, Agent, AskUserQuestion, Skill
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# /morph-apply
|
|
8
|
-
|
|
9
|
-
Atalho: invoque `Skill(morph-apply)`. A feature é a pasta do branch atual (ou o argumento).
|
|
10
|
-
|
|
11
|
-
Pré-requisito: `.morph/features/{feature}/2-plan/plan.md` e `2-plan/checks.json` (gravado por
|
|
12
|
-
`morph-spec plan-check`). Faltando, rode `/morph-plan`.
|
|
13
|
-
|
|
14
|
-
**Feature:** $ARGUMENTS
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
|
|
4
|
-
const NEEDS_CMD_SHIM = /^(npm|npx|pnpm|yarn)$/;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* On win32 `npx`/`npm`/… are `.cmd` shims: ENOENT without a shell, EINVAL as `.cmd`
|
|
8
|
-
* with `shell: false`. Playwright runs from its own JS entry, so it needs no shell.
|
|
9
|
-
*/
|
|
10
|
-
export function resolveSpawn(file, args = [], {
|
|
11
|
-
cwd = process.cwd(),
|
|
12
|
-
platform = process.platform,
|
|
13
|
-
exists = existsSync,
|
|
14
|
-
execPath = process.execPath,
|
|
15
|
-
} = {}) {
|
|
16
|
-
if (platform !== 'win32' || !NEEDS_CMD_SHIM.test(file)) return { file, args, shell: false };
|
|
17
|
-
|
|
18
|
-
if (file === 'npx' && args[0] === 'playwright') {
|
|
19
|
-
const cli = join(cwd, 'node_modules', '@playwright', 'test', 'cli.js');
|
|
20
|
-
if (exists(cli)) return { file: execPath, args: [cli, ...args.slice(1)], shell: false };
|
|
21
|
-
}
|
|
22
|
-
return { file: `${file}.cmd`, args, shell: true };
|
|
23
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# Guia de uso — CLAUDE.md.core.template
|
|
2
|
-
|
|
3
|
-
Este template é o ponto de entrada do harness para um projeto morph-spec.
|
|
4
|
-
Preencha cada campo uma vez, no setup. Não modifique a estrutura.
|
|
5
|
-
|
|
6
|
-
## Campos
|
|
7
|
-
|
|
8
|
-
**Nome do Projeto** — nome curto e identificável do sistema.
|
|
9
|
-
|
|
10
|
-
**Domínio** — 1-2 frases. O que o sistema faz, para quem, e qual o principal constraint (ex: multi-tenant, LGPD, tempo real).
|
|
11
|
-
|
|
12
|
-
**Stack** — não alterar. O harness assume o stack padrão. Se o projeto desvia (ex: Blazor em vez de Next.js), edite e documente o desvio aqui.
|
|
13
|
-
|
|
14
|
-
**Harness** — não alterar. Esta seção instrui o modelo a:
|
|
15
|
-
1. Ler `MORPH.md` ao iniciar a sessão
|
|
16
|
-
2. Tomar a feature pela pasta do branch atual (`.morph/features/<slug-do-branch>/`)
|
|
17
|
-
3. Assumir o papel correspondente sem aguardar instrução
|
|
18
|
-
|
|
19
|
-
**Standards do projeto** — opcional. Apenas se algum standard específico do projeto desvia do default do stack. Default já injetado pelo morph-plan.
|
|
20
|
-
|
|
21
|
-
**Slash commands** — não alterar. Os dois entry points oficiais.
|
|
22
|
-
|
|
23
|
-
## Regras
|
|
24
|
-
|
|
25
|
-
- Mantenha < 60 linhas — conteúdo acima não cabe em contexto comprimido.
|
|
26
|
-
- Não adicione regras condicionais (sem "se dotnet, então...").
|
|
27
|
-
- Não inline conteúdo de standards — aponte por ID, nunca copie.
|
|
28
|
-
- Não adicione campo "Feature ativa" estático — a feature é a do branch.
|
|
29
|
-
- Este arquivo pertence ao projeto. Versione no git.
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# [Nome do Projeto]
|
|
2
|
-
|
|
3
|
-
[1-2 frases sobre o domínio do sistema, quem usa, qual o principal constraint.]
|
|
4
|
-
|
|
5
|
-
## Stack
|
|
6
|
-
|
|
7
|
-
VSA + .NET 10 + EF Core + Neon (Postgres) + Microsoft Agent Framework + Next.js (App Router) + Tailwind + Framer Motion + Shadcn + Hangfire (quando necessário).
|
|
8
|
-
|
|
9
|
-
Padrões proibidos por padrão: `Guid.NewGuid()` (use `Guid.CreateVersion7()`), classes não-sealed sem justificativa, exceptions como fluxo de controle, camada de Service/Manager entre handler e dados, repository genérico (`IRepository<T>`/`IUnitOfWork`), SQL cru sem justificativa. Acesso a dados: `ApplicationDbContext` direto no slice (`DbSet<T>` já é repository, `DbContext` já é unit of work); para concorrência ou SQL específico, store dedicado hand-written com justificativa em `plan.md` (`## Decisões`).
|
|
10
|
-
|
|
11
|
-
## Harness
|
|
12
|
-
|
|
13
|
-
morph-spec NLH — leia `.morph/framework/MORPH.md` ao iniciar cada sessão. Em seguida, leia `.morph/state.json` para identificar a feature ativa e a fase atual; assuma o papel correspondente (Orchestrator/Specialist/Evaluator) e continue o trabalho.
|
|
14
|
-
|
|
15
|
-
## Standards do projeto
|
|
16
|
-
|
|
17
|
-
[Liste de 3 a 6 IDs de `.morph/framework/standards/STANDARDS.json` específicos deste projeto, se algum desviar do default. Caso contrário, deixe vazio — os defaults do stack já são aplicados pelo morph-plan.]
|
|
18
|
-
|
|
19
|
-
## Slash commands
|
|
20
|
-
|
|
21
|
-
- `/morph-plan {feature}` — entrevista, `plan.md`, `plan-check` e gate do plano
|
|
22
|
-
- `/morph-apply {feature}` — fatias do plano, `verify` e review (Gate 3)
|