harness-everything 0.16.4 → 0.16.6

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.
Files changed (36) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +12 -0
  4. package/ci/mechanism-2am-openai-packaged-helper-runtime.test.js +110 -0
  5. package/ci/mechanism-2an-environment-detection-readonly.test.js +113 -0
  6. package/ci/skill-routing-check.js +1 -1
  7. package/docs/workflows/environment-detection.md +15 -7
  8. package/environment-detection/SKILL.md +15 -16
  9. package/harness-everything/SKILL.md +1 -1
  10. package/harness-everything/scripts/bootstrap.js +4 -3
  11. package/harness-everything/scripts/runtime-paths.js +37 -0
  12. package/harness-everything/scripts/self-heal.js +31 -8
  13. package/harness-everything/scripts/tier-router.js +2 -6
  14. package/hooks/scripts/lib/platforms/claude.js +3 -3
  15. package/opencode-plugin/plugin.json +1 -1
  16. package/package.json +1 -1
  17. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  18. package/plugins/harness-everything/hooks/scripts/lib/platforms/claude.js +3 -3
  19. package/plugins/harness-everything/plugin.json +1 -1
  20. package/plugins/harness-everything/scripts/installer.js +629 -0
  21. package/plugins/harness-everything/scripts/lib/claude-hooks.js +84 -0
  22. package/plugins/harness-everything/scripts/lib/execution-contract.js +70 -0
  23. package/plugins/harness-everything/scripts/lib/gitignore.js +199 -0
  24. package/plugins/harness-everything/scripts/lib/manifest.js +142 -0
  25. package/plugins/harness-everything/scripts/lib/path-boundary.js +90 -0
  26. package/plugins/harness-everything/scripts/lib/prompts.js +241 -0
  27. package/plugins/harness-everything/scripts/lib/skills.js +314 -0
  28. package/plugins/harness-everything/scripts/lib/workspace.js +290 -0
  29. package/plugins/harness-everything/skills/environment-detection/SKILL.md +15 -16
  30. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  31. package/plugins/harness-everything/skills/harness-everything/scripts/bootstrap.js +4 -3
  32. package/plugins/harness-everything/skills/harness-everything/scripts/runtime-paths.js +37 -0
  33. package/plugins/harness-everything/skills/harness-everything/scripts/self-heal.js +31 -8
  34. package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +2 -6
  35. package/scripts/installer.js +12 -4
  36. package/scripts/sync-openai-plugin.js +5 -2
@@ -10,7 +10,7 @@
10
10
  "name": "harness-everything",
11
11
  "source": "./",
12
12
  "description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
