@dsmm/dsmm 0.3.19 → 0.3.21

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.
Files changed (47) hide show
  1. package/README.md +4 -4
  2. package/agent-presets/dsmm-clarifier/agent.cordis.yml +2 -2
  3. package/agent-presets/dsmm-oracle/agent.cordis.yml +2 -2
  4. package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +2 -2
  5. package/agent-presets/dsmm-orchestrator/agent.cordis.yml +3 -3
  6. package/agent-presets/dsmm-plan-critic/agent.cordis.yml +2 -2
  7. package/agent-presets/dsmm-planner/agent.cordis.yml +2 -2
  8. package/agent-presets/dsmm-reviewer/agent.cordis.yml +2 -2
  9. package/docs/maintenance.md +26 -0
  10. package/docs/native-permissions.md +11 -1
  11. package/docs/safety-guards.md +6 -0
  12. package/lib/core-permissions.d.ts +2 -2
  13. package/lib/core-permissions.js +2 -2
  14. package/lib/guards.d.ts +3 -0
  15. package/lib/guards.js +8 -0
  16. package/lib/index.js +2 -2
  17. package/lib/permission-controller.d.ts +4 -1
  18. package/lib/permission-controller.js +78 -12
  19. package/lib/permission-linear-script.d.ts +10 -0
  20. package/lib/permission-linear-script.js +91 -0
  21. package/lib/permission-native-command.d.ts +1 -0
  22. package/lib/permission-native-command.js +5 -0
  23. package/lib/permission-native-rules.d.ts +13 -1
  24. package/lib/permission-native-rules.js +109 -96
  25. package/package.json +1 -1
  26. package/prompts/deepwork.md +4 -4
  27. package/prompts/source/agents/clarifier.md +2 -2
  28. package/prompts/source/agents/orchestrator.md +3 -3
  29. package/prompts/source/agents/plan-critic.md +2 -2
  30. package/prompts/source/agents/planner.md +2 -2
  31. package/prompts/source/agents/reviewer.md +2 -2
  32. package/prompts/source/deepwork/default.md +4 -4
  33. package/prompts/source/deepwork/planner.md +3 -3
  34. package/skills/brainstorming/LICENSE +21 -0
  35. package/skills/brainstorming/SKILL.md +8 -21
  36. package/skills/brainstorming/references/artifacts-and-evidence.md +21 -0
  37. package/skills/requesting-code-review/LICENSE +21 -0
  38. package/skills/requesting-code-review/SKILL.md +5 -2
  39. package/skills/requesting-code-review/code-reviewer.md +9 -1
  40. package/skills/subagent-driven-development/LICENSE +21 -0
  41. package/skills/subagent-driven-development/SKILL.md +7 -63
  42. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +2 -2
  43. package/skills/subagent-driven-development/references/worker-return-and-review.md +72 -0
  44. package/skills/subagent-driven-development/spec-reviewer-prompt.md +5 -2
  45. package/skills/writing-plans/LICENSE +21 -0
  46. package/skills/writing-plans/SKILL.md +9 -6
  47. package/skills/writing-plans/plan-document-reviewer-prompt.md +10 -4
package/README.md CHANGED
@@ -4,12 +4,12 @@ DSMM 是 DeepSeek Harness(DSH)的插件。它让不同 Agent 分工处理任
4
4
 
5
5
  比如,让 Planner 拆解任务、Coding 写代码、Reviewer 检查结果,再由 Orchestrator 协调。各个角色可以用不同的模型,不必共用一套配置。
6
6
 
7
- 当前发布版本为 `@dsmm/dsmm@0.3.19`,支持 DSH `>=0.2.1-rc.2 <0.3.0`。安装前请确认客户端版本;范围外的 DSH 版本不受支持。Desktop 使用自带运行时,独立命令行环境需要 Node.js 22 或更高版本。
7
+ 当前发布版本为 `@dsmm/dsmm@0.3.21`,支持 DSH `>=0.2.1-rc.2 <0.3.0`。安装前请确认客户端版本;范围外的 DSH 版本不受支持。Desktop 使用自带运行时,独立命令行环境需要 Node.js 22 或更高版本。
8
8
 
9
9
  官方 DSH rc.3 以 `engines.dsh` 优先于 peer ranges 判定兼容性;DSH 依赖仍固定为 rc.2,作为开发基线。
10
10
 
