oc-harness-setup 0.3.0 โ†’ 0.3.2

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 (4) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +65 -43
  3. package/bin/cli.js +175 -31
  4. package/package.json +3 -2
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 nathwn12
3
+ Copyright (c) 2026 nathan <137482711+nathwn12@users.noreply.github.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,69 +1,91 @@
1
- <div align="center">
1
+ <p align="center">
2
+ <img src="assets/icon.svg" width="128" height="128" alt="oc-harness-setup icon" />
3
+ </p>
4
+ <h1 align="center">oc-harness-setup</h1>
5
+ <p align="center"><strong>Install and orchestrate the whole OpenCode harness in one command - PowerShell.</strong></p>
6
+ <p align="center">
7
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/nathwn12/oc-harness-setup" alt="License" /></a>
8
+ <img src="https://img.shields.io/github/languages/top/nathwn12/oc-harness-setup" alt="Language" />
9
+ <img src="https://img.shields.io/badge/platform-windows--linux-2b3137" alt="Platform" />
10
+ <a href="https://github.com/nathwn12/oc-harness-setup/actions/workflows/ci.yml"><img src="https://github.com/nathwn12/oc-harness-setup/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
11
+ </p>
2
12
 
3
- # :rocket: oc-harness-setup
13
+ ## What it is
4
14
 
5
- **The whole harness in one command.**
6
- *Orchestrator primary . 7 agents . 14 commands . 20 skills . a doctor that proves it.*
15
+ oc-harness-setup is a plug-and-play installer for the whole OpenCode harness. One explicit command lands an orchestrator primary with 7 agents, 14 commands, 20 skills, 18 PowerShell scripts, and a 16-law doctor gate that proves the install. It is a pure Node ESM package with zero runtime dependencies, shipped via npm.
7
16
 
