@coda-console/antigravity 1.3.3 → 1.4.1

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/README.md CHANGED
@@ -17,12 +17,12 @@ Coda 会把它存成回复正文,像答到一半出错,其实这一轮还在
17
17
  需要带会话指令兜底的 Coda(2026-11-13 部署版,coda#2500)或更新版本;旧版 Coda 不会给 Antigravity 送入会话指令。
18
18
 
19
19
  要求 Antigravity CLI **1.5.9 及以上**:`agy acp` 从 1.5.0 才有,Auto 模式与模式保持的修复在 1.5.4,上下文用量在 1.5.8;
20
- 插件的核对(握手、`--live`)都跑在 1.5.9 上。
20
+ 插件的核对(`--agent` 握手、`--live` 一轮)都跑在 1.5.9 上。
21
21
 
22
22
  ## 安装
23
23
 
24
24
  1. **运行机装 Antigravity CLI**:插件的设置动作(`scripts/setup.mjs`)在你安装或更新插件时于每台机器上运行:没有 `agy` 就用官方安装程序装上,
25
- 低于 1.5.9 就用 `agy update` 升级,新的不动;已有的 `agy` 跑不起来时只说明原因并失败,不替你删它。资源页「Antigravity」的「安装」也运行同一个设置动作。
25
+ 低于 1.5.9 就用 `agy update` 升级,新的不动;已有的 `agy` 跑不起来时只说明原因并失败,不替你删它。资源页「Antigravity」的「安装」是操作 `install`,指向同一个 `scripts/setup.mjs`(结果 `{}`,说明写在标准错误)。
26
26
  也可以自己装:
27
27
 
28
28
  ```sh
@@ -69,7 +69,7 @@ Coda 会把它存成回复正文,像答到一半出错,其实这一轮还在
69
69
  | skills | 读工作副本的 `.agents/skills`(清单的 `skillsDir`) |
70
70
  | 上下文占用、标题 | Antigravity 报 `usage_update` 与会话标题更新 |
71
71
  | 模型列表何时重读 | `~/.gemini/antigravity-cli/settings.json` 变了时 |
72
- | 资源页 | 登录后显示一条「Antigravity」,读数是各模型组的每周、每 5 小时剩余比例与重置时间(如「Gemini 每周」「Claude and GPT 5 小时」,组与周期按报告动态给出),最后是 CLI 版本。额度来自官方的只读报告 `agy -p /usage --output-format json`(CLI 1.1.11 起支持,插件要求 1.5.9 及以上):由 CLI 自己回答,不开会话、不花额度、不留对话,插件不读 token;这一次运行只设 `AGY_CLI_DISABLE_AUTO_UPDATE=true`,在系统临时目录里跑。整次读取给自己 25 秒(宿主只给 30 秒):版本和额度都只用剩下的时间并留 1 秒输出,剩下不到 3 秒就不再查额度,直接写「暂时无法获取额度:读取超时」,版本照旧显示。读数最多 8 条:额度最多 7 条,CLI 版本始终在最后。读不到额度(退出非 0、超时、报告不是成功、没有可显示的桶)时那一条带「暂时无法获取额度:原因」(原因是 CLI stderr 的首行,没有才写退出码;整句不超过 80 字,只截原因),版本照旧显示;缺比例、不在 0–1 内或标了 `disabled` 的桶不显示。登录状态只查钥匙串条目在不在(macOS 用 `security find-generic-password -s gemini -a antigravity`,只查条目,不读内容),也不读邮箱;钥匙串问不出来时读数失败,不当作登出(Linux 的细节见下) |
72
+ | 资源页 | 登录后显示一条「Antigravity」,读数是各模型组的每周、每 5 小时剩余比例与重置时间(如「Gemini 每周」「Claude and GPT 5 小时」,组与周期按报告动态给出),最后是 CLI 版本。额度来自官方的只读报告 `agy -p /usage --output-format json`(CLI 1.1.11 起支持,插件要求 1.5.9 及以上):由 CLI 自己回答,不开会话、不花额度、不留对话,插件不读 token;这一次运行只设 `AGY_CLI_DISABLE_AUTO_UPDATE=true`,在系统临时目录里跑。整次读取给自己 25 秒(宿主只给 30 秒):版本和额度都只用剩下的时间并留 1 秒输出,剩下不到 3 秒就不再查额度,命令失败,原因是「暂时无法获取额度:读取超时」。读数最多 8 条:额度最多 7 条,CLI 版本始终在最后。读不到额度(退出非 0、超时、报告不是成功、没有可显示的桶)时命令以非零退出,标准错误的最后一行是「暂时无法获取额度:原因」(原因是 CLI stderr 的首行,没有才写退出码),Coda 保留上一份记录,资源页显示「更新失败:原因」;缺比例、不在 0–1 内或标了 `disabled` 的桶不显示。登录状态只查钥匙串条目在不在(macOS 用 `security find-generic-password -s gemini -a antigravity`,只查条目,不读内容),也不读邮箱;钥匙串问不出来时命令同样以非零退出并写明原因,不当作登出(Linux 的细节见下)。记录命令是 `scripts/resource.mjs`,不定时(没有 `every`),资源页打开、点「刷新」和每个操作之后运行;登录了却找不到 CLI、或 CLI 低于所需版本时,记录照写:一行说明,登录与安装入口照常在;CLI 读不出版本则命令以非零退出。登录是操作 `sign-in`(`scripts/sign-in.mjs`):运行 `agy acp --login`,把它打印的授权链接用 `coda progress` 报给 Coda(只认完整的行,两路输出各自成行;报完才算登录结束,报失败登录就失败;20 秒内没有链接就失败,原因是那时 CLI 说的最后一行),再用 `coda ask` 要授权码、写进 CLI 的标准输入;CLI 已退出就不再问,码交出后 CLI 说的话不传出 |
73
73
 
74
74
  ## 已知限制
75
75
 
@@ -87,7 +87,7 @@ Coda 会把它存成回复正文,像答到一半出错,其实这一轮还在
87
87
  | Coda 的 MCP 工具在 auto 下也要审批 | 无人值守的子会话、流程步骤调用它们会停下;「全部放行」下不会。要在 auto 下放行,写法是在运行机的 `~/.gemini/antigravity-cli/settings.json` 里加 `{"permissions": {"allow": ["mcp(coda/*)"]}}`,出处是官方[权限文档](https://antigravity.google/docs/permissions/);插件不替你改这个文件 |
88
88
  | 压缩上下文不上报 Coda | Antigravity 会压缩上下文:`/compact` 在 `agy acp` 1.5.9 上实测会跑一次摘要,对话库里留下摘要步骤;二进制里也有按 token 阈值触发的压缩配置,自动压缩没有实测触发。但 ACP 流和 `acp-server` 日志都不报压缩(没有 `compaction_update`,也没有专门的通知或工具调用),唯一的痕迹在它私有的对话库里,入口不读它,也不从文本或用量反推。所以依赖压缩的功能(如 Ultra 压缩后重发说明)在它上面压缩后不生效 |
89
89
  | 额度耗尽 | 没有真实样本,不做失败分类,Coda 只看到 Antigravity 给的错误文字 |
90
- | 没有桌面会话的 Linux 登录 | 未实测:Linux 用 Secret Service(D-Bus),二进制里有「keyring 失败就落文件」的回退,但文件路径与触发条件没查清。资源页在 Linux 上用 `secret-tool lookup service gemini username antigravity` 查条目(属性名按 go-keyring 的写法,未在真机上试过),没有 `secret-tool`、查不到条目,或登录落在文件里时,资源页当作未登录(只是仍在「添加资源」里出现,会话不受影响)。装了 `secret-tool` 却联系不上 Secret Service(典型是没有会话 D-Bus 的无桌面机器,它带错误信息退出)时,资源页读数失败、保留上次的显示,首次读取就没有可保留的,也就无法从资源页添加:这样的机器在终端里运行 `agy acp --login` 登录 |
90
+ | 没有桌面会话的 Linux 登录 | 未实测:Linux 用 Secret Service(D-Bus),二进制里有「keyring 失败就落文件」的回退,但文件路径与触发条件没查清。资源页在 Linux 上用 `secret-tool lookup service gemini username antigravity` 查条目(属性名按 go-keyring 的写法,未在真机上试过),没有 `secret-tool`、查不到条目,或登录落在文件里时,资源页当作未登录(只是仍在「添加资源」里出现,会话不受影响)。装了 `secret-tool` 却联系不上 Secret Service(典型是没有会话 D-Bus 的无桌面机器,它带错误信息退出)时,资源页读取失败,原因是「读不了 Secret Service」,在这样的机器上要在终端里运行 `agy acp --login` 登录 |
91
91
  | 第三方模型 | 账号里的 Claude、GPT-OSS 未实测 |
92
92
  | 配置探测 | Coda 读模型、思考档位与模式的目录时,入口用插件状态目录里的缓存(`$CODA_PLUGIN_STATE/catalog-v1.json`)答一个只在当前连接有效的虚拟会话(`coda-probe:` 开头,不接受 prompt、不能恢复、断线即释放):**缓存命中时不建 Antigravity 会话**。缓存不按天数过期:距上次采集或比对满 1 小时后,下一次探测先跑一次 `agy models`(不建会话,约 2~3 秒,限时 8 秒),把它列出的模型(ID 与名称)和采集时记下的清单比对,一样就只记下比对时间(`catalog-v1.check.json`),不一样才重读;`agy models` 失败(未登录、断网、超时)时照旧用缓存,5 分钟后再比对,不因此重读;旧版插件留下的没有清单的缓存,在 `agy models` 第一次答上时重读一次。此外 agy 的路径或版本、`~/.gemini/antigravity-cli/settings.json` 变化、真实会话报的配置与缓存对不上时也重读。重读用一个独立的 `agy acp` 建一条空会话逐个模型读一遍(agy 1.5.9 删不了会话,这条会留在 `~/.gemini/antigravity-cli/conversations/`,会话 ID 记在 `catalog-v1.log`)。读失败时这次探测报错、不改用普通会话,同样的 agy 与设置 5 分钟内不再重读(未登录除外);比对发现变化而重读失败时照旧用原缓存答。要支持配置探测的新版 Coda 才生效;旧版 Coda 每次探测仍各建一条空会话 |
93
93
  | 并发进程 | 不加 `--process-per-session`:Coda 交给 Agent 的 MCP 服务器都是 stdio,官方只对 HTTP MCP 要求这个参数 |
@@ -95,8 +95,10 @@ Coda 会把它存成回复正文,像答到一半出错,其实这一轮还在
95
95
  ## 验收
96
96
 
97
97
  ```sh
98
- node bin/check.mjs plugins/antigravity # 握手:protocolVersion 1,session/new 给出会话与当前模型;资源读数合格式
99
- node bin/check.mjs plugins/antigravity --live # 一轮:会话指令、回复、取消、session/load
98
+ coda plugin check plugins/antigravity # 默认只读静态校验:清单、贡献点、BPMN 等,不执行插件代码
99
+ coda plugin check plugins/antigravity --resources # 执行资源记录命令,读数合格式
100
+ coda plugin check plugins/antigravity --agent # Agent 握手:protocolVersion 1,session/new 给出会话与当前模型
101
+ coda plugin check plugins/antigravity --agent --live # 完整对话轮次:会话指令、回复、取消、session/load
100
102
  ```
101
103
 
102
104
  然后在 Coda 里:发一句话收到回复;选 plan 出计划文件并停在审阅;选 default 跑一个要审批的命令,Mac 与 iPhone 都出卡片;选 auto 跑安全命令不再询问;选「全部放行」跑 `rm -rf`、写工作区外文件、调 MCP 工具都不出卡片,再切回 default 又出卡片;
package/package.json CHANGED
@@ -3,7 +3,10 @@
3
3
  "id": "antigravity",
4
4
  "displayName": "Antigravity",
5
5
  "description": "用 Antigravity CLI 跑会话",
6
- "version": "1.3.3",
6
+ "version": "1.4.1",
7
+ "engines": {
8
+ "coda": 6
9
+ },
7
10
  "categories": ["Agent"],
8
11
  "contributes": {
9
12
  "agents": [
@@ -29,21 +32,21 @@
29
32
  "setupHint": "请在「资源」里为运行机添加 Antigravity。"
30
33
  }
31
34
  ],
32
- "resources": [
35
+ "protocolImplementations": [
33
36
  {
34
- "id": "account",
35
- "title": "Antigravity",
36
- "command": "node \"$CODA_PLUGIN_PATH/scripts/resources.mjs\"",
37
- "maxAge": "PT5M",
38
- "signIn": {
39
- "command": "a=\"$HOME/.local/bin/agy\"; [ -x \"$a\" ] || a=agy; BROWSER=/usr/bin/true NO_COLOR=1 exec \"$a\" acp --login",
40
- "installed": "node \"$CODA_PLUGIN_PATH/scripts/setup.mjs\" --check",
41
- "install": "exec \"$CODA_NODE\" \"$CODA_PLUGIN_PATH/scripts/setup.mjs\"",
42
- "input": "authorizationCode",
43
- "note": "登录保存在这台机器的系统钥匙串里,由 Antigravity CLI 自己续期;用 Google 账号确认,把授权页给的授权码贴回来。"
37
+ "kind": "coda/resource@1",
38
+ "commands": {
39
+ "sign-in": "scripts/sign-in.mjs",
40
+ "install": "scripts/setup.mjs"
44
41
  }
45
42
  }
46
43
  ],
44
+ "records": [
45
+ {
46
+ "kind": "coda/resource@1",
47
+ "command": "scripts/resource.mjs"
48
+ }
49
+ ],
47
50
  "setup": {
48
51
  "command": "exec \"$CODA_NODE\" \"$CODA_PLUGIN_PATH/scripts/setup.mjs\""
49
52
  }
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ // The `coda/resource@1` record of the「Antigravity」type, printed once. No login here shows no resource (the type is then offered
3
+ // under「添加资源」); a login with the CLI gone, or older than the setup needs, is one row saying so, and the sign-in stays offered
4
+ // (it is how a machine without the CLI gets it). Shown with a login: the quota of each model group (the CLI's own read-only usage
5
+ // report, which opens no session and spends nothing) and the CLI's version. There is no cheap, reliable place for the email, so no
6
+ // account is shown. What cannot be read otherwise (a keychain that cannot be asked, a CLI that cannot say its version, a usage
7
+ // report that fails or has no quota) fails the command (exit 1, the reason on the last line of its standard error), which keeps
8
+ // the record Coda has.
9
+ import { agyBinary, asked, reading, signedIn } from './agy.mjs';
10
+ import { windows } from './quota.mjs';
11
+ import { MINIMUM, needed } from './setup.mjs';
12
+
13
+ // The whole reading gets 25 of the 30 seconds Coda allows, from here, so that it is printed, with the reason, rather than
14
+ // killed by Coda with nothing (agy.mjs `reading`: the version and the quota are asked what is left of it).
15
+ const deadline = Date.now() + 25_000;
16
+ const line = (text, max = 80) => [...text.replace(/\s+/g, ' ').trim()].slice(0, max).join('');
17
+ const fail = reason => { console.error(reason.replace(/\s+/g, ' ').trim()); process.exit(1); };
18
+ const problem = error => [{ name: 'Antigravity', values: [], buttons: [], error: line(error) }];
19
+ // Whether the CLI is installed: when it is there, runs and is not older than the setup needs.
20
+ const ready = binary => needed(binary, path => asked(path, Math.max(deadline - Date.now() - 1_000, 1))).action === 'none';
21
+ const print = (resources, installed) => console.log(JSON.stringify([{ key: 'account', spec: { type: 'account', title: 'Antigravity', resources,
22
+ signIn: { installed, installable: true, input: 'authorizationCode',
23
+ note: '登录保存在这台机器的系统钥匙串里,由 Antigravity CLI 自己续期;用 Google 账号确认,把授权页给的授权码贴回来。' } } }]));
24
+
25
+ const binary = agyBinary();
26
+ let login;
27
+ try { login = signedIn(); } catch (error) { fail(error.message); }
28
+ if (!login) { print([], ready(binary)); process.exit(0); }
29
+ if (!binary) { print(problem('这台机器上找不到 Antigravity CLI,请在运行机重新安装'), false); process.exit(0); }
30
+ const { version, tooOld, report, failure: why } = reading(binary, deadline, MINIMUM);
31
+ if (!version) fail(`读不出 Antigravity CLI 的版本(${binary})`);
32
+ if (why) fail(`暂时无法获取额度:${why}`);
33
+ const values = report ? windows(report) : [];
34
+ if (report && !values.length) fail('暂时无法获取额度:Antigravity CLI 没有给出额度');
35
+ // A reading lists 8 values at most: the version is always the last, after at most 7 of the quota.
36
+ print([{ name: 'Antigravity', values: [...values.slice(0, 7), { label: 'CLI 版本', value: version }], buttons: [],
37
+ ...(tooOld ? { error: `Antigravity CLI 低于所需的 ${MINIMUM},请重新安装插件或在运行机运行 agy update` } : {}) }], !tooOld);
package/scripts/setup.mjs CHANGED
@@ -1,10 +1,10 @@
1
- // The plugin's setup (`contributes.setup`), which Coda runs on each machine when the user installs or updates the plugin: it
2
- // ends well once the machine can run the agent. Without an Antigravity CLI, Google's installer puts the latest in
3
- // ~/.local/bin, where the agent looks first; one older than MINIMUM (the CLI the `agy acp` entry was checked against: the
1
+ #!/usr/bin/env node
2
+ // The plugin's setup (`contributes.setup`), which Coda runs on each machine when the user installs or updates the plugin, and the
3
+ // `install` operation of `coda/resource@1` (「安装」 on the resource page): it ends well once the machine can run the agent.
4
+ // Without an Antigravity CLI, Google's installer puts the latest in ~/.local/bin, where the agent looks first; one older than MINIMUM (the CLI the `agy acp` entry was checked against: the
4
5
  // subcommand is there from 1.5.0, Auto mode and keeping the mode from 1.5.4, context usage from 1.5.8) is brought up with its
5
6
  // own `agy update`; a newer one is kept. The installer does nothing where ~/.local/bin/agy exists, so a CLI that does not run
6
- // is never replaced: it is reported. Why the machine is not ready is said in one line on standard error.
7
- // `--check` only answers (exit 0) whether the machine is ready: the「Antigravity」type's `installed`.
7
+ // is never replaced: it is reported. Why the machine is not ready is said in one line on standard error; the result, when it is, is `{}`.
8
8
  import { spawnSync } from 'node:child_process';
9
9
  import { mkdtempSync, realpathSync, rmSync } from 'node:fs';
10
10
  import { homedir, tmpdir } from 'node:os';
@@ -28,7 +28,6 @@ export function needed(binary, run = asked) {
28
28
 
29
29
  if (process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))) {
30
30
  const before = needed(agyBinary());
31
- if (process.argv[2] === '--check') process.exit(before.action === 'none' ? 0 : 1);
32
31
  if (before.action === 'broken') { console.error(before.reason); process.exit(1); }
33
32
  if (before.action !== 'none') {
34
33
  // What the installer or the update prints goes to standard error with the rest of its story. The installer ends with
@@ -47,5 +46,6 @@ if (process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToP
47
46
  }
48
47
  const after = needed(agyBinary());
49
48
  if (after.action !== 'none') { console.error(after.reason); process.exit(1); }
50
- console.log(`Antigravity CLI ${after.version}`);
49
+ console.error(`Antigravity CLI ${after.version}`);
50
+ console.log('{}');
51
51
  }
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ // The「Antigravity」resource type's sign-in (the `sign-in` operation of `coda/resource@1`): `agy acp --login`, which prints
3
+ // the Google authorization link and waits for the code the page gives. This reports the link (`coda progress`), asks for the
4
+ // code (`coda ask`), once, and gives it to the CLI, which does the exchange and keeps and renews the credentials in the
5
+ // keychain. What the CLI says after the code is given is not passed on: it may carry the code.
6
+ import { execFile, spawn } from 'node:child_process';
7
+ import { resolve } from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { stripVTControlCharacters } from 'node:util';
10
+ import { agyBinary } from './agy.mjs';
11
+
12
+ // The authorization link a stream printed: the first on a whole line (output arrives in pieces, and a link cut short is not
13
+ // the link), terminal hyperlinks included.
14
+ export function authorizationLink(output) {
15
+ const lines = stripVTControlCharacters(output.slice(0, output.lastIndexOf('\n') + 1));
16
+ try { return new URL(lines.match(/https:\/\/[^\s]+/)?.[0]); } catch { return null; }
17
+ }
18
+
19
+ // Coda's own command: what it prints, or why it failed (its last line).
20
+ const coda = (...args) => new Promise((done, fail) => execFile('coda', args, (error, stdout, stderr) =>
21
+ error ? fail(new Error(stderr.trim().split('\n').at(-1) || error.message)) : done(stdout)));
22
+ const lastLine = text => stripVTControlCharacters(text).split('\n').map(line => line.trim()).filter(Boolean).at(-1);
23
+
24
+ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
25
+ const binary = agyBinary();
26
+ if (!binary) { console.error('找不到 Antigravity CLI'); process.exit(1); }
27
+ const child = spawn(binary, ['acp', '--login'], { env: { ...process.env, BROWSER: '/usr/bin/true', NO_COLOR: '1' }, stdio: ['pipe', 'pipe', 'pipe'] });
28
+ child.stdin.on('error', () => {});
29
+ // What each stream said, kept apart (a line is read from one stream only), and which spoke last.
30
+ const said = { stdout: '', stderr: '' };
31
+ let latest = 'stdout', url = null, reporting = Promise.resolve(), exited = false, submitted = false, failed = null;
32
+ // The first reason stays: what the CLI says when it is ended for it is not the reason.
33
+ const fail = message => { failed ??= message; child.kill(); };
34
+ // Without a link in 20 seconds, the login is over with what the CLI said last.
35
+ const silent = setTimeout(() => fail(lastLine(said[latest]) || '登录没有完成,请重新登录。'), 20_000);
36
+ // What the CLI says is kept until the code is given to it: after that it may carry the code.
37
+ const heard = name => chunk => {
38
+ if (submitted) return;
39
+ said[name] = (said[name] + chunk).slice(-8000); latest = name;
40
+ if (url) return;
41
+ url = authorizationLink(said[name]);
42
+ if (!url) return;
43
+ clearTimeout(silent);
44
+ reporting = coda('progress', JSON.stringify({ url: url.href })).catch(error => fail(error.message));
45
+ reporting.then(async () => {
46
+ // A CLI that has ended is not asked for a code: its last line is the reason.
47
+ if (failed || exited) return;
48
+ const { code } = JSON.parse(await coda('ask', JSON.stringify({ input: 'authorizationCode' })));
49
+ submitted = true;
50
+ child.stdin.write(`${code.trim()}\n`);
51
+ }).catch(error => fail(error.message));
52
+ };
53
+ for (const name of ['stdout', 'stderr']) child[name].setEncoding('utf8').on('data', heard(name));
54
+ child.on('error', () => { failed ??= 'Antigravity CLI 没能启动'; });
55
+ child.on('exit', () => { exited = true; });
56
+ // Coda ends the whole group; one ended alone takes its CLI along.
57
+ for (const signal of ['SIGTERM', 'SIGINT']) process.on(signal, () => { child.kill(); process.exit(1); });
58
+ child.on('close', async code => {
59
+ clearTimeout(silent);
60
+ await reporting;
61
+ if (code === 0 && !failed) { console.log('{}'); process.exit(0); }
62
+ console.error(failed ?? (submitted ? null : lastLine(said[latest])) ?? '登录没有完成,请重新登录。');
63
+ process.exit(1);
64
+ });
65
+ }
@@ -1,28 +0,0 @@
1
- // The「Antigravity」resources, printed once as `{ resources }`. No login here shows nothing (the type is then offered under
2
- // 「添加资源」); a keychain that cannot be asked fails the reading, which keeps the last one shown. Shown: the quota of each
3
- // model group (the CLI's own read-only usage report, which opens no session and spends nothing; or why it is not had) and the
4
- // CLI's version. There is no cheap, reliable place for the email, so no account is shown.
5
- import { agyBinary, reading, signedIn } from './agy.mjs';
6
- import { windows } from './quota.mjs';
7
- import { MINIMUM } from './setup.mjs';
8
-
9
- // The whole reading gets 25 of the 30 seconds Coda allows, from here, so that it is printed, with the reason, rather than
10
- // killed by Coda with nothing (agy.mjs `reading`: the version and the quota are asked what is left of it).
11
- const deadline = Date.now() + 25_000;
12
- const print = value => console.log(JSON.stringify(value));
13
- let login;
14
- try { login = signedIn(); } catch (error) { console.error(error.message); process.exit(1); }
15
- if (!login) { print({ resources: [] }); process.exit(0); }
16
- const binary = agyBinary();
17
- if (!binary) { print({ resources: [{ name: 'Antigravity', error: '这台机器上找不到 Antigravity CLI,请在运行机重新安装' }] }); process.exit(0); }
18
- const { version, tooOld, report, failure: why } = reading(binary, deadline, MINIMUM);
19
- if (!version) { console.error(`读不出 Antigravity CLI 的版本(${binary})`); process.exit(1); }
20
- const values = report ? windows(report) : [];
21
- const failure = why ?? (report && !values.length ? 'Antigravity CLI 没有给出额度' : null);
22
- const line = (text, max = 80) => [...text.replace(/\s+/g, ' ').trim()].slice(0, max).join('');
23
- // A reading lists 8 values at most: the version is always the last, after at most 7 of the quota. Only the reason is cut to
24
- // what the 80 characters leave after「暂时无法获取额度:」.
25
- const WHY = '暂时无法获取额度:';
26
- print({ resources: [{ name: 'Antigravity', values: [...values.slice(0, 7), { label: 'CLI 版本', value: version }],
27
- ...(tooOld ? { error: `Antigravity CLI 低于所需的 ${MINIMUM},请重新安装插件或在运行机运行 agy update` }
28
- : failure ? { error: WHY + line(failure, 80 - WHY.length) } : {}) }] });