@ran-sh/dsh-crew 0.3.6 → 0.3.7

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 (78) hide show
  1. package/.claude-plugin/plugin.json +8 -8
  2. package/.mcp.json +8 -8
  3. package/LICENSE +21 -21
  4. package/README.de.md +359 -359
  5. package/README.es.md +359 -359
  6. package/README.fr.md +359 -359
  7. package/README.hi.md +359 -359
  8. package/README.id.md +359 -359
  9. package/README.ja.md +359 -359
  10. package/README.ko.md +359 -359
  11. package/README.md +125 -180
  12. package/README.pt.md +359 -359
  13. package/README.ru.md +359 -359
  14. package/README.th.md +359 -359
  15. package/README.tr.md +359 -359
  16. package/README.vi.md +359 -359
  17. package/README.zh-TW.md +359 -359
  18. package/README.zh.md +125 -180
  19. package/agents/ds-flash.md +26 -26
  20. package/agents/ds-pro.md +32 -32
  21. package/agents/ds-reviewer.md +23 -23
  22. package/agents/ds-worker.md +22 -22
  23. package/codex/agents/ds-flash.toml +30 -30
  24. package/codex/agents/ds-pro.toml +31 -31
  25. package/codex/agents/ds-reviewer.toml +28 -28
  26. package/codex/agents/ds-worker.toml +28 -28
  27. package/codex/prompts/dsh-config.md +3 -3
  28. package/codex/prompts/dsh-status.md +1 -1
  29. package/commands/config.md +11 -11
  30. package/commands/off.md +5 -5
  31. package/commands/on.md +5 -5
  32. package/commands/status.md +5 -5
  33. package/cordis.patch.yml +4 -4
  34. package/lib/client.js +3446 -2765
  35. package/package.json +131 -131
  36. package/scripts/build-client.mjs +28 -28
  37. package/scripts/live-crew-smoke.mjs +39 -39
  38. package/scripts/live-policy-matrix.mjs +177 -177
  39. package/scripts/policy-probe.mjs +101 -101
  40. package/scripts/setup.mjs +284 -284
  41. package/scripts/smoke-real.mjs +110 -110
  42. package/scripts/smoke.mjs +78 -78
  43. package/scripts/verify-installer-fix.mjs +26 -26
  44. package/src/adaptive-routing.mjs +260 -260
  45. package/src/client/activation-summary.tsx +64 -64
  46. package/src/client/collapsible-sections.mjs +55 -0
  47. package/src/client/entry.tsx +236 -236
  48. package/src/client/index.tsx +1213 -1120
  49. package/src/config-readiness.mjs +59 -59
  50. package/src/delivery.mjs +205 -205
  51. package/src/dsh-cli-runtime.mjs +239 -239
  52. package/src/failure-classification.mjs +172 -172
  53. package/src/hub/entry.mjs +98 -98
  54. package/src/hub-client.mjs +132 -132
  55. package/src/hub-compatibility.mjs +49 -49
  56. package/src/i18n.mjs +19 -19
  57. package/src/install/cli.mjs +28 -28
  58. package/src/install/install-legacy.mjs +462 -462
  59. package/src/install/install.mjs +451 -451
  60. package/src/install/npx-lifecycle.mjs +1055 -1055
  61. package/src/mcp-runtime.mjs +257 -257
  62. package/src/model-catalog.mjs +173 -173
  63. package/src/model-routing.mjs +391 -391
  64. package/src/policy.mjs +197 -197
  65. package/src/readiness-matrix.mjs +169 -169
  66. package/src/runtime-controls.mjs +90 -90
  67. package/src/runtime-identity.mjs +108 -108
  68. package/src/server.mjs +477 -477
  69. package/src/status-shard.mjs +52 -52
  70. package/src/structured-error-code.mjs +38 -38
  71. package/src/vision-route.mjs +138 -138
  72. package/src/workflow-runtime.mjs +573 -573
  73. package/src/workflow.mjs +160 -160
  74. package/src/workspace-audit.mjs +231 -231
  75. package/src/workspace-isolation.mjs +365 -365
  76. package/statusline/statusline.sh +14 -14
  77. package/statusline/worker-segment.sh +35 -35
  78. package/worker.cordis.yml +77 -77
