@kyun.si/agy-polish 0.0.4-beta.7 → 0.0.4-beta.8

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
@@ -12,7 +12,7 @@ npx @kyun.si/agy-polish@beta setup
12
12
 
13
13
  In Windows PowerShell, use `npx.cmd` in place of `npx`.
14
14
 
15
- Setup starts with **Manual · polish only when asked**. Press Enter to keep it, or select Normal, Turbo, or Off. AGY Polish uses `gpt-6.2-sol` with Extra High reasoning (`xhigh`) by default. In setup, you can also follow your local Codex settings or choose a model and reasoning effort from your provider. Run `setup` again to change your choices, or use `/polish-settings` in Antigravity.
15
+ Setup starts with **Manual · polish only when asked**. In Manual the mode hook defaults to off. Explicit edits such as “说人话” still work. Choosing Normal or Turbo enables the mode hook for automatic edits. Off also skips explicit rewrites. AGY Polish uses `gpt-6.2-sol` with Extra High reasoning (`xhigh`) by default. In setup, you can also follow your local Codex settings or choose a model and reasoning effort from your provider. Run `setup` again to change your choices, or use `/polish-settings` in Antigravity.
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
 
@@ -26,6 +26,6 @@ npx @kyun.si/agy-polish@beta update
26
26
  npx @kyun.si/agy-polish@beta uninstall
