@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,329 @@
|
|
|
1
|
+
import { dirname, extname, isAbsolute, join, relative, sep } from "node:path";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
|
+
import { isDeepStrictEqual } from "node:util";
|
|
6
|
+
import { SourceReadset, jsonDocument, refuse } from "./cold-profile-sources.mjs";
|
|
7
|
+
|
|
8
|
+
export const BASE_BUNDLE = "@deepseek-ai/dsh-base";
|
|
9
|
+
export const MODULE_REPLACEMENTS = Object.freeze({
|
|
10
|
+
"@deepseek-ai/dsh-settings": "@dsmm/dsmm/managed-settings",
|
|
11
|
+
"@deepseek-ai/dsh-llm": "@dsmm/dsmm/llm-runtime",
|
|
12
|
+
"@deepseek-ai/dsh-subagent": "@dsmm/dsmm/subagent-runtime",
|
|
13
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "@dsmm/dsmm/session-persistence",
|
|
14
|
+
"@deepseek-ai/dsh-tool-bash": "@dsmm/dsmm/permission-bash",
|
|
15
|
+
"@deepseek-ai/dsh-tool-pwsh": "@dsmm/dsmm/permission-pwsh",
|
|
16
|
+
"@deepseek-ai/dsh-tool-fs": "@dsmm/dsmm/permission-fs",
|
|
17
|
+
"@deepseek-ai/dsh-tool-fs-search": "@dsmm/dsmm/permission-fs-search",
|
|
18
|
+
"@deepseek-ai/dsh-tool-web": "@dsmm/dsmm/permission-web",
|
|
19
|
+
});
|
|
20
|
+
const nativeToolIds = new Map([
|
|
21
|
+
["@deepseek-ai/dsh-tool-fs", "tool-fs"],
|
|
22
|
+
["@deepseek-ai/dsh-tool-fs-search", "tool-fs-search"],
|
|
23
|
+
["@deepseek-ai/dsh-tool-web", "tool-web"],
|
|
24
|
+
]);
|
|
25
|
+
const projectedNativeTools = new Set([...nativeToolIds.keys()].map(name => MODULE_REPLACEMENTS[name]));
|
|
26
|
+
const nativeGroups = new Set(["cordis:group", "@deepseek-ai/cordis-plugin-group"]);
|
|
27
|
+
const nativeIncludes = new Set(["cordis:include", "@deepseek-ai/cordis-plugin-include"]);
|
|
28
|
+
const officialLoop = "@deepseek-ai/dsh-agent-loop";
|
|
29
|
+
const officialPiAi = "@deepseek-ai/dsh-llm-pi-ai";
|
|
30
|
+
const object = value => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
31
|
+
const under = (root, filename) => {
|
|
32
|
+
const path = relative(root, filename);
|
|
33
|
+
return path === "" || (!path.startsWith(`..${sep}`) && path !== ".." && !isAbsolute(path));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function entryWalk(rows, visit) {
|
|
37
|
+
if (!Array.isArray(rows)) refuse("UNSUPPORTED_ENTRY_TREE");
|
|
38
|
+
for (const row of rows) {
|
|
39
|
+
if (!object(row) || typeof row.name !== "string") refuse("UNSUPPORTED_ENTRY_TREE");
|
|
40
|
+
visit(row);
|
|
41
|
+
if (nativeGroups.has(row.name)) entryWalk(row.config, visit);
|
|
42
|
+
else if (row.group) refuse("UNSUPPORTED_GROUP_CARRIER");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Mutates only approved, original base insertion declarations, never selector names. */
|
|
47
|
+
function projectBase(patches, { migrateShell, migrateSubagent, migrateSessionPersistence }) {
|
|
48
|
+
patches = structuredClone(patches);
|
|
49
|
+
const changed = new Map();
|
|
50
|
+
for (const patch of patches) {
|
|
51
|
+
if (!patch.insert) continue;
|
|
52
|
+
entryWalk(patch.insert, row => {
|
|
53
|
+
if (row.name === "@deepseek-ai/dsh-llm") {
|
|
54
|
+
if (row.id !== "llm" || changed.has(row.id)) refuse("AMBIGUOUS_BASE_LLM");
|
|
55
|
+
} else if (row.name === "@deepseek-ai/dsh-settings") {
|
|
56
|
+
if (row.id !== "settings" || changed.has(row.id)) refuse("AMBIGUOUS_BASE_SETTINGS");
|
|
57
|
+
} else if (row.name === "@deepseek-ai/dsh-subagent") {
|
|
58
|
+
if (!migrateSubagent) return;
|
|
59
|
+
if (row.id !== "subagent" || changed.has(row.id)) refuse("AMBIGUOUS_BASE_SUBAGENT");
|
|
60
|
+
} else if (row.name === "@deepseek-ai/dsh-session-persistence-jsonl") {
|
|
61
|
+
if (!migrateSessionPersistence) return;
|
|
62
|
+
if (row.id !== "session-persistence-jsonl" || changed.has(row.id)) refuse("AMBIGUOUS_BASE_SESSION_PERSISTENCE");
|
|
63
|
+
} else if (nativeToolIds.has(row.name)) {
|
|
64
|
+
if (row.id !== nativeToolIds.get(row.name)) refuse("AMBIGUOUS_BASE_NATIVE_TOOL");
|
|
65
|
+
} else if (!migrateShell || !["@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-pwsh"].includes(row.name)) return;
|
|
66
|
+
if (typeof row.id !== "string" || changed.has(row.id)) refuse("AMBIGUOUS_BASE_ENTRY");
|
|
67
|
+
const name = MODULE_REPLACEMENTS[row.name];
|
|
68
|
+
changed.set(row.id, { original: row.name, replacement: name });
|
|
69
|
+
row.name = name;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (!changed.has("llm")) refuse("ORIGINAL_BASE_LLM_REQUIRED");
|
|
73
|
+
if (!changed.has("settings")) refuse("ORIGINAL_BASE_SETTINGS_REQUIRED");
|
|
74
|
+
if (migrateSubagent && !changed.has("subagent")) refuse("ORIGINAL_BASE_SUBAGENT_REQUIRED");
|
|
75
|
+
if (migrateSessionPersistence && !changed.has("session-persistence-jsonl")) refuse("ORIGINAL_BASE_SESSION_PERSISTENCE_REQUIRED");
|
|
76
|
+
return { patches, changed };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function compose(boot, lists) {
|
|
80
|
+
const warnings = [];
|
|
81
|
+
const rows = boot.composeEntries(lists, warning => warnings.push(warning));
|
|
82
|
+
return { rows, warnings };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function expectedRows(rows, changed) {
|
|
86
|
+
const expected = structuredClone(rows);
|
|
87
|
+
const seen = new Set();
|
|
88
|
+
entryWalk(expected, row => {
|
|
89
|
+
const change = changed.get(row.id);
|
|
90
|
+
if (!change) return;
|
|
91
|
+
if (seen.has(row.id) || row.name !== change.original) refuse("ALTERNATE_ENTRY_OWNER");
|
|
92
|
+
seen.add(row.id);
|
|
93
|
+
row.name = change.replacement;
|
|
94
|
+
});
|
|
95
|
+
if (seen.size !== changed.size) refuse("MIGRATED_ENTRY_MISSING");
|
|
96
|
+
return expected;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function assertSelectorSemantics(composeAll, original, projected) {
|
|
100
|
+
const originalPatches = original.flat();
|
|
101
|
+
const projectedPatches = projected.flat();
|
|
102
|
+
// Prefix composition retains the SDK's single-pass patch index and detects
|
|
103
|
+
// changed match/skip decisions even when later patches mask their final values.
|
|
104
|
+
for (let count = 1; count <= originalPatches.length; count++) {
|
|
105
|
+
if (composeAll([originalPatches.slice(0, count)]).warnings.length !== composeAll([projectedPatches.slice(0, count)]).warnings.length) refuse("SELECTOR_SEMANTICS_CHANGED");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function llmRealm(row, inherited, position) {
|
|
110
|
+
if (row.intercept?.llm != null) refuse("UNSUPPORTED_LLM_TOPOLOGY");
|
|
111
|
+
if (!Object.hasOwn(row.isolate ?? {}, "llm")) return inherited;
|
|
112
|
+
const label = row.isolate.llm;
|
|
113
|
+
if (label == null || label === "") return "root";
|
|
114
|
+
if (label === true) return `local:${position}`;
|
|
115
|
+
if (typeof label === "string") return `named:${label}`;
|
|
116
|
+
refuse("UNSUPPORTED_LLM_TOPOLOGY");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** All declarations participate, including disabled/expression-gated rows; this is not activation proof. */
|
|
120
|
+
function assertLlmTopology(topology) {
|
|
121
|
+
if (topology.owners.length !== 1) refuse("ALTERNATE_LLM_OWNER");
|
|
122
|
+
if (topology.loops.length !== 1) refuse("OFFICIAL_AGENT_LOOP_REQUIRED");
|
|
123
|
+
const ownerRealm = topology.owners[0];
|
|
124
|
+
if ([...topology.loops, ...topology.providers, ...topology.consumers].some(realm => realm !== ownerRealm)) refuse("LLM_REALM_MISMATCH");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function dormantModule(row, options, readset, disabledBaseURL) {
|
|
128
|
+
if (!disabledBaseURL || row.group || !object(row.disabled) || typeof row.disabled.__jsExpr !== "string") return false;
|
|
129
|
+
const declarations = [
|
|
130
|
+
["dsh-tui-code-runtime", "@deepseek-ai/dsh-code-runtime-worker-thread", "@deepseek-ai/dsh-ptc-runtime-node", "code-runtime"],
|
|
131
|
+
["dsh-tui-agent-presets", "@deepseek-ai/dsh-agent-presets", "@deepseek-ai/dsh-agent-preset-registry", "agent-presets"],
|
|
132
|
+
];
|
|
133
|
+
for (const [id, name, capability, official] of declarations) {
|
|
134
|
+
if (row.id !== id || row.name !== name) continue;
|
|
135
|
+
const expression = `(() => {
|
|
136
|
+
const require = process.getBuiltinModule('node:module').createRequire(ctx.baseUrl)
|
|
137
|
+
try { require.resolve('${capability}/package.json'); return true } catch {}
|
|
138
|
+
return [...ctx.loader.entries()].some(entry => entry.options.id === '${official}' && entry.options.name === '${name}' && !entry.disabled)
|
|
139
|
+
})()`;
|
|
140
|
+
if (row.disabled.__jsExpr.trim() !== expression) return false;
|
|
141
|
+
return readset.dormantCapability(options, disabledBaseURL, `${capability}/package.json`);
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Native groups inherit context; native includes keep their own patch index and source base. */
|
|
147
|
+
function inspectTrees(rows, options, sdk, readset, baseURL, {
|
|
148
|
+
ancestors = new Set(), root = true, ids = new Set(), inheritedRealm = "root", prefix = "root",
|
|
149
|
+
topology = { owners: [], loops: [], providers: [], consumers: [] },
|
|
150
|
+
nativeToolSelection = { projected: [], unprojected: [] },
|
|
151
|
+
disabledBaseURL,
|
|
152
|
+
} = {}) {
|
|
153
|
+
if (!Array.isArray(rows)) refuse("UNSUPPORTED_ENTRY_TREE");
|
|
154
|
+
for (const [index, row] of rows.entries()) {
|
|
155
|
+
if (!object(row) || typeof row.name !== "string") refuse("UNSUPPORTED_ENTRY_TREE");
|
|
156
|
+
const position = `${prefix}/${index}`;
|
|
157
|
+
const slot = { path: position, ...(row.id ? { id: row.id } : {}), name: row.name };
|
|
158
|
+
if (nativeToolIds.has(row.name)) nativeToolSelection.unprojected.push(slot);
|
|
159
|
+
else if (projectedNativeTools.has(row.name)) nativeToolSelection.projected.push(slot);
|
|
160
|
+
if (row.id) {
|
|
161
|
+
if (ids.has(row.id)) refuse("DUPLICATE_ENTRY_ID");
|
|
162
|
+
ids.add(row.id);
|
|
163
|
+
}
|
|
164
|
+
if ((row.name === "@deepseek-ai/dsh-llm" || row.name === MODULE_REPLACEMENTS["@deepseek-ai/dsh-llm"]) && (!root || row.id !== "llm")) refuse("ALTERNATE_LLM_OWNER");
|
|
165
|
+
if ((row.id === "llm" || row.name.endsWith("/llm-runtime")) && row.name !== "@deepseek-ai/dsh-llm" && row.name !== MODULE_REPLACEMENTS["@deepseek-ai/dsh-llm"]) refuse("ALTERNATE_LLM_OWNER");
|
|
166
|
+
if (typeof row.inject !== "undefined" && row.inject !== null && !Array.isArray(row.inject) && !object(row.inject)) refuse("UNSUPPORTED_SCOPE_METADATA");
|
|
167
|
+
for (const key of ["isolate", "intercept"]) {
|
|
168
|
+
if (row[key] !== undefined && row[key] !== null && (!object(row[key]) || row[key].__jsExpr)) refuse("UNSUPPORTED_SCOPE_METADATA");
|
|
169
|
+
}
|
|
170
|
+
const realm = llmRealm(row, inheritedRealm, position);
|
|
171
|
+
if (row.name === "@deepseek-ai/dsh-llm" || row.name === MODULE_REPLACEMENTS["@deepseek-ai/dsh-llm"]) topology.owners.push(realm);
|
|
172
|
+
if (row.id === "agent-loop" || row.name === officialLoop || /(?:^|\/)agent-loop(?:$|\/)/.test(row.name)) {
|
|
173
|
+
if (row.name !== officialLoop || row.id !== "agent-loop") refuse("ALTERNATE_AGENT_LOOP");
|
|
174
|
+
topology.loops.push(realm);
|
|
175
|
+
}
|
|
176
|
+
if (row.id === "llm-pi-ai" && row.name !== officialPiAi) refuse("ALTERNATE_PROVIDER_OWNER");
|
|
177
|
+
if (row.name === officialPiAi || row.name.startsWith("@deepseek-ai/dsh-llm-deepseek-")) topology.providers.push(realm);
|
|
178
|
+
if ((Array.isArray(row.inject) && row.inject.includes("llm")) || (object(row.inject) && Object.hasOwn(row.inject, "llm"))) topology.consumers.push(realm);
|
|
179
|
+
if (!row.name.startsWith("cordis:") && !dormantModule(row, options, readset, disabledBaseURL)) {
|
|
180
|
+
let filename;
|
|
181
|
+
const local = row.name.startsWith("file:") || row.name.startsWith(".") || isAbsolute(row.name);
|
|
182
|
+
if (local) {
|
|
183
|
+
try { filename = isAbsolute(row.name) ? row.name : fileURLToPath(new URL(row.name, baseURL)); } catch { refuse("UNSUPPORTED_MODULE_SOURCE"); }
|
|
184
|
+
if (!options.sourceRoots.some(sourceRoot => under(sourceRoot, filename))) refuse("MODULE_OUTSIDE_SOURCE_SCOPE");
|
|
185
|
+
readset.module(filename);
|
|
186
|
+
} else {
|
|
187
|
+
const packageName = row.name.startsWith("@") ? row.name.split("/").slice(0, 2).join("/") : row.name.split("/")[0];
|
|
188
|
+
const entry = sdk.resolution.entries.find(entry => entry.name === packageName);
|
|
189
|
+
const require = createRequire(baseURL);
|
|
190
|
+
const localDir = (require.resolve.paths(packageName) ?? [])
|
|
191
|
+
.filter(searchPath => under(options.profileDir, searchPath))
|
|
192
|
+
.map(searchPath => join(searchPath, packageName))
|
|
193
|
+
.find(candidate => existsSync(join(candidate, "package.json")));
|
|
194
|
+
const packageDir = localDir ?? entry?.packageDir;
|
|
195
|
+
if (!packageDir) refuse("UNRESOLVED_ENTRY_MODULE");
|
|
196
|
+
const manifest = readset.package(join(packageDir, "package.json"));
|
|
197
|
+
try {
|
|
198
|
+
if (Object.hasOwn(manifest, "exports")) {
|
|
199
|
+
const targets = sdk.packageExports.exports(manifest, row.name, { conditions: ["node"] });
|
|
200
|
+
if (!targets || targets.length !== 1 || !targets[0].startsWith("./")) refuse("UNSUPPORTED_MODULE_EXPORT");
|
|
201
|
+
filename = join(packageDir, targets[0]);
|
|
202
|
+
} else {
|
|
203
|
+
const subpath = row.name.slice(packageName.length + 1);
|
|
204
|
+
filename = createRequire(join(packageDir, "package.json")).resolve(join(packageDir, subpath || manifest.main || "index.js"));
|
|
205
|
+
}
|
|
206
|
+
} catch {
|
|
207
|
+
refuse("UNRESOLVED_ENTRY_MODULE");
|
|
208
|
+
}
|
|
209
|
+
readset.module(filename, { packageSource: true });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (nativeGroups.has(row.name)) {
|
|
213
|
+
inspectTrees(row.config, options, sdk, readset, baseURL, { ancestors, root, ids, inheritedRealm: realm, prefix: position, topology, nativeToolSelection });
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (row.group) refuse("UNSUPPORTED_GROUP_CARRIER");
|
|
217
|
+
if (row.name === "@deepseek-ai/dsh-agent-preset") {
|
|
218
|
+
if (!object(row.config) || !Array.isArray(row.config.plugins)) refuse("UNSUPPORTED_PRESET_PLUGINS");
|
|
219
|
+
inspectTrees(row.config.plugins, options, sdk, readset, baseURL, {
|
|
220
|
+
ancestors, root: false, inheritedRealm: realm, prefix: `${position}/plugins`, nativeToolSelection,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
if (!nativeIncludes.has(row.name)) continue;
|
|
224
|
+
const config = row.config;
|
|
225
|
+
if (!object(config) || typeof config.path !== "string" || config.__jsExpr) refuse("UNSUPPORTED_INCLUDE");
|
|
226
|
+
let filename;
|
|
227
|
+
try { filename = fileURLToPath(new URL(config.path, baseURL)); } catch { refuse("UNSUPPORTED_INCLUDE"); }
|
|
228
|
+
if (!options.sourceRoots.some(sourceRoot => under(sourceRoot, filename))) refuse("INCLUDE_OUTSIDE_SOURCE_SCOPE");
|
|
229
|
+
if (!new Set([".json", ".yml", ".yaml"]).has(extname(filename)) || /(?:credentials|secrets|\.env)/i.test(filename)) refuse("UNSUPPORTED_INCLUDE");
|
|
230
|
+
if (ancestors.has(filename)) refuse("INCLUDE_CYCLE");
|
|
231
|
+
const content = readset.read(filename, { optional: true });
|
|
232
|
+
const source = content === null ? config.initial : extname(filename) === ".json"
|
|
233
|
+
? jsonDocument(content).value : sdk.yaml.load(content, { schema: sdk.include.entryListSchema });
|
|
234
|
+
if (!Array.isArray(source)) refuse("UNSUPPORTED_INCLUDE");
|
|
235
|
+
const warnings = [];
|
|
236
|
+
const children = sdk.include.applyEntryPatches(source, config.patches, (...args) => warnings.push(args));
|
|
237
|
+
if (warnings.length) refuse("INCLUDE_PATCH_DIAGNOSTIC");
|
|
238
|
+
const next = new Set(ancestors).add(filename);
|
|
239
|
+
inspectTrees(children, options, sdk, readset, new URL(".", pathToFileURL(filename)).href, {
|
|
240
|
+
ancestors: next, root: false, inheritedRealm: realm, prefix: `${position}/include`, topology,
|
|
241
|
+
nativeToolSelection,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return topology;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Full ordered bundle/profile/Home/explicit-launcher source validation and necessary CAS revision. */
|
|
248
|
+
export async function inspectColdComposition(options, sdk, { projectionName, receipt } = {}) {
|
|
249
|
+
const readset = new SourceReadset();
|
|
250
|
+
const manifestPath = join(options.profileDir, "package.json");
|
|
251
|
+
const manifestText = readset.read(manifestPath);
|
|
252
|
+
const manifest = jsonDocument(manifestText).value;
|
|
253
|
+
const bundles = manifest.dsh?.profile?.bundles;
|
|
254
|
+
if (!Array.isArray(bundles) || !bundles.every(name => typeof name === "string")) refuse("INVALID_BUNDLES");
|
|
255
|
+
const originalName = receipt?.projectionName ?? BASE_BUNDLE;
|
|
256
|
+
const slot = bundles.indexOf(originalName);
|
|
257
|
+
if (slot < 0 || bundles.lastIndexOf(originalName) !== slot) refuse("EXACT_BASE_SLOT_REQUIRED");
|
|
258
|
+
readset.package(options.installAnchor);
|
|
259
|
+
for (const filename of sdk.modulePaths) readset.module(filename, { packageSource: true });
|
|
260
|
+
readset.read(join(options.profileDir, "compatibility.json"), { optional: true });
|
|
261
|
+
readset.read(join(options.profileDir, "cordis.patch.yml"), { optional: true });
|
|
262
|
+
const homePatch = join(options.home, "cordis.patch.yml");
|
|
263
|
+
readset.read(homePatch, { optional: true });
|
|
264
|
+
for (const filename of options.overlays) readset.read(filename);
|
|
265
|
+
if (options.rootConfig) readset.read(options.rootConfig);
|
|
266
|
+
if (receipt) readset.read(join(options.profileDir, "node_modules", receipt.projectionName, ".dsmm-cold-profile.json"));
|
|
267
|
+
const discover = sdk.boot.loadProfileDirectory("dsmm-cold-profile", options.profileDir, options.installAnchor);
|
|
268
|
+
if (discover.skippedBundles.length || discover.layers.length !== bundles.length) refuse("SKIPPED_BUNDLE");
|
|
269
|
+
for (const layer of discover.layers) {
|
|
270
|
+
readset.package(join(layer.packageDir, "package.json"), { packageSource: layer.packageName !== originalName || !receipt });
|
|
271
|
+
for (const filename of layer.patchPaths) readset.read(filename, { packageSource: layer.packageName !== originalName || !receipt });
|
|
272
|
+
}
|
|
273
|
+
const profile = sdk.boot.loadProfileDirectory("dsmm-cold-profile", options.profileDir, options.installAnchor);
|
|
274
|
+
if (profile.skippedBundles.length || profile.layers.length !== bundles.length) refuse("SOURCE_CONFLICT");
|
|
275
|
+
const lists = profile.layers.map(layer => layer.patches);
|
|
276
|
+
lists.push(profile.patches, sdk.boot.loadOptionalPatches("dsmm-cold-profile", homePatch) ?? []);
|
|
277
|
+
lists.push(...options.overlays.map(filename => sdk.boot.loadOverlayPatches("dsmm-cold-profile", filename)));
|
|
278
|
+
// Normal profile launchers mount an empty root file. Explicit roots retain their original base.
|
|
279
|
+
const rootRows = options.rootConfig
|
|
280
|
+
? sdk.yaml.load(readset.read(options.rootConfig), { schema: sdk.include.entryListSchema }) : [];
|
|
281
|
+
if (!Array.isArray(rootRows)) refuse("UNSUPPORTED_ROOT_CONFIG");
|
|
282
|
+
const composeAll = layers => {
|
|
283
|
+
if (rootRows.length === 0) return compose(sdk.boot, layers);
|
|
284
|
+
const warnings = [];
|
|
285
|
+
const rows = sdk.include.applyEntryPatches(rootRows, layers.flat(), (...args) => warnings.push(args));
|
|
286
|
+
return { rows, warnings };
|
|
287
|
+
};
|
|
288
|
+
const before = composeAll(lists);
|
|
289
|
+
let projected = lists[slot];
|
|
290
|
+
let changed;
|
|
291
|
+
let after;
|
|
292
|
+
if (receipt) {
|
|
293
|
+
changed = new Map(receipt.changes.map(change => [change.id, change]));
|
|
294
|
+
after = before;
|
|
295
|
+
const originalLists = structuredClone(lists);
|
|
296
|
+
for (const patch of originalLists[slot]) if (patch.insert) entryWalk(patch.insert, row => {
|
|
297
|
+
const change = changed.get(row.id);
|
|
298
|
+
if (change && row.name === change.replacement) row.name = change.original;
|
|
299
|
+
});
|
|
300
|
+
const original = composeAll(originalLists);
|
|
301
|
+
assertSelectorSemantics(composeAll, originalLists, lists);
|
|
302
|
+
if (!isDeepStrictEqual(expectedRows(original.rows, changed), after.rows) || original.warnings.length !== after.warnings.length) refuse("SELECTOR_SEMANTICS_CHANGED");
|
|
303
|
+
} else {
|
|
304
|
+
({ patches: projected, changed } = projectBase(lists[slot], options));
|
|
305
|
+
const projectedLists = [...lists];
|
|
306
|
+
projectedLists[slot] = projected;
|
|
307
|
+
after = composeAll(projectedLists);
|
|
308
|
+
assertSelectorSemantics(composeAll, lists, projectedLists);
|
|
309
|
+
if (!isDeepStrictEqual(expectedRows(before.rows, changed), after.rows) || before.warnings.length !== after.warnings.length) refuse("SELECTOR_SEMANTICS_CHANGED");
|
|
310
|
+
}
|
|
311
|
+
const rootURL = pathToFileURL(options.rootConfig ?? join(options.profileDir, "cordis.yml")).href;
|
|
312
|
+
const resolution = await sdk.boot.createRuntimeResolution({ installAnchor: options.installAnchor, profile, home: options.home });
|
|
313
|
+
const nativeToolSelection = { projected: [], unprojected: [] };
|
|
314
|
+
// First disabled evaluation inherits loader.ctx before Entry._patchContext.
|
|
315
|
+
// Nested groups/includes/presets receive no proof from their traversal base.
|
|
316
|
+
assertLlmTopology(inspectTrees(after.rows, options, { ...sdk, resolution }, readset, rootURL, {
|
|
317
|
+
nativeToolSelection, disabledBaseURL: pathToFileURL(dirname(fileURLToPath(rootURL))).href + "/",
|
|
318
|
+
}));
|
|
319
|
+
readset.assertCurrent();
|
|
320
|
+
const context = { ...options, projectionName: receipt?.projectionName ?? projectionName ?? null };
|
|
321
|
+
// Generated transaction identity is not part of a caller's expected source revision.
|
|
322
|
+
delete context.projectionName;
|
|
323
|
+
return {
|
|
324
|
+
readset, revision: readset.revision(context), manifestText, manifestPath, slot,
|
|
325
|
+
baseLayer: profile.layers[slot], projected, changes: [...changed].map(([id, change]) => ({ id, ...change })),
|
|
326
|
+
rows: after.rows,
|
|
327
|
+
nativeToolSelection: { status: nativeToolSelection.unprojected.length ? "partial" : "projected", ...nativeToolSelection },
|
|
328
|
+
};
|
|
329
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { lstatSync, readFileSync, realpathSync } from "node:fs";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { dirname, isAbsolute, join, parse, resolve } from "node:path";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
+
import { findNodeAtLocation, parseTree } from "jsonc-parser";
|
|
8
|
+
|
|
9
|
+
export class ColdProfileMigrationError extends Error {
|
|
10
|
+
constructor(code) {
|
|
11
|
+
super(`Cold-profile migration refused: ${code}`);
|
|
12
|
+
this.name = "ColdProfileMigrationError";
|
|
13
|
+
this.code = code;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const refuse = code => { throw new ColdProfileMigrationError(code); };
|
|
18
|
+
export const digest = bytes => createHash("sha256").update(bytes).digest("hex");
|
|
19
|
+
|
|
20
|
+
/** Writes never follow a profile, Home, or output directory symlink/junction. */
|
|
21
|
+
export function plainPath(filename, { missing = false } = {}) {
|
|
22
|
+
if (!isAbsolute(filename)) refuse("ABSOLUTE_PATH_REQUIRED");
|
|
23
|
+
let cursor = resolve(filename);
|
|
24
|
+
while (cursor !== parse(cursor).root) {
|
|
25
|
+
try {
|
|
26
|
+
if (lstatSync(cursor).isSymbolicLink()) refuse("LINKED_SOURCE_OR_TARGET");
|
|
27
|
+
} catch (error) {
|
|
28
|
+
if (error.code !== "ENOENT" || !missing) throw error;
|
|
29
|
+
}
|
|
30
|
+
cursor = dirname(cursor);
|
|
31
|
+
}
|
|
32
|
+
return resolve(filename);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** One necessary source readset, held in memory; source contents are never receipts. */
|
|
36
|
+
export class SourceReadset {
|
|
37
|
+
files = new Map();
|
|
38
|
+
capabilities = new Map();
|
|
39
|
+
record(entry) {
|
|
40
|
+
const previous = this.files.get(entry.filename);
|
|
41
|
+
if (previous && JSON.stringify(previous) !== JSON.stringify(entry)) refuse("SOURCE_CONFLICT");
|
|
42
|
+
this.files.set(entry.filename, entry);
|
|
43
|
+
}
|
|
44
|
+
read(filename, { optional = false, packageSource = false } = {}) {
|
|
45
|
+
filename = resolve(filename);
|
|
46
|
+
if (!packageSource) plainPath(filename, { missing: optional });
|
|
47
|
+
let bytes = null;
|
|
48
|
+
let canonical = null;
|
|
49
|
+
try {
|
|
50
|
+
canonical = realpathSync(filename);
|
|
51
|
+
if (!lstatSync(canonical).isFile()) refuse("SOURCE_NOT_FILE");
|
|
52
|
+
bytes = readFileSync(filename);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (error.code !== "ENOENT" || !optional) throw error;
|
|
55
|
+
}
|
|
56
|
+
this.record({ kind: "source", filename, canonical, hash: bytes === null ? null : digest(bytes) });
|
|
57
|
+
return bytes?.toString("utf8") ?? null;
|
|
58
|
+
}
|
|
59
|
+
package(filename, { packageSource = true } = {}) {
|
|
60
|
+
filename = resolve(filename);
|
|
61
|
+
if (!packageSource) plainPath(filename);
|
|
62
|
+
const canonical = realpathSync(filename);
|
|
63
|
+
const manifest = jsonDocument(readFileSync(filename, "utf8")).value;
|
|
64
|
+
this.record({ kind: "package", filename, canonical, hash: packageIdentity(manifest) });
|
|
65
|
+
return manifest;
|
|
66
|
+
}
|
|
67
|
+
module(filename, { packageSource = false } = {}) {
|
|
68
|
+
filename = resolve(filename);
|
|
69
|
+
if (!packageSource) plainPath(filename);
|
|
70
|
+
const canonical = realpathSync(filename);
|
|
71
|
+
if (!lstatSync(canonical).isFile()) refuse("UNRESOLVED_ENTRY_MODULE");
|
|
72
|
+
this.record({ kind: "module", filename, canonical });
|
|
73
|
+
}
|
|
74
|
+
dormantCapability(options, baseURL, specifier) {
|
|
75
|
+
const request = { installAnchor: options.installAnchor, profileDir: options.profileDir, home: options.home, baseURL, specifier };
|
|
76
|
+
const selected = freshCapability(request);
|
|
77
|
+
if (!selected.resolved) return false;
|
|
78
|
+
const key = JSON.stringify(request);
|
|
79
|
+
const previous = this.capabilities.get(key);
|
|
80
|
+
if (previous && JSON.stringify(previous.selected) !== JSON.stringify(selected)) refuse("SOURCE_CONFLICT");
|
|
81
|
+
this.capabilities.set(key, { request, selected });
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
assertCurrent() {
|
|
85
|
+
for (const entry of this.files.values()) {
|
|
86
|
+
let canonical = null;
|
|
87
|
+
let hash = null;
|
|
88
|
+
try {
|
|
89
|
+
canonical = realpathSync(entry.filename);
|
|
90
|
+
if (!lstatSync(canonical).isFile()) refuse("SOURCE_CONFLICT");
|
|
91
|
+
if (entry.kind === "source") hash = digest(readFileSync(entry.filename));
|
|
92
|
+
else if (entry.kind === "package") hash = packageIdentity(jsonDocument(readFileSync(entry.filename, "utf8")).value);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (error.code !== "ENOENT") throw error;
|
|
95
|
+
}
|
|
96
|
+
if (canonical !== entry.canonical || (entry.kind !== "module" && hash !== entry.hash)) refuse("SOURCE_CONFLICT");
|
|
97
|
+
}
|
|
98
|
+
for (const { request, selected } of this.capabilities.values()) {
|
|
99
|
+
if (JSON.stringify(freshCapability(request)) !== JSON.stringify(selected)) refuse("SOURCE_CONFLICT");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
revision(context) {
|
|
103
|
+
const files = [...this.files.values()].sort((a, b) => a.filename.localeCompare(b.filename));
|
|
104
|
+
const capabilities = [...this.capabilities.values()].sort((a, b) => JSON.stringify(a.request).localeCompare(JSON.stringify(b.request)));
|
|
105
|
+
return digest(JSON.stringify({ context, files, ...(capabilities.length ? { capabilities } : {}) }));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const capabilitySpecifiers = new Set([
|
|
110
|
+
"@deepseek-ai/dsh-ptc-runtime-node/package.json",
|
|
111
|
+
"@deepseek-ai/dsh-agent-preset-registry/package.json",
|
|
112
|
+
]);
|
|
113
|
+
|
|
114
|
+
/** A new process discards Node's manifest/path caches and the SDK's ResolutionRouter caches. */
|
|
115
|
+
function freshCapability(request) {
|
|
116
|
+
if (!capabilitySpecifiers.has(request.specifier)) refuse("DORMANT_RESOLUTION_UNAVAILABLE");
|
|
117
|
+
// Preloaded hooks can change native routing or execute user code in the probe.
|
|
118
|
+
if (process.env.NODE_OPTIONS?.trim() || process.execArgv.some(arg => /^(?:--(?:import|require|loader|experimental-loader)(?:=|$)|-r)/.test(arg))) refuse("DORMANT_RESOLUTION_UNAVAILABLE");
|
|
119
|
+
const flags = [];
|
|
120
|
+
for (let i = 0; i < process.execArgv.length; i++) {
|
|
121
|
+
const arg = process.execArgv[i];
|
|
122
|
+
if (/^(?:--conditions=|--preserve-symlinks$|--preserve-symlinks-main$|--no-addons$|--no-experimental-require-module$)/.test(arg)) flags.push(arg);
|
|
123
|
+
else if (arg === "--conditions" || arg === "-C") flags.push(arg, process.execArgv[++i]);
|
|
124
|
+
}
|
|
125
|
+
const child = spawnSync(process.execPath, [...flags, fileURLToPath(import.meta.url), "--dsmm-dormant-resolution"], {
|
|
126
|
+
input: JSON.stringify(request), encoding: "utf8", timeout: 30_000, maxBuffer: 1024 * 1024,
|
|
127
|
+
env: { ...process.env, NODE_OPTIONS: "" }, windowsHide: true,
|
|
128
|
+
});
|
|
129
|
+
if (child.error || child.status !== 0) refuse("DORMANT_RESOLUTION_UNAVAILABLE");
|
|
130
|
+
let selected;
|
|
131
|
+
try { selected = JSON.parse(child.stdout); } catch { refuse("DORMANT_RESOLUTION_UNAVAILABLE"); }
|
|
132
|
+
if (typeof selected?.resolved !== "boolean") refuse("DORMANT_RESOLUTION_UNAVAILABLE");
|
|
133
|
+
return selected;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Uses the SDK's actual CJS interception, without mounting entries or importing capability code. */
|
|
137
|
+
async function resolveCapability(request) {
|
|
138
|
+
if (!capabilitySpecifiers.has(request.specifier)) refuse("DORMANT_RESOLUTION_UNAVAILABLE");
|
|
139
|
+
const native = createRequire(request.installAnchor);
|
|
140
|
+
const bootPath = native.resolve("@deepseek-ai/dsh-app-boot");
|
|
141
|
+
const boot = await import(pathToFileURL(bootPath).href);
|
|
142
|
+
if (boot.getDshRuntimeVersion() !== "0.2.0-rc.2") refuse("UNSUPPORTED_SDK");
|
|
143
|
+
const { Context } = await import(pathToFileURL(createRequire(bootPath).resolve("@deepseek-ai/cordis")).href);
|
|
144
|
+
const profile = boot.loadProfileDirectory("dsmm-cold-profile", request.profileDir, request.installAnchor);
|
|
145
|
+
if (profile.skippedBundles.length) refuse("SKIPPED_BUNDLE");
|
|
146
|
+
const resolution = await boot.createRuntimeResolution({ installAnchor: request.installAnchor, profile, home: request.home });
|
|
147
|
+
const ctx = new Context();
|
|
148
|
+
try {
|
|
149
|
+
await ctx.plugin(boot.PluginPackages, { resolution });
|
|
150
|
+
if (!ctx.get("pluginPackages")?.interception) refuse("DORMANT_RESOLUTION_UNAVAILABLE");
|
|
151
|
+
const require = createRequire(request.baseURL);
|
|
152
|
+
let target;
|
|
153
|
+
try { target = require.resolve(request.specifier); } catch { return { resolved: false }; }
|
|
154
|
+
const name = request.specifier.slice(0, -"/package.json".length);
|
|
155
|
+
const manifests = new Set([
|
|
156
|
+
target,
|
|
157
|
+
...(require.resolve.paths(name) ?? []).map(searchPath => join(searchPath, name, "package.json")),
|
|
158
|
+
...resolution.entries.filter(entry => entry.name === name).map(entry => join(entry.packageDir, "package.json")),
|
|
159
|
+
]);
|
|
160
|
+
const packages = [...manifests].sort().map(filename => {
|
|
161
|
+
try {
|
|
162
|
+
const canonical = realpathSync(filename);
|
|
163
|
+
const hash = packageIdentity(jsonDocument(readFileSync(filename, "utf8")).value);
|
|
164
|
+
return { filename, canonical, hash };
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (error.code !== "ENOENT" && error.code !== "ENOTDIR") throw error;
|
|
167
|
+
return { filename, canonical: null, hash: null };
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
const canonical = realpathSync(target);
|
|
171
|
+
if (!lstatSync(canonical).isFile()) refuse("DORMANT_RESOLUTION_UNAVAILABLE");
|
|
172
|
+
return { resolved: true, target, canonical, packages };
|
|
173
|
+
} finally {
|
|
174
|
+
await ctx.fiber.dispose();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function packageIdentity(manifest) {
|
|
179
|
+
const fields = ["name", "version", "type", "main", "exports", "imports", "dependencies", "peerDependencies", "optionalDependencies"];
|
|
180
|
+
const identity = Object.fromEntries(fields.filter(field => Object.hasOwn(manifest, field)).map(field => [field, manifest[field]]));
|
|
181
|
+
if (manifest.dsh?.bundle !== undefined) identity.bundle = manifest.dsh.bundle;
|
|
182
|
+
return digest(JSON.stringify(identity));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** SDK manifests are strict JSON; duplicate properties are refused rather than erased. */
|
|
186
|
+
export function jsonDocument(text) {
|
|
187
|
+
const errors = [];
|
|
188
|
+
const tree = parseTree(text, errors, { disallowComments: true, allowTrailingComma: false });
|
|
189
|
+
if (!tree || errors.length) refuse("INVALID_MANIFEST");
|
|
190
|
+
const visit = node => {
|
|
191
|
+
if (node.type === "object") {
|
|
192
|
+
const names = new Set();
|
|
193
|
+
for (const property of node.children ?? []) {
|
|
194
|
+
const key = property.children[0].value;
|
|
195
|
+
if (names.has(key)) refuse("DUPLICATE_MANIFEST_KEY");
|
|
196
|
+
names.add(key);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
for (const child of node.children ?? []) visit(child);
|
|
200
|
+
};
|
|
201
|
+
visit(tree);
|
|
202
|
+
return { tree, value: JSON.parse(text) };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function bundleToken(text, slot) {
|
|
206
|
+
const { tree } = jsonDocument(text);
|
|
207
|
+
const node = findNodeAtLocation(tree, ["dsh", "profile", "bundles", slot]);
|
|
208
|
+
if (node?.type !== "string") refuse("INVALID_BUNDLE_SLOT");
|
|
209
|
+
return { offset: node.offset, length: node.length, literal: text.slice(node.offset, node.offset + node.length) };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function replaceBundleToken(text, slot, name) {
|
|
213
|
+
const token = bundleToken(text, slot);
|
|
214
|
+
return text.slice(0, token.offset) + JSON.stringify(name) + text.slice(token.offset + token.length);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export async function loadColdProfileSdk(installAnchor) {
|
|
218
|
+
if (!isAbsolute(installAnchor)) refuse("ABSOLUTE_PATH_REQUIRED");
|
|
219
|
+
const require = createRequire(installAnchor);
|
|
220
|
+
const bootPath = require.resolve("@deepseek-ai/dsh-app-boot");
|
|
221
|
+
const includePath = require.resolve("@deepseek-ai/cordis-plugin-include");
|
|
222
|
+
const yamlPath = require.resolve("js-yaml");
|
|
223
|
+
const atomicPath = require.resolve("@deepseek-ai/dsh-atomic-write");
|
|
224
|
+
const exportsPath = createRequire(bootPath).resolve("resolve.exports");
|
|
225
|
+
const [boot, include, yaml, atomic, packageExports] = await Promise.all(
|
|
226
|
+
[bootPath, includePath, yamlPath, atomicPath, exportsPath].map(filename => import(pathToFileURL(filename).href)),
|
|
227
|
+
);
|
|
228
|
+
if (boot.getDshRuntimeVersion() !== "0.2.0-rc.2") refuse("UNSUPPORTED_SDK");
|
|
229
|
+
return { boot, include, yaml, atomic, packageExports, modulePaths: [bootPath, includePath, yamlPath, atomicPath, exportsPath] };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url) && process.argv[2] === "--dsmm-dormant-resolution") {
|
|
233
|
+
try {
|
|
234
|
+
process.stdout.write(JSON.stringify(await resolveCapability(JSON.parse(readFileSync(0, "utf8")))));
|
|
235
|
+
} catch {
|
|
236
|
+
process.exitCode = 1;
|
|
237
|
+
}
|
|
238
|
+
}
|