@borrowbrain/vck 0.0.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/README.md +17 -0
- package/dist/cli.js +206 -0
- package/package.json +17 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @borrowbrain/vck
|
|
2
|
+
|
|
3
|
+
Package scaffold for the VCK command-line wrapper.
|
|
4
|
+
|
|
5
|
+
This package is private until release readiness approves npm publication.
|
|
6
|
+
|
|
7
|
+
## EPIC-42 Scope
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
vck doctor
|
|
11
|
+
vck init
|
|
12
|
+
vck update --dry-run
|
|
13
|
+
vck help
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The commands delegate to existing VCK runtime tools in the repository.
|
|
17
|
+
Write-capable update behavior, `vck new`, and `vck connect` are deferred to EPIC-43.
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// packages/vck/src/cli.ts
|
|
32
|
+
var cli_exports = {};
|
|
33
|
+
__export(cli_exports, {
|
|
34
|
+
runVckCli: () => runVckCli
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(cli_exports);
|
|
37
|
+
|
|
38
|
+
// packages/vck/src/runtime/toolRunner.ts
|
|
39
|
+
var import_node_child_process = require("node:child_process");
|
|
40
|
+
|
|
41
|
+
// packages/vck/src/runtime/repoLocator.ts
|
|
42
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
43
|
+
var import_node_path = __toESM(require("node:path"));
|
|
44
|
+
function findVckRepoRoot(startDir = process.cwd()) {
|
|
45
|
+
let currentDir = import_node_path.default.resolve(startDir);
|
|
46
|
+
while (true) {
|
|
47
|
+
if (import_node_fs.default.existsSync(import_node_path.default.join(currentDir, "agent_repo_config.yaml"))) {
|
|
48
|
+
return {
|
|
49
|
+
found: true,
|
|
50
|
+
rootDir: currentDir
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const parentDir = import_node_path.default.dirname(currentDir);
|
|
54
|
+
if (parentDir === currentDir) {
|
|
55
|
+
return {
|
|
56
|
+
found: false,
|
|
57
|
+
searchedFrom: import_node_path.default.resolve(startDir)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
currentDir = parentDir;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function rootRelative(rootDir, relativePath) {
|
|
64
|
+
return import_node_path.default.join(rootDir, relativePath);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// packages/vck/src/runtime/toolRunner.ts
|
|
68
|
+
function runNodeTool(relativeToolPath, options = {}) {
|
|
69
|
+
const repoLocation = findVckRepoRoot(options.cwd ?? process.cwd());
|
|
70
|
+
if (!repoLocation.found) {
|
|
71
|
+
const message = [
|
|
72
|
+
"VCK project not found.",
|
|
73
|
+
`Searched from: ${repoLocation.searchedFrom}`,
|
|
74
|
+
"",
|
|
75
|
+
"Run this command from inside a VCK repository, or start with:",
|
|
76
|
+
" npm create @borrowbrain/vck@latest"
|
|
77
|
+
].join("\n");
|
|
78
|
+
return {
|
|
79
|
+
status: 1,
|
|
80
|
+
stdout: "",
|
|
81
|
+
stderr: message
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const toolPath = rootRelative(repoLocation.rootDir, relativeToolPath);
|
|
85
|
+
const result = (0, import_node_child_process.spawnSync)(process.execPath, [toolPath, ...options.extraArgs ?? []], {
|
|
86
|
+
cwd: repoLocation.rootDir,
|
|
87
|
+
encoding: "utf8",
|
|
88
|
+
stdio: ["inherit", "pipe", "pipe"]
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
status: result.status ?? 1,
|
|
92
|
+
stdout: result.stdout ?? "",
|
|
93
|
+
stderr: result.stderr ?? ""
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function printAndExit(result) {
|
|
97
|
+
if (result.stdout.length > 0) {
|
|
98
|
+
process.stdout.write(result.stdout);
|
|
99
|
+
}
|
|
100
|
+
if (result.stderr.length > 0) {
|
|
101
|
+
process.stderr.write(result.stderr.endsWith("\n") ? result.stderr : `${result.stderr}
|
|
102
|
+
`);
|
|
103
|
+
}
|
|
104
|
+
process.exitCode = result.status;
|
|
105
|
+
}
|
|
106
|
+
function normalizeArgs(args) {
|
|
107
|
+
return args.filter((arg) => arg.trim().length > 0);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// packages/vck/src/commands/doctor.ts
|
|
111
|
+
function runDoctor(args) {
|
|
112
|
+
printAndExit(
|
|
113
|
+
runNodeTool("agent/support/tools/starter_doctor.js", {
|
|
114
|
+
extraArgs: args
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// packages/vck/src/commands/init.ts
|
|
120
|
+
function runInit(args) {
|
|
121
|
+
printAndExit(
|
|
122
|
+
runNodeTool("agent/support/tools/kernel_init.js", {
|
|
123
|
+
extraArgs: args
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// packages/vck/src/commands/update.ts
|
|
129
|
+
function runUpdate(args) {
|
|
130
|
+
const hasWriteIntent = args.some((arg) => arg === "--write" || arg === "--apply" || arg === "--no-dry-run");
|
|
131
|
+
if (hasWriteIntent) {
|
|
132
|
+
process.stderr.write(
|
|
133
|
+
[
|
|
134
|
+
"vck update is dry-run only in the EPIC-42 first implementation.",
|
|
135
|
+
"Use the underlying update tool directly only if a later approved scope allows write behavior.",
|
|
136
|
+
""
|
|
137
|
+
].join("\n")
|
|
138
|
+
);
|
|
139
|
+
process.exitCode = 1;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const nextArgs = args.includes("--dry-run") ? args : ["--dry-run", ...args];
|
|
143
|
+
printAndExit(
|
|
144
|
+
runNodeTool("agent/support/tools/update_kernel.js", {
|
|
145
|
+
extraArgs: nextArgs
|
|
146
|
+
})
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// packages/vck/src/runtime/prompts.ts
|
|
151
|
+
function mainHelp() {
|
|
152
|
+
return [
|
|
153
|
+
"VCK command-line wrapper",
|
|
154
|
+
"",
|
|
155
|
+
"Usage:",
|
|
156
|
+
" vck doctor",
|
|
157
|
+
" vck init [kernel-init options]",
|
|
158
|
+
" vck update --dry-run [update options]",
|
|
159
|
+
" vck help",
|
|
160
|
+
"",
|
|
161
|
+
"First setup:",
|
|
162
|
+
" npm create @borrowbrain/vck@latest",
|
|
163
|
+
"",
|
|
164
|
+
"EPIC-42 scope:",
|
|
165
|
+
" doctor routes to starter_doctor.js",
|
|
166
|
+
" init routes to kernel_init.js",
|
|
167
|
+
" update is dry-run only unless a later EPIC expands write behavior"
|
|
168
|
+
].join("\n");
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// packages/vck/src/cli.ts
|
|
172
|
+
function runVckCli(rawArgs = process.argv.slice(2)) {
|
|
173
|
+
const args = normalizeArgs(rawArgs);
|
|
174
|
+
const command = args[0] ?? "help";
|
|
175
|
+
const rest = args.slice(1);
|
|
176
|
+
switch (command) {
|
|
177
|
+
case "doctor":
|
|
178
|
+
runDoctor(rest);
|
|
179
|
+
return;
|
|
180
|
+
case "init":
|
|
181
|
+
runInit(rest);
|
|
182
|
+
return;
|
|
183
|
+
case "update":
|
|
184
|
+
runUpdate(rest);
|
|
185
|
+
return;
|
|
186
|
+
case "help":
|
|
187
|
+
case "--help":
|
|
188
|
+
case "-h":
|
|
189
|
+
process.stdout.write(`${mainHelp()}
|
|
190
|
+
`);
|
|
191
|
+
return;
|
|
192
|
+
default:
|
|
193
|
+
process.stderr.write(`Unknown vck command: ${command}
|
|
194
|
+
|
|
195
|
+
${mainHelp()}
|
|
196
|
+
`);
|
|
197
|
+
process.exitCode = 1;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (require.main === module) {
|
|
201
|
+
runVckCli();
|
|
202
|
+
}
|
|
203
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
204
|
+
0 && (module.exports = {
|
|
205
|
+
runVckCli
|
|
206
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@borrowbrain/vck",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"bin": {
|
|
7
|
+
"vck": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"package.json",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=20.9.0"
|
|
16
|
+
}
|
|
17
|
+
}
|