dsh-flakefinder 0.4.2 → 0.4.4
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 -0
- package/docs/USAGE.en.md +4 -0
- package/docs/USAGE.md +4 -0
- package/docs/VALIDATION.md +4 -0
- package/docs/validation-0.4.4.md +5 -0
- package/lib/approval.d.ts +13 -0
- package/lib/approval.js +18 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +9 -0
- package/lib/update-client.js +28 -13
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
[返回简介](README.md) · [使用说明](docs/USAGE.md) · [验证记录](docs/VALIDATION.md)
|
|
4
4
|
|
|
5
|
+
## 0.4.4 (2026-10-28)
|
|
6
|
+
|
|
7
|
+
- 隔离清单写操作正确处理 never/未知审批策略,不再误报用户点击拒绝;保留宿主拒绝与原有可询问模式,不自动放宽审批。
|
|
8
|
+
|
|
9
|
+
## 0.4.3 (2026-10-27)
|
|
10
|
+
|
|
11
|
+
- 修复分批更新时的新旧更新控件混用:保留原页面、草稿与安装保护,空闲后接管旧控制器,兼容旧入口。
|
|
12
|
+
|
|
5
13
|
## 0.4.2 (2026-10-27)
|
|
6
14
|
|
|
7
15
|
- 更新控件移至原有工作台或原生插件详情页底部;更新记录与选项原地展开,移除独立更新菜单与页面。
|
package/docs/USAGE.en.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# dsh-flakefinder usage guide
|
|
2
2
|
|
|
3
|
+
## Confirmation in Full Access
|
|
4
|
+
|
|
5
|
+
The plugin keeps its confirmation requirement. With approval policy `never`, it reports that confirmation is unavailable and performs no write. Switch to a mode that can ask, or explicitly set `writeApproval: false` yourself. Host denials still apply.
|
|
6
|
+
|
|
3
7
|
[Overview](../README.en.md) · [Changelog](../CHANGELOG.md) · [Validation](VALIDATION.md)
|
|
4
8
|
|
|
5
9
|
## Current improvements
|
package/docs/USAGE.md
CHANGED
package/docs/VALIDATION.md
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Read the effective Host policy without importing a second copy of its services. */
|
|
2
|
+
export type ApprovalPolicy = 'ask' | 'never' | 'unknown';
|
|
3
|
+
export interface ApprovalContext {
|
|
4
|
+
get?(name: string): unknown;
|
|
5
|
+
approval?: {
|
|
6
|
+
config?: {
|
|
7
|
+
policy?: unknown;
|
|
8
|
+
};
|
|
9
|
+
overrideOf?(session: unknown): unknown;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare function approvalPolicy(ctx: ApprovalContext, execution: unknown): ApprovalPolicy;
|
|
13
|
+
export declare function approvalProblem(policy: ApprovalPolicy, setting: string): string | undefined;
|
package/lib/approval.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function approvalPolicy(ctx, execution) {
|
|
2
|
+
try {
|
|
3
|
+
const service = (ctx.get ? ctx.get('approval') : ctx.approval);
|
|
4
|
+
const session = execution?.agent?.session;
|
|
5
|
+
const policy = (session === undefined ? undefined : service?.overrideOf?.(session)) ?? service?.config?.policy;
|
|
6
|
+
return policy === 'ask' || policy === 'never' ? policy : 'unknown';
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return 'unknown';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function approvalProblem(policy, setting) {
|
|
13
|
+
if (policy === 'ask')
|
|
14
|
+
return undefined;
|
|
15
|
+
if (policy === 'never')
|
|
16
|
+
return '插件要求确认,但当前会话审批策略 never 不允许询问,操作未执行。请切换到可询问模式,或由用户明确设置 ' + setting + '=false / Confirmation is required but this session cannot ask; no action was performed.';
|
|
17
|
+
return '无法读取宿主审批策略,操作未执行。请检查 DSH 审批服务或插件配置 / Host approval policy unavailable; no action was performed.';
|
|
18
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
import { type FlakeConfig } from './config.js';
|
|
11
11
|
import { type SubprocessSpawnLike } from './runner.js';
|
|
12
12
|
import { type FlakeToolDefinition } from './tools.js';
|
|
13
|
+
import { type ApprovalContext } from './approval.js';
|
|
13
14
|
/** cordis 服务注入:apply 里要用 ctx.subprocess 与 ctx.tools。 */
|
|
14
15
|
export declare const name = "flakefinder";
|
|
15
16
|
export declare const inject: string[];
|
|
16
17
|
/** 插件所需的最小 ctx 面。 */
|
|
17
|
-
export interface FlakePluginContext {
|
|
18
|
+
export interface FlakePluginContext extends ApprovalContext {
|
|
18
19
|
subprocess: {
|
|
19
20
|
spawn: SubprocessSpawnLike;
|
|
20
21
|
};
|
package/lib/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { resolveConfig } from './config.js';
|
|
|
12
12
|
import { createSubprocessRunner } from './runner.js';
|
|
13
13
|
import { createStore } from './store.js';
|
|
14
14
|
import { buildFlakeTools } from './tools.js';
|
|
15
|
+
import { approvalPolicy, approvalProblem } from './approval.js';
|
|
15
16
|
/** cordis 服务注入:apply 里要用 ctx.subprocess 与 ctx.tools。 */
|
|
16
17
|
export const name = 'flakefinder';
|
|
17
18
|
export const inject = ['subprocess', 'tools'];
|
|
@@ -38,6 +39,14 @@ export function apply(ctx, config) {
|
|
|
38
39
|
if (typeof ctx.on === 'function') {
|
|
39
40
|
if (cfg.writeApproval) {
|
|
40
41
|
ctx.on('tools/pre-execute', async (exec, next) => {
|
|
42
|
+
if (exec.name !== 'flaky_quarantine' && exec.name !== 'flaky_clear')
|
|
43
|
+
return next();
|
|
44
|
+
const downstream = await next();
|
|
45
|
+
if (downstream?.kind === 'deny')
|
|
46
|
+
return downstream;
|
|
47
|
+
const problem = approvalProblem(approvalPolicy(ctx, exec), 'writeApproval');
|
|
48
|
+
if (problem)
|
|
49
|
+
return { kind: 'deny', reason: problem };
|
|
41
50
|
if (exec.name === 'flaky_quarantine')
|
|
42
51
|
return { kind: 'ask', reason: '把测试用例写入 .flakefinder.json 隔离清单' };
|
|
43
52
|
if (exec.name === 'flaky_clear')
|
package/lib/update-client.js
CHANGED
|
@@ -176,7 +176,7 @@ function __stardustUpdatesGuard(React, name, { dirty = false, busy = false, reta
|
|
|
176
176
|
function __StardustPluginUpdatesFooter({ React, name }) {
|
|
177
177
|
const [, render] = React.useState(0), pool = __stardustUpdatesGuards();
|
|
178
178
|
React.useEffect(() => { const fn = () => render(value => value + 1); pool.viewListeners.add(fn); return () => pool.viewListeners.delete(fn); }, []);
|
|
179
|
-
const client = [...pool.clients].find(client => client.has(name));
|
|
179
|
+
const client = [...pool.clients].find(client => typeof client.Footer === 'function' && client.has(name));
|
|
180
180
|
if (!client) return null;
|
|
181
181
|
return React.createElement(client.Footer, { name });
|
|
182
182
|
}
|
|
@@ -238,14 +238,22 @@ function __stardustUpdatesJoin(host, React, require, participant) {
|
|
|
238
238
|
if (typeof root.plugin !== 'function') return;
|
|
239
239
|
let record = pools.get(root);
|
|
240
240
|
if (!record) {
|
|
241
|
-
record = { refs: new Map(), timer: null, version: participant.version, alive: true, hold: false };
|
|
241
|
+
record = { refs: new Map(), timer: null, version: participant.version, alive: true, hold: false, uiRevision: 2 };
|
|
242
242
|
pools.set(root, record);
|
|
243
|
+
__stardustUpdatesActivate(record, pools, root, React, require);
|
|
244
|
+
} else if (record.uiRevision !== 2 && !record.migration) {
|
|
245
|
+
// The first loaded participant may still own a pre-footer client. Keep
|
|
246
|
+
// its references and draft guards, wait for any admitted install, then
|
|
247
|
+
// replace that one client fiber instead of running two window heartbeats.
|
|
243
248
|
const shared = record;
|
|
244
|
-
record.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
+
record.migration = Promise.resolve().then(async () => {
|
|
250
|
+
while (shared.alive && shared.hold) await new Promise(resolve => setTimeout(resolve, 500));
|
|
251
|
+
if (!shared.alive || !shared.refs.size) return;
|
|
252
|
+
await shared.fiber?.dispose?.();
|
|
253
|
+
if (!shared.refs.size) return;
|
|
254
|
+
shared.alive = true; shared.uiRevision = 2; pools.set(root, shared);
|
|
255
|
+
__stardustUpdatesActivate(shared, pools, root, React, require);
|
|
256
|
+
}).catch(() => { /* The original page remains usable if host disposal fails. */ });
|
|
249
257
|
}
|
|
250
258
|
clearTimeout(record.timer);
|
|
251
259
|
const ref = {}; record.refs.set(ref, participant);
|
|
@@ -259,10 +267,17 @@ function __stardustUpdatesJoin(host, React, require, participant) {
|
|
|
259
267
|
if (!record.refs.size) record.timer = setTimeout(stop, 1000);
|
|
260
268
|
});
|
|
261
269
|
}
|
|
270
|
+
function __stardustUpdatesActivate(shared, pools, root, React, require) {
|
|
271
|
+
shared.fiber = root.plugin({ name: 'stardustlc-plugin-updates-client', inject: ['slots', 'locale', 'remote', 'remote.pluginManager'], apply(ctx) {
|
|
272
|
+
const client = __stardustUpdatesClient(ctx, React, require, shared);
|
|
273
|
+
ctx.effect(() => () => { shared.alive = false; client.dispose(); if (pools.get(root) === shared) pools.delete(root); });
|
|
274
|
+
} });
|
|
275
|
+
Promise.resolve(shared.fiber).catch(() => { shared.alive = false; if (pools.get(root) === shared) pools.delete(root); });
|
|
276
|
+
}
|
|
262
277
|
function __stardustUpdatesClient(ctx, React, require, shared) {
|
|
263
278
|
const h = React.createElement, W = createWorkbenchUI(React), route = new URL('api/stardustlc/plugin-updates', document.baseURI);
|
|
264
279
|
const { useState, useEffect } = React, id = crypto.randomUUID(), listeners = new Set(), pool = __stardustUpdatesGuards(), requests = new Set(), notified = new Set(), knownRows = new Map();
|
|
265
|
-
let alive = true, registered = false, state = null, lastInteraction = Date.now(), inPoll = false, manualOperation = false;
|
|
280
|
+
let alive = true, registered = false, state = null, lastInteraction = Date.now(), inPoll = false, manualOperation = false, legacyHint = null;
|
|
266
281
|
const language = () => String(ctx.locale?.getSnapshot?.().active || '').startsWith('en') ? 'en' : 'zh';
|
|
267
282
|
const t = (zh, en) => language() === 'en' ? en : zh;
|
|
268
283
|
const preferences = name => state?.preferences.packages[name] || { checkEnabled: true, autoInstall: false, deferredUntil: 0, ignoredVersion: null };
|
|
@@ -387,11 +402,11 @@ function __stardustUpdatesClient(ctx, React, require, shared) {
|
|
|
387
402
|
function Reminder() {
|
|
388
403
|
useSnapshot();
|
|
389
404
|
const row = state?.rows.find(row => { const prefs = preferences(row.name); return row.available && !row.updating && !row.bundledBy && prefs.checkEnabled && prefs.deferredUntil <= Date.now() && prefs.ignoredVersion !== row.release.version && !notified.has(row.name + '@' + row.release.version); });
|
|
390
|
-
if (!row) return null;
|
|
405
|
+
if (!row && !legacyHint) return null;
|
|
391
406
|
let Toast; try { Toast = require('@deepseek-ai/dsh-client-ui-primitives').Toast; } catch { return null; }
|
|
392
407
|
if (!Toast) return null;
|
|
393
|
-
const key = row.name + '@' + row.release.version;
|
|
394
|
-
return h(Toast, { key, text: (language() === 'en' ? row.labelEn : row.label) + t('有新版本,可在页面底部查看。', ' has an update. Review it at the bottom of its page.'), icon: h(W.Icon, { name: 'refresh', size: 18 }), holdMs: 7000, onDone: () => { notified.add(key); notify(); } });
|
|
408
|
+
const hint = legacyHint, key = hint ? 'legacy-' + hint : row.name + '@' + row.release.version;
|
|
409
|
+
return h(Toast, { key, text: hint ? hint + t(':请打开「插件」中的此插件详情页,在底部管理更新。', ': open its details in Plugins to manage updates at the bottom.') : (language() === 'en' ? row.labelEn : row.label) + t('有新版本,可在页面底部查看。', ' has an update. Review it at the bottom of its page.'), icon: h(W.Icon, { name: 'refresh', size: 18 }), holdMs: 7000, onDone: () => { if (hint) legacyHint = null; else notified.add(key); notify(); } });
|
|
395
410
|
}
|
|
396
411
|
function register() {
|
|
397
412
|
if (!alive) return;
|
|
@@ -410,7 +425,7 @@ function __stardustUpdatesClient(ctx, React, require, shared) {
|
|
|
410
425
|
finally { inPoll = false; }
|
|
411
426
|
}
|
|
412
427
|
const timer = setInterval(() => { void poll(); }, 15000), first = setTimeout(() => { void poll(); }, 100);
|
|
413
|
-
const client = { t, Footer: Panel, has: name => registered && !!originalRow(name), row: rowFor, dispose() {
|
|
428
|
+
const client = { t, Footer: Panel, Button: W.Button, open(name) { const footer = [...document.querySelectorAll('[data-plugin-update-footer]')].find(node => node.getAttribute('data-plugin-update-footer') === name); if (footer) footer.scrollIntoView({ block: 'end', behavior: 'smooth' }); else { legacyHint = name; notify(); } }, has: name => registered && !!originalRow(name), row: rowFor, dispose() {
|
|
414
429
|
close(); alive = false; clearTimeout(first); clearInterval(timer); pool.clients.delete(client);
|
|
415
430
|
pool.listeners.delete(guardChanged); listeners.clear();
|
|
416
431
|
for (const event of ['pointerdown', 'keydown', 'input']) document.removeEventListener(event, interaction, true);
|
|
@@ -422,7 +437,7 @@ function __stardustUpdatesClient(ctx, React, require, shared) {
|
|
|
422
437
|
}
|
|
423
438
|
|
|
424
439
|
/* STARDUSTLC_UPDATE_CLIENT_BODY_START */
|
|
425
|
-
window.__ModuleLoader__.load(__stardustUpdatesWrap({id:"dsh-flakefinder",factory:require=>({apply(){}})},{"name":"dsh-flakefinder","version":"0.1.0","hasWorkbench":false,"packageVersion":"0.4.
|
|
440
|
+
window.__ModuleLoader__.load(__stardustUpdatesWrap({id:"dsh-flakefinder",factory:require=>({apply(){}})},{"name":"dsh-flakefinder","version":"0.1.0","hasWorkbench":false,"packageVersion":"0.4.4","label":"不稳定测试排查","labelEn":"Flakefinder","suiteComponent":true}));
|
|
426
441
|
|
|
427
442
|
/* STARDUSTLC_UPDATE_CLIENT_BODY_END */
|
|
428
443
|
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-flakefinder",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "重复运行测试,找出偶发失败用例并保留调查记录。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -72,6 +72,6 @@
|
|
|
72
72
|
"packageManager": "pnpm@11.7.0",
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"proper-lockfile": "4.1.2",
|
|
75
|
-
"@stardustlc/dsh-updates": "0.1.
|
|
75
|
+
"@stardustlc/dsh-updates": "0.1.3"
|
|
76
76
|
}
|
|
77
77
|
}
|