dsh-jira-tasks 1.0.7 → 1.0.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.en.md +19 -13
- package/README.md +20 -14
- package/lib/client.js +78 -30
- package/lib/index.js +16 -6
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -59,11 +59,17 @@ In a DSH session, use the Cordis tools: `cordis_define` (`kind: new`, `idPrefix:
|
|
|
59
59
|
Open **Settings → Plugins → Plugin configuration → JIRA** and fill in:
|
|
60
60
|
|
|
61
61
|
- **JIRA base URL**: e.g. `http://jira.example.com/` (stored in the user settings document and read back by the form)
|
|
62
|
-
- **Access token / PAT**: written to the credential store (`$DSH_HOME/.credentials.yaml`)
|
|
62
|
+
- **Access token / PAT**: written to the credential store (`$DSH_HOME/.credentials.yaml`) under the plugin-owned ref `JIRA_TASKS_TOKEN`; the browser only ever sees "configured", never the token itself
|
|
63
63
|
|
|
64
64
|
Leaving the token blank on save keeps the existing one; clearing the address on save removes the override and falls back to the environment. Auth is auto-detected: tokens containing `:` use Basic, otherwise Bearer (JIRA PAT).
|
|
65
65
|
|
|
66
|
-
> **
|
|
66
|
+
> **The settings-page token takes precedence over the environment.** When the environment that launched DSH already defines `JIRA_API_TOKEN` (a Windows *user-level* variable counts), the card is still editable: it stores the token in its own ref `JIRA_TASKS_TOKEN`, which DSH accepts (it only refuses to write a ref the launching environment shadows), and the Host resolves tokens in this order:
|
|
67
|
+
>
|
|
68
|
+
> ```
|
|
69
|
+
> JIRA_TASKS_TOKEN (settings card) > JIRA_API_TOKEN > JIRA_TOKEN
|
|
70
|
+
> ```
|
|
71
|
+
>
|
|
72
|
+
> Click **Clear settings token** in the card to fall back to the environment variable again.
|
|
67
73
|
|
|
68
74
|
#### Connection test
|
|
69
75
|
|
|
@@ -81,7 +87,7 @@ JIRA_API_TOKEN: "<PAT or user:token>"
|
|
|
81
87
|
```
|
|
82
88
|
|
|
83
89
|
- Base URL aliases: `JIRA_BASE_URL` / `JIRA_URL`
|
|
84
|
-
- Token
|
|
90
|
+
- Token resolution order: `JIRA_TASKS_TOKEN` (written by the settings card) → `JIRA_API_TOKEN` → `JIRA_TOKEN`; the first match wins
|
|
85
91
|
|
|
86
92
|
### 2. Project key and JQL (per workspace)
|
|
87
93
|
|
|
@@ -117,17 +123,17 @@ dsh plugin --profile web remove dsh-jira-tasks
|
|
|
117
123
|
</details>
|
|
118
124
|
|
|
119
125
|
<details>
|
|
120
|
-
<summary>
|
|
126
|
+
<summary>Can the settings card override the token from the environment?</summary>
|
|
121
127
|
|
|
122
|
-
|
|
128
|
+
**Yes.** The card stores the token under the plugin-owned ref `JIRA_TASKS_TOKEN` instead of writing the environment's `JIRA_API_TOKEN`. DSH only refuses to write a ref the launching environment *shadows*, so its own ref is always writable: even with `JIRA_API_TOKEN` exported by the shell or the OS, the field accepts input, the save succeeds, and the Host prefers it:
|
|
123
129
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
- Windows (GUI): System Properties → Advanced → Environment Variables, delete the user variable
|
|
128
|
-
- macOS / Linux: remove the export from `~/.zshrc` / `~/.bashrc` (or equivalent) and reopen the terminal
|
|
130
|
+
```
|
|
131
|
+
JIRA_TASKS_TOKEN (settings card) > JIRA_API_TOKEN > JIRA_TOKEN
|
|
132
|
+
```
|
|
129
133
|
|
|
130
|
-
|
|
134
|
+
- The card names the effective source: with a saved token it says "overrides environment variable JIRA_API_TOKEN"; without one it says "currently using environment variable JIRA_API_TOKEN — fill in and save to override"
|
|
135
|
+
- Saving re-probes the connection; **Clear settings token (fall back to environment)** removes the override
|
|
136
|
+
- The one remaining case that reports `is supplied read-only by the launching environment` is someone exporting `JIRA_TASKS_TOKEN` itself — that ref really is read-only then; remove it (Windows: System Properties → Environment Variables, or PowerShell `[Environment]::SetEnvironmentVariable('JIRA_TASKS_TOKEN', $null, 'User')`) and restart DSH
|
|
131
137
|
</details>
|
|
132
138
|
|
|
133
139
|
<details>
|
|
@@ -147,14 +153,14 @@ Since v1.0.7 the card detects a read-only token, disables the field, and shows t
|
|
|
147
153
|
│ conversation.composer.dock (active) │ │ webServer route /jira/api/search │
|
|
148
154
|
│ conversation.input.dock (new, order:99) │ │ ↓ │
|
|
149
155
|
│ ↓ on mount/refresh fetch POST │ │ settings.get("jira-tasks") │
|
|
150
|
-
│ render: list / error / unconfigured │ │ credentials.resolve(
|
|
156
|
+
│ render: list / error / unconfigured │ │ credentials.resolve(TOKEN_REFS) │
|
|
151
157
|
│ localStorage per-workspace key/JQL │ │ subprocess.spawn(curl …) │
|
|
152
158
|
│ settings.plugin.item (Settings card) │ │ ↓ stdout JSON │
|
|
153
159
|
└────────────────────────────────────────────┘ │ parse issues → {ok,issues} │
|
|
154
160
|
└────────────────────────────────┘
|
|
155
161
|
```
|
|
156
162
|
|
|
157
|
-
- **Host**: registers the `jira-tasks` settings namespace (`baseUrl`, readable) and a `webServer` route `POST /jira/api/search`; the address comes from the settings document, the token from the `credentials` service (Settings card
|
|
163
|
+
- **Host**: registers the `jira-tasks` settings namespace (`baseUrl`, readable) and a `webServer` route `POST /jira/api/search`; the address comes from the settings document, the token from the `credentials` service resolved in the order `JIRA_TASKS_TOKEN` (written by the Settings card) → `JIRA_API_TOKEN` → `JIRA_TOKEN` (`$DSH_HOME/.credentials.yaml` / environment, hot-reloaded), so a saved card token overrides the environment; queries run through `subprocess` spawning `curl` directly, with the auth header passed via stdin (`--config -`) so the token never appears in argv.
|
|
158
164
|
- **Client**: a standard `window.__ModuleLoader__.load({ id, factory })` web bundle; registers `conversation.composer.dock` (active sessions) and `conversation.input.dock` (new sessions, flex `order: 99` below the input, aligned width), plus `settings.plugin.item` (`key: "jira-tasks"`) for the Settings card — the address is written through `settingsScope` and the token through `remote.credentials`.
|
|
159
165
|
- **Why not the `shell` service**: `shell` wraps commands with `sandbox-exec`, which is broken on some macOS versions (`sandbox_apply: Operation not permitted`); `subprocess` is the raw process seam without this issue.
|
|
160
166
|
- **New-session display**: the DSH shell does not render `composer.dock` during the hero (blank session) phase, so the plugin also registers `input.dock` and de-duplicates by "session has messages".
|
package/README.md
CHANGED
|
@@ -70,11 +70,17 @@ dsh plugin --profile web add github:liu3734/jira-tasks-dsh-plugin
|
|
|
70
70
|
打开 **设置 → 插件 → 插件配置 → JIRA**,填写:
|
|
71
71
|
|
|
72
72
|
- **JIRA 地址**:如 `http://jira.example.com/`(存入用户设置文档,可在界面回读)
|
|
73
|
-
- **访问令牌 / PAT**:写入凭据存储(`$DSH_HOME/.credentials.yaml`),前端只显示"已配置",不回传令牌本身
|
|
73
|
+
- **访问令牌 / PAT**:写入凭据存储(`$DSH_HOME/.credentials.yaml`,引用名是插件自有的 `JIRA_TASKS_TOKEN`),前端只显示"已配置",不回传令牌本身
|
|
74
74
|
|
|
75
75
|
留空并保存会保持已有令牌不变;地址留空并保存则清除设置项,回退到环境变量。认证自动识别:令牌含 `:` 用 Basic,否则用 Bearer(JIRA PAT)。
|
|
76
76
|
|
|
77
|
-
>
|
|
77
|
+
> **设置页令牌优先于环境变量**:启动 DSH 的环境里已有 `JIRA_API_TOKEN`(Windows 用户级环境变量也算)时,卡片照常可以输入并保存——保存的是插件自有引用 `JIRA_TASKS_TOKEN`,DSH 不会拒绝(它只拒绝写入会被环境遮蔽的同名引用),Host 解析时也把它排在环境变量之前:
|
|
78
|
+
>
|
|
79
|
+
> ```
|
|
80
|
+
> JIRA_TASKS_TOKEN(设置页) > JIRA_API_TOKEN > JIRA_TOKEN
|
|
81
|
+
> ```
|
|
82
|
+
>
|
|
83
|
+
> 想改回用环境变量,点卡片里的「清除设置页令牌」即可。
|
|
78
84
|
|
|
79
85
|
#### 连接测试
|
|
80
86
|
|
|
@@ -92,7 +98,7 @@ JIRA_API_TOKEN: "<PAT 或 user:token>"
|
|
|
92
98
|
```
|
|
93
99
|
|
|
94
100
|
- 地址别名:`JIRA_BASE_URL` / `JIRA_URL`
|
|
95
|
-
-
|
|
101
|
+
- 令牌解析顺序:`JIRA_TASKS_TOKEN`(设置页写入)→ `JIRA_API_TOKEN` → `JIRA_TOKEN`,前者优先
|
|
96
102
|
|
|
97
103
|
### 2. 项目 Key 与 JQL(按工作区)
|
|
98
104
|
|
|
@@ -131,17 +137,17 @@ dsh plugin --profile web remove dsh-jira-tasks
|
|
|
131
137
|
</details>
|
|
132
138
|
|
|
133
139
|
<details>
|
|
134
|
-
<summary
|
|
140
|
+
<summary>环境变量里的令牌,能不能在设置页覆盖?</summary>
|
|
135
141
|
|
|
136
|
-
`JIRA_API_TOKEN
|
|
142
|
+
**能。** 卡片把令牌保存到插件自有引用 `JIRA_TASKS_TOKEN`,而不是直接写环境变量用的 `JIRA_API_TOKEN`。DSH 只拒绝写入「会被启动环境遮蔽的同名引用」,插件自有引用不受影响,所以哪怕 shell / 系统里已导出 `JIRA_API_TOKEN`,设置页也能正常输入并保存,并且 Host 解析时优先用它:
|
|
137
143
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
- Windows(图形界面):系统属性 → 高级 → 环境变量,删除对应用户变量
|
|
142
|
-
- macOS / Linux:从 `~/.zshrc` / `~/.bashrc` 等启动脚本中移除后重开终端
|
|
144
|
+
```
|
|
145
|
+
JIRA_TASKS_TOKEN(设置页) > JIRA_API_TOKEN > JIRA_TOKEN
|
|
146
|
+
```
|
|
143
147
|
|
|
144
|
-
|
|
148
|
+
- 卡片会显示当前生效来源:已保存设置页令牌时提示「优先于环境变量 JIRA_API_TOKEN」;未保存时提示「当前使用环境变量 JIRA_API_TOKEN,填写并保存即可覆盖」
|
|
149
|
+
- 保存后自动重测连接;点「清除设置页令牌(回退到环境变量)」可删除覆盖值
|
|
150
|
+
- 唯一仍会报 `is supplied read-only by the launching environment` 的情况:有人把 `JIRA_TASKS_TOKEN` 本身也导出到了启动环境——那种情况下该引用确实只读,需先移除它(Windows:系统属性 → 环境变量,或 PowerShell `[Environment]::SetEnvironmentVariable('JIRA_TASKS_TOKEN', $null, 'User')`)并重启 DSH
|
|
145
151
|
</details>
|
|
146
152
|
|
|
147
153
|
<details>
|
|
@@ -161,15 +167,15 @@ v1.0.7 起卡片会检测只读令牌并直接禁用输入框、在卡片内给
|
|
|
161
167
|
│ conversation.composer.dock(活跃会话) │ │ webServer 路由 /jira/api/search │
|
|
162
168
|
│ conversation.input.dock(新会话) │ │ ↓ │
|
|
163
169
|
│ 面板 hero 布局(flex order:99) │ │ settings.get("jira-tasks").baseUrl │
|
|
164
|
-
│ ↓ 挂载 / 刷新时 fetch POST │ │ credentials.resolve(
|
|
170
|
+
│ ↓ 挂载 / 刷新时 fetch POST │ │ credentials.resolve(TOKEN_REFS) │
|
|
165
171
|
│ 渲染:任务列表 / 错误 / 未配置 │ │ subprocess.spawn(curl …) │
|
|
166
172
|
│ localStorage 按工作区存取项目 Key/JQL │ │ ↓ stdout JSON │
|
|
167
173
|
│ settings.plugin.item(设置页卡片) │ │ 解析 issues → 返回 {ok,issues} │
|
|
168
174
|
└────────────────────────────────────────┘ └────────────────────────────────────┘
|
|
169
175
|
```
|
|
170
176
|
|
|
171
|
-
- **Host**:注册 `settings` 命名空间 `jira-tasks`(`baseUrl`,可读)与 `webServer` 路由 `POST /jira/api/search`;地址优先读设置文档,令牌经 `credentials`
|
|
172
|
-
- **Client**:`window.__ModuleLoader__.load({ id, factory })` 标准 web bundle;注册 `conversation.composer.dock`(活跃会话,注册 `order: 5`)与 `conversation.input.dock`(新会话,注册 `order: 10`)。新会话面板走 hero 布局:面板元素自身 `flex order: 99` 排在输入框之后下方,并以 `--dsh-composer-side-clearance` / `--dsh-composer-card-max-width` 与输入卡等宽。另注册 `settings.plugin.item`(`key: "jira-tasks"`)作为设置页卡片:地址经 `settingsScope` 写入命名空间,令牌经 `remote.credentials`
|
|
177
|
+
- **Host**:注册 `settings` 命名空间 `jira-tasks`(`baseUrl`,可读)与 `webServer` 路由 `POST /jira/api/search`;地址优先读设置文档,令牌经 `credentials` 服务按 `JIRA_TASKS_TOKEN`(设置页写入)→ `JIRA_API_TOKEN` → `JIRA_TOKEN` 的顺序解析(`$DSH_HOME/.credentials.yaml` / 环境变量,热加载),因此设置页保存的令牌能覆盖环境变量;查询用 `subprocess` 直接 `spawn curl`,认证头经 stdin(`--config -`)传入,令牌不进入命令行参数。
|
|
178
|
+
- **Client**:`window.__ModuleLoader__.load({ id, factory })` 标准 web bundle;注册 `conversation.composer.dock`(活跃会话,注册 `order: 5`)与 `conversation.input.dock`(新会话,注册 `order: 10`)。新会话面板走 hero 布局:面板元素自身 `flex order: 99` 排在输入框之后下方,并以 `--dsh-composer-side-clearance` / `--dsh-composer-card-max-width` 与输入卡等宽。另注册 `settings.plugin.item`(`key: "jira-tasks"`)作为设置页卡片:地址经 `settingsScope` 写入命名空间,令牌经 `remote.credentials` 写入 `JIRA_TASKS_TOKEN`。
|
|
173
179
|
- **为什么不用 `shell` 服务**:`shell` 会套 `sandbox-exec`,部分 macOS 上不可用(`sandbox_apply: Operation not permitted`);`subprocess` 是原始进程缝,无此问题。
|
|
174
180
|
- **新会话显示**:DSH 壳在 hero(空白会话)阶段不渲染 `composer.dock`,故额外注册 `input.dock`,并用「会话是否已有消息」去重(新版 DSH 依据 `SessionSnapshot.blank`),避免双份面板。
|
|
175
181
|
|
package/lib/client.js
CHANGED
|
@@ -285,8 +285,13 @@ window.__ModuleLoader__.load({
|
|
|
285
285
|
// ---- 设置页卡片:设置 → 插件 → JIRA ----
|
|
286
286
|
// 地址存 settings 命名空间(可读);令牌写 credentials(永不随响应回传)。
|
|
287
287
|
var SETTINGS_NS = "jira-tasks";
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
// 令牌写入插件自有引用,而不是直接写 JIRA_API_TOKEN:启动环境里导出的
|
|
289
|
+
// JIRA_API_TOKEN 会让那个引用只读(DSH 拒绝写入会被环境遮蔽的引用),而
|
|
290
|
+
// 插件自有引用不受影响,因此设置页保存的值可以覆盖环境变量——优先级由
|
|
291
|
+
// Host 的解析顺序保证(JIRA_TASKS_TOKEN → JIRA_API_TOKEN → JIRA_TOKEN)。
|
|
292
|
+
var TOKEN_REF = "JIRA_TASKS_TOKEN";
|
|
293
|
+
var ENV_TOKEN_REFS = ["JIRA_API_TOKEN", "JIRA_TOKEN"];
|
|
294
|
+
var TOKEN_REFS = [TOKEN_REF].concat(ENV_TOKEN_REFS);
|
|
290
295
|
|
|
291
296
|
// credentials-local 拒绝写入“由启动环境提供”的引用时,原始信息是英文的;这里取出引用名并给出可操作的中文说明。
|
|
292
297
|
function shadowedTokenRef(message) {
|
|
@@ -295,9 +300,9 @@ window.__ModuleLoader__.load({
|
|
|
295
300
|
}
|
|
296
301
|
function tokenReadOnlyHint(ref) {
|
|
297
302
|
var name = ref || TOKEN_REF;
|
|
298
|
-
return "
|
|
299
|
-
+ "
|
|
300
|
-
+ "[Environment]::SetEnvironmentVariable('" + name + "', $null, 'User')
|
|
303
|
+
return "环境变量 " + name + " 由启动 DSH 的终端提供且只读,无法写入该引用。"
|
|
304
|
+
+ "请先移除它(Windows:系统属性 → 环境变量,或 PowerShell "
|
|
305
|
+
+ "[Environment]::SetEnvironmentVariable('" + name + "', $null, 'User'))并重启 DSH。";
|
|
301
306
|
}
|
|
302
307
|
|
|
303
308
|
function useScopeSnapshot(scope) {
|
|
@@ -316,16 +321,26 @@ window.__ModuleLoader__.load({
|
|
|
316
321
|
function readTokenInfo() {
|
|
317
322
|
return credentials.describe(TOKEN_REFS).then(function (res) {
|
|
318
323
|
if (!res || !res.ok || !res.value) return { configured: false, writable: true };
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
324
|
+
var value = res.value;
|
|
325
|
+
var override = value[TOKEN_REF];
|
|
326
|
+
var overridden = !!(override && override.configured);
|
|
327
|
+
var fallbackRef = "", fallbackSource = "";
|
|
328
|
+
for (var i = 0; i < ENV_TOKEN_REFS.length; i++) {
|
|
329
|
+
var info = value[ENV_TOKEN_REFS[i]];
|
|
323
330
|
if (info && info.configured) {
|
|
324
|
-
|
|
331
|
+
fallbackRef = ENV_TOKEN_REFS[i];
|
|
332
|
+
fallbackSource = info.source || "";
|
|
333
|
+
break;
|
|
325
334
|
}
|
|
326
335
|
}
|
|
327
|
-
|
|
328
|
-
|
|
336
|
+
return {
|
|
337
|
+
configured: overridden || fallbackRef !== "",
|
|
338
|
+
overridden: overridden,
|
|
339
|
+
// 只有插件自有引用可能被环境遮蔽;JIRA_API_TOKEN 只读不影响这里的写入。
|
|
340
|
+
writable: !override || override.writable !== false,
|
|
341
|
+
// 仅当回退值确实来自启动环境时才称它为“环境变量”(旧版本可能把它存在凭据文件里)。
|
|
342
|
+
envRef: fallbackSource === "env" ? fallbackRef : ""
|
|
343
|
+
};
|
|
329
344
|
}).catch(function () {
|
|
330
345
|
// 状态读取失败不阻断保存,交由写入路径给出真实错误。
|
|
331
346
|
return { configured: false, writable: true };
|
|
@@ -362,31 +377,33 @@ window.__ModuleLoader__.load({
|
|
|
362
377
|
|
|
363
378
|
var storedBase = snapshot.value && typeof snapshot.value.baseUrl === "string" ? snapshot.value.baseUrl : "";
|
|
364
379
|
var baseValue = baseEdit === undefined ? storedBase : baseEdit;
|
|
365
|
-
var
|
|
380
|
+
var baseDirty = baseEdit !== undefined && baseEdit !== storedBase;
|
|
381
|
+
var tokenDraftText = (tokenDraft || "").trim();
|
|
382
|
+
var tokenDirty = tokenDraftText.length > 0;
|
|
383
|
+
var dirty = baseDirty || tokenDirty;
|
|
366
384
|
var writable = snapshot.writable !== false;
|
|
367
|
-
//
|
|
385
|
+
// 插件自有引用通常可写;只有 JIRA_TASKS_TOKEN 本身也被导出到启动环境时才会只读。
|
|
368
386
|
var tokenWritable = !tokenInfo || tokenInfo.writable !== false;
|
|
369
|
-
var
|
|
387
|
+
var tokenOverridden = !!(tokenInfo && tokenInfo.overridden);
|
|
388
|
+
var envTokenRef = tokenInfo && tokenInfo.envRef ? tokenInfo.envRef : "";
|
|
370
389
|
|
|
371
390
|
// 命名空间未挂载时不显示,避免留下一张无法操作的卡片。
|
|
372
391
|
if (snapshot.status === "unavailable") return null;
|
|
373
392
|
|
|
374
393
|
function save() {
|
|
375
394
|
if (busy || !dirty) return;
|
|
395
|
+
if (tokenDirty && !tokenWritable) {
|
|
396
|
+
setFailed(tokenReadOnlyHint(TOKEN_REF));
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
376
399
|
setBusy(true);
|
|
377
400
|
setFailed("");
|
|
378
401
|
var tasks = [];
|
|
379
|
-
if (
|
|
402
|
+
if (baseDirty) {
|
|
380
403
|
tasks.push(baseEdit === "" ? scope.unset("baseUrl") : scope.set("baseUrl", baseEdit));
|
|
381
404
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
setBusy(false);
|
|
385
|
-
setFailed(tokenReadOnlyHint(tokenInfo && tokenInfo.ref));
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
if (token) {
|
|
389
|
-
tasks.push(credentials.set(TOKEN_REF, token).then(function (res) {
|
|
405
|
+
if (tokenDirty) {
|
|
406
|
+
tasks.push(credentials.set(TOKEN_REF, tokenDraftText).then(function (res) {
|
|
390
407
|
if (res && res.ok === false) {
|
|
391
408
|
var err = res.error;
|
|
392
409
|
throw new Error((err && (err.message || err.code)) || "令牌保存失败");
|
|
@@ -400,6 +417,31 @@ window.__ModuleLoader__.load({
|
|
|
400
417
|
setBaseEdit(undefined);
|
|
401
418
|
setTokenDraft("");
|
|
402
419
|
setBusy(false);
|
|
420
|
+
// baseUrl 变更会经 snapshot.revision 触发自动重测;仅保存令牌时手动补一次。
|
|
421
|
+
if (!baseDirty) runProbe({});
|
|
422
|
+
}).catch(function (err) {
|
|
423
|
+
setBusy(false);
|
|
424
|
+
var shadowed = shadowedTokenRef(err && err.message);
|
|
425
|
+
setFailed(shadowed ? tokenReadOnlyHint(shadowed) : String((err && err.message) || err));
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// 清除设置页保存的令牌,回退到环境变量 / 凭据文件中的旧值。
|
|
430
|
+
function clearOverride() {
|
|
431
|
+
if (busy) return;
|
|
432
|
+
setBusy(true);
|
|
433
|
+
setFailed("");
|
|
434
|
+
credentials.unset(TOKEN_REF).then(function (res) {
|
|
435
|
+
if (res && res.ok === false) {
|
|
436
|
+
var err = res.error;
|
|
437
|
+
throw new Error((err && (err.message || err.code)) || "清除令牌失败");
|
|
438
|
+
}
|
|
439
|
+
return readTokenInfo();
|
|
440
|
+
}).then(function (info) {
|
|
441
|
+
setTokenInfo(info);
|
|
442
|
+
setTokenDraft("");
|
|
443
|
+
setBusy(false);
|
|
444
|
+
runProbe({});
|
|
403
445
|
}).catch(function (err) {
|
|
404
446
|
setBusy(false);
|
|
405
447
|
var shadowed = shadowedTokenRef(err && err.message);
|
|
@@ -430,9 +472,11 @@ window.__ModuleLoader__.load({
|
|
|
430
472
|
|
|
431
473
|
var tokenHint = tokenInfo === null
|
|
432
474
|
? "正在读取令牌状态…"
|
|
433
|
-
: (
|
|
434
|
-
?
|
|
435
|
-
: (
|
|
475
|
+
: (tokenOverridden
|
|
476
|
+
? "设置页令牌已保存" + (envTokenRef ? ",优先于环境变量 " + envTokenRef : "") + ";留空并保存可保持不变。"
|
|
477
|
+
: (envTokenRef
|
|
478
|
+
? "当前使用环境变量 " + envTokenRef + ";在下方填写并保存即可覆盖它。"
|
|
479
|
+
: (tokenInfo.configured ? "令牌已配置;留空并保存可保持不变。" : "令牌未配置。含 “:” 时用 Basic,否则用 Bearer。")));
|
|
436
480
|
var dotClass = probe.phase === "ok" ? "jt-dot jt-dot-ok"
|
|
437
481
|
: probe.phase === "fail" ? "jt-dot jt-dot-fail"
|
|
438
482
|
: probe.phase === "testing" ? "jt-dot jt-dot-testing" : "jt-dot";
|
|
@@ -461,14 +505,18 @@ window.__ModuleLoader__.load({
|
|
|
461
505
|
className: "jt-input",
|
|
462
506
|
type: "password",
|
|
463
507
|
value: tokenDraft,
|
|
464
|
-
placeholder:
|
|
508
|
+
placeholder: tokenOverridden ? "已保存,留空保持不变" : (envTokenRef ? "填写以覆盖环境变量" : (tokenInfo && tokenInfo.configured ? "已配置,留空保持不变" : "粘贴令牌")),
|
|
465
509
|
autoComplete: "off",
|
|
466
|
-
disabled:
|
|
510
|
+
disabled: busy || !tokenWritable,
|
|
467
511
|
onChange: function (e) { setTokenDraft(e.target.value); },
|
|
468
512
|
onKeyDown: function (e) { if (e.key === "Enter") save(); }
|
|
469
513
|
})
|
|
470
514
|
),
|
|
471
515
|
h("div", { className: "jt-hint", style: { marginBottom: "8px" } }, tokenHint),
|
|
516
|
+
tokenOverridden && tokenWritable
|
|
517
|
+
? h("div", { className: "jt-hint", style: { margin: "-4px 0 8px" } },
|
|
518
|
+
h("button", { className: "jt-linklike", disabled: busy, onClick: clearOverride }, "清除设置页令牌(回退到环境变量)"))
|
|
519
|
+
: null,
|
|
472
520
|
h("div", { className: "jt-probe", role: "status" },
|
|
473
521
|
h("span", { className: dotClass, "aria-hidden": "true" }),
|
|
474
522
|
h("span", null, probe.message || "未测试")
|
|
@@ -483,7 +531,7 @@ window.__ModuleLoader__.load({
|
|
|
483
531
|
onClick: function () { runProbe({ baseUrl: baseValue, token: (tokenDraft || "").trim() }); }
|
|
484
532
|
}, probe.phase === "testing" ? "测试中…" : "测试连接"),
|
|
485
533
|
h("button", { className: "jt-btn", disabled: !dirty || busy, onClick: discard }, "放弃"),
|
|
486
|
-
h("button", { className: "jt-btn jt-btn-primary", disabled: !dirty || busy || !writable || (
|
|
534
|
+
h("button", { className: "jt-btn jt-btn-primary", disabled: !dirty || busy || (baseDirty && !writable) || (tokenDirty && !tokenWritable), onClick: save }, busy ? "保存中…" : "保存")
|
|
487
535
|
)
|
|
488
536
|
);
|
|
489
537
|
};
|
package/lib/index.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dsh-jira-tasks — HOST half (persistent profile plugin).
|
|
3
3
|
* Serves POST /jira/api/search: reads the JIRA base URL from the `jira-tasks`
|
|
4
|
-
* settings namespace and the token from the credentials service
|
|
5
|
-
*
|
|
6
|
-
* /rest/api/2/search through
|
|
7
|
-
* --config -),
|
|
4
|
+
* settings namespace and the token from the credentials service — the
|
|
5
|
+
* settings-page JIRA_TASKS_TOKEN first, so it overrides an exported
|
|
6
|
+
* JIRA_API_TOKEN / JIRA_TOKEN — then queries JIRA /rest/api/2/search through
|
|
7
|
+
* subprocess+curl (auth header via stdin --config -), returning normalized
|
|
8
|
+
* issue JSON.
|
|
8
9
|
*/
|
|
9
10
|
import z from '@deepseek-ai/schemastery';
|
|
10
11
|
|
|
11
12
|
/** Settings namespace exposing the editable connection fields in the GUI. */
|
|
12
13
|
const SETTINGS_NS = 'jira-tasks';
|
|
13
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Token references in precedence order. `JIRA_TASKS_TOKEN` is the plugin-owned
|
|
17
|
+
* ref the settings card writes to: unlike `JIRA_API_TOKEN`, the credentials
|
|
18
|
+
* provider can always store it, because the launching environment does not
|
|
19
|
+
* supply it. Listing it first is what makes a saved token override an exported
|
|
20
|
+
* `JIRA_API_TOKEN` / `JIRA_TOKEN`.
|
|
21
|
+
*/
|
|
22
|
+
const TOKEN_REFS = ['JIRA_TASKS_TOKEN', 'JIRA_API_TOKEN', 'JIRA_TOKEN'];
|
|
23
|
+
|
|
14
24
|
/**
|
|
15
25
|
* Durable connection schema. `baseUrl` is a plain readable field; the token is
|
|
16
26
|
* deliberately NOT stored here — it stays in the credentials store (write-only
|
|
@@ -166,7 +176,7 @@ export default {
|
|
|
166
176
|
try {
|
|
167
177
|
const baseUrl = settingsBaseUrl() || await resolveFirst(['JIRA_BASE_URL', 'JIRA_URL']);
|
|
168
178
|
if (!baseUrl) return { ok: false, error: '未配置 JIRA 地址(设置 → 插件 → JIRA,或环境变量 JIRA_BASE_URL)' };
|
|
169
|
-
const token = await resolveFirst(
|
|
179
|
+
const token = await resolveFirst(TOKEN_REFS);
|
|
170
180
|
if (!token) return { ok: false, error: '未配置 JIRA 令牌(设置 → 插件 → JIRA,或环境变量 JIRA_API_TOKEN)' };
|
|
171
181
|
|
|
172
182
|
const jql = buildJql(args && args.jql ? String(args.jql) : '', projectKey);
|
|
@@ -213,7 +223,7 @@ export default {
|
|
|
213
223
|
const draftToken = args && typeof args.token === 'string' ? args.token.trim() : '';
|
|
214
224
|
const baseUrl = draftBase || settingsBaseUrl() || await resolveFirst(['JIRA_BASE_URL', 'JIRA_URL']);
|
|
215
225
|
if (!baseUrl) return { ok: false, code: 'unconfigured', error: '未配置 JIRA 地址' };
|
|
216
|
-
const token = draftToken || await resolveFirst(
|
|
226
|
+
const token = draftToken || await resolveFirst(TOKEN_REFS);
|
|
217
227
|
if (!token) return { ok: false, code: 'unconfigured', error: '未配置 JIRA 令牌' };
|
|
218
228
|
|
|
219
229
|
const raw = await probeJira(baseUrl, token);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-jira-tasks",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "JIRA open tasks panel for DeepSeek Harness (DSH): shows the current user's open/reopened issues below the composer, per-workspace project key, persistent profile bundle.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|