@dsmm/dsmm 0.1.8 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (409) hide show
  1. package/README.md +40 -22
  2. package/agent-presets/dsmm-builder/agent.cordis.yml +1949 -39
  3. package/agent-presets/dsmm-builder/preset.yml +1 -1
  4. package/agent-presets/dsmm-clarifier/agent.cordis.yml +436 -14
  5. package/agent-presets/dsmm-clarifier/preset.yml +1 -1
  6. package/agent-presets/dsmm-code-search/agent.cordis.yml +56 -14
  7. package/agent-presets/dsmm-code-search/preset.yml +1 -1
  8. package/agent-presets/dsmm-coding/agent.cordis.yml +588 -0
  9. package/agent-presets/dsmm-coding/preset.yml +3 -0
  10. package/agent-presets/dsmm-complex/agent.cordis.yml +1140 -0
  11. package/agent-presets/dsmm-complex/preset.yml +3 -0
  12. package/agent-presets/dsmm-creative/agent.cordis.yml +536 -12
  13. package/agent-presets/dsmm-creative/preset.yml +1 -1
  14. package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +1163 -0
  15. package/agent-presets/dsmm-cross-cutting/preset.yml +3 -0
  16. package/agent-presets/dsmm-deep/agent.cordis.yml +1173 -0
  17. package/agent-presets/dsmm-deep/preset.yml +3 -0
  18. package/agent-presets/dsmm-doc-search/agent.cordis.yml +56 -14
  19. package/agent-presets/dsmm-doc-search/preset.yml +1 -1
  20. package/agent-presets/dsmm-documenting/agent.cordis.yml +581 -0
  21. package/agent-presets/dsmm-documenting/preset.yml +3 -0
  22. package/agent-presets/dsmm-frontend/agent.cordis.yml +580 -0
  23. package/agent-presets/dsmm-frontend/preset.yml +3 -0
  24. package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +572 -0
  25. package/agent-presets/dsmm-hard-reasoning/preset.yml +3 -0
  26. package/agent-presets/dsmm-media-reader/agent.cordis.yml +56 -14
  27. package/agent-presets/dsmm-media-reader/preset.yml +1 -1
  28. package/agent-presets/dsmm-normal-task/agent.cordis.yml +546 -0
  29. package/agent-presets/dsmm-normal-task/preset.yml +3 -0
  30. package/agent-presets/dsmm-oracle/agent.cordis.yml +421 -12
  31. package/agent-presets/dsmm-oracle/preset.yml +1 -1
  32. package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +421 -12
  33. package/agent-presets/dsmm-oracle-2nd/preset.yml +1 -1
  34. package/agent-presets/dsmm-orchestrator/agent.cordis.yml +2023 -43
  35. package/agent-presets/dsmm-orchestrator/preset.yml +1 -1
  36. package/agent-presets/dsmm-plan-critic/agent.cordis.yml +416 -13
  37. package/agent-presets/dsmm-plan-critic/preset.yml +1 -1
  38. package/agent-presets/dsmm-planner/agent.cordis.yml +462 -13
  39. package/agent-presets/dsmm-planner/preset.yml +1 -1
  40. package/agent-presets/dsmm-quick/agent.cordis.yml +119 -0
  41. package/agent-presets/dsmm-quick/preset.yml +3 -0
  42. package/agent-presets/dsmm-research/agent.cordis.yml +141 -0
  43. package/agent-presets/dsmm-research/preset.yml +3 -0
  44. package/agent-presets/dsmm-reviewer/agent.cordis.yml +420 -13
  45. package/agent-presets/dsmm-reviewer/preset.yml +1 -1
  46. package/cordis.patch.yml +1 -5
  47. package/docs/agent-presets.md +64 -15
  48. package/docs/compatibility.md +67 -17
  49. package/docs/design.md +41 -0
  50. package/docs/lsp.md +12 -2
  51. package/docs/migration-from-ocmm.md +8 -0
  52. package/docs/profiles.md +42 -16
  53. package/docs/releasing.md +100 -28
  54. package/docs/roadmap.md +6 -0
  55. package/docs/runtime-recovery.md +12 -0
  56. package/docs/safety-guards.md +7 -3
  57. package/docs/settings-status.md +148 -7
  58. package/docs/skill-sync.md +52 -14
  59. package/lib/client/DeploymentPage.d.ts +18 -0
  60. package/lib/client/DeploymentPage.js +120 -0
  61. package/lib/client/ProfilesSection.js +4 -2
  62. package/lib/client/deployment-controller.d.ts +50 -0
  63. package/lib/client/deployment-controller.js +193 -0
  64. package/lib/client/deployment-data.d.ts +16 -0
  65. package/lib/client/deployment-data.js +109 -0
  66. package/lib/client/deployment-locales.d.ts +66 -0
  67. package/lib/client/deployment-locales.js +72 -0
  68. package/lib/client/index.js +50 -0
  69. package/lib/client/locales.d.ts +4 -0
  70. package/lib/client/locales.js +4 -2
  71. package/lib/client/plugins-contract.d.ts +27 -0
  72. package/lib/client/plugins-contract.js +2 -0
  73. package/lib/client/styles.d.ts +1 -1
  74. package/lib/client/styles.js +16 -0
  75. package/lib/client.js +1048 -29
  76. package/lib/commands.js +3 -0
  77. package/lib/config-file-store.d.ts +23 -0
  78. package/lib/config-file-store.js +67 -0
  79. package/lib/deployment-config.d.ts +37 -0
  80. package/lib/deployment-config.js +184 -0
  81. package/lib/dsh-home.d.ts +3 -0
  82. package/lib/dsh-home.js +10 -0
  83. package/lib/dsh-types.d.ts +12 -65
  84. package/lib/guards.d.ts +2 -1
  85. package/lib/guards.js +19 -2
  86. package/lib/index.d.ts +8 -1
  87. package/lib/index.js +115 -25
  88. package/lib/lsp.d.ts +13 -0
  89. package/lib/lsp.js +60 -0
  90. package/lib/mode.js +42 -47
  91. package/lib/model-routing.js +5 -2
  92. package/lib/modules.d.ts +27 -0
  93. package/lib/modules.js +21 -0
  94. package/lib/native-scope.d.ts +9 -0
  95. package/lib/native-scope.js +20 -0
  96. package/lib/plan-validation.js +6 -44
  97. package/lib/preset-materializer.js +2 -0
  98. package/lib/preset-registry.d.ts +1 -1
  99. package/lib/preset-registry.js +7 -4
  100. package/lib/preset-skills.d.ts +4 -1
  101. package/lib/preset-skills.js +60 -19
  102. package/lib/profile-remote.d.ts +14 -0
  103. package/lib/profile-remote.js +197 -4
  104. package/lib/profile-rpc.d.ts +24 -1
  105. package/lib/profile-rpc.js +139 -1
  106. package/lib/profile-runtime.d.ts +24 -0
  107. package/lib/profile-runtime.js +177 -33
  108. package/lib/profile-store.d.ts +45 -1
  109. package/lib/profile-store.js +236 -102
  110. package/lib/profile-types.d.ts +55 -0
  111. package/lib/prompt-content.d.ts +25 -0
  112. package/lib/prompt-content.js +27 -0
  113. package/lib/prompts.d.ts +8 -2
  114. package/lib/prompts.js +46 -34
  115. package/lib/role-policy.d.ts +51 -0
  116. package/lib/role-policy.js +224 -0
  117. package/lib/role-providers.d.ts +6 -2
  118. package/lib/role-providers.js +72 -39
  119. package/lib/role-subagents.d.ts +6 -2
  120. package/lib/role-subagents.js +187 -48
  121. package/lib/roles.d.ts +16 -4
  122. package/lib/roles.js +86 -186
  123. package/lib/runtime-recovery.js +16 -5
  124. package/lib/session-scope.js +2 -0
  125. package/lib/settings.d.ts +69 -1
  126. package/lib/settings.js +262 -91
  127. package/lib/skills.d.ts +24 -9
  128. package/lib/skills.js +114 -35
  129. package/lib/state.d.ts +10 -6
  130. package/lib/state.js +48 -49
  131. package/lib/status.d.ts +25 -0
  132. package/lib/status.js +47 -9
  133. package/locale/en.json +2 -2
  134. package/locale/zh.json +2 -2
  135. package/package.json +19 -2
  136. package/prompts/deepwork.md +144 -20
  137. package/prompts/source/agents/clarifier.md +45 -0
  138. package/prompts/source/agents/orchestrator.md +63 -0
  139. package/prompts/source/agents/plan-critic.md +25 -0
  140. package/prompts/source/agents/planner.md +19 -0
  141. package/prompts/source/agents/reviewer.md +17 -0
  142. package/prompts/source/catalog.json +548 -0
  143. package/prompts/source/category/coding.md +46 -0
  144. package/prompts/source/category/complex.md +29 -0
  145. package/prompts/source/category/creative.md +38 -0
  146. package/prompts/source/category/cross-cutting.md +52 -0
  147. package/prompts/source/category/deep.md +62 -0
  148. package/prompts/source/category/documenting.md +62 -0
  149. package/prompts/source/category/frontend.md +38 -0
  150. package/prompts/source/category/hard-reasoning.md +53 -0
  151. package/prompts/source/category/normal-task.md +27 -0
  152. package/prompts/source/category/quick.md +34 -0
  153. package/prompts/source/category/research.md +56 -0
  154. package/prompts/source/deepwork/claude-opus-5.md +28 -0
  155. package/prompts/source/deepwork/codex.md +9 -0
  156. package/prompts/source/deepwork/default.md +129 -0
  157. package/prompts/source/deepwork/gemini.md +184 -0
  158. package/prompts/source/deepwork/glm.md +256 -0
  159. package/prompts/source/deepwork/gpt.md +43 -0
  160. package/prompts/source/deepwork/kimi-k27.md +13 -0
  161. package/prompts/source/deepwork/planner.md +41 -0
  162. package/prompts/source/deepwork/swe-2.md +13 -0
  163. package/prompts/source/manifest.json +3118 -0
  164. package/prompts/source/shared/dsh-host-contract.md +6 -0
  165. package/prompts/source/shared/locale.md +8 -0
  166. package/prompts/source/shared/shell-safety.md +7 -0
  167. package/prompts/source/terminal/builder.md +13 -0
  168. package/prompts/source/terminal/clarifier.md +41 -0
  169. package/prompts/source/terminal/code-search.md +39 -0
  170. package/prompts/source/terminal/coding.md +41 -0
  171. package/prompts/source/terminal/complex.md +43 -0
  172. package/prompts/source/terminal/creative.md +41 -0
  173. package/prompts/source/terminal/cross-cutting.md +43 -0
  174. package/prompts/source/terminal/deep.md +43 -0
  175. package/prompts/source/terminal/doc-search.md +39 -0
  176. package/prompts/source/terminal/documenting.md +41 -0
  177. package/prompts/source/terminal/frontend.md +41 -0
  178. package/prompts/source/terminal/hard-reasoning.md +41 -0
  179. package/prompts/source/terminal/media-reader.md +39 -0
  180. package/prompts/source/terminal/normal-task.md +41 -0
  181. package/prompts/source/terminal/oracle-2nd.md +53 -0
  182. package/prompts/source/terminal/oracle.md +53 -0
  183. package/prompts/source/terminal/orchestrator.md +26 -0
  184. package/prompts/source/terminal/plan-critic.md +41 -0
  185. package/prompts/source/terminal/planner.md +42 -0
  186. package/prompts/source/terminal/quick.md +39 -0
  187. package/prompts/source/terminal/research.md +39 -0
  188. package/prompts/source/terminal/reviewer.md +53 -0
  189. package/skills/ast-grep/LICENSE +21 -0
  190. package/skills/ast-grep/README.md +138 -0
  191. package/skills/ast-grep/SKILL.md +284 -0
  192. package/skills/ast-grep/SOURCE +1 -0
  193. package/skills/ast-grep/install.ps1 +235 -0
  194. package/skills/ast-grep/install.sh +286 -0
  195. package/skills/ast-grep/references/cli.md +233 -0
  196. package/skills/ast-grep/references/install.md +168 -0
  197. package/skills/ast-grep/references/patterns.md +149 -0
  198. package/skills/ast-grep/references/pitfalls.md +305 -0
  199. package/skills/ast-grep/references/recipes.md +404 -0
  200. package/skills/ast-grep/references/sgconfig.md +250 -0
  201. package/skills/ast-grep/references/yaml-rules.md +511 -0
  202. package/skills/ast-grep/scripts/ast_grep_helper.py +760 -0
  203. package/skills/ast-grep/tests/smoke.ps1 +129 -0
  204. package/skills/ast-grep/tests/smoke.sh +212 -0
  205. package/skills/ast-grep/tests/test_resolver.py +154 -0
  206. package/skills/brainstorming/SKILL.md +102 -9
  207. package/skills/coding-agent-sessions/LICENSE-UPSTREAM.md +82 -0
  208. package/skills/coding-agent-sessions/NOTICE.md +24 -0
  209. package/skills/coding-agent-sessions/SKILL.md +144 -0
  210. package/skills/coding-agent-sessions/agents/openai.yaml +4 -0
  211. package/skills/coding-agent-sessions/pyrightconfig.json +5 -0
  212. package/skills/coding-agent-sessions/references/all-platforms.md +77 -0
  213. package/skills/coding-agent-sessions/references/claude.md +34 -0
  214. package/skills/coding-agent-sessions/references/codex.md +32 -0
  215. package/skills/coding-agent-sessions/references/opencode.md +45 -0
  216. package/skills/coding-agent-sessions/references/senpi.md +29 -0
  217. package/skills/coding-agent-sessions/scripts/agent_sessions/__init__.py +1 -0
  218. package/skills/coding-agent-sessions/scripts/agent_sessions/aside_scanner.py +140 -0
  219. package/skills/coding-agent-sessions/scripts/agent_sessions/claude.py +66 -0
  220. package/skills/coding-agent-sessions/scripts/agent_sessions/cli.py +283 -0
  221. package/skills/coding-agent-sessions/scripts/agent_sessions/codex.py +105 -0
  222. package/skills/coding-agent-sessions/scripts/agent_sessions/file_scanners.py +275 -0
  223. package/skills/coding-agent-sessions/scripts/agent_sessions/jsonio.py +55 -0
  224. package/skills/coding-agent-sessions/scripts/agent_sessions/kiro_scanner.py +91 -0
  225. package/skills/coding-agent-sessions/scripts/agent_sessions/opencode.py +289 -0
  226. package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -0
  227. package/skills/coding-agent-sessions/scripts/agent_sessions/scanners.py +104 -0
  228. package/skills/coding-agent-sessions/scripts/agent_sessions/sqlite_optional_scanners.py +203 -0
  229. package/skills/coding-agent-sessions/scripts/agent_sessions/sqlite_scanners.py +177 -0
  230. package/skills/coding-agent-sessions/scripts/agent_sessions/timeparse.py +51 -0
  231. package/skills/coding-agent-sessions/scripts/agent_sessions/transcript.py +149 -0
  232. package/skills/coding-agent-sessions/scripts/agent_sessions/types.py +57 -0
  233. package/skills/coding-agent-sessions/scripts/find-agent-sessions.py +19 -0
  234. package/skills/coding-agent-sessions/scripts/tests/test_agent_sessions.py +322 -0
  235. package/skills/coding-agent-sessions/scripts/tests/test_aside_scanner.py +131 -0
  236. package/skills/coding-agent-sessions/scripts/tests/test_cli_contract.py +126 -0
  237. package/skills/coding-agent-sessions/scripts/tests/test_extended_scanners.py +262 -0
  238. package/skills/coding-agent-sessions/scripts/tests/test_optional_sqlite_scanners.py +79 -0
  239. package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -0
  240. package/skills/debugging/SKILL.md +125 -4
  241. package/skills/debugging/references/logging.md +2 -0
  242. package/skills/debugging/references/methodology/00-setup.md +2 -0
  243. package/skills/debugging/references/methodology/02-investigate.md +8 -2
  244. package/skills/debugging/references/methodology/03-flaky-triage.md +3 -1
  245. package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +4 -2
  246. package/skills/debugging/references/methodology/05-escalate.md +2 -0
  247. package/skills/debugging/references/methodology/06-fix.md +2 -0
  248. package/skills/debugging/references/methodology/08-qa.md +2 -0
  249. package/skills/debugging/references/methodology/09-cleanup.md +2 -0
  250. package/skills/debugging/references/methodology/partial-runtime-evidence.md +4 -2
  251. package/skills/debugging/references/runtimes/bundled-js-binary.md +2 -0
  252. package/skills/debugging/references/runtimes/go.md +2 -0
  253. package/skills/debugging/references/runtimes/native-binary.md +2 -0
  254. package/skills/debugging/references/runtimes/node.md +2 -0
  255. package/skills/debugging/references/runtimes/python.md +2 -0
  256. package/skills/debugging/references/runtimes/rust.md +2 -0
  257. package/skills/debugging/references/scripts/dap.test.mjs +539 -0
  258. package/skills/debugging/references/scripts/fixture-adapter.mjs +164 -0
  259. package/skills/debugging/references/tools/dap.md +3 -1
  260. package/skills/debugging/references/tools/ghidra.md +2 -0
  261. package/skills/debugging/references/tools/playwright-cli.md +2 -0
  262. package/skills/debugging/references/tools/pwndbg.md +2 -0
  263. package/skills/debugging/references/tools/pwntools.md +2 -0
  264. package/skills/dispatching-parallel-agents/SKILL.md +94 -7
  265. package/skills/frontend/.frontend-materialized.json +856 -0
  266. package/skills/frontend/ATTRIBUTION.md +37 -0
  267. package/skills/frontend/LICENSE-Apache-2.0.txt +201 -0
  268. package/skills/frontend/LICENSE-taste-skill.txt +21 -0
  269. package/skills/frontend/LICENSE-ui-ux-pro-max.txt +21 -0
  270. package/skills/frontend/SKILL.md +142 -0
  271. package/skills/frontend/references/design/README.md +256 -0
  272. package/skills/frontend/references/design/_INDEX.md +206 -0
  273. package/skills/frontend/references/design/airbnb.md +393 -0
  274. package/skills/frontend/references/design/airtable.md +92 -0
  275. package/skills/frontend/references/design/apple.md +250 -0
  276. package/skills/frontend/references/design/aside.md +211 -0
  277. package/skills/frontend/references/design/binance.md +348 -0
  278. package/skills/frontend/references/design/bmw.md +183 -0
  279. package/skills/frontend/references/design/brutalist-skill.md +92 -0
  280. package/skills/frontend/references/design/bugatti.md +271 -0
  281. package/skills/frontend/references/design/cal.md +262 -0
  282. package/skills/frontend/references/design/claude.md +315 -0
  283. package/skills/frontend/references/design/clay.md +307 -0
  284. package/skills/frontend/references/design/clickhouse.md +284 -0
  285. package/skills/frontend/references/design/clone-from-url.md +69 -0
  286. package/skills/frontend/references/design/cohere.md +269 -0
  287. package/skills/frontend/references/design/coinbase.md +132 -0
  288. package/skills/frontend/references/design/composio.md +310 -0
  289. package/skills/frontend/references/design/cursor.md +312 -0
  290. package/skills/frontend/references/design/design-system-architecture.md +250 -0
  291. package/skills/frontend/references/design/elevenlabs.md +268 -0
  292. package/skills/frontend/references/design/expo.md +284 -0
  293. package/skills/frontend/references/design/ferrari.md +317 -0
  294. package/skills/frontend/references/design/figma.md +223 -0
  295. package/skills/frontend/references/design/framer.md +249 -0
  296. package/skills/frontend/references/design/gpt-tasteskill.md +74 -0
  297. package/skills/frontend/references/design/hashicorp.md +281 -0
  298. package/skills/frontend/references/design/ibm.md +335 -0
  299. package/skills/frontend/references/design/image-to-code-skill.md +1228 -0
  300. package/skills/frontend/references/design/imagegen-brandkit.md +798 -0
  301. package/skills/frontend/references/design/imagegen-frontend-mobile.md +1465 -0
  302. package/skills/frontend/references/design/imagegen-frontend-web.md +987 -0
  303. package/skills/frontend/references/design/interaction-skill.md +52 -0
  304. package/skills/frontend/references/design/intercom.md +149 -0
  305. package/skills/frontend/references/design/kraken.md +128 -0
  306. package/skills/frontend/references/design/lamborghini.md +291 -0
  307. package/skills/frontend/references/design/linear.app.md +370 -0
  308. package/skills/frontend/references/design/lovable.md +301 -0
  309. package/skills/frontend/references/design/mastercard.md +368 -0
  310. package/skills/frontend/references/design/meta.md +369 -0
  311. package/skills/frontend/references/design/minimalist-skill.md +85 -0
  312. package/skills/frontend/references/design/minimax.md +260 -0
  313. package/skills/frontend/references/design/mintlify.md +329 -0
  314. package/skills/frontend/references/design/miro.md +111 -0
  315. package/skills/frontend/references/design/mistral.ai.md +264 -0
  316. package/skills/frontend/references/design/mongodb.md +269 -0
  317. package/skills/frontend/references/design/nike.md +366 -0
  318. package/skills/frontend/references/design/notion.md +312 -0
  319. package/skills/frontend/references/design/nvidia.md +296 -0
  320. package/skills/frontend/references/design/ollama.md +270 -0
  321. package/skills/frontend/references/design/opencode.ai.md +284 -0
  322. package/skills/frontend/references/design/output-skill.md +49 -0
  323. package/skills/frontend/references/design/pinterest.md +233 -0
  324. package/skills/frontend/references/design/playstation.md +367 -0
  325. package/skills/frontend/references/design/posthog.md +259 -0
  326. package/skills/frontend/references/design/raycast.md +271 -0
  327. package/skills/frontend/references/design/react-dev-tooling-skill.md +232 -0
  328. package/skills/frontend/references/design/redesign-skill.md +178 -0
  329. package/skills/frontend/references/design/renault.md +314 -0
  330. package/skills/frontend/references/design/replicate.md +264 -0
  331. package/skills/frontend/references/design/resend.md +306 -0
  332. package/skills/frontend/references/design/revolut.md +188 -0
  333. package/skills/frontend/references/design/runwayml.md +247 -0
  334. package/skills/frontend/references/design/sanity.md +360 -0
  335. package/skills/frontend/references/design/sentry.md +265 -0
  336. package/skills/frontend/references/design/shopify.md +353 -0
  337. package/skills/frontend/references/design/soft-skill.md +98 -0
  338. package/skills/frontend/references/design/spacex.md +197 -0
  339. package/skills/frontend/references/design/spotify.md +249 -0
  340. package/skills/frontend/references/design/starbucks.md +583 -0
  341. package/skills/frontend/references/design/stitch-design-example.md +121 -0
  342. package/skills/frontend/references/design/stitch-skill.md +184 -0
  343. package/skills/frontend/references/design/stripe.md +325 -0
  344. package/skills/frontend/references/design/supabase.md +258 -0
  345. package/skills/frontend/references/design/superhuman.md +255 -0
  346. package/skills/frontend/references/design/taste-skill.md +1206 -0
  347. package/skills/frontend/references/design/tesla.md +289 -0
  348. package/skills/frontend/references/design/theverge.md +342 -0
  349. package/skills/frontend/references/design/together.ai.md +266 -0
  350. package/skills/frontend/references/design/uber.md +298 -0
  351. package/skills/frontend/references/design/vercel.md +313 -0
  352. package/skills/frontend/references/design/vodafone.md +426 -0
  353. package/skills/frontend/references/design/voltagent.md +326 -0
  354. package/skills/frontend/references/design/warp.md +256 -0
  355. package/skills/frontend/references/design/webflow.md +95 -0
  356. package/skills/frontend/references/design/wired.md +281 -0
  357. package/skills/frontend/references/design/wise.md +176 -0
  358. package/skills/frontend/references/design/x.ai.md +260 -0
  359. package/skills/frontend/references/design/zapier.md +331 -0
  360. package/skills/frontend/references/perfection/README.md +264 -0
  361. package/skills/frontend/references/perfection/react-perf-tooling.md +234 -0
  362. package/skills/frontend/references/ui-ux-db/README.md +659 -0
  363. package/skills/frontend/references/ui-ux-db/data/app-interface.csv +31 -0
  364. package/skills/frontend/references/ui-ux-db/data/charts.csv +26 -0
  365. package/skills/frontend/references/ui-ux-db/data/colors.csv +162 -0
  366. package/skills/frontend/references/ui-ux-db/data/google-fonts.csv +1924 -0
  367. package/skills/frontend/references/ui-ux-db/data/icons.csv +106 -0
  368. package/skills/frontend/references/ui-ux-db/data/landing.csv +35 -0
  369. package/skills/frontend/references/ui-ux-db/data/products.csv +162 -0
  370. package/skills/frontend/references/ui-ux-db/data/react-performance.csv +45 -0
  371. package/skills/frontend/references/ui-ux-db/data/stacks/angular.csv +51 -0
  372. package/skills/frontend/references/ui-ux-db/data/stacks/astro.csv +54 -0
  373. package/skills/frontend/references/ui-ux-db/data/stacks/flutter.csv +53 -0
  374. package/skills/frontend/references/ui-ux-db/data/stacks/html-tailwind.csv +56 -0
  375. package/skills/frontend/references/ui-ux-db/data/stacks/jetpack-compose.csv +53 -0
  376. package/skills/frontend/references/ui-ux-db/data/stacks/laravel.csv +51 -0
  377. package/skills/frontend/references/ui-ux-db/data/stacks/nextjs.csv +53 -0
  378. package/skills/frontend/references/ui-ux-db/data/stacks/nuxt-ui.csv +51 -0
  379. package/skills/frontend/references/ui-ux-db/data/stacks/nuxtjs.csv +59 -0
  380. package/skills/frontend/references/ui-ux-db/data/stacks/react-native.csv +52 -0
  381. package/skills/frontend/references/ui-ux-db/data/stacks/react.csv +54 -0
  382. package/skills/frontend/references/ui-ux-db/data/stacks/shadcn.csv +61 -0
  383. package/skills/frontend/references/ui-ux-db/data/stacks/svelte.csv +54 -0
  384. package/skills/frontend/references/ui-ux-db/data/stacks/swiftui.csv +51 -0
  385. package/skills/frontend/references/ui-ux-db/data/stacks/threejs.csv +54 -0
  386. package/skills/frontend/references/ui-ux-db/data/stacks/vue.csv +50 -0
  387. package/skills/frontend/references/ui-ux-db/data/styles.csv +85 -0
  388. package/skills/frontend/references/ui-ux-db/data/typography.csv +74 -0
  389. package/skills/frontend/references/ui-ux-db/data/ui-reasoning.csv +162 -0
  390. package/skills/frontend/references/ui-ux-db/data/ux-guidelines.csv +100 -0
  391. package/skills/frontend/references/ui-ux-db/data/web-interface.csv +31 -0
  392. package/skills/frontend/references/ui-ux-db/scripts/core.py +262 -0
  393. package/skills/frontend/references/ui-ux-db/scripts/design_system.py +1148 -0
  394. package/skills/frontend/references/ui-ux-db/scripts/search.py +114 -0
  395. package/skills/frontend/scripts/perfection/lighthouse-audit.py +201 -0
  396. package/skills/git-master/SKILL.md +112 -0
  397. package/skills/git-master/agents/openai.yaml +13 -0
  398. package/skills/init-deep/SKILL.md +279 -0
  399. package/skills/receiving-code-review/SKILL.md +112 -7
  400. package/skills/remove-ai-slops/SKILL.md +159 -8
  401. package/skills/requesting-code-review/SKILL.md +96 -3
  402. package/skills/requesting-code-review/code-reviewer.md +47 -0
  403. package/skills/subagent-driven-development/SKILL.md +176 -6
  404. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +23 -0
  405. package/skills/subagent-driven-development/implementer-prompt.md +69 -0
  406. package/skills/subagent-driven-development/spec-reviewer-prompt.md +32 -0
  407. package/skills/using-git-worktrees/SKILL.md +141 -0
  408. package/skills/writing-plans/SKILL.md +121 -7
  409. package/skills/writing-plans/plan-document-reviewer-prompt.md +38 -0
