Files
ECC/tests/scripts/antigravity-native-plugin.test.js
T
MohamedAfrash 5370535840 chore: integrate upstream and capture Antigravity policy regressions
Merge upstream main b92f181b, retaining updated ownership and script-boundary protections. Capture RED hook-policy and MCP-policy reproductions before fixes. Repair sibling Antigravity workflows: RED unsafe-root failure, GREEN focused regression and 73 lifecycle checks. Native plugin regression captures missing shared-script-utils target support.
2026-10-13 14:49:37 +01:00

63 lines
2.8 KiB
JavaScript

'use strict';
const assert = require('assert');
const fs = require('fs');
const os = require('os');
const path = require('path');
const { spawnSync } = require('child_process');
const { createManifestInstallPlan } = require('../../scripts/lib/install/plan');
const { applyInstallPlan } = require('../../scripts/lib/install/apply');
const { withHookConsent } = require('../../scripts/lib/install/hook-consent');
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-agy-native-'));
// Only pass filesystem locations owned by this test; never inherit authentication.
const env = {
PATH: process.env.PATH,
HOME: root,
USERPROFILE: root,
XDG_CONFIG_HOME: path.join(root, '.config'),
XDG_DATA_HOME: path.join(root, '.local', 'share'),
XDG_CACHE_HOME: path.join(root, '.cache'),
...(process.platform === 'win32' ? { SystemRoot: process.env.SystemRoot, APPDATA: root, LOCALAPPDATA: root } : {}),
};
function agy(args) {
return spawnSync('agy', args, { env, cwd: root, encoding: 'utf8', timeout: 15000 });
}
function checked(args) {
const result = agy(args);
assert.strictEqual(result.status, 0, result.error?.message || result.stderr || result.stdout);
return result.stdout;
}
try {
const version = agy(['--version']);
if (version.error?.code === 'ENOENT' || (version.status === 0 && version.stdout.trim() !== '1.2.9')) {
console.log(`SKIP: native plugin validation requires installed agy 1.2.9 (found ${version.stdout?.trim() || 'none'}); no download attempted.`);
} else {
assert.strictEqual(version.status, 0, version.error?.message || version.stderr);
const plan = withHookConsent(createManifestInstallPlan({
sourceRoot: path.resolve(__dirname, '../..'),
profileId: 'core',
target: 'antigravity-home',
projectRoot: path.join(root, 'workspace'),
homeDir: root,
}), 'enabled');
applyInstallPlan(plan);
assert.ok(fs.existsSync(path.join(plan.targetRoot, 'plugin.json')));
const validation = checked(['plugin', 'validate', plan.targetRoot]);
assert.match(validation, /\[ok\]/);
checked(['plugin', 'install', plan.targetRoot]);
const listed = JSON.parse(checked(['plugin', 'list', '--json']));
const plugin = listed.imports.find(entry => entry.name === 'ecc');
assert.ok(plugin, 'Native CLI must discover ECC after explicit local import');
assert.ok(plugin.components.includes('hooks'), 'Native importer must register lifecycle hooks');
assert.ok(plugin.components.includes('mcpServers'), 'Native importer must register ECC memory');
console.log('PASS: agy 1.2.9 validates and imports the generated ECC plugin in a disposable HOME.');
console.log('NOT CHECKED: authenticated tool execution, Stop execution, and automatic IDE discovery.');
}
} finally {
fs.rmSync(root, { recursive: true, force: true });
}