8
- ![npm](https://img.shields.io/npm/v/oc-harness-setup) ![license](https://img.shields.io/badge/license-MIT-blue) ![opencode](https://img.shields.io/badge/opencode-v2-blueviolet) ![node](https://img.shields.io/badge/node-%E2%89%A522-green) ![downloads](https://img.shields.io/npm/dm/oc-harness-setup)
17
+ ## Why
9
18
 
10
- </div>
19
+ Setting up the harness by hand means copying dozens of files and hoping they agree. This pack makes setup consent-first, idempotent, and verified: the full manifest prints before anything moves, re-runs skip identical files, and every install ends on the harness's own doctor. Installation never modifies config by itself; setup is always an explicit command, never a postinstall.
11
20
 
12
- ---
21
+ ## Features
13
22
 
14
- ## :zap: Quick start
23
+ - One-command setup: `npx --yes oc-harness-setup setup`, then restart OpenCode
24
+ - Consent gate: the full manifest prints before anything moves; `--dry-run` changes nothing
25
+ - Idempotent: re-run anytime, identical files are skipped
26
+ - Verified: ends on the 16-law harness doctor; failures name the check, the detail, and a fix
27
+ - Config-preserving merge: your model, providers, MCP, and plugins survive; runtime policy is owned by the pack
28
+ - Fail-closed permissions: the deny set survives `--auto`, skills load from an exact allowlist
29
+ - Reversible: a SHA-256 journal records every touched file; `--uninstall` restores from backup
30
+ - Zero runtime dependencies: pure Node ESM, stdlib only
15
31
 
16
- ```bash
17
- npx --yes oc-harness-setup setup
18
- ```
32
+ ## Install
19
33
 
20
- > Just installed OpenCode? This lands a **working harness**: an orchestrator that triages, swarms, and reduces - with the agents, commands, skills, and health gate already wired. Plug it in. Play.
34
+ 1. Run the installer: `npx --yes oc-harness-setup setup`
35
+ 2. Restart OpenCode.
36
+ 3. Verify: `pwsh -File ~/.config/opencode/scripts/harness-doctor.ps1`
21
37
 
22
- ---
38
+ Requires Node >= 22. The doctor gate needs PowerShell 7; where it is missing, laws are reported as skipped, not passed.
23
39
 
24
- ## :wrench: What setup does
40
+ ## Usage
25
41
 
26
- ```text
27
- preflight -> locate config -> consent gate -> backup -> install -> verify
28
- ```
42
+ Preview without touching a file:
29
43
 
30
- - **Consent first** - the full manifest prints before anything moves; `--dry-run` shows it without touching a file
31
- - **Your config survives** - the installer owns runtime policy (`$schema`, `default_agent`, `formatter`, `compaction`, `tool_output`, `media`, `watcher`), unions your `plugins` and `references` with the harness's, and preserves every other top-level key, known or unknown - `provider`, `model`, `agents`, `commands`, `skills`, `mcp`, or a key of your own
32
- - **Your `permissions` still apply** - your rules are placed after the harness's allow/ask rules and ahead of its hard denies, so a rule of yours beats a harness allow while the hard denies stay last
33
- - **Reversible** - a SHA-256 journal records every touched file; `--uninstall` removes the files the installer created and restores any file it overwrote from the pre-install backup (its path is printed before anything moves). Post-install edits to a restored file are copied aside first as `<name>.replaced-<ts>` - never destroyed
34
- - **Idempotent** - re-run anytime; identical files are skipped
35
- - **Verified** - ends on the harness's own 16-law doctor; red = nonzero exit, with every failing law naming the check, the detail, and a proposed fix. The doctor needs PowerShell 7: if it is missing, the laws are **skipped** and reported as skipped - not passed
44
+ ```bash
45
+ npx --yes oc-harness-setup setup --dry-run
46
+ ```
36
47
 
37
- > *Installation never modifies your config by itself - setup is always an explicit command you run. **No postinstall, ever.***
48
+ Install for real:
38
49
 
39
- ---
50
+ ```bash
51
+ npx --yes oc-harness-setup setup
52
+ ```
40
53
 
41
- ## :package: What you get
54
+ Remove everything the installer created and restore overwritten files from backup:
42
55
 
43
- | Component | What it gives you |
44
- |:---|:---|
45
- | ๐Ÿง  **Orchestrator** | dispatch tiers, parallel waves, fan-in reduction, one question per close |
46
- | ๐Ÿค– **7 agents** | orchestrator . plan . build . explore . general . reviewer . vault (secrets by pointer) |
47
- | โŒจ๏ธ **14 commands** | build . checkpoint . code-simplify . gauntlet . handoff . keeper . kill . plan . retro . review . ship . spec . test . webperf |
48
- | ๐Ÿงช **20 skills** | git ceremony . TDD . debugging . security . performance . test-flight . flight-deck . ... |
49
- | ๐Ÿฉบ **The doctor** | 16 self-derived laws; green = consistent, regressions != drift (runs as an installer-integrated gate, not a command) |
56
+ ```bash
57
+ npx --yes oc-harness-setup setup --uninstall
58
+ ```
50
59
 
51
- ---
60
+ ## Build from source
52
61
 
53
- ## ๐Ÿ›ก๏ธ Safety by design
62
+ Prerequisites: Node >= 22 and Bun (for the test suite). No build step: pure Node ESM, stdlib only.
54
63
 
55
- > Strict deny-set permissions that survive `--auto` . skills fail closed on unknown IDs . credentials stay by pointer . backup before any change.
64
+ ```bash
65
+ git clone https://github.com/nathwn12/oc-harness-setup.git
66
+ cd oc-harness-setup
67
+ npm test
68
+ npm run check
69
+ ```
56
70
 
57
- ### Policy
71
+ ## Docs
58
72
 
59
- This package ships a **fail-closed permission set**: the disk-destroy and credential denies hold even under `--auto`, and skills load only from an exact allowlist - an unknown skill ID is denied, not loaded. The author's own live harness runs permission-free; the guardrails here are intentional, kept for adopters who want the safety net. Rogue-session and housekeeping machinery ships too: `/kill` (with `scripts/interrupt-session.ps1`) stops a runaway session, and `scripts/gc-clean.ps1` sweeps junk with a dry-run default. Adopters who prefer the author's freer setup can relax or remove the deny entries in the merged opencode.jsonc, with one caveat: the installer's merge re-applies the harness's deny entries on every install run - the deny tail is always placed after your rules, and under last-match-wins a re-added deny outranks any relaxation you added. To keep relaxed permissions, remove the deny entries from the merged opencode.jsonc and do not re-run setup afterwards.
73
+ - [AGENTS.md](AGENTS.md) โ€” the harness contract the installer ships
74
+ - [reference/](reference/) โ€” harness references: dispatch, lifecycle, models, session state
75
+ - [.docs/unwired-routing.md](.docs/unwired-routing.md) โ€” unwired routing notes
60
76
 
61
- ---
77
+ ## Status
62
78
 
63
- <div align="center">
79
+ **Unverified** โ€” as-is, use at your own risk.
64
80
 
65
- OpenCode V2 . Node >= 22 . Windows / macOS / Linux (config path auto-resolved)
81
+ ## License
66
82
 
67
- **MIT ยฉ 2026 nathwn12** . For OpenCode. Free.
83
+ MIT โ€” see [LICENSE](LICENSE).
68
84
 
69
- </div>
85
+ <!-- nathwn12 house footer: identical in every repo. Do not edit. -->
86
+ <p align="center">
87
+ <a href="https://github.com/nathwn12"><img src="assets/signature.svg" width="96" alt="nathwn12" /></a>
88
+ </p>
89
+ <p align="center">
90
+ <sub>Built by <a href="https://github.com/nathwn12">nathwn12</a> ยท <a href="https://github.com/nathwn12?tab=repositories">All projects</a></sub>
91
+ </p>
package/bin/cli.js CHANGED
@@ -49,14 +49,14 @@ const PRESERVE_IF_EXISTS = new Set(['reference/models.md', 'reference/owner-pin.
49
49
  // package source only, never the adopter's config, so a legitimate
50
50
  // `{file:~/.secrets/โ€ฆ}` apiKey pointer can never abort an install.
51
51
  //
52
- // Every marker is anchored to the AUTHOR's CONCRETE machine โ€” drive `Q:`, user
53
- // `nathan`, a real `ses_<id>` โ€” never to the product's own vocabulary. The
52
+ // Every marker is anchored to the author's concrete machine โ€” a drive
53
+ // letter, a username, a real session id โ€” never to the product's own vocabulary. The
54
54
  // harness's safety tooling legitimately ships the generic forms
55
55
  // (`C:\Users\<name>`, `ses_<id>`, `~/.secrets/โ€ฆ` โ€” redactor regexes and their
56
56
  // self-test probes), so a bare generic token would abort every correct install.
57
57
  // A leak of an author path into a secret store is caught by the username/drive
58
58
  // markers; a bare `.secrets` cannot distinguish product from author and so is
59
- // deliberately not a marker. `nathan` also subsumes `C:\Users\nathan`.
59
+ // deliberately not a marker. The username marker also subsumes the full profile path.
60
60
  const LINT_PATTERNS = [
61
61
  { label: 'q:\\', test: /q:\\/ },
62
62
  { label: 'nathan', test: /nathan/ },
@@ -79,6 +79,28 @@ function nextFreePath(base) {
79
79
  }
80
80
  }
81
81
 
82
+ // F4: atomic file replace โ€” rename dest aside, rename tmp into place, then
83
+ // delete the aside copy (restoring the aside copy if the middle step throws).
84
+ // Closes the rm-then-rename window where a crash left the user's file DELETED
85
+ // with the new copy orphaned as tmp.
86
+ function atomicInstall(tmp, dest) {
87
+ if (!existsSync(dest)) {
88
+ renameSync(tmp, dest);
89
+ return;
90
+ }
91
+ const aside = nextFreePath(`${dest}.oc-harness-setup-aside-${process.pid}`);
92
+ renameSync(dest, aside);
93
+ try {
94
+ renameSync(tmp, dest);
95
+ } catch (err) {
96
+ try {
97
+ renameSync(aside, dest);
98
+ } catch {}
99
+ throw err;
100
+ }
101
+ rmSync(aside, { force: true });
102
+ }
103
+
82
104
  function usage() {
83
105
  console.log(`oc-harness-setup โ€” install the OpenCode harness into your config dir.
84
106
 
@@ -165,6 +187,10 @@ function findConfigDir() {
165
187
  dir = path.join(homedir(), dir.slice(2));
166
188
  }
167
189
  if (dir) {
190
+ // F7: opencode echoes OPENCODE_CONFIG_DIR verbatim, so a relative
191
+ // value arrives here still relative โ€” resolve to absolute so the
192
+ // manifest records a cwd-independent destination.
193
+ dir = path.resolve(dir);
168
194
  log('config', `resolved via 'opencode debug paths': ${dir}`);
169
195
  return dir;
170
196
  }
@@ -174,8 +200,16 @@ function findConfigDir() {
174
200
  }
175
201
  const env = process.env;
176
202
  if (env.OPENCODE_CONFIG_DIR) {
177
- log('config', `env OPENCODE_CONFIG_DIR: ${env.OPENCODE_CONFIG_DIR}`);
178
- return env.OPENCODE_CONFIG_DIR;
203
+ // F7: resolve verbatim env (relative โ†’ cwd-dependent) to absolute and
204
+ // expand a leading ~, mirroring the debug-paths branch.
205
+ let dir = String(env.OPENCODE_CONFIG_DIR).trim().replace(/^["']|["']$/g, '');
206
+ if (dir === '~' || (dir.startsWith('~') && (dir[1] === '/' || dir[1] === '\\'))) {
207
+ dir = path.join(homedir(), dir.length > 1 ? dir.slice(2) : '');
208
+ } else {
209
+ dir = path.resolve(dir);
210
+ }
211
+ log('config', `env OPENCODE_CONFIG_DIR: ${dir}`);
212
+ return dir;
179
213
  }
180
214
  if (env.XDG_CONFIG_HOME) {
181
215
  const p = path.join(env.XDG_CONFIG_HOME, 'opencode');
@@ -293,8 +327,7 @@ function stageFiles(files, manifest) {
293
327
  mkdirSync(path.dirname(f.dest), { recursive: true });
294
328
  const tmp = `${f.dest}.oc-harness-setup-tmp-${process.pid}`;
295
329
  writeFileSync(tmp, readFileSync(f.src));
296
- rmSync(f.dest, { force: true }); // Windows rename() cannot overwrite
297
- renameSync(tmp, f.dest);
330
+ atomicInstall(tmp, f.dest);
298
331
  written += 1;
299
332
  }
300
333
  // Preserved entries journal the SRC hash on purpose: --uninstall deletes
@@ -461,8 +494,7 @@ function mergeJsonc(configDir, backupPath, manifest) {
461
494
  mkdirSync(configDir, { recursive: true });
462
495
  const tmp = `${targetPath}.oc-harness-setup-tmp-${process.pid}`;
463
496
  writeFileSync(tmp, out);
464
- rmSync(targetPath, { force: true });
465
- renameSync(tmp, targetPath);
497
+ atomicInstall(tmp, targetPath);
466
498
  manifest.files.push({ path: 'opencode.jsonc', hash: sha256Text(out), action: 'merged' });
467
499
  log(
468
500
  'merge',
@@ -607,7 +639,10 @@ async function confirmProceed() {
607
639
 
608
640
  /* -------------------------------- uninstall -------------------------------- */
609
641
 
610
- function uninstall(configDir) {
642
+ function uninstall(configDir, opts = {}) {
643
+ // F3: --dry-run / --ci preview what would be removed and return 0 without
644
+ // deleting (setup --uninstall --dry-run must touch nothing).
645
+ const preview = !!(opts.preview || opts.dryRun || opts.ci);
611
646
  const manifestPath = path.join(configDir, MANIFEST_FILE);
612
647
  if (!existsSync(manifestPath)) {
613
648
  bail(
@@ -652,31 +687,63 @@ function uninstall(configDir) {
652
687
  // the restore overwrites it. Byte-identical installer output needs no
653
688
  // copy.
654
689
  if (!entry.hash || sha256File(resolved) !== entry.hash) {
655
- const keep = nextFreePath(`${resolved}.replaced-${tsStamp()}`);
656
- cpSync(resolved, keep);
657
- preserved += 1;
658
- log('uninstall', `kept ${path.relative(base, keep)} (your post-install edits โ€” copied before restore)`);
690
+ if (preview) {
691
+ preserved += 1;
692
+ log('uninstall', `would keep ${path.relative(base, nextFreePath(`${resolved}.replaced-${tsStamp()}`))} (your post-install edits โ€” would copy before restore)`);
693
+ } else {
694
+ const keep = nextFreePath(`${resolved}.replaced-${tsStamp()}`);
695
+ cpSync(resolved, keep);
696
+ preserved += 1;
697
+ log('uninstall', `kept ${path.relative(base, keep)} (your post-install edits โ€” copied before restore)`);
698
+ }
699
+ }
700
+ if (preview) {
701
+ restored += 1;
702
+ log('uninstall', `would restore ${rel} (your pre-install file, from ${manifest.backupPath})`);
703
+ } else {
704
+ cpSync(original, resolved, { force: true });
705
+ restored += 1;
706
+ log('uninstall', `restored ${rel} (your pre-install file, from ${manifest.backupPath})`);
707
+ }
708
+ } else if (entry.action === 'merged' && entry.hash && sha256File(resolved) === entry.hash) {
709
+ // F5: installer-created merge output (adopter had only opencode.json,
710
+ // so no backup holds opencode.jsonc) still hashes to what was written
711
+ // โ€” it is pure installer output, so delete it; keep only user-modified.
712
+ if (preview) {
713
+ removed += 1;
714
+ log('uninstall', `would remove ${rel} (installer-created merge output โ€” no pre-install file to restore)`);
715
+ } else {
716
+ rmSync(resolved, { force: true });
717
+ removed += 1;
718
+ log('uninstall', `removed ${rel} (installer-created merge output โ€” no pre-install file to restore)`);
659
719
  }
660
- cpSync(original, resolved, { force: true });
661
- restored += 1;
662
- log('uninstall', `restored ${rel} (your pre-install file, from ${manifest.backupPath})`);
663
720
  } else {
664
721
  kept += 1;
665
- log('uninstall', `kept ${rel} (WARNING: no backup at ${original || '(no backupPath recorded)'} โ€” not deleted)`);
722
+ log('uninstall', `${preview ? 'would keep' : 'kept '} ${rel} (WARNING: no backup at ${original || '(no backupPath recorded)'} โ€” not deleted)`);
666
723
  }
667
724
  continue;
668
725
  }
669
726
  if (entry.hash && sha256File(resolved) === entry.hash) {
670
- rmSync(resolved, { force: true });
671
- removed += 1;
672
- log('uninstall', `removed ${rel}`);
727
+ if (preview) {
728
+ removed += 1;
729
+ log('uninstall', `would remove ${rel}`);
730
+ } else {
731
+ rmSync(resolved, { force: true });
732
+ removed += 1;
733
+ log('uninstall', `removed ${rel}`);
734
+ }
673
735
  } else {
674
736
  kept += 1;
675
737
  log('uninstall', `kept ${rel} (you modified it โ€” hash differs)`);
676
738
  }
677
739
  }
678
- rmSync(manifestPath, { force: true });
679
- log('uninstall', `removed ${removed}, restored ${restored} overwritten, kept ${kept} modified, preserved ${preserved} edit-copies, already-missing ${missing}`);
740
+ if (preview) {
741
+ log('uninstall', `would remove ${removed}, would restore ${restored} overwritten, would keep ${kept} modified, preserved ${preserved} edit-copies, already-missing ${missing}`);
742
+ console.log('[dry-run] preview only โ€” nothing was touched.');
743
+ } else {
744
+ rmSync(manifestPath, { force: true });
745
+ log('uninstall', `removed ${removed}, restored ${restored} overwritten, kept ${kept} modified, preserved ${preserved} edit-copies, already-missing ${missing}`);
746
+ }
680
747
  console.log(` backup (pre-install config dir): ${manifest.backupPath || '(none recorded)'}`);
681
748
  if (manifest.priorBackup) console.log(` later snapshot (kept for the chain): ${manifest.priorBackup}`);
682
749
  console.log(' to restore it fully, replace the current config dir with that backup.');
@@ -758,7 +825,81 @@ function warnConfigTargets(configDir) {
758
825
  }
759
826
  }
760
827
 
828
+ // F6: sweep installer crash litter (*.oc-harness-setup-tmp-*) left if killed
829
+ // between writeFileSync and renameSync. The infix `.oc-harness-setup-tmp-`
830
+ // never appears in real user files (opencode.jsonc, agents/*.md, โ€ฆ), so the
831
+ // sweep is unambiguous installer junk. Runs only on the mutating path (never
832
+ // under --dry-run / --ci, which promise to touch nothing).
833
+ function sweepTmpLitter(configDir) {
834
+ if (!existsSync(configDir)) return 0;
835
+ try {
836
+ if (!statSync(configDir).isDirectory()) return 0;
837
+ } catch {
838
+ return 0;
839
+ }
840
+ let swept = 0;
841
+ const walk = (dir) => {
842
+ let ents;
843
+ try {
844
+ ents = readdirSync(dir, { withFileTypes: true });
845
+ } catch {
846
+ return;
847
+ }
848
+ for (const ent of ents) {
849
+ const p = path.join(dir, ent.name);
850
+ if (ent.isDirectory()) walk(p);
851
+ else if (ent.name.includes('.oc-harness-setup-tmp-')) {
852
+ try {
853
+ rmSync(p, { force: true });
854
+ swept += 1;
855
+ log('sweep', `removed crash litter ${path.relative(configDir, p)}`);
856
+ } catch {}
857
+ }
858
+ }
859
+ };
860
+ walk(configDir);
861
+ return swept;
862
+ }
863
+
864
+ // F1: validate every JSONC parse BEFORE any write, so a broken config bails
865
+ // before staging overwrites live files (no manifest => uninstall could not restore).
866
+ function validateJsoncInputs(configDir, backupPath) {
867
+ const distroPath = path.join(PKG_ROOT, 'opencode.jsonc');
868
+ if (existsSync(distroPath)) {
869
+ parseJsonc(
870
+ readFileSync(distroPath, 'utf8'),
871
+ 'the shipped opencode.jsonc (this package build looks broken)'
872
+ );
873
+ }
874
+ const targetPath = path.join(configDir, 'opencode.jsonc');
875
+ const jsonPath = path.join(configDir, 'opencode.json');
876
+ const sourcePath = existsSync(targetPath) ? targetPath : existsSync(jsonPath) ? jsonPath : null;
877
+ if (sourcePath) {
878
+ parseJsonc(
879
+ readFileSync(sourcePath, 'utf8'),
880
+ `your existing ${path.basename(sourcePath)} โ€” aborting before any write; your config is untouched (backup: ${backupPath})`
881
+ );
882
+ }
883
+ }
884
+
761
885
  async function setup(opts) {
886
+ // F2: --ci / --dry-run promise print-only exit 0 with no mutation โ€” honour
887
+ // them BEFORE preflight(), which bails without the opencode binary (exactly
888
+ // the headless case --ci exists for). Read-only manifest path only.
889
+ if (opts.ci || opts.dryRun) {
890
+ const configDir = findConfigDir();
891
+ const files = collectIncoming(configDir);
892
+ const prior = readManifest(configDir); // read-only
893
+ const newBackupPath = nextBackupPath(configDir);
894
+ const backupPath = prior && prior.backupPath ? prior.backupPath : newBackupPath;
895
+ printManifest(configDir, files, backupPath, doctorPlan());
896
+ if (opts.dryRun) {
897
+ console.log('[dry-run] manifest only โ€” nothing was touched.');
898
+ return 0;
899
+ }
900
+ console.log('[ci] refusing to mutate โ€” print-only. Run setup interactively to install.');
901
+ return 0;
902
+ }
762
903
  preflight();
763
904
  const configDir = findConfigDir();
764
905
  warnConfigTargets(configDir);
@@ -784,20 +925,18 @@ async function setup(opts) {
784
925
  const doctorProbe = pwshProbe(); // read-only probe
785
926
  printManifest(configDir, files, backupPath, doctorPlan());
786
927
 
787
- if (opts.dryRun) {
788
- console.log('[dry-run] manifest only โ€” nothing was touched.');
789
- return 0;
790
- }
791
- if (opts.ci) {
792
- console.log('[ci] refusing to mutate โ€” print-only. Run setup interactively to install.');
793
- return 0;
794
- }
928
+ // (F2: --dry-run / --ci already returned print-only before preflight.)
795
929
  if (!(await confirmProceed())) {
796
930
  console.log('[gate] aborted โ€” nothing was modified.');
797
931
  return 0;
798
932
  }
799
933
 
800
934
  /* ---------------- mutations begin (all journaled) ---------------- */
935
+ // F1: every parse validated BEFORE the first write โ€” a broken config bails
936
+ // here, before staging overwrites live files.
937
+ validateJsoncInputs(configDir, backupPath);
938
+ // F6: sweep unambiguous installer crash litter before the first write.
939
+ sweepTmpLitter(configDir);
801
940
  const backup = makeBackup(configDir, newBackupPath);
802
941
  const manifest = {
803
942
  package: PKG_NAME,
@@ -882,6 +1021,11 @@ async function main() {
882
1021
  if (!opts) return;
883
1022
  if (opts.uninstall) {
884
1023
  const configDir = findConfigDir();
1024
+ // F3: honour --dry-run / --ci in the uninstall branch โ€” preview only.
1025
+ if (opts.dryRun || opts.ci) {
1026
+ uninstall(configDir, { preview: true });
1027
+ return;
1028
+ }
885
1029
  uninstall(configDir);
886
1030
  return;
887
1031
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-harness-setup",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "oc-harness-setup": "bin/cli.js"
@@ -24,7 +24,8 @@
24
24
  },
25
25
  "scripts": {
26
26
  "check": "npm pack --dry-run",
27
- "test": "node --check bin/cli.js"
27
+ "test": "node --check bin/cli.js && bun test",
28
+ "prepublishOnly": "npm run check"
28
29
  },
29
30
  "publishConfig": {
30
31
  "access": "public"