@carljia/omd-dsh 0.1.1 → 0.1.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.
@@ -0,0 +1,147 @@
1
+ import { access, readFile } from "node:fs/promises";
2
+ import { isAbsolute, join } from "node:path";
3
+ import { scopeOf } from "@deepseek-ai/dsh-scope";
4
+ /**
5
+ * @module @carljia/omd-dsh/startwork
6
+ *
7
+ * omd-start-work: human-facing `/start-work` command -- the "start work"
8
+ * trigger at the end of the OMD planning workflow. It resolves the named
9
+ * plan file inside the workspace's plan directory (a fixed, code-level
10
+ * convention -- never mentioned in any persona/prompt text), arms a goal
11
+ * whose objective references the plan's absolute path, and goal
12
+ * auto-continuation then drives the agent to execute the plan without
13
+ * further input.
14
+ */
15
+ /** Cordis plugin name. */
16
+ const name = "omd-start-work";
17
+ /** The goal domain is already required by tool-goal in the same preset. */
18
+ const inject = ["goals"];
19
+ /** Plan directory segments relative to the session workspace root (cwd). */
20
+ const PLAN_DIR_SEGMENTS = [".omd", "plans"];
21
+ /** The prefix accepted when a user pastes the full relative plan path. */
22
+ const PLAN_DIR_PREFIX = ".omd/plans/";
23
+ /** Plan directory for one workspace root. */
24
+ function plansDir(cwd) {
25
+ return join(cwd, ...PLAN_DIR_SEGMENTS);
26
+ }
27
+ /**
28
+ * Resolve the user's file-name input to a candidate path inside the plan
29
+ * directory. Accepts a bare file name ("foo.md" / "foo") or the full
30
+ * relative path (".omd/plans/foo.md"); rejects absolute paths and anything
31
+ * that would escape the plan directory.
32
+ */
33
+ function resolveCandidate(cwd, input) {
34
+ const trimmed = String(input).trim().replace(/\\/g, "/");
35
+ if (trimmed === "" || isAbsolute(trimmed))
36
+ return undefined;
37
+ let name = trimmed.replace(/^\.\//, "");
38
+ if (name.includes("/")) {
39
+ if (!name.startsWith(PLAN_DIR_PREFIX))
40
+ return undefined;
41
+ name = name.slice(PLAN_DIR_PREFIX.length);
42
+ }
43
+ if (name === "" || name.includes("/") || name === "." || name === "..")
44
+ return undefined;
45
+ if (name.startsWith("."))
46
+ return undefined; // no hidden-file tricks
47
+ return join(plansDir(cwd), name);
48
+ }
49
+ /** One /start-work invocation through the goal domain. */
50
+ async function executeStartWork(ctx, invocation) {
51
+ const agent = invocation.agent;
52
+ const cwd = agent !== undefined &&
53
+ agent.session !== undefined &&
54
+ agent.session.header !== undefined &&
55
+ typeof agent.session.header.cwd === "string"
56
+ ? agent.session.header.cwd
57
+ : "";
58
+ if (cwd === "") {
59
+ return {
60
+ kind: "error",
61
+ text: "This session has no workspace directory; /start-work needs one to find the plan file.",
62
+ };
63
+ }
64
+ const candidate = resolveCandidate(cwd, invocation.rawInput);
65
+ if (candidate === undefined) {
66
+ return {
67
+ kind: "error",
68
+ text: "Usage: /start-work <plan file name> — the file must live inside " + PLAN_DIR_SEGMENTS.join("/") + "/.",
69
+ };
70
+ }
71
+ let file = candidate;
72
+ const usable = async (path) => {
73
+ try {
74
+ await access(path);
75
+ return true;
76
+ }
77
+ catch {
78
+ return false;
79
+ }
80
+ };
81
+ if (!(await usable(file)) && !file.endsWith(".md") && (await usable(file + ".md"))) {
82
+ file = file + ".md";
83
+ }
84
+ else if (!(await usable(file))) {
85
+ return {
86
+ kind: "error",
87
+ text: "Plan file not found: " + PLAN_DIR_SEGMENTS.join("/") + "/" + file.slice(plansDir(cwd).length + 1),
88
+ };
89
+ }
90
+ let text;
91
+ try {
92
+ text = await readFile(file, "utf8");
93
+ }
94
+ catch (error) {
95
+ return {
96
+ kind: "error",
97
+ text: "Cannot read the plan file: " + (error instanceof Error ? error.message : String(error)),
98
+ };
99
+ }
100
+ if (text.trim() === "") {
101
+ return { kind: "error", text: "The plan file is empty." };
102
+ }
103
+ try {
104
+ const current = ctx.goals.get(agent);
105
+ if (current !== undefined && current.phase !== "complete") {
106
+ return {
107
+ kind: "error",
108
+ text: `A goal is already ${current.phase}. Run /goal clear first, then /start-work <plan file name>.`,
109
+ };
110
+ }
111
+ ctx.goals.create(agent, {
112
+ objective: "Execute the approved plan file at " +
113
+ file +
114
+ ". Read the file in full, then carry out every step autonomously: implement, verify, and iterate until the plan's goal and success criteria are met. Work through goal continuation rounds until done.",
115
+ });
116
+ return {
117
+ kind: "success",
118
+ text: "Start work armed — executing the plan to completion.\nPlan: " +
119
+ PLAN_DIR_SEGMENTS.join("/") +
120
+ "/" +
121
+ file.slice(plansDir(cwd).length + 1),
122
+ };
123
+ }
124
+ catch (error) {
125
+ return {
126
+ kind: "error",
127
+ text: "start-work failed: " + (error instanceof Error ? error.message : String(error)),
128
+ };
129
+ }
130
+ }
131
+ function apply(ctx) {
132
+ if (scopeOf(ctx) === undefined) {
133
+ throw new Error("omd-start-work: refusing to mount outside a scoped context; mount this row inside an agent preset");
134
+ }
135
+ ctx.inject(["commands"], (commandCtx) => {
136
+ commandCtx.commands.register({
137
+ name: "start-work",
138
+ description: "start work: arm a goal that executes the named plan file to completion",
139
+ input: {
140
+ hint: "<plan file name>",
141
+ images: false,
142
+ },
143
+ handler: (invocation) => executeStartWork(ctx, invocation),
144
+ });
145
+ });
146
+ }
147
+ export { apply, inject, name };
@@ -13,7 +13,10 @@
13
13
  "model": "deepseek-v4-flash",
14
14
  "hint": "cheap and fast — repetitive investigation, searching, summarising, mechanical work",
15
15
  "persona": "You are a FAST worker subagent (快速执行子代理): complete the assigned task efficiently with the tools you have; prefer short, focused answers.",
16
- "toolFilter": { "deny": ["write", "edit"], "denyShell": true }
16
+ "toolFilter": {
17
+ "deny": ["write", "edit"],
18
+ "denyShell": true
19
+ }
17
20
  },