11
11
  - 源码仓库:[hugefiver/dsmm](https://github.com/hugefiver/dsmm)
12
- - 安装来源:[npm (@dsmm/dsmm)](https://www.npmjs.com/package/@dsmm/dsmm);发布资产:[GitHub Releases (v0.3.19)](https://github.com/hugefiver/dsmm/releases/tag/v0.3.19)
12
+ - 安装来源:[npm (@dsmm/dsmm)](https://www.npmjs.com/package/@dsmm/dsmm);发布资产:[GitHub Releases (v0.3.21)](https://github.com/hugefiver/dsmm/releases/tag/v0.3.21)
13
13
 
14
14
  ---
15
15
 
@@ -20,7 +20,7 @@ DSMM 是 DeepSeek Harness(DSH)的插件。它让不同 Agent 分工处理任
20
20
  ### 初次安装
21
21
 
22
22
  1. 打开 DeepSeek Harness Desktop,进入 **插件(Plugins)** 页面。
23
- 2. 点击 **添加插件(Add plugin)**,输入 `@dsmm/dsmm@0.3.19` 并确认。
23
+ 2. 点击 **添加插件(Add plugin)**,输入 `@dsmm/dsmm@0.3.21` 并确认。
24
24
  3. 安装完成后,检查插件是否处于启用状态。如果界面提示需要重启,请按提示重启客户端。
25
25
 
26
26
  Desktop 的插件由客户端自己管理。全局 npm 安装和独立 npm 版 `dsh` 命令不能替代这一步。
@@ -32,7 +32,7 @@ DSH Desktop 当前不支持在界面中用同名版本原位覆盖更新插件
32
32
  1. 保存好正在进行的任务,**正常退出并完全关闭 DSH Desktop**。
33
33
  2. 使用 Desktop 安装自带的命令行工具更新配置。以下示例适用于 Windows 默认安装路径(`%LOCALAPPDATA%\Programs\DeepSeek Harness\`):
34
34
  ```powershell
35
- & "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add @dsmm/dsmm@0.3.19 --save-exact --ignore-scripts --registry=https://registry.npmjs.org
35
+ & "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add @dsmm/dsmm@0.3.21 --save-exact --ignore-scripts --registry=https://registry.npmjs.org
36
36
  ```
37
37
  *若安装在自定义路径,请替换为对应的实际位置;非 Windows 系统请参考 Desktop 自身菜单或官方指引,不要混用非 Desktop 的独立 CLI 命令。*
38
38
  3. 重新打开 DSH Desktop 即可加载新版本。
@@ -33,9 +33,9 @@
33
33
  | Research | State the decision, exit criteria, bounded probes, and synthesis. |
34
34
  | Bug fix | Require reproduction or a failing test when feasible; direct root-cause evidence, minimal fix, regression checks, and real-surface proof. |
35
35
 
36
- Ask only the smallest useful set of questions for material ambiguity that changes the deliverable; do not impose a fixed question quota. Never recommend Reviewer or Oracle profiles for pre-implementation architecture or debugging; strict or high-risk conditions alone do not qualify for `hard-reasoning`.
36
+ Ask only the smallest useful set of questions for material ambiguity that changes the deliverable; explain what each answer would change or why the unresolved point matters, and do not impose a fixed question quota. Never recommend Reviewer or Oracle profiles for pre-implementation architecture or debugging; strict or high-risk conditions alone do not qualify for `hard-reasoning`.
37
37
 
38
- Use direct read-only discovery to resolve ambiguity. A leaf read-only lookup may establish a named fact; never dispatch planner, reviewer, any Oracle profile, plan-critic, clarifier, coordinator, or an implementation agent, and never delegate classification or the final questions.
38
+ Before asking, read the context the user supplied or named and the directly related project material until the current behavior and affected area are clear enough to avoid questions already answered by specs, plans, handoffs, files, or prior conversation. Use direct read-only discovery to resolve ambiguity. A leaf read-only lookup may establish a named fact; never dispatch planner, reviewer, any Oracle profile, plan-critic, clarifier, coordinator, or an implementation agent, and never delegate classification or the final questions.
39
39
 
40
40
  ## Output
41
41
 
@@ -21,7 +21,7 @@
21
21
 
22
22
  ## Review boundary
23
23
 
24
- Review the stated goal and acceptance criteria against the current committed range or working-tree/staged diff, including relevant new files, available verification, and constraints. Inputs need no prescribed labels or order. Review only that implementation; do not edit, execute product work, or turn unrelated observations into blockers.
24
+ Review the stated goal and acceptance criteria against the current committed range or working-tree/staged diff, including relevant new files, available verification, and constraints. Inputs need no prescribed labels or order. Consider valid input classes, environments, and failure conditions reasonably implied by the approved behavior and committed contracts when concrete user impact or regression risk supports them; specification silence is not permission to break expected behavior, but it does not authorize new features, preferences, or speculative scope. Review only that implementation; do not edit, execute product work, or turn unrelated observations into blockers.
25
25
 
26
26
  Never use this role for research, ideation, architecture design before implementation, root-cause debugging, general answer validation, or routine confidence. Ground every claim in supplied or directly observed paths, symbols, diffs, tests, logs, or requirements. Distinguish implementation defects from harness/tool/environment failures and other proof gaps in clear prose; labels are optional. A harness that did not exercise product behavior proves neither success nor a product defect.
27
27
 
@@ -29,7 +29,7 @@
29
29
 
30
30
  Tests cover valid requirements, functionality, and external interfaces. Reject string, regex, snapshot, or parsed-content locks for documentation, commit messages, package descriptions, or non-boundary error/log wording. Changed requirements update tests; removed components lose their dedicated tests, not gain absence tests. Preserve valid safety/protocol/input-handling coverage. Git commits bound compatibility: uncommitted intermediate behavior may change incompatibly for final requirements, but an uncommitted edit does not erase committed contracts or expand API/security/data/permission/irreversible-action authorization. Report actual defects, current risks, unresolved authorization, and unverified evidence.
31
31
 
32
- Evaluate existing evidence by material relevance; request missing or affected coverage instead of blanket reruns for unrelated code, dependency, or environment changes. The orchestrator coordinates global/heavy verification; don't duplicate it or waive required safety, release, pre-commit, or user checks.
32
+ Evaluate existing evidence by material relevance; request missing or affected coverage instead of blanket reruns for unrelated code, dependency, or environment changes. Explicitly name any important behavior you considered but cannot judge, why, and the missing evidence; do not require a dedicated heading, list, or quota. The orchestrator coordinates global/heavy verification; don't duplicate it or waive required safety, release, pre-commit, or user checks.
33
33
 
34
34
  Report material findings first with severity when useful, file path, concrete evidence, likely impact, and the smallest valid correction. Judge whether useful functionality is complete, interfaces are clear, and meaningful regression and real-surface evidence support the result. Review informs engineering judgment; it is not delivery authorization or a protocol gate. Repeat only the affected review for a newly identified or resolved blocker, a substantive correction, or relevant new evidence; repeated concerns or unchanged uncertainty do not justify another pass. Apply strict review only when the user explicitly requests it or a scoped, concrete high-risk condition warrants it.
35
35
 
@@ -21,7 +21,7 @@
21
21
 
22
22
  ## Review boundary
23
23
 
24
- Review the stated goal and acceptance criteria against the current committed range or working-tree/staged diff, including relevant new files, available verification, and constraints. Inputs need no prescribed labels or order. Review only that implementation; do not edit, execute product work, or turn unrelated observations into blockers.
24
+ Review the stated goal and acceptance criteria against the current committed range or working-tree/staged diff, including relevant new files, available verification, and constraints. Inputs need no prescribed labels or order. Consider valid input classes, environments, and failure conditions reasonably implied by the approved behavior and committed contracts when concrete user impact or regression risk supports them; specification silence is not permission to break expected behavior, but it does not authorize new features, preferences, or speculative scope. Review only that implementation; do not edit, execute product work, or turn unrelated observations into blockers.
25
25
 
26
26
  Never use this role for research, ideation, architecture design before implementation, root-cause debugging, general answer validation, or routine confidence. Ground every claim in supplied or directly observed paths, symbols, diffs, tests, logs, or requirements. Distinguish implementation defects from harness/tool/environment failures and other proof gaps in clear prose; labels are optional. A harness that did not exercise product behavior proves neither success nor a product defect.
27
27
 
@@ -29,7 +29,7 @@
29
29
 
30
30
  Tests cover valid requirements, functionality, and external interfaces. Reject string, regex, snapshot, or parsed-content locks for documentation, commit messages, package descriptions, or non-boundary error/log wording. Changed requirements update tests; removed components lose their dedicated tests, not gain absence tests. Preserve valid safety/protocol/input-handling coverage. Git commits bound compatibility: uncommitted intermediate behavior may change incompatibly for final requirements, but an uncommitted edit does not erase committed contracts or expand API/security/data/permission/irreversible-action authorization. Report actual defects, current risks, unresolved authorization, and unverified evidence.
31
31
 
32
- Evaluate existing evidence by material relevance; request missing or affected coverage instead of blanket reruns for unrelated code, dependency, or environment changes. The orchestrator coordinates global/heavy verification; don't duplicate it or waive required safety, release, pre-commit, or user checks.
32
+ Evaluate existing evidence by material relevance; request missing or affected coverage instead of blanket reruns for unrelated code, dependency, or environment changes. Explicitly name any important behavior you considered but cannot judge, why, and the missing evidence; do not require a dedicated heading, list, or quota. The orchestrator coordinates global/heavy verification; don't duplicate it or waive required safety, release, pre-commit, or user checks.
33
33
 
34
34
  Report material findings first with severity when useful, file path, concrete evidence, likely impact, and the smallest valid correction. Judge whether useful functionality is complete, interfaces are clear, and meaningful regression and real-surface evidence support the result. Review informs engineering judgment; it is not delivery authorization or a protocol gate. Repeat only the affected review for a newly identified or resolved blocker, a substantive correction, or relevant new evidence; repeated concerns or unchanged uncertainty do not justify another pass. Apply strict review only when the user explicitly requests it or a scoped, concrete high-risk condition warrants it.
35
35
 
@@ -23,10 +23,10 @@
23
23
 
24
24
  - Reclassify from the current message only; do not carry implementation authorization across turns. Announce the intent and routing decision briefly for non-trivial work.
25
25
  - Chinese: `我读到这是[任务类型]。我会[路由/执行计划]。` English: `I read this as [task type]. I will [route/plan].`
26
- - Explanation or research requests end in an answer, not edits. Ambiguity gets one material question or `clarifier`.
26
+ - Explanation or research requests end in an answer, not edits. Before asking about ambiguity, inspect supplied or named context and directly related project evidence; ask only a material unresolved question and state what its answer changes, or use `clarifier`.
27
27
  - For complex implementation of product business logic or behavior, default to the complete `planner` → `plan-critic` → implementation sequence. Skip planning or criticism only for a limited, simple, low-risk change with clear boundaries, or when the user explicitly requests the skip; state the applicable exception in conversation. Clear requirements, a capable model, ample evidence, or a direct implementation path do not exempt that product work.
28
28
  - Non-product routine operations, docs, maintenance, and release preparation use direct execution when resolvable, otherwise a material question or useful `complex`/specialist delegation. Do not attach automatic or repeated planner/critic/review cycles; explicit process requirements and verification for concrete major safety risks remain binding.
29
- - `brainstorming` resolves material design uncertainty without adding a second approval gate to an already authorized task. Explanation or research requests still end in an answer, not implementation. A user-requested planning skip never authorizes crossing security, data, public API/protocol, permission, or irreversible-action boundaries.
29
+ - `brainstorming` resolves material design uncertainty without adding a second approval gate to an already authorized task. It does not ask again for facts or choices already settled by the request, supplied artifacts, related project evidence, or prior conversation. Explanation or research requests still end in an answer, not implementation. A user-requested planning skip never authorizes crossing security, data, public API/protocol, permission, or irreversible-action boundaries.
30
30
  - Architecture/security/performance tradeoffs: gather evidence and decide directly unless genuinely difficult; strict or high-risk conditions alone do not qualify for `hard-reasoning`.
31
31
 
32
32
  ## Smallest-fit routing
@@ -55,7 +55,7 @@
55
55
 
56
56
  Reviewer is the primary-model or primary-lane self-review profile. Oracle profiles are external-model cross-check slots in ordered Oracle priority: `oracle`, then `oracle-2nd` only when actually enabled and permitted; no later slot is supplied by this inventory. Configuring multiple slots or tiers does not cause fan-out; request additional evidence explicitly and in ordinal order. Explicit user model configuration remains authoritative.
57
57
 
58
- Review informs engineering judgment; it does not authorize delivery. Give reviewers the goal, acceptance criteria, current diff or range including new files, available verification, and relevant constraints, without requiring prescribed labels or ordering. Repeat only the affected review for a newly identified or resolved blocker, a substantive correction, or relevant new evidence when further review is warranted.
58
+ Review informs engineering judgment; it does not authorize delivery. Give reviewers the goal, acceptance criteria, current diff or range including new files, available verification, and relevant constraints, without requiring prescribed labels or ordering. Reviewers may identify concrete gaps for input classes or failure conditions implied by approved behavior and committed contracts, but may not expand scope; they name important unjudged behavior, its reason, and missing evidence without a fixed heading or quota. Repeat only the affected review for a newly identified or resolved blocker, a substantive correction, or relevant new evidence when further review is warranted.
59
59
 
60
60
  Before dispatching planner or plan-critic, inspect actual admitted role tools, target enums and configured invocation levels. Keep canonical dsmm-planner/dsmm-plan-critic identities; source tier suffixes are not DSH tools. Omitted/normal preserves the default route. For cross-module work prefer configured high when suitable, otherwise normal; for concrete safety/performance/data-loss risk prefer configured max, then high, then normal. Use low only for explicit cost/latency intent. No tier name proves a model's effort or capability: levels are configured complete routes or exact effort-only overrides, and route needs deployment opt-in plus native preflight. Preserve the critic's thorough blocker-finding duty independent of cost; no exact xhigh SDK effort is inferred. Report a required unavailable planning capability to the stage owner.
61
61
 
@@ -23,7 +23,7 @@
23
23
 
24
24
  Review the supplied plan path or inline plan together with its goal, constraints, known dependencies and interfaces, risks, and intended outcome evidence. Inputs need no prescribed labels or order. If the review target is unclear, ask for the smallest clarification needed.
25
25
 
26
- Assess whether the plan describes the ideal end state and useful wave goals, exposes material dependencies, interfaces, and risks, and leaves workers room for minimal evidence-based equivalent implementation or ordering decisions. Plans are adjustable guidance, not hard scripts.
26
+ Assess whether the plan describes the ideal end state and useful wave goals, exposes material dependencies, interfaces, and risks, records necessary paths, signatures, requirement-fixed values, and decisive test assertions without transcribing derivable implementation bodies, and leaves workers room for minimal evidence-based equivalent implementation or ordering decisions. Plans are adjustable guidance, not hard scripts.
27
27
 
28
28
  Check final deliverable requirements, not a development or decision history. `docs/superpowers/specs/` and `docs/superpowers/plans/` are product-only; each describes one final result, with separate plans for changed requirements. Complex non-product tasks use conversation coordination or task-owned temporary plans elsewhere. Do not demand rationale/cost records for assumptions; require current constraints, unresolved authorization, risks, and missing acceptance evidence.
29
29
 
@@ -31,7 +31,7 @@
31
31
 
32
32
  ## Blocker Eligibility
33
33
 
34
- Trace the user's necessary outcome states and failure conditions to a feasible delivery path and sufficient evidence. Check critical interfaces and safety behavior, not just whether a command is listed. A missing necessary outcome or proof path is a blocker when it prevents the approved result from being delivered or demonstrated; name the concrete gap and smallest correction. Don't demand an exhaustive state inventory, fixed IS table, scenario quota, or QA ritual when the plan already covers the required result.
34
+ Trace the user's necessary outcome states and failure conditions to a feasible delivery path and sufficient evidence. Consider material input classes and failure conditions reasonably implied by the approved behavior and local contracts without creating speculative scope. Important behavior left unjudged must carry its reason and missing evidence, but no fixed review-focus heading, list, or quota is required. Check critical interfaces and safety behavior, not just whether a command is listed. A missing necessary outcome or proof path is a blocker when it prevents the approved result from being delivered or demonstrated; name the concrete gap and smallest correction. Don't demand an exhaustive state inventory, fixed IS table, scenario quota, or QA ritual when the plan already covers the required result.
35
35
 
36
36
  Treat as blockers only issues that contradict an explicit requirement or constraint, omit a necessary prerequisite, preserve a known failing regression, create a concrete security/data-loss/compatibility/release/runtime risk, or conflict with an external API, provider, protocol, platform, packaging, or release contract. Recommend the smallest useful correction without expanding scope.
37
37
 
@@ -23,8 +23,8 @@
23
23
 
24
24
  - Read, search, and analyze. Return a complete Markdown product plan when durable coordination is useful or requested; the authorized coordinator persists it if an artifact is needed. This native planner is read-only, including plan files: do not use shell, write/edit or a child proxy to persist one. Non-product coordination and reports stay in conversation unless explicitly requested as deliverables. Do not edit source, tests, configuration, or product documentation.
25
25
  - Reserve `docs/superpowers/specs/` and `docs/superpowers/plans/` for final product requirements to be delivered. Each artifact describes one final deliverable, not development decisions, rejected alternatives, assumption rationale/cost, or change history. Changed requirements use separate plans. Non-product tasks, regardless of complexity, use conversation coordination or a task-owned temporary plan outside those directories.
26
- - Plan around the ideal end state, dependencies, interfaces, material risks, wave goals, and useful outcome evidence. Treat steps and ordering as informed guidance that execution may adjust as evidence changes, not as a hard script.
27
- - Plan verification around valid requirements, functionality, and external interfaces, not descriptive-text locks. Requirement changes update tests; removed components lose their dedicated tests rather than gaining absence tests. Git commits bound compatibility: interim uncommitted behavior need not be preserved, but existing committed contracts and API/security/data/permission/irreversible-action authorization remain binding.
26
+ - Plan around the ideal end state, dependencies, interfaces, material risks, wave goals, and useful outcome evidence. Record decisions an implementer cannot safely infer: necessary paths and names, interface signatures and types, requirement-fixed values, and decisive test assertions or observable results. Do not transcribe implementation bodies already determined by those decisions. Treat steps and ordering as informed guidance that execution may adjust as evidence changes, not as a hard script.
27
+ - Plan verification around valid requirements, functionality, and external interfaces, including material input classes and failure conditions implied by the approved behavior and local contracts. Attach plausible regression coverage to the owning task; when an important behavior remains unjudged, state why and what evidence is missing without imposing a fixed review-focus heading, list, or quota. Do not expand scope from speculation or add descriptive-text locks. Requirement changes update tests; removed components lose their dedicated tests rather than gaining absence tests. Git commits bound compatibility: interim uncommitted behavior need not be preserved, but existing committed contracts and API/security/data/permission/irreversible-action authorization remain binding.
28
28
  - Return genuinely material unresolved design choices to the orchestrator for `brainstorming`; use `writing-plans` techniques proportionally rather than imposing ceremony.
29
29
  - Use direct tools first. A leaf read-only `code-search`, `doc-search`, or equivalent lookup is allowed only to resolve a named fact. If evidence leaves a genuinely difficult decision, report the blocker to the orchestrator for optional `hard-reasoning`; strict or high-risk conditions alone do not qualify.
30
30
  - Never compose workflow roles: Do not dispatch `plan-critic`, any Reviewer profile, or any Oracle profile; do not use Reviewer profiles or Oracle profiles. Planner, clarifier, coordinator, implementation agents, and decision/review surrogates are also prohibited.
@@ -21,7 +21,7 @@
21
21
 
22
22
  ## Review boundary
23
23
 
24
- Review the stated goal and acceptance criteria against the current committed range or working-tree/staged diff, including relevant new files, available verification, and constraints. Inputs need no prescribed labels or order. Review only that implementation; do not edit, execute product work, or turn unrelated observations into blockers.
24
+ Review the stated goal and acceptance criteria against the current committed range or working-tree/staged diff, including relevant new files, available verification, and constraints. Inputs need no prescribed labels or order. Consider valid input classes, environments, and failure conditions reasonably implied by the approved behavior and committed contracts when concrete user impact or regression risk supports them; specification silence is not permission to break expected behavior, but it does not authorize new features, preferences, or speculative scope. Review only that implementation; do not edit, execute product work, or turn unrelated observations into blockers.
25
25
 
26
26
  Never use this role for research, ideation, architecture design before implementation, root-cause debugging, general answer validation, or routine confidence. Ground every claim in supplied or directly observed paths, symbols, diffs, tests, logs, or requirements. Distinguish implementation defects from harness/tool/environment failures and other proof gaps in clear prose; labels are optional. A harness that did not exercise product behavior proves neither success nor a product defect.
27
27
 
@@ -29,7 +29,7 @@
29
29
 
30
30
  Tests cover valid requirements, functionality, and external interfaces. Reject string, regex, snapshot, or parsed-content locks for documentation, commit messages, package descriptions, or non-boundary error/log wording. Changed requirements update tests; removed components lose their dedicated tests, not gain absence tests. Preserve valid safety/protocol/input-handling coverage. Git commits bound compatibility: uncommitted intermediate behavior may change incompatibly for final requirements, but an uncommitted edit does not erase committed contracts or expand API/security/data/permission/irreversible-action authorization. Report actual defects, current risks, unresolved authorization, and unverified evidence.
31
31
 
32
- Evaluate existing evidence by material relevance; request missing or affected coverage instead of blanket reruns for unrelated code, dependency, or environment changes. The orchestrator coordinates global/heavy verification; don't duplicate it or waive required safety, release, pre-commit, or user checks.
32
+ Evaluate existing evidence by material relevance; request missing or affected coverage instead of blanket reruns for unrelated code, dependency, or environment changes. Explicitly name any important behavior you considered but cannot judge, why, and the missing evidence; do not require a dedicated heading, list, or quota. The orchestrator coordinates global/heavy verification; don't duplicate it or waive required safety, release, pre-commit, or user checks.
33
33
 
34
34
  Report material findings first with severity when useful, file path, concrete evidence, likely impact, and the smallest valid correction. Judge whether useful functionality is complete, interfaces are clear, and meaningful regression and real-surface evidence support the result. Review informs engineering judgment; it is not delivery authorization or a protocol gate. Repeat only the affected review for a newly identified or resolved blocker, a substantive correction, or relevant new evidence; repeated concerns or unchanged uncertainty do not justify another pass. Apply strict review only when the user explicitly requests it or a scoped, concrete high-risk condition warrants it.
35
35
 
@@ -79,6 +79,32 @@ native catalog's selected skill body or invocation policy. Full bodies stay lazy
79
79
  Historical v1/v2/v3 child captures without `avoid-ai-slop` restore it as disabled;
80
80
  explicit booleans remain captured without a protocol version or authority change.
81
81
 
82
+ ## Selective superpowers sources
83
+
84
+ The maintained [brainstorming](../skills/brainstorming/SKILL.md),
85
+ [writing-plans](../skills/writing-plans/SKILL.md),
86
+ [subagent-driven-development](../skills/subagent-driven-development/SKILL.md),
87
+ and [requesting-code-review](../skills/requesting-code-review/SKILL.md) resources
88
+ selectively adapt their corresponding `obra/superpowers` v7.0.1 skills. The
89
+ planning decision/signature/assertion guidance comes from the v7.0.1
90
+ [writing-plans skill](https://github.com/obra/superpowers/blob/v7.0.1/skills/writing-plans/SKILL.md);
91
+ look-before-asking guidance comes from the v7.0.1
92
+ [brainstorming skill](https://github.com/obra/superpowers/blob/v7.0.1/skills/brainstorming/SKILL.md);
93
+ and implied-input plus unjudged-evidence guidance comes from the v7.0.1
94
+ [reviewer template](https://github.com/obra/superpowers/blob/v7.0.1/skills/requesting-code-review/code-reviewer.md)
95
+ and related skill references. Each adapted skill directory retains Jesse
96
+ Vincent's upstream MIT notice in its local `LICENSE` file.
97
+
98
+ Local entry skills retain the native DSH resourceBase, permission, tool, depth,
99
+ stopping, escalation, Git and workflow-ownership contracts. Conditional detail
100
+ is split only by responsibility: brainstorming loads
101
+ `references/artifacts-and-evidence.md` when producing durable artifacts or test
102
+ guidance, and subagent-driven development loads
103
+ `references/worker-return-and-review.md` when workers return or implementation
104
+ review becomes relevant. These resources do not import upstream fixed design
105
+ approval, workspace ledgers, mandatory commits, universal TDD or per-task review,
106
+ or nested workflow controllers.
107
+
82
108
  ## Frontend resources and provenance
83
109
 
84
110
  The full `skills/frontend/` tree is maintained in this repository and shipped in
@@ -58,7 +58,17 @@ A trusted, writable native Root can manage Global rules without DSMM role admiss
58
58
 
59
59
  In the UI, new command entries are entered simply as command strings with Add and Remove actions. There are no ID, tool, cwd, sandbox or action selectors, and no repetitive override or explanation lines. Saved legacy structured entries display a compact read-only summary showing the command and identifiable constraints (tool, working directory, ask/sandbox differences viewable in collapsible details) plus a delete button.
60
60
 
61
- Simple command rules support literal command and subcommand prefixes (such as `git`, `git status`, `go test`) and optional alternatives (`go build|test`). A match takes priority over DSMM command ask/deny and legacy command entries, automatically approving native `danger-full-access` for that invocation. Unmatched commands follow the ordinary policy path. Shell chaining, pipes, redirects and complex shell syntax do not match. Current invocation identity, cancellation and role/tool eligibility remain required; the grant does not change the session's standing sandbox.
61
+ Simple command rules support literal command and subcommand prefixes (such as `git`, `git status`, `go test`) and optional alternatives (`go build|test`). An existing whole-command literal match takes priority over DSMM command ask/deny and legacy command entries, automatically approving native `danger-full-access` for that invocation. Ordinary unmatched single commands retain their existing policy path.
62
+
63
+ When `nativeCommands.enabled` is true, a completely recognized **linear script** also qualifies if every component either has no applicable existing DSMM constraint or matches a string entry. No whitelist hit is required: with empty entries, `echo one; echo two` qualifies when no existing rule constrains it. An unclassified program, alias, Git subcommand or static interpreter is not rejected merely for being unknown. This is a rule-based authorization policy, **not** proof that a command is safe or read-only, nor OS confinement.
64
+
65
+ The finite grammar supports unquoted `;`, LF/CRLF, `&&`, `||` and `|`, checks all branches and pipeline stages, and retains quoted separators as literal arguments. Leading/trailing blank lines, a trailing semicolon, and ordinary newlines after chain/pipe operators are supported. Unquoted POSIX backslash + LF continues a component, as does PowerShell backtick + LF/CRLF at a token boundary; POSIX backslash + CRLF falls back. PowerShell token-internal escaped newlines are not literal concatenation and fall back. Static quoting, Unicode and empty operands follow the existing literal matcher. The original script executes once without rewriting or splitting execution.
66
+
67
+ Control flow, functions, groups/blocks, expansion/substitution, globbing, comments, here-docs/strings, redirection, background `&`, PowerShell call/dot-sourcing operators, `--%`, smart quotes, unsupported escapes, unclosed quotes, `;;`, dangling operators and environment assignments are outside this grammar. `env ...`, `node -e '...'` and `bash -c '...'` may be ordinary literal components; interpreter code is not recursively evaluated for this authorization, and a wrapped command's whitelist does not match its wrapper. Existing Git `env` detection still applies. Unsupported syntax, incomplete evaluation or any uncovered constraint retains the original path, not a new script ask/deny.
68
+
69
+ Component constraints reuse the effective Agent's Git guard/scope, dialect-safety rules, managed exact-shell/outside-read rules and legacy object matching. Existing standing Full access semantics apply: guards contribute only applicable Git deny, native rules retain confirmed blacklists rather than unknown-read deny, and exact/legacy asks add no constraint. String matches can cover DSMM ask **or deny** for that component; legacy objects themselves are not string whitelist grants. Exact rules compare the original component text (only separator-adjacent spaces/tabs removed), actual executable and effective cwd; internal continuation text is retained. A rule matching the entire original script, including a whole-script outside-read constraint, covers **every** component and therefore requires every component to be string-whitelisted. Existing outside-read unknown/deny and trusted-read capability rules remain in effect; effect labels alone add no constraint. Stock tools do not gain a fictitious managed-rule identity.
70
+
71
+ Current invocation identity, cancellation and role/tool eligibility remain required. Native/third-party deny, native `approval.policy=never`, read-only ceilings and tool filters cannot be overridden. The grant changes neither the session's standing sandbox nor later calls, and is not saved as approval memory.
62
72
 
63
73
  An additional outer middleware may request approval after the pre-execution pipeline has returned. When that request has no exact execution association, it retains native approval handling; DSMM does not infer authorization from a shared call ID, signal or tool name.
64
74
 
@@ -57,6 +57,12 @@ Shell checks inspect the command argument for `bash`, `sh`, `zsh`, `pwsh`, and `
57
57
 
58
58
  For either scope, `ask` requires approval of the covered rules, `deny` rejects covered actions, and `off` contributes no automatic Git decision. `high-risk` only narrows automatic Git protection: explicit shell ask/deny and object-form native command asks still apply. Guard activation, shell dialect safety, readonly ceilings and existing standing Full access/simple-command priority are unchanged. This is not a general dangerous-command detector. Unrecognized aliases/wrappers receive no automatic Git decision; uncertain syntax cannot create a reusable broad approval. All command segments are considered, so an ordinary write before a high-risk action cannot hide the latter.
59
59
 
60
+ With `permissionControl.nativeCommands.enabled`, fully recognized linear scripts are eligible for one-call native `danger-full-access` when **each component has no applicable existing DSMM constraint or matches a string whitelist entry**. At least one whitelist hit is not required. For example, with `git commit` whitelisted, `echo before; git commit -m owned; echo after` qualifies under Git `ask` or `deny`, unless another uncovered constraint applies. Replacing commit with an uncovered controlled push retains the original policy path. With no applicable rules, even an unknown static program qualifies; this does not certify safety. Git scope `off`, inactive guard scope and writes outside `high-risk` contribute no Git constraint, while existing exact-shell, outside-read and legacy constraints still count.
61
+
62
+ The finite authorization grammar supports static literal components joined by `;`, LF/CRLF, `&&`, `||` or `|`, including all branches and pipeline stages, plus unquoted POSIX backslash + LF continuations and token-boundary PowerShell backtick + LF/CRLF continuations. POSIX backslash + CRLF and PowerShell token-internal escaped newlines are unsupported. Quoted separators stay literal. It does not parse full shell syntax: assignments, control flow, groups, expansion, globbing, comments, redirects, here-docs/strings, background execution and unsupported quoting/escapes fall back unchanged. Static interpreter code is not recursively parsed, and a wrapper needs its own string match when controlled. See [native permissions](native-permissions.md#configuration-drawer-and-command-rules) for the complete contract.
63
+
64
+ String matches override corresponding DSMM constraints, including deny, but never native/third-party deny, native `never`, read-only/tool ceilings or cancellation. A component exact rule uses its original raw text, actual shell executable and cwd; an exact or outside-read constraint on the original whole script requires **all components** to match string entries. Classification effects such as local write/destructive/unknown are not new risk rules. Successful qualification executes the original script once with existing invocation identity checks; it neither changes standing permissions nor creates cross-call approval memory. Unsupported or incompletely evaluated scripts receive no new grant or extra script-specific denial.
65
+
60
66
  The existing schema-driven **Plugins → DSMM bundle config → Permissions** fields expose both options in Global and current DSH profile scopes. Unset uses defaults in Global and restores inheritance in the profile; a named profile can also override `guards.gitWriteScope`. Sparse saves do not pin omitted values. Read-only configuration stays non-writable. Saved settings follow existing new-session admission; they do not apply a live overlay.
61
67
 
62
68
  ## Command-rule approval memory
@@ -2,8 +2,8 @@ import type { Context } from "@deepseek-ai/cordis";
2
2
  import type { Agent } from "@deepseek-ai/dsh-agent";
3
3
  import type { DsmmDeploymentConfig } from "./deployment-config.js";
4
4
  import type { PermissionControlCollaborators } from "./permission-control.js";
5
- import type { DsmmPermissionController } from "./permission-controller.js";
5
+ import type { DsmmPermissionController, PermissionControllerOptions } from "./permission-controller.js";
6
6
  import type { CommandApprovals } from "./command-approval.js";
7
7
  /** The native Core fiber owns one source backend, execution controller and RPC service. */
8
- export declare function installCorePermissions(ctx: Context, deployment: DsmmDeploymentConfig, authority: PermissionControlCollaborators, assertWritable: (root: Agent) => void, commandApprovals?: CommandApprovals): DsmmPermissionController;
8
+ export declare function installCorePermissions(ctx: Context, deployment: DsmmDeploymentConfig, authority: PermissionControlCollaborators, assertWritable: (root: Agent) => void, commandApprovals?: CommandApprovals, shellGuardConstraint?: PermissionControllerOptions["shellGuardConstraint"]): DsmmPermissionController;
9
9
  //# sourceMappingURL=core-permissions.d.ts.map
@@ -3,7 +3,7 @@ import { PermissionRefusal, permissionOriginal } from "./permission-control.js";
3
3
  import { installPermissionController } from "./permission-controller.js";
4
4
  import { registerPermissionControlRpc } from "./permission-rpc.js";
5
5
  /** The native Core fiber owns one source backend, execution controller and RPC service. */
6
- export function installCorePermissions(ctx, deployment, authority, assertWritable, commandApprovals) {
6
+ export function installCorePermissions(ctx, deployment, authority, assertWritable, commandApprovals, shellGuardConstraint) {
7
7
  let controller;
8
8
  const backend = installDeploymentPermissionRules(ctx, {
9
9
  deployment, assertWritable,
@@ -19,7 +19,7 @@ export function installCorePermissions(ctx, deployment, authority, assertWritabl
19
19
  },
20
20
  });
21
21
  controller = installPermissionController(ctx, {
22
- authority, rules: backend.runtime, commandApprovals,
22
+ authority, rules: backend.runtime, commandApprovals, shellGuardConstraint,
23
23
  // The public ShellExecutor has no executable/environment resolution proof.
24
24
  // This identity never grants read trust or filesystem colocation.
25
25
  shellIdentity: (_scope, kind) => Object.freeze({ executable: `unresolved-native-${kind}`,
package/lib/guards.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  import type { DshContext, DshPostToolDecision, DshPreToolDecision, DshToolExecution, DshToolExecutionResult } from "./dsh-types.js";
2
2
  import type { DsmmSettings, DsmmSettingsGetter } from "./settings.js";
3
+ import type { ShellDialect } from "./shell-command.js";
3
4
  import type { DeepworkModeController } from "./state.js";
4
5
  import type { DsmmRolePolicy } from "./role-policy.js";
5
6
  import type { CommandApprovals } from "./command-approval.js";
6
7
  export declare const DSMM_GUARD_PREFIX = "[dsmm safety]";
7
8
  export declare function truncateTextMiddle(text: string, maxBytes: number, toolName: string): string;
8
9
  export declare function isSafetyScopeActive(exec: DshToolExecution, settings: DsmmSettings, controller: DeepworkModeController): boolean;
10
+ /** Existing command constraints only; no tool execution or new risk classification. */
11
+ export declare function hasShellGuardConstraint(exec: DshToolExecution, command: string, dialect: ShellDialect, settings: DsmmSettings, controller: DeepworkModeController, nativeFullAccess?: boolean): boolean;
9
12
  export declare function decidePreToolExecution(exec: DshToolExecution, settings: DsmmSettings, controller: DeepworkModeController, nativeFullAccess?: boolean, simple?: boolean): DshPreToolDecision | undefined;
10
13
  export declare function decidePostToolExecution(exec: DshToolExecution, result: Readonly<DshToolExecutionResult>, decision: DshPostToolDecision, settings: DsmmSettings, controller: DeepworkModeController): DshPostToolDecision;
11
14
  export declare function registerSafetyGuards(ctx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter, rolePolicy?: DsmmRolePolicy, commandApprovals?: CommandApprovals): void;
package/lib/guards.js CHANGED
@@ -128,6 +128,14 @@ function gitActions(exec, settings) {
128
128
  return command === undefined || dialect === undefined ? [] : evaluateGitCommand(command, dialect)
129
129
  .filter(action => settings.guards.gitWriteScope !== "high-risk" || action.risk === "high-risk");
130
130
  }
131
+ /** Existing command constraints only; no tool execution or new risk classification. */
132
+ export function hasShellGuardConstraint(exec, command, dialect, settings, controller, nativeFullAccess = false) {
133
+ if (!isSafetyScopeActive(exec, settings, controller))
134
+ return false;
135
+ return !nativeFullAccess && settings.guards.shellCommandSafety && classifyShellDialectViolation(command, dialect) !== undefined
136
+ || (nativeFullAccess ? settings.guards.gitWriteGuard === "deny" : settings.guards.gitWriteGuard !== "off") && evaluateGitCommand(command, dialect)
137
+ .some(action => settings.guards.gitWriteScope !== "high-risk" || action.risk === "high-risk");
138
+ }
131
139
  function gitRuleReason(actions) {
132
140
  return actions.map(({ action, ruleId }) => `git ${action === "reset.hard" ? "reset --hard" : action.replaceAll(".", " ")} [${ruleId}]`).join(", ");
133
141
  }
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Context, symbols } from "@deepseek-ai/cordis";
2
2
  import { registerDsmmTuiAdapter } from "./tui-adapter.js";
3
- import { registerSafetyGuards } from "./guards.js";
3
+ import { hasShellGuardConstraint, registerSafetyGuards } from "./guards.js";
4
4
  import { registerDeepworkPrompt } from "./mode.js";
5
5
  import { registerAgentSkills } from "./preset-skills.js";
6
6
  import { registerModelRouting } from "./model-routing.js";
@@ -159,7 +159,7 @@ export async function apply(input, config = {}, startupOptions = {}) {
159
159
  ctx.inject(["typert"], scope => { registerConfigRpc(scope, deployment, startup.settings, () => profiles, startup.sources, mountedPermission); new DsmmProfilesHost(scope, profiles); registerRoleControlRpc(scope, nativeAdmission); });
160
160
  const permissions = createCorePermissionAuthority(ctx, { getSettings, rolePolicy: policy, signal: lifetime.signal });
161
161
  const installPermissions = () => ctx.inject(["tools", ...(ctx.fiber.entry === undefined ? [] : ["settings"])], scope => {
162
- const installed = installCorePermissions(scope, deployment, permissions.authority, permissions.assertWritable, commandApprovals);
162
+ const installed = installCorePermissions(scope, deployment, permissions.authority, permissions.assertWritable, commandApprovals, (exec, command, dialect) => hasShellGuardConstraint(exec, command, dialect, getSettings(exec.agent), controller, nativeStandingFullAccess(scope, exec.agent)));
163
163
  const identity = Reflect.get(installed, symbols.original) ?? installed;
164
164
  scopeLifetime(scope, "dsmm: release permission projection", () => { if (permissionOwner === identity)
165
165
  permissionOwner = undefined; }, () => { permissionOwner = identity; });
@@ -18,6 +18,8 @@ export interface PermissionControllerOptions {
18
18
  /** The existing live Core owner/admission/Root/realm/run facts, not serialized settings or a ready boolean. */
19
19
  readonly authority: PermissionControlCollaborators;
20
20
  readonly rules: PermissionRulesRuntimeSync;
21
+ /** Provided by the guard owner using this Agent's effective settings and live scope. */
22
+ shellGuardConstraint?(execution: Readonly<ToolExecution>, command: string, dialect: PermissionShellIdentity["dialect"]): boolean;
21
23
  /** Native registration identity; only an explicit capability proves Shell read semantics. */
22
24
  shellIdentity(scope: Context, kind: ManagedPermissionShell): PermissionShellIdentity;
23
25
  coLocated?(scope: Context, execution: Readonly<ToolExecution>, fs: NativePermissionFileSystem): boolean;
@@ -45,7 +47,8 @@ export declare class DsmmPermissionController extends Service {
45
47
  private readonly stockRegistrations;
46
48
  private readonly lifetime;
47
49
  constructor(ctx: Context, options: PermissionControllerOptions);
48
- /** Admit this exact simple match through the existing per-call native approval binding. */
50
+ private shellRuleIdentity;
51
+ /** Admit a whole literal match or completely covered linear script through the same per-call binding. */
49
52
  simpleCommandAllowed(exec: Readonly<ToolExecution>): Promise<boolean>;
50
53
  private stockRegistration;
51
54
  /** Public in-process facts for DSMM consumers; requested/configured modes never grant access. */
@@ -3,8 +3,9 @@ import { HarnessError } from "@deepseek-ai/dsh-llm";
3
3
  import { TOOL_ABORTED } from "@deepseek-ai/dsh-tools";
4
4
  import { isSandboxWidening, PermissionControl, PermissionRefusal, permissionApprovalAdapter, permissionOriginal } from "./permission-control.js";
5
5
  import { classifyPermissionShell } from "./permission-shell.js";
6
- import { nativeCommandMatches, simpleCommandMatch, simpleShellCommand, simpleShellDialect } from "./permission-native-command.js";
7
- import { NATIVE_PERMISSION_CAPABILITIES, registerNativePermissionRules } from "./permission-native-rules.js";
6
+ import { nativeCommandMatches, simpleCommandMatch, simpleCommandWordsMatch, simpleShellCommand, simpleShellDialect } from "./permission-native-command.js";
7
+ import { parseLinearScript } from "./permission-linear-script.js";
8
+ import { evaluateNativeShellRules, NATIVE_PERMISSION_CAPABILITIES, registerNativePermissionRules } from "./permission-native-rules.js";
8
9
  import { nativeStandingFullAccess } from "./permission-native-access.js";
9
10
  export const PERMISSION_CONTROLLER_INJECT = ["tools", "agents"];
10
11
  /** Bind methods to the original scoped receiver, preserving filters and registry layers. */
@@ -66,7 +67,7 @@ export class DsmmPermissionController extends Service {
66
67
  if (this.rules.status().mounted) {
67
68
  registerNativePermissionRules(ctx, {
68
69
  runtime: this.rules,
69
- simpleCommandAllowed: exec => this.permissions.isSimple(exec),
70
+ simpleCommandAllowed: exec => this.simpleCommandAllowed(exec),
70
71
  captureIntegrity: options.authority.captureIntegrity === undefined ? undefined : exec => options.authority.captureIntegrity(exec),
71
72
  identify: definition => {
72
73
  const managed = this.registrations.get(definition);
@@ -81,11 +82,7 @@ export class DsmmPermissionController extends Service {
81
82
  throw new PermissionRefusal("stale"); },
82
83
  coLocated: (exec, fs) => options.coLocated?.(tool.scope, exec, fs) === true };
83
84
  }
84
- return { kind: "shell", context: managed.scope, shell: managed.shell, signal: managed.registration.signal,
85
- assertIntegrity: () => { if (!managed.registration.active || !managed.registration.unchanged())
86
- throw new PermissionRefusal("stale"); },
87
- assertCurrent: exec => managed.registration.assertCurrent?.(exec),
88
- coLocated: (exec, fs) => options.coLocated?.(managed.scope, exec, fs) === true };
85
+ return this.shellRuleIdentity(managed);
89
86
  },
90
87
  captureAuthority: exec => {
91
88
  const current = options.authority.current(exec);
@@ -142,7 +139,14 @@ export class DsmmPermissionController extends Service {
142
139
  }
143
140
  ctx.effect(() => () => this.retire());
144
141
  }
145
- /** Admit this exact simple match through the existing per-call native approval binding. */
142
+ shellRuleIdentity(managed) {
143
+ return { kind: "shell", context: managed.scope, shell: managed.shell, signal: managed.registration.signal,
144
+ assertIntegrity: () => { if (!managed.registration.active || !managed.registration.unchanged())
145
+ throw new PermissionRefusal("stale"); },
146
+ assertCurrent: exec => managed.registration.assertCurrent?.(exec),
147
+ coLocated: (exec, fs) => this.options.coLocated?.(managed.scope, exec, fs) === true };
148
+ }
149
+ /** Admit a whole literal match or completely covered linear script through the same per-call binding. */
146
150
  async simpleCommandAllowed(exec) {
147
151
  if (this.permissions.isSimple(exec))
148
152
  return true;
@@ -158,7 +162,7 @@ export class DsmmPermissionController extends Service {
158
162
  const command = managed === undefined ? simpleShellCommand(exec.arguments) : Reflect.get(exec.arguments, managed.shell.commandField);
159
163
  if (dialect === undefined || typeof command !== "string")
160
164
  return false;
161
- const body = definition.execute, args = exec.arguments, name = exec.name, callId = exec.callId, signal = exec.signal;
165
+ const body = definition.execute, args = exec.arguments, name = exec.name, callId = exec.callId, signal = exec.signal, token = exec.token;
162
166
  const registry = agent.ctx.get("agents"), workspace = agent.session.header.cwd;
163
167
  const checkCall = () => {
164
168
  if (signal.aborted || exec.signal !== signal || this.lifetime.signal.aborted)
@@ -169,7 +173,7 @@ export class DsmmPermissionController extends Service {
169
173
  && definition.execute === stock.wrapper && stock.unchanged();
170
174
  if (exec.agent !== agent || agent.ctx !== realm || registry === undefined || liveRegistry === undefined
171
175
  || permissionOriginal(liveRegistry) !== permissionOriginal(registry) || liveRegistry.get(agent.id) !== agent
172
- || exec.arguments !== args || exec.name !== name || exec.callId !== callId || agent.session.header.cwd !== workspace
176
+ || exec.arguments !== args || exec.token !== token || exec.name !== name || exec.callId !== callId || agent.session.header.cwd !== workspace
173
177
  || liveTools === undefined || permissionOriginal(liveTools) !== permissionOriginal(tools)
174
178
  || tools.get(name, agent) !== definition || liveTools.get(name, agent) !== definition || !sameBody)
175
179
  throw new PermissionRefusal("stale");
@@ -190,7 +194,69 @@ export class DsmmPermissionController extends Service {
190
194
  catch {
191
195
  return false;
192
196
  }
193
- if (!simpleCommandMatch(snapshot.policy.nativeCommands, command, dialect))
197
+ const settings = snapshot.policy.nativeCommands;
198
+ let allowed = simpleCommandMatch(settings, command, dialect);
199
+ if (!allowed && settings.enabled && this.options.shellGuardConstraint !== undefined) {
200
+ const components = parseLinearScript(command, dialect);
201
+ if (components !== undefined) {
202
+ if (failure !== undefined || authority === undefined) {
203
+ checkCall();
204
+ return false;
205
+ }
206
+ const capturedAuthority = authority;
207
+ const identity = managed === undefined ? undefined : this.shellRuleIdentity(managed);
208
+ let coLocatedFs;
209
+ const check = () => {
210
+ checkCall();
211
+ this.options.authority.assertCurrent(capturedAuthority, exec);
212
+ identity?.assertIntegrity?.(exec);
213
+ identity?.assertCurrent(exec);
214
+ if (coLocatedFs !== undefined && identity?.coLocated?.(exec, coLocatedFs) !== true)
215
+ throw new PermissionRefusal("stale");
216
+ };
217
+ check();
218
+ const constrained = async (candidate, includeGuards) => {
219
+ if (includeGuards && this.options.shellGuardConstraint(exec, candidate, dialect))
220
+ return true;
221
+ // Stock tools have no managed native-rule identity; do not invent one from their name.
222
+ if (managed === undefined || identity === undefined)
223
+ return false;
224
+ const input = { ...args, [managed.shell.commandField]: candidate };
225
+ const nativeOnly = nativeStandingFullAccess(identity.context, exec.agent);
226
+ if (!nativeOnly) {
227
+ const entries = nativeCommandMatches(settings, managed.kind, managed.shell, input, workspace ?? "");
228
+ if (entries === "ambiguous" || entries.some(entry => entry.mode === "ask"))
229
+ return true;
230
+ }
231
+ const evaluation = { identity, snapshot, nativeOnly, workspaceRoot: workspace ?? "",
232
+ signal: AbortSignal.any([signal, ...identity.signal === undefined ? [] : [identity.signal]]),
233
+ fs: identity.context.get("fs"), asks: [] };
234
+ const action = await evaluateNativeShellRules(exec, evaluation, () => {
235
+ if (evaluation.provenCoLocation)
236
+ coLocatedFs = evaluation.fs;
237
+ check();
238
+ }, input);
239
+ return action === "ask" || action === "deny";
240
+ };
241
+ try {
242
+ const whole = await constrained(command, false);
243
+ allowed = true;
244
+ for (const component of components) {
245
+ if (!simpleCommandWordsMatch(settings, component.words, dialect) && (whole || await constrained(component.command, true))) {
246
+ allowed = false;
247
+ break;
248
+ }
249
+ }
250
+ }
251
+ catch {
252
+ allowed = false;
253
+ }
254
+ check();
255
+ if (this.rules.getPolicy() !== snapshot)
256
+ return false;
257
+ }
258
+ }
259
+ if (!allowed)
194
260
  return false;
195
261
  if (failure !== undefined)
196
262
  throw failure;
@@ -0,0 +1,10 @@
1
+ import type { PermissionShellIdentity } from "./permission-shell.js";
2
+ export interface LinearScriptComponent {
3
+ readonly start: number;
4
+ readonly end: number;
5
+ readonly command: string;
6
+ readonly words: readonly string[];
7
+ }
8
+ /** Complete finite recognition, not a shell AST. Original ranges are never rewritten for execution. */
9
+ export declare function parseLinearScript(command: string, dialect: PermissionShellIdentity["dialect"]): readonly LinearScriptComponent[] | undefined;
10
+ //# sourceMappingURL=permission-linear-script.d.ts.map
@@ -0,0 +1,91 @@
1
+ import { literalCommand } from "./permission-native-command.js";
2
+ /** Complete finite recognition, not a shell AST. Original ranges are never rewritten for execution. */
3
+ export function parseLinearScript(command, dialect) {
4
+ const components = [];
5
+ let start = 0, chunk = 0, quote = "", structured = false;
6
+ let pending;
7
+ let pieces = [];
8
+ const finish = (end) => {
9
+ const view = pieces.join("") + command.slice(chunk, end);
10
+ const words = literalCommand(view, dialect, "simple");
11
+ if (words === undefined)
12
+ return false;
13
+ let left = start, right = end;
14
+ while (command[left] === " " || command[left] === "\t")
15
+ left++;
16
+ while (right > left && (command[right - 1] === " " || command[right - 1] === "\t"))
17
+ right--;
18
+ components.push(Object.freeze({ start: left, end: right, command: command.slice(left, right), words }));
19
+ pieces = [];
20
+ return true;
21
+ };
22
+ for (let index = 0; index < command.length; index++) {
23
+ const char = command[index];
24
+ if (quote !== "") {
25
+ if (char === quote) {
26
+ if (dialect === "powershell" && quote === "'" && command[index + 1] === "'")
27
+ index++;
28
+ else
29
+ quote = "";
30
+ }
31
+ continue;
32
+ }
33
+ if (char === "'" || char === '"') {
34
+ quote = char;
35
+ continue;
36
+ }
37
+ if (char === (dialect === "posix" ? "\\" : "`")) {
38
+ const length = command[index + 1] === "\n" ? 2 : dialect === "powershell" && command.slice(index + 1, index + 3) === "\r\n" ? 3 : 0;
39
+ if (length !== 0) {
40
+ // Do not reinterpret token-internal PowerShell escaped newlines as POSIX concatenation.
41
+ if (dialect === "powershell" && index !== start && command[index - 1] !== " " && command[index - 1] !== "\t")
42
+ return undefined;
43
+ pieces.push(command.slice(chunk, index));
44
+ index += length - 1;
45
+ chunk = index + 1;
46
+ structured = true;
47
+ continue;
48
+ }
49
+ // Do not reinterpret CRLF as a POSIX continuation or split an escaped operator.
50
+ return undefined;
51
+ }
52
+ const newline = char === "\n" || char === "\r" && command[index + 1] === "\n";
53
+ if (!newline && char !== ";" && char !== "|" && char !== "&")
54
+ continue;
55
+ structured = true;
56
+ const chain = char === "|" || char === "&";
57
+ let length = newline && char === "\r" ? 2 : 1;
58
+ if (chain && command[index + 1] === char)
59
+ length = 2;
60
+ else if (char === "&")
61
+ return undefined;
62
+ const empty = /^[ \t]*$/u.test(pieces.join("") + command.slice(chunk, index));
63
+ if (empty) {
64
+ if (!newline)
65
+ return undefined;
66
+ }
67
+ else {
68
+ if (!finish(index))
69
+ return undefined;
70
+ pending = undefined;
71
+ }
72
+ if (chain)
73
+ pending = "chain";
74
+ else if (!newline)
75
+ pending = "separator";
76
+ index += length - 1;
77
+ start = chunk = index + 1;
78
+ pieces = [];
79
+ }
80
+ if (quote !== "" || !structured)
81
+ return undefined;
82
+ const empty = /^[ \t]*$/u.test(pieces.join("") + command.slice(chunk));
83
+ if (empty) {
84
+ if (pending === "chain")
85
+ return undefined;
86
+ }
87
+ else if (!finish(command.length))
88
+ return undefined;
89
+ return components.length === 0 ? undefined : Object.freeze(components);
90
+ }
91
+ //# sourceMappingURL=permission-linear-script.js.map