package/lib/client.js CHANGED
@@ -88,7 +88,7 @@ function isRecord(value) {
88
88
  var errorCodes = /* @__PURE__ */ new Set(["validation", "conflict", "not-found", "lock-timeout", "unsafe-path", "io", "activation", "corrupt-selection", "limit", "busy", "maintenance", "disposed", "not-owned", "unavailable", "cancelled"]);
89
89
  var idPattern = /^[a-z0-9][a-z0-9_-]{0,63}$/u;
90
90
  var revisionPattern = /^[a-f0-9]{64}$/u;
91
- var rolePattern = /^dsmm-(?:orchestrator|planner|plan-critic|builder|reviewer|oracle|oracle-2nd|creative|code-search|doc-search|clarifier|media-reader)$/u;
91
+ var rolePattern = /^dsmm-(?:orchestrator|planner|plan-critic|builder|reviewer|oracle|oracle-2nd|creative|code-search|doc-search|clarifier|media-reader|frontend|hard-reasoning|research|quick|coding|normal-task|complex|deep|documenting|cross-cutting)$/u;
92
92
  function isProfileId(value) {
93
93
  return typeof value === "string" && idPattern.test(value) && !/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])$/iu.test(value);
94
94
  }
@@ -161,7 +161,7 @@ function content(value) {
161
161
  return result;
162
162
  }
