@kunolu/dsh-sbtd 0.1.0-rc.1
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 +202 -0
- package/README.md +51 -0
- package/cordis.patch.yml +3 -0
- package/dist/hooks.d.ts +47 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +275 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/section.d.ts +14 -0
- package/dist/section.d.ts.map +1 -0
- package/dist/section.js +16 -0
- package/dist/section.js.map +1 -0
- package/dist/state.d.ts +38 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +41 -0
- package/dist/state.js.map +1 -0
- package/dist/tools/plan.d.ts +53 -0
- package/dist/tools/plan.d.ts.map +1 -0
- package/dist/tools/plan.js +290 -0
- package/dist/tools/plan.js.map +1 -0
- package/dist/tools/review.d.ts +41 -0
- package/dist/tools/review.d.ts.map +1 -0
- package/dist/tools/review.js +161 -0
- package/dist/tools/review.js.map +1 -0
- package/manuals/MANIFEST.json +67 -0
- package/manuals/book-ddd-distilled-modeling/SKILL.md +66 -0
- package/manuals/book-ddia-data-design/SKILL.md +74 -0
- package/manuals/book-legacy-change-safety/SKILL.md +74 -0
- package/manuals/book-refactoring-pass/SKILL.md +70 -0
- package/manuals/book-release-readiness/SKILL.md +73 -0
- package/manuals/domain-modeling/SKILL.md +74 -0
- package/manuals/grill-me/SKILL.md +7 -0
- package/manuals/grill-with-docs/SKILL.md +7 -0
- package/manuals/grilling/SKILL.md +28 -0
- package/manuals/to-spec/SKILL.md +75 -0
- package/manuals/to-tickets/SKILL.md +105 -0
- package/manuals/trellis-workflow/SKILL.md +475 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @kunolu/dsh-sbtd
|
|
2
|
+
|
|
3
|
+
DSH 宿主上的 SBTD workflow 适配器。当前为 T5:注册短中文 sbtd section、进程内会话状态、`sbtd_plan`、`sbtd_review`、`tools/pre-execute` / `agent/pre-step` hooks 门禁,以及从 640-skills 只读同步的 `manuals/`。
|
|
4
|
+
|
|
5
|
+
版本 **0.1.0-rc.1**,发布在 dist-tag `next`。目标宿主:`@deepseek-ai/dsh@0.1.1-rc.2`。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
使用 dist-tag `@next` 安装,不要使用裸包名、`@latest` 或 github 路径:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
dsh plugin --profile web add @kunolu/dsh-sbtd@next
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
加载时 `apply()` 注册短中文 sbtd section(name `sbtd`,order 50),注册 `sbtd_plan` 与 `sbtd_review`,并注册 hooks。不写用户磁盘或 `AGENTS.md`。无 plan 时对生产代码的 write/edit 会 ask 先调用 `sbtd_plan`;README 编辑放行。命中 book gate 须 `sbtd_review` 到通过态。
|
|
16
|
+
|
|
17
|
+
## sbtd_review
|
|
18
|
+
|
|
19
|
+
`kind` 仅五枚举:`legacy`、`refactor`、`ddd`、`ddia`、`release`。禁止别名与 skill-id。
|
|
20
|
+
|
|
21
|
+
| kind | status 枚举 | 3.4 通过态 |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| `legacy` | `characterized` `needs-safety-net` `seam-required` `blocked` | `characterized` → `passed` |
|
|
24
|
+
| `refactor` | `proceed` `refactor-first` `blocked` | `proceed` → `passed` |
|
|
25
|
+
| `ddd` | `confirmed` `needs-clarification` `blocked` | `confirmed` → `passed` |
|
|
26
|
+
| `ddia` | `confirmed` `needs-design-change` `blocked` | `confirmed` → `passed` |
|
|
27
|
+
| `release` | `ready` `needs-mitigation` `blocked` | `ready` → `passed` |
|
|
28
|
+
|
|
29
|
+
3.4 映射:`needs-*` / `seam-required` / `refactor-first` 保持 `running`;`blocked` → `blocked`。不改 `requirement`。
|
|
30
|
+
|
|
31
|
+
示例:
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
await sbtd_review({
|
|
35
|
+
kind: "legacy",
|
|
36
|
+
status: "characterized",
|
|
37
|
+
conclusions: "Safety net in t5-review.test.mjs",
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## manuals
|
|
42
|
+
|
|
43
|
+
`manuals/` 是从 `KunoLu/640-skills` v1.0.13(sourceRevision `f8aa0d7225a26c5e00b81d2f1b05121108e63630`)只读同步的 skill 正文。每个 skill 只拷贝 `SKILL.md` 与该 skill 自己的 `references/`。不要手改 manuals 正文。
|
|
44
|
+
|
|
45
|
+
重新同步:给本地 SOURCE 目录,或省略参数让脚本 clone 到钉死 SHA。
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
packages/dsh-sbtd/scripts/sync-manuals.sh /path/to/640-skills
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`manuals/MANIFEST.json` 每条记录含 `sourcePath`(640-skills 仓相对源路径)、`sha256` 与 `sourceRevision`。源缺失、SHA 不匹配、拷贝失败或 checksum 失败时退出非 0。
|
package/cordis.patch.yml
ADDED
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare const PRE_EXECUTE_EVENT = "tools/pre-execute";
|
|
2
|
+
export declare const PRE_STEP_EVENT = "agent/pre-step";
|
|
3
|
+
export declare const PLUGIN_NAME = "dsh-sbtd";
|
|
4
|
+
export type PreToolDecision = {
|
|
5
|
+
kind: "allow";
|
|
6
|
+
} | {
|
|
7
|
+
kind: "deny";
|
|
8
|
+
reason: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: "ask";
|
|
11
|
+
reason: string;
|
|
12
|
+
};
|
|
13
|
+
export type PreStepDecision = {
|
|
14
|
+
kind: "reject";
|
|
15
|
+
} | {
|
|
16
|
+
kind: "enter";
|
|
17
|
+
messages: PreStepMessage[];
|
|
18
|
+
};
|
|
19
|
+
export type ToolExec = {
|
|
20
|
+
name: string;
|
|
21
|
+
arguments?: unknown;
|
|
22
|
+
agent?: {
|
|
23
|
+
id?: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type PreStepMessage = {
|
|
27
|
+
id?: string;
|
|
28
|
+
role?: string;
|
|
29
|
+
content?: unknown;
|
|
30
|
+
source?: unknown;
|
|
31
|
+
};
|
|
32
|
+
export type PreStepPayload = {
|
|
33
|
+
agent?: {
|
|
34
|
+
id?: string;
|
|
35
|
+
};
|
|
36
|
+
messages?: PreStepMessage[];
|
|
37
|
+
};
|
|
38
|
+
export type HooksHost = {
|
|
39
|
+
on: {
|
|
40
|
+
(event: "tools/pre-execute", handler: (exec: ToolExec, next: () => Promise<PreToolDecision>) => Promise<PreToolDecision>): unknown;
|
|
41
|
+
(event: "agent/pre-step", handler: (payload: PreStepPayload, next: () => Promise<PreStepDecision>) => Promise<PreStepDecision>): unknown;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare function gatePreExecute(exec: ToolExec): PreToolDecision | undefined;
|
|
45
|
+
export declare function runPreStep(payload: PreStepPayload, next: () => Promise<PreStepDecision>): Promise<PreStepDecision>;
|
|
46
|
+
export declare function registerHooks(ctx: HooksHost): void;
|
|
47
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],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B,OAAO,CAAC;QACX,CACE,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,CACP,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,KACjC,OAAO,CAAC,eAAe,CAAC,GAC5B,OAAO,CAAC;KACZ,CAAC;CACH,CAAC;AAoMF,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,eAAe,GAAG,SAAS,CA8D1E;AA2BD,wBAAsB,UAAU,CAC9B,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,GACnC,OAAO,CAAC,eAAe,CAAC,CA2B1B;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CASlD"}
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { relative, resolve, sep } from "node:path";
|
|
2
|
+
import { getSession } from "./state.js";
|
|
3
|
+
import { sessionIdFromExec } from "./tools/plan.js";
|
|
4
|
+
export const PRE_EXECUTE_EVENT = "tools/pre-execute";
|
|
5
|
+
export const PRE_STEP_EVENT = "agent/pre-step";
|
|
6
|
+
export const PLUGIN_NAME = "dsh-sbtd";
|
|
7
|
+
const MUTATION_TOOLS = {
|
|
8
|
+
write: true,
|
|
9
|
+
edit: true,
|
|
10
|
+
str_replace_editor: true,
|
|
11
|
+
};
|
|
12
|
+
const GIT_ALLOW = /(?:^|[\s;&|])git(?:\s+-\S+)*\s+(commit|status|log|diff|show)(?:\s|$)/;
|
|
13
|
+
const GIT_CHAIN = /&&|\|\||;/;
|
|
14
|
+
const PUBLISH_BASH = /\b(?:npm|pnpm|yarn|bunx?)\s+publish\b|\bdsh\s+plugin\s+publish\b/;
|
|
15
|
+
const PKG_MGR = /\b(?:npm|pnpm|yarn|bunx?)\s+(?:add|remove|uninstall|install|i)\b/;
|
|
16
|
+
const RM_BASH = /(?:^|[\s;&|])rm(?:\s|$)/;
|
|
17
|
+
const MUTATING_BASH = /(?:^|[\s;&|])(?:rm|mv|cp|touch|chmod|chown|unlink|mkdir)\b|\s(?:>>?|tee)\s|\bsed\s+-i\b|\bperl\s+-i|\b(?:npm|pnpm|yarn|bunx?)\s+(?:add|remove|uninstall|install|i|publish)\b|\bgit\s+(?:add|push|reset|rebase|cherry-pick|stash|tag|merge)\b/;
|
|
18
|
+
const DEV_INTENT = /开发|实现|改代码|implement|refactor|bug\s*fix|生产代码|sbtd_plan|src\/|existing production|feature|write|edit/i;
|
|
19
|
+
const DATA_PATH = /(?:^|\/)(?:schema|migration|migrations|sql|prisma|drizzle|redis|cache|database|persist)(?:\/|$|\.)|\.(?:sql|prisma)$/i;
|
|
20
|
+
const IMPL_EXT = /\.(?:ts|tsx|js|jsx|mjs|cjs|mts|cts|py|go|rs|java|kt|swift|c|cc|cpp|h|hpp|cs)$/i;
|
|
21
|
+
const README = /(?:^|\/)README(?:\.[^/]+)?\.md$/i;
|
|
22
|
+
const EXEMPT = /(?:^|\/)(?:features|maestro\/flow|\.trellis)(?:\/|$)|(?:^|\/)[^/]*\.test\.[^/]+$|(?:^|\/)[^/]*\.spec\.[^/]+$/;
|
|
23
|
+
const ASK_PLAN = "尚未 sbtd_plan,请先调用 sbtd_plan。";
|
|
24
|
+
const ASK_RM_PKG = "rm 或包管理器将改业务代码,请确认;若尚未计划请先调用 sbtd_plan。";
|
|
25
|
+
const NOTICE_TEXT = "尚未 sbtd_plan。开发任务先调用 sbtd_plan。";
|
|
26
|
+
const NOTICE_SUMMARY = "尚未 sbtd_plan,先调用 sbtd_plan。";
|
|
27
|
+
function sessionFromAgent(agent) {
|
|
28
|
+
const exec = {};
|
|
29
|
+
const id = agent?.id;
|
|
30
|
+
if (typeof id === "string" && id.length > 0) {
|
|
31
|
+
exec.agent = { id };
|
|
32
|
+
}
|
|
33
|
+
return sessionIdFromExec(exec);
|
|
34
|
+
}
|
|
35
|
+
function asRecord(value) {
|
|
36
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
function stringField(record, key) {
|
|
42
|
+
const value = record?.[key];
|
|
43
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
44
|
+
}
|
|
45
|
+
function commandOf(args) {
|
|
46
|
+
const record = asRecord(args);
|
|
47
|
+
return stringField(record, "command") ?? stringField(record, "cmd") ?? "";
|
|
48
|
+
}
|
|
49
|
+
function pathOf(args) {
|
|
50
|
+
const record = asRecord(args);
|
|
51
|
+
return (stringField(record, "path") ??
|
|
52
|
+
stringField(record, "file_path") ??
|
|
53
|
+
stringField(record, "filePath"));
|
|
54
|
+
}
|
|
55
|
+
function relToCwd(file) {
|
|
56
|
+
return relative(process.cwd(), resolve(process.cwd(), file))
|
|
57
|
+
.split(sep)
|
|
58
|
+
.join("/");
|
|
59
|
+
}
|
|
60
|
+
function pathsFromBash(command) {
|
|
61
|
+
const out = [];
|
|
62
|
+
for (const token of command.split(/\s+/)) {
|
|
63
|
+
if (token.includes("/") ||
|
|
64
|
+
README.test(token) ||
|
|
65
|
+
IMPL_EXT.test(token) ||
|
|
66
|
+
/^(?:src|app|packages|features|maestro|\.trellis)/.test(token)) {
|
|
67
|
+
out.push(token.replace(/^['"]|['"]$/g, ""));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
function classifyRel(rel) {
|
|
73
|
+
if (rel === "" || rel.startsWith("..")) {
|
|
74
|
+
return "other";
|
|
75
|
+
}
|
|
76
|
+
if (README.test(rel)) {
|
|
77
|
+
return "readme";
|
|
78
|
+
}
|
|
79
|
+
if (EXEMPT.test(rel)) {
|
|
80
|
+
return "exempt";
|
|
81
|
+
}
|
|
82
|
+
if (/^(?:src|app|packages)(?:\/|$)/.test(rel) && !rel.endsWith(".md")) {
|
|
83
|
+
return "production";
|
|
84
|
+
}
|
|
85
|
+
return "other";
|
|
86
|
+
}
|
|
87
|
+
function denyReview(kind) {
|
|
88
|
+
return {
|
|
89
|
+
kind: "deny",
|
|
90
|
+
reason: `required gate 未 passed,请先调用 sbtd_review kind=${kind}。`,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function unpassedRequired(gate) {
|
|
94
|
+
return gate?.requirement === "required" && gate.state !== "passed";
|
|
95
|
+
}
|
|
96
|
+
function isGitAllow(command) {
|
|
97
|
+
return GIT_ALLOW.test(command) && !GIT_CHAIN.test(command);
|
|
98
|
+
}
|
|
99
|
+
function isMutatingBash(command) {
|
|
100
|
+
if (command.length === 0) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
if (isGitAllow(command)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
return MUTATING_BASH.test(command);
|
|
107
|
+
}
|
|
108
|
+
function primaryClass(exec) {
|
|
109
|
+
const args = exec.arguments;
|
|
110
|
+
const direct = pathOf(args);
|
|
111
|
+
const command = exec.name === "bash" ? commandOf(args) : "";
|
|
112
|
+
const files = direct !== undefined ? [direct] : pathsFromBash(command);
|
|
113
|
+
if (files.length === 0) {
|
|
114
|
+
return "other";
|
|
115
|
+
}
|
|
116
|
+
let sawExempt = false;
|
|
117
|
+
let sawReadme = false;
|
|
118
|
+
for (const file of files) {
|
|
119
|
+
const kind = classifyRel(relToCwd(file));
|
|
120
|
+
if (kind === "production") {
|
|
121
|
+
return "production";
|
|
122
|
+
}
|
|
123
|
+
if (kind === "readme") {
|
|
124
|
+
sawReadme = true;
|
|
125
|
+
}
|
|
126
|
+
if (kind === "exempt") {
|
|
127
|
+
sawExempt = true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (sawReadme) {
|
|
131
|
+
return "readme";
|
|
132
|
+
}
|
|
133
|
+
return sawExempt ? "exempt" : "other";
|
|
134
|
+
}
|
|
135
|
+
function isDataPathExec(exec) {
|
|
136
|
+
const args = exec.arguments;
|
|
137
|
+
const direct = pathOf(args);
|
|
138
|
+
const command = exec.name === "bash" ? commandOf(args) : "";
|
|
139
|
+
const files = direct !== undefined ? [direct] : pathsFromBash(command);
|
|
140
|
+
const hay = files.join(" ");
|
|
141
|
+
return DATA_PATH.test(hay);
|
|
142
|
+
}
|
|
143
|
+
function isRmOrPkgBusiness(exec) {
|
|
144
|
+
if (exec.name !== "bash") {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
const command = commandOf(exec.arguments);
|
|
148
|
+
if (RM_BASH.test(command)) {
|
|
149
|
+
const cls = primaryClass(exec);
|
|
150
|
+
return cls === "production" || cls === "other";
|
|
151
|
+
}
|
|
152
|
+
if (PKG_MGR.test(command)) {
|
|
153
|
+
return /(?:^|\s)(?:src|app|packages)\b|\.\/(?:src|app|packages)/.test(command);
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
export function gatePreExecute(exec) {
|
|
158
|
+
const name = exec.name;
|
|
159
|
+
if (name === "view") {
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
if (name === "str_replace_editor" && commandOf(exec.arguments) === "view") {
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
const command = name === "bash" ? commandOf(exec.arguments) : "";
|
|
166
|
+
if (name === "bash" && isGitAllow(command)) {
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
const mutating = MUTATION_TOOLS[name] === true ||
|
|
170
|
+
(name === "bash" && isMutatingBash(command));
|
|
171
|
+
if (!mutating) {
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
const cls = primaryClass(exec);
|
|
175
|
+
if (cls === "readme") {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
const session = getSession(sessionFromAgent(exec.agent));
|
|
179
|
+
const plan = session.plan;
|
|
180
|
+
if (isRmOrPkgBusiness(exec) && plan === undefined) {
|
|
181
|
+
return { kind: "ask", reason: ASK_RM_PKG };
|
|
182
|
+
}
|
|
183
|
+
if (plan === undefined) {
|
|
184
|
+
if (cls === "other") {
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
return { kind: "ask", reason: ASK_PLAN };
|
|
188
|
+
}
|
|
189
|
+
if (cls === "exempt") {
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
if (name === "bash" &&
|
|
193
|
+
PUBLISH_BASH.test(command) &&
|
|
194
|
+
unpassedRequired(plan.gates.release)) {
|
|
195
|
+
return denyReview("release");
|
|
196
|
+
}
|
|
197
|
+
if (cls !== "production") {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
if (unpassedRequired(plan.gates.legacy)) {
|
|
201
|
+
return denyReview("legacy");
|
|
202
|
+
}
|
|
203
|
+
if (unpassedRequired(plan.gates.refactor)) {
|
|
204
|
+
return denyReview("refactor");
|
|
205
|
+
}
|
|
206
|
+
if (unpassedRequired(plan.gates.ddd)) {
|
|
207
|
+
return denyReview("ddd");
|
|
208
|
+
}
|
|
209
|
+
if (unpassedRequired(plan.gates.ddia) && isDataPathExec(exec)) {
|
|
210
|
+
return denyReview("ddia");
|
|
211
|
+
}
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
function contentText(content) {
|
|
215
|
+
if (typeof content === "string") {
|
|
216
|
+
return content;
|
|
217
|
+
}
|
|
218
|
+
if (!Array.isArray(content)) {
|
|
219
|
+
return "";
|
|
220
|
+
}
|
|
221
|
+
const parts = [];
|
|
222
|
+
for (const block of content) {
|
|
223
|
+
const record = asRecord(block);
|
|
224
|
+
const text = stringField(record, "text");
|
|
225
|
+
if (text !== undefined) {
|
|
226
|
+
parts.push(text);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return parts.join("\n");
|
|
230
|
+
}
|
|
231
|
+
function messagesText(messages) {
|
|
232
|
+
if (messages === undefined) {
|
|
233
|
+
return "";
|
|
234
|
+
}
|
|
235
|
+
return messages.map((message) => contentText(message.content)).join("\n");
|
|
236
|
+
}
|
|
237
|
+
export async function runPreStep(payload, next) {
|
|
238
|
+
const decision = await next();
|
|
239
|
+
if (decision.kind !== "enter") {
|
|
240
|
+
return decision;
|
|
241
|
+
}
|
|
242
|
+
const session = getSession(sessionFromAgent(payload.agent));
|
|
243
|
+
const text = `${messagesText(payload.messages)}\n${messagesText(decision.messages)}`;
|
|
244
|
+
if (session.plan === undefined && DEV_INTENT.test(text)) {
|
|
245
|
+
return {
|
|
246
|
+
kind: "enter",
|
|
247
|
+
messages: [
|
|
248
|
+
...decision.messages,
|
|
249
|
+
{
|
|
250
|
+
id: "dsh-sbtd-pre-step-notice",
|
|
251
|
+
role: "user",
|
|
252
|
+
content: [{ type: "text", text: NOTICE_TEXT }],
|
|
253
|
+
source: {
|
|
254
|
+
kind: "plugin",
|
|
255
|
+
plugin: PLUGIN_NAME,
|
|
256
|
+
form: "notice",
|
|
257
|
+
summary: NOTICE_SUMMARY,
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
],
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return decision;
|
|
264
|
+
}
|
|
265
|
+
export function registerHooks(ctx) {
|
|
266
|
+
ctx.on(PRE_EXECUTE_EVENT, async (exec, next) => {
|
|
267
|
+
const decision = gatePreExecute(exec);
|
|
268
|
+
if (decision === undefined) {
|
|
269
|
+
return next();
|
|
270
|
+
}
|
|
271
|
+
return decision;
|
|
272
|
+
});
|
|
273
|
+
ctx.on(PRE_STEP_EVENT, async (payload, next) => runPreStep(payload, next));
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAqB,iBAAiB,E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OAAO;YACL,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE;gBACR,GAAG,QAAQ,CAAC,QAAQ;gBACpB;oBACE,EAAE,EAAE,0BAA0B;oBAC9B,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;oBAC9C,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ;wBACd,MAAM,EAAE,WAAW;wBACnB,IAAI,EAAE,QAAQ;wBACd,OAAO,EAAE,cAAc;qBACxB;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAc;IAC1C,GAAG,CAAC,EAAE,CAAC,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAC7C,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;AAC7E,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type HooksHost } from "./hooks.js";
|
|
2
|
+
import { type SectionHost } from "./section.js";
|
|
3
|
+
import { type ToolsHost } from "./tools/plan.js";
|
|
4
|
+
export declare const name = "dsh-sbtd";
|
|
5
|
+
export declare const inject: readonly ["tools", "systemPrompt"];
|
|
6
|
+
export type PluginHost = SectionHost & ToolsHost & HooksHost;
|
|
7
|
+
export { PRE_EXECUTE_EVENT, PRE_STEP_EVENT, registerHooks, } from "./hooks.js";
|
|
8
|
+
export { registerSection, SBTD_SECTION_NAME, SBTD_SECTION_ORDER, SBTD_SECTION_TEXT, } from "./section.js";
|
|
9
|
+
export { getSession, restore, serialize } from "./state.js";
|
|
10
|
+
export { createPlanTool, inferRequirements, registerPlanTool, SBTD_PLAN_TOOL_NAME, sbtdPlan, sessionIdFromExec, taskIdFromSummary, } from "./tools/plan.js";
|
|
11
|
+
export { createReviewTool, REVIEW_KINDS, REVIEW_TITLES, registerReviewTool, SBTD_REVIEW_TOOL_NAME, sbtdReview, } from "./tools/review.js";
|
|
12
|
+
export declare function apply(ctx: PluginHost): void;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGnE,eAAO,MAAM,IAAI,aAAa,CAAC;AAC/B,eAAO,MAAM,MAAM,oCAAqC,CAAC;AAEzD,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;AAE7D,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,GACX,MAAM,mBAAmB,CAAC;AAE3B,wBAAgB,KAAK,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAM3C"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { registerHooks } from "./hooks.js";
|
|
2
|
+
import { registerSection } from "./section.js";
|
|
3
|
+
import { registerPlanTool } from "./tools/plan.js";
|
|
4
|
+
import { registerReviewTool } from "./tools/review.js";
|
|
5
|
+
export const name = "dsh-sbtd";
|
|
6
|
+
export const inject = ["tools", "systemPrompt"];
|
|
7
|
+
export { PRE_EXECUTE_EVENT, PRE_STEP_EVENT, registerHooks, } from "./hooks.js";
|
|
8
|
+
export { registerSection, SBTD_SECTION_NAME, SBTD_SECTION_ORDER, SBTD_SECTION_TEXT, } from "./section.js";
|
|
9
|
+
export { getSession, restore, serialize } from "./state.js";
|
|
10
|
+
export { createPlanTool, inferRequirements, registerPlanTool, SBTD_PLAN_TOOL_NAME, sbtdPlan, sessionIdFromExec, taskIdFromSummary, } from "./tools/plan.js";
|
|
11
|
+
export { createReviewTool, REVIEW_KINDS, REVIEW_TITLES, registerReviewTool, SBTD_REVIEW_TOOL_NAME, sbtdReview, } from "./tools/review.js";
|
|
12
|
+
export function apply(ctx) {
|
|
13
|
+
console.log("[dsh-sbtd] plugin loaded (T0 stub)");
|
|
14
|
+
registerSection(ctx);
|
|
15
|
+
registerPlanTool(ctx);
|
|
16
|
+
registerReviewTool(ctx);
|
|
17
|
+
registerHooks(ctx);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAkB,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAAC;AAC/B,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,cAAc,CAAU,CAAC;AAIzD,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,GACX,MAAM,mBAAmB,CAAC;AAE3B,MAAM,UAAU,KAAK,CAAC,GAAe;IACnC,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;IAClD,eAAe,CAAC,GAAG,CAAC,CAAC;IACrB,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACtB,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACxB,aAAa,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const SBTD_SECTION_NAME = "sbtd";
|
|
2
|
+
export declare const SBTD_SECTION_ORDER = 50;
|
|
3
|
+
export declare const SBTD_SECTION_TEXT = "\u5F00\u53D1\u4EFB\u52A1\u5148\u8C03\u7528 sbtd_plan\uFF0C\u672A\u51FA\u8BA1\u5212\u4E0D\u51C6\u6539\u751F\u4EA7\u4EE3\u7801\u3002\n\u6F84\u6E05\u8D70 sbtd_clarify\uFF0C\u5B8C\u6574\u6F84\u6E05\u540E\u5FC5\u987B\u6709 DDD \u590D\u5BA1\u901A\u8FC7\u6001\u3002\n\u6539\u4EE3\u7801\u524D/\u540E\u7684\u5206\u6790\u3001\u9A8C\u8BC1\u8D70 sbtd_validate / sbtd_e2e\uFF0C\u4E0D\u8981\u76F4\u63A5\u88F8\u8C03 MCP \u540D\u79F0\u3002\n\u547D\u4E2D book gate \u5FC5\u987B sbtd_review \u5230\u901A\u8FC7\u6001\u3002\n\u6700\u7EC8\u8F93\u51FA\u5FC5\u987B\u5305\u542B\u7ED3\u8BBA\u3001\u6587\u4EF6\u3001\u9A8C\u8BC1\u3001\u8DF3\u8FC7\u539F\u56E0\u3001\u98CE\u9669\u3002\nMaestro\uFF1A\u7F3A Java / CLI / \u8BBE\u5907 / \u5DF2\u88C5 app / app \u5185\u6D4B\u8BD5\u73AF\u5883\u65F6 blocked\uFF0C\u5148\u5F15\u5BFC\u7528\u6237\u3002";
|
|
4
|
+
export type SectionHost = {
|
|
5
|
+
systemPrompt: {
|
|
6
|
+
section: (opts: {
|
|
7
|
+
name: string;
|
|
8
|
+
order: number;
|
|
9
|
+
text: string;
|
|
10
|
+
}) => void;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare function registerSection(ctx: SectionHost): void;
|
|
14
|
+
//# sourceMappingURL=section.d.ts.map
|