@wundr.io/cli 1.0.0 ā 1.0.3
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 +696 -280
- package/dist/ai/ai-service.d.ts +2 -2
- package/dist/ai/ai-service.d.ts.map +1 -1
- package/dist/ai/ai-service.js +1 -1
- package/dist/ai/ai-service.js.map +1 -1
- package/dist/ai/claude-client.d.ts.map +1 -1
- package/dist/ai/claude-client.js +2 -1
- package/dist/ai/claude-client.js.map +1 -1
- package/dist/ai/conversation-manager.d.ts +2 -2
- package/dist/ai/conversation-manager.d.ts.map +1 -1
- package/dist/ai/conversation-manager.js +5 -3
- package/dist/ai/conversation-manager.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +32 -13
- package/dist/cli.js.map +1 -1
- package/dist/commands/ai.d.ts +3 -3
- package/dist/commands/ai.d.ts.map +1 -1
- package/dist/commands/ai.js +2 -2
- package/dist/commands/ai.js.map +1 -1
- package/dist/commands/alignment.d.ts +78 -0
- package/dist/commands/alignment.d.ts.map +1 -0
- package/dist/commands/alignment.js +817 -0
- package/dist/commands/alignment.js.map +1 -0
- package/dist/commands/analyze-optimized.d.ts.map +1 -1
- package/dist/commands/analyze-optimized.js +9 -6
- package/dist/commands/analyze-optimized.js.map +1 -1
- package/dist/commands/analyze.d.ts +3 -3
- package/dist/commands/analyze.d.ts.map +1 -1
- package/dist/commands/analyze.js +2 -2
- package/dist/commands/analyze.js.map +1 -1
- package/dist/commands/batch.d.ts +3 -3
- package/dist/commands/batch.d.ts.map +1 -1
- package/dist/commands/batch.js +7 -7
- package/dist/commands/batch.js.map +1 -1
- package/dist/commands/chat.d.ts +3 -3
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +3 -3
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/claude-init.d.ts +1 -1
- package/dist/commands/claude-init.d.ts.map +1 -1
- package/dist/commands/claude-init.js +11 -7
- package/dist/commands/claude-init.js.map +1 -1
- package/dist/commands/claude-setup.d.ts +88 -1
- package/dist/commands/claude-setup.d.ts.map +1 -1
- package/dist/commands/claude-setup.js +549 -46
- package/dist/commands/claude-setup.js.map +1 -1
- package/dist/commands/computer-setup-commands.d.ts +17 -3
- package/dist/commands/computer-setup-commands.d.ts.map +1 -1
- package/dist/commands/computer-setup-commands.js +145 -3
- package/dist/commands/computer-setup-commands.js.map +1 -1
- package/dist/commands/computer-setup.d.ts.map +1 -1
- package/dist/commands/computer-setup.js +372 -4
- package/dist/commands/computer-setup.js.map +1 -1
- package/dist/commands/create-command.d.ts.map +1 -1
- package/dist/commands/create-command.js +3 -3
- package/dist/commands/create-command.js.map +1 -1
- package/dist/commands/create.d.ts +3 -3
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +3 -3
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/dashboard.d.ts +3 -3
- package/dist/commands/dashboard.d.ts.map +1 -1
- package/dist/commands/dashboard.js +4 -3
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/govern.d.ts +3 -3
- package/dist/commands/govern.d.ts.map +1 -1
- package/dist/commands/govern.js +4 -3
- package/dist/commands/govern.js.map +1 -1
- package/dist/commands/governance.d.ts +17 -0
- package/dist/commands/governance.d.ts.map +1 -0
- package/dist/commands/governance.js +703 -0
- package/dist/commands/governance.js.map +1 -0
- package/dist/commands/guardian.d.ts +20 -0
- package/dist/commands/guardian.d.ts.map +1 -0
- package/dist/commands/guardian.js +597 -0
- package/dist/commands/guardian.js.map +1 -0
- package/dist/commands/init.d.ts +7 -3
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +71 -5
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/performance-optimizer.d.ts +2 -2
- package/dist/commands/performance-optimizer.d.ts.map +1 -1
- package/dist/commands/performance-optimizer.js +8 -7
- package/dist/commands/performance-optimizer.js.map +1 -1
- package/dist/commands/plugins.d.ts +3 -3
- package/dist/commands/plugins.d.ts.map +1 -1
- package/dist/commands/plugins.js +2 -2
- package/dist/commands/plugins.js.map +1 -1
- package/dist/commands/rag.d.ts +7 -0
- package/dist/commands/rag.d.ts.map +1 -0
- package/dist/commands/rag.js +748 -0
- package/dist/commands/rag.js.map +1 -0
- package/dist/commands/session.d.ts +41 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +441 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/setup.d.ts +3 -3
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +1 -3
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/test-init.d.ts.map +1 -1
- package/dist/commands/test-init.js +2 -2
- package/dist/commands/test-init.js.map +1 -1
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +2 -2
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/vp.d.ts +7 -0
- package/dist/commands/vp.d.ts.map +1 -0
- package/dist/commands/vp.js +571 -0
- package/dist/commands/vp.js.map +1 -0
- package/dist/commands/watch.d.ts +3 -3
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +10 -7
- package/dist/commands/watch.js.map +1 -1
- package/dist/commands/worktree.d.ts +63 -0
- package/dist/commands/worktree.d.ts.map +1 -0
- package/dist/commands/worktree.js +774 -0
- package/dist/commands/worktree.js.map +1 -0
- package/dist/context/context-manager.d.ts +1 -1
- package/dist/context/context-manager.d.ts.map +1 -1
- package/dist/context/context-manager.js +1 -1
- package/dist/context/context-manager.js.map +1 -1
- package/dist/context/session-manager.d.ts +2 -2
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +9 -5
- package/dist/context/session-manager.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interactive/interactive-mode.d.ts +2 -2
- package/dist/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/interactive/interactive-mode.js +6 -4
- package/dist/interactive/interactive-mode.js.map +1 -1
- package/dist/nlp/command-mapper.d.ts +1 -1
- package/dist/nlp/command-mapper.d.ts.map +1 -1
- package/dist/nlp/command-mapper.js +3 -2
- package/dist/nlp/command-mapper.js.map +1 -1
- package/dist/nlp/command-parser.d.ts +1 -1
- package/dist/nlp/command-parser.d.ts.map +1 -1
- package/dist/nlp/command-parser.js +2 -1
- package/dist/nlp/command-parser.js.map +1 -1
- package/dist/nlp/intent-parser.d.ts +1 -1
- package/dist/nlp/intent-parser.d.ts.map +1 -1
- package/dist/nlp/intent-parser.js +14 -9
- package/dist/nlp/intent-parser.js.map +1 -1
- package/dist/plugins/plugin-manager.d.ts +2 -2
- package/dist/plugins/plugin-manager.d.ts.map +1 -1
- package/dist/plugins/plugin-manager.js +3 -3
- package/dist/plugins/plugin-manager.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/backup-rollback-manager.d.ts +72 -0
- package/dist/utils/backup-rollback-manager.d.ts.map +1 -0
- package/dist/utils/backup-rollback-manager.js +289 -0
- package/dist/utils/backup-rollback-manager.js.map +1 -0
- package/dist/utils/claude-config-installer.d.ts +94 -0
- package/dist/utils/claude-config-installer.d.ts.map +1 -0
- package/dist/utils/claude-config-installer.js +628 -0
- package/dist/utils/claude-config-installer.js.map +1 -0
- package/dist/utils/config-manager.d.ts +1 -1
- package/dist/utils/config-manager.d.ts.map +1 -1
- package/dist/utils/config-manager.js +5 -5
- package/dist/utils/config-manager.js.map +1 -1
- package/dist/utils/error-handler.d.ts +1 -1
- package/dist/utils/error-handler.d.ts.map +1 -1
- package/dist/utils/error-handler.js.map +1 -1
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +22 -11
- package/dist/utils/logger.js.map +1 -1
- package/package.json +26 -7
- package/src/ai/ai-service.ts +22 -19
- package/src/ai/claude-client.ts +20 -16
- package/src/ai/conversation-manager.ts +37 -30
- package/src/cli.ts +42 -13
- package/src/commands/ai.ts +59 -57
- package/src/commands/alignment.ts +1212 -0
- package/src/commands/analyze-optimized.ts +70 -62
- package/src/commands/analyze.ts +22 -20
- package/src/commands/batch.ts +41 -38
- package/src/commands/chat.ts +37 -34
- package/src/commands/claude-init.ts +38 -30
- package/src/commands/claude-setup.ts +692 -97
- package/src/commands/computer-setup-commands.ts +203 -37
- package/src/commands/computer-setup.ts +474 -4
- package/src/commands/create-command.ts +7 -7
- package/src/commands/create.ts +36 -33
- package/src/commands/dashboard.ts +33 -28
- package/src/commands/govern.ts +34 -29
- package/src/commands/governance.ts +1005 -0
- package/src/commands/guardian.ts +887 -0
- package/src/commands/init.ts +112 -22
- package/src/commands/performance-optimizer.ts +48 -42
- package/src/commands/plugins.ts +35 -32
- package/src/commands/project-update.ts +1053 -0
- package/src/commands/rag.ts +904 -0
- package/src/commands/session.ts +631 -0
- package/src/commands/setup.ts +35 -31
- package/src/commands/test-init.ts +6 -5
- package/src/commands/test.ts +7 -6
- package/src/commands/vp.ts +762 -0
- package/src/commands/watch.ts +44 -33
- package/src/commands/worktree.ts +1057 -0
- package/src/context/context-manager.ts +15 -12
- package/src/context/session-manager.ts +51 -40
- package/src/index.ts +7 -6
- package/src/interactive/interactive-mode.ts +25 -18
- package/src/lib/conflict-resolution.ts +28 -0
- package/src/lib/merge-strategy.ts +28 -0
- package/src/lib/safety-mechanisms.ts +47 -0
- package/src/lib/state-detection.ts +28 -0
- package/src/nlp/command-mapper.ts +35 -30
- package/src/nlp/command-parser.ts +20 -17
- package/src/nlp/intent-classifier.ts +7 -7
- package/src/nlp/intent-parser.ts +61 -49
- package/src/plugins/plugin-manager.ts +27 -23
- package/src/tests/computer-setup-integration.test.ts +439 -0
- package/src/types/index.ts +1 -1
- package/src/types/modules.d.ts +1 -0
- package/src/utils/backup-rollback-manager.ts +363 -0
- package/src/utils/claude-config-installer.ts +734 -0
- package/src/utils/config-manager.ts +12 -9
- package/src/utils/error-handler.ts +5 -3
- package/src/utils/logger.ts +35 -12
|
@@ -0,0 +1,734 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code Configuration Installer
|
|
3
|
+
* Handles installation of CLAUDE.md, hooks, conventions, and agent templates
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { existsSync } from 'fs';
|
|
7
|
+
import * as fs from 'fs/promises';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
import ora from 'ora';
|
|
12
|
+
|
|
13
|
+
import { BackupRollbackManager } from './backup-rollback-manager';
|
|
14
|
+
import { logger } from './logger';
|
|
15
|
+
|
|
16
|
+
export interface ClaudeConfigOptions {
|
|
17
|
+
claudeDir?: string;
|
|
18
|
+
sourceDir?: string;
|
|
19
|
+
dryRun?: boolean;
|
|
20
|
+
skipBackup?: boolean;
|
|
21
|
+
overwrite?: boolean;
|
|
22
|
+
verbose?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface InstallResult {
|
|
26
|
+
success: boolean;
|
|
27
|
+
installed: string[];
|
|
28
|
+
skipped: string[];
|
|
29
|
+
errors: Array<{ file: string; error: string }>;
|
|
30
|
+
backupId?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class ClaudeConfigInstaller {
|
|
34
|
+
private claudeDir: string;
|
|
35
|
+
private sourceDir: string;
|
|
36
|
+
private backupManager: BackupRollbackManager;
|
|
37
|
+
private homeDir: string;
|
|
38
|
+
|
|
39
|
+
constructor(options: ClaudeConfigOptions = {}) {
|
|
40
|
+
this.homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
41
|
+
this.claudeDir = options.claudeDir || path.join(this.homeDir, '.claude');
|
|
42
|
+
this.sourceDir = options.sourceDir || process.cwd();
|
|
43
|
+
this.backupManager = new BackupRollbackManager();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Initialize installer
|
|
48
|
+
*/
|
|
49
|
+
async initialize(): Promise<void> {
|
|
50
|
+
await this.backupManager.initialize();
|
|
51
|
+
|
|
52
|
+
// Create Claude directory structure
|
|
53
|
+
await this.createDirectoryStructure();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Install all Claude Code configurations
|
|
58
|
+
*/
|
|
59
|
+
async install(options: ClaudeConfigOptions = {}): Promise<InstallResult> {
|
|
60
|
+
const { dryRun = false, skipBackup = false, overwrite = false, verbose = false } = options;
|
|
61
|
+
|
|
62
|
+
const result: InstallResult = {
|
|
63
|
+
success: false,
|
|
64
|
+
installed: [],
|
|
65
|
+
skipped: [],
|
|
66
|
+
errors: [],
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
console.log(chalk.cyan('\nš§ Installing Claude Code Configuration\n'));
|
|
71
|
+
|
|
72
|
+
// Create backup of existing configs
|
|
73
|
+
if (!skipBackup && !dryRun) {
|
|
74
|
+
const existingFiles = await this.getExistingConfigFiles();
|
|
75
|
+
if (existingFiles.length > 0) {
|
|
76
|
+
const spinner = ora('Creating backup of existing configurations...').start();
|
|
77
|
+
const backup = await this.backupManager.createBackup(
|
|
78
|
+
existingFiles,
|
|
79
|
+
'Pre-installation backup',
|
|
80
|
+
);
|
|
81
|
+
result.backupId = backup.backupId;
|
|
82
|
+
spinner.succeed(`Backup created: ${backup.backupId}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Install CLAUDE.md
|
|
87
|
+
await this.installClaudeMd(result, { dryRun, overwrite, verbose });
|
|
88
|
+
|
|
89
|
+
// Install hooks
|
|
90
|
+
await this.installHooks(result, { dryRun, overwrite, verbose });
|
|
91
|
+
|
|
92
|
+
// Install conventions
|
|
93
|
+
await this.installConventions(result, { dryRun, overwrite, verbose });
|
|
94
|
+
|
|
95
|
+
// Install agent templates
|
|
96
|
+
await this.installAgentTemplates(result, { dryRun, overwrite, verbose });
|
|
97
|
+
|
|
98
|
+
// Install git-worktree workflows
|
|
99
|
+
await this.installGitWorktreeWorkflows(result, { dryRun, overwrite, verbose });
|
|
100
|
+
|
|
101
|
+
// Install validation scripts
|
|
102
|
+
await this.installValidationScripts(result, { dryRun, overwrite, verbose });
|
|
103
|
+
|
|
104
|
+
result.success = result.errors.length === 0;
|
|
105
|
+
|
|
106
|
+
// Display summary
|
|
107
|
+
this.displayInstallSummary(result, dryRun);
|
|
108
|
+
|
|
109
|
+
return result;
|
|
110
|
+
} catch (error) {
|
|
111
|
+
logger.error('Installation failed', error);
|
|
112
|
+
result.errors.push({
|
|
113
|
+
file: 'general',
|
|
114
|
+
error: error instanceof Error ? error.message : String(error),
|
|
115
|
+
});
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Install enhanced CLAUDE.md to ~/.claude/
|
|
122
|
+
*/
|
|
123
|
+
private async installClaudeMd(
|
|
124
|
+
result: InstallResult,
|
|
125
|
+
options: { dryRun: boolean; overwrite: boolean; verbose: boolean },
|
|
126
|
+
): Promise<void> {
|
|
127
|
+
const spinner = ora('Installing CLAUDE.md...').start();
|
|
128
|
+
|
|
129
|
+
try {
|
|
130
|
+
const sourcePath = path.join(this.sourceDir, 'CLAUDE.md');
|
|
131
|
+
const targetPath = path.join(this.claudeDir, 'CLAUDE.md');
|
|
132
|
+
|
|
133
|
+
if (!existsSync(sourcePath)) {
|
|
134
|
+
spinner.warn('CLAUDE.md not found in source directory');
|
|
135
|
+
result.skipped.push('CLAUDE.md');
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (existsSync(targetPath) && !options.overwrite) {
|
|
140
|
+
if (options.verbose) {
|
|
141
|
+
spinner.info('CLAUDE.md already exists (use --overwrite to replace)');
|
|
142
|
+
}
|
|
143
|
+
result.skipped.push('CLAUDE.md');
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (options.dryRun) {
|
|
148
|
+
spinner.info('Would install CLAUDE.md');
|
|
149
|
+
result.installed.push('CLAUDE.md (dry-run)');
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
await fs.copyFile(sourcePath, targetPath);
|
|
154
|
+
spinner.succeed('CLAUDE.md installed');
|
|
155
|
+
result.installed.push('CLAUDE.md');
|
|
156
|
+
|
|
157
|
+
logger.info('CLAUDE.md installed', { target: targetPath });
|
|
158
|
+
} catch (error) {
|
|
159
|
+
spinner.fail('Failed to install CLAUDE.md');
|
|
160
|
+
result.errors.push({
|
|
161
|
+
file: 'CLAUDE.md',
|
|
162
|
+
error: error instanceof Error ? error.message : String(error),
|
|
163
|
+
});
|
|
164
|
+
logger.error('CLAUDE.md installation failed', error);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Install hooks configuration
|
|
170
|
+
*/
|
|
171
|
+
private async installHooks(
|
|
172
|
+
result: InstallResult,
|
|
173
|
+
options: { dryRun: boolean; overwrite: boolean; verbose: boolean },
|
|
174
|
+
): Promise<void> {
|
|
175
|
+
const spinner = ora('Installing hooks...').start();
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
const hooksDir = path.join(this.claudeDir, 'hooks');
|
|
179
|
+
await fs.mkdir(hooksDir, { recursive: true });
|
|
180
|
+
|
|
181
|
+
const hooks = this.generateHooksConfig();
|
|
182
|
+
|
|
183
|
+
for (const [hookName, hookContent] of Object.entries(hooks)) {
|
|
184
|
+
const hookPath = path.join(hooksDir, hookName);
|
|
185
|
+
|
|
186
|
+
if (existsSync(hookPath) && !options.overwrite) {
|
|
187
|
+
result.skipped.push(`hooks/${hookName}`);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (options.dryRun) {
|
|
192
|
+
result.installed.push(`hooks/${hookName} (dry-run)`);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
await fs.writeFile(hookPath, hookContent);
|
|
197
|
+
await fs.chmod(hookPath, 0o755); // Make executable
|
|
198
|
+
result.installed.push(`hooks/${hookName}`);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
spinner.succeed(`Hooks installed (${Object.keys(hooks).length} files)`);
|
|
202
|
+
logger.info('Hooks installed', { count: Object.keys(hooks).length });
|
|
203
|
+
} catch (error) {
|
|
204
|
+
spinner.fail('Failed to install hooks');
|
|
205
|
+
result.errors.push({
|
|
206
|
+
file: 'hooks',
|
|
207
|
+
error: error instanceof Error ? error.message : String(error),
|
|
208
|
+
});
|
|
209
|
+
logger.error('Hooks installation failed', error);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Install conventions
|
|
215
|
+
*/
|
|
216
|
+
private async installConventions(
|
|
217
|
+
result: InstallResult,
|
|
218
|
+
options: { dryRun: boolean; overwrite: boolean; verbose: boolean },
|
|
219
|
+
): Promise<void> {
|
|
220
|
+
const spinner = ora('Installing conventions...').start();
|
|
221
|
+
|
|
222
|
+
try {
|
|
223
|
+
const conventionsPath = path.join(this.claudeDir, 'conventions.json');
|
|
224
|
+
const conventions = this.generateConventions();
|
|
225
|
+
|
|
226
|
+
if (existsSync(conventionsPath) && !options.overwrite) {
|
|
227
|
+
spinner.info('Conventions already exist');
|
|
228
|
+
result.skipped.push('conventions.json');
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (options.dryRun) {
|
|
233
|
+
spinner.info('Would install conventions');
|
|
234
|
+
result.installed.push('conventions.json (dry-run)');
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
await fs.writeFile(conventionsPath, JSON.stringify(conventions, null, 2));
|
|
239
|
+
spinner.succeed('Conventions installed');
|
|
240
|
+
result.installed.push('conventions.json');
|
|
241
|
+
|
|
242
|
+
logger.info('Conventions installed', { path: conventionsPath });
|
|
243
|
+
} catch (error) {
|
|
244
|
+
spinner.fail('Failed to install conventions');
|
|
245
|
+
result.errors.push({
|
|
246
|
+
file: 'conventions.json',
|
|
247
|
+
error: error instanceof Error ? error.message : String(error),
|
|
248
|
+
});
|
|
249
|
+
logger.error('Conventions installation failed', error);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Install agent templates
|
|
255
|
+
*/
|
|
256
|
+
private async installAgentTemplates(
|
|
257
|
+
result: InstallResult,
|
|
258
|
+
options: { dryRun: boolean; overwrite: boolean; verbose: boolean },
|
|
259
|
+
): Promise<void> {
|
|
260
|
+
const spinner = ora('Installing agent templates...').start();
|
|
261
|
+
|
|
262
|
+
try {
|
|
263
|
+
const agentsDir = path.join(this.claudeDir, 'agents');
|
|
264
|
+
await fs.mkdir(agentsDir, { recursive: true });
|
|
265
|
+
|
|
266
|
+
const templates = this.generateAgentTemplates();
|
|
267
|
+
|
|
268
|
+
for (const [agentName, agentConfig] of Object.entries(templates)) {
|
|
269
|
+
const agentPath = path.join(agentsDir, `${agentName}.json`);
|
|
270
|
+
|
|
271
|
+
if (existsSync(agentPath) && !options.overwrite) {
|
|
272
|
+
result.skipped.push(`agents/${agentName}.json`);
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (options.dryRun) {
|
|
277
|
+
result.installed.push(`agents/${agentName}.json (dry-run)`);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
await fs.writeFile(agentPath, JSON.stringify(agentConfig, null, 2));
|
|
282
|
+
result.installed.push(`agents/${agentName}.json`);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
spinner.succeed(`Agent templates installed (${Object.keys(templates).length} templates)`);
|
|
286
|
+
logger.info('Agent templates installed', { count: Object.keys(templates).length });
|
|
287
|
+
} catch (error) {
|
|
288
|
+
spinner.fail('Failed to install agent templates');
|
|
289
|
+
result.errors.push({
|
|
290
|
+
file: 'agent-templates',
|
|
291
|
+
error: error instanceof Error ? error.message : String(error),
|
|
292
|
+
});
|
|
293
|
+
logger.error('Agent templates installation failed', error);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Install git-worktree workflows
|
|
299
|
+
*/
|
|
300
|
+
private async installGitWorktreeWorkflows(
|
|
301
|
+
result: InstallResult,
|
|
302
|
+
options: { dryRun: boolean; overwrite: boolean; verbose: boolean },
|
|
303
|
+
): Promise<void> {
|
|
304
|
+
const spinner = ora('Installing git-worktree workflows...').start();
|
|
305
|
+
|
|
306
|
+
try {
|
|
307
|
+
const workflowsDir = path.join(this.claudeDir, 'workflows');
|
|
308
|
+
await fs.mkdir(workflowsDir, { recursive: true });
|
|
309
|
+
|
|
310
|
+
const workflows = this.generateGitWorktreeWorkflows();
|
|
311
|
+
|
|
312
|
+
for (const [workflowName, workflowContent] of Object.entries(workflows)) {
|
|
313
|
+
const workflowPath = path.join(workflowsDir, `${workflowName}.json`);
|
|
314
|
+
|
|
315
|
+
if (existsSync(workflowPath) && !options.overwrite) {
|
|
316
|
+
result.skipped.push(`workflows/${workflowName}.json`);
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (options.dryRun) {
|
|
321
|
+
result.installed.push(`workflows/${workflowName}.json (dry-run)`);
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
await fs.writeFile(workflowPath, JSON.stringify(workflowContent, null, 2));
|
|
326
|
+
result.installed.push(`workflows/${workflowName}.json`);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
spinner.succeed(`Git-worktree workflows installed (${Object.keys(workflows).length} workflows)`);
|
|
330
|
+
logger.info('Git-worktree workflows installed', { count: Object.keys(workflows).length });
|
|
331
|
+
} catch (error) {
|
|
332
|
+
spinner.fail('Failed to install git-worktree workflows');
|
|
333
|
+
result.errors.push({
|
|
334
|
+
file: 'git-worktree-workflows',
|
|
335
|
+
error: error instanceof Error ? error.message : String(error),
|
|
336
|
+
});
|
|
337
|
+
logger.error('Git-worktree workflows installation failed', error);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Install validation scripts
|
|
343
|
+
*/
|
|
344
|
+
private async installValidationScripts(
|
|
345
|
+
result: InstallResult,
|
|
346
|
+
options: { dryRun: boolean; overwrite: boolean; verbose: boolean },
|
|
347
|
+
): Promise<void> {
|
|
348
|
+
const spinner = ora('Installing validation scripts...').start();
|
|
349
|
+
|
|
350
|
+
try {
|
|
351
|
+
const scriptsDir = path.join(this.claudeDir, 'scripts');
|
|
352
|
+
await fs.mkdir(scriptsDir, { recursive: true });
|
|
353
|
+
|
|
354
|
+
const scripts = this.generateValidationScripts();
|
|
355
|
+
|
|
356
|
+
for (const [scriptName, scriptContent] of Object.entries(scripts)) {
|
|
357
|
+
const scriptPath = path.join(scriptsDir, scriptName);
|
|
358
|
+
|
|
359
|
+
if (existsSync(scriptPath) && !options.overwrite) {
|
|
360
|
+
result.skipped.push(`scripts/${scriptName}`);
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (options.dryRun) {
|
|
365
|
+
result.installed.push(`scripts/${scriptName} (dry-run)`);
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
await fs.writeFile(scriptPath, scriptContent);
|
|
370
|
+
await fs.chmod(scriptPath, 0o755); // Make executable
|
|
371
|
+
result.installed.push(`scripts/${scriptName}`);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
spinner.succeed(`Validation scripts installed (${Object.keys(scripts).length} scripts)`);
|
|
375
|
+
logger.info('Validation scripts installed', { count: Object.keys(scripts).length });
|
|
376
|
+
} catch (error) {
|
|
377
|
+
spinner.fail('Failed to install validation scripts');
|
|
378
|
+
result.errors.push({
|
|
379
|
+
file: 'validation-scripts',
|
|
380
|
+
error: error instanceof Error ? error.message : String(error),
|
|
381
|
+
});
|
|
382
|
+
logger.error('Validation scripts installation failed', error);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Create directory structure
|
|
388
|
+
*/
|
|
389
|
+
private async createDirectoryStructure(): Promise<void> {
|
|
390
|
+
const dirs = [
|
|
391
|
+
this.claudeDir,
|
|
392
|
+
path.join(this.claudeDir, 'hooks'),
|
|
393
|
+
path.join(this.claudeDir, 'agents'),
|
|
394
|
+
path.join(this.claudeDir, 'workflows'),
|
|
395
|
+
path.join(this.claudeDir, 'scripts'),
|
|
396
|
+
path.join(this.claudeDir, 'templates'),
|
|
397
|
+
];
|
|
398
|
+
|
|
399
|
+
for (const dir of dirs) {
|
|
400
|
+
await fs.mkdir(dir, { recursive: true });
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Get existing config files for backup
|
|
406
|
+
*/
|
|
407
|
+
private async getExistingConfigFiles(): Promise<string[]> {
|
|
408
|
+
const files: string[] = [];
|
|
409
|
+
const checkFiles = [
|
|
410
|
+
path.join(this.claudeDir, 'CLAUDE.md'),
|
|
411
|
+
path.join(this.claudeDir, 'conventions.json'),
|
|
412
|
+
];
|
|
413
|
+
|
|
414
|
+
for (const file of checkFiles) {
|
|
415
|
+
if (existsSync(file)) {
|
|
416
|
+
files.push(file);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return files;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Generate hooks configuration files
|
|
425
|
+
*/
|
|
426
|
+
private generateHooksConfig(): Record<string, string> {
|
|
427
|
+
return {
|
|
428
|
+
'pre-commit': `#!/bin/bash
|
|
429
|
+
# Claude Code pre-commit hook
|
|
430
|
+
# Auto-generated by Wundr computer-setup
|
|
431
|
+
|
|
432
|
+
echo "š Running pre-commit checks..."
|
|
433
|
+
|
|
434
|
+
# Run linting
|
|
435
|
+
if command -v npm &> /dev/null; then
|
|
436
|
+
npm run lint --if-present || true
|
|
437
|
+
fi
|
|
438
|
+
|
|
439
|
+
# Run type checking
|
|
440
|
+
if command -v npm &> /dev/null; then
|
|
441
|
+
npm run typecheck --if-present || true
|
|
442
|
+
fi
|
|
443
|
+
|
|
444
|
+
echo "ā
Pre-commit checks completed"
|
|
445
|
+
`,
|
|
446
|
+
'post-checkout': `#!/bin/bash
|
|
447
|
+
# Claude Code post-checkout hook
|
|
448
|
+
# Auto-generated by Wundr computer-setup
|
|
449
|
+
|
|
450
|
+
echo "š Post-checkout: Installing dependencies..."
|
|
451
|
+
|
|
452
|
+
# Install dependencies if package.json changed
|
|
453
|
+
if command -v npm &> /dev/null; then
|
|
454
|
+
npm install --if-present || true
|
|
455
|
+
fi
|
|
456
|
+
|
|
457
|
+
echo "ā
Post-checkout completed"
|
|
458
|
+
`,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Generate conventions configuration
|
|
464
|
+
*/
|
|
465
|
+
private generateConventions(): any {
|
|
466
|
+
return {
|
|
467
|
+
fileNaming: {
|
|
468
|
+
components: 'PascalCase',
|
|
469
|
+
utilities: 'camelCase',
|
|
470
|
+
constants: 'UPPER_SNAKE_CASE',
|
|
471
|
+
types: 'PascalCase',
|
|
472
|
+
},
|
|
473
|
+
codeStyle: {
|
|
474
|
+
indentation: 2,
|
|
475
|
+
quotes: 'single',
|
|
476
|
+
semicolons: true,
|
|
477
|
+
trailingComma: 'es5',
|
|
478
|
+
},
|
|
479
|
+
imports: {
|
|
480
|
+
order: ['external', 'internal', 'parent', 'sibling', 'index'],
|
|
481
|
+
grouping: true,
|
|
482
|
+
},
|
|
483
|
+
testing: {
|
|
484
|
+
framework: 'jest',
|
|
485
|
+
coverage: {
|
|
486
|
+
statements: 80,
|
|
487
|
+
branches: 80,
|
|
488
|
+
functions: 80,
|
|
489
|
+
lines: 80,
|
|
490
|
+
},
|
|
491
|
+
},
|
|
492
|
+
git: {
|
|
493
|
+
commitMessage: 'conventional-commits',
|
|
494
|
+
branchNaming: 'feature/*, fix/*, chore/*',
|
|
495
|
+
},
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Generate agent templates
|
|
501
|
+
*/
|
|
502
|
+
private generateAgentTemplates(): Record<string, any> {
|
|
503
|
+
return {
|
|
504
|
+
'backend-developer': {
|
|
505
|
+
name: 'Backend Developer',
|
|
506
|
+
role: 'backend-dev',
|
|
507
|
+
responsibilities: [
|
|
508
|
+
'Design RESTful and GraphQL APIs',
|
|
509
|
+
'Implement database models and queries',
|
|
510
|
+
'Create authentication and authorization',
|
|
511
|
+
'Write comprehensive API documentation',
|
|
512
|
+
],
|
|
513
|
+
tools: ['node', 'typescript', 'postgresql', 'redis'],
|
|
514
|
+
patterns: [
|
|
515
|
+
'Controller-Service-Repository',
|
|
516
|
+
'DTO pattern',
|
|
517
|
+
'Middleware pattern',
|
|
518
|
+
],
|
|
519
|
+
},
|
|
520
|
+
'frontend-developer': {
|
|
521
|
+
name: 'Frontend Developer',
|
|
522
|
+
role: 'frontend-dev',
|
|
523
|
+
responsibilities: [
|
|
524
|
+
'Build responsive user interfaces',
|
|
525
|
+
'Implement state management',
|
|
526
|
+
'Create reusable components',
|
|
527
|
+
'Optimize performance',
|
|
528
|
+
],
|
|
529
|
+
tools: ['react', 'typescript', 'tailwind', 'vite'],
|
|
530
|
+
patterns: ['Component composition', 'Custom hooks', 'Context API'],
|
|
531
|
+
},
|
|
532
|
+
'fullstack-developer': {
|
|
533
|
+
name: 'Fullstack Developer',
|
|
534
|
+
role: 'fullstack-dev',
|
|
535
|
+
responsibilities: [
|
|
536
|
+
'Develop end-to-end features',
|
|
537
|
+
'Integrate frontend and backend',
|
|
538
|
+
'Manage database schemas',
|
|
539
|
+
'Deploy applications',
|
|
540
|
+
],
|
|
541
|
+
tools: ['node', 'react', 'typescript', 'docker'],
|
|
542
|
+
patterns: ['Full-stack architecture', 'API integration', 'CI/CD'],
|
|
543
|
+
},
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Generate git-worktree workflows
|
|
549
|
+
*/
|
|
550
|
+
private generateGitWorktreeWorkflows(): Record<string, any> {
|
|
551
|
+
return {
|
|
552
|
+
'feature-development': {
|
|
553
|
+
name: 'Feature Development Workflow',
|
|
554
|
+
description: 'Workflow for developing new features in isolation',
|
|
555
|
+
steps: [
|
|
556
|
+
{
|
|
557
|
+
name: 'Create worktree',
|
|
558
|
+
command: 'git worktree add ../feature-name feature/name',
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
name: 'Setup environment',
|
|
562
|
+
command: 'cd ../feature-name && npm install',
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
name: 'Run tests',
|
|
566
|
+
command: 'npm test',
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
name: 'Commit changes',
|
|
570
|
+
command: 'git add . && git commit -m "feat: description"',
|
|
571
|
+
},
|
|
572
|
+
],
|
|
573
|
+
},
|
|
574
|
+
'bug-fix': {
|
|
575
|
+
name: 'Bug Fix Workflow',
|
|
576
|
+
description: 'Workflow for fixing bugs without affecting main development',
|
|
577
|
+
steps: [
|
|
578
|
+
{
|
|
579
|
+
name: 'Create worktree',
|
|
580
|
+
command: 'git worktree add ../fix-bug fix/bug-name',
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
name: 'Reproduce bug',
|
|
584
|
+
command: 'npm test -- bug.test.ts',
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
name: 'Fix and verify',
|
|
588
|
+
command: 'npm test',
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
name: 'Commit fix',
|
|
592
|
+
command: 'git add . && git commit -m "fix: description"',
|
|
593
|
+
},
|
|
594
|
+
],
|
|
595
|
+
},
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Generate validation scripts
|
|
601
|
+
*/
|
|
602
|
+
private generateValidationScripts(): Record<string, string> {
|
|
603
|
+
return {
|
|
604
|
+
'validate-setup.sh': `#!/bin/bash
|
|
605
|
+
# Validate Claude Code setup
|
|
606
|
+
# Auto-generated by Wundr computer-setup
|
|
607
|
+
|
|
608
|
+
echo "š Validating Claude Code setup..."
|
|
609
|
+
|
|
610
|
+
# Check for required files
|
|
611
|
+
FILES=(
|
|
612
|
+
"$HOME/.claude/CLAUDE.md"
|
|
613
|
+
"$HOME/.claude/conventions.json"
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
MISSING=0
|
|
617
|
+
for file in "\${FILES[@]}"; do
|
|
618
|
+
if [ ! -f "$file" ]; then
|
|
619
|
+
echo "ā Missing: $file"
|
|
620
|
+
MISSING=$((MISSING + 1))
|
|
621
|
+
else
|
|
622
|
+
echo "ā
Found: $file"
|
|
623
|
+
fi
|
|
624
|
+
done
|
|
625
|
+
|
|
626
|
+
# Check for required directories
|
|
627
|
+
DIRS=(
|
|
628
|
+
"$HOME/.claude/hooks"
|
|
629
|
+
"$HOME/.claude/agents"
|
|
630
|
+
"$HOME/.claude/workflows"
|
|
631
|
+
)
|
|
632
|
+
|
|
633
|
+
for dir in "\${DIRS[@]}"; do
|
|
634
|
+
if [ ! -d "$dir" ]; then
|
|
635
|
+
echo "ā Missing directory: $dir"
|
|
636
|
+
MISSING=$((MISSING + 1))
|
|
637
|
+
else
|
|
638
|
+
echo "ā
Found directory: $dir"
|
|
639
|
+
fi
|
|
640
|
+
done
|
|
641
|
+
|
|
642
|
+
if [ $MISSING -eq 0 ]; then
|
|
643
|
+
echo "ā
All validations passed!"
|
|
644
|
+
exit 0
|
|
645
|
+
else
|
|
646
|
+
echo "ā $MISSING validation(s) failed"
|
|
647
|
+
exit 1
|
|
648
|
+
fi
|
|
649
|
+
`,
|
|
650
|
+
'check-config.sh': `#!/bin/bash
|
|
651
|
+
# Check Claude Code configuration
|
|
652
|
+
# Auto-generated by Wundr computer-setup
|
|
653
|
+
|
|
654
|
+
echo "š§ Checking Claude Code configuration..."
|
|
655
|
+
|
|
656
|
+
# Check Claude CLI
|
|
657
|
+
if command -v claude &> /dev/null; then
|
|
658
|
+
echo "ā
Claude CLI: $(claude --version)"
|
|
659
|
+
else
|
|
660
|
+
echo "ā ļø Claude CLI not found"
|
|
661
|
+
fi
|
|
662
|
+
|
|
663
|
+
# Check Node.js
|
|
664
|
+
if command -v node &> /dev/null; then
|
|
665
|
+
echo "ā
Node.js: $(node --version)"
|
|
666
|
+
else
|
|
667
|
+
echo "ā Node.js not found"
|
|
668
|
+
fi
|
|
669
|
+
|
|
670
|
+
# Check Git
|
|
671
|
+
if command -v git &> /dev/null; then
|
|
672
|
+
echo "ā
Git: $(git --version)"
|
|
673
|
+
else
|
|
674
|
+
echo "ā Git not found"
|
|
675
|
+
fi
|
|
676
|
+
|
|
677
|
+
echo "ā
Configuration check complete"
|
|
678
|
+
`,
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Display installation summary
|
|
684
|
+
*/
|
|
685
|
+
private displayInstallSummary(result: InstallResult, dryRun: boolean): void {
|
|
686
|
+
console.log(chalk.cyan('\nš Installation Summary\n'));
|
|
687
|
+
|
|
688
|
+
if (dryRun) {
|
|
689
|
+
console.log(chalk.yellow('š DRY RUN MODE - No files were modified\n'));
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
if (result.backupId) {
|
|
693
|
+
console.log(chalk.gray(`Backup ID: ${result.backupId}\n`));
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
if (result.installed.length > 0) {
|
|
697
|
+
console.log(chalk.green(`ā
Installed (${result.installed.length}):`));
|
|
698
|
+
result.installed.forEach(file => {
|
|
699
|
+
console.log(chalk.white(` ⢠${file}`));
|
|
700
|
+
});
|
|
701
|
+
console.log();
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
if (result.skipped.length > 0) {
|
|
705
|
+
console.log(chalk.yellow(`āļø Skipped (${result.skipped.length}):`));
|
|
706
|
+
result.skipped.forEach(file => {
|
|
707
|
+
console.log(chalk.gray(` ⢠${file}`));
|
|
708
|
+
});
|
|
709
|
+
console.log();
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
if (result.errors.length > 0) {
|
|
713
|
+
console.log(chalk.red(`ā Errors (${result.errors.length}):`));
|
|
714
|
+
result.errors.forEach(error => {
|
|
715
|
+
console.log(chalk.red(` ⢠${error.file}: ${error.error}`));
|
|
716
|
+
});
|
|
717
|
+
console.log();
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
if (result.success) {
|
|
721
|
+
console.log(chalk.green('ā
Installation completed successfully!\n'));
|
|
722
|
+
console.log(chalk.cyan('Next steps:'));
|
|
723
|
+
console.log(chalk.white(' 1. Review installed configurations'));
|
|
724
|
+
console.log(chalk.white(' 2. Run validation: ~/.claude/scripts/validate-setup.sh'));
|
|
725
|
+
console.log(chalk.white(' 3. Customize agent templates as needed'));
|
|
726
|
+
} else {
|
|
727
|
+
console.log(chalk.red('ā Installation completed with errors\n'));
|
|
728
|
+
if (result.backupId) {
|
|
729
|
+
console.log(chalk.cyan('To rollback:'));
|
|
730
|
+
console.log(chalk.white(` wundr computer-setup rollback --backup ${result.backupId}`));
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|