dsh-plugin-recipe 0.0.0-stage → 0.2.4
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.
- package/LICENSE +21 -0
- package/README.md +81 -2
- package/cordis.patch.yml +4 -0
- package/dist/index.d.ts +165 -0
- package/dist/index.js +1297 -0
- package/icon.png +0 -0
- package/package.json +78 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-experience-optimizer contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,82 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-plugin-recipe
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
把业务目标翻译成可校验、可导出的 DSH 工作流蓝图。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
从 GitHub Release 安装(当前推荐,无需 npm):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
dsh plugin --profile web add "https://github.com/Starlit-Sky-code/dsh-experience-optimizer/releases/download/v0.2.4/dsh-plugin-recipe-0.2.4.tgz"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
发布到 npm 后:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
dsh plugin --profile web add dsh-plugin-recipe
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
本地开发:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
dsh plugin --profile web add /absolute/path/to/packages/plugin-recipe
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Web 控制台
|
|
26
|
+
|
|
27
|
+
`dsh-plugin-trim` 的 Web 控制台包含「工作流配方」页签;本插件提供其 Host API,
|
|
28
|
+
用于生成和导出蓝图。安装两个插件后即可在 **设置 → 插件 → 体验优化** 使用。
|
|
29
|
+
|
|
30
|
+
## 工具
|
|
31
|
+
|
|
32
|
+
| 工具 | 读写 | 说明 |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| `recipe_plan_workflow` | 只读 | 最多 4 组追问,输出蓝图/步骤/最小插件集/权限/失败策略/验收/回滚 |
|
|
35
|
+
| `recipe_validate_workflow` | 只读 | 校验依赖、工具、循环、schedule 服务、人工确认、兼容性 |
|
|
36
|
+
| `recipe_export_workflow` | 写数据目录 | 导出 Markdown + JSON 到 `$DSH_HOME/experience-optimizer/recipe/blueprints` |
|
|
37
|
+
|
|
38
|
+
## 使用流程
|
|
39
|
+
|
|
40
|
+
1. 用户说:“我想每周自动整理项目周报。”
|
|
41
|
+
2. 模型调用 `recipe_plan_workflow({ goal })`。
|
|
42
|
+
3. 工具返回一个关键问题(项目/频率、数据源、输出/交付、失败/验收);模型把用户回答填入 `answers` 后再次调用。
|
|
43
|
+
4. 答案足够后返回蓝图;模型调用 `recipe_validate_workflow`。
|
|
44
|
+
5. 用户要求导出时调用 `recipe_export_workflow`。
|
|
45
|
+
|
|
46
|
+
## 自定义能力
|
|
47
|
+
|
|
48
|
+
在 `$DSH_HOME/experience-optimizer/capabilities.json` 写一个数组,或 `{ "capabilities": [...] }`:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
[
|
|
52
|
+
{
|
|
53
|
+
"id": "dingtalk-send",
|
|
54
|
+
"name": "发送到钉钉",
|
|
55
|
+
"purpose": "把周报推送到钉钉群",
|
|
56
|
+
"tools": ["notify_ding"],
|
|
57
|
+
"trigger": "manual",
|
|
58
|
+
"permissions": ["external-send"],
|
|
59
|
+
"needsConfirm": true,
|
|
60
|
+
"keywords": ["钉钉", "发送", "通知"],
|
|
61
|
+
"pluginIds": ["dsh-notify-ding"]
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
同 id 会覆盖内置能力。没有对应工具的能力不会被用于生成步骤。
|
|
67
|
+
|
|
68
|
+
## 配置
|
|
69
|
+
|
|
70
|
+
| key | 默认 | 说明 |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| `maxSteps` | `12` | 超过给 warn |
|
|
73
|
+
| `allowExport` | `true` | 是否允许写蓝图文件 |
|
|
74
|
+
| `capabilitiesFile` | `''` | 自定义能力文件路径;空则用数据目录默认路径 |
|
|
75
|
+
| `defaultDelivery` | `present` | 未命名发送能力时的默认交付 |
|
|
76
|
+
|
|
77
|
+
## 限制
|
|
78
|
+
|
|
79
|
+
- 不自动创建 schedule、不发消息、不改插件。
|
|
80
|
+
- 没有发送工具时只报告 `uncertainties`,不编造步骤。
|
|
81
|
+
- 兼容性报告存在 error 的主体不会进入蓝图;validate 会给出 `COMPAT_CONFLICT`。
|
|
82
|
+
- agent preset 自带工具由 preset 提供,蓝图按“当前可用”生成,不承诺 trim 可开关。
|
package/cordis.patch.yml
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
3
|
+
/** Deployment configuration for the recipe plugin. */
|
|
4
|
+
export interface Config {
|
|
5
|
+
/** Maximum workflow steps before a warning. */
|
|
6
|
+
maxSteps: number;
|
|
7
|
+
/** Allow exporting blueprints to the DSH data directory. */
|
|
8
|
+
allowExport: boolean;
|
|
9
|
+
/** Optional custom capability catalog JSON path; empty uses the default data path. */
|
|
10
|
+
capabilitiesFile: string;
|
|
11
|
+
/** Default delivery seam when the user does not name a send capability. */
|
|
12
|
+
defaultDelivery: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const Config: z<Config>;
|
|
15
|
+
/** A capability seam a workflow step can bind to. */
|
|
16
|
+
interface CapabilitySeam {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
purpose: string;
|
|
20
|
+
/** Model-facing tool names that implement the seam. Empty for model-only capabilities. */
|
|
21
|
+
tools: string[];
|
|
22
|
+
trigger: 'manual' | 'schedule' | 'event';
|
|
23
|
+
permissions: string[];
|
|
24
|
+
needsConfirm: boolean;
|
|
25
|
+
keywords: string[];
|
|
26
|
+
/** Tool package names for the minimum plugin set. */
|
|
27
|
+
pluginIds: string[];
|
|
28
|
+
/** True for a reasoning-only step that needs no tool. */
|
|
29
|
+
modelOnly?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** One workflow step in a plan produced by the recipe layer. */
|
|
32
|
+
interface WorkflowStep {
|
|
33
|
+
id: string;
|
|
34
|
+
intent: string;
|
|
35
|
+
kind: 'tool' | 'model' | 'human' | 'schedule';
|
|
36
|
+
capabilityId: string | null;
|
|
37
|
+
toolNames: string[];
|
|
38
|
+
pluginIds: string[];
|
|
39
|
+
dependsOn: string[];
|
|
40
|
+
needsConfirm: boolean;
|
|
41
|
+
inputs: string[];
|
|
42
|
+
outputs: string[];
|
|
43
|
+
onFailure: string;
|
|
44
|
+
}
|
|
45
|
+
/** Wizard answers. Every field beyond `goal` is optional. */
|
|
46
|
+
interface WizardAnswers {
|
|
47
|
+
goal: string;
|
|
48
|
+
scope?: string;
|
|
49
|
+
frequency?: string;
|
|
50
|
+
sources?: string[];
|
|
51
|
+
outputFormat?: string;
|
|
52
|
+
delivery?: string;
|
|
53
|
+
onFailure?: string;
|
|
54
|
+
acceptance?: string[];
|
|
55
|
+
}
|
|
56
|
+
/** One wizard question, with defaults the model can confirm or correct. */
|
|
57
|
+
interface WizardQuestion {
|
|
58
|
+
step: 'scope-frequency' | 'sources' | 'output-delivery' | 'failure-acceptance';
|
|
59
|
+
question: string;
|
|
60
|
+
defaults: string[];
|
|
61
|
+
allowSkip: boolean;
|
|
62
|
+
fields: (keyof WizardAnswers)[];
|
|
63
|
+
}
|
|
64
|
+
/** A validated, exportable workflow blueprint. */
|
|
65
|
+
interface WorkflowBlueprint {
|
|
66
|
+
schemaVersion: 1;
|
|
67
|
+
id: string;
|
|
68
|
+
createdAt: string;
|
|
69
|
+
goal: string;
|
|
70
|
+
template: 'weekly-report' | 'generic';
|
|
71
|
+
answers: WizardAnswers;
|
|
72
|
+
steps: WorkflowStep[];
|
|
73
|
+
minPluginSet: string[];
|
|
74
|
+
suggestedDisable: string[];
|
|
75
|
+
permissions: string[];
|
|
76
|
+
failurePolicy: string;
|
|
77
|
+
acceptance: string[];
|
|
78
|
+
rollback: string;
|
|
79
|
+
uncertainties: string[];
|
|
80
|
+
}
|
|
81
|
+
interface ValidationIssue {
|
|
82
|
+
level: 'error' | 'warn';
|
|
83
|
+
code: string;
|
|
84
|
+
message: string;
|
|
85
|
+
stepId?: string;
|
|
86
|
+
fix?: string;
|
|
87
|
+
}
|
|
88
|
+
/** Compatibility analysis domain. */
|
|
89
|
+
type CompatDomain = 'plugin-plugin' | 'plugin-runtime' | 'profile' | 'workspace';
|
|
90
|
+
/** Compatibility severity. */
|
|
91
|
+
type CompatSeverity = 'error' | 'warn' | 'info';
|
|
92
|
+
interface CompatEvidence {
|
|
93
|
+
source: 'manifest' | 'loader' | 'plugin-manager' | 'prompt' | 'profile-file' | 'lockfile' | 'runtime';
|
|
94
|
+
summary: string;
|
|
95
|
+
ref?: string;
|
|
96
|
+
}
|
|
97
|
+
interface CompatFix {
|
|
98
|
+
kind: 'disable' | 'enable' | 'update' | 'exemption' | 'reorder' | 'edit-patch' | 'rename' | 'none';
|
|
99
|
+
summary: string;
|
|
100
|
+
safe: boolean;
|
|
101
|
+
target?: string;
|
|
102
|
+
requiresConsent: boolean;
|
|
103
|
+
}
|
|
104
|
+
interface CompatFinding {
|
|
105
|
+
id: string;
|
|
106
|
+
domain: CompatDomain;
|
|
107
|
+
code: string;
|
|
108
|
+
severity: CompatSeverity;
|
|
109
|
+
title: string;
|
|
110
|
+
subjects: string[];
|
|
111
|
+
evidence: CompatEvidence[];
|
|
112
|
+
confidence: 'high' | 'medium' | 'low';
|
|
113
|
+
fix?: CompatFix;
|
|
114
|
+
autoApplicable: boolean;
|
|
115
|
+
}
|
|
116
|
+
/** Built-in capability seams. Tools are checked against the current agent scope at planning time. */
|
|
117
|
+
export declare const BUILT_IN_CAPABILITIES: CapabilitySeam[];
|
|
118
|
+
interface CapabilityCatalog {
|
|
119
|
+
capabilities: CapabilitySeam[];
|
|
120
|
+
diagnostics: string[];
|
|
121
|
+
}
|
|
122
|
+
/** Load built-ins plus an optional user catalog from disk. */
|
|
123
|
+
export declare function loadCapabilities(path?: string): Promise<CapabilityCatalog>;
|
|
124
|
+
interface WizardOptions {
|
|
125
|
+
forceBlueprint?: boolean;
|
|
126
|
+
}
|
|
127
|
+
/** Whether a goal looks like an automatable workflow rather than ordinary Q&A. */
|
|
128
|
+
export declare function isWorkflowGoal(goal: string): boolean;
|
|
129
|
+
/** Fill defaults for the fields the user has not answered. */
|
|
130
|
+
export declare function defaultsFor(goal: string, answers: WizardAnswers): WizardAnswers;
|
|
131
|
+
/** Return the next question group, or null when enough answers exist. */
|
|
132
|
+
export declare function nextQuestion(goal: string, answers: WizardAnswers, options?: WizardOptions): WizardQuestion | null;
|
|
133
|
+
interface TranslateOptions {
|
|
134
|
+
available: Set<string>;
|
|
135
|
+
suggestedDisable?: readonly string[];
|
|
136
|
+
}
|
|
137
|
+
/** Translate a business goal plus answers into a workflow blueprint. */
|
|
138
|
+
export declare function translateGoal(goal: string, answers: WizardAnswers, capabilities: readonly CapabilitySeam[], options: TranslateOptions): WorkflowBlueprint;
|
|
139
|
+
interface ValidateDeps {
|
|
140
|
+
toolExists: (name: string) => boolean;
|
|
141
|
+
pluginKnown: (name: string) => boolean;
|
|
142
|
+
scheduleAvailable: boolean;
|
|
143
|
+
maxSteps: number;
|
|
144
|
+
capabilities: readonly CapabilitySeam[];
|
|
145
|
+
compatFindings?: readonly CompatFinding[];
|
|
146
|
+
}
|
|
147
|
+
/** Validate a blueprint for dependencies, capabilities, permissions, failure handling, and compat. */
|
|
148
|
+
export declare function validateBlueprint(blueprint: WorkflowBlueprint, deps: ValidateDeps): ValidationIssue[];
|
|
149
|
+
/** Render a validation result as a compact Markdown report. */
|
|
150
|
+
export declare function renderValidation(issues: readonly ValidationIssue[]): string;
|
|
151
|
+
type ExportFormat = 'markdown' | 'json' | 'both';
|
|
152
|
+
interface ExportResult {
|
|
153
|
+
id: string;
|
|
154
|
+
markdownPath?: string;
|
|
155
|
+
jsonPath?: string;
|
|
156
|
+
}
|
|
157
|
+
/** Write a blueprint to the DSH data directory. */
|
|
158
|
+
export declare function exportBlueprint(blueprint: WorkflowBlueprint, format?: ExportFormat): Promise<ExportResult>;
|
|
159
|
+
/** Render the human runbook plus a machine-readable JSON block. */
|
|
160
|
+
export declare function renderBlueprintMarkdown(blueprint: WorkflowBlueprint): string;
|
|
161
|
+
export declare const name = "dsh-plugin-recipe";
|
|
162
|
+
export declare const inject: string[];
|
|
163
|
+
/** Register the workflow planner tools. */
|
|
164
|
+
export declare function apply(ctx: Context, config?: Partial<Config>): void;
|
|
165
|
+
export type { Config as RecipeConfig };
|