@polymorphism-tech/morph-spec 4.8.19 → 4.9.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 +21 -0
- package/README.md +2 -2
- package/bin/morph-spec.js +15 -56
- package/bin/task-manager.js +115 -14
- package/bin/validate.js +67 -33
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +201 -203
- package/docs/QUICKSTART.md +2 -2
- package/framework/CLAUDE.md +21 -0
- package/framework/agents.json +698 -176
- package/framework/hooks/claude-code/post-tool-use/context-refresh.js +1 -1
- package/framework/hooks/claude-code/post-tool-use/dispatch.js +2 -2
- package/framework/hooks/claude-code/post-tool-use/skill-reminder.js +155 -0
- package/framework/hooks/claude-code/pre-tool-use/protect-spec-files.js +1 -1
- package/framework/hooks/claude-code/session-start/inject-morph-context.js +71 -2
- package/framework/hooks/claude-code/statusline.py +76 -30
- package/framework/hooks/claude-code/user-prompt/set-terminal-title.js +14 -6
- package/framework/hooks/shared/activity-logger.js +0 -24
- package/framework/hooks/shared/phase-utils.js +3 -0
- package/framework/hooks/shared/skill-reminder-helpers.js +79 -0
- package/framework/hooks/shared/stale-task-reset.js +57 -0
- package/framework/hooks/shared/state-reader.js +2 -2
- package/framework/hooks/shared/worktree-helpers.js +53 -0
- package/framework/phases.json +40 -8
- package/framework/skills/level-0-meta/brainstorming/SKILL.md +1 -1
- package/framework/skills/level-0-meta/code-review/SKILL.md +1 -1
- package/framework/skills/level-0-meta/code-review-nextjs/SKILL.md +163 -163
- package/framework/skills/level-0-meta/frontend-review/SKILL.md +5 -5
- package/framework/skills/level-0-meta/morph-checklist/SKILL.md +2 -2
- package/framework/skills/level-0-meta/morph-init/SKILL.md +5 -5
- package/framework/skills/level-0-meta/morph-replicate/SKILL.md +4 -4
- package/framework/skills/level-0-meta/morph-replicate/references/blazor-html-mapping.md +1 -1
- package/framework/skills/level-0-meta/post-implementation/SKILL.md +59 -12
- package/framework/skills/level-0-meta/simulation-checklist/SKILL.md +1 -1
- package/framework/skills/level-0-meta/terminal-title/SKILL.md +1 -1
- package/framework/skills/level-0-meta/tool-usage-guide/SKILL.md +1 -1
- package/framework/skills/level-0-meta/tool-usage-guide/references/tools-per-phase.md +6 -5
- package/framework/skills/level-0-meta/verification-before-completion/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/phase-clarify/SKILL.md +215 -189
- package/framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md +251 -251
- package/framework/skills/level-1-workflows/phase-design/SKILL.md +382 -365
- package/framework/skills/level-1-workflows/phase-implement/SKILL.md +492 -450
- package/framework/skills/level-1-workflows/phase-setup/SKILL.md +194 -190
- package/framework/skills/level-1-workflows/phase-tasks/SKILL.md +270 -270
- package/framework/skills/level-1-workflows/phase-uiux/SKILL.md +285 -285
- package/framework/standards/STANDARDS.json +640 -88
- package/framework/standards/infrastructure/vercel/vercel-database.md +106 -0
- package/framework/templates/REGISTRY.json +1825 -1909
- package/framework/templates/context/CONTEXT-FEATURE.md +276 -276
- package/framework/templates/docs/onboarding.md +1 -5
- package/package.json +2 -6
- package/src/commands/agents/dispatch-agents.js +55 -4
- package/src/commands/project/doctor.js +16 -47
- package/src/commands/project/init.js +1 -1
- package/src/commands/project/status.js +2 -2
- package/src/commands/project/update.js +381 -365
- package/src/commands/project/worktree.js +154 -0
- package/src/commands/state/advance-phase.js +120 -30
- package/src/commands/state/approve.js +2 -2
- package/src/commands/state/index.js +7 -8
- package/src/commands/state/phase-runner.js +1 -1
- package/src/commands/state/state.js +61 -6
- package/src/commands/tasks/task.js +78 -99
- package/src/commands/templates/template-render.js +93 -173
- package/src/commands/trust/trust.js +26 -21
- package/src/core/paths/output-schema.js +15 -0
- package/src/core/state/state-manager.js +28 -54
- package/src/core/workflows/workflow-detector.js +9 -87
- package/src/lib/phase-chain/phase-validator.js +330 -0
- package/src/lib/stack/stack-profile.js +88 -0
- package/src/lib/tasks/task-classifier.js +16 -0
- package/src/lib/tasks/test-runner.js +77 -0
- package/src/lib/trust/trust-manager.js +32 -144
- package/src/lib/validators/spec-validator.js +58 -4
- package/src/lib/validators/validation-runner.js +23 -11
- package/src/scripts/setup-infra.js +240 -224
- package/src/utils/agents-installer.js +2 -2
- package/src/utils/banner.js +1 -1
- package/src/utils/claude-settings-manager.js +1 -1
- package/src/utils/file-copier.js +1 -0
- package/src/utils/hooks-installer.js +258 -8
- package/framework/hooks/dev/check-sync-health.js +0 -117
- package/framework/hooks/dev/guard-version-numbers.js +0 -57
- package/framework/hooks/dev/sync-standards-registry.js +0 -60
- package/framework/hooks/dev/sync-template-registry.js +0 -60
- package/framework/hooks/dev/validate-skill-format.js +0 -70
- package/framework/hooks/dev/validate-standard-format.js +0 -73
- package/framework/templates/meta-prompts/hops/hop-retry.md +0 -78
- package/framework/templates/meta-prompts/hops/hop-validation.md +0 -97
- package/framework/templates/meta-prompts/hops/hop-wrapper.md +0 -36
- package/framework/workflows/configs/design-impl.json +0 -49
- package/framework/workflows/configs/express.json +0 -45
- package/framework/workflows/configs/fast-track.json +0 -42
- package/framework/workflows/configs/full-morph.json +0 -79
- package/framework/workflows/configs/fusion.json +0 -39
- package/framework/workflows/configs/long-running.json +0 -33
- package/framework/workflows/configs/spec-only.json +0 -43
- package/framework/workflows/configs/ui-refresh.json +0 -49
- package/framework/workflows/configs/zero-touch.json +0 -82
- package/src/commands/project/monitor.js +0 -295
- package/src/commands/project/tutorial.js +0 -115
- package/src/commands/state/validate-phase.js +0 -238
- package/src/commands/templates/generate-contracts.js +0 -445
- package/src/core/orchestrator.js +0 -171
- package/src/core/registry/command-registry.js +0 -28
- package/src/core/registry/index.js +0 -8
- package/src/core/registry/validator-registry.js +0 -204
- package/src/core/templates/template-validator.js +0 -296
- package/src/generator/config-generator.js +0 -206
- package/src/generator/templates/config.json.template +0 -40
- package/src/generator/templates/project.md.template +0 -67
- package/src/lib/agents/micro-agent-factory.js +0 -161
- package/src/lib/analysis/complexity-analyzer.js +0 -441
- package/src/lib/analysis/index.js +0 -7
- package/src/lib/analytics/analytics-engine.js +0 -345
- package/src/lib/checkpoints/checkpoint-hooks.js +0 -298
- package/src/lib/checkpoints/index.js +0 -7
- package/src/lib/context/context-bundler.js +0 -241
- package/src/lib/context/context-optimizer.js +0 -212
- package/src/lib/context/context-tracker.js +0 -273
- package/src/lib/context/core-four-tracker.js +0 -201
- package/src/lib/context/mcp-optimizer.js +0 -200
- package/src/lib/execution/fusion-executor.js +0 -304
- package/src/lib/execution/parallel-executor.js +0 -270
- package/src/lib/hooks/stop-hook-executor.js +0 -286
- package/src/lib/hops/hop-composer.js +0 -221
- package/src/lib/phase-chain/eligibility-checker.js +0 -243
- package/src/lib/threads/thread-coordinator.js +0 -238
- package/src/lib/threads/thread-manager.js +0 -317
- package/src/lib/tracking/artifact-trail.js +0 -202
- package/src/scanner/project-scanner.js +0 -242
- package/src/ui/diff-display.js +0 -91
- package/src/ui/interactive-wizard.js +0 -96
- package/src/ui/user-review.js +0 -211
- package/src/ui/wizard-questions.js +0 -188
- package/src/utils/color-utils.js +0 -70
- package/src/utils/process-handler.js +0 -97
|
@@ -1,224 +1,240 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* setup-infra.js
|
|
3
|
-
*
|
|
4
|
-
* Headless infrastructure setup for MORPH-SPEC.
|
|
5
|
-
* Extracted from init.js (steps 1-10) so it can be called by the
|
|
6
|
-
* /morph-init Claude Code skill via `morph-spec setup-infra` without
|
|
7
|
-
* interactive prompts or stack detection.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* import { setupInfra } from './setup-infra.js';
|
|
11
|
-
* await setupInfra('/path/to/project');
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { join, dirname } from 'path';
|
|
15
|
-
import { fileURLToPath } from 'url';
|
|
16
|
-
import { execSync } from 'child_process';
|
|
17
|
-
import {
|
|
18
|
-
copyDirectory,
|
|
19
|
-
copyFile,
|
|
20
|
-
pathExists,
|
|
21
|
-
writeJson,
|
|
22
|
-
ensureDir,
|
|
23
|
-
writeFile,
|
|
24
|
-
updateGitignore
|
|
25
|
-
} from '../utils/file-copier.js';
|
|
26
|
-
import { saveProjectMorphVersion, getInstalledCLIVersion } from '../utils/version-checker.js';
|
|
27
|
-
import { installClaudeHooks, installGlobalStatusline } from '../utils/claude-settings-manager.js';
|
|
28
|
-
import { installSkills } from '../utils/skills-installer.js';
|
|
29
|
-
import { installAgents, installDomainAgents } from '../utils/agents-installer.js';
|
|
30
|
-
|
|
31
|
-
const FRAMEWORK_DIR = join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'framework');
|
|
32
|
-
|
|
33
|
-
const REQUIRED_PLUGINS = [
|
|
34
|
-
'superpowers@claude-plugins-official',
|
|
35
|
-
'context7@claude-plugins-official',
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
async function installRequiredPlugins(log, exec) {
|
|
39
|
-
log('Step 0: Installing required Claude Code plugins...');
|
|
40
|
-
for (const plugin of REQUIRED_PLUGINS) {
|
|
41
|
-
try {
|
|
42
|
-
exec(`claude plugin install ${plugin}`, { stdio: 'inherit' });
|
|
43
|
-
log(` ✓ ${plugin}`);
|
|
44
|
-
} catch {
|
|
45
|
-
log(` ⚠ Failed to install ${plugin} — install manually: claude plugin install ${plugin}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Installs MORPH-SPEC infrastructure into the target project directory.
|
|
52
|
-
* Headless — no prompts, no spinner (suppressed when MORPH_QUIET=1), no stack detection.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} targetPath - Absolute path to the target project directory
|
|
55
|
-
*/
|
|
56
|
-
export async function setupInfra(targetPath, { _exec = execSync } = {}) {
|
|
57
|
-
const quiet = process.env.MORPH_QUIET === '1';
|
|
58
|
-
|
|
59
|
-
function log(msg) {
|
|
60
|
-
if (!quiet) process.stdout.write(msg + '\n');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// --- 0. Install required Claude Code plugins ---
|
|
64
|
-
await installRequiredPlugins(log, _exec);
|
|
65
|
-
|
|
66
|
-
// --- 1. Copy CLAUDE.md (backup existing non-MORPH CLAUDE.md) ---
|
|
67
|
-
log('Step 1: Copying CLAUDE.md...');
|
|
68
|
-
const claudeMdSrc = join(FRAMEWORK_DIR, 'CLAUDE.md');
|
|
69
|
-
const claudeMdDest = join(targetPath, 'CLAUDE.md');
|
|
70
|
-
|
|
71
|
-
if (await pathExists(claudeMdDest)) {
|
|
72
|
-
const { readFile } = await import('../utils/file-copier.js');
|
|
73
|
-
const existingContent = await readFile(claudeMdDest);
|
|
74
|
-
if (!existingContent.includes('MORPH-SPEC')) {
|
|
75
|
-
await copyFile(claudeMdDest, `${claudeMdDest}.backup`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
await copyFile(claudeMdSrc, claudeMdDest);
|
|
79
|
-
|
|
80
|
-
// --- 2. Create .morph directory structure ---
|
|
81
|
-
log('Step 2: Creating .morph structure...');
|
|
82
|
-
const morphPath = join(targetPath, '.morph');
|
|
83
|
-
const configDir = join(morphPath, 'config');
|
|
84
|
-
const frameworkDestDir = join(morphPath, 'framework');
|
|
85
|
-
const contextDir = join(morphPath, 'context');
|
|
86
|
-
const featuresDir = join(morphPath, 'features');
|
|
87
|
-
const checkpointsDir = join(morphPath, 'checkpoints');
|
|
88
|
-
const memoryDir = join(morphPath, 'memory');
|
|
89
|
-
const archiveDir = join(morphPath, 'archive');
|
|
90
|
-
|
|
91
|
-
await ensureDir(configDir);
|
|
92
|
-
await ensureDir(frameworkDestDir);
|
|
93
|
-
await ensureDir(contextDir);
|
|
94
|
-
await ensureDir(featuresDir);
|
|
95
|
-
await ensureDir(checkpointsDir);
|
|
96
|
-
await ensureDir(memoryDir);
|
|
97
|
-
await ensureDir(archiveDir);
|
|
98
|
-
|
|
99
|
-
// --- 3. Write minimal config.json (only if not exists) ---
|
|
100
|
-
log('Step 3: Writing config.json...');
|
|
101
|
-
const configPath = join(configDir, 'config.json');
|
|
102
|
-
if (!(await pathExists(configPath))) {
|
|
103
|
-
const dirName = targetPath.split(/[\/]/).pop();
|
|
104
|
-
const config = {
|
|
105
|
-
framework: 'global',
|
|
106
|
-
frameworkVersion: getInstalledCLIVersion(),
|
|
107
|
-
project: {
|
|
108
|
-
name: dirName
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
await writeJson(configPath, config);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// --- 4. Write placeholder context/README.md (only if not exists) ---
|
|
115
|
-
log('Step 4: Writing context/README.md...');
|
|
116
|
-
const contextReadmePath = join(contextDir, 'README.md');
|
|
117
|
-
if (!(await pathExists(contextReadmePath))) {
|
|
118
|
-
const dirName = targetPath.split(/[\/]/).pop();
|
|
119
|
-
const readmeContent = `# ${dirName} — Project Context\n\nRun /morph
|
|
120
|
-
await writeFile(contextReadmePath, readmeContent);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// --- 5. Copy framework/templates → .morph/framework/templates ---
|
|
124
|
-
log('Step 5: Copying framework templates...');
|
|
125
|
-
const frameworkTemplatesSrc = join(FRAMEWORK_DIR, 'templates');
|
|
126
|
-
const templatesDest = join(frameworkDestDir, 'templates');
|
|
127
|
-
if (await pathExists(frameworkTemplatesSrc)) {
|
|
128
|
-
await copyDirectory(frameworkTemplatesSrc, templatesDest);
|
|
129
|
-
} else {
|
|
130
|
-
await ensureDir(templatesDest);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// --- 6. Copy framework/standards → .morph/framework/standards ---
|
|
134
|
-
log('Step 6: Copying framework standards...');
|
|
135
|
-
const frameworkStandardsSrc = join(FRAMEWORK_DIR, 'standards');
|
|
136
|
-
const frameworkStandardsDest = join(frameworkDestDir, 'standards');
|
|
137
|
-
if (await pathExists(frameworkStandardsSrc)) {
|
|
138
|
-
await copyDirectory(frameworkStandardsSrc, frameworkStandardsDest);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// --- 7. Copy framework/hooks → .morph/framework/hooks ---
|
|
142
|
-
log('Step 7: Copying hooks...');
|
|
143
|
-
const hooksSrc = join(FRAMEWORK_DIR, 'hooks');
|
|
144
|
-
const hooksDest = join(frameworkDestDir, 'hooks');
|
|
145
|
-
if (await pathExists(hooksSrc)) {
|
|
146
|
-
await copyDirectory(hooksSrc, hooksDest);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// --- 8. Copy framework/agents.json → .morph/framework/agents.json ---
|
|
150
|
-
log('Step 8: Copying agents.json...');
|
|
151
|
-
const agentsSrc = join(FRAMEWORK_DIR, 'agents.json');
|
|
152
|
-
const agentsDest = join(frameworkDestDir, 'agents.json');
|
|
153
|
-
if (await pathExists(agentsSrc)) {
|
|
154
|
-
await copyFile(agentsSrc, agentsDest);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// --- 9. Copy framework/commands → .claude/commands ---
|
|
158
|
-
log('Step 9: Setting up Claude Code integration...');
|
|
159
|
-
const claudeDest = join(targetPath, '.claude');
|
|
160
|
-
const commandsSrc = join(FRAMEWORK_DIR, 'commands');
|
|
161
|
-
const commandsDest = join(claudeDest, 'commands');
|
|
162
|
-
if (await pathExists(commandsSrc)) {
|
|
163
|
-
await copyDirectory(commandsSrc, commandsDest);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// --- 10. Copy framework/rules → .claude/rules ---
|
|
167
|
-
log('Step 10: Installing path-scoped rules...');
|
|
168
|
-
const rulesSrc = join(FRAMEWORK_DIR, 'rules');
|
|
169
|
-
const rulesDest = join(claudeDest, 'rules');
|
|
170
|
-
if (await pathExists(rulesSrc)) {
|
|
171
|
-
await copyDirectory(rulesSrc, rulesDest);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// --- 11. installSkills ---
|
|
175
|
-
log('Step 11: Installing skills...');
|
|
176
|
-
await installSkills(targetPath);
|
|
177
|
-
|
|
178
|
-
// --- 12. installAgents ---
|
|
179
|
-
log('Step 12: Installing agents...');
|
|
180
|
-
const agentCounts = await installAgents(targetPath, FRAMEWORK_DIR, { projectStack: null });
|
|
181
|
-
|
|
182
|
-
// --- 13. installDomainAgents ---
|
|
183
|
-
log('Step 13: Installing domain agents...');
|
|
184
|
-
const domainCounts = await installDomainAgents(targetPath, FRAMEWORK_DIR);
|
|
185
|
-
|
|
186
|
-
// --- 14. Copy framework/CLAUDE.md → .claude/CLAUDE.md ---
|
|
187
|
-
log('Step 14: Installing .claude/CLAUDE.md...');
|
|
188
|
-
const runtimeClaudeMdDest = join(claudeDest, 'CLAUDE.md');
|
|
189
|
-
if (await pathExists(claudeMdSrc)) {
|
|
190
|
-
await copyFile(claudeMdSrc, runtimeClaudeMdDest);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// --- 15. installGlobalStatusline (non-critical) ---
|
|
194
|
-
log('Step 15: Installing global statusline...');
|
|
195
|
-
const HOOKS_SRC = join(FRAMEWORK_DIR, 'hooks', 'claude-code');
|
|
196
|
-
try {
|
|
197
|
-
await installGlobalStatusline(HOOKS_SRC);
|
|
198
|
-
} catch {
|
|
199
|
-
// Non-critical — global ~/.claude may not be writable
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// --- 16. installClaudeHooks ---
|
|
203
|
-
log('Step 16: Installing Claude Code hooks...');
|
|
204
|
-
await installClaudeHooks(targetPath);
|
|
205
|
-
|
|
206
|
-
// ---
|
|
207
|
-
log('Step
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
log('
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
1
|
+
/**
|
|
2
|
+
* setup-infra.js
|
|
3
|
+
*
|
|
4
|
+
* Headless infrastructure setup for MORPH-SPEC.
|
|
5
|
+
* Extracted from init.js (steps 1-10) so it can be called by the
|
|
6
|
+
* /morph-init Claude Code skill via `morph-spec setup-infra` without
|
|
7
|
+
* interactive prompts or stack detection.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* import { setupInfra } from './setup-infra.js';
|
|
11
|
+
* await setupInfra('/path/to/project');
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { join, dirname } from 'path';
|
|
15
|
+
import { fileURLToPath } from 'url';
|
|
16
|
+
import { execSync } from 'child_process';
|
|
17
|
+
import {
|
|
18
|
+
copyDirectory,
|
|
19
|
+
copyFile,
|
|
20
|
+
pathExists,
|
|
21
|
+
writeJson,
|
|
22
|
+
ensureDir,
|
|
23
|
+
writeFile,
|
|
24
|
+
updateGitignore
|
|
25
|
+
} from '../utils/file-copier.js';
|
|
26
|
+
import { saveProjectMorphVersion, getInstalledCLIVersion } from '../utils/version-checker.js';
|
|
27
|
+
import { installClaudeHooks, installGlobalStatusline, installVSCodeTerminalSettings, installShellIntegration } from '../utils/claude-settings-manager.js';
|
|
28
|
+
import { installSkills } from '../utils/skills-installer.js';
|
|
29
|
+
import { installAgents, installDomainAgents } from '../utils/agents-installer.js';
|
|
30
|
+
|
|
31
|
+
const FRAMEWORK_DIR = join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'framework');
|
|
32
|
+
|
|
33
|
+
const REQUIRED_PLUGINS = [
|
|
34
|
+
'superpowers@claude-plugins-official',
|
|
35
|
+
'context7@claude-plugins-official',
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
async function installRequiredPlugins(log, exec) {
|
|
39
|
+
log('Step 0: Installing required Claude Code plugins...');
|
|
40
|
+
for (const plugin of REQUIRED_PLUGINS) {
|
|
41
|
+
try {
|
|
42
|
+
exec(`claude plugin install ${plugin}`, { stdio: 'inherit' });
|
|
43
|
+
log(` ✓ ${plugin}`);
|
|
44
|
+
} catch {
|
|
45
|
+
log(` ⚠ Failed to install ${plugin} — install manually: claude plugin install ${plugin}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Installs MORPH-SPEC infrastructure into the target project directory.
|
|
52
|
+
* Headless — no prompts, no spinner (suppressed when MORPH_QUIET=1), no stack detection.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} targetPath - Absolute path to the target project directory
|
|
55
|
+
*/
|
|
56
|
+
export async function setupInfra(targetPath, { _exec = execSync } = {}) {
|
|
57
|
+
const quiet = process.env.MORPH_QUIET === '1';
|
|
58
|
+
|
|
59
|
+
function log(msg) {
|
|
60
|
+
if (!quiet) process.stdout.write(msg + '\n');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// --- 0. Install required Claude Code plugins ---
|
|
64
|
+
await installRequiredPlugins(log, _exec);
|
|
65
|
+
|
|
66
|
+
// --- 1. Copy CLAUDE.md (backup existing non-MORPH CLAUDE.md) ---
|
|
67
|
+
log('Step 1: Copying CLAUDE.md...');
|
|
68
|
+
const claudeMdSrc = join(FRAMEWORK_DIR, 'CLAUDE.md');
|
|
69
|
+
const claudeMdDest = join(targetPath, 'CLAUDE.md');
|
|
70
|
+
|
|
71
|
+
if (await pathExists(claudeMdDest)) {
|
|
72
|
+
const { readFile } = await import('../utils/file-copier.js');
|
|
73
|
+
const existingContent = await readFile(claudeMdDest);
|
|
74
|
+
if (!existingContent.includes('MORPH-SPEC')) {
|
|
75
|
+
await copyFile(claudeMdDest, `${claudeMdDest}.backup`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
await copyFile(claudeMdSrc, claudeMdDest);
|
|
79
|
+
|
|
80
|
+
// --- 2. Create .morph directory structure ---
|
|
81
|
+
log('Step 2: Creating .morph structure...');
|
|
82
|
+
const morphPath = join(targetPath, '.morph');
|
|
83
|
+
const configDir = join(morphPath, 'config');
|
|
84
|
+
const frameworkDestDir = join(morphPath, 'framework');
|
|
85
|
+
const contextDir = join(morphPath, 'context');
|
|
86
|
+
const featuresDir = join(morphPath, 'features');
|
|
87
|
+
const checkpointsDir = join(morphPath, 'checkpoints');
|
|
88
|
+
const memoryDir = join(morphPath, 'memory');
|
|
89
|
+
const archiveDir = join(morphPath, 'archive');
|
|
90
|
+
|
|
91
|
+
await ensureDir(configDir);
|
|
92
|
+
await ensureDir(frameworkDestDir);
|
|
93
|
+
await ensureDir(contextDir);
|
|
94
|
+
await ensureDir(featuresDir);
|
|
95
|
+
await ensureDir(checkpointsDir);
|
|
96
|
+
await ensureDir(memoryDir);
|
|
97
|
+
await ensureDir(archiveDir);
|
|
98
|
+
|
|
99
|
+
// --- 3. Write minimal config.json (only if not exists) ---
|
|
100
|
+
log('Step 3: Writing config.json...');
|
|
101
|
+
const configPath = join(configDir, 'config.json');
|
|
102
|
+
if (!(await pathExists(configPath))) {
|
|
103
|
+
const dirName = targetPath.split(/[\/]/).pop();
|
|
104
|
+
const config = {
|
|
105
|
+
framework: 'global',
|
|
106
|
+
frameworkVersion: getInstalledCLIVersion(),
|
|
107
|
+
project: {
|
|
108
|
+
name: dirName
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
await writeJson(configPath, config);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// --- 4. Write placeholder context/README.md (only if not exists) ---
|
|
115
|
+
log('Step 4: Writing context/README.md...');
|
|
116
|
+
const contextReadmePath = join(contextDir, 'README.md');
|
|
117
|
+
if (!(await pathExists(contextReadmePath))) {
|
|
118
|
+
const dirName = targetPath.split(/[\/]/).pop();
|
|
119
|
+
const readmeContent = `# ${dirName} — Project Context\n\nRun /morph:init to generate project context.\n`;
|
|
120
|
+
await writeFile(contextReadmePath, readmeContent);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// --- 5. Copy framework/templates → .morph/framework/templates ---
|
|
124
|
+
log('Step 5: Copying framework templates...');
|
|
125
|
+
const frameworkTemplatesSrc = join(FRAMEWORK_DIR, 'templates');
|
|
126
|
+
const templatesDest = join(frameworkDestDir, 'templates');
|
|
127
|
+
if (await pathExists(frameworkTemplatesSrc)) {
|
|
128
|
+
await copyDirectory(frameworkTemplatesSrc, templatesDest);
|
|
129
|
+
} else {
|
|
130
|
+
await ensureDir(templatesDest);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// --- 6. Copy framework/standards → .morph/framework/standards ---
|
|
134
|
+
log('Step 6: Copying framework standards...');
|
|
135
|
+
const frameworkStandardsSrc = join(FRAMEWORK_DIR, 'standards');
|
|
136
|
+
const frameworkStandardsDest = join(frameworkDestDir, 'standards');
|
|
137
|
+
if (await pathExists(frameworkStandardsSrc)) {
|
|
138
|
+
await copyDirectory(frameworkStandardsSrc, frameworkStandardsDest);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// --- 7. Copy framework/hooks → .morph/framework/hooks ---
|
|
142
|
+
log('Step 7: Copying hooks...');
|
|
143
|
+
const hooksSrc = join(FRAMEWORK_DIR, 'hooks');
|
|
144
|
+
const hooksDest = join(frameworkDestDir, 'hooks');
|
|
145
|
+
if (await pathExists(hooksSrc)) {
|
|
146
|
+
await copyDirectory(hooksSrc, hooksDest);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// --- 8. Copy framework/agents.json → .morph/framework/agents.json ---
|
|
150
|
+
log('Step 8: Copying agents.json...');
|
|
151
|
+
const agentsSrc = join(FRAMEWORK_DIR, 'agents.json');
|
|
152
|
+
const agentsDest = join(frameworkDestDir, 'agents.json');
|
|
153
|
+
if (await pathExists(agentsSrc)) {
|
|
154
|
+
await copyFile(agentsSrc, agentsDest);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// --- 9. Copy framework/commands → .claude/commands ---
|
|
158
|
+
log('Step 9: Setting up Claude Code integration...');
|
|
159
|
+
const claudeDest = join(targetPath, '.claude');
|
|
160
|
+
const commandsSrc = join(FRAMEWORK_DIR, 'commands');
|
|
161
|
+
const commandsDest = join(claudeDest, 'commands');
|
|
162
|
+
if (await pathExists(commandsSrc)) {
|
|
163
|
+
await copyDirectory(commandsSrc, commandsDest);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// --- 10. Copy framework/rules → .claude/rules ---
|
|
167
|
+
log('Step 10: Installing path-scoped rules...');
|
|
168
|
+
const rulesSrc = join(FRAMEWORK_DIR, 'rules');
|
|
169
|
+
const rulesDest = join(claudeDest, 'rules');
|
|
170
|
+
if (await pathExists(rulesSrc)) {
|
|
171
|
+
await copyDirectory(rulesSrc, rulesDest);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// --- 11. installSkills ---
|
|
175
|
+
log('Step 11: Installing skills...');
|
|
176
|
+
await installSkills(targetPath);
|
|
177
|
+
|
|
178
|
+
// --- 12. installAgents ---
|
|
179
|
+
log('Step 12: Installing agents...');
|
|
180
|
+
const agentCounts = await installAgents(targetPath, FRAMEWORK_DIR, { projectStack: null });
|
|
181
|
+
|
|
182
|
+
// --- 13. installDomainAgents ---
|
|
183
|
+
log('Step 13: Installing domain agents...');
|
|
184
|
+
const domainCounts = await installDomainAgents(targetPath, FRAMEWORK_DIR);
|
|
185
|
+
|
|
186
|
+
// --- 14. Copy framework/CLAUDE.md → .claude/CLAUDE.md ---
|
|
187
|
+
log('Step 14: Installing .claude/CLAUDE.md...');
|
|
188
|
+
const runtimeClaudeMdDest = join(claudeDest, 'CLAUDE.md');
|
|
189
|
+
if (await pathExists(claudeMdSrc)) {
|
|
190
|
+
await copyFile(claudeMdSrc, runtimeClaudeMdDest);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// --- 15. installGlobalStatusline (non-critical) ---
|
|
194
|
+
log('Step 15: Installing global statusline...');
|
|
195
|
+
const HOOKS_SRC = join(FRAMEWORK_DIR, 'hooks', 'claude-code');
|
|
196
|
+
try {
|
|
197
|
+
await installGlobalStatusline(HOOKS_SRC);
|
|
198
|
+
} catch {
|
|
199
|
+
// Non-critical — global ~/.claude may not be writable
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// --- 16. installClaudeHooks ---
|
|
203
|
+
log('Step 16: Installing Claude Code hooks...');
|
|
204
|
+
await installClaudeHooks(targetPath);
|
|
205
|
+
|
|
206
|
+
// --- 16a. installShellIntegration (non-critical) ---
|
|
207
|
+
log('Step 16a: Installing shell integration...');
|
|
208
|
+
try {
|
|
209
|
+
await installShellIntegration();
|
|
210
|
+
} catch {
|
|
211
|
+
// Non-critical — shell profile may not be writable
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// --- 16b. installVSCodeTerminalSettings (non-critical) ---
|
|
215
|
+
log('Step 16b: Configuring VS Code terminal settings...');
|
|
216
|
+
try {
|
|
217
|
+
await installVSCodeTerminalSettings();
|
|
218
|
+
} catch {
|
|
219
|
+
// Non-critical — VS Code settings may not be present
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// --- 17. saveProjectMorphVersion ---
|
|
223
|
+
log('Step 17: Saving version info...');
|
|
224
|
+
const cliVersion = getInstalledCLIVersion();
|
|
225
|
+
await saveProjectMorphVersion(targetPath, cliVersion);
|
|
226
|
+
|
|
227
|
+
// --- 18. updateGitignore ---
|
|
228
|
+
log('Step 18: Updating .gitignore...');
|
|
229
|
+
await updateGitignore(targetPath);
|
|
230
|
+
|
|
231
|
+
log('setup-infra: complete.');
|
|
232
|
+
|
|
233
|
+
return {
|
|
234
|
+
agents: {
|
|
235
|
+
tier1: agentCounts?.tier1 ?? 0,
|
|
236
|
+
tier2: agentCounts?.tier2 ?? 0,
|
|
237
|
+
specialists: domainCounts?.specialists ?? 0,
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
}
|
|
@@ -78,14 +78,14 @@ const TIER_DEFAULTS = {
|
|
|
78
78
|
model: 'inherit',
|
|
79
79
|
tools: 'Read, Grep, Glob, Bash, Task',
|
|
80
80
|
maxTurns: 30,
|
|
81
|
-
skills: ['morph
|
|
81
|
+
skills: ['morph:checklist'],
|
|
82
82
|
memory: 'project',
|
|
83
83
|
},
|
|
84
84
|
2: {
|
|
85
85
|
model: 'inherit',
|
|
86
86
|
tools: 'Read, Grep, Glob, Bash',
|
|
87
87
|
maxTurns: 20,
|
|
88
|
-
skills: ['morph
|
|
88
|
+
skills: ['morph:checklist'],
|
|
89
89
|
memory: 'local',
|
|
90
90
|
},
|
|
91
91
|
};
|
package/src/utils/banner.js
CHANGED
|
@@ -45,7 +45,7 @@ export function printInstallBanner({ version, nodeVersion, results = [] }) {
|
|
|
45
45
|
'',
|
|
46
46
|
sep('Next'),
|
|
47
47
|
` ${chalk.cyan('1.')} Open your project in Claude Code`,
|
|
48
|
-
` ${chalk.cyan('2.')} Run ${chalk.bold.white('/morph
|
|
48
|
+
` ${chalk.cyan('2.')} Run ${chalk.bold.white('/morph:init')}`,
|
|
49
49
|
'',
|
|
50
50
|
].join('\n'));
|
|
51
51
|
}
|
|
@@ -17,7 +17,7 @@ const MORPH_MANAGED_KEY = '_morph_managed';
|
|
|
17
17
|
// Re-export from hooks-installer (v2 registry-based)
|
|
18
18
|
// ============================================================================
|
|
19
19
|
|
|
20
|
-
export { installClaudeHooks, installGlobalStatusline, getHooksVersion } from './hooks-installer.js';
|
|
20
|
+
export { installClaudeHooks, installGlobalStatusline, installVSCodeTerminalSettings, installShellIntegration, getHooksVersion } from './hooks-installer.js';
|
|
21
21
|
export { installAgents } from './agents-installer.js';
|
|
22
22
|
|
|
23
23
|
// ============================================================================
|