gsd-for-omp 1.1.1 → 1.1.2
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/CHANGELOG.md +8 -1
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/docs/CONFIGURATION.md +4 -0
- package/docs/GETTING-STARTED.md +2 -0
- package/package.json +1 -1
- package/src/extension/lifecycle.cjs +9 -0
- package/src/extension/status.cjs +4 -1
- package/src/extension/update-check.cjs +262 -0
- package/src/extension.cjs +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes to `gsd-for-omp` are recorded here in [Keep a Changelog](htt
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [1.1.2] - 2026-10-21
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- In GSD projects, OMP now tells you when a newer `gsd-for-omp` is on npm: one notification per session (in the project's `response_language`) and a `⬆ <version>` marker in the GSD footer. The registry lookup (`npm view gsd-for-omp version`) runs in the background at most once a day, is cached in `~/.cache/gsd-for-omp/update-check.json` (or under `XDG_CACHE_HOME`), and fails silently. The same notice asks for `gsd-for-omp install` when the package was upgraded but the OMP files were not re-projected. The suggested command always carries a shell-quoted `--root` for the session's runtime root, so it also works for custom roots from a terminal without `PI_CODING_AGENT_DIR`. Set `GSD_FOR_OMP_NO_UPDATE_CHECK=1` or `NO_UPDATE_NOTIFIER=1` to turn it off; it is also off when `CI` is set.
|
|
12
|
+
|
|
7
13
|
## [1.1.1] - 2026-10-21
|
|
8
14
|
|
|
9
15
|
### Security
|
|
@@ -90,7 +96,8 @@ Related: [PR #53](https://github.com/tchivs/gsd-omp/pull/53), [release PR #54](h
|
|
|
90
96
|
|
|
91
97
|
Related: [PR #51](https://github.com/tchivs/gsd-omp/pull/51), [release PR #52](https://github.com/tchivs/gsd-omp/pull/52).
|
|
92
98
|
|
|
93
|
-
[Unreleased]: https://github.com/GManzato/gsd-for-omp/compare/v1.1.
|
|
99
|
+
[Unreleased]: https://github.com/GManzato/gsd-for-omp/compare/v1.1.2...HEAD
|
|
100
|
+
[1.1.2]: https://github.com/GManzato/gsd-for-omp/compare/v1.1.1...v1.1.2
|
|
94
101
|
[1.1.1]: https://github.com/GManzato/gsd-for-omp/compare/v1.1.0...v1.1.1
|
|
95
102
|
[1.1.0]: https://github.com/GManzato/gsd-for-omp/compare/v1.0.27...v1.1.0
|
|
96
103
|
[1.0.27]: https://github.com/GManzato/gsd-for-omp/compare/v1.0.26...v1.0.27
|
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@ The `gsd_invoke` tool gives agents structured access to the same `gsd-tools` CLI
|
|
|
50
50
|
## OMP integration
|
|
51
51
|
|
|
52
52
|
- **Status overlay** — `Ctrl+Shift+G` opens a live GSD status overlay (also available at startup with the `--gsd-status` flag); a widget and footer show the same state.
|
|
53
|
+
- **Update notice** — in GSD projects, a notification and a `⬆` footer marker appear when a newer `gsd-for-omp` is published; the npm check runs in the background at most once a day. Opt out with `GSD_FOR_OMP_NO_UPDATE_CHECK=1`.
|
|
53
54
|
- **Native controls** — `/gsd-status` accepts `--compact`, `--stop`, `--branch`, `--tree`, `--switch`, and `--reload` for OMP's native session controls.
|
|
54
55
|
- **Goal Mode** — when the host emits `goal_updated`, the objective, status, and token budget are mirrored in `/gsd-status`; pause or drop the goal (`/goal pause`, `/goal drop`) before `/gsd-next`. Hosts without it, such as OMP 17, keep everything else.
|
|
55
56
|
- **Models** — OMP owns the model. Switch with OMP's `/model`; the GSD `model_profile` setting has no effect under OMP. See [Configuration](docs/CONFIGURATION.md#model-routing).
|
package/README.zh-CN.md
CHANGED
|
@@ -50,6 +50,7 @@ gsd-for-omp doctor
|
|
|
50
50
|
## OMP 集成
|
|
51
51
|
|
|
52
52
|
- **状态 overlay** —— `Ctrl+Shift+G` 打开实时 GSD 状态 overlay(也可在启动时用 `--gsd-status` flag 打开);widget 与 footer 显示同样的状态。
|
|
53
|
+
- **更新提示** —— 在 GSD 项目中,当 npm 上发布了更新的 `gsd-for-omp` 时,会弹出通知并在页脚显示 `⬆` 标记;npm 检查在后台运行,每天最多一次。设置 `GSD_FOR_OMP_NO_UPDATE_CHECK=1` 可关闭。
|
|
53
54
|
- **原生控制** —— `/gsd-status` 接受 `--compact`、`--stop`、`--branch`、`--tree`、`--switch`、`--reload`,对应 OMP 的原生会话控制。
|
|
54
55
|
- **Goal Mode** —— 当主机提供 `goal_updated` 事件时,目标、状态与 token 预算会同步到 `/gsd-status`;运行 `/gsd-next` 前请先暂停或放弃目标(`/goal pause`、`/goal drop`)。没有该事件的主机(如 OMP 17)仍可使用其余全部功能。
|
|
55
56
|
- **模型** —— 模型由 OMP 掌管。请使用 OMP 的 `/model` 切换;GSD 的 `model_profile` 设置在 OMP 下不起作用。详见[配置参考](docs/CONFIGURATION.md#model-routing)。
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -52,6 +52,10 @@ The extension passes `GSD_AGENTS_DIR` together with `GSD_RUNTIME=omp` to every `
|
|
|
52
52
|
| `LC_ALL` | Optional | Next POSIX locale or `en` | First POSIX fallback after `GSD_FOR_OMP_LOCALE`. |
|
|
53
53
|
| `LC_MESSAGES` | Optional | Next POSIX locale or `en` | Second POSIX fallback after `GSD_FOR_OMP_LOCALE` and `LC_ALL`. |
|
|
54
54
|
| `LANG` | Optional | `en` | Final POSIX locale fallback after `GSD_FOR_OMP_LOCALE`, `LC_ALL`, and `LC_MESSAGES`. |
|
|
55
|
+
| `GSD_FOR_OMP_NO_UPDATE_CHECK` | Optional | unset | Any value other than empty, `0`, `false`, `no`, or `off` disables the in-session update notice and its background `npm view gsd-for-omp version` lookup. |
|
|
56
|
+
| `NO_UPDATE_NOTIFIER` | Optional | unset | Conventional opt-out honored the same way as `GSD_FOR_OMP_NO_UPDATE_CHECK`. |
|
|
57
|
+
| `CI` | Optional | unset | When set to a truthy value, the update notice is skipped so CI never queries the registry. |
|
|
58
|
+
| `XDG_CACHE_HOME` | Optional | `~/.cache` | Parent of `gsd-for-omp/update-check.json`, which caches the last registry result for 24 hours (1 hour after a failed lookup). |
|
|
55
59
|
|
|
56
60
|
The effective shell/EoS locale is selected in this exact order: `GSD_FOR_OMP_LOCALE`, `LC_ALL`, `LC_MESSAGES`, `LANG`. Supported dictionaries are `en` and `zh-CN`; a value such as `zh_CN.UTF-8` selects `zh-CN`, while an unknown or empty value falls back to English. This locale does not override a project's in-session language setting.
|
|
57
61
|
|
package/docs/GETTING-STARTED.md
CHANGED
|
@@ -145,6 +145,8 @@ gsd-for-omp install
|
|
|
145
145
|
|
|
146
146
|
The update also upgrades the plugin's bundled GSD Core dependency. It does not update an OMP-managed engine tree; use OMP's own update path for the host itself.
|
|
147
147
|
|
|
148
|
+
Inside a GSD project, OMP tells you when an update is available: one notification per session and a `⬆ <version>` marker in the GSD footer. The registry lookup runs in the background at most once a day and never blocks or fails a session. If the package was upgraded with `npm` but `gsd-for-omp install` was not rerun, the same notice asks you to re-project instead (footer `⬆ reinstall`). Set `GSD_FOR_OMP_NO_UPDATE_CHECK=1` to turn it off; see [Configuration](CONFIGURATION.md#runtime-and-localization-variables).
|
|
149
|
+
|
|
148
150
|
## Uninstall
|
|
149
151
|
|
|
150
152
|
Remove managed projections before removing the global installer:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gsd-for-omp",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Oh My Pi host plugin for the GSD Embeddable Orchestration System — extension bindings, slash-command surface, Host-Integration SDK adapter, and optional Goal Mode status integration for AI coding agents",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Gilles Manzato",
|
|
@@ -8,9 +8,11 @@ const fs = require('node:fs');
|
|
|
8
8
|
const path = require('node:path');
|
|
9
9
|
const { goalStateFromEvent } = require('./goal-mode.cjs');
|
|
10
10
|
const { extractCheckpoint, extractNextAction, persistCheckpoint, persistNextAction } = require('./planning-store.cjs');
|
|
11
|
+
const { usesChinese } = require('./localize.cjs');
|
|
11
12
|
const { isGsdProject, stateReminder } = require('./planning.cjs');
|
|
12
13
|
const { releaseGsdProjectRuntimeState } = require('./state.cjs');
|
|
13
14
|
const { extractTaskResults, failedNativeTaskResults } = require('./task-results.cjs');
|
|
15
|
+
const { updateNoticeMessage } = require('./update-check.cjs');
|
|
14
16
|
|
|
15
17
|
function assistantMessageText(message) {
|
|
16
18
|
if (message?.role !== 'assistant' || !Array.isArray(message.content)) return '';
|
|
@@ -27,6 +29,7 @@ function registerLifecycleHandlers({
|
|
|
27
29
|
pi,
|
|
28
30
|
runtimeRoot,
|
|
29
31
|
state,
|
|
32
|
+
cancelUpdateCheck,
|
|
30
33
|
choosePendingContinuation,
|
|
31
34
|
forgetGoalModeState,
|
|
32
35
|
nativePhaseWriteBlock,
|
|
@@ -42,6 +45,7 @@ function registerLifecycleHandlers({
|
|
|
42
45
|
scheduleOnboardingPrompt,
|
|
43
46
|
setNativeRuntimeSignal,
|
|
44
47
|
showNativeStatusOverlay,
|
|
48
|
+
startUpdateCheck,
|
|
45
49
|
startGraphifyAutoUpdate,
|
|
46
50
|
trackGraphifyHead,
|
|
47
51
|
trackGsdTaskProgress,
|
|
@@ -70,6 +74,10 @@ function registerLifecycleHandlers({
|
|
|
70
74
|
if (!ctx.hasUI) return;
|
|
71
75
|
const reminder = stateReminder(ctx.cwd);
|
|
72
76
|
if (reminder) ctx.ui.notify(reminder, 'info');
|
|
77
|
+
startUpdateCheck((notice) => {
|
|
78
|
+
ctx.ui.notify(updateNoticeMessage(notice, usesChinese(ctx.cwd)), 'info');
|
|
79
|
+
updateStatus(ctx);
|
|
80
|
+
});
|
|
73
81
|
});
|
|
74
82
|
|
|
75
83
|
try {
|
|
@@ -88,6 +96,7 @@ function registerLifecycleHandlers({
|
|
|
88
96
|
}
|
|
89
97
|
|
|
90
98
|
pi.on('session_shutdown', (_event, ctx) => {
|
|
99
|
+
cancelUpdateCheck();
|
|
91
100
|
forgetGoalModeState(ctx);
|
|
92
101
|
releaseGsdProjectRuntimeState(state, ctx.cwd);
|
|
93
102
|
});
|
package/src/extension/status.cjs
CHANGED
|
@@ -12,6 +12,7 @@ const { localizedPlanProgress, planProgress } = require('./phases.cjs');
|
|
|
12
12
|
const { checkpointRecoveryLines, readNextAction, resumableCheckpoint } = require('./planning-store.cjs');
|
|
13
13
|
const { isGsdProject, stateSnapshot } = require('./planning.cjs');
|
|
14
14
|
const { nativeTaskRecovery, nativeTaskRecoveryLines } = require('./task-results.cjs');
|
|
15
|
+
const { updateNoticeStatus } = require('./update-check.cjs');
|
|
15
16
|
|
|
16
17
|
function contextUsageFor(ctx) {
|
|
17
18
|
if (typeof ctx?.getContextUsage !== 'function') return null;
|
|
@@ -50,7 +51,7 @@ function widgetColor(code, text) {
|
|
|
50
51
|
/**
|
|
51
52
|
* Status surfaces bound to the shared runtime state, Goal Mode and native task tracking.
|
|
52
53
|
*/
|
|
53
|
-
function createStatusSurface({ state, goalModeStateFor, nativeTaskActivityCount, nativeTaskExecutionSnapshot }) {
|
|
54
|
+
function createStatusSurface({ state, goalModeStateFor, nativeTaskActivityCount, nativeTaskExecutionSnapshot, updateNotice }) {
|
|
54
55
|
const { nativeRuntimeSignals } = state;
|
|
55
56
|
|
|
56
57
|
function setNativeRuntimeSignal(cwd, signal) {
|
|
@@ -279,6 +280,8 @@ function createStatusSurface({ state, goalModeStateFor, nativeTaskActivityCount,
|
|
|
279
280
|
if (signal?.kind === 'compacting') statusParts.push(chinese ? '压缩中' : 'compacting');
|
|
280
281
|
if (signal?.kind === 'retrying') statusParts.push(chinese ? `重试 ${signal.attempt}/${signal.maxAttempts}` : `retry ${signal.attempt}/${signal.maxAttempts}`);
|
|
281
282
|
if (usage) statusParts.push(`${usage.percent}% ${chinese ? '上下文' : 'context'}`);
|
|
283
|
+
const pendingUpdate = updateNotice();
|
|
284
|
+
if (pendingUpdate) statusParts.push(updateNoticeStatus(pendingUpdate, chinese));
|
|
282
285
|
const statusText = statusParts.join(' · ');
|
|
283
286
|
if (typeof ctx.ui.setWidget === 'function') ctx.ui.setWidget('gsd', widgetLines(ctx.cwd, goalState), { placement: 'aboveEditor' });
|
|
284
287
|
if (typeof ctx.ui.setStatus === 'function') {
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Background "gsd-for-omp update available" check for GSD project sessions.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors GSD Core's SessionStart update check: the registry lookup runs in the
|
|
7
|
+
* background, its result is cached for a day, and failures never surface. The
|
|
8
|
+
* extension shows at most one notification per instance plus a footer marker.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const fs = require('node:fs');
|
|
12
|
+
const os = require('node:os');
|
|
13
|
+
const path = require('node:path');
|
|
14
|
+
const { spawn } = require('node:child_process');
|
|
15
|
+
const packageJson = require('../../package.json');
|
|
16
|
+
|
|
17
|
+
const PACKAGE_NAME = packageJson.name;
|
|
18
|
+
const MANIFEST_NAME = '.gsd-for-omp-manifest.json';
|
|
19
|
+
const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
20
|
+
const FAILED_CHECK_RETRY_MS = 60 * 60 * 1000;
|
|
21
|
+
const NPM_VIEW_TIMEOUT_MS = 15_000;
|
|
22
|
+
const MAX_NPM_OUTPUT = 64 * 1024;
|
|
23
|
+
|
|
24
|
+
function parseVersion(value) {
|
|
25
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)$/.exec(String(value ?? '').trim());
|
|
26
|
+
return match ? match.slice(1).map(Number) : null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function isNewerVersion(candidate, current) {
|
|
30
|
+
const a = parseVersion(candidate);
|
|
31
|
+
const b = parseVersion(current);
|
|
32
|
+
if (!a || !b) return false;
|
|
33
|
+
for (let index = 0; index < 3; index += 1) {
|
|
34
|
+
if (a[index] !== b[index]) return a[index] > b[index];
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function enabledFlag(value) {
|
|
40
|
+
return value !== undefined && value !== '' && !/^(0|false|no|off)$/i.test(String(value));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function updateCheckDisabled(env) {
|
|
44
|
+
return enabledFlag(env.GSD_FOR_OMP_NO_UPDATE_CHECK)
|
|
45
|
+
|| enabledFlag(env.NO_UPDATE_NOTIFIER)
|
|
46
|
+
|| enabledFlag(env.CI);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function defaultCacheFile(env) {
|
|
50
|
+
const cacheRoot = env.XDG_CACHE_HOME ? path.resolve(env.XDG_CACHE_HOME) : path.join(os.homedir(), '.cache');
|
|
51
|
+
return path.join(cacheRoot, PACKAGE_NAME, 'update-check.json');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Resolve the npm `latest` version through the user's npm configuration, the
|
|
56
|
+
* same lookup `gsd-for-omp update` performs. Bounded, abortable, never throws.
|
|
57
|
+
*/
|
|
58
|
+
function npmLatestVersion({ signal, timeout = NPM_VIEW_TIMEOUT_MS, spawnChild = spawn } = {}) {
|
|
59
|
+
return new Promise((resolve) => {
|
|
60
|
+
let child;
|
|
61
|
+
let stdout = '';
|
|
62
|
+
let settled = false;
|
|
63
|
+
let timeoutTimer;
|
|
64
|
+
let killTimer;
|
|
65
|
+
const finish = (version = null) => {
|
|
66
|
+
if (settled) return;
|
|
67
|
+
settled = true;
|
|
68
|
+
clearTimeout(timeoutTimer);
|
|
69
|
+
clearTimeout(killTimer);
|
|
70
|
+
signal?.removeEventListener('abort', stop);
|
|
71
|
+
resolve(version);
|
|
72
|
+
};
|
|
73
|
+
function stop() {
|
|
74
|
+
try { child?.kill('SIGTERM'); } catch { /* already exited */ }
|
|
75
|
+
killTimer = setTimeout(() => {
|
|
76
|
+
try { child?.kill('SIGKILL'); } catch { /* already exited */ }
|
|
77
|
+
finish();
|
|
78
|
+
}, 250);
|
|
79
|
+
}
|
|
80
|
+
if (signal?.aborted) {
|
|
81
|
+
finish();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
child = spawnChild('npm', ['view', PACKAGE_NAME, 'version', '--json'], {
|
|
86
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
87
|
+
windowsHide: true,
|
|
88
|
+
});
|
|
89
|
+
} catch {
|
|
90
|
+
finish();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
child.stdout.setEncoding('utf8');
|
|
94
|
+
child.stdout.on('data', (chunk) => {
|
|
95
|
+
if (stdout.length < MAX_NPM_OUTPUT) stdout += chunk;
|
|
96
|
+
});
|
|
97
|
+
child.on('error', () => finish());
|
|
98
|
+
child.on('close', (code) => {
|
|
99
|
+
if (code !== 0) return finish();
|
|
100
|
+
try {
|
|
101
|
+
const version = JSON.parse(stdout);
|
|
102
|
+
finish(typeof version === 'string' && parseVersion(version) ? version.trim() : null);
|
|
103
|
+
} catch {
|
|
104
|
+
finish();
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
signal?.addEventListener('abort', stop, { once: true });
|
|
108
|
+
timeoutTimer = setTimeout(stop, timeout);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Per-instance update check. Every dependency is injectable so tests never
|
|
114
|
+
* touch the network or the user's cache directory.
|
|
115
|
+
*/
|
|
116
|
+
function createUpdateCheck({
|
|
117
|
+
runtimeRoot,
|
|
118
|
+
env = process.env,
|
|
119
|
+
now = Date.now,
|
|
120
|
+
currentVersion = packageJson.version,
|
|
121
|
+
latestVersion = npmLatestVersion,
|
|
122
|
+
cacheFile,
|
|
123
|
+
} = {}) {
|
|
124
|
+
const cachePath = cacheFile || defaultCacheFile(env);
|
|
125
|
+
let latest = null;
|
|
126
|
+
let notice = null;
|
|
127
|
+
let notified = false;
|
|
128
|
+
let pending = null;
|
|
129
|
+
let controller = null;
|
|
130
|
+
|
|
131
|
+
function readCache() {
|
|
132
|
+
try {
|
|
133
|
+
const cached = JSON.parse(fs.readFileSync(cachePath, 'utf8'));
|
|
134
|
+
if (!cached || typeof cached !== 'object' || !Number.isFinite(cached.checkedAt)) return null;
|
|
135
|
+
return {
|
|
136
|
+
checkedAt: cached.checkedAt,
|
|
137
|
+
latest: parseVersion(cached.latest) ? cached.latest : null,
|
|
138
|
+
ok: cached.ok === true,
|
|
139
|
+
};
|
|
140
|
+
} catch {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function writeCache(record) {
|
|
146
|
+
const temporary = `${cachePath}.${process.pid}.tmp`;
|
|
147
|
+
try {
|
|
148
|
+
fs.mkdirSync(path.dirname(cachePath), { recursive: true });
|
|
149
|
+
fs.writeFileSync(temporary, `${JSON.stringify(record)}\n`);
|
|
150
|
+
fs.renameSync(temporary, cachePath);
|
|
151
|
+
} catch {
|
|
152
|
+
try { fs.rmSync(temporary, { force: true }); } catch { /* best effort */ }
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function projectedVersion() {
|
|
157
|
+
try {
|
|
158
|
+
const version = JSON.parse(fs.readFileSync(path.join(runtimeRoot, MANIFEST_NAME), 'utf8'))?.version;
|
|
159
|
+
return typeof version === 'string' ? version : null;
|
|
160
|
+
} catch {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function computeNotice() {
|
|
166
|
+
if (isNewerVersion(latest, currentVersion)) return { kind: 'available', latest, current: currentVersion, root: runtimeRoot };
|
|
167
|
+
const projected = projectedVersion();
|
|
168
|
+
if (projected && projected !== currentVersion) return { kind: 'reinstall', projected, current: currentVersion, root: runtimeRoot };
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function announce(onNotice) {
|
|
173
|
+
notice = computeNotice();
|
|
174
|
+
if (!notice || notified) return;
|
|
175
|
+
notified = true;
|
|
176
|
+
try { onNotice(notice); } catch { /* advisory only */ }
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Show what is already known (fresh or stale cache, projection drift) and
|
|
181
|
+
* refresh the registry result in the background when the cache is stale.
|
|
182
|
+
*/
|
|
183
|
+
function startUpdateCheck(onNotice) {
|
|
184
|
+
if (updateCheckDisabled(env)) return;
|
|
185
|
+
const cached = readCache();
|
|
186
|
+
if (cached?.latest) latest = cached.latest;
|
|
187
|
+
const age = cached ? now() - cached.checkedAt : Infinity;
|
|
188
|
+
const fresh = age >= 0 && age < (cached?.ok ? CHECK_INTERVAL_MS : FAILED_CHECK_RETRY_MS);
|
|
189
|
+
if (fresh || pending) {
|
|
190
|
+
announce(onNotice);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
// A stale cached version is still a valid lower bound for "newer than installed".
|
|
194
|
+
if (isNewerVersion(latest, currentVersion)) announce(onNotice);
|
|
195
|
+
controller = new AbortController();
|
|
196
|
+
const { signal } = controller;
|
|
197
|
+
pending = Promise.resolve()
|
|
198
|
+
.then(() => latestVersion({ signal }))
|
|
199
|
+
.catch(() => null)
|
|
200
|
+
.then((version) => {
|
|
201
|
+
if (signal.aborted) return;
|
|
202
|
+
const resolved = parseVersion(version) ? String(version).trim() : null;
|
|
203
|
+
writeCache({ checkedAt: now(), latest: resolved || latest, ok: Boolean(resolved) });
|
|
204
|
+
if (resolved) latest = resolved;
|
|
205
|
+
announce(onNotice);
|
|
206
|
+
})
|
|
207
|
+
.finally(() => {
|
|
208
|
+
pending = null;
|
|
209
|
+
controller = null;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function cancelUpdateCheck() {
|
|
214
|
+
controller?.abort();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
cancelUpdateCheck,
|
|
219
|
+
startUpdateCheck,
|
|
220
|
+
updateNotice: () => notice,
|
|
221
|
+
_pendingUpdateCheck: () => pending,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function shellQuote(value) {
|
|
226
|
+
return /^[\w@%+=:,./-]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The suggested command always names the active runtime root: a terminal
|
|
231
|
+
* without this OMP session's PI_CODING_AGENT_DIR would otherwise target
|
|
232
|
+
* ~/.omp/agent and leave a custom-root projection stale.
|
|
233
|
+
*/
|
|
234
|
+
function noticeCommand(notice, command) {
|
|
235
|
+
return `gsd-for-omp ${command} --root ${shellQuote(notice.root)}`;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function updateNoticeMessage(notice, chinese) {
|
|
239
|
+
if (notice.kind === 'available') {
|
|
240
|
+
const command = noticeCommand(notice, 'update');
|
|
241
|
+
return chinese
|
|
242
|
+
? `gsd-for-omp ${notice.latest} 已发布(当前 ${notice.current})。请在终端运行 \`${command}\`,然后重启 OMP。`
|
|
243
|
+
: `gsd-for-omp ${notice.latest} is available (installed ${notice.current}). Run \`${command}\` in a terminal, then restart OMP.`;
|
|
244
|
+
}
|
|
245
|
+
const command = noticeCommand(notice, 'install');
|
|
246
|
+
return chinese
|
|
247
|
+
? `已安装 gsd-for-omp ${notice.current},但 OMP 文件仍由 ${notice.projected} 生成。请在终端运行 \`${command}\`,然后重启 OMP。`
|
|
248
|
+
: `gsd-for-omp ${notice.current} is installed but the OMP files were generated by ${notice.projected}. Run \`${command}\` in a terminal, then restart OMP.`;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function updateNoticeStatus(notice, chinese) {
|
|
252
|
+
if (notice.kind === 'available') return chinese ? `⬆ 可更新 ${notice.latest}` : `⬆ ${notice.latest}`;
|
|
253
|
+
return chinese ? '⬆ 需重新安装' : '⬆ reinstall';
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
module.exports = {
|
|
257
|
+
createUpdateCheck,
|
|
258
|
+
npmLatestVersion,
|
|
259
|
+
updateCheckDisabled,
|
|
260
|
+
updateNoticeMessage,
|
|
261
|
+
updateNoticeStatus,
|
|
262
|
+
};
|
package/src/extension.cjs
CHANGED
|
@@ -35,6 +35,7 @@ const { createSessionControls } = require('./extension/session-controls.cjs');
|
|
|
35
35
|
const { createRuntimeState } = require('./extension/state.cjs');
|
|
36
36
|
const { createStatusSurface } = require('./extension/status.cjs');
|
|
37
37
|
const { createTaskResultsWriter } = require('./extension/task-results.cjs');
|
|
38
|
+
const { createUpdateCheck } = require('./extension/update-check.cjs');
|
|
38
39
|
|
|
39
40
|
module.exports = function gsdPiExtension(pi, options = {}) {
|
|
40
41
|
if (!pi || typeof pi !== 'object') {
|
|
@@ -56,7 +57,8 @@ module.exports = function gsdPiExtension(pi, options = {}) {
|
|
|
56
57
|
const toolHooks = createToolHooks({ pi, state });
|
|
57
58
|
const taskResults = createTaskResultsWriter();
|
|
58
59
|
const { invokeAsync } = createCliBridge({ agentsDir, cliPath });
|
|
59
|
-
const
|
|
60
|
+
const updateCheck = createUpdateCheck({ runtimeRoot, ...options.updateCheck });
|
|
61
|
+
const status = createStatusSurface({ state, ...goalMode, ...taskTracker, updateNotice: updateCheck.updateNotice });
|
|
60
62
|
const nativeUi = createNativeUi({ pi, ...status });
|
|
61
63
|
const sessionControls = createSessionControls({ pi, ...goalMode, ...taskTracker, ...status });
|
|
62
64
|
const onboarding = createOnboarding({ state, ...status });
|
|
@@ -92,6 +94,7 @@ module.exports = function gsdPiExtension(pi, options = {}) {
|
|
|
92
94
|
...nativeUi,
|
|
93
95
|
...onboarding,
|
|
94
96
|
...continuation,
|
|
97
|
+
...updateCheck,
|
|
95
98
|
});
|
|
96
99
|
|
|
97
100
|
gsdPiExtension._internals = {
|
|
@@ -100,6 +103,7 @@ module.exports = function gsdPiExtension(pi, options = {}) {
|
|
|
100
103
|
widgetLines: status.widgetLines,
|
|
101
104
|
_nativeTaskActivityCount: taskTracker.nativeTaskActivityCount,
|
|
102
105
|
_nativeTaskExecutionSnapshot: taskTracker.nativeTaskExecutionSnapshot,
|
|
106
|
+
_pendingUpdateCheck: updateCheck._pendingUpdateCheck,
|
|
103
107
|
};
|
|
104
108
|
};
|
|
105
109
|
|