@kyun.si/agy-polish 0.0.4-beta.8 → 0.0.4-beta.9
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 +2 -0
- package/package.json +1 -1
- package/plugins/agy-polish/plugin.json +1 -1
- package/plugins/agy-polish/rules/AGENTS.md +2 -2
- package/plugins/agy-polish/scripts/mcp-server.mjs +6 -3
- package/plugins/agy-polish/scripts/mode-hook-config.mjs +69 -16
- package/plugins/agy-polish/scripts/mode-hook.mjs +9 -0
- package/plugins/agy-polish/scripts/polish-reply.mjs +2 -2
- package/plugins/agy-polish/scripts/settings.mjs +11 -7
- package/plugins/agy-polish/scripts/terminal-draft.mjs +22 -0
- package/scripts/agy-cli.mjs +7 -2
package/README.md
CHANGED
|
@@ -16,6 +16,8 @@ Setup starts with **Manual · polish only when asked**. In Manual the mode hook
|
|
|
16
16
|
|
|
17
17
|
Start a new `agy` chat and try `/polish Rewrite the previous reply in two sentences.` If Antigravity asks for permission, allow the `polish_reply` tool.
|
|
18
18
|
|
|
19
|
+
In a terminal, Normal and Turbo show the original draft before automatic polishing, then display the rewrite if it changes. If you decline the tool request, the original draft is already visible.
|
|
20
|
+
|
|
19
21
|
For a full reply rewrite, your Codex provider receives the current draft, its question and your editing directions. For a selected passage, it receives just that passage and the relevant directions.
|
|
20
22
|
|
|
21
23
|
## Maintenance
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agy-polish",
|
|
3
3
|
"displayName": "AGY Polish · 回复润色",
|
|
4
|
-
"version": "0.0.4-beta.
|
|
4
|
+
"version": "0.0.4-beta.9",
|
|
5
5
|
"description": "Polish Antigravity replies with your local Codex CLI. 用本机 Codex CLI 润色 Antigravity 的回复。",
|
|
6
6
|
"author": { "name": "mreasonyang" },
|
|
7
7
|
"repository": "https://github.com/mreasonyang/agent-polish",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Reply polishing
|
|
2
2
|
|
|
3
|
-
Answer the user normally, including doing any requested work. On an ordinary question, use only the Codex Polish mode message for **this user turn**. In Normal or Turbo, finish the complete Gemini draft
|
|
3
|
+
Answer the user normally, including doing any requested work. On an ordinary question, use only the Codex Polish mode message for **this user turn**. In Normal or Turbo, finish the complete Gemini draft, then call the `polish_reply` MCP tool from the agy-polish plugin once with the current user question, the complete draft, and `trigger: "auto"`. Publish the draft before calling the tool only when the current-turn mode message requests a visible draft in the interactive terminal. With no current-turn mode message (the default), or in Manual, send ordinary answers directly. Never call the MCP tool or run a command to determine the mode for an ordinary answer. On an explicit polishing request, including a standalone “说人话”, follow the polish skill even when the hook is disabled.
|
|
4
4
|
|
|
5
5
|
- In Off, never invoke Codex or the `polish_reply` MCP tool for reply polishing. If the request only asks to polish supplied text or an identifiable previous reply, return the original text or complete reply verbatim, preserving leading and trailing whitespace, line breaks, Markdown, and code. Do not rewrite it yourself or add anything to it, even if the user specifies edits. If `/polish` accompanies a new question or task, answer it normally and send the answer directly.
|
|
6
6
|
- Use `trigger: "explicit"` when the user asks to polish or invokes `/polish`. A standalone “说人话” asks to rewrite the previous assistant reply in plain language. Pass that reply verbatim as `draft` and the user's wording as `rewrite_request`. Follow the polish skill for a prior reply or a selected passage. Ordinary requests to edit a file or write content are not explicit requests to polish the chat reply.
|
|
7
7
|
- For “配置回复润色”, “configure reply polishing”, or requests to view or change **reply polishing** mode, Codex model, or thinking level, use the `polish-settings` skill. Send the settings answer directly. Unrelated Antigravity settings remain ordinary host settings.
|
|
8
8
|
- Skip polishing when the user asks to cancel, skip polishing, keep the turn private, use Gemini only, or avoid sharing the material with another model or service. Also skip it for exact-format or verbatim responses, such as a JSON-only answer, literal transcription, or a raw command. A request for prose with no preamble or extra commentary still permits polishing. Follow these instructions even in Turbo and on an explicit turn. When uncertain about permission to share, keep the Gemini response.
|
|
9
|
-
- Send only the current question, the final draft, and explicitly requested editing instructions.
|
|
9
|
+
- Send only the current question, the final draft, and explicitly requested editing instructions. Use the tool's full text as the final reply verbatim, preserving the language, Markdown, code, and whitespace. On tool errors, unavailability, cancellation, or if the tool returns no usable body, keep the Gemini draft and never retry in the same turn. If the original draft is already visible and no usable rewrite was returned, end the turn without repeating the draft. If the turn itself is cancelled, stop.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
2
3
|
import manifest from '../plugin.json' with { type: 'json' };
|
|
3
4
|
import { polishInputSchema, polishReply, validInput } from './polish-reply.mjs';
|
|
5
|
+
import { eagerPolishAvailable } from './mode-hook-config.mjs';
|
|
4
6
|
|
|
5
7
|
const versions = ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05'];
|
|
6
8
|
const tool = {
|
|
@@ -8,6 +10,7 @@ const tool = {
|
|
|
8
10
|
description: 'Polish one complete Antigravity draft with the local Codex CLI when the current polishing settings permit it. The response text is the entire final reply, or the original draft unchanged if skipped or unsuccessful.',
|
|
9
11
|
inputSchema: polishInputSchema
|
|
10
12
|
};
|
|
13
|
+
const available = () => eagerPolishAvailable(dirname(import.meta.dirname), process.argv.slice(2));
|
|
11
14
|
|
|
12
15
|
const active = new Map();
|
|
13
16
|
const lines = createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
@@ -25,7 +28,7 @@ async function call(id, input) {
|
|
|
25
28
|
const controller = new AbortController();
|
|
26
29
|
active.set(id, controller);
|
|
27
30
|
try {
|
|
28
|
-
const text = await polishReply(input, { signal: controller.signal });
|
|
31
|
+
const text = await polishReply(input, { signal: controller.signal, available });
|
|
29
32
|
if (!controller.signal.aborted) write({ id, result: { content: [{ type: 'text', text }] } });
|
|
30
33
|
} finally {
|
|
31
34
|
active.delete(id);
|
|
@@ -68,10 +71,10 @@ lines.on('line', (line) => {
|
|
|
68
71
|
write({ id, result: {} });
|
|
69
72
|
break;
|
|
70
73
|
case 'tools/list':
|
|
71
|
-
write({ id, result: { tools: [tool] } });
|
|
74
|
+
write({ id, result: { tools: available() ? [tool] : [] } });
|
|
72
75
|
break;
|
|
73
76
|
case 'tools/call':
|
|
74
|
-
if (params?.name !== tool.name || !validInput(params.arguments)) {
|
|
77
|
+
if (!available() || params?.name !== tool.name || !validInput(params.arguments)) {
|
|
75
78
|
fail(id, -32602, 'Invalid polish_reply arguments');
|
|
76
79
|
} else {
|
|
77
80
|
void call(id, params.arguments);
|
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { chmodSync, lstatSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { join } from 'node:path';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
4
5
|
|
|
5
6
|
const group = 'agy-polish-mode';
|
|
7
|
+
const server = 'agy-polish_agy-polish';
|
|
8
|
+
const managedFlag = '--agy-polish-eager';
|
|
6
9
|
export const automaticMode = mode => mode === 'normal' || mode === 'turbo';
|
|
7
10
|
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
11
|
-
|
|
11
|
+
function readJson(path, allowEmpty = false) {
|
|
12
|
+
const entry = lstatSync(path);
|
|
13
|
+
if (!entry.isFile()) throw new Error('Expected a regular Antigravity configuration file');
|
|
14
|
+
const raw = readFileSync(path, 'utf8');
|
|
15
|
+
const data = allowEmpty && !raw.trim() ? {} : JSON.parse(raw);
|
|
16
|
+
if (!data || typeof data !== 'object' || Array.isArray(data)) throw new Error('Invalid Antigravity configuration');
|
|
17
|
+
return { data, mode: entry.mode & 0o777 };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function writeJson(path, data, mode) {
|
|
21
|
+
const temp = join(dirname(path), '.agy-polish-' + randomUUID() + '.tmp');
|
|
22
|
+
try {
|
|
23
|
+
writeFileSync(temp, JSON.stringify(data, null, 2) + '\n', { flag: 'wx', mode });
|
|
24
|
+
chmodSync(temp, mode);
|
|
25
|
+
renameSync(temp, path);
|
|
26
|
+
} finally {
|
|
27
|
+
rmSync(temp, { force: true });
|
|
28
|
+
}
|
|
12
29
|
}
|
|
13
30
|
|
|
14
31
|
export function savedModeHook(root) {
|
|
15
32
|
try {
|
|
16
|
-
const enabled =
|
|
33
|
+
const enabled = readJson(join(root, 'hooks.json')).data[group]?.enabled;
|
|
17
34
|
if (enabled !== undefined && typeof enabled !== 'boolean') throw new Error('Invalid mode hook setting');
|
|
18
35
|
return enabled;
|
|
19
36
|
} catch (error) {
|
|
@@ -24,19 +41,55 @@ export function savedModeHook(root) {
|
|
|
24
41
|
|
|
25
42
|
// Write only the plugin's own hook, preserving the other declarations and file permissions.
|
|
26
43
|
export function setModeHook(root, enabled) {
|
|
27
|
-
const
|
|
44
|
+
const path = join(root, 'hooks.json');
|
|
45
|
+
const { data: hooks, mode } = readJson(path);
|
|
28
46
|
const previous = hooks[group].enabled;
|
|
29
47
|
if (previous === enabled) return previous;
|
|
30
48
|
hooks[group].enabled = enabled;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
writeJson(path, hooks, mode);
|
|
50
|
+
return previous;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// AgY 1.5.21 applies eager tool preferences from the profile MCP configuration.
|
|
54
|
+
// Use the bundled server's exact name so the existing per-tool permission still applies.
|
|
55
|
+
export function setEagerPolishTool(root, enabled) {
|
|
56
|
+
const profile = dirname(dirname(root));
|
|
57
|
+
const file = join(profile, 'mcp_config.json');
|
|
58
|
+
let data, mode;
|
|
34
59
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
60
|
+
// Antigravity can create this file with no initial contents.
|
|
61
|
+
({ data, mode } = readJson(file, true));
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (!enabled) return;
|
|
64
|
+
if (error.code !== 'ENOENT') throw error;
|
|
65
|
+
data = {};
|
|
66
|
+
mode = 0o600;
|
|
67
|
+
}
|
|
68
|
+
const servers = Object.hasOwn(data, 'mcpServers') ? data.mcpServers : {};
|
|
69
|
+
if (!servers || typeof servers !== 'object' || Array.isArray(servers)) {
|
|
70
|
+
if (!enabled) return;
|
|
71
|
+
throw new Error('Invalid Antigravity MCP servers');
|
|
72
|
+
}
|
|
73
|
+
const args = [join(root, 'scripts', 'mcp-server.mjs'), managedFlag];
|
|
74
|
+
const existing = servers[server];
|
|
75
|
+
const managed = existing?.command === 'node' && isDeepStrictEqual(existing.args, args);
|
|
76
|
+
if (enabled) {
|
|
77
|
+
if (Object.hasOwn(servers, server)) return;
|
|
78
|
+
servers[server] = { command: 'node', args, tools: { polish_reply: { eager: true } } };
|
|
79
|
+
} else {
|
|
80
|
+
if (!managed) return;
|
|
81
|
+
delete servers[server];
|
|
82
|
+
}
|
|
83
|
+
data.mcpServers = servers;
|
|
84
|
+
writeJson(file, data, mode);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function eagerPolishAvailable(root, argv) {
|
|
88
|
+
if (!argv.includes(managedFlag)) return true;
|
|
89
|
+
try {
|
|
90
|
+
const { data } = readJson(join(dirname(dirname(root)), 'config.json'));
|
|
91
|
+
return data.plugins?.['agy-polish']?.enabled === true && savedModeHook(root) === true;
|
|
92
|
+
} catch {
|
|
93
|
+
return false;
|
|
40
94
|
}
|
|
41
|
-
return previous;
|
|
42
95
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { readSettings } from './settings.mjs';
|
|
3
|
+
import { showsTerminalDraft } from './terminal-draft.mjs';
|
|
3
4
|
|
|
4
5
|
const instructions = {
|
|
5
6
|
normal: 'On an eligible ordinary turn call polish_reply once with trigger auto. On an explicit polishing turn use trigger explicit.',
|
|
@@ -11,6 +12,11 @@ const instructions = {
|
|
|
11
12
|
'If /polish accompanies a new question or task, answer it normally and deliver the answer directly.'
|
|
12
13
|
};
|
|
13
14
|
|
|
15
|
+
const terminalDraft = 'For automatic polishing in this interactive terminal, first send the complete draft as visible assistant text before making the tool call. ' +
|
|
16
|
+
'Label that message “Original draft” in the user’s language. Pass the same draft text without the label to polish_reply with trigger auto. ' +
|
|
17
|
+
'After a successful edit, send the returned rewrite verbatim. If the call fails or returns the original draft, end the turn without repeating the draft. ' +
|
|
18
|
+
'Use the usual workflow for explicit polishing requests and for turns that should skip polishing.';
|
|
19
|
+
|
|
14
20
|
function modeContext() {
|
|
15
21
|
const input = JSON.parse(readFileSync(0, 'utf8'));
|
|
16
22
|
// ProtoJSON may omit the initial, zero-valued invocation number.
|
|
@@ -22,6 +28,9 @@ function modeContext() {
|
|
|
22
28
|
// Treat unavailable settings as off for this turn.
|
|
23
29
|
}
|
|
24
30
|
let guidance = instructions[mode];
|
|
31
|
+
if ((mode === 'normal' || mode === 'turbo') && showsTerminalDraft(input.artifactDirectoryPath)) {
|
|
32
|
+
guidance += ' ' + terminalDraft;
|
|
33
|
+
}
|
|
25
34
|
if (typeof input.lastUserInput === 'string' && /^说人话[。!.!]*$/u.test(input.lastUserInput.trim())) {
|
|
26
35
|
guidance = mode === 'off'
|
|
27
36
|
? 'For this request, return the previous assistant reply verbatim. Do not call polish_reply or invoke Codex.'
|
|
@@ -129,7 +129,7 @@ export function validInput(input) {
|
|
|
129
129
|
(input.selection === undefined || (typeof input.selection === 'string' && !!input.selection.trim()));
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
export async function polishReply(input, { signal, timeout = 90_000 } = {}) {
|
|
132
|
+
export async function polishReply(input, { signal, timeout = 90_000, available = () => true } = {}) {
|
|
133
133
|
if (!validInput(input)) return typeof input?.draft === 'string' ? input.draft : '';
|
|
134
134
|
const { draft, question, trigger, rewrite_request, selection } = input;
|
|
135
135
|
try {
|
|
@@ -147,7 +147,7 @@ export async function polishReply(input, { signal, timeout = 90_000 } = {}) {
|
|
|
147
147
|
const reply = await withWorkspace((workspace) => editWithCodex(workspace, { signal, timeout }, outputSchema, () => {
|
|
148
148
|
// Provider and credential lookup can take time. Read the current preferences at dispatch.
|
|
149
149
|
const { mode, model, effort } = readSettings();
|
|
150
|
-
if (signal?.aborted || mode === 'off' || (mode === 'manual' && initialMode !== 'manual')) return;
|
|
150
|
+
if (signal?.aborted || !available() || mode === 'off' || (mode === 'manual' && initialMode !== 'manual')) return;
|
|
151
151
|
return { model, effort, prompt: promptFor(input, mode, selected) };
|
|
152
152
|
}));
|
|
153
153
|
if (reply === undefined || signal?.aborted) return draft;
|
|
@@ -8,7 +8,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
8
8
|
import { withWorkspace } from './codex-process.mjs';
|
|
9
9
|
import { withCodexAppServer } from './codex-provider.mjs';
|
|
10
10
|
import { withLock } from './directory-lock.mjs';
|
|
11
|
-
import { automaticMode, setModeHook } from './mode-hook-config.mjs';
|
|
11
|
+
import { automaticMode, setEagerPolishTool, setModeHook } from './mode-hook-config.mjs';
|
|
12
12
|
|
|
13
13
|
const MODES = ['normal', 'turbo', 'manual', 'off'];
|
|
14
14
|
export const DEFAULT_MODEL = 'gpt-6.2-sol';
|
|
@@ -72,7 +72,7 @@ function replaceSettings(source, destination) {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
export async function writeSettings(patch, hookRoot) {
|
|
75
|
+
export async function writeSettings(patch, hookRoot, profileInstall = false) {
|
|
76
76
|
if (patch === null || typeof patch !== 'object' || Array.isArray(patch)) {
|
|
77
77
|
throw new Error('Invalid polishing settings patch');
|
|
78
78
|
}
|
|
@@ -89,16 +89,20 @@ export async function writeSettings(patch, hookRoot) {
|
|
|
89
89
|
mkdirSync(writer, { recursive: true, mode: 0o700 });
|
|
90
90
|
return withLock(writer, () => {
|
|
91
91
|
// Store the choice itself so changing only the model can use that model's default effort.
|
|
92
|
-
const
|
|
92
|
+
const current = readDocument(file);
|
|
93
|
+
const document = { ...EMPTY_SETTINGS, ...current, ...patch };
|
|
93
94
|
const settings = preferences(document);
|
|
94
95
|
const stage = join(writer, randomUUID() + '.tmp');
|
|
95
96
|
try {
|
|
96
97
|
writeFileSync(stage, JSON.stringify(document, null, 2) + '\n', { flag: 'wx', mode: 0o600 });
|
|
97
|
-
const
|
|
98
|
+
const auto = automaticMode(settings.mode);
|
|
99
|
+
const previous = hookRoot && setModeHook(hookRoot, auto);
|
|
98
100
|
try {
|
|
101
|
+
if (profileInstall) setEagerPolishTool(hookRoot, auto);
|
|
99
102
|
replaceSettings(stage, file);
|
|
100
103
|
} catch (error) {
|
|
101
104
|
if (hookRoot) setModeHook(hookRoot, previous);
|
|
105
|
+
if (profileInstall) setEagerPolishTool(hookRoot, previous === true && automaticMode(current.mode));
|
|
102
106
|
throw error;
|
|
103
107
|
}
|
|
104
108
|
return settings;
|
|
@@ -112,10 +116,10 @@ function setFromChat(patch) {
|
|
|
112
116
|
const root = dirname(import.meta.dirname);
|
|
113
117
|
const profile = dirname(dirname(root));
|
|
114
118
|
// Only change the active plugin's installed copy. Source checkouts and npm packages are immutable.
|
|
115
|
-
const
|
|
116
|
-
|
|
119
|
+
const profileInstall = basename(profile) === 'config' && basename(dirname(profile)) === '.gemini';
|
|
120
|
+
const installed = basename(dirname(root)) === 'plugins' && (basename(profile) === '.agents' || profileInstall);
|
|
117
121
|
if (!patch.mode || !installed) return writeSettings(patch);
|
|
118
|
-
return withLock(profile, () => writeSettings(patch, root));
|
|
122
|
+
return withLock(profile, () => writeSettings(patch, root, profileInstall));
|
|
119
123
|
}
|
|
120
124
|
|
|
121
125
|
export async function listModels({ signal, timeout = 20_000 } = {}) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { closeSync, openSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, isAbsolute } from 'node:path';
|
|
3
|
+
import { isatty } from 'node:tty';
|
|
4
|
+
|
|
5
|
+
function hasControllingTerminal() {
|
|
6
|
+
// Hook stdin and stdout are pipes even when the host is interactive.
|
|
7
|
+
let fd;
|
|
8
|
+
try {
|
|
9
|
+
fd = openSync(process.platform === 'win32' ? '\\\\.\\CONIN$' : '/dev/tty', 'r');
|
|
10
|
+
return isatty(fd);
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
} finally {
|
|
14
|
+
if (fd !== undefined) closeSync(fd);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function showsTerminalDraft(artifactDirectoryPath, hasTerminal = hasControllingTerminal) {
|
|
19
|
+
if (typeof artifactDirectoryPath !== 'string' || !isAbsolute(artifactDirectoryPath)) return false;
|
|
20
|
+
const brain = dirname(artifactDirectoryPath);
|
|
21
|
+
return basename(brain) === 'brain' && basename(dirname(brain)) === 'antigravity-cli' && hasTerminal();
|
|
22
|
+
}
|
package/scripts/agy-cli.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
AgyInstallError, agyProfile, requireAgyCli, installedAgy, validateAgyBundle,
|
|
13
13
|
changeAgyPlugin, installAgyPlugin, loadAgySettings, checkCodexProvider
|
|
14
14
|
} from './agy_install.mjs';
|
|
15
|
-
import { automaticMode, savedModeHook } from '../plugins/agy-polish/scripts/mode-hook-config.mjs';
|
|
15
|
+
import { automaticMode, savedModeHook, setEagerPolishTool } from '../plugins/agy-polish/scripts/mode-hook-config.mjs';
|
|
16
16
|
|
|
17
17
|
const fail = (zh, en) => new AgyInstallError(tr(zh, en));
|
|
18
18
|
|
|
@@ -196,6 +196,7 @@ async function runAgyHost(action, plan, installDependency, lang, hook) {
|
|
|
196
196
|
if (action === 'uninstall') {
|
|
197
197
|
if (before) changeAgyPlugin('uninstall');
|
|
198
198
|
if (installedAgy()) throw fail('agy 仍显示插件已安装,请再试一次卸载。', 'agy still lists the plugin as installed. Run uninstall again.');
|
|
199
|
+
setEagerPolishTool(before?.path ?? join(profile, 'plugins', 'agy-polish'), false);
|
|
199
200
|
console.log(t('agy-polish 已卸载,模式和模型设置已保留。', 'agy-polish is uninstalled. Your mode and model settings were kept.'));
|
|
200
201
|
return null;
|
|
201
202
|
}
|
|
@@ -210,8 +211,10 @@ async function runAgyHost(action, plan, installDependency, lang, hook) {
|
|
|
210
211
|
'This package is older than the installed agy-polish. Use a newer package.');
|
|
211
212
|
}
|
|
212
213
|
const previousHook = hook === undefined && before && !plan?.patch.mode ? savedModeHook(before.path) : undefined;
|
|
214
|
+
const auto = hook !== 'off' && (hook === 'on' || previousHook !== false) &&
|
|
215
|
+
automaticMode(plan?.mode ?? (await loadAgySettings()).current.mode);
|
|
213
216
|
const hookEnabled = hook === undefined
|
|
214
|
-
? previousHook ??
|
|
217
|
+
? previousHook ?? auto
|
|
215
218
|
: hook === 'on';
|
|
216
219
|
// Persist a fresh install's selected mode before agy can load the plugin.
|
|
217
220
|
if (!before) await save();
|
|
@@ -226,6 +229,8 @@ async function runAgyHost(action, plan, installDependency, lang, hook) {
|
|
|
226
229
|
'agy did not confirm the plugin version and enabled state. Check the installation in Antigravity.');
|
|
227
230
|
}
|
|
228
231
|
if (before) await save();
|
|
232
|
+
try { setEagerPolishTool(entry.path, hookEnabled && auto); }
|
|
233
|
+
catch { throw fail('无法写入 Antigravity 的 MCP 设置,请检查 mcp_config.json。', 'Could not update Antigravity MCP settings. Check mcp_config.json.'); }
|
|
229
234
|
console.log(action === 'update'
|
|
230
235
|
? t('agy-polish 已更新到 ', 'Updated agy-polish to ') + version
|
|
231
236
|
: t('agy-polish 已安装,版本 ', 'agy-polish is installed, version ') + version);
|