crewcode-plugin-cli 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 +202 -0
- package/README.md +39 -0
- package/bin/crewcode.mjs +388 -0
- package/package.json +40 -0
- package/templates/plugins/README.md +25 -0
- package/templates/plugins/browser-docs-grabber/crewcode-plugin-api.js +80 -0
- package/templates/plugins/browser-docs-grabber/crewcode.plugin.json +13 -0
- package/templates/plugins/browser-docs-grabber/panel.html +1 -0
- package/templates/plugins/browser-docs-grabber/plugin.js +1 -0
- package/templates/plugins/codebase-graph-lite/crewcode-plugin-api.js +80 -0
- package/templates/plugins/codebase-graph-lite/crewcode.plugin.json +57 -0
- package/templates/plugins/codebase-graph-lite/panel.html +53 -0
- package/templates/plugins/codebase-graph-lite/plugin.js +49 -0
- package/templates/plugins/company-agent-http-adapter/crewcode-plugin-api.js +80 -0
- package/templates/plugins/company-agent-http-adapter/crewcode.plugin.json +24 -0
- package/templates/plugins/company-agent-http-adapter/panel.html +1 -0
- package/templates/plugins/company-agent-http-adapter/plugin.js +1 -0
- package/templates/plugins/company-agent-http-adapter/server.mjs +27 -0
- package/templates/plugins/git-risk-lens/crewcode-plugin-api.js +80 -0
- package/templates/plugins/git-risk-lens/crewcode.plugin.json +13 -0
- package/templates/plugins/git-risk-lens/panel.html +1 -0
- package/templates/plugins/git-risk-lens/plugin.js +2 -0
- package/templates/plugins/github-copilot-cli-provider/crewcode-plugin-api.js +80 -0
- package/templates/plugins/github-copilot-cli-provider/crewcode.plugin.json +42 -0
- package/templates/plugins/github-copilot-cli-provider/panel.html +1 -0
- package/templates/plugins/github-copilot-cli-provider/plugin.js +1 -0
- package/templates/plugins/handoff-pack/crewcode-plugin-api.js +80 -0
- package/templates/plugins/handoff-pack/crewcode.plugin.json +72 -0
- package/templates/plugins/handoff-pack/panel.html +63 -0
- package/templates/plugins/handoff-pack/plugin.js +156 -0
- package/templates/plugins/mcp-server-template/README.md +22 -0
- package/templates/plugins/mcp-server-template/crewcode-plugin-api.js +80 -0
- package/templates/plugins/mcp-server-template/crewcode.plugin.json +30 -0
- package/templates/plugins/mcp-server-template/panel.html +25 -0
- package/templates/plugins/mcp-server-template/plugin.js +9 -0
- package/templates/plugins/mcp-server-template/server.mjs +30 -0
- package/templates/plugins/mission-ci-widget/crewcode-plugin-api.js +80 -0
- package/templates/plugins/mission-ci-widget/crewcode.plugin.json +13 -0
- package/templates/plugins/mission-ci-widget/panel.html +1 -0
- package/templates/plugins/mission-ci-widget/plugin.js +1 -0
- package/templates/plugins/mock-agent-provider/crewcode-plugin-api.js +80 -0
- package/templates/plugins/mock-agent-provider/crewcode.plugin.json +38 -0
- package/templates/plugins/mock-agent-provider/panel.html +45 -0
- package/templates/plugins/mock-agent-provider/plugin.js +3 -0
- package/templates/plugins/openai-compatible-provider/README.md +17 -0
- package/templates/plugins/openai-compatible-provider/crewcode-plugin-api.js +80 -0
- package/templates/plugins/openai-compatible-provider/crewcode.plugin.json +28 -0
- package/templates/plugins/openai-compatible-provider/panel.html +1 -0
- package/templates/plugins/openai-compatible-provider/plugin.js +4 -0
- package/templates/plugins/openai-compatible-provider/server.mjs +21 -0
- package/templates/plugins/repo-radar/crewcode-plugin-api.js +80 -0
- package/templates/plugins/repo-radar/crewcode.plugin.json +55 -0
- package/templates/plugins/repo-radar/panel.html +56 -0
- package/templates/plugins/repo-radar/plugin.js +103 -0
- package/templates/plugins/static-panel-template/README.md +19 -0
- package/templates/plugins/static-panel-template/crewcode-plugin-api.js +80 -0
- package/templates/plugins/static-panel-template/crewcode.plugin.json +44 -0
- package/templates/plugins/static-panel-template/panel.html +36 -0
- package/templates/plugins/static-panel-template/plugin.js +30 -0
- package/templates/plugins/terminal-watchdog-lite/crewcode-plugin-api.js +80 -0
- package/templates/plugins/terminal-watchdog-lite/crewcode.plugin.json +13 -0
- package/templates/plugins/terminal-watchdog-lite/panel.html +1 -0
- package/templates/plugins/terminal-watchdog-lite/plugin.js +1 -0
- package/templates/plugins/typescript-panel-template/README.md +40 -0
- package/templates/plugins/typescript-panel-template/compiled/assets/panel-ECHDDxZz.js +8 -0
- package/templates/plugins/typescript-panel-template/compiled/assets/panel-u6HzQzUF.css +1 -0
- package/templates/plugins/typescript-panel-template/compiled/src/panel.html +13 -0
- package/templates/plugins/typescript-panel-template/crewcode.plugin.json +23 -0
- package/templates/plugins/typescript-panel-template/package.json +19 -0
- package/templates/plugins/typescript-panel-template/src/crewcode-api.ts +146 -0
- package/templates/plugins/typescript-panel-template/src/main.tsx +38 -0
- package/templates/plugins/typescript-panel-template/src/panel.html +12 -0
- package/templates/plugins/typescript-panel-template/src/style.css +17 -0
- package/templates/plugins/typescript-panel-template/tsconfig.json +20 -0
- package/templates/plugins/typescript-panel-template/vite.config.ts +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 OnPoint Tools
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# crewcode-plugin-cli
|
|
2
|
+
|
|
3
|
+
Command-line tool for scaffolding, developing, and packaging [CrewCode](https://github.com/CjLogic/CrewCode) plugins. Exposes the `crewcode` binary.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g crewcode-plugin-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run without installing:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx crewcode-plugin-cli plugin list
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
crewcode plugin list # show all templates
|
|
21
|
+
crewcode plugin create my-plugin --template static-panel
|
|
22
|
+
crewcode plugin dev ./my-plugin # live-install for development
|
|
23
|
+
crewcode plugin package ./my-plugin # build a distributable archive
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Commands
|
|
27
|
+
|
|
28
|
+
- `crewcode plugin list` — list every bundled template with its aliases and description.
|
|
29
|
+
- `crewcode plugin create <id>` — scaffold a local plugin from a bundled template. Flags: `--template`, `--out`, `--name`, `--force`.
|
|
30
|
+
- `crewcode plugin dev [pluginDir]` — validate and install a plugin into `~/.crewcode/plugins` (override with `CREWCODE_PLUGINS_DIR`) as a symlink/junction by default. Flags: `--copy`, `--build`, `--watch`.
|
|
31
|
+
- `crewcode plugin package [pluginDir]` — validate, optionally build, and write a `.crewcode-plugin.tgz` plus a SHA-256 summary JSON. Flag: `--no-build`.
|
|
32
|
+
|
|
33
|
+
## Templates
|
|
34
|
+
|
|
35
|
+
Run `crewcode plugin list` for the current set with descriptions. Each has short aliases, e.g. `--template panel`, `--template react`, `--template mcp`.
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
Apache-2.0.
|
package/bin/crewcode.mjs
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createHash } from 'crypto'
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'url'
|
|
4
|
+
import { createReadStream, createWriteStream } from 'fs'
|
|
5
|
+
import {
|
|
6
|
+
cpSync,
|
|
7
|
+
existsSync,
|
|
8
|
+
lstatSync,
|
|
9
|
+
mkdirSync,
|
|
10
|
+
mkdtempSync,
|
|
11
|
+
readdirSync,
|
|
12
|
+
readFileSync,
|
|
13
|
+
realpathSync,
|
|
14
|
+
rmSync,
|
|
15
|
+
symlinkSync,
|
|
16
|
+
writeFileSync,
|
|
17
|
+
} from 'fs'
|
|
18
|
+
import { tmpdir, homedir } from 'os'
|
|
19
|
+
import { dirname, join, relative, resolve, sep } from 'path'
|
|
20
|
+
import { spawnSync } from 'child_process'
|
|
21
|
+
import { createGzip } from 'zlib'
|
|
22
|
+
|
|
23
|
+
const API_VERSION = '0.1'
|
|
24
|
+
const MANIFEST = 'crewcode.plugin.json'
|
|
25
|
+
const TEMPLATE_ALIASES = new Map([
|
|
26
|
+
['static', 'static-panel-template'],
|
|
27
|
+
['static-panel', 'static-panel-template'],
|
|
28
|
+
['panel', 'static-panel-template'],
|
|
29
|
+
['typescript', 'typescript-panel-template'],
|
|
30
|
+
['typescript-panel', 'typescript-panel-template'],
|
|
31
|
+
['react', 'typescript-panel-template'],
|
|
32
|
+
['ts-react', 'typescript-panel-template'],
|
|
33
|
+
['mock-agent', 'mock-agent-provider'],
|
|
34
|
+
['http-agent', 'company-agent-http-adapter'],
|
|
35
|
+
['openai-agent', 'openai-compatible-provider'],
|
|
36
|
+
['exec-agent', 'github-copilot-cli-provider'],
|
|
37
|
+
['mcp', 'mcp-server-template'],
|
|
38
|
+
['browser-action', 'browser-docs-grabber'],
|
|
39
|
+
['git-lens', 'git-risk-lens'],
|
|
40
|
+
['graph', 'codebase-graph-lite'],
|
|
41
|
+
['handoff', 'handoff-pack'],
|
|
42
|
+
['mission', 'mission-ci-widget'],
|
|
43
|
+
['mission-widget', 'mission-ci-widget'],
|
|
44
|
+
['radar', 'repo-radar'],
|
|
45
|
+
['watchdog', 'terminal-watchdog-lite'],
|
|
46
|
+
['terminal-watcher', 'terminal-watchdog-lite'],
|
|
47
|
+
])
|
|
48
|
+
const SKIP_DIRS = new Set(['.git', 'node_modules', '.cache', '.turbo', 'dist'])
|
|
49
|
+
const SKIP_FILES = new Set(['.DS_Store'])
|
|
50
|
+
const VALID_PERMISSIONS = new Set([
|
|
51
|
+
'workspace:read', 'workspace:write', 'git:read', 'git:write', 'terminal:spawn', 'terminal:read',
|
|
52
|
+
'agent:prompt', 'agent:provider', 'browser:read', 'mcp:server', 'network:fetch', 'secrets:read',
|
|
53
|
+
])
|
|
54
|
+
const CONTRIBUTION_KEYS = [
|
|
55
|
+
'commands', 'tabs', 'sidebarPanels', 'statusItems', 'editorActions', 'chatActions', 'chatHeaderItems',
|
|
56
|
+
'mcpServers', 'agentProviders', 'gitLenses', 'missionWidgets', 'terminalWatchers', 'browserActions',
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
function packageRoot() {
|
|
60
|
+
return resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Derived from disk, not hardcoded: the old static list had drifted and hid 5
|
|
64
|
+
// of the 14 shipped templates.
|
|
65
|
+
function listTemplates() {
|
|
66
|
+
const root = join(packageRoot(), 'templates', 'plugins')
|
|
67
|
+
if (!existsSync(root)) return []
|
|
68
|
+
const aliasesFor = new Map()
|
|
69
|
+
for (const [alias, target] of TEMPLATE_ALIASES) {
|
|
70
|
+
if (!aliasesFor.has(target)) aliasesFor.set(target, [])
|
|
71
|
+
aliasesFor.get(target).push(alias)
|
|
72
|
+
}
|
|
73
|
+
const out = []
|
|
74
|
+
for (const name of readdirSync(root).sort()) {
|
|
75
|
+
const manifestPath = join(root, name, MANIFEST)
|
|
76
|
+
if (!existsSync(manifestPath)) continue
|
|
77
|
+
let description = ''
|
|
78
|
+
try { description = String(readJson(manifestPath).description || '') } catch { /* unreadable */ }
|
|
79
|
+
out.push({ name, aliases: aliasesFor.get(name) || [], description })
|
|
80
|
+
}
|
|
81
|
+
return out
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function formatTemplates() {
|
|
85
|
+
return listTemplates().map(t => {
|
|
86
|
+
const alias = t.aliases.length ? ` (${t.aliases.join(', ')})` : ''
|
|
87
|
+
const desc = t.description ? `\n ${t.description}` : ''
|
|
88
|
+
return ` ${t.name}${alias}${desc}`
|
|
89
|
+
}).join('\n')
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function usage() {
|
|
93
|
+
return `crewcode plugin <command> [options]
|
|
94
|
+
|
|
95
|
+
Commands:
|
|
96
|
+
create <id> [--template static-panel] [--out <dir>] [--name <name>] [--force]
|
|
97
|
+
dev [pluginDir] [--copy] [--watch] [--build]
|
|
98
|
+
package [pluginDir] [--out <dir>] [--no-build]
|
|
99
|
+
list
|
|
100
|
+
|
|
101
|
+
Templates:
|
|
102
|
+
${formatTemplates()}
|
|
103
|
+
`
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function listCommand() {
|
|
107
|
+
const templates = listTemplates()
|
|
108
|
+
console.log(`${templates.length} templates available:\n`)
|
|
109
|
+
console.log(formatTemplates())
|
|
110
|
+
return { ok: true, templates: templates.map(t => t.name) }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function parseArgs(argv) {
|
|
114
|
+
const args = []
|
|
115
|
+
const flags = new Map()
|
|
116
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
117
|
+
const item = argv[i]
|
|
118
|
+
if (!item.startsWith('--')) { args.push(item); continue }
|
|
119
|
+
const raw = item.slice(2)
|
|
120
|
+
if (raw.startsWith('no-')) { flags.set(raw.slice(3), false); continue }
|
|
121
|
+
const eq = raw.indexOf('=')
|
|
122
|
+
if (eq !== -1) { flags.set(raw.slice(0, eq), raw.slice(eq + 1)); continue }
|
|
123
|
+
const next = argv[i + 1]
|
|
124
|
+
if (next && !next.startsWith('--')) { flags.set(raw, next); i += 1 }
|
|
125
|
+
else flags.set(raw, true)
|
|
126
|
+
}
|
|
127
|
+
return { args, flags }
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function pluginHome() {
|
|
131
|
+
return process.env.CREWCODE_PLUGINS_DIR || join(homedir(), '.crewcode', 'plugins')
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function titleFromId(id) {
|
|
135
|
+
return id.split(/[-_.]+/).filter(Boolean).map(part => part[0]?.toUpperCase() + part.slice(1)).join(' ')
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function validatePluginId(id) {
|
|
139
|
+
if (!/^[a-z0-9][a-z0-9._-]*$/i.test(id)) throw new Error(`invalid plugin id "${id}"`)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function templateDir(name) {
|
|
143
|
+
const resolvedName = TEMPLATE_ALIASES.get(name) || name
|
|
144
|
+
const dir = join(packageRoot(), 'templates', 'plugins', resolvedName)
|
|
145
|
+
if (!existsSync(join(dir, MANIFEST))) throw new Error(`unknown template "${name}"`)
|
|
146
|
+
return dir
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function readJson(path) {
|
|
150
|
+
return JSON.parse(readFileSync(path, 'utf8'))
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function writeJson(path, value) {
|
|
154
|
+
writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`, 'utf8')
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function safeInside(root, target) {
|
|
158
|
+
const rel = relative(root, target)
|
|
159
|
+
return rel === '' || (!!rel && !rel.startsWith('..') && !rel.includes(`..${sep}`))
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function validateManifest(pluginDir) {
|
|
163
|
+
const manifestPath = join(pluginDir, MANIFEST)
|
|
164
|
+
if (!existsSync(manifestPath)) throw new Error(`missing ${MANIFEST}`)
|
|
165
|
+
const manifest = readJson(manifestPath)
|
|
166
|
+
validatePluginId(String(manifest.id || ''))
|
|
167
|
+
if (!manifest.name || typeof manifest.name !== 'string') throw new Error('manifest.name must be a non-empty string')
|
|
168
|
+
if (!manifest.version || typeof manifest.version !== 'string') throw new Error('manifest.version must be a non-empty string')
|
|
169
|
+
const apiVersion = manifest.crewcode?.apiVersion || API_VERSION
|
|
170
|
+
if (apiVersion !== API_VERSION) throw new Error(`unsupported crewcode.apiVersion "${apiVersion}"; supported: ${API_VERSION}`)
|
|
171
|
+
for (const permission of manifest.permissions || []) {
|
|
172
|
+
if (!VALID_PERMISSIONS.has(permission)) throw new Error(`unknown permission "${permission}"`)
|
|
173
|
+
}
|
|
174
|
+
const contributes = manifest.contributes || {}
|
|
175
|
+
for (const key of Object.keys(contributes)) {
|
|
176
|
+
if (!CONTRIBUTION_KEYS.includes(key)) throw new Error(`unknown contributes.${key}`)
|
|
177
|
+
}
|
|
178
|
+
for (const key of ['tabs', 'sidebarPanels']) {
|
|
179
|
+
for (const panel of contributes[key] || []) {
|
|
180
|
+
if (!panel.entry || typeof panel.entry !== 'string') throw new Error(`contributes.${key} entry required`)
|
|
181
|
+
if (/^(?:[a-zA-Z][a-zA-Z0-9+.-]*:|[\\/])/.test(panel.entry)) throw new Error(`contributes.${key} entry must be relative`)
|
|
182
|
+
const entryPath = resolve(pluginDir, panel.entry)
|
|
183
|
+
if (!safeInside(pluginDir, entryPath)) throw new Error(`contributes.${key} entry escapes plugin folder`)
|
|
184
|
+
if (!existsSync(entryPath)) throw new Error(`panel entry missing: ${panel.entry}`)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return manifest
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function copyTemplate(src, dest, force) {
|
|
191
|
+
if (existsSync(dest)) {
|
|
192
|
+
if (!force) throw new Error(`destination exists: ${dest}`)
|
|
193
|
+
rmSync(dest, { recursive: true, force: true })
|
|
194
|
+
}
|
|
195
|
+
mkdirSync(dirname(dest), { recursive: true })
|
|
196
|
+
cpSync(src, dest, { recursive: true, filter: source => !source.includes(`${sep}node_modules${sep}`) })
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function rewriteCreatedProject(dest, id, name) {
|
|
200
|
+
const manifestPath = join(dest, MANIFEST)
|
|
201
|
+
const manifest = readJson(manifestPath)
|
|
202
|
+
manifest.$schema = 'https://crewcode.cortex-ai.icu/schemas/crewcode.plugin.schema.json'
|
|
203
|
+
manifest.id = id
|
|
204
|
+
manifest.name = name
|
|
205
|
+
if (manifest.contributes?.tabs) {
|
|
206
|
+
for (const tab of manifest.contributes.tabs) if (typeof tab.title === 'string') tab.title = name
|
|
207
|
+
}
|
|
208
|
+
if (manifest.contributes?.sidebarPanels) {
|
|
209
|
+
for (const panel of manifest.contributes.sidebarPanels) if (typeof panel.title === 'string') panel.title = name
|
|
210
|
+
}
|
|
211
|
+
writeJson(manifestPath, manifest)
|
|
212
|
+
|
|
213
|
+
const packagePath = join(dest, 'package.json')
|
|
214
|
+
if (existsSync(packagePath)) {
|
|
215
|
+
const pkg = readJson(packagePath)
|
|
216
|
+
pkg.name = id
|
|
217
|
+
writeJson(packagePath, pkg)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export function createPlugin(argv) {
|
|
222
|
+
const { args, flags } = parseArgs(argv)
|
|
223
|
+
const id = args[0]
|
|
224
|
+
if (!id) throw new Error('plugin id required')
|
|
225
|
+
validatePluginId(id)
|
|
226
|
+
const name = String(flags.get('name') || titleFromId(id))
|
|
227
|
+
const template = String(flags.get('template') || 'static-panel')
|
|
228
|
+
const outRoot = resolve(String(flags.get('out') || process.cwd()))
|
|
229
|
+
const dest = resolve(outRoot, id)
|
|
230
|
+
copyTemplate(templateDir(template), dest, flags.get('force') === true)
|
|
231
|
+
rewriteCreatedProject(dest, id, name)
|
|
232
|
+
validateManifest(dest)
|
|
233
|
+
return { ok: true, path: dest, id, name, template }
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function installPlugin(pluginDir, copyMode) {
|
|
237
|
+
const manifest = validateManifest(pluginDir)
|
|
238
|
+
const root = pluginHome()
|
|
239
|
+
const dest = join(root, manifest.id)
|
|
240
|
+
mkdirSync(root, { recursive: true })
|
|
241
|
+
rmSync(dest, { recursive: true, force: true })
|
|
242
|
+
if (copyMode) {
|
|
243
|
+
cpSync(pluginDir, dest, { recursive: true, filter: source => !source.includes(`${sep}node_modules${sep}`) })
|
|
244
|
+
return { manifest, dest, mode: 'copy' }
|
|
245
|
+
}
|
|
246
|
+
const type = process.platform === 'win32' ? 'junction' : 'dir'
|
|
247
|
+
symlinkSync(resolve(pluginDir), dest, type)
|
|
248
|
+
return { manifest, dest, mode: 'link' }
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function runPackageScript(pluginDir, script, inherit = true) {
|
|
252
|
+
if (!existsSync(join(pluginDir, 'package.json'))) return { ran: false, status: 0 }
|
|
253
|
+
const pkg = readJson(join(pluginDir, 'package.json'))
|
|
254
|
+
if (!pkg.scripts?.[script]) return { ran: false, status: 0 }
|
|
255
|
+
const result = spawnSync('npm', ['run', script], { cwd: pluginDir, stdio: inherit ? 'inherit' : 'pipe', shell: process.platform === 'win32' })
|
|
256
|
+
if (result.status !== 0) throw new Error(`npm run ${script} failed`)
|
|
257
|
+
return { ran: true, status: result.status }
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function devPlugin(argv) {
|
|
261
|
+
const { args, flags } = parseArgs(argv)
|
|
262
|
+
const pluginDir = resolve(args[0] || process.cwd())
|
|
263
|
+
if (flags.get('build') === true) runPackageScript(pluginDir, 'build')
|
|
264
|
+
const installed = installPlugin(pluginDir, flags.get('copy') === true)
|
|
265
|
+
if (flags.get('watch') === true) {
|
|
266
|
+
runPackageScript(pluginDir, 'dev')
|
|
267
|
+
}
|
|
268
|
+
return { ok: true, pluginId: installed.manifest.id, path: installed.dest, mode: installed.mode }
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function collectPackageFiles(root) {
|
|
272
|
+
const files = []
|
|
273
|
+
function walk(dir) {
|
|
274
|
+
for (const name of readdirSync(dir)) {
|
|
275
|
+
if (SKIP_FILES.has(name)) continue
|
|
276
|
+
const abs = join(dir, name)
|
|
277
|
+
const rel = relative(root, abs).replace(/\\/g, '/')
|
|
278
|
+
const st = lstatSync(abs)
|
|
279
|
+
if (st.isDirectory()) {
|
|
280
|
+
if (SKIP_DIRS.has(name)) continue
|
|
281
|
+
walk(abs)
|
|
282
|
+
} else if (st.isFile()) {
|
|
283
|
+
files.push({ abs, rel, mode: st.mode & 0o777, size: st.size })
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
walk(root)
|
|
288
|
+
files.sort((a, b) => a.rel.localeCompare(b.rel))
|
|
289
|
+
return files
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function tarHeader(name, size, mode, mtime = 0) {
|
|
293
|
+
const buf = Buffer.alloc(512, 0)
|
|
294
|
+
const write = (text, offset, length) => buf.write(String(text).slice(0, length), offset, length, 'utf8')
|
|
295
|
+
write(name, 0, 100)
|
|
296
|
+
write(mode.toString(8).padStart(7, '0') + '\0', 100, 8)
|
|
297
|
+
write('0000000\0', 108, 8)
|
|
298
|
+
write('0000000\0', 116, 8)
|
|
299
|
+
write(size.toString(8).padStart(11, '0') + '\0', 124, 12)
|
|
300
|
+
write(Math.floor(mtime).toString(8).padStart(11, '0') + '\0', 136, 12)
|
|
301
|
+
buf.fill(0x20, 148, 156)
|
|
302
|
+
write('0', 156, 1)
|
|
303
|
+
write('ustar\0', 257, 6)
|
|
304
|
+
write('00', 263, 2)
|
|
305
|
+
let sum = 0
|
|
306
|
+
for (const byte of buf) sum += byte
|
|
307
|
+
write(sum.toString(8).padStart(6, '0') + '\0 ', 148, 8)
|
|
308
|
+
return buf
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function writeTarGz(root, files, outFile) {
|
|
312
|
+
const tempTar = join(mkdtempSync(join(tmpdir(), 'crewcode-plugin-package-')), 'plugin.tar')
|
|
313
|
+
const out = createWriteStream(tempTar)
|
|
314
|
+
for (const file of files) {
|
|
315
|
+
out.write(tarHeader(`package/${file.rel}`, file.size, file.mode))
|
|
316
|
+
out.write(readFileSync(file.abs))
|
|
317
|
+
const pad = (512 - (file.size % 512)) % 512
|
|
318
|
+
if (pad) out.write(Buffer.alloc(pad, 0))
|
|
319
|
+
}
|
|
320
|
+
out.write(Buffer.alloc(1024, 0))
|
|
321
|
+
out.end()
|
|
322
|
+
return new Promise((resolvePromise, rejectPromise) => {
|
|
323
|
+
out.on('error', rejectPromise)
|
|
324
|
+
out.on('finish', () => {
|
|
325
|
+
const gz = createGzip({ mtime: 0 })
|
|
326
|
+
const input = createReadStream(tempTar)
|
|
327
|
+
const output = createWriteStream(outFile)
|
|
328
|
+
input.pipe(gz).pipe(output)
|
|
329
|
+
output.on('finish', () => {
|
|
330
|
+
rmSync(dirname(tempTar), { recursive: true, force: true })
|
|
331
|
+
resolvePromise()
|
|
332
|
+
})
|
|
333
|
+
output.on('error', rejectPromise)
|
|
334
|
+
})
|
|
335
|
+
})
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export async function packagePlugin(argv) {
|
|
339
|
+
const { args, flags } = parseArgs(argv)
|
|
340
|
+
const pluginDir = resolve(args[0] || process.cwd())
|
|
341
|
+
if (flags.get('build') !== false) runPackageScript(pluginDir, 'build')
|
|
342
|
+
const manifest = validateManifest(pluginDir)
|
|
343
|
+
const files = collectPackageFiles(pluginDir)
|
|
344
|
+
const outRoot = resolve(String(flags.get('out') || join(pluginDir, 'dist')))
|
|
345
|
+
mkdirSync(outRoot, { recursive: true })
|
|
346
|
+
const base = `${manifest.id}-${manifest.version}.crewcode-plugin.tgz`
|
|
347
|
+
const outFile = join(outRoot, base)
|
|
348
|
+
await writeTarGz(pluginDir, files, outFile)
|
|
349
|
+
const sha256 = createHash('sha256').update(readFileSync(outFile)).digest('hex')
|
|
350
|
+
writeJson(join(outRoot, `${base}.json`), { id: manifest.id, version: manifest.version, file: base, sha256, files: files.map(f => f.rel) })
|
|
351
|
+
return { ok: true, path: outFile, sha256, files: files.length }
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
355
|
+
const [group, command, ...rest] = argv
|
|
356
|
+
if (group !== 'plugin' || !command || command === '--help' || command === '-h') {
|
|
357
|
+
console.log(usage())
|
|
358
|
+
return { ok: true }
|
|
359
|
+
}
|
|
360
|
+
if (command === 'create') return createPlugin(rest)
|
|
361
|
+
if (command === 'dev') return devPlugin(rest)
|
|
362
|
+
if (command === 'package') return packagePlugin(rest)
|
|
363
|
+
if (command === 'list') return listCommand()
|
|
364
|
+
throw new Error(`unknown command: crewcode plugin ${command}`)
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// npm symlinks `bin` entries, so process.argv[1] is the symlink path while
|
|
368
|
+
// import.meta.url is the real one — string-comparing `file://` + argv[1] never
|
|
369
|
+
// matched and main() silently never ran for globally installed users. realpath
|
|
370
|
+
// resolves the symlink; pathToFileURL gets Windows' file:///C:/ form right.
|
|
371
|
+
function isDirectRun() {
|
|
372
|
+
const entry = process.argv[1]
|
|
373
|
+
if (!entry) return false
|
|
374
|
+
try {
|
|
375
|
+
return import.meta.url === pathToFileURL(realpathSync(entry)).href
|
|
376
|
+
} catch {
|
|
377
|
+
return false
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (isDirectRun()) {
|
|
382
|
+
main().then(result => {
|
|
383
|
+
if (result?.path) console.log(result.path)
|
|
384
|
+
}).catch(err => {
|
|
385
|
+
console.error(err.message)
|
|
386
|
+
process.exit(1)
|
|
387
|
+
})
|
|
388
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "crewcode-plugin-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Command-line tool for scaffolding, developing, and packaging CrewCode plugins.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"crewcode",
|
|
9
|
+
"plugin",
|
|
10
|
+
"cli",
|
|
11
|
+
"scaffold",
|
|
12
|
+
"ade",
|
|
13
|
+
"ai-agents"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/CjLogic/CrewCode/tree/main/packages/crewcode-plugin-cli#readme",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/CjLogic/CrewCode.git",
|
|
19
|
+
"directory": "packages/crewcode-plugin-cli"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/CjLogic/CrewCode/issues"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"crewcode": "bin/crewcode.mjs"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": "./bin/crewcode.mjs"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"test": "vitest run ../../src/main/crewcode-plugin-cli.test.ts",
|
|
32
|
+
"pack:dry": "npm pack --dry-run"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"bin",
|
|
36
|
+
"templates",
|
|
37
|
+
"LICENSE",
|
|
38
|
+
"README.md"
|
|
39
|
+
]
|
|
40
|
+
}
|