13
- "version": "0.16.4",
13
+ "version": "0.16.6",
14
14
  "author": {
15
15
  "name": "Miya Daniel"
16
16
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "harness-everything",
3
3
  "description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
4
- "version": "0.16.4",
4
+ "version": "0.16.6",
5
5
  "author": {
6
6
  "name": "Miya Daniel"
7
7
  },
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [0.16.6](https://github.com/dyphn1/Harness-everything/compare/v0.16.5...v0.16.6) (2026-09-21)
6
+
7
+ ### Bug Fixes
8
+
9
+ * **environment-detection:** keep discovery read-only ([#214](https://github.com/dyphn1/Harness-everything/issues/214)) ([f6fa7ec](https://github.com/dyphn1/Harness-everything/commit/f6fa7ec57fb95072dce1177ee4e93718b77b21ef))
10
+
11
+ ## [0.16.5](https://github.com/dyphn1/Harness-everything/compare/v0.16.4...v0.16.5) (2026-09-21)
12
+
13
+ ### Bug Fixes
14
+
15
+ * **codex:** make packaged helper runtime self-contained ([96cba55](https://github.com/dyphn1/Harness-everything/commit/96cba55b2347251c90306a727825377ba26465c2))
16
+
5
17
  ## [0.16.4](https://github.com/dyphn1/Harness-everything/compare/v0.16.3...v0.16.4) (2026-09-20)
6
18
 
7
19
  ### Bug Fixes
@@ -0,0 +1,110 @@
1
+ 'use strict';
2
+
3
+ const assert = require('assert');
4
+ const fs = require('fs');
5
+ const os = require('os');
6
+ const path = require('path');
7
+ const { spawnSync } = require('child_process');
8
+
9
+ const repoRoot = path.resolve(__dirname, '..');
10
+ const packagedPlugin = path.join(repoRoot, 'plugins', 'harness-everything');
11
+
12
+ function runNode(script, args, options) {
13
+ return spawnSync(process.execPath, [script, ...args], {
14
+ cwd: options.cwd,
15
+ env: { ...process.env, ...options.env },
16
+ input: options.input,
17
+ encoding: 'utf8'
18
+ });
19
+ }
20
+
21
+ function describe(result) {
22
+ return [result.stdout, result.stderr].filter(Boolean).join('\n');
23
+ }
24
+
25
+ const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-openai-plugin-'));
26
+ try {
27
+ const pluginRoot = path.join(tempRoot, 'plugin');
28
+ const workspaceRoot = path.join(tempRoot, 'workspace');
29
+ const stateHome = path.join(tempRoot, 'state');
30
+ fs.cpSync(packagedPlugin, pluginRoot, { recursive: true });
31
+ fs.mkdirSync(workspaceRoot, { recursive: true });
32
+ fs.mkdirSync(stateHome, { recursive: true });
33
+ fs.mkdirSync(path.join(workspaceRoot, '.git'), { recursive: true });
34
+ fs.writeFileSync(path.join(workspaceRoot, 'AGENTS.md'), '# managed workspace\n', 'utf8');
35
+
36
+ const env = {
37
+ HARNESS_STATE_HOME: stateHome,
38
+ HARNESS_WORKSPACE_ROOT: workspaceRoot,
39
+ };
40
+
41
+ const scriptsRoot = path.join(pluginRoot, 'skills', 'harness-everything', 'scripts');
42
+ const selfHeal = runNode(path.join(scriptsRoot, 'self-heal.js'), ['--check'], {
43
+ cwd: workspaceRoot,
44
+ env,
45
+ });
46
+ assert.strictEqual(selfHeal.status, 0, `packaged self-heal --check failed:\n${describe(selfHeal)}`);
47
+
48
+ // Public OpenAI skills-only submissions intentionally omit the plugin-root
49
+ // installer/runtime. The read-only audit must degrade safely instead of
50
+ // searching arbitrary parent/cache paths or failing skill execution.
51
+ const skillsOnlyRoot = path.join(tempRoot, 'skills-only');
52
+ const skillsOnlyWorkspace = path.join(tempRoot, 'skills-only-workspace');
53
+ fs.cpSync(path.join(pluginRoot, 'skills'), path.join(skillsOnlyRoot, 'skills'), { recursive: true });
54
+ fs.mkdirSync(path.join(skillsOnlyWorkspace, '.git'), { recursive: true });
55
+ fs.writeFileSync(path.join(skillsOnlyWorkspace, 'AGENTS.md'), '# skills-only workspace\n', 'utf8');
56
+ const skillsOnlyAgentsBefore = fs.readFileSync(path.join(skillsOnlyWorkspace, 'AGENTS.md'), 'utf8');
57
+ const skillsOnlyCheck = runNode(
58
+ path.join(skillsOnlyRoot, 'skills', 'harness-everything', 'scripts', 'self-heal.js'),
59
+ ['--check'],
60
+ {
61
+ cwd: skillsOnlyWorkspace,
62
+ env: {
63
+ HARNESS_STATE_HOME: path.join(tempRoot, 'skills-only-state'),
64
+ HARNESS_WORKSPACE_ROOT: skillsOnlyWorkspace,
65
+ },
66
+ }
67
+ );
68
+ assert.strictEqual(skillsOnlyCheck.status, 0, `skills-only self-heal --check failed:\n${describe(skillsOnlyCheck)}`);
69
+ assert.match(describe(skillsOnlyCheck), /Local repair runtime unavailable on this distribution surface/);
70
+ assert.strictEqual(
71
+ fs.readFileSync(path.join(skillsOnlyWorkspace, 'AGENTS.md'), 'utf8'),
72
+ skillsOnlyAgentsBefore,
73
+ 'skills-only read-only audit must not rewrite workspace integration files'
74
+ );
75
+
76
+ const installer = runNode(path.join(pluginRoot, 'scripts', 'installer.js'), ['--codex', '--no-skills', '--yes'], {
77
+ cwd: workspaceRoot,
78
+ env,
79
+ });
80
+ assert.strictEqual(installer.status, 0, `packaged installer failed:\n${describe(installer)}`);
81
+ assert.match(
82
+ fs.readFileSync(path.join(workspaceRoot, 'AGENTS.md'), 'utf8'),
83
+ /Harness OS Guidance \(Advisory\)/,
84
+ 'packaged installer did not write the Codex advisory file'
85
+ );
86
+
87
+ const bootstrap = runNode(path.join(scriptsRoot, 'bootstrap.js'), [], {
88
+ cwd: workspaceRoot,
89
+ env,
90
+ input: JSON.stringify({ session_id: 'packaged-runtime-smoke', cwd: workspaceRoot }),
91
+ });
92
+ assert.strictEqual(bootstrap.status, 0, `packaged bootstrap failed:\n${describe(bootstrap)}`);
93
+ assert.match(describe(bootstrap), /Harness OS initialized/, 'packaged bootstrap did not initialize Harness');
94
+
95
+ const tierRouter = runNode(path.join(scriptsRoot, 'tier-router.js'), ['audit the repository and run tests'], {
96
+ cwd: workspaceRoot,
97
+ env,
98
+ });
99
+ assert.strictEqual(tierRouter.status, 0, `packaged tier-router failed:\n${describe(tierRouter)}`);
100
+ assert.doesNotMatch(
101
+ describe(tierRouter),
102
+ /BASE EXECUTION LOOP: Load 'todo-driven-workflow'/,
103
+ 'direct packaged tier-router still emits retired mandatory todo guidance'
104
+ );
105
+ assert.match(describe(tierRouter), /WORKFLOW STRATEGY:/, 'packaged tier-router did not emit the workflow contract');
106
+
107
+ console.log('OpenAI packaged helper runtime smoke test passed');
108
+ } finally {
109
+ fs.rmSync(tempRoot, { recursive: true, force: true });
110
+ }
@@ -0,0 +1,113 @@
1
+ 'use strict';
2
+
3
+ const assert = require('assert');
4
+ const crypto = require('crypto');
5
+ const fs = require('fs');
6
+ const os = require('os');
7
+ const path = require('path');
8
+ const { spawnSync } = require('child_process');
9
+
10
+ const ROOT = path.resolve(__dirname, '..');
11
+ const SELF_HEAL = path.join(ROOT, 'harness-everything', 'scripts', 'self-heal.js');
12
+ const SKILL = path.join(ROOT, 'environment-detection', 'SKILL.md');
13
+ const OPENCODE = path.join(ROOT, 'opencode-plugin', 'index.mjs');
14
+
15
+ function write(root, relative, content) {
16
+ const target = path.join(root, relative);
17
+ fs.mkdirSync(path.dirname(target), { recursive: true });
18
+ fs.writeFileSync(target, content, 'utf8');
19
+ return target;
20
+ }
21
+
22
+ function treeDigest(root) {
23
+ const hash = crypto.createHash('sha256');
24
+ function walk(dir, relative = '') {
25
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
26
+ const rel = relative ? `${relative}/${entry.name}` : entry.name;
27
+ const full = path.join(dir, entry.name);
28
+ hash.update(`${entry.isDirectory() ? 'D' : 'F'}:${rel}\0`);
29
+ if (entry.isDirectory()) walk(full, rel);
30
+ else hash.update(fs.readFileSync(full));
31
+ }
32
+ }
33
+ walk(root);
34
+ return hash.digest('hex');
35
+ }
36
+
37
+ function run(workspace, home, args) {
38
+ const env = {
39
+ ...process.env,
40
+ HARNESS_WORKSPACE_ROOT: workspace,
41
+ HARNESS_STATE_HOME: path.join(home, 'state'),
42
+ HOME: home,
43
+ USERPROFILE: home,
44
+ APPDATA: path.join(home, 'AppData', 'Roaming'),
45
+ VSCODE_USER_PROMPTS_FOLDER: path.join(home, 'vscode-prompts'),
46
+ };
47
+ for (const key of ['CLAUDE', 'CLAUDECODE', 'CLAUDE_CODE', 'CURSOR_SANDBOX', 'GITHUB_COPILOT_CHAT', 'COPILOT_AGENT', 'AI_AGENT']) {
48
+ delete env[key];
49
+ }
50
+ return spawnSync(process.execPath, [SELF_HEAL, ...args], {
51
+ cwd: workspace,
52
+ env,
53
+ encoding: 'utf8',
54
+ });
55
+ }
56
+
57
+ const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-213-readonly-'));
58
+ try {
59
+ const workspace = path.join(tempRoot, 'workspace');
60
+ const home = path.join(tempRoot, 'home');
61
+ fs.mkdirSync(path.join(workspace, '.git'), { recursive: true });
62
+ fs.mkdirSync(home, { recursive: true });
63
+
64
+ // Seed all six installer/self-heal adapter surfaces with user-owned content.
65
+ write(workspace, '.claude/settings.json', JSON.stringify({ customSetting: true, hooks: {} }, null, 2));
66
+ write(workspace, '.cursorrules', 'user cursor rule\n');
67
+ write(workspace, '.github/copilot-instructions.md', 'user copilot instruction\n');
68
+ write(workspace, 'AGENTS.md', 'user codex instruction\n');
69
+ write(workspace, '.continue/rules/user.md', '# user continue rule\n');
70
+ write(workspace, '.hermes.md', 'user hermes context\n');
71
+
72
+ const beforeAudit = treeDigest(workspace);
73
+ const audit = run(workspace, home, ['--check']);
74
+ assert.strictEqual(audit.status, 0, `read-only audit failed:\n${audit.stdout}\n${audit.stderr}`);
75
+ assert.strictEqual(treeDigest(workspace), beforeAudit, '--check changed the workspace');
76
+ for (const label of ['Claude Code hooks', 'Cursor rules', 'Copilot instructions', 'Codex instructions', 'Continue.dev rules', 'Hermes Agent instructions']) {
77
+ assert.ok(audit.stdout.includes(label), `audit omitted ${label}`);
78
+ }
79
+
80
+ // Explicit repair remains available, preserves user-owned content, and is
81
+ // idempotent on the second run.
82
+ const repair = run(workspace, home, []);
83
+ assert.strictEqual(repair.status, 0, `explicit repair failed:\n${repair.stdout}\n${repair.stderr}`);
84
+ assert.strictEqual(JSON.parse(fs.readFileSync(path.join(workspace, '.claude/settings.json'), 'utf8')).customSetting, true);
85
+ assert.match(fs.readFileSync(path.join(workspace, '.cursorrules'), 'utf8'), /user cursor rule/);
86
+ assert.match(fs.readFileSync(path.join(workspace, '.github', 'copilot-instructions.md'), 'utf8'), /user copilot instruction/);
87
+ assert.match(fs.readFileSync(path.join(workspace, 'AGENTS.md'), 'utf8'), /user codex instruction/);
88
+ assert.match(fs.readFileSync(path.join(workspace, '.hermes.md'), 'utf8'), /user hermes context/);
89
+ assert.strictEqual(fs.readFileSync(path.join(workspace, '.continue', 'rules', 'user.md'), 'utf8'), '# user continue rule\n');
90
+
91
+ const afterRepair = treeDigest(workspace);
92
+ const secondRepair = run(workspace, home, []);
93
+ assert.strictEqual(secondRepair.status, 0, `second repair failed:\n${secondRepair.stdout}\n${secondRepair.stderr}`);
94
+ assert.strictEqual(treeDigest(workspace), afterRepair, 'explicit repair is not idempotent');
95
+
96
+ // The routed skill contract must keep default detection observational and
97
+ // use a portable sibling-skill path rather than a repository/cache root.
98
+ const skill = fs.readFileSync(SKILL, 'utf8');
99
+ assert.ok(skill.includes('self-heal.js" --check'));
100
+ assert.doesNotMatch(skill, /<skills-repo-root>/);
101
+ assert.match(skill, /Only explicit install\/setup\/repair intent may omit/);
102
+ assert.match(skill, /OpenCode has its own plugin runtime/);
103
+ assert.match(skill, /skills-only surfaces may lack repair/);
104
+
105
+ // OpenCode is a separate runtime surface; its session/plugin startup must
106
+ // not import or invoke the six-adapter installer/self-heal path implicitly.
107
+ const opencode = fs.readFileSync(OPENCODE, 'utf8');
108
+ assert.doesNotMatch(opencode, /self-heal\.js|scripts[\\/]installer\.js/);
109
+
110
+ console.log('Issue #213 verified: detection is read-only across six adapters, repair is explicit/idempotent, and OpenCode stays separate.');
111
+ } finally {
112
+ fs.rmSync(tempRoot, { recursive: true, force: true });
113
+ }
@@ -49,7 +49,7 @@ function discoverNestedSkills(skillDir) {
49
49
 
50
50
  function expectedMarker(skill) {
51
51
  if (skill === 'harness-everything') return 'RECOMMENDED TIER';
52
- if (skill === 'todo-driven-workflow') return 'BASE EXECUTION LOOP';
52
+ if (skill === 'todo-driven-workflow') return 'WORKFLOW STRATEGY';
53
53
  return `${skill}/SKILL.md`;
54
54
  }
55
55
 
@@ -13,8 +13,12 @@ graph TD
13
13
  PreflightOk -->|yes| ParseOut[Parse OS shell PATH and CLIs]
14
14
  PreflightOk -->|no| FallbackProbe[Inspect environment_info and probe shell]
15
15
  FallbackProbe --> ParseOut
16
- ParseOut --> SelfHealAudit[Audit harness touchpoints with self-heal.js]
17
- SelfHealAudit --> AdoptSyntax[Adopt shell-specific syntax]
16
+ ParseOut --> SelfHealAudit[Run self-heal.js --check when supported]
17
+ SelfHealAudit --> Drift{Integration drift found?}
18
+ Drift -->|ordinary detection| ReportOnly[Report only; do not mutate]
19
+ Drift -->|explicit repair intent| Repair[Run supported platform repair]
20
+ ReportOnly --> AdoptSyntax[Adopt shell-specific syntax]
21
+ Repair --> AdoptSyntax
18
22
  AdoptSyntax --> DoneCtx([Session context aligned])
19
23
  ```
20
24
 
@@ -48,10 +52,11 @@ graph LR
48
52
  A session starts on Windows with PowerShell as the active shell. The agent needs to list files and check Node availability before running tests.
49
53
 
50
54
  1. Run `node "<skill-dir>/scripts/preflight.js"` to detect Windows + PowerShell + available CLIs.
51
- 2. Adopt PowerShell syntax for paths and env vars instead of Git Bash assumptions.
52
- 3. If `preflight.js` cannot run, inspect `<environment_info>` and probe with minimal echo/env commands, then adopt syntax.
53
- 4. Stay inside `process.cwd()`; ignore other workspace, history, or temp paths shown by the IDE.
54
- 5. If the same aligned command still fails three times, stop retrying the syntax and trigger `zoom-out`.
55
+ 2. Where the local Harness runtime exists, run self-heal in `--check` mode only; report drift without changing hooks or advisory files.
56
+ 3. If the helper/runtime is absent (for example a skills-only distribution), report that the local repair surface is unavailable and continue without searching parent/cache paths.
57
+ 4. Only an explicit install/setup/repair request may invoke mutating self-heal. OpenCode keeps its separate plugin installation/runtime boundary.
58
+ 5. Adopt PowerShell syntax for paths and env vars instead of Git Bash assumptions. If `preflight.js` cannot run, inspect `<environment_info>` and probe minimally.
59
+ 6. Stay inside `process.cwd()`; if the same aligned command still fails three times, trigger `zoom-out`.
55
60
 
56
61
  ```mermaid
57
62
  graph TD
@@ -68,6 +73,9 @@ graph TD
68
73
  - [ ] Detection ran at session start via `environment-detection/scripts/preflight.js`, with `<environment_info>` inspection and probing used only as fallback
69
74
  - [ ] Adopted syntax matches detected shell: Git Bash uses `/`, `$VAR`, Unix cmds without `dir`/`del`; PowerShell uses `$env:VAR` and cmdlets; CMD uses `\`, `%VAR%`, `dir`/`del`/`copy` without Unix cmds
70
75
  - [ ] All commands stayed inside `process.cwd()`; no commands ran outside the current project root
71
- - [ ] No toolchain installation was attempted; scope stayed to detection, alignment, and touchpoint repair
76
+ - [ ] Ordinary detection changed no workspace integration files; touchpoint inspection used `--check` or safely skipped an unavailable local runtime
77
+ - [ ] Mutating self-heal ran only for explicit install/setup/repair intent and only on a supported local platform surface
78
+ - [ ] OpenCode was kept on its separate plugin runtime; skills-only distributions did not assume a local installer
79
+ - [ ] No toolchain installation was attempted; scope stayed to detection and alignment
72
80
  - [ ] After three failures of the same command, execution stopped blind retry and triggered `zoom-out`
73
81
  - [ ] Shell detail followed `environment-detection/references/shell-syntax-rules.md` where needed
@@ -4,38 +4,37 @@ description: Use at session start (Discover phase) to detect and align with the
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: Miya Daniel
7
- version: 0.4.0
7
+ version: 0.16.6
8
8
  ---
9
9
 
10
10
  # Environment Detection & Shell Alignment
11
11
 
12
- Think > Try > Summarize > Record: detect before executing.
13
-
14
12
  ## 📋 Skill Contract
15
13
 
16
14
  | Component | Specification |
17
15
  | :--- | :--- |
18
16
  | **Trigger / Input** | Session start or complex terminal sequences. |
19
- | **Expected Output** | Detected OS, shell, PATH via script or heuristics. |
20
- | **State Mutations** | Session context adopts path/env-var syntax. |
21
- | **Enforcement Gate** | Preflight; fall back to `<environment_info>` inspection and probing. |
17
+ | **Expected Output** | OS, shell, PATH, available CLIs. |
18
+ | **State Mutations** | Read-only by default; explicit repair may update Harness files. |
19
+ | **Enforcement Gate** | Preflight; fall back to `<environment_info>` and minimal probes. |
22
20
 
23
- Boundary: operate solely within `process.cwd()`; ignore other workspaces, history, or temp paths surfaced by the IDE — never run commands outside the current project root.
21
+ Boundary: stay inside `process.cwd()`. Detection never writes integrations or searches parent/cache paths for another runtime.
24
22
 
25
23
  ## Workflow
26
24
 
27
- 1. Preflight from this skill's own directory; parse OS, shell, available CLIs: `node "<this-skill-dir>/scripts/preflight.js"`
28
- 2. Self-heal harness touchpoints (idempotent): `node "<skills-repo-root>/harness-everything/scripts/self-heal.js"` — audits `<workspace>/.claude/settings.json`, `<workspace>/.cursorrules`, `<workspace>/.github/copilot-instructions.md`, `<workspace>/AGENTS.md`.
29
- 3. Adopt syntax: Git Bash → forward `/`, `$VAR`, Unix cmds (`ls`, `rm -rf`), never `dir`/`del`/PowerShell · PowerShell → `$env:VAR`, cmdlets · CMD → `\`, `%VAR%`, `dir`/`del`/`copy`, never Unix.
30
- 4. On failure don't blindly retry — suspect wrong-shell syntax. Three failures → trigger `zoom-out`.
25
+ 1. Run `node "<this-skill-dir>/scripts/preflight.js"`; detect OS, shell, CLIs.
26
+ 2. Where supported, audit read-only: `node "<this-skill-dir>/../harness-everything/scripts/self-heal.js" --check`. If unavailable, report and continue.
27
+ 3. Only explicit install/setup/repair intent may omit `--check`. Repair covers Claude, Codex, Copilot, Cursor, Continue, Hermes. OpenCode has its own plugin runtime; skills-only surfaces may lack repair.
28
+ 4. Adopt shell syntax: Git Bash → `/`, `$VAR`, Unix commands; PowerShell → `$env:VAR`, cmdlets; CMD → `\`, `%VAR%`, Windows commands. Three repeated failures → `zoom-out`.
31
29
 
32
30
  Deep dive: <this-skill-dir>/references/shell-syntax-rules.md
33
31
 
34
32
  ## USE FOR:
35
- - session-start OS/shell/toolchain detection
36
- - per-terminal command/path/env-var alignment
37
- - repairing missing harness touchpoints
33
+ - session-start environment detection
34
+ - shell/path/toolchain alignment
35
+ - read-only audit or explicit repair
38
36
 
39
37
  ## DO NOT USE FOR:
40
- - operating outside the current workspace
41
- - installing toolchains from scratch
38
+ - implicit repair during detection
39
+ - six-adapter repair on OpenCode/skills-only surfaces
40
+ - work outside the workspace or toolchain installation
@@ -4,7 +4,7 @@ description: "Route software/project work through the Harness kernel: classify T
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: Miya Daniel
7
- version: 0.16.3
7
+ version: 0.16.6
8
8
  ---
9
9
 
10
10
  # Harness Everything
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
+ const { getHarnessRoot, requireHarnessState, requireWorkspace } = require('./runtime-paths');
4
5
  const {
5
6
  getWorkspaceRoot,
6
7
  getSessionId,
7
8
  getSessionDir,
8
9
  writeCurrentSession,
9
10
  pruneStaleSessions,
10
- } = require('../../hooks/scripts/lib/harness-state');
11
+ } = requireHarnessState();
11
12
 
12
13
  console.log("Bootstrapping Harness Skills OS...");
13
14
 
@@ -162,9 +163,9 @@ try {
162
163
  // npx/global install auditing the harness checkout itself compares two
163
164
  // different paths and wrongly advises a repair that self-heal then skips
164
165
  // (issue #40). Required lazily so a missing lib can never break session start.
165
- const { isHarnessRepo } = require('../../scripts/lib/workspace');
166
+ const { isHarnessRepo } = requireWorkspace();
166
167
  const auditingSelf = isHarnessRepo(workspaceRoot)
167
- || path.resolve(workspaceRoot) === path.resolve(__dirname, '..', '..');
168
+ || path.resolve(workspaceRoot) === path.resolve(getHarnessRoot());
168
169
 
169
170
  if (missing.length > 0 && !auditingSelf) {
170
171
  console.log(`\n[Self-Heal] Missing integration touchpoints: ${missing.join(', ')}`);
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ // Helpers live in both the source checkout and the packaged plugin's skill
7
+ // tree. Resolve the owning runtime root instead of assuming either layout.
8
+ function candidateRoots() {
9
+ return [
10
+ path.resolve(__dirname, '..', '..'),
11
+ path.resolve(__dirname, '..', '..', '..'),
12
+ ];
13
+ }
14
+
15
+ function getHarnessRoot() {
16
+ const root = candidateRoots().find(candidate =>
17
+ fs.existsSync(path.join(candidate, 'scripts', 'lib', 'workspace.js'))
18
+ );
19
+ if (!root) {
20
+ throw new Error(`Harness runtime root not found from ${__dirname}`);
21
+ }
22
+ return root;
23
+ }
24
+
25
+ function requireWorkspace() {
26
+ return require(path.join(getHarnessRoot(), 'scripts', 'lib', 'workspace.js'));
27
+ }
28
+
29
+ function requireHarnessState() {
30
+ return require(path.join(getHarnessRoot(), 'hooks', 'scripts', 'lib', 'harness-state.js'));
31
+ }
32
+
33
+ module.exports = {
34
+ getHarnessRoot,
35
+ requireWorkspace,
36
+ requireHarnessState,
37
+ };
@@ -2,12 +2,12 @@
2
2
  /**
3
3
  * Self-healing installation audit for Harness OS.
4
4
  *
5
- * Audits the six platform integration touchpoints in the current workspace
6
- * and, when any are missing, re-runs the idempotent installer to repair them.
7
- * This makes the harness portable across editors: install once via Claude
8
- * Code, then open the same repo in Copilot/Cursor/Codex/Continue/Hermes and
9
- * the missing advisory instructions are backfilled automatically the first time
10
- * harness-everything (or the environment-detection Discover phase) runs.
5
+ * Audits the six platform integration touchpoints in the current workspace.
6
+ * Read-only callers use --check. Repair mode is explicit: only a direct run
7
+ * without --check may delegate to the idempotent installer.
8
+ *
9
+ * environment-detection uses the read-only path; ordinary Discover/preflight
10
+ * must never backfill hooks or advisory files as a side effect.
11
11
  *
12
12
  * Usage:
13
13
  * node self-heal.js Audit and repair anything missing.
@@ -23,7 +23,27 @@
23
23
  const fs = require('fs');
24
24
  const path = require('path');
25
25
  const { execSync } = require('child_process');
26
- const { getWorkspaceRoot, isHarnessRepo } = require('../../scripts/lib/workspace');
26
+ const { getHarnessRoot, requireWorkspace } = require('./runtime-paths');
27
+
28
+ function resolveLocalRuntime(checkOnly) {
29
+ try {
30
+ const { getWorkspaceRoot, isHarnessRepo } = requireWorkspace();
31
+ return { getWorkspaceRoot, isHarnessRepo, harnessSourceDir: getHarnessRoot() };
32
+ } catch (err) {
33
+ const message = err && err.message ? err.message : String(err);
34
+ if (!/Harness runtime root not found/.test(message)) throw err;
35
+
36
+ if (checkOnly) {
37
+ console.log('[Harness Self-Heal Audit]');
38
+ console.log(' SKIPPED Local repair runtime unavailable on this distribution surface.');
39
+ console.log('\nRead-only audit skipped; no workspace files were changed.');
40
+ return null;
41
+ }
42
+
43
+ console.error('Cannot repair: local Harness installer/runtime is unavailable on this distribution surface.');
44
+ process.exit(1);
45
+ }
46
+ }
27
47
 
28
48
  const MARKER = 'Harness OS Guidance (Advisory)';
29
49
  const HOOK_ID = 'harness:pre:bootstrap';
@@ -193,8 +213,11 @@ function main() {
193
213
  const checkOnly = process.argv.includes('--check');
194
214
  const forceSelf = process.argv.includes('--force-self');
195
215
 
216
+ const runtime = resolveLocalRuntime(checkOnly);
217
+ if (!runtime) return;
218
+
219
+ const { getWorkspaceRoot, isHarnessRepo, harnessSourceDir } = runtime;
196
220
  const workspaceRoot = getWorkspaceRoot();
197
- const harnessSourceDir = path.resolve(__dirname, '..', '..');
198
221
  const installerPath = path.join(harnessSourceDir, 'scripts', 'installer.js');
199
222
 
200
223
  console.log(`Workspace: ${workspaceRoot}`);
@@ -5,6 +5,7 @@ const {
5
5
  buildRouterContract,
6
6
  writeRouterContract,
7
7
  } = require('./router-contract');
8
+ const { requireWorkspace } = require('./runtime-paths');
8
9
 
9
10
  const DEFAULT_ROUTING_CONFIG = {
10
11
  tiers: { tier3: [], tier2: [] },
@@ -163,7 +164,7 @@ function plannerInputsFromContext(context, promptLower) {
163
164
  function emitDynamicSkills(promptLower, context, recommendedGuides) {
164
165
  try {
165
166
  const userHome = process.env.HOME || process.env.USERPROFILE || '';
166
- const { getWorkspaceRoot } = require('../../scripts/lib/workspace');
167
+ const { getWorkspaceRoot } = requireWorkspace();
167
168
  const workspaceRoot = getWorkspaceRoot(context);
168
169
 
169
170
  const manifestPaths = [
@@ -315,11 +316,6 @@ function run(userPrompt, context) {
315
316
  console.log(`\n=> RECOMMENDED TIER: ${recommendedTier}`);
316
317
  console.log(`=> RATIONALE: ${rationale}`);
317
318
 
318
- if (recommendedTier.startsWith('Tier 2') || recommendedTier.startsWith('Tier 3')) {
319
- console.log(`\n=> BASE EXECUTION LOOP: Load 'todo-driven-workflow' and initialize its checklist (3-7 verifiable sub-tasks) BEFORE editing any file.`);
320
- console.log(` Track exactly ONE item in-progress at a time; verify with real evidence before marking completed.`);
321
- }
322
-
323
319
  const requestedFableModel = detectFableModel(promptLower);
324
320
  if (requestedFableModel) {
325
321
  console.log(`\n=> REQUESTED FABLE MODEL MODE: ${requestedFableModel}`);
@@ -107,7 +107,7 @@ module.exports = {
107
107
  manifestPath: manifest.getManifestPath(claudeDir)
108
108
  };
109
109
  },
110
- install({ isGlobal, targetWorkspaceRoot, harnessSourceDir, packageVersion, claudeHooks, manifest }) {
110
+ install({ isGlobal, targetWorkspaceRoot, harnessSourceDir, harnessRuntimeRoot = harnessSourceDir, packageVersion, claudeHooks, manifest }) {
111
111
  const userHome = require('os').homedir();
112
112
  const claudeDir = isGlobal ? path.join(userHome, '.claude') : path.join(targetWorkspaceRoot, '.claude');
113
113
  if (!fs.existsSync(claudeDir)) {
@@ -124,7 +124,7 @@ module.exports = {
124
124
  }
125
125
  }
126
126
 
127
- const sourceHooksFile = path.join(harnessSourceDir, 'hooks', 'hooks.json');
127
+ const sourceHooksFile = path.join(harnessRuntimeRoot, 'hooks', 'hooks.json');
128
128
  if (fs.existsSync(sourceHooksFile)) {
129
129
  const sourceHooksObj = JSON.parse(fs.readFileSync(sourceHooksFile, 'utf8'));
130
130
  const resolvedHooks = {};
@@ -134,7 +134,7 @@ module.exports = {
134
134
  if (cloned.hooks) {
135
135
  cloned.hooks = cloned.hooks.map(h => {
136
136
  if (h.type === 'command' && h.command) {
137
- h.command = resolveClaudeHookCommand(h.command, harnessSourceDir);
137
+ h.command = resolveClaudeHookCommand(h.command, harnessRuntimeRoot);
138
138
  }
139
139
  return h;
140
140
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "harness-enforcement",
3
3
  "description": "Repository inventory for the opencode enforcement plugin and its standalone helper",
4
- "version": "0.16.4",
4
+ "version": "0.16.6",
5
5
  "runtime": "index.mjs",
6
6
  "hooks": {
7
7
  "verify": "hooks/verify.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harness-everything",
3
- "version": "0.16.4",
3
+ "version": "0.16.6",
4
4
  "description": "Harness OS: An Orchestrated Agent Operating System for AI-driven Development",
5
5
  "main": "harness-everything/scripts/bootstrap.js",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harness-everything",
3
- "version": "0.16.4",
3
+ "version": "0.16.6",
4
4
  "description": "Invariant-first engineering harness for routing, verification, and failure recovery while preserving agent autonomy.",
5
5
  "author": {
6
6
  "name": "Miya Daniel",
@@ -107,7 +107,7 @@ module.exports = {
107
107
  manifestPath: manifest.getManifestPath(claudeDir)
108
108
  };
109
109
  },
110
- install({ isGlobal, targetWorkspaceRoot, harnessSourceDir, packageVersion, claudeHooks, manifest }) {
110
+ install({ isGlobal, targetWorkspaceRoot, harnessSourceDir, harnessRuntimeRoot = harnessSourceDir, packageVersion, claudeHooks, manifest }) {
111
111
  const userHome = require('os').homedir();
112
112
  const claudeDir = isGlobal ? path.join(userHome, '.claude') : path.join(targetWorkspaceRoot, '.claude');
113
113
  if (!fs.existsSync(claudeDir)) {
@@ -124,7 +124,7 @@ module.exports = {
124
124
  }
125
125
  }
126
126
 
127
- const sourceHooksFile = path.join(harnessSourceDir, 'hooks', 'hooks.json');
127
+ const sourceHooksFile = path.join(harnessRuntimeRoot, 'hooks', 'hooks.json');
128
128
  if (fs.existsSync(sourceHooksFile)) {
129
129
  const sourceHooksObj = JSON.parse(fs.readFileSync(sourceHooksFile, 'utf8'));
130
130
  const resolvedHooks = {};
@@ -134,7 +134,7 @@ module.exports = {
134
134
  if (cloned.hooks) {
135
135
  cloned.hooks = cloned.hooks.map(h => {
136
136
  if (h.type === 'command' && h.command) {
137
- h.command = resolveClaudeHookCommand(h.command, harnessSourceDir);
137
+ h.command = resolveClaudeHookCommand(h.command, harnessRuntimeRoot);
138
138
  }
139
139
  return h;
140
140
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "harness-everything",
4
- "version": "0.16.4",
4
+ "version": "0.16.6",
5
5
  "description": "Invariant-first engineering harness for routing, verification, and failure recovery while preserving agent autonomy.",
6
6
  "author": {
7
7
  "name": "Miya Daniel",