@kyun.si/agy-polish 0.0.4-beta.5 → 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,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
- Choose Normal, Turbo, Manual, or Off. With polishing on, you can keep the Codex default or choose a model and a supported reasoning effort from your provider’s model list. Run `setup` again to change your choices, or use `/polish-settings` in Antigravity.
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
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kyun.si/agy-polish",
3
- "version": "0.0.4-beta.5",
3
+ "version": "0.0.4-beta.6",
4
4
  "description": "Polish Antigravity replies with Codex · 用 Codex 润色 Antigravity 回复",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agy-polish",
3
3
  "displayName": "AGY Polish · 回复润色",
4
- "version": "0.0.4-beta.5",
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 DEFAULTS = { mode: 'normal', model: null, effort: null };
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 values = { ...DEFAULTS };
44
- for (const key of Object.keys(values)) {
45
- if (!own(document, key)) continue;
46
- validate(key, document[key]);
47
- values[key] = document[key];
48
- }
49
- return values;
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(DEFAULTS, key)) throw new Error('Unknown polishing setting');
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
- const document = { ...readDocument(file), ...patch };
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({ ...document, ...settings }, null, 2) + '\n', { flag: 'wx', mode: 0o600 });
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 normal
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. Only when asked (仅手动) runs only on explicit requests. Off (关闭) disables polishing. The supported mode values are `normal`, `turbo`, `manual`, and `off`.
16
- - Make an unambiguous requested change directly. When changing to a specific Codex model or thinking level, consult `list-models`; use the exact model ID and an effort supported by that model. Use the row marked `isDefault` when the saved model is null. If changing models would make the saved thinking level invalid, ask which supported level to use or whether to follow the selected model's default. An explicitly requested reset to the default model or effort uses `default` for that flag. Supply only requested options to `set`. Quote values for the shell and only use model IDs and efforts from the catalog or the literal `default`.
17
- - If the catalog is unavailable, mode changes and resets remain available. Report the result of the command in the user's language. A null model or effort follows Codex's default for the polishing subprocess. Do not ask for keys or credentials in chat.
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.
@@ -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 defaultModel = t('Codex 默认', 'Codex default');
41
- const saved = (model ?? defaultModel) + (effort ? ' · ' + agyEffortLabel(effort, lang) : '');
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: 'default', name: defaultModel },
44
- { id: 'keep', name: t('保留当前设置', 'Keep current settings') + ' · ' + saved },
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('没能读取账号模型。可使用 Codex 默认或保留当前设置。',
51
- 'Could not read the account model list. You can use the Codex default or keep your settings.')
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, model || effort ? 'keep' : 'default');
60
+ choices, lang, process.stdin, process.stdout, initialChoice);
57
61
  if (!choice) return null;
58
- if (choice === 'keep') return {};
59
- if (choice === 'default') return { model: null, effort: null };
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 模型列表中没有可选模型。可使用 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,16 +88,19 @@ 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, model ?? models.find(item => item.isDefault)?.id);
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 initial = id === model && selected.efforts.includes(effort) ? effort : selected.defaultEffort;
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;
@@ -121,9 +128,7 @@ async function prepareAgySetup(interactive, lang) {
121
128
  if (provider.ready || provider.canListModels) {
122
129
  const model = await chooseAgyModel(settings, current, provider, lang);
123
130
  if (!model) return null;
124
- if (Object.hasOwn(model, 'model') && (model.model !== current.model || model.effort !== current.effort)) {
125
- Object.assign(patch, model);
126
- }
131
+ Object.assign(patch, model);
127
132
  }
128
133
  }
129
134
  return { settings, patch, mode, provider };
@@ -131,9 +136,12 @@ async function prepareAgySetup(interactive, lang) {
131
136
 
132
137
  async function doctorAgy(lang) {
133
138
  const t = (zh, en) => tr(zh, en, lang);
134
- const { current: { mode, model, effort } } = await loadAgySettings();
135
- console.log(t('Antigravity 润色模式:', 'Antigravity polishing mode: ') + t(...agyModeLabels[mode]));
136
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]));
137
145
  if (entry) {
138
146
  console.log(t('agy-polish 已安装,版本 ', 'agy-polish is installed, version ') + entry.version +
139
147
  (entry.enabled ? '' : t('(已停用)', ' (disabled)')));
@@ -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.');