@stmcw1/dacw 1.1.0 → 1.1.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/README.md CHANGED
@@ -57,11 +57,11 @@ DACW 是一个 **DSH Host 插件**:写手子代理按增量协议产出代码
57
57
 
58
58
  ```bash
59
59
  node build.mjs # 构建 dist/(Node 内置类型擦除,无需 typescript)
60
- node selftest.mjs # 131 项回归自测
60
+ node selftest.mjs # 135 项回归自测
61
61
  npm pack --pack-destination ../dacw-pack # 生成安装产物
62
62
  ```
63
63
 
64
- 在 DSH 插件管理器中执行 `install_bundle`,target 填 tarball 的绝对路径并加 `file:` 前缀(例如 `file:/absolute/path/to/stmcw1-dacw-1.1.0.tgz`)。安装后向 profile 插入 Host 行 `dacw`(bundle 包名 `@stmcw1/dacw`)。**不要用目录路径安装**——目录安装会绕过 `files` 白名单,把源码、测试与构建脚本一并装进 profile。
64
+ 在 DSH 插件管理器中执行 `install_bundle`,target 填 tarball 的绝对路径并加 `file:` 前缀(例如 `file:/absolute/path/to/stmcw1-dacw-1.1.1.tgz`)。安装后向 profile 插入 Host 行 `dacw`(bundle 包名 `@stmcw1/dacw`)。**不要用目录路径安装**——目录安装会绕过 `files` 白名单,把源码、测试与构建脚本一并装进 profile。
65
65
 
66
66
  升级:改代码 → `node build.mjs` → `npm pack` → `remove_bundle` → `install_bundle` 同一 tarball → 重启 Harness。
67
67
 
@@ -227,7 +227,7 @@ DACW 会执行模型生成的代码与命令。**测试在审查之前执行**
227
227
 
228
228
  ## 状态
229
229
 
230
- 实验性开发者预览(当前版本 `v1.1.0`,bundle `@stmcw1/dacw`):构建冒烟与 131 项回归自测通过。默认执行策略为宿主直执(`sandbox.mode: "host"`,无隔离);`auto`/`docker` 为显式可选(Docker 不可用时 fail-closed / 交互确认,见「沙箱配置」)。**宿主执行闭环验证状态:** v1.1.0 改动了默认执行策略、回滚授权、秘密管控、测试后对账与宿主能力探测,已在 DSH 0.2.2-rc.1 桌面宿主下完成闭环验证:插件激活、`dacw_run` 写手产出 → 测试 → 独立审查 → `NEED_HUMAN`、`dacw_rollback` 工作区恢复、秘密扫描命中拒绝、`userQuestions` 人工确认,五条链路均实测走通。已知限制见 ROADMAP「4b. 已知限制 / 建议优先」。欢迎 issue / PR。
230
+ 实验性开发者预览(当前版本 `v1.1.1`,bundle `@stmcw1/dacw`):构建冒烟与 135 项回归自测通过;`v1.1.1` 为 patch 版本,修复回滚后地基文件残留(兼容 1.1.0 旧 state)。默认执行策略为宿主直执(`sandbox.mode: "host"`,无隔离);`auto`/`docker` 为显式可选(Docker 不可用时 fail-closed / 交互确认,见「沙箱配置」)。**宿主执行闭环验证状态:** v1.1.0 改动了默认执行策略、回滚授权、秘密管控、测试后对账与宿主能力探测,已在 DSH 0.2.2-rc.1 桌面宿主下完成闭环验证:插件激活、`dacw_run` 写手产出 → 测试 → 独立审查 → `NEED_HUMAN`、`dacw_rollback` 工作区恢复、秘密扫描命中拒绝、`userQuestions` 人工确认,五条链路均实测走通。已知限制见 ROADMAP「4b. 已知限制 / 建议优先」。欢迎 issue / PR。
231
231
 
232
232
  ## 许可证
233
233
 
