harness-everything 0.16.4 → 0.16.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +6 -0
- package/ci/mechanism-2am-openai-packaged-helper-runtime.test.js +82 -0
- package/ci/skill-routing-check.js +1 -1
- package/harness-everything/SKILL.md +1 -1
- package/harness-everything/scripts/bootstrap.js +4 -3
- package/harness-everything/scripts/runtime-paths.js +37 -0
- package/harness-everything/scripts/self-heal.js +3 -2
- package/harness-everything/scripts/tier-router.js +2 -6
- package/hooks/scripts/lib/platforms/claude.js +3 -3
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/scripts/lib/platforms/claude.js +3 -3
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/scripts/installer.js +629 -0
- package/plugins/harness-everything/scripts/lib/claude-hooks.js +84 -0
- package/plugins/harness-everything/scripts/lib/execution-contract.js +70 -0
- package/plugins/harness-everything/scripts/lib/gitignore.js +199 -0
- package/plugins/harness-everything/scripts/lib/manifest.js +142 -0
- package/plugins/harness-everything/scripts/lib/path-boundary.js +90 -0
- package/plugins/harness-everything/scripts/lib/prompts.js +241 -0
- package/plugins/harness-everything/scripts/lib/skills.js +314 -0
- package/plugins/harness-everything/scripts/lib/workspace.js +290 -0
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/bootstrap.js +4 -3
- package/plugins/harness-everything/skills/harness-everything/scripts/runtime-paths.js +37 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/self-heal.js +3 -2
- package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +2 -6
- package/scripts/installer.js +12 -4
- package/scripts/sync-openai-plugin.js +5 -2
|
@@ -0,0 +1,629 @@
|
|
|
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, getWorkspaceStateDir, 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, removeWorkspaceExcludePatterns, cleanEmptyDirs } = require('./lib/gitignore');
|
|
36
|
+
|
|
37
|
+
const userHome = require('os').homedir();
|
|
38
|
+
const detectedWorkspaceRoot = getWorkspaceRoot();
|
|
39
|
+
// Global installs are valid outside a repository, but the module still needs
|
|
40
|
+
// a non-null path while it evaluates local-detection helpers. Keep this
|
|
41
|
+
// fallback private to global mode; main() rejects non-global work from a
|
|
42
|
+
// directory whose workspace identity cannot be resolved.
|
|
43
|
+
const workspaceRoot = detectedWorkspaceRoot || path.resolve(process.cwd());
|
|
44
|
+
const harnessPackageRoot = path.resolve(__dirname, '..');
|
|
45
|
+
const harnessSourceDir = fs.existsSync(path.join(harnessPackageRoot, 'plugin.json')) &&
|
|
46
|
+
fs.existsSync(path.join(harnessPackageRoot, 'skills'))
|
|
47
|
+
? path.join(harnessPackageRoot, 'skills')
|
|
48
|
+
: harnessPackageRoot;
|
|
49
|
+
const packageManifestPath = fs.existsSync(path.join(harnessPackageRoot, 'package.json'))
|
|
50
|
+
? path.join(harnessPackageRoot, 'package.json')
|
|
51
|
+
: path.join(harnessPackageRoot, 'plugin.json');
|
|
52
|
+
const packageVersion = require(packageManifestPath).version;
|
|
53
|
+
|
|
54
|
+
let platformModules = [];
|
|
55
|
+
try {
|
|
56
|
+
platformModules = require(path.join(__dirname, '../hooks/scripts/lib/platforms'));
|
|
57
|
+
} catch (e) {
|
|
58
|
+
platformModules = []; // Best-effort - gitignore hints and state cleanup degrade gracefully without it.
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function main() {
|
|
62
|
+
const args = process.argv;
|
|
63
|
+
const command = args[2] || 'install'; // 'install', 'add', 'skills', etc.
|
|
64
|
+
|
|
65
|
+
const isInteractive = process.stdin.isTTY && process.stdout.isTTY;
|
|
66
|
+
const hasClaudeFlag = args.includes('--claude');
|
|
67
|
+
const hasCursorFlag = args.includes('--cursor');
|
|
68
|
+
const hasCopilotFlag = args.includes('--copilot');
|
|
69
|
+
const hasCodexFlag = args.includes('--codex');
|
|
70
|
+
const hasContinueFlag = args.includes('--continue');
|
|
71
|
+
const hasHermesFlag = args.includes('--hermes');
|
|
72
|
+
const hasAllFlag = args.includes('--all');
|
|
73
|
+
const hasGlobalFlag = args.includes('--global') || args.includes('-g');
|
|
74
|
+
const hasYesFlag = args.includes('-y') || args.includes('--yes');
|
|
75
|
+
// Self-heal repair mode: configure the platform touchpoints (advisory text,
|
|
76
|
+
// hooks settings, gitignore patterns) WITHOUT copying any skills into the
|
|
77
|
+
// workspace - skill installation is an explicit user choice, never a
|
|
78
|
+
// side effect of a background repair.
|
|
79
|
+
const hasNoSkillsFlag = args.includes('--no-skills');
|
|
80
|
+
if (!detectedWorkspaceRoot && !hasGlobalFlag) {
|
|
81
|
+
throw new Error('cannot install locally outside a git workspace; pass --global for a user-wide install');
|
|
82
|
+
}
|
|
83
|
+
const hasAnyPlatformFlag = hasClaudeFlag || hasCursorFlag || hasCopilotFlag || hasCodexFlag || hasContinueFlag || hasHermesFlag || hasAllFlag;
|
|
84
|
+
// #49: default 'auto' tries a junction (Windows) / symlink (elsewhere) into
|
|
85
|
+
// one canonical per-scope copy and silently falls back to an independent
|
|
86
|
+
// physical copy per target if that fails. --copy/--symlink override the
|
|
87
|
+
// auto-detection explicitly - --symlink surfaces a link failure as an
|
|
88
|
+
// error instead of silently falling back, since the user asked for it.
|
|
89
|
+
const linkMode = args.includes('--copy') ? 'copy' : args.includes('--symlink') ? 'symlink' : 'auto';
|
|
90
|
+
|
|
91
|
+
let requestedSkills = ['add', 'skill', 'skills'].includes(command)
|
|
92
|
+
? args.slice(3).filter(arg => !arg.startsWith('-'))
|
|
93
|
+
: [];
|
|
94
|
+
|
|
95
|
+
const skillFlagIdx = args.indexOf('--skill') !== -1 ? args.indexOf('--skill') : args.indexOf('--skills');
|
|
96
|
+
if (skillFlagIdx !== -1 && args[skillFlagIdx + 1] && !args[skillFlagIdx + 1].startsWith('-')) {
|
|
97
|
+
requestedSkills.push(args[skillFlagIdx + 1]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const claudeExists = fs.existsSync(path.join(workspaceRoot, '.claude'));
|
|
101
|
+
const cursorExists = fs.existsSync(path.join(workspaceRoot, '.cursorrules'));
|
|
102
|
+
const copilotExists = fs.existsSync(path.join(workspaceRoot, '.github', 'copilot-instructions.md')) || fs.existsSync(path.join(workspaceRoot, '.github'));
|
|
103
|
+
const codexExists = fs.existsSync(path.join(workspaceRoot, 'AGENTS.md'));
|
|
104
|
+
const continueExists = fs.existsSync(path.join(workspaceRoot, '.continue'));
|
|
105
|
+
const hermesExists = fs.existsSync(path.join(workspaceRoot, '.hermes.md'));
|
|
106
|
+
const detectedAny = claudeExists || cursorExists || copilotExists || codexExists || continueExists || hermesExists;
|
|
107
|
+
|
|
108
|
+
if (command === 'uninstall') {
|
|
109
|
+
await runUninstall({ hasYesFlag, args, isInteractive });
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let targets = {
|
|
114
|
+
claude: false,
|
|
115
|
+
cursor: false,
|
|
116
|
+
copilot: false,
|
|
117
|
+
codex: false,
|
|
118
|
+
continue: false,
|
|
119
|
+
hermes: false
|
|
120
|
+
};
|
|
121
|
+
let chosenSkills = [];
|
|
122
|
+
let isGlobal = hasGlobalFlag;
|
|
123
|
+
|
|
124
|
+
const runInteractively = isInteractive && !hasYesFlag && !hasAnyPlatformFlag && (['install', 'add', 'skill', 'skills'].includes(command) && requestedSkills.length === 0);
|
|
125
|
+
|
|
126
|
+
if (runInteractively) {
|
|
127
|
+
console.log("=================================================");
|
|
128
|
+
console.log(` Harness OS - Interactive Setup `);
|
|
129
|
+
console.log("=================================================");
|
|
130
|
+
|
|
131
|
+
// Step 1: Choose platforms
|
|
132
|
+
console.log("\n[Step 1/3] Select target platforms to configure:");
|
|
133
|
+
const platformItems = [
|
|
134
|
+
{ id: 'claude', name: `Claude Code (hook-enforced) ${claudeExists ? '(Detected)' : ''}`, checked: claudeExists || !detectedAny },
|
|
135
|
+
{ id: 'cursor', name: `Cursor (.cursorrules) ${cursorExists ? '(Detected)' : ''}`, checked: cursorExists },
|
|
136
|
+
{ id: 'copilot', name: `Copilot (.github/copilot-...) ${copilotExists ? '(Detected)' : ''}`, checked: copilotExists },
|
|
137
|
+
{ id: 'codex', name: `Codex (AGENTS.md) ${codexExists ? '(Detected)' : ''}`, checked: codexExists },
|
|
138
|
+
{ id: 'continue', name: `Continue.dev (.continue/rules) ${continueExists ? '(Detected)' : ''}`, checked: continueExists },
|
|
139
|
+
{ id: 'hermes', name: `Hermes Agent (.hermes.md) ${hermesExists ? '(Detected)' : ''}`, checked: hermesExists }
|
|
140
|
+
];
|
|
141
|
+
const selectedPlatforms = await interactiveSelect(platformItems);
|
|
142
|
+
selectedPlatforms.forEach(p => {
|
|
143
|
+
targets[p.id] = p.checked;
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Step 2: Choose skills
|
|
147
|
+
const availableSkills = skills.getAvailableSkills(harnessSourceDir);
|
|
148
|
+
console.log("\n[Step 2/3] Select skills to install:");
|
|
149
|
+
const skillItems = availableSkills.map(s => {
|
|
150
|
+
const info = skills.getSkillInfo(harnessSourceDir, s);
|
|
151
|
+
// Pre-check all skills (install all by default)
|
|
152
|
+
const isHarnessEverything = s === 'harness-everything';
|
|
153
|
+
return {
|
|
154
|
+
id: s,
|
|
155
|
+
name: isHarnessEverything ? `${s} (Required)` : s,
|
|
156
|
+
description: info ? info.description : '',
|
|
157
|
+
checked: true
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
const selectedSkills = await interactiveSelect(skillItems, 8);
|
|
161
|
+
chosenSkills = selectedSkills.filter(s => s.checked).map(s => s.id);
|
|
162
|
+
|
|
163
|
+
// Step 3: Choose global vs local location
|
|
164
|
+
console.log("\n[Step 3/3] Select installation scope / location:");
|
|
165
|
+
const locationItems = [
|
|
166
|
+
{ id: 'local', name: "Local Workspace (Install to current project directories)", checked: true },
|
|
167
|
+
{ id: 'global', name: "Global (~/.agents - applies across all projects)", checked: false }
|
|
168
|
+
];
|
|
169
|
+
const chosenLocationId = await interactiveSingleSelect(locationItems);
|
|
170
|
+
isGlobal = chosenLocationId === 'global';
|
|
171
|
+
} else {
|
|
172
|
+
// Non-interactive/bypass mode
|
|
173
|
+
isGlobal = hasGlobalFlag;
|
|
174
|
+
|
|
175
|
+
if (['add', 'skill', 'skills'].includes(command)) {
|
|
176
|
+
if (requestedSkills.length > 0) {
|
|
177
|
+
const availableSkills = skills.getAvailableSkills(harnessSourceDir);
|
|
178
|
+
for (const skillName of requestedSkills) {
|
|
179
|
+
if (availableSkills.includes(skillName)) {
|
|
180
|
+
chosenSkills.push(skillName);
|
|
181
|
+
} else {
|
|
182
|
+
console.error(`⚠️ Skill "${skillName}" not found. Skipping.`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
chosenSkills = skills.getAvailableSkills(harnessSourceDir);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (!isGlobal) {
|
|
190
|
+
targets.claude = claudeExists;
|
|
191
|
+
targets.cursor = cursorExists;
|
|
192
|
+
targets.copilot = copilotExists;
|
|
193
|
+
targets.codex = codexExists;
|
|
194
|
+
targets.continue = continueExists;
|
|
195
|
+
targets.hermes = hermesExists;
|
|
196
|
+
if (!detectedAny) {
|
|
197
|
+
targets.claude = true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} else {
|
|
201
|
+
if (hasAnyPlatformFlag) {
|
|
202
|
+
if (hasAllFlag) {
|
|
203
|
+
targets.claude = true;
|
|
204
|
+
targets.cursor = true;
|
|
205
|
+
targets.copilot = true;
|
|
206
|
+
targets.codex = true;
|
|
207
|
+
targets.continue = true;
|
|
208
|
+
targets.hermes = true;
|
|
209
|
+
} else {
|
|
210
|
+
targets.claude = hasClaudeFlag;
|
|
211
|
+
targets.cursor = hasCursorFlag;
|
|
212
|
+
targets.copilot = hasCopilotFlag;
|
|
213
|
+
targets.codex = hasCodexFlag;
|
|
214
|
+
targets.continue = hasContinueFlag;
|
|
215
|
+
targets.hermes = hasHermesFlag;
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
if (detectedAny) {
|
|
219
|
+
targets.claude = claudeExists;
|
|
220
|
+
targets.cursor = cursorExists;
|
|
221
|
+
targets.copilot = copilotExists;
|
|
222
|
+
targets.codex = codexExists;
|
|
223
|
+
targets.continue = continueExists;
|
|
224
|
+
targets.hermes = hermesExists;
|
|
225
|
+
} else {
|
|
226
|
+
targets.claude = true;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
chosenSkills = hasNoSkillsFlag ? [] : skills.getAvailableSkills(harnessSourceDir);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Ensure harness-everything is ALWAYS included in chosenSkills
|
|
234
|
+
if (!hasNoSkillsFlag && !chosenSkills.includes('harness-everything')) {
|
|
235
|
+
chosenSkills.push('harness-everything');
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// If no targets selected at all, exit
|
|
239
|
+
if (!targets.claude && !targets.cursor && !targets.copilot && !targets.codex && !targets.continue && !targets.hermes && !isGlobal) {
|
|
240
|
+
console.log("\n❌ No platforms selected. Exiting.");
|
|
241
|
+
process.exit(0);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const targetWorkspaceRoot = isGlobal ? path.join(userHome, '.agents') : workspaceRoot;
|
|
245
|
+
|
|
246
|
+
console.log("\n-------------------------------------------------");
|
|
247
|
+
console.log(`Installing Harness OS to ${isGlobal ? 'Global Home' : 'Local Workspace'}`);
|
|
248
|
+
console.log("-------------------------------------------------");
|
|
249
|
+
|
|
250
|
+
for (const platform of platformModules) {
|
|
251
|
+
if (targets[platform.name] && typeof platform.install === 'function') {
|
|
252
|
+
platform.install({
|
|
253
|
+
isGlobal,
|
|
254
|
+
targetWorkspaceRoot,
|
|
255
|
+
harnessSourceDir,
|
|
256
|
+
harnessRuntimeRoot: harnessPackageRoot,
|
|
257
|
+
packageVersion,
|
|
258
|
+
getUserPromptsDir,
|
|
259
|
+
advisory,
|
|
260
|
+
claudeHooks,
|
|
261
|
+
manifest,
|
|
262
|
+
userHome,
|
|
263
|
+
workspaceRoot
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Install chosen skills. Every platform's skills stay at that platform's
|
|
269
|
+
// own native location (unchanged) EXCEPT Claude, which has its copy under
|
|
270
|
+
// .claude/skills/. Each platform's manifest.json tracks its own.
|
|
271
|
+
if (chosenSkills.length > 0) {
|
|
272
|
+
const targetDirs = [];
|
|
273
|
+
const addedPaths = new Set();
|
|
274
|
+
for (const platform of platformModules) {
|
|
275
|
+
// If it's a global install, gather all configured/selected platforms or defaults
|
|
276
|
+
if (targets[platform.name] || (isGlobal && (targets.claude || targets.cursor || targets.copilot || targets.codex || targets.continue || targets.hermes))) {
|
|
277
|
+
if (typeof platform.getSkillsTarget === 'function') {
|
|
278
|
+
const tgt = platform.getSkillsTarget({ workspaceRoot, userHome, isGlobal, manifest });
|
|
279
|
+
if (tgt && tgt.path && !addedPaths.has(tgt.path)) {
|
|
280
|
+
targetDirs.push(tgt);
|
|
281
|
+
addedPaths.add(tgt.path);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
console.log(`\nInstalling Harness skills:`);
|
|
288
|
+
const canonicalDir = skills.getCanonicalSkillsDir({ isGlobal, workspaceRoot, userHome });
|
|
289
|
+
skills.installSkillsToTargets({ chosenSkills, targetDirs, harnessSourceDir, packageVersion, canonicalDir, linkMode });
|
|
290
|
+
|
|
291
|
+
// Claude Code discovers named agents from .claude/agents/, not from a
|
|
292
|
+
// nested skill directory. Keep the source copies in fable-mode for plugin
|
|
293
|
+
// distribution, and also install them into Claude's native agent folder.
|
|
294
|
+
if (chosenSkills.includes('fable-mode') && targets.claude) {
|
|
295
|
+
const claudePlatform = platformModules.find(platform => platform.name === 'claude');
|
|
296
|
+
if (claudePlatform && typeof claudePlatform.getAgentsTarget === 'function') {
|
|
297
|
+
const agentTarget = claudePlatform.getAgentsTarget({ workspaceRoot, userHome, isGlobal, manifest });
|
|
298
|
+
skills.installAgentsToTarget({ target: agentTarget, harnessSourceDir, packageVersion });
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (!isGlobal) {
|
|
304
|
+
const patternsToIgnore = [];
|
|
305
|
+
for (const platform of platformModules) {
|
|
306
|
+
if (targets[platform.name] && typeof platform.getIgnorePatterns === 'function') {
|
|
307
|
+
for (const pattern of platform.getIgnorePatterns(workspaceRoot)) {
|
|
308
|
+
if (!patternsToIgnore.includes(pattern)) {
|
|
309
|
+
patternsToIgnore.push(pattern);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (patternsToIgnore.length === 0) {
|
|
315
|
+
// Fallback if platform modules failed to load entirely.
|
|
316
|
+
if (targets.claude) patternsToIgnore.push('.claude/harness-everything/');
|
|
317
|
+
if (targets.cursor) patternsToIgnore.push('.cursor/harness-everything/', '.cursor/skills/');
|
|
318
|
+
if (targets.copilot) patternsToIgnore.push('.github/harness-everything/', '.github/skills/');
|
|
319
|
+
if (targets.codex) patternsToIgnore.push('.codex/harness-everything/', '.codex/skills/');
|
|
320
|
+
if (targets.continue) patternsToIgnore.push('.continue/harness-everything/', '.continue/skills/');
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// The local canonical skills store (#49) is new territory - .agents/
|
|
324
|
+
// wasn't previously a Harness-owned local directory - so it needs its
|
|
325
|
+
// own ignore pattern rather than relying on any platform's own list.
|
|
326
|
+
if (chosenSkills.length > 0 && linkMode !== 'copy') {
|
|
327
|
+
const canonicalDir = skills.getCanonicalSkillsDir({ isGlobal: false, workspaceRoot, userHome });
|
|
328
|
+
if (fs.existsSync(canonicalDir)) {
|
|
329
|
+
patternsToIgnore.push('.agents/skills/');
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
ensureWorkspaceGitignorePatterns(workspaceRoot, patternsToIgnore);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
console.log("\n🎉 INSTALL SUCCESS! Harness OS is now protecting this project.");
|
|
337
|
+
console.log("Try your first AI interaction! The bootstrapped OS will auto-route your tier.");
|
|
338
|
+
console.log("=================================================");
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
async function runUninstall({ hasYesFlag, args, isInteractive }) {
|
|
342
|
+
const localHarnessDirs = platformModules
|
|
343
|
+
.filter(p => typeof p.getHarnessDir === 'function')
|
|
344
|
+
.map(p => p.getHarnessDir(workspaceRoot));
|
|
345
|
+
|
|
346
|
+
const localInstalled = fs.existsSync(path.join(workspaceRoot, '.harness')) || // legacy pre-reorg root
|
|
347
|
+
localHarnessDirs.some(d => fs.existsSync(d)) ||
|
|
348
|
+
fs.existsSync(path.join(workspaceRoot, '.claude', 'settings.json')) ||
|
|
349
|
+
fs.existsSync(path.join(workspaceRoot, '.cursorrules')) ||
|
|
350
|
+
fs.existsSync(path.join(workspaceRoot, '.github', 'copilot-instructions.md')) ||
|
|
351
|
+
fs.existsSync(path.join(workspaceRoot, 'AGENTS.md')) ||
|
|
352
|
+
fs.existsSync(path.join(workspaceRoot, '.continue', 'rules', 'harness.md')) ||
|
|
353
|
+
fs.existsSync(path.join(workspaceRoot, '.hermes.md'));
|
|
354
|
+
|
|
355
|
+
const globalAgentsDir = path.join(userHome, '.agents');
|
|
356
|
+
const globalHarnessDir = manifest.getHarnessDir(globalAgentsDir);
|
|
357
|
+
const globalInstalled = fs.existsSync(globalHarnessDir) ||
|
|
358
|
+
fs.existsSync(path.join(userHome, '.claude', 'settings.json')) ||
|
|
359
|
+
fs.existsSync(path.join(userHome, '.cursorrules')) ||
|
|
360
|
+
fs.existsSync(path.join(userHome, '.continue', 'rules', 'harness.md')) ||
|
|
361
|
+
fs.existsSync(path.join(getUserPromptsDir(), 'harness.instructions.md')) ||
|
|
362
|
+
fs.existsSync(path.join(getUserPromptsDir(), 'harness.agent.md'));
|
|
363
|
+
|
|
364
|
+
const installedSkills = skills.getInstalledSkills(workspaceRoot, userHome);
|
|
365
|
+
const installedAgents = skills.getInstalledAgents(workspaceRoot, userHome);
|
|
366
|
+
|
|
367
|
+
console.log("=================================================");
|
|
368
|
+
console.log(` Harness OS - Uninstall Utility `);
|
|
369
|
+
console.log("=================================================");
|
|
370
|
+
|
|
371
|
+
let removeLocal = false;
|
|
372
|
+
let removeGlobal = false;
|
|
373
|
+
let removeSkills = false;
|
|
374
|
+
|
|
375
|
+
const hasLocalFlag = args.includes('--local');
|
|
376
|
+
const hasGlobalUninstallFlag = args.includes('--global') || args.includes('-g');
|
|
377
|
+
const hasSkillsUninstallFlag = args.includes('--skills');
|
|
378
|
+
// #48: any explicit scope flag wins over the interactive menu, even with a
|
|
379
|
+
// TTY attached - so `uninstall --local --global --skills` actually does
|
|
380
|
+
// what it says instead of being silently swapped for the checkbox menu
|
|
381
|
+
// (where only -y previously had that effect). Only a truly bare `uninstall`
|
|
382
|
+
// (no flags at all) still goes interactive when a TTY is available.
|
|
383
|
+
const hasAnyScopeFlag = hasYesFlag || hasLocalFlag || hasGlobalUninstallFlag || hasSkillsUninstallFlag;
|
|
384
|
+
const runInteractively = isInteractive && !hasAnyScopeFlag;
|
|
385
|
+
|
|
386
|
+
if (!runInteractively && !hasAnyScopeFlag) {
|
|
387
|
+
// #48: no flags AND no interactive terminal to fall back on - this used
|
|
388
|
+
// to silently do nothing while still printing "UNINSTALL COMPLETE!".
|
|
389
|
+
// Fail loudly instead so a non-TTY invocation (npx in some shells/CI/
|
|
390
|
+
// piped input) never looks like a successful no-op.
|
|
391
|
+
console.error("\n❌ No scope specified and no interactive terminal detected.");
|
|
392
|
+
console.error(" Pass flags to say what to remove, e.g.:");
|
|
393
|
+
console.error(" uninstall --local --skills");
|
|
394
|
+
console.error(" uninstall --local --global --skills -y");
|
|
395
|
+
console.error(" ...or run this command in an interactive terminal to use the menu.");
|
|
396
|
+
process.exit(1);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (runInteractively) {
|
|
400
|
+
const choices = [];
|
|
401
|
+
if (localInstalled) {
|
|
402
|
+
choices.push({ id: 'local', name: 'Uninstall Harness OS from Local Workspace (Hooks & Advisory files)', checked: true });
|
|
403
|
+
}
|
|
404
|
+
if (globalInstalled) {
|
|
405
|
+
choices.push({ id: 'global', name: 'Uninstall Harness OS from Global Home (~/.agents, VS Code Prompts, etc.)', checked: false });
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
if (choices.length > 0) {
|
|
409
|
+
console.log("\nSelect installation scopes to uninstall:");
|
|
410
|
+
const selectedScopes = await interactiveSelect(choices);
|
|
411
|
+
removeLocal = selectedScopes.some(s => s.id === 'local' && s.checked);
|
|
412
|
+
removeGlobal = selectedScopes.some(s => s.id === 'global' && s.checked);
|
|
413
|
+
} else {
|
|
414
|
+
console.log("\nNo Harness OS installation detected in local workspace or global home.");
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (installedSkills.length > 0) {
|
|
418
|
+
console.log(`\nDetected ${installedSkills.length} installed skill(s):`);
|
|
419
|
+
installedSkills.forEach(s => {
|
|
420
|
+
console.log(` - ${s.id} (${s.scope})`);
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
console.log("\nWould you like to uninstall these skills?");
|
|
424
|
+
const skillChoiceItems = [
|
|
425
|
+
{ id: 'all', name: 'Remove ALL detected skills', checked: true },
|
|
426
|
+
{ id: 'select', name: 'Select specific skills to remove', checked: false },
|
|
427
|
+
{ id: 'none', name: 'Keep all skills', checked: false }
|
|
428
|
+
];
|
|
429
|
+
const skillAction = await interactiveSingleSelect(skillChoiceItems);
|
|
430
|
+
|
|
431
|
+
if (skillAction === 'all') {
|
|
432
|
+
removeSkills = true;
|
|
433
|
+
} else if (skillAction === 'select') {
|
|
434
|
+
const selectSkillItems = installedSkills.map(s => ({
|
|
435
|
+
id: s.dirPath,
|
|
436
|
+
name: `${s.id} (${s.scope})`,
|
|
437
|
+
checked: true,
|
|
438
|
+
_entry: s
|
|
439
|
+
}));
|
|
440
|
+
const chosenSkillsToRemove = await interactiveSelect(selectSkillItems);
|
|
441
|
+
for (const item of chosenSkillsToRemove) {
|
|
442
|
+
if (item.checked) {
|
|
443
|
+
skills.removeSkill(item._entry, { workspaceRoot, userHome });
|
|
444
|
+
console.log(` ✅ Removed skill: ${item.name}`);
|
|
445
|
+
cleanEmptyDirs(item._entry.parentPath, [workspaceRoot, userHome]);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
} else {
|
|
451
|
+
if (hasYesFlag) {
|
|
452
|
+
// -y auto-confirms local (cwd-scoped, obviously "this project") but
|
|
453
|
+
// must NEVER auto-confirm global (~/.agents, ~/.claude, etc.) just
|
|
454
|
+
// because something global happens to exist - home-directory state
|
|
455
|
+
// isn't implied by "yes" to the workspace you're standing in, and a
|
|
456
|
+
// bare `-y` run from any random project must not be able to wipe it.
|
|
457
|
+
removeLocal = localInstalled;
|
|
458
|
+
removeGlobal = globalInstalled && hasGlobalUninstallFlag;
|
|
459
|
+
removeSkills = installedSkills.length > 0;
|
|
460
|
+
} else {
|
|
461
|
+
removeLocal = hasLocalFlag;
|
|
462
|
+
removeGlobal = hasGlobalUninstallFlag;
|
|
463
|
+
removeSkills = hasSkillsUninstallFlag;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (removeLocal) {
|
|
468
|
+
console.log("\n-------------------------------------------------");
|
|
469
|
+
console.log("Uninstalling Harness OS from Local Workspace...");
|
|
470
|
+
console.log("-------------------------------------------------");
|
|
471
|
+
|
|
472
|
+
for (const platform of platformModules) {
|
|
473
|
+
if (typeof platform.uninstall === 'function') {
|
|
474
|
+
platform.uninstall({
|
|
475
|
+
removeLocal: true,
|
|
476
|
+
removeGlobal: false,
|
|
477
|
+
workspaceRoot,
|
|
478
|
+
userHome,
|
|
479
|
+
getUserPromptsDir,
|
|
480
|
+
cleanEmptyDirs,
|
|
481
|
+
claudeHooks
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (typeof platform.getStateDir === 'function') {
|
|
486
|
+
// Legacy per-workspace state dir (pre-#42) - almost always already
|
|
487
|
+
// gone by the time uninstall runs, since the first hook invocation
|
|
488
|
+
// after the fix migrates it into the global home below. Kept as a
|
|
489
|
+
// no-op-in-the-common-case safety net for a workspace that was
|
|
490
|
+
// never actually used since upgrading.
|
|
491
|
+
const stateDir = platform.getStateDir(workspaceRoot);
|
|
492
|
+
if (fs.existsSync(stateDir)) {
|
|
493
|
+
fs.rmSync(stateDir, { recursive: true, force: true });
|
|
494
|
+
console.log(` ✅ Removed local ${path.relative(workspaceRoot, stateDir).replace(/\\/g, '/')}/ directory`);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// Runtime state for this workspace now lives outside it entirely, under
|
|
500
|
+
// ~/.agents/harness-everything/workspaces/<key>/ (issue #42) - remove
|
|
501
|
+
// this workspace's slice of it too, so uninstalling doesn't leave an
|
|
502
|
+
// orphaned global state dir behind.
|
|
503
|
+
const globalWorkspaceStateDir = getWorkspaceStateDir(workspaceRoot);
|
|
504
|
+
if (fs.existsSync(globalWorkspaceStateDir)) {
|
|
505
|
+
fs.rmSync(globalWorkspaceStateDir, { recursive: true, force: true });
|
|
506
|
+
console.log(` ✅ Removed global runtime state for this workspace (${globalWorkspaceStateDir})`);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// One-time migration cleanup: earlier versions used a self-invented
|
|
510
|
+
// top-level .harness/ directory for Claude's manifest + skill copies.
|
|
511
|
+
const legacyHarnessDir = path.join(workspaceRoot, '.harness');
|
|
512
|
+
if (fs.existsSync(legacyHarnessDir)) {
|
|
513
|
+
fs.rmSync(legacyHarnessDir, { recursive: true, force: true });
|
|
514
|
+
console.log(` ✅ Removed legacy .harness/ directory (superseded by .claude/harness-everything/)`);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// Remove Harness's local-only ignore section (.git/info/exclude) and any
|
|
518
|
+
// legacy banner block older installers appended to the working-tree
|
|
519
|
+
// .gitignore. Only ever touches Harness-owned lines.
|
|
520
|
+
removeWorkspaceExcludePatterns(workspaceRoot);
|
|
521
|
+
|
|
522
|
+
for (const agent of installedAgents.filter(entry => entry.scope.startsWith('local'))) {
|
|
523
|
+
skills.removeAgent(agent);
|
|
524
|
+
console.log(` ✅ Removed agent: ${agent.filePath}`);
|
|
525
|
+
}
|
|
526
|
+
cleanEmptyDirs(path.join(workspaceRoot, '.claude', 'agents'), [workspaceRoot, userHome]);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (removeGlobal) {
|
|
530
|
+
console.log("\n-------------------------------------------------");
|
|
531
|
+
console.log("Uninstalling Harness OS from Global Home...");
|
|
532
|
+
console.log("-------------------------------------------------");
|
|
533
|
+
|
|
534
|
+
for (const platform of platformModules) {
|
|
535
|
+
if (typeof platform.uninstall === 'function') {
|
|
536
|
+
platform.uninstall({
|
|
537
|
+
removeLocal: false,
|
|
538
|
+
removeGlobal: true,
|
|
539
|
+
workspaceRoot,
|
|
540
|
+
userHome,
|
|
541
|
+
getUserPromptsDir,
|
|
542
|
+
cleanEmptyDirs,
|
|
543
|
+
claudeHooks
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// ~/.agents is a shared directory - other tools or the user's own files
|
|
549
|
+
// may live there. Never touch it directly; only clean up the
|
|
550
|
+
// harness-everything/ subfolder (manifest bookkeeping) and the skills/
|
|
551
|
+
// subfolder this package exclusively owns, and only once each is
|
|
552
|
+
// actually empty (manifest.json is removed automatically by the
|
|
553
|
+
// skills-removal step below once no skills remain in it).
|
|
554
|
+
cleanEmptyDirs(path.join(globalAgentsDir, 'skills'), [userHome]);
|
|
555
|
+
cleanEmptyDirs(globalHarnessDir, [userHome]);
|
|
556
|
+
|
|
557
|
+
for (const agent of installedAgents.filter(entry => entry.scope.startsWith('global'))) {
|
|
558
|
+
skills.removeAgent(agent);
|
|
559
|
+
console.log(` ✅ Removed agent: ${agent.filePath}`);
|
|
560
|
+
}
|
|
561
|
+
cleanEmptyDirs(path.join(userHome, '.claude', 'agents'), [workspaceRoot, userHome]);
|
|
562
|
+
cleanEmptyDirs(globalHarnessDir, [userHome]);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
if (removeSkills && installedSkills.length > 0) {
|
|
566
|
+
// This block is only reached via a bulk "remove everything detected"
|
|
567
|
+
// path (interactive "all", or the non-interactive -y/--skills bypass) -
|
|
568
|
+
// never via the interactive per-item picker, which already removes
|
|
569
|
+
// exactly what the user checked. A bulk sweep must not reach into the
|
|
570
|
+
// real global home directory unless the user separately opted into
|
|
571
|
+
// global scope (same rule as the config removal above). Every entry in
|
|
572
|
+
// `installedSkills` is already manifest-tracked (or, for legacy
|
|
573
|
+
// installs, author-marker-verified) - see lib/skills.js - so this never
|
|
574
|
+
// touches a skill Harness didn't install.
|
|
575
|
+
const skillsToRemove = installedSkills.filter(s => s.scope !== 'global' || removeGlobal);
|
|
576
|
+
const skippedGlobalCount = installedSkills.length - skillsToRemove.length;
|
|
577
|
+
|
|
578
|
+
console.log("\n-------------------------------------------------");
|
|
579
|
+
console.log("Uninstalling all detected skills...");
|
|
580
|
+
console.log("-------------------------------------------------");
|
|
581
|
+
for (const skill of skillsToRemove) {
|
|
582
|
+
// pathPresent (not bare existsSync) so a dangling link - its canonical
|
|
583
|
+
// target already gone - still gets its manifest row cleaned up instead
|
|
584
|
+
// of being silently skipped forever.
|
|
585
|
+
if (skills.pathPresent(skill.dirPath)) {
|
|
586
|
+
skills.removeSkill(skill, { workspaceRoot, userHome });
|
|
587
|
+
console.log(` ✅ Removed skill: ${skill.id} (${skill.scope})`);
|
|
588
|
+
cleanEmptyDirs(skill.parentPath, [workspaceRoot, userHome]);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
if (skippedGlobalCount > 0) {
|
|
592
|
+
console.log(` ℹ️ Skipped ${skippedGlobalCount} global-scoped skill(s) - pass --global (or select "Uninstall ... Global Home") to remove those too.`);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// Final sweep: a platform's harness-everything/ dir (manifest + Claude's
|
|
597
|
+
// skill copies) may have only just become empty above - either through the
|
|
598
|
+
// bulk removeSkills block or the interactive per-item picker, both of
|
|
599
|
+
// which clean up the skill's own parent dir but not necessarily this one.
|
|
600
|
+
// Always safe to run unconditionally: cleanEmptyDirs only ever removes a
|
|
601
|
+
// directory that's genuinely empty.
|
|
602
|
+
for (const platform of platformModules) {
|
|
603
|
+
if (typeof platform.getHarnessDir !== 'function') continue;
|
|
604
|
+
cleanEmptyDirs(platform.getHarnessDir(workspaceRoot), [workspaceRoot, userHome]);
|
|
605
|
+
}
|
|
606
|
+
cleanEmptyDirs(path.join(workspaceRoot, '.claude'), [workspaceRoot, userHome]);
|
|
607
|
+
|
|
608
|
+
// Canonical skills store (#49) - removeSkill() above already deletes each
|
|
609
|
+
// now-unreferenced canonical copy as its last link goes; this just tidies
|
|
610
|
+
// up the now-empty .agents/skills/ (and .agents/ itself, if nothing else
|
|
611
|
+
// put anything there). Runs here rather than inside the removeLocal/
|
|
612
|
+
// removeGlobal blocks above because skill removal itself happens later,
|
|
613
|
+
// in the removeSkills block below those - running any earlier would find
|
|
614
|
+
// the directory still populated.
|
|
615
|
+
if (removeLocal) {
|
|
616
|
+
cleanEmptyDirs(skills.getCanonicalSkillsDir({ isGlobal: false, workspaceRoot, userHome }), [workspaceRoot, userHome]);
|
|
617
|
+
}
|
|
618
|
+
if (removeGlobal) {
|
|
619
|
+
cleanEmptyDirs(skills.getCanonicalSkillsDir({ isGlobal: true, workspaceRoot, userHome }), [userHome]);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
console.log("\n🎉 UNINSTALL COMPLETE! Harness OS has been removed.");
|
|
623
|
+
console.log("=================================================");
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
main().catch(err => {
|
|
627
|
+
console.error(`\n❌ Install failed: ${err.message}`);
|
|
628
|
+
process.exit(1);
|
|
629
|
+
});
|