@jianxx/dsh-cc-plugin-loader 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/LICENSE +201 -0
- package/README.i18n.yaml +6 -0
- package/README.md +45 -0
- package/README.zh.md +45 -0
- package/lib/agents.d.ts +109 -0
- package/lib/agents.d.ts.map +1 -0
- package/lib/agents.js +147 -0
- package/lib/agents.js.map +1 -0
- package/lib/commands.d.ts +56 -0
- package/lib/commands.d.ts.map +1 -0
- package/lib/commands.js +66 -0
- package/lib/commands.js.map +1 -0
- package/lib/hooks.d.ts +44 -0
- package/lib/hooks.d.ts.map +1 -0
- package/lib/hooks.js +89 -0
- package/lib/hooks.js.map +1 -0
- package/lib/index.d.ts +73 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +92 -0
- package/lib/index.js.map +1 -0
- package/lib/manifest.d.ts +23 -0
- package/lib/manifest.d.ts.map +1 -0
- package/lib/manifest.js +117 -0
- package/lib/manifest.js.map +1 -0
- package/lib/mcp.d.ts +41 -0
- package/lib/mcp.d.ts.map +1 -0
- package/lib/mcp.js +64 -0
- package/lib/mcp.js.map +1 -0
- package/lib/seams.d.ts +59 -0
- package/lib/seams.d.ts.map +1 -0
- package/lib/seams.js +56 -0
- package/lib/seams.js.map +1 -0
- package/lib/settings.d.ts +41 -0
- package/lib/settings.d.ts.map +1 -0
- package/lib/settings.js +44 -0
- package/lib/settings.js.map +1 -0
- package/lib/skill-semantics.d.ts +92 -0
- package/lib/skill-semantics.d.ts.map +1 -0
- package/lib/skill-semantics.js +98 -0
- package/lib/skill-semantics.js.map +1 -0
- package/lib/skills.d.ts +49 -0
- package/lib/skills.d.ts.map +1 -0
- package/lib/skills.js +117 -0
- package/lib/skills.js.map +1 -0
- package/lib/types.d.ts +89 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +12 -0
- package/lib/types.js.map +1 -0
- package/package.json +57 -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 run verify-translation-pairing --write packages/compat/cc-plugin-loader/README.md
|
|
5
|
+
README.md: 351640f50f5087cee64f9ed9d1fe4801bd65f634
|
|
6
|
+
README.zh.md: c9c105c663418ba580c05138e65c1ea7dc37e938
|
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @jianxx/dsh-cc-plugin-loader
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
Load a Claude Code plugin's `plugin.json` manifest and mount each component as an in-memory dsh plugin.
|
|
6
|
+
|
|
7
|
+
This compatibility loader reads a CC plugin manifest subset, translates each component with the pure helpers from [`@jianxx/dsh-cc-skill-loader`](../../skill/skill-claude-code/README.md) and [`@jianxx/dsh-cc-claude-code-agents`](../../preset/claude-code-agents/README.md), and consults the host seam for that component through `ctx.get(...)`. It is not a runtime: it produces typed mounts and a structural report, leaving execution to the seams it registers onto.
|
|
8
|
+
|
|
9
|
+
## Loader
|
|
10
|
+
|
|
11
|
+
`mountCcPlugin(ctx, { root, seams? })` reads `${root}/plugin.json`, validates the manifest subset, and mounts every present component as a Cordis effect. It returns `{ report, dispose }` — `report` is the per-component outcome, and `dispose` recalls every mounted component (a context teardown calls it automatically).
|
|
12
|
+
|
|
13
|
+
### Manifest subset
|
|
14
|
+
|
|
15
|
+
The loader validates `name` (mandatory, kebab-case), `version`, `description`, `author`, and the component fields `commands`, `agents`, `skills`, `hooks`, `mcpServers`, and `settings`. A malformed manifest throws at load with the plugin name. Unknown top-level fields are ignored, matching Claude Code's tolerant handling.
|
|
16
|
+
|
|
17
|
+
### Components and their seams
|
|
18
|
+
|
|
19
|
+
Each component is peer-style: the loader probes the host seam via `ctx.get(...)` and reports the component `skipped` (never failing the whole load) when the seam is absent.
|
|
20
|
+
|
|
21
|
+
| Component | Source | Seam (probed) | Translation |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| `commands` | manifest inline or source | `commands` | registers each slash command via `register`; the handler returns the command content |
|
|
24
|
+
| `agents` | `agents/` dir or manifest paths | `subagents` | loads `AgentDefinition`s via `loadAgentsDir` and registers each as a named provider via `registerProvider` |
|
|
25
|
+
| `skills` | `skills/` dir or manifest paths | `skills` | discovers `SKILL.md` via `discoverCcSkills`, parses frontmatter, and registers each as a runtime skill via `register` |
|
|
26
|
+
| `hooks` | `hooks/hooks.json` or inline | `hooks` (guest) | injects the per-event hook map via `mergePluginHooks` |
|
|
27
|
+
| `mcpServers` | inline record or `.mcp.json` | `mcp` (guest) | registers each server via `registerServer` (tool naming is the seam's responsibility) |
|
|
28
|
+
| `settings` | manifest record | `settings` (guest) | filters to the allowlist (currently `agent`) and writes via `set` |
|
|
29
|
+
|
|
30
|
+
The `hooks` and `mcp` seams have no harness-owned service today; a deployment that wants those components provides a guest seam or they are reported skipped.
|
|
31
|
+
|
|
32
|
+
## Skill semantic wiring
|
|
33
|
+
|
|
34
|
+
On top of the skill mount, this package is the consumer that turns `skill-claude-code`'s metadata into actionable registrations:
|
|
35
|
+
|
|
36
|
+
- **`allowed-tools`** — `skillToolRestriction(metadata)` builds the allow-only `tools.restrict()` filter; `applySkillRestriction(metadata, agent)` applies it to a scoped agent and returns the disposer.
|
|
37
|
+
- **`context: fork`** — `resolveSkillExecution(metadata, subagentsPresent)` routes the skill to subagent execution; when the subagent seam is absent it downgrades to inline and is reported.
|
|
38
|
+
- **`paths`** — `registerSkillPathActivator(ctx, skill, projectRoot)` wires the `fs/observed` path activator for conditional activation.
|
|
39
|
+
- **Inline shell** — `activationFor(metadata, subagentsPresent)` reports `forbidInlineShell` (a `shell: false` skill must not open an inline shell).
|
|
40
|
+
|
|
41
|
+
## Known Limitations and Deferred Work
|
|
42
|
+
|
|
43
|
+
- **Guest seams are absent in the harness** — `hooks`, `mcp`, and `settings` report `skipped` unless a deployment supplies the guest seam. There is no harness-owned `ctx.mcp` or `ctx.hooks` service today.
|
|
44
|
+
- **Agent providers forward execution** — the agents provider names its backend (default `fork`) and delegates `start`; executing a CC agent requires a `fork` backend on the subagent seam at run time.
|
|
45
|
+
- **Skill activation is host-driven** — the loader registers the wiring and activation descriptors; applying them at the model-facing moment is the host's responsibility.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @jianxx/dsh-cc-plugin-loader
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
加载 Claude Code 插件的 `plugin.json` 清单,并把每个组件挂载为内存中的 dsh 插件。
|
|
6
|
+
|
|
7
|
+
这个兼容性加载器读取 CC 插件清单子集,用 [`@jianxx/dsh-cc-skill-loader`](../../skill/skill-claude-code/README.md) 与 [`@jianxx/dsh-cc-claude-code-agents`](../../preset/claude-code-agents/README.md) 的纯函数翻译每个组件,并通过 `ctx.get(...)` 读取该组件的宿主 seam。它不是运行时:它产出类型化挂载与结构化报告,把执行交给它注册到的 seam。
|
|
8
|
+
|
|
9
|
+
## 加载器
|
|
10
|
+
|
|
11
|
+
`mountCcPlugin(ctx, { root, seams? })` 读取 `${root}/plugin.json`、校验清单子集,并把每个存在的组件作为 Cordis effect 挂载。它返回 `{ report, dispose }`——`report` 是每个组件的加载结果,`dispose` 回收所有已挂载组件(context 卸载时自动调用)。
|
|
12
|
+
|
|
13
|
+
### 清单子集
|
|
14
|
+
|
|
15
|
+
加载器校验 `name`(必填、kebab-case)、`version`、`description`、`author`,以及组件字段 `commands`、`agents`、`skills`、`hooks`、`mcpServers`、`settings`。格式错误的清单会在加载时携带插件名抛错。未知的顶层字段被忽略,与 Claude Code 的宽容处理一致。
|
|
16
|
+
|
|
17
|
+
### 组件及其 seam
|
|
18
|
+
|
|
19
|
+
每个组件都是 peer 风格:加载器通过 `ctx.get(...)` 探测宿主 seam,当该 seam 缺失时把组件报告为 `skipped`(绝不让整个加载失败)。
|
|
20
|
+
|
|
21
|
+
| 组件 | 来源 | Seam(探测) | 翻译 |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| `commands` | 清单内联或 source | `commands` | 通过 `register` 注册每个斜杠命令;handler 返回命令内容 |
|
|
24
|
+
| `agents` | `agents/` 目录或清单路径 | `subagents` | 通过 `loadAgentsDir` 加载 `AgentDefinition`,再通过 `registerProvider` 注册为命名 provider |
|
|
25
|
+
| `skills` | `skills/` 目录或清单路径 | `skills` | 通过 `discoverCcSkills` 发现 `SKILL.md`、解析 frontmatter,再通过 `register` 注册为运行时技能 |
|
|
26
|
+
| `hooks` | `hooks/hooks.json` 或内联 | `hooks`(guest)| 通过 `mergePluginHooks` 注入按事件组织的 hook 映射 |
|
|
27
|
+
| `mcpServers` | 内联记录或 `.mcp.json` | `mcp`(guest)| 通过 `registerServer` 注册每个 server(工具命名是 seam 的职责)|
|
|
28
|
+
| `settings` | 清单记录 | `settings`(guest)| 过滤到 allowlist(当前是 `agent`)后通过 `set` 写入 |
|
|
29
|
+
|
|
30
|
+
`hooks` 与 `mcp` seam 目前没有 harness 自有的服务;希望挂载这些组件的部署应提供 guest seam,否则它们会被报告为 `skipped`。
|
|
31
|
+
|
|
32
|
+
## 技能语义接线
|
|
33
|
+
|
|
34
|
+
在技能挂载之上,本包是把 `skill-claude-code` 的 metadata 转成可执行注册的 consumer:
|
|
35
|
+
|
|
36
|
+
- **`allowed-tools`** —— `skillToolRestriction(metadata)` 构建仅允许的 `tools.restrict()` 过滤器;`applySkillRestriction(metadata, agent)` 把它应用到 scoped agent 并返回 disposer。
|
|
37
|
+
- **`context: fork`** —— `resolveSkillExecution(metadata, subagentsPresent)` 把技能路由到子代理执行;当 subagent seam 缺失时降级为内联并被报告。
|
|
38
|
+
- **`paths`** —— `registerSkillPathActivator(ctx, skill, projectRoot)` 挂上用于条件激活的 `fs/observed` 路径激活器。
|
|
39
|
+
- **内联 shell** —— `activationFor(metadata, subagentsPresent)` 报告 `forbidInlineShell`(`shell: false` 的技能不得开启内联 shell)。
|
|
40
|
+
|
|
41
|
+
## 已知限制与待办工作
|
|
42
|
+
|
|
43
|
+
- **harness 中缺少 guest seam** —— 除非部署提供 guest seam,否则 `hooks`、`mcp`、`settings` 会报告为 `skipped`。当前没有 harness 自有的 `ctx.mcp` 或 `ctx.hooks` 服务。
|
|
44
|
+
- **agent provider 转发执行** —— agents provider 以名字命名其后端(默认 `fork`)并委托 `start`;执行 CC agent 需要 subagent seam 在运行时存在 `fork` 后端。
|
|
45
|
+
- **技能激活由宿主驱动** —— 加载器注册接线与激活描述符;在模型可见的时刻应用它们由宿主负责。
|
package/lib/agents.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mount a Claude Code plugin's sub-agent definitions.
|
|
3
|
+
*
|
|
4
|
+
* Loads `AgentDefinition`s from the plugin's standard `agents/` directory and
|
|
5
|
+
* any inline manifest `agents` paths via the claude-code-agents loader, then
|
|
6
|
+
* registers each as a named subagent provider backing `context: fork`. The
|
|
7
|
+
* provider is a thin forwarder: `start` resolves a named execution backend on
|
|
8
|
+
* the subagent seam (default `fork`) and delegates, overlaying the agent's
|
|
9
|
+
* system prompt, model, and tool restriction. Registration is effect-scoped so
|
|
10
|
+
* unmounting the plugin removes every agent.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import type { AgentDefinition } from '@jianxx/dsh-cc-claude-code-agents';
|
|
15
|
+
import type { CcPluginManifest } from './types.ts';
|
|
16
|
+
import { ComponentTally } from './seams.ts';
|
|
17
|
+
/**
|
|
18
|
+
* Resolve a frontmatter `model` into a dsh `{provider, model}` route at spawn
|
|
19
|
+
* time. Returns `undefined` meaning "no override" (the child inherits the
|
|
20
|
+
* parent's route). When the function is absent, providers keep the historical
|
|
21
|
+
* byte-identical behavior of overlaying the literal model id. The optional
|
|
22
|
+
* fields admit explicit `undefined` (per-field inheritance), matching the
|
|
23
|
+
* `ResolvedRoute` shape from `@jianxx/dsh-cc-model-aliases`.
|
|
24
|
+
*/
|
|
25
|
+
export type ResolveModel = (model: string | undefined) => {
|
|
26
|
+
readonly provider?: string | undefined;
|
|
27
|
+
readonly model?: string | undefined;
|
|
28
|
+
} | undefined;
|
|
29
|
+
/** The subagent seam: a named-provider registry with a backend resolver. */
|
|
30
|
+
export interface SubagentsSeam {
|
|
31
|
+
/**
|
|
32
|
+
* Register a named execution provider.
|
|
33
|
+
* @param provider - the provider to register.
|
|
34
|
+
* @returns the exact disposer that removes the provider.
|
|
35
|
+
*/
|
|
36
|
+
registerProvider(provider: unknown): () => void;
|
|
37
|
+
/** Look up a provider by name, for backend resolution at `start`. */
|
|
38
|
+
getProvider(name: string): unknown | undefined;
|
|
39
|
+
}
|
|
40
|
+
/** The execution backend a CC agent provider forwards to. */
|
|
41
|
+
export interface SubagentBackend {
|
|
42
|
+
/** Start a one-shot child run against a delegation request. */
|
|
43
|
+
start(request: unknown): Promise<unknown>;
|
|
44
|
+
}
|
|
45
|
+
/** A thin forwarder provider: overlays an AgentDefinition and delegates. Exported for the cc-shell bundle's base-agent glue. */
|
|
46
|
+
export declare class AgentProvider implements SubagentBackend {
|
|
47
|
+
private readonly definition;
|
|
48
|
+
private readonly resolve;
|
|
49
|
+
private readonly resolveModel?;
|
|
50
|
+
private readonly backendName;
|
|
51
|
+
constructor(definition: AgentDefinition, resolve: (name: string) => SubagentBackend | undefined, resolveModel?: ResolveModel | undefined);
|
|
52
|
+
/** Register-time provider name; `start` forwards to the backend. */
|
|
53
|
+
get name(): string;
|
|
54
|
+
/** The start-time features this agent's definition requires. */
|
|
55
|
+
get capabilities(): {
|
|
56
|
+
outputSchema: boolean;
|
|
57
|
+
depthLimit: boolean;
|
|
58
|
+
toolFilter: boolean;
|
|
59
|
+
persona: boolean;
|
|
60
|
+
};
|
|
61
|
+
/** Whether the child sees the parent's completed-turn prefix. */
|
|
62
|
+
get inheritsParentContext(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Delegate a delegation request to the resolved backend, overlaying the
|
|
65
|
+
* agent's system prompt, model, and tool restriction.
|
|
66
|
+
* @param request - the delegating request forwarded from the seam.
|
|
67
|
+
* @returns the backend's run handle.
|
|
68
|
+
* @throws when no backend is resolvable (execution depends on the host).
|
|
69
|
+
*/
|
|
70
|
+
start(request: unknown): Promise<unknown>;
|
|
71
|
+
/**
|
|
72
|
+
* Compute the `agentOptions` model override for one spawn.
|
|
73
|
+
*
|
|
74
|
+
* With no resolver injected this is byte-identical to the historical
|
|
75
|
+
* behaviour: overlay the literal frontmatter `model` id. With a resolver
|
|
76
|
+
* injected, the resolver's return is honored directly — a route overlays its
|
|
77
|
+
* defined fields (per-field inheritance preserved by dropping `undefined`),
|
|
78
|
+
* and `undefined` means "no override", so `inherit`/unconfigured-builtin
|
|
79
|
+
* resolve to inheriting the parent route rather than re-overlaying the
|
|
80
|
+
* literal model.
|
|
81
|
+
* @returns the model/provider override, or `undefined` for no override.
|
|
82
|
+
*/
|
|
83
|
+
private resolveModelOverride;
|
|
84
|
+
}
|
|
85
|
+
/** Agents live under this directory in a plugin root, when present. */
|
|
86
|
+
export declare const STANDARD_AGENTS_DIR = "agents";
|
|
87
|
+
/** Options for mounting one plugin's agents. */
|
|
88
|
+
export interface MountAgentsOptions {
|
|
89
|
+
/** The plugin root directory; standard `agents/` resolves against it. */
|
|
90
|
+
readonly pluginRoot: string;
|
|
91
|
+
/** The parsed manifest, whose `agents` paths add extra agent files. */
|
|
92
|
+
readonly manifest: CcPluginManifest;
|
|
93
|
+
/** The subagent seam (probed; `undefined` to skip agents). */
|
|
94
|
+
readonly subagents: SubagentsSeam | undefined;
|
|
95
|
+
/** Optional plugin manifest-name prefix applied to each agent type. */
|
|
96
|
+
readonly namespacePrefix?: string;
|
|
97
|
+
/** Optional spawn-time model resolver threaded into every provider. */
|
|
98
|
+
readonly resolveModel?: ResolveModel;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Load and register a plugin's sub-agent definitions.
|
|
102
|
+
* @param options - plugin root, manifest, and the subagent seam.
|
|
103
|
+
* @returns mounted disposers and per-component counts.
|
|
104
|
+
*/
|
|
105
|
+
export declare function mountAgents(options: MountAgentsOptions): Promise<{
|
|
106
|
+
disposers: (() => void)[];
|
|
107
|
+
tally: ComponentTally;
|
|
108
|
+
}>;
|
|
109
|
+
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE3C;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,CAAA;AAErJ,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,IAAI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AC,SAAS,EAAE,aAAa,GAAG,SAAS,CAAA;IAC7C,uEAAuE;IACvE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,uEAAuE;IACvE,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAA;CACrC;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC;IAAE,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,CAAC,CAmB5H"}
|
package/lib/agents.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mount a Claude Code plugin's sub-agent definitions.
|
|
3
|
+
*
|
|
4
|
+
* Loads `AgentDefinition`s from the plugin's standard `agents/` directory and
|
|
5
|
+
* any inline manifest `agents` paths via the claude-code-agents loader, then
|
|
6
|
+
* registers each as a named subagent provider backing `context: fork`. The
|
|
7
|
+
* provider is a thin forwarder: `start` resolves a named execution backend on
|
|
8
|
+
* the subagent seam (default `fork`) and delegates, overlaying the agent's
|
|
9
|
+
* system prompt, model, and tool restriction. Registration is effect-scoped so
|
|
10
|
+
* unmounting the plugin removes every agent.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import { join, resolve } from 'node:path';
|
|
15
|
+
import { loadAgentsDir } from '@jianxx/dsh-cc-claude-code-agents';
|
|
16
|
+
import { ComponentTally } from "./seams.js";
|
|
17
|
+
/** A thin forwarder provider: overlays an AgentDefinition and delegates. Exported for the cc-shell bundle's base-agent glue. */
|
|
18
|
+
export class AgentProvider {
|
|
19
|
+
definition;
|
|
20
|
+
resolve;
|
|
21
|
+
resolveModel;
|
|
22
|
+
backendName = 'fork';
|
|
23
|
+
constructor(definition, resolve, resolveModel) {
|
|
24
|
+
this.definition = definition;
|
|
25
|
+
this.resolve = resolve;
|
|
26
|
+
this.resolveModel = resolveModel;
|
|
27
|
+
}
|
|
28
|
+
/** Register-time provider name; `start` forwards to the backend. */
|
|
29
|
+
get name() {
|
|
30
|
+
return this.definition.agentType;
|
|
31
|
+
}
|
|
32
|
+
/** The start-time features this agent's definition requires. */
|
|
33
|
+
get capabilities() {
|
|
34
|
+
return {
|
|
35
|
+
outputSchema: false,
|
|
36
|
+
depthLimit: false,
|
|
37
|
+
toolFilter: this.definition.toolRestriction !== undefined,
|
|
38
|
+
persona: this.definition.permissionMode !== undefined || this.definition.isolation !== undefined,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Whether the child sees the parent's completed-turn prefix. */
|
|
42
|
+
get inheritsParentContext() {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Delegate a delegation request to the resolved backend, overlaying the
|
|
47
|
+
* agent's system prompt, model, and tool restriction.
|
|
48
|
+
* @param request - the delegating request forwarded from the seam.
|
|
49
|
+
* @returns the backend's run handle.
|
|
50
|
+
* @throws when no backend is resolvable (execution depends on the host).
|
|
51
|
+
*/
|
|
52
|
+
async start(request) {
|
|
53
|
+
const backend = this.resolve(this.backendName);
|
|
54
|
+
if (backend === undefined) {
|
|
55
|
+
throw new Error(`cc-plugin-loader: no "${this.backendName}" subagent backend is registered to run agent "${this.definition.agentType}"`);
|
|
56
|
+
}
|
|
57
|
+
const delegation = request;
|
|
58
|
+
const modelOverride = this.resolveModelOverride();
|
|
59
|
+
return backend.start({
|
|
60
|
+
...delegation,
|
|
61
|
+
prompt: this.definition.systemPrompt,
|
|
62
|
+
...modelOverride !== undefined
|
|
63
|
+
? { agentOptions: { ...delegation['agentOptions'], ...modelOverride } }
|
|
64
|
+
: {},
|
|
65
|
+
...this.definition.toolRestriction !== undefined ? { toolFilter: this.definition.toolRestriction } : {},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Compute the `agentOptions` model override for one spawn.
|
|
70
|
+
*
|
|
71
|
+
* With no resolver injected this is byte-identical to the historical
|
|
72
|
+
* behaviour: overlay the literal frontmatter `model` id. With a resolver
|
|
73
|
+
* injected, the resolver's return is honored directly — a route overlays its
|
|
74
|
+
* defined fields (per-field inheritance preserved by dropping `undefined`),
|
|
75
|
+
* and `undefined` means "no override", so `inherit`/unconfigured-builtin
|
|
76
|
+
* resolve to inheriting the parent route rather than re-overlaying the
|
|
77
|
+
* literal model.
|
|
78
|
+
* @returns the model/provider override, or `undefined` for no override.
|
|
79
|
+
*/
|
|
80
|
+
resolveModelOverride() {
|
|
81
|
+
const model = this.definition.model;
|
|
82
|
+
const resolver = this.resolveModel;
|
|
83
|
+
if (resolver === undefined) {
|
|
84
|
+
return model !== undefined ? { model } : undefined;
|
|
85
|
+
}
|
|
86
|
+
if (model === undefined)
|
|
87
|
+
return undefined;
|
|
88
|
+
const route = resolver(model);
|
|
89
|
+
if (route === undefined)
|
|
90
|
+
return undefined;
|
|
91
|
+
const out = {};
|
|
92
|
+
if (route.provider !== undefined)
|
|
93
|
+
out.provider = route.provider;
|
|
94
|
+
if (route.model !== undefined)
|
|
95
|
+
out.model = route.model;
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Agents live under this directory in a plugin root, when present. */
|
|
100
|
+
export const STANDARD_AGENTS_DIR = 'agents';
|
|
101
|
+
/**
|
|
102
|
+
* Load and register a plugin's sub-agent definitions.
|
|
103
|
+
* @param options - plugin root, manifest, and the subagent seam.
|
|
104
|
+
* @returns mounted disposers and per-component counts.
|
|
105
|
+
*/
|
|
106
|
+
export async function mountAgents(options) {
|
|
107
|
+
const tally = new ComponentTally('agents');
|
|
108
|
+
const disposers = [];
|
|
109
|
+
if (options.subagents === undefined) {
|
|
110
|
+
tally.addSkipped('subagent seam "subagents" is not mounted');
|
|
111
|
+
return { disposers, tally };
|
|
112
|
+
}
|
|
113
|
+
const definitions = await loadAgentDefinitions(options.pluginRoot, options.manifest);
|
|
114
|
+
if (definitions.length === 0) {
|
|
115
|
+
tally.addSkipped('plugin ships no agents directory or manifest agents paths');
|
|
116
|
+
return { disposers, tally };
|
|
117
|
+
}
|
|
118
|
+
const subagents = options.subagents;
|
|
119
|
+
for (const definition of definitions) {
|
|
120
|
+
const provider = new AgentProvider(definition, name => subagents.getProvider(name), options.resolveModel);
|
|
121
|
+
disposers.push(subagents.registerProvider(provider));
|
|
122
|
+
tally.addLoaded();
|
|
123
|
+
}
|
|
124
|
+
return { disposers, tally };
|
|
125
|
+
}
|
|
126
|
+
/** Load agent definitions from the standard `agents/` dir and manifest paths. */
|
|
127
|
+
async function loadAgentDefinitions(pluginRoot, manifest) {
|
|
128
|
+
const dirs = [join(pluginRoot, STANDARD_AGENTS_DIR)];
|
|
129
|
+
const extra = manifest.agents.map((path) => {
|
|
130
|
+
const resolved = resolve(pluginRoot, path);
|
|
131
|
+
// An inline path may name one `.md`/`.json` file; load its parent dir.
|
|
132
|
+
return /\.(md|json)$/.test(resolved) ? dirname(resolved) : resolved;
|
|
133
|
+
});
|
|
134
|
+
dirs.push(...extra);
|
|
135
|
+
const byName = new Map();
|
|
136
|
+
for (const dir of dirs) {
|
|
137
|
+
for (const agent of await loadAgentsDir(dir, 'project')) {
|
|
138
|
+
byName.set(agent.agentType, agent);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return Array.from(byName.values());
|
|
142
|
+
}
|
|
143
|
+
function dirname(path) {
|
|
144
|
+
const index = path.lastIndexOf('/');
|
|
145
|
+
return index === -1 ? '.' : path.slice(0, index);
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AAGjE,OAAO,EAAE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QAC1C,uEAAuE;QACvE,OAAO,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;IACrE,CAAC,CAAC,CAAA;IACF,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;IACnB,MAAM,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAA;IACjD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,KAAK,MAAM,KAAK,IAAI,MAAM,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC;YACxD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QACpC,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;AACpC,CAAC;AAED,SAAS,OAAO,CAAC,IAAY;IAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACnC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;AAClD,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mount a Claude Code plugin's slash commands.
|
|
3
|
+
*
|
|
4
|
+
* Translates manifest `commands` entries (inline content or a source file) into
|
|
5
|
+
* typed command definitions registered on the commands seam. Each handler
|
|
6
|
+
* returns the command's rendered content, so invoking `/name` surfaces the
|
|
7
|
+
* plugin author's instructions. Registration is effect-scoped.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import type { CcPluginManifest } from './types.ts';
|
|
12
|
+
import { ComponentTally } from './seams.ts';
|
|
13
|
+
/** The commands seam: accepts a typed slash-command definition. */
|
|
14
|
+
export interface CommandsSeam {
|
|
15
|
+
/**
|
|
16
|
+
* Register one command definition.
|
|
17
|
+
* @param definition - the command to register.
|
|
18
|
+
* @returns the exact disposer that removes the command.
|
|
19
|
+
*/
|
|
20
|
+
register(definition: CommandDefinition): () => void;
|
|
21
|
+
}
|
|
22
|
+
/** The minimal typed command definition this loader emits. */
|
|
23
|
+
export interface CommandDefinition {
|
|
24
|
+
/** Lowercase kebab command name. */
|
|
25
|
+
readonly name: string;
|
|
26
|
+
/** Human-readable description. */
|
|
27
|
+
readonly description: string;
|
|
28
|
+
/** Prompts the command's execution (returns content). */
|
|
29
|
+
readonly handler: () => CommandResult | Promise<CommandResult>;
|
|
30
|
+
}
|
|
31
|
+
/** Result shape the loader's command handlers return. */
|
|
32
|
+
export type CommandResult = {
|
|
33
|
+
readonly kind: 'success';
|
|
34
|
+
readonly text?: string;
|
|
35
|
+
};
|
|
36
|
+
/** Commands live under this directory in a plugin root, when present. */
|
|
37
|
+
export declare const STANDARD_COMMANDS_DIR = "commands";
|
|
38
|
+
/** Options for mounting one plugin's commands. */
|
|
39
|
+
export interface MountCommandsOptions {
|
|
40
|
+
/** The plugin root directory; inline `source` paths resolve against it. */
|
|
41
|
+
readonly pluginRoot: string;
|
|
42
|
+
/** The parsed manifest, whose `commands` field drives registration. */
|
|
43
|
+
readonly manifest: CcPluginManifest;
|
|
44
|
+
/** The commands seam (probed; `undefined` to skip commands). */
|
|
45
|
+
readonly commands: CommandsSeam | undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Register a plugin's manifest commands.
|
|
49
|
+
* @param options - plugin root, manifest, and the commands seam.
|
|
50
|
+
* @returns mounted disposers and per-component counts.
|
|
51
|
+
*/
|
|
52
|
+
export declare function mountCommands(options: MountCommandsOptions): {
|
|
53
|
+
disposers: (() => void)[];
|
|
54
|
+
tally: ComponentTally;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
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