package/README_EN.md CHANGED
@@ -57,11 +57,11 @@ Build requires Node ≥ 22.13; tests run on the host by default (no isolation, r
57
57
 
58
58
  ```bash
59
59
  node build.mjs # build dist/ (Node built-in type stripping, no typescript)
60
- node selftest.mjs # 131 regression vectors
60
+ node selftest.mjs # 135 regression vectors
61
61
  npm pack --pack-destination ../dacw-pack # produce the install artifact
62
62
  ```
63
63
 
64
- In the DSH plugin manager run `install_bundle` with the tarball's absolute path prefixed by `file:` (for example `file:/absolute/path/to/stmcw1-dacw-1.1.0.tgz`). Installation inserts Host row `dacw` (bundle package `@stmcw1/dacw`) into the profile. **Do not install with a directory path** — a directory install bypasses the `files` whitelist and ships sources, tests and build scripts into the profile.
64
+ In the DSH plugin manager run `install_bundle` with the tarball's absolute path prefixed by `file:` (for example `file:/absolute/path/to/stmcw1-dacw-1.1.1.tgz`). Installation inserts Host row `dacw` (bundle package `@stmcw1/dacw`) into the profile. **Do not install with a directory path** — a directory install bypasses the `files` whitelist and ships sources, tests and build scripts into the profile.
65
65
 
66
66
  Upgrade: edit sources → `node build.mjs` → `npm pack` → `remove_bundle` → `install_bundle` the same tarball → restart the Harness.
67
67
 
@@ -225,7 +225,7 @@ See [SAFETY_EN.md](SAFETY_EN.md) for the full boundaries, execution order and di
225
225
 
226
226
  ## Status
227
227
 
228
- Experimental developer preview (current version `v1.1.0`, bundle `@stmcw1/dacw`): the build smoke check and 131 regression vectors pass. The default execution policy is host (no isolation); `auto`/`docker` are explicit opt-ins (fail-closed / interactive confirmation when Docker is unavailable — see "Sandbox configuration"). **Live host-execution loop status:** v1.1.0 changed the default execution policy, rollback authorization, secret controls, post-test reconciliation and host capability probe, and **has completed the closed-loop verification on the DSH `0.2.2-rc.1` desktop host** (2026-11-06): plugin activation, `dacw_run` writer output → test → independent review → `NEED_HUMAN`, `dacw_rollback` workspace restore, secret-scan hit rejection, and `userQuestions` human confirmation — all five paths measured in effect. Known limitations: see ROADMAP "4b. Known limitations / Prioritized suggestions". Issues and PRs are welcome.
228
+ Experimental developer preview (current version `v1.1.1`, bundle `@stmcw1/dacw`): the build smoke check and 135 regression vectors pass; `v1.1.1` is a patch release fixing leftover root-level foundation files after rollback (compatible with 1.1.0 state). The default execution policy is host (no isolation); `auto`/`docker` are explicit opt-ins (fail-closed / interactive confirmation when Docker is unavailable — see "Sandbox configuration"). **Live host-execution loop status:** v1.1.0 changed the default execution policy, rollback authorization, secret controls, post-test reconciliation and host capability probe, and **has completed the closed-loop verification on the DSH `0.2.2-rc.1` desktop host** (2026-11-06): plugin activation, `dacw_run` writer output → test → independent review → `NEED_HUMAN`, `dacw_rollback` workspace restore, secret-scan hit rejection, and `userQuestions` human confirmation — all five paths measured in effect. Known limitations: see ROADMAP "4b. Known limitations / Prioritized suggestions". Issues and PRs are welcome.
229
229
 
230
230
  ## License
231
231
 
package/dist/index.js CHANGED
@@ -129,6 +129,21 @@ const CLEAN_PROTECTED_PATTERNS = [
129
129
  function isFoundationName(name) {
130
130
  return CLEAN_PROTECTED_PATTERNS.some((p)=>p.test(name));
131
131
  }
132
+ export async function listRootFoundationFiles(workspaceDir) {
133
+ const resolved = path.resolve(workspaceDir);
134
+ const entries = await fs.readdir(resolved, {
135
+ withFileTypes: true
136
+ });
137
+ const names = [];
138
+ for (const entry of entries){
139
+ if (entry.name === '.git' || entry.name === 'node_modules' || entry.name === '.dacw-workspace') continue;
140
+ if (!entry.isFile()) continue;
141
+ if (!isFoundationName(entry.name)) continue;
142
+ names.push(entry.name);
143
+ }
144
+ names.sort();
145
+ return names;
146
+ }
132
147
  function resolveInsideWorkspace(workspaceDir, relPath) {
133
148
  const safeDir = path.resolve(workspaceDir);
134
149
  const target = path.resolve(safeDir, relPath);
@@ -638,6 +653,7 @@ export async function captureRollbackPoint(workspaceDir, stateDir, rawTaskId) {
638
653
  throw new Error(`检测到 .git 但无法读取 HEAD(仓库可能损坏):${e?.message ?? String(e)}`);
639
654
  }
640
655
  }
656
+ const foundationAtStart = await listRootFoundationFiles(resolvedWorkspace);
641
657
  const backupKey = crypto.createHash('sha256').update(String(rawTaskId) + '\n' + resolvedWorkspace).digest('hex').slice(0, 8);
642
658
  const backupDir = path.join(resolvedStateDir, 'backup', backupKey);
643
659
  await fs.rm(backupDir, {
@@ -666,7 +682,8 @@ export async function captureRollbackPoint(workspaceDir, stateDir, rawTaskId) {
666
682
  return {
667
683
  mode: 'workspace',
668
684
  ref: backupKey,
669
- capturedAt
685
+ capturedAt,
686
+ foundationAtStart
670
687
  };
671
688
  }
672
689
  export async function rollbackTask(stateDir, rawTaskId, workspaceDir, reason = '用户请求回滚', checksumFn, onBeforeExecute) {
@@ -745,6 +762,13 @@ export async function rollbackTask(stateDir, rawTaskId, workspaceDir, reason = '
745
762
  }
746
763
  try {
747
764
  await safeCleanWorkspace(resolvedWorkspace);
765
+ if (Array.isArray(rollbackPoint.foundationAtStart)) {
766
+ const keptFoundation = new Set(rollbackPoint.foundationAtStart);
767
+ for (const name of (await listRootFoundationFiles(resolvedWorkspace))){
768
+ if (keptFoundation.has(name)) continue;
769
+ await fs.unlink(path.join(resolvedWorkspace, name));
770
+ }
771
+ }
748
772
  await fs.cp(backupDir, resolvedWorkspace, {
749
773
  recursive: true,
750
774
  filter: (src)=>{
package/dist/plugin.js CHANGED
@@ -3,7 +3,7 @@ import * as os from 'os';
3
3
  import * as path from 'path';
4
4
  import { apply as createEngine, isValidWorkspaceMarker, resolveEngineOptions, rollbackTask } from './index.js';
5
5
  import { DEFAULT_SANDBOX_CONFIG, normalizeSandboxConfig, parseSandboxConsentAnswer } from './sandbox.js';
6
- const PLUGIN_VERSION = '1.1.0';
6
+ const PLUGIN_VERSION = '1.1.1';
7
7
  const WRITER_PRESET_ID = 'dacw-writer';
8
8
  const REVIEWER_PRESET_ID = 'dacw-reviewer';
9
9
  const WORKSPACE_MARKER = '.dacw-workspace';
@@ -1,6 +1,24 @@
1
1
  import * as fs from 'fs/promises';
2
2
  import * as path from 'path';
3
3
  import * as crypto from 'crypto';
4
+ function serializeChecksumBody(state) {
5
+ const { taskId, round, status, taskPrompt, writtenFiles, testResult, reviewResult, reviewExcluded, secretScanHits, rollbackPoint, rollback, lastError } = state;
6
+ return JSON.stringify({
7
+ taskId,
8
+ round,
9
+ status,
10
+ taskPrompt,
11
+ writtenFiles,
12
+ testResult,
13
+ reviewResult,
14
+ reviewExcluded: reviewExcluded ?? null,
15
+ secretScanHits: secretScanHits ?? null,
16
+ rollbackPoint: rollbackPoint ?? null,
17
+ rollback: rollback ?? null,
18
+ lastError
19
+ });
20
+ }
21
+ const DEFAULT_CHECKSUM_FN = (body)=>crypto.createHash('sha256').update(body).digest('hex');
4
22
  export class StateManager {
5
23
  stateDir;
6
24
  stateFilePath;
@@ -13,27 +31,15 @@ export class StateManager {
13
31
  const safeTaskId = rawTaskId.replace(/[^a-zA-Z0-9_\-]/g, '_');
14
32
  const idHash = crypto.createHash('sha256').update(String(rawTaskId) + '\n' + String(workspaceDir)).digest('hex').slice(0, 8);
15
33
  this.taskId = safeTaskId;
16
- this.checksumFn = checksumFn ?? ((body)=>crypto.createHash('sha256').update(body).digest('hex'));
34
+ this.checksumFn = checksumFn ?? DEFAULT_CHECKSUM_FN;
17
35
  this.stateDir = path.resolve(stateDir);
18
36
  this.stateFilePath = path.join(this.stateDir, `state_${safeTaskId}_${idHash}.json`);
19
37
  }
38
+ static computeChecksum(state) {
39
+ return DEFAULT_CHECKSUM_FN(serializeChecksumBody(state));
40
+ }
20
41
  checksumOf(state) {
21
- const { taskId, round, status, taskPrompt, writtenFiles, testResult, reviewResult, reviewExcluded, secretScanHits, rollbackPoint, rollback, lastError } = state;
22
- const body = JSON.stringify({
23
- taskId,
24
- round,
25
- status,
26
- taskPrompt,
27
- writtenFiles,
28
- testResult,
29
- reviewResult,
30
- reviewExcluded: reviewExcluded ?? null,
31
- secretScanHits: secretScanHits ?? null,
32
- rollbackPoint: rollbackPoint ?? null,
33
- rollback: rollback ?? null,
34
- lastError
35
- });
36
- return this.checksumFn(body);
42
+ return this.checksumFn(serializeChecksumBody(state));
37
43
  }
38
44
  async persist(state) {
39
45
  await fs.mkdir(this.stateDir, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stmcw1/dacw",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Defensive Agent Coding Workflow (DACW) as a DSH Host plugin: an AI writer proposes code, a deterministic runner tests it, a separate reviewer audits it, and a human gate decides the merge.",
5
5
  "keywords": [
6
6
  "dacw",