harness-everything 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/build-multi-agent-system/SKILL.md +68 -68
- package/create-agent-launcher/SKILL.md +48 -48
- package/docs/workflows/build-multi-agent-system.md +62 -62
- package/docs/workflows/create-agent-launcher.md +62 -62
- package/docs/workflows/environment-detection.md +63 -63
- package/docs/workflows/eval-harness.md +57 -57
- package/docs/workflows/fable-discipline.md +59 -59
- package/docs/workflows/fable-mode.md +32 -32
- package/docs/workflows/git-commit.md +62 -62
- package/docs/workflows/grill-me.md +62 -62
- package/docs/workflows/grill-with-docs.md +62 -62
- package/docs/workflows/improve-codebase-architecture.md +60 -60
- package/docs/workflows/repo-docs.md +59 -59
- package/docs/workflows/rewrite-commits.md +60 -60
- package/docs/workflows/security-review.md +58 -58
- package/docs/workflows/self-evolve.md +59 -59
- package/docs/workflows/tdd.md +39 -39
- package/docs/workflows/todo-driven-workflow.md +36 -36
- package/docs/workflows/using-git-worktrees.md +63 -63
- package/docs/workflows/verification-loop.md +69 -69
- package/docs/workflows/verify-before-claim.md +60 -60
- package/docs/workflows/zoom-out.md +62 -62
- package/environment-detection/SKILL.md +77 -77
- package/eval-framework/behavioral-test.js +105 -105
- package/eval-framework/mechanism-test.js +251 -251
- package/eval-harness/SKILL.md +59 -59
- package/fable-discipline/SKILL.md +38 -38
- package/fable-mode/SKILL.md +51 -51
- package/git-commit/SKILL.md +55 -55
- package/grill-me/SKILL.md +36 -36
- package/grill-with-docs/SKILL.md +99 -99
- package/harness-everything/SKILL.md +141 -141
- package/harness-everything/examples/README.md +9 -9
- package/harness-everything/examples/todo-workflow.md +22 -22
- package/harness-everything/scripts/todo-cli.js +157 -157
- package/harness-everything/scripts/verify-gate.js +31 -31
- package/hooks/scripts/atomic-commit-check.js +68 -68
- package/hooks/scripts/context-compact.js +114 -114
- package/hooks/scripts/lib/harness-state.js +29 -3
- package/hooks/scripts/lib/platforms/claude.js +42 -42
- package/hooks/scripts/lib/platforms/codex.js +46 -46
- package/hooks/scripts/lib/platforms/continue.js +41 -41
- package/hooks/scripts/lib/platforms/copilot.js +41 -41
- package/hooks/scripts/lib/platforms/cursor.js +41 -41
- package/hooks/scripts/rule-of-3.js +176 -176
- package/improve-codebase-architecture/SKILL.md +44 -44
- package/install-cognitive-os/SKILL.md +95 -95
- package/package.json +1 -1
- package/repo-docs/SKILL.md +45 -45
- package/rewrite-commits/SKILL.md +32 -32
- package/scripts/installer.js +649 -649
- package/scripts/lib/advisory-text.js +163 -163
- package/scripts/lib/claude-hooks.js +71 -71
- package/scripts/lib/gitignore.js +80 -58
- package/scripts/lib/manifest.js +82 -82
- package/scripts/lib/prompts.js +241 -241
- package/scripts/lib/skills.js +172 -172
- package/scripts/lib/workspace.js +28 -28
- package/security-review/SKILL.md +510 -510
- package/self-evolve/SKILL.md +54 -54
- package/skill-creator/SKILL.md +91 -91
- package/skill-creator/references/testing-workflow.md +32 -32
- package/skill-style/SKILL.md +48 -48
- package/tdd/SKILL.md +53 -53
- package/todo-driven-workflow/SKILL.md +54 -54
- package/using-git-worktrees/SKILL.md +161 -161
- package/verification-loop/SKILL.md +138 -138
- package/verify-before-claim/SKILL.md +86 -86
- package/zoom-out/SKILL.md +90 -90
package/scripts/installer.js
CHANGED
|
@@ -1,649 +1,649 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Lightweight, non-intrusive installer for Harness OS.
|
|
4
|
-
* Detects the local project layout (Claude Code, Cursor, etc.)
|
|
5
|
-
* and merges the Harness hook definitions safely without destroying user configs.
|
|
6
|
-
*
|
|
7
|
-
* Placement rule: a platform's own native file/folder (`.claude/settings.json`,
|
|
8
|
-
* `.cursorrules`, `.cursor/skills/`, etc.) is never moved - it lives exactly
|
|
9
|
-
* where that platform expects it. Anything Harness itself needs that has no
|
|
10
|
-
* native home (install manifest, runtime hook state, and - only for Claude,
|
|
11
|
-
* which has no native project-skill directory - the installed skill copies)
|
|
12
|
-
* converges into one exclusively-owned subfolder per platform:
|
|
13
|
-
* `<platform-dir>/harness-everything/`. Nothing else ever creates a directory
|
|
14
|
-
* literally named "harness-everything", so it can be added or removed as a
|
|
15
|
-
* unit without touching anything else in that platform's directory.
|
|
16
|
-
*
|
|
17
|
-
* This file only orchestrates the install/uninstall flow (CLI parsing,
|
|
18
|
-
* interactive prompts, sequencing). Each concern it delegates to lives in
|
|
19
|
-
* scripts/lib/: skill discovery & manifest-tracked install/removal
|
|
20
|
-
* (lib/skills.js, lib/manifest.js), Claude Code hook merge/removal
|
|
21
|
-
* (lib/claude-hooks.js), advisory-file injection for hookless platforms
|
|
22
|
-
* (lib/advisory-text.js), .gitignore/empty-dir housekeeping (lib/gitignore.js),
|
|
23
|
-
* and the terminal picker widgets (lib/prompts.js).
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const fs = require('fs');
|
|
27
|
-
const path = require('path');
|
|
28
|
-
|
|
29
|
-
const { getWorkspaceRoot, getUserPromptsDir } = require('./lib/workspace');
|
|
30
|
-
const { interactiveSelect, interactiveSingleSelect, askQuestion } = require('./lib/prompts');
|
|
31
|
-
const advisory = require('./lib/advisory-text');
|
|
32
|
-
const claudeHooks = require('./lib/claude-hooks');
|
|
33
|
-
const manifest = require('./lib/manifest');
|
|
34
|
-
const skills = require('./lib/skills');
|
|
35
|
-
const { ensureWorkspaceGitignorePatterns, cleanEmptyDirs } = require('./lib/gitignore');
|
|
36
|
-
|
|
37
|
-
const userHome = require('os').homedir();
|
|
38
|
-
const workspaceRoot = getWorkspaceRoot();
|
|
39
|
-
const harnessSourceDir = path.resolve(__dirname, '..');
|
|
40
|
-
const packageVersion = require(path.join(harnessSourceDir, 'package.json')).version;
|
|
41
|
-
|
|
42
|
-
let platformModules = [];
|
|
43
|
-
try {
|
|
44
|
-
platformModules = require(path.join(__dirname, '../hooks/scripts/lib/platforms'));
|
|
45
|
-
} catch (e) {
|
|
46
|
-
platformModules = []; // Best-effort - gitignore hints and state cleanup degrade gracefully without it.
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async function main() {
|
|
50
|
-
const args = process.argv;
|
|
51
|
-
const command = args[2] || 'install'; // 'install', 'add', 'skills', etc.
|
|
52
|
-
|
|
53
|
-
const isInteractive = process.stdin.isTTY && process.stdout.isTTY;
|
|
54
|
-
const hasClaudeFlag = args.includes('--claude');
|
|
55
|
-
const hasCursorFlag = args.includes('--cursor');
|
|
56
|
-
const hasCopilotFlag = args.includes('--copilot');
|
|
57
|
-
const hasCodexFlag = args.includes('--codex');
|
|
58
|
-
const hasContinueFlag = args.includes('--continue');
|
|
59
|
-
const hasHermesFlag = args.includes('--hermes');
|
|
60
|
-
const hasAllFlag = args.includes('--all');
|
|
61
|
-
const hasGlobalFlag = args.includes('--global') || args.includes('-g');
|
|
62
|
-
const hasYesFlag = args.includes('-y') || args.includes('--yes');
|
|
63
|
-
const hasAnyPlatformFlag = hasClaudeFlag || hasCursorFlag || hasCopilotFlag || hasCodexFlag || hasContinueFlag || hasHermesFlag || hasAllFlag;
|
|
64
|
-
const requestedSkills = ['add', 'skill', 'skills'].includes(command)
|
|
65
|
-
? args.slice(3).filter(arg => !arg.startsWith('-'))
|
|
66
|
-
: [];
|
|
67
|
-
|
|
68
|
-
const claudeExists = fs.existsSync(path.join(workspaceRoot, '.claude'));
|
|
69
|
-
const cursorExists = fs.existsSync(path.join(workspaceRoot, '.cursorrules'));
|
|
70
|
-
const copilotExists = fs.existsSync(path.join(workspaceRoot, '.github', 'copilot-instructions.md')) || fs.existsSync(path.join(workspaceRoot, '.github'));
|
|
71
|
-
const codexExists = fs.existsSync(path.join(workspaceRoot, 'AGENTS.md'));
|
|
72
|
-
const continueExists = fs.existsSync(path.join(workspaceRoot, '.continue'));
|
|
73
|
-
const hermesExists = fs.existsSync(path.join(workspaceRoot, '.hermes.md'));
|
|
74
|
-
const detectedAny = claudeExists || cursorExists || copilotExists || codexExists || continueExists || hermesExists;
|
|
75
|
-
|
|
76
|
-
if (command === 'uninstall') {
|
|
77
|
-
await runUninstall({ hasYesFlag, args, isInteractive });
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
let targets = {
|
|
82
|
-
claude: false,
|
|
83
|
-
cursor: false,
|
|
84
|
-
copilot: false,
|
|
85
|
-
codex: false,
|
|
86
|
-
continue: false,
|
|
87
|
-
hermes: false
|
|
88
|
-
};
|
|
89
|
-
let chosenSkills = [];
|
|
90
|
-
let isGlobal = hasGlobalFlag;
|
|
91
|
-
|
|
92
|
-
const runInteractively = isInteractive && !hasYesFlag && !hasAnyPlatformFlag && (['install', 'add', 'skill', 'skills'].includes(command) && requestedSkills.length === 0);
|
|
93
|
-
|
|
94
|
-
if (runInteractively) {
|
|
95
|
-
console.log("=================================================");
|
|
96
|
-
console.log(` Harness OS - Interactive Setup `);
|
|
97
|
-
console.log("=================================================");
|
|
98
|
-
|
|
99
|
-
// Step 1: Choose platforms
|
|
100
|
-
console.log("\n[Step 1/3] Select target platforms to configure:");
|
|
101
|
-
const platformItems = [
|
|
102
|
-
{ id: 'claude', name: `Claude Code (hook-enforced) ${claudeExists ? '(Detected)' : ''}`, checked: claudeExists || !detectedAny },
|
|
103
|
-
{ id: 'cursor', name: `Cursor (.cursorrules) ${cursorExists ? '(Detected)' : ''}`, checked: cursorExists },
|
|
104
|
-
{ id: 'copilot', name: `Copilot (.github/copilot-...) ${copilotExists ? '(Detected)' : ''}`, checked: copilotExists },
|
|
105
|
-
{ id: 'codex', name: `Codex (AGENTS.md) ${codexExists ? '(Detected)' : ''}`, checked: codexExists },
|
|
106
|
-
{ id: 'continue', name: `Continue.dev (.continue/rules) ${continueExists ? '(Detected)' : ''}`, checked: continueExists },
|
|
107
|
-
{ id: 'hermes', name: `Hermes Agent (.hermes.md) ${hermesExists ? '(Detected)' : ''}`, checked: hermesExists }
|
|
108
|
-
];
|
|
109
|
-
const selectedPlatforms = await interactiveSelect(platformItems);
|
|
110
|
-
selectedPlatforms.forEach(p => {
|
|
111
|
-
targets[p.id] = p.checked;
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
// Step 2: Choose skills
|
|
115
|
-
const availableSkills = skills.getAvailableSkills(harnessSourceDir);
|
|
116
|
-
console.log("\n[Step 2/3] Select skills to install:");
|
|
117
|
-
const skillItems = availableSkills.map(s => {
|
|
118
|
-
const info = skills.getSkillInfo(harnessSourceDir, s);
|
|
119
|
-
// Pre-check essential skills
|
|
120
|
-
const isEssential = ['tdd', 'git-commit', 'todo-driven-workflow', 'verification-loop'].includes(s);
|
|
121
|
-
const isHarnessEverything = s === 'harness-everything';
|
|
122
|
-
return {
|
|
123
|
-
id: s,
|
|
124
|
-
name: isHarnessEverything ? `${s} (Required)` : s,
|
|
125
|
-
description: info ? info.description : '',
|
|
126
|
-
checked: isEssential || isHarnessEverything
|
|
127
|
-
};
|
|
128
|
-
});
|
|
129
|
-
const selectedSkills = await interactiveSelect(skillItems, 8);
|
|
130
|
-
chosenSkills = selectedSkills.filter(s => s.checked).map(s => s.id);
|
|
131
|
-
|
|
132
|
-
// Step 3: Choose global vs local location
|
|
133
|
-
console.log("\n[Step 3/3] Select installation scope / location:");
|
|
134
|
-
const locationItems = [
|
|
135
|
-
{ id: 'local', name: "Local Workspace (Install to current project directories)", checked: true },
|
|
136
|
-
{ id: 'global', name: "Global (~/.agents - applies across all projects)", checked: false }
|
|
137
|
-
];
|
|
138
|
-
const chosenLocationId = await interactiveSingleSelect(locationItems);
|
|
139
|
-
isGlobal = chosenLocationId === 'global';
|
|
140
|
-
} else {
|
|
141
|
-
// Non-interactive/bypass mode
|
|
142
|
-
isGlobal = hasGlobalFlag;
|
|
143
|
-
|
|
144
|
-
if (['add', 'skill', 'skills'].includes(command)) {
|
|
145
|
-
if (requestedSkills.length > 0) {
|
|
146
|
-
const availableSkills = skills.getAvailableSkills(harnessSourceDir);
|
|
147
|
-
for (const skillName of requestedSkills) {
|
|
148
|
-
if (availableSkills.includes(skillName)) {
|
|
149
|
-
chosenSkills.push(skillName);
|
|
150
|
-
} else {
|
|
151
|
-
console.error(`⚠️ Skill "${skillName}" not found. Skipping.`);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
chosenSkills = ['tdd', 'git-commit', 'todo-driven-workflow', 'verification-loop', 'zoom-out', 'install-cognitive-os'];
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (!isGlobal) {
|
|
159
|
-
targets.claude = claudeExists;
|
|
160
|
-
targets.cursor = cursorExists;
|
|
161
|
-
targets.copilot = copilotExists;
|
|
162
|
-
targets.codex = codexExists;
|
|
163
|
-
targets.continue = continueExists;
|
|
164
|
-
targets.hermes = hermesExists;
|
|
165
|
-
if (!detectedAny) {
|
|
166
|
-
targets.claude = true;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
} else {
|
|
170
|
-
if (hasAnyPlatformFlag) {
|
|
171
|
-
if (hasAllFlag) {
|
|
172
|
-
targets.claude = true;
|
|
173
|
-
targets.cursor = true;
|
|
174
|
-
targets.copilot = true;
|
|
175
|
-
targets.codex = true;
|
|
176
|
-
targets.continue = true;
|
|
177
|
-
targets.hermes = true;
|
|
178
|
-
} else {
|
|
179
|
-
targets.claude = hasClaudeFlag;
|
|
180
|
-
targets.cursor = hasCursorFlag;
|
|
181
|
-
targets.copilot = hasCopilotFlag;
|
|
182
|
-
targets.codex = hasCodexFlag;
|
|
183
|
-
targets.continue = hasContinueFlag;
|
|
184
|
-
targets.hermes = hasHermesFlag;
|
|
185
|
-
}
|
|
186
|
-
} else {
|
|
187
|
-
if (detectedAny) {
|
|
188
|
-
targets.claude = claudeExists;
|
|
189
|
-
targets.cursor = cursorExists;
|
|
190
|
-
targets.copilot = copilotExists;
|
|
191
|
-
targets.codex = codexExists;
|
|
192
|
-
targets.continue = continueExists;
|
|
193
|
-
targets.hermes = hermesExists;
|
|
194
|
-
} else {
|
|
195
|
-
targets.claude = true;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
chosenSkills = ['tdd', 'git-commit', 'todo-driven-workflow', 'verification-loop', 'zoom-out', 'install-cognitive-os'];
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Ensure harness-everything is ALWAYS included in chosenSkills
|
|
203
|
-
if (!chosenSkills.includes('harness-everything')) {
|
|
204
|
-
chosenSkills.push('harness-everything');
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// If no targets selected at all, exit
|
|
208
|
-
if (!targets.claude && !targets.cursor && !targets.copilot && !targets.codex && !targets.continue && !targets.hermes && !isGlobal) {
|
|
209
|
-
console.log("\n❌ No platforms selected. Exiting.");
|
|
210
|
-
process.exit(0);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const targetWorkspaceRoot = isGlobal ? path.join(userHome, '.agents') : workspaceRoot;
|
|
214
|
-
|
|
215
|
-
console.log("\n-------------------------------------------------");
|
|
216
|
-
console.log(`Installing Harness OS to ${isGlobal ? 'Global Home' : 'Local Workspace'}`);
|
|
217
|
-
console.log("-------------------------------------------------");
|
|
218
|
-
|
|
219
|
-
// Merge into .claude/settings.json (only if Claude Code selected)
|
|
220
|
-
if (targets.claude) {
|
|
221
|
-
installClaudeHooks({ isGlobal, targetWorkspaceRoot });
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Cursor
|
|
225
|
-
if (targets.cursor) {
|
|
226
|
-
const targetFile = isGlobal ? path.join(userHome, '.cursorrules') : path.join(targetWorkspaceRoot, '.cursorrules');
|
|
227
|
-
advisory.injectAdvisoryText(targetFile, '# Cursor Project Rules', isGlobal ? '~/.cursorrules' : '.cursorrules');
|
|
228
|
-
}
|
|
229
|
-
// Copilot Chat
|
|
230
|
-
if (targets.copilot) {
|
|
231
|
-
if (!isGlobal) {
|
|
232
|
-
const targetFile = path.join(targetWorkspaceRoot, '.github', 'copilot-instructions.md');
|
|
233
|
-
advisory.injectAdvisoryText(targetFile, '# Copilot Instructions', '.github/copilot-instructions.md');
|
|
234
|
-
} else {
|
|
235
|
-
try {
|
|
236
|
-
const promptsDir = getUserPromptsDir();
|
|
237
|
-
if (!fs.existsSync(promptsDir)) {
|
|
238
|
-
fs.mkdirSync(promptsDir, { recursive: true });
|
|
239
|
-
}
|
|
240
|
-
const vscodeInstFile = path.join(promptsDir, 'harness.instructions.md');
|
|
241
|
-
fs.writeFileSync(vscodeInstFile, advisory.buildCopilotGlobalContent(), 'utf8');
|
|
242
|
-
console.log(` ✅ Installed global Copilot instructions to VS Code: ${vscodeInstFile}`);
|
|
243
|
-
} catch (err) {
|
|
244
|
-
console.warn(` ⚠️ Failed to write VS Code user prompts folder: ${err.message}`);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
// Codex
|
|
249
|
-
if (targets.codex) {
|
|
250
|
-
if (!isGlobal) {
|
|
251
|
-
const targetFile = path.join(targetWorkspaceRoot, 'AGENTS.md');
|
|
252
|
-
advisory.injectAdvisoryText(targetFile, '# AGENTS.md', 'AGENTS.md');
|
|
253
|
-
} else {
|
|
254
|
-
try {
|
|
255
|
-
const promptsDir = getUserPromptsDir();
|
|
256
|
-
if (!fs.existsSync(promptsDir)) {
|
|
257
|
-
fs.mkdirSync(promptsDir, { recursive: true });
|
|
258
|
-
}
|
|
259
|
-
const vscodeAgentFile = path.join(promptsDir, 'harness.agent.md');
|
|
260
|
-
fs.writeFileSync(vscodeAgentFile, advisory.buildCodexGlobalContent(), 'utf8');
|
|
261
|
-
console.log(` ✅ Installed global Codex agent to VS Code: ${vscodeAgentFile}`);
|
|
262
|
-
} catch (err) {
|
|
263
|
-
console.warn(` ⚠️ Failed to write VS Code user prompts folder: ${err.message}`);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
// Continue.dev
|
|
268
|
-
if (targets.continue) {
|
|
269
|
-
const targetFile = isGlobal ? path.join(userHome, '.continue', 'rules', 'harness.md') : path.join(workspaceRoot, '.continue', 'rules', 'harness.md');
|
|
270
|
-
advisory.installContinueRule(targetFile, isGlobal ? '~/.continue/rules/harness.md' : '.continue/rules/harness.md');
|
|
271
|
-
}
|
|
272
|
-
// Hermes Agent (reads .hermes.md/AGENTS.md/CLAUDE.md/.cursorrules from the
|
|
273
|
-
// project it's launched in - project scope only, no documented global
|
|
274
|
-
// equivalent, so --global is a documented no-op here rather than a guess).
|
|
275
|
-
if (targets.hermes) {
|
|
276
|
-
if (!isGlobal) {
|
|
277
|
-
const targetFile = path.join(targetWorkspaceRoot, '.hermes.md');
|
|
278
|
-
advisory.injectAdvisoryText(targetFile, '# .hermes.md', '.hermes.md');
|
|
279
|
-
} else {
|
|
280
|
-
console.log(` ℹ️ Hermes Agent has no documented global instructions file (it reads .hermes.md from the current project directory only) - skipping global install for --hermes.`);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// Install chosen skills. Every platform's skills stay at that platform's
|
|
285
|
-
// own native location (unchanged) EXCEPT Claude, which never had one -
|
|
286
|
-
// its copy lives under its own harness-everything/ subfolder instead.
|
|
287
|
-
// Every platform still gets its own harness-everything/manifest.json so
|
|
288
|
-
// "what did we install here" is always precisely answerable per platform.
|
|
289
|
-
if (chosenSkills.length > 0) {
|
|
290
|
-
const targetDirs = [];
|
|
291
|
-
if (isGlobal) {
|
|
292
|
-
const globalAgentsDir = path.join(userHome, '.agents');
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
//
|
|
325
|
-
//
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if (targets.
|
|
347
|
-
if (targets.
|
|
348
|
-
if (targets.
|
|
349
|
-
if (targets.
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
console.log("
|
|
357
|
-
console.log("
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
//
|
|
385
|
-
//
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
cloned
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
.
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
fs.existsSync(path.join(workspaceRoot, '.
|
|
424
|
-
fs.existsSync(path.join(workspaceRoot, '.
|
|
425
|
-
fs.existsSync(path.join(workspaceRoot, '.
|
|
426
|
-
fs.existsSync(path.join(workspaceRoot, '
|
|
427
|
-
fs.existsSync(path.join(workspaceRoot, '.
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
fs.existsSync(path.join(userHome, '.
|
|
434
|
-
fs.existsSync(path.join(userHome, '.
|
|
435
|
-
fs.existsSync(path.join(
|
|
436
|
-
fs.existsSync(path.join(getUserPromptsDir(), 'harness.
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
console.log(
|
|
442
|
-
console.log(
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
let
|
|
446
|
-
let
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
{ id: '
|
|
478
|
-
{ id: '
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
const
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
//
|
|
509
|
-
//
|
|
510
|
-
//
|
|
511
|
-
//
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
console.log("
|
|
525
|
-
console.log("
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
//
|
|
532
|
-
//
|
|
533
|
-
//
|
|
534
|
-
//
|
|
535
|
-
//
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
advisory.removeAdvisoryText(path.join(workspaceRoot, '.
|
|
547
|
-
advisory.removeAdvisoryText(path.join(workspaceRoot, '.
|
|
548
|
-
advisory.removeAdvisoryText(path.join(workspaceRoot, '
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
//
|
|
555
|
-
//
|
|
556
|
-
//
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
console.log("
|
|
567
|
-
console.log("
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
const
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
//
|
|
594
|
-
//
|
|
595
|
-
//
|
|
596
|
-
//
|
|
597
|
-
//
|
|
598
|
-
cleanEmptyDirs(path.join(
|
|
599
|
-
cleanEmptyDirs(globalHarnessDir, [userHome]);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
if (removeSkills && installedSkills.length > 0) {
|
|
603
|
-
// This block is only reached via a bulk "remove everything detected"
|
|
604
|
-
// path (interactive "all", or the non-interactive -y/--skills bypass) -
|
|
605
|
-
// never via the interactive per-item picker, which already removes
|
|
606
|
-
// exactly what the user checked. A bulk sweep must not reach into the
|
|
607
|
-
// real global home directory unless the user separately opted into
|
|
608
|
-
// global scope (same rule as the config removal above). Every entry in
|
|
609
|
-
// `installedSkills` is already manifest-tracked (or, for legacy
|
|
610
|
-
// installs, author-marker-verified) - see lib/skills.js - so this never
|
|
611
|
-
// touches a skill Harness didn't install.
|
|
612
|
-
const skillsToRemove = installedSkills.filter(s => s.scope !== 'global' || removeGlobal);
|
|
613
|
-
const skippedGlobalCount = installedSkills.length - skillsToRemove.length;
|
|
614
|
-
|
|
615
|
-
console.log("\n-------------------------------------------------");
|
|
616
|
-
console.log("Uninstalling all detected skills...");
|
|
617
|
-
console.log("-------------------------------------------------");
|
|
618
|
-
for (const skill of skillsToRemove) {
|
|
619
|
-
if (fs.existsSync(skill.dirPath)) {
|
|
620
|
-
skills.removeSkill(skill);
|
|
621
|
-
console.log(` ✅ Removed skill: ${skill.id} (${skill.scope})`);
|
|
622
|
-
cleanEmptyDirs(skill.parentPath, [workspaceRoot, userHome]);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
if (skippedGlobalCount > 0) {
|
|
626
|
-
console.log(` ℹ️ Skipped ${skippedGlobalCount} global-scoped skill(s) - pass --global (or select "Uninstall ... Global Home") to remove those too.`);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
// Final sweep: a platform's harness-everything/ dir (manifest + Claude's
|
|
631
|
-
// skill copies) may have only just become empty above - either through the
|
|
632
|
-
// bulk removeSkills block or the interactive per-item picker, both of
|
|
633
|
-
// which clean up the skill's own parent dir but not necessarily this one.
|
|
634
|
-
// Always safe to run unconditionally: cleanEmptyDirs only ever removes a
|
|
635
|
-
// directory that's genuinely empty.
|
|
636
|
-
for (const platform of platformModules) {
|
|
637
|
-
if (typeof platform.getHarnessDir !== 'function') continue;
|
|
638
|
-
cleanEmptyDirs(platform.getHarnessDir(workspaceRoot), [workspaceRoot, userHome]);
|
|
639
|
-
}
|
|
640
|
-
cleanEmptyDirs(path.join(workspaceRoot, '.claude'), [workspaceRoot, userHome]);
|
|
641
|
-
|
|
642
|
-
console.log("\n🎉 UNINSTALL COMPLETE! Harness OS has been removed.");
|
|
643
|
-
console.log("=================================================");
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
main().catch(err => {
|
|
647
|
-
console.error(`\n❌ Install failed: ${err.message}`);
|
|
648
|
-
process.exit(1);
|
|
649
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Lightweight, non-intrusive installer for Harness OS.
|
|
4
|
+
* Detects the local project layout (Claude Code, Cursor, etc.)
|
|
5
|
+
* and merges the Harness hook definitions safely without destroying user configs.
|
|
6
|
+
*
|
|
7
|
+
* Placement rule: a platform's own native file/folder (`.claude/settings.json`,
|
|
8
|
+
* `.cursorrules`, `.cursor/skills/`, etc.) is never moved - it lives exactly
|
|
9
|
+
* where that platform expects it. Anything Harness itself needs that has no
|
|
10
|
+
* native home (install manifest, runtime hook state, and - only for Claude,
|
|
11
|
+
* which has no native project-skill directory - the installed skill copies)
|
|
12
|
+
* converges into one exclusively-owned subfolder per platform:
|
|
13
|
+
* `<platform-dir>/harness-everything/`. Nothing else ever creates a directory
|
|
14
|
+
* literally named "harness-everything", so it can be added or removed as a
|
|
15
|
+
* unit without touching anything else in that platform's directory.
|
|
16
|
+
*
|
|
17
|
+
* This file only orchestrates the install/uninstall flow (CLI parsing,
|
|
18
|
+
* interactive prompts, sequencing). Each concern it delegates to lives in
|
|
19
|
+
* scripts/lib/: skill discovery & manifest-tracked install/removal
|
|
20
|
+
* (lib/skills.js, lib/manifest.js), Claude Code hook merge/removal
|
|
21
|
+
* (lib/claude-hooks.js), advisory-file injection for hookless platforms
|
|
22
|
+
* (lib/advisory-text.js), .gitignore/empty-dir housekeeping (lib/gitignore.js),
|
|
23
|
+
* and the terminal picker widgets (lib/prompts.js).
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const fs = require('fs');
|
|
27
|
+
const path = require('path');
|
|
28
|
+
|
|
29
|
+
const { getWorkspaceRoot, getUserPromptsDir } = require('./lib/workspace');
|
|
30
|
+
const { interactiveSelect, interactiveSingleSelect, askQuestion } = require('./lib/prompts');
|
|
31
|
+
const advisory = require('./lib/advisory-text');
|
|
32
|
+
const claudeHooks = require('./lib/claude-hooks');
|
|
33
|
+
const manifest = require('./lib/manifest');
|
|
34
|
+
const skills = require('./lib/skills');
|
|
35
|
+
const { ensureWorkspaceGitignorePatterns, cleanEmptyDirs } = require('./lib/gitignore');
|
|
36
|
+
|
|
37
|
+
const userHome = require('os').homedir();
|
|
38
|
+
const workspaceRoot = getWorkspaceRoot();
|
|
39
|
+
const harnessSourceDir = path.resolve(__dirname, '..');
|
|
40
|
+
const packageVersion = require(path.join(harnessSourceDir, 'package.json')).version;
|
|
41
|
+
|
|
42
|
+
let platformModules = [];
|
|
43
|
+
try {
|
|
44
|
+
platformModules = require(path.join(__dirname, '../hooks/scripts/lib/platforms'));
|
|
45
|
+
} catch (e) {
|
|
46
|
+
platformModules = []; // Best-effort - gitignore hints and state cleanup degrade gracefully without it.
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function main() {
|
|
50
|
+
const args = process.argv;
|
|
51
|
+
const command = args[2] || 'install'; // 'install', 'add', 'skills', etc.
|
|
52
|
+
|
|
53
|
+
const isInteractive = process.stdin.isTTY && process.stdout.isTTY;
|
|
54
|
+
const hasClaudeFlag = args.includes('--claude');
|
|
55
|
+
const hasCursorFlag = args.includes('--cursor');
|
|
56
|
+
const hasCopilotFlag = args.includes('--copilot');
|
|
57
|
+
const hasCodexFlag = args.includes('--codex');
|
|
58
|
+
const hasContinueFlag = args.includes('--continue');
|
|
59
|
+
const hasHermesFlag = args.includes('--hermes');
|
|
60
|
+
const hasAllFlag = args.includes('--all');
|
|
61
|
+
const hasGlobalFlag = args.includes('--global') || args.includes('-g');
|
|
62
|
+
const hasYesFlag = args.includes('-y') || args.includes('--yes');
|
|
63
|
+
const hasAnyPlatformFlag = hasClaudeFlag || hasCursorFlag || hasCopilotFlag || hasCodexFlag || hasContinueFlag || hasHermesFlag || hasAllFlag;
|
|
64
|
+
const requestedSkills = ['add', 'skill', 'skills'].includes(command)
|
|
65
|
+
? args.slice(3).filter(arg => !arg.startsWith('-'))
|
|
66
|
+
: [];
|
|
67
|
+
|
|
68
|
+
const claudeExists = fs.existsSync(path.join(workspaceRoot, '.claude'));
|
|
69
|
+
const cursorExists = fs.existsSync(path.join(workspaceRoot, '.cursorrules'));
|
|
70
|
+
const copilotExists = fs.existsSync(path.join(workspaceRoot, '.github', 'copilot-instructions.md')) || fs.existsSync(path.join(workspaceRoot, '.github'));
|
|
71
|
+
const codexExists = fs.existsSync(path.join(workspaceRoot, 'AGENTS.md'));
|
|
72
|
+
const continueExists = fs.existsSync(path.join(workspaceRoot, '.continue'));
|
|
73
|
+
const hermesExists = fs.existsSync(path.join(workspaceRoot, '.hermes.md'));
|
|
74
|
+
const detectedAny = claudeExists || cursorExists || copilotExists || codexExists || continueExists || hermesExists;
|
|
75
|
+
|
|
76
|
+
if (command === 'uninstall') {
|
|
77
|
+
await runUninstall({ hasYesFlag, args, isInteractive });
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let targets = {
|
|
82
|
+
claude: false,
|
|
83
|
+
cursor: false,
|
|
84
|
+
copilot: false,
|
|
85
|
+
codex: false,
|
|
86
|
+
continue: false,
|
|
87
|
+
hermes: false
|
|
88
|
+
};
|
|
89
|
+
let chosenSkills = [];
|
|
90
|
+
let isGlobal = hasGlobalFlag;
|
|
91
|
+
|
|
92
|
+
const runInteractively = isInteractive && !hasYesFlag && !hasAnyPlatformFlag && (['install', 'add', 'skill', 'skills'].includes(command) && requestedSkills.length === 0);
|
|
93
|
+
|
|
94
|
+
if (runInteractively) {
|
|
95
|
+
console.log("=================================================");
|
|
96
|
+
console.log(` Harness OS - Interactive Setup `);
|
|
97
|
+
console.log("=================================================");
|
|
98
|
+
|
|
99
|
+
// Step 1: Choose platforms
|
|
100
|
+
console.log("\n[Step 1/3] Select target platforms to configure:");
|
|
101
|
+
const platformItems = [
|
|
102
|
+
{ id: 'claude', name: `Claude Code (hook-enforced) ${claudeExists ? '(Detected)' : ''}`, checked: claudeExists || !detectedAny },
|
|
103
|
+
{ id: 'cursor', name: `Cursor (.cursorrules) ${cursorExists ? '(Detected)' : ''}`, checked: cursorExists },
|
|
104
|
+
{ id: 'copilot', name: `Copilot (.github/copilot-...) ${copilotExists ? '(Detected)' : ''}`, checked: copilotExists },
|
|
105
|
+
{ id: 'codex', name: `Codex (AGENTS.md) ${codexExists ? '(Detected)' : ''}`, checked: codexExists },
|
|
106
|
+
{ id: 'continue', name: `Continue.dev (.continue/rules) ${continueExists ? '(Detected)' : ''}`, checked: continueExists },
|
|
107
|
+
{ id: 'hermes', name: `Hermes Agent (.hermes.md) ${hermesExists ? '(Detected)' : ''}`, checked: hermesExists }
|
|
108
|
+
];
|
|
109
|
+
const selectedPlatforms = await interactiveSelect(platformItems);
|
|
110
|
+
selectedPlatforms.forEach(p => {
|
|
111
|
+
targets[p.id] = p.checked;
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Step 2: Choose skills
|
|
115
|
+
const availableSkills = skills.getAvailableSkills(harnessSourceDir);
|
|
116
|
+
console.log("\n[Step 2/3] Select skills to install:");
|
|
117
|
+
const skillItems = availableSkills.map(s => {
|
|
118
|
+
const info = skills.getSkillInfo(harnessSourceDir, s);
|
|
119
|
+
// Pre-check essential skills
|
|
120
|
+
const isEssential = ['tdd', 'git-commit', 'todo-driven-workflow', 'verification-loop'].includes(s);
|
|
121
|
+
const isHarnessEverything = s === 'harness-everything';
|
|
122
|
+
return {
|
|
123
|
+
id: s,
|
|
124
|
+
name: isHarnessEverything ? `${s} (Required)` : s,
|
|
125
|
+
description: info ? info.description : '',
|
|
126
|
+
checked: isEssential || isHarnessEverything
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
const selectedSkills = await interactiveSelect(skillItems, 8);
|
|
130
|
+
chosenSkills = selectedSkills.filter(s => s.checked).map(s => s.id);
|
|
131
|
+
|
|
132
|
+
// Step 3: Choose global vs local location
|
|
133
|
+
console.log("\n[Step 3/3] Select installation scope / location:");
|
|
134
|
+
const locationItems = [
|
|
135
|
+
{ id: 'local', name: "Local Workspace (Install to current project directories)", checked: true },
|
|
136
|
+
{ id: 'global', name: "Global (~/.agents - applies across all projects)", checked: false }
|
|
137
|
+
];
|
|
138
|
+
const chosenLocationId = await interactiveSingleSelect(locationItems);
|
|
139
|
+
isGlobal = chosenLocationId === 'global';
|
|
140
|
+
} else {
|
|
141
|
+
// Non-interactive/bypass mode
|
|
142
|
+
isGlobal = hasGlobalFlag;
|
|
143
|
+
|
|
144
|
+
if (['add', 'skill', 'skills'].includes(command)) {
|
|
145
|
+
if (requestedSkills.length > 0) {
|
|
146
|
+
const availableSkills = skills.getAvailableSkills(harnessSourceDir);
|
|
147
|
+
for (const skillName of requestedSkills) {
|
|
148
|
+
if (availableSkills.includes(skillName)) {
|
|
149
|
+
chosenSkills.push(skillName);
|
|
150
|
+
} else {
|
|
151
|
+
console.error(`⚠️ Skill "${skillName}" not found. Skipping.`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
chosenSkills = ['tdd', 'git-commit', 'todo-driven-workflow', 'verification-loop', 'zoom-out', 'install-cognitive-os'];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!isGlobal) {
|
|
159
|
+
targets.claude = claudeExists;
|
|
160
|
+
targets.cursor = cursorExists;
|
|
161
|
+
targets.copilot = copilotExists;
|
|
162
|
+
targets.codex = codexExists;
|
|
163
|
+
targets.continue = continueExists;
|
|
164
|
+
targets.hermes = hermesExists;
|
|
165
|
+
if (!detectedAny) {
|
|
166
|
+
targets.claude = true;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
} else {
|
|
170
|
+
if (hasAnyPlatformFlag) {
|
|
171
|
+
if (hasAllFlag) {
|
|
172
|
+
targets.claude = true;
|
|
173
|
+
targets.cursor = true;
|
|
174
|
+
targets.copilot = true;
|
|
175
|
+
targets.codex = true;
|
|
176
|
+
targets.continue = true;
|
|
177
|
+
targets.hermes = true;
|
|
178
|
+
} else {
|
|
179
|
+
targets.claude = hasClaudeFlag;
|
|
180
|
+
targets.cursor = hasCursorFlag;
|
|
181
|
+
targets.copilot = hasCopilotFlag;
|
|
182
|
+
targets.codex = hasCodexFlag;
|
|
183
|
+
targets.continue = hasContinueFlag;
|
|
184
|
+
targets.hermes = hasHermesFlag;
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
if (detectedAny) {
|
|
188
|
+
targets.claude = claudeExists;
|
|
189
|
+
targets.cursor = cursorExists;
|
|
190
|
+
targets.copilot = copilotExists;
|
|
191
|
+
targets.codex = codexExists;
|
|
192
|
+
targets.continue = continueExists;
|
|
193
|
+
targets.hermes = hermesExists;
|
|
194
|
+
} else {
|
|
195
|
+
targets.claude = true;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
chosenSkills = ['tdd', 'git-commit', 'todo-driven-workflow', 'verification-loop', 'zoom-out', 'install-cognitive-os'];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Ensure harness-everything is ALWAYS included in chosenSkills
|
|
203
|
+
if (!chosenSkills.includes('harness-everything')) {
|
|
204
|
+
chosenSkills.push('harness-everything');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// If no targets selected at all, exit
|
|
208
|
+
if (!targets.claude && !targets.cursor && !targets.copilot && !targets.codex && !targets.continue && !targets.hermes && !isGlobal) {
|
|
209
|
+
console.log("\n❌ No platforms selected. Exiting.");
|
|
210
|
+
process.exit(0);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const targetWorkspaceRoot = isGlobal ? path.join(userHome, '.agents') : workspaceRoot;
|
|
214
|
+
|
|
215
|
+
console.log("\n-------------------------------------------------");
|
|
216
|
+
console.log(`Installing Harness OS to ${isGlobal ? 'Global Home' : 'Local Workspace'}`);
|
|
217
|
+
console.log("-------------------------------------------------");
|
|
218
|
+
|
|
219
|
+
// Merge into .claude/settings.json (only if Claude Code selected)
|
|
220
|
+
if (targets.claude) {
|
|
221
|
+
installClaudeHooks({ isGlobal, targetWorkspaceRoot });
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Cursor
|
|
225
|
+
if (targets.cursor) {
|
|
226
|
+
const targetFile = isGlobal ? path.join(userHome, '.cursorrules') : path.join(targetWorkspaceRoot, '.cursorrules');
|
|
227
|
+
advisory.injectAdvisoryText(targetFile, '# Cursor Project Rules', isGlobal ? '~/.cursorrules' : '.cursorrules');
|
|
228
|
+
}
|
|
229
|
+
// Copilot Chat
|
|
230
|
+
if (targets.copilot) {
|
|
231
|
+
if (!isGlobal) {
|
|
232
|
+
const targetFile = path.join(targetWorkspaceRoot, '.github', 'copilot-instructions.md');
|
|
233
|
+
advisory.injectAdvisoryText(targetFile, '# Copilot Instructions', '.github/copilot-instructions.md');
|
|
234
|
+
} else {
|
|
235
|
+
try {
|
|
236
|
+
const promptsDir = getUserPromptsDir();
|
|
237
|
+
if (!fs.existsSync(promptsDir)) {
|
|
238
|
+
fs.mkdirSync(promptsDir, { recursive: true });
|
|
239
|
+
}
|
|
240
|
+
const vscodeInstFile = path.join(promptsDir, 'harness.instructions.md');
|
|
241
|
+
fs.writeFileSync(vscodeInstFile, advisory.buildCopilotGlobalContent(), 'utf8');
|
|
242
|
+
console.log(` ✅ Installed global Copilot instructions to VS Code: ${vscodeInstFile}`);
|
|
243
|
+
} catch (err) {
|
|
244
|
+
console.warn(` ⚠️ Failed to write VS Code user prompts folder: ${err.message}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// Codex
|
|
249
|
+
if (targets.codex) {
|
|
250
|
+
if (!isGlobal) {
|
|
251
|
+
const targetFile = path.join(targetWorkspaceRoot, 'AGENTS.md');
|
|
252
|
+
advisory.injectAdvisoryText(targetFile, '# AGENTS.md', 'AGENTS.md');
|
|
253
|
+
} else {
|
|
254
|
+
try {
|
|
255
|
+
const promptsDir = getUserPromptsDir();
|
|
256
|
+
if (!fs.existsSync(promptsDir)) {
|
|
257
|
+
fs.mkdirSync(promptsDir, { recursive: true });
|
|
258
|
+
}
|
|
259
|
+
const vscodeAgentFile = path.join(promptsDir, 'harness.agent.md');
|
|
260
|
+
fs.writeFileSync(vscodeAgentFile, advisory.buildCodexGlobalContent(), 'utf8');
|
|
261
|
+
console.log(` ✅ Installed global Codex agent to VS Code: ${vscodeAgentFile}`);
|
|
262
|
+
} catch (err) {
|
|
263
|
+
console.warn(` ⚠️ Failed to write VS Code user prompts folder: ${err.message}`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
// Continue.dev
|
|
268
|
+
if (targets.continue) {
|
|
269
|
+
const targetFile = isGlobal ? path.join(userHome, '.continue', 'rules', 'harness.md') : path.join(workspaceRoot, '.continue', 'rules', 'harness.md');
|
|
270
|
+
advisory.installContinueRule(targetFile, isGlobal ? '~/.continue/rules/harness.md' : '.continue/rules/harness.md');
|
|
271
|
+
}
|
|
272
|
+
// Hermes Agent (reads .hermes.md/AGENTS.md/CLAUDE.md/.cursorrules from the
|
|
273
|
+
// project it's launched in - project scope only, no documented global
|
|
274
|
+
// equivalent, so --global is a documented no-op here rather than a guess).
|
|
275
|
+
if (targets.hermes) {
|
|
276
|
+
if (!isGlobal) {
|
|
277
|
+
const targetFile = path.join(targetWorkspaceRoot, '.hermes.md');
|
|
278
|
+
advisory.injectAdvisoryText(targetFile, '# .hermes.md', '.hermes.md');
|
|
279
|
+
} else {
|
|
280
|
+
console.log(` ℹ️ Hermes Agent has no documented global instructions file (it reads .hermes.md from the current project directory only) - skipping global install for --hermes.`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Install chosen skills. Every platform's skills stay at that platform's
|
|
285
|
+
// own native location (unchanged) EXCEPT Claude, which never had one -
|
|
286
|
+
// its copy lives under its own harness-everything/ subfolder instead.
|
|
287
|
+
// Every platform still gets its own harness-everything/manifest.json so
|
|
288
|
+
// "what did we install here" is always precisely answerable per platform.
|
|
289
|
+
if (chosenSkills.length > 0) {
|
|
290
|
+
const targetDirs = [];
|
|
291
|
+
if (isGlobal) {
|
|
292
|
+
const globalAgentsDir = path.join(userHome, '.agents');
|
|
293
|
+
targetDirs.push({
|
|
294
|
+
path: path.join(globalAgentsDir, 'skills'),
|
|
295
|
+
label: '~/.agents/skills/',
|
|
296
|
+
manifestPath: manifest.getManifestPath(globalAgentsDir),
|
|
297
|
+
});
|
|
298
|
+
} else {
|
|
299
|
+
if (targets.claude) {
|
|
300
|
+
const claudeDir = path.join(workspaceRoot, '.claude');
|
|
301
|
+
targetDirs.push({
|
|
302
|
+
path: path.join(manifest.getHarnessDir(claudeDir), 'skills'),
|
|
303
|
+
label: '.claude/harness-everything/skills/',
|
|
304
|
+
manifestPath: manifest.getManifestPath(claudeDir),
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
if (targets.cursor) {
|
|
308
|
+
const cursorDir = path.join(workspaceRoot, '.cursor');
|
|
309
|
+
targetDirs.push({ path: path.join(cursorDir, 'skills'), label: '.cursor/skills/', manifestPath: manifest.getManifestPath(cursorDir) });
|
|
310
|
+
}
|
|
311
|
+
if (targets.copilot) {
|
|
312
|
+
const githubDir = path.join(workspaceRoot, '.github');
|
|
313
|
+
targetDirs.push({ path: path.join(githubDir, 'skills'), label: '.github/skills/', manifestPath: manifest.getManifestPath(githubDir) });
|
|
314
|
+
}
|
|
315
|
+
if (targets.codex) {
|
|
316
|
+
const codexDir = path.join(workspaceRoot, '.codex');
|
|
317
|
+
targetDirs.push({ path: path.join(codexDir, 'skills'), label: '.codex/skills/', manifestPath: manifest.getManifestPath(codexDir) });
|
|
318
|
+
}
|
|
319
|
+
if (targets.continue) {
|
|
320
|
+
const continueDir = path.join(workspaceRoot, '.continue');
|
|
321
|
+
targetDirs.push({ path: path.join(continueDir, 'skills'), label: '.continue/skills/', manifestPath: manifest.getManifestPath(continueDir) });
|
|
322
|
+
}
|
|
323
|
+
// Hermes has no documented project-level skills directory - its skills
|
|
324
|
+
// system is per-profile only (~/.hermes/skills/), which the isGlobal
|
|
325
|
+
// branch above already covers via the shared global harness-everything/ target.
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
console.log(`\nInstalling Harness skills:`);
|
|
329
|
+
skills.installSkillsToTargets({ chosenSkills, targetDirs, harnessSourceDir, packageVersion });
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (!isGlobal) {
|
|
333
|
+
const patternsToIgnore = [];
|
|
334
|
+
for (const platform of platformModules) {
|
|
335
|
+
if (targets[platform.name] && typeof platform.getIgnorePatterns === 'function') {
|
|
336
|
+
for (const pattern of platform.getIgnorePatterns(workspaceRoot)) {
|
|
337
|
+
if (!patternsToIgnore.includes(pattern)) {
|
|
338
|
+
patternsToIgnore.push(pattern);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (patternsToIgnore.length === 0) {
|
|
344
|
+
// Fallback if platform modules failed to load entirely.
|
|
345
|
+
if (targets.claude) patternsToIgnore.push('.claude/harness-everything/');
|
|
346
|
+
if (targets.cursor) patternsToIgnore.push('.cursor/harness-everything/', '.cursor/skills/');
|
|
347
|
+
if (targets.copilot) patternsToIgnore.push('.github/harness-everything/', '.github/skills/');
|
|
348
|
+
if (targets.codex) patternsToIgnore.push('.codex/harness-everything/', '.codex/skills/');
|
|
349
|
+
if (targets.continue) patternsToIgnore.push('.continue/harness-everything/', '.continue/skills/');
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
ensureWorkspaceGitignorePatterns(workspaceRoot, patternsToIgnore);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
console.log("\n🎉 INSTALL SUCCESS! Harness OS is now protecting this project.");
|
|
356
|
+
console.log("Try your first AI interaction! The bootstrapped OS will auto-route your tier.");
|
|
357
|
+
console.log("=================================================");
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function installClaudeHooks({ isGlobal, targetWorkspaceRoot }) {
|
|
361
|
+
const claudeDir = isGlobal ? path.join(userHome, '.claude') : path.join(targetWorkspaceRoot, '.claude');
|
|
362
|
+
if (!fs.existsSync(claudeDir)) {
|
|
363
|
+
fs.mkdirSync(claudeDir, { recursive: true });
|
|
364
|
+
console.log(` Created ${isGlobal ? '~/.claude' : '.claude'} directory`);
|
|
365
|
+
}
|
|
366
|
+
const claudeSettingsFile = path.join(claudeDir, 'settings.json');
|
|
367
|
+
let claudeConfig = {};
|
|
368
|
+
if (fs.existsSync(claudeSettingsFile)) {
|
|
369
|
+
try {
|
|
370
|
+
claudeConfig = JSON.parse(fs.readFileSync(claudeSettingsFile, 'utf8'));
|
|
371
|
+
} catch (e) {
|
|
372
|
+
console.warn(` ⚠️ Existing ${isGlobal ? '~' : ''}/.claude/settings.json is malformed, creating fresh one.`);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const resolvedHooks = resolveSourceHooks();
|
|
377
|
+
claudeHooks.mergeHarnessHooks(claudeConfig, resolvedHooks);
|
|
378
|
+
|
|
379
|
+
fs.writeFileSync(claudeSettingsFile, JSON.stringify(claudeConfig, null, 2), 'utf8');
|
|
380
|
+
console.log(` ✅ Configured Claude Code hooks safely in ${isGlobal ? '~' : ''}/.claude/settings.json`);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Resolves the source hooks.json into absolute script paths and stamps each
|
|
384
|
+
// entry with which package/version/author installed it (informational -
|
|
385
|
+
// removal itself still keys off the `harness:` id prefix alone).
|
|
386
|
+
function resolveSourceHooks() {
|
|
387
|
+
const sourceHooksFile = path.join(harnessSourceDir, 'hooks', 'hooks.json');
|
|
388
|
+
if (!fs.existsSync(sourceHooksFile)) {
|
|
389
|
+
throw new Error(`Harness source hooks definition not found at: ${sourceHooksFile}`);
|
|
390
|
+
}
|
|
391
|
+
const sourceHooksObj = JSON.parse(fs.readFileSync(sourceHooksFile, 'utf8'));
|
|
392
|
+
|
|
393
|
+
const resolvedHooks = {};
|
|
394
|
+
for (const [hookType, hookList] of Object.entries(sourceHooksObj.hooks || {})) {
|
|
395
|
+
resolvedHooks[hookType] = hookList.map(hookItem => {
|
|
396
|
+
const cloned = JSON.parse(JSON.stringify(hookItem));
|
|
397
|
+
if (cloned.hooks) {
|
|
398
|
+
cloned.hooks = cloned.hooks.map(h => {
|
|
399
|
+
if (h.type === 'command' && h.command) {
|
|
400
|
+
h.command = h.command.replace(/^node\s+"?([^"\s]+)"?/, (m, scriptPath) => {
|
|
401
|
+
const abs = path.isAbsolute(scriptPath) ? scriptPath : path.join(harnessSourceDir, scriptPath);
|
|
402
|
+
return `node "${abs}"`;
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
return h;
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
cloned.harness = { package: manifest.PACKAGE_NAME, version: packageVersion, author: manifest.HARNESS_AUTHOR };
|
|
409
|
+
return cloned;
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
return resolvedHooks;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
async function runUninstall({ hasYesFlag, args, isInteractive }) {
|
|
416
|
+
const localHarnessDirs = platformModules
|
|
417
|
+
.filter(p => typeof p.getHarnessDir === 'function')
|
|
418
|
+
.map(p => p.getHarnessDir(workspaceRoot));
|
|
419
|
+
|
|
420
|
+
const localInstalled = fs.existsSync(path.join(workspaceRoot, '.harness')) || // legacy pre-reorg root
|
|
421
|
+
localHarnessDirs.some(d => fs.existsSync(d)) ||
|
|
422
|
+
fs.existsSync(path.join(workspaceRoot, '.claude', 'settings.json')) ||
|
|
423
|
+
fs.existsSync(path.join(workspaceRoot, '.cursorrules')) ||
|
|
424
|
+
fs.existsSync(path.join(workspaceRoot, '.github', 'copilot-instructions.md')) ||
|
|
425
|
+
fs.existsSync(path.join(workspaceRoot, 'AGENTS.md')) ||
|
|
426
|
+
fs.existsSync(path.join(workspaceRoot, '.continue', 'rules', 'harness.md')) ||
|
|
427
|
+
fs.existsSync(path.join(workspaceRoot, '.hermes.md'));
|
|
428
|
+
|
|
429
|
+
const globalAgentsDir = path.join(userHome, '.agents');
|
|
430
|
+
const globalHarnessDir = manifest.getHarnessDir(globalAgentsDir);
|
|
431
|
+
const globalInstalled = fs.existsSync(globalHarnessDir) ||
|
|
432
|
+
fs.existsSync(path.join(userHome, '.claude', 'settings.json')) ||
|
|
433
|
+
fs.existsSync(path.join(userHome, '.cursorrules')) ||
|
|
434
|
+
fs.existsSync(path.join(userHome, '.continue', 'rules', 'harness.md')) ||
|
|
435
|
+
fs.existsSync(path.join(getUserPromptsDir(), 'harness.instructions.md')) ||
|
|
436
|
+
fs.existsSync(path.join(getUserPromptsDir(), 'harness.agent.md'));
|
|
437
|
+
|
|
438
|
+
const installedSkills = skills.getInstalledSkills(workspaceRoot, userHome);
|
|
439
|
+
|
|
440
|
+
console.log("=================================================");
|
|
441
|
+
console.log(` Harness OS - Uninstall Utility `);
|
|
442
|
+
console.log("=================================================");
|
|
443
|
+
|
|
444
|
+
let removeLocal = false;
|
|
445
|
+
let removeGlobal = false;
|
|
446
|
+
let removeSkills = false;
|
|
447
|
+
|
|
448
|
+
const runInteractively = isInteractive && !hasYesFlag;
|
|
449
|
+
|
|
450
|
+
if (runInteractively) {
|
|
451
|
+
const choices = [];
|
|
452
|
+
if (localInstalled) {
|
|
453
|
+
choices.push({ id: 'local', name: 'Uninstall Harness OS from Local Workspace (Hooks & Advisory files)', checked: true });
|
|
454
|
+
}
|
|
455
|
+
if (globalInstalled) {
|
|
456
|
+
choices.push({ id: 'global', name: 'Uninstall Harness OS from Global Home (~/.agents, VS Code Prompts, etc.)', checked: false });
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
if (choices.length > 0) {
|
|
460
|
+
console.log("\nSelect installation scopes to uninstall:");
|
|
461
|
+
const selectedScopes = await interactiveSelect(choices);
|
|
462
|
+
removeLocal = selectedScopes.some(s => s.id === 'local' && s.checked);
|
|
463
|
+
removeGlobal = selectedScopes.some(s => s.id === 'global' && s.checked);
|
|
464
|
+
} else {
|
|
465
|
+
console.log("\nNo Harness OS installation detected in local workspace or global home.");
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
if (installedSkills.length > 0) {
|
|
469
|
+
console.log(`\nDetected ${installedSkills.length} installed skill(s):`);
|
|
470
|
+
installedSkills.forEach(s => {
|
|
471
|
+
console.log(` - ${s.id} (${s.scope})`);
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
console.log("\nWould you like to uninstall these skills?");
|
|
475
|
+
const skillChoiceItems = [
|
|
476
|
+
{ id: 'all', name: 'Remove ALL detected skills', checked: true },
|
|
477
|
+
{ id: 'select', name: 'Select specific skills to remove', checked: false },
|
|
478
|
+
{ id: 'none', name: 'Keep all skills', checked: false }
|
|
479
|
+
];
|
|
480
|
+
const skillAction = await interactiveSingleSelect(skillChoiceItems);
|
|
481
|
+
|
|
482
|
+
if (skillAction === 'all') {
|
|
483
|
+
removeSkills = true;
|
|
484
|
+
} else if (skillAction === 'select') {
|
|
485
|
+
const selectSkillItems = installedSkills.map(s => ({
|
|
486
|
+
id: s.dirPath,
|
|
487
|
+
name: `${s.id} (${s.scope})`,
|
|
488
|
+
checked: true,
|
|
489
|
+
_entry: s
|
|
490
|
+
}));
|
|
491
|
+
const chosenSkillsToRemove = await interactiveSelect(selectSkillItems);
|
|
492
|
+
for (const item of chosenSkillsToRemove) {
|
|
493
|
+
if (item.checked) {
|
|
494
|
+
skills.removeSkill(item._entry);
|
|
495
|
+
console.log(` ✅ Removed skill: ${item.name}`);
|
|
496
|
+
cleanEmptyDirs(item._entry.parentPath, [workspaceRoot, userHome]);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
} else {
|
|
502
|
+
const hasLocalFlag = args.includes('--local');
|
|
503
|
+
const hasGlobalUninstallFlag = args.includes('--global') || args.includes('-g');
|
|
504
|
+
const hasSkillsUninstallFlag = args.includes('--skills');
|
|
505
|
+
|
|
506
|
+
if (hasYesFlag) {
|
|
507
|
+
// -y auto-confirms local (cwd-scoped, obviously "this project") but
|
|
508
|
+
// must NEVER auto-confirm global (~/.agents, ~/.claude, etc.) just
|
|
509
|
+
// because something global happens to exist - home-directory state
|
|
510
|
+
// isn't implied by "yes" to the workspace you're standing in, and a
|
|
511
|
+
// bare `-y` run from any random project must not be able to wipe it.
|
|
512
|
+
removeLocal = localInstalled;
|
|
513
|
+
removeGlobal = globalInstalled && hasGlobalUninstallFlag;
|
|
514
|
+
removeSkills = installedSkills.length > 0;
|
|
515
|
+
} else {
|
|
516
|
+
removeLocal = hasLocalFlag;
|
|
517
|
+
removeGlobal = hasGlobalUninstallFlag;
|
|
518
|
+
removeSkills = hasSkillsUninstallFlag;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (removeLocal) {
|
|
523
|
+
console.log("\n-------------------------------------------------");
|
|
524
|
+
console.log("Uninstalling Harness OS from Local Workspace...");
|
|
525
|
+
console.log("-------------------------------------------------");
|
|
526
|
+
|
|
527
|
+
const localSettingsFile = path.join(workspaceRoot, '.claude', 'settings.json');
|
|
528
|
+
claudeHooks.removeHarnessHooks(localSettingsFile);
|
|
529
|
+
|
|
530
|
+
// Clear each platform's own runtime hook-state. Manifest + any remaining
|
|
531
|
+
// skills are a separate, opt-in concern handled by the skills-removal
|
|
532
|
+
// step below, so the harness-everything/ dir itself isn't swept here yet
|
|
533
|
+
// - manifest.json (deleted only once its skills list empties out) may
|
|
534
|
+
// still be sitting in it at this point. The final sweep near the end of
|
|
535
|
+
// this function catches it once skill removal has actually run.
|
|
536
|
+
for (const platform of platformModules) {
|
|
537
|
+
if (typeof platform.getStateDir !== 'function') continue;
|
|
538
|
+
const stateDir = platform.getStateDir(workspaceRoot);
|
|
539
|
+
if (fs.existsSync(stateDir)) {
|
|
540
|
+
fs.rmSync(stateDir, { recursive: true, force: true });
|
|
541
|
+
console.log(` ✅ Removed local ${path.relative(workspaceRoot, stateDir).replace(/\\/g, '/')}/ directory`);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
advisory.removeAdvisoryText(path.join(workspaceRoot, '.cursorrules'));
|
|
546
|
+
advisory.removeAdvisoryText(path.join(workspaceRoot, '.github', 'copilot-instructions.md'));
|
|
547
|
+
advisory.removeAdvisoryText(path.join(workspaceRoot, 'AGENTS.md'));
|
|
548
|
+
advisory.removeAdvisoryText(path.join(workspaceRoot, '.hermes.md'));
|
|
549
|
+
|
|
550
|
+
advisory.removeContinueRule(path.join(workspaceRoot, '.continue', 'rules', 'harness.md'));
|
|
551
|
+
cleanEmptyDirs(path.join(workspaceRoot, '.continue', 'rules'), [workspaceRoot, userHome]);
|
|
552
|
+
|
|
553
|
+
// One-time migration cleanup: earlier versions used a self-invented
|
|
554
|
+
// top-level .harness/ directory for Claude's manifest + skill copies.
|
|
555
|
+
// It was never shared with anything else in the workspace, so - unlike
|
|
556
|
+
// every other removal in this file - it's always safe to wipe wholesale.
|
|
557
|
+
const legacyHarnessDir = path.join(workspaceRoot, '.harness');
|
|
558
|
+
if (fs.existsSync(legacyHarnessDir)) {
|
|
559
|
+
fs.rmSync(legacyHarnessDir, { recursive: true, force: true });
|
|
560
|
+
console.log(` ✅ Removed legacy .harness/ directory (superseded by .claude/harness-everything/)`);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
if (removeGlobal) {
|
|
565
|
+
console.log("\n-------------------------------------------------");
|
|
566
|
+
console.log("Uninstalling Harness OS from Global Home...");
|
|
567
|
+
console.log("-------------------------------------------------");
|
|
568
|
+
|
|
569
|
+
const globalSettingsFile = path.join(userHome, '.claude', 'settings.json');
|
|
570
|
+
claudeHooks.removeHarnessHooks(globalSettingsFile);
|
|
571
|
+
const globalClaudeDir = path.join(userHome, '.claude');
|
|
572
|
+
cleanEmptyDirs(globalClaudeDir, [userHome]);
|
|
573
|
+
|
|
574
|
+
advisory.removeAdvisoryText(path.join(userHome, '.cursorrules'));
|
|
575
|
+
|
|
576
|
+
advisory.removeContinueRule(path.join(userHome, '.continue', 'rules', 'harness.md'));
|
|
577
|
+
cleanEmptyDirs(path.join(userHome, '.continue', 'rules'), [userHome]);
|
|
578
|
+
|
|
579
|
+
const promptsDir = getUserPromptsDir();
|
|
580
|
+
const vscodeInstFile = path.join(promptsDir, 'harness.instructions.md');
|
|
581
|
+
if (fs.existsSync(vscodeInstFile)) {
|
|
582
|
+
fs.unlinkSync(vscodeInstFile);
|
|
583
|
+
console.log(` ✅ Removed global Copilot instructions: ${vscodeInstFile}`);
|
|
584
|
+
}
|
|
585
|
+
const vscodeAgentFile = path.join(promptsDir, 'harness.agent.md');
|
|
586
|
+
if (fs.existsSync(vscodeAgentFile)) {
|
|
587
|
+
fs.unlinkSync(vscodeAgentFile);
|
|
588
|
+
console.log(` ✅ Removed global Codex agent: ${vscodeAgentFile}`);
|
|
589
|
+
}
|
|
590
|
+
cleanEmptyDirs(promptsDir, [userHome]);
|
|
591
|
+
|
|
592
|
+
// ~/.agents is a shared directory - other tools or the user's own files
|
|
593
|
+
// may live there. Never touch it directly; only clean up the
|
|
594
|
+
// harness-everything/ subfolder (manifest bookkeeping) and the skills/
|
|
595
|
+
// subfolder this package exclusively owns, and only once each is
|
|
596
|
+
// actually empty (manifest.json is removed automatically by the
|
|
597
|
+
// skills-removal step below once no skills remain in it).
|
|
598
|
+
cleanEmptyDirs(path.join(globalAgentsDir, 'skills'), [userHome]);
|
|
599
|
+
cleanEmptyDirs(globalHarnessDir, [userHome]);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (removeSkills && installedSkills.length > 0) {
|
|
603
|
+
// This block is only reached via a bulk "remove everything detected"
|
|
604
|
+
// path (interactive "all", or the non-interactive -y/--skills bypass) -
|
|
605
|
+
// never via the interactive per-item picker, which already removes
|
|
606
|
+
// exactly what the user checked. A bulk sweep must not reach into the
|
|
607
|
+
// real global home directory unless the user separately opted into
|
|
608
|
+
// global scope (same rule as the config removal above). Every entry in
|
|
609
|
+
// `installedSkills` is already manifest-tracked (or, for legacy
|
|
610
|
+
// installs, author-marker-verified) - see lib/skills.js - so this never
|
|
611
|
+
// touches a skill Harness didn't install.
|
|
612
|
+
const skillsToRemove = installedSkills.filter(s => s.scope !== 'global' || removeGlobal);
|
|
613
|
+
const skippedGlobalCount = installedSkills.length - skillsToRemove.length;
|
|
614
|
+
|
|
615
|
+
console.log("\n-------------------------------------------------");
|
|
616
|
+
console.log("Uninstalling all detected skills...");
|
|
617
|
+
console.log("-------------------------------------------------");
|
|
618
|
+
for (const skill of skillsToRemove) {
|
|
619
|
+
if (fs.existsSync(skill.dirPath)) {
|
|
620
|
+
skills.removeSkill(skill);
|
|
621
|
+
console.log(` ✅ Removed skill: ${skill.id} (${skill.scope})`);
|
|
622
|
+
cleanEmptyDirs(skill.parentPath, [workspaceRoot, userHome]);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
if (skippedGlobalCount > 0) {
|
|
626
|
+
console.log(` ℹ️ Skipped ${skippedGlobalCount} global-scoped skill(s) - pass --global (or select "Uninstall ... Global Home") to remove those too.`);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// Final sweep: a platform's harness-everything/ dir (manifest + Claude's
|
|
631
|
+
// skill copies) may have only just become empty above - either through the
|
|
632
|
+
// bulk removeSkills block or the interactive per-item picker, both of
|
|
633
|
+
// which clean up the skill's own parent dir but not necessarily this one.
|
|
634
|
+
// Always safe to run unconditionally: cleanEmptyDirs only ever removes a
|
|
635
|
+
// directory that's genuinely empty.
|
|
636
|
+
for (const platform of platformModules) {
|
|
637
|
+
if (typeof platform.getHarnessDir !== 'function') continue;
|
|
638
|
+
cleanEmptyDirs(platform.getHarnessDir(workspaceRoot), [workspaceRoot, userHome]);
|
|
639
|
+
}
|
|
640
|
+
cleanEmptyDirs(path.join(workspaceRoot, '.claude'), [workspaceRoot, userHome]);
|
|
641
|
+
|
|
642
|
+
console.log("\n🎉 UNINSTALL COMPLETE! Harness OS has been removed.");
|
|
643
|
+
console.log("=================================================");
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
main().catch(err => {
|
|
647
|
+
console.error(`\n❌ Install failed: ${err.message}`);
|
|
648
|
+
process.exit(1);
|
|
649
|
+
});
|