18
21
  "deep": {
19
22
  "provider": "deepseek-official",
@@ -23,7 +26,7 @@
23
26
  }
24
27
  }
25
28
  },
26
- "architect": {
29
+ "ultraworker": {
27
30
  "provider": "deepseek-official",
28
31
  "model": "deepseek-v4-pro",
29
32
  "tiers": {
@@ -32,7 +35,10 @@
32
35
  "model": "deepseek-v4-flash",
33
36
  "hint": "cheap and fast — repetitive investigation, searching, summarising, mechanical work",
34
37
  "persona": "You are a FAST worker subagent (快速执行子代理): complete the assigned task efficiently with the tools you have; prefer short, focused answers.",
35
- "toolFilter": { "deny": ["write", "edit"], "denyShell": true }
38
+ "toolFilter": {
39
+ "deny": ["write", "edit"],
40
+ "denyShell": true
41
+ }
36
42
  },
37
43
  "deep": {
38
44
  "provider": "deepseek-official",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carljia/omd-dsh",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "OMD 理念的 DeepSeek Harness 插件:模式能力边界 + 按模式配模型 + tier 差异化子代理委派",
5
5
  "keywords": [
6
6
  "deepseek-harness",
@@ -43,7 +43,7 @@
43
43
  "files": [
44
44
  "lib",
45
45
  "presets",
46
- "omd-matrix.json",
46
+ "omd-matrix.default.json",
47
47
  "README.md",
48
48
  "LICENSE"
49
49
  ],
@@ -8,6 +8,8 @@
8
8
 
9
9
  # [omd-dsh:mode:start]
10
10
  # [omd-dsh:mode:end]
11
+ - id: omd-mode-switch
12
+ name: '../.omd-vendor/omd-mode-switch.mjs'
11
13
  - id: tool-ask-user
12
14
  name: '@deepseek-ai/dsh-tool-ask-user'
13
15
 
@@ -4,10 +4,37 @@
4
4
  name: '@deepseek-ai/dsh-persona'
5
5
  config:
6
6
  text: >-
7
- You are in OMD EXECUTOR mode (OMD · 执行者): a full-capability autonomous executor on DeepSeek Harness. Work autonomously toward the stated goal — plan, execute, verify, and iterate until the task is actually done. For long-running work use the harness-native orchestration: the goal tool for a tracked completion objective, workflow for multi-agent fan-out, ralph for fresh-agent iteration, and omd_task for tiered delegation (cheap tiers for repetitive investigation, strong tiers for hard reasoning). Do not stop to ask when the path forward is clear. If the user starts a message with ulw or ultrawork, treat the rest as one autonomous objective: create a goal for it and pursue it to completion without further input. 本模式路由模型:{{model}}(provider: {{provider}})。
7
+ You are in OMD EXECUTOR mode (OMD · 执行者): a full-capability autonomous executor on DeepSeek Harness. Work autonomously toward the stated goal — plan, execute, verify, and iterate until the task is actually done. For long-running work use the harness-native orchestration: the goal tool for a tracked completion objective, workflow for multi-agent fan-out, ralph for fresh-agent iteration, and omd_task for tiered delegation (cheap tiers for repetitive investigation, strong tiers for hard reasoning). Do not stop to ask when the path forward is clear. If the user starts a message with ulw or ultrawork, treat the rest as one autonomous objective: create a goal for it and pursue it to completion without further input. If a /start-work command arms a goal, execute the plan file named by the goal objective: read that file in full, then carry out its steps autonomously until its goal and success criteria are met. 本模式路由模型:{{model}}(provider: {{provider}})。
8
8
 
9
9
  # [omd-dsh:mode:start]
10
10
  # [omd-dsh:mode:end]
11
+ - id: omd-start-work
12
+ name: '../.omd-vendor/omd-start-work.mjs'
13
+
14
+ - id: omd-mode-switch
15
+ name: '../.omd-vendor/omd-mode-switch.mjs'
16
+
17
+ - id: planning
18
+ name: cordis:group
19
+ group: true
20
+ isolate:
21
+ planMode: true
22
+ config:
23
+ - id: plan-mode
24
+ name: '@deepseek-ai/dsh-plan-mode'
25
+ config:
26
+ section: |
27
+ You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
28
+
29
+ Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
30
+
31
+ The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
32
+
33
+ Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
34
+
35
+ Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
36
+
37
+ When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
11
38
  - id: agent-instructions
12
39
  name: '@deepseek-ai/dsh-agent-instructions'
13
40
  config:
@@ -8,6 +8,8 @@
8
8
 
9
9
  # [omd-dsh:mode:start]
10
10
  # [omd-dsh:mode:end]
11
+ - id: omd-mode-switch
12
+ name: '../.omd-vendor/omd-mode-switch.mjs'
11
13
  - id: agent-instructions
12
14
  name: '@deepseek-ai/dsh-agent-instructions'
13
15
  config:
@@ -8,6 +8,8 @@
8
8
 
9
9
  # [omd-dsh:mode:start]
10
10
  # [omd-dsh:mode:end]
11
+ - id: omd-mode-switch
12
+ name: '../.omd-vendor/omd-mode-switch.mjs'
11
13
  - id: agent-instructions
12
14
  name: '@deepseek-ai/dsh-agent-instructions'
13
15
  config:
@@ -4,10 +4,15 @@
4
4
  name: '@deepseek-ai/dsh-persona'
5
5
  config:
6
6
  text: >-
7
- You are in OMD PLANNER mode (OMD · 规划访谈): a planning-and-interview agent on DeepSeek Harness. The harness plan-mode section supplies your planning rules — follow it. You are read-only: explore, ask the user, and produce plans; never edit files or run shells. Delegate content investigation to omd_task tier investigate (a cheap model does the repetitive research) and plan review to tier review; keep the top-level planning with your own reasoning. 本模式路由模型:{{model}}(provider: {{provider}})。
7
+ You are in OMD PLANNER mode (OMD · 规划访谈): a planning-and-interview agent on DeepSeek Harness. The harness plan-mode section supplies your planning rules — follow it. You are read-only: explore, ask the user, and produce plans; never edit files or run shells. Delegate content investigation to omd_task tier investigate (a cheap model does the repetitive research) and plan review to tier review; keep the top-level planning with your own reasoning. When the plan is approved, the exit_plan_mode result names the plan file that was saved automatically. Your final message in this session MUST end with the fixed START WORK step (the last step of this workflow, always): confirm the plan is saved, then tell the user the two ways to start working — run /start-work <计划文件名> in a new omd-executor session, or run /mode omd-executor to switch this session and continue right here. Never begin implementing in this read-only planner session. 本模式路由模型:{{model}}(provider: {{provider}})。
8
8
 
9
9
  # [omd-dsh:mode:start]
10
10
  # [omd-dsh:mode:end]
11
+ - id: omd-plan
12
+ name: '../.omd-vendor/omd-plan.mjs'
13
+
14
+ - id: omd-mode-switch
15
+ name: '../.omd-vendor/omd-mode-switch.mjs'
11
16
  - id: agent-instructions
12
17
  name: '@deepseek-ai/dsh-agent-instructions'
13
18
  config:
@@ -35,6 +40,8 @@
35
40
 
36
41
  When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
37
42
 
43
+ Once the plan is approved, the exit_plan_mode result names the automatically saved plan file. Close the conversation with your persona's fixed Start Work final step — this is the last workflow step, always — and never start implementing in this read-only session.
44
+
38
45
  - id: tool-fs
39
46
  name: '@deepseek-ai/dsh-tool-fs'
40
47
 
@@ -8,6 +8,8 @@
8
8
 
9
9
  # [omd-dsh:mode:start]
10
10
  # [omd-dsh:mode:end]
11
+ - id: omd-mode-switch
12
+ name: '../.omd-vendor/omd-mode-switch.mjs'
11
13
  - id: agent-instructions
12
14
  name: '@deepseek-ai/dsh-agent-instructions'
13
15
  config:
@@ -1,13 +1,18 @@
1
- # omd-architect preset (OMD architect mode). Generated by omd-dsh — see README for the mode matrix.
1
+ # omd-ultraworker preset (OMD ultraworker mode). Generated by omd-dsh — see README for the mode matrix.
2
2
 
3
3
  - id: persona
4
4
  name: '@deepseek-ai/dsh-persona'
5
5
  config:
6
6
  text: >-
7
- You are in OMD ARCHITECT mode (OMD · 架构构建): a deep builder on DeepSeek Harness. Design first — understand the system, identify seams and invariants — then implement in careful, reviewable steps and verify before declaring done. Use workflow for structured multi-piece work and omd_task for tiered delegation (cheap tiers for repetitive investigation, strong tiers for deep reasoning). 本模式路由模型:{{model}}(provider: {{provider}})。
7
+ You are in ULTRAWORKER mode (OMD · 超能工作者): a deep, high-throughput builder on DeepSeek Harness with PTC (Code Mode) tool presentation. Design first — understand the system, identify seams and invariants — then implement in careful, reviewable steps and verify before declaring done. Your tools are presented as a TypeScript SDK: compose multi-step operations into one run_code program instead of one tool call per action. Use workflow for structured multi-piece work and omd_task for tiered delegation (cheap tiers for repetitive investigation, strong tiers for deep reasoning). If a /start-work command arms a goal, execute the plan file named by the goal objective: read that file in full, then carry out its steps autonomously until its goal and success criteria are met. 本模式路由模型:{{model}}(provider: {{provider}})。
8
8
 
9
9
  # [omd-dsh:mode:start]
10
10
  # [omd-dsh:mode:end]
11
+ - id: omd-start-work
12
+ name: '../.omd-vendor/omd-start-work.mjs'
13
+
14
+ - id: omd-mode-switch
15
+ name: '../.omd-vendor/omd-mode-switch.mjs'
11
16
  - id: agent-instructions
12
17
  name: '@deepseek-ai/dsh-agent-instructions'
13
18
  config:
@@ -110,3 +115,12 @@
110
115
  config:
111
116
  fetch: false
112
117
  searchTimeoutMs: 60000
118
+
119
+ # PTC (Code Mode) presentation for this agent alone: the model writes a
120
+ # TypeScript program against a generated SDK and run_code executes it, so a
121
+ # sequence that would be five round trips becomes one. The row waits for the
122
+ # host's codeRuntime rather than assuming it.
123
+ - id: tool-presentation
124
+ name: '@deepseek-ai/dsh-agent-tool-presentation'
125
+ config:
126
+ mode: code
@@ -0,0 +1,3 @@
1
+ name: OMD · 超能工作者
2
+ description: 深度构建模式:完整工具集 + workflow + omd_task 差异化委派 + PTC(Code Mode,模型以 TypeScript SDK 呈现工具,多步操作一次往返)。
3
+ order: 102
@@ -1,3 +0,0 @@
1
- name: OMD · 架构构建
2
- description: 深度构建模式:完整工具集 + workflow + omd_task 差异化委派(不含 ralph)。
3
- order: 102