mirror of
https://github.com/affaan-m/ECC.git
synced 2026-08-17 21:15:40 +02:00
fix(install): close reviewed reliability gaps
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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}`;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user