@kyun.si/agy-polish 0.0.4-beta.4 → 0.0.4-beta.6
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,9 @@ npx @kyun.si/agy-polish@beta setup
|
|
|
12
12
|
|
|
13
13
|
In Windows PowerShell, use `npx.cmd` in place of `npx`.
|
|
14
14
|
|
|
15
|
-
|
|
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.
|
|
16
|
+
|
|
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.
|
|
16
18
|
|
|
17
19
|
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.
|
|
18
20
|
|
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.6",
|
|
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",
|
|
@@ -10,7 +10,10 @@ import { withCodexAppServer } from './codex-provider.mjs';
|
|
|
10
10
|
import { withLock } from './directory-lock.mjs';
|
|
11
11
|
|
|
12
12
|
const MODES = ['normal', 'turbo', 'manual', 'off'];
|
|
13
|
-
const
|
|
13
|
+
export const DEFAULT_MODEL = 'gpt-6.2-sol';
|
|
14
|
+
export const DEFAULT_EFFORT = 'xhigh';
|
|
15
|
+
export const FOLLOW_CODEX = 'codex-default';
|
|
16
|
+
const EMPTY_SETTINGS = { mode: 'manual', model: null, effort: null };
|
|
14
17
|
const own = Object.hasOwn;
|
|
15
18
|
|
|
16
19
|
function settingsPath() {
|
|
@@ -39,18 +42,19 @@ function validate(key, value) {
|
|
|
39
42
|
throw new Error(`Invalid polishing ${key}`);
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
function preferences(document) {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
function preferences(document, legacyDefaults = false) {
|
|
46
|
+
const { mode = legacyDefaults ? 'normal' : EMPTY_SETTINGS.mode, model = null, effort = null } = document;
|
|
47
|
+
validate('mode', mode);
|
|
48
|
+
validate('model', model);
|
|
49
|
+
validate('effort', effort);
|
|
50
|
+
if (legacyDefaults) return { mode, model, effort };
|
|
51
|
+
const editorModel = model === FOLLOW_CODEX ? null : model ?? DEFAULT_MODEL;
|
|
52
|
+
const defaultEffort = editorModel === DEFAULT_MODEL ? DEFAULT_EFFORT : null;
|
|
53
|
+
return { mode, model: editorModel, effort: effort === FOLLOW_CODEX ? null : effort ?? defaultEffort };
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
export function readSettings() {
|
|
53
|
-
return preferences(readDocument(settingsPath()));
|
|
56
|
+
export function readSettings({ legacyDefaults = false } = {}) {
|
|
57
|
+
return preferences(readDocument(settingsPath()), legacyDefaults);
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
const lockWait = new Int32Array(new SharedArrayBuffer(4));
|
|
@@ -73,7 +77,7 @@ export async function writeSettings(patch) {
|
|
|
73
77
|
}
|
|
74
78
|
const keys = Object.keys(patch);
|
|
75
79
|
for (const key of keys) {
|
|
76
|
-
if (!own(
|
|
80
|
+
if (!own(EMPTY_SETTINGS, key)) throw new Error('Unknown polishing setting');
|
|
77
81
|
validate(key, patch[key]);
|
|
78
82
|
}
|
|
79
83
|
if (!keys.length) return readSettings();
|
|
@@ -83,11 +87,12 @@ export async function writeSettings(patch) {
|
|
|
83
87
|
const writer = join(dirname(file), '.settings-writer');
|
|
84
88
|
mkdirSync(writer, { recursive: true, mode: 0o700 });
|
|
85
89
|
return withLock(writer, () => {
|
|
86
|
-
|
|
90
|
+
// Store the choice itself so changing only the model can use that model's default effort.
|
|
91
|
+
const document = { ...EMPTY_SETTINGS, ...readDocument(file), ...patch };
|
|
87
92
|
const settings = preferences(document);
|
|
88
93
|
const stage = join(writer, randomUUID() + '.tmp');
|
|
89
94
|
try {
|
|
90
|
-
writeFileSync(stage, JSON.stringify(
|
|
95
|
+
writeFileSync(stage, JSON.stringify(document, null, 2) + '\n', { flag: 'wx', mode: 0o600 });
|
|
91
96
|
replaceSettings(stage, file);
|
|
92
97
|
return settings;
|
|
93
98
|
} finally {
|
|
@@ -8,10 +8,12 @@ Use the bundled [settings command](scripts/settings.mjs) via Node.js. Resolve th
|
|
|
8
8
|
```text
|
|
9
9
|
node "<skill directory>/scripts/settings.mjs" show
|
|
10
10
|
node "<skill directory>/scripts/settings.mjs" list-models
|
|
11
|
-
node "<skill directory>/scripts/settings.mjs" set --mode
|
|
11
|
+
node "<skill directory>/scripts/settings.mjs" set --mode manual
|
|
12
12
|
node "<skill directory>/scripts/settings.mjs" set --model default --effort default
|
|
13
|
+
node "<skill directory>/scripts/settings.mjs" set --model codex-default --effort codex-default
|
|
13
14
|
```
|
|
14
15
|
|
|
15
|
-
- `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.
|
|
16
|
-
-
|
|
17
|
-
-
|
|
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
|
+
- 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
|
+
- 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
|
+
- 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.
|
package/scripts/agy-cli.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { parseArgs } from 'node:util';
|
|
|
6
6
|
import { agyExecutable, canonical, compareVersions, interactiveTerminal, LEGACY_BOTH_SETUP, npmChannel, windows } from './installer_common.mjs';
|
|
7
7
|
import { systemLanguage, tr } from './installer_locale.mjs';
|
|
8
8
|
import { withLock } from './installer_lock.mjs';
|
|
9
|
-
import {
|
|
9
|
+
import { chooseOption, thinkingLabels, waitForCatalog } from './installer_terminal.mjs';
|
|
10
10
|
import { AGY_INSTALL, installAgyBootstrap } from './agy_bootstrap.mjs';
|
|
11
11
|
import {
|
|
12
12
|
AgyInstallError, agyProfile, requireAgyCli, installedAgy, validateAgyBundle,
|
|
@@ -37,26 +37,31 @@ function agyEffortLabel(effort, lang) {
|
|
|
37
37
|
|
|
38
38
|
async function chooseAgyModel(settings, { model, effort }, { signedIn }, lang) {
|
|
39
39
|
const t = (zh, en) => tr(zh, en, lang);
|
|
40
|
-
const
|
|
41
|
-
const
|
|
40
|
+
const { DEFAULT_MODEL, DEFAULT_EFFORT, FOLLOW_CODEX } = settings;
|
|
41
|
+
const usingRecommended = model === DEFAULT_MODEL && effort === DEFAULT_EFFORT;
|
|
42
|
+
const followingCodex = model === null && effort === null;
|
|
43
|
+
const initialChoice = usingRecommended ? 'recommended' : followingCodex ? 'follow' : 'keep';
|
|
42
44
|
const choices = [
|
|
43
|
-
{ id: '
|
|
44
|
-
{ id: '
|
|
45
|
-
{ id: 'lookup', name: signedIn
|
|
46
|
-
? t('选择账号可用模型和思考等级…', 'Choose a model and reasoning effort from my account…')
|
|
47
|
-
: t('从 Codex 模型列表选择模型和思考等级…', 'Choose a model and reasoning effort from the Codex model list…') }
|
|
45
|
+
{ id: 'recommended', name: DEFAULT_MODEL + ' · ' + agyEffortLabel(DEFAULT_EFFORT, lang) + t('(默认)', ' (default)') },
|
|
46
|
+
{ id: 'follow', name: t('跟随本机 Codex 配置', 'Follow local Codex configuration') }
|
|
48
47
|
];
|
|
48
|
+
if (initialChoice === 'keep') {
|
|
49
|
+
const saved = (model ?? t('Codex 默认', 'Codex default')) + (effort ? ' · ' + agyEffortLabel(effort, lang) : '');
|
|
50
|
+
choices.push({ id: 'keep', name: t('保留当前设置', 'Keep current settings') + ' · ' + saved });
|
|
51
|
+
}
|
|
52
|
+
choices.push({ id: 'lookup', name: signedIn
|
|
53
|
+
? t('选择账号可用模型和思考等级…', 'Choose a model and reasoning effort from my account…')
|
|
54
|
+
: t('从 Codex 模型列表选择模型和思考等级…', 'Choose a model and reasoning effort from the Codex model list…') });
|
|
49
55
|
const unavailable = signedIn
|
|
50
|
-
? t('
|
|
51
|
-
|
|
52
|
-
: t('没能读取 Codex 模型列表。可使用 Codex 默认或保留当前设置。',
|
|
53
|
-
'Could not read the Codex model list. You can use the Codex default or keep your settings.');
|
|
56
|
+
? t('没能读取账号模型。', 'Could not read the account model list.')
|
|
57
|
+
: t('没能读取 Codex 模型列表。', 'Could not read the Codex model list.');
|
|
54
58
|
while (true) {
|
|
55
59
|
const choice = await chooseOption(t('选择改写用的 Codex 模型', 'Choose the Codex model for rewrites'),
|
|
56
|
-
choices, lang, process.stdin, process.stdout,
|
|
60
|
+
choices, lang, process.stdin, process.stdout, initialChoice);
|
|
57
61
|
if (!choice) return null;
|
|
58
|
-
if (choice ===
|
|
59
|
-
if (choice === '
|
|
62
|
+
if (choice === initialChoice) return {};
|
|
63
|
+
if (choice === 'recommended') return { model: null, effort: null };
|
|
64
|
+
if (choice === 'follow') return { model: FOLLOW_CODEX, effort: FOLLOW_CODEX };
|
|
60
65
|
let models;
|
|
61
66
|
const controller = new AbortController();
|
|
62
67
|
try {
|
|
@@ -74,8 +79,7 @@ async function chooseAgyModel(settings, { model, effort }, { signedIn }, lang) {
|
|
|
74
79
|
}
|
|
75
80
|
if (!models.length) {
|
|
76
81
|
console.log(signedIn ? unavailable
|
|
77
|
-
: t('Codex
|
|
78
|
-
'The Codex model list has no models to choose from. You can use the Codex default or keep your settings.'));
|
|
82
|
+
: t('Codex 模型列表中没有可选模型。', 'The Codex model list has no models to choose from.'));
|
|
79
83
|
continue;
|
|
80
84
|
}
|
|
81
85
|
const defaultLabel = signedIn ? t('(账号默认)', ' (account default)') : t('(Codex 默认)', ' (Codex default)');
|
|
@@ -84,50 +88,47 @@ async function chooseAgyModel(settings, { model, effort }, { signedIn }, lang) {
|
|
|
84
88
|
name: (models.some(other => other.id !== item.id && other.name === item.name) ? item.name + ' (' + item.id + ')' : item.name) +
|
|
85
89
|
(item.isDefault ? defaultLabel : '')
|
|
86
90
|
}));
|
|
91
|
+
const initialModel = models.find(item => item.id === model) ?? models.find(item => item.isDefault);
|
|
87
92
|
const id = await chooseOption(t('用哪个模型改写?', 'Which model should rewrite your replies?'), rows,
|
|
88
|
-
lang, process.stdin, process.stdout,
|
|
93
|
+
lang, process.stdin, process.stdout, initialModel?.id);
|
|
89
94
|
if (!id) return null;
|
|
90
95
|
const selected = models.find(item => item.id === id);
|
|
91
|
-
if (!selected.efforts.length) return { model: id, effort: null };
|
|
96
|
+
if (!selected.efforts.length) return { model: id, effort: id === DEFAULT_MODEL ? FOLLOW_CODEX : null };
|
|
92
97
|
const efforts = selected.efforts.map(id => ({
|
|
93
98
|
id,
|
|
94
99
|
name: agyEffortLabel(id, lang) + (id === selected.defaultEffort ? t('(模型默认)', ' (model default)') : '')
|
|
95
100
|
}));
|
|
96
|
-
const
|
|
101
|
+
const savedEffort = id === model && selected.efforts.includes(effort) ? effort : null;
|
|
102
|
+
const recommendedEffort = id === DEFAULT_MODEL && selected.efforts.includes(DEFAULT_EFFORT) ? DEFAULT_EFFORT : null;
|
|
103
|
+
const initial = savedEffort ?? recommendedEffort ?? selected.defaultEffort;
|
|
97
104
|
const level = await chooseOption(t('Codex 思考等级', 'Codex reasoning effort'), efforts,
|
|
98
105
|
lang, process.stdin, process.stdout, initial);
|
|
99
106
|
return level ? { model: id, effort: level } : null;
|
|
100
107
|
}
|
|
101
108
|
}
|
|
102
109
|
|
|
103
|
-
async function prepareAgySetup(interactive,
|
|
110
|
+
async function prepareAgySetup(interactive, lang) {
|
|
104
111
|
const { settings, current } = await loadAgySettings();
|
|
105
112
|
const t = (zh, en) => tr(zh, en, lang);
|
|
106
113
|
const patch = {};
|
|
107
114
|
let mode = current.mode;
|
|
108
115
|
if (interactive) {
|
|
109
116
|
console.log(t(...agyDataNotice));
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
mode = await chooseOption(title, modes, lang, process.stdin, process.stdout, current.mode);
|
|
116
|
-
} else {
|
|
117
|
-
mode = await chooseOnboardingMode(title, current.mode, lang);
|
|
118
|
-
}
|
|
117
|
+
const modes = Object.entries(agyModeLabels).map(([id, label]) => ({
|
|
118
|
+
id, name: t(...label) + (id === current.mode ? t('(当前)', ' (current)') : '')
|
|
119
|
+
}));
|
|
120
|
+
mode = await chooseOption(t('在 Antigravity 中如何润色?', 'How should Antigravity replies be polished?'),
|
|
121
|
+
modes, lang, process.stdin, process.stdout, current.mode);
|
|
119
122
|
if (!mode) return null;
|
|
120
123
|
if (mode !== current.mode) patch.mode = mode;
|
|
121
124
|
}
|
|
122
125
|
let provider;
|
|
123
|
-
if (mode !== 'off' && interactive
|
|
126
|
+
if (mode !== 'off' && interactive) {
|
|
124
127
|
provider = await checkCodexProvider(lang);
|
|
125
128
|
if (provider.ready || provider.canListModels) {
|
|
126
129
|
const model = await chooseAgyModel(settings, current, provider, lang);
|
|
127
130
|
if (!model) return null;
|
|
128
|
-
|
|
129
|
-
Object.assign(patch, model);
|
|
130
|
-
}
|
|
131
|
+
Object.assign(patch, model);
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
return { settings, patch, mode, provider };
|
|
@@ -135,9 +136,12 @@ async function prepareAgySetup(interactive, advanced, lang) {
|
|
|
135
136
|
|
|
136
137
|
async function doctorAgy(lang) {
|
|
137
138
|
const t = (zh, en) => tr(zh, en, lang);
|
|
138
|
-
const { current: { mode, model, effort } } = await loadAgySettings();
|
|
139
|
-
console.log(t('Antigravity 润色模式:', 'Antigravity polishing mode: ') + t(...agyModeLabels[mode]));
|
|
140
139
|
const entry = installedAgy();
|
|
140
|
+
// Doctor describes the plugin Antigravity is running, even before the user updates it.
|
|
141
|
+
const legacyDefaults = entry && compareVersions(entry.version, '0.0.4-beta.6',
|
|
142
|
+
() => fail('没法确定 agy-polish 的版本。', "Couldn't determine the agy-polish version.")) < 0;
|
|
143
|
+
const { current: { mode, model, effort } } = await loadAgySettings({ legacyDefaults });
|
|
144
|
+
console.log(t('Antigravity 润色模式:', 'Antigravity polishing mode: ') + t(...agyModeLabels[mode]));
|
|
141
145
|
if (entry) {
|
|
142
146
|
console.log(t('agy-polish 已安装,版本 ', 'agy-polish is installed, version ') + entry.version +
|
|
143
147
|
(entry.enabled ? '' : t('(已停用)', ' (disabled)')));
|
|
@@ -241,8 +245,8 @@ async function runAgyHost(action, plan, installDependency, lang) {
|
|
|
241
245
|
|
|
242
246
|
function usage(lang) {
|
|
243
247
|
return tr(
|
|
244
|
-
'用法:agy-polish [setup|update|doctor|uninstall] [--install-agy]
|
|
245
|
-
'Usage: agy-polish [setup|update|doctor|uninstall] [--install-agy]
|
|
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.',
|
|
246
250
|
lang
|
|
247
251
|
);
|
|
248
252
|
}
|
|
@@ -253,7 +257,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
253
257
|
console.log(usage(lang));
|
|
254
258
|
return 0;
|
|
255
259
|
}
|
|
256
|
-
let action, installDependency
|
|
260
|
+
let action, installDependency;
|
|
257
261
|
try {
|
|
258
262
|
const { values, positionals } = parseArgs({
|
|
259
263
|
args, allowPositionals: true,
|
|
@@ -261,9 +265,8 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
261
265
|
});
|
|
262
266
|
action = positionals[0] ?? 'setup';
|
|
263
267
|
installDependency = values['install-agy'] ?? false;
|
|
264
|
-
advanced = values.advanced ?? false;
|
|
265
268
|
if (positionals.length > 1 || !['setup', 'update', 'doctor', 'uninstall'].includes(action) ||
|
|
266
|
-
(advanced && action !== 'setup') || (installDependency && !['setup', 'update'].includes(action))) {
|
|
269
|
+
(values.advanced && action !== 'setup') || (installDependency && !['setup', 'update'].includes(action))) {
|
|
267
270
|
throw new Error('invalid installer arguments');
|
|
268
271
|
}
|
|
269
272
|
} catch {
|
|
@@ -271,7 +274,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
271
274
|
return 2;
|
|
272
275
|
}
|
|
273
276
|
try {
|
|
274
|
-
const plan = action === 'setup' ? await prepareAgySetup(interactiveTerminal(),
|
|
277
|
+
const plan = action === 'setup' ? await prepareAgySetup(interactiveTerminal(), lang) : undefined;
|
|
275
278
|
if (plan === null) {
|
|
276
279
|
const legacy = process.env[LEGACY_BOTH_SETUP];
|
|
277
280
|
if (legacy === 'codex-complete') console.log(tr('Codex 配置已完成。Antigravity 配置已取消。',
|
package/scripts/agy_install.mjs
CHANGED
|
@@ -97,7 +97,7 @@ export function changeAgyPlugin(action, target = PLUGIN) {
|
|
|
97
97
|
pluginCommand([action, target]);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
export async function loadAgySettings() {
|
|
100
|
+
export async function loadAgySettings(options) {
|
|
101
101
|
let settings;
|
|
102
102
|
try {
|
|
103
103
|
settings = await import(new URL('scripts/settings.mjs', SOURCE));
|
|
@@ -106,7 +106,7 @@ export async function loadAgySettings() {
|
|
|
106
106
|
'Could not load agy-polish settings. Download a fresh copy of the full package.');
|
|
107
107
|
}
|
|
108
108
|
try {
|
|
109
|
-
return { settings, current: await settings.readSettings() };
|
|
109
|
+
return { settings, current: await settings.readSettings(options) };
|
|
110
110
|
} catch {
|
|
111
111
|
throw error('无法读取 agy-polish 设置。请检查设置目录中的 settings.json 是否有效、可读。',
|
|
112
112
|
'Could not read agy-polish settings. Check that settings.json is valid and readable.');
|