27
27
  ```
28
28
 
29
- AGY Polish keeps your mode and model settings when you update or uninstall the plugin.
29
+ Use `update --hook on` or `update --hook off` to change just the mode hook. Start a new chat after changing it. AGY Polish keeps your mode and model settings when you update or uninstall the plugin.
30
30
 
31
31
  [Agent Polish source and documentation](https://github.com/mreasonyang/agent-polish) · [Apache-2.0 License](LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kyun.si/agy-polish",
3
- "version": "0.0.4-beta.7",
3
+ "version": "0.0.4-beta.8",
4
4
  "description": "Polish Antigravity replies with Codex · 用 Codex 润色 Antigravity 回复",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "agy-polish-mode": {
3
+ "enabled": false,
3
4
  "PreInvocation": [
4
5
  { "type": "command", "command": "node ./scripts/mode-hook.mjs", "timeout": 3 }
5
6
  ]
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agy-polish",
3
3
  "displayName": "AGY Polish · 回复润色",
4
- "version": "0.0.4-beta.7",
4
+ "version": "0.0.4-beta.8",
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,6 +1,6 @@
1
1
  # Reply polishing
2
2
 
3
- Answer the user normally, including doing any requested work. Use the latest Codex Polish mode message for this user turn. In Normal or Turbo, finish the complete Gemini draft before publishing, then call the `polish_reply` MCP tool from the agy-polish plugin once with the current user question, the complete draft, and `trigger: "auto"`. In Manual (Only when asked), send ordinary answers directly and use the tool only for explicit polishing requests. If the current-turn mode message is missing, answer directly. Never call the MCP tool or run a command to determine the mode for an ordinary answer.
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 before publishing, then call the `polish_reply` MCP tool from the agy-polish plugin once with the current user question, the complete draft, and `trigger: "auto"`. 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.
@@ -0,0 +1,42 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { chmodSync, lstatSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+
5
+ const group = 'agy-polish-mode';
6
+ export const automaticMode = mode => mode === 'normal' || mode === 'turbo';
7
+
8
+ function readHooks(root) {
9
+ const path = join(root, 'hooks.json');
10
+ if (!lstatSync(path).isFile()) throw new Error('Expected a regular Antigravity hooks.json');
11
+ return JSON.parse(readFileSync(path, 'utf8'));
12
+ }
13
+
14
+ export function savedModeHook(root) {
15
+ try {
16
+ const enabled = readHooks(root)[group]?.enabled;
17
+ if (enabled !== undefined && typeof enabled !== 'boolean') throw new Error('Invalid mode hook setting');
18
+ return enabled;
19
+ } catch (error) {
20
+ if (error.code === 'ENOENT') return undefined;
21
+ throw error;
22
+ }
23
+ }
24
+
25
+ // Write only the plugin's own hook, preserving the other declarations and file permissions.
26
+ export function setModeHook(root, enabled) {
27
+ const hooks = readHooks(root);
28
+ const previous = hooks[group].enabled;
29
+ if (previous === enabled) return previous;
30
+ hooks[group].enabled = enabled;
31
+ const path = join(root, 'hooks.json');
32
+ const temp = join(root, '.hooks-' + randomUUID() + '.tmp');
33
+ const mode = lstatSync(path).mode & 0o777;
34
+ try {
35
+ writeFileSync(temp, JSON.stringify(hooks, null, 2) + '\n', { flag: 'wx', mode });
36
+ chmodSync(temp, mode);
37
+ renameSync(temp, path);
38
+ } finally {
39
+ rmSync(temp, { force: true });
40
+ }
41
+ return previous;
42
+ }
@@ -3,11 +3,12 @@ import {
3
3
  mkdirSync, readFileSync, renameSync, rmSync, writeFileSync
4
4
  } from 'node:fs';
5
5
  import { homedir } from 'node:os';
6
- import { dirname, join, resolve } from 'node:path';
6
+ import { basename, dirname, join, resolve } from 'node:path';
7
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
12
 
12
13
  const MODES = ['normal', 'turbo', 'manual', 'off'];
13
14
  export const DEFAULT_MODEL = 'gpt-6.2-sol';
@@ -71,7 +72,7 @@ function replaceSettings(source, destination) {
71
72
  }
72
73
  }
73
74
 
74
- export async function writeSettings(patch) {
75
+ export async function writeSettings(patch, hookRoot) {
75
76
  if (patch === null || typeof patch !== 'object' || Array.isArray(patch)) {
76
77
  throw new Error('Invalid polishing settings patch');
77
78
  }
@@ -93,7 +94,13 @@ export async function writeSettings(patch) {
93
94
  const stage = join(writer, randomUUID() + '.tmp');
94
95
  try {
95
96
  writeFileSync(stage, JSON.stringify(document, null, 2) + '\n', { flag: 'wx', mode: 0o600 });
96
- replaceSettings(stage, file);
97
+ const previous = hookRoot && setModeHook(hookRoot, automaticMode(settings.mode));
98
+ try {
99
+ replaceSettings(stage, file);
100
+ } catch (error) {
101
+ if (hookRoot) setModeHook(hookRoot, previous);
102
+ throw error;
103
+ }
97
104
  return settings;
98
105
  } finally {
99
106
  rmSync(stage, { force: true });
@@ -101,6 +108,16 @@ export async function writeSettings(patch) {
101
108
  });
102
109
  }
103
110
 
111
+ function setFromChat(patch) {
112
+ const root = dirname(import.meta.dirname);
113
+ const profile = dirname(dirname(root));
114
+ // Only change the active plugin's installed copy. Source checkouts and npm packages are immutable.
115
+ const installed = basename(dirname(root)) === 'plugins' && (basename(profile) === '.agents' ||
116
+ (basename(profile) === 'config' && basename(dirname(profile)) === '.gemini'));
117
+ if (!patch.mode || !installed) return writeSettings(patch);
118
+ return withLock(profile, () => writeSettings(patch, root));
119
+ }
120
+
104
121
  export async function listModels({ signal, timeout = 20_000 } = {}) {
105
122
  return withWorkspace(({ cwd }) => withCodexAppServer(cwd, { signal, timeout }, async (request) => {
106
123
  const { config } = await request('config/read', { includeLayers: false, cwd });
@@ -159,7 +176,7 @@ export async function runSettingsCommand([command, ...args]) {
159
176
  if (own(patch, key)) throw new Error('Duplicate flag');
160
177
  patch[key] = key !== 'mode' && value === 'default' ? null : value;
161
178
  }
162
- result = await writeSettings(patch);
179
+ result = await setFromChat(patch);
163
180
  } else {
164
181
  throw new Error('Invalid command');
165
182
  }
@@ -3,7 +3,7 @@ name: polish
3
3
  description: Explicitly polish an Antigravity reply with Codex. Use /polish or when explicitly asked to polish this or a previous reply, with optional editing instructions or a selected passage. 润色这条或上一条回复,可指定改法或只选一段。单独发送「说人话」时,把上一条回复改成大白话。
4
4
  ---
5
5
 
6
- Use the current-turn Codex Polish mode from the plugin hook. Respect the plugin rule about sharing, cancellation, and exact-format responses.
6
+ Respect the plugin rule about sharing, cancellation, and exact-format responses. For an explicit request, use the mode message from this user turn if present. The hook is off by default. When there is no current-turn message, run `node "<absolute path to this skill>/../../scripts/settings.mjs" show` locally and read its `mode` field. This check takes no conversation text and makes no model request. Use it only for an explicit edit. Never infer the mode from an earlier turn.
7
7
 
8
8
  In Off mode, or if the current mode is unavailable, never invoke Codex or the `polish_reply` MCP tool. For a polish-only request, copy just the supplied source text or the complete referenced reply verbatim. Preserve leading and trailing whitespace, line breaks, Markdown, and code. Do not apply any editing directions yourself or add an introduction, status message, or wrapping. For `/polish` with a new question or task, answer normally and send that answer directly. If no text or reply can be identified for a polish-only request, ask which one the user means.
9
9
 
@@ -14,6 +14,7 @@ node "<skill directory>/scripts/settings.mjs" set --model codex-default --effort
14
14
  ```
