fix: harden install planning and sync tracked catalogs

This commit is contained in:
Affaan Mustafa
2026-03-31 22:57:48 -07:00
parent 03c4a90ffa
commit e1bc08fa6e
19 changed files with 970 additions and 118 deletions

View File

@@ -4,14 +4,28 @@ const {
createFlatRuleOperations,
createInstallTargetAdapter,
createManagedScaffoldOperation,
normalizeRelativePath,
} = require('./helpers');
const SUPPORTED_SOURCE_PREFIXES = ['rules', 'commands', 'agents', 'skills', '.agents', 'AGENTS.md'];
function supportsAntigravitySourcePath(sourceRelativePath) {
const normalizedPath = normalizeRelativePath(sourceRelativePath);
return SUPPORTED_SOURCE_PREFIXES.some(prefix => (
normalizedPath === prefix || normalizedPath.startsWith(`${prefix}/`)
));
}
module.exports = createInstallTargetAdapter({
id: 'antigravity-project',
target: 'antigravity',
kind: 'project',
rootSegments: ['.agent'],
installStatePathSegments: ['ecc-install-state.json'],
supportsModule(module) {
const paths = Array.isArray(module && module.paths) ? module.paths : [];
return paths.length > 0;
},
planOperations(input, adapter) {
const modules = Array.isArray(input.modules)
? input.modules
@@ -30,7 +44,9 @@ module.exports = createInstallTargetAdapter({
return modules.flatMap(module => {
const paths = Array.isArray(module.paths) ? module.paths : [];
return paths.flatMap(sourceRelativePath => {
return paths
.filter(supportsAntigravitySourcePath)
.flatMap(sourceRelativePath => {
if (sourceRelativePath === 'rules') {
return createFlatRuleOperations({
moduleId: module.id,
@@ -62,8 +78,8 @@ module.exports = createInstallTargetAdapter({
];
}
return [adapter.createScaffoldOperation(module.id, sourceRelativePath, planningInput)];
});
return [adapter.createScaffoldOperation(module.id, sourceRelativePath, planningInput)];
});
});
},
});

View File

@@ -276,6 +276,13 @@ function createInstallTargetAdapter(config) {
input
));
},
supportsModule(module, input = {}) {
if (typeof config.supportsModule === 'function') {
return config.supportsModule(module, input, adapter);
}
return true;
},
validate(input = {}) {
if (typeof config.validate === 'function') {
return config.validate(input, adapter);