The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
test(opencode): cover legacy migration boundaries
haelyrae3f2a537f986
diff --git a/docs/testing/ecc-2.2-release-readiness.tdd.md b/docs/testing/ecc-2.2-release-readiness.tdd.mdindex 37ea8e1df..cd1230ca6 100644--- a/docs/testing/ecc-2.2-release-readiness.tdd.md+++ b/docs/testing/ecc-2.2-release-readiness.tdd.md@@ -43,6 +43,7 @@ All three changed core modules exceeded the 80 percent line target:| `scripts/lib/multi-harness-setup.js` | 88.75% | 82.75% | 74.01% || `scripts/lib/install/claude-skill-migration.js` | 95.20% | 100% | 88.78% || `scripts/lib/install-targets/opencode-home.js` | 86.66% | 100% | 78.94% |+| `scripts/lib/install/opencode-legacy-migration.js` | 82.24% | 100% | 68.29% |Coverage commands used `c8 --check-coverage --lines 80` against the corresponding focused test files.diff --git a/tests/lib/opencode-legacy-migration.test.js b/tests/lib/opencode-legacy-migration.test.jsindex e55745306..071e0f24e 100644--- a/tests/lib/opencode-legacy-migration.test.js+++ b/tests/lib/opencode-legacy-migration.test.js@@ -15,6 +15,11 @@ const {uninstallInstalledStates,} = require('../../scripts/lib/install-lifecycle');const { createInstallState, writeInstallState } = require('../../scripts/lib/install-state');+const {+ cleanupLegacyOpencodeInstall,+ getLegacyOpencodeLocation,+ inspectLegacyOpencodeState,+} = require('../../scripts/lib/install/opencode-legacy-migration');const REPO_ROOT = path.join(__dirname, '..', '..');const SOURCE_RELATIVE_PATH = path.join('skills', 'skill-comply', 'SKILL.md');@@ -94,6 +99,35 @@ function canonicalPlan(homeDir) {console.log('\n=== Testing OpenCode legacy migration ===\n');+test('legacy inspection distinguishes absent, invalid, and unreadable state', () => {+ const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'opencode-legacy-inspect-'));+ try {+ const location = getLegacyOpencodeLocation(homeDir);+ assert.strictEqual(inspectLegacyOpencodeState(null).status, 'absent');+ assert.strictEqual(inspectLegacyOpencodeState(location).status, 'absent');++ fs.mkdirSync(location.targetRoot, { recursive: true });+ fs.mkdirSync(location.installStatePath);+ assert.strictEqual(inspectLegacyOpencodeState(location).status, 'invalid');+ fs.rmSync(location.installStatePath, { recursive: true, force: true });++ fs.writeFileSync(location.installStatePath, '{not-json', 'utf8');+ const unreadable = inspectLegacyOpencodeState(location);+ assert.strictEqual(unreadable.status, 'unreadable');+ assert.ok(unreadable.error.includes(location.installStatePath));++ assert.deepStrictEqual(cleanupLegacyOpencodeInstall(null), {+ detected: false,+ complete: false,+ removedPaths: [],+ retainedPaths: [],+ warnings: [],+ });+ } finally {+ fs.rmSync(homeDir, { recursive: true, force: true });+ }+});+test('discovery and doctor surface the legacy managed root', () => {const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'opencode-legacy-discover-'));try {