package/src/policy.mjs CHANGED
@@ -1,197 +1,197 @@
1
- // v0.3 config-authority facade over the frozen v0.2 policy implementation.
2
- //
3
- // The v0.2 module remains byte-for-byte available as policy-legacy.mjs. New
4
- // callers import this facade. For schema-v3 persisted configs, the nested
5
- // worker/review/execution/legacy snapshot is authoritative; flat Flash/Pro
6
- // fields are compatibility mirrors only. Legacy files still flow through the
7
- // old migration exactly as before.
8
-
9
- export * from './policy-legacy.mjs';
10
- import * as legacy from './policy-legacy.mjs';
11
- import { normalizeAdaptiveRouting } from './adaptive-routing.mjs';
12
-
13
- export { normalizeAdaptiveRouting };
14
- export const CONFIG_SCHEMA_VERSION = 3;
15
-
16
- function validObject(value) {
17
- return !!value && typeof value === 'object' && !Array.isArray(value);
18
- }
19
-
20
- function hasCanonicalAuthority(raw) {
21
- return Number(raw?.config_schema_version) >= CONFIG_SCHEMA_VERSION
22
- && validObject(raw?.worker)
23
- && validObject(raw?.review)
24
- && validObject(raw?.execution);
25
- }
26
-
27
- function semanticLegacyMode(canonical) {
28
- if (canonical.review.auto_review === true && canonical.review.state === 'auto') return 'review-pipeline';
29
- if (canonical.worker.state === 'auto' && canonical.review.state === 'disabled'
30
- && canonical.worker.model_policy.strategy === 'economy') return 'flash-only';
31
- if (canonical.worker.state === 'auto' && canonical.review.state === 'disabled'
32
- && canonical.worker.model_policy.strategy === 'quality') return 'pro-only';
33
- if (canonical.worker.state === 'auto' && canonical.review.state === 'manual') return 'balanced';
34
- return 'custom';
35
- }
36
-
37
- function normalizeLegacySnapshot(raw, canonical) {
38
- // A nested v3 legacy snapshot is canonical compatibility metadata. Flat
39
- // fields are only a fallback for transitional/pre-v3 inputs.
40
- const nested = validObject(raw?.legacy) ? raw.legacy : {};
41
- const source = { ...raw, ...nested };
42
- const mode = legacy.COLLABORATION_MODES.includes(source.collaboration_mode)
43
- ? source.collaboration_mode
44
- : semanticLegacyMode(canonical);
45
-
46
- let flash = legacy.TIER_STATES.includes(source.flash_state) ? source.flash_state : undefined;
47
- let pro = legacy.TIER_STATES.includes(source.pro_state) ? source.pro_state : undefined;
48
- if (mode === 'flash-only') { flash = 'auto'; pro = 'disabled'; }
49
- else if (mode === 'pro-only') { flash = 'disabled'; pro = 'auto'; }
50
- else if (mode === 'balanced' || mode === 'review-pipeline') { flash = 'auto'; pro = 'auto'; }
51
- else {
52
- flash ??= canonical.worker.state;
53
- // reviewer=manual historically means the Pro tier is available/Auto but
54
- // review itself is on-demand. Preserve an explicit nested pro state when
55
- // present; otherwise use a conservative compatibility reconstruction.
56
- pro ??= canonical.review.state === 'disabled' ? 'disabled' : 'auto';
57
- }
58
-
59
- return {
60
- collaboration_mode: mode,
61
- tier_policy: mode === 'flash-only' ? 'flash-only' : mode === 'pro-only' ? 'pro-only' : 'auto',
62
- flash_state: flash,
63
- pro_state: pro,
64
- };
65
- }
66
-
67
- function modelPolicyWithAdaptive(basePolicy, rawPolicy) {
68
- return {
69
- ...basePolicy,
70
- adaptive: normalizeAdaptiveRouting(rawPolicy?.adaptive),
71
- };
72
- }
73
-
74
- function normalizeCanonical(raw) {
75
- const base = legacy.getCanonical(raw);
76
- const providerMode = legacy.normalizeWorkerProviderMode(base.worker?.provider_mode);
77
- const canonical = {
78
- ...base,
79
- execution: {
80
- ...base.execution,
81
- // There is one global dispatch permission. `execution.enabled` is a
82
- // canonical mirror of the top-level switch, never a second authority.
83
- enabled: base.subagents_enabled,
84
- },
85
- worker: {
86
- ...base.worker,
87
- provider_mode: providerMode,
88
- model_policy: modelPolicyWithAdaptive(base.worker.model_policy, raw?.worker?.model_policy),
89
- },
90
- review: {
91
- ...base.review,
92
- // v0.3 still exposes one Worker Provider selector. Until per-role
93
- // provider modes become first-class, keep both roles aligned.
94
- provider_mode: providerMode,
95
- model_policy: modelPolicyWithAdaptive(base.review.model_policy, raw?.review?.model_policy),
96
- },
97
- };
98
- canonical.legacy = normalizeLegacySnapshot(raw, canonical);
99
- return canonical;
100
- }
101
-
102
- function proMirror(canonical) {
103
- const escalation = canonical.worker.model_policy;
104
- const reviewer = canonical.review.model_policy;
105
- if (escalation.escalation_priority_configured || escalation.escalation_priority.length > 0) {
106
- return {
107
- priority: escalation.escalation_priority,
108
- configured: escalation.escalation_priority_configured,
109
- fallback: escalation.fallback,
110
- };
111
- }
112
- return {
113
- priority: reviewer.priority,
114
- configured: reviewer.priorityConfigured,
115
- fallback: reviewer.fallback,
116
- };
117
- }
118
-
119
- function legacyRoutingMirror(canonical) {
120
- // Legacy tier/UI behavior has its own canonical compatibility sub-domain.
121
- // Never infer this back from flat mirrors: schema-v3 `legacy` owns it.
122
- return normalizeLegacySnapshot({ legacy: canonical.legacy }, canonical);
123
- }
124
-
125
- /**
126
- * Re-exported normalizer with schema-v3 precedence.
127
- *
128
- * `legacy.normalizeGlobalConfig` remains the import path for legacy-file
129
- * migration. Once schema v3 is present, flat compatibility fields are rebuilt
130
- * from the canonical snapshot so a stale/manual mirror cannot override runtime
131
- * behavior.
132
- */
133
- export function normalizeGlobalConfig(raw = {}) {
134
- const normalized = legacy.normalizeGlobalConfig(raw);
135
- if (!hasCanonicalAuthority(raw)) return normalized;
136
-
137
- const canonical = normalizeCanonical(raw);
138
- const pro = proMirror(canonical);
139
- const routing = legacyRoutingMirror(canonical);
140
- return {
141
- ...normalized,
142
- config_schema_version: CONFIG_SCHEMA_VERSION,
143
- subagents_enabled: canonical.subagents_enabled,
144
- main_agent_mode: canonical.main_agent_mode,
145
- default_effort: canonical.execution.default_effort,
146
- default_timeout_seconds: canonical.execution.default_timeout_seconds,
147
- mode: canonical.execution.mode,
148
- max_parallel: canonical.execution.max_parallel,
149
- isolation: canonical.execution.isolation,
150
- collaboration_mode: routing.collaboration_mode,
151
- tier_policy: routing.tier_policy,
152
- flash_state: routing.flash_state,
153
- pro_state: routing.pro_state,
154
- worker_state: canonical.worker.state,
155
- review_state: canonical.review.state,
156
- auto_review: canonical.review.auto_review === true,
157
- worker_provider_mode: canonical.worker.provider_mode,
158
- flash_model_priority: [...canonical.worker.model_policy.priority],
159
- flash_model_priority_configured: canonical.worker.model_policy.priorityConfigured,
160
- flash_model_fallback: canonical.worker.model_policy.fallback,
161
- pro_model_priority: [...pro.priority],
162
- pro_model_priority_configured: pro.configured,
163
- pro_model_fallback: pro.fallback,
164
- escalate_on_failure: canonical.worker.model_policy.escalation.enabled,
165
- pro_reviews_flash: canonical.review.auto_review === true,
166
- execution: canonical.execution,
167
- worker: canonical.worker,
168
- review: canonical.review,
169
- legacy: canonical.legacy,
170
- };
171
- }
172
-
173
- /**
174
- * v0.3 model-policy view. The frozen v0.2 resolver remains authoritative for
175
- * every existing dimension. This facade only adds the normalized opt-in
176
- * adaptive sub-domain, so direct canonical-ish v0.2 callers retain the exact
177
- * priority/escalation semantics they had before schema-v3 existed.
178
- */
179
- export function resolveModelPolicy(config = {}, role = 'worker', context = {}) {
180
- const base = legacy.resolveModelPolicy(config, role, context);
181
- const rawPolicy = role === 'reviewer'
182
- ? config?.review?.model_policy
183
- : config?.worker?.model_policy;
184
- return {
185
- ...base,
186
- adaptive: normalizeAdaptiveRouting(rawPolicy?.adaptive ?? base.adaptive),
187
- };
188
- }
189
-
190
- /** Explicit legacy-import normalizer for the persistence layer. */
191
- export function normalizeLegacyGlobalConfig(raw = {}) {
192
- return legacy.normalizeGlobalConfig(raw);
193
- }
194
-
195
- export function configHasCanonicalAuthority(raw = {}) {
196
- return hasCanonicalAuthority(raw);
197
- }
1
+ // v0.3 config-authority facade over the frozen v0.2 policy implementation.
2
+ //
3
+ // The v0.2 module remains byte-for-byte available as policy-legacy.mjs. New
4
+ // callers import this facade. For schema-v3 persisted configs, the nested
5
+ // worker/review/execution/legacy snapshot is authoritative; flat Flash/Pro
6
+ // fields are compatibility mirrors only. Legacy files still flow through the
7
+ // old migration exactly as before.
8
+
9
+ export * from './policy-legacy.mjs';
10
+ import * as legacy from './policy-legacy.mjs';
11
+ import { normalizeAdaptiveRouting } from './adaptive-routing.mjs';
12
+
13
+ export { normalizeAdaptiveRouting };
14
+ export const CONFIG_SCHEMA_VERSION = 3;
15
+
16
+ function validObject(value) {
17
+ return !!value && typeof value === 'object' && !Array.isArray(value);
18
+ }
19
+
20
+ function hasCanonicalAuthority(raw) {
21
+ return Number(raw?.config_schema_version) >= CONFIG_SCHEMA_VERSION
22
+ && validObject(raw?.worker)
23
+ && validObject(raw?.review)
24
+ && validObject(raw?.execution);
25
+ }
26
+
27
+ function semanticLegacyMode(canonical) {
28
+ if (canonical.review.auto_review === true && canonical.review.state === 'auto') return 'review-pipeline';
29
+ if (canonical.worker.state === 'auto' && canonical.review.state === 'disabled'
30
+ && canonical.worker.model_policy.strategy === 'economy') return 'flash-only';
31
+ if (canonical.worker.state === 'auto' && canonical.review.state === 'disabled'
32
+ && canonical.worker.model_policy.strategy === 'quality') return 'pro-only';
33
+ if (canonical.worker.state === 'auto' && canonical.review.state === 'manual') return 'balanced';
34
+ return 'custom';
35
+ }
36
+
37
+ function normalizeLegacySnapshot(raw, canonical) {
38
+ // A nested v3 legacy snapshot is canonical compatibility metadata. Flat
39
+ // fields are only a fallback for transitional/pre-v3 inputs.
40
+ const nested = validObject(raw?.legacy) ? raw.legacy : {};
41
+ const source = { ...raw, ...nested };
42
+ const mode = legacy.COLLABORATION_MODES.includes(source.collaboration_mode)
43
+ ? source.collaboration_mode
44
+ : semanticLegacyMode(canonical);
45
+
46
+ let flash = legacy.TIER_STATES.includes(source.flash_state) ? source.flash_state : undefined;
47
+ let pro = legacy.TIER_STATES.includes(source.pro_state) ? source.pro_state : undefined;
48
+ if (mode === 'flash-only') { flash = 'auto'; pro = 'disabled'; }
49
+ else if (mode === 'pro-only') { flash = 'disabled'; pro = 'auto'; }
50
+ else if (mode === 'balanced' || mode === 'review-pipeline') { flash = 'auto'; pro = 'auto'; }
51
+ else {
52
+ flash ??= canonical.worker.state;
53
+ // reviewer=manual historically means the Pro tier is available/Auto but
54
+ // review itself is on-demand. Preserve an explicit nested pro state when
55
+ // present; otherwise use a conservative compatibility reconstruction.
56
+ pro ??= canonical.review.state === 'disabled' ? 'disabled' : 'auto';
57
+ }
58
+
59
+ return {
60
+ collaboration_mode: mode,
61
+ tier_policy: mode === 'flash-only' ? 'flash-only' : mode === 'pro-only' ? 'pro-only' : 'auto',
62
+ flash_state: flash,
63
+ pro_state: pro,
64
+ };
65
+ }
66
+
67
+ function modelPolicyWithAdaptive(basePolicy, rawPolicy) {
68
+ return {
69
+ ...basePolicy,
70
+ adaptive: normalizeAdaptiveRouting(rawPolicy?.adaptive),
71
+ };
72
+ }
73
+
74
+ function normalizeCanonical(raw) {
75
+ const base = legacy.getCanonical(raw);
76
+ const providerMode = legacy.normalizeWorkerProviderMode(base.worker?.provider_mode);
77
+ const canonical = {
78
+ ...base,
79
+ execution: {
80
+ ...base.execution,
81
+ // There is one global dispatch permission. `execution.enabled` is a
82
+ // canonical mirror of the top-level switch, never a second authority.
83
+ enabled: base.subagents_enabled,
84
+ },
85
+ worker: {
86
+ ...base.worker,
87
+ provider_mode: providerMode,
88
+ model_policy: modelPolicyWithAdaptive(base.worker.model_policy, raw?.worker?.model_policy),
89
+ },
90
+ review: {
91
+ ...base.review,
92
+ // v0.3 still exposes one Worker Provider selector. Until per-role
93
+ // provider modes become first-class, keep both roles aligned.
94
+ provider_mode: providerMode,
95
+ model_policy: modelPolicyWithAdaptive(base.review.model_policy, raw?.review?.model_policy),
96
+ },
97
+ };
98
+ canonical.legacy = normalizeLegacySnapshot(raw, canonical);
99
+ return canonical;
100
+ }
101
+
102
+ function proMirror(canonical) {
103
+ const escalation = canonical.worker.model_policy;
104
+ const reviewer = canonical.review.model_policy;
105
+ if (escalation.escalation_priority_configured || escalation.escalation_priority.length > 0) {
106
+ return {
107
+ priority: escalation.escalation_priority,
108
+ configured: escalation.escalation_priority_configured,
109
+ fallback: escalation.fallback,
110
+ };
111
+ }
112
+ return {
113
+ priority: reviewer.priority,
114
+ configured: reviewer.priorityConfigured,
115
+ fallback: reviewer.fallback,
116
+ };
117
+ }
118
+
119
+ function legacyRoutingMirror(canonical) {
120
+ // Legacy tier/UI behavior has its own canonical compatibility sub-domain.
121
+ // Never infer this back from flat mirrors: schema-v3 `legacy` owns it.
122
+ return normalizeLegacySnapshot({ legacy: canonical.legacy }, canonical);
123
+ }
124
+
125
+ /**
126
+ * Re-exported normalizer with schema-v3 precedence.
127
+ *
128
+ * `legacy.normalizeGlobalConfig` remains the import path for legacy-file
129
+ * migration. Once schema v3 is present, flat compatibility fields are rebuilt
130
+ * from the canonical snapshot so a stale/manual mirror cannot override runtime
131
+ * behavior.
132
+ */
133
+ export function normalizeGlobalConfig(raw = {}) {
134
+ const normalized = legacy.normalizeGlobalConfig(raw);
135
+ if (!hasCanonicalAuthority(raw)) return normalized;
136
+
137
+ const canonical = normalizeCanonical(raw);
138
+ const pro = proMirror(canonical);
139
+ const routing = legacyRoutingMirror(canonical);
140
+ return {
141
+ ...normalized,
142
+ config_schema_version: CONFIG_SCHEMA_VERSION,
143
+ subagents_enabled: canonical.subagents_enabled,
144
+ main_agent_mode: canonical.main_agent_mode,
145
+ default_effort: canonical.execution.default_effort,
146
+ default_timeout_seconds: canonical.execution.default_timeout_seconds,
147
+ mode: canonical.execution.mode,
148
+ max_parallel: canonical.execution.max_parallel,
149
+ isolation: canonical.execution.isolation,
150
+ collaboration_mode: routing.collaboration_mode,
151
+ tier_policy: routing.tier_policy,
152
+ flash_state: routing.flash_state,
153
+ pro_state: routing.pro_state,
154
+ worker_state: canonical.worker.state,
155
+ review_state: canonical.review.state,
156
+ auto_review: canonical.review.auto_review === true,
157
+ worker_provider_mode: canonical.worker.provider_mode,
158
+ flash_model_priority: [...canonical.worker.model_policy.priority],
159
+ flash_model_priority_configured: canonical.worker.model_policy.priorityConfigured,
160
+ flash_model_fallback: canonical.worker.model_policy.fallback,
161
+ pro_model_priority: [...pro.priority],
162
+ pro_model_priority_configured: pro.configured,
163
+ pro_model_fallback: pro.fallback,
164
+ escalate_on_failure: canonical.worker.model_policy.escalation.enabled,
165
+ pro_reviews_flash: canonical.review.auto_review === true,
166
+ execution: canonical.execution,
167
+ worker: canonical.worker,
168
+ review: canonical.review,
169
+ legacy: canonical.legacy,
170
+ };
171
+ }
172
+
173
+ /**
174
+ * v0.3 model-policy view. The frozen v0.2 resolver remains authoritative for
175
+ * every existing dimension. This facade only adds the normalized opt-in
176
+ * adaptive sub-domain, so direct canonical-ish v0.2 callers retain the exact
177
+ * priority/escalation semantics they had before schema-v3 existed.
178
+ */
179
+ export function resolveModelPolicy(config = {}, role = 'worker', context = {}) {
180
+ const base = legacy.resolveModelPolicy(config, role, context);
181
+ const rawPolicy = role === 'reviewer'
182
+ ? config?.review?.model_policy
183
+ : config?.worker?.model_policy;
184
+ return {
185
+ ...base,
186
+ adaptive: normalizeAdaptiveRouting(rawPolicy?.adaptive ?? base.adaptive),
187
+ };
188
+ }
189
+
190
+ /** Explicit legacy-import normalizer for the persistence layer. */
191
+ export function normalizeLegacyGlobalConfig(raw = {}) {
192
+ return legacy.normalizeGlobalConfig(raw);
193
+ }
194
+
195
+ export function configHasCanonicalAuthority(raw = {}) {
196
+ return hasCanonicalAuthority(raw);
197
+ }