skill-evolution 0.0.0-stage → 0.1.0
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/CHANGELOG.md +59 -0
- package/LICENSE +21 -0
- package/README.en.md +208 -0
- package/README.md +207 -2
- package/assets/icon-180.png +0 -0
- package/assets/screenshots/workbench.png +0 -0
- package/client.js +2135 -0
- package/cordis.patch.yml +41 -0
- package/icon.svg +6 -0
- package/index.js +884 -0
- package/lib/applier.js +221 -0
- package/lib/collector.js +356 -0
- package/lib/consolidation.js +344 -0
- package/lib/gatekeeper.js +293 -0
- package/lib/http-api.js +919 -0
- package/lib/ledger.js +316 -0
- package/lib/prompts.js +514 -0
- package/lib/provenance.js +103 -0
- package/lib/reflector.js +226 -0
- package/lib/synthesizer.js +295 -0
- package/lib/tidy.js +263 -0
- package/lib/usage.js +223 -0
- package/locale/en.json +8 -0
- package/locale/zh.json +8 -0
- package/package.json +87 -4
- package/screenshots.json +3 -0
package/lib/prompts.js
ADDED
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 审查提示词(Review Prompts)
|
|
3
|
+
*
|
|
4
|
+
* **逐字移植自 Hermes `agent/background_review.py`。**
|
|
5
|
+
*
|
|
6
|
+
* 为什么逐字移植而不是重写:这三段文本不是普通的 prompt,它们是 Hermes 团队
|
|
7
|
+
* 在真实使用中反复踩坑后沉淀下来的"什么该记、什么绝不能记、怎么写才算好技能"
|
|
8
|
+
* 的完整经验编码。重写会丢掉那些用血换来的教训。
|
|
9
|
+
*
|
|
10
|
+
* 对应关系:
|
|
11
|
+
* _MEMORY_ROUTING_BLOCK → MEMORY_ROUTING_BLOCK
|
|
12
|
+
* _LESSON_LAYER_BLOCK → LESSON_LAYER_BLOCK
|
|
13
|
+
* _DO_NOT_CAPTURE_BLOCK → DO_NOT_CAPTURE_BLOCK
|
|
14
|
+
* _SKILL_REVIEW_PROMPT → SKILL_REVIEW_PROMPT
|
|
15
|
+
* _COMBINED_REVIEW_PROMPT → COMBINED_REVIEW_PROMPT
|
|
16
|
+
*
|
|
17
|
+
* 唯一改动:把 Hermes 的工具名(skill_view / skills_list / skill_manage)
|
|
18
|
+
* 换成 DSH 语境下的等价描述(skill 工具 / 技能目录 / 写入草稿),
|
|
19
|
+
* 把 `~/.hermes/skills/` 换成 DSH 的技能根目录。语义完全保持不变。
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 记忆路由(两个库,一条事实只进一个)
|
|
24
|
+
* 移植自 `_MEMORY_ROUTING_BLOCK`。
|
|
25
|
+
*/
|
|
26
|
+
export const MEMORY_ROUTING_BLOCK =
|
|
27
|
+
"TWO distinct stores — pick the right one for each fact:\n" +
|
|
28
|
+
" • USER.md (memory tool, target='user'): who the user is — persona, preferences, " +
|
|
29
|
+
"communication and work style, personal details they revealed, and expectations about how you " +
|
|
30
|
+
"should behave.\n" +
|
|
31
|
+
" • MEMORY.md (memory tool, target='memory'): facts about the ENVIRONMENT you operate in — " +
|
|
32
|
+
"tool quirks, project conventions, config gotchas, paths and endpoints that matter.\n\n" +
|
|
33
|
+
"One fact goes to ONE store, never both — writing it to both bloats both files until they hit " +
|
|
34
|
+
"their size limits and crowds out the facts that matter; misrouting it puts it where the next " +
|
|
35
|
+
"session won't look. If the tool schema lists only one " +
|
|
36
|
+
"target, that store is the only one enabled — use it and skip the other.\n\n" +
|
|
37
|
+
"Save only facts GROUNDED in this conversation — a user message or tool result you can point " +
|
|
38
|
+
"to. Never infer the user's traits, skill level, role, mood or preferences from topic, tone or " +
|
|
39
|
+
"tools used, and never turn a one-off request into a standing preference (in either store) " +
|
|
40
|
+
"unless the user marked it general ('always', 'from now on', 'remember') or stated a standing " +
|
|
41
|
+
"like/dislike ('I hate X', 'stop doing Y'). If unsure, leave it " +
|
|
42
|
+
"out — a wrong fact misleads every future session.\n\n";
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 教训层:什么算一个好技能
|
|
46
|
+
* 移植自 `_LESSON_LAYER_BLOCK`。
|
|
47
|
+
*
|
|
48
|
+
* 这段文本防的是"囤积式技能库"这种失败形态:每个会话一个 references 文件、
|
|
49
|
+
* 用叙事代替规则、把 PR 号当内容、重复仓库 AGENTS.md 已经教过的东西。
|
|
50
|
+
*/
|
|
51
|
+
export const LESSON_LAYER_BLOCK =
|
|
52
|
+
"What a skill IS: the instructions for doing a class of task the most efficient and correct " +
|
|
53
|
+
"way, to THIS user's specifications — the procedure, the tools and commands that work, the " +
|
|
54
|
+
"order, the user's preferences for how the result should look, and the pitfalls that cost time. " +
|
|
55
|
+
"A future session should be able to follow it and produce what the user wants on the first " +
|
|
56
|
+
"try. Everything below is about writing that well:\n" +
|
|
57
|
+
" • Procedure first: the steps in the order they are done, with the concrete commands, tool " +
|
|
58
|
+
"calls, and decision points. Lessons and pitfalls attach to the step they affect.\n" +
|
|
59
|
+
" • A pitfall is a generalizable rule + one clause of WHY (the mechanism), imperative. 'Grep the " +
|
|
60
|
+
"test tree for the SYMBOL before widening a helper signature — hand-rolled mocks reimplement the " +
|
|
61
|
+
"old shape and fail on a shard you did not run.' Not a narrative of what happened this session.\n" +
|
|
62
|
+
" • No PR/issue numbers, dates, ticket IDs, or quoted user text as content — the rule must stand " +
|
|
63
|
+
"without the incident behind it. Keep a short quote ONLY when the quote itself is the clearest " +
|
|
64
|
+
"statement of the rule.\n" +
|
|
65
|
+
" • The same lesson learned twice is ONE rule. Before adding, search the skill (and its " +
|
|
66
|
+
"references/) for the rule already stated; strengthen or clarify it rather than appending a " +
|
|
67
|
+
"second copy.\n" +
|
|
68
|
+
" • Not a duplicate of what the environment already teaches: repo AGENTS.md files, tool schema " +
|
|
69
|
+
"descriptions, and other always-loaded context. A skill carries the WORKFLOW and the pitfalls; " +
|
|
70
|
+
"it does not restate the codebase map or a tool's parameter list.\n" +
|
|
71
|
+
" • Always-on rules (standing user preferences, gates that apply to every instance of the " +
|
|
72
|
+
"task) live in SKILL.md itself, whole. references/ is for depth that is only needed sometimes: " +
|
|
73
|
+
"a decision table, a recipe, a domain note — each file topical and reusable, never " +
|
|
74
|
+
"'<date>-<incident>.md'. Prefer extending an existing references/ file over creating one; " +
|
|
75
|
+
"a skill with dozens of one-off references is the failure shape, not the goal.\n" +
|
|
76
|
+
" • Fix the skill in place when it is wrong: edit the sentence that misled, do not append " +
|
|
77
|
+
"'UPDATE: actually...' underneath it.\n\n";
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 绝不能记什么
|
|
81
|
+
* 移植自 `_DO_NOT_CAPTURE_BLOCK`。
|
|
82
|
+
*
|
|
83
|
+
* 这是整个机制里最重要的护栏:没有它,agent 会把自己写的
|
|
84
|
+
* "X 工具不能用" 当成事实引用好几个月,即使问题早已修复。
|
|
85
|
+
*/
|
|
86
|
+
export const DO_NOT_CAPTURE_BLOCK =
|
|
87
|
+
" (these become persistent self-imposed constraints that bite you later when the environment " +
|
|
88
|
+
"changes):\n" +
|
|
89
|
+
" • Environment-dependent failures: missing binaries, fresh-install errors, post-migration " +
|
|
90
|
+
"path mismatches, 'command not found', unconfigured credentials, uninstalled packages. The " +
|
|
91
|
+
"user can fix these — they are not durable rules.\n" +
|
|
92
|
+
" • Negative claims about tools or features ('browser tools do not work', 'X tool is broken', " +
|
|
93
|
+
"'cannot use Y from execute_code'). These harden into refusals the agent cites against itself " +
|
|
94
|
+
"for months after the actual problem was fixed.\n" +
|
|
95
|
+
" • Session-specific transient errors that resolved before the conversation ended. If " +
|
|
96
|
+
"retrying worked, the lesson is the retry pattern, not the original failure.\n" +
|
|
97
|
+
" • One-off task narratives. A user asking 'summarize today's market' or 'analyze this PR' is " +
|
|
98
|
+
"not a class of work that warrants a skill.\n\n" +
|
|
99
|
+
" • Unresolved failures: if the session ended WITHOUT actually finding a working method — you " +
|
|
100
|
+
"tried several things, none worked, and told the user to check manually — do NOT write those " +
|
|
101
|
+
"attempts up as a 'reliable workflow' or 'recommended approach'. That presents an untested " +
|
|
102
|
+
"sequence of failures as validated guidance a future session will trust and repeat. Either say " +
|
|
103
|
+
"'Nothing to save', or, only if you are independently confident of a real working alternative " +
|
|
104
|
+
"(not something you are merely guessing might work), capture ONLY that alternative — never the " +
|
|
105
|
+
"dead ends, and never dressed up as best practice.\n\n" +
|
|
106
|
+
"If a tool failed because of setup state, capture the FIX (install command, config step, env " +
|
|
107
|
+
"var to set) under an existing setup or troubleshooting skill — never 'this tool does not " +
|
|
108
|
+
"work' as a standalone constraint.\n\n";
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 技能审查提示词(主模板)
|
|
112
|
+
* 移植自 `_SKILL_REVIEW_PROMPT`。
|
|
113
|
+
*
|
|
114
|
+
* 关键设计:
|
|
115
|
+
* - 开篇就反对惰性:"Be ACTIVE — 空过是失败,不是中立结果"
|
|
116
|
+
* - 明确目标形态:类级别技能(CLASS-LEVEL),不是一次性窄技能
|
|
117
|
+
* - 四级优先顺序:改已加载的 > 改已有伞 > 加支撑文件 > 新建
|
|
118
|
+
* - Read-before-write 强制
|
|
119
|
+
* - 用户偏好嵌入技能而非记忆
|
|
120
|
+
*/
|
|
121
|
+
export const SKILL_REVIEW_PROMPT =
|
|
122
|
+
"Review the conversation above and update the skill library. Be ACTIVE — most sessions produce " +
|
|
123
|
+
"at least one skill update, even if small. A pass that does nothing is a missed learning " +
|
|
124
|
+
"opportunity, not a neutral outcome.\n\n" +
|
|
125
|
+
"Target shape of the library: CLASS-LEVEL skills, each with a SKILL.md of always-on rules and a " +
|
|
126
|
+
"small `references/` set of topical depth. Not a flat list of narrow one-session skills, and " +
|
|
127
|
+
"not an umbrella hoarding a references/ file per session. This shapes HOW you update, not " +
|
|
128
|
+
"WHETHER you update.\n\n" +
|
|
129
|
+
LESSON_LAYER_BLOCK +
|
|
130
|
+
"Signals to look for (any one of these warrants action):\n" +
|
|
131
|
+
" • User corrected your style, tone, format, legibility, or verbosity. Frustration signals " +
|
|
132
|
+
"like 'stop doing X', 'this is too verbose', 'don't format like this', 'why are you " +
|
|
133
|
+
"explaining', 'just give me the answer', 'you always do Y and I hate it', or an explicit " +
|
|
134
|
+
"'remember this' are FIRST-CLASS skill signals, not just memory signals. Update the relevant " +
|
|
135
|
+
"skill(s) to embed the preference so the next session starts already knowing.\n" +
|
|
136
|
+
" • User corrected your workflow, approach, or sequence of steps. Encode the correction as a " +
|
|
137
|
+
"pitfall or explicit step in the skill that governs that class of task.\n" +
|
|
138
|
+
" • Non-trivial technique, fix, workaround, debugging path, or tool-usage pattern emerged " +
|
|
139
|
+
"that a future session would benefit from. Capture it.\n" +
|
|
140
|
+
" • A skill that got loaded or consulted this session turned out to be wrong, missing a step, " +
|
|
141
|
+
"or outdated. Patch it NOW.\n\n" +
|
|
142
|
+
"Preference order — prefer the earliest action that fits, but do pick one when a signal above " +
|
|
143
|
+
"fired:\n" +
|
|
144
|
+
" 1. UPDATE A CURRENTLY-LOADED SKILL. Look back through the conversation for skills the user " +
|
|
145
|
+
"loaded via /skill-name or you read via the skill tool. If any of them covers the territory of " +
|
|
146
|
+
"the new learning, PATCH that one first (re-load it with the skill tool during this review — " +
|
|
147
|
+
"see Read-before-write below). It is the skill that was in play, so it's the right one to " +
|
|
148
|
+
"extend — whoever wrote it: hand-written, installed, bundled, and pinned skills are all yours " +
|
|
149
|
+
"to improve. The one exception is a skill the user LOCKED: the write is refused — do not " +
|
|
150
|
+
"retry and do not recreate it under another name; put the suggested " +
|
|
151
|
+
"change in your summary instead.\n" +
|
|
152
|
+
" 2. UPDATE AN EXISTING UMBRELLA (via the skill catalog + the skill tool). If no loaded skill " +
|
|
153
|
+
"fits but an existing class-level skill does, patch it. Add a subsection, a pitfall, or " +
|
|
154
|
+
"broaden a trigger.\n" +
|
|
155
|
+
" 3. ADD A SUPPORT FILE under an existing umbrella. Skills can be packaged with three kinds " +
|
|
156
|
+
"of support files — use the right directory per kind:\n" +
|
|
157
|
+
" • `references/<topic>.md` — topical depth needed only sometimes: a decision table, a " +
|
|
158
|
+
"reproduction recipe, provider quirks, condensed domain notes or API excerpts. Name it by " +
|
|
159
|
+
"TOPIC and extend an existing file when one covers the topic; do not create a per-session or " +
|
|
160
|
+
"per-incident file, and do not paste error transcripts — distill them to the rule.\n" +
|
|
161
|
+
" • `templates/<name>.<ext>` — starter files meant to be copied and modified (boilerplate " +
|
|
162
|
+
"configs, scaffolding, a known-good example the agent can `reproduce with modifications`).\n" +
|
|
163
|
+
" • `scripts/<name>.<ext>` — statically re-runnable actions the skill can invoke directly " +
|
|
164
|
+
"(verification scripts, fixture generators, deterministic probes, anything the agent should " +
|
|
165
|
+
"run rather than hand-type each time).\n" +
|
|
166
|
+
" The umbrella's SKILL.md should gain a one-line pointer to any new support file so future " +
|
|
167
|
+
"agents know it exists.\n" +
|
|
168
|
+
" 4. CREATE A NEW CLASS-LEVEL UMBRELLA SKILL when no existing skill covers the class. The " +
|
|
169
|
+
"name MUST be at the class level. The name MUST NOT be a specific PR number, error string, " +
|
|
170
|
+
"feature codename, library-alone name, or 'fix-X / debug-Y / audit-Z-today' session artifact. " +
|
|
171
|
+
"If the proposed name only makes sense for today's task, it's wrong — fall back to (1), (2), " +
|
|
172
|
+
"or (3).\n\n" +
|
|
173
|
+
"Read-before-write (ENFORCED — the write is refused otherwise): before you patch or edit an " +
|
|
174
|
+
"existing skill's SKILL.md, load that skill with the skill tool during this review. Before " +
|
|
175
|
+
"you overwrite or remove an EXISTING supporting file, load that exact file. Content quoted " +
|
|
176
|
+
"earlier in the conversation transcript does NOT count — the " +
|
|
177
|
+
"guard requires a fresh load within this review, and your write must be based on what " +
|
|
178
|
+
"the skill tool just returned. Creating a brand-new skill or adding a NEW supporting file " +
|
|
179
|
+
"needs no prior read. If a write is refused with a read-before-write error, load the " +
|
|
180
|
+
"named target once and retry the write once; do not loop.\n\n" +
|
|
181
|
+
"User-preference embedding (important): when the user expressed a style/format/workflow " +
|
|
182
|
+
"preference, the update belongs in the SKILL.md body, not just in memory. Memory captures 'who " +
|
|
183
|
+
"the user is and what the current situation and state of your operations are'; skills capture " +
|
|
184
|
+
"'how to do this class of task for this user'. When they complain about how you handled a " +
|
|
185
|
+
"task, the skill that governs that task needs to carry the lesson.\n\n" +
|
|
186
|
+
"If you notice two existing skills that overlap, note it in your reply — the background " +
|
|
187
|
+
"curator handles consolidation at scale. Never delete a skill here.\n\n" +
|
|
188
|
+
"Do NOT capture" +
|
|
189
|
+
DO_NOT_CAPTURE_BLOCK +
|
|
190
|
+
"'Nothing to save.' is a real option but should NOT be the default. If the session ran " +
|
|
191
|
+
"smoothly with no corrections and produced no new technique, just say 'Nothing to save.' and " +
|
|
192
|
+
"stop. Otherwise, act.";
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 组合审查提示词(记忆 + 技能一次搞定)
|
|
196
|
+
* 移植自 `_COMBINED_REVIEW_PROMPT`。
|
|
197
|
+
*/
|
|
198
|
+
export const COMBINED_REVIEW_PROMPT =
|
|
199
|
+
"Review the conversation above and update two things:\n\n" +
|
|
200
|
+
"**Memory**: " +
|
|
201
|
+
MEMORY_ROUTING_BLOCK +
|
|
202
|
+
"**Skills**: how to do this class of task. Be ACTIVE — most sessions produce at least one " +
|
|
203
|
+
"skill update. A pass that does nothing is a missed learning opportunity, not a neutral " +
|
|
204
|
+
"outcome.\n\n" +
|
|
205
|
+
"Target shape of the skill library: CLASS-LEVEL skills with a SKILL.md of always-on rules and a " +
|
|
206
|
+
"small `references/` set of topical depth — not narrow one-session skills, and not an umbrella " +
|
|
207
|
+
"hoarding a references/ file per session.\n\n" +
|
|
208
|
+
LESSON_LAYER_BLOCK +
|
|
209
|
+
"Signals that warrant a skill update (any one is enough):\n" +
|
|
210
|
+
" • User corrected your style, tone, format, legibility, verbosity, or approach. Frustration " +
|
|
211
|
+
"is a FIRST-CLASS skill signal, not just a memory signal. 'stop doing X', 'don't format like " +
|
|
212
|
+
"this', 'I hate when you Y' — embed the lesson in the skill that governs that task so the next " +
|
|
213
|
+
"session starts fixed.\n" +
|
|
214
|
+
" • Non-trivial technique, fix, workaround, or debugging path emerged.\n" +
|
|
215
|
+
" • A skill that was loaded or consulted turned out wrong, missing, or outdated — patch it " +
|
|
216
|
+
"now.\n\n" +
|
|
217
|
+
"Preference order for skills — pick the earliest that fits:\n" +
|
|
218
|
+
" 1. UPDATE A CURRENTLY-LOADED SKILL. Check what skills were loaded via /skill-name or " +
|
|
219
|
+
"the skill tool in the conversation. If one of them covers the learning, PATCH it first " +
|
|
220
|
+
"(re-load it during this review — see Read-before-write below). It was in play; it's the " +
|
|
221
|
+
"right place, whoever wrote it.\n" +
|
|
222
|
+
" 2. UPDATE AN EXISTING UMBRELLA (skill catalog + skill tool to find the right one). Patch it.\n" +
|
|
223
|
+
" 3. ADD A SUPPORT FILE under an existing umbrella. Three " +
|
|
224
|
+
"kinds: `references/<topic>.md` for topical depth (decision tables, recipes, quirks, condensed " +
|
|
225
|
+
"domain notes) — extend an existing topical file before creating one, never a per-session file; " +
|
|
226
|
+
"`templates/<name>.<ext>` for starter files meant to be copied and modified; " +
|
|
227
|
+
"`scripts/<name>.<ext>` for statically re-runnable actions (verification, fixture generators, " +
|
|
228
|
+
"probes). Add a one-line pointer in SKILL.md so future agents find them.\n" +
|
|
229
|
+
" 4. CREATE A NEW CLASS-LEVEL UMBRELLA when nothing exists. Name at the class level — NOT a " +
|
|
230
|
+
"PR number, error string, codename, library-alone name, or 'fix-X / debug-Y' session artifact. " +
|
|
231
|
+
"If the name only fits today's task, fall back to (1), (2), or (3).\n\n" +
|
|
232
|
+
"Read-before-write (ENFORCED — the write is refused otherwise): before patching or editing an " +
|
|
233
|
+
"existing skill's SKILL.md, load it with the skill tool during this review; before " +
|
|
234
|
+
"overwriting or removing an EXISTING supporting file, load that exact " +
|
|
235
|
+
"file. Content quoted earlier in the transcript does NOT count — base the write on what " +
|
|
236
|
+
"the skill tool just returned. New skills and NEW supporting files need no prior read. On a " +
|
|
237
|
+
"read-before-write refusal: load the named target once, retry the write once, do not loop.\n\n" +
|
|
238
|
+
"User-preference embedding: when the user complains about how you handled a task, update the " +
|
|
239
|
+
"skill that governs that task rather than memory. Memory says 'who the user is and " +
|
|
240
|
+
"what the current situation and state of your operations are'; skills say 'how to do this " +
|
|
241
|
+
"class of task for this user'. A user-preference lesson lives in exactly ONE place: the skill " +
|
|
242
|
+
"that governs the task when one exists, USER.md only for cross-cutting preferences no skill " +
|
|
243
|
+
"owns — never both. Duplicating it is how a memory file ends up restating SKILL.md until both " +
|
|
244
|
+
"hit their size limits.\n\n" +
|
|
245
|
+
"If you notice overlapping existing skills, mention it — the background curator handles " +
|
|
246
|
+
"consolidation. Never delete a skill here.\n\n" +
|
|
247
|
+
"Do NOT capture as skills" +
|
|
248
|
+
DO_NOT_CAPTURE_BLOCK +
|
|
249
|
+
"Act on whichever of the two dimensions has real signal. If genuinely nothing stands out on " +
|
|
250
|
+
"either, say 'Nothing to save.' and stop — but don't reach for that conclusion as a default.";
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* DSH 特有的输出契约(Hermes 没有这一段,因为 Hermes 直接调工具写入;
|
|
254
|
+
* DSH 的复盘 fork 是只读的,必须输出结构化 JSON 交给 Synthesizer 落盘)。
|
|
255
|
+
*
|
|
256
|
+
* 这段必须放在提示词最后,确保模型在理解完所有规则后再看输出格式。
|
|
257
|
+
*/
|
|
258
|
+
export const OUTPUT_CONTRACT = `
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Output contract (DSH-specific — overrides the tool-calling instructions above)
|
|
263
|
+
|
|
264
|
+
You are a READ-ONLY review fork. You cannot write files. Instead, output ONE fenced JSON block
|
|
265
|
+
and nothing else after it. The harness will apply it under a gate.
|
|
266
|
+
|
|
267
|
+
Follow the exact Hermes skill-writing rules for \`frontmatter\` and \`body\`.
|
|
268
|
+
In addition, provide a \`briefing\` object in Simplified Chinese (简体中文) so the visual UI can render a clear
|
|
269
|
+
decision simulation for the user.
|
|
270
|
+
|
|
271
|
+
\`\`\`json
|
|
272
|
+
{
|
|
273
|
+
"action": "create" | "patch" | "add_reference" | "nothing",
|
|
274
|
+
"target": "<kebab-case skill name>",
|
|
275
|
+
"filePath": "<only for add_reference, e.g. references/decision-table.md>",
|
|
276
|
+
"frontmatter": { "name": "<same as target>", "description": "<Concise trigger phrase, MUST be <= 60 chars (Hermes SKILL_PROMPT_DESC_LIMIT)>" },
|
|
277
|
+
"body": "<Full Markdown body for create, or the COMPLETE new body for patch>",
|
|
278
|
+
"rationale": "<one or two sentences: which signal fired and why this action>",
|
|
279
|
+
"briefing": {
|
|
280
|
+
"titleZh": "<简短中文标题>",
|
|
281
|
+
"triggerZh": "<一句话中文触发场景>",
|
|
282
|
+
"whatItIs": "<一句话中文说明这个技能的核心经验>",
|
|
283
|
+
"ifApprove": "<中文说明:如果同意,系统会如何生效>",
|
|
284
|
+
"ifReject": "<中文说明:如果驳回,会发生什么>"
|
|
285
|
+
},
|
|
286
|
+
"signals": ["user-correction" | "new-technique" | "skill-was-wrong" | "workflow-correction"],
|
|
287
|
+
"confidence": "high" | "medium" | "low"
|
|
288
|
+
}
|
|
289
|
+
\`\`\`
|
|
290
|
+
|
|
291
|
+
Rules for the JSON:
|
|
292
|
+
- \`action: "nothing"\` with \`target: ""\` is valid ONLY when no signal fired at all.
|
|
293
|
+
- For \`patch\`, \`body\` must be the ENTIRE new SKILL.md body (frontmatter excluded) — the harness
|
|
294
|
+
replaces the body wholesale. Preserve everything still true; fix only what the lesson touches.
|
|
295
|
+
- Never invent a skill name that is a session artifact (see rule 4 above).
|
|
296
|
+
- \`confidence: "low"\` means the harness will stage it for human review instead of applying it.`;
|
|
297
|
+
|
|
298
|
+
/** 组装最终复盘提示词。 */
|
|
299
|
+
export function buildReviewPrompt({ includeMemory = false } = {}) {
|
|
300
|
+
const base = includeMemory ? COMBINED_REVIEW_PROMPT : SKILL_REVIEW_PROMPT;
|
|
301
|
+
return base + OUTPUT_CONTRACT;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Curator 合并提示词(建伞 pass)
|
|
306
|
+
*
|
|
307
|
+
* **逐字移植自 Hermes `agent/curator.py` 的 `CURATOR_REVIEW_PROMPT`。**
|
|
308
|
+
*
|
|
309
|
+
* 这是 curator 的 LLM 部分——把一堆窄技能合并成类级别的"伞"。
|
|
310
|
+
* Hermes 的原文强调:几百个各捕获一次会话 bug 的窄技能是**失败**,不是特性。
|
|
311
|
+
*
|
|
312
|
+
* 替换:`skill_view`/`skills_list`/`skill_manage` → DSH 的 `skill` 工具与插件写入路径;
|
|
313
|
+
* `~/.hermes/skills/.archive/` → DSH 的 `.archive/`;`hermes curator rollback` → `/evolution rollback`。
|
|
314
|
+
*/
|
|
315
|
+
export const CURATOR_REVIEW_PROMPT =
|
|
316
|
+
"You are running as DSH's background skill CURATOR. This is an " +
|
|
317
|
+
"UMBRELLA-BUILDING consolidation pass, not a passive audit and not a " +
|
|
318
|
+
"duplicate-finder.\n\n" +
|
|
319
|
+
"The goal of the skill collection is a LIBRARY OF CLASS-LEVEL " +
|
|
320
|
+
"INSTRUCTIONS AND EXPERIENTIAL KNOWLEDGE. A collection of hundreds of " +
|
|
321
|
+
"narrow skills where each one captures one session's specific bug is " +
|
|
322
|
+
"a FAILURE of the library — not a feature. An agent searching skills " +
|
|
323
|
+
"matches on descriptions, not on exact names (note: the system prompt " +
|
|
324
|
+
"skill index shows 60 chars of a description — keep the trigger class " +
|
|
325
|
+
"in that window). One broad umbrella " +
|
|
326
|
+
"skill with labeled subsections beats five narrow siblings for " +
|
|
327
|
+
"discoverability, not the other way around.\n\n" +
|
|
328
|
+
"The right target shape is CLASS-LEVEL skills whose SKILL.md carries the " +
|
|
329
|
+
"always-on rules and whose `references/`, `templates/`, and `scripts/` hold a " +
|
|
330
|
+
"SMALL set of topical depth — not one-session-one-skill micro-entries, and " +
|
|
331
|
+
"not an umbrella that hoards one references/ file per absorbed sibling. " +
|
|
332
|
+
"Consolidation means DISTILLING: the absorbed content becomes rules " +
|
|
333
|
+
"(imperative + one clause of why), the same lesson stated twice becomes " +
|
|
334
|
+
"one rule, and incident narration, PR/issue numbers, dates and quoted " +
|
|
335
|
+
"chatter are dropped — the rule must stand without the story. Moving a " +
|
|
336
|
+
"file unchanged under references/ is filing, not consolidating. A SKILL.md " +
|
|
337
|
+
"body over ~24k chars is a consolidation target on its own: loading it " +
|
|
338
|
+
"pulls all of it into context for the rest of the session, so distill it to " +
|
|
339
|
+
"the always-on rules and push topic depth into references/.\n\n" +
|
|
340
|
+
"Hard rules — do not violate:\n" +
|
|
341
|
+
"1. DO NOT touch bundled, hub-installed, or external-dir skills. The " +
|
|
342
|
+
"candidate list below is already filtered to local curator-managed skills " +
|
|
343
|
+
"only; external skills are externally owned and read-only to this curator.\n" +
|
|
344
|
+
"2. DO NOT delete any skill. Archiving (moving the skill's directory " +
|
|
345
|
+
"into the skills root's `.archive/`) is the maximum destructive action. " +
|
|
346
|
+
"Archives are recoverable; deletion is not.\n" +
|
|
347
|
+
"3. DO NOT touch skills shown as pinned=yes. Skip them entirely.\n" +
|
|
348
|
+
"3b. DO NOT archive, delete, consolidate, move, or otherwise modify any " +
|
|
349
|
+
"skill named in the protected built-ins list. These back load-bearing UX " +
|
|
350
|
+
"and are filtered out of the candidate list below — never resurrect " +
|
|
351
|
+
"one as an archive or absorb target.\n" +
|
|
352
|
+
"4. DO NOT use usage counters as a reason to skip consolidation. The " +
|
|
353
|
+
"counters are new and often mostly zero. Judge overlap on CONTENT, " +
|
|
354
|
+
"not on use_count. 'use=0' is not evidence a skill is valuable; it's " +
|
|
355
|
+
"absence of evidence either way. Corollary: 'use=0' is ALSO not a " +
|
|
356
|
+
"reason to PRUNE a skill. Never archive a never-used skill (use=0) " +
|
|
357
|
+
"unless it is at least 30 days old (check last_activity / created date) " +
|
|
358
|
+
"AND its content is genuinely obsolete or fully absorbed elsewhere — a " +
|
|
359
|
+
"recently-created skill simply may not have had its trigger come up yet.\n" +
|
|
360
|
+
"5. DO NOT reject consolidation on the grounds that 'each skill has " +
|
|
361
|
+
"a distinct trigger'. Pairwise distinctness is the wrong bar. The " +
|
|
362
|
+
"right bar is: 'would a human maintainer write this as N separate " +
|
|
363
|
+
"skills, or as one skill with N labeled subsections?' When the " +
|
|
364
|
+
"answer is the latter, merge.\n\n" +
|
|
365
|
+
"How to work — not optional:\n" +
|
|
366
|
+
"1. Scan the full candidate list. Identify PREFIX CLUSTERS (skills " +
|
|
367
|
+
"sharing a first word or domain keyword). Expect 10-25 clusters.\n" +
|
|
368
|
+
"2. For each cluster with 2+ members, do NOT ask 'are these pairs " +
|
|
369
|
+
"overlapping?' — ask 'what is the UMBRELLA CLASS these skills all " +
|
|
370
|
+
"serve? Would a maintainer name that class and write one skill for " +
|
|
371
|
+
"it?' If yes, pick (or create) the umbrella and absorb the siblings " +
|
|
372
|
+
"into it.\n" +
|
|
373
|
+
"3. Three ways to consolidate — use the right one per cluster:\n" +
|
|
374
|
+
" a. MERGE INTO EXISTING UMBRELLA — one skill in the cluster is " +
|
|
375
|
+
"already broad enough to be the umbrella. Patch it to add a labeled " +
|
|
376
|
+
"section for each sibling's unique insight, then archive the " +
|
|
377
|
+
"siblings.\n" +
|
|
378
|
+
" b. CREATE A NEW UMBRELLA SKILL.md — no existing member is broad " +
|
|
379
|
+
"enough. Create a new class-level " +
|
|
380
|
+
"skill whose SKILL.md covers the shared workflow and has short " +
|
|
381
|
+
"labeled subsections. Archive the now-absorbed narrow siblings.\n" +
|
|
382
|
+
" c. DEMOTE TO REFERENCES/TEMPLATES/SCRIPTS — a sibling has " +
|
|
383
|
+
"narrow-but-valuable depth that is only needed sometimes. Distill it " +
|
|
384
|
+
"into the umbrella's appropriate support directory:\n" +
|
|
385
|
+
" • `references/<topic>.md` — named by TOPIC, merged into an " +
|
|
386
|
+
"existing topical file when one covers it (decision tables, recipes, " +
|
|
387
|
+
"provider quirks, condensed domain notes). Never `<sibling-name>.md` " +
|
|
388
|
+
"copied verbatim; never a per-incident file.\n" +
|
|
389
|
+
" • `templates/<name>.<ext>` for starter files meant to be " +
|
|
390
|
+
"copied and modified\n" +
|
|
391
|
+
" • `scripts/<name>.<ext>` for statically re-runnable actions " +
|
|
392
|
+
"(verification scripts, fixture generators, probes)\n" +
|
|
393
|
+
" Then archive the old sibling. Re-home the content through the " +
|
|
394
|
+
"LEDGERED write path so it is rollback-able — never a shell mv/cp, " +
|
|
395
|
+
"which writes the same bytes with no ledger entry, so the archive that " +
|
|
396
|
+
"follows snapshots an already-stripped package and rollback restores a " +
|
|
397
|
+
"hollow skill.\n\n" +
|
|
398
|
+
"Package integrity — not optional:\n" +
|
|
399
|
+
"Before demoting or archiving a skill, inspect it as a COMPLETE " +
|
|
400
|
+
"directory package, not just SKILL.md. A skill root may include " +
|
|
401
|
+
"`references/`, `templates/`, `scripts/`, and `assets/`; the skill " +
|
|
402
|
+
"loader discovers those relative to the skill root. A reference markdown " +
|
|
403
|
+
"file inside another skill is NOT a new skill root and does not get its own " +
|
|
404
|
+
"linked-file discovery.\n" +
|
|
405
|
+
"If the source skill has support files OR SKILL.md contains relative " +
|
|
406
|
+
"links such as `references/...`, `templates/...`, `scripts/...`, or " +
|
|
407
|
+
"`assets/...`, DO NOT flatten only SKILL.md into " +
|
|
408
|
+
"`<umbrella>/references/<old>.md`. Choose one safe path instead:\n" +
|
|
409
|
+
" • keep it as a standalone skill, OR\n" +
|
|
410
|
+
" • fully merge it by re-homing every needed support file into the " +
|
|
411
|
+
"umbrella's canonical `references/`, `templates/`, `scripts/`, or " +
|
|
412
|
+
"`assets/` directories AND rewrite the destination instructions to " +
|
|
413
|
+
"the new paths, OR\n" +
|
|
414
|
+
" • archive the entire original skill package unchanged.\n" +
|
|
415
|
+
"Never leave archived/demoted instructions pointing at files that were " +
|
|
416
|
+
"left behind under the old skill directory.\n" +
|
|
417
|
+
"4. Also flag skills whose NAME is too narrow (contains a PR number, " +
|
|
418
|
+
"a feature codename, a specific error string, an 'audit' / " +
|
|
419
|
+
"'diagnosis' / 'salvage' session artifact). These almost always " +
|
|
420
|
+
"belong as a subsection or support file under a class-level umbrella.\n" +
|
|
421
|
+
"5. Iterate. After one consolidation round, scan the remaining set " +
|
|
422
|
+
"and look for the NEXT umbrella opportunity. Don't stop after 3 " +
|
|
423
|
+
"merges.\n\n" +
|
|
424
|
+
"Your toolset:\n" +
|
|
425
|
+
" - the skill tool — read the current landscape\n" +
|
|
426
|
+
" READ BEFORE WRITE — enforced, not advisory. Before patching, " +
|
|
427
|
+
"overwriting an existing support file, or removing a file, load that " +
|
|
428
|
+
"SAME target in this review turn and build the write from the content " +
|
|
429
|
+
"it just returned. A write without that read is REFUSED.\n" +
|
|
430
|
+
" - action=patch — add sections to the umbrella\n" +
|
|
431
|
+
" - action=create — create a new umbrella SKILL.md\n" +
|
|
432
|
+
" - action=write_file — add a references/, templates/, " +
|
|
433
|
+
"or scripts/ file under an existing skill (the skill must already " +
|
|
434
|
+
"exist)\n" +
|
|
435
|
+
" - action=archive — archive a skill. MUST name `absorbed_into=<umbrella>` " +
|
|
436
|
+
"naming the skill you merged its content " +
|
|
437
|
+
"into (the umbrella must already exist). Archives without a verified " +
|
|
438
|
+
"forwarding target are refused — pruning with no absorption target is " +
|
|
439
|
+
"the deterministic staleness pass's job, never this one's.\n" +
|
|
440
|
+
" You have NO terminal access in this pass — every filesystem mutation " +
|
|
441
|
+
"goes through the ledgered write path above so it is rollback-able.\n\n" +
|
|
442
|
+
"'keep' is a legitimate decision ONLY when the skill is already a " +
|
|
443
|
+
"class-level umbrella and none of the proposed merges would improve " +
|
|
444
|
+
"discoverability. 'This is narrow but distinct from its siblings' " +
|
|
445
|
+
"is NOT a reason to keep — it's a reason to move it under an " +
|
|
446
|
+
"umbrella as a subsection or support file.\n\n" +
|
|
447
|
+
"Expected output: real umbrella-ification. Process every obvious " +
|
|
448
|
+
"cluster.\n\n" +
|
|
449
|
+
"When done, write a human summary AND a structured machine-readable " +
|
|
450
|
+
"block so downstream tooling can distinguish consolidation from " +
|
|
451
|
+
"pruning. Format EXACTLY:\n\n" +
|
|
452
|
+
"## Structured summary (required)\n" +
|
|
453
|
+
"```yaml\n" +
|
|
454
|
+
"consolidations:\n" +
|
|
455
|
+
" - from: <old-skill-name>\n" +
|
|
456
|
+
" into: <umbrella-skill-name>\n" +
|
|
457
|
+
" reason: <one short sentence — why merged, not just 'similar'>\n" +
|
|
458
|
+
"prunings:\n" +
|
|
459
|
+
" - name: <skill-name>\n" +
|
|
460
|
+
" reason: <one short sentence — why archived with no merge target>\n" +
|
|
461
|
+
"```\n\n" +
|
|
462
|
+
"Every skill you moved to `.archive/` MUST appear in exactly one of the " +
|
|
463
|
+
"two lists. If you consolidated X into umbrella Y (patched Y, wrote " +
|
|
464
|
+
"a references file to Y, or created Y with X's content absorbed), X " +
|
|
465
|
+
"goes under `consolidations` with `into: Y`. If you archived X with " +
|
|
466
|
+
"no absorption — truly stale, irrelevant, or obsolete — X goes under " +
|
|
467
|
+
"`prunings`. Leave a list empty (`consolidations: []`) if none. Do " +
|
|
468
|
+
"not omit the block. The block comes AFTER your human-readable " +
|
|
469
|
+
"summary of clusters processed, patches made, and decisions left alone.";
|
|
470
|
+
|
|
471
|
+
/** Curator 合并的输出契约(DSH 特有:fork 只读,输出 JSON 由插件执行)。 */
|
|
472
|
+
export const CURATOR_OUTPUT_CONTRACT = `
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## Output contract (DSH-specific)
|
|
477
|
+
|
|
478
|
+
You are a READ-ONLY curator fork. You cannot write files. Output ONE fenced JSON block:
|
|
479
|
+
|
|
480
|
+
\`\`\`json
|
|
481
|
+
{
|
|
482
|
+
"operations": [
|
|
483
|
+
{ "op": "patch", "target": "<umbrella>", "body": "<complete new SKILL.md body>" },
|
|
484
|
+
{ "op": "create", "target": "<new-umbrella>", "frontmatter": { "name": "...", "description": "..." }, "body": "..." },
|
|
485
|
+
{ "op": "write_file", "target": "<umbrella>", "filePath": "references/<topic>.md", "body": "..." },
|
|
486
|
+
{ "op": "archive", "target": "<sibling>", "absorbedInto": "<umbrella>", "reason": "..." }
|
|
487
|
+
],
|
|
488
|
+
"summary": "<one paragraph: clusters processed, what merged where>"
|
|
489
|
+
}
|
|
490
|
+
\`\`\`
|
|
491
|
+
|
|
492
|
+
Rules:
|
|
493
|
+
- Every \`archive\` MUST name \`absorbedInto\` pointing at a skill that exists or is created in this same block.
|
|
494
|
+
- Never archive a pinned or protected skill.
|
|
495
|
+
- If nothing should change, output \`{"operations": [], "summary": "..."}\`.`;
|
|
496
|
+
|
|
497
|
+
/** 组装 curator 合并提示词。 */
|
|
498
|
+
export function buildCuratorPrompt({ candidates = [], protectedNames = [] } = {}) {
|
|
499
|
+
const list = candidates.length
|
|
500
|
+
? candidates
|
|
501
|
+
.map((s) => {
|
|
502
|
+
const header = `- ${s.name} (use=${s.useCount ?? 0}, state=${s.state ?? "active"}${s.pinned ? ", pinned=yes" : ""}): ${s.description || "(no description)"}`;
|
|
503
|
+
const excerpt = s.body ? `\n \`\`\`markdown\n ${String(s.body).trim().replace(/\n/g, "\n ")}\n \`\`\`` : "";
|
|
504
|
+
return header + excerpt;
|
|
505
|
+
})
|
|
506
|
+
.join("\n\n")
|
|
507
|
+
: "(no curator-managed skills yet)";
|
|
508
|
+
return (
|
|
509
|
+
CURATOR_REVIEW_PROMPT +
|
|
510
|
+
`\n\n## Candidate list (already filtered)\n\n${list}\n` +
|
|
511
|
+
(protectedNames.length ? `\nProtected built-ins (never touch): ${protectedNames.join(", ")}\n` : "") +
|
|
512
|
+
CURATOR_OUTPUT_CONTRACT
|
|
513
|
+
);
|
|
514
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 写来源溯源(Write-Origin Provenance)
|
|
3
|
+
*
|
|
4
|
+
* 移植自 Hermes `tools/skill_provenance.py`。
|
|
5
|
+
*
|
|
6
|
+
* 核心不变量:**用户明确要求的技能归用户,自动复盘产生的技能归 curator。**
|
|
7
|
+
* 这决定了谁有权归档、修改或删除一个技能。没有这层区分,自进化机制会
|
|
8
|
+
* 悄悄改写用户手写的技能,那是不可接受的。
|
|
9
|
+
*
|
|
10
|
+
* 两种来源:
|
|
11
|
+
* - "foreground" 任何常规 agent(CLI、gateway、cron、subagent、用户直接对话)
|
|
12
|
+
* - "background_review" 自进化复盘 fork 写出的内容
|
|
13
|
+
*
|
|
14
|
+
* 另有一个正交维度「是否有人值守」(attended):
|
|
15
|
+
* - 用户显式触发 `/refine` 的复盘仍是 background_review(所有 curator 护栏照样生效),
|
|
16
|
+
* 但因为是用户要求的,无人值守专属的删除闸门不适用。
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
20
|
+
|
|
21
|
+
export const FOREGROUND = "foreground";
|
|
22
|
+
export const BACKGROUND_REVIEW = "background_review";
|
|
23
|
+
|
|
24
|
+
const VALID_ORIGINS = new Set([FOREGROUND, BACKGROUND_REVIEW]);
|
|
25
|
+
|
|
26
|
+
const _store = new AsyncLocalStorage();
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 在当前异步上下文中绑定写来源,返回一个 token 供 reset 使用。
|
|
30
|
+
* 用法:
|
|
31
|
+
* const token = setCurrentWriteOrigin(BACKGROUND_REVIEW);
|
|
32
|
+
* try { ...写入技能... } finally { resetCurrentWriteOrigin(token); }
|
|
33
|
+
*/
|
|
34
|
+
export function setCurrentWriteOrigin(origin) {
|
|
35
|
+
const previous = _store.getStore() ?? { origin: FOREGROUND, attended: false };
|
|
36
|
+
const next = { ...previous, origin: VALID_ORIGINS.has(origin) ? origin : FOREGROUND };
|
|
37
|
+
_store.enterWith(next);
|
|
38
|
+
return previous;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** 恢复到 setCurrentWriteOrigin 之前的上下文。 */
|
|
42
|
+
export function resetCurrentWriteOrigin(previous) {
|
|
43
|
+
_store.enterWith(previous ?? { origin: FOREGROUND, attended: false });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** 当前写来源:常规 agent 为 "foreground",复盘 fork 为 "background_review"。 */
|
|
47
|
+
export function getCurrentWriteOrigin() {
|
|
48
|
+
return _store.getStore()?.origin ?? FOREGROUND;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** 是否处于自动复盘 fork 中。所有 curator / 账本 / 审批闸门都以此为判定依据。 */
|
|
52
|
+
export function isBackgroundReview() {
|
|
53
|
+
return getCurrentWriteOrigin() === BACKGROUND_REVIEW;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** 标记本次复盘是否由用户显式触发(有人值守)。 */
|
|
57
|
+
export function setReviewAttended(attended) {
|
|
58
|
+
const previous = _store.getStore() ?? { origin: FOREGROUND, attended: false };
|
|
59
|
+
_store.enterWith({ ...previous, attended: Boolean(attended) });
|
|
60
|
+
return previous;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function resetReviewAttended(previous) {
|
|
64
|
+
_store.enterWith(previous ?? { origin: FOREGROUND, attended: false });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 无人值守的自动复盘:background_review 且用户没有显式要求。
|
|
69
|
+
* 这是权限最小的一档——只允许产出草稿,不允许直接落盘或删除任何东西。
|
|
70
|
+
*/
|
|
71
|
+
export function isUnattendedReview() {
|
|
72
|
+
const s = _store.getStore();
|
|
73
|
+
return s?.origin === BACKGROUND_REVIEW && !s?.attended;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 某个技能是否允许被自动复盘修改。
|
|
78
|
+
*
|
|
79
|
+
* 规则(移植自 Hermes 的归属原则):
|
|
80
|
+
* - 技能带 `created_by: agent` 标记 → 自动复盘可以改(它是我们自己造的)
|
|
81
|
+
* - 否则(用户手写 / 内置 / 从 hub 安装 / 用户明确要求)→ 自动复盘只能"建议",不能改
|
|
82
|
+
*
|
|
83
|
+
* 注意:这里刻意**不**用"技能在哪个目录"来推断归属——位置会被移动,
|
|
84
|
+
* 只有显式标记才是可信来源。
|
|
85
|
+
*/
|
|
86
|
+
export function mayAutoModify(skillMeta) {
|
|
87
|
+
if (!skillMeta || typeof skillMeta !== "object") return false;
|
|
88
|
+
const createdBy =
|
|
89
|
+
skillMeta.createdBy ??
|
|
90
|
+
skillMeta.created_by ??
|
|
91
|
+
skillMeta.metadata?.createdBy ??
|
|
92
|
+
skillMeta.metadata?.created_by;
|
|
93
|
+
return createdBy === "agent";
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** 给新建技能打上归属标记(写入 SKILL.md frontmatter 的 metadata 段)。 */
|
|
97
|
+
export function agentMetadata(extra = {}) {
|
|
98
|
+
return {
|
|
99
|
+
createdBy: "agent",
|
|
100
|
+
origin: getCurrentWriteOrigin(),
|
|
101
|
+
...extra,
|
|
102
|
+
};
|
|
103
|
+
}
|