agy-squad 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/full-review/SKILL.md +89 -0
- package/.agents/skills/full-review/references/evidence-intake.md +146 -0
- package/.agents/skills/full-review/references/report-template.md +216 -0
- package/.agents/skills/full-review/references/review-roles.md +91 -0
- package/.agents/skills/pr-review/SKILL.md +60 -0
- package/.agents/skills/pr-review/references/pr-review-standard.md +163 -0
- package/.agents/skills/self-diagnosis/SKILL.md +63 -0
- package/.agents/skills/self-diagnosis/references/execution-and-teardown.md +71 -0
- package/.agents/skills/self-diagnosis/references/optimization-and-review-rubric.md +61 -0
- package/.agents/skills/self-diagnosis/resources/comparative-research-manifest.json +42 -0
- package/.agents/skills/self-diagnosis/resources/self-diagnosis-manifest.json +144 -0
- package/.agents/skills/self-diagnosis/scripts/diagnose.mjs +1971 -0
- package/.agents/skills/swarm-governance/SKILL.md +59 -0
- package/.agents/skills/swarm-governance/references/bundling-and-wire-format.md +88 -0
- package/.agents/skills/swarm-governance/references/intake-and-planning.md +120 -0
- package/.agents/skills/swarm-governance/references/large-swarms.md +39 -0
- package/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +156 -2
- package/bin/agy-squad.mjs +293 -0
- package/docs/assets/architecture-overview.svg +39 -0
- package/docs/assets/manifest-and-modes.svg +39 -0
- package/docs/assets/role-and-verdict-gate.svg +39 -0
- package/docs/assets/skill-role-workflows.svg +39 -0
- package/docs/assets/swarm-lifecycle.svg +39 -0
- package/docs/benchmarks.md +102 -0
- package/docs/concepts.md +81 -0
- package/docs/core-workflows.md +128 -0
- package/docs/getting-started.md +116 -0
- package/docs/index.md +47 -0
- package/docs/plans/LEDGER.md +24 -0
- package/docs/plans/comparative-harness-architecture-retest.md +1174 -0
- package/docs/plans/comparative-harness-architecture-teamwork.md +1170 -0
- package/docs/plans/comparative-harness-architecture.md +256 -0
- package/docs/plans/native-enforcement-ledger.md +126 -0
- package/docs/plans/pr3-option-b-fixes.md +803 -0
- package/docs/plans/wsl-cli-verification.md +55 -0
- package/docs/reviews/post-pr5-governance-review.md +221 -0
- package/docs/reviews/pr1-code-review-ledger.md +581 -0
- package/docs/reviews/pr1-production-readiness-review.md +764 -0
- package/docs/reviews/pr2-documentation-review-ledger.md +380 -0
- package/docs/reviews/pr3-squad-alignment-full-review.md +1021 -0
- package/docs/reviews/pr4-swarm-governance-pivot-review.md +593 -0
- package/docs/reviews/pr5-full-review-direction.md +330 -0
- package/docs/reviews/pr5-independent-review.md +266 -0
- package/docs/reviews/pr5-layered-swarm-review.md +513 -0
- package/docs/reviews/pr5-phase2-swarm-planner-review.md +470 -0
- package/docs/reviews/pr5-reconciled-review.md +573 -0
- package/docs/reviews/rebuild-wsl-dispatch-review-r2.md +427 -0
- package/docs/reviews/rebuild-wsl-dispatch-review.md +552 -0
- package/docs/roles-and-workflows.md +115 -0
- package/docs/stopping-agents.md +39 -0
- package/docs/tools.md +122 -0
- package/install.ps1 +5 -0
- package/install.sh +4 -0
- package/mcp/briefs.mjs +202 -0
- package/mcp/dispatch.mjs +280 -0
- package/mcp/handoffs.mjs +814 -0
- package/mcp/index.js +322 -0
- package/mcp/planner.mjs +755 -0
- package/mcp/verdicts.mjs +224 -0
- package/package.json +57 -4
- package/plugin.json +20 -0
- package/scripts/install-register.mjs +510 -0
- package/scripts/release-preflight.mjs +142 -0
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Agy-Squad Registration & Installation Engine
|
|
5
|
+
* Zero-clone cross-platform installer for Google Antigravity:
|
|
6
|
+
* - Links or installs native plugin into ~/.gemini/config/plugins/agy-squad
|
|
7
|
+
* - Links plugin skills (skills -> .agents/skills) for Antigravity discovery
|
|
8
|
+
* - Registers agy-squad MCP server in ~/.gemini/config/mcp_config.json (preserving foreign servers)
|
|
9
|
+
* - Enables agy-squad plugin in ~/.gemini/config/config.json
|
|
10
|
+
* - Provisions executable agy-squad CLI shims in ~/.gemini/antigravity/bin/
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import fs from "node:fs";
|
|
14
|
+
import os from "node:os";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
import { performance } from "node:perf_hooks";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
|
|
19
|
+
const fsPromises = fs.promises;
|
|
20
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
const repoRoot = path.resolve(__dirname, "..");
|
|
22
|
+
|
|
23
|
+
const PACKAGE_VERSION = (() => {
|
|
24
|
+
try {
|
|
25
|
+
return JSON.parse(fs.readFileSync(path.join(repoRoot, "package.json"), "utf8")).version || "0.1.0";
|
|
26
|
+
} catch {
|
|
27
|
+
return "0.1.0";
|
|
28
|
+
}
|
|
29
|
+
})();
|
|
30
|
+
|
|
31
|
+
const PLUGIN_KEY = "agy-squad";
|
|
32
|
+
const homeDir = process.env.AGY_TEST_PROFILE_DIR || os.homedir();
|
|
33
|
+
const geminiConfigDir = path.join(homeDir, ".gemini", "config");
|
|
34
|
+
const pluginsDir = path.join(geminiConfigDir, "plugins");
|
|
35
|
+
const pluginDest = path.join(pluginsDir, PLUGIN_KEY);
|
|
36
|
+
const configJsonPath = path.join(geminiConfigDir, "config.json");
|
|
37
|
+
const configBakPath = path.join(geminiConfigDir, "config.json.bak");
|
|
38
|
+
const mcpJsonPath = path.join(geminiConfigDir, "mcp_config.json");
|
|
39
|
+
const mcpBakPath = path.join(geminiConfigDir, "mcp_config.json.bak");
|
|
40
|
+
const antigravityMcpRootDir = path.join(homeDir, ".gemini", "antigravity", "mcp");
|
|
41
|
+
const antigravityBinDir = path.join(homeDir, ".gemini", "antigravity", "bin");
|
|
42
|
+
|
|
43
|
+
function normalizeSlash(p) {
|
|
44
|
+
return p.replace(/\\/g, "/");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function safeWriteFileIfChanged(filePath, content, mode) {
|
|
48
|
+
try {
|
|
49
|
+
if (fs.existsSync(filePath)) {
|
|
50
|
+
const current = await fsPromises.readFile(filePath, "utf8");
|
|
51
|
+
if (current === content) {
|
|
52
|
+
if (mode !== undefined && os.platform() !== "win32") {
|
|
53
|
+
await fsPromises.chmod(filePath, mode);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} catch {}
|
|
59
|
+
await fsPromises.mkdir(path.dirname(filePath), { recursive: true });
|
|
60
|
+
const tmpPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
61
|
+
await fsPromises.writeFile(tmpPath, content, "utf8");
|
|
62
|
+
if (mode !== undefined && os.platform() !== "win32") {
|
|
63
|
+
await fsPromises.chmod(tmpPath, mode);
|
|
64
|
+
}
|
|
65
|
+
await fsPromises.rename(tmpPath, filePath);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function readAndValidateJsonFile(filePath, label) {
|
|
70
|
+
if (!fs.existsSync(filePath)) return null;
|
|
71
|
+
let raw = "";
|
|
72
|
+
try {
|
|
73
|
+
raw = fs.readFileSync(filePath, "utf8");
|
|
74
|
+
} catch (err) {
|
|
75
|
+
throw new Error(`Cannot read ${label} (${filePath}): ${err.message}`);
|
|
76
|
+
}
|
|
77
|
+
if (!raw.trim()) {
|
|
78
|
+
throw new Error(`Existing ${label} (${filePath}) is empty; aborting to preserve user configuration.`);
|
|
79
|
+
}
|
|
80
|
+
let parsed;
|
|
81
|
+
try {
|
|
82
|
+
parsed = JSON.parse(raw);
|
|
83
|
+
} catch (err) {
|
|
84
|
+
throw new Error(`Existing ${label} (${filePath}) contains malformed JSON (${err.message}); aborting to preserve user configuration.`);
|
|
85
|
+
}
|
|
86
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
87
|
+
throw new Error(`Existing ${label} (${filePath}) root must be a JSON object; aborting to preserve user configuration.`);
|
|
88
|
+
}
|
|
89
|
+
return parsed;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function detectExistingInstallation() {
|
|
93
|
+
const details = {
|
|
94
|
+
plugin: { exists: false, skillsReady: false, path: pluginDest },
|
|
95
|
+
mcp: { registered: false, path: mcpJsonPath },
|
|
96
|
+
cliShim: { exists: false, path: antigravityBinDir },
|
|
97
|
+
config: { enabled: false, path: configJsonPath }
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
if (fs.existsSync(pluginDest)) {
|
|
102
|
+
details.plugin.exists = true;
|
|
103
|
+
const skillsPath = path.join(pluginDest, "skills");
|
|
104
|
+
const prReviewSkill = path.join(skillsPath, "pr-review", "SKILL.md");
|
|
105
|
+
details.plugin.skillsReady = fs.existsSync(prReviewSkill);
|
|
106
|
+
}
|
|
107
|
+
} catch {}
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
if (fs.existsSync(mcpJsonPath)) {
|
|
111
|
+
const parsed = JSON.parse(fs.readFileSync(mcpJsonPath, "utf8"));
|
|
112
|
+
const entry = parsed?.mcpServers?.[PLUGIN_KEY];
|
|
113
|
+
if (entry && typeof entry.command === "string" && Array.isArray(entry.args) && entry.args.length > 0) {
|
|
114
|
+
details.mcp.registered = true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
} catch {}
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
const isWin = os.platform() === "win32";
|
|
121
|
+
const shimPath = path.join(antigravityBinDir, isWin ? "agy-squad.cmd" : "agy-squad");
|
|
122
|
+
details.cliShim.exists = fs.existsSync(shimPath);
|
|
123
|
+
} catch {}
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
if (fs.existsSync(configJsonPath)) {
|
|
127
|
+
const parsed = JSON.parse(fs.readFileSync(configJsonPath, "utf8"));
|
|
128
|
+
details.config.enabled = parsed?.plugins?.[PLUGIN_KEY]?.enabled === true;
|
|
129
|
+
} else {
|
|
130
|
+
details.config.enabled = true;
|
|
131
|
+
}
|
|
132
|
+
} catch {}
|
|
133
|
+
|
|
134
|
+
const isInstalled =
|
|
135
|
+
details.plugin.exists &&
|
|
136
|
+
details.plugin.skillsReady &&
|
|
137
|
+
details.mcp.registered &&
|
|
138
|
+
details.cliShim.exists;
|
|
139
|
+
|
|
140
|
+
return { isInstalled, details };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function populateLinkedPluginDir(sourceRoot, targetPluginDir) {
|
|
144
|
+
await fsPromises.mkdir(targetPluginDir, { recursive: true });
|
|
145
|
+
for (const file of ["package.json", "plugin.json", "README.md"]) {
|
|
146
|
+
const src = path.join(sourceRoot, file);
|
|
147
|
+
if (fs.existsSync(src)) {
|
|
148
|
+
await fsPromises.copyFile(src, path.join(targetPluginDir, file));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const isWin = os.platform() === "win32";
|
|
152
|
+
const linkMappings = [
|
|
153
|
+
["bin", path.join(sourceRoot, "bin")],
|
|
154
|
+
["mcp", path.join(sourceRoot, "mcp")],
|
|
155
|
+
["scripts", path.join(sourceRoot, "scripts")],
|
|
156
|
+
[".agents", path.join(sourceRoot, ".agents")],
|
|
157
|
+
["skills", path.join(sourceRoot, ".agents", "skills")]
|
|
158
|
+
];
|
|
159
|
+
for (const [name, srcTarget] of linkMappings) {
|
|
160
|
+
if (!fs.existsSync(srcTarget)) continue;
|
|
161
|
+
const destPath = path.join(targetPluginDir, name);
|
|
162
|
+
try {
|
|
163
|
+
const stat = fs.lstatSync(destPath);
|
|
164
|
+
if (stat.isSymbolicLink() || stat.isDirectory()) {
|
|
165
|
+
if (stat.isSymbolicLink()) await fsPromises.unlink(destPath);
|
|
166
|
+
else await fsPromises.rm(destPath, { recursive: true, force: true });
|
|
167
|
+
}
|
|
168
|
+
} catch {}
|
|
169
|
+
try {
|
|
170
|
+
fs.symlinkSync(srcTarget, destPath, isWin ? "junction" : "dir");
|
|
171
|
+
} catch {
|
|
172
|
+
await fsPromises.cp(srcTarget, destPath, { recursive: true });
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
await ensurePluginSkillsAndMcpManifest(targetPluginDir);
|
|
176
|
+
}
|
|
177
|
+
async function ensurePluginSkillsAndMcpManifest(targetPluginDir) {
|
|
178
|
+
const dotAgentsSkills = path.join(targetPluginDir, ".agents", "skills");
|
|
179
|
+
const skillsDest = path.join(targetPluginDir, "skills");
|
|
180
|
+
if (!fs.existsSync(skillsDest) && fs.existsSync(dotAgentsSkills)) {
|
|
181
|
+
try {
|
|
182
|
+
const isWin = os.platform() === "win32";
|
|
183
|
+
fs.symlinkSync(
|
|
184
|
+
isWin ? dotAgentsSkills : path.join(".agents", "skills"),
|
|
185
|
+
skillsDest,
|
|
186
|
+
isWin ? "junction" : "dir"
|
|
187
|
+
);
|
|
188
|
+
} catch {
|
|
189
|
+
await fsPromises.cp(dotAgentsSkills, skillsDest, { recursive: true });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const pluginMcpJson = path.join(targetPluginDir, "mcp_config.json");
|
|
194
|
+
const pluginMcpContent = JSON.stringify(
|
|
195
|
+
{
|
|
196
|
+
mcpServers: {
|
|
197
|
+
[PLUGIN_KEY]: {
|
|
198
|
+
command: "node",
|
|
199
|
+
args: ["./mcp/index.js"]
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
null,
|
|
204
|
+
2
|
|
205
|
+
) + "\n";
|
|
206
|
+
await safeWriteFileIfChanged(pluginMcpJson, pluginMcpContent);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async function installCliShims({ targetRoot, log }) {
|
|
210
|
+
await fsPromises.mkdir(antigravityBinDir, { recursive: true });
|
|
211
|
+
const cliTarget = normalizeSlash(path.join(targetRoot, "bin", "agy-squad.mjs"));
|
|
212
|
+
const posixShimPath = path.join(antigravityBinDir, "agy-squad");
|
|
213
|
+
const cmdShimPath = path.join(antigravityBinDir, "agy-squad.cmd");
|
|
214
|
+
|
|
215
|
+
const posixContent = `#!/usr/bin/env sh\nexec node "${cliTarget}" "$@"\n`;
|
|
216
|
+
const cmdContent = `@echo off\r\nnode "${path.join(targetRoot, "bin", "agy-squad.mjs")}" %*\r\n`;
|
|
217
|
+
|
|
218
|
+
const posixChanged = await safeWriteFileIfChanged(posixShimPath, posixContent, 0o755);
|
|
219
|
+
let cmdChanged = false;
|
|
220
|
+
if (os.platform() === "win32") {
|
|
221
|
+
cmdChanged = await safeWriteFileIfChanged(cmdShimPath, cmdContent);
|
|
222
|
+
}
|
|
223
|
+
const verb = posixChanged || cmdChanged ? "installed" : "verified";
|
|
224
|
+
log(`[OK] CLI shim (agy-squad) ${verb} in: ${antigravityBinDir}`);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export async function runCheckOnly(options = {}) {
|
|
228
|
+
const log = options.silent ? () => {} : console.log;
|
|
229
|
+
log("Running Agy-Squad read-only preflight check (--check)...");
|
|
230
|
+
|
|
231
|
+
for (const requiredRel of ["package.json", "plugin.json", "bin/agy-squad.mjs", "mcp/index.js", ".agents/skills/pr-review/SKILL.md"]) {
|
|
232
|
+
const abs = path.join(repoRoot, requiredRel);
|
|
233
|
+
if (!fs.existsSync(abs)) {
|
|
234
|
+
throw new Error(`Required repository file missing: ${requiredRel}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
readAndValidateJsonFile(mcpJsonPath, "mcp_config.json");
|
|
239
|
+
readAndValidateJsonFile(configJsonPath, "config.json");
|
|
240
|
+
|
|
241
|
+
const status = detectExistingInstallation();
|
|
242
|
+
log(`[OK] Read-only check passed (currently installed: ${status.isInstalled ? "YES" : "NO"}).`);
|
|
243
|
+
return status;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export async function runInstall(options = {}) {
|
|
247
|
+
const startTime = performance.now();
|
|
248
|
+
const log = options.silent ? () => {} : console.log;
|
|
249
|
+
const warn = options.silent ? () => {} : console.warn;
|
|
250
|
+
|
|
251
|
+
const validatedMcp = readAndValidateJsonFile(mcpJsonPath, "mcp_config.json");
|
|
252
|
+
const validatedConfig = readAndValidateJsonFile(configJsonPath, "config.json");
|
|
253
|
+
const existing = detectExistingInstallation();
|
|
254
|
+
|
|
255
|
+
if (existing.isInstalled) {
|
|
256
|
+
log("Existing Agy-Squad installation detected:");
|
|
257
|
+
log(` [OK] Native Plugin Link: ${pluginDest}`);
|
|
258
|
+
log(` [OK] MCP Server (${PLUGIN_KEY}): Registered in ${mcpJsonPath}`);
|
|
259
|
+
log(` [OK] CLI Shim (agy-squad): Installed in ${antigravityBinDir}`);
|
|
260
|
+
log(`\nRe-verifying and synchronizing to v${PACKAGE_VERSION}...`);
|
|
261
|
+
} else {
|
|
262
|
+
log(`Installing Agy-Squad v${PACKAGE_VERSION}...`);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
await fsPromises.mkdir(pluginsDir, { recursive: true });
|
|
266
|
+
const isGitRepo = fs.existsSync(path.join(repoRoot, ".git"));
|
|
267
|
+
const isTempOrNpx =
|
|
268
|
+
!isGitRepo || repoRoot.includes("_npx") || repoRoot.includes("npm-cache") || repoRoot.includes("node_modules");
|
|
269
|
+
const copyFilter = (src) => {
|
|
270
|
+
const rel = path.relative(repoRoot, src);
|
|
271
|
+
if (!rel) return true;
|
|
272
|
+
const topSegment = rel.split(path.sep)[0];
|
|
273
|
+
return ![".git", "node_modules", ".venv", "scratch", "site", "benchmarks", "tests"].includes(topSegment);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
try {
|
|
277
|
+
if (fs.existsSync(pluginDest) && fs.lstatSync(pluginDest).isSymbolicLink()) {
|
|
278
|
+
await fsPromises.unlink(pluginDest);
|
|
279
|
+
}
|
|
280
|
+
} catch {}
|
|
281
|
+
|
|
282
|
+
if (isTempOrNpx || options.forceCopyFallback) {
|
|
283
|
+
await fsPromises.cp(repoRoot, pluginDest, { recursive: true, filter: copyFilter });
|
|
284
|
+
await ensurePluginSkillsAndMcpManifest(pluginDest);
|
|
285
|
+
log(`[OK] Native Antigravity Plugin installed to: ${pluginDest}`);
|
|
286
|
+
} else {
|
|
287
|
+
await populateLinkedPluginDir(repoRoot, pluginDest);
|
|
288
|
+
log(`[OK] Native Antigravity Plugin linked: ${pluginDest} -> ${repoRoot}`);
|
|
289
|
+
}
|
|
290
|
+
log(`[OK] Plugin skills & manifest verified: ${path.join(pluginDest, "skills")}`);
|
|
291
|
+
|
|
292
|
+
const mcpEntryPoint = normalizeSlash(path.join(pluginDest, "mcp", "index.js"));
|
|
293
|
+
const nextMcp = validatedMcp ? { ...validatedMcp } : {};
|
|
294
|
+
const existingServers =
|
|
295
|
+
nextMcp.mcpServers && typeof nextMcp.mcpServers === "object" && !Array.isArray(nextMcp.mcpServers)
|
|
296
|
+
? { ...nextMcp.mcpServers }
|
|
297
|
+
: {};
|
|
298
|
+
existingServers[PLUGIN_KEY] = {
|
|
299
|
+
command: "node",
|
|
300
|
+
args: [mcpEntryPoint]
|
|
301
|
+
};
|
|
302
|
+
nextMcp.mcpServers = existingServers;
|
|
303
|
+
const nextMcpRaw = JSON.stringify(nextMcp, null, 2) + "\n";
|
|
304
|
+
|
|
305
|
+
if (fs.existsSync(mcpJsonPath) && !fs.existsSync(mcpBakPath)) {
|
|
306
|
+
try {
|
|
307
|
+
const currentRaw = fs.readFileSync(mcpJsonPath, "utf8");
|
|
308
|
+
if (currentRaw !== nextMcpRaw && Object.keys(validatedMcp?.mcpServers || {}).length > 0) {
|
|
309
|
+
await fsPromises.copyFile(mcpJsonPath, mcpBakPath);
|
|
310
|
+
log(`[OK] Created configuration backup: ${mcpBakPath}`);
|
|
311
|
+
}
|
|
312
|
+
} catch (err) {
|
|
313
|
+
warn(`[WARN] Could not create backup of ${mcpJsonPath}: ${err.message}`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const mcpChanged = await safeWriteFileIfChanged(mcpJsonPath, nextMcpRaw);
|
|
317
|
+
log(`[OK] MCP server (${PLUGIN_KEY}) ${mcpChanged ? "registered" : "verified"} in: ${mcpJsonPath}`);
|
|
318
|
+
|
|
319
|
+
const nextConfig = validatedConfig ? { ...validatedConfig } : {};
|
|
320
|
+
const prevPluginEntry = nextConfig.plugins?.[PLUGIN_KEY];
|
|
321
|
+
if (!prevPluginEntry || prevPluginEntry.enabled !== true) {
|
|
322
|
+
if (fs.existsSync(configJsonPath) && !fs.existsSync(configBakPath)) {
|
|
323
|
+
try {
|
|
324
|
+
await fsPromises.copyFile(configJsonPath, configBakPath);
|
|
325
|
+
} catch {}
|
|
326
|
+
}
|
|
327
|
+
nextConfig.plugins = {
|
|
328
|
+
...(nextConfig.plugins && typeof nextConfig.plugins === "object" ? nextConfig.plugins : {}),
|
|
329
|
+
[PLUGIN_KEY]: {
|
|
330
|
+
...(prevPluginEntry && typeof prevPluginEntry === "object" ? prevPluginEntry : {}),
|
|
331
|
+
enabled: true
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
await safeWriteFileIfChanged(configJsonPath, JSON.stringify(nextConfig, null, 2) + "\n");
|
|
335
|
+
log(`[OK] Enabled plugin '${PLUGIN_KEY}' in: ${configJsonPath}`);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
await installCliShims({ targetRoot: pluginDest, log });
|
|
339
|
+
|
|
340
|
+
const elapsed = (performance.now() - startTime).toFixed(1);
|
|
341
|
+
log(`\nAgy-Squad installation ${existing.isInstalled ? "synchronized & up-to-date" : "completed"} in ${elapsed}ms!\n`);
|
|
342
|
+
return { ...detectExistingInstallation(), isInstalled: true, elapsedMs: elapsed };
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export async function runRestoreBackups(options = {}) {
|
|
346
|
+
const log = options.silent ? () => {} : console.log;
|
|
347
|
+
let restoredCount = 0;
|
|
348
|
+
for (const [bakPath, targetPath] of [
|
|
349
|
+
[mcpBakPath, mcpJsonPath],
|
|
350
|
+
[configBakPath, configJsonPath]
|
|
351
|
+
]) {
|
|
352
|
+
if (fs.existsSync(bakPath)) {
|
|
353
|
+
await fsPromises.copyFile(bakPath, targetPath);
|
|
354
|
+
await fsPromises.unlink(bakPath);
|
|
355
|
+
log(`[OK] Restored backup: ${bakPath} -> ${targetPath}`);
|
|
356
|
+
restoredCount += 1;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (restoredCount === 0) {
|
|
360
|
+
log("[INFO] No backup files (*.bak) found to restore.");
|
|
361
|
+
}
|
|
362
|
+
return { restoredCount };
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export async function runUninstall(options = {}) {
|
|
366
|
+
const log = options.silent ? () => {} : console.log;
|
|
367
|
+
log("Uninstalling Agy-Squad...");
|
|
368
|
+
|
|
369
|
+
const validatedMcp = readAndValidateJsonFile(mcpJsonPath, "mcp_config.json");
|
|
370
|
+
const validatedConfig = readAndValidateJsonFile(configJsonPath, "config.json");
|
|
371
|
+
|
|
372
|
+
if (fs.existsSync(pluginDest)) {
|
|
373
|
+
try {
|
|
374
|
+
const stat = fs.lstatSync(pluginDest);
|
|
375
|
+
if (stat.isSymbolicLink()) {
|
|
376
|
+
await fsPromises.unlink(pluginDest);
|
|
377
|
+
} else {
|
|
378
|
+
await fsPromises.rm(pluginDest, { recursive: true, force: true });
|
|
379
|
+
}
|
|
380
|
+
log(`[OK] Removed plugin installation: ${pluginDest}`);
|
|
381
|
+
} catch (err) {
|
|
382
|
+
log(`[WARN] Could not remove ${pluginDest}: ${err.message}`);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const repoSkillsLink = path.join(repoRoot, "skills");
|
|
387
|
+
try {
|
|
388
|
+
if (fs.existsSync(repoSkillsLink) && fs.lstatSync(repoSkillsLink).isSymbolicLink()) {
|
|
389
|
+
await fsPromises.unlink(repoSkillsLink);
|
|
390
|
+
}
|
|
391
|
+
} catch {}
|
|
392
|
+
|
|
393
|
+
if (validatedMcp?.mcpServers && typeof validatedMcp.mcpServers === "object") {
|
|
394
|
+
const nextServers = { ...validatedMcp.mcpServers };
|
|
395
|
+
delete nextServers[PLUGIN_KEY];
|
|
396
|
+
const nextMcp = { ...validatedMcp, mcpServers: nextServers };
|
|
397
|
+
await safeWriteFileIfChanged(mcpJsonPath, JSON.stringify(nextMcp, null, 2) + "\n");
|
|
398
|
+
log(`[OK] Removed '${PLUGIN_KEY}' from: ${mcpJsonPath} (foreign entries preserved)`);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if (validatedConfig?.plugins && typeof validatedConfig.plugins === "object" && PLUGIN_KEY in validatedConfig.plugins) {
|
|
402
|
+
const nextPlugins = { ...validatedConfig.plugins };
|
|
403
|
+
delete nextPlugins[PLUGIN_KEY];
|
|
404
|
+
const nextConfig = { ...validatedConfig, plugins: nextPlugins };
|
|
405
|
+
await safeWriteFileIfChanged(configJsonPath, JSON.stringify(nextConfig, null, 2) + "\n");
|
|
406
|
+
log(`[OK] Removed '${PLUGIN_KEY}' plugin state from: ${configJsonPath}`);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
for (const shimName of ["agy-squad", "agy-squad.cmd"]) {
|
|
410
|
+
const shimPath = path.join(antigravityBinDir, shimName);
|
|
411
|
+
if (fs.existsSync(shimPath)) {
|
|
412
|
+
await fsPromises.unlink(shimPath);
|
|
413
|
+
log(`[OK] Removed CLI shim: ${shimPath}`);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (fs.existsSync(antigravityMcpRootDir)) {
|
|
418
|
+
try {
|
|
419
|
+
for (const entry of fs.readdirSync(antigravityMcpRootDir)) {
|
|
420
|
+
if (entry === PLUGIN_KEY || entry.startsWith(`${PLUGIN_KEY}_`)) {
|
|
421
|
+
await fsPromises.rm(path.join(antigravityMcpRootDir, entry), { recursive: true, force: true });
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
} catch {}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
if (options.restoreBackups) {
|
|
428
|
+
await runRestoreBackups(options);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
log("\nAgy-Squad uninstallation complete.");
|
|
432
|
+
return detectExistingInstallation();
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export function printStatus() {
|
|
436
|
+
const status = detectExistingInstallation();
|
|
437
|
+
console.log("Checking Agy-Squad installation status...\n");
|
|
438
|
+
console.log(
|
|
439
|
+
`- Native Plugin Link: ${status.details.plugin.exists ? "ACTIVE" : "MISSING"} (${status.details.plugin.path})`
|
|
440
|
+
);
|
|
441
|
+
console.log(
|
|
442
|
+
`- Governance Skills (pr-review, full-review, self-diagnosis, swarm-governance): ${
|
|
443
|
+
status.details.plugin.skillsReady ? "READY" : "MISSING"
|
|
444
|
+
}`
|
|
445
|
+
);
|
|
446
|
+
console.log(
|
|
447
|
+
`- MCP Server (${PLUGIN_KEY}): ${status.details.mcp.registered ? "REGISTERED" : "MISSING"} (${status.details.mcp.path})`
|
|
448
|
+
);
|
|
449
|
+
console.log(
|
|
450
|
+
`- CLI Shim (agy-squad): ${status.details.cliShim.exists ? "INSTALLED" : "MISSING"} (${status.details.cliShim.path})`
|
|
451
|
+
);
|
|
452
|
+
console.log(
|
|
453
|
+
`- Plugin Enabled (config.json): ${status.details.config.enabled ? "ENABLED" : "DISABLED"}`
|
|
454
|
+
);
|
|
455
|
+
console.log(`\nOverall Status: ${status.isInstalled ? "HEALTHY & ACTIVE" : "NOT INSTALLED"}`);
|
|
456
|
+
return status;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function printCliHelp() {
|
|
460
|
+
console.log(`
|
|
461
|
+
Agy-Squad Registration & Lifecycle Engine (v${PACKAGE_VERSION})
|
|
462
|
+
|
|
463
|
+
Usage:
|
|
464
|
+
node scripts/install-register.mjs [command/option]
|
|
465
|
+
|
|
466
|
+
Commands & Options:
|
|
467
|
+
--status, status Check live integration status (plugin, skills, MCP server, CLI shim)
|
|
468
|
+
--check, -c Run read-only pre-flight validation check without writing changes
|
|
469
|
+
--uninstall, uninstall Remove plugin link, MCP entry, CLI shims, and schema caches
|
|
470
|
+
--restore-backups Restore original configuration backup files (*.bak)
|
|
471
|
+
--help, -h, help Show this help message
|
|
472
|
+
(no arguments) Install or synchronize Agy-Squad v${PACKAGE_VERSION}
|
|
473
|
+
`);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
477
|
+
const args = process.argv.slice(2);
|
|
478
|
+
const isHelp = args.includes("--help") || args.includes("-h") || args.includes("help");
|
|
479
|
+
const isUninstall = args.includes("--uninstall") || args.includes("uninstall");
|
|
480
|
+
const isStatus = args.includes("--status") || args.includes("status");
|
|
481
|
+
const isCheck = args.includes("--check") || args.includes("-c");
|
|
482
|
+
const isRestoreBackups = args.includes("--restore-backups") || args.includes("restore-backups");
|
|
483
|
+
|
|
484
|
+
if (isHelp) {
|
|
485
|
+
printCliHelp();
|
|
486
|
+
process.exit(0);
|
|
487
|
+
}
|
|
488
|
+
if (isCheck && (isUninstall || isRestoreBackups)) {
|
|
489
|
+
console.error("Conflicting flags: --check is read-only and cannot be combined with --uninstall or --restore-backups.");
|
|
490
|
+
process.exit(1);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
try {
|
|
494
|
+
if (isStatus) {
|
|
495
|
+
const st = printStatus();
|
|
496
|
+
process.exit(st.isInstalled ? 0 : 1);
|
|
497
|
+
} else if (isCheck) {
|
|
498
|
+
await runCheckOnly();
|
|
499
|
+
} else if (isUninstall) {
|
|
500
|
+
await runUninstall({ restoreBackups: isRestoreBackups });
|
|
501
|
+
} else if (isRestoreBackups) {
|
|
502
|
+
await runRestoreBackups();
|
|
503
|
+
} else {
|
|
504
|
+
await runInstall();
|
|
505
|
+
}
|
|
506
|
+
} catch (err) {
|
|
507
|
+
console.error(`Error: ${err.message}`);
|
|
508
|
+
process.exit(1);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Non-destructive release metadata/package preflight for Agy-Squad.
|
|
4
|
+
* Run from the repository root: node scripts/release-preflight.mjs
|
|
5
|
+
*/
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
|
|
10
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
11
|
+
const errors = [];
|
|
12
|
+
const warnings = [];
|
|
13
|
+
|
|
14
|
+
function readText(relativePath) {
|
|
15
|
+
const target = path.join(root, relativePath);
|
|
16
|
+
try {
|
|
17
|
+
return fs.readFileSync(target, "utf8");
|
|
18
|
+
} catch {
|
|
19
|
+
errors.push(`Required file is missing or unreadable: ${relativePath}`);
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function exists(relativePath) {
|
|
25
|
+
return fs.existsSync(path.join(root, relativePath));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let pkg;
|
|
29
|
+
const pkgText = readText("package.json");
|
|
30
|
+
if (pkgText) {
|
|
31
|
+
try {
|
|
32
|
+
pkg = JSON.parse(pkgText);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
errors.push(`package.json is not valid JSON: ${error.message}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (pkg) {
|
|
39
|
+
if (pkg.name !== "agy-squad") {
|
|
40
|
+
errors.push(`Expected package name "agy-squad"; found ${JSON.stringify(pkg.name)}.`);
|
|
41
|
+
}
|
|
42
|
+
if (pkg.private === true) {
|
|
43
|
+
errors.push('package.json has "private": true; remove it for public npm publishing.');
|
|
44
|
+
}
|
|
45
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(pkg.version ?? "")) {
|
|
46
|
+
errors.push(`package.json version is not a valid semver release version: ${JSON.stringify(pkg.version)}.`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const pluginText = readText("plugin.json");
|
|
50
|
+
if (pluginText) {
|
|
51
|
+
try {
|
|
52
|
+
const pluginManifest = JSON.parse(pluginText);
|
|
53
|
+
if (pluginManifest.name !== pkg.name) {
|
|
54
|
+
errors.push(`plugin.json name ${JSON.stringify(pluginManifest.name)} does not match package.json name ${JSON.stringify(pkg.name)}.`);
|
|
55
|
+
}
|
|
56
|
+
if (pluginManifest.version !== pkg.version) {
|
|
57
|
+
errors.push(`plugin.json version ${JSON.stringify(pluginManifest.version)} does not match package.json version ${JSON.stringify(pkg.version)}.`);
|
|
58
|
+
}
|
|
59
|
+
} catch (error) {
|
|
60
|
+
errors.push(`plugin.json is not valid JSON: ${error.message}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const changelogText = readText("CHANGELOG.md");
|
|
65
|
+
if (changelogText && pkg.version && !changelogText.includes(`## [${pkg.version}]`)) {
|
|
66
|
+
errors.push(`CHANGELOG.md is missing a release heading for current version "## [${pkg.version}]".`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const requiredMetadata = [
|
|
70
|
+
["repository.url", pkg.repository?.url],
|
|
71
|
+
["homepage", pkg.homepage],
|
|
72
|
+
["bugs.url", pkg.bugs?.url],
|
|
73
|
+
["engines.node", pkg.engines?.node],
|
|
74
|
+
["publishConfig.access", pkg.publishConfig?.access]
|
|
75
|
+
];
|
|
76
|
+
for (const [label, value] of requiredMetadata) {
|
|
77
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
78
|
+
errors.push(`Add package.json metadata field "${label}" before publishing.`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const requiredPackageFiles = [
|
|
83
|
+
"bin/agy-squad.mjs",
|
|
84
|
+
"mcp/index.js",
|
|
85
|
+
"mcp/planner.mjs",
|
|
86
|
+
"mcp/briefs.mjs",
|
|
87
|
+
"mcp/handoffs.mjs",
|
|
88
|
+
"mcp/verdicts.mjs",
|
|
89
|
+
"scripts/install-register.mjs",
|
|
90
|
+
"scripts/release-preflight.mjs",
|
|
91
|
+
".agents/skills/pr-review/SKILL.md",
|
|
92
|
+
".agents/skills/full-review/SKILL.md",
|
|
93
|
+
".agents/skills/self-diagnosis/SKILL.md",
|
|
94
|
+
".agents/skills/swarm-governance/SKILL.md",
|
|
95
|
+
"plugin.json",
|
|
96
|
+
"install.sh",
|
|
97
|
+
"install.ps1",
|
|
98
|
+
"README.md",
|
|
99
|
+
"CHANGELOG.md",
|
|
100
|
+
"LICENSE"
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
for (const relativePath of requiredPackageFiles) {
|
|
104
|
+
if (!exists(relativePath)) {
|
|
105
|
+
errors.push(`Required runtime/release file is missing: ${relativePath}`);
|
|
106
|
+
}
|
|
107
|
+
const alwaysIncluded = ["package.json", "README.md", "CHANGELOG.md", "LICENSE"].includes(relativePath);
|
|
108
|
+
const coveredByFiles =
|
|
109
|
+
alwaysIncluded ||
|
|
110
|
+
(pkg.files ?? []).some((entry) => {
|
|
111
|
+
const normalized = entry.replace(/\\/g, "/").replace(/\/$/, "");
|
|
112
|
+
return relativePath === normalized || relativePath.startsWith(`${normalized}/`);
|
|
113
|
+
});
|
|
114
|
+
if (!coveredByFiles) {
|
|
115
|
+
errors.push(`package.json "files" does not clearly include ${relativePath}.`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
for (const relativePath of ["SECURITY.md", "CONTRIBUTING.md", "CODE_OF_CONDUCT.md"]) {
|
|
120
|
+
if (!exists(relativePath)) {
|
|
121
|
+
errors.push(`Add ${relativePath} before the public release.`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (!pkg.scripts?.setup || !pkg.scripts?.status || !pkg.scripts?.uninstall || !pkg.scripts?.preflight || !pkg.scripts?.test) {
|
|
126
|
+
errors.push("Expected npm scripts setup, status, uninstall, preflight, and test to be present.");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (Object.keys(pkg.dependencies ?? {}).length > 0) {
|
|
130
|
+
warnings.push(`Runtime npm dependencies are present (${Object.keys(pkg.dependencies).join(", ")}); review whether each is required.`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
for (const warning of warnings) console.warn(`WARN: ${warning}`);
|
|
135
|
+
for (const error of errors) console.error(`FAIL: ${error}`);
|
|
136
|
+
|
|
137
|
+
if (errors.length) {
|
|
138
|
+
console.error(`\nRelease preflight failed with ${errors.length} error(s) and ${warnings.length} warning(s).`);
|
|
139
|
+
process.exitCode = 1;
|
|
140
|
+
} else {
|
|
141
|
+
console.log(`\nRelease preflight passed${warnings.length ? ` with ${warnings.length} warning(s)` : ""}.`);
|
|
142
|
+
}
|