dsh-jira-work-overview 0.15.0 → 0.15.1
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 +14 -0
- package/README.md +2 -1
- package/README.zh.md +1 -1
- package/index.js +34 -7
- package/package.json +1 -1
- package/test/dsh-jira-credential.mjs +25 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,20 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.15.1] - 2026-11-19
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **四条 `/api` 路由在真宿主里根本没注册 —— 配置页「读取令牌状态失败:HTTP 404」的根因。** 插件在 `apply()`
|
|
14
|
+
里同步 `ctx.get('connection')` 取 Fetch 注册表;而 `client-connection` 的 `apply` 是异步的(先建 BrowserAuth
|
|
15
|
+
的密钥),同一个加载批里它还没 provide,`ctx.get` 只返回 `undefined`,之后也不会有人再补 —— 角标状态 / 状态流转 /
|
|
16
|
+
令牌配置 / 配置写入四条路由就这样静默丢掉(Host 侧只剩三行「这个 profile 没有 connection.fetch 服务」的 note,
|
|
17
|
+
浏览器侧 `GET /api/jira-work-overview/credential` 直接 404)。现在四条路由统一走 `ctx.inject(['connection'], …)`,
|
|
18
|
+
等服务就绪再注册(服务重建时会重跑);没有 `ctx.inject` 的老宿主 / 离线测试桩仍退回同步读取。
|
|
19
|
+
- `test/dsh-jira-credential.mjs` 的宿主桩改成真宿主的时序:加载时 `ctx.get('connection')` 返回 `undefined`,
|
|
20
|
+
只有 `inject` 回调能看到它;回调执行后必须凑满 4 条路由,否则打印 `FAIL` 并以 1 退出。这条回归以前是
|
|
21
|
+
「离线测试全绿、真机路由全 404」。
|
|
22
|
+
|
|
9
23
|
## [0.15.0] - 2026-11-19
|
|
10
24
|
|
|
11
25
|
改状态变轻了(不再为一行变化重拉整个列表),也不会再被自己的操作通知一次;面板的失败提示按类型说话。
|
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ Show **your** Jira work items — with their real workflow status — inside [De
|
|
|
33
33
|
DSH installs plugins from an **installation spec** — anything `pnpm add` accepts (registry package name, git URL, tarball, absolute path). Pick one:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
# 1) from the npm registry (published since 0.14.0; pin a version with @0.
|
|
36
|
+
# 1) from the npm registry (published since 0.14.0; pin a version with @0.15.1)
|
|
37
37
|
plugin_manager install_bundle(target="dsh-jira-work-overview")
|
|
38
38
|
|
|
39
39
|
# 2) straight from GitHub (no npm publishing needed)
|
|
@@ -152,6 +152,7 @@ The plugin's own copy follows the DSH language setting; English and Chinese ship
|
|
|
152
152
|
| `Cannot reach https://… (…): ECONNRESET` / `HTTP 000` | your machine cannot reach Jira right now (VPN/proxy/network), not a plugin bug |
|
|
153
153
|
| "No matching work items" with no error row | the query returned nothing — widen the status filter or the project tab |
|
|
154
154
|
| footer says "live watch unavailable" | the Electron shell did not expose a fetch transport; the panel/badge degrade, tools still work |
|
|
155
|
+
| configure dialog says "Reading the token state failed: HTTP 404" | the plugin's `/api` routes were not registered (the host loaded the plugin before its connection service existed) — reload the plugin; a fixed build registers them once the service is up |
|
|
155
156
|
| footer says "live watch disconnected" | transient transport error; it retries with backoff |
|
|
156
157
|
| token rejected when saving | the email + token pair is wrong, or the token has no Jira access |
|
|
157
158
|
| panel says "No Jira token yet" | nothing is configured yet: click **Configure** and paste an API token (or set `JIRA_API_TOKEN`) |
|
package/README.zh.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
DSH 用**安装 spec** 装插件 —— 凡是 `pnpm add` 能吃的写法都行(registry 包名、git 地址、tarball、绝对路径)。选一个:
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
# 1) 从 npm 装(0.14.0 起已发布;要钉版本就在后面写 @0.
|
|
22
|
+
# 1) 从 npm 装(0.14.0 起已发布;要钉版本就在后面写 @0.15.1)
|
|
23
23
|
plugin_manager install_bundle(target="dsh-jira-work-overview")
|
|
24
24
|
|
|
25
25
|
# 2) 直接从 GitHub 装(不需要 npm 发布)
|
package/index.js
CHANGED
|
@@ -222,6 +222,7 @@ const TEXT = {
|
|
|
222
222
|
'note.noCredentialRouteError': '未注册令牌配置通道({path}):{message}',
|
|
223
223
|
'note.noSettingsRoute': '未注册配置写入通道({path}):这个 profile 没有 connection.fetch 服务;仍可直接改 profile 的 cordis.patch.yml。',
|
|
224
224
|
'note.noSettingsRouteError': '未注册配置写入通道({path}):{message}',
|
|
225
|
+
'note.noRouteInject': '未能等待 connection 服务就绪({message}),已改为立即注册 /api 通道。',
|
|
225
226
|
'note.credUnavailable': '凭据服务不可用,{key} 仍从配置里的明文 token 读取。',
|
|
226
227
|
'note.tokenMigrated': '已把配置里的明文 token 迁移进 DSH 凭据库({key}),可以从插件配置里删除 apiToken 了。',
|
|
227
228
|
'note.tokenMigrateUnreadable': '凭据库写入 {key} 后读不回来,仍从配置里的明文 token 读取。',
|
|
@@ -387,6 +388,7 @@ const TEXT = {
|
|
|
387
388
|
'note.noCredentialRouteError': 'Did not register the token config channel ({path}): {message}',
|
|
388
389
|
'note.noSettingsRoute': 'Did not register the settings write channel ({path}): this profile has no connection.fetch service; you can still edit the profile cordis.patch.yml directly.',
|
|
389
390
|
'note.noSettingsRouteError': 'Did not register the settings write channel ({path}): {message}',
|
|
391
|
+
'note.noRouteInject': 'Could not wait for the connection service ({message}); registered the /api channels immediately.',
|
|
390
392
|
'note.credUnavailable': 'Credential service unavailable; {key} is still read from the plaintext token in config.',
|
|
391
393
|
'note.tokenMigrated': 'Migrated the plaintext token from config into the DSH credential store ({key}); you can remove apiToken from the plugin config now.',
|
|
392
394
|
'note.tokenMigrateUnreadable': 'Wrote {key} into the credential store but could not read it back; still reading the plaintext token from config.',
|
|
@@ -650,13 +652,7 @@ export function apply(ctx, config) {
|
|
|
650
652
|
|
|
651
653
|
// 后台监视:本机定时轮询 + 变化时的系统通知;面板角标通过 /api 之下的精确 Fetch 路由读同一份状态。
|
|
652
654
|
jira.watch = startWatcher(ctx, jira, settings);
|
|
653
|
-
|
|
654
|
-
// 面板里「改状态」用的通道(GET 列可用流转 / POST 执行流转)。
|
|
655
|
-
registerTransitionRoute(ctx, jira);
|
|
656
|
-
// 插件配置页里的令牌填写通道(GET 打码状态 / POST 保存或清除),仍写同一个凭据库键。
|
|
657
|
-
registerCredentialRoute(ctx, jira, settings);
|
|
658
|
-
// 面板「配置」里的后台监视表单(轮询开关 / 间隔 / 通知)走宿主 settings 服务写 volatile 字段。
|
|
659
|
-
registerSettingsRoute(ctx, jira, settings);
|
|
655
|
+
registerApiRoutes(ctx, jira, settings);
|
|
660
656
|
|
|
661
657
|
ctx.tools.register(myWorkTool(jira, settings));
|
|
662
658
|
ctx.tools.register(issueTool(jira, settings));
|
|
@@ -668,6 +664,37 @@ export function apply(ctx, config) {
|
|
|
668
664
|
if (settings.apiToken) void migrateLegacyToken(ctx, jira, settings);
|
|
669
665
|
}
|
|
670
666
|
|
|
667
|
+
/**
|
|
668
|
+
* 四条 /api 精确 Fetch 路由(角标状态 / 状态流转 / 令牌配置 / 配置写入)。
|
|
669
|
+
*
|
|
670
|
+
* **必须等 connection 服务就绪再注册。** client-connection 的 apply 是异步的(要先建 BrowserAuth
|
|
671
|
+
* 的密钥),同一批加载时同步 `ctx.get('connection')` 拿到的是 undefined,而且之后不会有人再补——
|
|
672
|
+
* 旧实现就是这样把四条路由全部静默丢掉的:Host 侧只有三行「没有 connection.fetch 服务」的 note,
|
|
673
|
+
* 浏览器侧 GET /api/jira-work-overview/credential 直接 404(配置页显示「读取令牌状态失败:HTTP 404」)。
|
|
674
|
+
* `ctx.inject` 的回调在服务 provide 之后才跑(服务重建时还会重跑),路由的生命周期挂在那个上下文上。
|
|
675
|
+
*/
|
|
676
|
+
function registerApiRoutes(ctx, jira, settings) {
|
|
677
|
+
const install = (routeCtx) => {
|
|
678
|
+
registerWatchRoute(routeCtx, jira, jira.watch);
|
|
679
|
+
// 面板里「改状态」用的通道(GET 列可用流转 / POST 执行流转)。
|
|
680
|
+
registerTransitionRoute(routeCtx, jira);
|
|
681
|
+
// 插件配置页里的令牌填写通道(GET 打码状态 / POST 保存或清除),仍写同一个凭据库键。
|
|
682
|
+
registerCredentialRoute(routeCtx, jira, settings);
|
|
683
|
+
// 面板「配置」里的后台监视表单(轮询开关 / 间隔 / 通知)走宿主 settings 服务写 volatile 字段。
|
|
684
|
+
registerSettingsRoute(routeCtx, jira, settings);
|
|
685
|
+
};
|
|
686
|
+
if (typeof ctx?.inject === 'function') {
|
|
687
|
+
try {
|
|
688
|
+
ctx.inject(['connection'], install);
|
|
689
|
+
return;
|
|
690
|
+
} catch (error) {
|
|
691
|
+
jira.notes.push(t('note.noRouteInject', { message: error?.message ?? error }));
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
// 老宿主 / 离线测试桩没有 ctx.inject:退回同步读取。
|
|
695
|
+
install(ctx);
|
|
696
|
+
}
|
|
697
|
+
|
|
671
698
|
/**
|
|
672
699
|
* 同一个操作只实现一次:工具给 agent 用,斜杠命令给人在命令面里直接用
|
|
673
700
|
* (命令结果不进入模型消息)。这里用 ctx.get 而不是 inject,避免在没有
|
package/package.json
CHANGED
|
@@ -284,6 +284,13 @@ const settingsService = {
|
|
|
284
284
|
settingsWrites.push({ ns, ops, expectedRevision });
|
|
285
285
|
},
|
|
286
286
|
};
|
|
287
|
+
// 照真宿主的时序搭桩:client-connection 的 apply 是异步的(要先建 BrowserAuth 密钥),同一个
|
|
288
|
+
// 加载批里 ctx.get('connection') 还是 undefined,只有 ctx.inject 的回调会在服务 provide 之后跑。
|
|
289
|
+
// 旧实现同步 ctx.get 拿不到就永久丢掉四条路由(浏览器侧 GET /api/jira-work-overview/credential 404),
|
|
290
|
+
// 这里让这种回归直接失败。
|
|
291
|
+
const connectionService = { fetch: { register(route) { watchRoutes.push(route); return async () => {}; } } };
|
|
292
|
+
let connectionReady = false;
|
|
293
|
+
const pendingInjects = [];
|
|
287
294
|
const hostCtx = {
|
|
288
295
|
get(name) {
|
|
289
296
|
if (name === CRED) return credentials;
|
|
@@ -291,11 +298,13 @@ const hostCtx = {
|
|
|
291
298
|
if (name === 'commands') {
|
|
292
299
|
return { register(definition) { hostCommands.push(definition); return () => {}; } };
|
|
293
300
|
}
|
|
294
|
-
if (name === 'connection')
|
|
295
|
-
return { fetch: { register(route) { watchRoutes.push(route); return async () => {}; } } };
|
|
296
|
-
}
|
|
301
|
+
if (name === 'connection') return connectionReady ? connectionService : undefined;
|
|
297
302
|
return undefined;
|
|
298
303
|
},
|
|
304
|
+
inject(deps, callback) {
|
|
305
|
+
pendingInjects.push({ deps: Array.isArray(deps) ? deps : [], callback });
|
|
306
|
+
return {};
|
|
307
|
+
},
|
|
299
308
|
tools: { register(definition) { hostTools.set(definition.name, definition); } },
|
|
300
309
|
};
|
|
301
310
|
|
|
@@ -317,6 +326,19 @@ host.apply(hostCtx, hostConfig);
|
|
|
317
326
|
const hostCommand = hostCommands.find((row) => row.name === 'jira');
|
|
318
327
|
console.log('host: tools =', [...hostTools.keys()].join(','), '| commands =', hostCommands.map((row) => row.name).join(','));
|
|
319
328
|
|
|
329
|
+
/* 服务就绪:真宿主里 client-connection 稍后才 provide,插件必须用 ctx.inject 等它。 */
|
|
330
|
+
console.log('加载时 connection 已就绪:', connectionReady, '(真宿主为 false)| 待执行 inject 回调:', pendingInjects.length);
|
|
331
|
+
const connectionInjects = pendingInjects.filter((row) => row.deps.includes('connection'));
|
|
332
|
+
if (connectionInjects.length === 0) {
|
|
333
|
+
console.log('FAIL: 插件没有通过 ctx.inject 等 connection 就绪 —— 同步 ctx.get 会永久丢掉四条 /api 路由(浏览器侧 404)');
|
|
334
|
+
process.exit(1);
|
|
335
|
+
}
|
|
336
|
+
connectionReady = true;
|
|
337
|
+
// 回调收到的是拿到该服务的子上下文;其余服务照旧从同一份桩里取。
|
|
338
|
+
const readyCtx = { get: (name) => hostCtx.get(name), inject: hostCtx.inject, tools: hostCtx.tools };
|
|
339
|
+
for (const row of connectionInjects) row.callback(readyCtx);
|
|
340
|
+
console.log('connection 就绪后注册的路由数:', watchRoutes.length, '(期望 4)');
|
|
341
|
+
|
|
320
342
|
/* --------------------------------------------------------- client 半边 */
|
|
321
343
|
|
|
322
344
|
const calls = [];
|