dsh-coding-enhanced 0.8.4 → 0.8.5
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 +10 -0
- package/README.md +1 -0
- package/docs/review-prompts-and-chain.md +33 -2
- package/lib/client.js +21 -0
- package/lib/index.js +149 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.5
|
|
4
|
+
|
|
5
|
+
- Native `bash` is denied while Pre-review is on; shell commands go through
|
|
6
|
+
`review_bash`, which detects writes and asks for a second confirmation.
|
|
7
|
+
- Build/test artifacts (`dist`, `build`, `node_modules`, ...) are allowed;
|
|
8
|
+
writes to source are blocked.
|
|
9
|
+
- Audit changes at `turn/end` against the turn-start snapshot and warn about
|
|
10
|
+
files changed outside review.
|
|
11
|
+
- Update the review prompt to read / review tools / review_bash.
|
|
12
|
+
|
|
3
13
|
## 0.5.15
|
|
4
14
|
|
|
5
15
|
- Restore the native tool gate: while AI Change Review and the input-bar Auto
|
package/README.md
CHANGED
|
@@ -272,6 +272,7 @@ Open **Settings → Coding Enhanced** (the same controls appear on the plugin's
|
|
|
272
272
|
| **Automatic cleanup** | on | run `git gc` on shadow snapshots after pruning or withdrawing |
|
|
273
273
|
| **Clean up now** | — | prune extra snapshots and compact every shadow repository |
|
|
274
274
|
| **Updates** | — | check npm for the latest release and install it from the settings card; restart DSH after updating |
|
|
275
|
+
| **Review shell** | on | native `bash` is denied while Pre-review is on; commands go through `review_bash` (write detection + confirmation) |
|
|
275
276
|
|
|
276
277
|
Settings apply immediately and persist in `$DSH_HOME/coding-enhanced/settings.json`.
|
|
277
278
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Review contract: prompts & chain
|
|
2
2
|
|
|
3
|
-
> Version: **0.8.
|
|
3
|
+
> Version: **0.8.5** · Date: 2026-11-22 · Source: `dsh-coding-enhanced`
|
|
4
4
|
>
|
|
5
5
|
> This document records the exact prompts, tool contracts and execution chain
|
|
6
6
|
> of the AI change-review workflow. It is intended as a reference for
|
|
@@ -304,10 +304,40 @@ dropped:
|
|
|
304
304
|
- npm publishing uses Trusted Publishing (OIDC); the registry CDN may lag a few
|
|
305
305
|
minutes after the workflow succeeds.
|
|
306
306
|
- The review contract is versioned with the plugin; this document describes
|
|
307
|
-
0.8.
|
|
307
|
+
0.8.5.
|
|
308
308
|
|
|
309
309
|
---
|
|
310
310
|
|
|
311
|
+
## 7.1 Shell gate (0.8.5)
|
|
312
|
+
|
|
313
|
+
Native `bash` is denied while Pre-review is on. All commands go through the
|
|
314
|
+
plugin tool `review_bash`:
|
|
315
|
+
|
|
316
|
+
```text
|
|
317
|
+
review_bash({ command, confirmed?, cwd? })
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
- First call: write detection only, no execution. Returns the reasons and a
|
|
321
|
+
self-check prompt.
|
|
322
|
+
- The agent self-checks whether the command creates/modifies/deletes files.
|
|
323
|
+
- If it writes source: use `review_write` / `review_patch`.
|
|
324
|
+
- If it writes nothing: call again with `confirmed: true`.
|
|
325
|
+
- Second call: re-detect, then run `/bin/sh -c` with the session cwd.
|
|
326
|
+
|
|
327
|
+
Write detection covers shell redirection, `tee`, `sed -i`, `perl -i`,
|
|
328
|
+
`cp/mv/rm/rmdir/mkdir/touch/ln/chmod`, `git apply`, `patch`, dependency
|
|
329
|
+
installs, and inline Python/Node writes. Writes under `dist`, `build`, `out`,
|
|
330
|
+
`target`, `node_modules`, `.next`, `.cache`, `coverage`, `.vitest`,
|
|
331
|
+
`__pycache__`, `.pytest_cache`, `.turbo` are build/test artifacts and pass.
|
|
332
|
+
|
|
333
|
+
### Post-turn audit
|
|
334
|
+
|
|
335
|
+
At `turn/end` the host diffs the turn-start snapshot against the current
|
|
336
|
+
workspace, subtracts reviewed paths and artifact paths, and stores the
|
|
337
|
+
remaining files as `audits[sessionId].outside`. The review tab shows a warning
|
|
338
|
+
listing them; the user can withdraw the turn or accept. The audit is a
|
|
339
|
+
backstop for writes the shell detection missed; it does not auto-revert.
|
|
340
|
+
|
|
311
341
|
## 8. Version history (review workflow)
|
|
312
342
|
|
|
313
343
|
| Version | Change |
|
|
@@ -317,3 +347,4 @@ dropped:
|
|
|
317
347
|
| 0.8.0–0.8.2 | Plugin-owned persistent waiter via `ctx.subagents` (agent-scoped tool, `spawn`) |
|
|
318
348
|
| 0.8.3 | Parent-written explanations; per-file notes validation; comment subagent dropped |
|
|
319
349
|
| 0.8.4 | Copy fixes; this document |
|
|
350
|
+
| 0.8.5 | Native bash denied; `review_bash` with two-step confirmation and write detection; post-turn audit; read/edit/run prompt |
|
package/lib/client.js
CHANGED
|
@@ -123,6 +123,8 @@ window.__ModuleLoader__.load({
|
|
|
123
123
|
settingsAboutTitle: 'Coding Enhanced',
|
|
124
124
|
settingsAboutDesc: 'The DSH change gate: pre-write review, multi-turn withdraw, and a non-blocking review handoff. The full README lives on the plugin page and in the repository.',
|
|
125
125
|
settingsReadme: 'Open the full README',
|
|
126
|
+
auditTitle: 'Changed outside review',
|
|
127
|
+
auditDesc: 'Files changed outside review: {files}. Withdraw the turn or accept the change.',
|
|
126
128
|
settingsUpdates: 'Plugin updates',
|
|
127
129
|
settingsUpdatesDesc: 'Check npm for the latest release and install it from here.',
|
|
128
130
|
settingsCurrentVersion: 'Current version',
|
|
@@ -234,6 +236,8 @@ window.__ModuleLoader__.load({
|
|
|
234
236
|
settingsAboutTitle: 'Coding Enhanced',
|
|
235
237
|
settingsAboutDesc: 'DSH 变更闸门:写入前审查、多轮回退、非阻塞 review 交接。完整 README 在插件页和仓库里。',
|
|
236
238
|
settingsReadme: '打开完整 README',
|
|
239
|
+
auditTitle: 'review 外改动',
|
|
240
|
+
auditDesc: '以下文件在 review 外被修改:{files}。可撤回这一轮或接受改动。',
|
|
237
241
|
settingsUpdates: '插件更新',
|
|
238
242
|
settingsUpdatesDesc: '检查 npm 最新版本,并在这里安装。',
|
|
239
243
|
settingsCurrentVersion: '当前版本',
|
|
@@ -334,6 +338,9 @@ window.__ModuleLoader__.load({
|
|
|
334
338
|
.wr-diff-resize{flex:none;height:.75em;min-height:10px;cursor:ns-resize;background:linear-gradient(to bottom,transparent,color-mix(in srgb,var(--dsw-alias-border-l1,rgba(0,0,0,.08)) 60%,transparent));position:relative}
|
|
335
339
|
.wr-diff-resize::after{content:'';position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:2.4em;height:.25em;border-radius:999px;background:var(--dsw-alias-border-l3,rgba(0,0,0,.18))}
|
|
336
340
|
.wr-diff-resize:hover{background:color-mix(in srgb,var(--dsw-alias-state-business-primary,#4d6bfe) 12%,transparent)}
|
|
341
|
+
.wr-audit{margin:.55em .7em .2em;padding:.55em .7em;border-radius:.5em;border:1px solid color-mix(in srgb,var(--dsw-alias-state-warn-primary,#9a6700) 35%,transparent);background:color-mix(in srgb,var(--dsw-alias-state-warn-primary,#9a6700) 8%,transparent);font-size:.82em;line-height:1.5}
|
|
342
|
+
.wr-audit-title{font-weight:600;color:var(--dsw-alias-state-warn-primary,#9a6700)}
|
|
343
|
+
.wr-audit-desc{margin-top:.2em;color:var(--dsw-alias-label-secondary,#555);white-space:pre-wrap;overflow-wrap:anywhere}
|
|
337
344
|
.wr-ai-line{background:linear-gradient(90deg,rgba(124,58,237,.10),rgba(217,70,239,.07) 55%,rgba(34,211,238,.05));box-shadow:inset 2px 0 0 #a855f7;cursor:help}
|
|
338
345
|
.wr-ai-line:hover{background:linear-gradient(90deg,rgba(124,58,237,.15),rgba(217,70,239,.10) 55%,rgba(34,211,238,.07))}
|
|
339
346
|
.wr-ai-line .wr-no{background:rgba(168,85,247,.10);color:transparent}
|
|
@@ -858,6 +865,7 @@ div:has(> [data-detail-document]) > [data-plugin-config]{order:-1}
|
|
|
858
865
|
const feed = {
|
|
859
866
|
version: -1,
|
|
860
867
|
reviews: [],
|
|
868
|
+
audits: {},
|
|
861
869
|
loaded: false,
|
|
862
870
|
error: null,
|
|
863
871
|
listeners: new Set(),
|
|
@@ -889,6 +897,7 @@ div:has(> [data-detail-document]) > [data-plugin-config]{order:-1}
|
|
|
889
897
|
}
|
|
890
898
|
feed.version = result.value.version
|
|
891
899
|
feed.reviews = result.value.reviews ?? []
|
|
900
|
+
feed.audits = result.value.audits ?? {}
|
|
892
901
|
feed.error = null
|
|
893
902
|
feed.loaded = true
|
|
894
903
|
feedNotify()
|
|
@@ -964,6 +973,8 @@ div:has(> [data-detail-document]) > [data-plugin-config]{order:-1}
|
|
|
964
973
|
const state = useReviews()
|
|
965
974
|
const tabs = useOpenTabs()
|
|
966
975
|
const review = pendingReview(state.reviews)
|
|
976
|
+
const audit = state.audits?.[sessionId]
|
|
977
|
+
const auditOutside = Array.isArray(audit?.outside) ? audit.outside : []
|
|
967
978
|
const opened = React.useRef(null)
|
|
968
979
|
const tabOpen = tabs.some((tab) => tab.kind === REVIEW_KIND && tab.sessionId === sessionId)
|
|
969
980
|
|
|
@@ -1004,6 +1015,8 @@ div:has(> [data-detail-document]) > [data-plugin-config]{order:-1}
|
|
|
1004
1015
|
const { tab } = useTabInfo()
|
|
1005
1016
|
const state = useReviews()
|
|
1006
1017
|
const review = pendingReview(state.reviews)
|
|
1018
|
+
const audit = state.audits?.[sessionId]
|
|
1019
|
+
const auditOutside = Array.isArray(audit?.outside) ? audit.outside : []
|
|
1007
1020
|
const [local, setLocal] = React.useState({})
|
|
1008
1021
|
const [submitting, setSubmitting] = React.useState(false)
|
|
1009
1022
|
const [error, setError] = React.useState(null)
|
|
@@ -1377,6 +1390,14 @@ div:has(> [data-detail-document]) > [data-plugin-config]{order:-1}
|
|
|
1377
1390
|
: `${review.entries.length} files`,
|
|
1378
1391
|
),
|
|
1379
1392
|
),
|
|
1393
|
+
auditOutside.length > 0
|
|
1394
|
+
? React.createElement(
|
|
1395
|
+
'div',
|
|
1396
|
+
{ className: 'wr-audit' },
|
|
1397
|
+
React.createElement('div', { className: 'wr-audit-title' }, typeof t === 'function' ? t('auditTitle') : 'Changed outside review'),
|
|
1398
|
+
React.createElement('div', { className: 'wr-audit-desc' }, typeof t === 'function' ? t('auditDesc', { files: auditOutside.join(', ') }) : `Files changed outside review: ${auditOutside.join(', ')}`),
|
|
1399
|
+
)
|
|
1400
|
+
: null,
|
|
1380
1401
|
!submitted
|
|
1381
1402
|
? React.createElement('div', { className: 'wr-collecting' }, typeof t === 'function' ? t('collecting') : 'Waiting for the agent to submit.')
|
|
1382
1403
|
: null,
|
package/lib/index.js
CHANGED
|
@@ -867,11 +867,47 @@ export function apply(ctx) {
|
|
|
867
867
|
|
|
868
868
|
// ------------------------------------------------------- review gate ---
|
|
869
869
|
const REVIEW_TOOLS = new Set(['write', 'edit', 'apply_patch', 'str_replace_editor', 'multi_edit', 'notebook_edit'])
|
|
870
|
+
const ARTIFACT_DIRS = ['dist', 'build', 'out', 'target', 'node_modules', '.next', '.cache', 'coverage', '.vitest', '__pycache__', '.pytest_cache', '.turbo', '.parcel-cache']
|
|
871
|
+
const isArtifactPath = (value) => {
|
|
872
|
+
const cleaned = String(value).replace(/^['"]|['"]$/g, '').replace(/^\.\//, '')
|
|
873
|
+
if (cleaned === '/dev/null' || cleaned.startsWith('/tmp/') || cleaned === '/tmp') return true
|
|
874
|
+
return ARTIFACT_DIRS.some((dir) => cleaned === dir || cleaned.startsWith(`${dir}/`) || cleaned.includes(`/${dir}/`))
|
|
875
|
+
}
|
|
876
|
+
const detectShellWrites = (command) => {
|
|
877
|
+
const reasons = []
|
|
878
|
+
const targets = []
|
|
879
|
+
const add = (reason, target) => {
|
|
880
|
+
reasons.push(reason)
|
|
881
|
+
if (typeof target === 'string' && target !== '') targets.push(target)
|
|
882
|
+
}
|
|
883
|
+
for (const match of command.matchAll(/(?:^|[^>])>{1,2}\s*([^\s;&|]+)/g)) add('shell redirection', match[1])
|
|
884
|
+
const tee = /\btee\s+(?:-[A-Za-z]+\s+)*([^\s;&|]+)/.exec(command)
|
|
885
|
+
if (tee !== null) add('tee', tee[1])
|
|
886
|
+
const sed = /\bsed\s+(?:[^;&|]*\s)?-i(?:\.\w+)?\s+([^\s;&|]+)/.exec(command)
|
|
887
|
+
if (sed !== null) add('in-place edit', sed[1])
|
|
888
|
+
const perl = /\bperl\s+-i\s+([^\s;&|]+)/.exec(command)
|
|
889
|
+
if (perl !== null) add('in-place edit', perl[1])
|
|
890
|
+
for (const op of ['cp', 'mv', 'rm', 'rmdir', 'mkdir', 'touch', 'ln', 'chmod']) {
|
|
891
|
+
const match = new RegExp(`\\b${op}\\b([^;&|]*)`).exec(command)
|
|
892
|
+
if (match === null) continue
|
|
893
|
+
const args = match[1].split(/\s+/).filter((part) => part !== '' && !part.startsWith('-') && !part.includes('='))
|
|
894
|
+
add(op, args.length > 0 ? args[args.length - 1] : undefined)
|
|
895
|
+
}
|
|
896
|
+
if (/\bgit\s+apply\b/.test(command)) add('git apply')
|
|
897
|
+
if (/\bpatch\b/.test(command)) add('patch')
|
|
898
|
+
if (/\b(npm\s+(install|ci)|pnpm\s+add|yarn\s+add)\b/.test(command)) add('dependency install')
|
|
899
|
+
if (/\b(python3?|node)\b/.test(command) && /\b(open|writeFileSync|writeFile|write_text|to_csv|savefig|fs\.write)/.test(command)) add('inline write')
|
|
900
|
+
const sourceTargets = targets.filter((target) => !isArtifactPath(target))
|
|
901
|
+
const blocked = reasons.length > 0 && (sourceTargets.length > 0 || targets.length < reasons.length)
|
|
902
|
+
return { blocked, reasons, targets }
|
|
903
|
+
}
|
|
904
|
+
|
|
870
905
|
const MAX_REVIEW_FILE_BYTES = 2 * 1024 * 1024
|
|
871
906
|
const MAX_EDITABLE_BYTES = 200 * 1024
|
|
872
907
|
/** sessionId -> review { id, sessionId, entries, virtual, submitted, finished, canceled, waiters } */
|
|
873
908
|
const reviews = new Map()
|
|
874
909
|
const reviewWaiters = new Map()
|
|
910
|
+
const audits = new Map()
|
|
875
911
|
let reviewVersion = 0
|
|
876
912
|
|
|
877
913
|
const bumpReview = () => {
|
|
@@ -1537,15 +1573,95 @@ export function apply(ctx) {
|
|
|
1537
1573
|
}), { when: () => featureFlags.review === true && featureFlags.autoReview === true })
|
|
1538
1574
|
}
|
|
1539
1575
|
|
|
1576
|
+
const execShell = (command, cwd) => new Promise((resolve) => {
|
|
1577
|
+
execFile('/bin/sh', ['-c', command], { cwd, timeout: 120000, maxBuffer: 8 * 1024 * 1024, env: process.env }, (error, stdout, stderr) => {
|
|
1578
|
+
resolve({ code: error === null ? 0 : (typeof error.code === 'number' ? error.code : 1), stdout: String(stdout ?? ''), stderr: String(stderr ?? '') })
|
|
1579
|
+
})
|
|
1580
|
+
})
|
|
1581
|
+
|
|
1582
|
+
const registerBashTool = () => {
|
|
1583
|
+
ctx.tools.register(defineTool({
|
|
1584
|
+
name: 'review_bash',
|
|
1585
|
+
description: 'Run a shell command for inspection or tests. The first call does not execute: it returns the write-detection result and asks you to self-check whether the command creates, modifies or deletes files. If it does, use review_write / review_patch instead. If it does not, call again with confirmed:true. The second call re-checks, then runs /bin/sh -c. Build/test artifacts under dist, build, node_modules and similar directories are allowed; writes to source are blocked.',
|
|
1586
|
+
parameters: {
|
|
1587
|
+
command: { type: 'string', required: true, description: 'Shell command to run.' },
|
|
1588
|
+
confirmed: { type: 'boolean', description: 'Set true only after you have checked that the command does not create, modify or delete source files.' },
|
|
1589
|
+
cwd: { type: 'string', description: 'Optional working directory; defaults to the session workspace.' },
|
|
1590
|
+
},
|
|
1591
|
+
output: {
|
|
1592
|
+
schema: {
|
|
1593
|
+
type: 'object',
|
|
1594
|
+
additionalProperties: false,
|
|
1595
|
+
properties: {
|
|
1596
|
+
status: { type: 'string' },
|
|
1597
|
+
command: { type: 'string' },
|
|
1598
|
+
writes: { type: 'boolean' },
|
|
1599
|
+
reasons: { type: 'array', items: { type: 'string' } },
|
|
1600
|
+
exitCode: { type: 'integer' },
|
|
1601
|
+
stdout: { type: 'string' },
|
|
1602
|
+
stderr: { type: 'string' },
|
|
1603
|
+
message: { type: 'string' },
|
|
1604
|
+
},
|
|
1605
|
+
},
|
|
1606
|
+
render: (_args, value) => [{ type: 'text', text: JSON.stringify(value, null, 2) }],
|
|
1607
|
+
},
|
|
1608
|
+
async execute(args, exec) {
|
|
1609
|
+
const session = exec.agent?.session
|
|
1610
|
+
if (session === undefined) return { status: 'error', command: '', writes: false, message: 'No active session.' }
|
|
1611
|
+
const command = typeof args?.command === 'string' ? args.command : ''
|
|
1612
|
+
if (command.trim() === '') return { status: 'error', command, writes: false, message: 'command is required.' }
|
|
1613
|
+
const base = typeof session.header?.cwd === 'string' && session.header.cwd !== '' ? session.header.cwd : process.cwd()
|
|
1614
|
+
const cwd = typeof args?.cwd === 'string' && args.cwd !== '' ? path.resolve(base, args.cwd) : base
|
|
1615
|
+
const detection = detectShellWrites(command)
|
|
1616
|
+
if (args?.confirmed !== true) {
|
|
1617
|
+
return {
|
|
1618
|
+
status: 'confirm',
|
|
1619
|
+
command,
|
|
1620
|
+
writes: detection.blocked,
|
|
1621
|
+
reasons: detection.reasons,
|
|
1622
|
+
message: detection.blocked
|
|
1623
|
+
? 'This command appears to write source files. Use review_write / review_patch for file changes.'
|
|
1624
|
+
: 'Self-check: does this command create, modify or delete files? If yes, use review_write / review_patch. If no, call review_bash again with confirmed:true.',
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
if (detection.blocked === true) {
|
|
1628
|
+
return {
|
|
1629
|
+
status: 'blocked',
|
|
1630
|
+
command,
|
|
1631
|
+
writes: true,
|
|
1632
|
+
reasons: detection.reasons,
|
|
1633
|
+
message: 'Write detection blocked this command. Use review_write / review_patch for file changes.',
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
const result = await execShell(command, cwd)
|
|
1637
|
+
return {
|
|
1638
|
+
status: result.code === 0 ? 'ok' : 'error',
|
|
1639
|
+
command,
|
|
1640
|
+
writes: false,
|
|
1641
|
+
reasons: detection.reasons,
|
|
1642
|
+
exitCode: result.code,
|
|
1643
|
+
stdout: result.stdout,
|
|
1644
|
+
stderr: result.stderr,
|
|
1645
|
+
}
|
|
1646
|
+
},
|
|
1647
|
+
}), { when: () => featureFlags.review === true && featureFlags.autoReview === true })
|
|
1648
|
+
}
|
|
1540
1649
|
|
|
1541
1650
|
registerReviewTools()
|
|
1651
|
+
registerBashTool()
|
|
1542
1652
|
|
|
1543
1653
|
const nativeGate = async (exec, next) => {
|
|
1544
1654
|
if (featureFlags.review !== true || featureFlags.autoReview !== true) return next()
|
|
1655
|
+
if (exec.name === 'bash') {
|
|
1656
|
+
return {
|
|
1657
|
+
kind: 'deny',
|
|
1658
|
+
reason: 'Use review_bash for shell commands while Pre-review is on. It self-checks writes and asks for a second confirmation; file changes must use review_write / review_patch. Do not use bash to write files.',
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1545
1661
|
if (!REVIEW_TOOLS.has(exec.name)) return next()
|
|
1546
1662
|
return {
|
|
1547
1663
|
kind: 'deny',
|
|
1548
|
-
reason: 'File changes must go through the review gate while Pre-review is on. Use review_write (new file / full file) or review_patch (unified diff) with at least one note per changed file; the plugin starts or reuses the review waiter automatically; just continue. Never call review_wait from the main agent.
|
|
1664
|
+
reason: 'File changes must go through the review gate while Pre-review is on. Use review_write (new file / full file) or review_patch (unified diff) with at least one note per changed file; the plugin starts or reuses the review waiter automatically; just continue. Never call review_wait from the main agent. Run shell commands with review_bash.',
|
|
1549
1665
|
}
|
|
1550
1666
|
}
|
|
1551
1667
|
|
|
@@ -1556,17 +1672,46 @@ export function apply(ctx) {
|
|
|
1556
1672
|
name: 'tool:review-gate',
|
|
1557
1673
|
order: 110,
|
|
1558
1674
|
text: () => featureFlags.review === true && featureFlags.autoReview === true
|
|
1559
|
-
? '🎟️ FILE-EDIT VELVET ROPE: The human personally reviews every file change.
|
|
1675
|
+
? '🎟️ FILE-EDIT VELVET ROPE: The human personally reviews every file change. Read with read; change files with review_write (new file / full file) or review_patch (unified diff); run commands with review_bash. Do not use write/edit/apply_patch/str_replace_editor. Never use bash to write files: review_bash first returns the write-detection result, you self-check whether the command creates/modifies/deletes files, and only a second call with confirmed:true runs it when it writes no source files. Include at least one note per changed file while AI explanations are on; add line-level notes for user-requested, key or hard-to-understand changes (no upper limit). The plugin starts or reuses the review waiter automatically: after queueing, just continue or end the turn; never call review_wait and do not manage a subagent. If a file is rejected, read the comment and revise. This is house rules. 💅'
|
|
1560
1676
|
: '',
|
|
1561
1677
|
}), 'coding-enhanced: review prompt')
|
|
1562
1678
|
})
|
|
1563
1679
|
|
|
1680
|
+
const runAudit = async (session, turn) => {
|
|
1681
|
+
try {
|
|
1682
|
+
const snapshot = snapshotOf(session.id, turn)
|
|
1683
|
+
if (snapshot === undefined) return
|
|
1684
|
+
const cwd = typeof session.header?.cwd === 'string' && session.header.cwd !== '' ? session.header.cwd : process.cwd()
|
|
1685
|
+
const review = reviews.get(session.id)
|
|
1686
|
+
const reviewed = review === undefined ? [] : [...review.entries.values()].map((entry) => entry.display)
|
|
1687
|
+
const base = await captureWorkspace(session.id, cwd)
|
|
1688
|
+
if (base === undefined) return
|
|
1689
|
+
const diff = await runGit(['diff', '--name-status', snapshot.tree, base.tree], { gitDir: snapshot.gitDir, workTree: cwd })
|
|
1690
|
+
const changed = diff.split('\n').map((line) => line.trim()).filter((line) => line !== '').map((line) => {
|
|
1691
|
+
const parts = line.split('\t')
|
|
1692
|
+
return parts.length >= 2 ? parts[parts.length - 1] : ''
|
|
1693
|
+
}).filter((value) => value !== '')
|
|
1694
|
+
const outside = changed.filter((file) => !reviewed.includes(file) && !isArtifactPath(file))
|
|
1695
|
+
audits.set(session.id, {
|
|
1696
|
+
turn,
|
|
1697
|
+
outside,
|
|
1698
|
+
reviewed,
|
|
1699
|
+
artifacts: changed.filter((file) => isArtifactPath(file)),
|
|
1700
|
+
at: Date.now(),
|
|
1701
|
+
})
|
|
1702
|
+
bumpReview()
|
|
1703
|
+
} catch (error) {
|
|
1704
|
+
ctx.logger?.warn?.(`coding-enhanced: audit failed: ${String(error)}`)
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1564
1708
|
ctx.on('session/event', (session, event) => {
|
|
1565
1709
|
if (event.type === 'turn/start') {
|
|
1566
1710
|
const cwd = session.header?.cwd
|
|
1567
1711
|
if (typeof cwd !== 'string' || cwd === '' || isSubagent(session)) return
|
|
1568
1712
|
const turn = event.data?.turn
|
|
1569
1713
|
activeTurns.set(session.id, turn)
|
|
1714
|
+
audits.delete(session.id)
|
|
1570
1715
|
if (featureFlags.withdraw === true) {
|
|
1571
1716
|
const promise = captureSnapshot(session.id, cwd, turn).catch((error) => {
|
|
1572
1717
|
ctx.logger?.warn?.(`coding-enhanced: cannot snapshot ${cwd}: ${String(error)}`)
|
|
@@ -1580,6 +1725,7 @@ export function apply(ctx) {
|
|
|
1580
1725
|
}
|
|
1581
1726
|
if (event.type === 'turn/end') {
|
|
1582
1727
|
const turn = event.data?.turn
|
|
1728
|
+
void runAudit(session, turn)
|
|
1583
1729
|
activeTurns.delete(session.id)
|
|
1584
1730
|
const review = reviews.get(session.id)
|
|
1585
1731
|
if (review !== undefined) {
|
|
@@ -2162,6 +2308,7 @@ export function apply(ctx) {
|
|
|
2162
2308
|
version: reviewVersion,
|
|
2163
2309
|
unchanged: false,
|
|
2164
2310
|
reviews: [...reviews.values()].map(serializeReview),
|
|
2311
|
+
audits: Object.fromEntries(audits),
|
|
2165
2312
|
})
|
|
2166
2313
|
}
|
|
2167
2314
|
if (endpoint === 'decide') return decideReview(payload?.reviewId, payload?.decisions)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-coding-enhanced",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"description": "The DSH change gate: queue AI edits before write, rewind turns with shadow-git snapshots, and hand review to a non-blocking waiter subagent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|