@polymorphism-tech/morph-spec 10.12.0 → 11.0.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/CLAUDE.md +27 -57
- package/README.md +51 -340
- package/bin/morph-spec.js +22 -373
- package/docs/CHEATSHEET.md +37 -166
- package/docs/QUICKSTART.md +14 -74
- package/framework/CLAUDE.md +15 -26
- package/framework/MORPH.md +34 -101
- package/framework/agents.json +8 -8
- package/framework/commands/morph-apply.md +5 -5
- package/framework/commands/morph-infra.md +1 -1
- package/framework/docs/CLI.md +74 -886
- package/framework/evals/review-checklist.md +14 -14
- package/framework/hooks/README.md +21 -189
- package/framework/hooks/claude-code/core/README.md +2 -5
- package/framework/hooks/claude-code/core/conventional-commit.js +2 -2
- package/framework/hooks/claude-code/core/denylist.json +3 -3
- package/framework/hooks/claude-code/core/graph-refresh-kick.js +2 -2
- package/framework/hooks/claude-code/core/masked-exit.js +6 -6
- package/framework/hooks/claude-code/core/pre-bash-denylist.js +2 -2
- package/framework/hooks/claude-code/core/protect-spec-files.js +17 -61
- package/framework/hooks/claude-code/core/stack-changed.js +35 -0
- package/framework/hooks/claude-code/core/validate-completion.js +31 -86
- package/framework/hooks/shared/{heavy-command.js → command-kind.js} +6 -79
- package/framework/hooks/shared/command-tokens.js +0 -139
- package/framework/hooks/shared/contract.js +14 -0
- package/framework/hooks/shared/feature-slug.js +21 -0
- package/framework/hooks/shared/frontend-locations.js +0 -1
- package/framework/hooks/shared/git-paths.js +0 -15
- package/framework/hooks/shared/graph-freshness.js +0 -19
- package/framework/hooks/shared/hook-response.js +0 -7
- package/framework/hooks/shared/morph-cli.js +2 -81
- package/framework/hooks/shared/owner-words.js +2 -120
- package/framework/hooks/shared/payload-utils.js +0 -39
- package/framework/hooks/shared/report-progress.js +7 -101
- package/framework/hooks/statusline.js +16 -60
- package/framework/mcp/registry.json +2 -2
- package/framework/rules/ai-agents-standards.md +1 -1
- package/framework/rules/asaas-standards.md +1 -1
- package/framework/rules/ef-standards.md +1 -1
- package/framework/rules/gsap-standards.md +1 -1
- package/framework/rules/hangfire-standards.md +1 -1
- package/framework/rules/implement-report.md +3 -3
- package/framework/rules/neon-auth-standards.md +1 -1
- package/framework/rules/nextjs-standards.md +1 -1
- package/framework/rules/plan-grammar.md +13 -11
- package/framework/rules/resend-standards.md +1 -1
- package/framework/rules/ui-design.md +4 -0
- package/framework/schemas/config.schema.json +95 -310
- package/framework/skills/README.md +12 -32
- 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 +21 -46
- package/framework/skills/core/morph-plan/SKILL.md +28 -63
- package/framework/skills/core/morph-uiux/SKILL.md +23 -25
- package/framework/{templates/docs/ui-mockups.md → skills/core/morph-uiux/references/mockups.md} +4 -4
- package/framework/standards/STANDARDS.json +10 -11
- package/framework/standards/STANDARDS.meta.json +1 -1
- package/framework/standards/ai-agents/evals-with-cache.md +18 -32
- package/framework/standards/ai-agents/observability-patterns.md +2 -2
- package/framework/standards/architecture/code-comments.md +2 -5
- package/framework/standards/architecture/engineering-lens.md +1 -1
- package/framework/standards/backend/dotnet/testing.md +4 -4
- package/framework/standards/frontend/nextjs/lint.md +24 -10
- package/framework/standards/frontend/nextjs/testing.md +2 -2
- package/framework/standards/infrastructure/docker/local-compose-isolation.md +14 -30
- package/framework/templates/CLAUDE.md.core.guide.md +2 -2
- package/framework/templates/README.md +1 -1
- package/framework/templates/REGISTRY.json +3 -33
- package/framework/templates/docs/plan.md +3 -2
- package/framework/templates/dotnet/ai-kit/README.md +2 -4
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheMissException.cs +1 -1
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalFixture.cs +1 -1
- package/package.json +1 -2
- package/src/commands/graph/explain.js +2 -1
- package/src/commands/graph/status.js +2 -1
- package/src/commands/mcp/mcp-setup.js +1 -2
- package/src/commands/project/doctor.js +5 -341
- package/src/commands/project/env.js +21 -52
- package/src/commands/project/init-contract.js +47 -0
- package/src/commands/project/init.js +36 -66
- package/src/commands/project/stack-scan.js +1 -1
- package/src/commands/project/update.js +15 -50
- package/src/commands/validation/check.js +128 -0
- package/src/commands/validation/plan-check.js +41 -64
- package/src/commands/validation/prove-red.js +1 -1
- package/src/core/paths/output-schema.js +0 -22
- package/src/core/templates/template-renderer.js +0 -14
- package/src/lib/ai/ai-project-scan.js +1 -6
- package/src/lib/check/attempts.js +38 -0
- package/src/lib/check/signals.js +145 -0
- package/src/lib/config/project-config.js +13 -0
- package/src/lib/contract/apply.js +62 -0
- package/src/lib/contract/defaults.js +96 -0
- package/src/lib/contract/merge.js +79 -0
- package/src/lib/contract/ports.js +43 -0
- package/src/lib/contract/scan.js +102 -0
- package/src/lib/detectors/claude-config-detector.js +7 -0
- package/src/lib/{procs → detectors}/mcp-config.js +1 -37
- package/src/lib/diff/diff-lines.js +64 -0
- package/src/lib/generators/architecture-scanner.js +1 -1
- package/src/lib/generators/scaffold-generator.js +0 -7
- package/src/lib/git/default-branch.js +0 -122
- package/src/lib/graph/diff-tree.js +2 -1
- package/src/lib/graph/god-nodes.js +2 -1
- package/src/lib/graph/graphify-runtime.js +0 -1
- package/src/lib/graph/graphifyignore.js +1 -1
- package/src/lib/graph/sanitize.js +2 -8
- package/src/lib/installers/memory-installer.js +15 -30
- package/src/lib/installers/stack-sync.js +16 -9
- package/src/lib/plan/checks.js +20 -64
- package/src/lib/plan/media.js +1 -1
- package/src/lib/plan/plan-parser.js +5 -5
- package/src/lib/review-reports.js +3 -77
- package/src/lib/scan/worktree-dirs.js +3 -0
- package/src/lib/specs/adr-index.js +2 -2
- package/src/lib/stack/dotnet-build-ignores.js +10 -2
- package/src/lib/stack/stack-scan.js +2 -2
- package/src/lib/stack-filter.js +3 -2
- package/src/lib/tests-audit/audit.js +1 -1
- package/src/scripts/setup-infra.js +6 -59
- package/src/utils/agents-installer.js +1 -34
- package/src/utils/atomic-json.js +27 -0
- package/src/utils/file-copier.js +4 -12
- package/src/utils/hooks-installer.js +9 -107
- package/claude-plugin.json +0 -14
- package/framework/commands/morph-archive.md +0 -46
- package/framework/commands/morph-hotfix.md +0 -17
- package/framework/commands/morph-preflight.md +0 -180
- package/framework/commands/morph-review.md +0 -15
- package/framework/commands/morph-status.md +0 -37
- package/framework/hooks/claude-code/core/block-destructive-worktree-removal.js +0 -80
- package/framework/hooks/claude-code/core/block-raw-worktree-add.js +0 -72
- package/framework/hooks/claude-code/core/enforce-phase-writes.js +0 -100
- package/framework/hooks/claude-code/core/gate-guard.js +0 -148
- package/framework/hooks/claude-code/core/heavy-gate.js +0 -78
- package/framework/hooks/claude-code/core/heavy-release.js +0 -23
- package/framework/hooks/claude-code/core/loop-detect.js +0 -79
- package/framework/hooks/claude-code/core/state-sync.js +0 -214
- package/framework/hooks/claude-code/core/telemetry-log.js +0 -259
- package/framework/hooks/claude-code/core/test-budget.js +0 -29
- package/framework/hooks/claude-code/core/worktree-context.js +0 -249
- package/framework/hooks/claude-code/core/worktree-create.js +0 -119
- package/framework/hooks/claude-code/core/worktree-env-inject.js +0 -68
- package/framework/hooks/claude-code/core/worktree-remove.js +0 -55
- package/framework/hooks/shared/build-check.js +0 -120
- package/framework/hooks/shared/claim-registry.js +0 -125
- package/framework/hooks/shared/e2e-check.js +0 -1022
- package/framework/hooks/shared/feature-locator.js +0 -82
- package/framework/hooks/shared/gate-event.js +0 -18
- package/framework/hooks/shared/gate-question.js +0 -20
- package/framework/hooks/shared/heavy-config.js +0 -113
- package/framework/hooks/shared/heavy-holders.js +0 -85
- package/framework/hooks/shared/heavy-slots.js +0 -280
- package/framework/hooks/shared/host-services.js +0 -440
- package/framework/hooks/shared/next-step.js +0 -181
- package/framework/hooks/shared/redact-secrets.js +0 -44
- package/framework/hooks/shared/reparse-scan.js +0 -40
- package/framework/hooks/shared/state-reader.js +0 -220
- package/framework/hooks/shared/state-writer.js +0 -112
- package/framework/hooks/shared/telemetry-logger.js +0 -101
- package/framework/hooks/shared/transcript-usage.js +0 -58
- package/framework/hooks/shared/worktree-root.js +0 -71
- package/framework/phases.json +0 -92
- package/framework/schemas/feature.schema.json +0 -242
- package/framework/skills/core/morph-apply/references/hotfix.md +0 -46
- package/framework/skills/core/morph-apply/references/machine.md +0 -30
- package/framework/skills/core/morph-apply/references/review.md +0 -77
- package/framework/skills/core/morph-plan/references/critique.md +0 -51
- package/framework/skills/core/morph-plan/references/interview.md +0 -37
- package/framework/templates/state.template.json +0 -17
- package/src/commands/dashboard/dashboard.js +0 -74
- package/src/commands/e2e/e2e.js +0 -400
- package/src/commands/observability/cost.js +0 -283
- package/src/commands/project/branch.js +0 -129
- package/src/commands/project/claim.js +0 -132
- package/src/commands/project/doctor-procs.js +0 -162
- package/src/commands/project/fleet.js +0 -66
- package/src/commands/project/heavy.js +0 -81
- package/src/commands/project/install-plugin-cmd.js +0 -27
- package/src/commands/project/status.js +0 -61
- package/src/commands/project/worktree.js +0 -1234
- package/src/commands/state/advance.js +0 -248
- package/src/commands/state/approve.js +0 -303
- package/src/commands/state/archive.js +0 -231
- package/src/commands/state/auto-approval.js +0 -67
- package/src/commands/state/create.js +0 -274
- package/src/commands/state/delete.js +0 -192
- package/src/commands/state/finish.js +0 -1247
- package/src/commands/state/gate-check.js +0 -244
- package/src/commands/state/gate-decision.js +0 -122
- package/src/commands/state/list.js +0 -244
- package/src/commands/state/next.js +0 -24
- package/src/commands/state/recap.js +0 -80
- package/src/commands/state/report-check.js +0 -244
- package/src/commands/state/retype.js +0 -110
- package/src/commands/validation/verify.js +0 -421
- package/src/core/state/feature-identity.js +0 -10
- package/src/core/state/gate-order.js +0 -23
- package/src/core/state/lifecycle-audit.js +0 -171
- package/src/core/state/state-manager.js +0 -523
- package/src/core/templates/template-seed.js +0 -21
- package/src/core/work-types.js +0 -44
- package/src/dashboard/app/App.jsx +0 -84
- package/src/dashboard/app/components/ActivityFeed.jsx +0 -166
- package/src/dashboard/app/components/CommandPalette.jsx +0 -144
- package/src/dashboard/app/components/DetailPanel.jsx +0 -43
- package/src/dashboard/app/components/EntityLink.jsx +0 -42
- package/src/dashboard/app/components/ErrorBoundary.jsx +0 -47
- package/src/dashboard/app/components/FlowGraph.jsx +0 -19
- package/src/dashboard/app/components/GatePauses.jsx +0 -116
- package/src/dashboard/app/components/KnowledgeMarkdown.jsx +0 -42
- package/src/dashboard/app/components/Markdown.jsx +0 -38
- package/src/dashboard/app/components/PhaseRail.jsx +0 -100
- package/src/dashboard/app/components/SearchFilter.jsx +0 -36
- package/src/dashboard/app/components/SessionMap.jsx +0 -77
- package/src/dashboard/app/components/Sidebar.jsx +0 -147
- package/src/dashboard/app/hooks/useMorphQuery.js +0 -44
- package/src/dashboard/app/hooks/usePref.js +0 -34
- package/src/dashboard/app/lib/format.js +0 -69
- package/src/dashboard/app/lib/phases.js +0 -75
- package/src/dashboard/app/lib/project.js +0 -38
- package/src/dashboard/app/main.jsx +0 -13
- package/src/dashboard/app/pages/Activity.jsx +0 -28
- package/src/dashboard/app/pages/AgentMap.jsx +0 -363
- package/src/dashboard/app/pages/FeatureDetail.jsx +0 -579
- package/src/dashboard/app/pages/Features.jsx +0 -393
- package/src/dashboard/app/pages/Guide.jsx +0 -145
- package/src/dashboard/app/pages/HookInspector.jsx +0 -444
- package/src/dashboard/app/pages/PhasePipeline.jsx +0 -273
- package/src/dashboard/app/pages/Portfolio.jsx +0 -190
- package/src/dashboard/app/pages/RulesMap.jsx +0 -285
- package/src/dashboard/app/pages/SkillsLibrary.jsx +0 -468
- package/src/dashboard/app/pages/Standards.jsx +0 -392
- package/src/dashboard/app/styles/index.css +0 -187
- package/src/dashboard/index.html +0 -14
- package/src/dashboard/package.json +0 -32
- package/src/dashboard/scanner/activity-scanner.js +0 -321
- package/src/dashboard/scanner/agents-scanner.js +0 -67
- package/src/dashboard/scanner/docs-scanner.js +0 -34
- package/src/dashboard/scanner/feature-status.js +0 -7
- package/src/dashboard/scanner/features-scanner.js +0 -397
- package/src/dashboard/scanner/hooks-scanner.js +0 -96
- package/src/dashboard/scanner/index.js +0 -21
- package/src/dashboard/scanner/phases-scanner.js +0 -14
- package/src/dashboard/scanner/portfolio.js +0 -129
- package/src/dashboard/scanner/project-api.js +0 -160
- package/src/dashboard/scanner/rules-scanner.js +0 -46
- package/src/dashboard/scanner/skills-scanner.js +0 -104
- package/src/dashboard/scanner/standards-scanner.js +0 -38
- package/src/dashboard/vite-plugin-morph-data.js +0 -120
- package/src/dashboard/vite.config.js +0 -26
- package/src/lib/ci/ci-verify.js +0 -30
- package/src/lib/ci/github-ci.js +0 -52
- package/src/lib/ci/pr-checks.js +0 -76
- package/src/lib/e2e/applicability.js +0 -39
- package/src/lib/e2e/compose-env.js +0 -80
- package/src/lib/e2e/stack-teardown.js +0 -96
- package/src/lib/git/branch-classifier.js +0 -104
- package/src/lib/git/evidence-staleness.js +0 -40
- package/src/lib/git/gh.js +0 -15
- package/src/lib/git/pending-prs.js +0 -58
- package/src/lib/git/pr-files.js +0 -31
- package/src/lib/git/pr-index.js +0 -39
- package/src/lib/git/tree-fingerprint.js +0 -58
- package/src/lib/git/tree-state.js +0 -125
- package/src/lib/heavy/cleanup.js +0 -72
- package/src/lib/heavy/gate.js +0 -168
- package/src/lib/heavy/live-stacks.js +0 -64
- package/src/lib/heavy/reclaim.js +0 -107
- package/src/lib/heavy/watchdog.js +0 -46
- package/src/lib/next-step.js +0 -12
- package/src/lib/plan/critique.js +0 -67
- package/src/lib/plan/plan-template.js +0 -18
- package/src/lib/procs/classify.js +0 -91
- package/src/lib/procs/list.js +0 -124
- package/src/lib/procs/prune.js +0 -47
- package/src/lib/procs/wslconfig.js +0 -70
- package/src/lib/projects/registry.js +0 -121
- package/src/lib/recap/piper.js +0 -36
- package/src/lib/recap/recap.js +0 -259
- package/src/lib/review-confirmation.js +0 -66
- package/src/lib/risk/diff-risk.js +0 -137
- package/src/lib/risk-detector.js +0 -638
- package/src/lib/specs/design-seed.js +0 -18
- package/src/lib/specs/screen-checklist.js +0 -315
- package/src/lib/stack/stack-profile.js +0 -69
- package/src/lib/tasks/eval-node.js +0 -293
- package/src/lib/tasks/linux-runner.js +0 -200
- package/src/lib/tasks/test-nodes.js +0 -414
- package/src/lib/tasks/test-runner.js +0 -569
- package/src/lib/telemetry/metrics.js +0 -384
- package/src/lib/telemetry/telemetry-reader.js +0 -276
- package/src/lib/telemetry/verify-event.js +0 -57
- package/src/lib/validators/code-budget/code-budget-validator.js +0 -170
- package/src/lib/validators/contracts/contract-compliance-validator.js +0 -219
- package/src/lib/validators/nextjs/next-component-validator.js +0 -142
- package/src/lib/validators/packages/package-validator.js +0 -310
- package/src/lib/validators/reuse/reuse-validator.js +0 -202
- package/src/lib/validators/reuse/symbol-scanner.js +0 -64
- package/src/lib/validators/validation-runner.js +0 -188
- package/src/lib/validators/verify-cache.js +0 -63
- package/src/lib/validators/verify-runner.js +0 -971
- package/src/lib/verify/affected.js +0 -143
- package/src/lib/verify/detached.js +0 -159
- package/src/lib/view/feature-html.js +0 -480
- package/src/lib/view/feature-page.client.js +0 -109
- package/src/lib/view/feature-page.css +0 -278
- package/src/lib/view/feature-view.js +0 -113
- package/src/lib/view/flow-layers.js +0 -79
- package/src/lib/view/flow-svg.js +0 -63
- package/src/lib/view/tokens.css +0 -18
- package/src/lib/work-type-detector.js +0 -81
- package/src/lib/worktree/dirs.js +0 -3
- package/src/lib/worktree/docker-audit.js +0 -175
- package/src/lib/worktree/env-allocator.js +0 -177
- package/src/lib/worktree/feature-truth.js +0 -145
- package/src/lib/worktree/finish-backup.js +0 -529
- package/src/lib/worktree/fleet-scanner.js +0 -223
- package/src/lib/worktree/ignored-triage.js +0 -136
- package/src/lib/worktree/vscode-settings.js +0 -112
- package/src/lib/worktree/worktree-audit.js +0 -323
- package/src/lib/worktree/worktree-include.js +0 -44
- package/src/scripts/install-plugin.js +0 -114
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, readdirSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import { homedir } from 'os';
|
|
4
|
+
import { readMcpConfig } from './mcp-config.js';
|
|
4
5
|
|
|
5
6
|
// User settings first, then the project's: a later file overrides, and `false` turns a plugin off.
|
|
6
7
|
export function readEnabledPlugins(targetPath, home = homedir()) {
|
|
@@ -82,6 +83,12 @@ export function detectClaudeConfig(targetPath) {
|
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
// User and local scopes live in ~/.claude.json: missing them rewrites a server the user already has into .mcp.json.
|
|
87
|
+
for (const s of readMcpConfig({ projectDir: targetPath }).servers) {
|
|
88
|
+
if (s.scope === 'project' || result.mcpServers.some(m => m.name === s.name)) continue;
|
|
89
|
+
result.mcpServers.push({ name: s.name, config: { command: s.command, args: s.args, url: s.url }, source: s.scope });
|
|
90
|
+
}
|
|
91
|
+
|
|
85
92
|
const pluginsPath = join(homedir(), '.claude', 'plugins', 'installed_plugins.json');
|
|
86
93
|
if (existsSync(pluginsPath)) {
|
|
87
94
|
try {
|
|
@@ -2,14 +2,7 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
2
2
|
import { join, resolve } from 'node:path';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { jsoncToJson } from '../../../framework/hooks/shared/comment-stripper.js';
|
|
5
|
-
import { readEnabledPlugins } from '
|
|
6
|
-
|
|
7
|
-
const GENERIC_TOKENS = new Set([
|
|
8
|
-
'cmd', 'cmd.exe', 'npx', 'npx.cmd', 'npm', 'node', 'node.exe', 'python', 'python3', 'uv', 'uvx',
|
|
9
|
-
'dotnet', 'docker', 'run', 'exec', 'bash', 'sh', 'powershell', 'pwsh',
|
|
10
|
-
]);
|
|
11
|
-
|
|
12
|
-
const toolNamePart = (s) => String(s).replace(/[^A-Za-z0-9_-]/g, '_');
|
|
5
|
+
import { readEnabledPlugins } from './claude-config-detector.js';
|
|
13
6
|
|
|
14
7
|
function readJsonc(file, unreadable) {
|
|
15
8
|
if (!existsSync(file)) return null;
|
|
@@ -72,32 +65,3 @@ export function readMcpConfig({ projectDir, home = homedir() }) {
|
|
|
72
65
|
|
|
73
66
|
return { servers, pluginServers, enabledPlugins, unreadable };
|
|
74
67
|
}
|
|
75
|
-
|
|
76
|
-
export function findDuplicateMcps({ servers, pluginServers }) {
|
|
77
|
-
const duplicates = [];
|
|
78
|
-
for (const ps of pluginServers) {
|
|
79
|
-
const declared = servers.filter((s) => s.name === ps.name);
|
|
80
|
-
if (!declared.length) continue;
|
|
81
|
-
duplicates.push({
|
|
82
|
-
server: ps.name,
|
|
83
|
-
plugin: ps.plugin,
|
|
84
|
-
declaredIn: [...new Set(declared.map((s) => s.scope))],
|
|
85
|
-
toolNames: [`mcp__${ps.name}`, `mcp__plugin_${toolNamePart(ps.plugin)}_${toolNamePart(ps.name)}`],
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
return duplicates;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function mcpCommandTokens({ servers, pluginServers }) {
|
|
92
|
-
const tokens = new Set();
|
|
93
|
-
for (const s of [...servers, ...pluginServers]) {
|
|
94
|
-
if (s.url && !s.command) continue;
|
|
95
|
-
for (const raw of [s.command, ...s.args]) {
|
|
96
|
-
if (typeof raw !== 'string') continue;
|
|
97
|
-
const token = raw.toLowerCase().replace(/\\/g, '/');
|
|
98
|
-
if (token.length < 4 || /^[-/]/.test(token) || token.includes('${') || GENERIC_TOKENS.has(token)) continue;
|
|
99
|
-
tokens.add(token);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return [...tokens];
|
|
103
|
-
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { execFileSync } from 'child_process';
|
|
2
|
+
import { minimatch } from 'minimatch';
|
|
3
|
+
|
|
4
|
+
// O predicado único de teste do grafo e do validador de reuso. Só três formas de pasta, porque
|
|
5
|
+
// `[^/]*[Tt]ests?/` genérico também casaria `latest/` e `contests/`.
|
|
6
|
+
const TEST_PATH = /(^|\/)__tests__\/|\.(test|spec)\.[jt]sx?$|(^|\/)(?:[Tt]ests?|[^/]*\.[Tt]ests?|[^/]*[a-z0-9_]Tests?)\//;
|
|
7
|
+
|
|
8
|
+
export function isTestPath(sourceFile) {
|
|
9
|
+
return TEST_PATH.test(String(sourceFile || '').replace(/\\/g, '/'));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const DOC_PATH = /(^|\/)docs\/|\.(md|mdx|txt|rst|adoc|png|jpe?g|gif|svg|webp|ico)$/i;
|
|
13
|
+
const CONFIG_PATH = /\.(json|jsonc|ya?ml|toml|ini|xml|editorconfig|env\.example)$|(^|\/)\.(gitignore|gitattributes|npmrc|nvmrc|prettierrc|eslintignore)$|(^|\/)\.env(\.[^/]+)?$/i;
|
|
14
|
+
// Resolves or compiles everything: a change here reaches code the diff does not name.
|
|
15
|
+
export const WIDE_PATH = /(^|\/)(package(-lock)?\.json|pnpm-lock\.yaml|yarn\.lock|global\.json|Directory\.(Build|Packages)\.(props|targets)|tsconfig[^/]*\.json|[^/]+\.(csproj|sln|slnx|props|targets))$/i;
|
|
16
|
+
|
|
17
|
+
export function git(cwd, args) {
|
|
18
|
+
return execFileSync('git', args, { cwd, stdio: 'pipe', maxBuffer: 256 * 1024 * 1024 }).toString();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// An agent reads these as instructions: a changed sentence is changed behaviour, whatever the extension.
|
|
22
|
+
const PROMPT_PATH = /(^|\/)(prompts?|agents?|skills?|playbooks?|personas?|instructions?|\.claude)\/|(^|\/)(CLAUDE|AGENTS|GEMINI|MORPH|SKILL|copilot-instructions)\.md$|prompt[^/]*$/i;
|
|
23
|
+
|
|
24
|
+
export function isPromptPath(path, promptGlobs = []) {
|
|
25
|
+
return PROMPT_PATH.test(path) || promptGlobs.some((g) => minimatch(path, g));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function fileClass(path, promptGlobs = []) {
|
|
29
|
+
if (path.startsWith('.morph/')) return 'state';
|
|
30
|
+
if (isPromptPath(path, promptGlobs)) return 'code';
|
|
31
|
+
if (DOC_PATH.test(path)) return 'doc';
|
|
32
|
+
if (CONFIG_PATH.test(path) && !WIDE_PATH.test(path)) return 'config';
|
|
33
|
+
return isTestPath(path) || /(^|\/)e2e\//.test(path) ? 'test' : 'code';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Per file: `added`/`removed` lines and `deleted` (the whole file went away). */
|
|
37
|
+
export function diffLines(cwd, from, to = null) {
|
|
38
|
+
const range = to ? [from, to] : [from];
|
|
39
|
+
const text = git(cwd, ['-c', 'core.quotepath=off', 'diff', '-U0', '--no-color', '--no-ext-diff', '--no-renames', ...range, '--', '.']);
|
|
40
|
+
const files = new Map();
|
|
41
|
+
let current = null;
|
|
42
|
+
for (const line of text.split('\n')) {
|
|
43
|
+
if (line.startsWith('diff --git ')) {
|
|
44
|
+
const path = line.split(' b/').pop();
|
|
45
|
+
current = { path, added: [], removed: [], deleted: false };
|
|
46
|
+
files.set(path, current);
|
|
47
|
+
} else if (!current) {
|
|
48
|
+
continue;
|
|
49
|
+
} else if (line.startsWith('deleted file mode')) {
|
|
50
|
+
current.deleted = true;
|
|
51
|
+
} else if (line.startsWith('+') && !line.startsWith('+++')) {
|
|
52
|
+
current.added.push(line.slice(1));
|
|
53
|
+
} else if (line.startsWith('-') && !line.startsWith('---')) {
|
|
54
|
+
current.removed.push(line.slice(1));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!to) {
|
|
58
|
+
for (const path of git(cwd, ['ls-files', '--others', '--exclude-standard']).split('\n').filter(Boolean)) {
|
|
59
|
+
files.set(path, { path, added: [''], removed: [], deleted: false, untracked: true });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return [...files.values()];
|
|
63
|
+
}
|
|
64
|
+
|
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'url';
|
|
|
4
4
|
import { existsSync, readFileSync } from 'fs';
|
|
5
5
|
import { scanGraph } from '../graph/god-nodes.js';
|
|
6
6
|
import { renderTemplate } from '../../core/templates/template-renderer.js';
|
|
7
|
-
import { WORKTREE_DIR_NAMES } from '../worktree
|
|
7
|
+
import { WORKTREE_DIR_NAMES } from '../scan/worktree-dirs.js';
|
|
8
8
|
|
|
9
9
|
export const SKIP_DIRS = new Set(['node_modules', 'bin', 'obj', '.git', '.morph', '.next', 'dist', 'out', ...WORKTREE_DIR_NAMES]);
|
|
10
10
|
const MAX_FILES_PER_SCANNER = 200;
|
|
@@ -10,13 +10,6 @@ function toPascalCase(str) {
|
|
|
10
10
|
.join('');
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
function toCamelCase(str) {
|
|
14
|
-
return str
|
|
15
|
-
.split('-')
|
|
16
|
-
.map((word, i) => i === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
17
|
-
.join('');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
13
|
/** Kebab-case so Handlebars {{pascalCase}} reconstructs it: "MyBookStore" → "my-book-store", "My.App" → "my-app". */
|
|
21
14
|
export function normalizeNamespaceToKebab(ns) {
|
|
22
15
|
return ns
|
|
@@ -52,42 +52,6 @@ export function detectDefaultBranch(cwd = process.cwd()) {
|
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
/**
|
|
56
|
-
* Where a new feature branch starts: origin's default after a best-effort fetch, so a local default that
|
|
57
|
-
* was never pulled does not hand the feature an old base. Falls back to the local default.
|
|
58
|
-
*/
|
|
59
|
-
export function freshDefaultRef(cwd = process.cwd()) {
|
|
60
|
-
const branch = detectDefaultBranch(cwd);
|
|
61
|
-
if (!branch) return null;
|
|
62
|
-
try {
|
|
63
|
-
execFileSync('git', ['fetch', '-q', 'origin', branch], { cwd, stdio: 'pipe', timeout: 30_000 });
|
|
64
|
-
} catch { /* offline or no origin: the local default */ }
|
|
65
|
-
try {
|
|
66
|
-
execFileSync('git', ['show-ref', '--verify', '--quiet', `refs/remotes/origin/${branch}`], { cwd, stdio: 'pipe' });
|
|
67
|
-
return `origin/${branch}`;
|
|
68
|
-
} catch {
|
|
69
|
-
return branch;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function hasOriginRemote(cwd = process.cwd()) {
|
|
74
|
-
try {
|
|
75
|
-
const url = execFileSync('git', ['remote', 'get-url', 'origin'], { cwd, stdio: 'pipe' }).toString().trim();
|
|
76
|
-
return url.length > 0;
|
|
77
|
-
} catch {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** @returns {string|null} null outside a repo or on an unborn HEAD; never throws. */
|
|
83
|
-
export function getHeadSha(cwd = process.cwd()) {
|
|
84
|
-
try {
|
|
85
|
-
return execFileSync('git', ['rev-parse', 'HEAD'], { cwd, stdio: 'pipe' }).toString().trim();
|
|
86
|
-
} catch {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
55
|
function parseShortstat(text) {
|
|
92
56
|
const files = /(\d+) files? changed/.exec(text || '');
|
|
93
57
|
const ins = /(\d+) insertions?\(\+\)/.exec(text || '');
|
|
@@ -122,89 +86,3 @@ function listUntrackedFiles(cwd) {
|
|
|
122
86
|
}
|
|
123
87
|
}
|
|
124
88
|
|
|
125
|
-
/**
|
|
126
|
-
* Diff against the WORKING TREE (not `baseRef...HEAD`), so uncommitted work counts.
|
|
127
|
-
* `filesChanged` includes untracked files; `untrackedFiles` breaks them out.
|
|
128
|
-
* @returns {{ filesChanged: number, insertions: number, deletions: number, untrackedFiles: number }|null}
|
|
129
|
-
*/
|
|
130
|
-
export function getDiffStat(baseRef, cwd = process.cwd()) {
|
|
131
|
-
if (!baseRef) return null;
|
|
132
|
-
try {
|
|
133
|
-
const out = execFileSync('git', ['diff', '--shortstat', baseRef], { cwd, stdio: 'pipe' }).toString().trim();
|
|
134
|
-
const stat = parseShortstat(out);
|
|
135
|
-
const untrackedFiles = countUntrackedFiles(cwd);
|
|
136
|
-
return { ...stat, filesChanged: stat.filesChanged + untrackedFiles, untrackedFiles };
|
|
137
|
-
} catch {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Paths changed in the working tree against `baseRef`, untracked included, sorted.
|
|
144
|
-
* `[]` means both "nothing changed" and "ref did not resolve".
|
|
145
|
-
* @returns {string[]}
|
|
146
|
-
*/
|
|
147
|
-
export function changedPathsAgainst(baseRef, cwd = process.cwd()) {
|
|
148
|
-
if (!baseRef) return [];
|
|
149
|
-
|
|
150
|
-
let tracked;
|
|
151
|
-
try {
|
|
152
|
-
// From the merge-base: what the default gained after the branch point is not this feature's.
|
|
153
|
-
// origin's copy first: a local default that was never pulled holds the merge-base back.
|
|
154
|
-
let base = baseRef;
|
|
155
|
-
for (const ref of [`origin/${baseRef}`, baseRef]) {
|
|
156
|
-
try {
|
|
157
|
-
base = execFileSync('git', ['merge-base', 'HEAD', ref], { cwd, stdio: 'pipe' }).toString().trim() || baseRef;
|
|
158
|
-
break;
|
|
159
|
-
} catch { /* next ref */ }
|
|
160
|
-
}
|
|
161
|
-
tracked = splitLines(
|
|
162
|
-
execFileSync('git', ['diff', '--name-only', base], { cwd, stdio: 'pipe' }).toString()
|
|
163
|
-
);
|
|
164
|
-
} catch {
|
|
165
|
-
return [];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return [...new Set([...tracked, ...listUntrackedFiles(cwd)])].sort();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Added lines per file, measured from the merge-base so a moved-on default branch
|
|
173
|
-
* lends nothing; paths relative to `cwd` (`--relative`), like the untracked listing.
|
|
174
|
-
* @returns {Map<string, number[]|null>|null} `null` value = whole untracked file;
|
|
175
|
-
* `null` result = cannot tell.
|
|
176
|
-
*/
|
|
177
|
-
export function addedLinesAgainst(baseRef, cwd = process.cwd()) {
|
|
178
|
-
if (!baseRef) return null;
|
|
179
|
-
const git = (args) => execFileSync('git', args, { cwd, stdio: 'pipe', maxBuffer: 256 * 1024 * 1024 }).toString();
|
|
180
|
-
|
|
181
|
-
let diff;
|
|
182
|
-
try {
|
|
183
|
-
let base = baseRef;
|
|
184
|
-
try { base = git(['merge-base', 'HEAD', baseRef]).trim() || baseRef; } catch { /* diff against the ref itself */ }
|
|
185
|
-
diff = git(['-c', 'core.quotepath=off', 'diff', '-U0', '--no-color', '--no-ext-diff', '-M', '--relative',
|
|
186
|
-
'--src-prefix=a/', '--dst-prefix=b/', base]);
|
|
187
|
-
} catch {
|
|
188
|
-
return null;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const added = new Map();
|
|
192
|
-
let current = null;
|
|
193
|
-
for (const line of diff.split('\n')) {
|
|
194
|
-
if (line.startsWith('+++ ')) {
|
|
195
|
-
const target = line.slice(4).trim().replace(/^"|"$/g, '');
|
|
196
|
-
current = target.startsWith('b/') ? target.slice(2) : null;
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
const hunk = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/.exec(line);
|
|
200
|
-
if (!hunk || !current) continue;
|
|
201
|
-
const start = Number(hunk[1]);
|
|
202
|
-
const count = hunk[2] === undefined ? 1 : Number(hunk[2]);
|
|
203
|
-
if (count === 0) continue;
|
|
204
|
-
const lines = added.get(current) ?? [];
|
|
205
|
-
for (let n = start; n < start + count; n++) lines.push(n);
|
|
206
|
-
added.set(current, lines);
|
|
207
|
-
}
|
|
208
|
-
for (const path of listUntrackedFiles(cwd)) added.set(path, null);
|
|
209
|
-
return added;
|
|
210
|
-
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { buildIndex, linksOf, resolveEdgeTarget
|
|
1
|
+
import { buildIndex, linksOf, resolveEdgeTarget } from './sanitize.js';
|
|
2
|
+
import { isTestPath } from '../diff/diff-lines.js';
|
|
2
3
|
|
|
3
4
|
const CALL_RELATIONS = new Set(['calls', 'indirect_call', 'dispatches_to']);
|
|
4
5
|
const HUNK_RE = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Só nós com source_file, e nada de teste: dublês e fixtures estão no grafo para serem achados, não para
|
|
2
2
|
// disputar centralidade. Aresta com uma ponta em teste não conta, e comunidade só de teste some.
|
|
3
3
|
import { loadGraph } from './graph-loader.js';
|
|
4
|
-
import { buildIndex, resolveEdgeTarget, linksOf
|
|
4
|
+
import { buildIndex, resolveEdgeTarget, linksOf } from './sanitize.js';
|
|
5
|
+
import { isTestPath } from '../diff/diff-lines.js';
|
|
5
6
|
|
|
6
7
|
/** Sem `graphify label`, as comunidades se chamam Community_N — ruído puro. */
|
|
7
8
|
const PLACEHOLDER_LABEL = /^Community[_ ]?\d+$/i;
|
|
@@ -8,7 +8,6 @@ export { GRAPHIFY_PACKAGE };
|
|
|
8
8
|
// Pin exato: o graphify é pré-1.0 com release quase diária e semver não garante nada; subir é decisão
|
|
9
9
|
// consciente, com o fixture de regressão regerado.
|
|
10
10
|
export const GRAPHIFY_VERSION = '0.9.50';
|
|
11
|
-
export const GRAPHIFY_BIN = 'graphify';
|
|
12
11
|
|
|
13
12
|
const PREFERENCE = ['uv', 'pipx', 'python3', 'python'];
|
|
14
13
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { writeFileSync, existsSync, readFileSync } from 'node:fs';
|
|
5
5
|
import { execFileSync } from 'node:child_process';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
|
-
import { WORKTREE_DIR_NAMES } from '../worktree
|
|
7
|
+
import { WORKTREE_DIR_NAMES } from '../scan/worktree-dirs.js';
|
|
8
8
|
import { ignoreRules } from '../../../framework/hooks/shared/graph-freshness.js';
|
|
9
9
|
|
|
10
10
|
export const ALWAYS_IGNORED = [
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isTestPath } from '../diff/diff-lines.js';
|
|
2
|
+
|
|
1
3
|
// O graphify não resolve escopo hierárquico de namespace em C#: tipo do namespace pai vira stub por arquivo.
|
|
2
4
|
// Label com 1 nó real coalesce; 0 reais é externo; 2+ reais é ambíguo e são símbolos do projeto, por isso
|
|
3
5
|
// externo é `real.length === 0`, nunca "o que sobrou".
|
|
@@ -17,14 +19,6 @@ const LANG_BY_EXT = {
|
|
|
17
19
|
sql: 'sql', py: 'python', go: 'go', rs: 'rust', java: 'jvm', kt: 'jvm',
|
|
18
20
|
};
|
|
19
21
|
|
|
20
|
-
// O predicado único de teste do grafo e do validador de reuso. Só três formas de pasta, porque
|
|
21
|
-
// `[^/]*[Tt]ests?/` genérico também casaria `latest/` e `contests/`.
|
|
22
|
-
const TEST_PATH = /(^|\/)__tests__\/|\.(test|spec)\.[jt]sx?$|(^|\/)(?:[Tt]ests?|[^/]*\.[Tt]ests?|[^/]*[a-z0-9_]Tests?)\//;
|
|
23
|
-
|
|
24
|
-
export function isTestPath(sourceFile) {
|
|
25
|
-
return TEST_PATH.test(String(sourceFile || '').replace(/\\/g, '/'));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
22
|
/** Família de linguagem do arquivo, ou '' quando desconhecida. */
|
|
29
23
|
export function languageOf(sourceFile) {
|
|
30
24
|
const m = /\.([a-z0-9]+)$/i.exec(sourceFile || '');
|
|
@@ -15,7 +15,7 @@ function getMemoryRoot(projectPath) {
|
|
|
15
15
|
function projectMemoryContent(info) {
|
|
16
16
|
return `---
|
|
17
17
|
name: project-morph-spec
|
|
18
|
-
description: morph-spec project configuration, paths
|
|
18
|
+
description: morph-spec project configuration, paths and slash commands
|
|
19
19
|
metadata:
|
|
20
20
|
type: project
|
|
21
21
|
---
|
|
@@ -23,44 +23,31 @@ metadata:
|
|
|
23
23
|
# ${info.projectName} — morph-spec project
|
|
24
24
|
|
|
25
25
|
**Framework version:** ${info.frameworkVersion}
|
|
26
|
-
**Stack:** ${info.stack ?? '
|
|
27
|
-
**Trust mode:** auto (gates auto-pass without risk signals)
|
|
26
|
+
**Stack:** ${info.stack ?? 'from the contract (.morph/config/config.json)'}
|
|
28
27
|
|
|
29
28
|
## Key paths
|
|
30
29
|
|
|
31
|
-
- \`.morph/framework/MORPH.md\` —
|
|
32
|
-
- \`.morph/
|
|
33
|
-
- \`.morph/
|
|
34
|
-
- \`.morph/
|
|
35
|
-
- \`.morph/
|
|
36
|
-
- \`.morph/state.json\` — feature state (managed by state-sync hook; Edit fallback allowed)
|
|
30
|
+
- \`.morph/framework/MORPH.md\` — the flow (read once per session)
|
|
31
|
+
- \`.morph/config/config.json\` — the repo contract: stack, test commands per tier, risk globs, limits
|
|
32
|
+
- \`.morph/features/<branch-slug>/\` — plan (2-plan), screens (1-design), report (3-implement), review (4-review)
|
|
33
|
+
- \`.morph/framework/agents.json\` — the 3 read-only review personas (\`verifier\`, \`reviewer\`, \`security\`)
|
|
34
|
+
- \`.morph/framework/standards/STANDARDS.json\` — standards index (\`morph-spec standards --find\`)
|
|
37
35
|
|
|
38
36
|
## Slash commands
|
|
39
37
|
|
|
40
38
|
| Command | Skill invoked |
|
|
41
39
|
|---------|---------------|
|
|
42
|
-
| \`/morph-plan
|
|
43
|
-
| \`/morph-apply
|
|
44
|
-
| \`/morph-status [feature]\` | inspect state.json |
|
|
45
|
-
| \`/morph-archive {feature}\` | move completed feature to .morph/archive/ |
|
|
46
|
-
| \`/morph-preflight\` | pre-deploy validation |
|
|
40
|
+
| \`/morph-plan\` | \`Skill(morph-plan)\` — issue → plan.md with C1..Cn → plan-check |
|
|
41
|
+
| \`/morph-apply\` | \`Skill(morph-apply)\` — prove-red → implement → check → review personas → check --report |
|
|
47
42
|
| \`/morph-troubleshoot [erro]\` | diagnose .NET/Next.js errors |
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
\`morph-plan\`, \`morph-apply\`, \`morph-uiux\`, \`morph-review\`, \`morph-hotfix\`, \`morph-standards\`
|
|
52
|
-
|
|
53
|
-
**Why:** This project is managed by morph-spec — spec-driven autonomous development with trust-aware gates.
|
|
54
|
-
|
|
55
|
-
**How to apply:**
|
|
56
|
-
- When user mentions a feature, check \`.morph/features/\` first.
|
|
57
|
-
- In \`trust: "auto"\`, gates auto-pass; only AskUserQuestion on risk signals.
|
|
44
|
+
**How to apply:** the feature is the folder of the current branch; without a human (\`MORPH_AUTONOMOUS=1\`) nothing is asked and what is not the session's call ends as \`precisa-humano\`.
|
|
58
45
|
`;
|
|
59
46
|
}
|
|
60
47
|
|
|
61
48
|
const REFERENCE_MEMORY_CONTENT = `---
|
|
62
49
|
name: reference-morph-context
|
|
63
|
-
description: where to find long-lived morph-spec project context
|
|
50
|
+
description: where to find long-lived morph-spec project context
|
|
64
51
|
metadata:
|
|
65
52
|
type: reference
|
|
66
53
|
---
|
|
@@ -69,11 +56,9 @@ metadata:
|
|
|
69
56
|
|
|
70
57
|
- \`.morph/context/README.md\` — generated architecture overview
|
|
71
58
|
- \`.morph/context/design-system.md\` — design tokens and components (source of truth)
|
|
72
|
-
- \`.morph/
|
|
73
|
-
- \`.morph/framework/
|
|
74
|
-
- \`.morph/framework/
|
|
75
|
-
- \`.morph/framework/agents.json\` — Gate 3 agent definitions (verifier, reviewer, security)
|
|
76
|
-
- \`.morph/framework/evals/review-checklist.md\` — what the Gate 3 verifier, reviewer and security check (verdict SHIP/FIX + evidence-typed blockers)
|
|
59
|
+
- \`.morph/specs/adrs/\` — project-scope decisions, written by plan-check
|
|
60
|
+
- \`.morph/framework/CLI.md\` — the CLI reference, one section per command
|
|
61
|
+
- \`.morph/framework/evals/review-checklist.md\` — what the review personas check (SHIP/FIX + evidence-typed blockers)
|
|
77
62
|
`;
|
|
78
63
|
|
|
79
64
|
// Idempotent: memory files are overwritten, MEMORY.md entries appended only if missing.
|
|
@@ -95,7 +80,7 @@ export async function installProjectMemory(projectPath, info) {
|
|
|
95
80
|
indexContent = '# Memory Index\n';
|
|
96
81
|
}
|
|
97
82
|
|
|
98
|
-
const projectLine = '- [morph-spec project](project_morph_spec.md) — stack,
|
|
83
|
+
const projectLine = '- [morph-spec project](project_morph_spec.md) — stack, slash commands, key paths';
|
|
99
84
|
const refLine = '- [morph-spec context](reference_morph_context.md) — where to find long-lived context';
|
|
100
85
|
|
|
101
86
|
if (!indexContent.includes('project_morph_spec.md')) {
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import { existsSync, readFileSync, readdirSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import { detectProject } from '../detectors/index.js';
|
|
4
|
+
import { scanRepo } from '../contract/scan.js';
|
|
4
5
|
import { getProjectTags, parseStacks, shouldInstall } from '../stack-filter.js';
|
|
5
|
-
import { WORKTREE_DIR_NAMES } from '../worktree
|
|
6
|
-
import { resolveComposeFile } from '../../../framework/hooks/shared/e2e-check.js';
|
|
6
|
+
import { WORKTREE_DIR_NAMES } from '../scan/worktree-dirs.js';
|
|
7
7
|
import { createEffects } from './effects.js';
|
|
8
8
|
import { MAF_RULE, MAF_TAG, installRuleFile, ruleContentFor } from './rules-installer.js';
|
|
9
9
|
|
|
10
|
+
const COMPOSE_CANDIDATES = ['compose.yaml', 'compose.yml', 'docker-compose.yaml', 'docker-compose.yml'];
|
|
11
|
+
|
|
12
|
+
function resolveComposeFile(cwd, config) {
|
|
13
|
+
const configured = config?.e2e?.composeFile;
|
|
14
|
+
if (configured) return existsSync(join(cwd, configured)) ? configured : null;
|
|
15
|
+
return COMPOSE_CANDIDATES.find((name) => existsSync(join(cwd, name))) ?? null;
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
const RULES_SRC = join(import.meta.dirname, '..', '..', '..', 'framework', 'rules');
|
|
11
|
-
const STACK_TAGS = new Set(['nextjs', 'dotnet']);
|
|
19
|
+
const STACK_TAGS = new Set(['nextjs', 'dotnet', 'react', 'vue', 'node', 'python', 'static']);
|
|
20
|
+
// Tags only skills react to: no rule names them, so ruleTags() never lists them.
|
|
21
|
+
const SKILL_TAGS = ['umbraco'];
|
|
12
22
|
const SKIP_DIRS = new Set(['node_modules', 'bin', 'obj', ...WORKTREE_DIR_NAMES]);
|
|
13
23
|
const MAX_DEPTH = 5;
|
|
14
24
|
const MAX_ENTRIES = 20000;
|
|
@@ -53,6 +63,7 @@ export function detectStackTags(projectDir, { config = null, rulesSrc = RULES_SR
|
|
|
53
63
|
const { structure } = detectProject(projectDir);
|
|
54
64
|
for (const t of String(structure.stack).split('+')) found.add(t);
|
|
55
65
|
for (const t of structure.integrations) found.add(t);
|
|
66
|
+
for (const t of scanRepo(projectDir).tags) found.add(t);
|
|
56
67
|
|
|
57
68
|
walk(projectDir, (name, path) => {
|
|
58
69
|
if (name.endsWith('.csproj') || name.endsWith('.sln') || name.endsWith('.slnx')) found.add('dotnet');
|
|
@@ -121,11 +132,9 @@ const NOOP = Object.freeze({ added: [], updated: [], tags: [], configChanged: fa
|
|
|
121
132
|
/**
|
|
122
133
|
* Installs every stack rule (a `stacks:` other than `*`) the project needs and lacks, after adding to
|
|
123
134
|
* config.json the stack tags its files show. Only an installed project (with config.json) is touched. Never throws.
|
|
124
|
-
* `persistTags: false` leaves config.json alone: a check (`verify`) may write gitignored harness files, never a tracked one.
|
|
125
135
|
*/
|
|
126
136
|
export function syncStackRules(projectDir, {
|
|
127
137
|
dryRun = false, fx = createEffects({ dryRun }), log = (line) => console.log(line), rulesSrc = RULES_SRC,
|
|
128
|
-
persistTags = true,
|
|
129
138
|
} = {}) {
|
|
130
139
|
try {
|
|
131
140
|
const configPath = configPathOf(projectDir);
|
|
@@ -137,9 +146,7 @@ export function syncStackRules(projectDir, {
|
|
|
137
146
|
}
|
|
138
147
|
|
|
139
148
|
const detected = detectStackTags(projectDir, { config, rulesSrc });
|
|
140
|
-
const merged =
|
|
141
|
-
? mergeDetectedTags(config, detected.persist)
|
|
142
|
-
: { config, added: [], changed: false };
|
|
149
|
+
const merged = mergeDetectedTags(config, detected.persist);
|
|
143
150
|
if (merged.changed) {
|
|
144
151
|
fx.writeJson(configPath, merged.config);
|
|
145
152
|
log(` + config.json: ${merged.added.join(', ')} (detectado nos arquivos)`);
|
|
@@ -161,7 +168,7 @@ export function syncStackRules(projectDir, {
|
|
|
161
168
|
|
|
162
169
|
/** What `stack-set` accepts: the stack tags, and the integrations some rule (or the MAF rewrite) reacts to. */
|
|
163
170
|
export function knownStackTags(rulesSrc = RULES_SRC) {
|
|
164
|
-
const integrations = [...ruleTags(rulesSrc), MAF_TAG].filter((t) => !STACK_TAGS.has(t));
|
|
171
|
+
const integrations = [...ruleTags(rulesSrc), MAF_TAG, ...SKILL_TAGS].filter((t) => !STACK_TAGS.has(t));
|
|
165
172
|
return { stacks: [...STACK_TAGS].sort(), integrations: [...new Set(integrations)].sort() };
|
|
166
173
|
}
|
|
167
174
|
|