15
15
 
16
16
  - `show` reports the current choice; offer the available modes in the user's language when they just ask to configure polishing. Normal (普通) edits when useful. Turbo (积极润色) edits more actively. Manual (仅手动) is the default and runs only on explicit requests. Off (关闭) disables polishing. The supported mode values are `normal`, `turbo`, `manual`, and `off`.
17
+ - Setting Normal or Turbo enables the installed plugin’s mode hook. Setting Manual or Off disables it. Start a new chat to load a changed hook declaration. In Manual, explicit requests such as “说人话” also work with the hook off.
17
18
  - The AGY Polish default is `gpt-6.2-sol` with Extra High (`xhigh`) reasoning. Use `set --model default --effort default` to restore both. When the user wants to follow their local Codex configuration, use `codex-default` for the requested field or fields. A null in the output of `show` means Codex determines that setting.
18
19
  - Make an unambiguous requested change directly. When changing to a specific Codex model or thinking level, consult `list-models` and use the exact model ID and a supported effort. Use the row marked `isDefault` when following the local Codex model. If a newly chosen model does not support the current effort, offer its supported levels and the option to follow Codex. Supply only the requested options to `set` and quote their values for the shell. Resetting effort with `default` selects `xhigh` for `gpt-6.2-sol` and lets Codex determine the effort for other models.
19
20
  - If the catalog is unavailable, mode changes and resets remain available. Report the command result in the user's language. Do not ask for keys or credentials in chat.
@@ -10,8 +10,9 @@ import { chooseOption, thinkingLabels, waitForCatalog } from './installer_termin
10
10
  import { AGY_INSTALL, installAgyBootstrap } from './agy_bootstrap.mjs';
