create-codemodekit 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 +16 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +110 -0
- package/dist/cli.js.map +1 -0
- package/dist/command.d.ts +10 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +93 -0
- package/dist/command.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/scaffold.d.ts +26 -0
- package/dist/scaffold.d.ts.map +1 -0
- package/dist/scaffold.js +112 -0
- package/dist/scaffold.js.map +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
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.
|
|
202
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# create-codemodekit
|
|
2
|
+
|
|
3
|
+
Scaffold a runnable, one-file Code Mode MCP server from an upstream MCP command.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm create codemodekit@latest my-code-mode -- \
|
|
7
|
+
--mcp-name upstream \
|
|
8
|
+
--mcp-command 'uvx my-mcp-server'
|
|
9
|
+
|
|
10
|
+
cd my-code-mode
|
|
11
|
+
npm start
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The command is parsed directly into an executable and argument array. Shell operators, shell expansion, and leading environment assignments are rejected; no shell is invoked. Dependency installation is automatic unless `--no-install` is supplied.
|
|
15
|
+
|
|
16
|
+
Generated servers use `--policy allow-all` by default so the project runs immediately. Use `--policy deny-all` when you want the generated server to start closed while you define a narrower tool policy.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAaA,wBAAsB,MAAM,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBnE"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseMcpCommand } from "./command.js";
|
|
3
|
+
import { scaffoldCodeModeMcp } from "./scaffold.js";
|
|
4
|
+
export async function runCli(args) {
|
|
5
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
6
|
+
process.stdout.write(usage());
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const options = parseOptions(args);
|
|
10
|
+
const result = await scaffoldCodeModeMcp({
|
|
11
|
+
targetDirectory: options.targetDirectory,
|
|
12
|
+
mcpName: options.mcpName,
|
|
13
|
+
mcpCommand: parseMcpCommand(options.mcpCommand),
|
|
14
|
+
...(options.serverName === undefined
|
|
15
|
+
? {}
|
|
16
|
+
: { serverName: options.serverName }),
|
|
17
|
+
policy: options.policy,
|
|
18
|
+
install: options.install,
|
|
19
|
+
});
|
|
20
|
+
process.stdout.write(`\nCreated ${options.serverName ?? `${options.mcpName}-code-mode`} in ${result.directory}\n\n` +
|
|
21
|
+
`${result.installed ? "" : " npm install\n"} npm start\n\n` +
|
|
22
|
+
`Tool policy: ${options.policy}\n`);
|
|
23
|
+
}
|
|
24
|
+
function parseOptions(args) {
|
|
25
|
+
let targetDirectory;
|
|
26
|
+
let mcpName;
|
|
27
|
+
let mcpCommand;
|
|
28
|
+
let serverName;
|
|
29
|
+
let policy = "allow-all";
|
|
30
|
+
let install = true;
|
|
31
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
32
|
+
const argument = args[index];
|
|
33
|
+
if (argument === undefined)
|
|
34
|
+
continue;
|
|
35
|
+
if (!argument.startsWith("-")) {
|
|
36
|
+
if (targetDirectory !== undefined) {
|
|
37
|
+
throw new TypeError(`Unexpected argument: ${argument}`);
|
|
38
|
+
}
|
|
39
|
+
targetDirectory = argument;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (argument === "--no-install") {
|
|
43
|
+
install = false;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const value = args[index + 1];
|
|
47
|
+
if (value === undefined || value.startsWith("--")) {
|
|
48
|
+
throw new TypeError(`Missing value for ${argument}`);
|
|
49
|
+
}
|
|
50
|
+
index += 1;
|
|
51
|
+
switch (argument) {
|
|
52
|
+
case "--mcp-name":
|
|
53
|
+
mcpName = value;
|
|
54
|
+
break;
|
|
55
|
+
case "--mcp-command":
|
|
56
|
+
mcpCommand = value;
|
|
57
|
+
break;
|
|
58
|
+
case "--server-name":
|
|
59
|
+
serverName = value;
|
|
60
|
+
break;
|
|
61
|
+
case "--policy":
|
|
62
|
+
if (value !== "allow-all" && value !== "deny-all") {
|
|
63
|
+
throw new TypeError("--policy must be allow-all or deny-all");
|
|
64
|
+
}
|
|
65
|
+
policy = value;
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
throw new TypeError(`Unknown option: ${argument}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (targetDirectory === undefined) {
|
|
72
|
+
throw new TypeError("A target directory is required");
|
|
73
|
+
}
|
|
74
|
+
if (mcpName === undefined) {
|
|
75
|
+
throw new TypeError("--mcp-name is required");
|
|
76
|
+
}
|
|
77
|
+
if (mcpCommand === undefined) {
|
|
78
|
+
throw new TypeError("--mcp-command is required");
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
targetDirectory,
|
|
82
|
+
mcpName,
|
|
83
|
+
mcpCommand,
|
|
84
|
+
...(serverName === undefined ? {} : { serverName }),
|
|
85
|
+
policy,
|
|
86
|
+
install,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function usage() {
|
|
90
|
+
return `Create a batteries-included Code Mode MCP server.
|
|
91
|
+
|
|
92
|
+
Usage:
|
|
93
|
+
npm create codemodekit@latest <directory> -- \\
|
|
94
|
+
--mcp-name <name> \\
|
|
95
|
+
--mcp-command '<executable> [args...]'
|
|
96
|
+
|
|
97
|
+
Options:
|
|
98
|
+
--server-name <name> Downstream MCP server name
|
|
99
|
+
--policy allow-all Allow every discovered upstream tool (default)
|
|
100
|
+
--policy deny-all Deny every upstream tool until policy is edited
|
|
101
|
+
--no-install Generate files without running npm install
|
|
102
|
+
-h, --help Show this help
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
runCli(process.argv.slice(2)).catch((error) => {
|
|
106
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
107
|
+
process.stderr.write(`create-codemodekit: ${message}\n\n${usage()}`);
|
|
108
|
+
process.exitCode = 1;
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAWpD,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAuB;IAClD,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACnD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC9B,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,M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C,2BAA2B,CAAC,CAAC;IACnD,CAAC;IAED,OAAO;QACL,eAAe;QACf,OAAO;QACP,UAAU;QACV,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;QACnD,MAAM;QACN,OAAO;KACR,CAAC;AACJ,CAAC;AAED,SAAS,KAAK;IACZ,OAAO;;;;;;;;;;;;;CAaR,CAAC;AACF,CAAC;AAED,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IACrD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,OAAO,OAAO,KAAK,EAAE,EAAE,CAAC,CAAC;IACrE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ParsedCommand {
|
|
2
|
+
readonly command: string;
|
|
3
|
+
readonly args: readonly string[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Parses a human-friendly command line without invoking a shell. Quoting and
|
|
7
|
+
* backslash escaping are supported; shell operators and expansion are not.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseMcpCommand(input: string): ParsedCommand;
|
|
10
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAiG5D"}
|
package/dist/command.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a human-friendly command line without invoking a shell. Quoting and
|
|
3
|
+
* backslash escaping are supported; shell operators and expansion are not.
|
|
4
|
+
*/
|
|
5
|
+
export function parseMcpCommand(input) {
|
|
6
|
+
const tokens = [];
|
|
7
|
+
let token = "";
|
|
8
|
+
let tokenStarted = false;
|
|
9
|
+
let quote;
|
|
10
|
+
let escaping = false;
|
|
11
|
+
const finishToken = () => {
|
|
12
|
+
if (!tokenStarted)
|
|
13
|
+
return;
|
|
14
|
+
tokens.push(token);
|
|
15
|
+
token = "";
|
|
16
|
+
tokenStarted = false;
|
|
17
|
+
};
|
|
18
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
19
|
+
const character = input[index];
|
|
20
|
+
if (character === undefined)
|
|
21
|
+
continue;
|
|
22
|
+
if (escaping) {
|
|
23
|
+
token += character;
|
|
24
|
+
tokenStarted = true;
|
|
25
|
+
escaping = false;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (quote === "single") {
|
|
29
|
+
if (character === "'") {
|
|
30
|
+
quote = undefined;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
token += character;
|
|
34
|
+
}
|
|
35
|
+
tokenStarted = true;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (character === "\\") {
|
|
39
|
+
escaping = true;
|
|
40
|
+
tokenStarted = true;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (character === "\"") {
|
|
44
|
+
quote = quote === "double" ? undefined : "double";
|
|
45
|
+
tokenStarted = true;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (quote === "double") {
|
|
49
|
+
if (character === "`" || (character === "$" && input[index + 1] === "(")) {
|
|
50
|
+
throw unsupportedShellSyntax();
|
|
51
|
+
}
|
|
52
|
+
token += character;
|
|
53
|
+
tokenStarted = true;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (character === "'") {
|
|
57
|
+
quote = "single";
|
|
58
|
+
tokenStarted = true;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (/\s/u.test(character)) {
|
|
62
|
+
finishToken();
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if ("|&;<>`".includes(character)) {
|
|
66
|
+
throw unsupportedShellSyntax();
|
|
67
|
+
}
|
|
68
|
+
if (character === "$" && input[index + 1] === "(") {
|
|
69
|
+
throw unsupportedShellSyntax();
|
|
70
|
+
}
|
|
71
|
+
token += character;
|
|
72
|
+
tokenStarted = true;
|
|
73
|
+
}
|
|
74
|
+
if (escaping) {
|
|
75
|
+
throw new TypeError("MCP command ends with an incomplete escape");
|
|
76
|
+
}
|
|
77
|
+
if (quote !== undefined) {
|
|
78
|
+
throw new TypeError("MCP command contains an unterminated quote");
|
|
79
|
+
}
|
|
80
|
+
finishToken();
|
|
81
|
+
const command = tokens[0];
|
|
82
|
+
if (command === undefined || command === "") {
|
|
83
|
+
throw new TypeError("MCP command must not be empty");
|
|
84
|
+
}
|
|
85
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*=/u.test(command)) {
|
|
86
|
+
throw new TypeError("Environment assignments are not supported in --mcp-command; configure environment variables outside the command");
|
|
87
|
+
}
|
|
88
|
+
return { command, args: tokens.slice(1) };
|
|
89
|
+
}
|
|
90
|
+
function unsupportedShellSyntax() {
|
|
91
|
+
return new TypeError("Shell operators and expansion are not supported in --mcp-command; pass a single executable and its arguments");
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,MAAM,MAA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AS,CAAC,+BAA+B,CAAC,CAAC;IACvD,CAAC;IACD,IAAI,2BAA2B,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,SAAS,CACjB,iHAAiH,CAClH,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5C,CAAC;AAED,SAAS,sBAAsB;IAC7B,OAAO,IAAI,SAAS,CAClB,8GAA8G,CAC/G,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,KAAK,0BAA0B,EAC/B,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAsB,MAAM,cAAc,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,mBAAmB,GAGpB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ParsedCommand } from "./command.js";
|
|
2
|
+
export interface ScaffoldCodeModeMcpOptions {
|
|
3
|
+
readonly targetDirectory: string;
|
|
4
|
+
readonly mcpName: string;
|
|
5
|
+
readonly mcpCommand: ParsedCommand;
|
|
6
|
+
readonly serverName?: string;
|
|
7
|
+
readonly packageName?: string;
|
|
8
|
+
readonly policy?: "allow-all" | "deny-all";
|
|
9
|
+
readonly install?: boolean;
|
|
10
|
+
readonly cwd?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ScaffoldResult {
|
|
13
|
+
readonly directory: string;
|
|
14
|
+
readonly entrypoint: string;
|
|
15
|
+
readonly installed: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function scaffoldCodeModeMcp(options: ScaffoldCodeModeMcpOptions): Promise<ScaffoldResult>;
|
|
18
|
+
interface RenderServerOptions {
|
|
19
|
+
readonly serverName: string;
|
|
20
|
+
readonly mcpName: string;
|
|
21
|
+
readonly mcpCommand: ParsedCommand;
|
|
22
|
+
readonly policy: "allow-all" | "deny-all";
|
|
23
|
+
}
|
|
24
|
+
export declare function renderServer(options: RenderServerOptions): string;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=scaffold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,cAAc,CAAC,CAuDzB;AAED,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,CAAC;CAC3C;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAsBjE"}
|
package/dist/scaffold.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { mkdir, readdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
export async function scaffoldCodeModeMcp(options) {
|
|
5
|
+
const cwd = options.cwd ?? process.cwd();
|
|
6
|
+
const directory = path.resolve(cwd, options.targetDirectory);
|
|
7
|
+
const mcpName = required(options.mcpName, "MCP name");
|
|
8
|
+
const serverName = required(options.serverName ?? `${mcpName}-code-mode`, "Server name");
|
|
9
|
+
const packageName = validPackageName(options.packageName ?? packageNameFromDirectory(directory));
|
|
10
|
+
const policy = options.policy ?? "allow-all";
|
|
11
|
+
await ensureEmptyDirectory(directory);
|
|
12
|
+
await mkdir(path.join(directory, "src"), { recursive: true });
|
|
13
|
+
const packageJson = {
|
|
14
|
+
name: packageName,
|
|
15
|
+
version: "0.1.0",
|
|
16
|
+
private: true,
|
|
17
|
+
type: "module",
|
|
18
|
+
engines: { node: ">=20" },
|
|
19
|
+
scripts: { start: "node src/server.mjs" },
|
|
20
|
+
dependencies: { "codemodekit": "^0.1.0" },
|
|
21
|
+
};
|
|
22
|
+
const entrypoint = path.join(directory, "src", "server.mjs");
|
|
23
|
+
await Promise.all([
|
|
24
|
+
writeFile(path.join(directory, "package.json"), `${JSON.stringify(packageJson, null, 2)}\n`, "utf8"),
|
|
25
|
+
writeFile(path.join(directory, ".gitignore"), "node_modules/\n.env\n.env.*\n!.env.example\n", "utf8"),
|
|
26
|
+
writeFile(entrypoint, renderServer({
|
|
27
|
+
serverName,
|
|
28
|
+
mcpName,
|
|
29
|
+
mcpCommand: options.mcpCommand,
|
|
30
|
+
policy,
|
|
31
|
+
}), "utf8"),
|
|
32
|
+
]);
|
|
33
|
+
if (options.install === true) {
|
|
34
|
+
await runNpmInstall(directory);
|
|
35
|
+
}
|
|
36
|
+
return { directory, entrypoint, installed: options.install === true };
|
|
37
|
+
}
|
|
38
|
+
export function renderServer(options) {
|
|
39
|
+
const policyFactory = options.policy === "allow-all" ? "allowAllToolCalls" : "denyAllToolCalls";
|
|
40
|
+
return `import {
|
|
41
|
+
${policyFactory},
|
|
42
|
+
mcp,
|
|
43
|
+
serveCodeModeStdio,
|
|
44
|
+
} from "codemodekit";
|
|
45
|
+
|
|
46
|
+
await serveCodeModeStdio({
|
|
47
|
+
name: ${JSON.stringify(options.serverName)},
|
|
48
|
+
version: "0.1.0",
|
|
49
|
+
toolPolicy: ${policyFactory}(),
|
|
50
|
+
sources: [
|
|
51
|
+
mcp.stdio({
|
|
52
|
+
name: ${JSON.stringify(options.mcpName)},
|
|
53
|
+
command: ${JSON.stringify(options.mcpCommand.command)},
|
|
54
|
+
args: ${JSON.stringify(options.mcpCommand.args)},
|
|
55
|
+
}),
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
async function ensureEmptyDirectory(directory) {
|
|
61
|
+
try {
|
|
62
|
+
const entries = await readdir(directory);
|
|
63
|
+
if (entries.length > 0) {
|
|
64
|
+
throw new Error(`Target directory is not empty: ${directory}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (isMissing(error)) {
|
|
69
|
+
await mkdir(directory, { recursive: true });
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function runNpmInstall(directory) {
|
|
76
|
+
return new Promise((resolve, reject) => {
|
|
77
|
+
const child = spawn("npm", ["install"], {
|
|
78
|
+
cwd: directory,
|
|
79
|
+
stdio: "inherit",
|
|
80
|
+
shell: false,
|
|
81
|
+
});
|
|
82
|
+
child.once("error", reject);
|
|
83
|
+
child.once("exit", (code, signal) => {
|
|
84
|
+
if (code === 0) {
|
|
85
|
+
resolve();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
reject(new Error(`npm install failed${signal === null ? ` with exit code ${String(code)}` : ` from signal ${signal}`}`));
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function packageNameFromDirectory(directory) {
|
|
93
|
+
return path.basename(directory).toLowerCase().replace(/[^a-z0-9._-]+/gu, "-");
|
|
94
|
+
}
|
|
95
|
+
function validPackageName(value) {
|
|
96
|
+
const name = required(value, "Package name");
|
|
97
|
+
if (!/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/u.test(name)) {
|
|
98
|
+
throw new TypeError(`Invalid npm package name: ${name}`);
|
|
99
|
+
}
|
|
100
|
+
return name;
|
|
101
|
+
}
|
|
102
|
+
function required(value, label) {
|
|
103
|
+
if (value.trim() === "")
|
|
104
|
+
throw new TypeError(`${label} must not be empty`);
|
|
105
|
+
return value;
|
|
106
|
+
}
|
|
107
|
+
function isMissing(error) {
|
|
108
|
+
return (error instanceof Error &&
|
|
109
|
+
"code" in error &&
|
|
110
|
+
error.code === "ENOENT");
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=scaffold.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAC;AAqB7B,M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AAI,CAAC,qCAAqC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,SAAS,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,KAAa;IAC5C,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,oBAAoB,CAAC,CAAC;IAC3E,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,MAAM,IAAI,KAAK;QACd,KAA+B,CAAC,IAAI,KAAK,QAAQ,CACnD,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-codemodekit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Scaffold a runnable CodeModeKit server from an MCP command.",
|
|
5
|
+
"author": "Stephen Brown",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/stjbrown/codemodekit.git",
|
|
10
|
+
"directory": "packages/create-codemodekit"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/stjbrown/codemodekit#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/stjbrown/codemodekit/issues"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=20"
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"create-codemodekit": "./dist/cli.js"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist/*.js",
|
|
34
|
+
"dist/*.d.ts",
|
|
35
|
+
"dist/*.map"
|
|
36
|
+
],
|
|
37
|
+
"keywords": [
|
|
38
|
+
"code-mode",
|
|
39
|
+
"mcp",
|
|
40
|
+
"model-context-protocol",
|
|
41
|
+
"scaffold"
|
|
42
|
+
],
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {}
|
|
47
|
+
}
|