dsh-awesome-optimizer 1.7.0 → 1.8.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/README.md CHANGED
@@ -5,21 +5,22 @@ English | [中文](README.zh.md)
5
5
  [![npm version](https://img.shields.io/npm/v/dsh-awesome-optimizer.svg?color=blue)](https://www.npmjs.com/package/dsh-awesome-optimizer)
6
6
  [![license](https://img.shields.io/github/license/Jaylor-Wang/dsh-awesome-optimizer.svg)](LICENSE)
7
7
  [![GitHub release](https://img.shields.io/github/v/release/Jaylor-Wang/dsh-awesome-optimizer.svg)](https://github.com/Jaylor-Wang/dsh-awesome-optimizer/releases)
8
- [![Tests](https://img.shields.io/badge/tests-21%20passed-brightgreen.svg)](test/)
8
+ [![Tests](https://img.shields.io/badge/tests-31%20passed-brightgreen.svg)](test/)
9
9
  [![TypeScript](https://img.shields.io/badge/TypeScript-Strict%20Types-blue.svg)](src/)
10
10
 
11
11
  High-performance runtime policy guards, PTC-backed composite batch tooling, standalone refined system prompt engine, and objective A/B turn telemetry plugin for the official [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (`@deepseek-ai/dsh-agent-loop`).
12
12
 
13
13
  ---
14
14
 
15
- ## Highlights in v1.7.0
15
+ ## Highlights in v1.8.0
16
16
 
17
- - **Environment Facts Hardening & Weak Modal Elimination**: Upgraded injected environment facts to strict RFC 2119 directives (`NEVER require/import as node modules`, `NEVER run exploratory probing`), completely eliminating weak modals (`Avoid`) and preventing exploratory startup probing.
18
- - **Cross-Platform Python Environment Detection (`detectPythonEnv`)**: Safely detects active Python runtimes (`python` / `python3` and version) with one-shot memoization and timeout guards, unblocking cross-platform parity while steering models gracefully to Node.js when Python is absent.
19
- - **Playwright File Protocol Guard (`PLAYWRIGHT_FILE_PROTOCOL_BLOCKED`)**: Pre-execution interception of `playwright-cli open/goto file://...` commands, steering models toward local HTTP loopback servers to eliminate protocol errors and orphaned browser processes.
20
- - **Host Environment Facts Injection (`injectEnvironmentFacts`)**: Zero-overhead injection of active Node.js version, platform, CLI tool boundaries, and browser protocol facts into system prompts, eliminating speculative startup probe turns (`node -v`, `which`).
21
- - **CLI vs NPM Module Import Confusion Guard**: Added `cli-require-confusion` static lint rule in Prompt Linter to detect and prevent treating standalone CLIs (`playwright-cli`, `gh`, `ast-grep`) as requireable npm packages.
22
- - **Refined Batch Tooling Directives & Windows Arguments Streamlining**: Upgraded batch scheduling directives to `MUST`, eliminated cross-file grammatical ambiguities, and streamlined Windows arguments instructions by 52% with strict `NEVER raw shell arguments` enforcement.
17
+ - **Host Requirement Relaxation (`未声明宿主要求`)**: Removed `engines.dsh` constraint and migrated all `@deepseek-ai/*` peer dependencies to `devDependencies` (aligned with `dsh-tool-antigravity`), eliminating artificial version intersection tags (`DSH >=0.2.2-rc.1 ∩ *`) in DSH / Cordis plugin marketplace and enabling seamless installation across any DSH runtime.
18
+ - **Windows IPC Deadlock Elimination in Test Runner**: Reconfigured test script with `--test-concurrency=1 --test-timeout=10000`, switching `node:test` runner from parallel multi-worker fork races to deterministic linear single-channel execution, completely eliminating Windows stdio buffer lockups and EOF hang risks.
19
+ - **Heavy Task Chain Isolation Policy (`CHAINED_HEAVY_COMMAND`)**: Proactively intercepts heavy execution and publishing commands (`npm test`, `npm run build`, `vitest`, `npm publish`) in compound shell chains (`&&`, `;`) to prevent Windows console pipe deadlocks, while allowing seamless Git pipeline chaining (`git add ... && git commit ... && git push`).
20
+ - **Normative Ad-Hoc Script Disk Writing Enforcement**: Elevated ad-hoc script and IK/mathematical calculation guidelines to strict RFC 2119 `MUST` (`MUST write ad-hoc Node/Python scripts to disk via native write first`), eliminating friction with inline `python -c` or `node -e` shell payload overflow.
21
+ - **Playwright CLI Contract & Parameter Hardening**: Hardened selector target semantics (`screenshot takes selector target ONLY; auto-saved without output filename`), coupled with absolute bans on exploratory `--help` / `--version` probing.
22
+ - **Prompt Signal-to-Noise Refinement**: Pruned conflicting `produce deliverables directly` clauses, streamlined `Windows arguments & paths` to focus 100% on quoting/escaping, and eliminated redundant artifact cleanup instructions.
23
+ - **Ecosystem Description & Marketplace Alignment**: Harmonized GitHub About and documentation with official DSH marketplace card semantics, featuring standardized `SYSTEM.md replacement mode`.
23
24
 
24
25
  ---
25
26
 
@@ -36,7 +37,7 @@ High-performance runtime policy guards, PTC-backed composite batch tooling, stan
36
37
  - **Flexible Cascading Strategies**:
37
38
  Supports `concat` (cascading global and workspace prompts, default) and `workspace-override` (repo prompt completely replaces global prompt).
38
39
  - **Built-in Prompt Linter & Auto-Fixer**:
39
- Provides `lintPrompt` / `fixPrompt` / `lintPromptFile` APIs with **preset-aware dynamic tool validation**. Eliminates subjective tool assumptions by verifying tool directives directly against active plugins: flags redundant defensive clauses for unloaded tools or conflicts with actively loaded tools, checks weak modals (`bias toward` -> `Prioritize`), unclosed backticks, and enforces RFC 2119 uppercase constraints with actionable health scoring (0-100).
40
+ Provides `lintPrompt` / `fixPrompt` / `lintPromptFile` APIs with **preset-aware dynamic tool validation**. Eliminates subjective tool assumptions by verifying tool directives directly against active plugins: flags redundant defensive clauses for unloaded tools or conflicts with actively loaded tools, checks weak modals (e.g. upgrading soft wording to direct imperatives), unclosed backticks, and enforces RFC 2119 uppercase constraints with actionable health scoring (0-100).
40
41
 
41
42
  | Dimension | Official Default System Prompt | Optimized with This Plugin | Savings |
42
43
  | :--- | :--- | :--- | :--- |
@@ -59,8 +60,8 @@ High-performance runtime policy guards, PTC-backed composite batch tooling, stan
59
60
  Computes deterministic tool invocation fingerprints. If an identical failing tool call repeats up to `noProgressLimit` (default `2`), the plugin blocks execution at `tools/pre-execute`, forcing the agent to adapt its diagnostic approach.
60
61
  - **Windows Oversized Shell Command Interception (`EMBEDDED_SHELL_PAYLOAD_TOO_LARGE`)**:
61
62
  Automatically blocks commands exceeding `4096` bytes or inline scripts (`node -e`, `python -c`, `pwsh -Command`) exceeding `512` bytes, steering the model to write deliverables to disk first.
62
- - **Windows Chained Network Command Guard (`CHAINED_NETWORK_COMMAND`)**:
63
- Intercepts compound shell commands that chain network/credential-bound operations (`npm publish`) with local operations during `tools/pre-execute`. Enforces clean two-tier execution: local operations chained via `&&` for zero-RTT speed, and network operations isolated standalone to eliminate Windows process handle hanging and 120s timeouts.
63
+ - **Windows Chained Heavy Task Guard (`CHAINED_HEAVY_COMMAND`)**:
64
+ Intercepts compound shell commands that chain heavy concurrent or publishing tasks (`npm test`, `npm run build`, `vitest`, `npm publish`) with other operations during `tools/pre-execute`. Enforces clean two-tier execution: heavy tasks isolated standalone to prevent Windows process handle hanging and deadlocks, while lightweight Git workflows chain via `&&` for zero-RTT speed.
64
65
  - **Playwright File Protocol Guard (`PLAYWRIGHT_FILE_PROTOCOL_BLOCKED`)**:
65
66
  Pre-execution guard against `playwright-cli open/goto file://...` commands, steering models toward local HTTP loopback servers to prevent protocol errors and orphaned browser processes.
66
67
  - **Full Overwrite Protection & Single-Shot Recovery (`failureRecovery`)**:
@@ -146,17 +147,16 @@ You are a master autonomous software engineer powered by DeepSeek Harness.
146
147
  - Shell: ONLY `bash`. Launch `pwsh.exe` from `bash` when needed.
147
148
  - Web: Research/fetch STRICTLY via skills (`agent-reach`, `gh`, `opencli-*`, `smart-search`) or bash CLIs.
148
149
  - Tool boundaries: External tools (playwright-cli, gh, ast-grep) are standalone CLIs via bash, NEVER require/import as node modules.
149
- - Intermediate artifacts: Write ad-hoc Node/Python scripts to temporary files or clean them up; NEVER clutter the workspace with disposable test pages.
150
150
 
151
151
  ## Efficiency
152
152
 
153
153
  ### Hard Constraints
154
154
 
155
155
  - Retry ONLY when the error or new evidence supports a specific correction; after two failures without progress, switch diagnostic approaches.
156
- - Windows arguments & paths: use forward slashes in paths to prevent escape corruption. Pass complex/multiline payloads (`node -e`, `python -c`, `playwright-cli eval`, `gh`) via files or stdin, NEVER raw shell arguments; quote single-line patterns carefully (`ast-grep` patterns STRICTLY in single quotes `'...'` to prevent `$$` expansion). On quoting failures, switch input method rather than re-escaping.
156
+ - Windows arguments & paths: use forward slashes in paths to prevent escape corruption. NEVER embed multiline or complex scripts in shell arguments (`node -e`, `python -c`, `pwsh -Command`). Quote single-line patterns carefully (`ast-grep` patterns STRICTLY in single quotes `'...'` to prevent `$$` expansion). On quoting failures, switch input method rather than re-escaping.
157
157
  - Byte-fidelity: default new text files to UTF-8. Preserve existing file encodings, BOMs, line endings, `.gitattributes`, and hook policies unless explicitly requested.
158
158
  - Policy denials (`file access denied`, network blocked, approval disabled/rejected) are not command bugs: report; do not bypass. Request wider access via `sandbox_permissions` ONLY when escalation is explicitly available; otherwise do not retry or escalate. Diagnose ordinary lock, permission, or connectivity errors normally.
159
- - Tool exclusivity: STRICTLY native `glob`/`grep`/`read_batch`/`read`/`edit_batch`/`edit`/`write`. NEVER use shell commands or redirects for workspace search or file ops (`grep`, `rg`, `find`, `ls`, `dir`, `cat`, `type`, `head`, `tail`, `sed`, `awk`, `tee`, `>`/`>>`). Filtering piped command output (`cmd | grep`) is fine.
159
+ - Tool exclusivity: STRICTLY native `glob`/`grep`/`read_batch`/`read`/`edit_batch`/`edit`/`write`. NEVER use shell commands or redirects for workspace search or reading/writing files (`grep`, `rg`, `find`, `ls`, `dir`, `cat`, `type`, `head`, `tail`, `sed`, `awk`, `tee`, `>`/`>>`). Filtering piped command output (`cmd | grep`) and batch removing temporary artifacts (`rm -rf`) are permitted.
160
160
 
161
161
  ### Execution & Context Efficiency
162
162
 
@@ -165,15 +165,15 @@ You are a master autonomous software engineer powered by DeepSeek Harness.
165
165
  - Scheduling: MUST use `read_batch` for multi-file inspection (2+ files); keep single-file reads, retries, and dependent checks sequential.
166
166
  - Diagnosis: inspect contiguous context in one pass; cite locators and minimal raw excerpts only as evidence.
167
167
  - Search & navigation:
168
- - Scope & environment: verify via `git rev-parse --is-inside-work-tree` when workspace boundary is ambiguous (do not probe `.git`). Probe binary availability via `which`/`command -v` ONLY when execution fails; NEVER run speculative probing (`node -v`, `node -e`, `playwright-cli --version`) on startup—host facts are already hydrated.
168
+ - Scope & environment: verify via `git rev-parse --is-inside-work-tree` when workspace boundary is ambiguous (do not probe `.git`). Probe binary availability via `which`/`command -v` ONLY when execution fails.
169
169
  - Runtime context: `pwd`/runtime cwd defines the workspace; the DSH implementation checkout is ONLY for inspecting/extending DSH—NEVER infer cwd from it or edit it unless explicitly requested.
170
170
  - Code intelligence: prioritize `lsp` CLI (`lsp def`, `lsp ref`, `lsp hover`); outline via `lsp symbols <file>` or `ast-grep outline` before reading large files; `ast-grep` for structural queries (`-p`, `-k`; `ast-grep run` exit 1 means 0 matches, not error; `scan` exits 0 either way).
171
171
  - Files & text: native `glob`/`grep` (gitignore-aware by default; pass `gitignore: false` for ignored paths); broad matches → narrow `path`/glob or page via `skip`, NEVER truncate blindly. Use `git` via `bash` ONLY for git-specific facts (tracked status, history, diffs).
172
172
  - Modification & execution:
173
- - File ops: produce deliverables directly; MUST use `edit_batch` for 2+ edits (whether in one file or across multiple files); use `edit` for a single edit, and `write` for new files or ad-hoc Node/Python scripts.
173
+ - File ops: MUST use `edit_batch` for 2+ edits (whether in one file or across multiple files); use `edit` for a single edit, and `write` for new files or ad-hoc Node/Python scripts.
174
174
  - Staged refactor: preview, then apply — symbol renames via `lsp rename` (dry-run → `--apply`); structural rewrites via `ast-grep run -p ... -r ...` (then `-U`).
175
- - Structured data: process STRICTLY via ad-hoc Node/Python scripts passed via stdin or temp files; NEVER dump raw data into context.
176
- - Shell execution: prioritize chaining local non-blocking operations via `&&` (`git add ... && git commit ... && npm test`) to eliminate round-trip latency; keep network- or credential-bound commands (`npm publish`, remote fetch) separate to prevent Windows process handle hanging and timeouts.
175
+ - Structured data & calculations: MUST write ad-hoc Node/Python scripts to disk first via native `write` and execute by file path; NEVER embed calculations or processing in `python -c` or `node -e`.
176
+ - Shell execution: run heavy tasks (`npm test`, `npm run build`, `vitest`, `npm publish`) standalone to prevent Windows deadlocks; chain lightweight commands via `&&` (`git add ... && git commit ... && git push`) to eliminate round trips.
177
177
  - Reporting: diffs and evidence first; zero filler. Routine status ≤ 300 Chinese characters. Answer/explain/review/diagnose/plan: no length cap. Compact locators, lists, and deltas only.
178
178
 
179
179
  ## Verification
@@ -186,7 +186,7 @@ Applies ONLY to change/build/fix.
186
186
  - Behavior changes: check static diagnostics via primary tools (e.g. `lsp diag <file|dir> -e`, skip if language unsupported; no redundant CLI linters), then run the smallest non-destructive targeted build/test covering affected behavior and internal interfaces.
187
187
  - Shared API, schema, or migration changes: run the full related suite plus project-wide type checking where applicable (e.g. `tsc --noEmit`).
188
188
  - Report checks, results, and verification gaps; if primary diagnostics are unavailable, use an existing equivalent check when possible.
189
- - Browser checks: STRICTLY `playwright-cli` post-write. Playwright CLI blocks 'file:' URLs—serve static HTML via loopback HTTP (http://127.0.0.1:<port>). NEVER pre-probe (`node -v`, `playwright-cli --version`), create dummy pages, or switch tools. Reuse runtime Web GUI or active app URL (loopback for static); stabilize animations before capture. Batch-cleanup sessions/servers/artifacts without redundant listings. On failure, report root cause.
189
+ - Browser checks: STRICTLY `playwright-cli` post-write. Playwright CLI blocks 'file:' URLs—serve static HTML via loopback HTTP (http://127.0.0.1:<port>). 'screenshot' takes selector target ONLY (no output filename; auto-saved to .playwright-cli/). NEVER pre-probe ('--help', '--version', 'node -v'), create dummy pages, or switch tools. Reuse runtime Web GUI or active app URL (loopback for static); stabilize animations before capture. Batch-cleanup sessions/servers/artifacts without redundant listings. On failure, report root cause.
190
190
  - Persistent failure: report failed command(s), 1–2 sentence root cause, blast radius, next steps.
191
191
  ```
192
192
  </details>
package/README.zh.md CHANGED
@@ -5,21 +5,22 @@
5
5
  [![npm version](https://img.shields.io/npm/v/dsh-awesome-optimizer.svg?color=blue)](https://www.npmjs.com/package/dsh-awesome-optimizer)
6
6
  [![license](https://img.shields.io/github/license/Jaylor-Wang/dsh-awesome-optimizer.svg)](LICENSE)
7
7
  [![GitHub release](https://img.shields.io/github/v/release/Jaylor-Wang/dsh-awesome-optimizer.svg)](https://github.com/Jaylor-Wang/dsh-awesome-optimizer/releases)
8
- [![Tests](https://img.shields.io/badge/tests-21%20passed-brightgreen.svg)](test/)
8
+ [![Tests](https://img.shields.io/badge/tests-31%20passed-brightgreen.svg)](test/)
9
9
  [![TypeScript](https://img.shields.io/badge/TypeScript-Strict%20Types-blue.svg)](src/)
10
10
 
11
11
  围绕官方 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (`@deepseek-ai/dsh-agent-loop`) 打造的高性能运行时策略防护、PTC 复合批处理工具、全新独立系统提示词接管与客观 A/B 轮次度量插件。
12
12
 
13
13
  ---
14
14
 
15
- ## v1.7.0 版本重要更新
15
+ ## v1.8.0 版本重要更新
16
16
 
17
- - **宿主环境事实注水全面加固与弱语气词拔除**:环境事实注水段落全面升级为 RFC 2119 绝对强约束,将模块与脚本边界严格收敛为 `NEVER require/import as node modules`,彻底封死 CommonJS 与 ESM 两种导入路径;将开局探测禁令拔除 `Avoid` 弱语气词并收敛为铁律 `NEVER run exploratory probing (pwd, ls, node -v, which)`。
18
- - **Python 跨平台环境智能识别与单例缓存 (`detectPythonEnv`)**:在环境事实注水时自动探测当前系统 Python 可用性(`python` / `python3` 及版本号),抹平跨平台命令分歧;采用单例懒加载缓存与超时守卫,零首字延迟开销;未装配时自动引导模型纯粹使用 Node.js,杜绝盲目生成 `.py` 脚本导致的执行失败。
19
- - **Playwright `file:` 协议前置硬拦截 (`PLAYWRIGHT_FILE_PROTOCOL_BLOCKED`)**:在 `tools/pre-execute` 阶段主动检测并拦截 `playwright-cli open/goto file://...`,杜绝协议阻断异常与浏览器僵尸子进程,引导模型无缝切换至本地 HTTP 环回服务。
20
- - **轻量宿主环境事实注水 (`injectEnvironmentFacts`)**:系统提示词组装阶段自动注入 Node.js 版本、系统架构、独立 CLI 工具边界与 Playwright 协议指引,彻底消除模型开局盲目执行探针命令。
21
- - **CLI 独立工具与 NPM 模块边界防混淆**:在 Prompt Linter 中新增 `cli-require-confusion` 静态规则,静态拦截将外部 CLI 工具当成 Node 模块导入的认知混淆错误。
22
- - **复合批处理工具语义精准化与规范收敛**:`read_batch` 与 `edit_batch` 全面加固为 `MUST` 硬约束,精准规范单/多文件介词与数量阈值;精炼 Windows 参数与路径指令,去除冗余科普并强化 `NEVER raw shell arguments` 边界。
17
+ - **解除宿主要求限制(显示为「未声明宿主要求」)**:完全对齐 `dsh-tool-antigravity` 规范,移除了 `package.json` 中的 `engines.dsh` 并将所有 `@deepseek-ai/*` 宿主依赖收拢至开发时依赖(`devDependencies`),彻底消除了插件市场中计算生成的 `DSH >=0.2.2-rc.1 ∩ *` 约束标签,展示为纯净的「未声明宿主要求」,允许在任意 DSH 运行时环境下无阻碍安装与更新。
18
+ - **测试运行器 Windows 管道死锁根治**:将测试脚本重构为 `node --test --test-concurrency=1 --test-timeout=10000`,由多 Worker 并发争用改为确定性单通道顺序执行,彻底消除 Windows 控制台 stdio 管道缓冲区互锁与未回收 EOF 挂起隐患。
19
+ - **重型任务复合命令链隔离拦截 (`CHAINED_HEAVY_COMMAND`)**:在 `tools/pre-execute` 阶段主动检测并拦截复合链(`&&`、`;`)中的重型构建、测试与发布命令(`npm test`、`npm run build`、`vitest`、`npm publish`),彻底杜绝 Windows 控制台管道死锁;同时放行纯净的 Git 流水线串联(`git add ... && git commit ... && git push`)。
20
+ - **临时脚本落地磁盘硬约束升维 (`MUST`)**:将数学建模、复杂计算与辅助脚本的磁盘落地要求全面升级为最高级 RFC 2119 规范 `MUST write ad-hoc Node/Python scripts to disk`,并与 `NEVER embed multiline scripts` 形成工整对仗。
21
+ - **Playwright CLI 选择器语义与探测硬约束加固**:明确 `screenshot` 仅接收 CSS 选择器且自动落盘(无输出文件名参数),配合 `--help` / `--version` 探针硬性禁令,消除多余回合损耗与选择器报错。
22
+ - **提示词信噪比深度净化与冲突消除**:移除与辅助脚本产生认知对抗的 `produce deliverables directly` 语句;净化 `Windows arguments & paths` 使其 100% 聚焦于引号与转义防坑;去重冗余的 `rm -rf` 清理描述。
23
+ - **生态与插件市场表述全量对齐**:全面对齐 DSH 官方插件市场卡片规范,采用标准工业级特性命名 `SYSTEM.md replacement mode`,去除生僻术语。
23
24
 
24
25
  ---
25
26
 
@@ -36,7 +37,7 @@
36
37
  - **级联策略灵活可选**:
37
38
  支持 `concat`(全局与工作区级联合并,默认)与 `workspace-override`(项目级完全覆盖全局)。
38
39
  - **内置 Prompt Linter 健康度校验与一键修复**:
39
- 提供 `lintPrompt` / `fixPrompt` / `lintPromptFile` API。**基于用户当前预设加载的插件工具做动态客观判定**,杜绝主观臆断:当工具未在预设加载时提示冗余防守,当工具已加载却声明禁用时提示配置冲突,并校验弱语气词(如 `bias toward` 自动升级为 `Prioritize`)、RFC 2119 强约束大写规范及未闭合反引号,输出健康度打分(0-100)并支持一键无损修复。
40
+ 提供 `lintPrompt` / `fixPrompt` / `lintPromptFile` API。**基于用户当前预设加载的插件工具做动态客观判定**,杜绝主观臆断:当工具未在预设加载时提示冗余防守,当工具已加载却声明禁用时提示配置冲突,并校验弱语气词(如软性建议词自动升级为标准动词)、RFC 2119 强约束大写规范及未闭合反引号,输出健康度打分(0-100)并支持一键无损修复。
40
41
 
41
42
  | 指标维度 | 官方默认 System Prompt | 开启本插件优化后 | 收益 |
42
43
  | :--- | :--- | :--- | :--- |
@@ -59,8 +60,8 @@
59
60
  基于输入参数指纹计算,当同一工具以相同参数连续失败达到 `noProgressLimit`(默认 `2` 次)时,在 `tools/pre-execute` 阶段立即硬拦截并强迫模型转换诊断思路,杜绝死循环。
60
61
  - **Windows 超大 Shell 载荷拦截 (`EMBEDDED_SHELL_PAYLOAD_TOO_LARGE`)**:
61
62
  自动拦截超过 `4096` 字节的 `bash` 命令,或超过 `512` 字节的内联脚本参数(`node -e`、`python -c`、`pwsh -Command` 等),引导模型先通过原生 `write` 落盘再执行,规避 Windows 命令行参数溢出崩溃。
62
- - **Windows 复合网络命令挂起防御 (`CHAINED_NETWORK_COMMAND`)**:
63
- 在 `tools/pre-execute` 阶段自动拦截将网络/凭据操作(`npm publish` 等)与本地耗时操作混合串联的复合命令,强行引导模型执行两分法:本地确定性操作(`git add ... && git commit ... && npm test`)复合提速,网络发布独立把关,彻底规避 Windows 子进程句柄悬挂与 120s 超时。
63
+ - **Windows 重型任务串联死锁防御 (`CHAINED_HEAVY_COMMAND`)**:
64
+ 在 `tools/pre-execute` 阶段自动拦截将重型并发或发布操作(`npm test`, `npm run build`, `vitest`, `npm publish`)与其他命令串联的复合语句,强行引导单列执行重型任务以防 Windows 死锁,同时彻底放行轻量确定性操作(`git add ... && git commit ... && git push`)链式执行,最大化节省交互轮次。
64
65
  - **Playwright 文件协议前置拦截 (`PLAYWRIGHT_FILE_PROTOCOL_BLOCKED`)**:
65
66
  在 `tools/pre-execute` 阶段主动检测并拦截 `playwright-cli open/goto file://...` 调用,立即引导模型使用本地 HTTP 环回服务访问,防止浏览器僵尸子进程残留与协议阻断异常。
66
67
  - **大文件覆写防御与快速重放恢复 (`failureRecovery`)**:
@@ -146,17 +147,16 @@ You are a master autonomous software engineer powered by DeepSeek Harness.
146
147
  - Shell: ONLY `bash`. Launch `pwsh.exe` from `bash` when needed.
147
148
  - Web: Research/fetch STRICTLY via skills (`agent-reach`, `gh`, `opencli-*`, `smart-search`) or bash CLIs.
148
149
  - Tool boundaries: External tools (playwright-cli, gh, ast-grep) are standalone CLIs via bash, NEVER require/import as node modules.
149
- - Intermediate artifacts: Write ad-hoc Node/Python scripts to temporary files or clean them up; NEVER clutter the workspace with disposable test pages.
150
150
 
151
151
  ## Efficiency
152
152
 
153
153
  ### Hard Constraints
154
154
 
155
155
  - Retry ONLY when the error or new evidence supports a specific correction; after two failures without progress, switch diagnostic approaches.
156
- - Windows arguments & paths: use forward slashes in paths to prevent escape corruption. Pass complex/multiline payloads (`node -e`, `python -c`, `playwright-cli eval`, `gh`) via files or stdin, NEVER raw shell arguments; quote single-line patterns carefully (`ast-grep` patterns STRICTLY in single quotes `'...'` to prevent `$$` expansion). On quoting failures, switch input method rather than re-escaping.
156
+ - Windows arguments & paths: use forward slashes in paths to prevent escape corruption. NEVER embed multiline or complex scripts in shell arguments (`node -e`, `python -c`, `pwsh -Command`). Quote single-line patterns carefully (`ast-grep` patterns STRICTLY in single quotes `'...'` to prevent `$$` expansion). On quoting failures, switch input method rather than re-escaping.
157
157
  - Byte-fidelity: default new text files to UTF-8. Preserve existing file encodings, BOMs, line endings, `.gitattributes`, and hook policies unless explicitly requested.
158
158
  - Policy denials (`file access denied`, network blocked, approval disabled/rejected) are not command bugs: report; do not bypass. Request wider access via `sandbox_permissions` ONLY when escalation is explicitly available; otherwise do not retry or escalate. Diagnose ordinary lock, permission, or connectivity errors normally.
159
- - Tool exclusivity: STRICTLY native `glob`/`grep`/`read_batch`/`read`/`edit_batch`/`edit`/`write`. NEVER use shell commands or redirects for workspace search or file ops (`grep`, `rg`, `find`, `ls`, `dir`, `cat`, `type`, `head`, `tail`, `sed`, `awk`, `tee`, `>`/`>>`). Filtering piped command output (`cmd | grep`) is fine.
159
+ - Tool exclusivity: STRICTLY native `glob`/`grep`/`read_batch`/`read`/`edit_batch`/`edit`/`write`. NEVER use shell commands or redirects for workspace search or reading/writing files (`grep`, `rg`, `find`, `ls`, `dir`, `cat`, `type`, `head`, `tail`, `sed`, `awk`, `tee`, `>`/`>>`). Filtering piped command output (`cmd | grep`) and batch removing temporary artifacts (`rm -rf`) are permitted.
160
160
 
161
161
  ### Execution & Context Efficiency
162
162
 
@@ -165,15 +165,15 @@ You are a master autonomous software engineer powered by DeepSeek Harness.
165
165
  - Scheduling: MUST use `read_batch` for multi-file inspection (2+ files); keep single-file reads, retries, and dependent checks sequential.
166
166
  - Diagnosis: inspect contiguous context in one pass; cite locators and minimal raw excerpts only as evidence.
167
167
  - Search & navigation:
168
- - Scope & environment: verify via `git rev-parse --is-inside-work-tree` when workspace boundary is ambiguous (do not probe `.git`). Probe binary availability via `which`/`command -v` ONLY when execution fails; NEVER run speculative probing (`node -v`, `node -e`, `playwright-cli --version`) on startup—host facts are already hydrated.
168
+ - Scope & environment: verify via `git rev-parse --is-inside-work-tree` when workspace boundary is ambiguous (do not probe `.git`). Probe binary availability via `which`/`command -v` ONLY when execution fails.
169
169
  - Runtime context: `pwd`/runtime cwd defines the workspace; the DSH implementation checkout is ONLY for inspecting/extending DSH—NEVER infer cwd from it or edit it unless explicitly requested.
170
170
  - Code intelligence: prioritize `lsp` CLI (`lsp def`, `lsp ref`, `lsp hover`); outline via `lsp symbols <file>` or `ast-grep outline` before reading large files; `ast-grep` for structural queries (`-p`, `-k`; `ast-grep run` exit 1 means 0 matches, not error; `scan` exits 0 either way).
171
171
  - Files & text: native `glob`/`grep` (gitignore-aware by default; pass `gitignore: false` for ignored paths); broad matches → narrow `path`/glob or page via `skip`, NEVER truncate blindly. Use `git` via `bash` ONLY for git-specific facts (tracked status, history, diffs).
172
172
  - Modification & execution:
173
- - File ops: produce deliverables directly; MUST use `edit_batch` for 2+ edits (whether in one file or across multiple files); use `edit` for a single edit, and `write` for new files or ad-hoc Node/Python scripts.
173
+ - File ops: MUST use `edit_batch` for 2+ edits (whether in one file or across multiple files); use `edit` for a single edit, and `write` for new files or ad-hoc Node/Python scripts.
174
174
  - Staged refactor: preview, then apply — symbol renames via `lsp rename` (dry-run → `--apply`); structural rewrites via `ast-grep run -p ... -r ...` (then `-U`).
175
- - Structured data: process STRICTLY via ad-hoc Node/Python scripts passed via stdin or temp files; NEVER dump raw data into context.
176
- - Shell execution: prioritize chaining local non-blocking operations via `&&` (`git add ... && git commit ... && npm test`) to eliminate round-trip latency; keep network- or credential-bound commands (`npm publish`, remote fetch) separate to prevent Windows process handle hanging and timeouts.
175
+ - Structured data & calculations: MUST write ad-hoc Node/Python scripts to disk first via native `write` and execute by file path; NEVER embed calculations or processing in `python -c` or `node -e`.
176
+ - Shell execution: run heavy tasks (`npm test`, `npm run build`, `vitest`, `npm publish`) standalone to prevent Windows deadlocks; chain lightweight commands via `&&` (`git add ... && git commit ... && git push`) to eliminate round trips.
177
177
  - Reporting: diffs and evidence first; zero filler. Routine status ≤ 300 Chinese characters. Answer/explain/review/diagnose/plan: no length cap. Compact locators, lists, and deltas only.
178
178
 
179
179
  ## Verification
@@ -186,7 +186,7 @@ Applies ONLY to change/build/fix.
186
186
  - Behavior changes: check static diagnostics via primary tools (e.g. `lsp diag <file|dir> -e`, skip if language unsupported; no redundant CLI linters), then run the smallest non-destructive targeted build/test covering affected behavior and internal interfaces.
187
187
  - Shared API, schema, or migration changes: run the full related suite plus project-wide type checking where applicable (e.g. `tsc --noEmit`).
188
188
  - Report checks, results, and verification gaps; if primary diagnostics are unavailable, use an existing equivalent check when possible.
189
- - Browser checks: STRICTLY `playwright-cli` post-write. Playwright CLI blocks 'file:' URLs—serve static HTML via loopback HTTP (http://127.0.0.1:<port>). NEVER pre-probe (`node -v`, `playwright-cli --version`), create dummy pages, or switch tools. Reuse runtime Web GUI or active app URL (loopback for static); stabilize animations before capture. Batch-cleanup sessions/servers/artifacts without redundant listings. On failure, report root cause.
189
+ - Browser checks: STRICTLY `playwright-cli` post-write. Playwright CLI blocks 'file:' URLs—serve static HTML via loopback HTTP (http://127.0.0.1:<port>). 'screenshot' takes selector target ONLY (no output filename; auto-saved to .playwright-cli/). NEVER pre-probe ('--help', '--version', 'node -v'), create dummy pages, or switch tools. Reuse runtime Web GUI or active app URL (loopback for static); stabilize animations before capture. Batch-cleanup sessions/servers/artifacts without redundant listings. On failure, report root cause.
190
190
  - Persistent failure: report failed command(s), 1–2 sentence root cause, blast radius, next steps.
191
191
  ```
192
192
  </details>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-awesome-optimizer",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Runtime policy guards, composite batch tooling, soft convergence guidance, reactive custom prompt engine, and A/B telemetry plugin for the official DeepSeek Harness (dsh) agent loop.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -57,12 +57,11 @@
57
57
  }
58
58
  },
59
59
  "engines": {
60
- "node": ">=22.0.0",
61
- "dsh": ">=0.2.2-rc.1"
60
+ "node": ">=22.0.0"
62
61
  },
63
62
  "scripts": {
64
63
  "setup:local": "node scripts/setup-local.mjs",
65
- "test": "node --test --test-timeout=15000 test/*.test.js",
64
+ "test": "node --test --test-concurrency=1 --test-timeout=10000 test/*.test.js",
66
65
  "typecheck": "node scripts/typecheck.mjs",
67
66
  "benchmark": "node scripts/benchmark.mjs"
68
67
  },
@@ -87,7 +86,7 @@
87
86
  "telemetry",
88
87
  "composite-tools"
89
88
  ],
90
- "peerDependencies": {
89
+ "devDependencies": {
91
90
  "@deepseek-ai/cordis": ">=4.0.0",
92
91
  "@deepseek-ai/dsh-agent": "*",
93
92
  "@deepseek-ai/dsh-agent-loop": "*",
@@ -96,19 +95,5 @@
96
95
  "@deepseek-ai/dsh-system-prompt": "*",
97
96
  "@deepseek-ai/dsh-tools": "*",
98
97
  "@deepseek-ai/schemastery": ">=3.0.0"
99
- },
100
- "peerDependenciesMeta": {
101
- "@deepseek-ai/dsh-agent": {
102
- "optional": true
103
- },
104
- "@deepseek-ai/dsh-agent-loop": {
105
- "optional": true
106
- },
107
- "@deepseek-ai/dsh-session": {
108
- "optional": true
109
- },
110
- "@deepseek-ai/schemastery": {
111
- "optional": true
112
- }
113
98
  }
114
99
  }
@@ -8,8 +8,8 @@ export const SOURCE = 'optimizer-convergence';
8
8
  export const GUIDANCE = [
9
9
  "Work toward the user's completion criteria with as few model round trips as practical.",
10
10
  'Batch independent reads, searches, and checks in a single response when their inputs are known (or use read_batch for multi-file reads); preserve dependencies and exclusive tool barriers.',
11
- 'Command chaining: Prioritize chaining local non-blocking operations via && (git add ... && git commit ... && npm test) to eliminate round-trip latency. Keep network- or credential-bound commands (npm publish, remote fetch) separate to prevent Windows process handle hanging and timeouts.',
12
- 'Before emitting a large payload, produce deliverables or reusable scripts to disk using native write and execute by file path. NEVER embed complete files or large scripts in shell arguments (node -e, python -c, pwsh -Command).',
11
+ 'Command chaining: Run heavy tasks (npm test, npm run build, vitest, npm publish) standalone to prevent Windows deadlocks; chain lightweight commands via && (git add ... && git commit ... && git push) to eliminate round trips.',
12
+ 'Before emitting a large payload or calculation, produce deliverables or reusable scripts to disk using native write and execute by file path. NEVER embed complete files, calculations, or large scripts in shell arguments (node -e, python -c, pwsh -Command).',
13
13
  'For localized revisions on existing files, reuse context already in the conversation and prefer native edit (or edit_batch for multi-file/multi-location revisions) with an unambiguous match over rewriting the entire file.',
14
14
  'After receiving tool results, make the next complete useful decision without repeating equivalent searches or checks unless new evidence justifies them.',
15
15
  'This efficiency guidance NEVER overrides the user, correctness, permission checks, required verification, or cancellation.'
@@ -64,8 +64,9 @@ export function formatEnvironmentFacts(processRef = process, pythonDetector = de
64
64
  '## Host Environment & Tooling Facts',
65
65
  `- Runtime: Node.js ${version}${pyInfo} on ${platform} (${arch}).`,
66
66
  '- Standalone CLIs: playwright-cli, gh, ast-grep, and opencli are standalone binaries via bash; NEVER require/import as node modules.',
67
- '- Browser automation: playwright-cli blocks "file:" URLs; serve static HTML via loopback HTTP (http://127.0.0.1:<port>).',
68
- '- Zero startup probing: workspace context and host facts are already hydrated. NEVER run exploratory probing (pwd, ls, node -v, which).'
67
+ '- Browser automation: playwright-cli blocks "file:" URLs (serve via loopback HTTP); \'screenshot\' takes selector target ONLY (no output filename; auto-saved to .playwright-cli/). NEVER probe via \'--help\' or \'--version\'.',
68
+ '- Zero startup probing: workspace context and host facts are already hydrated. NEVER run exploratory probing (pwd, ls, node -v, which).',
69
+ '- Ad-hoc scripts & cleanup: MUST write ad-hoc Node/Python scripts to disk via native write first and execute by file path; remove temporary artifacts directly via bash (rm -rf).'
69
70
  ].join('\n');
70
71
  }
71
72
 
@@ -371,23 +371,27 @@ export class RuntimePolicyManager {
371
371
  };
372
372
  }
373
373
 
374
- // Guard against dangerous network/credential command chaining on Windows
374
+ // Guard against dangerous heavy concurrent or publishing command chaining on Windows
375
375
  if (this.config.disallowChainedNetworkCommands) {
376
376
  const hasCompoundOperator = /(&&|;)/.test(cmd);
377
- const hasChainedNetworkAction = /(?:^|[\s;&|])(?:npm\s+publish|gh\s+(?:pr|issue)\s+create)\b/i.test(cmd);
378
- if (hasCompoundOperator && hasChainedNetworkAction) {
379
- state.shellPayloadBlocks++;
380
- state.policyDenials++;
381
- if (exec.token !== undefined) state.deniedTokens.add(exec.token);
382
- return {
383
- kind: 'deny',
384
- reason: JSON.stringify({
385
- code: 'CHAINED_NETWORK_COMMAND',
386
- reason: "Chaining network/credential-bound commands ('npm publish') with other commands causes Windows process handle hanging and 120s timeouts.",
387
- nextAction: "Separate into independent steps: execute local operations first, then run network command ('npm publish') standalone.",
388
- retryable: false
389
- })
390
- };
377
+ if (hasCompoundOperator) {
378
+ // Strip quoted string literals to prevent false positives in commit messages / echo args
379
+ const unquoted = cmd.replace(/"[^"\\]*(?:\\.[^"\\]*)*"/g, '""').replace(/'[^'\\]*(?:\\.[^'\\]*)*'/g, "''");
380
+ const hasBlockedCompoundAction = /(?:^|[\s;&|])(?:npm\s+(?:test|t|run\s+build|publish)|vitest)\b/i.test(unquoted);
381
+ if (hasBlockedCompoundAction) {
382
+ state.shellPayloadBlocks++;
383
+ state.policyDenials++;
384
+ if (exec.token !== undefined) state.deniedTokens.add(exec.token);
385
+ return {
386
+ kind: 'deny',
387
+ reason: JSON.stringify({
388
+ code: 'CHAINED_HEAVY_COMMAND',
389
+ reason: "Heavy tasks ('npm test', 'npm run build', 'vitest', 'npm publish') must run standalone to prevent Windows deadlocks.",
390
+ nextAction: "Execute heavy tasks standalone, then chain lightweight commands via '&&'.",
391
+ retryable: false
392
+ })
393
+ };
394
+ }
391
395
  }
392
396
  }
393
397
  }