163
163
  function snapshot(value) {
164
- const item = object(value, ["profiles", "selectedId", "appliedRevision", "selectionRevision"], ["selectionError", "roles", "editorDefaults"]);
164
+ const item = object(value, ["profiles", "selectedId", "appliedRevision", "selectionRevision"], ["selectionError", "roles", "editorDefaults", "origin", "readOnly", "writeRestriction"]);
165
165
  if (!Array.isArray(item.profiles) || item.profiles.length > 128) fail("profiles");
166
166
  return {
167
167
  profiles: item.profiles.map((input) => {
@@ -173,7 +173,7 @@ function snapshot(value) {
173
173
  selectionRevision: item.selectionRevision === "unavailable" && Object.hasOwn(item, "selectionError") ? "unavailable" : selectionRevision(item.selectionRevision),
174
174
  ...optional(item, "selectionError", errorInfo),
175
175
  ...optional(item, "roles", (input) => {
176
- if (!Array.isArray(input) || input.length > 12) fail("roles");
176
+ if (!Array.isArray(input) || input.length > 22) fail("roles");
177
177
  const result = input.map((value2) => {
178
178
  const row = object(value2, ["id", "label", "enabled"], ["runtimePolicy"]);
179
179
  return { id: role(row.id), label: text(row.label, "label", 120), enabled: boolean(row.enabled, "enabled"), ...optional(row, "runtimePolicy", (input2) => {
@@ -184,7 +184,13 @@ function snapshot(value) {
184
184
  if (new Set(result.map((row) => row.id)).size !== result.length) fail("roles");
185
185
  return result;
186
186
  }),
187
- ...optional(item, "editorDefaults", runtimePolicy)
187
+ ...optional(item, "editorDefaults", runtimePolicy),
188
+ ...optional(item, "origin", (input) => {
189
+ if (!["central", "legacy", "explicit"].includes(String(input))) fail("origin");
190
+ return input;
191
+ }),
192
+ ...optional(item, "readOnly", (input) => boolean(input, "readOnly")),
193
+ ...optional(item, "writeRestriction", (input) => text(input, "writeRestriction", 1024))
188
194
  };
189
195
  }
190
196
  function rateLimit(value) {
@@ -219,7 +225,7 @@ function selectionState(value) {
219
225
  return { selectedId: item.selectedId === null ? null : id(item.selectedId), appliedRevision: item.appliedRevision === null ? null : revision(item.appliedRevision), selectionRevision: selectionRevision(item.selectionRevision) };
220
226
  }
221
227
  function sessionSnapshot(value) {
222
- const item = object(value, ["sessionId", "globalDefault", "selection", "scope", "admissionEpoch", "switchAllowed"], ["admittedSelection", "switchUnavailableReason", "rolePolicy", "profileModel", "deepwork"]);
228
+ const item = object(value, ["sessionId", "globalDefault", "selection", "scope", "admissionEpoch", "switchAllowed"], ["admittedSelection", "switchUnavailableReason", "rolePolicy", "profileModel", "deepwork", "modules", "configuration"]);
223
229
  if (typeof item.scope !== "string" || !["global-default", "session-override", "deployment-baseline"].includes(item.scope)) fail("scope");
224
230
  return {
225
231
  sessionId: sessionId(item.sessionId),
@@ -235,6 +241,8 @@ function sessionSnapshot(value) {
235
241
  }),
236
242
  ...optional(item, "rolePolicy", rolePolicy),
237
243
  ...optional(item, "profileModel", modelRoute),
244
+ ...optional(item, "modules", moduleStates),
245
+ ...optional(item, "configuration", admissionView),
238
246
  ...optional(item, "deepwork", (input) => {
239
247
  const mode = object(input, ["active", "explicit", "locked", "revision"]);
240
248
  return { active: boolean(mode.active, "active"), explicit: boolean(mode.explicit, "explicit"), locked: boolean(mode.locked, "locked"), revision: revision(mode.revision) };
@@ -267,9 +275,178 @@ function codec(symbol, parse3) {
267
275
  function descriptor(method, result, parameter) {
268
276
  return { id: `@dsmm/dsmm#dsmmProfiles/${method}`, service: "dsmmProfiles", namespace: "dsmmProfiles", method, invocation: { kind: "direct" }, parameters: parameter === void 0 ? [] : [{ name: parameter.name, wire: parameter.name, source: "json", codec: parameter.codec }], result };
269
277
  }
278
+ function jsonData(value, depth = 0, active = /* @__PURE__ */ new Set()) {
279
+ if (depth > 32) fail("JSON depth");
280
+ if (value === null || typeof value === "string" || typeof value === "boolean") return value;
281
+ if (typeof value === "number" && Number.isFinite(value)) return value;
282
+ if (typeof value !== "object" || value === null || active.has(value)) fail("JSON value");
283
+ if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) fail("JSON object");
284
+ active.add(value);
285
+ const result = Array.isArray(value) ? value.map((child) => jsonData(child, depth + 1, active)) : Object.fromEntries(Object.entries(value).map(([key, child]) => {
286
+ if (["__proto__", "prototype", "constructor"].includes(key)) fail("JSON key");
287
+ return [key, jsonData(child, depth + 1, active)];
288
+ }));
289
+ active.delete(value);
290
+ return result;
291
+ }
292
+ function globalSnapshot(value) {
293
+ const row = object(value, ["config", "revision"]);
294
+ object(row.config, [], Object.keys(row.config));
295
+ return { config: jsonData(row.config), revision: selectionRevision(row.revision) };
296
+ }
297
+ function admissionView(value) {
298
+ const row = object(value, ["settings", "sources", "captures", "restartRequired", "named"]);
299
+ object(row.settings, [], Object.keys(row.settings));
300
+ for (const key of ["sources", "captures"]) {
301
+ const map = object(row[key], [], Object.keys(row[key]));
302
+ for (const [path, value2] of Object.entries(map)) {
303
+ if (path.startsWith("lsp.env.")) fail("private environment field");
304
+ text(value2, key, 128);
305
+ }
306
+ }
307
+ if (!Array.isArray(row.restartRequired) || row.restartRequired.length > 256) fail("restartRequired");
308
+ const named = row.named === null ? null : object(row.named, ["id", "revision"]);
309
+ return {
310
+ settings: readOnlySettingsData(row.settings),
311
+ sources: jsonData(row.sources),
312
+ captures: jsonData(row.captures),
313
+ restartRequired: row.restartRequired.map((value2) => text(value2, "field", 256)),
314
+ named: named === null ? null : { id: id(named.id), revision: revision(named.revision) }
315
+ };
316
+ }
317
+ function readOnlySettingsData(value) {
318
+ const settings = jsonData(value);
319
+ const configured = (value2) => {
320
+ if (value2 !== "" && value2 !== "<configured>") fail("private configured value");
321
+ };
322
+ if (settings.lsp !== void 0) {
323
+ const lsp = object(settings.lsp, ["enabled", "serverName", "command", "args", "cwd", "env", "toolCallTimeoutMs", "failOnStartupError"]);
324
+ configured(lsp.command);
325
+ configured(lsp.cwd);
326
+ if (!Array.isArray(lsp.args) || lsp.args.some((value2) => value2 !== "<configured>")) fail("private arguments");
327
+ const env = object(lsp.env, [], Object.keys(lsp.env));
328
+ for (const [key, value2] of Object.entries(env)) if (!/^variable-[1-9][0-9]*$/u.test(key) || value2 !== "<redacted>") fail("private environment");
329
+ }
330
+ if (settings.presets !== void 0) {
331
+ const presets = object(settings.presets, ["materialize"], ["root"]);
332
+ if (presets.root !== void 0 && presets.root !== "<configured>") fail("private directory");
333
+ }
334
+ if (settings.runtimeRecovery !== void 0) {
335
+ const recovery = object(settings.runtimeRecovery, ["enabled", "retryOnStatusCodes", "retryOnCodes", "fallbackRoutes", "maxFallbackAttempts", "idleContinuation"]);
336
+ const idle = object(recovery.idleContinuation, ["enabled", "maxContinuations", "prompt"]);
337
+ configured(idle.prompt);
338
+ }
339
+ return settings;
340
+ }
341
+ function editorSnapshot(value) {
342
+ const row = object(value, ["entryId", "namespace", "hostProfileKey", "global", "globalRevision", "profile", "nativeRevision", "nativeFormRevision", "nativeForm", "desired", "sources", "startup", "defaults", "schema", "nextRoot", "modules"], ["startupSources"]);
343
+ const result = jsonData(row);
344
+ text(row.entryId, "entryId", 256);
345
+ if (row.namespace !== null) text(row.namespace, "namespace", 256);
346
+ revision(row.hostProfileKey);
347
+ selectionRevision(row.globalRevision);
348
+ revision(row.nativeRevision);
349
+ if (row.nativeFormRevision !== null) integer(row.nativeFormRevision, "nativeFormRevision");
350
+ for (const key of ["global", "profile", "desired", "sources", "startup", "defaults", "schema"]) object(row[key], [], Object.keys(row[key]));
351
+ if (row.nativeForm !== null) object(row.nativeForm, ["base", "user"]);
352
+ if (row.nextRoot !== null) result.nextRoot = admissionView(row.nextRoot);
353
+ result.desired = readOnlySettingsData(row.desired);
354
+ result.startup = readOnlySettingsData(row.startup);
355
+ result.schema = schemaNode(row.schema);
356
+ for (const map of [result.sources, result.startupSources]) {
357
+ if (map === void 0) continue;
358
+ object(map, [], Object.keys(map));
359
+ for (const [path, value2] of Object.entries(map)) {
360
+ if (path.startsWith("lsp.env.")) fail("private environment field");
361
+ text(value2, "source", 128);
362
+ }
363
+ }
364
+ result.modules = moduleStates(row.modules);
365
+ return result;
366
+ }
367
+ function schemaNode(value) {
368
+ const row = object(value, ["type"], ["fields", "inner", "alternatives", "value", "min", "max", "step", "required", "keys", "nonempty"]);
369
+ if (!["object", "dict", "array", "union", "const", "string", "number", "boolean"].includes(String(row.type))) fail("schema type");
370
+ const node = { type: String(row.type) };
371
+ if (row.fields !== void 0) node.fields = Object.fromEntries(Object.entries(object(row.fields, [], Object.keys(row.fields))).map(([key, child]) => [key, schemaNode(child)]));
372
+ if (row.inner !== void 0) node.inner = schemaNode(row.inner);
373
+ if (row.alternatives !== void 0) {
374
+ if (!Array.isArray(row.alternatives)) fail("schema alternatives");
375
+ node.alternatives = row.alternatives.map(schemaNode);
376
+ }
377
+ if (Object.hasOwn(row, "value")) {
378
+ if (!["string", "number", "boolean"].includes(typeof row.value)) fail("schema value");
379
+ node.value = row.value;
380
+ }
381
+ for (const key of ["min", "max", "step"]) if (row[key] !== void 0) {
382
+ if (typeof row[key] !== "number" || !Number.isFinite(row[key])) fail("schema bound");
383
+ node[key] = row[key];
384
+ }
385
+ if (row.required !== void 0) node.required = boolean(row.required, "schema required");
386
+ if (row.nonempty !== void 0) {
387
+ if (row.type !== "string") fail("schema nonempty");
388
+ node.nonempty = boolean(row.nonempty, "schema nonempty");
389
+ }
390
+ if (row.keys !== void 0) {
391
+ if (row.type !== "dict" || !Array.isArray(row.keys) || row.keys.length > 64) fail("schema keys");
392
+ node.keys = row.keys.map((key) => text(key, "schema key", 128));
393
+ }
394
+ return node;
395
+ }
396
+ function globalSaveRequest(value) {
397
+ const row = object(value, ["expectedRevision", "edits"]);
398
+ if (!Array.isArray(row.edits) || row.edits.length > 128) fail("edits");
399
+ return { expectedRevision: selectionRevision(row.expectedRevision), edits: row.edits.map((value2) => {
400
+ const edit = object(value2, ["op", "path"], ["value"]);
401
+ if (!Array.isArray(edit.path) || edit.path.length < 1 || edit.path.length > 8) fail("field path");
402
+ const path = edit.path.map((part) => {
403
+ const key = text(part, "field", 128);
404
+ if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/u.test(key) || ["constructor", "prototype", "__proto__"].includes(key)) fail("field");
405
+ return key;
406
+ });
407
+ if (edit.op === "unset" && !Object.hasOwn(edit, "value")) return { op: "unset", path };
408
+ if (edit.op !== "set" || !Object.hasOwn(edit, "value")) fail("edit");
409
+ return { op: "set", path, value: jsonData(edit.value) };
410
+ }) };
411
+ }
412
+ function configDescriptor(method, parameter) {
413
+ return {
414
+ id: `@dsmm/dsmm#dsmmConfig/${method}`,
415
+ service: "dsmmConfig",
416
+ namespace: "dsmmConfig",
417
+ method,
418
+ invocation: { kind: "direct" },
419
+ parameters: parameter === void 0 ? [] : [{ name: "request", wire: "request", source: "json", codec: parameter }],
420
+ result: codec("GlobalConfigSnapshot", globalSnapshot)
421
+ };
422
+ }
423
+ function moduleStates(value) {
424
+ if (!Array.isArray(value) || value.length !== 1) fail("modules");
425
+ return value.map((value2) => {
426
+ const row = object(value2, ["descriptor", "hostBundleEnabled", "desired", "startupMounted", "admitted", "nextRoot", "reason", "pending"]);
427
+ const descriptor2 = object(row.descriptor, ["id", "label", "key"]);
428
+ if (descriptor2.id !== "deepwork" || descriptor2.label !== "Deepwork" || descriptor2.key !== "modules.deepwork.enabled" || row.hostBundleEnabled !== "unknown") fail("module descriptor");
429
+ const desired = object(row.desired, ["enabled", "source", "capture"]), next = object(row.nextRoot, ["admitted", "reason"]);
430
+ if (!["defaults", "global"].includes(String(desired.source)) || !["current-global", "admission", "startup"].includes(String(desired.capture)) || ![null, "global-disabled", "restart-required"].includes(next.reason) || ![null, "global-disabled", "restart-required", "captured-off"].includes(row.reason)) fail("module state");
431
+ return {
432
+ descriptor: { id: "deepwork", label: "Deepwork", key: "modules.deepwork.enabled" },
433
+ hostBundleEnabled: "unknown",
434
+ desired: { enabled: boolean(desired.enabled, "desired.enabled"), source: desired.source, capture: desired.capture },
435
+ startupMounted: boolean(row.startupMounted, "startupMounted"),
436
+ admitted: row.admitted === null ? null : boolean(row.admitted, "admitted"),
437
+ nextRoot: { admitted: boolean(next.admitted, "nextRoot.admitted"), reason: next.reason },
438
+ reason: row.reason,
439
+ pending: boolean(row.pending, "pending")
440
+ };
441
+ });
442
+ }
270
443
  var TYPERT_REMOTE = {
271
444
  package: "@dsmm/dsmm",
272
445
  descriptors: [
446
+ configDescriptor("describe"),
447
+ configDescriptor("save", codec("GlobalConfigSaveRequest", globalSaveRequest)),
448
+ { ...configDescriptor("describeModules"), result: codec("DsmmModuleStateArray", moduleStates) },
449
+ { ...configDescriptor("describeSettings"), result: codec("DeploymentEditorSnapshot", editorSnapshot) },
273
450
  {
274
451
  ...descriptor("selectMode", codec("SessionProfileSnapshot", sessionSnapshot)),
275
452
  parameters: [
@@ -2244,6 +2421,10 @@ var ProfilesController = class {
2244
2421
  // src/client/locales.ts
2245
2422
  var NS = "settings.dsmm-profiles";
2246
2423
  var en = {
2424
+ centralOrigin: "Named resources: shared central store.",
2425
+ legacyOrigin: "Named resources: legacy native-profile store (read-only).",
2426
+ explicitOrigin: "Named resources: explicitly configured store.",
2427
+ readOnlyOrigin: "This legacy store is read-only. Files are not copied or migrated; selection and current-session actions retain their own authority.",
2247
2428
  headerCompactProfiles: "Profiles · keep model",
2248
2429
  headerCompactRefresh: "Refresh",
2249
2430
  headerNoSession: "Select a session to make changes.",
@@ -2335,7 +2516,7 @@ var en = {
2335
2516
  headerCancelledRefused: "The profile request was cancelled. Refresh current-session state before retrying; do not assume a change completed.",
2336
2517
  headerUnavailableRefused: "The native session or profile service is unavailable. Reconnect and refresh before retrying.",
2337
2518
  headerWaitRetryHint: "Wait for the native work or maintenance to finish, then Refresh and retry. No profile change is queued automatically.",
2338
- noSession: "No native session is selected. Session Apply is disabled; global defaults and drafts remain editable.",
2519
+ noSession: "No native session is selected. Applying to the current session is unavailable.",
2339
2520
  sessionUnavailable: "The current session could not be confirmed. Refresh its state before retrying; the prior policy is kept.",
2340
2521
  sessionBusy: "Switching is unavailable: {reason}. The Host must reserve a truly idle ordinary session before applying.",
2341
2522
  sessionState: "Session {id}: {profile}; scope {scope}; admission epoch {epoch}.",
@@ -2415,6 +2596,10 @@ var en = {
2415
2596
  invalidNumber: "Correct this bounded integer before saving or changing roles. The invalid value has not replaced the saved draft policy."
2416
2597
  };
2417
2598
  var zh = {
2599
+ centralOrigin: "具名资源:共享中央存储。",
2600
+ legacyOrigin: "具名资源:旧原生配置存储(只读)。",
2601
+ explicitOrigin: "具名资源:显式指定的存储。",
2602
+ readOnlyOrigin: "此旧存储只读,不复制或迁移文件;选择与当前会话操作仍使用各自的权限。",
2418
2603
  headerCompactProfiles: "配置档 · 保留模型",
2419
2604
  headerCompactRefresh: "刷新",
2420
2605
  headerNoSession: "选择会话后可更改。",
@@ -2506,7 +2691,7 @@ var zh = {
2506
2691
  headerCancelledRefused: "配置档请求已取消,请刷新当前会话状态后重试,不要假定更改已完成。",
2507
2692
  headerUnavailableRefused: "原生会话或配置档服务不可用,请重新连接并刷新后重试。",
2508
2693
  headerWaitRetryHint: "请等待原生运行或维护结束,然后刷新并重试。不会自动排队应用配置档。",
2509
- noSession: "未选择原生会话。会话应用已禁用;仍可编辑全局默认值和草稿。",
2694
+ noSession: "未选择原生会话。无法应用到当前会话。",
2510
2695
  sessionUnavailable: "无法确认当前会话。重试前请刷新状态;原策略已保留。",
2511
2696
  sessionBusy: "暂不可切换:{reason}。Host 必须先保留真正空闲的普通会话。",
2512
2697
  sessionState: "会话 {id}:{profile};范围 {scope};准入代次 {epoch}。",
@@ -2981,6 +3166,8 @@ function ProfilesSection(props) {
2981
3166
  const disabled = state.busy !== null || state.pendingEditor !== null || state.sessionBusy === "apply" || state.sessionBusy === "reset";
2982
3167
  const snapshot2 = state.snapshot;
2983
3168
  const editor = state.editor;
3169
+ const readOnly = snapshot2?.readOnly === true;
3170
+ const editorDisabled = disabled || readOnly;
2984
3171
  const reconcilable = canReconcileSelection(snapshot2);
2985
3172
  const selectionConflict = reconcilable && snapshot2?.selectionError?.code === "conflict";
2986
3173
  const invalid = state.issue?.kind === "domain" && state.issue.code === "validation";
@@ -3009,17 +3196,19 @@ function ProfilesSection(props) {
3009
3196
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "dsmm-profiles", "aria-labelledby": `${prefix}-title`, "aria-busy": state.busy !== null, children: [
3010
3197
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { id: `${prefix}-title`, children: t("title") }),
3011
3198
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: t("description") }),
3199
+ snapshot2?.origin !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "dsmm-hint", children: t(snapshot2.origin === "legacy" ? "legacyOrigin" : snapshot2.origin === "central" ? "centralOrigin" : "explicitOrigin") }),
3200
+ readOnly && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { role: "status", className: "dsmm-hint", children: t("readOnlyOrigin") }),
3012
3201
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { id: `${prefix}-global`, children: t("globalScope") }),
3013
3202
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "dsmm-hint", children: t("newSessions") }),
3014
3203
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { "data-dsmm-selection": true, children: selection }),
3015
3204
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-actions", children: [
3016
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled: disabled || snapshot2 === null, onClick: () => {
3205
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled: editorDisabled || snapshot2 === null, onClick: () => {
3017
3206
  void props.create();
3018
3207
  }, children: t("new") }),
3019
3208
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled, onClick: () => {
3020
3209
  void props.refresh();
3021
3210
  }, children: t(state.busy === "refresh" ? "refreshing" : "refresh") }),
3022
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled: disabled || !reconcilable || snapshot2?.selectedId === null && !selectionConflict, onClick: () => {
3211
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled: editorDisabled || !reconcilable || snapshot2?.selectedId === null && !selectionConflict, onClick: () => {
3023
3212
  void props.reset();
3024
3213
  }, children: t(state.busy === "reset" ? "resetting" : "reset") })
3025
3214
  ] }),
@@ -3066,12 +3255,12 @@ function ProfilesSection(props) {
3066
3255
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Input, { ref: inputRef, id: `${prefix}-id`, className: "dsmm-input", value: editor.id, disabled: disabled || editor.revision !== null, "aria-invalid": idInvalid || void 0, "aria-describedby": `${prefix}-id-hint${idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editId(event.currentTarget.value) }),
3067
3256
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { id: `${prefix}-id-hint`, className: "dsmm-hint", children: t("idHint") })
3068
3257
  ] }),
3069
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StructuredEditor, { state, actions: props, disabled, t }, state.editorEpoch),
3258
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StructuredEditor, { state, actions: props, disabled: editorDisabled, t }, state.editorEpoch),
3070
3259
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("details", { className: "dsmm-advanced", open: true, children: [
3071
3260
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("summary", { children: t("advanced") }),
3072
3261
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-field", children: [
3073
3262
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { htmlFor: `${prefix}-content`, children: t("configuration") }),
3074
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("textarea", { ref: editorRef, id: `${prefix}-content`, rows: 12, spellCheck: false, value: editor.content, disabled, "aria-invalid": rawInvalid || invalid && !idInvalid || void 0, "aria-describedby": `${prefix}-content-hint ${prefix}-structural-hint${invalid && !idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editContent(event.currentTarget.value) }),
3263
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("textarea", { ref: editorRef, id: `${prefix}-content`, rows: 12, spellCheck: false, value: editor.content, readOnly, disabled, "aria-invalid": rawInvalid || invalid && !idInvalid || void 0, "aria-describedby": `${prefix}-content-hint ${prefix}-structural-hint${invalid && !idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editContent(event.currentTarget.value) }),
3075
3264
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { id: `${prefix}-content-hint`, className: "dsmm-hint", children: t("configurationHint") }),
3076
3265
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { id: `${prefix}-structural-hint`, className: "dsmm-hint", children: t("structuralHint") })
3077
3266
  ] })
@@ -3079,10 +3268,10 @@ function ProfilesSection(props) {
3079
3268
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { "data-dsmm-editor-state": true, children: t(state.dirty ? "dirty" : applied ? "savedApplied" : "savedNotApplied") }),
3080
3269
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { id: `${prefix}-global-action`, className: "dsmm-hint", children: t("globalActionHint") }),
3081
3270
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-actions", children: [
3082
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "primary", disabled: disabled || !state.dirty || snapshot2 === null || state.invalidFields.length > 0, onClick: () => {
3271
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "primary", disabled: editorDisabled || !state.dirty || snapshot2 === null || state.invalidFields.length > 0, onClick: () => {
3083
3272
  void props.save();
3084
3273
  }, children: t(state.busy === "save" ? "saving" : "save") }),
3085
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", "aria-describedby": `${prefix}-global-action`, disabled: disabled || state.dirty || editor.revision === null || !reconcilable || applied && !selectionConflict, onClick: () => {
3274
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", "aria-describedby": `${prefix}-global-action`, disabled: editorDisabled || state.dirty || editor.revision === null || !reconcilable || applied && !selectionConflict, onClick: () => {
3086
3275
  void props.apply();
3087
3276
  }, children: t(state.busy === "apply" ? "applying" : "apply") }),
3088
3277
  editor.revision !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled, onClick: () => {
@@ -3090,22 +3279,8 @@ function ProfilesSection(props) {
3090
3279
  }, children: t("reload") })
3091
3280
  ] })
3092
3281
  ] }),
3093
- state.issue !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-issue", id: `${prefix}-issue`, role: "alert", children: [
3094
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: t(issueKey(state.issue)) }),
3095
- state.issue.kind === "domain" && state.issue.message !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
3096
- t("details"),
3097
- ": ",
3098
- state.issue.message
3099
- ] })
3100
- ] }),
3101
- snapshot2?.selectionError !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsmm-issue", children: [
3102
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
3103
- t("details"),
3104
- ": ",
3105
- snapshot2.selectionError.message
3106
- ] }),
3107
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: t(selectionConflict ? "selectionConflict" : "retry") })
3108
- ] }),
3282
+ state.issue !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsmm-issue", id: `${prefix}-issue`, role: "alert", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: t(issueKey(state.issue)) }) }),
3283
+ snapshot2?.selectionError !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsmm-issue", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: t(selectionConflict ? "selectionConflict" : "retry") }) }),
3109
3284
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.busy === "refresh" && snapshot2 === null ? t("loading") : state.busy === "read" ? t("reading") : notice })
3110
3285
  ] });
3111
3286
  }
@@ -3150,15 +3325,859 @@ var PROFILE_STYLES = `
3150
3325
  .dsmm-profiles .dsmm-issue{padding:12px;border-left:4px solid var(--dsw-alias-state-error-primary);color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}
3151
3326
  .dsmm-profiles .dsmm-issue p+p{margin-top:8px}
3152
3327
  .dsmm-profiles .dsmm-status{min-height:22px}
3328
+ .dsmm-deployment{gap:8px}
3329
+ .dsmm-deployment .dsmm-deployment-card{min-width:0;border:1px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md)}
3330
+ .dsmm-deployment .dsmm-deployment-card>summary{padding:8px 12px;font-weight:500;line-height:22px;min-height:32px;box-sizing:border-box}
3331
+ .dsmm-deployment .dsmm-deployment-card>summary:hover{background:var(--dsw-alias-interactive-bg-hover)}
3332
+ .dsmm-deployment .dsmm-deployment-card>summary:active{background:var(--dsw-alias-interactive-bg-active)}
3333
+ .dsmm-deployment .dsmm-deployment-card>summary>span{margin-left:8px;font-weight:400}
3334
+ .dsmm-deployment .dsmm-deployment-card>summary>span:empty{display:none}
3335
+ .dsmm-deployment .dsmm-deployment-card>div,.dsmm-deployment .dsmm-deployment-card>fieldset{display:flex;flex-direction:column;gap:8px;padding:0 12px 12px;border:0}
3336
+ .dsmm-deployment .dsmm-deployment-card>fieldset>legend{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
3337
+ .dsmm-deployment .dsmm-deployment-group{border-top:1px solid var(--dsw-alias-border-l4);padding-top:8px;min-width:0}
3338
+ .dsmm-deployment .dsmm-deployment-group>div{display:flex;flex-direction:column;gap:8px;padding-top:8px}
3339
+ .dsmm-deployment code{font-family:var(--ds-font-family-code);overflow-wrap:anywhere}
3340
+ .dsmm-deployment label code,.dsmm-deployment summary code{margin-left:8px;font-size:12px;line-height:18px;font-weight:400;color:var(--dsw-alias-label-secondary)}
3341
+ .dsmm-deployment pre{margin:0;max-width:100%;white-space:pre-wrap;overflow-wrap:anywhere;font-family:var(--ds-font-family-code)}
3342
+ .dsmm-deployment .dsmm-deployment-state{display:flex;flex-direction:column;gap:4px;margin:0;padding:12px;border-top:1px solid var(--dsw-alias-border-l4)}
3343
+ .dsmm-deployment .dsmm-deployment-state dd{margin:0;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}
3153
3344
  @media(prefers-reduced-motion:reduce){.dsmm-profiles *{transition:none!important;animation:none!important}}
3154
3345
  `;
3155
3346
 
3347
+ // src/client/deployment-data.ts
3348
+ function record2(value) {
3349
+ return value !== null && typeof value === "object" && !Array.isArray(value);
3350
+ }
3351
+ function at(value, path) {
3352
+ return path.reduce((node, key) => record2(node) && Object.hasOwn(node, key) ? node[key] : void 0, value);
3353
+ }
3354
+ function equal(a, b) {
3355
+ if (record2(a) && record2(b)) return Object.keys(a).length === Object.keys(b).length && Object.keys(a).every((key) => Object.hasOwn(b, key) && equal(a[key], b[key]));
3356
+ if (Array.isArray(a) && Array.isArray(b)) return a.length === b.length && a.every((value, i) => equal(value, b[i]));
3357
+ return a === b;
3358
+ }
3359
+ function mergeLayer(base, override) {
3360
+ if (!record2(base) || !record2(override)) return override;
3361
+ return Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(base), ...Object.keys(override)])].map((key) => [
3362
+ key,
3363
+ Object.hasOwn(override, key) ? mergeLayer(base[key], override[key]) : base[key]
3364
+ ]));
3365
+ }
3366
+ function parseAdvanced(text2) {
3367
+ if (text2.trim() === "") return void 0;
3368
+ const errors = [];
3369
+ const root = parseTree2(text2, errors, { disallowComments: true, allowTrailingComma: false });
3370
+ const unique = (node) => {
3371
+ if (node.type === "object") {
3372
+ const keys = node.children.map((child) => child.children[0].value);
3373
+ if (new Set(keys).size !== keys.length) return false;
3374
+ }
3375
+ return (node.children ?? []).every(unique);
3376
+ };
3377
+ if (root === void 0 || errors.length || !unique(root)) throw new Error("Invalid JSON");
3378
+ return JSON.parse(text2);
3379
+ }
3380
+ function editLayer(base, path, value) {
3381
+ const next = structuredClone(base);
3382
+ let node = next;
3383
+ for (const key2 of path.slice(0, -1)) {
3384
+ if (!record2(node[key2])) node[key2] = {};
3385
+ node = node[key2];
3386
+ }
3387
+ const key = path.at(-1);
3388
+ if (value === void 0) delete node[key];
3389
+ else node[key] = structuredClone(value);
3390
+ return next;
3391
+ }
3392
+ function layerDiff(base, draft, prefix = []) {
3393
+ return [.../* @__PURE__ */ new Set([...Object.keys(base), ...Object.keys(draft)])].flatMap((key) => {
3394
+ const path = [...prefix, key], before = base[key], after = draft[key];
3395
+ if (equal(before, after)) return [];
3396
+ if (!Object.hasOwn(draft, key)) return [{ op: "unset", path }];
3397
+ if (record2(before) && record2(after)) return layerDiff(before, after, path);
3398
+ return [{ op: "set", path, value: after }];
3399
+ });
3400
+ }
3401
+ function validateEditorValue(value, schema, sparse = false) {
3402
+ if (schema.type === "union") return schema.alternatives?.some((node) => validateEditorValue(value, node, sparse)) === true;
3403
+ if (schema.type === "const") return value === schema.value;
3404
+ if (schema.type === "object" || schema.type === "dict") return record2(value) && (sparse || schema.type !== "object" || Object.entries(schema.fields ?? {}).every(([key, node]) => !node.required || Object.hasOwn(value, key))) && Object.entries(value).every(([key, child]) => {
3405
+ if (["__proto__", "prototype", "constructor"].includes(key)) return false;
3406
+ if (schema.keys !== void 0 && !schema.keys.includes(key)) return false;
3407
+ const node = schema.type === "dict" ? schema.inner : schema.fields?.[key];
3408
+ return node !== void 0 && validateEditorValue(child, node, sparse);
3409
+ });
3410
+ if (schema.type === "array") return Array.isArray(value) && (schema.max === void 0 || value.length <= schema.max) && schema.inner !== void 0 && value.every((child) => validateEditorValue(child, schema.inner));
3411
+ if (schema.type === "string" && schema.nonempty) return typeof value === "string" && value.trim() !== "";
3412
+ if (["string", "boolean", "number"].includes(schema.type)) return typeof value === schema.type && (typeof value !== "number" || Number.isFinite(value) && (schema.min === void 0 || value >= schema.min) && (schema.max === void 0 || value <= schema.max) && (schema.step === void 0 || Number.isInteger(value / schema.step)));
3413
+ return false;
3414
+ }
3415
+ function enumValues(schema) {
3416
+ return schema.type === "union" && schema.alternatives?.every((node) => node.type === "const") ? schema.alternatives.map((node) => node.value) : null;
3417
+ }
3418
+ function inspectorPaths(snapshot2, admitted) {
3419
+ const paths = /* @__PURE__ */ new Set([
3420
+ ...Object.keys(snapshot2.sources),
3421
+ ...Object.keys(snapshot2.startupSources ?? {}),
3422
+ ...Object.keys(snapshot2.nextRoot?.sources ?? {}),
3423
+ ...Object.keys(snapshot2.nextRoot?.captures ?? {}),
3424
+ ...Object.keys(admitted?.sources ?? {}),
3425
+ ...Object.keys(admitted?.captures ?? {})
3426
+ ]);
3427
+ const visit2 = (value, path) => {
3428
+ if (record2(value) && Object.keys(value).length && path.join(".") !== "lsp.env") for (const [key, child] of Object.entries(value)) visit2(child, [...path, key]);
3429
+ else if (path.length) paths.add(path.join("."));
3430
+ };
3431
+ for (const value of [snapshot2.desired, snapshot2.startup, snapshot2.nextRoot?.settings, admitted?.settings]) if (value !== void 0) visit2(value, []);
3432
+ return [...paths].sort();
3433
+ }
3434
+
3435
+ // src/client/deployment-controller.ts
3436
+ var Refusal = class extends Error {
3437
+ constructor(code) {
3438
+ super(code);
3439
+ this.code = code;
3440
+ }
3441
+ };
3442
+ async function unwrap(promise) {
3443
+ const result = await promise;
3444
+ if (result.ok) return result.value;
3445
+ if (result.error.code === "dsmm-profiles/refused") {
3446
+ const code = result.error.details.code;
3447
+ throw new Refusal(["conflict", "validation", "not-owned"].includes(code) ? code : "unavailable");
3448
+ }
3449
+ throw new Refusal("transport");
3450
+ }
3451
+ var DeploymentController = class _DeploymentController {
3452
+ constructor(remote, layer, rowNamespace = null) {
3453
+ this.remote = remote;
3454
+ this.layer = layer;
3455
+ this.rowNamespace = rowNamespace;
3456
+ }
3457
+ state = { snapshot: null, draft: {}, dirty: false, busy: false, issue: null, saved: false, session: null };
3458
+ listeners = /* @__PURE__ */ new Set();
3459
+ generation = 0;
3460
+ disposed = false;
3461
+ baseline = {};
3462
+ form = null;
3463
+ invalid = /* @__PURE__ */ new Set();
3464
+ connection = null;
3465
+ connectionBaseline;
3466
+ stopConnection = null;
3467
+ getSnapshot = () => this.state;
3468
+ subscribe = (listener) => {
3469
+ this.listeners.add(listener);
3470
+ return () => this.listeners.delete(listener);
3471
+ };
3472
+ dispose() {
3473
+ this.disposed = true;
3474
+ this.generation++;
3475
+ this.stopConnection?.();
3476
+ this.listeners.clear();
3477
+ this.form = null;
3478
+ }
3479
+ bindConnection(source) {
3480
+ this.stopConnection?.();
3481
+ this.connection = source;
3482
+ this.stopConnection = source.subscribe(() => {
3483
+ if (this.disposed) return;
3484
+ this.generation++;
3485
+ this.publish({ busy: false, issue: source.getSnapshot() === void 0 ? "transport" : "conflict", saved: false });
3486
+ });
3487
+ }
3488
+ forProfile(namespace) {
3489
+ const controller = new _DeploymentController(this.remote, "profile", namespace);
3490
+ if (this.connection !== null) controller.bindConnection(this.connection);
3491
+ return controller;
3492
+ }
3493
+ currentConnection() {
3494
+ return this.connection === null || this.connection.getSnapshot() !== void 0 && this.connection.getSnapshot() === this.connectionBaseline;
3495
+ }
3496
+ setSession(session) {
3497
+ this.publish({ session });
3498
+ }
3499
+ publish(patch) {
3500
+ if (this.disposed) return;
3501
+ this.state = { ...this.state, ...patch };
3502
+ for (const listener of this.listeners) listener();
3503
+ }
3504
+ attachForm(form) {
3505
+ this.form = form;
3506
+ }
3507
+ setInvalid(path, invalid) {
3508
+ if (this.invalid.has(path) === invalid) return;
3509
+ if (invalid) this.invalid.add(path);
3510
+ else this.invalid.delete(path);
3511
+ this.publish({ dirty: this.invalid.size > 0 || !equal(this.baseline, this.state.draft), saved: false });
3512
+ }
3513
+ canWriteProfile(snapshot2 = this.state.snapshot) {
3514
+ const native = this.form?.state;
3515
+ return this.currentConnection() && snapshot2 !== null && this.rowNamespace !== null && this.rowNamespace === snapshot2.namespace && native?.status === "ready" && native.mode === "host" && native.writable && native.revision === snapshot2.nativeFormRevision && snapshot2.nativeForm !== null && equal(native.base ?? null, snapshot2.nativeForm.base) && equal(native.user ?? null, snapshot2.nativeForm.user);
3516
+ }
3517
+ edit(path, value) {
3518
+ if (this.state.busy || this.disposed || this.state.snapshot === null || !this.currentConnection() || this.state.issue === "not-owned" || this.layer === "profile" && !this.canWriteProfile()) return;
3519
+ const draft = editLayer(this.state.draft, path, value);
3520
+ this.publish({ draft, dirty: this.invalid.size > 0 || !equal(this.baseline, draft), issue: null, saved: false });
3521
+ }
3522
+ async refresh(discard = false) {
3523
+ if (this.disposed || this.state.busy) return;
3524
+ const generation = ++this.generation;
3525
+ const connection = this.connection?.getSnapshot();
3526
+ this.publish({ busy: true, saved: false });
3527
+ try {
3528
+ if (this.connection !== null && connection === void 0) throw new Refusal("transport");
3529
+ const snapshot2 = await unwrap(this.remote.describeSettings());
3530
+ if (this.disposed || generation !== this.generation) return;
3531
+ const old = this.state.snapshot;
3532
+ if (old !== null && (old.entryId !== snapshot2.entryId || old.hostProfileKey !== snapshot2.hostProfileKey)) throw new Refusal("unavailable");
3533
+ if (this.state.dirty && !discard) {
3534
+ const stale = !this.currentConnection() || (this.layer === "global" ? old?.globalRevision !== snapshot2.globalRevision : old?.nativeRevision !== snapshot2.nativeRevision || old?.globalRevision !== snapshot2.globalRevision);
3535
+ this.publish({ issue: stale ? "conflict" : null });
3536
+ } else {
3537
+ this.invalid.clear();
3538
+ this.connectionBaseline = connection;
3539
+ this.baseline = this.layer === "global" ? snapshot2.global : record2(snapshot2.nativeForm?.user) ? snapshot2.nativeForm.user : {};
3540
+ this.publish({ snapshot: snapshot2, draft: structuredClone(this.baseline), dirty: false, issue: null });
3541
+ }
3542
+ } catch (error) {
3543
+ if (!this.disposed && generation === this.generation) this.publish({ issue: error instanceof Refusal ? error.code : "transport" });
3544
+ } finally {
3545
+ if (!this.disposed && generation === this.generation) this.publish({ busy: false });
3546
+ }
3547
+ }
3548
+ async save() {
3549
+ const { snapshot: snapshot2, draft, dirty, busy, issue } = this.state;
3550
+ if (this.disposed || snapshot2 === null || !dirty || busy || issue !== null || !this.currentConnection() || this.invalid.size > 0 || this.layer === "profile" && !this.canWriteProfile()) return;
3551
+ const schema = this.layer === "global" ? snapshot2.schema : { ...snapshot2.schema, fields: Object.fromEntries(Object.entries(snapshot2.schema.fields ?? {}).filter(([key]) => key !== "modules")) };
3552
+ const editable = { ...draft };
3553
+ if (this.layer === "profile") {
3554
+ if (!equal(editable.sessionPersistence, this.baseline.sessionPersistence)) {
3555
+ this.publish({ issue: "validation" });
3556
+ return;
3557
+ }
3558
+ delete editable.sessionPersistence;
3559
+ }
3560
+ const lower = this.layer === "global" ? snapshot2.defaults : mergeLayer(mergeLayer(snapshot2.defaults, snapshot2.global), snapshot2.nativeForm?.base ?? {});
3561
+ const candidate = mergeLayer(lower, editable);
3562
+ const merged = this.layer === "global" ? mergeLayer(candidate, snapshot2.profile) : candidate;
3563
+ delete merged.sessionPersistence;
3564
+ if (!validateEditorValue(editable, schema, true) || !validateEditorValue(merged, snapshot2.schema)) {
3565
+ this.publish({ issue: "validation" });
3566
+ return;
3567
+ }
3568
+ const edits = layerDiff(this.baseline, draft);
3569
+ if (edits.length > 128) {
3570
+ this.publish({ issue: "validation" });
3571
+ return;
3572
+ }
3573
+ const generation = ++this.generation;
3574
+ this.publish({ busy: true, saved: false });
3575
+ try {
3576
+ const current = await unwrap(this.remote.describeSettings());
3577
+ if (this.disposed || generation !== this.generation) return;
3578
+ if (current.entryId !== snapshot2.entryId || current.hostProfileKey !== snapshot2.hostProfileKey || current.globalRevision !== snapshot2.globalRevision) throw new Refusal("conflict");
3579
+ if (this.layer === "global") await unwrap(this.remote.save({ expectedRevision: snapshot2.globalRevision, edits }));
3580
+ else {
3581
+ if (current.nativeRevision !== snapshot2.nativeRevision || !this.canWriteProfile(current)) throw new Refusal("conflict");
3582
+ const form = this.form;
3583
+ if (!await form.mutate(edits, snapshot2.nativeFormRevision)) throw new Refusal("conflict");
3584
+ }
3585
+ if (this.disposed || generation !== this.generation) return;
3586
+ this.baseline = structuredClone(draft);
3587
+ this.publish({ dirty: false, saved: true, issue: null });
3588
+ try {
3589
+ const next = await unwrap(this.remote.describeSettings());
3590
+ if (!this.disposed && generation === this.generation) this.publish({ snapshot: next });
3591
+ } catch {
3592
+ if (!this.disposed && generation === this.generation) this.publish({ issue: "unavailable" });
3593
+ }
3594
+ } catch (error) {
3595
+ if (!this.disposed && generation === this.generation) this.publish({ issue: error instanceof Refusal ? error.code : "transport" });
3596
+ } finally {
3597
+ if (!this.disposed && generation === this.generation) this.publish({ busy: false });
3598
+ }
3599
+ }
3600
+ };
3601
+
3602
+ // src/client/DeploymentPage.tsx
3603
+ var import_react4 = require("react");
3604
+ var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
3605
+
3606
+ // src/client/deployment-locales.ts
3607
+ var DEPLOYMENT_NS = "plugins.dsmm";
3608
+ var deploymentEn = {
3609
+ title: "DSMM",
3610
+ summary: "Global config and profile overrides",
3611
+ description: "Layers save independently; native models and running sessions stay unchanged.",
3612
+ global: "DSMM Global config",
3613
+ globalHint: "Shared by this Home’s DSH profiles. Unset fields use built-in defaults.",
3614
+ profile: "Current DSH profile overrides",
3615
+ profileHint: "This entry only. Unset fields inherit Global config.",
3616
+ profileUnavailable: "Unavailable",
3617
+ unavailableForm: "No verified writable form. Open this entry’s bundle or row config to edit profile overrides.",
3618
+ ceiling: "Deepwork master is Global-only; profiles and session modes cannot lift its captured ceiling.",
3619
+ hostUnknown: "Host bundle status: unknown (separate switch).",
3620
+ boundaries: "New roots capture saved settings within startup capabilities. Save does not restart or reload LSP; startup-only changes require a separate Host restart, which may cancel sessions.",
3621
+ saveGlobal: "Save Global config",
3622
+ saveProfile: "Save profile overrides",
3623
+ saving: "Saving…",
3624
+ refresh: "Refresh",
3625
+ discard: "Discard and reload",
3626
+ dirty: "Unsaved changes",
3627
+ saved: "Saved",
3628
+ inherit: "Inherit",
3629
+ explicit: "Override",
3630
+ defaultPin: "Built-in default pinned",
3631
+ hostPin: "Host pin remains when cleared",
3632
+ globalSource: "Global",
3633
+ profileSource: "DSH profile",
3634
+ defaultsSource: "Built-in default",
3635
+ namedSource: "Named/session",
3636
+ startupSource: "Startup capture",
3637
+ deploymentCapture: "Deployment capture",
3638
+ desired: "Merged desired",
3639
+ startup: "Startup mounted / captured",
3640
+ next: "Next root",
3641
+ session: "Current-session admitted",
3642
+ noSession: "No active session: admission is unknown.",
3643
+ sessionUnavailable: "Session admission unavailable. Reconnect and refresh the session separately.",
3644
+ absent: "Absent",
3645
+ mixedSource: "Mixed sources",
3646
+ inspectorStale: "Saved state, not draft",
3647
+ pending: "Pending independent restart",
3648
+ unknown: "Unknown",
3649
+ on: "On",
3650
+ off: "Off",
3651
+ state: "Field sources and effective state",
3652
+ module: "Deepwork module",
3653
+ advanced: "Advanced JSON",
3654
+ advancedHint: "Schema keys only; omit to inherit. Arrays replace. No credentials or scripts; use existing providers.",
3655
+ invalid: "Invalid field. Check type, bounds and keys; draft retained.",
3656
+ conflict: "Revision conflict; draft retained. Review changes, then discard and reload. Refresh does not merge.",
3657
+ unavailable: "Scope unavailable; draft retained. Reconnect and refresh.",
3658
+ "not-owned": "Read-only: requires an authenticated local Host operator.",
3659
+ validation: "Host rejected configuration; draft retained. Check fields and merged constraints.",
3660
+ transport: "Disconnected; draft retained. Reconnect and refresh.",
3661
+ namedIndependent: "Deepwork Profiles is a separate named JSONC runtime-resource editor in Settings. Saving here does not apply a named profile or select its model."
3662
+ };
3663
+ var deploymentZh = {
3664
+ title: "DSMM",
3665
+ summary: "全局配置与当前配置覆盖",
3666
+ description: "两层独立保存,不改原生模型或运行中会话。",
3667
+ global: "DSMM 全局配置",
3668
+ globalHint: "同一 Home 的 DSH 配置共用;未设置字段使用内建默认值。",
3669
+ profile: "当前 DSH 配置覆盖",
3670
+ profileHint: "仅此实例;未设置字段继承全局配置。",
3671
+ profileUnavailable: "不可用",
3672
+ unavailableForm: "没有已核验的可写表单。请打开此实例的 bundle 或条目配置以编辑覆盖。",
3673
+ ceiling: "Deepwork 总开关仅全局可改;配置和会话模式不能突破已捕获上限。",
3674
+ hostUnknown: "宿主整包状态:未知(独立开关)。",
3675
+ boundaries: "新根会话在启动能力内采用已保存设置。保存不重启或重载 LSP;仅启动时生效的更改需另行重启宿主,可能取消会话。",
3676
+ saveGlobal: "保存全局配置",
3677
+ saveProfile: "保存当前配置覆盖",
3678
+ saving: "正在保存…",
3679
+ refresh: "刷新",
3680
+ discard: "丢弃并重载",
3681
+ dirty: "未保存",
3682
+ saved: "已保存",
3683
+ inherit: "继承",
3684
+ explicit: "覆盖",
3685
+ defaultPin: "固定为内建默认值",
3686
+ hostPin: "清除后仍有宿主固定值",
3687
+ globalSource: "全局",
3688
+ profileSource: "DSH 配置",
3689
+ defaultsSource: "内建默认",
3690
+ namedSource: "具名/会话",
3691
+ startupSource: "启动捕获",
3692
+ deploymentCapture: "部署捕获",
3693
+ desired: "合并后意图",
3694
+ startup: "启动挂载/捕获",
3695
+ next: "下一个根会话",
3696
+ session: "当前会话准入",
3697
+ noSession: "没有活动会话:准入状态未知。",
3698
+ sessionUnavailable: "会话准入暂不可用;恢复连接后另行刷新会话。",
3699
+ absent: "不存在",
3700
+ mixedSource: "混合来源",
3701
+ inspectorStale: "已保存状态,非草稿",
3702
+ pending: "等待独立重启",
3703
+ unknown: "未知",
3704
+ on: "开启",
3705
+ off: "关闭",
3706
+ state: "字段来源与实际生效状态",
3707
+ module: "Deepwork 子模块",
3708
+ advanced: "高级 JSON",
3709
+ advancedHint: "仅 schema 声明的键;省略为继承,数组整项替换。不填凭据或脚本,仅用已有提供商。",
3710
+ invalid: "字段无效,请核对类型、范围与键;草稿保留。",
3711
+ conflict: "版本冲突,草稿保留。核对后丢弃并重载;刷新不自动合并。",
3712
+ unavailable: "作用域不可用,草稿保留;重连后刷新。",
3713
+ "not-owned": "只读:需要本地宿主已认证 operator 权限。",
3714
+ validation: "宿主拒绝配置,草稿保留;核对字段及合并约束。",
3715
+ transport: "连接中断,草稿保留;重连后刷新。",
3716
+ namedIndependent: "设置中的 Deepwork Profiles 是独立的具名 JSONC 运行时资源编辑器。在此保存不会应用具名配置或选择其模型。"
3717
+ };
3718
+ var deploymentFieldLabels = {
3719
+ modules: ["Modules", "子模块"],
3720
+ skills: ["Skills", "技能"],
3721
+ roles: ["Agent roles", "Agent 角色"],
3722
+ deepwork: ["Deepwork", "Deepwork"],
3723
+ deepseekV4ProCalibration: ["DeepSeek V4 Pro calibration", "DeepSeek V4 Pro 校准"],
3724
+ deepseekV4ProDefaultReasoningEffort: ["DeepSeek V4 Pro default reasoning", "DeepSeek V4 Pro 默认推理强度"],
3725
+ deepseekV4ProMaxReasoningPresets: ["DeepSeek V4 Pro max presets", "DeepSeek V4 Pro 最高强度预设"],
3726
+ deepseekFlashCalibration: ["DeepSeek Flash calibration", "DeepSeek Flash 校准"],
3727
+ deepseekFlashDefaultReasoningEffort: ["DeepSeek Flash default reasoning", "DeepSeek Flash 默认推理强度"],
3728
+ deepseekFlashMaxReasoningPresets: ["DeepSeek Flash max presets", "DeepSeek Flash 最高强度预设"],
3729
+ roleRouting: ["Existing-provider routes", "已有提供商路由"],
3730
+ runtimePolicy: ["Routing and retry policy", "路由与重试策略"],
3731
+ workflow: ["Workflow gates", "工作流关卡"],
3732
+ guards: ["Safety guards", "安全保护"],
3733
+ runtimeRecovery: ["Runtime recovery", "运行时恢复"],
3734
+ subagents: ["Subagents", "子 Agent"],
3735
+ lsp: ["LSP", "LSP"],
3736
+ presets: ["Preset materialization", "预设物化"],
3737
+ modeName: ["Mode name", "模式名称"],
3738
+ section: ["Prompt section", "提示词章节"],
3739
+ promptOrder: ["Prompt order", "提示词顺序"],
3740
+ defaultActive: ["Default Deepwork mode", "默认 Deepwork 模式"],
3741
+ enabled: ["Enabled", "启用"],
3742
+ materialize: ["Materialize presets", "物化预设"],
3743
+ scope: ["Guard scope", "保护范围"],
3744
+ shellCommandSafety: ["Shell command safety", "Shell 命令安全"],
3745
+ gitWriteGuard: ["Git write policy", "Git 写入策略"],
3746
+ toolOutputTruncation: ["Tool output truncation", "工具输出截断"],
3747
+ maxInlineBytes: ["Inline byte limit", "内联字节上限"],
3748
+ planFormatValidation: ["Plan format validation", "计划格式校验"],
3749
+ questionLabelHelper: ["Question labels", "提问标签"],
3750
+ maxLabelChars: ["Label character limit", "标签字符上限"],
3751
+ todoDisciplineHelper: ["Todo discipline", "待办纪律"],
3752
+ enableRunInBackground: ["Allow background runs", "允许后台执行"],
3753
+ backgroundMode: ["Background mode", "后台模式"],
3754
+ maxDepth: ["Maximum depth", "最大深度"],
3755
+ policy: ["Policy", "策略"],
3756
+ strictGates: ["Strict gates", "严格关卡"],
3757
+ reviewCap: ["Review limit", "审查上限"],
3758
+ finalReviewPolicy: ["Final review policy", "最终审查策略"],
3759
+ retryOnStatusCodes: ["Retry HTTP statuses", "重试 HTTP 状态码"],
3760
+ retryOnCodes: ["Retry error codes", "重试错误码"],
3761
+ fallbackRoutes: ["Ordered fallback routes", "有序备用路由"],
3762
+ maxFallbackAttempts: ["Fallback attempt limit", "备用尝试上限"],
3763
+ idleContinuation: ["Idle continuation", "空闲继续"],
3764
+ maxContinuations: ["Continuation limit", "继续次数上限"],
3765
+ prompt: ["Continuation prompt", "继续提示词"],
3766
+ root: ["Materialization directory", "物化目录"],
3767
+ strategy: ["Routing strategy", "路由策略"],
3768
+ rateLimit: ["Bounded rate-limit retry", "有界限流重试"],
3769
+ maxRetries: ["Retry limit", "重试上限"],
3770
+ initialDelayMs: ["Initial delay (ms)", "初始延迟(毫秒)"],
3771
+ maxDelayMs: ["Delay limit (ms)", "延迟上限(毫秒)"],
3772
+ maxTotalDelayMs: ["Total wait budget (ms)", "累计等待上限(毫秒)"],
3773
+ switchAfterRateLimits: ["Rate limits before switching", "切换前限流次数"],
3774
+ maxSwitches: ["Switch limit", "切换上限"],
3775
+ serverName: ["LSP server name", "LSP 服务名称"],
3776
+ command: ["LSP command", "LSP 命令"],
3777
+ args: ["LSP arguments", "LSP 参数"],
3778
+ cwd: ["LSP working directory", "LSP 工作目录"],
3779
+ env: ["LSP environment", "LSP 环境变量"],
3780
+ toolCallTimeoutMs: ["LSP tool timeout (ms)", "LSP 工具超时(毫秒)"],
3781
+ failOnStartupError: ["Fail on LSP startup error", "LSP 启动错误时拒绝加载"]
3782
+ };
3783
+
3784
+ // src/client/DeploymentPage.tsx
3785
+ var import_jsx_runtime4 = require("react/jsx-runtime");
3786
+ function label(path, t) {
3787
+ const key = path.at(-1);
3788
+ const item = deploymentFieldLabels[key];
3789
+ return item === void 0 ? key.replace(/^dsmm-/u, "").replace(/([a-z])([A-Z])/gu, "$1 $2") : item[t("global") === "DSMM 全局配置" ? 1 : 0];
3790
+ }
3791
+ function displayValue(value, t) {
3792
+ if (value === void 0) return t("unknown");
3793
+ if (typeof value === "boolean") return t(value ? "on" : "off");
3794
+ const text2 = JSON.stringify(value);
3795
+ return text2.length > 120 ? `${text2.slice(0, 120)}…` : text2;
3796
+ }
3797
+ function AdvancedField({ schema, path, value, inherited, upper, reset, disabled, onChange, setInvalid, t }) {
3798
+ const id2 = (0, import_react4.useId)(), name = path.join(".");
3799
+ const serialized = value === void 0 ? "" : JSON.stringify(value, null, 2);
3800
+ const [text2, setText] = (0, import_react4.useState)(serialized);
3801
+ const [invalid, setLocalInvalid] = (0, import_react4.useState)(false);
3802
+ (0, import_react4.useEffect)(() => {
3803
+ setText(serialized);
3804
+ setLocalInvalid(false);
3805
+ setInvalid(name, false);
3806
+ }, [serialized, reset]);
3807
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { className: "dsmm-deployment-group", children: [
3808
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("summary", { children: [
3809
+ label(path, t),
3810
+ " · ",
3811
+ t("advanced"),
3812
+ " ",
3813
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: name })
3814
+ ] }),
3815
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
3816
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { htmlFor: id2, children: [
3817
+ label(path, t),
3818
+ " · ",
3819
+ t("advanced"),
3820
+ " ",
3821
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: name })
3822
+ ] }),
3823
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", id: `${id2}-hint`, children: t("advancedHint") }),
3824
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("textarea", { id: id2, rows: 6, maxLength: 32768, value: text2, disabled, "aria-invalid": invalid, "aria-describedby": `${id2}-hint ${id2}-error`, onChange: (event) => {
3825
+ const next = event.currentTarget.value;
3826
+ setText(next);
3827
+ let parsed, valid = true;
3828
+ try {
3829
+ parsed = parseAdvanced(next);
3830
+ const candidate = parsed === void 0 ? inherited : mergeLayer(inherited, parsed);
3831
+ valid = parsed === void 0 || validateEditorValue(parsed, schema, true) && validateEditorValue(upper === void 0 ? candidate : mergeLayer(candidate, upper), schema);
3832
+ } catch {
3833
+ valid = false;
3834
+ }
3835
+ setLocalInvalid(!valid);
3836
+ setInvalid(name, !valid);
3837
+ if (valid) onChange(parsed);
3838
+ } }),
3839
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { id: `${id2}-error`, className: "dsmm-hint", children: invalid ? t("invalid") : "" }),
3840
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { children: [
3841
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("summary", { children: [
3842
+ t("advanced"),
3843
+ " · schema"
3844
+ ] }),
3845
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("pre", { children: JSON.stringify(schema, null, 2) })
3846
+ ] })
3847
+ ] })
3848
+ ] });
3849
+ }
3850
+ function ScalarField({ schema, path, controller, disabled, inherited, invalid, t }) {
3851
+ const state = (0, import_react4.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
3852
+ const value = at(state.draft, path), name = path.join("."), id2 = (0, import_react4.useId)();
3853
+ const [text2, setText] = (0, import_react4.useState)(String(value ?? inherited ?? ""));
3854
+ const [bad, setBad] = (0, import_react4.useState)(false);
3855
+ (0, import_react4.useEffect)(() => {
3856
+ setText(String(value ?? inherited ?? ""));
3857
+ setBad(false);
3858
+ invalid(name, false);
3859
+ }, [value, inherited, state.snapshot]);
3860
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
3861
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { htmlFor: id2, children: [
3862
+ label(path, t),
3863
+ " ",
3864
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: name })
3865
+ ] }),
3866
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-actions", children: [
3867
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Input, { className: "dsmm-input", id: id2, type: "text", inputMode: schema.type === "number" ? "decimal" : void 0, value: text2, disabled, "aria-invalid": bad, "aria-describedby": `${id2}-error`, onChange: (event) => {
3868
+ const raw = event.currentTarget.value;
3869
+ setText(raw);
3870
+ const candidate = schema.type === "number" ? Number(raw) : raw;
3871
+ const valid = (schema.type !== "number" || raw.trim() !== "") && validateEditorValue(candidate, schema);
3872
+ setBad(!valid);
3873
+ invalid(name, !valid);
3874
+ if (valid) controller.edit(path, candidate);
3875
+ } }),
3876
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Button, { type: "button", variant: "outline", disabled: disabled || value === void 0 && !bad, onClick: () => {
3877
+ setText(String(inherited ?? ""));
3878
+ setBad(false);
3879
+ invalid(name, false);
3880
+ controller.edit(path, void 0);
3881
+ }, children: t("inherit") })
3882
+ ] }),
3883
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { id: `${id2}-error`, className: "dsmm-hint", children: [
3884
+ bad ? t("invalid") : "",
3885
+ schema.type === "number" && (schema.min !== void 0 || schema.max !== void 0) ? ` ${schema.min ?? "—"} – ${schema.max ?? "—"}` : ""
3886
+ ] })
3887
+ ] });
3888
+ }
3889
+ function Field({ schema, path, controller, invalid, t }) {
3890
+ const state = (0, import_react4.useSyncExternalStore)(controller.subscribe, controller.getSnapshot), snapshot2 = state.snapshot;
3891
+ const id2 = (0, import_react4.useId)(), name = path.join("."), explicit = at(state.draft, path);
3892
+ const inherited = controller.layer === "global" ? at(snapshot2.defaults, path) : at(mergeLayer(mergeLayer(snapshot2.defaults, snapshot2.global), snapshot2.nativeForm?.base ?? {}), path);
3893
+ const disabled = state.busy || state.issue === "not-owned" || state.issue === "unavailable" || state.issue === "transport" || controller.layer === "profile" && !controller.canWriteProfile();
3894
+ const choices = enumValues(schema);
3895
+ if (schema.type === "object" && schema.fields !== void 0 && path[0] !== "roleRouting" && path[0] !== "lsp") return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { className: "dsmm-deployment-group", children: [
3896
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("summary", { children: [
3897
+ label(path, t),
3898
+ " ",
3899
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: name })
3900
+ ] }),
3901
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: Object.entries(schema.fields).map(([key, node]) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Field, { schema: node, path: [...path, key], controller, invalid, t }, key)) })
3902
+ ] });
3903
+ if (!["boolean", "string", "number"].includes(schema.type) && choices === null) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AdvancedField, { schema, path, value: explicit, inherited, upper: controller.layer === "global" ? at(snapshot2.profile, path) : void 0, reset: snapshot2, disabled, t, onChange: (value) => controller.edit(path, value), setInvalid: invalid });
3904
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field dsmm-deployment-field", children: [
3905
+ schema.type === "boolean" || choices !== null ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
3906
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { htmlFor: id2, children: [
3907
+ label(path, t),
3908
+ " ",
3909
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: name })
3910
+ ] }),
3911
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: id2, disabled, value: explicit === void 0 ? "inherit" : JSON.stringify(explicit), onChange: (event) => controller.edit(path, event.currentTarget.value === "inherit" ? void 0 : JSON.parse(event.currentTarget.value)), children: [
3912
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("option", { value: "inherit", children: [
3913
+ t("inherit"),
3914
+ " · ",
3915
+ displayValue(inherited, t)
3916
+ ] }),
3917
+ (choices ?? [true, false]).map((choice) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: JSON.stringify(choice), children: displayValue(choice, t) }, String(choice)))
3918
+ ] })
3919
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ScalarField, { schema, path, controller, disabled, inherited, invalid, t }),
3920
+ (explicit !== void 0 || controller.layer === "profile" && at(snapshot2.nativeForm?.base, path) !== void 0) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "dsmm-hint", children: [
3921
+ explicit === void 0 ? "" : equal(explicit, at(snapshot2.defaults, path)) ? t("defaultPin") : t("explicit"),
3922
+ controller.layer === "profile" && at(snapshot2.nativeForm?.base, path) !== void 0 ? `${explicit === void 0 ? "" : " · "}${t("hostPin")}` : ""
3923
+ ] })
3924
+ ] });
3925
+ }
3926
+ function Layer({ controller, t }) {
3927
+ const state = (0, import_react4.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
3928
+ const [invalid, setInvalid] = (0, import_react4.useState)(/* @__PURE__ */ new Set());
3929
+ const updateInvalid = (path, bad) => {
3930
+ controller.setInvalid(path, bad);
3931
+ setInvalid((previous) => {
3932
+ if (previous.has(path) === bad) return previous;
3933
+ const next = new Set(previous);
3934
+ if (bad) next.add(path);
3935
+ else next.delete(path);
3936
+ return next;
3937
+ });
3938
+ };
3939
+ const title = controller.layer === "global" ? "global" : "profile";
3940
+ const disabled = state.busy || state.snapshot === null || state.issue !== null || invalid.size > 0 || controller.layer === "profile" && !controller.canWriteProfile();
3941
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-dsmm-layer": controller.layer, "aria-busy": state.busy, children: [
3942
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { className: "dsmm-deployment-card", children: [
3943
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("summary", { children: [
3944
+ t(title),
3945
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { role: "status", "aria-live": "polite", className: "dsmm-hint", children: state.busy ? t("saving") : state.dirty ? t("dirty") : state.saved ? t("saved") : "" })
3946
+ ] }),
3947
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { children: [
3948
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: t(title) }),
3949
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", children: t(title === "global" ? "globalHint" : "profileHint") }),
3950
+ state.snapshot !== null && Object.entries(state.snapshot.schema.fields ?? {}).filter(([key]) => controller.layer === "global" || key !== "modules").sort(([a], [b]) => a === "modules" ? -1 : b === "modules" ? 1 : 0).map(([key, schema]) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Field, { schema, path: [key], controller, invalid: updateInvalid, t }, key)),
3951
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-actions", children: [
3952
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Button, { type: "button", variant: "primary", disabled: disabled || !state.dirty, onClick: () => {
3953
+ void controller.save();
3954
+ }, children: t(state.busy ? "saving" : title === "global" ? "saveGlobal" : "saveProfile") }),
3955
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => {
3956
+ void controller.refresh();
3957
+ }, children: t("refresh") }),
3958
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Button, { type: "button", variant: "outline", disabled: state.busy || !state.dirty && state.issue === null, onClick: () => {
3959
+ setInvalid(/* @__PURE__ */ new Set());
3960
+ void controller.refresh(true);
3961
+ }, children: t("discard") })
3962
+ ] })
3963
+ ] })
3964
+ ] }),
3965
+ state.issue !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-issue", role: "alert", children: t(state.issue) }),
3966
+ invalid.size > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-issue", role: "alert", children: t("invalid") }),
3967
+ controller.layer === "profile" && !controller.canWriteProfile() && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", children: t("unavailableForm") })
3968
+ ] });
3969
+ }
3970
+ function NativeProfileLayer({ namespace, forms, remote, form, core, t }) {
3971
+ const shared = (0, import_react4.useMemo)(() => forms.get(namespace), [forms, namespace]);
3972
+ const snapshot2 = (0, import_react4.useSyncExternalStore)((listener) => shared.subscribe(listener), () => shared.getSnapshot());
3973
+ const controller = (0, import_react4.useMemo)(() => core.forProfile(namespace), [core, remote, namespace]);
3974
+ const state = (0, import_react4.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
3975
+ const coreState = (0, import_react4.useSyncExternalStore)(core.subscribe, core.getSnapshot);
3976
+ controller.attachForm(form ?? { state: snapshot2, mutate: (ops, revision2) => shared.mutate(ops, revision2) });
3977
+ (0, import_react4.useEffect)(() => {
3978
+ void controller.refresh();
3979
+ return () => controller.dispose();
3980
+ }, [controller]);
3981
+ (0, import_react4.useEffect)(() => {
3982
+ if (state.saved) void core.refresh();
3983
+ }, [state.saved, core]);
3984
+ (0, import_react4.useEffect)(() => {
3985
+ if (controller.getSnapshot().snapshot !== null) void controller.refresh();
3986
+ }, [coreState.snapshot?.globalRevision, snapshot2.revision, controller]);
3987
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Layer, { controller, t });
3988
+ }
3989
+ function StateInspector({ controller, session, t }) {
3990
+ const { snapshot: snapshot2, dirty, issue } = (0, import_react4.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
3991
+ if (snapshot2 === null) return null;
3992
+ const admitted = session?.configuration ?? null;
3993
+ const source = (value2) => t(value2 === "profile" ? "profileSource" : value2 === "global" ? "globalSource" : value2 === "defaults" ? "defaultsSource" : value2 === "named-session" ? "namedSource" : value2 === "startup" ? "startupSource" : value2 === "deployment" ? "deploymentCapture" : value2 === "mixed" ? "mixedSource" : "unknown");
3994
+ const value = (layer, path) => layer === void 0 ? t("unknown") : at(layer, path.split(".")) === void 0 ? t("absent") : displayValue(at(layer, path.split(".")), t);
3995
+ const metadata = (layer, path, entry) => layer !== void 0 && at(layer, path.split(".")) === void 0 && entry === void 0 ? t("absent") : source(entry);
3996
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { className: "dsmm-deployment-card", children: [
3997
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("summary", { children: [
3998
+ t("state"),
3999
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsmm-hint", children: (snapshot2.nextRoot?.restartRequired.length ?? 0) > 0 ? t("pending") : dirty || issue !== null ? t("inspectorStale") : "" })
4000
+ ] }),
4001
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
4002
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "status", "aria-live": "polite", children: session === null ? t("noSession") : admitted === null ? t("sessionUnavailable") : `${t("namedSource")}: ${admitted.named?.id ?? "—"}` }),
4003
+ session !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { children: [
4004
+ t("session"),
4005
+ ": ",
4006
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: session.sessionId }),
4007
+ " · ",
4008
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: session.admissionEpoch }),
4009
+ " · ",
4010
+ session.scope
4011
+ ] }),
4012
+ (dirty || issue !== null) && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", children: t("inspectorStale") }),
4013
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "dsmm-hint", children: [
4014
+ "Global CAS: ",
4015
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: snapshot2.globalRevision }),
4016
+ " · native CAS: ",
4017
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: snapshot2.nativeRevision }),
4018
+ " · Host form: ",
4019
+ snapshot2.nativeFormRevision ?? "—"
4020
+ ] }),
4021
+ inspectorPaths(snapshot2, admitted).map((path) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dl", { className: "dsmm-deployment-state", children: [
4022
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: path }) }),
4023
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dd", { children: [
4024
+ t("globalSource"),
4025
+ ": ",
4026
+ at(snapshot2.global, path.split(".")) === void 0 ? t("absent") : t("globalSource")
4027
+ ] }),
4028
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dd", { children: [
4029
+ t("desired"),
4030
+ ": ",
4031
+ value(snapshot2.desired, path),
4032
+ " · ",
4033
+ metadata(snapshot2.desired, path, snapshot2.sources[path])
4034
+ ] }),
4035
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dd", { children: [
4036
+ t("startup"),
4037
+ ": ",
4038
+ value(snapshot2.startup, path),
4039
+ " · ",
4040
+ metadata(snapshot2.startup, path, snapshot2.startupSources?.[path]),
4041
+ " / ",
4042
+ at(snapshot2.startup, path.split(".")) === void 0 ? t("absent") : t("startupSource")
4043
+ ] }),
4044
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dd", { children: [
4045
+ t("next"),
4046
+ ": ",
4047
+ value(snapshot2.nextRoot?.settings, path),
4048
+ " · ",
4049
+ metadata(snapshot2.nextRoot?.settings, path, snapshot2.nextRoot?.sources[path]),
4050
+ " / ",
4051
+ metadata(snapshot2.nextRoot?.settings, path, snapshot2.nextRoot?.captures[path])
4052
+ ] }),
4053
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dd", { children: [
4054
+ t("session"),
4055
+ ": ",
4056
+ value(admitted?.settings, path),
4057
+ " · ",
4058
+ metadata(admitted?.settings, path, admitted?.sources[path]),
4059
+ " / ",
4060
+ metadata(admitted?.settings, path, admitted?.captures[path])
4061
+ ] })
4062
+ ] }, path)),
4063
+ (snapshot2.nextRoot?.restartRequired.length ?? 0) > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { children: [
4064
+ t("pending"),
4065
+ ": ",
4066
+ snapshot2.nextRoot.restartRequired.join(", ")
4067
+ ] })
4068
+ ] })
4069
+ ] });
4070
+ }
4071
+ function DeploymentPage(props) {
4072
+ const state = (0, import_react4.useSyncExternalStore)(props.core.subscribe, props.core.getSnapshot);
4073
+ (0, import_react4.useEffect)(() => {
4074
+ if (props.view === "page") void props.core.refresh();
4075
+ }, [props.core, props.view]);
4076
+ if (props.view === "summary") return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: props.t("summary") });
4077
+ const { t } = props, snapshot2 = state.snapshot, module2 = snapshot2?.modules[0];
4078
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "dsmm-profiles dsmm-deployment", "data-dsmm-page": true, "aria-label": t("title"), children: [
4079
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", children: t("description") }),
4080
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", children: t("boundaries") }),
4081
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { className: "dsmm-deployment-card", children: [
4082
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("summary", { children: [
4083
+ t("module"),
4084
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsmm-hint", children: module2?.pending ? t("pending") : module2 === void 0 ? t("unknown") : t(module2.desired.enabled ? "on" : "off") })
4085
+ ] }),
4086
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
4087
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: t("hostUnknown") }),
4088
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { children: [
4089
+ t("desired"),
4090
+ ": ",
4091
+ module2 === void 0 ? t("unknown") : t(module2.desired.enabled ? "on" : "off"),
4092
+ " · ",
4093
+ module2?.desired.source ?? "—"
4094
+ ] }),
4095
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { children: [
4096
+ t("startup"),
4097
+ ": ",
4098
+ module2 === void 0 ? t("unknown") : t(module2.startupMounted ? "on" : "off"),
4099
+ " · ",
4100
+ t("next"),
4101
+ ": ",
4102
+ module2 === void 0 ? t("unknown") : t(module2.nextRoot.admitted ? "on" : "off")
4103
+ ] }),
4104
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { children: [
4105
+ t("session"),
4106
+ ": ",
4107
+ state.session?.modules?.[0]?.admitted == null ? t("unknown") : t(state.session.modules[0].admitted ? "on" : "off")
4108
+ ] }),
4109
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", children: t("ceiling") })
4110
+ ] })
4111
+ ] }),
4112
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Layer, { controller: props.core, t }),
4113
+ props.profilePage && props.forms !== void 0 && snapshot2?.namespace !== null && snapshot2?.namespace !== void 0 && (props.rowNamespace === void 0 || props.rowNamespace === snapshot2.namespace) ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NativeProfileLayer, { namespace: snapshot2.namespace, forms: props.forms, remote: props.remote, form: props.form, core: props.core, t }, `${snapshot2.hostProfileKey}:${snapshot2.entryId}`) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
4114
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { className: "dsmm-deployment-card", children: [
4115
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("summary", { children: [
4116
+ t("profile"),
4117
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsmm-hint", children: t("profileUnavailable") })
4118
+ ] }),
4119
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: t("profileHint") }) })
4120
+ ] }),
4121
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", children: t("unavailableForm") })
4122
+ ] }),
4123
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StateInspector, { controller: props.core, session: state.session, t })
4124
+ ] });
4125
+ }
4126
+
3156
4127
  // src/client/index.ts
3157
4128
  var inject = ["slots", "locale", "remote"];
3158
4129
  async function apply(ctx) {
3159
4130
  await ctx.remote.$mount(TYPERT_REMOTE);
4131
+ let deployment = null;
4132
+ let profiles = null;
4133
+ await ctx.inject(["remote.dsmmConfig"], (coreCtx) => {
4134
+ const core = new DeploymentController(coreCtx.remote.dsmmConfig, "global");
4135
+ void coreCtx.inject(["connection"], (connectionCtx) => {
4136
+ core.bindConnection(connectionCtx.connection.generation);
4137
+ void core.refresh();
4138
+ });
4139
+ deployment = core;
4140
+ if (profiles !== null) core.setSession(profiles.store.getSnapshot().session);
4141
+ coreCtx.effect(() => () => {
4142
+ deployment = null;
4143
+ core.dispose();
4144
+ }, "dsmm: core settings editor");
4145
+ coreCtx.effect(() => coreCtx.locale.register(DEPLOYMENT_NS, { en: deploymentEn, zh: deploymentZh }), "dsmm: core locale");
4146
+ coreCtx.effect(() => {
4147
+ const style = document.createElement("style");
4148
+ style.dataset.dsmmSettings = "";
4149
+ style.textContent = PROFILE_STYLES;
4150
+ document.head.append(style);
4151
+ return () => style.remove();
4152
+ }, "dsmm: core styles");
4153
+ const t = coreCtx.locale.bind(DEPLOYMENT_NS);
4154
+ const inject2 = () => ({ core, remote: coreCtx.remote.dsmmConfig });
4155
+ coreCtx.slots.inject("plugins.item", () => coreCtx.slots.register({ name: "plugins.item", id: "dsmm", label: () => t("title"), order: 30, locale: DEPLOYMENT_NS, inject: inject2 }, DeploymentPage));
4156
+ void coreCtx.inject(["configForms"], (formCtx) => {
4157
+ const injectProfile = () => ({ ...inject2(), forms: formCtx.configForms, profilePage: true });
4158
+ formCtx.slots.inject("plugins.bundle.config", () => formCtx.slots.register({ name: "plugins.bundle.config", key: "@dsmm/dsmm", locale: DEPLOYMENT_NS, inject: injectProfile }, DeploymentPage));
4159
+ let namespace = null, disposeRow;
4160
+ const registerRow = () => {
4161
+ const next = core.getSnapshot().snapshot?.namespace ?? null;
4162
+ if (next === namespace) return;
4163
+ disposeRow?.();
4164
+ namespace = next;
4165
+ if (next !== null) disposeRow = formCtx.slots.inject("plugins.row.config", () => formCtx.slots.register({ name: "plugins.row.config", key: `@dsmm/dsmm#${next}`, locale: DEPLOYMENT_NS, inject: () => ({ ...injectProfile(), rowNamespace: next }) }, DeploymentPage));
4166
+ };
4167
+ registerRow();
4168
+ formCtx.effect(() => core.subscribe(registerRow));
4169
+ formCtx.effect(() => () => disposeRow?.());
4170
+ });
4171
+ void core.refresh();
4172
+ });
3160
4173
  await ctx.inject(["remote.dsmmProfiles"], (profileCtx) => {
3161
4174
  const controller = new ProfilesController(profileCtx.remote.dsmmProfiles);
4175
+ profiles = controller;
4176
+ profileCtx.effect(() => controller.store.subscribe(() => deployment?.setSession(controller.store.getSnapshot().session)));
4177
+ profileCtx.effect(() => () => {
4178
+ profiles = null;
4179
+ deployment?.setSession(null);
4180
+ });
3162
4181
  profileCtx.effect(() => () => controller.dispose(), "dsmm: profile editor");
3163
4182
  profileCtx.effect(() => profileCtx.locale.register(NS, { en, zh }), "dsmm: profile locale");
3164
4183
  profileCtx.effect(() => {