oc-harness-setup 0.6.0 → 1.0.0
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/AGENTS.md +73 -81
- package/CHANGELOG.md +39 -0
- package/README.md +2 -2
- package/agents/code-agent.md +89 -0
- package/agents/git-agent.md +72 -0
- package/agents/harness-agent.md +88 -0
- package/agents/host-agent.md +68 -0
- package/agents/memory-agent.md +93 -0
- package/agents/release-agent.md +74 -0
- package/agents/research-agent.md +72 -0
- package/agents/secret-agent.md +72 -0
- package/agents/surface-agent.md +83 -0
- package/agents/verify-agent.md +117 -0
- package/bin/cli.js +207 -98
- package/docs/GUIDE.md +8 -8
- package/package.json +2 -2
- package/reference/README.md +6 -6
- package/reference/context.md +19 -21
- package/reference/enforcement.md +7 -3
- package/reference/flow.md +37 -17
- package/reference/harness.md +6 -8
- package/reference/hygiene.md +23 -4
- package/reference/memory.md +25 -13
- package/reference/models.md +1 -1
- package/reference/phases.md +12 -22
- package/reference/tools.md +17 -16
- package/agents/cleaner.md +0 -86
- package/agents/critic.md +0 -79
- package/agents/historian.md +0 -92
- package/agents/maintainer.md +0 -106
- package/agents/ops.md +0 -69
- package/agents/orchestrator.md +0 -68
- package/agents/researcher.md +0 -72
- package/agents/verifier.md +0 -84
- package/agents/worker.md +0 -87
package/bin/cli.js
CHANGED
|
@@ -49,7 +49,11 @@ const FILE_ALIASES = { 'gitignore.template': '.gitignore' };
|
|
|
49
49
|
const DIR_ALIASES = { 'state-seed': 'state' };
|
|
50
50
|
// Ownership table for the opencode.jsonc merge. Every top-level key falls into
|
|
51
51
|
// exactly one bucket; there is no "known merge key" list to drift out of date.
|
|
52
|
-
// INSTALL_OWNED — the distro
|
|
52
|
+
// INSTALL_OWNED — the distro supplies a default; on a collision the adopter's
|
|
53
|
+
// value wins and the collided key is reported by name.
|
|
54
|
+
// DENY_OWNED — the hard tool.use deny block. Unioned with the adopter's
|
|
55
|
+
// entries, distro denies last, so a user rule can be added but
|
|
56
|
+
// can never shadow a shipped deny.
|
|
53
57
|
// UNION_KEYS — arrays unioned + deduped (distro entries first).
|
|
54
58
|
// 'references' — object union: distro keys + user-only keys.
|
|
55
59
|
// 'permissions' — ordered union: harness allow/ask rules first, then the
|
|
@@ -60,7 +64,8 @@ const DIR_ALIASES = { 'state-seed': 'state' };
|
|
|
60
64
|
// allowlist is deny-then-allows; see mergeJsonc).
|
|
61
65
|
// everything else (known or unknown) — the adopter's value wins; the distro
|
|
62
66
|
// value stays when the adopter does not define the key.
|
|
63
|
-
const INSTALL_OWNED = ['$schema', 'default_agent', 'formatter', 'compaction', 'tool_output', 'media', 'watcher'
|
|
67
|
+
const INSTALL_OWNED = ['$schema', 'default_agent', 'formatter', 'compaction', 'tool_output', 'media', 'watcher'];
|
|
68
|
+
const DENY_OWNED = ['policies'];
|
|
64
69
|
const UNION_KEYS = ['plugins'];
|
|
65
70
|
const DISTRO_PLUGIN_IDS = ['oc-flight-deck'];
|
|
66
71
|
|
|
@@ -111,16 +116,11 @@ function normalizePluginEntries(entries) {
|
|
|
111
116
|
return out;
|
|
112
117
|
}
|
|
113
118
|
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
// genuinely adopter-edited one is kept. The template is a controlled copy
|
|
120
|
-
// graded by the doctor, so adopter edits are archived then overwritten.
|
|
121
|
-
const PRESERVE_IF_EXISTS = new Set(['reference/models.md', 'AGENTS.md', '.gitignore', 'state/lessons.md']);
|
|
122
|
-
// Keyed on forward slashes; matched through norm() because rel is platform-native
|
|
123
|
-
// (path.join yields backslashes on Windows).
|
|
119
|
+
// Every shipped file follows one decision table (classifyDest): new bytes land
|
|
120
|
+
// in place only where the destination still matches what we installed. A
|
|
121
|
+
// destination that cannot be proven package-owned is the adopter's file, so it
|
|
122
|
+
// is never overwritten — the new version lands beside it as `<name>.new`.
|
|
123
|
+
//
|
|
124
124
|
// Leak markers — generic shapes, never a concrete machine. They catch the
|
|
125
125
|
// maintainer's workstation leaking into the shipped tree (an absolute
|
|
126
126
|
// user-profile path, a session id). They are linted against the package
|
|
@@ -179,6 +179,15 @@ function atomicInstall(tmp, dest) {
|
|
|
179
179
|
rmSync(aside, { force: true });
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
// Write bytes through the atomic replace, so a crash never leaves the
|
|
183
|
+
// destination deleted with the new copy orphaned as tmp.
|
|
184
|
+
function installBytes(dest, buf) {
|
|
185
|
+
mkdirSync(path.dirname(dest), { recursive: true });
|
|
186
|
+
const tmp = `${dest}.oc-harness-setup-tmp-${process.pid}`;
|
|
187
|
+
writeFileSync(tmp, buf);
|
|
188
|
+
atomicInstall(tmp, dest);
|
|
189
|
+
}
|
|
190
|
+
|
|
182
191
|
function usage() {
|
|
183
192
|
console.log(`oc-harness-setup — install the OpenCode harness into your config dir.
|
|
184
193
|
|
|
@@ -427,7 +436,7 @@ function nextBackupPath(configDir) {
|
|
|
427
436
|
|
|
428
437
|
/* ------------------------------ staged copy -------------------------------- */
|
|
429
438
|
|
|
430
|
-
function stageFiles(files, manifest, prior
|
|
439
|
+
function stageFiles(files, manifest, prior) {
|
|
431
440
|
// Prior manifests spell paths with either separator; incoming rels use the
|
|
432
441
|
// platform join. Compare on normalized slashes so a prior entry still
|
|
433
442
|
// matches its incoming path (journaling keeps each entry's own spelling).
|
|
@@ -435,85 +444,81 @@ function stageFiles(files, manifest, prior, configDir) {
|
|
|
435
444
|
const priorByPath = new Map(
|
|
436
445
|
(prior && Array.isArray(prior.files) ? prior.files : []).map((f) => [norm(f.path), f])
|
|
437
446
|
);
|
|
438
|
-
|
|
447
|
+
const counts = { added: 0, updated: 0, kept: 0, skipped: 0 };
|
|
439
448
|
for (const f of files) {
|
|
440
449
|
const srcHash = sha256File(f.src);
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
action = 'skip';
|
|
448
|
-
log('staging', `skip ${f.rel} (already identical — rerun-safe)`);
|
|
449
|
-
} else if (PRESERVE_IF_EXISTS.has(norm(f.rel))) {
|
|
450
|
-
// Upgrade rule: preserve only a GENUINELY adopter-edited file, i.e.
|
|
451
|
-
// one that differs from the prior manifest hash. A destination that
|
|
452
|
-
// still matches the prior installed hash is unmodified pack content —
|
|
453
|
-
// update it, so a stock 0.3.3 AGENTS.md is replaced by the V9 contract
|
|
454
|
-
// while an adopter-edited AGENTS.md is kept. No prior record means we
|
|
455
|
-
// cannot prove it is stock, so preserve (never destroy unknown data).
|
|
456
|
-
const p = priorByPath.get(norm(f.rel));
|
|
457
|
-
if (p && p.hash && destHash === p.hash) {
|
|
458
|
-
action = 'overwritten';
|
|
459
|
-
prevHash = destHash;
|
|
460
|
-
log('staging', `update ${f.rel} (matches the prior installed hash — unmodified pack content, overwriting; backup + manifest protect you)`);
|
|
461
|
-
} else {
|
|
462
|
-
action = 'preserved';
|
|
463
|
-
log('staging', `preserve ${f.rel} (exists and differs from the prior install — kept; harness will not overwrite adopter-owned files)`);
|
|
464
|
-
}
|
|
465
|
-
} else {
|
|
466
|
-
// Safe-upgrade rule: a destination the user edited since install
|
|
467
|
-
// (its bytes differ from the prior manifest hash) is archived before
|
|
468
|
-
// the overwrite, so a user-modified 0.3.x file that the new distro
|
|
469
|
-
// still ships — e.g. agents/orchestrator.md — is never silently
|
|
470
|
-
// destroyed. Unmodified pack content (or no prior record) overwrites
|
|
471
|
-
// normally; the pre-install backup still protects it. Files in
|
|
472
|
-
// PRESERVE_IF_EXISTS never reach this branch (kept above, never
|
|
473
|
-
// archived). Same archive root and nextFreePath as retireStale.
|
|
474
|
-
const p = priorByPath.get(norm(f.rel));
|
|
475
|
-
// state/template.md is pack-owned but graded: an existing copy that
|
|
476
|
-
// differs from the shipped bytes is ALWAYS archived before the
|
|
477
|
-
// overwrite, with or without a prior manifest entry.
|
|
478
|
-
const isTemplate = norm(f.rel) === 'state/template.md';
|
|
479
|
-
if ((p && p.hash && destHash !== p.hash) || (isTemplate && destHash !== srcHash)) {
|
|
480
|
-
const dest2 = nextFreePath(path.join(configDir, 'state', 'archive', 'legacy-0.3.x', f.rel));
|
|
481
|
-
mkdirSync(path.dirname(dest2), { recursive: true });
|
|
482
|
-
renameSync(f.dest, dest2);
|
|
483
|
-
archivedTo = path.relative(configDir, dest2);
|
|
484
|
-
action = 'overwritten';
|
|
485
|
-
prevHash = destHash;
|
|
486
|
-
log('staging', `archive ${f.rel} → ${archivedTo} (you edited the old file — pre-upgrade bytes moved aside; writing the new file)`);
|
|
487
|
-
} else {
|
|
488
|
-
// A genuine overwrite: journal it so --uninstall can put the original
|
|
489
|
-
// back from the pre-install backup instead of deleting the harness copy.
|
|
490
|
-
action = 'overwritten';
|
|
491
|
-
prevHash = destHash;
|
|
492
|
-
log('staging', `update ${f.rel} (destination differs — overwriting; backup + manifest protect you)`);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
} else {
|
|
496
|
-
log('staging', `copy ${f.rel}`);
|
|
450
|
+
const verdict = classifyDest(f, srcHash, priorByPath, norm);
|
|
451
|
+
if (verdict.action === 'skip') {
|
|
452
|
+
counts.skipped += 1;
|
|
453
|
+
log('staging', `skip ${f.rel} (already identical — rerun-safe)`);
|
|
454
|
+
manifest.files.push({ path: f.rel, hash: srcHash, action: 'skip' });
|
|
455
|
+
continue;
|
|
497
456
|
}
|
|
498
|
-
if (action === 'written'
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
457
|
+
if (verdict.action === 'written') {
|
|
458
|
+
installBytes(f.dest, readFileSync(f.src));
|
|
459
|
+
counts.added += 1;
|
|
460
|
+
log('staging', `copy ${f.rel}`);
|
|
461
|
+
manifest.files.push({ path: f.rel, hash: srcHash, action: 'written' });
|
|
462
|
+
continue;
|
|
504
463
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
464
|
+
if (verdict.action === 'kept') {
|
|
465
|
+
// The destination is the adopter's file: leave it byte-identical and put
|
|
466
|
+
// the new pack bytes beside it. `newPath` is journaled so --uninstall can
|
|
467
|
+
// sweep the `.new` and so a later run can see the adopter's adoption.
|
|
468
|
+
const newRel = `${norm(f.rel)}.new`;
|
|
469
|
+
const newPath = `${f.dest}.new`;
|
|
470
|
+
if (!(existsSync(newPath) && sha256File(newPath) === srcHash)) {
|
|
471
|
+
installBytes(newPath, readFileSync(f.src));
|
|
472
|
+
}
|
|
473
|
+
counts.kept += 1;
|
|
474
|
+
log('staging', `kept user file ${norm(f.rel)}, wrote ${newRel} (differs from what we installed — your bytes are untouched)`);
|
|
475
|
+
manifest.files.push({ path: f.rel, hash: srcHash, prevHash: verdict.prevHash, action: 'kept', newPath: newRel });
|
|
476
|
+
continue;
|
|
514
477
|
}
|
|
478
|
+
// `overwritten`: the destination still matches the prior installed hash, so
|
|
479
|
+
// it is package-owned content and replacing it IS the upgrade.
|
|
480
|
+
installBytes(f.dest, readFileSync(f.src));
|
|
481
|
+
counts.updated += 1;
|
|
482
|
+
log('staging', `update ${f.rel} (unmodified package content — updated in place; backup + manifest protect you)`);
|
|
483
|
+
manifest.files.push({ path: f.rel, hash: srcHash, prevHash: verdict.prevHash, action: 'overwritten' });
|
|
484
|
+
}
|
|
485
|
+
return counts;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// The whole install policy in one place: a destination is only replaced when it
|
|
489
|
+
// still carries the bytes we installed. Silence about a path (no prior record)
|
|
490
|
+
// proves no ownership, so the adopter keeps it.
|
|
491
|
+
// absent → written (nothing to respect)
|
|
492
|
+
// identical to the pack → skip (rerun-safe)
|
|
493
|
+
// identical to the prior install → overwritten (package-owned; this is the upgrade)
|
|
494
|
+
// anything else → kept (adopter-owned; `.new` lands beside it)
|
|
495
|
+
function classifyDest(f, srcHash, priorByPath, norm) {
|
|
496
|
+
if (!existsSync(f.dest)) return { action: 'written' };
|
|
497
|
+
const destHash = sha256File(f.dest);
|
|
498
|
+
if (destHash === srcHash) return { action: 'skip' };
|
|
499
|
+
const prior = priorByPath.get(norm(f.rel));
|
|
500
|
+
if (prior && prior.hash && destHash === prior.hash) {
|
|
501
|
+
return { action: 'overwritten', prevHash: destHash };
|
|
502
|
+
}
|
|
503
|
+
return { action: 'kept', prevHash: destHash };
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// Read-only twin of stageFiles for the pre-gate manifest: the same decision
|
|
507
|
+
// table, counted and never written.
|
|
508
|
+
function planCounts(files, prior) {
|
|
509
|
+
const norm = (p) => String(p).replace(/\\/g, '/');
|
|
510
|
+
const priorByPath = new Map(
|
|
511
|
+
(prior && Array.isArray(prior.files) ? prior.files : []).map((f) => [norm(f.path), f])
|
|
512
|
+
);
|
|
513
|
+
const counts = { added: 0, updated: 0, kept: 0, skipped: 0 };
|
|
514
|
+
for (const f of files) {
|
|
515
|
+
const v = classifyDest(f, sha256File(f.src), priorByPath, norm);
|
|
516
|
+
if (v.action === 'written') counts.added += 1;
|
|
517
|
+
else if (v.action === 'overwritten') counts.updated += 1;
|
|
518
|
+
else if (v.action === 'kept') counts.kept += 1;
|
|
519
|
+
else counts.skipped += 1;
|
|
515
520
|
}
|
|
516
|
-
return
|
|
521
|
+
return counts;
|
|
517
522
|
}
|
|
518
523
|
|
|
519
524
|
// A prior `skills/<id>/...` path belongs to skill <id>; anything else is not
|
|
@@ -582,6 +587,26 @@ function retireStale(configDir, prior, files, manifest) {
|
|
|
582
587
|
if (settled) retiredSkills.add(settled);
|
|
583
588
|
continue;
|
|
584
589
|
}
|
|
590
|
+
if (entry.action === 'kept') {
|
|
591
|
+
// The live path holds the adopter's bytes, not ours — an upgrade must not
|
|
592
|
+
// move it anywhere. Only our own `.new` beside it is retired.
|
|
593
|
+
log('retire', `keep ${rel} (your file from an earlier install — left in place)`);
|
|
594
|
+
const newRel = entry.newPath ? String(entry.newPath) : `${norm(rel)}.new`;
|
|
595
|
+
const newResolved = path.resolve(base, newRel);
|
|
596
|
+
if (newResolved.startsWith(base + path.sep) && existsSync(newResolved)) {
|
|
597
|
+
try {
|
|
598
|
+
if (entry.hash && sha256File(newResolved) === entry.hash) {
|
|
599
|
+
rmSync(newResolved, { force: true });
|
|
600
|
+
log('retire', `removed ${newRel} (our copy beside your file — this version no longer ships it)`);
|
|
601
|
+
} else {
|
|
602
|
+
log('retire', `keep ${newRel} (you edited it — left in place)`);
|
|
603
|
+
}
|
|
604
|
+
} catch {
|
|
605
|
+
log('retire', `keep ${newRel} (unreadable — refusing)`);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
585
610
|
const resolved = path.resolve(base, rel);
|
|
586
611
|
if (resolved !== base && !resolved.startsWith(base + path.sep)) {
|
|
587
612
|
log('retire', `skip ${rel} (escapes the config dir — refusing)`);
|
|
@@ -700,6 +725,33 @@ function parseJsonc(text, what) {
|
|
|
700
725
|
}
|
|
701
726
|
}
|
|
702
727
|
|
|
728
|
+
const isPlainObject = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
729
|
+
|
|
730
|
+
// Additive merge for an install-owned key: the distro value is a default the
|
|
731
|
+
// adopter may adopt, never a replacement for their own. Plain objects merge, so
|
|
732
|
+
// a subkey the adopter never set still arrives; every collided leaf keeps the
|
|
733
|
+
// adopter's value and is named in `collisions` so the report can cite it.
|
|
734
|
+
function adoptInstallOwned(distro, user, key, pathParts, collisions) {
|
|
735
|
+
const d = distro[key];
|
|
736
|
+
const u = user[key];
|
|
737
|
+
if (isPlainObject(d) && isPlainObject(u)) {
|
|
738
|
+
for (const sub of Object.keys(u)) adoptInstallOwned(d, u, sub, [...pathParts, sub], collisions);
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
if (JSON.stringify(d) !== JSON.stringify(u)) collisions.push(pathParts.join('.'));
|
|
742
|
+
distro[key] = u;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// Deny-owning blocks are additive without being softenable: the adopter's own
|
|
746
|
+
// entries ride along, every shipped entry stays, and the shipped entries land
|
|
747
|
+
// last so a user allow can never shadow a shipped deny under last-match-wins.
|
|
748
|
+
function unionDenyLast(distro, user) {
|
|
749
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
750
|
+
const d = Array.isArray(distro) ? distro : [];
|
|
751
|
+
const u = Array.isArray(user) ? user : [];
|
|
752
|
+
return [...u.filter((r) => !d.some((x) => same(x, r))), ...d];
|
|
753
|
+
}
|
|
754
|
+
|
|
703
755
|
function mergeJsonc(configDir, backupPath, manifest, retiredSkills = new Set(), prior = null) {
|
|
704
756
|
const distroPath = path.join(PKG_ROOT, 'opencode.jsonc');
|
|
705
757
|
if (!existsSync(distroPath)) {
|
|
@@ -734,8 +786,22 @@ function mergeJsonc(configDir, backupPath, manifest, retiredSkills = new Set(),
|
|
|
734
786
|
if (user.permissions !== undefined && !userPerms) {
|
|
735
787
|
console.warn('[warn] merge: your "permissions" is not an array (v2 expects an array of {action,resource,effect}) — harness denies kept; fix your rules manually.');
|
|
736
788
|
}
|
|
789
|
+
const ownedCollisions = [];
|
|
737
790
|
for (const k of Object.keys(user)) {
|
|
738
|
-
if (
|
|
791
|
+
if (DENY_OWNED.includes(k)) {
|
|
792
|
+
if (!Array.isArray(user[k])) {
|
|
793
|
+
console.warn(`[warn] merge: your "${k}" is not an array — the shipped deny entries are kept and yours cannot be merged; fix your rules manually.`);
|
|
794
|
+
} else {
|
|
795
|
+
merged[k] = unionDenyLast(merged[k], user[k]);
|
|
796
|
+
}
|
|
797
|
+
preserved.push(k);
|
|
798
|
+
continue;
|
|
799
|
+
}
|
|
800
|
+
if (INSTALL_OWNED.includes(k)) {
|
|
801
|
+
adoptInstallOwned(merged, user, k, [k], ownedCollisions);
|
|
802
|
+
preserved.push(k);
|
|
803
|
+
continue;
|
|
804
|
+
}
|
|
739
805
|
if (k === 'permissions') {
|
|
740
806
|
if (!userPerms) continue;
|
|
741
807
|
// Ordered union, deny-last. Under last-match-wins an adopter's rule must
|
|
@@ -803,6 +869,9 @@ function mergeJsonc(configDir, backupPath, manifest, retiredSkills = new Set(),
|
|
|
803
869
|
}
|
|
804
870
|
preserved.push(k);
|
|
805
871
|
}
|
|
872
|
+
if (ownedCollisions.length) {
|
|
873
|
+
log('merge', `kept your value(s) for install-owned key(s): ${ownedCollisions.join(', ')} — the shipped default is not applied to them (delete the key to adopt it)`);
|
|
874
|
+
}
|
|
806
875
|
} else {
|
|
807
876
|
log('merge', 'no existing opencode.jsonc/opencode.json — writing the harness base');
|
|
808
877
|
}
|
|
@@ -844,7 +913,7 @@ function mergeJsonc(configDir, backupPath, manifest, retiredSkills = new Set(),
|
|
|
844
913
|
manifest.files.push({ path: 'opencode.jsonc', hash: sha256Text(out), action: 'merged' });
|
|
845
914
|
log(
|
|
846
915
|
'merge',
|
|
847
|
-
`ownership —
|
|
916
|
+
`ownership — your value wins on a collision for: ${INSTALL_OWNED.join(', ')} · deny block unioned, shipped denies last: ${DENY_OWNED.join(', ')} · union: ${[...UNION_KEYS, 'references'].join(', ')} · your keys preserved: ${preserved.length}${preserved.length ? ` (${preserved.join(', ')})` : ''}`
|
|
848
917
|
);
|
|
849
918
|
log('merge', `rewrote ${targetPath} (distro base + your keys; permissions = harness allows, yours, harness denies last)`);
|
|
850
919
|
}
|
|
@@ -910,18 +979,19 @@ function runDoctor(configDir, probe) {
|
|
|
910
979
|
|
|
911
980
|
/* --------------------------- manifest print (gate) ------------------------- */
|
|
912
981
|
|
|
913
|
-
function printManifest(configDir, files, backupPath, doctor) {
|
|
982
|
+
function printManifest(configDir, files, backupPath, doctor, prior = null) {
|
|
914
983
|
const newCount = files.filter((f) => !existsSync(f.dest)).length;
|
|
915
984
|
const sameCount = files.length - newCount;
|
|
985
|
+
const plan = planCounts(files, prior);
|
|
916
986
|
console.log('----------------------------- install manifest -----------------------------');
|
|
917
987
|
console.log(` destination config dir : ${configDir}`);
|
|
918
988
|
console.log(` incoming files : ${files.length} (${newCount} new, ${sameCount} already identical — rerun-safe)`);
|
|
989
|
+
console.log(` policy : ${plan.updated} updated in place (unmodified package files) · ${plan.kept} kept + .new written (your files) · ${plan.added} added · ${plan.skipped} skipped (identical)`);
|
|
919
990
|
console.log(` backup path : ${backupPath}`);
|
|
920
991
|
console.log(' opencode.jsonc merge : distro base (permissions/deny block, policies block, skill allowlist,');
|
|
921
992
|
console.log(' default_agent: "orchestrator", references registry)');
|
|
922
|
-
console.log(' + your keys kept · permissions: harness allows, yours, harness denies last');
|
|
923
|
-
console.log(' state-seed/ -> state/ : shipped seed maps to live state/ (state
|
|
924
|
-
console.log(' state/template.md is pack-owned, and an edited copy is archived under state/archive/ then replaced)');
|
|
993
|
+
console.log(' + your keys kept, your value wins on a collision · permissions: harness allows, yours, harness denies last');
|
|
994
|
+
console.log(' state-seed/ -> state/ : shipped seed maps to live state/ (an edited state file is kept, the seeded copy lands as <name>.new)');
|
|
925
995
|
console.log(` doctor plan : harness-doctor, 18 laws — ${doctor}`);
|
|
926
996
|
console.log('----------------------------------------------------------------------------');
|
|
927
997
|
}
|
|
@@ -1030,6 +1100,32 @@ function uninstall(configDir, opts = {}) {
|
|
|
1030
1100
|
}
|
|
1031
1101
|
continue;
|
|
1032
1102
|
}
|
|
1103
|
+
if (entry.action === 'kept') {
|
|
1104
|
+
// The live path is the adopter's file — uninstall never removes it. The
|
|
1105
|
+
// `.new` beside it is our bytes, so that one goes when it is unmodified.
|
|
1106
|
+
kept += 1;
|
|
1107
|
+
const newRel = entry.newPath ? String(entry.newPath) : null;
|
|
1108
|
+
const newResolved = newRel ? path.resolve(base, newRel) : null;
|
|
1109
|
+
const insideBase = newResolved && newResolved.startsWith(base + path.sep);
|
|
1110
|
+
if (!insideBase || !existsSync(newResolved)) {
|
|
1111
|
+
log('uninstall', `kept ${rel} (your file — never removed)`);
|
|
1112
|
+
continue;
|
|
1113
|
+
}
|
|
1114
|
+
if (entry.hash && sha256File(newResolved) === entry.hash) {
|
|
1115
|
+
if (preview) {
|
|
1116
|
+
removed += 1;
|
|
1117
|
+
log('uninstall', `would remove ${newRel} (our copy beside your kept file)`);
|
|
1118
|
+
} else {
|
|
1119
|
+
rmSync(newResolved, { force: true });
|
|
1120
|
+
removed += 1;
|
|
1121
|
+
log('uninstall', `removed ${newRel} (our copy beside your kept file)`);
|
|
1122
|
+
}
|
|
1123
|
+
} else {
|
|
1124
|
+
kept += 1;
|
|
1125
|
+
log('uninstall', `kept ${newRel} (you edited the new version — keeping it)`);
|
|
1126
|
+
}
|
|
1127
|
+
continue;
|
|
1128
|
+
}
|
|
1033
1129
|
if (!existsSync(resolved)) {
|
|
1034
1130
|
missing += 1;
|
|
1035
1131
|
continue;
|
|
@@ -1142,17 +1238,26 @@ function carryForwardJournal(manifest, prior) {
|
|
|
1142
1238
|
if (p.action === 'overwritten') {
|
|
1143
1239
|
e.action = 'overwritten';
|
|
1144
1240
|
e.prevHash = p.prevHash || e.prevHash;
|
|
1145
|
-
} else if (p.action === '
|
|
1241
|
+
} else if (p.action === 'kept' && e.action !== 'overwritten') {
|
|
1242
|
+
// The adopter's file was never ours; an identical destination (they may
|
|
1243
|
+
// have adopted the old `.new`) must not be downgraded to `skip`, or
|
|
1244
|
+
// --uninstall would delete a file the harness never wrote.
|
|
1245
|
+
e.action = 'kept';
|
|
1246
|
+
e.prevHash = p.prevHash || e.prevHash;
|
|
1247
|
+
e.newPath = p.newPath || e.newPath;
|
|
1248
|
+
} else if (p.action === 'preserved' && e.action !== 'overwritten' && e.action !== 'kept') {
|
|
1146
1249
|
e.action = 'preserved';
|
|
1147
1250
|
}
|
|
1148
1251
|
}
|
|
1149
1252
|
// A re-run must not forget what an earlier run settled: those paths are
|
|
1150
1253
|
// already deleted or archived and absent from this run's staging, but
|
|
1151
1254
|
// --uninstall still needs them to restore the pre-install originals from
|
|
1152
|
-
// the backup chain.
|
|
1255
|
+
// the backup chain. A kept adopter path the pack no longer ships is carried
|
|
1256
|
+
// for the same reason: its `.new` may still be beside it.
|
|
1153
1257
|
const now = new Set(manifest.files.map((f) => norm(f.path)));
|
|
1154
1258
|
for (const p of prior.files) {
|
|
1155
|
-
|
|
1259
|
+
const settled = p.action === 'retired' || p.action === 'archived' || p.action === 'kept';
|
|
1260
|
+
if (settled && !now.has(norm(p.path))) {
|
|
1156
1261
|
manifest.files.push(p);
|
|
1157
1262
|
now.add(norm(p.path));
|
|
1158
1263
|
}
|
|
@@ -1265,7 +1370,7 @@ async function setup(opts) {
|
|
|
1265
1370
|
const prior = readManifest(configDir); // read-only
|
|
1266
1371
|
const newBackupPath = nextBackupPath(configDir);
|
|
1267
1372
|
const backupPath = prior && prior.backupPath ? prior.backupPath : newBackupPath;
|
|
1268
|
-
printManifest(configDir, files, backupPath, doctorPlan());
|
|
1373
|
+
printManifest(configDir, files, backupPath, doctorPlan(), prior);
|
|
1269
1374
|
if (opts.dryRun) {
|
|
1270
1375
|
console.log('[dry-run] manifest only — nothing was touched.');
|
|
1271
1376
|
return 0;
|
|
@@ -1299,7 +1404,7 @@ async function setup(opts) {
|
|
|
1299
1404
|
// a lie. Keep the original pointer; chain the new snapshot as priorBackup.
|
|
1300
1405
|
const backupPath = prior && prior.backupPath ? prior.backupPath : newBackupPath;
|
|
1301
1406
|
const doctorProbe = pwshProbe(); // read-only probe
|
|
1302
|
-
printManifest(configDir, files, backupPath, doctorPlan());
|
|
1407
|
+
printManifest(configDir, files, backupPath, doctorPlan(), prior);
|
|
1303
1408
|
|
|
1304
1409
|
// (F2: --dry-run / --ci already returned print-only before preflight.)
|
|
1305
1410
|
if (!(await confirmProceed())) {
|
|
@@ -1329,7 +1434,7 @@ async function setup(opts) {
|
|
|
1329
1434
|
|
|
1330
1435
|
const retiredSkills = retireStale(configDir, prior, files, manifest);
|
|
1331
1436
|
if (retiredSkills.size) log('retire', `${retiredSkills.size} stale skill id(s) retired — their allowlist entries are pruned from the merge (${[...retiredSkills].join(', ')})`);
|
|
1332
|
-
stageFiles(files, manifest, prior
|
|
1437
|
+
const staged = stageFiles(files, manifest, prior);
|
|
1333
1438
|
carryForwardJournal(manifest, prior);
|
|
1334
1439
|
// An adopter's own plugins[] entries survive the merge via UNION_KEYS; the
|
|
1335
1440
|
// distro ships no plugins of its own, so there is nothing to register here.
|
|
@@ -1346,6 +1451,10 @@ async function setup(opts) {
|
|
|
1346
1451
|
console.log();
|
|
1347
1452
|
console.log('-------------------------------- summary ---------------------------------');
|
|
1348
1453
|
console.log(' installed: agents/, commands/, skills/, reference/, scripts/, .docs/, state/ (from state-seed/), AGENTS.md, GLOSSARY.md + merged opencode.jsonc');
|
|
1454
|
+
console.log(` policy : ${staged.updated} updated in place (unmodified package files) · ${staged.kept} kept + .new written (your files) · ${staged.added} added · ${staged.skipped} skipped (identical)`);
|
|
1455
|
+
if (staged.kept > 0) {
|
|
1456
|
+
console.log(' adopt : the new version of each kept file sits beside it as <name>.new — diff it and move it over when you want it');
|
|
1457
|
+
}
|
|
1349
1458
|
console.log(` backup : ${manifest.backupPath}${manifest.priorBackup ? `\n snapshot : ${manifest.priorBackup} (chained — backup() pointer above is the original)` : ''}`);
|
|
1350
1459
|
if (manifest.doctorSkipped) {
|
|
1351
1460
|
console.log(' doctor : ⚠ SKIPPED — the 18 laws were NOT verified (journaled as doctorSkipped; install PowerShell 7 and re-run to verify)');
|
package/docs/GUIDE.md
CHANGED
|
@@ -11,17 +11,17 @@ First run prints a manifest of everything it will touch and waits for you to typ
|
|
|
11
11
|
|
|
12
12
|
## Why this starter
|
|
13
13
|
|
|
14
|
-
- Small on purpose:
|
|
15
|
-
- A loop that closes:
|
|
16
|
-
- Research that cites:
|
|
17
|
-
- Memory that survives:
|
|
18
|
-
- Cleanup that ships:
|
|
14
|
+
- Small on purpose: 10 seats, 6 skills, 12 on-demand references; the primary loads one, the rest wait for a trigger.
|
|
15
|
+
- A loop that closes: brief -> seat -> skill -> evidence -> verify -> memory; no self-verdicts.
|
|
16
|
+
- Research that cites: research-agent + search + canon; claims arrive sourced or `UNVERIFIED`.
|
|
17
|
+
- Memory that survives: memory-agent writes dated lessons to `state/lessons.md` (superseded ones move to `state/archive/`); your `state/` is seeded and preserved on upgrade.
|
|
18
|
+
- Cleanup that ships: leave-no-trail hygiene removes this session's scratch and proves the tree clean at close.
|
|
19
19
|
- Grows with you: `evolve` turns a repeated workflow, a user request, or an upstream feature into a skill, command, reference, seat, or config change — 1:1 and doctor-checked.
|
|
20
20
|
- Reversible and fail-closed: manifest first, SHA-256 journal, uninstall restores originals, hard denies last.
|
|
21
21
|
|
|
22
22
|
## What you get
|
|
23
23
|
|
|
24
|
-
-
|
|
24
|
+
- 10 seats with named seams: one routing table in `reference/flow.md` gives each seat its trigger, owned paths, and check; the verdict never comes from the author.
|
|
25
25
|
- 6 skills behind 6 commands: close, evolve, fast, loop, search, and swarm.
|
|
26
26
|
- 12 on-demand references behind a single index; load only the file a rule names.
|
|
27
27
|
- 18-law doctor gate: every setup run ends on it, and failures name the check and the fix.
|
|
@@ -45,8 +45,8 @@ Set `OPENCODE_CONFIG_DIR` to override the config dir when the OpenCode CLI canno
|
|
|
45
45
|
|
|
46
46
|
- Your `opencode.jsonc` settings, providers, MCP servers, plugins, and state survive.
|
|
47
47
|
- `default_agent` stays `orchestrator`, so an existing 0.3.x config keeps resolving.
|
|
48
|
-
-
|
|
49
|
-
-
|
|
48
|
+
- The installer is additive: an unmodified package file updates in place, while a file you edited or own is kept byte-identical and the new version lands beside it as `<name>.new`.
|
|
49
|
+
- Stale pack paths the new distro no longer ships are retired only when still byte-identical to the prior install (journaled, restorable on uninstall); anything you modified moves to `state/archive/legacy-0.3.x/` instead of being deleted, and is reported.
|
|
50
50
|
- Stale `skill` allow entries for retired skills are pruned; custom skills are left alone.
|
|
51
51
|
- The custom `/goal` looper ships as `/loop` (`commands/loop.md` + `skills/loop/SKILL.md`); a fresh install writes neither `commands/goal.md` nor `skills/goal`, and both `/loop` bodies name the host's native `/goal` session-continuation command (OpenCode 2.2.1) so the distinction is explicit.
|
|
52
52
|
- An upgrade settles a tracked `/goal` path only when a prior manifest entry lists it with a recorded hash, per file: matching bytes are retired, differing bytes are archived under `state/archive/legacy-0.3.x/`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-harness-setup",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"oc-harness-setup": "bin/cli.js"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"url": "git+https://github.com/nathwn12/oc-collections.git",
|
|
43
43
|
"directory": "packages/oc-harness-setup"
|
|
44
44
|
},
|
|
45
|
-
"description": "A general OpenCode starter for Windows:
|
|
45
|
+
"description": "A general OpenCode starter for Windows: 10 seats on a dispatch loop, 6 skills, fresh-verdict research, lesson memory, leave-no-trail hygiene, and self-extension tooling - installed by one explicit command.",
|
|
46
46
|
"keywords": [
|
|
47
47
|
"opencode",
|
|
48
48
|
"agents",
|
package/reference/README.md
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
- `canon.md` — locked research source canon and citation bar.
|
|
6
6
|
- `context.md` — context budget, delegation detail, mechanisms, worked examples.
|
|
7
|
-
- `enforcement.md` — network reach
|
|
8
|
-
- `flow.md` —
|
|
7
|
+
- `enforcement.md` — hard denies, network reach, enforcement examples.
|
|
8
|
+
- `flow.md` — the one seat routing table, the seat law, `OUT:` definitions, lane overlap.
|
|
9
9
|
- `gates.md` — the five repo-local gates the harness requires.
|
|
10
10
|
- `harness.md` — who writes what, what ships, how it versions.
|
|
11
|
-
- `hygiene.md` — scratch discipline and
|
|
12
|
-
- `memory.md` —
|
|
13
|
-
- `models.md` — bulk-vs-verdict tiering, binding, and catalog for the doctor check.
|
|
14
|
-
- `phases.md` — context
|
|
11
|
+
- `hygiene.md` — scratch discipline, the close trash sweep, checkout and freshness proof.
|
|
12
|
+
- `memory.md` — graph-first codebase memory, ADRs, lessons; session state is retired.
|
|
13
|
+
- `models.md` — bulk-vs-verdict tiering, binding, and the catalog for the doctor check.
|
|
14
|
+
- `phases.md` — the context move to make at a phase boundary.
|
|
15
15
|
- `repos.md` — repo lifecycle, location, commits, delivery, CI policy.
|
|
16
16
|
- `tools.md` — host-tool registry; native only when listed here.
|
package/reference/context.md
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
1
|
# Context detail
|
|
2
|
-
|
|
2
|
+
Read when the working set, delegation detail, mechanisms, or worked examples matter.
|
|
3
3
|
|
|
4
4
|
<example>Good: slice names one file plus its check. Good: verify cites command plus output. Bad: two artifacts in one slice.</example>
|
|
5
5
|
|
|
6
6
|
## Context budget
|
|
7
7
|
- Root ceiling is 200 lines, target 120. Quality outranks brevity: a decision belongs in the root, detail lives behind a pointer. Cut filler, never a rule.
|
|
8
|
-
- Skills stay <500 lines; detail sits behind pointers.
|
|
9
|
-
- State is markdown; load index first, detail on demand.
|
|
8
|
+
- Skills stay <500 lines; detail sits behind pointers. Every reference targets 50 lines and hits 80 at worst.
|
|
9
|
+
- State is markdown; load the index first, detail on demand.
|
|
10
10
|
- Engineer the working set down; never fill the window.
|
|
11
|
-
<example>Good: new rule goes behind a pointer. Good: phase ends so context resets. Bad: pasting forty files into the trace.</example>
|
|
11
|
+
<example>Good: a new rule goes behind a pointer. Good: a phase ends so context resets. Bad: pasting forty files into the trace.</example>
|
|
12
12
|
|
|
13
|
-
<example>Good: new network reach earns
|
|
13
|
+
<example>Good: new network reach earns a seat. Good: a new doc type reuses `code-agent`. Bad: adding a seat for a craft.</example>
|
|
14
14
|
|
|
15
|
+
## Lanes
|
|
15
16
|
- One write lane per artifact; parallel reads freely.
|
|
16
|
-
-
|
|
17
|
-
- Two
|
|
18
|
-
- Parallel writes only across disjoint
|
|
19
|
-
- Every brief carries objective, output format, tool/source guidance, task boundaries.
|
|
17
|
+
- Twenty-four live lanes is the ceiling; past twenty-four, the rest queue. The seam decides whether a split is valid; the ceiling decides how many run.
|
|
18
|
+
- Two seats on one file is a collision, not a review. One writer per artifact, always; a second reader is free.
|
|
19
|
+
- Parallel writes run only across disjoint path sets, behind an integration point with a fresh `verify-agent`.
|
|
20
|
+
- Every brief carries objective, output format, tool/source guidance, task boundaries, a time budget, and the check that proves the end state.
|
|
20
21
|
- Return a summary plus `file:line`; raw reads stay in the child.
|
|
21
|
-
- Cost: multi-agent
|
|
22
|
-
<example>Good: forty-file sweep returns a summary. Good: two disjoint packages merge behind one
|
|
22
|
+
- Cost: a multi-agent run spends a multiple of a single chat — spend it on isolation and review, never on parallel writes to one file.
|
|
23
|
+
<example>Good: a forty-file sweep returns a summary. Good: two disjoint packages merge behind one `verify-agent`. Bad: two lanes editing one file.</example>
|
|
23
24
|
|
|
24
25
|
## Mechanisms
|
|
25
|
-
- Need automation? Prefer, in this order:
|
|
26
|
-
- A loose script is the last resort: allowed only when none of those
|
|
27
|
-
- Adding a mechanism is a harness change, not a task step:
|
|
28
|
-
- Whatever no mechanism can reach is an instruction,
|
|
29
|
-
- Installing tooling is ingress
|
|
30
|
-
-
|
|
31
|
-
- Exception: a one-shot ceremony script under the temp session dir is a deliverable, not plumbing; a 2FA click needs a visible terminal, so the script is allowed and is deleted after the run.
|
|
32
|
-
- A script the owner asks for is a deliverable, not infrastructure: it is the product, it is never wired into the harness, and it carries a header saying what it is for.
|
|
33
|
-
<example>Good: a missing capability becomes a plugin ref in config. Good: an existing CLI does the job and gets used. Bad: a one-off script that nothing proves and nobody owns.</example>
|
|
26
|
+
- Need automation? Prefer, in this order: a tool already installed on the machine → a package you add through the package manager → a small extension to OpenCode → a script you write and prove.
|
|
27
|
+
- A loose script is the last resort: allowed only when none of those fit, and it states in its header why they failed.
|
|
28
|
+
- Adding a mechanism is a harness change, not a task step: its own brief, its own proof, never a side effect of finishing something else.
|
|
29
|
+
- Whatever no mechanism can reach is an instruction, labelled as one — never dressed up as enforcement.
|
|
30
|
+
- Installing tooling is ingress: it pulls code in and sends nothing out, so the outward gate is unchanged. Name the package and the reason in the brief.
|
|
31
|
+
- Exception: a one-shot ceremony script under the temp session dir is a deliverable, not plumbing; it is deleted after the run, and it carries a header saying what it is for.
|
|
34
32
|
|
|
35
|
-
<example>Good: `pytest -q` cited passing. Good: fresh
|
|
33
|
+
<example>Good: `pytest -q` cited passing. Good: a fresh `verify-agent` returns pass plus evidence. Bad: claiming green with no run.</example>
|
package/reference/enforcement.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# Enforcement detail
|
|
2
|
-
|
|
2
|
+
Read when a hard deny, network reach, or an enforced-versus-instructed boundary matters.
|
|
3
3
|
|
|
4
|
-
-
|
|
4
|
+
- `policies` `tool.use` denies are hard: `*.env`, `*.env.*`, `*secrets*`, on read and on edit. They override ask and allow, and they are the only boundary in this pack a mechanism holds.
|
|
5
|
+
- One seat holds open-web reach: `research-agent`. A shell fetch by any other seat is denied; the single sanctioned exception is a brief that names the endpoint and the reason, run by `host-agent`.
|
|
6
|
+
- Outward verbs — push, publish, release, PR, merge, approve — are owner-gated. This pack grants none, so `git-agent` and `release-agent` prepare and prove, and the owner takes the final act.
|
|
7
|
+
- Code Mode (`execute`) carries its own `fetch`, so it is the one route that stays narrow: a seat holds it only when its agent file grants it.
|
|
8
|
+
- The rest is instructed, not enforced: brief-scoped path confinement, unprinted secret values, lane counts, and the no-redirection write rule. Drift there is caught by a check or a review, never by a claim.
|
|
5
9
|
|
|
6
|
-
<example>Good: `read:*.env` denied with Blocked by configuration policy. Good:
|
|
10
|
+
<example>Good: `read:*.env` denied with Blocked by configuration policy. Good: `code-agent` denied `git push`. Bad: claiming a network boundary when shell is open.</example>
|