11
11
  import {
12
12
  AgyInstallError, agyProfile, requireAgyCli, installedAgy, validateAgyBundle,
13
- changeAgyPlugin, loadAgySettings, checkCodexProvider
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
16
 
16
17
  const fail = (zh, en) => new AgyInstallError(tr(zh, en));
17
18
 
@@ -145,6 +146,10 @@ async function doctorAgy(lang) {
145
146
  if (entry) {
146
147
  console.log(t('agy-polish 已安装,版本 ', 'agy-polish is installed, version ') + entry.version +
147
148
  (entry.enabled ? '' : t('(已停用)', ' (disabled)')));
149
+ const hook = savedModeHook(entry.path);
150
+ if (hook !== undefined) console.log(hook
151
+ ? t('agy-polish-mode hook 已启用。', 'The agy-polish-mode hook is on.')
152
+ : t('agy-polish-mode hook 已关闭。', 'The agy-polish-mode hook is off.'));
148
153
  } else {
149
154
  console.log(t('agy-polish 未安装。运行 ', 'agy-polish is not installed. Run ') + agySetupCommand);
150
155
  }
@@ -157,7 +162,7 @@ async function doctorAgy(lang) {
157
162
  return entry && provider.ready ? 0 : 1;
158
163
  }
159
164
 
160
- async function runAgyHost(action, plan, installDependency, lang) {
165
+ async function runAgyHost(action, plan, installDependency, lang, hook) {
161
166
  if (action === 'doctor') return doctorAgy(lang);
162
167
  const t = (zh, en) => tr(zh, en, lang);
163
168
  const settingsHelp = t('可在 Antigravity 对话中输入 /polish-settings 调整模式、模型和思考等级。',
@@ -186,17 +191,17 @@ async function runAgyHost(action, plan, installDependency, lang) {
186
191
  requireAgyCli();
187
192
  const profile = canonical(agyProfile());
188
193
  fs.mkdirSync(profile, { recursive: true, mode: 0o700 });
189
- const enabled = await withLock(profile, async () => {
194
+ const installed = await withLock(profile, async () => {
190
195
  const before = installedAgy();
191
196
  if (action === 'uninstall') {
192
197
  if (before) changeAgyPlugin('uninstall');
193
198
  if (installedAgy()) throw fail('agy 仍显示插件已安装,请再试一次卸载。', 'agy still lists the plugin as installed. Run uninstall again.');
194
199
  console.log(t('agy-polish 已卸载,模式和模型设置已保留。', 'agy-polish is uninstalled. Your mode and model settings were kept.'));
195
- return false;
200
+ return null;
196
201
  }
197
202
  if (action === 'update' && !before) {
198
203
  console.log(t('agy-polish 未安装。要加装,运行 ', 'agy-polish is not installed. To add it, run ') + agySetupCommand);
199
- return false;
204
+ return null;
200
205
  }
201
206
  const { path, version } = validateAgyBundle();
202
207
  if (before && compareVersions(version, before.version,
@@ -204,9 +209,13 @@ async function runAgyHost(action, plan, installDependency, lang) {
204
209
  throw fail('这个包比已安装的 agy-polish 旧。请使用更新的安装包。',
205
210
  'This package is older than the installed agy-polish. Use a newer package.');
206
211
  }
212
+ const previousHook = hook === undefined && before && !plan?.patch.mode ? savedModeHook(before.path) : undefined;
213
+ const hookEnabled = hook === undefined
214
+ ? previousHook ?? automaticMode(plan?.mode ?? (await loadAgySettings()).current.mode)
215
+ : hook === 'on';
207
216
  // Persist a fresh install's selected mode before agy can load the plugin.
208
217
  if (!before) await save();
209
- changeAgyPlugin('install', path);
218
+ installAgyPlugin(path, hookEnabled);
210
219
  let entry = installedAgy();
211
220
  if (before?.enabled === false && entry?.enabled === true) {
212
221
  changeAgyPlugin('disable');
@@ -222,19 +231,21 @@ async function runAgyHost(action, plan, installDependency, lang) {
222
231
  : t('agy-polish 已安装,版本 ', 'agy-polish is installed, version ') + version);
223
232
  if (!entry.enabled) console.log(t('插件目前仍是停用状态,可在 Antigravity 的插件设置中启用。',
224
233
  'The plugin is still disabled. You can enable it in Antigravity plugin settings.'));
225
- return entry.enabled;
234
+ return entry;
226
235
  });
227
236
  if (!plan) return 0;
228
- if (plan.mode === 'off') console.log(enabled ? off + ' ' + settingsHelp : off);
229
- else if (enabled) {
237
+ if (plan.mode === 'off') console.log(installed?.enabled ? off + ' ' + settingsHelp : off);
238
+ else if (installed?.enabled) {
230
239
  const provider = plan.provider ?? await checkCodexProvider(lang);
231
240
  if (!provider.ready) console.log(provider.message);
232
241
  const start = provider.ready
233
242
  ? t('在 Antigravity 中新开对话。', 'Start a new chat in Antigravity.')
234
243
  : t('处理上面的 Codex 问题后,在 Antigravity 中新开对话。', 'After resolving the Codex issue above, start a new chat in Antigravity.');
235
- const use = plan.mode === 'manual'
236
- ? t('输入 /polish,或提问时加一句「请润色」。', 'Use /polish or ask for polishing in your question.')
237
- : t('输入 /polish,或像平常一样提问。', 'Use /polish or ask a question as usual.');
244
+ let use = t('输入 /polish,或像平常一样提问。', 'Use /polish or ask a question as usual.');
245
+ if (plan.mode === 'manual') use = t('手动润色无需 hook。输入 /polish,或提问时加一句「请润色」。',
246
+ 'Manual polishing works without a hook. Use /polish or ask for polishing in your question.');
247
+ else if (savedModeHook(installed.path) === false) use = t('模式 hook 已关闭。可直接输入 /polish,或用 update --hook on 开启自动润色。',
248
+ 'The mode hook is off. Use /polish for a single edit, or run update --hook on for automatic edits.');
238
249
  console.log(start + ' ' + use);
239
250
  console.log(t('看到 MCP 授权提示时,只授权 agy-polish 的 polish_reply 工具。',
240
251
  'If Antigravity prompts for MCP approval, approve only the agy-polish tool polish_reply.'));
@@ -245,8 +256,8 @@ async function runAgyHost(action, plan, installDependency, lang) {
245
256
 
246
257
  function usage(lang) {
247
258
  return tr(
248
- '用法:agy-polish [setup|update|doctor|uninstall] [--install-agy]\nsetup(默认命令)安装 Antigravity 插件,可选择润色模式、Codex 模型和思考等级。\n--install-agy 可在 setup 或 update 中安装 Google 的 Antigravity CLI。\n-h, --help 显示帮助。',
249
- 'Usage: agy-polish [setup|update|doctor|uninstall] [--install-agy]\nsetup (default) installs the Antigravity plugin and lets you choose the polishing mode, Codex model and reasoning effort.\n--install-agy can install Google’s Antigravity CLI during setup or update.\n-h, --help shows this help.',
259
+ '用法:agy-polish [setup|update|doctor|uninstall] [--install-agy] [--hook on|off]\nsetup(默认命令)安装 Antigravity 插件,可选择润色模式、Codex 模型和思考等级。\n--install-agy 可在 setup 或 update 中安装 Google 的 Antigravity CLI。\n--hook on|off 可在 setup 或 update 中单独开关本插件的 hook。\n-h, --help 显示帮助。',
260
+ 'Usage: agy-polish [setup|update|doctor|uninstall] [--install-agy] [--hook on|off]\nsetup (default) installs the Antigravity plugin and lets you choose the polishing mode, Codex model and reasoning effort.\n--install-agy can install Google’s Antigravity CLI during setup or update.\n--hook on|off enables or disables this plugin’s mode hook during setup or update.\n-h, --help shows this help.',
250
261
  lang
251
262
  );
252
263
  }
@@ -257,15 +268,17 @@ export async function main(args = process.argv.slice(2)) {
257
268
  console.log(usage(lang));
258
269
  return 0;
259
270
  }
260
- let action, installDependency;
271
+ let action, installDependency, hook;
261
272
  try {
262
273
  const { values, positionals } = parseArgs({
263
274
  args, allowPositionals: true,
264
- options: { 'install-agy': { type: 'boolean' }, advanced: { type: 'boolean' } }
275
+ options: { 'install-agy': { type: 'boolean' }, advanced: { type: 'boolean' }, hook: { type: 'string' } }
265
276
  });
266
277
  action = positionals[0] ?? 'setup';
267
278
  installDependency = values['install-agy'] ?? false;
279
+ hook = values.hook;
268
280
  if (positionals.length > 1 || !['setup', 'update', 'doctor', 'uninstall'].includes(action) ||
281
+ (hook !== undefined && (!['on', 'off'].includes(hook) || !['setup', 'update'].includes(action))) ||
269
282
  (values.advanced && action !== 'setup') || (installDependency && !['setup', 'update'].includes(action))) {
270
283
  throw new Error('invalid installer arguments');
271
284
  }
@@ -282,7 +295,7 @@ export async function main(args = process.argv.slice(2)) {
282
295
  if (legacy === 'codex-failed') console.log(tr('Antigravity 配置已取消。', 'Antigravity setup was cancelled.', lang));
283
296
  return 0;
284
297
  }
285
- return await runAgyHost(action, plan, installDependency, lang);
298
+ return await runAgyHost(action, plan, installDependency, lang, hook);
286
299
  } catch (error) {
287
300
  console.error(error instanceof AgyInstallError ? error.message :
288
301
  tr('没法核对安装文件或环境。请检查文件权限和发行包后再试。',
@@ -1,6 +1,6 @@
1
1
  import { spawnSync } from 'node:child_process';
2
- import { constants, readFileSync } from 'node:fs';
3
- import { homedir } from 'node:os';
2
+ import { constants, cpSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
3
+ import { homedir, tmpdir } from 'node:os';
4
4
  import { isAbsolute, join } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { agyExecutable, available, pathDirectories, windows } from './installer_common.mjs';
@@ -8,6 +8,7 @@ import { tr } from './installer_locale.mjs';
8
8
  import { AGY_INSTALL } from './agy_bootstrap.mjs';
9
9
  import { fileLoginExists, withWorkspace } from '../plugins/agy-polish/scripts/codex-process.mjs';
10
10
  import { withCodexAppServer } from '../plugins/agy-polish/scripts/codex-provider.mjs';
11
+ import { setModeHook } from '../plugins/agy-polish/scripts/mode-hook-config.mjs';
11
12
 
12
13
  const PLUGIN = 'agy-polish';
13
14
  const SOURCE = new URL('../plugins/agy-polish/', import.meta.url);
@@ -97,6 +98,20 @@ export function changeAgyPlugin(action, target = PLUGIN) {
97
98
  pluginCommand([action, target]);
98
99
  }
99
100
 
101
+ export function installAgyPlugin(source, hookEnabled) {
102
+ if (!hookEnabled) return changeAgyPlugin('install', source);
103
+ // agy copies the source directory. Give it the opted-in declaration before the host can load it.
104
+ const stage = mkdtempSync(join(tmpdir(), 'agy-polish-install-'));
105
+ try {
106
+ const plugin = join(stage, PLUGIN);
107
+ cpSync(source, plugin, { recursive: true });
108
+ setModeHook(plugin, true);
109
+ changeAgyPlugin('install', plugin);
110
+ } finally {
111
+ rmSync(stage, { recursive: true, force: true });
112
+ }
113
+ }
114
+
100
115
  export async function loadAgySettings(options) {
101
116
  let settings;
102
117
  try {