@stardustlc/dsh-review 0.4.8 → 0.5.0
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/INTEGRATION.md +3 -1
- package/lib/index.js +8 -1
- package/lib/modes.d.ts +7 -0
- package/lib/modes.js +9 -0
- package/lib/tools.d.ts +6 -0
- package/lib/tools.js +38 -7
- package/lib/update-client.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# 变更记录
|
|
2
2
|
|
|
3
|
+
## 0.5.0 (2026-11-03)
|
|
4
|
+
|
|
5
|
+
- 新增只读的 review_health:报告 Git 工作区、插件依赖的宿主服务(子智能体、权限预设、作业管理)、本轮生效的预算与三档模式,不作审阅结论;首次使用和环境排查先跑它。
|
|
6
|
+
- 首次使用路径明确为 review_diff(看范围、风险、模式与预算)→ review_run → review_gate;README 中英文同步。
|
|
7
|
+
- 三档审阅模式在调用处可见:mode 参数说明与 review_diff 的 modeOptions 列出各自的问题类别、复核人数、汇总者与预计调用量,模式适用说明由 modes.ts 统一提供。
|
|
8
|
+
- 工作区尚无审阅记录时,review_status 与 review_gate 返回 nextStep,直接说明下一步该调用哪个工具,而不是只报零值或不通过。
|
|
9
|
+
- State the first-use path (review_diff → review_run → review_gate) and expose the three modes with their budgets at the call site instead of only in the README; empty workspaces now explain the next tool call.
|
|
10
|
+
|
|
3
11
|
## 0.4.8 (2026-10-30)
|
|
4
12
|
|
|
5
13
|
- 重整中英文首页:用途、三步流程图、安装入口与操作示例;详细配置与边界集中到完整说明。
|
package/docs/INTEGRATION.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## 本地与 DSH
|
|
4
4
|
|
|
5
|
-
先在 Git
|
|
5
|
+
先在 Git 仓库根目录打开会话,运行构建/测试。需要确认环境是否就绪时先调用只读的 review_health:它报告 Git 工作区、插件依赖的宿主服务(子智能体、权限预设、作业管理)、本轮生效的预算与三档模式,不作任何审阅结论。
|
|
6
|
+
|
|
7
|
+
再调用 review_run。它默认审工作区;指定 staged=true 会固定索引内容;指定 base=main 会审 merge-base 到 HEAD 的提交差异。base 与 staged 不可同时使用。
|
|
6
8
|
|
|
7
9
|
先保留 review_diff 返回的覆盖范围。遇到超限、符号链接、二进制、模型错误或权限问题,应拆分改动、补领域检查或交给人,不得把失败改成空数组后继续。
|
|
8
10
|
|
package/lib/index.js
CHANGED
|
@@ -48,7 +48,14 @@ export function apply(ctx, config) {
|
|
|
48
48
|
output: String(value.stdout?.text ?? '') + (value.stderr?.text ? '\n' + value.stderr.text : '') };
|
|
49
49
|
};
|
|
50
50
|
const dispatcher = (exec, root, signal) => createDispatcher({ subagents: ctx.subagents, parent: exec.agent, provider: resolved.subagentProvider, signal, cwd: root });
|
|
51
|
-
|
|
51
|
+
// review_health reports the same services the tools need, so a first run fails
|
|
52
|
+
// with a readable readiness line instead of a mid-review service error.
|
|
53
|
+
const services = () => ({
|
|
54
|
+
subagents: typeof ctx.subagents?.dispatch === 'function' || typeof ctx.subagents?.settle === 'function',
|
|
55
|
+
permissionPresets: typeof ctx.permissionPresets?.current === 'function' && typeof ctx.permissionPresets?.resolve === 'function',
|
|
56
|
+
jobs: typeof ctx.jobs?.kill === 'function' && typeof ctx.jobs?.wait === 'function',
|
|
57
|
+
});
|
|
58
|
+
for (const definition of buildReviewTools(resolved, { runner, dispatcher, services })) {
|
|
52
59
|
if (ctx.effect)
|
|
53
60
|
ctx.effect(() => ctx.tools.register(definition));
|
|
54
61
|
else
|
package/lib/modes.d.ts
CHANGED
|
@@ -20,6 +20,13 @@ export interface ModePlan {
|
|
|
20
20
|
estimatedCalls: number;
|
|
21
21
|
}
|
|
22
22
|
export declare const LENSES: Record<string, Lens>;
|
|
23
|
+
/**
|
|
24
|
+
* When to pick each mode, in the words used by the tools and the README.
|
|
25
|
+
* Kept beside `planForMode` so the advertised cost and the real budget cannot drift.
|
|
26
|
+
*/
|
|
27
|
+
export declare const MODE_GUIDANCE: Record<Mode, {
|
|
28
|
+
when: string;
|
|
29
|
+
}>;
|
|
23
30
|
export declare function planForMode(mode: Mode): ModePlan;
|
|
24
31
|
export declare function classifyRisk(files: string[], extraSensitive?: string[]): {
|
|
25
32
|
tier: RiskTier;
|
package/lib/modes.js
CHANGED
|
@@ -10,6 +10,15 @@ export const LENSES = {
|
|
|
10
10
|
breaking: { id: 'breaking', title: '破坏性变更', focus: '公开 API/配置/协议兼容、默认值改变、序列化格式' },
|
|
11
11
|
security: { id: 'security', title: '安全与秘密', focus: '注入、路径穿越、权限判断、密钥泄漏、日志敏感信息' },
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* When to pick each mode, in the words used by the tools and the README.
|
|
15
|
+
* Kept beside `planForMode` so the advertised cost and the real budget cannot drift.
|
|
16
|
+
*/
|
|
17
|
+
export const MODE_GUIDANCE = {
|
|
18
|
+
quick: { when: 'Small, low-risk changes and docs-only edits, where one verifier per candidate is enough.' },
|
|
19
|
+
standard: { when: 'Mixed code changes of any size; the default when the change is neither trivial nor sensitive.' },
|
|
20
|
+
deep: { when: 'Sensitive paths (payments, auth, migrations, workflows, manifests); these always require deep and cannot be downgraded.' },
|
|
21
|
+
};
|
|
13
22
|
export function planForMode(mode) {
|
|
14
23
|
if (mode === 'quick') {
|
|
15
24
|
return { mode, finders: [LENSES.correctness, LENSES.security], verifiersPerFinding: 1, arbiter: false, estimatedCalls: 5 };
|
package/lib/tools.d.ts
CHANGED
|
@@ -24,5 +24,11 @@ export interface ReviewToolDefinition {
|
|
|
24
24
|
export interface BuildOptions {
|
|
25
25
|
runner?: CommandRunner;
|
|
26
26
|
dispatcher?: (exec: ToolExecutionContext, root: string, signal: AbortSignal) => Dispatcher;
|
|
27
|
+
/** Host services this plugin depends on; `index.ts` supplies them, direct callers may omit them. */
|
|
28
|
+
services?: () => {
|
|
29
|
+
subagents: boolean;
|
|
30
|
+
permissionPresets: boolean;
|
|
31
|
+
jobs: boolean;
|
|
32
|
+
};
|
|
27
33
|
}
|
|
28
34
|
export declare function buildReviewTools(config: ReviewConfig, options?: BuildOptions): ReviewToolDefinition[];
|
package/lib/tools.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { realpathSync } from 'node:fs';
|
|
2
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import { classifyRisk, modeForRisk, planForMode, requiredApprovals } from './modes.js';
|
|
4
|
+
import { classifyRisk, modeForRisk, planForMode, requiredApprovals, MODE_GUIDANCE } from './modes.js';
|
|
5
5
|
import { Ledger } from './ledger.js';
|
|
6
6
|
import { captureTarget } from './target.js';
|
|
7
7
|
import { runCheck } from './check.js';
|
|
@@ -46,9 +46,27 @@ const targetSpec = {
|
|
|
46
46
|
base: { type: 'string', description: 'Compare the merge base of this ref with HEAD; omit for working tree.' },
|
|
47
47
|
staged: { type: 'boolean', description: 'Review index snapshots, independently of the working tree.' },
|
|
48
48
|
includeUntracked: { type: 'boolean', description: 'Include untracked files; default true for working-tree reviews.' },
|
|
49
|
-
mode: { type: 'string', enum: ['quick', 'standard', 'deep'], description: '
|
|
49
|
+
mode: { type: 'string', enum: ['quick', 'standard', 'deep'], description: 'quick: 2 lenses, 1 verifier per finding, about 5 calls, for small low-risk changes. standard: 4 lenses, 3 voters, about 15 calls, for mixed code changes. deep: adds an arbiter, about 25 calls, and is always required for sensitive paths. Omit to let risk tier and file count decide.' },
|
|
50
50
|
};
|
|
51
|
+
const MODES = ['quick', 'standard', 'deep'];
|
|
52
|
+
/** The three modes with the same budget `planForMode` schedules, so the choice is visible before spending calls. */
|
|
53
|
+
function modeOptions() {
|
|
54
|
+
return MODES.map(mode => { const plan = planForMode(mode); return { mode, finders: plan.finders.length, verifiersPerFinding: plan.verifiersPerFinding, arbiter: plan.arbiter, estimatedCalls: plan.estimatedCalls, when: MODE_GUIDANCE[mode].when }; });
|
|
55
|
+
}
|
|
51
56
|
const runSpec = { runId: { type: 'string', required: true }, targetId: { type: 'string', required: true } };
|
|
57
|
+
/** Walk up like Git does; a worktree or submodule stores `.git` as a file. */
|
|
58
|
+
function repositoryRoot(directory) {
|
|
59
|
+
let current = directory;
|
|
60
|
+
for (let depth = 0; depth < 40; depth++) {
|
|
61
|
+
if (existsSync(path.join(current, '.git')))
|
|
62
|
+
return current;
|
|
63
|
+
const parent = path.dirname(current);
|
|
64
|
+
if (parent === current)
|
|
65
|
+
return null;
|
|
66
|
+
current = parent;
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
52
70
|
function render(_args, value) {
|
|
53
71
|
const result = value;
|
|
54
72
|
if (result.runId)
|
|
@@ -68,13 +86,14 @@ export function buildReviewTools(config, options = {}) {
|
|
|
68
86
|
} };
|
|
69
87
|
}
|
|
70
88
|
return [
|
|
71
|
-
tool('review_diff', '
|
|
89
|
+
tool('review_diff', 'Start here: capture an immutable diff and source snapshot, then plan the independent review with its risk tier, mode and call budget. This is a plan, never an approval.', targetSpec, async (args, exec, root, ledger) => {
|
|
72
90
|
const target = await captureTarget(root, args, config.maxDiffBytes, config.stateDir, exec.signal);
|
|
73
91
|
const risk = classifyRisk(target.allPaths, target.rules.sensitivePaths), mode = modeFor(target, args.mode);
|
|
74
92
|
const record = ledger.snapshot().heads[target.series];
|
|
75
93
|
return { targetId: target.id, head: target.head, base: target.base, kind: target.kind, mode, risk, suggestedHumanApprovals: requiredApprovals(risk.tier),
|
|
76
94
|
files: target.files.map(f => ({ path: f.path, oldPath: f.oldPath, status: f.status, binary: f.binary, added: f.addedLines.length, removed: f.removedLines.length })),
|
|
77
|
-
skipped: target.skipped, rules: target.rules, plan: planForMode(mode), completedRounds: record?.round ?? 0, roundCap: config.roundCap, maxCalls: config.maxCalls,
|
|
95
|
+
skipped: target.skipped, rules: target.rules, plan: planForMode(mode), modeOptions: modeOptions(), completedRounds: record?.round ?? 0, roundCap: config.roundCap, maxCalls: config.maxCalls,
|
|
96
|
+
nextStep: 'Review the risk tier and budget, then call review_run with the same base/staged/includeUntracked inputs to execute this plan, and review_gate afterwards. dryRun only returns a manual task book and cannot pass the automatic gate.',
|
|
78
97
|
advice: 'Fresh-context bug finders, independent verification and two risk classifications. No merge or human approval is granted.' };
|
|
79
98
|
}),
|
|
80
99
|
tool('review_run', 'Run fresh-context finders, two risk classifiers, independent verifiers and deep-mode arbitration. Resume with runId; dryRun returns task envelopes and never passes the automatic gate.', { ...targetSpec, runId: { type: 'string', description: 'Resume this run; omit to start a new snapshot.' }, dryRun: { type: 'boolean' }, abandon: { type: 'boolean', description: 'Explicitly stop this run; no approval survives.' } }, async (args, exec, root, ledger) => {
|
|
@@ -142,7 +161,7 @@ export function buildReviewTools(config, options = {}) {
|
|
|
142
161
|
run = undefined;
|
|
143
162
|
}
|
|
144
163
|
if (!run)
|
|
145
|
-
return { ok: false, exitCode: 1, reasons: ['No review of this exact current snapshot'], boundary: 'AI review only; CI and human approval are separate.' };
|
|
164
|
+
return { ok: false, exitCode: 1, reasons: ['No review of this exact current snapshot'], nextStep: 'Run review_diff for the current snapshot, then review_run on the same target. A gate only reports a completed independent review of this exact snapshot; editing code invalidates earlier runs.', boundary: 'AI review only; CI and human approval are separate.' };
|
|
146
165
|
await assertCurrent(run, ledger, config, exec.signal);
|
|
147
166
|
return automatedVerdict(ledger.snapshot(), run.id);
|
|
148
167
|
}),
|
|
@@ -170,7 +189,7 @@ export function buildReviewTools(config, options = {}) {
|
|
|
170
189
|
const rows = findings.filter(f => (f.lens ?? 'unknown') === lens), answered = rows.filter(f => f.disposition), wrong = answered.filter(f => f.disposition === 'wrong' || f.disposition === 'intentional');
|
|
171
190
|
return { lens, posted: rows.length, answered: answered.length, noiseRate: answered.length ? wrong.length / answered.length : null };
|
|
172
191
|
});
|
|
173
|
-
return { ...status, lenses };
|
|
192
|
+
return { ...status, lenses, ...(status.heads === 0 ? { nextStep: 'No review has been recorded in this workspace yet. Call review_diff to see the snapshot plan, risk tier and mode budget, then review_run to execute it.' } : {}) };
|
|
174
193
|
}),
|
|
175
194
|
tool('review_learn', 'Draft concise review rules from independently verified fixed bugs and their failure classes. Returns a draft; never edits project instructions.', {}, async (_args, _exec, _root, ledger) => {
|
|
176
195
|
const findings = Object.values(ledger.snapshot().heads).flatMap(h => Object.values(h.posted)).filter(f => f.disposition === 'fixed' && f.classOfBug);
|
|
@@ -183,5 +202,17 @@ export function buildReviewTools(config, options = {}) {
|
|
|
183
202
|
return { kind, advisory: true, prompt: buildIssueTriagePrompt({ title, body, root, outFile: path.join(ledger.directory, 'triage-' + randomUUID() + '.json') }), published: false };
|
|
184
203
|
}),
|
|
185
204
|
tool('review_eval', 'Register human-curated historical bugs and clean controls, prepare blinded tasks, record exact native runs and score recall/noise per cohort. Any finding is not a recall hit.', { action: { type: 'string', required: true, enum: ['register', 'list', 'prompts', 'record', 'score'] }, entries: { type: 'array', items: { type: 'object', additionalProperties: true } }, caseId: { type: 'string' }, runId: { type: 'string' }, cohort: { type: 'string' } }, async (args, _exec, root, ledger) => evaluation(ledger, root, args)),
|
|
205
|
+
tool('review_health', 'Read-only readiness self-check before the first review: Git workspace, required host services, resolved budgets and the next call. Never captures a snapshot, reviews code or grants approval.', {}, async (_args, _exec, root) => {
|
|
206
|
+
const repository = repositoryRoot(root), host = options.services?.() ?? null;
|
|
207
|
+
return {
|
|
208
|
+
ok: repository !== null && (host === null || Object.values(host).every(Boolean)),
|
|
209
|
+
workspace: { root, gitRepository: repository !== null, repositoryRoot: repository },
|
|
210
|
+
host: host === null ? { checked: false, reason: 'The host service snapshot is unavailable in this context.' } : { checked: true, ...host },
|
|
211
|
+
limits: { roundCap: config.roundCap, maxCalls: config.maxCalls, maxParallel: config.maxParallel, runTimeoutMs: config.runTimeoutMs, commandTimeoutMs: config.commandTimeoutMs, maxDiffBytes: config.maxDiffBytes, severityFloor: config.severityFloor, subagentProvider: config.subagentProvider },
|
|
212
|
+
modes: modeOptions(),
|
|
213
|
+
nextStep: 'Call review_diff for the snapshot plan, then review_run on the same target; review_status lists unfinished work and review_gate reports only the AI layer.',
|
|
214
|
+
boundary: 'Readiness only: no snapshot was captured, no code was reviewed and no approval was granted.',
|
|
215
|
+
};
|
|
216
|
+
}),
|
|
186
217
|
];
|
|
187
218
|
}
|
package/lib/update-client.js
CHANGED
|
@@ -437,7 +437,7 @@ function __stardustUpdatesClient(ctx, React, require, shared) {
|
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
/* STARDUSTLC_UPDATE_CLIENT_BODY_START */
|
|
440
|
-
window.__ModuleLoader__.load(__stardustUpdatesWrap({id:"@stardustlc/dsh-review",factory:require=>({apply(){}})},{"name":"@stardustlc/dsh-review","version":"0.1.0","hasWorkbench":false,"packageVersion":"0.
|
|
440
|
+
window.__ModuleLoader__.load(__stardustUpdatesWrap({id:"@stardustlc/dsh-review",factory:require=>({apply(){}})},{"name":"@stardustlc/dsh-review","version":"0.1.0","hasWorkbench":false,"packageVersion":"0.5.0","label":"代码审阅","labelEn":"Review","suiteComponent":false}));
|
|
441
441
|
|
|
442
442
|
/* STARDUSTLC_UPDATE_CLIENT_BODY_END */
|
|
443
443
|
})();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stardustlc/dsh-review",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "DSH 代码审阅:独立发现缺陷、证据复核、修复跟踪与门禁;支持三种审阅模式。欢迎提交 issues 和 PR。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|