fix(install): close reviewed reliability gaps

This commit is contained in:
haelyra
2026-08-13 18:03:37 -04:00
parent 01335551a3
commit 9e39385666
5 changed files with 49 additions and 30 deletions
+10 -5
View File
@@ -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 {
module.exports = { main, readFlag };
if (require.main === module) {
try {
main();
} catch (error) {
} catch (error) {
process.stderr.write(`[ecc-sync] ERROR: ${error.message}\n`);
process.exit(1);
}
}
module.exports = { main, readFlag };
+7 -9
View File
@@ -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 {
@@ -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,
+13 -7
View File
@@ -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}`;
+11 -4
View File
@@ -402,13 +402,20 @@ function applyInstallPlan(plan, dependencies = {}) {
beforeInstallStateWrite({ plan: appliedPlan, state: finalState });
}
persistInstallState(plan.installStatePath, finalState);
let antigravityMigrationWarnings = [];
try {
const antigravityMigration = cleanupLegacyAntigravityInstall(appliedPlan);
const antigravityMigrationWarnings = antigravityMigration.detected && !antigravityMigration.complete
? [
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,