@dsh-cc/tool-manage-skill 0.8.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 +201 -0
- package/README.i18n.yaml +6 -0
- package/README.md +32 -0
- package/README.zh.md +27 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +150 -0
- package/lib/index.js.map +1 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.i18n.yaml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
|
|
2
|
+
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
|
+
# after editing either side, bring the other along and re-record with:
|
|
4
|
+
# pnpm check:readme --write
|
|
5
|
+
README.md: 9520415dc1d228f21b7da1b1ad0dc96f353ebd49
|
|
6
|
+
README.zh.md: 34b088c46d7b184b3ebc8cab45432a71f37074c8
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @dsh-cc/tool-manage-skill
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
Model-facing `manage_skill` tool for learned skills (plan
|
|
6
|
+
`docs/plans/2026-09-23-learned-skills.md` §4.4). Mounted unconditionally in the
|
|
7
|
+
cc-services group of the CC preset; the `cc-learn.enabled` gate is checked at
|
|
8
|
+
call time.
|
|
9
|
+
|
|
10
|
+
## Behavior
|
|
11
|
+
|
|
12
|
+
- **Actions**: `create` (requires `name`, `description`, `body`), `update`
|
|
13
|
+
(requires `name` plus at least one of `body`/`description`; all other
|
|
14
|
+
frontmatter keys are preserved), `delete` (removes the whole skill
|
|
15
|
+
directory), `list` (one line per learned skill:
|
|
16
|
+
`<name> — <description> (<bytes> B) — <path>`; empty root → "no learned
|
|
17
|
+
skills").
|
|
18
|
+
- **Storage**: shared `LearnedSkillStore` from `@dsh-cc/skill-loader`, rooted
|
|
19
|
+
at `$DSH_HOME/learned-skills/`. Writes are atomic (wx create; temp+rename
|
|
20
|
+
update; `rm -r` delete).
|
|
21
|
+
- **Gate**: reads `settings.get('cc-learn')` directly; a missing section or
|
|
22
|
+
service falls back to enabled. Gate off → non-error text
|
|
23
|
+
"manage_skill is disabled (`cc-learn.enabled` is false in settings)."
|
|
24
|
+
- **Errors**: `isError: true` tool results carrying a stable code word —
|
|
25
|
+
`invalid_name`, `invalid_params`, `too_large`, `shadowed`,
|
|
26
|
+
`already_exists`, `not_found` (with an authored-claimant hint where the
|
|
27
|
+
store adds one).
|
|
28
|
+
- **Refresh**: every successful mutation emits the package-private
|
|
29
|
+
`skills/learned-changed` cordis event so the skill registry invalidates its
|
|
30
|
+
collect cache (§4.5); failures never emit.
|
|
31
|
+
- **Promotion guidance** (in the tool description): promote only procedural,
|
|
32
|
+
repeatable lessons ("how to do X here"); facts and secrets stay in memory.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @dsh-cc/tool-manage-skill
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
面向模型的 `manage_skill` 工具,用于 learned skills(计划
|
|
6
|
+
`docs/plans/2026-09-23-learned-skills.md` §4.4)。无条件挂载在 CC preset 的
|
|
7
|
+
cc-services 组内;`cc-learn.enabled` 门控在调用时读取。
|
|
8
|
+
|
|
9
|
+
## 行为
|
|
10
|
+
|
|
11
|
+
- **动作**:`create`(需要 `name`、`description`、`body`)、`update`
|
|
12
|
+
(需要 `name` 及 `body`/`description` 至少其一;其余 frontmatter 键全部保留)、
|
|
13
|
+
`delete`(删除整个技能目录)、`list`(每个技能一行:
|
|
14
|
+
`<name> — <description> (<bytes> B) — <path>`;空根目录输出 "no learned skills")。
|
|
15
|
+
- **存储**:复用 `@dsh-cc/skill-loader` 的共享 `LearnedSkillStore`,根目录为
|
|
16
|
+
`$DSH_HOME/learned-skills/`。写入是原子的(创建用 wx;更新用临时文件+rename;
|
|
17
|
+
删除用 `rm -r`)。
|
|
18
|
+
- **门控**:直接读取 `settings.get('cc-learn')`;缺少配置节或服务时默认启用。
|
|
19
|
+
关闭时返回非错误文本
|
|
20
|
+
"manage_skill is disabled (`cc-learn.enabled` is false in settings)."
|
|
21
|
+
- **错误**:`isError: true` 的工具结果携带稳定代码词——`invalid_name`、
|
|
22
|
+
`invalid_params`、`too_large`、`shadowed`、`already_exists`、`not_found`
|
|
23
|
+
(store 附加 authored-claimant 提示时一并提供)。
|
|
24
|
+
- **刷新**:每次成功变更都会发出包私有的 `skills/learned-changed` cordis 事件,
|
|
25
|
+
令技能注册表失效其 collect 缓存(§4.5);失败不发出。
|
|
26
|
+
- **晋升指引**(写入工具描述):只晋升过程性、可复用的经验("如何在这里做 X");
|
|
27
|
+
事实与机密留在 memory,绝不写入 learned skill。
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing `manage_skill` tool: create/update/delete/list learned skills
|
|
3
|
+
* under `$DSH_HOME/learned-skills/` through the shared `LearnedSkillStore`
|
|
4
|
+
* (§4.6 of docs/plans/2026-09-23-learned-skills.md). The `cc-learn.enabled`
|
|
5
|
+
* gate is read at call time; a successful mutation emits the package-private
|
|
6
|
+
* `skills/learned-changed` cordis event so the skill registry invalidates its
|
|
7
|
+
* collect cache (§4.5).
|
|
8
|
+
* @module @dsh-cc/tool-manage-skill
|
|
9
|
+
*/
|
|
10
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
11
|
+
export declare const name = "tool-manage-skill";
|
|
12
|
+
export declare const inject: string[];
|
|
13
|
+
/** Tool arguments: one action plus optional per-action fields. */
|
|
14
|
+
export interface ManageSkillArgs {
|
|
15
|
+
action: 'create' | 'update' | 'delete' | 'list';
|
|
16
|
+
name?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
body?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function apply(ctx: Context): void;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAOlD,eAAO,MAAM,IAAI,sBAAsB,CAAA;AACvC,eAAO,MAAM,MAAM,UAAsB,CAAA;AAgBzC,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAA;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAyBD,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAsGxC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing `manage_skill` tool: create/update/delete/list learned skills
|
|
3
|
+
* under `$DSH_HOME/learned-skills/` through the shared `LearnedSkillStore`
|
|
4
|
+
* (§4.6 of docs/plans/2026-09-23-learned-skills.md). The `cc-learn.enabled`
|
|
5
|
+
* gate is read at call time; a successful mutation emits the package-private
|
|
6
|
+
* `skills/learned-changed` cordis event so the skill registry invalidates its
|
|
7
|
+
* collect cache (§4.5).
|
|
8
|
+
* @module @dsh-cc/tool-manage-skill
|
|
9
|
+
*/
|
|
10
|
+
import { resolveDshHome } from '@deepseek-ai/dsh-home-paths';
|
|
11
|
+
import { LearnedSkillStore } from '@dsh-cc/skill-loader';
|
|
12
|
+
import { defineTool } from '@dsh-cc/tools';
|
|
13
|
+
export const name = 'tool-manage-skill';
|
|
14
|
+
export const inject = ['tools', 'skills'];
|
|
15
|
+
/** Model-visible failure (maps to an isError tool result carrying the code word). */
|
|
16
|
+
class ManageSkillError extends Error {
|
|
17
|
+
}
|
|
18
|
+
/** Whether the `cc-learn` gate is on: default enabled when the section is absent. */
|
|
19
|
+
function gateEnabled(section) {
|
|
20
|
+
return section?.enabled !== false;
|
|
21
|
+
}
|
|
22
|
+
/** Validate per-action required params; `undefined` when complete. */
|
|
23
|
+
function missingParams(args) {
|
|
24
|
+
const has = (value) => typeof value === 'string' && value.length > 0;
|
|
25
|
+
switch (args.action) {
|
|
26
|
+
case 'create':
|
|
27
|
+
if (!has(args.name) || !has(args.description) || !has(args.body)) {
|
|
28
|
+
return 'create requires name, description and body';
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
case 'update':
|
|
32
|
+
if (!has(args.name))
|
|
33
|
+
return 'update requires name';
|
|
34
|
+
if (!has(args.body) && !has(args.description))
|
|
35
|
+
return 'update requires a body or description';
|
|
36
|
+
return undefined;
|
|
37
|
+
case 'delete':
|
|
38
|
+
if (!has(args.name))
|
|
39
|
+
return 'delete requires name';
|
|
40
|
+
return undefined;
|
|
41
|
+
case 'list':
|
|
42
|
+
return undefined;
|
|
43
|
+
default:
|
|
44
|
+
return `unknown action ${JSON.stringify(args.action)}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function apply(ctx) {
|
|
48
|
+
// Gate read at call time: capture the (possibly absent) settings service at
|
|
49
|
+
// apply time, resolve the live section on every call (headless fallback: enabled).
|
|
50
|
+
let settings;
|
|
51
|
+
ctx.inject(['settings'], (sctx) => {
|
|
52
|
+
settings = sctx.settings;
|
|
53
|
+
});
|
|
54
|
+
const store = new LearnedSkillStore({
|
|
55
|
+
dshHome: resolveDshHome(),
|
|
56
|
+
listClaimants: async () => {
|
|
57
|
+
const skills = (await ctx.skills.list({ cwd: process.cwd() }));
|
|
58
|
+
return skills.map(c => ({ name: c.name, provider: c.provider, source: c.source }));
|
|
59
|
+
},
|
|
60
|
+
onChanged: () => {
|
|
61
|
+
ctx.emit('skills/learned-changed');
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
const tool = defineTool({
|
|
65
|
+
name: 'manage_skill',
|
|
66
|
+
description: 'Create, update, delete, or list learned skills — durable, reusable procedural lessons distilled from this '
|
|
67
|
+
+ 'project\'s sessions. Promote only procedural, repeatable lessons ("how to do X here"): workflows, gotchas, '
|
|
68
|
+
+ 'command sequences. Facts, credentials, and secrets stay in memory, never in a learned skill. '
|
|
69
|
+
+ 'Actions: `create` (requires name — lowercase-kebab, description, body), `update` (requires name plus at '
|
|
70
|
+
+ 'least one of body/description; other frontmatter keys are preserved), `delete` (requires name; removes '
|
|
71
|
+
+ 'the whole skill), `list` (no arguments — enumerate learned skills). The name must match '
|
|
72
|
+
+ '^[a-z0-9][a-z0-9-]{0,63}$.',
|
|
73
|
+
parameters: {
|
|
74
|
+
action: {
|
|
75
|
+
type: 'string',
|
|
76
|
+
required: true,
|
|
77
|
+
description: 'One of create, update, delete, list.',
|
|
78
|
+
},
|
|
79
|
+
name: { type: 'string', description: 'Learned-skill name (lowercase kebab). Required for create/update/delete.' },
|
|
80
|
+
description: { type: 'string', description: 'Model-facing one-line description. Required for create; optional for update.' },
|
|
81
|
+
body: { type: 'string', description: 'Markdown skill body. Required for create; optional for update.' },
|
|
82
|
+
},
|
|
83
|
+
output: {
|
|
84
|
+
schema: {
|
|
85
|
+
type: 'object',
|
|
86
|
+
additionalProperties: false,
|
|
87
|
+
properties: {
|
|
88
|
+
message: { type: 'string', required: true },
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
render: (_args, value) => [{ type: 'text', text: value.message }],
|
|
92
|
+
},
|
|
93
|
+
// Mutations touch the shared learned root: never overlap.
|
|
94
|
+
isConcurrencySafe: () => false,
|
|
95
|
+
async execute(args, _exec) {
|
|
96
|
+
const section = settings?.get('cc-learn');
|
|
97
|
+
if (!gateEnabled(section)) {
|
|
98
|
+
return { message: 'manage_skill is disabled (`cc-learn.enabled` is false in settings).' };
|
|
99
|
+
}
|
|
100
|
+
const missing = missingParams(args);
|
|
101
|
+
if (missing !== undefined) {
|
|
102
|
+
throw new ManageSkillError(`manage_skill invalid_params: ${missing}`);
|
|
103
|
+
}
|
|
104
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
105
|
+
switch (args.action) {
|
|
106
|
+
case 'create': {
|
|
107
|
+
const result = await store.create({
|
|
108
|
+
name: args.name,
|
|
109
|
+
description: args.description,
|
|
110
|
+
learnedFrom: `manage_skill ${today}`,
|
|
111
|
+
body: args.body,
|
|
112
|
+
});
|
|
113
|
+
if (!result.ok)
|
|
114
|
+
throw new ManageSkillError(`manage_skill ${result.code}: ${result.detail}`);
|
|
115
|
+
return { message: `created learned skill ${args.name} (${result.value.bytes} B) at ${result.value.path}` };
|
|
116
|
+
}
|
|
117
|
+
case 'update': {
|
|
118
|
+
const result = await store.update({
|
|
119
|
+
name: args.name,
|
|
120
|
+
...(args.description !== undefined ? { description: args.description } : {}),
|
|
121
|
+
...(args.body !== undefined ? { body: args.body } : {}),
|
|
122
|
+
});
|
|
123
|
+
if (!result.ok)
|
|
124
|
+
throw new ManageSkillError(`manage_skill ${result.code}: ${result.detail}`);
|
|
125
|
+
return { message: `updated learned skill ${args.name} (${result.value.bytes} B) at ${result.value.path}` };
|
|
126
|
+
}
|
|
127
|
+
case 'delete': {
|
|
128
|
+
const result = await store.delete(args.name);
|
|
129
|
+
if (!result.ok)
|
|
130
|
+
throw new ManageSkillError(`manage_skill ${result.code}: ${result.detail}`);
|
|
131
|
+
return { message: `deleted learned skill ${args.name} (directory of ${result.value.path})` };
|
|
132
|
+
}
|
|
133
|
+
case 'list': {
|
|
134
|
+
const result = await store.list();
|
|
135
|
+
if (!result.ok)
|
|
136
|
+
throw new ManageSkillError(`manage_skill ${result.code}: ${result.detail}`);
|
|
137
|
+
if (result.value.length === 0)
|
|
138
|
+
return { message: 'no learned skills' };
|
|
139
|
+
return {
|
|
140
|
+
message: result.value
|
|
141
|
+
.map(entry => `${entry.name} — ${entry.description} (${entry.bytes} B) — ${entry.path}`)
|
|
142
|
+
.join('\n'),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
ctx.tools.register(tool);
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG1C,MAAM,CAAC,MAAM,IAAI,GAAG,mBAAmB,CAAA;AACvC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AAQzC,qFAAqF;AACrF,MAAM,gBAAiB,SAAQ,KAAK;CAAG;AAEvC,qFAAqF;AACrF,SAAS,WAAW,CAAC,OAAiC;IACpD,OAAO,OAAO,EAAE,OAAO,KAAK,KAAK,CAAA;AACnC,CAAC;AAUD,sEAAsE;AACtE,SAAS,aAAa,CAAC,IAAqB;IAC1C,MAAM,GAAG,GAAG,CAAC,KAAyB,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;IACzG,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;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,gBAAgB,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;oBAC3F,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;wBAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAA;oBACtE,OAAO;wBACL,OAAO,EAAE,MAAM,CAAC,KAAK;6BAClB,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,KAAK,SAAS,KAAK,CAAC,IAAI,EAAE,CAAC;6BACvF,IAAI,CAAC,IAAI,CAAC;qBACd,CAAA;gBACH,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC,CAAA;IACF,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAA2D,CAAC,CAAA;AACjF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dsh-cc/tool-manage-skill",
|
|
3
|
+
"description": "CC-style manage_skill tool: create/update/delete/list learned skills under $DSH_HOME/learned-skills via the shared LearnedSkillStore, gated by the cc-learn.enabled setting",
|
|
4
|
+
"version": "0.8.1",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/dsh-cc/dsh-cc.git",
|
|
8
|
+
"directory": "packages/core/tool-manage-skill"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./lib/index.d.ts",
|
|
14
|
+
"default": "./lib/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./src/*": "./src/*",
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"lib"
|
|
21
|
+
],
|
|
22
|
+
"license": "Apache-2.0",
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@dsh-cc/tools": "^0.8.1",
|
|
28
|
+
"@dsh-cc/skill-loader": "^0.8.1"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@deepseek-ai/cordis": ">=0.1.5-rc.1",
|
|
32
|
+
"@deepseek-ai/dsh-home-paths": ">=0.1.5-rc.1",
|
|
33
|
+
"@deepseek-ai/dsh-llm": ">=0.1.5-rc.1",
|
|
34
|
+
"@deepseek-ai/dsh-skill": ">=0.1.5-rc.1",
|
|
35
|
+
"@deepseek-ai/dsh-system-prompt": ">=0.1.5-rc.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@deepseek-ai/cordis": "link:../../../../deepseek-harness/vendor/cordis",
|
|
39
|
+
"@deepseek-ai/dsh-home-paths": "link:../../../../deepseek-harness/packages/util/home-paths",
|
|
40
|
+
"@deepseek-ai/dsh-llm": "link:../../../../deepseek-harness/packages/llm/llm",
|
|
41
|
+
"@deepseek-ai/dsh-skill": "link:../../../../deepseek-harness/packages/skill/skill",
|
|
42
|
+
"@deepseek-ai/dsh-system-prompt": "link:../../../../deepseek-harness/packages/core/system-prompt"
|
|
43
|
+
}
|
|
44
|
+
}
|