claude-everything-workflow 0.2.9 → 0.2.11
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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +1 -1
- package/README.md +11 -5
- package/README.zh-CN.md +12 -6
- package/bin/claude-everything-workflow.js +16 -4
- package/commands/code-review.md +4 -4
- package/docs/plugins.md +20 -2
- package/evals/routing-scenarios.json +8 -9
- package/package.json +1 -1
- package/scripts/eval-scenarios.js +49 -15
- package/scripts/install-antigravity.js +501 -0
- package/scripts/install-rules.js +186 -32
- package/scripts/install.ps1 +75 -4
- package/scripts/install.sh +72 -20
- package/scripts/legacy-common-rule-hashes.json +2 -1
- package/scripts/verify/install-rules.test.js +367 -7
- package/scripts/verify/metadata-checks.js +23 -0
- package/scripts/verify/scenario-checks.test.js +52 -10
- package/skills/README.md +1 -1
- package/skills/code-review/SKILL.md +15 -21
- package/skills/feature-acceptance/SKILL.md +1 -1
- package/skills/implement/SKILL.md +2 -2
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const crypto = require("node:crypto");
|
|
7
|
+
const { spawnSync } = require("node:child_process");
|
|
8
|
+
const {
|
|
9
|
+
BACKUP_ROOT_NAME,
|
|
10
|
+
checkedPath,
|
|
11
|
+
defaultBackupId,
|
|
12
|
+
finalizeBackups,
|
|
13
|
+
installRules,
|
|
14
|
+
validateBackupId,
|
|
15
|
+
validateRuleTargets,
|
|
16
|
+
} = require("./install-rules");
|
|
17
|
+
|
|
18
|
+
const PLUGIN_NAME = "claude-everything-workflow";
|
|
19
|
+
const PLUGIN_SUBPATH = path.posix.join(".gemini/config/plugins", PLUGIN_NAME);
|
|
20
|
+
const PLUGIN_HOME_REF = `~/.gemini/config/plugins/${PLUGIN_NAME}`;
|
|
21
|
+
|
|
22
|
+
const DEFAULT_ANTIGRAVITY_TOOLS = [
|
|
23
|
+
"read_file",
|
|
24
|
+
"edit_file",
|
|
25
|
+
"write_file",
|
|
26
|
+
"run_command",
|
|
27
|
+
"manage_task",
|
|
28
|
+
"search_web",
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const TOOL_MAP = {
|
|
32
|
+
Read: ["read_file"],
|
|
33
|
+
Glob: ["read_file"],
|
|
34
|
+
Grep: ["read_file"],
|
|
35
|
+
Edit: ["edit_file"],
|
|
36
|
+
MultiEdit: ["edit_file"],
|
|
37
|
+
Write: ["write_file"],
|
|
38
|
+
Bash: ["run_command", "manage_task"],
|
|
39
|
+
WebSearch: ["search_web"],
|
|
40
|
+
WebFetch: ["search_web"],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
function lstatIfExists(target) {
|
|
44
|
+
try {
|
|
45
|
+
return fs.lstatSync(target);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (error.code === "ENOENT" || error.code === "ENOTDIR") return null;
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function assertNoSymlinkAncestors(homeDir) {
|
|
53
|
+
const resolvedHome = path.resolve(homeDir);
|
|
54
|
+
const chain = [
|
|
55
|
+
".gemini",
|
|
56
|
+
".gemini/config",
|
|
57
|
+
".gemini/config/plugins",
|
|
58
|
+
PLUGIN_SUBPATH,
|
|
59
|
+
];
|
|
60
|
+
for (const relative of chain) {
|
|
61
|
+
const candidate = path.join(resolvedHome, relative);
|
|
62
|
+
if (lstatIfExists(candidate)?.isSymbolicLink()) {
|
|
63
|
+
throw new Error(`Refusing symlinked install path: ${candidate}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return path.join(resolvedHome, PLUGIN_SUBPATH);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function unquoteScalar(raw) {
|
|
70
|
+
const trimmed = raw.trim();
|
|
71
|
+
if (trimmed.length < 2) return trimmed;
|
|
72
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"')) {
|
|
73
|
+
try {
|
|
74
|
+
return JSON.parse(trimmed);
|
|
75
|
+
} catch {
|
|
76
|
+
return trimmed.slice(1, -1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (trimmed.startsWith("'") && trimmed.endsWith("'")) {
|
|
80
|
+
return trimmed.slice(1, -1).replace(/''/g, "'");
|
|
81
|
+
}
|
|
82
|
+
return trimmed;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function parseInlineArray(raw) {
|
|
86
|
+
const inner = raw.trim().slice(1, -1).trim();
|
|
87
|
+
if (!inner) return [];
|
|
88
|
+
try {
|
|
89
|
+
const parsed = JSON.parse(raw.trim());
|
|
90
|
+
if (Array.isArray(parsed)) return parsed.map(String);
|
|
91
|
+
} catch {
|
|
92
|
+
// Fallback for unquoted YAML flow sequences such as [Read, Edit].
|
|
93
|
+
}
|
|
94
|
+
return inner.split(",").map((item) => unquoteScalar(item)).filter(Boolean);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function parseBlockScalar(lines, startIndex, style) {
|
|
98
|
+
const collected = [];
|
|
99
|
+
let indent = null;
|
|
100
|
+
let index = startIndex;
|
|
101
|
+
while (index < lines.length) {
|
|
102
|
+
const line = lines[index];
|
|
103
|
+
if (line.trim() === "") {
|
|
104
|
+
collected.push("");
|
|
105
|
+
index += 1;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const match = line.match(/^(\s+)/);
|
|
109
|
+
if (!match) break;
|
|
110
|
+
if (indent === null) indent = match[1].length;
|
|
111
|
+
if (match[1].length < indent) break;
|
|
112
|
+
collected.push(line.slice(indent));
|
|
113
|
+
index += 1;
|
|
114
|
+
}
|
|
115
|
+
const joined = style.startsWith(">")
|
|
116
|
+
? collected.map((part) => part || "\n").join(" ").replace(/ \n /g, "\n")
|
|
117
|
+
: collected.join("\n");
|
|
118
|
+
return { value: joined.trim(), nextIndex: index };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function parseFrontmatter(text) {
|
|
122
|
+
const normalized = text.replace(/\r\n/g, "\n");
|
|
123
|
+
const match = normalized.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
124
|
+
if (!match) return { data: null, body: normalized };
|
|
125
|
+
|
|
126
|
+
const data = {};
|
|
127
|
+
const lines = match[1].split("\n");
|
|
128
|
+
for (let i = 0; i < lines.length; ) {
|
|
129
|
+
const line = lines[i];
|
|
130
|
+
if (!line.trim() || line.trimStart().startsWith("#")) {
|
|
131
|
+
i += 1;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const kv = line.match(/^([A-Za-z0-9_-]+):\s*(.*)$/);
|
|
135
|
+
if (!kv) {
|
|
136
|
+
i += 1;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const key = kv[1];
|
|
140
|
+
const rest = kv[2].trim();
|
|
141
|
+
if (rest === "|" || rest === "|-" || rest === ">" || rest === ">-") {
|
|
142
|
+
const block = parseBlockScalar(lines, i + 1, rest);
|
|
143
|
+
data[key] = block.value;
|
|
144
|
+
i = block.nextIndex;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (rest.startsWith("[") && rest.endsWith("]")) {
|
|
148
|
+
data[key] = parseInlineArray(rest);
|
|
149
|
+
i += 1;
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (rest === "") {
|
|
153
|
+
const items = [];
|
|
154
|
+
let j = i + 1;
|
|
155
|
+
while (j < lines.length) {
|
|
156
|
+
const itemMatch = lines[j].match(/^\s*-\s+(.*)$/);
|
|
157
|
+
if (!itemMatch) break;
|
|
158
|
+
items.push(unquoteScalar(itemMatch[1]));
|
|
159
|
+
j += 1;
|
|
160
|
+
}
|
|
161
|
+
data[key] = items.length > 0 ? items : "";
|
|
162
|
+
i = j;
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
data[key] = unquoteScalar(rest);
|
|
166
|
+
i += 1;
|
|
167
|
+
}
|
|
168
|
+
return { data, body: match[2] };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function mapTools(rawTools, agentFile = "agent") {
|
|
172
|
+
if (rawTools === undefined) {
|
|
173
|
+
return [...DEFAULT_ANTIGRAVITY_TOOLS];
|
|
174
|
+
}
|
|
175
|
+
if (!Array.isArray(rawTools)) {
|
|
176
|
+
throw new Error(`agents/${agentFile} declares invalid tools field`);
|
|
177
|
+
}
|
|
178
|
+
const mapped = [];
|
|
179
|
+
const seen = new Set();
|
|
180
|
+
for (const tool of rawTools) {
|
|
181
|
+
const targets = TOOL_MAP[tool] || (DEFAULT_ANTIGRAVITY_TOOLS.includes(tool) ? [tool] : []);
|
|
182
|
+
for (const target of targets) {
|
|
183
|
+
if (!seen.has(target)) {
|
|
184
|
+
seen.add(target);
|
|
185
|
+
mapped.push(target);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (mapped.length === 0) {
|
|
190
|
+
throw new Error(`agents/${agentFile} declares no supported Antigravity tools`);
|
|
191
|
+
}
|
|
192
|
+
return mapped;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function normalizeRepoUrl(repo) {
|
|
196
|
+
const raw = typeof repo === "string" ? repo : repo?.url;
|
|
197
|
+
if (typeof raw !== "string" || !raw.trim()) {
|
|
198
|
+
return "https://github.com/xu91102/claude-everything-Workflow";
|
|
199
|
+
}
|
|
200
|
+
return raw.replace(/^git\+/, "").replace(/\.git$/, "");
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function buildPluginManifest(sourceRoot) {
|
|
204
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(sourceRoot, "package.json"), "utf8"));
|
|
205
|
+
const repository = normalizeRepoUrl(pkg.repository);
|
|
206
|
+
const manifest = {
|
|
207
|
+
name: pkg.name || PLUGIN_NAME,
|
|
208
|
+
displayName: "Claude Everything Workflow",
|
|
209
|
+
version: pkg.version,
|
|
210
|
+
description:
|
|
211
|
+
"Evidence-based engineering workflows for Antigravity: implement, debug, review, verify, and PR gates.",
|
|
212
|
+
author: { name: "xu91102" },
|
|
213
|
+
homepage: pkg.homepage || repository,
|
|
214
|
+
repository,
|
|
215
|
+
suggestedPrompts: [
|
|
216
|
+
"按 CEW 流程排查并修复这个 bug,输出验证证据",
|
|
217
|
+
"对当前分支改动做代码审查并给出分级问题清单",
|
|
218
|
+
"为这个需求起草正式工程 Spec 并等我审批",
|
|
219
|
+
],
|
|
220
|
+
};
|
|
221
|
+
return JSON.stringify(manifest, null, 2) + "\n";
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function writeManagedFile({ pluginRoot, relative, content, mode, backupId, dryRun, log }) {
|
|
225
|
+
const target = checkedPath(pluginRoot, relative);
|
|
226
|
+
const next = Buffer.isBuffer(content) ? content : Buffer.from(content, "utf8");
|
|
227
|
+
const existingStat = lstatIfExists(target);
|
|
228
|
+
if (existingStat) {
|
|
229
|
+
if (existingStat.isSymbolicLink()) throw new Error(`Refusing symlink: ${target}`);
|
|
230
|
+
const previous = fs.readFileSync(target);
|
|
231
|
+
if (next.equals(previous)) return;
|
|
232
|
+
if (backupId) {
|
|
233
|
+
const backup = checkedPath(pluginRoot, path.posix.join(BACKUP_ROOT_NAME, backupId, relative));
|
|
234
|
+
log(`${dryRun ? "[dry-run] " : ""}备份文件: ${backup}`);
|
|
235
|
+
if (!dryRun) {
|
|
236
|
+
fs.mkdirSync(path.dirname(backup), { recursive: true });
|
|
237
|
+
fs.copyFileSync(target, backup);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (!dryRun) {
|
|
242
|
+
const writableMode = mode !== undefined ? (mode & 0o777) | 0o200 : undefined;
|
|
243
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
244
|
+
const temp = `${target}.tmp-${crypto.randomUUID()}`;
|
|
245
|
+
try {
|
|
246
|
+
fs.writeFileSync(temp, next, {
|
|
247
|
+
flag: "wx",
|
|
248
|
+
...(writableMode !== undefined ? { mode: writableMode } : {}),
|
|
249
|
+
});
|
|
250
|
+
if (process.platform !== "win32" && writableMode !== undefined) {
|
|
251
|
+
fs.chmodSync(temp, writableMode);
|
|
252
|
+
}
|
|
253
|
+
fs.renameSync(temp, target);
|
|
254
|
+
} finally {
|
|
255
|
+
fs.rmSync(temp, { force: true });
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
log(`[dry-run] 写入文件: ${target}`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function collectDirectoryFiles(sourceDir, relativePrefix = "") {
|
|
263
|
+
const entries = [];
|
|
264
|
+
if (!fs.existsSync(sourceDir)) return entries;
|
|
265
|
+
for (const entry of fs.readdirSync(sourceDir, { withFileTypes: true })) {
|
|
266
|
+
const srcPath = path.join(sourceDir, entry.name);
|
|
267
|
+
const relPath = relativePrefix ? path.posix.join(relativePrefix, entry.name) : entry.name;
|
|
268
|
+
if (entry.isSymbolicLink()) {
|
|
269
|
+
throw new Error(`Refusing symlink in source directory: ${srcPath}`);
|
|
270
|
+
}
|
|
271
|
+
if (entry.isDirectory()) {
|
|
272
|
+
entries.push(...collectDirectoryFiles(srcPath, relPath));
|
|
273
|
+
} else if (entry.isFile()) {
|
|
274
|
+
entries.push({ srcPath, relPath, mode: fs.statSync(srcPath).mode & 0o777 });
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return entries;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function buildCommandSkills(sourceRoot) {
|
|
281
|
+
const commandsDir = path.join(sourceRoot, "commands");
|
|
282
|
+
if (!fs.existsSync(commandsDir)) return [];
|
|
283
|
+
const generated = [];
|
|
284
|
+
for (const entry of fs.readdirSync(commandsDir, { withFileTypes: true })) {
|
|
285
|
+
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
286
|
+
const cmdName = entry.name.slice(0, -3);
|
|
287
|
+
if (fs.existsSync(path.join(sourceRoot, "skills", cmdName, "SKILL.md"))) {
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
const raw = fs.readFileSync(path.join(commandsDir, entry.name), "utf8");
|
|
291
|
+
const { data, body } = parseFrontmatter(raw);
|
|
292
|
+
if (!data || typeof data.description !== "string" || !data.description.trim()) {
|
|
293
|
+
throw new Error(`commands/${entry.name} missing frontmatter description`);
|
|
294
|
+
}
|
|
295
|
+
const updatedBody = body
|
|
296
|
+
.replace(/\$ARGUMENTS/g, "用户本次请求的内容和参数")
|
|
297
|
+
.replace(/^\n+/, "");
|
|
298
|
+
const content = `---\nname: ${cmdName}\ndescription: ${JSON.stringify(data.description)}\n---\n\n${updatedBody}`;
|
|
299
|
+
generated.push({ relative: path.posix.join("skills", cmdName, "SKILL.md"), content });
|
|
300
|
+
}
|
|
301
|
+
return generated;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function buildAgentFiles(sourceRoot) {
|
|
305
|
+
const agentsDir = path.join(sourceRoot, "agents");
|
|
306
|
+
if (!fs.existsSync(agentsDir)) return [];
|
|
307
|
+
const generated = [];
|
|
308
|
+
for (const entry of fs.readdirSync(agentsDir, { withFileTypes: true })) {
|
|
309
|
+
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
310
|
+
const raw = fs.readFileSync(path.join(agentsDir, entry.name), "utf8");
|
|
311
|
+
const { data, body } = parseFrontmatter(raw);
|
|
312
|
+
if (
|
|
313
|
+
!data ||
|
|
314
|
+
typeof data.name !== "string" ||
|
|
315
|
+
!data.name.trim() ||
|
|
316
|
+
typeof data.description !== "string" ||
|
|
317
|
+
!data.description.trim()
|
|
318
|
+
) {
|
|
319
|
+
throw new Error(`agents/${entry.name} missing name or description`);
|
|
320
|
+
}
|
|
321
|
+
const tools = mapTools(data.tools, entry.name);
|
|
322
|
+
const updatedBody = body
|
|
323
|
+
.replace(/`(skills\/[^`\s]+)`/g, (_, target) => `\`${PLUGIN_HOME_REF}/${target}\``)
|
|
324
|
+
.replace(/`(references\/agents\/[^`\s]+)`/g, (_, target) => `\`${PLUGIN_HOME_REF}/${target}\``)
|
|
325
|
+
.replace(/^\n+/, "");
|
|
326
|
+
const frontmatter = [
|
|
327
|
+
`name: ${data.name}`,
|
|
328
|
+
`description: ${JSON.stringify(data.description)}`,
|
|
329
|
+
"subagent: true",
|
|
330
|
+
"mainAgent: false",
|
|
331
|
+
`tools: [${tools.join(", ")}]`,
|
|
332
|
+
].join("\n");
|
|
333
|
+
generated.push({
|
|
334
|
+
relative: path.posix.join("agents", entry.name),
|
|
335
|
+
content: `---\n${frontmatter}\n---\n\n${updatedBody}`,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
return generated;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function runRetiredSkillCleanup(sourceRoot, pluginRoot, dryRun, log) {
|
|
342
|
+
const script = path.join(sourceRoot, "scripts/cleanup-retired-skills.js");
|
|
343
|
+
const args = [script, pluginRoot];
|
|
344
|
+
if (dryRun) args.push("--dry-run");
|
|
345
|
+
const result = spawnSync(process.execPath, args, { encoding: "utf8" });
|
|
346
|
+
if (result.error) throw result.error;
|
|
347
|
+
if (result.stdout) {
|
|
348
|
+
for (const line of result.stdout.trimEnd().split(/\r?\n/)) {
|
|
349
|
+
if (line) log(line);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (result.status !== 0) {
|
|
353
|
+
throw new Error(result.stderr?.trim() || `Retired skill cleanup exited ${result.status}`);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function installAntigravity({
|
|
358
|
+
sourceRoot,
|
|
359
|
+
homeDir,
|
|
360
|
+
backupId = defaultBackupId(),
|
|
361
|
+
dryRun = false,
|
|
362
|
+
log = console.log,
|
|
363
|
+
}) {
|
|
364
|
+
const pluginRoot = assertNoSymlinkAncestors(homeDir);
|
|
365
|
+
log(`${dryRun ? "[dry-run] " : ""}Installing Antigravity plugin to ${pluginRoot}`);
|
|
366
|
+
|
|
367
|
+
const refFiles = collectDirectoryFiles(path.join(sourceRoot, "references"), "references");
|
|
368
|
+
const skillFiles = collectDirectoryFiles(path.join(sourceRoot, "skills"), "skills")
|
|
369
|
+
.filter((item) => item.relPath !== "skills/README.md");
|
|
370
|
+
const learningFiles = collectDirectoryFiles(
|
|
371
|
+
path.join(sourceRoot, "scripts/learning"),
|
|
372
|
+
"scripts/learning",
|
|
373
|
+
);
|
|
374
|
+
const commandSkills = buildCommandSkills(sourceRoot);
|
|
375
|
+
const agentFiles = buildAgentFiles(sourceRoot);
|
|
376
|
+
|
|
377
|
+
const managedPaths = [
|
|
378
|
+
BACKUP_ROOT_NAME,
|
|
379
|
+
"plugin.json",
|
|
380
|
+
"rules/AGENTS.md",
|
|
381
|
+
"harness/manifest.json",
|
|
382
|
+
...refFiles.map((item) => item.relPath),
|
|
383
|
+
...skillFiles.map((item) => item.relPath),
|
|
384
|
+
...learningFiles.map((item) => item.relPath),
|
|
385
|
+
...commandSkills.map((item) => item.relative),
|
|
386
|
+
...agentFiles.map((item) => item.relative),
|
|
387
|
+
];
|
|
388
|
+
|
|
389
|
+
// Validate every target before the first write; checkedPath refuses symlinks.
|
|
390
|
+
for (const relative of managedPaths) {
|
|
391
|
+
checkedPath(pluginRoot, relative);
|
|
392
|
+
}
|
|
393
|
+
validateRuleTargets({ sourceRoot, installRoot: pluginRoot, host: "antigravity" });
|
|
394
|
+
|
|
395
|
+
validateBackupId(backupId);
|
|
396
|
+
if (!dryRun) {
|
|
397
|
+
fs.mkdirSync(pluginRoot, { recursive: true });
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
writeManagedFile({
|
|
401
|
+
pluginRoot,
|
|
402
|
+
relative: "plugin.json",
|
|
403
|
+
content: buildPluginManifest(sourceRoot),
|
|
404
|
+
backupId,
|
|
405
|
+
dryRun,
|
|
406
|
+
log,
|
|
407
|
+
});
|
|
408
|
+
writeManagedFile({
|
|
409
|
+
pluginRoot,
|
|
410
|
+
relative: "rules/AGENTS.md",
|
|
411
|
+
content: fs.readFileSync(path.join(sourceRoot, "AGENTS.md")),
|
|
412
|
+
backupId,
|
|
413
|
+
dryRun,
|
|
414
|
+
log,
|
|
415
|
+
});
|
|
416
|
+
writeManagedFile({
|
|
417
|
+
pluginRoot,
|
|
418
|
+
relative: "harness/manifest.json",
|
|
419
|
+
content: fs.readFileSync(path.join(sourceRoot, "harness/manifest.json")),
|
|
420
|
+
dryRun,
|
|
421
|
+
log,
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
for (const item of [...refFiles, ...skillFiles, ...learningFiles]) {
|
|
425
|
+
writeManagedFile({
|
|
426
|
+
pluginRoot,
|
|
427
|
+
relative: item.relPath,
|
|
428
|
+
content: fs.readFileSync(item.srcPath),
|
|
429
|
+
mode: item.mode,
|
|
430
|
+
dryRun,
|
|
431
|
+
log,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
for (const item of [...commandSkills, ...agentFiles]) {
|
|
435
|
+
writeManagedFile({
|
|
436
|
+
pluginRoot,
|
|
437
|
+
relative: item.relative,
|
|
438
|
+
content: item.content,
|
|
439
|
+
dryRun,
|
|
440
|
+
log,
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
installRules({
|
|
445
|
+
sourceRoot,
|
|
446
|
+
installRoot: pluginRoot,
|
|
447
|
+
host: "antigravity",
|
|
448
|
+
backupId,
|
|
449
|
+
dryRun,
|
|
450
|
+
log,
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
runRetiredSkillCleanup(sourceRoot, pluginRoot, dryRun, log);
|
|
454
|
+
finalizeBackups({ installRoot: pluginRoot, dryRun, log });
|
|
455
|
+
|
|
456
|
+
const legacyAgents = path.join(path.resolve(homeDir), ".gemini/AGENTS.md");
|
|
457
|
+
if (lstatIfExists(legacyAgents)) {
|
|
458
|
+
log(`提示: 检测到 ${legacyAgents},若为旧版配置可能与插件 rules/AGENTS.md 冲突;请按需手动备份后移除。`);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return pluginRoot;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
module.exports = { PLUGIN_SUBPATH, installAntigravity, parseFrontmatter, mapTools };
|
|
465
|
+
|
|
466
|
+
function parseCli(argv) {
|
|
467
|
+
let dryRun = false;
|
|
468
|
+
let backupId;
|
|
469
|
+
const positional = [];
|
|
470
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
471
|
+
const arg = argv[i];
|
|
472
|
+
if (arg === "--dry-run") {
|
|
473
|
+
dryRun = true;
|
|
474
|
+
} else if (arg === "--backup-id") {
|
|
475
|
+
backupId = validateBackupId(argv[++i]);
|
|
476
|
+
} else if (arg.startsWith("-")) {
|
|
477
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
478
|
+
} else {
|
|
479
|
+
positional.push(arg);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return { dryRun, backupId, positional };
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (require.main === module) {
|
|
486
|
+
try {
|
|
487
|
+
const { dryRun, backupId, positional } = parseCli(process.argv.slice(2));
|
|
488
|
+
if (positional.length !== 1 || !positional[0]) {
|
|
489
|
+
throw new Error("Usage: install-antigravity.js <home-dir> [--backup-id <id>] [--dry-run]");
|
|
490
|
+
}
|
|
491
|
+
installAntigravity({
|
|
492
|
+
sourceRoot: path.resolve(__dirname, ".."),
|
|
493
|
+
homeDir: positional[0],
|
|
494
|
+
backupId: backupId || defaultBackupId(),
|
|
495
|
+
dryRun,
|
|
496
|
+
});
|
|
497
|
+
} catch (error) {
|
|
498
|
+
process.stderr.write(`${error.message}\n`);
|
|
499
|
+
process.exitCode = 1;
|
|
500
|
+
}
|
|
501
|
+
}
|