kandev 0.65.0 → 0.69.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.
@@ -1,74 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.buildLaunchManifest = buildLaunchManifest;
7
- exports.writeLaunchManifest = writeLaunchManifest;
8
- exports.readLaunchManifest = readLaunchManifest;
9
- exports.allowedEnv = allowedEnv;
10
- const node_fs_1 = __importDefault(require("node:fs"));
11
- const node_path_1 = __importDefault(require("node:path"));
12
- const paths_1 = require("./paths");
13
- const ENV_ALLOWLIST = new Set([
14
- "KANDEV_HOME_DIR",
15
- "KANDEV_DATABASE_PATH",
16
- "KANDEV_SERVER_PORT",
17
- "KANDEV_WEB_INTERNAL_URL",
18
- "KANDEV_AGENT_STANDALONE_PORT",
19
- "KANDEV_LOG_LEVEL",
20
- "KANDEV_DEBUG_DEV_MODE",
21
- "KANDEV_DEBUG_AGENT_MESSAGES",
22
- "KANDEV_DEBUG_PPROF_ENABLED",
23
- "KANDEV_E2E_MOCK",
24
- "KANDEV_MOCK_AGENT",
25
- "KANDEV_MOCK_GITHUB",
26
- "KANDEV_MOCK_JIRA",
27
- "KANDEV_MOCK_LINEAR",
28
- "KANDEV_SUPERVISOR_SOCKET",
29
- "KANDEV_SUPERVISOR_MANIFEST",
30
- "KANDEV_RESTART_ADAPTER",
31
- ]);
32
- function buildLaunchManifest(input) {
33
- if (!node_path_1.default.isAbsolute(input.backend_executable)) {
34
- throw new Error("backend_executable must be absolute");
35
- }
36
- if (!node_path_1.default.isAbsolute(input.cwd)) {
37
- throw new Error("cwd must be absolute");
38
- }
39
- if (!node_path_1.default.isAbsolute(input.home_dir)) {
40
- throw new Error("home_dir must be absolute");
41
- }
42
- return {
43
- version: 1,
44
- backend_executable: input.backend_executable,
45
- argv: [...input.argv],
46
- cwd: input.cwd,
47
- env: allowedEnv(input.env),
48
- home_dir: input.home_dir,
49
- port: input.port,
50
- mode: input.mode,
51
- created_at: (input.now ?? new Date()).toISOString(),
52
- };
53
- }
54
- function writeLaunchManifest(manifest, targetPath = (0, paths_1.manifestPath)(manifest.home_dir)) {
55
- (0, paths_1.prepareSupervisorDir)(manifest.home_dir);
56
- node_fs_1.default.writeFileSync(targetPath, `${JSON.stringify(manifest, null, 2)}\n`, { mode: 0o600 });
57
- if (process.platform !== "win32") {
58
- node_fs_1.default.chmodSync(targetPath, 0o600);
59
- }
60
- return targetPath;
61
- }
62
- function readLaunchManifest(targetPath) {
63
- return JSON.parse(node_fs_1.default.readFileSync(targetPath, "utf8"));
64
- }
65
- function allowedEnv(env) {
66
- const out = {};
67
- for (const key of ENV_ALLOWLIST) {
68
- const value = env[key];
69
- if (value !== undefined) {
70
- out[key] = value;
71
- }
72
- }
73
- return out;
74
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.supervisorDir = supervisorDir;
7
- exports.manifestPath = manifestPath;
8
- exports.socketPath = socketPath;
9
- exports.prepareSupervisorDir = prepareSupervisorDir;
10
- const node_fs_1 = __importDefault(require("node:fs"));
11
- const node_path_1 = __importDefault(require("node:path"));
12
- const constants_1 = require("../constants");
13
- function supervisorDir(homeDir = (0, constants_1.resolveKandevHomeDir)()) {
14
- return node_path_1.default.join(homeDir, "supervisor");
15
- }
16
- function manifestPath(homeDir = (0, constants_1.resolveKandevHomeDir)()) {
17
- return node_path_1.default.join(supervisorDir(homeDir), "launch.json");
18
- }
19
- function socketPath(homeDir = (0, constants_1.resolveKandevHomeDir)()) {
20
- if (process.platform === "win32") {
21
- const safe = homeDir.replace(/[^a-zA-Z0-9_.-]/g, "-");
22
- return `\\\\.\\pipe\\kandev-${safe}-supervisor`;
23
- }
24
- return node_path_1.default.join(supervisorDir(homeDir), "control.sock");
25
- }
26
- function prepareSupervisorDir(homeDir = (0, constants_1.resolveKandevHomeDir)()) {
27
- const dir = supervisorDir(homeDir);
28
- node_fs_1.default.mkdirSync(dir, { recursive: true, mode: 0o700 });
29
- if (process.platform !== "win32") {
30
- node_fs_1.default.chmodSync(dir, 0o700);
31
- }
32
- return dir;
33
- }
package/dist/version.js DELETED
@@ -1,57 +0,0 @@
1
- "use strict";
2
- /**
3
- * Centralized version parsing and comparison for the CLI.
4
- *
5
- * Version format: optional "v" prefix + dot-separated numeric segments.
6
- * Examples: "v1.2", "0.3.0", "v2.0.1", "1"
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.parseVersion = parseVersion;
10
- exports.compareVersions = compareVersions;
11
- exports.sortVersionsDesc = sortVersionsDesc;
12
- /**
13
- * Parse a version string into numeric segments.
14
- * Strips leading "v" prefix if present.
15
- *
16
- * "v1.2.3" -> { raw: "v1.2.3", segments: [1, 2, 3] }
17
- * "0.3" -> { raw: "0.3", segments: [0, 3] }
18
- * "bad" -> { raw: "bad", segments: [] }
19
- */
20
- function parseVersion(version) {
21
- const cleaned = String(version).replace(/^v/, "");
22
- const parts = cleaned.split(".");
23
- const segments = [];
24
- for (const part of parts) {
25
- const n = parseInt(part, 10);
26
- if (Number.isNaN(n))
27
- return { raw: version, segments: [] };
28
- segments.push(n);
29
- }
30
- return { raw: version, segments };
31
- }
32
- /**
33
- * Compare two version strings.
34
- * Returns 1 if a > b, -1 if a < b, 0 if equal.
35
- * Missing segments are treated as 0 (e.g. "1.0" == "1.0.0").
36
- */
37
- function compareVersions(a, b) {
38
- const pa = parseVersion(a).segments;
39
- const pb = parseVersion(b).segments;
40
- const len = Math.max(pa.length, pb.length);
41
- for (let i = 0; i < len; i++) {
42
- const av = pa[i] ?? 0;
43
- const bv = pb[i] ?? 0;
44
- if (av > bv)
45
- return 1;
46
- if (av < bv)
47
- return -1;
48
- }
49
- return 0;
50
- }
51
- /**
52
- * Sort version strings in descending order (newest first).
53
- * Non-parseable strings sort to the end.
54
- */
55
- function sortVersionsDesc(versions) {
56
- return [...versions].sort((a, b) => compareVersions(b, a));
57
- }
package/dist/web.js DELETED
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.openBrowser = openBrowser;
4
- exports.launchWebApp = launchWebApp;
5
- const node_child_process_1 = require("node:child_process");
6
- const node_fs_1 = require("node:fs");
7
- // Node CLIs that install as .cmd shims on Windows. Anything in this set goes
8
- // through cmd.exe /c on win32 so we can spawn the shim safely:
9
- // - Node's spawn doesn't apply PATHEXT, so spawn("pnpm", …) hits ENOENT.
10
- // - spawn("pnpm.cmd", …) directly returns EINVAL on Node 21+ (the
11
- // CVE-2024-27980 fix forbids direct .bat/.cmd spawning).
12
- // - spawn(…, {shell:true}) works but trips DEP0190 (the args-aren't-escaped
13
- // security warning) and forks an extra cmd.exe per spawn.
14
- // Going through cmd.exe explicitly is the cleanest option: no warning, no
15
- // EINVAL, and the args (-C, --filter, identifier-like strings) contain no
16
- // cmd metacharacters that need extra escaping.
17
- const WIN_SHIM_COMMANDS = new Set(["pnpm", "npm", "npx", "yarn"]);
18
- function resolveWindowsShim(command, args) {
19
- if (process.platform !== "win32")
20
- return { command, args };
21
- if (!WIN_SHIM_COMMANDS.has(command))
22
- return { command, args };
23
- return { command: "cmd.exe", args: ["/c", command, ...args] };
24
- }
25
- let _isWSL;
26
- function isWSL() {
27
- if (_isWSL === undefined) {
28
- try {
29
- _isWSL = (0, node_fs_1.readFileSync)("/proc/version", "utf8").toLowerCase().includes("microsoft");
30
- }
31
- catch {
32
- _isWSL = false;
33
- }
34
- }
35
- return _isWSL;
36
- }
37
- function openBrowser(url) {
38
- if (process.env.KANDEV_NO_BROWSER === "1") {
39
- return;
40
- }
41
- const useCmd = process.platform === "win32" || isWSL();
42
- const opener = process.platform === "darwin" ? "open" : useCmd ? "cmd.exe" : "xdg-open";
43
- const args = useCmd ? ["/c", "start", "", url] : [url];
44
- try {
45
- const child = (0, node_child_process_1.spawn)(opener, args, { stdio: "ignore", detached: true });
46
- child.on("error", () => { }); // ignore async spawn errors (e.g. xdg-open missing)
47
- child.unref();
48
- }
49
- catch {
50
- // ignore browser launch errors
51
- }
52
- }
53
- function launchWebApp({ command, args, cwd, env, supervisor, label, quiet = false, }) {
54
- const stdio = quiet ? ["ignore", "pipe", "pipe"] : "inherit";
55
- const resolved = resolveWindowsShim(command, args);
56
- const proc = (0, node_child_process_1.spawn)(resolved.command, resolved.args, { cwd, env, stdio });
57
- supervisor.children.push(proc);
58
- // In quiet mode, only forward stderr
59
- if (quiet && proc.stderr) {
60
- proc.stderr.pipe(process.stderr);
61
- }
62
- proc.on("exit", (code, signal) => {
63
- console.error(`[kandev] ${label} exited (code=${code}, signal=${signal})`);
64
- const exitCode = signal ? 0 : (code ?? 1);
65
- void supervisor.shutdown(`${label} exit`).then(() => process.exit(exitCode));
66
- });
67
- return proc;
68
- }