dsh-coding 0.0.0-stage → 0.1.1-rc1

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 (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +91 -2
  3. package/cordis.patch.yml +233 -0
  4. package/docs/DETAIL.md +183 -0
  5. package/docs/DEVELOPMENT.md +189 -0
  6. package/icon.svg +6 -0
  7. package/lib/apply-patch.js +268 -0
  8. package/lib/client/capsule.js +120 -0
  9. package/lib/client/card.js +220 -0
  10. package/lib/client/command-row.js +76 -0
  11. package/lib/client/config-page.js +392 -0
  12. package/lib/client/definition.js +164 -0
  13. package/lib/client/index.js +129 -0
  14. package/lib/client/locales.js +156 -0
  15. package/lib/client/mode-picker.js +77 -0
  16. package/lib/client/styles.js +283 -0
  17. package/lib/client.js +1691 -0
  18. package/lib/coding-projection.js +349 -0
  19. package/lib/config.js +204 -0
  20. package/lib/contract.js +124 -0
  21. package/lib/editor.js +23 -0
  22. package/lib/failures.js +142 -0
  23. package/lib/handoff.js +312 -0
  24. package/lib/index.js +115 -0
  25. package/lib/language.js +136 -0
  26. package/lib/messages.js +43 -0
  27. package/lib/models.js +154 -0
  28. package/lib/patch.js +235 -0
  29. package/lib/preset.js +1488 -0
  30. package/lib/reasoning-levels.js +28 -0
  31. package/lib/reasoning-projection.js +178 -0
  32. package/lib/reasoning.js +585 -0
  33. package/lib/stages.js +306 -0
  34. package/lib/state.js +550 -0
  35. package/lib/system-language.js +56 -0
  36. package/lib/types/apply-patch.d.ts +13 -0
  37. package/lib/types/client/capsule.d.ts +9 -0
  38. package/lib/types/client/card.d.ts +72 -0
  39. package/lib/types/client/command-row.d.ts +42 -0
  40. package/lib/types/client/config-page.d.ts +136 -0
  41. package/lib/types/client/definition.d.ts +51 -0
  42. package/lib/types/client/index.d.ts +10 -0
  43. package/lib/types/client/locales.d.ts +18 -0
  44. package/lib/types/client/mode-picker.d.ts +25 -0
  45. package/lib/types/client/styles.d.ts +28 -0
  46. package/lib/types/coding-projection.d.ts +116 -0
  47. package/lib/types/config.d.ts +193 -0
  48. package/lib/types/contract.d.ts +33 -0
  49. package/lib/types/editor.d.ts +9 -0
  50. package/lib/types/failures.d.ts +62 -0
  51. package/lib/types/handoff.d.ts +112 -0
  52. package/lib/types/index.d.ts +144 -0
  53. package/lib/types/language.d.ts +56 -0
  54. package/lib/types/messages.d.ts +27 -0
  55. package/lib/types/models.d.ts +82 -0
  56. package/lib/types/patch.d.ts +37 -0
  57. package/lib/types/preset.d.ts +22 -0
  58. package/lib/types/reasoning-levels.d.ts +20 -0
  59. package/lib/types/reasoning-projection.d.ts +64 -0
  60. package/lib/types/reasoning.d.ts +141 -0
  61. package/lib/types/stages.d.ts +164 -0
  62. package/lib/types/state.d.ts +261 -0
  63. package/lib/types/system-language.d.ts +10 -0
  64. package/lib/types/verification-tool.d.ts +32 -0
  65. package/lib/types/verification.d.ts +77 -0
  66. package/lib/types/verifier.d.ts +9 -0
  67. package/lib/types/volatile.d.ts +17 -0
  68. package/lib/verification-tool.js +176 -0
  69. package/lib/verification.js +337 -0
  70. package/lib/verifier.js +25 -0
  71. package/lib/volatile.js +20 -0
  72. package/locale/en.json +7 -0
  73. package/locale/zh.json +7 -0
  74. package/package.json +129 -3
@@ -0,0 +1,193 @@
1
+ /**
2
+ * Configuration contract of the `dsh-coding` bundle.
3
+ *
4
+ * The same contract is stated three ways on purpose: {@link CodingConfig} for
5
+ * TypeScript, {@link Config} (Schemastery) for the Loader's activation-time
6
+ * validation, and {@link configJsonSchema} for non-Loader consumers such as the
7
+ * plugin page and the tests. `normalizeConfig` adds the checks a schema cannot
8
+ * state — in particular that a worker model names a real `provider/model`
9
+ * route, because a silent fall-back to the lead's own model is the one outcome
10
+ * this plugin must never allow.
11
+ *
12
+ * @module dsh-coding/config
13
+ */
14
+ import z from '@deepseek-ai/schemastery';
15
+ import { type CodingMode } from './stages.js';
16
+ import { type LanguageMode } from './language.js';
17
+ import { volatileValue } from './volatile.js';
18
+ export { volatileValue };
19
+ /** Reasoning-level policies the plugin accepts. */
20
+ export declare const REASONING_MODES: readonly ["auto", "low", "high", "max"];
21
+ /** One reasoning-level policy: auto classifies, the others pin. */
22
+ export type ReasoningMode = typeof REASONING_MODES[number];
23
+ /** One resolved `provider/model` route for a worker subagent. */
24
+ export interface WorkerRoute {
25
+ readonly provider: string;
26
+ readonly model: string;
27
+ }
28
+ /**
29
+ * Verified plugin configuration.
30
+ *
31
+ * Every field is required or defaulted by {@link Config}; the worker routes are
32
+ * required strings because dispatch refuses to inherit the lead's model.
33
+ */
34
+ export interface CodingConfig {
35
+ /** Mode a new Coding session starts in. Defaults to `auto`. */
36
+ readonly defaultMode: CodingMode;
37
+ /** `provider/model` route for the implement worker. Required. */
38
+ readonly implementWorkerModel: string;
39
+ /** `provider/model` route for the verify worker. Required. */
40
+ readonly verifyWorkerModel: string;
41
+ /**
42
+ * `provider/model` route for the planner worker (pro model). Required.
43
+ */
44
+ readonly plannerWorkerModel: string;
45
+ /**
46
+ * Conversation language: `auto` follows the DSH interface, then the host
47
+ * locale; `zh` / `en` pin it. The prompt fixes replies, todo items, and
48
+ * delivery notes to it.
49
+ */
50
+ readonly language: LanguageMode;
51
+ /**
52
+ * Reasoning-level policy: `auto` classifies each turn from the request, while
53
+ * `low` / `high` / `max` pin every turn. A session override (chat box or
54
+ * `coding_reasoning`) only applies while the policy is `auto`.
55
+ */
56
+ readonly reasoning: ReasoningMode;
57
+ /**
58
+ * Verification-failure retry budget of one session: every failed verification
59
+ * spends one attempt, and once the budget is gone the runtime delivers a
60
+ * blocked result that names the failure instead of looping forever. `0` means
61
+ * no limit.
62
+ */
63
+ readonly maxVerifyAttempts: number;
64
+ /**
65
+ * How many times the identical failure may repeat before the runtime stops
66
+ * retrying and delivers blocked. `0` means no limit.
67
+ */
68
+ readonly maxSameFailure: number;
69
+ /**
70
+ * Longest running time of one verification command, in milliseconds. A check
71
+ * that outlives it is terminated and counted as a failed verification, so a
72
+ * test script that never exits cannot block the run. `0` means no limit.
73
+ */
74
+ readonly verificationTimeoutMs: number;
75
+ /**
76
+ * Verification command overrides, keyed by `kind` (`test`, `build`, `lint`,
77
+ * `typecheck`) or by `kind` plus scope (`test:targeted`, `test:full`, …).
78
+ * An absent entry is detected from the project's own package manifest.
79
+ */
80
+ readonly verificationCommands: Readonly<Record<string, string>>;
81
+ }
82
+ /**
83
+ * Type face of the same-named {@link Config} schema, so an importer can write
84
+ * `import { Config } from 'dsh-coding'` and use it as both the value schema and
85
+ * the configuration type.
86
+ */
87
+ export interface Config extends CodingConfig {
88
+ }
89
+ /** Schemastery schema the Loader validates the bundle row's `config` with. */
90
+ export declare const Config: z<Config>;
91
+ /** The same contract as plain JSON Schema, for consumers that never load the plugin. */
92
+ export declare const configJsonSchema: {
93
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
94
+ readonly title: "dsh-coding configuration";
95
+ readonly type: "object";
96
+ readonly additionalProperties: false;
97
+ readonly required: readonly ["implementWorkerModel", "verifyWorkerModel", "plannerWorkerModel"];
98
+ readonly properties: {
99
+ readonly defaultMode: {
100
+ readonly type: "string";
101
+ readonly enum: readonly CodingMode[];
102
+ readonly default: "auto";
103
+ readonly description: "Mode a new Coding session starts in.";
104
+ };
105
+ readonly implementWorkerModel: {
106
+ readonly type: "string";
107
+ readonly pattern: "^[^/\\s]+/[^/\\s]+$";
108
+ readonly description: "provider/model route for the implement worker; never inherited from the lead.";
109
+ };
110
+ readonly verifyWorkerModel: {
111
+ readonly type: "string";
112
+ readonly pattern: "^[^/\\s]+/[^/\\s]+$";
113
+ readonly description: "provider/model route for the verify worker; never inherited from the lead.";
114
+ };
115
+ readonly plannerWorkerModel: {
116
+ readonly type: "string";
117
+ readonly pattern: "^[^/\\s]+/[^/\\s]+$";
118
+ readonly description: "provider/model route for the planner worker (pro model); never inherited from the lead.";
119
+ };
120
+ readonly language: {
121
+ readonly type: "string";
122
+ readonly enum: readonly LanguageMode[];
123
+ readonly default: "auto";
124
+ readonly description: "Conversation language: auto follows the DSH interface, then the host locale.";
125
+ };
126
+ readonly reasoning: {
127
+ readonly type: "string";
128
+ readonly enum: readonly ["auto", "low", "high", "max"];
129
+ readonly default: "auto";
130
+ readonly description: "Reasoning level: auto classifies each turn; low, high, and max pin every turn.";
131
+ };
132
+ readonly maxVerifyAttempts: {
133
+ readonly type: "integer";
134
+ readonly minimum: 0;
135
+ readonly default: 5;
136
+ readonly description: "Failed verifications allowed before the run delivers blocked; 0 means no limit.";
137
+ };
138
+ readonly maxSameFailure: {
139
+ readonly type: "integer";
140
+ readonly minimum: 0;
141
+ readonly default: 2;
142
+ readonly description: "Repeats of the identical failure allowed before delivering blocked; 0 means no limit.";
143
+ };
144
+ readonly verificationTimeoutMs: {
145
+ readonly type: "integer";
146
+ readonly minimum: 0;
147
+ readonly default: 360000;
148
+ readonly description: "Longest running time of one verification command in ms; a timeout counts as a failed verification; 0 means no limit.";
149
+ };
150
+ readonly verificationCommands: {
151
+ readonly type: "object";
152
+ readonly additionalProperties: {
153
+ readonly type: "string";
154
+ };
155
+ readonly default: {};
156
+ readonly description: "Verification command overrides keyed by kind or kind:scope.";
157
+ };
158
+ };
159
+ };
160
+ /** The verification kinds `run_verification` accepts. */
161
+ export declare const VERIFICATION_KINDS: readonly ["test", "build", "lint", "typecheck"];
162
+ /** The verification scopes `run_verification` accepts. */
163
+ export declare const VERIFICATION_SCOPES: readonly ["targeted", "package", "full"];
164
+ /** One accepted verification kind. */
165
+ export type VerificationKind = typeof VERIFICATION_KINDS[number];
166
+ /** One accepted verification scope. */
167
+ export type VerificationScope = typeof VERIFICATION_SCOPES[number];
168
+ /**
169
+ * Parse a `provider/model` route. Both halves are required: an omitted provider
170
+ * would let the request silently inherit the lead's route, which is exactly the
171
+ * fall-back the plugin refuses.
172
+ * @param raw - configured route text.
173
+ * @param field - configuration field name, for an actionable failure.
174
+ * @returns the split route.
175
+ * @throws when the value is not exactly `provider/model`.
176
+ */
177
+ export declare function parseWorkerRoute(raw: unknown, field: string): WorkerRoute;
178
+ /**
179
+ * Verify a decoded (or directly applied) configuration and fill the defaults a
180
+ * direct `apply()` call would otherwise miss.
181
+ * @param raw - Loader-validated config, or a hand-authored object in tests.
182
+ * @returns the verified configuration.
183
+ * @throws when a worker route is absent or malformed.
184
+ */
185
+ export declare function normalizeConfig(raw: Partial<CodingConfig> | undefined): CodingConfig;
186
+ /**
187
+ * Pick the configured command for a verification request.
188
+ * @param config - verified configuration.
189
+ * @param kind - requested kind.
190
+ * @param scope - requested scope.
191
+ * @returns the most specific configured command, when one exists.
192
+ */
193
+ export declare function configuredCommand(config: CodingConfig, kind: VerificationKind, scope: VerificationScope): string | undefined;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The delivery contract, split into the stage that owns each rule.
3
+ *
4
+ * Nothing here is a global system prompt: one fragment is injected as
5
+ * per-step context for the stage actually in force, so the model reads the rule
6
+ * it can act on now. That also keeps a long session from carrying every rule of
7
+ * every stage in its system prompt.
8
+ *
9
+ * @module dsh-coding/contract
10
+ */
11
+ import { type CodingMode, type CodingStage } from './stages.js';
12
+ /** One paragraph per mode, injected with every stage fragment. */
13
+ export declare const MODE_CONTRACT: Readonly<Record<CodingMode, string>>;
14
+ /** The rule set owned by each stage. */
15
+ export declare const STAGE_CONTRACT: Readonly<Record<CodingStage, string>>;
16
+ /** One-line communication rule shared by every stage. */
17
+ export declare const COMMUNICATION_RULE: string;
18
+ /** Everything the model needs to know about the current state. */
19
+ export interface StageContextInput {
20
+ readonly mode: CodingMode;
21
+ readonly stage: CodingStage;
22
+ readonly status: string;
23
+ /** Digest of the handoff the earlier stages recorded, when one exists. */
24
+ readonly handoff?: string;
25
+ readonly rejection?: string;
26
+ }
27
+ /**
28
+ * Render the per-step context message. Kept terse: it rides in every request of
29
+ * the session, so each line must earn its tokens.
30
+ * @param input - mode, stage, and the rendered status line.
31
+ * @returns the injected context text.
32
+ */
33
+ export declare function stageContext(input: StageContextInput): string;
@@ -0,0 +1,9 @@
1
+ /** Cordis plugin name used by loader diagnostics. */
2
+ export declare const name = "dsh-coding-editor";
3
+ /** The editor needs the tool registry and the composed filesystem. */
4
+ export declare const inject: string[];
5
+ /**
6
+ * Register `apply_patch` in this preset's scope.
7
+ * @param ctx - preset scope that owns the registration.
8
+ */
9
+ export declare function apply(ctx: any): void;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Structured failure reports: the reason a blocking step could not finish, and
3
+ * what the operator can do about it.
4
+ *
5
+ * The runtime catches its own blocking exceptions at a small, fixed set of
6
+ * dispatch points. Catching them silently would leave the user watching a card
7
+ * that stopped moving, so each one becomes a {@link CodingFailure} that travels
8
+ * with the checkpoint and reaches the next step as a one-shot notice. The note
9
+ * never becomes a Turn and never adds a Session event: it rides the message
10
+ * channel the Host already injects into.
11
+ *
12
+ * This module is pure and browser safe: no I/O, no dependencies, and no clock
13
+ * other than the timestamp default, so the Host preset, the worker presets, and
14
+ * the Web client can all import it.
15
+ *
16
+ * @module dsh-coding/failures
17
+ */
18
+ import type { PromptLanguage } from './language.js';
19
+ /** The dispatch points whose blocking exceptions are reported. */
20
+ export type FailurePoint = 'projection' | 'restore' | 'tool-table' | 'reasoning' | 'delegate' | 'verification' | 'handoff' | 'command';
21
+ /** Every failure point, in report order. */
22
+ export declare const FAILURE_POINTS: readonly FailurePoint[];
23
+ /** One blocking exception, reduced to what a notice and a status line need. */
24
+ export interface CodingFailure {
25
+ /** Which dispatch point threw. */
26
+ readonly point: FailurePoint;
27
+ /** The exception message, trimmed and bounded. */
28
+ readonly reason: string;
29
+ /** What the operator can do about it, in the conversation language. */
30
+ readonly action: string;
31
+ readonly at: number;
32
+ }
33
+ /**
34
+ * Build a report for one blocking exception.
35
+ * @param point - dispatch point that threw.
36
+ * @param error - the caught value, usually an `Error`.
37
+ * @param language - conversation language of the session.
38
+ * @param at - timestamp to stamp, defaults to now.
39
+ * @returns the report; its action is drawn from {@link FAILURE_ACTION}.
40
+ */
41
+ export declare function makeFailure(point: FailurePoint, error: unknown, language: PromptLanguage, at?: number): CodingFailure;
42
+ /**
43
+ * Validate one untyped value as a {@link CodingFailure}. The report is persisted
44
+ * in checkpoints and restored from durable JSON written by an arbitrary earlier
45
+ * build, so every field is re-checked here rather than trusted.
46
+ * @param value - decoded JSON or any other untyped value.
47
+ * @returns the normalized report, or undefined when it is not one.
48
+ */
49
+ export declare function asFailure(value: unknown): CodingFailure | undefined;
50
+ /**
51
+ * Render the user-facing notice for one report: what broke and what to do.
52
+ * @param failure - the report to render.
53
+ * @param language - conversation language of the session.
54
+ * @returns the notice as a short Markdown block.
55
+ */
56
+ export declare function failureNotice(failure: CodingFailure, language: PromptLanguage): string;
57
+ /**
58
+ * Render the one-fragment form used by the status line.
59
+ * @param failure - the report to render.
60
+ * @returns `failure <point>`.
61
+ */
62
+ export declare function failureStatus(failure: CodingFailure): string;
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Cross-stage handoff: the bounded record one stage gives the next.
3
+ *
4
+ * The record is a summary, never a transcript: every list and every free-text
5
+ * value has a fixed cap, so a long run cannot flood the next worker's prompt. A
6
+ * patch is merged into the previous record instead of replacing it, because the
7
+ * planner, implementer, and verifier each contribute their own section.
8
+ *
9
+ * This module is pure and browser safe: no I/O, no dependencies, no clock other
10
+ * than the timestamp default. The Host runtime, the worker presets, and the Web
11
+ * client can therefore import it directly.
12
+ *
13
+ * @module dsh-coding/handoff
14
+ */
15
+ /** Version of the persisted {@link CodingHandoff} shape. */
16
+ export declare const HANDOFF_VERSION = 1;
17
+ /** Longest single free-text value (goal, one list item, acceptance, avoid note). */
18
+ export declare const HANDOFF_TEXT_LIMIT = 600;
19
+ /** Most entries kept per bullet section (`constraints`, `findings`, …). */
20
+ export declare const HANDOFF_ITEMS_LIMIT = 10;
21
+ /** Most plan tasks the handoff carries. */
22
+ export declare const HANDOFF_TASKS_LIMIT = 8;
23
+ /** Most changed-file entries the handoff carries. */
24
+ export declare const HANDOFF_CHANGES_LIMIT = 20;
25
+ /** Default length of {@link handoffDigest}. */
26
+ export declare const HANDOFF_DIGEST_LIMIT = 1200;
27
+ /** Longest worker-facing rendering of the handoff. */
28
+ export declare const HANDOFF_WORKER_LIMIT = 2000;
29
+ /** One planned task of the run, as the planner worker reports it. */
30
+ export interface HandoffTask {
31
+ readonly goal: string;
32
+ readonly files: readonly string[];
33
+ readonly acceptance: string;
34
+ /** What the implementer must not do while touching these files. */
35
+ readonly avoid?: string;
36
+ }
37
+ /** One file this run changed, with the smallest useful summary. */
38
+ export interface HandoffChange {
39
+ readonly file: string;
40
+ readonly summary: string;
41
+ }
42
+ /** The bounded handoff record a stage persists for the stages after it. */
43
+ export interface CodingHandoff {
44
+ readonly version: typeof HANDOFF_VERSION;
45
+ /** What the run is for; cleared by patching it with an empty string. */
46
+ readonly goal?: string;
47
+ readonly constraints: readonly string[];
48
+ /** Acceptance criteria: the definition of done `verify` and `deliver` check. */
49
+ readonly acceptance: readonly string[];
50
+ readonly findings: readonly string[];
51
+ readonly decisions: readonly string[];
52
+ /** Questions still open; the next stage answers or escalates them. */
53
+ readonly open: readonly string[];
54
+ readonly tasks: readonly HandoffTask[];
55
+ readonly changes: readonly HandoffChange[];
56
+ readonly updatedAt: number;
57
+ }
58
+ /** A partial update applied by {@link mergeHandoff}; absent fields are untouched. */
59
+ export interface HandoffPatch {
60
+ readonly goal?: string;
61
+ readonly constraints?: readonly string[];
62
+ readonly acceptance?: readonly string[];
63
+ readonly findings?: readonly string[];
64
+ readonly decisions?: readonly string[];
65
+ readonly open?: readonly string[];
66
+ /** Replaces the task list wholesale when present. */
67
+ readonly tasks?: readonly HandoffTask[];
68
+ /** Merged by `file` when present, so a later stage refines a summary. */
69
+ readonly changes?: readonly HandoffChange[];
70
+ }
71
+ /** A role that receives the handoff, in dispatch order. */
72
+ type HandoffRole = 'plan' | 'implement' | 'verify';
73
+ /** An empty handoff stamped at `at`, defaulting to now. */
74
+ export declare function emptyHandoff(at?: number): CodingHandoff;
75
+ /**
76
+ * Merge one patch into a handoff. A list patch appends (dropping exact
77
+ * duplicates, keeping the newest {@link HANDOFF_ITEMS_LIMIT} entries); a task
78
+ * patch replaces the list; a change patch refines entries by `file`.
79
+ * @param base - the record being updated, or undefined to start empty.
80
+ * @param patch - the sections this stage contributes.
81
+ * @param at - timestamp to stamp, defaults to now.
82
+ * @returns a new record; the inputs are not mutated.
83
+ */
84
+ export declare function mergeHandoff(base: CodingHandoff | undefined, patch: HandoffPatch, at?: number): CodingHandoff;
85
+ /**
86
+ * Validate one untyped value as a {@link CodingHandoff}. The record is persisted
87
+ * in checkpoints and restored from durable JSON, so every field is re-checked
88
+ * here rather than trusted from the writer's build.
89
+ * @param value - decoded JSON or any other untyped value.
90
+ * @returns the normalized record, or undefined when it is not version 1.
91
+ */
92
+ export declare function asHandoff(value: unknown): CodingHandoff | undefined;
93
+ /**
94
+ * Render the handoff as a compact multi-line digest for logs and status text.
95
+ * Only the sections carrying content are rendered, one short line each.
96
+ * @param handoff - record to render, or undefined.
97
+ * @param limit - maximum length, whole lines preferred.
98
+ * @returns the digest, or '' when the record is empty.
99
+ */
100
+ export declare function handoffDigest(handoff: CodingHandoff | undefined, limit?: number): string;
101
+ /**
102
+ * Render the sections one worker role receives, as a prompt fragment.
103
+ * @param handoff - record to render, or undefined.
104
+ * @param role - worker about to run.
105
+ * @returns the fragment, or '' when nothing applies to this role.
106
+ */
107
+ export declare function handoffForWorker(handoff: CodingHandoff | undefined, role: HandoffRole): string;
108
+ /** Whether the handoff states a goal, which `plan` requires before planning. */
109
+ export declare function hasGoal(handoff: CodingHandoff): boolean;
110
+ /** Whether the handoff states at least one acceptance criterion, which `verify` and `deliver` require. */
111
+ export declare function hasDefinitionOfDone(handoff: CodingHandoff): boolean;
112
+ export {};
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Host-side settings service of the `dsh-coding` bundle.
3
+ *
4
+ * This row is the bundle's only Host contribution: it owns the verified
5
+ * configuration the Coding preset and its three worker presets read, and it
6
+ * performs no agent work by itself. Installing the bundle therefore changes no
7
+ * existing session; only a session that selects the Coding preset runs the
8
+ * enforced runtime.
9
+ *
10
+ * It also filters this bundle's three internal worker presets out of the exported
11
+ * preset roster: no client offers them, while the Host roster keeps resolving
12
+ * the compositions `delegate_implement` and `delegate_verify` dispatch to.
13
+ *
14
+ * The configuration is validated twice on purpose: {@link Config} (Schemastery)
15
+ * rejects a malformed row at activation, and {@link normalizeConfig} parses both
16
+ * worker routes so a missing model fails the mount instead of silently
17
+ * inheriting the lead's own model at dispatch.
18
+ *
19
+ * @module dsh-coding
20
+ */
21
+ import { Service } from '@deepseek-ai/cordis';
22
+ import { Config as CodingConfigSchema, type CodingConfig } from './config.js';
23
+ export { Config, configJsonSchema, parseWorkerRoute } from './config.js';
24
+ export type { CodingConfig, WorkerRoute } from './config.js';
25
+ /** The same JSON Schema under the name non-Loader consumers expect. */
26
+ export declare const configSchema: {
27
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
28
+ readonly title: "dsh-coding configuration";
29
+ readonly type: "object";
30
+ readonly additionalProperties: false;
31
+ readonly required: readonly ["implementWorkerModel", "verifyWorkerModel", "plannerWorkerModel"];
32
+ readonly properties: {
33
+ readonly defaultMode: {
34
+ readonly type: "string";
35
+ readonly enum: readonly import("./stages.js").CodingMode[];
36
+ readonly default: "auto";
37
+ readonly description: "Mode a new Coding session starts in.";
38
+ };
39
+ readonly implementWorkerModel: {
40
+ readonly type: "string";
41
+ readonly pattern: "^[^/\\s]+/[^/\\s]+$";
42
+ readonly description: "provider/model route for the implement worker; never inherited from the lead.";
43
+ };
44
+ readonly verifyWorkerModel: {
45
+ readonly type: "string";
46
+ readonly pattern: "^[^/\\s]+/[^/\\s]+$";
47
+ readonly description: "provider/model route for the verify worker; never inherited from the lead.";
48
+ };
49
+ readonly plannerWorkerModel: {
50
+ readonly type: "string";
51
+ readonly pattern: "^[^/\\s]+/[^/\\s]+$";
52
+ readonly description: "provider/model route for the planner worker (pro model); never inherited from the lead.";
53
+ };
54
+ readonly language: {
55
+ readonly type: "string";
56
+ readonly enum: readonly import("./language.js").LanguageMode[];
57
+ readonly default: "auto";
58
+ readonly description: "Conversation language: auto follows the DSH interface, then the host locale.";
59
+ };
60
+ readonly reasoning: {
61
+ readonly type: "string";
62
+ readonly enum: readonly ["auto", "low", "high", "max"];
63
+ readonly default: "auto";
64
+ readonly description: "Reasoning level: auto classifies each turn; low, high, and max pin every turn.";
65
+ };
66
+ readonly maxVerifyAttempts: {
67
+ readonly type: "integer";
68
+ readonly minimum: 0;
69
+ readonly default: 5;
70
+ readonly description: "Failed verifications allowed before the run delivers blocked; 0 means no limit.";
71
+ };
72
+ readonly maxSameFailure: {
73
+ readonly type: "integer";
74
+ readonly minimum: 0;
75
+ readonly default: 2;
76
+ readonly description: "Repeats of the identical failure allowed before delivering blocked; 0 means no limit.";
77
+ };
78
+ readonly verificationTimeoutMs: {
79
+ readonly type: "integer";
80
+ readonly minimum: 0;
81
+ readonly default: 360000;
82
+ readonly description: "Longest running time of one verification command in ms; a timeout counts as a failed verification; 0 means no limit.";
83
+ };
84
+ readonly verificationCommands: {
85
+ readonly type: "object";
86
+ readonly additionalProperties: {
87
+ readonly type: "string";
88
+ };
89
+ readonly default: {};
90
+ readonly description: "Verification command overrides keyed by kind or kind:scope.";
91
+ };
92
+ };
93
+ };
94
+ /** Cordis plugin name used by loader diagnostics. */
95
+ export declare const name = "dsh-coding";
96
+ /** One roster row as the preset registry exports it. */
97
+ interface RosterRow {
98
+ readonly id: string;
99
+ }
100
+ /**
101
+ * The client-facing roster without this bundle's worker presets. The Host
102
+ * roster keeps them: `delegate_implement` / `delegate_verify` resolve their
103
+ * compositions from it, and only the exported list is a user-facing surface.
104
+ * @param roster - `remoteExportList()` result.
105
+ * @returns the same roster minus the worker rows.
106
+ */
107
+ export declare function filterWorkerPresets<T extends {
108
+ presets: readonly RosterRow[];
109
+ }>(roster: T): T;
110
+ /**
111
+ * Filter the preset registry's client-facing export for this deployment.
112
+ *
113
+ * DSH has no hidden-preset flag, and a browser-side replacement of the shipped
114
+ * picker costs the product's own chip, copy, and interaction. The registry
115
+ * exports its roster through one Remote method, and the gateway resolves that
116
+ * method per call, so wrapping it here hides the workers from every client
117
+ * surface while the Host keeps dispatching to them.
118
+ * @param ctx - owning host context.
119
+ */
120
+ export declare function installWorkerPresetFilter(ctx: any): void;
121
+ /**
122
+ * Bundle settings surface (`ctx.dshCodingRuntime`).
123
+ *
124
+ * The service exposes only immutable, already-verified options: consumers never
125
+ * re-validate, and no agent behavior depends on an unvalidated value.
126
+ */
127
+ export default class DshCodingSettings extends Service {
128
+ /** Schemastery schema the Loader validates the bundle row's `config` with. */
129
+ static Config: import("@deepseek-ai/schemastery").default<CodingConfigSchema>;
130
+ private readonly raw;
131
+ /**
132
+ * @param ctx - owning host context.
133
+ * @param config - Loader-validated row configuration. The page-editable fields
134
+ * arrive as Schemastery volatile accessors, so every read below observes the
135
+ * value currently saved on the plugin page.
136
+ * @throws when a worker route is absent or not a `provider/model` pair.
137
+ */
138
+ constructor(ctx: any, config: CodingConfig);
139
+ /**
140
+ * Verified configuration, re-read from the volatile fields on every access.
141
+ * @throws when a page-edited worker route is not a usable `provider/model` pair.
142
+ */
143
+ get options(): CodingConfig;
144
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Conversation language for this Host. The package ships Chinese and English
3
+ * only: a Chinese desktop or host locale selects Chinese, everything else
4
+ * falls back to English — the same rule the Client dictionaries follow.
5
+ *
6
+ * DSH keeps the interface preference inside the locale plugin's entry config,
7
+ * so the Host reads it from the running composition instead of guessing from
8
+ * the browser. When nothing stored a preference, the operating system's
9
+ * language list decides — the same source the desktop window uses — and only
10
+ * then the host locale.
11
+ */
12
+ export type PromptLanguage = 'zh' | 'en';
13
+ export type LanguageMode = 'auto' | PromptLanguage;
14
+ /** Values accepted by the settings surface. */
15
+ export declare const LANGUAGE_MODES: readonly LanguageMode[];
16
+ /** Malformed or unknown values fall back to automatic resolution. */
17
+ export declare function normalizeLanguageMode(value: unknown): LanguageMode;
18
+ /**
19
+ * Map one BCP 47-style tag (or a POSIX `LANG` value) onto a shipped language.
20
+ * Chinese is the only match that selects Chinese; every other tag is English.
21
+ */
22
+ export declare function languageOf(tag: unknown): PromptLanguage;
23
+ /**
24
+ * A POSIX locale that states no language preference at all. `C.UTF-8` is a
25
+ * codeset variant of `C`, and it is the value a macOS login shell commonly
26
+ * exports — treating it as "English" is what made a Chinese desktop answer in
27
+ * English.
28
+ */
29
+ export declare function isNeutralLocale(value: string): boolean;
30
+ /**
31
+ * The DSH interface preference, read from the locale plugin's loader entry.
32
+ * `loader.entries()` covers the whole composition, so a nested row is found
33
+ * too; an unavailable loader simply means "no explicit preference".
34
+ */
35
+ export declare function localePreferenceOf(loader: any): string | undefined;
36
+ /** The host locale: POSIX locale variables first, then the OS default. */
37
+ export declare function hostLocaleOf(env?: Record<string, string | undefined>): string;
38
+ export interface LanguageInputs {
39
+ /** The plugin setting: auto follows DSH, zh/en pin the language. */
40
+ mode?: unknown;
41
+ /** The running composition, used for the stored DSH preference. */
42
+ loader?: any;
43
+ /** Test seam for the host locale; defaults to POSIX variables and the OS. */
44
+ locale?: string;
45
+ /**
46
+ * The operating system's preferred languages, in order. The Host runs with
47
+ * the login-shell environment, so on a macOS desktop the POSIX variables are
48
+ * usually neutral while the window itself follows the system language.
49
+ * Passing a thunk keeps the probe from running when the language is pinned.
50
+ */
51
+ systemLanguages?: readonly string[] | (() => readonly string[]);
52
+ }
53
+ /** Resolve the language used by prompts, tool text, and todo items. */
54
+ export declare function resolveHostLanguage(inputs?: LanguageInputs): PromptLanguage;
55
+ /** Prompt section that fixes the conversation language for the session. */
56
+ export declare function languagePrompt(language: PromptLanguage): string;
@@ -0,0 +1,27 @@
1
+ import type { ContextFormed, UserMessage } from '@deepseek-ai/dsh-llm';
2
+ declare module '@deepseek-ai/dsh-llm' {
3
+ interface MessageSourceMap {
4
+ /** Per-step stage contract injected by the Coding runtime. */
5
+ 'dsh-coding-stage': {
6
+ kind: 'dsh-coding-stage';
7
+ } & ContextFormed;
8
+ /** A control notice produced by `/coding` and by the stage machine. */
9
+ 'dsh-coding-control': {
10
+ kind: 'dsh-coding-control';
11
+ } & ContextFormed;
12
+ }
13
+ }
14
+ /**
15
+ * Build the per-step stage context message.
16
+ * @param text - complete stage fragment.
17
+ * @param summary - one-line account shown without expanding the row.
18
+ * @returns an immutable user-role context message.
19
+ */
20
+ export declare function stageMessage(text: string, summary: string): UserMessage;
21
+ /**
22
+ * Build a control notice delivered by `agent.followup()` or `agent.steer()`.
23
+ * @param text - what the runtime decided and what the model should do.
24
+ * @param summary - one-line account for the conversation row.
25
+ * @returns an immutable user-role context message.
26
+ */
27
+ export declare function controlMessage(text: string, summary: string): UserMessage;