@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
|
@@ -15,14 +15,14 @@ const INDEX_LABEL = '.morph/specs/adrs/';
|
|
|
15
15
|
const INDEX_FILE_RE = /^([a-z0-9][a-z0-9-]*)--(ADR-\d+)\.md$/;
|
|
16
16
|
|
|
17
17
|
/** `admin/ADR-001` ↔ `admin--ADR-001.md`. */
|
|
18
|
-
|
|
18
|
+
const adrFileName = (ref) => `${ref.replace('/', '--')}.md`;
|
|
19
19
|
const refOf = (name) => {
|
|
20
20
|
const m = INDEX_FILE_RE.exec(name);
|
|
21
21
|
return m ? `${m[1]}/${m[2]}` : null;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
function renderAdrFile({ ref, title, body }, feature) {
|
|
25
|
-
const source = `.morph/
|
|
25
|
+
const source = `.morph/features/${feature}/${PLAN.phaseDir}/${PLAN.filename}`;
|
|
26
26
|
return [
|
|
27
27
|
'---',
|
|
28
28
|
`adr: ${ref}`,
|
|
@@ -32,7 +32,7 @@ function renderAdrFile({ ref, title, body }, feature) {
|
|
|
32
32
|
'',
|
|
33
33
|
`# ${ref}: ${title}`,
|
|
34
34
|
'',
|
|
35
|
-
'> Mantido pelo `morph-spec
|
|
35
|
+
'> Mantido pelo `morph-spec plan-check` — não edite à mão. Vale no projeto até que o `plan.md` de uma',
|
|
36
36
|
'> feature o revogue em `### Conflitos com o acervo`: por inteiro, e este arquivo sai; em parte, e `scope:` diz onde ele ainda vale.',
|
|
37
37
|
'',
|
|
38
38
|
body,
|
|
@@ -115,7 +115,7 @@ export function revocationWarnings(cwd, plan) {
|
|
|
115
115
|
const indexed = new Set(readAdrIndex(cwd).map((a) => a.ref));
|
|
116
116
|
for (const e of entries) {
|
|
117
117
|
if (!indexed.has(e.id)) {
|
|
118
|
-
warnings.push(`### Conflitos com o acervo: ${e.id} não está no índice de ADRs ativos (${INDEX_LABEL}) —
|
|
118
|
+
warnings.push(`### Conflitos com o acervo: ${e.id} não está no índice de ADRs ativos (${INDEX_LABEL}) — não há o que retirar`);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
return warnings;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// plan-check reports the problems while the plan can still change, so nothing ambiguous reaches the
|
|
1
|
+
// plan-check reports the problems while the plan can still change, so nothing ambiguous reaches the ADR index.
|
|
2
2
|
|
|
3
3
|
import { SEPARATOR_ROW_RE, isTableLine, tableCells } from './gfm-table.js';
|
|
4
4
|
|
|
5
5
|
/** ADR numbers restart in every feature, so only `{feature}/ADR-{nnn}` is unambiguous. */
|
|
6
|
-
|
|
6
|
+
const ADR_REF_RE = /^[a-z0-9][a-z0-9-]*\/ADR-\d+$/;
|
|
7
7
|
|
|
8
8
|
const FENCE_RE = /^\s*(```|~~~)/;
|
|
9
9
|
const REF_TOKEN_RE = /\b[a-z0-9][a-z0-9-]*\/ADR-\d+\b/;
|
|
@@ -55,7 +55,7 @@ export function parseRevocations(conflicts) {
|
|
|
55
55
|
const stray = LIST_ITEM_RE.test(line) ? REF_TOKEN_RE.exec(line) : null;
|
|
56
56
|
if (stray) {
|
|
57
57
|
problems.push({ id: stray[0], reason: 'outside-table',
|
|
58
|
-
message: `${stray[0]} aparece fora da tabela ADR | Mudança | Escopo — só as linhas da tabela são aplicadas
|
|
58
|
+
message: `${stray[0]} aparece fora da tabela ADR | Mudança | Escopo — só as linhas da tabela são aplicadas` });
|
|
59
59
|
}
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
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
|
|
|
8
8
|
export const SEVERITIES = ['Bloqueante', 'Alto', 'Médio', 'Baixo'];
|
|
9
|
-
|
|
9
|
+
const MAX_FILES = 20000;
|
|
10
10
|
|
|
11
11
|
const SKIP_DIRS = new Set([
|
|
12
12
|
'node_modules', '.git', 'bin', 'obj', 'dist', 'build', 'out', 'coverage', '.next', '.morph', '.claude', '.vs', '.idea',
|
|
@@ -192,7 +192,7 @@ function auditNextjs(root, read) {
|
|
|
192
192
|
add('Médio', 'ESLint do stack ausente (o lint não barra import proibido nem fetch em `useEffect`)', eslintConfig ? [eslintConfig] : [],
|
|
193
193
|
'`eslint.config.mjs` na raiz do app: `morph-spec standards --show frontend-nextjs-lint#files`');
|
|
194
194
|
} else if (shadcn && !/forbid-elements/.test(read(eslintConfig) ?? '')) {
|
|
195
|
-
add('Baixo', 'ESLint sem `react/forbid-elements` (
|
|
195
|
+
add('Baixo', 'ESLint sem `react/forbid-elements` (elemento cru passa sem aviso no editor)', [eslintConfig],
|
|
196
196
|
'copiar `RAW_ELEMENTS` e o bloco da regra: `morph-spec standards --show frontend-nextjs-lint#files`');
|
|
197
197
|
}
|
|
198
198
|
if (shadcn) {
|
|
@@ -251,7 +251,7 @@ function whereText(where) {
|
|
|
251
251
|
return ` — onde: ${shown}${unique.length > WHERE_LIMIT ? ` (+${unique.length - WHERE_LIMIT})` : ''} (${unique.length} arquivo(s))`;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
function notAuditedReason(result) {
|
|
255
255
|
return result.stack
|
|
256
256
|
? `não auditado: nenhuma regra de varredura para \`${result.stack}\``
|
|
257
257
|
: 'não auditado: project.stack ausente em .morph/config/config.json';
|
|
@@ -5,7 +5,7 @@ export const STANDARDS_FILE = 'STANDARDS.json';
|
|
|
5
5
|
export const STANDARDS_META_FILE = 'STANDARDS.meta.json';
|
|
6
6
|
|
|
7
7
|
/** Per-standard fields that live in the sidecar, keyed by id: no runtime reader needs them to pick a standard. */
|
|
8
|
-
|
|
8
|
+
const META_FIELDS = ['aliases', 'verifiedAgainst', 'provedBy'];
|
|
9
9
|
|
|
10
10
|
export function metaPathFor(standardsJsonPath) {
|
|
11
11
|
return join(dirname(standardsJsonPath), STANDARDS_META_FILE);
|
|
@@ -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.
|
|
@@ -33,11 +33,11 @@ export function parseVerifiedAgainst(text) {
|
|
|
33
33
|
|
|
34
34
|
// Three real typesettings: backtick before the clause, after it, or the clause in
|
|
35
35
|
// bold mid-sentence. The non-letter prefix keeps `aprovado por` out.
|
|
36
|
-
|
|
36
|
+
const PROVED_BY_TRIGGER_RE = /(?:^|[^a-zA-Z])provado por/gi;
|
|
37
37
|
|
|
38
38
|
// A path needs a `/` and a closing backtick, so denials ("sem cláusula `provado por`")
|
|
39
39
|
// derive nothing. `*`/`_` are separators for the bold form. Anchored: prose ends the scan.
|
|
40
|
-
|
|
40
|
+
const PROVED_BY_PATH_RE =
|
|
41
41
|
/^[\s`,;*_]*(?:\be\b[\s`,;*_]*)?([A-Za-z0-9_.][A-Za-z0-9_.\-]*(?:\/[A-Za-z0-9_.\-]*)+)`/;
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -2,9 +2,10 @@ 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
|
-
|
|
7
|
+
const PROSE_MIN_HITS = 3;
|
|
8
|
+
const FAMILY_MIN_SIZE = 4;
|
|
8
9
|
|
|
9
10
|
const TEST_FILE = /\.(cs|[cm]?[jt]sx?)$/i;
|
|
10
11
|
const CS_CASE = /\[\s*\w*(Fact|Theory)\b/g;
|
|
@@ -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;
|
|
@@ -1,16 +1,46 @@
|
|
|
1
|
-
import { join, dirname } from 'path';
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
1
|
+
import { join, dirname, resolve } from 'path';
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
3
3
|
import { homedir, platform } from 'os';
|
|
4
|
-
import {
|
|
4
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
5
5
|
import { existsSync } from 'fs';
|
|
6
6
|
import { execSync } from 'child_process';
|
|
7
7
|
import { installGlobalStatusline } from '../utils/hooks-installer.js';
|
|
8
8
|
|
|
9
9
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
const
|
|
10
|
+
const PACKAGE_ROOT = join(__dirname, '..', '..');
|
|
11
|
+
const FRAMEWORK_DIR = join(PACKAGE_ROOT, 'framework');
|
|
12
|
+
const PATH_MARKER = '# morph-spec: ensure npm global in PATH';
|
|
13
|
+
const PATH_END = '# end morph-spec PATH';
|
|
14
|
+
|
|
15
|
+
// `npm install` inside this repo (INIT_CWD is the package itself) or on CI is not a user install.
|
|
16
|
+
export function isDevOrCiInstall(env = process.env, packageRoot = PACKAGE_ROOT) {
|
|
17
|
+
if (env.CI) return true;
|
|
18
|
+
if (!env.INIT_CWD) return false;
|
|
19
|
+
const same = (a, b) => (platform() === 'win32' ? a.toLowerCase() === b.toLowerCase() : a === b);
|
|
20
|
+
return same(resolve(env.INIT_CWD), resolve(packageRoot));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function pathSnippet(npmGlobalDir) {
|
|
24
|
+
return [
|
|
25
|
+
PATH_MARKER,
|
|
26
|
+
`if ($env:PATH -notlike "*${npmGlobalDir}*") {`,
|
|
27
|
+
` $env:PATH += ";${npmGlobalDir}"`,
|
|
28
|
+
'}',
|
|
29
|
+
PATH_END,
|
|
30
|
+
].join('\n');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// A block from an older install is replaced in place: its guard never matched and it grew PATH on every shell.
|
|
34
|
+
export function withPathSnippet(content, snippet) {
|
|
35
|
+
const start = content.indexOf(PATH_MARKER);
|
|
36
|
+
if (start < 0) return content ? `${content}\n\n${snippet}\n` : `${snippet}\n`;
|
|
37
|
+
const end = content.indexOf(PATH_END, start);
|
|
38
|
+
if (end < 0) return content;
|
|
39
|
+
return content.slice(0, start) + snippet + content.slice(end + PATH_END.length);
|
|
40
|
+
}
|
|
11
41
|
|
|
12
42
|
/** Windows only: adds the npm global bin to the PowerShell $PROFILE so new terminals find `morph-spec`. */
|
|
13
|
-
|
|
43
|
+
async function ensureNpmGlobalInPath() {
|
|
14
44
|
if (platform() !== 'win32') return;
|
|
15
45
|
|
|
16
46
|
let npmGlobalDir;
|
|
@@ -25,33 +55,25 @@ export async function ensureNpmGlobalInPath() {
|
|
|
25
55
|
const psProfile = join(homedir(), 'Documents', 'PowerShell', 'Microsoft.PowerShell_profile.ps1');
|
|
26
56
|
const psProfileLegacy = join(homedir(), 'Documents', 'WindowsPowerShell', 'Microsoft.PowerShell_profile.ps1');
|
|
27
57
|
|
|
28
|
-
const
|
|
29
|
-
const snippet = [
|
|
30
|
-
marker,
|
|
31
|
-
`if ($env:PATH -notlike "*${npmGlobalDir.replace(/\\/g, '\\\\')}*") {`,
|
|
32
|
-
` $env:PATH += ";${npmGlobalDir}"`,
|
|
33
|
-
'}',
|
|
34
|
-
'# end morph-spec PATH',
|
|
35
|
-
].join('\n');
|
|
58
|
+
const snippet = pathSnippet(npmGlobalDir);
|
|
36
59
|
|
|
37
60
|
for (const profilePath of [psProfile, psProfileLegacy]) {
|
|
38
61
|
try {
|
|
39
62
|
let content = '';
|
|
40
63
|
if (existsSync(profilePath)) {
|
|
41
64
|
content = await readFile(profilePath, 'utf8');
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
await mkdir(dirname(profilePath), { recursive: true });
|
|
65
|
+
} else if (!existsSync(dirname(profilePath))) {
|
|
66
|
+
continue;
|
|
45
67
|
}
|
|
46
|
-
const
|
|
47
|
-
await writeFile(profilePath,
|
|
68
|
+
const next = withPathSnippet(content, snippet);
|
|
69
|
+
if (next !== content) await writeFile(profilePath, next, 'utf8');
|
|
48
70
|
} catch {
|
|
49
71
|
// non-critical — skip silently
|
|
50
72
|
}
|
|
51
73
|
}
|
|
52
74
|
}
|
|
53
75
|
|
|
54
|
-
if (process.argv[1]
|
|
76
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href && !isDevOrCiInstall()) {
|
|
55
77
|
const HOOKS_SRC = join(FRAMEWORK_DIR, 'hooks', 'claude-code');
|
|
56
78
|
const { readFileSync } = await import('fs');
|
|
57
79
|
const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
|
|
@@ -1,35 +1,43 @@
|
|
|
1
|
-
import { basename, join,
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
1
|
+
import { basename, join, resolve } from 'path';
|
|
3
2
|
import { execSync } from 'child_process';
|
|
4
|
-
import { readFileSync
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
5
4
|
import {
|
|
6
5
|
copyDirectory,
|
|
7
6
|
copyFile,
|
|
8
7
|
pathExists,
|
|
9
8
|
writeJson,
|
|
10
9
|
ensureDir,
|
|
11
|
-
writeFile,
|
|
12
10
|
updateGitignore,
|
|
13
11
|
ensureGitattributes
|
|
14
12
|
} from '../utils/file-copier.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
13
|
+
import { getProjectTags } from '../lib/stack-filter.js';
|
|
14
|
+
import { readMorphConfig } from '../lib/config/project-config.js';
|
|
15
|
+
import { removeMorphImport } from '../utils/claude-md-injector.js';
|
|
17
16
|
import { saveProjectMorphVersion, getInstalledCLIVersion, getProjectMorphVersion } from '../utils/version-checker.js';
|
|
18
17
|
import { installClaudeHooks, installGlobalStatusline } from '../utils/claude-settings-manager.js';
|
|
19
|
-
import { installSkills } from '../utils/skills-installer.js';
|
|
20
|
-
import { installAgents } from '../utils/agents-installer.js';
|
|
21
|
-
import { reconcileLegacyTemplatesCopy } from '../lib/installers/templates-reconcile.js';
|
|
22
18
|
import { realEffects } from '../lib/installers/effects.js';
|
|
23
|
-
import {
|
|
19
|
+
import { installAssetsForTags, refreshAssetsForTags } from '../lib/installers/stack-assets.js';
|
|
24
20
|
|
|
25
|
-
const FRAMEWORK_DIR = join(
|
|
21
|
+
const FRAMEWORK_DIR = join(import.meta.dirname, '..', '..', 'framework');
|
|
26
22
|
|
|
27
23
|
const REQUIRED_PLUGINS = [
|
|
28
24
|
'context7@claude-plugins-official',
|
|
29
25
|
];
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
|
|
33
|
+
const toolInstallOff = () => process.env.MORPH_NO_TOOL_INSTALL === '1';
|
|
34
|
+
|
|
35
|
+
function installRequiredPlugins(log, exec) {
|
|
36
|
+
if (toolInstallOff()) {
|
|
37
|
+
log(`Plugins do Claude Code não instalados (MORPH_NO_TOOL_INSTALL=1): ${REQUIRED_PLUGINS.join(', ')}`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
log('Installing required Claude Code plugins...');
|
|
33
41
|
for (const plugin of REQUIRED_PLUGINS) {
|
|
34
42
|
try {
|
|
35
43
|
exec(`claude plugin install ${plugin}`, { stdio: 'inherit' });
|
|
@@ -40,59 +48,13 @@ async function installRequiredPlugins(log, exec) {
|
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const dest = join(commandsDest, file);
|
|
51
|
-
if (shouldInstall(parseStacks(readFileSync(join(commandsSrc, file), 'utf-8')), projectTags)) {
|
|
52
|
-
fx.copyFile(join(commandsSrc, file), dest);
|
|
53
|
-
installed++;
|
|
54
|
-
} else if (!fx.dryRun && existsSync(dest)) {
|
|
55
|
-
fx.remove(dest);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return { installed };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async function installStackAwareAssets(targetPath, log) {
|
|
62
|
-
const configPath = join(targetPath, '.morph', 'config', 'config.json');
|
|
63
|
-
let projectTags = [];
|
|
64
|
-
if (await pathExists(configPath)) {
|
|
65
|
-
try {
|
|
66
|
-
// BOM-tolerant: a config.json written by PS 5.1 Out-File carries a BOM, and a failed parse
|
|
67
|
-
// here silently installs only the universal personas.
|
|
68
|
-
const config = JSON.parse(readFileSync(configPath, 'utf-8').replace(/^/, ''));
|
|
69
|
-
projectTags = getProjectTags(config);
|
|
70
|
-
} catch { /* ignore malformed config */ }
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const claudeDest = join(targetPath, '.claude');
|
|
74
|
-
log('Installing stack-filtered commands...');
|
|
75
|
-
const commandsSrc = join(FRAMEWORK_DIR, 'commands');
|
|
76
|
-
const commandsDest = join(claudeDest, 'commands');
|
|
77
|
-
if (await pathExists(commandsSrc)) {
|
|
78
|
-
await ensureDir(commandsDest);
|
|
79
|
-
installCommandsForStack(commandsSrc, commandsDest, projectTags);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
log('Installing stack-filtered rules...');
|
|
83
|
-
const rulesSrc = join(FRAMEWORK_DIR, 'rules');
|
|
84
|
-
const rulesDest = join(claudeDest, 'rules');
|
|
85
|
-
if (await pathExists(rulesSrc)) {
|
|
86
|
-
await ensureDir(rulesDest);
|
|
87
|
-
installRulesForStack(rulesSrc, rulesDest, projectTags);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
log('Installing skills...');
|
|
91
|
-
await installSkills(targetPath, { projectTags });
|
|
92
|
-
|
|
93
|
-
log('Installing agents...');
|
|
94
|
-
const agentCounts = await installAgents(targetPath, FRAMEWORK_DIR, { projectTags });
|
|
95
|
-
|
|
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 }) {
|
|
53
|
+
const projectTags = getProjectTags(readMorphConfig(targetPath));
|
|
54
|
+
log('Installing stack-filtered rules, commands, skills and agents...');
|
|
55
|
+
const { agents: agentCounts } = full
|
|
56
|
+
? await installAssetsForTags(targetPath, projectTags, { frameworkSrc: FRAMEWORK_DIR, createManifest: true })
|
|
57
|
+
: await refreshAssetsForTags(targetPath, projectTags, { frameworkSrc: FRAMEWORK_DIR });
|
|
96
58
|
return { agentCounts, projectTags };
|
|
97
59
|
}
|
|
98
60
|
|
|
@@ -115,7 +77,7 @@ export async function updateClaudeMdAgentsBlock(claudeMdPath, agents = [], optio
|
|
|
115
77
|
const block = `${START}\n**Personas de revisão** (derivado de agents.json na última instalação):\n\n${list}\n${END}`;
|
|
116
78
|
const updated = content.replace(
|
|
117
79
|
new RegExp(`${START}[\\s\\S]*?${END}`),
|
|
118
|
-
block
|
|
80
|
+
() => block
|
|
119
81
|
);
|
|
120
82
|
fx.writeFile(claudeMdPath, updated);
|
|
121
83
|
}
|
|
@@ -124,7 +86,7 @@ export async function updateClaudeMdAgentsBlock(claudeMdPath, agents = [], optio
|
|
|
124
86
|
* Headless install: no prompts, no stack detection.
|
|
125
87
|
*/
|
|
126
88
|
export async function setupInfra(targetPath, {
|
|
127
|
-
_exec = execSync, _detectGraphifyVersion = null, _log = null, reinstall = false,
|
|
89
|
+
_exec = execSync, _detectGraphifyVersion = null, _detectInstaller = null, _log = null, reinstall = false,
|
|
128
90
|
} = {}) {
|
|
129
91
|
const quiet = process.env.MORPH_QUIET === '1';
|
|
130
92
|
|
|
@@ -135,149 +97,68 @@ export async function setupInfra(targetPath, {
|
|
|
135
97
|
|
|
136
98
|
if (reinstall) {
|
|
137
99
|
log('setup-infra (reinstall): re-installing stack-aware assets...');
|
|
138
|
-
const { agentCounts } = await installStackAwareAssets(targetPath, log);
|
|
100
|
+
const { agentCounts } = await installStackAwareAssets(targetPath, log, { full: false });
|
|
139
101
|
await updateClaudeMdAgentsBlock(join(targetPath, '.claude', 'CLAUDE.md'), agentCounts?.agents ?? []);
|
|
140
102
|
log('setup-infra (reinstall): complete.');
|
|
141
103
|
return { agents: { installed: agentCounts?.installed ?? 0 } };
|
|
142
104
|
}
|
|
143
105
|
|
|
144
|
-
|
|
106
|
+
installRequiredPlugins(log, _exec);
|
|
145
107
|
|
|
146
|
-
log('Step 1: Setting up CLAUDE.md...');
|
|
147
108
|
const claudeMdSrc = join(FRAMEWORK_DIR, 'CLAUDE.md');
|
|
148
|
-
|
|
149
|
-
const importResult = await injectMorphImport(claudeMdDest);
|
|
150
|
-
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');
|
|
151
110
|
|
|
152
|
-
log('
|
|
111
|
+
log('Creating .morph structure...');
|
|
153
112
|
const morphPath = join(targetPath, '.morph');
|
|
154
113
|
const configDir = join(morphPath, 'config');
|
|
155
114
|
const frameworkDestDir = join(morphPath, 'framework');
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
await ensureDir(configDir);
|
|
160
|
-
await ensureDir(frameworkDestDir);
|
|
161
|
-
await ensureDir(contextDir);
|
|
162
|
-
await ensureDir(featuresDir);
|
|
115
|
+
for (const dir of [configDir, frameworkDestDir, join(morphPath, 'context'), join(morphPath, 'features')]) {
|
|
116
|
+
await ensureDir(dir);
|
|
117
|
+
}
|
|
163
118
|
|
|
164
|
-
log('Step 3: Writing config.json...');
|
|
165
119
|
const configPath = join(configDir, 'config.json');
|
|
166
120
|
if (!(await pathExists(configPath))) {
|
|
167
|
-
|
|
121
|
+
await writeJson(configPath, {
|
|
122
|
+
$schema: CONFIG_SCHEMA_REF,
|
|
168
123
|
frameworkVersion: getInstalledCLIVersion(),
|
|
169
124
|
project: { name: basename(resolve(targetPath)) },
|
|
170
|
-
};
|
|
171
|
-
await writeJson(configPath, config);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
log('Step 4: Writing context/README.md...');
|
|
175
|
-
const contextReadmePath = join(contextDir, 'README.md');
|
|
176
|
-
if (!(await pathExists(contextReadmePath))) {
|
|
177
|
-
const readmeContent = `# ${basename(resolve(targetPath))} — Project Context\n\nRun \`morph-spec context refresh\` to generate architecture context.\n`;
|
|
178
|
-
await writeFile(contextReadmePath, readmeContent);
|
|
125
|
+
});
|
|
179
126
|
}
|
|
180
127
|
|
|
181
|
-
log('
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const legacyTemplatesDir = join(frameworkDestDir, 'templates');
|
|
185
|
-
if (await pathExists(legacyTemplatesDir)) {
|
|
186
|
-
const priorVersionInfo = await getProjectMorphVersion(targetPath);
|
|
187
|
-
if (priorVersionInfo) {
|
|
188
|
-
const result = reconcileLegacyTemplatesCopy(legacyTemplatesDir, priorVersionInfo.morphVersion);
|
|
189
|
-
if (result === 'removed-legacy') {
|
|
190
|
-
log(' ✓ .morph/framework/templates/ (cópia legada de instalação antiga removida — resolvida do pacote)');
|
|
191
|
-
} else {
|
|
192
|
-
log(' ⚠ .morph/framework/templates/ (override local presente, versão anterior pós-R3 — preservado, não reconciliado)');
|
|
193
|
-
}
|
|
194
|
-
} else {
|
|
195
|
-
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.');
|
|
196
|
-
}
|
|
128
|
+
log('Copying standards, hooks, review checklist, schemas, agents.json, ai-pin.json, MORPH.md and CLI.md...');
|
|
129
|
+
for (const dir of ['standards', 'hooks', 'evals', 'schemas']) {
|
|
130
|
+
await copyDirectory(join(FRAMEWORK_DIR, dir), join(frameworkDestDir, dir), dir === 'hooks' ? { filter: hooksPayloadFilter } : {});
|
|
197
131
|
}
|
|
132
|
+
for (const file of ['agents.json', 'ai-pin.json', 'MORPH.md']) await copyFile(join(FRAMEWORK_DIR, file), join(frameworkDestDir, file));
|
|
133
|
+
await copyFile(join(FRAMEWORK_DIR, 'docs', 'CLI.md'), join(frameworkDestDir, 'CLI.md'));
|
|
198
134
|
|
|
199
|
-
|
|
200
|
-
const frameworkStandardsSrc = join(FRAMEWORK_DIR, 'standards');
|
|
201
|
-
const frameworkStandardsDest = join(frameworkDestDir, 'standards');
|
|
202
|
-
if (await pathExists(frameworkStandardsSrc)) {
|
|
203
|
-
await copyDirectory(frameworkStandardsSrc, frameworkStandardsDest);
|
|
204
|
-
}
|
|
135
|
+
const { agentCounts, projectTags } = await installStackAwareAssets(targetPath, log, { full: true });
|
|
205
136
|
|
|
206
|
-
log('
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
await copyDirectory(hooksSrc, hooksDest);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
log('Step 7c: Copying evals (review checklist + trace schema)...');
|
|
214
|
-
const evalsSrc = join(FRAMEWORK_DIR, 'evals');
|
|
215
|
-
const evalsDest = join(frameworkDestDir, 'evals');
|
|
216
|
-
if (await pathExists(evalsSrc)) {
|
|
217
|
-
await copyDirectory(evalsSrc, evalsDest);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
log('Step 8: Copying agents.json...');
|
|
221
|
-
const agentsSrc = join(FRAMEWORK_DIR, 'agents.json');
|
|
222
|
-
const agentsDest = join(frameworkDestDir, 'agents.json');
|
|
223
|
-
if (await pathExists(agentsSrc)) {
|
|
224
|
-
await copyFile(agentsSrc, agentsDest);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
log('Step 8b: Copying MORPH.md (NLH charter)...');
|
|
228
|
-
const morphMdSrc = join(FRAMEWORK_DIR, 'MORPH.md');
|
|
229
|
-
const morphMdDest = join(frameworkDestDir, 'MORPH.md');
|
|
230
|
-
if (await pathExists(morphMdSrc)) {
|
|
231
|
-
await copyFile(morphMdSrc, morphMdDest);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
log('Step 8b2: Copying CLI.md (command reference)...');
|
|
235
|
-
const cliMdSrc = join(FRAMEWORK_DIR, 'docs', 'CLI.md');
|
|
236
|
-
const cliMdDest = join(frameworkDestDir, 'CLI.md');
|
|
237
|
-
if (await pathExists(cliMdSrc)) {
|
|
238
|
-
await copyFile(cliMdSrc, cliMdDest);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
log('Step 8d: Copying schemas...');
|
|
242
|
-
const schemasSrc = join(FRAMEWORK_DIR, 'schemas');
|
|
243
|
-
const schemasDest = join(frameworkDestDir, 'schemas');
|
|
244
|
-
if (await pathExists(schemasSrc)) {
|
|
245
|
-
await copyDirectory(schemasSrc, schemasDest);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const claudeDest = join(targetPath, '.claude');
|
|
249
|
-
|
|
250
|
-
log('Steps 10-13: Installing stack-aware assets...');
|
|
251
|
-
const { agentCounts, projectTags } = await installStackAwareAssets(targetPath, log);
|
|
252
|
-
|
|
253
|
-
log('Step 14: Installing .claude/CLAUDE.md...');
|
|
254
|
-
const runtimeClaudeMdDest = join(claudeDest, 'CLAUDE.md');
|
|
255
|
-
if (await pathExists(claudeMdSrc)) {
|
|
256
|
-
await copyFile(claudeMdSrc, runtimeClaudeMdDest);
|
|
257
|
-
await updateClaudeMdAgentsBlock(runtimeClaudeMdDest, agentCounts?.agents ?? []);
|
|
258
|
-
}
|
|
137
|
+
log('Installing .claude/CLAUDE.md...');
|
|
138
|
+
const runtimeClaudeMdDest = join(targetPath, '.claude', 'CLAUDE.md');
|
|
139
|
+
await copyFile(claudeMdSrc, runtimeClaudeMdDest);
|
|
140
|
+
await updateClaudeMdAgentsBlock(runtimeClaudeMdDest, agentCounts?.agents ?? []);
|
|
259
141
|
|
|
260
|
-
log('
|
|
261
|
-
|
|
142
|
+
log('Installing global statusline...');
|
|
143
|
+
let statusline = true;
|
|
262
144
|
try {
|
|
263
|
-
await installGlobalStatusline(
|
|
145
|
+
await installGlobalStatusline(join(FRAMEWORK_DIR, 'hooks', 'claude-code'));
|
|
264
146
|
} catch {
|
|
265
|
-
|
|
147
|
+
statusline = false;
|
|
148
|
+
log(' ⚠ ~/.claude não gravável: statusline global não instalado');
|
|
266
149
|
}
|
|
267
150
|
|
|
268
|
-
log('
|
|
269
|
-
await installClaudeHooks(targetPath);
|
|
151
|
+
log('Installing Claude Code hooks...');
|
|
152
|
+
const hooks = await installClaudeHooks(targetPath);
|
|
270
153
|
|
|
271
|
-
|
|
272
|
-
const cliVersion = getInstalledCLIVersion();
|
|
273
|
-
await saveProjectMorphVersion(targetPath, cliVersion);
|
|
154
|
+
await saveProjectMorphVersion(targetPath, getInstalledCLIVersion());
|
|
274
155
|
|
|
275
|
-
log('
|
|
156
|
+
log('Updating .gitignore + .gitattributes...');
|
|
276
157
|
await updateGitignore(targetPath);
|
|
277
158
|
await ensureGitattributes(targetPath);
|
|
278
159
|
|
|
279
160
|
// Fail-open por inteiro: o wrapper de CLI mata o processo em qualquer throw.
|
|
280
|
-
log('
|
|
161
|
+
log('Codebase graph (graphify)...');
|
|
281
162
|
try {
|
|
282
163
|
const { writeGraphifyignore, describeOutdatedIgnore } = await import('../lib/graph/graphifyignore.js');
|
|
283
164
|
const {
|
|
@@ -285,7 +166,7 @@ export async function setupInfra(targetPath, {
|
|
|
285
166
|
GRAPHIFY_VERSION, GRAPHIFY_PACKAGE,
|
|
286
167
|
} = await import('../lib/graph/graphify-runtime.js');
|
|
287
168
|
const { ensureClaudeignore } = await import('../utils/file-copier.js');
|
|
288
|
-
const {
|
|
169
|
+
const { collectProjectFiles } = await import('../lib/ai/ai-project-scan.js');
|
|
289
170
|
|
|
290
171
|
const ignore = writeGraphifyignore(targetPath, projectTags ?? []);
|
|
291
172
|
if (ignore.migrated) log(' ✓ .graphifyignore atualizado (dublês, fixtures e helpers de teste no grafo)');
|
|
@@ -302,14 +183,14 @@ export async function setupInfra(targetPath, {
|
|
|
302
183
|
if (installed === GRAPHIFY_VERSION) {
|
|
303
184
|
log(` ✓ graphify ${installed} já instalado`);
|
|
304
185
|
} else {
|
|
305
|
-
const
|
|
306
|
-
if (
|
|
186
|
+
const kind = toolInstallOff() ? null : (_detectInstaller ?? detectInstaller)().kind;
|
|
187
|
+
if (toolInstallOff()) {
|
|
307
188
|
log(` ○ graphify não instalado (MORPH_NO_TOOL_INSTALL=1). Depois: uv tool install ${GRAPHIFY_PACKAGE}==${GRAPHIFY_VERSION}`);
|
|
308
189
|
} else if (!kind) {
|
|
309
190
|
log(` ⚠ Sem uv/pipx/python — grafo indisponível. Depois: uv tool install ${GRAPHIFY_PACKAGE}==${GRAPHIFY_VERSION}`);
|
|
310
191
|
} else {
|
|
311
192
|
// Sem o extra [sql] os arquivos .sql são ignorados em silêncio.
|
|
312
|
-
const withSql = (
|
|
193
|
+
const withSql = collectProjectFiles(targetPath, (name) => name.endsWith('.sql')).length > 0;
|
|
313
194
|
const { cmd, args } = installArgs(kind, { withSql });
|
|
314
195
|
try {
|
|
315
196
|
_exec(`${cmd} ${args.join(' ')}`, { stdio: 'ignore' });
|
|
@@ -321,16 +202,16 @@ export async function setupInfra(targetPath, {
|
|
|
321
202
|
}
|
|
322
203
|
}
|
|
323
204
|
|
|
324
|
-
// Sem hook git do graphify: o refresh mora nos hooks do Claude
|
|
205
|
+
// Sem hook git do graphify: o refresh mora nos hooks do Claude. O `graphify hook install`
|
|
325
206
|
// 0.9.50 não roda em worktree vinculada, não tem post-merge e carimba HEAD num grafo sem o merge.
|
|
326
207
|
if (probe()) {
|
|
327
|
-
log(' ✓ refresh automático do grafo da raiz: depois dos comandos git/gh/morph-spec do agente
|
|
208
|
+
log(' ✓ refresh automático do grafo da raiz: depois dos comandos git/gh/morph-spec do agente');
|
|
328
209
|
}
|
|
329
210
|
} catch (err) {
|
|
330
|
-
log(` ⚠
|
|
211
|
+
log(` ⚠ Grafo pulado: ${err.message}`);
|
|
331
212
|
}
|
|
332
213
|
|
|
333
214
|
log('setup-infra: complete.');
|
|
334
215
|
|
|
335
|
-
return { agents: { installed: agentCounts?.installed ?? 0 } };
|
|
216
|
+
return { agents: { installed: agentCounts?.installed ?? 0 }, hooks: hooks.installed, statusline };
|
|
336
217
|
}
|