@dsmm/dsmm 0.1.9 → 0.2.2
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 +46 -58
- package/agent-presets/dsmm-builder/agent.cordis.yml +91 -186
- package/agent-presets/dsmm-builder/preset.yml +1 -1
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +120 -17
- package/agent-presets/dsmm-clarifier/preset.yml +1 -1
- package/agent-presets/dsmm-code-search/agent.cordis.yml +72 -17
- package/agent-presets/dsmm-code-search/preset.yml +1 -1
- package/agent-presets/dsmm-coding/agent.cordis.yml +169 -0
- package/agent-presets/dsmm-coding/preset.yml +3 -0
- package/agent-presets/dsmm-complex/agent.cordis.yml +154 -0
- package/agent-presets/dsmm-complex/preset.yml +3 -0
- package/agent-presets/dsmm-creative/agent.cordis.yml +122 -15
- package/agent-presets/dsmm-creative/preset.yml +1 -1
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +179 -0
- package/agent-presets/dsmm-cross-cutting/preset.yml +3 -0
- package/agent-presets/dsmm-deep/agent.cordis.yml +189 -0
- package/agent-presets/dsmm-deep/preset.yml +3 -0
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +72 -17
- package/agent-presets/dsmm-doc-search/preset.yml +1 -1
- package/agent-presets/dsmm-documenting/agent.cordis.yml +168 -0
- package/agent-presets/dsmm-documenting/preset.yml +3 -0
- package/agent-presets/dsmm-frontend/agent.cordis.yml +161 -0
- package/agent-presets/dsmm-frontend/preset.yml +3 -0
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +153 -0
- package/agent-presets/dsmm-hard-reasoning/preset.yml +3 -0
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +72 -17
- package/agent-presets/dsmm-media-reader/preset.yml +1 -1
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +127 -0
- package/agent-presets/dsmm-normal-task/preset.yml +3 -0
- package/agent-presets/dsmm-oracle/agent.cordis.yml +109 -15
- package/agent-presets/dsmm-oracle/preset.yml +1 -1
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +109 -15
- package/agent-presets/dsmm-oracle-2nd/preset.yml +1 -1
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +174 -190
- package/agent-presets/dsmm-orchestrator/preset.yml +1 -1
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +102 -16
- package/agent-presets/dsmm-plan-critic/preset.yml +1 -1
- package/agent-presets/dsmm-planner/agent.cordis.yml +134 -15
- package/agent-presets/dsmm-planner/preset.yml +1 -1
- package/agent-presets/dsmm-quick/agent.cordis.yml +132 -0
- package/agent-presets/dsmm-quick/preset.yml +3 -0
- package/agent-presets/dsmm-research/agent.cordis.yml +156 -0
- package/agent-presets/dsmm-research/preset.yml +3 -0
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +108 -16
- package/agent-presets/dsmm-reviewer/preset.yml +1 -1
- package/cordis.patch.yml +1 -5
- package/docs/agent-presets.md +48 -15
- package/docs/compatibility.md +58 -68
- package/docs/deferred-native-approval-risk.md +19 -0
- package/docs/design.md +43 -2
- package/docs/lsp.md +12 -12
- package/docs/migration-from-ocmm.md +10 -2
- package/docs/model-routing.md +84 -59
- package/docs/native-permissions.md +35 -0
- package/docs/profiles.md +43 -64
- package/docs/releasing.md +159 -8
- package/docs/roadmap.md +77 -17
- package/docs/runtime-recovery.md +12 -0
- package/docs/safety-guards.md +7 -3
- package/docs/settings-status.md +46 -40
- package/docs/skill-sync.md +89 -14
- package/lib/child-admission-contract.d.ts +37 -0
- package/lib/child-admission-contract.js +2 -0
- package/lib/child-admission.d.ts +42 -0
- package/lib/child-admission.js +162 -0
- package/lib/child-capture.d.ts +81 -0
- package/lib/child-capture.js +203 -0
- package/lib/child-evidence.d.ts +17 -0
- package/lib/child-evidence.js +43 -0
- package/lib/client/ChildrenPanel.d.ts +43 -0
- package/lib/client/ChildrenPanel.js +82 -0
- package/lib/client/DeploymentPage.d.ts +18 -0
- package/lib/client/DeploymentPage.js +127 -0
- package/lib/client/EditableChoice.d.ts +17 -0
- package/lib/client/EditableChoice.js +49 -0
- package/lib/client/PermissionsPanel.d.ts +14 -0
- package/lib/client/PermissionsPanel.js +46 -0
- package/lib/client/ProfilesSection.js +32 -15
- package/lib/client/RoleAvailability.d.ts +7 -0
- package/lib/client/RoleAvailability.js +19 -0
- package/lib/client/SessionProfiles.js +27 -9
- package/lib/client/StructuredEditor.js +15 -7
- package/lib/client/children-controller.d.ts +98 -0
- package/lib/client/children-controller.js +296 -0
- package/lib/client/children-locales.d.ts +367 -0
- package/lib/client/children-locales.js +69 -0
- package/lib/client/controller.d.ts +6 -1
- package/lib/client/controller.js +14 -8
- package/lib/client/deployment-controller.d.ts +50 -0
- package/lib/client/deployment-controller.js +193 -0
- package/lib/client/deployment-data.d.ts +17 -0
- package/lib/client/deployment-data.js +138 -0
- package/lib/client/deployment-locales.d.ts +70 -0
- package/lib/client/deployment-locales.js +81 -0
- package/lib/client/diagnostics.d.ts +14 -0
- package/lib/client/diagnostics.js +53 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +145 -1
- package/lib/client/locales.d.ts +58 -0
- package/lib/client/locales.js +38 -18
- package/lib/client/permission-client.d.ts +16 -0
- package/lib/client/permission-client.js +38 -0
- package/lib/client/permission-controller.d.ts +62 -0
- package/lib/client/permission-controller.js +149 -0
- package/lib/client/permission-locales.d.ts +114 -0
- package/lib/client/permission-locales.js +75 -0
- package/lib/client/plugins-contract.d.ts +27 -0
- package/lib/client/plugins-contract.js +2 -0
- package/lib/client/session-labels.js +4 -4
- package/lib/client/structured.js +19 -5
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +36 -0
- package/lib/client.js +6724 -1604
- package/lib/commands.js +3 -0
- package/lib/config-file-store.d.ts +23 -0
- package/lib/config-file-store.js +67 -0
- package/lib/core-permission-authority.d.ts +18 -0
- package/lib/core-permission-authority.js +255 -0
- package/lib/core-permissions.d.ts +8 -0
- package/lib/core-permissions.js +33 -0
- package/lib/delivery-authority.d.ts +68 -0
- package/lib/delivery-authority.js +260 -0
- package/lib/deployment-config.d.ts +60 -0
- package/lib/deployment-config.js +205 -0
- package/lib/deployment-permission-rules.d.ts +55 -0
- package/lib/deployment-permission-rules.js +306 -0
- package/lib/dsh-home.d.ts +3 -0
- package/lib/dsh-home.js +10 -0
- package/lib/dsh-types.d.ts +22 -69
- package/lib/guards.d.ts +3 -2
- package/lib/guards.js +44 -6
- package/lib/host-llm-startup.d.ts +41 -0
- package/lib/host-llm-startup.js +65 -0
- package/lib/host-llm.d.ts +92 -0
- package/lib/host-llm.js +325 -0
- package/lib/index.d.ts +23 -5
- package/lib/index.js +383 -40
- package/lib/legacy-child-policy.d.ts +51 -0
- package/lib/legacy-child-policy.js +123 -0
- package/lib/legacy-read-composition.d.ts +20 -0
- package/lib/legacy-read-composition.js +144 -0
- package/lib/legacy-read-contracts.d.ts +157 -0
- package/lib/legacy-read-contracts.js +39 -0
- package/lib/legacy-read-host.d.ts +19 -0
- package/lib/legacy-read-host.js +67 -0
- package/lib/legacy-read-integration.d.ts +121 -0
- package/lib/legacy-read-integration.js +522 -0
- package/lib/legacy-read-proxy.d.ts +26 -0
- package/lib/legacy-read-proxy.js +237 -0
- package/lib/live-pi-ai-owner.d.ts +18 -0
- package/lib/live-pi-ai-owner.js +144 -0
- package/lib/llm-runtime.d.ts +11 -0
- package/lib/llm-runtime.js +21 -0
- package/lib/lsp.d.ts +13 -0
- package/lib/lsp.js +60 -0
- package/lib/managed-settings.d.ts +5 -0
- package/lib/managed-settings.js +14 -0
- package/lib/mode.js +42 -47
- package/lib/model-parameter-policy.d.ts +11 -0
- package/lib/model-parameter-policy.js +27 -0
- package/lib/model-routing.js +33 -19
- package/lib/modules.d.ts +35 -0
- package/lib/modules.js +37 -0
- package/lib/native-child-evidence.d.ts +42 -0
- package/lib/native-child-evidence.js +133 -0
- package/lib/native-pi-ai-wire.d.ts +37 -0
- package/lib/native-pi-ai-wire.js +261 -0
- package/lib/native-scope.d.ts +9 -0
- package/lib/native-scope.js +20 -0
- package/lib/permission-bash.d.ts +6 -0
- package/lib/permission-bash.js +7 -0
- package/lib/permission-control.d.ts +73 -0
- package/lib/permission-control.js +205 -0
- package/lib/permission-controller.d.ts +68 -0
- package/lib/permission-controller.js +317 -0
- package/lib/permission-errors.d.ts +7 -0
- package/lib/permission-errors.js +21 -0
- package/lib/permission-fs-search.d.ts +5 -0
- package/lib/permission-fs-search.js +7 -0
- package/lib/permission-fs.d.ts +5 -0
- package/lib/permission-fs.js +7 -0
- package/lib/permission-native-access.d.ts +11 -0
- package/lib/permission-native-access.js +6 -0
- package/lib/permission-native-command.d.ts +10 -0
- package/lib/permission-native-command.js +93 -0
- package/lib/permission-native-rules.d.ts +75 -0
- package/lib/permission-native-rules.js +278 -0
- package/lib/permission-pwsh.d.ts +6 -0
- package/lib/permission-pwsh.js +7 -0
- package/lib/permission-remote.d.ts +26 -0
- package/lib/permission-remote.js +53 -0
- package/lib/permission-rpc.d.ts +29 -0
- package/lib/permission-rpc.js +152 -0
- package/lib/permission-rules.d.ts +115 -0
- package/lib/permission-rules.js +256 -0
- package/lib/permission-settings.d.ts +45 -0
- package/lib/permission-settings.js +48 -0
- package/lib/permission-shell.d.ts +38 -0
- package/lib/permission-shell.js +150 -0
- package/lib/permission-web.d.ts +5 -0
- package/lib/permission-web.js +7 -0
- package/lib/plan-validation.js +6 -44
- package/lib/preset-materializer.js +2 -0
- package/lib/preset-registry.d.ts +1 -1
- package/lib/preset-registry.js +38 -24
- package/lib/preset-skills.d.ts +4 -1
- package/lib/preset-skills.js +60 -19
- package/lib/profile-diagnostics.d.ts +45 -0
- package/lib/profile-diagnostics.js +148 -0
- package/lib/profile-locale.d.ts +3 -0
- package/lib/profile-locale.js +2 -0
- package/lib/profile-remote.d.ts +22 -0
- package/lib/profile-remote.js +344 -27
- package/lib/profile-rpc.d.ts +25 -1
- package/lib/profile-rpc.js +143 -3
- package/lib/profile-runtime.d.ts +63 -0
- package/lib/profile-runtime.js +496 -77
- package/lib/profile-store.d.ts +56 -1
- package/lib/profile-store.js +377 -111
- package/lib/profile-types.d.ts +125 -1
- package/lib/profile-types.js +1 -0
- package/lib/profiles.d.ts +16 -2
- package/lib/profiles.js +156 -79
- package/lib/prompt-content.d.ts +25 -0
- package/lib/prompt-content.js +27 -0
- package/lib/prompts.d.ts +45 -4
- package/lib/prompts.js +157 -43
- package/lib/recovery-policy.js +20 -7
- package/lib/role-control-remote.d.ts +38 -0
- package/lib/role-control-remote.js +211 -0
- package/lib/role-control-rpc.d.ts +51 -0
- package/lib/role-control-rpc.js +377 -0
- package/lib/role-control-types.d.ts +92 -0
- package/lib/role-control-types.js +8 -0
- package/lib/role-invocation.d.ts +47 -0
- package/lib/role-invocation.js +135 -0
- package/lib/role-llm-runtime.d.ts +17 -0
- package/lib/role-llm-runtime.js +62 -0
- package/lib/role-llm.d.ts +31 -0
- package/lib/role-llm.js +66 -0
- package/lib/role-policy.d.ts +92 -0
- package/lib/role-policy.js +601 -0
- package/lib/role-providers.d.ts +7 -3
- package/lib/role-providers.js +74 -46
- package/lib/role-routing.d.ts +11 -2
- package/lib/role-routing.js +42 -25
- package/lib/role-runs.d.ts +135 -0
- package/lib/role-runs.js +304 -0
- package/lib/role-subagents.d.ts +63 -4
- package/lib/role-subagents.js +299 -47
- package/lib/roles.d.ts +20 -9
- package/lib/roles.js +87 -216
- package/lib/route-json.d.ts +19 -0
- package/lib/route-json.js +129 -0
- package/lib/routing-policy.d.ts +2 -0
- package/lib/routing-policy.js +12 -2
- package/lib/runtime-integration.d.ts +112 -0
- package/lib/runtime-integration.js +784 -0
- package/lib/runtime-recovery.js +34 -13
- package/lib/session-scope.js +2 -0
- package/lib/settings.d.ts +116 -14
- package/lib/settings.js +455 -149
- package/lib/skills.d.ts +24 -9
- package/lib/skills.js +114 -35
- package/lib/state.d.ts +10 -6
- package/lib/state.js +48 -49
- package/lib/status.d.ts +35 -1
- package/lib/status.js +58 -17
- package/lib/subagent-runtime.d.ts +45 -0
- package/lib/subagent-runtime.js +131 -0
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +112 -45
- package/patches/subagent-runtime.yml +15 -0
- package/prompts/deepseek-flash.md +1 -1
- package/prompts/deepseek-v4-pro.md +2 -2
- package/prompts/deepwork.md +153 -20
- package/prompts/source/agents/clarifier.md +47 -0
- package/prompts/source/agents/orchestrator.md +72 -0
- package/prompts/source/agents/plan-critic.md +29 -0
- package/prompts/source/agents/planner.md +21 -0
- package/prompts/source/agents/reviewer.md +23 -0
- package/prompts/source/catalog.json +548 -0
- package/prompts/source/category/coding.md +46 -0
- package/prompts/source/category/complex.md +29 -0
- package/prompts/source/category/creative.md +40 -0
- package/prompts/source/category/cross-cutting.md +54 -0
- package/prompts/source/category/deep.md +64 -0
- package/prompts/source/category/documenting.md +68 -0
- package/prompts/source/category/frontend.md +38 -0
- package/prompts/source/category/hard-reasoning.md +53 -0
- package/prompts/source/category/normal-task.md +27 -0
- package/prompts/source/category/quick.md +34 -0
- package/prompts/source/category/research.md +58 -0
- package/prompts/source/deepwork/claude-opus-5.md +28 -0
- package/prompts/source/deepwork/codex.md +9 -0
- package/prompts/source/deepwork/default.md +136 -0
- package/prompts/source/deepwork/gemini.md +191 -0
- package/prompts/source/deepwork/glm.md +263 -0
- package/prompts/source/deepwork/gpt.md +49 -0
- package/prompts/source/deepwork/kimi-k27.md +13 -0
- package/prompts/source/deepwork/planner.md +44 -0
- package/prompts/source/deepwork/swe-2.md +13 -0
- package/prompts/source/manifest.json +3233 -0
- package/prompts/source/shared/dsh-host-contract.md +8 -0
- package/prompts/source/shared/locale.md +8 -0
- package/prompts/source/shared/shell-safety.md +7 -0
- package/prompts/source/terminal/builder.md +13 -0
- package/prompts/source/terminal/clarifier.md +41 -0
- package/prompts/source/terminal/code-search.md +39 -0
- package/prompts/source/terminal/coding.md +41 -0
- package/prompts/source/terminal/complex.md +43 -0
- package/prompts/source/terminal/creative.md +41 -0
- package/prompts/source/terminal/cross-cutting.md +43 -0
- package/prompts/source/terminal/deep.md +43 -0
- package/prompts/source/terminal/doc-search.md +39 -0
- package/prompts/source/terminal/documenting.md +41 -0
- package/prompts/source/terminal/frontend.md +41 -0
- package/prompts/source/terminal/hard-reasoning.md +41 -0
- package/prompts/source/terminal/media-reader.md +39 -0
- package/prompts/source/terminal/normal-task.md +41 -0
- package/prompts/source/terminal/oracle-2nd.md +53 -0
- package/prompts/source/terminal/oracle.md +53 -0
- package/prompts/source/terminal/orchestrator.md +26 -0
- package/prompts/source/terminal/plan-critic.md +41 -0
- package/prompts/source/terminal/planner.md +42 -0
- package/prompts/source/terminal/quick.md +39 -0
- package/prompts/source/terminal/research.md +39 -0
- package/prompts/source/terminal/reviewer.md +53 -0
- package/scripts/cold-profile-composition.mjs +329 -0
- package/scripts/cold-profile-sources.mjs +238 -0
- package/scripts/migrate-cold-profile.mjs +315 -0
- package/skills/ast-grep/LICENSE +21 -0
- package/skills/ast-grep/README.md +138 -0
- package/skills/ast-grep/SKILL.md +287 -0
- package/skills/ast-grep/SOURCE +1 -0
- package/skills/ast-grep/install.ps1 +235 -0
- package/skills/ast-grep/install.sh +286 -0
- package/skills/ast-grep/references/cli.md +233 -0
- package/skills/ast-grep/references/install.md +168 -0
- package/skills/ast-grep/references/patterns.md +149 -0
- package/skills/ast-grep/references/pitfalls.md +305 -0
- package/skills/ast-grep/references/recipes.md +404 -0
- package/skills/ast-grep/references/sgconfig.md +250 -0
- package/skills/ast-grep/references/yaml-rules.md +511 -0
- package/skills/ast-grep/scripts/ast_grep_helper.py +760 -0
- package/skills/ast-grep/tests/smoke.ps1 +129 -0
- package/skills/ast-grep/tests/smoke.sh +212 -0
- package/skills/ast-grep/tests/test_resolver.py +154 -0
- package/skills/brainstorming/SKILL.md +123 -9
- package/skills/coding-agent-sessions/LICENSE-UPSTREAM.md +82 -0
- package/skills/coding-agent-sessions/NOTICE.md +24 -0
- package/skills/coding-agent-sessions/SKILL.md +147 -0
- package/skills/coding-agent-sessions/agents/openai.yaml +4 -0
- package/skills/coding-agent-sessions/pyrightconfig.json +5 -0
- package/skills/coding-agent-sessions/references/all-platforms.md +77 -0
- package/skills/coding-agent-sessions/references/claude.md +34 -0
- package/skills/coding-agent-sessions/references/codex.md +32 -0
- package/skills/coding-agent-sessions/references/opencode.md +45 -0
- package/skills/coding-agent-sessions/references/senpi.md +29 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/__init__.py +1 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/aside_scanner.py +140 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/claude.py +66 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/cli.py +283 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/codex.py +105 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/file_scanners.py +275 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/jsonio.py +55 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/kiro_scanner.py +91 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/opencode.py +289 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/scanners.py +104 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/sqlite_optional_scanners.py +203 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/sqlite_scanners.py +177 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/timeparse.py +51 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/transcript.py +149 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/types.py +57 -0
- package/skills/coding-agent-sessions/scripts/find-agent-sessions.py +19 -0
- package/skills/coding-agent-sessions/scripts/tests/test_agent_sessions.py +322 -0
- package/skills/coding-agent-sessions/scripts/tests/test_aside_scanner.py +131 -0
- package/skills/coding-agent-sessions/scripts/tests/test_cli_contract.py +126 -0
- package/skills/coding-agent-sessions/scripts/tests/test_extended_scanners.py +262 -0
- package/skills/coding-agent-sessions/scripts/tests/test_optional_sqlite_scanners.py +79 -0
- package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -0
- package/skills/debugging/SKILL.md +130 -4
- package/skills/debugging/references/logging.md +2 -0
- package/skills/debugging/references/methodology/00-setup.md +16 -62
- package/skills/debugging/references/methodology/02-investigate.md +11 -5
- package/skills/debugging/references/methodology/03-flaky-triage.md +6 -4
- package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +6 -16
- package/skills/debugging/references/methodology/05-escalate.md +2 -0
- package/skills/debugging/references/methodology/06-fix.md +8 -6
- package/skills/debugging/references/methodology/08-qa.md +7 -5
- package/skills/debugging/references/methodology/09-cleanup.md +16 -152
- package/skills/debugging/references/methodology/partial-runtime-evidence.md +7 -18
- package/skills/debugging/references/runtimes/bundled-js-binary.md +3 -16
- package/skills/debugging/references/runtimes/go.md +2 -0
- package/skills/debugging/references/runtimes/native-binary.md +11 -54
- package/skills/debugging/references/runtimes/node.md +6 -15
- package/skills/debugging/references/runtimes/python.md +5 -15
- package/skills/debugging/references/runtimes/rust.md +4 -18
- package/skills/debugging/references/scripts/dap.test.mjs +539 -0
- package/skills/debugging/references/scripts/fixture-adapter.mjs +164 -0
- package/skills/debugging/references/tools/dap.md +4 -2
- package/skills/debugging/references/tools/ghidra.md +6 -15
- package/skills/debugging/references/tools/playwright-cli.md +5 -15
- package/skills/debugging/references/tools/pwndbg.md +2 -0
- package/skills/debugging/references/tools/pwntools.md +6 -16
- package/skills/dispatching-parallel-agents/SKILL.md +96 -7
- package/skills/frontend/.frontend-materialized.json +856 -0
- package/skills/frontend/ATTRIBUTION.md +37 -0
- package/skills/frontend/LICENSE-Apache-2.0.txt +201 -0
- package/skills/frontend/LICENSE-taste-skill.txt +21 -0
- package/skills/frontend/LICENSE-ui-ux-pro-max.txt +21 -0
- package/skills/frontend/SKILL.md +145 -0
- package/skills/frontend/references/design/README.md +256 -0
- package/skills/frontend/references/design/_INDEX.md +206 -0
- package/skills/frontend/references/design/airbnb.md +393 -0
- package/skills/frontend/references/design/airtable.md +92 -0
- package/skills/frontend/references/design/apple.md +250 -0
- package/skills/frontend/references/design/aside.md +211 -0
- package/skills/frontend/references/design/binance.md +348 -0
- package/skills/frontend/references/design/bmw.md +183 -0
- package/skills/frontend/references/design/brutalist-skill.md +92 -0
- package/skills/frontend/references/design/bugatti.md +271 -0
- package/skills/frontend/references/design/cal.md +262 -0
- package/skills/frontend/references/design/claude.md +315 -0
- package/skills/frontend/references/design/clay.md +307 -0
- package/skills/frontend/references/design/clickhouse.md +284 -0
- package/skills/frontend/references/design/clone-from-url.md +69 -0
- package/skills/frontend/references/design/cohere.md +269 -0
- package/skills/frontend/references/design/coinbase.md +132 -0
- package/skills/frontend/references/design/composio.md +310 -0
- package/skills/frontend/references/design/cursor.md +312 -0
- package/skills/frontend/references/design/design-system-architecture.md +250 -0
- package/skills/frontend/references/design/elevenlabs.md +268 -0
- package/skills/frontend/references/design/expo.md +284 -0
- package/skills/frontend/references/design/ferrari.md +317 -0
- package/skills/frontend/references/design/figma.md +223 -0
- package/skills/frontend/references/design/framer.md +249 -0
- package/skills/frontend/references/design/gpt-tasteskill.md +74 -0
- package/skills/frontend/references/design/hashicorp.md +281 -0
- package/skills/frontend/references/design/ibm.md +335 -0
- package/skills/frontend/references/design/image-to-code-skill.md +1228 -0
- package/skills/frontend/references/design/imagegen-brandkit.md +798 -0
- package/skills/frontend/references/design/imagegen-frontend-mobile.md +1465 -0
- package/skills/frontend/references/design/imagegen-frontend-web.md +987 -0
- package/skills/frontend/references/design/interaction-skill.md +52 -0
- package/skills/frontend/references/design/intercom.md +149 -0
- package/skills/frontend/references/design/kraken.md +128 -0
- package/skills/frontend/references/design/lamborghini.md +291 -0
- package/skills/frontend/references/design/linear.app.md +370 -0
- package/skills/frontend/references/design/lovable.md +301 -0
- package/skills/frontend/references/design/mastercard.md +368 -0
- package/skills/frontend/references/design/meta.md +369 -0
- package/skills/frontend/references/design/minimalist-skill.md +85 -0
- package/skills/frontend/references/design/minimax.md +260 -0
- package/skills/frontend/references/design/mintlify.md +329 -0
- package/skills/frontend/references/design/miro.md +111 -0
- package/skills/frontend/references/design/mistral.ai.md +264 -0
- package/skills/frontend/references/design/mongodb.md +269 -0
- package/skills/frontend/references/design/nike.md +366 -0
- package/skills/frontend/references/design/notion.md +312 -0
- package/skills/frontend/references/design/nvidia.md +296 -0
- package/skills/frontend/references/design/ollama.md +270 -0
- package/skills/frontend/references/design/opencode.ai.md +284 -0
- package/skills/frontend/references/design/output-skill.md +49 -0
- package/skills/frontend/references/design/pinterest.md +233 -0
- package/skills/frontend/references/design/playstation.md +367 -0
- package/skills/frontend/references/design/posthog.md +259 -0
- package/skills/frontend/references/design/raycast.md +271 -0
- package/skills/frontend/references/design/react-dev-tooling-skill.md +232 -0
- package/skills/frontend/references/design/redesign-skill.md +178 -0
- package/skills/frontend/references/design/renault.md +314 -0
- package/skills/frontend/references/design/replicate.md +264 -0
- package/skills/frontend/references/design/resend.md +306 -0
- package/skills/frontend/references/design/revolut.md +188 -0
- package/skills/frontend/references/design/runwayml.md +247 -0
- package/skills/frontend/references/design/sanity.md +360 -0
- package/skills/frontend/references/design/sentry.md +265 -0
- package/skills/frontend/references/design/shopify.md +353 -0
- package/skills/frontend/references/design/soft-skill.md +98 -0
- package/skills/frontend/references/design/spacex.md +197 -0
- package/skills/frontend/references/design/spotify.md +249 -0
- package/skills/frontend/references/design/starbucks.md +583 -0
- package/skills/frontend/references/design/stitch-design-example.md +121 -0
- package/skills/frontend/references/design/stitch-skill.md +184 -0
- package/skills/frontend/references/design/stripe.md +325 -0
- package/skills/frontend/references/design/supabase.md +258 -0
- package/skills/frontend/references/design/superhuman.md +255 -0
- package/skills/frontend/references/design/taste-skill.md +1206 -0
- package/skills/frontend/references/design/tesla.md +289 -0
- package/skills/frontend/references/design/theverge.md +342 -0
- package/skills/frontend/references/design/together.ai.md +266 -0
- package/skills/frontend/references/design/uber.md +298 -0
- package/skills/frontend/references/design/vercel.md +313 -0
- package/skills/frontend/references/design/vodafone.md +426 -0
- package/skills/frontend/references/design/voltagent.md +326 -0
- package/skills/frontend/references/design/warp.md +256 -0
- package/skills/frontend/references/design/webflow.md +95 -0
- package/skills/frontend/references/design/wired.md +281 -0
- package/skills/frontend/references/design/wise.md +176 -0
- package/skills/frontend/references/design/x.ai.md +260 -0
- package/skills/frontend/references/design/zapier.md +331 -0
- package/skills/frontend/references/perfection/README.md +264 -0
- package/skills/frontend/references/perfection/react-perf-tooling.md +234 -0
- package/skills/frontend/references/ui-ux-db/README.md +659 -0
- package/skills/frontend/references/ui-ux-db/data/app-interface.csv +31 -0
- package/skills/frontend/references/ui-ux-db/data/charts.csv +26 -0
- package/skills/frontend/references/ui-ux-db/data/colors.csv +162 -0
- package/skills/frontend/references/ui-ux-db/data/google-fonts.csv +1924 -0
- package/skills/frontend/references/ui-ux-db/data/icons.csv +106 -0
- package/skills/frontend/references/ui-ux-db/data/landing.csv +35 -0
- package/skills/frontend/references/ui-ux-db/data/products.csv +162 -0
- package/skills/frontend/references/ui-ux-db/data/react-performance.csv +45 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/angular.csv +51 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/astro.csv +54 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/flutter.csv +53 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/html-tailwind.csv +56 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/jetpack-compose.csv +53 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/laravel.csv +51 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/nextjs.csv +53 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/nuxt-ui.csv +51 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/nuxtjs.csv +59 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/react-native.csv +52 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/react.csv +54 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/shadcn.csv +61 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/svelte.csv +54 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/swiftui.csv +51 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/threejs.csv +54 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/vue.csv +50 -0
- package/skills/frontend/references/ui-ux-db/data/styles.csv +85 -0
- package/skills/frontend/references/ui-ux-db/data/typography.csv +74 -0
- package/skills/frontend/references/ui-ux-db/data/ui-reasoning.csv +162 -0
- package/skills/frontend/references/ui-ux-db/data/ux-guidelines.csv +100 -0
- package/skills/frontend/references/ui-ux-db/data/web-interface.csv +31 -0
- package/skills/frontend/references/ui-ux-db/scripts/core.py +262 -0
- package/skills/frontend/references/ui-ux-db/scripts/design_system.py +1148 -0
- package/skills/frontend/references/ui-ux-db/scripts/search.py +114 -0
- package/skills/frontend/scripts/perfection/lighthouse-audit.py +201 -0
- package/skills/git-master/SKILL.md +115 -0
- package/skills/git-master/agents/openai.yaml +13 -0
- package/skills/init-deep/SKILL.md +282 -0
- package/skills/receiving-code-review/SKILL.md +117 -7
- package/skills/remove-ai-slops/SKILL.md +160 -8
- package/skills/requesting-code-review/SKILL.md +98 -3
- package/skills/requesting-code-review/code-reviewer.md +59 -0
- package/skills/subagent-driven-development/SKILL.md +179 -6
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +23 -0
- package/skills/subagent-driven-development/implementer-prompt.md +87 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +37 -0
- package/skills/using-git-worktrees/SKILL.md +144 -0
- package/skills/writing-plans/SKILL.md +126 -7
- package/skills/writing-plans/plan-document-reviewer-prompt.md +47 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
2
|
+
import type { NativePermissionCapabilityView } from "./permission-native-rules.js";
|
|
3
|
+
import type { PermissionControlSettings, PermissionRuleAction, PermissionWebPolicy } from "./permission-settings.js";
|
|
4
|
+
export type PermissionRuleMatch = {
|
|
5
|
+
readonly kind: "outside-read";
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly scope: "exact" | "tree";
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: "shell";
|
|
10
|
+
readonly executable: string;
|
|
11
|
+
readonly command: string;
|
|
12
|
+
readonly workingDirectory: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "webSearch" | "webFetch";
|
|
15
|
+
};
|
|
16
|
+
export interface PermissionRuleDraft {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly action: Exclude<PermissionRuleAction, "inherit">;
|
|
19
|
+
readonly match: PermissionRuleMatch;
|
|
20
|
+
}
|
|
21
|
+
export type PermissionRuleSource = {
|
|
22
|
+
readonly kind: "operator";
|
|
23
|
+
readonly sessionId: string;
|
|
24
|
+
readonly savedAt: number;
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: "user-import";
|
|
27
|
+
readonly label: string;
|
|
28
|
+
};
|
|
29
|
+
export interface PermissionRule extends PermissionRuleDraft {
|
|
30
|
+
readonly source: PermissionRuleSource;
|
|
31
|
+
readonly revision: number;
|
|
32
|
+
readonly revoked: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface PermissionRuleSnapshot {
|
|
35
|
+
readonly revision: string;
|
|
36
|
+
readonly policy: PermissionControlSettings;
|
|
37
|
+
}
|
|
38
|
+
export interface PermissionRulesStatus {
|
|
39
|
+
readonly savedRevision: string;
|
|
40
|
+
readonly runtimeRevision: string;
|
|
41
|
+
readonly state: "synced" | "updating" | "unsynced";
|
|
42
|
+
readonly mounted: boolean;
|
|
43
|
+
readonly restartRequired: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface PermissionRulesSaveRequest {
|
|
46
|
+
readonly expectedRevision: string;
|
|
47
|
+
readonly changes?: {
|
|
48
|
+
readonly outsideReads?: PermissionRuleAction;
|
|
49
|
+
readonly webSearch?: PermissionWebPolicy;
|
|
50
|
+
readonly webFetch?: PermissionWebPolicy;
|
|
51
|
+
};
|
|
52
|
+
readonly upsert?: readonly PermissionRuleDraft[];
|
|
53
|
+
readonly revoke?: readonly string[];
|
|
54
|
+
}
|
|
55
|
+
export interface PermissionRulesSaveAuthority {
|
|
56
|
+
readonly root: Agent;
|
|
57
|
+
readonly peer: object;
|
|
58
|
+
readonly signal: AbortSignal;
|
|
59
|
+
/** Backend calls this after awaits and immediately before its durable CAS. Includes readonly. */
|
|
60
|
+
assertCurrent(): void;
|
|
61
|
+
}
|
|
62
|
+
/** One central backend only. Every permission-affecting save (including imports) uses sync. */
|
|
63
|
+
export interface PermissionRulesBackend {
|
|
64
|
+
assertWritable(root: Agent): void;
|
|
65
|
+
read(authority: PermissionRulesSaveAuthority): Promise<PermissionRuleSnapshot>;
|
|
66
|
+
save(request: PermissionRulesSaveRequest, authority: PermissionRulesSaveAuthority): Promise<PermissionRulesSaveResult>;
|
|
67
|
+
}
|
|
68
|
+
export interface PermissionRulesSaveResult {
|
|
69
|
+
readonly snapshot: PermissionRuleSnapshot;
|
|
70
|
+
readonly runtime: PermissionRulesStatus;
|
|
71
|
+
readonly capabilities?: NativePermissionCapabilityView;
|
|
72
|
+
}
|
|
73
|
+
export declare function permissionRuleRow(value: unknown, required: readonly string[], optional?: readonly string[]): Record<string, unknown>;
|
|
74
|
+
/** Persistent backend source identity, not a counter or a prescribed hash format. */
|
|
75
|
+
export declare function permissionRevision(value: unknown): string;
|
|
76
|
+
export declare function parsePermissionRules(value: unknown): readonly PermissionRule[];
|
|
77
|
+
export declare function parsePermissionRulesSave(value: unknown): PermissionRulesSaveRequest;
|
|
78
|
+
/** Backend derives provenance from its verified Host authority, never from a client rule. */
|
|
79
|
+
export declare function applyPermissionRulesSave(previous: PermissionRuleSnapshot, input: PermissionRulesSaveRequest, source: PermissionRuleSource): PermissionControlSettings;
|
|
80
|
+
export declare function operatorPermissionRulesSource(authority: PermissionRulesSaveAuthority): PermissionRuleSource;
|
|
81
|
+
/** Import paths explicitly re-stamp all records; imported operator claims are not ACKs. */
|
|
82
|
+
export declare function importPermissionRules(input: readonly PermissionRuleDraft[], label: string, revision: number): readonly PermissionRule[];
|
|
83
|
+
export interface PermissionRulesUpdate {
|
|
84
|
+
readonly expectedRevision: string;
|
|
85
|
+
}
|
|
86
|
+
/** In-process protocol owned by A's single CAS backend. No file watcher or persistence. */
|
|
87
|
+
export declare class PermissionRulesRuntimeSync {
|
|
88
|
+
private readonly revoke;
|
|
89
|
+
private snapshot;
|
|
90
|
+
private savedRevision;
|
|
91
|
+
private state;
|
|
92
|
+
private update?;
|
|
93
|
+
private lifetime;
|
|
94
|
+
private retired;
|
|
95
|
+
private readonly mounted;
|
|
96
|
+
private desiredEnabled;
|
|
97
|
+
constructor(initial: PermissionRuleSnapshot, revoke: () => void);
|
|
98
|
+
private validate;
|
|
99
|
+
status(): PermissionRulesStatus;
|
|
100
|
+
getPolicy(): PermissionRuleSnapshot;
|
|
101
|
+
get signal(): AbortSignal;
|
|
102
|
+
/** Source backends override this entry; consumers never reconcile storage themselves. */
|
|
103
|
+
refresh(): Promise<PermissionRuleSnapshot>;
|
|
104
|
+
invalidate(): void;
|
|
105
|
+
private assertLive;
|
|
106
|
+
begin(expectedRevision: string): PermissionRulesUpdate;
|
|
107
|
+
private check;
|
|
108
|
+
/** Called only after CAS succeeded. notify must acknowledge all runtime revocation consumers. */
|
|
109
|
+
commit(update: PermissionRulesUpdate, saved: PermissionRuleSnapshot, notify: (snapshot: PermissionRuleSnapshot) => Promise<void>): Promise<PermissionRulesStatus>;
|
|
110
|
+
/** CAS failure or failed notification: reread authoritative storage, never publish the rejected request. */
|
|
111
|
+
recover(update: PermissionRulesUpdate | undefined, authoritative: PermissionRuleSnapshot, notify: (snapshot: PermissionRuleSnapshot) => Promise<void>): Promise<PermissionRulesStatus>;
|
|
112
|
+
retire(): void;
|
|
113
|
+
}
|
|
114
|
+
export declare function intersectPermissionActions(actions: readonly PermissionRuleAction[]): PermissionRuleAction;
|
|
115
|
+
//# sourceMappingURL=permission-rules.d.ts.map
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { PermissionRefusal } from "./permission-errors.js";
|
|
2
|
+
import { resolvePermissionControl } from "./permission-settings.js";
|
|
3
|
+
function invalid() { throw new PermissionRefusal("validation"); }
|
|
4
|
+
export function permissionRuleRow(value, required, optional = []) {
|
|
5
|
+
if (value === null || typeof value !== "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
6
|
+
invalid();
|
|
7
|
+
const fields = Object.getOwnPropertyDescriptors(value);
|
|
8
|
+
if (Reflect.ownKeys(value).some(key => typeof key !== "string" || !required.includes(key) && !optional.includes(key))
|
|
9
|
+
|| required.some(key => !Object.hasOwn(fields, key)) || Object.values(fields).some(field => !Object.hasOwn(field, "value") || !field.enumerable))
|
|
10
|
+
invalid();
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
function text(value, max = 32768) {
|
|
14
|
+
if (typeof value !== "string" || value.length === 0 || value.length > max || value.includes("\0"))
|
|
15
|
+
invalid();
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
/** Persistent backend source identity, not a counter or a prescribed hash format. */
|
|
19
|
+
export function permissionRevision(value) { return text(value, 4096); }
|
|
20
|
+
function integer(value) { if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)
|
|
21
|
+
invalid(); return value; }
|
|
22
|
+
function ruleAction(value, inherit = false) {
|
|
23
|
+
if (typeof value !== "string" || !(inherit ? ["inherit", "allow", "ask", "deny"] : ["allow", "ask", "deny"]).includes(value))
|
|
24
|
+
invalid();
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
function draft(value, persisted = false) {
|
|
28
|
+
const input = permissionRuleRow(value, ["id", "action", "match", ...persisted ? ["source", "revision", "revoked"] : []]);
|
|
29
|
+
const kind = permissionRuleRow(input.match, ["kind"], ["path", "scope", "executable", "command", "workingDirectory"]).kind;
|
|
30
|
+
let match;
|
|
31
|
+
if (kind === "outside-read") {
|
|
32
|
+
const row = permissionRuleRow(input.match, ["kind", "path", "scope"]);
|
|
33
|
+
if (row.scope !== "exact" && row.scope !== "tree")
|
|
34
|
+
invalid();
|
|
35
|
+
match = { kind, path: text(row.path), scope: row.scope };
|
|
36
|
+
}
|
|
37
|
+
else if (kind === "shell") {
|
|
38
|
+
const row = permissionRuleRow(input.match, ["kind", "executable", "command", "workingDirectory"]);
|
|
39
|
+
match = { kind, executable: text(row.executable), command: text(row.command), workingDirectory: text(row.workingDirectory) };
|
|
40
|
+
}
|
|
41
|
+
else if (kind === "webSearch" || kind === "webFetch") {
|
|
42
|
+
permissionRuleRow(input.match, ["kind"]);
|
|
43
|
+
match = { kind };
|
|
44
|
+
}
|
|
45
|
+
else
|
|
46
|
+
invalid();
|
|
47
|
+
return Object.freeze({ id: text(input.id, 256), action: ruleAction(input.action), match: Object.freeze(match) });
|
|
48
|
+
}
|
|
49
|
+
export function parsePermissionRules(value) {
|
|
50
|
+
if (!Array.isArray(value) || value.length > 1024)
|
|
51
|
+
invalid();
|
|
52
|
+
const ids = new Set();
|
|
53
|
+
return Object.freeze(value.map(item => {
|
|
54
|
+
const parsed = draft(item, true), row = item;
|
|
55
|
+
if (ids.has(parsed.id) || typeof row.revoked !== "boolean")
|
|
56
|
+
invalid();
|
|
57
|
+
ids.add(parsed.id);
|
|
58
|
+
const sourceRow = permissionRuleRow(row.source, ["kind"], ["sessionId", "savedAt", "label"]);
|
|
59
|
+
let source;
|
|
60
|
+
if (sourceRow.kind === "operator") {
|
|
61
|
+
permissionRuleRow(row.source, ["kind", "sessionId", "savedAt"]);
|
|
62
|
+
source = { kind: "operator", sessionId: text(sourceRow.sessionId, 256), savedAt: integer(sourceRow.savedAt) };
|
|
63
|
+
}
|
|
64
|
+
else if (sourceRow.kind === "user-import") {
|
|
65
|
+
permissionRuleRow(row.source, ["kind", "label"]);
|
|
66
|
+
source = { kind: "user-import", label: text(sourceRow.label, 512) };
|
|
67
|
+
}
|
|
68
|
+
else
|
|
69
|
+
invalid();
|
|
70
|
+
return Object.freeze({ ...parsed, source: Object.freeze(source), revision: integer(row.revision), revoked: row.revoked });
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
export function parsePermissionRulesSave(value) {
|
|
74
|
+
const row = permissionRuleRow(value, ["expectedRevision"], ["changes", "upsert", "revoke"]);
|
|
75
|
+
let changes;
|
|
76
|
+
if (row.changes !== undefined) {
|
|
77
|
+
const input = permissionRuleRow(row.changes, [], ["outsideReads", "webSearch", "webFetch"]);
|
|
78
|
+
const web = (value) => { const row = permissionRuleRow(value, ["enabled", "rule"]); if (typeof row.enabled !== "boolean")
|
|
79
|
+
invalid(); return Object.freeze({ enabled: row.enabled, rule: ruleAction(row.rule, true) }); };
|
|
80
|
+
changes = Object.freeze({ ...input.outsideReads === undefined ? {} : { outsideReads: ruleAction(input.outsideReads, true) },
|
|
81
|
+
...input.webSearch === undefined ? {} : { webSearch: web(input.webSearch) }, ...input.webFetch === undefined ? {} : { webFetch: web(input.webFetch) } });
|
|
82
|
+
}
|
|
83
|
+
if (row.upsert !== undefined && (!Array.isArray(row.upsert) || row.upsert.length > 1024)
|
|
84
|
+
|| row.revoke !== undefined && (!Array.isArray(row.revoke) || row.revoke.length > 1024))
|
|
85
|
+
invalid();
|
|
86
|
+
const upsert = row.upsert?.map(item => draft(item)), revoke = row.revoke?.map(item => text(item, 256));
|
|
87
|
+
const ids = [...upsert?.map(item => item.id) ?? [], ...revoke ?? []];
|
|
88
|
+
if (ids.length !== new Set(ids).size || ids.length === 0 && (changes === undefined || Object.keys(changes).length === 0))
|
|
89
|
+
invalid();
|
|
90
|
+
return Object.freeze({ expectedRevision: permissionRevision(row.expectedRevision), ...changes === undefined ? {} : { changes },
|
|
91
|
+
...upsert === undefined ? {} : { upsert: Object.freeze(upsert) }, ...revoke === undefined ? {} : { revoke: Object.freeze(revoke) } });
|
|
92
|
+
}
|
|
93
|
+
/** Backend derives provenance from its verified Host authority, never from a client rule. */
|
|
94
|
+
export function applyPermissionRulesSave(previous, input, source) {
|
|
95
|
+
const request = parsePermissionRulesSave(input);
|
|
96
|
+
if (permissionRevision(previous.revision) !== request.expectedRevision)
|
|
97
|
+
throw new PermissionRefusal("stale");
|
|
98
|
+
const policy = resolvePermissionControl(previous.policy), rules = new Map(policy.rules.map(rule => [rule.id, rule]));
|
|
99
|
+
for (const id of request.revoke ?? []) {
|
|
100
|
+
const existing = rules.get(id);
|
|
101
|
+
if (existing === undefined)
|
|
102
|
+
throw new PermissionRefusal("not-found");
|
|
103
|
+
rules.set(id, { ...existing, revision: integer(existing.revision + 1), revoked: true, source });
|
|
104
|
+
}
|
|
105
|
+
for (const rule of request.upsert ?? [])
|
|
106
|
+
rules.set(rule.id, { ...rule, revision: integer((rules.get(rule.id)?.revision ?? 0) + 1), revoked: false, source });
|
|
107
|
+
return resolvePermissionControl({ ...policy, ...request.changes, rules: [...rules.values()] });
|
|
108
|
+
}
|
|
109
|
+
export function operatorPermissionRulesSource(authority) {
|
|
110
|
+
authority.signal.throwIfAborted();
|
|
111
|
+
authority.assertCurrent();
|
|
112
|
+
return Object.freeze({ kind: "operator", sessionId: authority.root.id, savedAt: Date.now() });
|
|
113
|
+
}
|
|
114
|
+
/** Import paths explicitly re-stamp all records; imported operator claims are not ACKs. */
|
|
115
|
+
export function importPermissionRules(input, label, revision) {
|
|
116
|
+
return parsePermissionRules(input.map(item => ({ ...draft(item), source: { kind: "user-import", label: text(label, 512) }, revision: integer(revision), revoked: false })));
|
|
117
|
+
}
|
|
118
|
+
/** In-process protocol owned by A's single CAS backend. No file watcher or persistence. */
|
|
119
|
+
export class PermissionRulesRuntimeSync {
|
|
120
|
+
revoke;
|
|
121
|
+
snapshot;
|
|
122
|
+
savedRevision;
|
|
123
|
+
state = "synced";
|
|
124
|
+
update;
|
|
125
|
+
lifetime = new AbortController();
|
|
126
|
+
retired = false;
|
|
127
|
+
mounted;
|
|
128
|
+
desiredEnabled;
|
|
129
|
+
constructor(initial, revoke) {
|
|
130
|
+
this.revoke = revoke;
|
|
131
|
+
this.snapshot = this.validate(initial);
|
|
132
|
+
this.savedRevision = initial.revision;
|
|
133
|
+
this.mounted = initial.policy.enabled;
|
|
134
|
+
this.desiredEnabled = initial.policy.enabled;
|
|
135
|
+
}
|
|
136
|
+
validate(value) {
|
|
137
|
+
const revision = permissionRevision(value.revision), policy = resolvePermissionControl(value.policy);
|
|
138
|
+
return Object.freeze({ revision, policy });
|
|
139
|
+
}
|
|
140
|
+
status() {
|
|
141
|
+
return Object.freeze({ savedRevision: this.savedRevision, runtimeRevision: this.snapshot.revision,
|
|
142
|
+
state: this.state, mounted: this.mounted, restartRequired: this.desiredEnabled !== this.mounted });
|
|
143
|
+
}
|
|
144
|
+
getPolicy() {
|
|
145
|
+
if (this.retired || this.state !== "synced" || this.lifetime.signal.aborted)
|
|
146
|
+
throw new PermissionRefusal("unavailable");
|
|
147
|
+
return this.snapshot;
|
|
148
|
+
}
|
|
149
|
+
get signal() { return this.lifetime.signal; }
|
|
150
|
+
/** Source backends override this entry; consumers never reconcile storage themselves. */
|
|
151
|
+
async refresh() { return this.getPolicy(); }
|
|
152
|
+
invalidate() {
|
|
153
|
+
if (this.retired)
|
|
154
|
+
return;
|
|
155
|
+
this.state = "unsynced";
|
|
156
|
+
this.update = undefined;
|
|
157
|
+
this.lifetime.abort();
|
|
158
|
+
if (!this.retired)
|
|
159
|
+
this.revoke();
|
|
160
|
+
}
|
|
161
|
+
assertLive() { if (this.retired)
|
|
162
|
+
throw new PermissionRefusal("unavailable"); }
|
|
163
|
+
begin(expectedRevision) {
|
|
164
|
+
this.assertLive();
|
|
165
|
+
if (this.state === "updating" || permissionRevision(expectedRevision) !== this.savedRevision)
|
|
166
|
+
throw new PermissionRefusal("stale");
|
|
167
|
+
const update = Object.freeze({ expectedRevision, generation: {} });
|
|
168
|
+
this.update = update;
|
|
169
|
+
this.state = "updating";
|
|
170
|
+
this.lifetime.abort();
|
|
171
|
+
try {
|
|
172
|
+
this.revoke();
|
|
173
|
+
this.check(update);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
if (this.update === update) {
|
|
177
|
+
this.state = "unsynced";
|
|
178
|
+
this.update = undefined;
|
|
179
|
+
}
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
return update;
|
|
183
|
+
}
|
|
184
|
+
check(update) { this.assertLive(); if (update !== this.update)
|
|
185
|
+
throw new PermissionRefusal("stale"); }
|
|
186
|
+
/** Called only after CAS succeeded. notify must acknowledge all runtime revocation consumers. */
|
|
187
|
+
async commit(update, saved, notify) {
|
|
188
|
+
this.check(update);
|
|
189
|
+
const snapshot = this.validate(saved);
|
|
190
|
+
this.savedRevision = snapshot.revision;
|
|
191
|
+
this.desiredEnabled = snapshot.policy.enabled;
|
|
192
|
+
try {
|
|
193
|
+
await notify(snapshot);
|
|
194
|
+
this.check(update);
|
|
195
|
+
this.snapshot = snapshot;
|
|
196
|
+
this.state = "synced";
|
|
197
|
+
this.update = undefined;
|
|
198
|
+
this.lifetime = new AbortController();
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
if (this.update === update) {
|
|
202
|
+
this.state = "unsynced";
|
|
203
|
+
this.update = undefined;
|
|
204
|
+
}
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
return this.status();
|
|
208
|
+
}
|
|
209
|
+
/** CAS failure or failed notification: reread authoritative storage, never publish the rejected request. */
|
|
210
|
+
async recover(update, authoritative, notify) {
|
|
211
|
+
this.assertLive();
|
|
212
|
+
if (update !== undefined)
|
|
213
|
+
this.check(update);
|
|
214
|
+
else if (this.state !== "unsynced")
|
|
215
|
+
throw new PermissionRefusal("stale");
|
|
216
|
+
const snapshot = this.validate(authoritative);
|
|
217
|
+
const recovery = Object.freeze({ expectedRevision: snapshot.revision, generation: {} });
|
|
218
|
+
this.update = recovery;
|
|
219
|
+
this.state = "updating";
|
|
220
|
+
try {
|
|
221
|
+
this.lifetime.abort();
|
|
222
|
+
this.check(recovery);
|
|
223
|
+
this.revoke();
|
|
224
|
+
this.check(recovery);
|
|
225
|
+
this.savedRevision = snapshot.revision;
|
|
226
|
+
this.desiredEnabled = snapshot.policy.enabled;
|
|
227
|
+
await notify(snapshot);
|
|
228
|
+
this.check(recovery);
|
|
229
|
+
this.snapshot = snapshot;
|
|
230
|
+
this.state = "synced";
|
|
231
|
+
this.update = undefined;
|
|
232
|
+
this.lifetime = new AbortController();
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
if (this.update === recovery) {
|
|
236
|
+
this.state = "unsynced";
|
|
237
|
+
this.update = undefined;
|
|
238
|
+
}
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
241
|
+
return this.status();
|
|
242
|
+
}
|
|
243
|
+
retire() {
|
|
244
|
+
if (this.retired)
|
|
245
|
+
return;
|
|
246
|
+
this.retired = true;
|
|
247
|
+
this.state = "unsynced";
|
|
248
|
+
this.update = undefined;
|
|
249
|
+
this.lifetime.abort();
|
|
250
|
+
this.revoke();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
export function intersectPermissionActions(actions) {
|
|
254
|
+
return actions.includes("deny") ? "deny" : actions.includes("ask") ? "ask" : actions.includes("allow") ? "allow" : "inherit";
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=permission-rules.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
import type { PermissionRule } from "./permission-rules.js";
|
|
3
|
+
export type PermissionRuleAction = "inherit" | "allow" | "ask" | "deny";
|
|
4
|
+
export interface PermissionWebPolicy {
|
|
5
|
+
readonly enabled: boolean;
|
|
6
|
+
readonly rule: PermissionRuleAction;
|
|
7
|
+
}
|
|
8
|
+
export interface NativeCommandEntry {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly mode: "ask" | "allow";
|
|
11
|
+
readonly match: {
|
|
12
|
+
readonly tool: "bash" | "pwsh";
|
|
13
|
+
readonly executable: string;
|
|
14
|
+
readonly subcommand?: string;
|
|
15
|
+
readonly args: readonly string[];
|
|
16
|
+
readonly workingDirectory: string;
|
|
17
|
+
};
|
|
18
|
+
readonly sandboxMode: "workspace-write" | "danger-full-access";
|
|
19
|
+
}
|
|
20
|
+
export interface NativeCommandsSettings {
|
|
21
|
+
readonly enabled: boolean;
|
|
22
|
+
readonly entries: readonly NativeCommandEntry[];
|
|
23
|
+
}
|
|
24
|
+
/** Only enabled is deployment-only. Rules are independently synchronized at runtime. */
|
|
25
|
+
export interface PermissionControlSettings {
|
|
26
|
+
readonly enabled: boolean;
|
|
27
|
+
readonly outsideReads: PermissionRuleAction;
|
|
28
|
+
readonly webSearch: PermissionWebPolicy;
|
|
29
|
+
readonly webFetch: PermissionWebPolicy;
|
|
30
|
+
readonly rules: readonly PermissionRule[];
|
|
31
|
+
readonly nativeCommands: NativeCommandsSettings;
|
|
32
|
+
}
|
|
33
|
+
export interface PermissionControlSchemaInput {
|
|
34
|
+
readonly enabled?: boolean;
|
|
35
|
+
readonly outsideReads?: PermissionRuleAction;
|
|
36
|
+
readonly webSearch?: Partial<PermissionWebPolicy>;
|
|
37
|
+
readonly webFetch?: Partial<PermissionWebPolicy>;
|
|
38
|
+
readonly rules?: readonly PermissionRule[];
|
|
39
|
+
readonly nativeCommands?: Partial<NativeCommandsSettings>;
|
|
40
|
+
}
|
|
41
|
+
export declare function parseNativeCommands(input?: unknown): NativeCommandsSettings;
|
|
42
|
+
export declare const DEFAULT_PERMISSION_CONTROL: PermissionControlSettings;
|
|
43
|
+
export declare const permissionControlSchema: z<PermissionControlSettings>;
|
|
44
|
+
export declare function resolvePermissionControl(input?: PermissionControlSchemaInput): PermissionControlSettings;
|
|
45
|
+
//# sourceMappingURL=permission-settings.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
import { parsePermissionRules, permissionRuleRow } from "./permission-rules.js";
|
|
3
|
+
import { PermissionRefusal } from "./permission-errors.js";
|
|
4
|
+
export function parseNativeCommands(input = {}) {
|
|
5
|
+
const row = permissionRuleRow(input, [], ["enabled", "entries"]);
|
|
6
|
+
if (row.enabled !== undefined && typeof row.enabled !== "boolean" || row.entries !== undefined && (!Array.isArray(row.entries) || row.entries.length > 1024))
|
|
7
|
+
throw new PermissionRefusal("validation");
|
|
8
|
+
const text = (value) => { if (typeof value !== "string" || value.trim().length === 0 || value.length > 32768 || value.includes("\0"))
|
|
9
|
+
throw new PermissionRefusal("validation"); return value; };
|
|
10
|
+
const ids = new Set();
|
|
11
|
+
const entries = (row.entries ?? []).map(value => {
|
|
12
|
+
const entry = permissionRuleRow(value, ["id", "mode", "match", "sandboxMode"]), match = permissionRuleRow(entry.match, ["tool", "executable", "args", "workingDirectory"], ["subcommand"]);
|
|
13
|
+
const id = text(entry.id), cwd = text(match.workingDirectory);
|
|
14
|
+
if (ids.has(id) || !["ask", "allow"].includes(entry.mode) || !["bash", "pwsh"].includes(match.tool)
|
|
15
|
+
|| !["workspace-write", "danger-full-access"].includes(entry.sandboxMode)
|
|
16
|
+
// Wire paths belong to the Host, not the browser's platform. The Host validates and canonicalizes them before use.
|
|
17
|
+
|| !/^(?:\/|[a-z]:[\\/]|\\\\[^\\/]+[\\/][^\\/]+(?:[\\/]|$))/iu.test(cwd) || !Array.isArray(match.args))
|
|
18
|
+
throw new PermissionRefusal("validation");
|
|
19
|
+
ids.add(id);
|
|
20
|
+
return Object.freeze({ id, mode: entry.mode, sandboxMode: entry.sandboxMode, match: Object.freeze({
|
|
21
|
+
tool: match.tool, executable: text(match.executable), ...match.subcommand === undefined ? {} : { subcommand: text(match.subcommand) },
|
|
22
|
+
args: Object.freeze(match.args.map(text)), workingDirectory: cwd,
|
|
23
|
+
}) });
|
|
24
|
+
});
|
|
25
|
+
return Object.freeze({ enabled: row.enabled ?? false, entries: Object.freeze(entries) });
|
|
26
|
+
}
|
|
27
|
+
const nativeCommands = z.object({ enabled: z.boolean().default(false), entries: z.array(z.object({
|
|
28
|
+
id: z.string().required(), mode: z.union(["ask", "allow"]).required(), match: z.object({
|
|
29
|
+
tool: z.union(["bash", "pwsh"]).required(), executable: z.string().required(), subcommand: z.string(), args: z.array(z.string()).required(), workingDirectory: z.string().required(),
|
|
30
|
+
}).required(), sandboxMode: z.union(["workspace-write", "danger-full-access"]).required(),
|
|
31
|
+
})).default([]) });
|
|
32
|
+
const webDefault = Object.freeze({ enabled: true, rule: "inherit" });
|
|
33
|
+
export const DEFAULT_PERMISSION_CONTROL = Object.freeze({ enabled: true, outsideReads: "inherit", webSearch: webDefault, webFetch: webDefault, rules: Object.freeze([]), nativeCommands: parseNativeCommands() });
|
|
34
|
+
const action = () => z.union(["inherit", "allow", "ask", "deny"]).default("inherit");
|
|
35
|
+
const web = () => z.object({ enabled: z.boolean().default(true), rule: action() }).default({});
|
|
36
|
+
export const permissionControlSchema = z.transform(z.object({ enabled: z.boolean().default(true), outsideReads: action(), webSearch: web(), webFetch: web(),
|
|
37
|
+
nativeCommands, rules: z.array(z.any()).default([]) }), input => Object.freeze({ ...input, webSearch: Object.freeze(input.webSearch), webFetch: Object.freeze(input.webFetch), rules: parsePermissionRules(input.rules), nativeCommands: parseNativeCommands(input.nativeCommands) }), true);
|
|
38
|
+
export function resolvePermissionControl(input = {}) {
|
|
39
|
+
permissionRuleRow(input, [], ["enabled", "outsideReads", "webSearch", "webFetch", "rules", "nativeCommands"]);
|
|
40
|
+
if (Object.hasOwn(input, "nativeCommands"))
|
|
41
|
+
parseNativeCommands(input.nativeCommands);
|
|
42
|
+
for (const web of [input.webSearch, input.webFetch])
|
|
43
|
+
if (web !== undefined)
|
|
44
|
+
permissionRuleRow(web, [], ["enabled", "rule"]);
|
|
45
|
+
const parsed = permissionControlSchema(input);
|
|
46
|
+
return Object.freeze({ ...parsed, webSearch: Object.freeze(parsed.webSearch), webFetch: Object.freeze(parsed.webFetch), rules: parsePermissionRules(parsed.rules) });
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=permission-settings.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ShellDialect } from "./shell-command.js";
|
|
2
|
+
import type { ToolExecution } from "@deepseek-ai/dsh-tools";
|
|
3
|
+
export type PermissionReadExecutable = "git" | "echo" | "printf" | "pwd" | "ls" | "cat" | "head" | "tail" | "wc" | "rg" | "grep" | "write-output" | "get-location" | "get-childitem" | "get-content";
|
|
4
|
+
/** Host-only native resolution proof for the actual execution realm and environment. */
|
|
5
|
+
export interface PermissionShellReadCapability {
|
|
6
|
+
readonly signal: AbortSignal;
|
|
7
|
+
/** Return a canonical implementation only after verifying actual executable/cmdlet identity and resolution in this cwd/Agent realm.
|
|
8
|
+
* The effective environment/configuration must exclude external preprocessors, pagers, hooks, fsmonitor, textconv and other dynamic handlers for these reads. */
|
|
9
|
+
resolveExecutable(token: string, workingDirectory: string, execution?: Readonly<ToolExecution>): PermissionReadExecutable | undefined;
|
|
10
|
+
/** Pure check of the same native executable/environment generation; not another SDK/third-party guard. */
|
|
11
|
+
assertCurrent(execution: Readonly<ToolExecution>): void;
|
|
12
|
+
}
|
|
13
|
+
/** Supplied by the trusted registration adapter, not inferred from a display name. */
|
|
14
|
+
export interface PermissionShellIdentity {
|
|
15
|
+
readonly executable: string;
|
|
16
|
+
readonly dialect: ShellDialect;
|
|
17
|
+
readonly commandField: string;
|
|
18
|
+
readonly cwdField?: string;
|
|
19
|
+
readonly readCapability?: PermissionShellReadCapability;
|
|
20
|
+
}
|
|
21
|
+
export type PermissionEffect = "read" | "local-write" | "external-write" | "destructive" | "unknown";
|
|
22
|
+
export interface PermissionOperation {
|
|
23
|
+
readonly effect: PermissionEffect;
|
|
24
|
+
readonly operations: readonly string[];
|
|
25
|
+
readonly rememberable: boolean;
|
|
26
|
+
readonly executable: string;
|
|
27
|
+
readonly command: string;
|
|
28
|
+
readonly workingDirectory: string;
|
|
29
|
+
}
|
|
30
|
+
/** Classification supports exact-operation authorization, not filesystem or network isolation. */
|
|
31
|
+
export declare function classifyPermissionShell(identity: PermissionShellIdentity, args: unknown, cwd: string, execution?: Readonly<ToolExecution>): PermissionOperation;
|
|
32
|
+
export interface PermissionShellReadPaths {
|
|
33
|
+
readonly workingDirectory: string;
|
|
34
|
+
readonly paths: readonly string[];
|
|
35
|
+
}
|
|
36
|
+
/** Typed DSMM extraction, not an SDK operand field. Undefined means exact native ask, not inside. */
|
|
37
|
+
export declare function parsePermissionShellReadPaths(identity: PermissionShellIdentity, args: unknown, cwd: string, execution?: Readonly<ToolExecution>): PermissionShellReadPaths | undefined;
|
|
38
|
+
//# sourceMappingURL=permission-shell.d.ts.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { classifyKnownGitWrite, parseShellCommand } from "./shell-command.js";
|
|
2
|
+
import { isAbsolute, resolve } from "node:path";
|
|
3
|
+
const reads = new Set(["echo", "printf", "pwd", "ls", "cat", "head", "tail", "wc", "rg", "grep", "write-output", "get-location", "get-childitem", "get-content"]);
|
|
4
|
+
const localWrites = new Set(["mkdir", "touch", "cp", "mv", "tee", "new-item", "set-content", "add-content", "copy-item", "move-item"]);
|
|
5
|
+
const destroys = new Set(["rm", "rmdir", "del", "erase", "remove-item", "format-volume"]);
|
|
6
|
+
const rank = { read: 0, "local-write": 1, "external-write": 2, destructive: 3, unknown: 4 };
|
|
7
|
+
const base = (name) => name.replace(/^.*[\\/]/u, "").replace(/\.exe$/iu, "").toLowerCase();
|
|
8
|
+
const readFlags = {
|
|
9
|
+
echo: ["-n", "-e", "-E"], printf: [], pwd: ["-L", "-P"], ls: ["-l", "-a", "-A", "-h", "-1", "--color=never"],
|
|
10
|
+
cat: ["-n", "-b", "-s", "-v", "-e", "-t"], head: [], tail: [], wc: ["-l", "-w", "-c", "-m", "-L"],
|
|
11
|
+
rg: ["-n", "--line-number", "-i", "--ignore-case", "-F", "--fixed-strings", "-l", "--files-with-matches", "--files", "--no-config", "--hidden", "--no-ignore", "--color=never"],
|
|
12
|
+
grep: ["-n", "--line-number", "-i", "--ignore-case", "-F", "--fixed-strings", "-E", "--extended-regexp", "-r", "-R", "-l", "-c", "-v"],
|
|
13
|
+
"write-output": ["-noenumerate"], "get-location": [], "get-childitem": ["-recurse", "-force", "-name", "-file", "-directory"], "get-content": ["-raw"],
|
|
14
|
+
};
|
|
15
|
+
const gitReadFlags = {
|
|
16
|
+
status: ["-s", "--short", "-b", "--branch", "--porcelain", "--porcelain=v1", "--porcelain=v2"],
|
|
17
|
+
diff: ["--no-ext-diff", "--no-textconv", "--stat", "--name-only", "--name-status", "--cached", "--staged", "--quiet", "--exit-code"],
|
|
18
|
+
log: ["--oneline", "--no-decorate", "--no-color", "--no-ext-diff", "--no-textconv"],
|
|
19
|
+
show: ["--stat", "--name-only", "--name-status", "--no-color", "--no-ext-diff", "--no-textconv"],
|
|
20
|
+
"ls-files": ["--cached", "--stage", "--others", "--exclude-standard"], "rev-parse": ["--show-toplevel", "--git-dir", "--is-inside-work-tree", "--verify"],
|
|
21
|
+
"rev-list": ["--count", "--all"], describe: ["--tags", "--always", "--abbrev=0"], version: [],
|
|
22
|
+
};
|
|
23
|
+
function knownReadArguments(command, args) {
|
|
24
|
+
let flags, operands = args;
|
|
25
|
+
if (command === "git") {
|
|
26
|
+
if (operands[0] === "--no-pager")
|
|
27
|
+
operands = operands.slice(1);
|
|
28
|
+
const subcommand = operands[0];
|
|
29
|
+
if (subcommand === undefined || !Object.hasOwn(gitReadFlags, subcommand))
|
|
30
|
+
return false;
|
|
31
|
+
flags = gitReadFlags[subcommand];
|
|
32
|
+
operands = operands.slice(1);
|
|
33
|
+
}
|
|
34
|
+
else
|
|
35
|
+
flags = readFlags[command];
|
|
36
|
+
const cmdlet = command.startsWith("get-") || command === "write-output";
|
|
37
|
+
for (let index = 0; index < operands.length; index++) {
|
|
38
|
+
const argument = operands[index], option = cmdlet ? argument.toLowerCase() : argument;
|
|
39
|
+
if (!cmdlet && option === "--")
|
|
40
|
+
return true;
|
|
41
|
+
if (!argument.startsWith("-"))
|
|
42
|
+
continue;
|
|
43
|
+
if (flags.includes(option))
|
|
44
|
+
continue;
|
|
45
|
+
if (cmdlet && ["get-content", "get-childitem"].includes(command) && ["-path", "-literalpath"].includes(option) && operands[index + 1] !== undefined) {
|
|
46
|
+
index++;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
/** Classification supports exact-operation authorization, not filesystem or network isolation. */
|
|
54
|
+
export function classifyPermissionShell(identity, args, cwd, execution) {
|
|
55
|
+
const row = typeof args === "object" && args !== null && !Array.isArray(args) ? args : {};
|
|
56
|
+
const command = typeof row[identity.commandField] === "string" ? row[identity.commandField] : "";
|
|
57
|
+
const explicitCwd = identity.cwdField !== undefined && typeof row[identity.cwdField] === "string" ? row[identity.cwdField] : undefined;
|
|
58
|
+
const workingDirectory = explicitCwd === undefined ? cwd : cwd !== "" && !isAbsolute(explicitCwd) ? resolve(cwd, explicitCwd) : explicitCwd;
|
|
59
|
+
let effect = "read";
|
|
60
|
+
const operations = [];
|
|
61
|
+
// Dynamic evaluation, interpolation, script blocks, wrappers and malformed quotes
|
|
62
|
+
// remain exact-once asks. No command family wildcard is created from them.
|
|
63
|
+
// PowerShell smart quotes are lexical delimiters unsupported by the ASCII tokenizer.
|
|
64
|
+
const unsupportedQuotes = identity.dialect === "powershell" && /[\u2018-\u201f]/u.test(command);
|
|
65
|
+
const dynamic = unsupportedQuotes || command === "" || /[$`{}()]/u.test(command) || /\b(?:eval|exec|invoke-expression|iex|cmd|pwsh|powershell|bash|sh|zsh|env|sudo|node|python)\b/iu.test(command)
|
|
66
|
+
|| (command.match(/'/gu)?.length ?? 0) % 2 !== 0 || (command.match(/"/gu)?.length ?? 0) % 2 !== 0;
|
|
67
|
+
for (const segment of parseShellCommand(command, identity.dialect)) {
|
|
68
|
+
const token = segment.words[0] ?? "";
|
|
69
|
+
const trusted = identity.readCapability?.signal.aborted === false ? identity.readCapability.resolveExecutable(token, workingDirectory, execution) : undefined;
|
|
70
|
+
const name = trusted ?? base(token);
|
|
71
|
+
let next = "unknown", operation = name;
|
|
72
|
+
if (name === "git") {
|
|
73
|
+
const write = classifyKnownGitWrite(segment.words.map(word => JSON.stringify(word)).join(" "), identity.dialect);
|
|
74
|
+
const sub = segment.words[1]?.toLowerCase();
|
|
75
|
+
operation = `git:${write ?? sub ?? "unknown"}`;
|
|
76
|
+
if (write !== undefined) {
|
|
77
|
+
next = write === "push" ? "external-write" : ["clean", "reset --hard", "rm", "stash drop", "stash clear"].includes(write) ? "destructive" : "local-write";
|
|
78
|
+
}
|
|
79
|
+
else if (trusted === "git" && knownReadArguments("git", segment.words.slice(1)))
|
|
80
|
+
next = "read";
|
|
81
|
+
if (segment.words.slice(1).some(word => /^-(?:c|C)(?:.+)?$/u.test(word) || /^--(?:config-env|exec-path|git-dir|work-tree)(?:=|$)/u.test(word)))
|
|
82
|
+
next = "unknown";
|
|
83
|
+
}
|
|
84
|
+
else if (reads.has(name) && trusted !== undefined && knownReadArguments(trusted, segment.words.slice(1)))
|
|
85
|
+
next = "read";
|
|
86
|
+
else if (localWrites.has(name))
|
|
87
|
+
next = "local-write";
|
|
88
|
+
else if (destroys.has(name))
|
|
89
|
+
next = "destructive";
|
|
90
|
+
if (/[\\/]/u.test(token) && trusted === undefined)
|
|
91
|
+
next = "unknown";
|
|
92
|
+
if (segment.tokens.some(token => token.kind === "operator" && token.value.includes(">")) && rank[next] < rank["local-write"])
|
|
93
|
+
next = "local-write";
|
|
94
|
+
if (rank[next] > rank[effect])
|
|
95
|
+
effect = next;
|
|
96
|
+
operations.push(operation);
|
|
97
|
+
}
|
|
98
|
+
if (dynamic || operations.length === 0)
|
|
99
|
+
effect = "unknown";
|
|
100
|
+
return Object.freeze({ effect, operations: Object.freeze(operations), rememberable: effect !== "unknown" && workingDirectory !== "", executable: identity.executable, command, workingDirectory });
|
|
101
|
+
}
|
|
102
|
+
/** Typed DSMM extraction, not an SDK operand field. Undefined means exact native ask, not inside. */
|
|
103
|
+
export function parsePermissionShellReadPaths(identity, args, cwd, execution) {
|
|
104
|
+
const operation = classifyPermissionShell(identity, args, cwd, execution);
|
|
105
|
+
if (operation.effect !== "read" || operation.workingDirectory === "" || identity.readCapability === undefined)
|
|
106
|
+
return undefined;
|
|
107
|
+
if (/[|<>]/u.test(operation.command))
|
|
108
|
+
return undefined;
|
|
109
|
+
const paths = [];
|
|
110
|
+
for (const segment of parseShellCommand(operation.command, identity.dialect)) {
|
|
111
|
+
// Redirects, pipelines, wildcard expansion and Git object/pathspec semantics require an exact question.
|
|
112
|
+
if (segment.tokens.some(token => token.kind === "operator" && ![";", "&&"].includes(token.value)))
|
|
113
|
+
return undefined;
|
|
114
|
+
const command = identity.readCapability.resolveExecutable(segment.words[0], operation.workingDirectory, execution);
|
|
115
|
+
if (command === undefined || command === "git")
|
|
116
|
+
return undefined;
|
|
117
|
+
if (["echo", "printf", "pwd", "write-output", "get-location"].includes(command))
|
|
118
|
+
continue;
|
|
119
|
+
const operands = [];
|
|
120
|
+
let options = true;
|
|
121
|
+
for (const word of segment.words.slice(1)) {
|
|
122
|
+
if (word === "--" && options) {
|
|
123
|
+
options = false;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (options && word.startsWith("-"))
|
|
127
|
+
continue;
|
|
128
|
+
operands.push(word);
|
|
129
|
+
}
|
|
130
|
+
if (command === "rg" || command === "grep") {
|
|
131
|
+
if (!(command === "rg" && segment.words.includes("--files"))) {
|
|
132
|
+
if (operands.length === 0)
|
|
133
|
+
return undefined;
|
|
134
|
+
operands.shift();
|
|
135
|
+
}
|
|
136
|
+
if (operands.length === 0)
|
|
137
|
+
operands.push(".");
|
|
138
|
+
}
|
|
139
|
+
else if (["ls", "get-childitem"].includes(command) && operands.length === 0)
|
|
140
|
+
operands.push(".");
|
|
141
|
+
// Missing file operands use stdin, which may be supplied by unparsed shell syntax.
|
|
142
|
+
else if (operands.length === 0)
|
|
143
|
+
return undefined;
|
|
144
|
+
if (operands.some(path => path === "-" || /[*?\[\]]/u.test(path) || /^~(?:[\\/]|$)/u.test(path)))
|
|
145
|
+
return undefined;
|
|
146
|
+
paths.push(...operands);
|
|
147
|
+
}
|
|
148
|
+
return Object.freeze({ workingDirectory: operation.workingDirectory, paths: Object.freeze(paths) });
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=permission-shell.js.map
|