@polymorphism-tech/morph-spec 11.2.0 → 11.3.1
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 +7 -7
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +1 -1
- package/framework/MORPH.md +2 -2
- package/framework/agents.json +4 -4
- package/framework/docs/CLI.md +19 -11
- package/framework/evals/review-checklist.md +26 -2
- package/framework/hooks/README.md +3 -2
- package/framework/hooks/claude-code/core/graph-refresh-kick.js +2 -2
- package/framework/mcp/registry.json +15 -15
- package/framework/rules/ai-agents-standards.md +9 -1
- package/framework/rules/gsap-standards.md +8 -0
- package/framework/rules/mcp-standards.md +10 -0
- package/framework/schemas/config.schema.json +7 -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 +4 -3
- package/framework/skills/core/morph-plan/SKILL.md +1 -1
- package/framework/skills/core/morph-uiux/SKILL.md +1 -1
- 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 +124 -266
- package/framework/templates/README.md +52 -82
- package/framework/templates/REGISTRY.json +0 -206
- 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 +1 -1
- 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 +2 -4
- package/framework/templates/frontend/nextjs/gsap-scroll-section.tsx.hbs +13 -17
- package/framework/templates/infrastructure/github/README.md +10 -13
- package/package.json +9 -3
- package/src/commands/mcp/manual-setup.js +95 -0
- package/src/commands/mcp/mcp-setup.js +23 -191
- package/src/commands/project/doctor.js +6 -16
- package/src/commands/project/init-contract.js +2 -2
- package/src/commands/project/init.js +15 -133
- package/src/commands/project/stack-scan.js +6 -14
- package/src/commands/project/stack-set.js +1 -1
- package/src/commands/project/standards.js +1 -2
- package/src/commands/project/update.js +52 -66
- package/src/commands/scaffold/scaffold.js +28 -7
- package/src/lib/ai/ai-project-scan.js +1 -4
- package/src/lib/ai/code-audit.js +1 -6
- package/src/lib/ai/registry-audit.js +2 -1
- package/src/lib/config/project-config.js +3 -2
- package/src/lib/contract/apply.js +2 -1
- package/src/lib/contract/merge.js +1 -0
- package/src/lib/contract/scan.js +5 -5
- package/src/lib/detectors/claude-config-detector.js +45 -47
- package/src/lib/detectors/mcp-config.js +2 -1
- package/src/lib/diff/diff-lines.js +2 -7
- package/src/lib/graph/graph-loader.js +2 -1
- package/src/lib/graph/graphifyignore.js +2 -1
- package/src/lib/installers/install-manifest.js +56 -0
- package/src/lib/installers/mcp-installer.js +14 -5
- package/src/lib/installers/rules-installer.js +9 -15
- package/src/lib/installers/stack-assets.js +42 -21
- package/src/lib/installers/stack-sync.js +12 -12
- 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 +3 -2
- package/src/lib/plan/media.js +3 -3
- package/src/lib/plan/plan-parser.js +5 -10
- package/src/lib/review-reports.js +5 -4
- package/src/lib/stack/stack-scan.js +1 -1
- package/src/lib/standards/verified-against.js +1 -1
- package/src/lib/tests-audit/audit.js +1 -1
- package/src/lib/text.js +5 -0
- package/src/scripts/setup-infra.js +22 -33
- package/src/utils/agents-installer.js +13 -30
- package/src/utils/claude-md-injector.js +16 -50
- package/src/utils/claude-settings-manager.js +2 -2
- package/src/utils/file-copier.js +3 -4
- package/src/utils/hooks-installer.js +55 -20
- package/src/utils/skills-installer.js +18 -78
- 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/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/lib/detectors/index.js +0 -153
- package/src/lib/installers/templates-reconcile.js +0 -26
package/src/lib/plan/media.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { foldAccents } from '../text.js';
|
|
2
|
+
|
|
1
3
|
const MEDIA_STANDARD_IDS = [
|
|
2
4
|
'ai-agents-modalities-image-gen',
|
|
3
5
|
'ai-agents-media-video',
|
|
@@ -18,8 +20,6 @@ function featureGeneratesMedia(planText) {
|
|
|
18
20
|
return MEDIA_STANDARD_IDS.some((id) => tokens.has(id));
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
const fold = (s) => s.normalize('NFD').replace(/\p{M}/gu, '').toLowerCase();
|
|
22
|
-
|
|
23
23
|
// Vocabulário estreito de propósito: "imagem" sozinha (upload, avatar) não é mídia gerada.
|
|
24
24
|
const GENERATED_MEDIA_RE = new RegExp([
|
|
25
25
|
String.raw`\b(gera[rd]?[ao]?s?|geracao|generat\w*)\b[^.\n]{0,40}\b(imagem|imagens|images?|videos?|ilustrac\w*|thumbnails?)\b`,
|
|
@@ -33,7 +33,7 @@ const NO_MEDIA_RE = /^\s*[-*]?\s*\**midia gerada:?\**:?\s*nao\b/m;
|
|
|
33
33
|
/** Plano que fala em gerar imagem ou vídeo e não cita o standard deixaria o guardrail desarmado em silêncio. */
|
|
34
34
|
export function mediaCitationError(planText) {
|
|
35
35
|
if (typeof planText !== 'string' || featureGeneratesMedia(planText)) return null;
|
|
36
|
-
const text =
|
|
36
|
+
const text = foldAccents(planText);
|
|
37
37
|
if (NO_MEDIA_RE.test(text)) return null;
|
|
38
38
|
const hit = GENERATED_MEDIA_RE.exec(text);
|
|
39
39
|
if (!hit) return null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { tableCells, isTableLine, SEPARATOR_ROW_RE } from '../specs/gfm-table.js';
|
|
2
|
+
import { foldAccents } from '../text.js';
|
|
2
3
|
import { ARTIFACT_MARKER_RE } from './artifact-vocabulary.js';
|
|
3
4
|
import { markdownLines } from '../../../framework/hooks/shared/errata.js';
|
|
4
5
|
|
|
@@ -44,7 +45,7 @@ const ADR_PLAIN = {
|
|
|
44
45
|
const WHY_RE =new RegExp(String.raw`^\s*>\s*` + ARTIFACT_MARKER_RE.source + String.raw`\s*(.*?)\s*$`, 'i');
|
|
45
46
|
const SCOPE_RE = /^\s*\*\*Alcance:\*\*\s*(.*?)\s*$/i;
|
|
46
47
|
|
|
47
|
-
const fold = (s) => s
|
|
48
|
+
const fold = (s) => foldAccents(s).trim();
|
|
48
49
|
|
|
49
50
|
function splitSections(lines) {
|
|
50
51
|
const sections = [];
|
|
@@ -150,12 +151,11 @@ function parseReuse(lines) {
|
|
|
150
151
|
line: line.n,
|
|
151
152
|
});
|
|
152
153
|
}
|
|
153
|
-
return
|
|
154
|
+
return rows;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
function parseSummary(lines) {
|
|
157
158
|
const found = { name: null, kind: null, today: null, after: null, source: null, watch: [] };
|
|
158
|
-
const rest = [];
|
|
159
159
|
let open = null;
|
|
160
160
|
for (const line of lines) {
|
|
161
161
|
const m = !line.fenced && SUMMARY_RE.exec(line.raw);
|
|
@@ -168,9 +168,8 @@ function parseSummary(lines) {
|
|
|
168
168
|
}
|
|
169
169
|
if (open && /^\s+\S/.test(line.raw)) { open.text += ` ${line.raw.trim()}`; continue; }
|
|
170
170
|
open = null;
|
|
171
|
-
rest.push(line.raw);
|
|
172
171
|
}
|
|
173
|
-
return { name: found.name?.text ?? null, kind: found.kind?.text.trim().toLowerCase() ?? null, today: found.today?.text ?? null, after: found.after?.text ?? null, source: found.source?.text ?? null, watch: found.watch.map((w) => w.text)
|
|
172
|
+
return { name: found.name?.text ?? null, kind: found.kind?.text.trim().toLowerCase() ?? null, today: found.today?.text ?? null, after: found.after?.text ?? null, source: found.source?.text ?? null, watch: found.watch.map((w) => w.text) };
|
|
174
173
|
}
|
|
175
174
|
|
|
176
175
|
function parseDefaults(lines) {
|
|
@@ -215,7 +214,6 @@ export function parsePlan(text) {
|
|
|
215
214
|
}
|
|
216
215
|
const body = (key) => byName.get(key)?.lines ?? [];
|
|
217
216
|
const decisions = parseDecisions(body('decisions'));
|
|
218
|
-
const reuse = parseReuse(body('reuse'));
|
|
219
217
|
const errata = byName.get('errata');
|
|
220
218
|
|
|
221
219
|
return {
|
|
@@ -224,14 +222,11 @@ export function parsePlan(text) {
|
|
|
224
222
|
scenarios: parseScenarios(body('scenarios')),
|
|
225
223
|
adrs: decisions.adrs,
|
|
226
224
|
conflicts: decisions.conflicts,
|
|
227
|
-
reuse: reuse
|
|
228
|
-
reuseHeader: reuse.header,
|
|
225
|
+
reuse: parseReuse(body('reuse')),
|
|
229
226
|
summary: parseSummary(body('summary')),
|
|
230
227
|
defaults: parseDefaults(body('defaults')),
|
|
231
228
|
states: parseStates(body('states')),
|
|
232
229
|
flow: parseStates(body('flow')),
|
|
233
|
-
text: Object.fromEntries(Object.keys(SECTIONS).map((k) => [k, body(k).map((l) => l.raw).join('\n').trim()])),
|
|
234
|
-
errata: errata ? errata.lines.map((l) => l.raw).join('\n').trim() : null,
|
|
235
230
|
sectionsAfterErrata: errata ? sections.filter((s) => s.line > errata.line).map((s) => s.name) : [],
|
|
236
231
|
};
|
|
237
232
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import { OUTPUT_SCHEMA } from '../core/paths/output-schema.js';
|
|
4
|
+
import { tableCells } from './specs/gfm-table.js';
|
|
5
|
+
import { foldAccents } from './text.js';
|
|
4
6
|
import { PARTIAL_MARKER } from '../../framework/hooks/shared/report-progress.js';
|
|
5
7
|
|
|
6
8
|
export const VERDICT_TOKEN = '**Verdict:**';
|
|
@@ -39,7 +41,7 @@ function lastSectionBody(text, re) {
|
|
|
39
41
|
return bodies.length ? bodies[bodies.length - 1] : null;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
const normalize = (s) => String(s ?? '')
|
|
44
|
+
const normalize = (s) => foldAccents(String(s ?? '')).replace(/\s+/g, ' ').trim();
|
|
43
45
|
const cleanId = (s) => String(s ?? '').replace(/[*`_]/g, '').trim().toUpperCase();
|
|
44
46
|
|
|
45
47
|
const isSeparator = (cells) => cells.every((c) => /^:?-{2,}:?$/.test(c) || c === '');
|
|
@@ -54,10 +56,9 @@ function tableRows(body, keepHeader = () => true) {
|
|
|
54
56
|
const lines = body.split(/\r?\n/);
|
|
55
57
|
for (const [i, line] of lines.entries()) {
|
|
56
58
|
if (!/^\s*\|/.test(line)) { skipping = false; continue; }
|
|
57
|
-
const cells = line
|
|
59
|
+
const cells = tableCells(line);
|
|
58
60
|
if (isSeparator(cells)) continue;
|
|
59
|
-
|
|
60
|
-
if (next && /^\s*\|/.test(lines[i + 1]) && isSeparator(next) && !skipping) {
|
|
61
|
+
if (/^\s*\|/.test(lines[i + 1] ?? '') && isSeparator(tableCells(lines[i + 1])) && !skipping) {
|
|
61
62
|
skipping = !keepHeader(cells);
|
|
62
63
|
continue;
|
|
63
64
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, readdirSync, statSync } from 'fs';
|
|
2
2
|
import { join, relative } from 'path';
|
|
3
3
|
import { getProjectTags } from '../stack-filter.js';
|
|
4
|
-
import { PACKAGE_LOCATIONS } from '
|
|
4
|
+
import { PACKAGE_LOCATIONS } from '../../../framework/hooks/shared/frontend-locations.js';
|
|
5
5
|
import { isTestPath } from '../diff/diff-lines.js';
|
|
6
6
|
import { WORKTREE_DIR_NAMES } from '../scan/worktree-dirs.js';
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ const AI_PIN_RELATIVE = join('framework', 'ai-pin.json');
|
|
|
11
11
|
|
|
12
12
|
// Group 1 = subject, group 2 = ISO date. `[^\n]*?` keeps it on one line: a
|
|
13
13
|
// `Last-verified:` further down belongs to another claim.
|
|
14
|
-
|
|
14
|
+
const LAST_VERIFIED_RE = /\*\*Verified against:\*\*([^\n]*?)Last-verified:\s*(\d{4}-\d{2}-\d{2})/;
|
|
15
15
|
|
|
16
16
|
// Real markers are end-of-line and often lack a colon (`x; // VERIFY namespace`),
|
|
17
17
|
// so no line-start/colon anchor. The fence rule lives in countVerifyMarkers.
|
|
@@ -2,6 +2,7 @@ import { execFileSync } from 'child_process';
|
|
|
2
2
|
import { readFileSync } from 'fs';
|
|
3
3
|
import { basename, join } from 'path';
|
|
4
4
|
import { isTestPath } from '../diff/diff-lines.js';
|
|
5
|
+
import { lineOf } from '../text.js';
|
|
5
6
|
|
|
6
7
|
const PROSE_MIN_HITS = 3;
|
|
7
8
|
const FAMILY_MIN_SIZE = 4;
|
|
@@ -24,7 +25,6 @@ function trackedTestFiles(root) {
|
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
const lineOf = (text, index) => text.slice(0, index).split('\n').length;
|
|
28
28
|
const countOf = (text, re) => (text.match(re) ?? []).length;
|
|
29
29
|
|
|
30
30
|
function factFamilies(text) {
|
package/src/lib/text.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Lowercase without diacritics: `Regressão` and `regressao` compare equal. */
|
|
2
|
+
export const foldAccents = (s) => s.normalize('NFD').replace(/\p{M}/gu, '').toLowerCase();
|
|
3
|
+
|
|
4
|
+
/** 1-based line of a character offset. */
|
|
5
|
+
export const lineOf = (text, index) => text.slice(0, index).split('\n').length;
|
|
@@ -12,12 +12,11 @@ import {
|
|
|
12
12
|
} from '../utils/file-copier.js';
|
|
13
13
|
import { getProjectTags } from '../lib/stack-filter.js';
|
|
14
14
|
import { readMorphConfig } from '../lib/config/project-config.js';
|
|
15
|
-
import {
|
|
15
|
+
import { removeMorphImport } from '../utils/claude-md-injector.js';
|
|
16
16
|
import { saveProjectMorphVersion, getInstalledCLIVersion, getProjectMorphVersion } from '../utils/version-checker.js';
|
|
17
17
|
import { installClaudeHooks, installGlobalStatusline } from '../utils/claude-settings-manager.js';
|
|
18
|
-
import { reconcileLegacyTemplatesCopy } from '../lib/installers/templates-reconcile.js';
|
|
19
18
|
import { realEffects } from '../lib/installers/effects.js';
|
|
20
|
-
import { installAssetsForTags } from '../lib/installers/stack-assets.js';
|
|
19
|
+
import { installAssetsForTags, refreshAssetsForTags } from '../lib/installers/stack-assets.js';
|
|
21
20
|
|
|
22
21
|
const FRAMEWORK_DIR = join(import.meta.dirname, '..', '..', 'framework');
|
|
23
22
|
|
|
@@ -25,6 +24,12 @@ const REQUIRED_PLUGINS = [
|
|
|
25
24
|
'context7@claude-plugins-official',
|
|
26
25
|
];
|
|
27
26
|
|
|
27
|
+
// The status line runs from `~/.claude/` and imports only `shared/` from the project: its project copy has no reader.
|
|
28
|
+
export const hooksPayloadFilter = (from) => !['statusline.js', 'README.md'].includes(basename(from));
|
|
29
|
+
|
|
30
|
+
// Relative to `.morph/config/config.json`: the editor validates the contract against the installed schema.
|
|
31
|
+
export const CONFIG_SCHEMA_REF = '../framework/schemas/config.schema.json';
|
|
32
|
+
|
|
28
33
|
const toolInstallOff = () => process.env.MORPH_NO_TOOL_INSTALL === '1';
|
|
29
34
|
|
|
30
35
|
function installRequiredPlugins(log, exec) {
|
|
@@ -43,10 +48,13 @@ function installRequiredPlugins(log, exec) {
|
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
// The full install writes the manifest and installs the hooks itself, deny included; `--reinstall` only follows a manifest that exists.
|
|
52
|
+
async function installStackAwareAssets(targetPath, log, { full }) {
|
|
47
53
|
const projectTags = getProjectTags(readMorphConfig(targetPath));
|
|
48
54
|
log('Installing stack-filtered rules, commands, skills and agents...');
|
|
49
|
-
const
|
|
55
|
+
const { agents: agentCounts } = full
|
|
56
|
+
? await installAssetsForTags(targetPath, projectTags, { frameworkSrc: FRAMEWORK_DIR, createManifest: true })
|
|
57
|
+
: await refreshAssetsForTags(targetPath, projectTags, { frameworkSrc: FRAMEWORK_DIR });
|
|
50
58
|
return { agentCounts, projectTags };
|
|
51
59
|
}
|
|
52
60
|
|
|
@@ -78,7 +86,7 @@ export async function updateClaudeMdAgentsBlock(claudeMdPath, agents = [], optio
|
|
|
78
86
|
* Headless install: no prompts, no stack detection.
|
|
79
87
|
*/
|
|
80
88
|
export async function setupInfra(targetPath, {
|
|
81
|
-
_exec = execSync, _detectGraphifyVersion = null, _log = null, reinstall = false,
|
|
89
|
+
_exec = execSync, _detectGraphifyVersion = null, _detectInstaller = null, _log = null, reinstall = false,
|
|
82
90
|
} = {}) {
|
|
83
91
|
const quiet = process.env.MORPH_QUIET === '1';
|
|
84
92
|
|
|
@@ -89,7 +97,7 @@ export async function setupInfra(targetPath, {
|
|
|
89
97
|
|
|
90
98
|
if (reinstall) {
|
|
91
99
|
log('setup-infra (reinstall): re-installing stack-aware assets...');
|
|
92
|
-
const { agentCounts } = await installStackAwareAssets(targetPath, log);
|
|
100
|
+
const { agentCounts } = await installStackAwareAssets(targetPath, log, { full: false });
|
|
93
101
|
await updateClaudeMdAgentsBlock(join(targetPath, '.claude', 'CLAUDE.md'), agentCounts?.agents ?? []);
|
|
94
102
|
log('setup-infra (reinstall): complete.');
|
|
95
103
|
return { agents: { installed: agentCounts?.installed ?? 0 } };
|
|
@@ -97,10 +105,8 @@ export async function setupInfra(targetPath, {
|
|
|
97
105
|
|
|
98
106
|
installRequiredPlugins(log, _exec);
|
|
99
107
|
|
|
100
|
-
log('Setting up CLAUDE.md...');
|
|
101
108
|
const claudeMdSrc = join(FRAMEWORK_DIR, 'CLAUDE.md');
|
|
102
|
-
|
|
103
|
-
log(` ✓ Root CLAUDE.md: ${importResult}`);
|
|
109
|
+
if ((await removeMorphImport(join(targetPath, 'CLAUDE.md'))).startsWith('removed')) log(' ✓ CLAUDE.md da raiz sem o import antigo: o Claude Code carrega .claude/CLAUDE.md sozinho');
|
|
104
110
|
|
|
105
111
|
log('Creating .morph structure...');
|
|
106
112
|
const morphPath = join(targetPath, '.morph');
|
|
@@ -113,37 +119,20 @@ export async function setupInfra(targetPath, {
|
|
|
113
119
|
const configPath = join(configDir, 'config.json');
|
|
114
120
|
if (!(await pathExists(configPath))) {
|
|
115
121
|
await writeJson(configPath, {
|
|
122
|
+
$schema: CONFIG_SCHEMA_REF,
|
|
116
123
|
frameworkVersion: getInstalledCLIVersion(),
|
|
117
124
|
project: { name: basename(resolve(targetPath)) },
|
|
118
125
|
});
|
|
119
126
|
}
|
|
120
127
|
|
|
121
|
-
|
|
122
|
-
// before `.morph/.morphversion` is rewritten below.
|
|
123
|
-
const legacyTemplatesDir = join(frameworkDestDir, 'templates');
|
|
124
|
-
if (await pathExists(legacyTemplatesDir)) {
|
|
125
|
-
const priorVersionInfo = await getProjectMorphVersion(targetPath);
|
|
126
|
-
if (priorVersionInfo) {
|
|
127
|
-
const result = reconcileLegacyTemplatesCopy(legacyTemplatesDir, priorVersionInfo.morphVersion);
|
|
128
|
-
if (result === 'removed-legacy') {
|
|
129
|
-
log(' ✓ .morph/framework/templates/ (cópia legada de instalação antiga removida — resolvida do pacote)');
|
|
130
|
-
} else {
|
|
131
|
-
log(' ⚠ .morph/framework/templates/ (override local presente — preservado, não reconciliado)');
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
log(' ⚠ .morph/framework/templates/ existe (instalação antiga) e tem precedência sobre os templates do pacote — sem versão anterior registrada em .morph/.morphversion para decidir com segurança; rode `morph-spec update` para reconciliar, ou apague se não for customização sua.');
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
log('Copying standards, hooks, review checklist, schemas, agents.json, MORPH.md and CLI.md...');
|
|
128
|
+
log('Copying standards, hooks, review checklist, schemas, agents.json, ai-pin.json, MORPH.md and CLI.md...');
|
|
139
129
|
for (const dir of ['standards', 'hooks', 'evals', 'schemas']) {
|
|
140
|
-
await copyDirectory(join(FRAMEWORK_DIR, dir), join(frameworkDestDir, dir));
|
|
130
|
+
await copyDirectory(join(FRAMEWORK_DIR, dir), join(frameworkDestDir, dir), dir === 'hooks' ? { filter: hooksPayloadFilter } : {});
|
|
141
131
|
}
|
|
142
|
-
await copyFile(join(FRAMEWORK_DIR,
|
|
143
|
-
await copyFile(join(FRAMEWORK_DIR, 'MORPH.md'), join(frameworkDestDir, 'MORPH.md'));
|
|
132
|
+
for (const file of ['agents.json', 'ai-pin.json', 'MORPH.md']) await copyFile(join(FRAMEWORK_DIR, file), join(frameworkDestDir, file));
|
|
144
133
|
await copyFile(join(FRAMEWORK_DIR, 'docs', 'CLI.md'), join(frameworkDestDir, 'CLI.md'));
|
|
145
134
|
|
|
146
|
-
const { agentCounts, projectTags } = await installStackAwareAssets(targetPath, log);
|
|
135
|
+
const { agentCounts, projectTags } = await installStackAwareAssets(targetPath, log, { full: true });
|
|
147
136
|
|
|
148
137
|
log('Installing .claude/CLAUDE.md...');
|
|
149
138
|
const runtimeClaudeMdDest = join(targetPath, '.claude', 'CLAUDE.md');
|
|
@@ -194,7 +183,7 @@ export async function setupInfra(targetPath, {
|
|
|
194
183
|
if (installed === GRAPHIFY_VERSION) {
|
|
195
184
|
log(` ✓ graphify ${installed} já instalado`);
|
|
196
185
|
} else {
|
|
197
|
-
const
|
|
186
|
+
const kind = toolInstallOff() ? null : (_detectInstaller ?? detectInstaller)().kind;
|
|
198
187
|
if (toolInstallOff()) {
|
|
199
188
|
log(` ○ graphify não instalado (MORPH_NO_TOOL_INSTALL=1). Depois: uv tool install ${GRAPHIFY_PACKAGE}==${GRAPHIFY_VERSION}`);
|
|
200
189
|
} else if (!kind) {
|
|
@@ -2,6 +2,7 @@ import { readFileSync, existsSync, readdirSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import { shouldInstall } from '../lib/stack-filter.js';
|
|
4
4
|
import { realEffects } from '../lib/installers/effects.js';
|
|
5
|
+
import { pruneOwned } from '../lib/installers/install-manifest.js';
|
|
5
6
|
import { REVIEW_ROLES, VERDICT_TOKEN, REVIEWED_SHA_TOKEN, VERDICTS } from '../lib/review-reports.js';
|
|
6
7
|
|
|
7
8
|
const DEFAULT_AGENT_TOOLS = 'Read, Glob, Grep, Bash';
|
|
@@ -94,10 +95,9 @@ const MANAGED_HEADER =
|
|
|
94
95
|
' Do NOT edit by hand: changes are overwritten on `morph-spec update` / `setup-infra --reinstall`.\n' +
|
|
95
96
|
' Drift is flagged by `morph-spec doctor`. -->';
|
|
96
97
|
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
/** `previous`: the agents the manifest records. `prune: false` when the caller already emptied `.claude/agents/`. */
|
|
99
99
|
export async function installAgents(projectDir, frameworkDir = 'framework', options = {}) {
|
|
100
|
-
const { projectTags = [], fx = realEffects() } = options;
|
|
100
|
+
const { projectTags = [], fx = realEffects(), previous = [], prune = true } = options;
|
|
101
101
|
|
|
102
102
|
const agentsJsonPath = join(frameworkDir, 'agents.json');
|
|
103
103
|
const agentsJson = JSON.parse(readFileSync(agentsJsonPath, 'utf-8'));
|
|
@@ -120,10 +120,9 @@ export async function installAgents(projectDir, frameworkDir = 'framework', opti
|
|
|
120
120
|
|
|
121
121
|
const eligible = agents.filter(a => agentEligible(a, projectTags));
|
|
122
122
|
|
|
123
|
-
const
|
|
123
|
+
const shipped = agents.map(a => `morph-${a.id}.md`);
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
const installedFilenames = new Set();
|
|
125
|
+
const names = [];
|
|
127
126
|
const installedAgents = [];
|
|
128
127
|
|
|
129
128
|
for (const agent of eligible) {
|
|
@@ -131,36 +130,19 @@ export async function installAgents(projectDir, frameworkDir = 'framework', opti
|
|
|
131
130
|
const targetPath = join(targetDir, filename);
|
|
132
131
|
|
|
133
132
|
fx.writeFile(targetPath, renderAgentMd(agent, knownMcpIds));
|
|
134
|
-
|
|
133
|
+
names.push(filename);
|
|
135
134
|
installedAgents.push({
|
|
136
135
|
id: agent.id,
|
|
137
136
|
name: `morph-${agent.id}`,
|
|
138
137
|
title: agent.title ?? agent.id,
|
|
139
138
|
domains: agent.domains ?? [],
|
|
140
139
|
});
|
|
141
|
-
installed++;
|
|
142
140
|
}
|
|
143
141
|
|
|
144
|
-
//
|
|
145
|
-
if (
|
|
146
|
-
for (const file of readdirSync(targetDir)) {
|
|
147
|
-
if (installedFilenames.has(file)) continue;
|
|
148
|
-
const path = join(targetDir, file);
|
|
149
|
-
if (allPossible.has(file) || isManagedOrphan(file, path)) fx.remove(path);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
142
|
+
// A persona dropped from agents.json is in `previous` (the manifest); a hand-written morph-*.md is in neither list.
|
|
143
|
+
if (prune) pruneOwned(targetDir, { previous, shipped, installed: names, fx });
|
|
152
144
|
|
|
153
|
-
return { installed, agents: installedAgents };
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Only the managed header proves the file is ours: a hand-written morph-*.md is never deleted.
|
|
157
|
-
function isManagedOrphan(file, path) {
|
|
158
|
-
if (!file.startsWith('morph-') || !file.endsWith('.md')) return false;
|
|
159
|
-
try {
|
|
160
|
-
return readFileSync(path, 'utf-8').includes(MANAGED_HEADER_MARKER);
|
|
161
|
-
} catch {
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
145
|
+
return { installed: names.length, names, agents: installedAgents };
|
|
164
146
|
}
|
|
165
147
|
|
|
166
148
|
// Deterministic: the doctor drift check compares files byte-for-byte against this output.
|
|
@@ -210,12 +192,13 @@ export const REVIEW_REPORT_CONTRACT = [
|
|
|
210
192
|
'## Relatório da revisão',
|
|
211
193
|
'',
|
|
212
194
|
'Grave o relatório que o dispatch nomeia antes de encerrar — o arquivo é o retorno, não a mensagem final. ' +
|
|
213
|
-
'Se ele já existir quando você começar
|
|
214
|
-
'
|
|
195
|
+
'Se ele já existir quando você começar e o dispatch não trouxer `confirma:`, é resíduo de outra revisão: não o leia antes de escrever o seu (ancoragem no veredito alheio). ' +
|
|
196
|
+
'Com `confirma: <sha>` o arquivo é o seu relatório: leia-o e acrescente `## Confirmação` ao fim, sem reescrever o que está acima. ' +
|
|
197
|
+
'Nunca leia os relatórios dos outros papéis.',
|
|
215
198
|
'',
|
|
216
199
|
`Primeira linha \`${VERDICT_TOKEN} ${VERDICTS.join('|')}\`, depois \`${REVIEWED_SHA_TOKEN} {sha}\`, ` +
|
|
217
200
|
'tabela `## Bloqueadores` (`| id | tipo | onde | evidência |`; vazia = `Nenhum.`) e `## Notas`. ' +
|
|
218
|
-
'Bloqueador só com evidência e tipo; o resto é nota,
|
|
201
|
+
'Bloqueador só com evidência e tipo; o resto é nota, com `arquivo:linha` e o que mudar.',
|
|
219
202
|
];
|
|
220
203
|
|
|
221
204
|
function buildBody(agent, maxTurns) {
|
|
@@ -2,58 +2,24 @@ import { pathExists, readFile } from './file-copier.js';
|
|
|
2
2
|
import { realEffects } from '../lib/installers/effects.js';
|
|
3
3
|
|
|
4
4
|
const MORPH_IMPORT = '@.claude/CLAUDE.md';
|
|
5
|
-
const
|
|
5
|
+
const CREATED_BY_MORPH = `# Project\n\n${MORPH_IMPORT}`;
|
|
6
|
+
const INJECTED_BLOCK = /\n*## MORPH-SPEC\s*\n+@\.claude\/CLAUDE\.md[ \t]*\n?/;
|
|
7
|
+
const IMPORT_LINE = /^@\.claude\/CLAUDE\.md[ \t]*\r?\n?/m;
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
+
* Claude Code loads `.claude/CLAUDE.md` by itself, so the import older versions wrote into the root
|
|
11
|
+
* CLAUDE.md is removed; a root file that held nothing else was created by morph-spec and goes too.
|
|
12
|
+
* @returns {Promise<'absent'|'clean'|'removed-file'|'removed-import'>}
|
|
10
13
|
*/
|
|
11
|
-
export async function
|
|
12
|
-
if (!await pathExists(claudeMdPath))
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
export async function removeMorphImport(claudeMdPath, fx = realEffects()) {
|
|
15
|
+
if (!await pathExists(claudeMdPath)) return 'absent';
|
|
16
|
+
const content = (await readFile(claudeMdPath)).replace(/\r\n/g, '\n');
|
|
17
|
+
if (!content.includes(MORPH_IMPORT)) return 'clean';
|
|
18
|
+
if (content.trim() === CREATED_BY_MORPH) {
|
|
19
|
+
fx.remove(claudeMdPath);
|
|
20
|
+
return 'removed-file';
|
|
15
21
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (content.includes(MORPH_IMPORT)) {
|
|
20
|
-
return 'already-present';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (isMorphOnly(content)) {
|
|
24
|
-
fx.writeFile(claudeMdPath, `# Project\n\n${MORPH_IMPORT}\n`);
|
|
25
|
-
return 'migrated';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const separator = content.endsWith('\n') ? '\n' : '\n\n';
|
|
29
|
-
fx.writeFile(claudeMdPath, `${content}${separator}## MORPH-SPEC\n\n${MORPH_IMPORT}\n`);
|
|
30
|
-
return 'injected';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function isMorphOnly(content) {
|
|
34
|
-
if (!content.includes(MORPH_MARKER)) return false;
|
|
35
|
-
|
|
36
|
-
const stripped = content
|
|
37
|
-
.replace(/# MORPH-SPEC Runtime Instructions/g, '')
|
|
38
|
-
.replace(/by Polymorphism Tech[^\n]*/g, '')
|
|
39
|
-
.replace(/\*MORPH-SPEC by Polymorphism Tech\*/g, '')
|
|
40
|
-
.replace(/@\.morph\/context\/README\.md/g, '')
|
|
41
|
-
.replace(/@\.claude\/CLAUDE\.md/g, '')
|
|
42
|
-
.replace(/## Critical Rules[\s\S]*?(?=##|$)/g, '')
|
|
43
|
-
.replace(/## Quick Reference[\s\S]*?(?=##|$)/g, '')
|
|
44
|
-
.replace(/## State & Outputs[\s\S]*?(?=##|$)/g, '')
|
|
45
|
-
.replace(/## Phase Sequence[\s\S]*?(?=##|$)/g, '')
|
|
46
|
-
.replace(/## Agents[\s\S]*?(?=##|$)/g, '')
|
|
47
|
-
.replace(/## Context Window Tip[\s\S]*?(?=##|$)/g, '')
|
|
48
|
-
.replace(/## Project Context[\s\S]*?(?=##|$)/g, '')
|
|
49
|
-
.replace(/[#\-|>*`\s]/g, '');
|
|
50
|
-
|
|
51
|
-
return stripped.length < 50;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export async function checkClaudeMdImport(claudeMdPath) {
|
|
55
|
-
if (!await pathExists(claudeMdPath)) return 'missing';
|
|
56
|
-
const content = await readFile(claudeMdPath);
|
|
57
|
-
if (content.includes(MORPH_IMPORT)) return 'ok';
|
|
58
|
-
return 'missing-import';
|
|
22
|
+
const stripped = INJECTED_BLOCK.test(content) ? content.replace(INJECTED_BLOCK, '\n') : content.replace(IMPORT_LINE, '');
|
|
23
|
+
fx.writeFile(claudeMdPath, `${stripped.trimEnd()}\n`);
|
|
24
|
+
return 'removed-import';
|
|
59
25
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
2
|
import { readFile, writeFile, mkdir, copyFile, unlink } from 'fs/promises';
|
|
3
3
|
import { existsSync } from 'fs';
|
|
4
|
-
import { MORPH_ALLOW,
|
|
4
|
+
import { MORPH_ALLOW, managedDeny } from './hooks-installer.js';
|
|
5
5
|
|
|
6
6
|
const MORPH_MANAGED_KEY = '_morph_managed';
|
|
7
7
|
|
|
@@ -28,7 +28,7 @@ export async function resetMorphSettings(targetPath) {
|
|
|
28
28
|
const backupPath = settingsPath + '.backup';
|
|
29
29
|
await copyFile(settingsPath, backupPath);
|
|
30
30
|
|
|
31
|
-
const footprint = { deny:
|
|
31
|
+
const footprint = { deny: managedDeny(settings), allow: MORPH_ALLOW, envKeys: LEGACY_ENV_KEYS };
|
|
32
32
|
const permissionsRemoved = [];
|
|
33
33
|
const envRemoved = [];
|
|
34
34
|
|
package/src/utils/file-copier.js
CHANGED
|
@@ -4,6 +4,7 @@ import { join, dirname, resolve } from 'path';
|
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import { WORKTREE_DIR_NAMES } from '../lib/scan/worktree-dirs.js';
|
|
6
6
|
import { realEffects } from '../lib/installers/effects.js';
|
|
7
|
+
import { stripBom } from '../lib/json-file.js';
|
|
7
8
|
|
|
8
9
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
10
|
const frameworkRoot = join(__dirname, '..', '..');
|
|
@@ -40,9 +41,7 @@ export async function pathExists(path) {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
export async function readJson(path) {
|
|
43
|
-
|
|
44
|
-
const raw = await fs.readFile(path, 'utf-8');
|
|
45
|
-
return JSON.parse(raw.replace(/^/, ''));
|
|
44
|
+
return JSON.parse(stripBom(await fs.readFile(path, 'utf-8')));
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
export async function writeJson(path, data) {
|
|
@@ -63,7 +62,7 @@ export async function readFile(path) {
|
|
|
63
62
|
return fs.readFile(path, 'utf8');
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
const MORPH_GITIGNORE_ENTRIES = [
|
|
67
66
|
'.morph/framework/',
|
|
68
67
|
'.morph/memory/',
|
|
69
68
|
'.morph/plans/',
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
2
|
import { readFile } from 'fs/promises';
|
|
3
|
-
import { existsSync } from 'fs';
|
|
3
|
+
import { existsSync, readFileSync } from 'fs';
|
|
4
4
|
import { homedir } from 'os';
|
|
5
5
|
import { realEffects } from '../lib/installers/effects.js';
|
|
6
|
+
import { readManifest } from '../lib/installers/install-manifest.js';
|
|
6
7
|
import { SHELL_TOOLS } from '../../framework/hooks/shared/payload-utils.js';
|
|
7
8
|
|
|
8
|
-
const HOOKS_VERSION = '4.1.0';
|
|
9
|
+
export const HOOKS_VERSION = '4.1.0';
|
|
9
10
|
|
|
10
11
|
const SHELL_MATCHER = [...SHELL_TOOLS].join('|');
|
|
11
12
|
|
|
@@ -14,11 +15,58 @@ const SHELL_MATCHER = [...SHELL_TOOLS].join('|');
|
|
|
14
15
|
export const MORPH_DENY = [
|
|
15
16
|
'Edit(.morph/framework/**)',
|
|
16
17
|
'Edit(.claude/CLAUDE.md)',
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
// Whole folders, as written before the manifest: they left the project no rule, skill or `morph-*` agent of its own.
|
|
21
|
+
const LEGACY_DENY = [
|
|
17
22
|
'Edit(.claude/rules/**)',
|
|
18
23
|
'Edit(.claude/agents/morph-*)',
|
|
19
24
|
'Edit(.claude/skills/**)',
|
|
20
25
|
];
|
|
21
26
|
|
|
27
|
+
/** One entry per rule, agent and skill the manifest records; commands stay editable, as they always were. */
|
|
28
|
+
export function assetDeny(manifest) {
|
|
29
|
+
if (!manifest) return [];
|
|
30
|
+
return [
|
|
31
|
+
...manifest.rules.map((file) => `Edit(.claude/rules/${file})`),
|
|
32
|
+
...manifest.agents.map((file) => `Edit(.claude/agents/${file})`),
|
|
33
|
+
...manifest.skills.map((name) => `Edit(.claude/skills/${name}/**)`),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Every deny entry morph-spec may have written into this settings object: the list it recorded, the fixed ones and the legacy ones. */
|
|
38
|
+
export function managedDeny(settings) {
|
|
39
|
+
const recorded = settings?._morph_managed?.deny;
|
|
40
|
+
return [...new Set([...MORPH_DENY, ...LEGACY_DENY, ...(Array.isArray(recorded) ? recorded : [])])];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function applyManagedDeny(settings, manifest) {
|
|
44
|
+
const wanted = [...MORPH_DENY, ...assetDeny(manifest)];
|
|
45
|
+
const ours = new Set([...managedDeny(settings), ...wanted]);
|
|
46
|
+
const current = Array.isArray(settings.permissions?.deny) ? settings.permissions.deny : [];
|
|
47
|
+
settings.permissions = settings.permissions || {};
|
|
48
|
+
settings.permissions.deny = [...current.filter((p) => !ours.has(p)), ...wanted];
|
|
49
|
+
settings._morph_managed = settings._morph_managed || {};
|
|
50
|
+
settings._morph_managed.deny = wanted;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* For a path that changes the installed assets without reinstalling the hooks. A settings file
|
|
55
|
+
* the installer never wrote, or a project with no manifest, is left as it is.
|
|
56
|
+
*/
|
|
57
|
+
export function syncAssetDeny(targetPath, { fx = realEffects(), manifest = readManifest(targetPath) } = {}) {
|
|
58
|
+
const settingsPath = join(targetPath, '.claude', 'settings.local.json');
|
|
59
|
+
if (!manifest || !existsSync(settingsPath)) return false;
|
|
60
|
+
let settings;
|
|
61
|
+
try { settings = JSON.parse(readFileSync(settingsPath, 'utf-8')); } catch { return false; }
|
|
62
|
+
if (!settings?._morph_managed) return false;
|
|
63
|
+
const before = JSON.stringify([settings.permissions?.deny, settings._morph_managed.deny]);
|
|
64
|
+
applyManagedDeny(settings, manifest);
|
|
65
|
+
if (JSON.stringify([settings.permissions.deny, settings._morph_managed.deny]) === before) return false;
|
|
66
|
+
fx.writeFile(settingsPath, JSON.stringify(settings, null, 2) + '\n');
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
22
70
|
export const MORPH_ALLOW = [
|
|
23
71
|
'Edit(.morph/features/**)',
|
|
24
72
|
'Edit(.morph/context/**)',
|
|
@@ -29,7 +77,7 @@ export const MORPH_ALLOW = [
|
|
|
29
77
|
// A multi-hook group is ONE `core/chain.js` command whose `args` list the hooks in
|
|
30
78
|
// run order (block-first-wins). `args` stays separate from `command`: getHookSubpath()
|
|
31
79
|
// would capture inlined args into the quoted path. `timeout` is in SECONDS.
|
|
32
|
-
const MORPH_HOOKS = [
|
|
80
|
+
export const MORPH_HOOKS = [
|
|
33
81
|
{
|
|
34
82
|
event: 'PreToolUse',
|
|
35
83
|
matcher: 'Write|Edit',
|
|
@@ -81,10 +129,11 @@ const MORPH_HOOKS = [
|
|
|
81
129
|
];
|
|
82
130
|
|
|
83
131
|
/**
|
|
84
|
-
* Idempotent merge of the MORPH-SPEC hooks into `.claude/settings.local.json`.
|
|
132
|
+
* Idempotent merge of the MORPH-SPEC hooks into `.claude/settings.local.json`. Runs AFTER the assets:
|
|
133
|
+
* the deny is one entry per asset of the manifest (`manifest` in memory on `--dry-run`, which writes none).
|
|
85
134
|
* @returns {Promise<{ installed: number }>}
|
|
86
135
|
*/
|
|
87
|
-
export async function installClaudeHooks(targetPath, { fx = realEffects() } = {}) {
|
|
136
|
+
export async function installClaudeHooks(targetPath, { fx = realEffects(), manifest = readManifest(targetPath) } = {}) {
|
|
88
137
|
const claudeDir = join(targetPath, '.claude');
|
|
89
138
|
const settingsPath = join(claudeDir, 'settings.local.json');
|
|
90
139
|
|
|
@@ -127,15 +176,9 @@ export async function installClaudeHooks(targetPath, { fx = realEffects() } = {}
|
|
|
127
176
|
installed++;
|
|
128
177
|
}
|
|
129
178
|
|
|
130
|
-
settings
|
|
131
|
-
settings.permissions.deny = settings.permissions.deny || [];
|
|
179
|
+
applyManagedDeny(settings, manifest);
|
|
132
180
|
settings.permissions.allow = settings.permissions.allow || [];
|
|
133
181
|
|
|
134
|
-
settings.permissions.deny = settings.permissions.deny.filter(p => !MORPH_DENY.includes(p));
|
|
135
|
-
for (const perm of MORPH_DENY) {
|
|
136
|
-
settings.permissions.deny.push(perm);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
182
|
// An entry that left MORPH_ALLOW would survive forever in an existing install unless named here.
|
|
140
183
|
const STALE_ALLOW = ['Edit(.morph/state.json)'];
|
|
141
184
|
settings.permissions.allow = settings.permissions.allow.filter(
|
|
@@ -239,11 +282,3 @@ function getHookSubpath(command) {
|
|
|
239
282
|
const match = command.match(/claude-code\/(.+)$/);
|
|
240
283
|
return match ? match[1] : command;
|
|
241
284
|
}
|
|
242
|
-
|
|
243
|
-
export function getHooksVersion() {
|
|
244
|
-
return HOOKS_VERSION;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export function getHookDefinitions() {
|
|
248
|
-
return MORPH_HOOKS;
|
|
249
|
-
}
|