@jianxx/dsh-cc-bundle-shell 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 +31 -0
- package/README.zh.md +23 -0
- package/cordis.patch.yml +28 -0
- package/lib/ccPlugins.d.ts +67 -0
- package/lib/ccPlugins.d.ts.map +1 -0
- package/lib/ccPlugins.js +121 -0
- package/lib/ccPlugins.js.map +1 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +84 -0
- package/lib/index.js.map +1 -0
- package/package.json +76 -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/bundle/cc-shell/README.md
|
|
5
|
+
README.md: ba7e9d6a16f2b92b8515696f12214f0277a7113f
|
|
6
|
+
README.zh.md: 320b7ce6a665591e0744a206ff57db5f4a50c41a
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# dsh-cc-bundle-shell
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
The CC shell **host-plane infra** bundle. This package carries the pieces that are genuinely host-level — the tools-registry swap with deferred-name support, and the settings-migrations mechanism — plus the `cc-shell-glue` plugin *code* (the glue code still lives here, but its mount action is performed by the CC preset, not this bundle's patch). All agent-facing composition — tool-search, skill loader, memory, coordinator, worktree/sleep/notebook/structured-output tools, the 19 slash commands, the hook bridge, output-style rendering — moved to the [`@jianxx/dsh-cc-preset-cc`](../../preset/cc/README.md) composition package, so it can be isolated per preset instead of leaking into every mode.
|
|
6
|
+
|
|
7
|
+
## What it does
|
|
8
|
+
|
|
9
|
+
- **Tools registry swap.** Disables the in-box `tools` row and remounts `@jianxx/dsh-cc-tools`. `reserve()`/`isAdmitted()` join the restrictable-name universe, so permission gates can name deferred tools before they load; the shipped behavior otherwise matches upstream. The base row's `DSH_TOOLS_MODE` toggle is carried forward ($DSH_HOME / process.cwd() semantics unchanged).
|
|
10
|
+
- **Settings migrations.** Mounts `@jianxx/dsh-cc-settings-migrations` to apply version-gated `settings.json` migrations at startup (equivalent to CC's `runMigrations`). Empty registry — mechanism only — for now.
|
|
11
|
+
- **Glue plugin code (mounted by the CC preset).** `cc-shell-glue` mounts what a cordis patch row cannot express statically: on-disk Claude Code plugin directories (each holding `plugin.json`, providing agents/skills/commands/hooks/mcp servers) and `.mcp.json` server wiring. Discovery is best-effort — every absent path mounts nothing. It also exposes the `ccPlugins` service for live enumeration/rescan of mounted plugins. The glue threads the spawn-time `resolveModel` into `AgentProvider` as a
|
|
12
|
+
**lazy trampoline** over the `ccModelRoutes` service:
|
|
13
|
+
`(model) => ctx.get('ccModelRoutes')?.resolve(model)` — queried on every spawn, degrading to
|
|
14
|
+
inherit the parent route when the service is unmounted.
|
|
15
|
+
|
|
16
|
+
### What moved out of the glue
|
|
17
|
+
|
|
18
|
+
Two pieces that used to live in `cc-shell-glue` moved to their owning packages:
|
|
19
|
+
|
|
20
|
+
- **`model-aliases` settings-namespace registration** → the `@jianxx/dsh-cc-model-aliases`
|
|
21
|
+
`ccModelRoutes` service (`packages/compat/cc-model-aliases`). The glue no longer registers
|
|
22
|
+
the namespace (a duplicate registration would throw); it only consumes the service lazily.
|
|
23
|
+
`Config.modelAliases` was removed from the glue config.
|
|
24
|
+
- **Base CC-agent discovery** (`~/.claude/agents` + `<cwd>/.claude/agents` → subagent
|
|
25
|
+
providers) → the `@jianxx/dsh-cc-subagent-task` Task tool, which discovers per the **session**
|
|
26
|
+
cwd (not the host process cwd). `Config.registerBaseAgents` was removed.
|
|
27
|
+
|
|
28
|
+
## Known limits / notes
|
|
29
|
+
|
|
30
|
+
- This bundle no longer globally mounts any agent-facing surface. Only the host-plane infra rows (tools registry swap + settings-migrations) are mounted by this bundle's `cordis.patch.yml`; the glue plugin and all agent surfaces are mounted by `@jianxx/dsh-cc-preset-cc` so they stay scoped to that preset.
|
|
31
|
+
- Because the tool-web executor row is unshipped by the CLI dependency tree through rc.6, fetch-based web tooling is mounted by the preset, not here; see the preset's "Known limits" for the current fetch status.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# dsh-cc-bundle-shell
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
CC 壳层的 **host-plane infra** 组合包。本包承载真正属于宿主层的部件——带 deferred-name 支持的 tools 注册表替换、settings-migrations 机制——以及 `cc-shell-glue` 插件的*代码*(glue 代码仍住在这里,但挂载动作由 CC preset 执行,而非本包的 patch)。所有 agent-face 组合——tool-search、skill loader、memory、coordinator、worktree/sleep/notebook/structured-output 工具、19 个斜杠命令、hook 桥、output-style 渲染——都已迁至 [`@jianxx/dsh-cc-preset-cc`](../../preset/cc/README.md) 组合包,以便按 preset 隔离,而不是泄漏进每个模式。
|
|
6
|
+
|
|
7
|
+
## 作用
|
|
8
|
+
|
|
9
|
+
- **tools 注册表替换。** 禁用 in-box 的 `tools` 行,重挂 `@jianxx/dsh-cc-tools`。`reserve()`/`isAdmitted()` 加入可限制名 universe,权限门可在 deferred 工具加载前按名门控;其余行为与上游一致。基础行的 `DSH_TOOLS_MODE` 开关被延续($DSH_HOME / process.cwd() 语义不变)。
|
|
10
|
+
- **settings 迁移。** 挂载 `@jianxx/dsh-cc-settings-migrations`,在启动时应用版本门控的 `settings.json` 迁移(等价于 CC 的 `runMigrations`)。当前为空注册表——仅机制。
|
|
11
|
+
- **glue 插件代码(由 CC preset 挂载)。** `cc-shell-glue` 挂载 cordis patch 行无法静态表达的部件:磁盘上的 Claude Code 插件目录(每个含 `plugin.json`,提供 agents/skills/commands/hooks/mcp servers)与 `.mcp.json` server 接线。发现为尽力而为——每个缺失路径都只是不挂载任何东西。它还暴露 `ccPlugins` 服务,用于对已挂载插件做实时枚举/重扫。glue 以 **惰性 trampoline** 基于 `ccModelRoutes` 服务把派发时的 `resolveModel` 接入 `AgentProvider`:`(model) => ctx.get('ccModelRoutes')?.resolve(model)`——每次派发查询,服务未挂载时降级为继承父路由。
|
|
12
|
+
|
|
13
|
+
### 从 glue 迁出的部分
|
|
14
|
+
|
|
15
|
+
两个原本住在 `cc-shell-glue` 里的部件迁到了各自的属主包:
|
|
16
|
+
|
|
17
|
+
- **`model-aliases` settings 命名空间注册** → `@jianxx/dsh-cc-model-aliases` 的 `ccModelRoutes` 服务(`packages/compat/cc-model-aliases`)。glue 不再注册该命名空间(重复注册会 throw),只惰性消费服务。glue config 的 `Config.modelAliases` 已删除。
|
|
18
|
+
- **基础 CC-agent 发现**(`~/.claude/agents` + `<cwd>/.claude/agents` → subagent providers)→ `@jianxx/dsh-cc-subagent-task` 的 Task 工具,它按**会话** cwd(而非宿主进程 cwd)发现。`Config.registerBaseAgents` 已删除。
|
|
19
|
+
|
|
20
|
+
## 已知限制 / 说明
|
|
21
|
+
|
|
22
|
+
- 本包不再全局挂载任何 agent-face 表面。只有 host-plane infra 行(tools 注册表替换 + settings-migrations)由本包的 `cordis.patch.yml` 挂载;glue 插件与所有 agent 表面由 `@jianxx/dsh-cc-preset-cc` 挂载,从而限定在该 preset 内。
|
|
23
|
+
- 由于 tool-web executor 行在 rc.6 之前未被 CLI 依赖树携带,基于 fetch 的 web 工具由 preset 挂载而非此处;当前 fetch 状态见 preset 的「已知限制」。
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# CC shell host-plane infra swap: the tools registry (deferred-name support)
|
|
2
|
+
# plus settings migrations. Everything agent-facing (tool-search, skill-loader,
|
|
3
|
+
# glue-driven hooks/commands, memory, coordinator, worktree/sleep/notebook/
|
|
4
|
+
# structured-output tools, 19 slash commands, the hook bridge) moved to
|
|
5
|
+
# packages/preset/cc. Rationale: globally registered tools/commands/system-prompt/
|
|
6
|
+
# skills mounted here leak into every agent preset; preset-izing them is what
|
|
7
|
+
# isolates each surface. glue plugin code still lives here but is mounted by the
|
|
8
|
+
# CC preset, not this bundle.
|
|
9
|
+
|
|
10
|
+
# Swap the in-box tool registry for the vendored one. reserve()/isAdmitted()
|
|
11
|
+
# join the restrictable-name universe so permission gates may name deferred
|
|
12
|
+
# tools before they load; the shipped behavior otherwise matches upstream.
|
|
13
|
+
- id: tools
|
|
14
|
+
disabled: true
|
|
15
|
+
|
|
16
|
+
- insert:
|
|
17
|
+
# Remount below (in the insert list) with fetch enabled and the fetch provider.
|
|
18
|
+
- id: tools-cc
|
|
19
|
+
name: '@jianxx/dsh-cc-tools'
|
|
20
|
+
config:
|
|
21
|
+
# Carry the base tools row's DSH_TOOLS_MODE toggle forward (dsh-web-app
|
|
22
|
+
# patches `tools` with it). Absent env ⇒ undefined, the established semantics.
|
|
23
|
+
mode: !!js process.env.DSH_TOOLS_MODE
|
|
24
|
+
|
|
25
|
+
# Settings migrations: apply version-gated settings.json migrations at startup
|
|
26
|
+
# (equivalent to CC's runMigrations). Empty registry — mechanism only — for now.
|
|
27
|
+
- id: settings-migrations
|
|
28
|
+
name: '@jianxx/dsh-cc-settings-migrations'
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin-mount registry for the cc-shell glue plugin.
|
|
3
|
+
*
|
|
4
|
+
* Tracks every Claude Code plugin directory the glue mounts (keyed by plugin
|
|
5
|
+
* root) and exposes a `ccPlugins` service so host plugins — slash commands such
|
|
6
|
+
* as `/plugin`, `/reload-plugins`, `/mcp` — can enumerate what is mounted and
|
|
7
|
+
* rescan the on-disk discovery roots live. Rescan disposes all tracked mounts
|
|
8
|
+
* in reverse mount order (the innermost/last-mounted tear down first) and then
|
|
9
|
+
* re-runs the same best-effort discovery the glue performs at activation,
|
|
10
|
+
* collecting per-plugin failures without aborting the rest.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import { Service, type Context } from '@deepseek-ai/cordis';
|
|
15
|
+
import { type PluginLoadReport, type ResolveModel } from '@jianxx/dsh-cc-plugin-loader';
|
|
16
|
+
declare module '@deepseek-ai/cordis' {
|
|
17
|
+
interface Context {
|
|
18
|
+
/** The mounted Claude Code plugin registry, when cc-shell-glue is composed. */
|
|
19
|
+
ccPlugins: CcPluginsService;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** A tracked plugin mount's public summary. */
|
|
23
|
+
export interface CcPluginSummary {
|
|
24
|
+
/** The plugin's manifest name. */
|
|
25
|
+
name: string;
|
|
26
|
+
/** The plugin root directory holding `plugin.json`. */
|
|
27
|
+
root: string;
|
|
28
|
+
/** Per-component load outcome. */
|
|
29
|
+
components: PluginLoadReport['components'];
|
|
30
|
+
}
|
|
31
|
+
/** One failure (or dispose error) surfaced from a rescan, keyed by plugin root. */
|
|
32
|
+
export interface CcPluginRescanError {
|
|
33
|
+
/** The plugin root that failed to mount (or whose mount failed to dispose). */
|
|
34
|
+
root: string;
|
|
35
|
+
/** The manifest name, when a mount was disposed and the manifest was known. */
|
|
36
|
+
name?: string;
|
|
37
|
+
/** The error message. */
|
|
38
|
+
error: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The `ccPlugins` service: enumerate and rescan the mounted Claude Code plugins.
|
|
42
|
+
*/
|
|
43
|
+
export declare class CcPluginsService extends Service {
|
|
44
|
+
private readonly pluginDirs;
|
|
45
|
+
private readonly resolveModel?;
|
|
46
|
+
/** Live mounts keyed by plugin root directory. */
|
|
47
|
+
private readonly mounts;
|
|
48
|
+
constructor(ctx: Context, pluginDirs: readonly string[], resolveModel?: ResolveModel | undefined);
|
|
49
|
+
/** The discovered plugin roots for every configured discovery root. */
|
|
50
|
+
private discover;
|
|
51
|
+
/** Mount one plugin root and track it; never throws (failures are logged). */
|
|
52
|
+
private mountOne;
|
|
53
|
+
/**
|
|
54
|
+
* Discover and mount every configured plugin root. Returns per-plugin
|
|
55
|
+
* failures without halting the remaining roots.
|
|
56
|
+
*/
|
|
57
|
+
mountAll(): Promise<CcPluginRescanError[]>;
|
|
58
|
+
/** Enumerate the currently mounted plugins. */
|
|
59
|
+
list(): CcPluginSummary[];
|
|
60
|
+
/**
|
|
61
|
+
* Dispose all tracked mounts in reverse mount order, then re-run discovery
|
|
62
|
+
* and mount from the same roots. Individual failures are collected and the
|
|
63
|
+
* remaining plugins still mount.
|
|
64
|
+
*/
|
|
65
|
+
rescan(): Promise<CcPluginRescanError[]>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=ccPlugins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ccPlugins.d.ts","sourceRoot":"","sources":["../src/ccPlugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAiB,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAEtG,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf,+EAA+E;QAC/E,SAAS,EAAE,gBAAgB,CAAA;KAC5B;CACF;AAED,+CAA+C;AAC/C,MAAM,WAAW,eAAe;IAC9B,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAA;IACZ,kCAAkC;IAClC,UAAU,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAA;CAC3C;AAED,mFAAmF;AACnF,MAAM,WAAW,mBAAmB;IAClC,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAA;IACZ,+EAA+E;IAC/E,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAA;CACd;AAYD;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,OAAO;IAMzC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IANhC,kDAAkD;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkC;gBAGvD,GAAG,EAAE,OAAO,EACK,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,YAAY,CAAC,EAAE,YAAY,YAAA;IAK9C,uEAAuE;IACvE,OAAO,CAAC,QAAQ;IAqBhB,8EAA8E;YAChE,QAAQ;IAoBtB;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAShD,+CAA+C;IAC/C,IAAI,IAAI,eAAe,EAAE;IAQzB;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;CAiB/C"}
|
package/lib/ccPlugins.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin-mount registry for the cc-shell glue plugin.
|
|
3
|
+
*
|
|
4
|
+
* Tracks every Claude Code plugin directory the glue mounts (keyed by plugin
|
|
5
|
+
* root) and exposes a `ccPlugins` service so host plugins — slash commands such
|
|
6
|
+
* as `/plugin`, `/reload-plugins`, `/mcp` — can enumerate what is mounted and
|
|
7
|
+
* rescan the on-disk discovery roots live. Rescan disposes all tracked mounts
|
|
8
|
+
* in reverse mount order (the innermost/last-mounted tear down first) and then
|
|
9
|
+
* re-runs the same best-effort discovery the glue performs at activation,
|
|
10
|
+
* collecting per-plugin failures without aborting the rest.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
15
|
+
import { join } from 'node:path';
|
|
16
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
17
|
+
import { mountCcPlugin } from '@jianxx/dsh-cc-plugin-loader';
|
|
18
|
+
/**
|
|
19
|
+
* The `ccPlugins` service: enumerate and rescan the mounted Claude Code plugins.
|
|
20
|
+
*/
|
|
21
|
+
export class CcPluginsService extends Service {
|
|
22
|
+
pluginDirs;
|
|
23
|
+
resolveModel;
|
|
24
|
+
/** Live mounts keyed by plugin root directory. */
|
|
25
|
+
mounts = new Map();
|
|
26
|
+
constructor(ctx, pluginDirs, resolveModel) {
|
|
27
|
+
super(ctx, 'ccPlugins');
|
|
28
|
+
this.pluginDirs = pluginDirs;
|
|
29
|
+
this.resolveModel = resolveModel;
|
|
30
|
+
}
|
|
31
|
+
/** The discovered plugin roots for every configured discovery root. */
|
|
32
|
+
discover() {
|
|
33
|
+
const roots = [];
|
|
34
|
+
for (const root of this.pluginDirs) {
|
|
35
|
+
if (!existsSync(root))
|
|
36
|
+
continue;
|
|
37
|
+
if (existsSync(join(root, 'plugin.json'))) {
|
|
38
|
+
roots.push(root);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
43
|
+
if (entry.isDirectory() && existsSync(join(root, entry.name, 'plugin.json'))) {
|
|
44
|
+
roots.push(join(root, entry.name));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Best-effort discovery: an unreadable discovery root mounts nothing.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return roots;
|
|
53
|
+
}
|
|
54
|
+
/** Mount one plugin root and track it; never throws (failures are logged). */
|
|
55
|
+
async mountOne(dir) {
|
|
56
|
+
try {
|
|
57
|
+
const mounted = await mountCcPlugin(this.ctx, {
|
|
58
|
+
root: dir,
|
|
59
|
+
...this.resolveModel !== undefined ? { resolveModel: this.resolveModel } : {},
|
|
60
|
+
});
|
|
61
|
+
this.mounts.set(dir, {
|
|
62
|
+
root: dir,
|
|
63
|
+
name: mounted.report.name,
|
|
64
|
+
dispose: mounted.dispose,
|
|
65
|
+
report: mounted.report,
|
|
66
|
+
});
|
|
67
|
+
return { ok: true };
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
const message = String(error);
|
|
71
|
+
this.ctx.logger.warn(`cc-shell-glue: failed to mount CC plugin at ${dir}: ${message}`);
|
|
72
|
+
return { ok: false, error: message };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Discover and mount every configured plugin root. Returns per-plugin
|
|
77
|
+
* failures without halting the remaining roots.
|
|
78
|
+
*/
|
|
79
|
+
async mountAll() {
|
|
80
|
+
const errors = [];
|
|
81
|
+
for (const dir of this.discover()) {
|
|
82
|
+
const result = await this.mountOne(dir);
|
|
83
|
+
if (!result.ok)
|
|
84
|
+
errors.push({ root: dir, error: result.error });
|
|
85
|
+
}
|
|
86
|
+
return errors;
|
|
87
|
+
}
|
|
88
|
+
/** Enumerate the currently mounted plugins. */
|
|
89
|
+
list() {
|
|
90
|
+
return Array.from(this.mounts.values()).map(mount => ({
|
|
91
|
+
name: mount.name,
|
|
92
|
+
root: mount.root,
|
|
93
|
+
components: mount.report.components,
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Dispose all tracked mounts in reverse mount order, then re-run discovery
|
|
98
|
+
* and mount from the same roots. Individual failures are collected and the
|
|
99
|
+
* remaining plugins still mount.
|
|
100
|
+
*/
|
|
101
|
+
async rescan() {
|
|
102
|
+
const errors = [];
|
|
103
|
+
const tracked = Array.from(this.mounts.values()).reverse();
|
|
104
|
+
this.mounts.clear();
|
|
105
|
+
for (const mount of tracked) {
|
|
106
|
+
try {
|
|
107
|
+
mount.dispose();
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
errors.push({ root: mount.root, name: mount.name, error: String(error) });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (const dir of this.discover()) {
|
|
114
|
+
const result = await this.mountOne(dir);
|
|
115
|
+
if (!result.ok)
|
|
116
|
+
errors.push({ root: dir, error: result.error });
|
|
117
|
+
}
|
|
118
|
+
return errors;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=ccPlugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ccPlugins.js","sourceRoot":"","sources":["../src/ccPlugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAgB,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,aAAa,EAA4C,MAAM,8BAA8B,CAAA;AAuCtG;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,OAAO;IAMxB;IACA;IANnB,kDAAkD;IACjC,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAA;IAEzD,YACE,GAAY,EACK,UAA6B,EAC7B,YAA2B;QAE5C,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;QAHN,eAAU,GAAV,UAAU,CAAmB;QAC7B,iBAAY,GAAZ,YAAY,CAAe;IAG9C,CAAC;IAED,uEAAuE;IAC/D,QAAQ;QACd,MAAM,KAAK,GAAa,EAAE,CAAA;QAC1B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACnC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;gBAAE,SAAQ;YAC/B,IAAI,UAA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CAAC;YAC5B,IAAI,CAAC;gBACH,KAAK,CAAC,OAAO,EAAE,CAAA;YACjB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YAC3E,CAAC;QACH,CAAC;QACD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;YAClC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;YACvC,IAAI,CAAC,MAAM,CAAC,EAAE;gBAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;QACjE,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Glue plugin for the cc-shell bundle: mounts the things cordis patch rows
|
|
3
|
+
* cannot express statically — Claude Code plugin directories on disk and MCP
|
|
4
|
+
* server configs from `.mcp.json`. Base CC-agent discovery moved to the
|
|
5
|
+
* subagent/task package (per-workspace), and the `model-aliases` namespace is
|
|
6
|
+
* owned by the `@jianxx/dsh-cc-model-aliases` routes service. Discovery is
|
|
7
|
+
* best-effort: every absent path simply mounts nothing.
|
|
8
|
+
*
|
|
9
|
+
* @module @jianxx/dsh-cc-bundle-shell
|
|
10
|
+
*/
|
|
11
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
+
import z from '@deepseek-ai/schemastery';
|
|
13
|
+
/** Plugin config: which on-disk CC surfaces to mount. */
|
|
14
|
+
export interface Config {
|
|
15
|
+
/** Directories that each carry a plugin.json (Claude Code plugins). */
|
|
16
|
+
pluginDirs?: string[];
|
|
17
|
+
/** `.mcp.json` documents whose accepted servers become mcp-client instances. */
|
|
18
|
+
mcpConfigFiles?: string[];
|
|
19
|
+
}
|
|
20
|
+
/** Runtime config schema (all fields optional; discovery prefers explicit lists). */
|
|
21
|
+
export declare const Config: z<Config>;
|
|
22
|
+
/** Cordis plugin id. */
|
|
23
|
+
export declare const name = "cc-shell-glue";
|
|
24
|
+
/**
|
|
25
|
+
* Mount the discovered CC surfaces. Each piece is effect-scoped where the
|
|
26
|
+
* underlying loader supports it.
|
|
27
|
+
* @param ctx - the plug context.
|
|
28
|
+
* @param config - discovery configuration.
|
|
29
|
+
*/
|
|
30
|
+
export declare function apply(ctx: Context, config: Config): Promise<void>;
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAMxC,yDAAyD;AACzD,MAAM,WAAW,MAAM;IACrB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;CAC1B;AAED,qFAAqF;AACrF,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAG3B,CAAA;AAEF,wBAAwB;AACxB,eAAO,MAAM,IAAI,kBAAkB,CAAA;AAgBnC;;;;;GAKG;AACH,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0CvE"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Glue plugin for the cc-shell bundle: mounts the things cordis patch rows
|
|
3
|
+
* cannot express statically — Claude Code plugin directories on disk and MCP
|
|
4
|
+
* server configs from `.mcp.json`. Base CC-agent discovery moved to the
|
|
5
|
+
* subagent/task package (per-workspace), and the `model-aliases` namespace is
|
|
6
|
+
* owned by the `@jianxx/dsh-cc-model-aliases` routes service. Discovery is
|
|
7
|
+
* best-effort: every absent path simply mounts nothing.
|
|
8
|
+
*
|
|
9
|
+
* @module @jianxx/dsh-cc-bundle-shell
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
import { homedir } from 'node:os';
|
|
14
|
+
import z from '@deepseek-ai/schemastery';
|
|
15
|
+
import { buildRegistrations } from '@jianxx/dsh-cc-mcp-config';
|
|
16
|
+
import * as CcMcpClient from '@jianxx/dsh-cc-mcp-client';
|
|
17
|
+
import { CcPluginsService } from "./ccPlugins.js";
|
|
18
|
+
/** Runtime config schema (all fields optional; discovery prefers explicit lists). */
|
|
19
|
+
export const Config = z.object({
|
|
20
|
+
pluginDirs: z.array(z.string()),
|
|
21
|
+
mcpConfigFiles: z.array(z.string()),
|
|
22
|
+
});
|
|
23
|
+
/** Cordis plugin id. */
|
|
24
|
+
export const name = 'cc-shell-glue';
|
|
25
|
+
/** Default `.mcp.json` locations: project, then user-home Claude space. */
|
|
26
|
+
function defaultMcpFiles() {
|
|
27
|
+
return [
|
|
28
|
+
join(process.cwd(), '.mcp.json'),
|
|
29
|
+
join(homedir(), '.claude', '.mcp.json'),
|
|
30
|
+
join(homedir(), '.claude.json'),
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
/** Default Claude Code plugin roots: the user's enabled-plugins dir. */
|
|
34
|
+
function defaultPluginDirs() {
|
|
35
|
+
return [join(homedir(), '.claude', 'plugins')];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Mount the discovered CC surfaces. Each piece is effect-scoped where the
|
|
39
|
+
* underlying loader supports it.
|
|
40
|
+
* @param ctx - the plug context.
|
|
41
|
+
* @param config - discovery configuration.
|
|
42
|
+
*/
|
|
43
|
+
export async function apply(ctx, config) {
|
|
44
|
+
const results = [];
|
|
45
|
+
// The spawn-time model resolver is provided by the `@jianxx/dsh-cc-model-aliases`
|
|
46
|
+
// routes service (`ccModelRoutes`). Query it lazily on every spawn so mount
|
|
47
|
+
// order doesn't matter and an unmounted routes service degrades to inherit.
|
|
48
|
+
const resolveModel = (model) => ctx.get('ccModelRoutes')?.resolve(model);
|
|
49
|
+
// 1. Claude Code plugins (each dir = one plugin root holding plugin.json).
|
|
50
|
+
// The CcPluginsService tracks every mount so host plugins can enumerate
|
|
51
|
+
// and rescan; mountAll performs the same best-effort discovery the glue
|
|
52
|
+
// always performed, tolerating any number of absent/invalid roots.
|
|
53
|
+
const pluginDirs = config.pluginDirs ?? defaultPluginDirs();
|
|
54
|
+
const plugins = new CcPluginsService(ctx, pluginDirs, resolveModel);
|
|
55
|
+
const pluginErrors = await plugins.mountAll();
|
|
56
|
+
for (const { root, error } of pluginErrors) {
|
|
57
|
+
ctx.logger.warn(`cc-shell-glue: failed to mount CC plugin at ${root}: ${error}`);
|
|
58
|
+
}
|
|
59
|
+
for (const summary of plugins.list()) {
|
|
60
|
+
const tallies = summary.components;
|
|
61
|
+
const loaded = tallies.reduce((n, c) => n + c.loaded, 0);
|
|
62
|
+
const skipped = tallies.reduce((n, c) => n + c.skipped, 0);
|
|
63
|
+
results.push(`cc-plugin ${summary.name}: ${loaded} loaded/${skipped} skipped`);
|
|
64
|
+
}
|
|
65
|
+
// 2. `.mcp.json` documents → per-server @jianxx/dsh-cc-mcp-client instances.
|
|
66
|
+
for (const file of config.mcpConfigFiles ?? defaultMcpFiles()) {
|
|
67
|
+
if (!existsSync(file))
|
|
68
|
+
continue;
|
|
69
|
+
try {
|
|
70
|
+
const body = JSON.parse(readFileSync(file, 'utf8'));
|
|
71
|
+
const registrations = buildRegistrations(body, { env: process.env });
|
|
72
|
+
for (const server of registrations) {
|
|
73
|
+
await ctx.plugin(CcMcpClient, server);
|
|
74
|
+
results.push(`mcp server ${server.serverName} mounted from ${file}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
ctx.logger.warn(`cc-shell-glue: failed to mount MCP config ${file}: ${String(error)}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (results.length > 0)
|
|
82
|
+
ctx.logger.info(`cc-shell-glue: mounted — ${results.join('; ')}`);
|
|
83
|
+
}
|
|
84
|
+
//# 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;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,OAAO,EAAE,kBAAkB,EAAsB,MAAM,2BAA2B,CAAA;AAClF,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAUjD,qFAAqF;AACrF,MAAM,CAAC,MAAM,MAAM,GAAc,CAAC,CAAC,MAAM,CAAC;IACxC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC/B,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CACpC,CAAC,CAAA;AAEF,wBAAwB;AACxB,MAAM,CAAC,MAAM,IAAI,GAAG,eAAe,CAAA;AAEnC,2EAA2E;AAC3E,SAAS,eAAe;IACtB,OAAO;QACL,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC;QAChC,IAAI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+
{
|
|
2
|
+
"name": "@jianxx/dsh-cc-bundle-shell",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CC shell host-plane infra: tools registry swap (deferred-name support) + settings migrations; the glue plugin code lives here but is mounted by the CC preset (packages/preset/cc)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"lib",
|
|
10
|
+
"cordis.patch.yml"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./lib/index.d.ts",
|
|
15
|
+
"default": "./lib/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
18
|
+
"./src/*": "./src/*",
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"dsh": {
|
|
22
|
+
"bundle": {
|
|
23
|
+
"patch": "./cordis.patch.yml"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/jianxx/dsh-cc-plugins.git",
|
|
29
|
+
"directory": "packages/bundle/cc-shell"
|
|
30
|
+
},
|
|
31
|
+
"license": "Apache-2.0",
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@deepseek-ai/cordis": ">=0.1.1-rc.2",
|
|
34
|
+
"@deepseek-ai/dsh-settings": ">=0.1.1-rc.2"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@jianxx/dsh-cc-claude-code-agents": "^0.1.0",
|
|
38
|
+
"@jianxx/dsh-cc-plugin-loader": "^0.1.0",
|
|
39
|
+
"@jianxx/dsh-cc-mcp-client": "^0.1.0",
|
|
40
|
+
"@jianxx/dsh-cc-model-aliases": "^0.1.0",
|
|
41
|
+
"@jianxx/dsh-cc-mcp-config": "^0.1.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@deepseek-ai/dsh-settings": "link:../../../../deepseek-harness/packages/settings/settings",
|
|
45
|
+
"@deepseek-ai/cordis": "link:../../../../deepseek-harness/vendor/cordis",
|
|
46
|
+
"@deepseek-ai/cordis-plugin-loader": "link:../../../../deepseek-harness/vendor/loader",
|
|
47
|
+
"@deepseek-ai/schemastery": "link:../../../../deepseek-harness/vendor/schemastery",
|
|
48
|
+
"@deepseek-ai/dsh-agent": "link:../../../../deepseek-harness/packages/core/agent",
|
|
49
|
+
"@deepseek-ai/dsh-agent-loop": "link:../../../../deepseek-harness/packages/core/agent-loop",
|
|
50
|
+
"@deepseek-ai/dsh-agent-loop-testkit": "link:../../../../deepseek-harness/packages/test-support/agent-loop-testkit",
|
|
51
|
+
"@deepseek-ai/dsh-llm": "link:../../../../deepseek-harness/packages/llm/llm",
|
|
52
|
+
"@deepseek-ai/dsh-schedule": "link:../../../../deepseek-harness/packages/schedule/schedule",
|
|
53
|
+
"@deepseek-ai/dsh-session": "link:../../../../deepseek-harness/packages/core/session",
|
|
54
|
+
"@deepseek-ai/dsh-subagent": "link:../../../../deepseek-harness/packages/subagent/subagent",
|
|
55
|
+
"@deepseek-ai/dsh-system-prompt": "link:../../../../deepseek-harness/packages/core/system-prompt",
|
|
56
|
+
"@deepseek-ai/dsh-tool-web": "link:../../../../deepseek-harness/packages/web/tool-web",
|
|
57
|
+
"@deepseek-ai/dsh-tools": "link:../../../../deepseek-harness/packages/core/tools",
|
|
58
|
+
"@deepseek-ai/dsh-tool-ask-user": "link:../../../../deepseek-harness/packages/interaction/tool-ask-user",
|
|
59
|
+
"@deepseek-ai/dsh-user-questions": "link:../../../../deepseek-harness/packages/interaction/user-questions",
|
|
60
|
+
"@deepseek-ai/dsh-lsp": "link:../../../../deepseek-harness/packages/lsp/lsp",
|
|
61
|
+
"@deepseek-ai/dsh-lsp-stdio": "link:../../../../deepseek-harness/packages/lsp/lsp-stdio",
|
|
62
|
+
"@deepseek-ai/dsh-tool-lsp": "link:../../../../deepseek-harness/packages/lsp/tool-lsp",
|
|
63
|
+
"@deepseek-ai/dsh-web": "link:../../../../deepseek-harness/packages/web/web",
|
|
64
|
+
"@deepseek-ai/dsh-web-fetch-http": "link:../../../../deepseek-harness/packages/web/web-fetch-http",
|
|
65
|
+
"typescript": "6.0.3",
|
|
66
|
+
"@deepseek-ai/dsh-fs-local": "link:../../../../deepseek-harness/packages/fs/fs-local",
|
|
67
|
+
"@jianxx/dsh-cc-tools": "^0.1.0",
|
|
68
|
+
"@jianxx/dsh-cc-tool-notebook-edit": "^0.1.0",
|
|
69
|
+
"@jianxx/dsh-cc-tool-sleep": "^0.1.0",
|
|
70
|
+
"@jianxx/dsh-cc-settings-migrations": "^0.1.0",
|
|
71
|
+
"@jianxx/dsh-cc-tool-structured-output": "^0.1.0"
|
|
72
|
+
},
|
|
73
|
+
"publishConfig": {
|
|
74
|
+
"access": "public"
|
|
75
|
+
}
|
|
76
|
+
}
|