@ran-sh/dsh-crew 0.3.1 → 0.3.3

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 (80) hide show
  1. package/.claude-plugin/marketplace.json +17 -17
  2. package/.claude-plugin/plugin.json +8 -8
  3. package/.mcp.json +8 -8
  4. package/LICENSE +21 -21
  5. package/README.de.md +359 -359
  6. package/README.es.md +359 -359
  7. package/README.fr.md +359 -359
  8. package/README.hi.md +359 -359
  9. package/README.id.md +359 -359
  10. package/README.ja.md +359 -359
  11. package/README.ko.md +359 -359
  12. package/README.md +168 -140
  13. package/README.pt.md +359 -359
  14. package/README.ru.md +359 -359
  15. package/README.th.md +359 -359
  16. package/README.tr.md +359 -359
  17. package/README.vi.md +359 -359
  18. package/README.zh-TW.md +359 -359
  19. package/README.zh.md +168 -140
  20. package/agents/ds-flash.md +26 -26
  21. package/agents/ds-pro.md +32 -32
  22. package/agents/ds-reviewer.md +23 -23
  23. package/agents/ds-worker.md +22 -22
  24. package/bin/dsh-crew.mjs +12 -0
  25. package/codex/agents/ds-flash.toml +30 -30
  26. package/codex/agents/ds-pro.toml +31 -31
  27. package/codex/agents/ds-reviewer.toml +28 -28
  28. package/codex/agents/ds-worker.toml +28 -28
  29. package/codex/prompts/dsh-config.md +3 -3
  30. package/codex/prompts/dsh-status.md +1 -1
  31. package/commands/config.md +11 -11
  32. package/commands/off.md +5 -5
  33. package/commands/on.md +5 -5
  34. package/commands/status.md +5 -5
  35. package/cordis.patch.yml +4 -4
  36. package/lib/client.js +2765 -2765
  37. package/package.json +131 -127
  38. package/scripts/build-client.mjs +28 -28
  39. package/scripts/live-crew-smoke.mjs +39 -39
  40. package/scripts/live-policy-matrix.mjs +177 -177
  41. package/scripts/policy-probe.mjs +101 -101
  42. package/scripts/setup.mjs +295 -294
  43. package/scripts/smoke-real.mjs +110 -110
  44. package/scripts/smoke.mjs +78 -78
  45. package/scripts/verify-installer-fix.mjs +26 -26
  46. package/scripts/verify-npm-install.mjs +297 -276
  47. package/src/adaptive-routing.mjs +260 -260
  48. package/src/client/activation-summary.tsx +64 -64
  49. package/src/client/entry.tsx +236 -236
  50. package/src/client/index.tsx +1120 -1120
  51. package/src/config-readiness.mjs +59 -59
  52. package/src/delivery.mjs +205 -205
  53. package/src/dsh-cli-runtime.mjs +447 -251
  54. package/src/failure-classification.mjs +172 -172
  55. package/src/hub/entry.mjs +98 -98
  56. package/src/hub-client.mjs +132 -132
  57. package/src/hub-compatibility.mjs +49 -49
  58. package/src/i18n.mjs +19 -19
  59. package/src/install/cli.mjs +28 -28
  60. package/src/install/install-legacy.mjs +462 -460
  61. package/src/install/install.mjs +451 -451
  62. package/src/install/npx-lifecycle.mjs +797 -0
  63. package/src/mcp-runtime.mjs +257 -257
  64. package/src/model-catalog.mjs +173 -173
  65. package/src/model-routing.mjs +391 -391
  66. package/src/policy.mjs +197 -197
  67. package/src/readiness-matrix.mjs +169 -169
  68. package/src/runtime-controls.mjs +90 -90
  69. package/src/runtime-identity.mjs +108 -108
  70. package/src/server.mjs +477 -477
  71. package/src/status-shard.mjs +52 -52
  72. package/src/structured-error-code.mjs +38 -38
  73. package/src/vision-route.mjs +138 -138
  74. package/src/workflow-runtime.mjs +573 -567
  75. package/src/workflow.mjs +160 -160
  76. package/src/workspace-audit.mjs +231 -231
  77. package/src/workspace-isolation.mjs +365 -306
  78. package/statusline/statusline.sh +14 -14
  79. package/statusline/worker-segment.sh +35 -35
  80. 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
+ }