The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
fix(install): close reviewed reliability gaps
haelyra9e393856668d
diff --git a/scripts/codex/legacy-sync-state.js b/scripts/codex/legacy-sync-state.jsindex b6ce0c57b..2089cfac4 100644--- a/scripts/codex/legacy-sync-state.js+++ b/scripts/codex/legacy-sync-state.js@@ -10,7 +10,10 @@ const {function readFlag(args, name) {const index = args.indexOf(name);- return index === -1 ? null : args[index + 1] || null;+ if (index === -1) return null;+ const value = args[index + 1];+ if (!value || value.startsWith('--')) return null;+ return value;}function main(argv = process.argv.slice(2)) {@@ -51,11 +54,13 @@ function main(argv = process.argv.slice(2)) {throw new Error('Usage: legacy-sync-state.js <begin|record|finalize|rollback> [options]');}-try {- main();-} catch (error) {- process.stderr.write(`[ecc-sync] ERROR: ${error.message}\n`);- process.exit(1);-}-module.exports = { main, readFlag };++if (require.main === module) {+ try {+ main();+ } catch (error) {+ process.stderr.write(`[ecc-sync] ERROR: ${error.message}\n`);+ process.exit(1);+ }+}diff --git a/scripts/lib/install-state-store-sync.js b/scripts/lib/install-state-store-sync.jsindex 3f3333486..aa8fb6325 100644--- a/scripts/lib/install-state-store-sync.js+++ b/scripts/lib/install-state-store-sync.js@@ -7,17 +7,15 @@ const {} = require('./state-store');function openFailure(error) {+ const warning = {+ code: 'projection-open-failed',+ message: error.message,+ };return {status: 'warning',warningCount: 1,- warnings: [{- code: 'projection-open-failed',- message: error.message,- }],- warning: {- code: 'projection-open-failed',- message: error.message,- },+ warnings: [warning],+ warning,};}@@ -29,7 +27,7 @@ async function withStateStore(options, operation) {dbPath: options.dbPath,homeDir: options.homeDir,});- return operation(store);+ return await operation(store);} catch (error) {return openFailure(error);} finally {diff --git a/scripts/lib/install-targets/antigravity-project.js b/scripts/lib/install-targets/antigravity-project.jsindex 34a500eab..7861bbc25 100644--- a/scripts/lib/install-targets/antigravity-project.js+++ b/scripts/lib/install-targets/antigravity-project.js@@ -50,7 +50,10 @@ module.exports = createInstallTargetAdapter({.flatMap(sourceRelativePath => {const normalizedSourcePath = normalizeRelativePath(sourceRelativePath);- if (normalizedSourcePath === 'rules') {+ if (+ normalizedSourcePath === 'rules'+ || normalizedSourcePath.startsWith('rules/')+ ) {return createFlatRuleOperations({moduleId: module.id,repoRoot,diff --git a/scripts/lib/install/antigravity-agent.js b/scripts/lib/install/antigravity-agent.jsindex ce9138a7a..e5e4a1883 100644--- a/scripts/lib/install/antigravity-agent.js+++ b/scripts/lib/install/antigravity-agent.js@@ -1,5 +1,7 @@'use strict';+const yaml = require('js-yaml');+const TOOL_NAMES = Object.freeze({Read: 'view_file',Write: 'write_to_file',@@ -23,7 +25,7 @@ function splitFrontmatter(source, label) {throw new Error(`Cannot adapt Antigravity agent ${label}: missing YAML frontmatter`);}- const frontmatter = require('js-yaml').load(match[1]);+ const frontmatter = yaml.load(match[1]);if (!frontmatter || typeof frontmatter !== 'object' || Array.isArray(frontmatter)) {throw new Error(`Cannot adapt Antigravity agent ${label}: frontmatter must be an object`);}@@ -45,12 +47,16 @@ function normalizeToolNames(value) {function adaptAntigravityAgent(source, label = '<unknown>') {const { frontmatter, body } = splitFrontmatter(source, label);const { color: _claudeColor, ...supportedFrontmatter } = frontmatter;- const adapted = {- ...supportedFrontmatter,- tools: normalizeToolNames(frontmatter.tools),- model: MODEL_NAMES[frontmatter.model] || frontmatter.model,- };- const serialized = require('js-yaml')+ const adapted = { ...supportedFrontmatter };+ if (Object.hasOwn(frontmatter, 'tools')) {+ adapted.tools = normalizeToolNames(frontmatter.tools);+ }+ if (Object.hasOwn(frontmatter, 'model')) {+ adapted.model = Object.hasOwn(MODEL_NAMES, frontmatter.model)+ ? MODEL_NAMES[frontmatter.model]+ : frontmatter.model;+ }+ const serialized = yaml.dump(adapted, { lineWidth: -1, noRefs: true }).trimEnd();return `---\n${serialized}\n---\n${body}`;diff --git a/scripts/lib/install/apply.js b/scripts/lib/install/apply.jsindex d1180b436..24627e6ed 100644--- a/scripts/lib/install/apply.js+++ b/scripts/lib/install/apply.js@@ -402,13 +402,20 @@ function applyInstallPlan(plan, dependencies = {}) {beforeInstallStateWrite({ plan: appliedPlan, state: finalState });}persistInstallState(plan.installStatePath, finalState);- const antigravityMigration = cleanupLegacyAntigravityInstall(appliedPlan);- const antigravityMigrationWarnings = antigravityMigration.detected && !antigravityMigration.complete- ? [+ let antigravityMigrationWarnings = [];+ try {+ const antigravityMigration = cleanupLegacyAntigravityInstall(appliedPlan);+ if (antigravityMigration.detected && !antigravityMigration.complete) {+ antigravityMigrationWarnings = ['Legacy Antigravity migration is incomplete. ECC preserved modified, unverifiable, or unmanaged content under .agent; review and move anything you want to keep, then rerun the Antigravity install.',...(Array.isArray(antigravityMigration.warnings) ? antigravityMigration.warnings : []),- ]- : [];+ ];+ }+ } catch (error) {+ antigravityMigrationWarnings = [+ `Legacy Antigravity cleanup did not finish: ${error.message}. Content under .agent was preserved; remove it manually or rerun the Antigravity install.`,+ ];+ }return {...plan,