@kibitzsh/kibitz 0.0.4 → 0.0.5

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,174 +1,146 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/core/platform-support.ts
31
+ var platform_support_exports = {};
32
+ __export(platform_support_exports, {
33
+ findCommandPath: () => findCommandPath,
34
+ getProviderCliCommand: () => getProviderCliCommand,
35
+ inheritShellPath: () => inheritShellPath,
36
+ resolveCmdNodeScript: () => resolveCmdNodeScript
17
37
  });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.getProviderCliCommand = getProviderCliCommand;
37
- exports.resolveCmdNodeScript = resolveCmdNodeScript;
38
- exports.inheritShellPath = inheritShellPath;
39
- exports.findCommandPath = findCommandPath;
40
- const child_process_1 = require("child_process");
41
- const fs = __importStar(require("fs"));
42
- const path = __importStar(require("path"));
43
- /**
44
- * Keep CLI discovery consistent across panel and terminal flows.
45
- */
38
+ module.exports = __toCommonJS(platform_support_exports);
39
+ var import_child_process = require("child_process");
40
+ var fs = __toESM(require("fs"));
41
+ var path = __toESM(require("path"));
46
42
  function getProviderCliCommand(provider, platform = process.platform) {
47
- return platform === 'win32' ? `${provider}.cmd` : provider;
43
+ return platform === "win32" ? `${provider}.cmd` : provider;
48
44
  }
49
- /**
50
- * Resolve npm .cmd wrappers to their underlying JavaScript file.
51
- * This avoids cmd.exe arg limits on Windows for long prompts.
52
- */
53
45
  function resolveCmdNodeScript(cmdPath) {
54
- if (!String(cmdPath || '').toLowerCase().endsWith('.cmd'))
55
- return null;
56
- try {
57
- const content = fs.readFileSync(cmdPath, 'utf8');
58
- const match = content.match(/%dp0%\\(.+?\.js)/i);
59
- if (!match)
60
- return null;
61
- const scriptPath = path.join(path.dirname(cmdPath), match[1]);
62
- return fs.existsSync(scriptPath) ? scriptPath : null;
63
- }
64
- catch {
65
- return null;
66
- }
46
+ if (!String(cmdPath || "").toLowerCase().endsWith(".cmd")) return null;
47
+ try {
48
+ const content = fs.readFileSync(cmdPath, "utf8");
49
+ const match = content.match(/%dp0%\\(.+?\.js)/i);
50
+ if (!match) return null;
51
+ const scriptPath = path.join(path.dirname(cmdPath), match[1]);
52
+ return fs.existsSync(scriptPath) ? scriptPath : null;
53
+ } catch {
54
+ return null;
55
+ }
67
56
  }
68
- /**
69
- * Merge user shell PATH into process PATH so packaged VS Code extension host
70
- * can still locate user-installed CLIs.
71
- */
72
57
  function inheritShellPath(platform = process.platform) {
73
- if (platform === 'darwin') {
74
- inheritDarwinPath();
75
- return;
76
- }
77
- if (platform === 'win32') {
78
- inheritNpmPrefixPath('win32');
79
- return;
80
- }
81
- // Linux remains best-effort in this phase.
82
- inheritNpmPrefixPath('linux');
58
+ if (platform === "darwin") {
59
+ inheritDarwinPath();
60
+ return;
61
+ }
62
+ if (platform === "win32") {
63
+ inheritNpmPrefixPath("win32");
64
+ return;
65
+ }
66
+ inheritNpmPrefixPath("linux");
83
67
  }
84
68
  function findCommandPath(command, platform = process.platform) {
85
- try {
86
- if (platform === 'win32') {
87
- const out = (0, child_process_1.execSync)(`where ${command}`, {
88
- encoding: 'utf8',
89
- timeout: 5000,
90
- stdio: ['ignore', 'pipe', 'ignore'],
91
- }).trim();
92
- const first = out.split(/\r?\n/).map((line) => line.trim()).find(Boolean);
93
- return first || undefined;
94
- }
95
- const out = (0, child_process_1.execFileSync)('which', [command], {
96
- encoding: 'utf8',
97
- timeout: 5000,
98
- stdio: ['ignore', 'pipe', 'ignore'],
99
- }).trim();
100
- return out || undefined;
101
- }
102
- catch {
103
- return undefined;
69
+ try {
70
+ if (platform === "win32") {
71
+ const out2 = (0, import_child_process.execSync)(`where ${command}`, {
72
+ encoding: "utf8",
73
+ timeout: 5e3,
74
+ stdio: ["ignore", "pipe", "ignore"]
75
+ }).trim();
76
+ const first = out2.split(/\r?\n/).map((line) => line.trim()).find(Boolean);
77
+ return first || void 0;
104
78
  }
79
+ const out = (0, import_child_process.execFileSync)("which", [command], {
80
+ encoding: "utf8",
81
+ timeout: 5e3,
82
+ stdio: ["ignore", "pipe", "ignore"]
83
+ }).trim();
84
+ return out || void 0;
85
+ } catch {
86
+ return void 0;
87
+ }
105
88
  }
106
89
  function inheritDarwinPath() {
107
- const currentPath = process.env.PATH || '';
108
- const parts = new Set(currentPath.split(path.delimiter).filter(Boolean));
109
- const candidateShells = [process.env.SHELL, '/bin/zsh', '/bin/bash']
110
- .map((value) => String(value || '').trim())
111
- .filter(Boolean)
112
- .filter((value, index, arr) => arr.indexOf(value) === index);
113
- for (const shell of candidateShells) {
114
- if (!fs.existsSync(shell))
115
- continue;
116
- try {
117
- const shellPath = (0, child_process_1.execFileSync)(shell, ['-lic', 'echo $PATH'], {
118
- encoding: 'utf8',
119
- timeout: 5000,
120
- stdio: ['ignore', 'pipe', 'ignore'],
121
- }).trim();
122
- if (!shellPath)
123
- continue;
124
- process.env.PATH = mergePath(currentPath, shellPath, parts);
125
- return;
126
- }
127
- catch {
128
- // Try next shell candidate.
129
- }
90
+ const currentPath = process.env.PATH || "";
91
+ const parts = new Set(currentPath.split(path.delimiter).filter(Boolean));
92
+ const candidateShells = [process.env.SHELL, "/bin/zsh", "/bin/bash"].map((value) => String(value || "").trim()).filter(Boolean).filter((value, index, arr) => arr.indexOf(value) === index);
93
+ for (const shell of candidateShells) {
94
+ if (!fs.existsSync(shell)) continue;
95
+ try {
96
+ const shellPath = (0, import_child_process.execFileSync)(shell, ["-lic", "echo $PATH"], {
97
+ encoding: "utf8",
98
+ timeout: 5e3,
99
+ stdio: ["ignore", "pipe", "ignore"]
100
+ }).trim();
101
+ if (!shellPath) continue;
102
+ process.env.PATH = mergePath(currentPath, shellPath, parts);
103
+ return;
104
+ } catch {
130
105
  }
106
+ }
131
107
  }
132
108
  function inheritNpmPrefixPath(platform) {
133
- const npmCommand = platform === 'win32' ? 'npm.cmd' : 'npm';
134
- try {
135
- const npmPrefix = (0, child_process_1.execFileSync)(npmCommand, ['prefix', '-g'], {
136
- encoding: 'utf8',
137
- timeout: 5000,
138
- stdio: ['ignore', 'pipe', 'ignore'],
139
- shell: platform === 'win32',
140
- }).trim();
141
- if (!npmPrefix)
142
- return;
143
- const candidates = platform === 'win32'
144
- ? [npmPrefix, path.join(npmPrefix, 'node_modules', '.bin')]
145
- : [path.join(npmPrefix, 'bin')];
146
- let nextPath = process.env.PATH || '';
147
- const parts = new Set(nextPath.split(path.delimiter).filter(Boolean));
148
- for (const candidate of candidates) {
149
- if (!candidate || parts.has(candidate))
150
- continue;
151
- nextPath = nextPath ? `${candidate}${path.delimiter}${nextPath}` : candidate;
152
- parts.add(candidate);
153
- }
154
- process.env.PATH = nextPath;
155
- }
156
- catch {
157
- // npm unavailable; keep current PATH.
109
+ const npmCommand = platform === "win32" ? "npm.cmd" : "npm";
110
+ try {
111
+ const npmPrefix = (0, import_child_process.execFileSync)(npmCommand, ["prefix", "-g"], {
112
+ encoding: "utf8",
113
+ timeout: 5e3,
114
+ stdio: ["ignore", "pipe", "ignore"],
115
+ shell: platform === "win32"
116
+ }).trim();
117
+ if (!npmPrefix) return;
118
+ const candidates = platform === "win32" ? [npmPrefix, path.join(npmPrefix, "node_modules", ".bin")] : [path.join(npmPrefix, "bin")];
119
+ let nextPath = process.env.PATH || "";
120
+ const parts = new Set(nextPath.split(path.delimiter).filter(Boolean));
121
+ for (const candidate of candidates) {
122
+ if (!candidate || parts.has(candidate)) continue;
123
+ nextPath = nextPath ? `${candidate}${path.delimiter}${nextPath}` : candidate;
124
+ parts.add(candidate);
158
125
  }
126
+ process.env.PATH = nextPath;
127
+ } catch {
128
+ }
159
129
  }
160
130
  function mergePath(currentPath, shellPath, knownParts) {
161
- const additions = [];
162
- for (const candidate of shellPath.split(path.delimiter).filter(Boolean)) {
163
- if (knownParts.has(candidate))
164
- continue;
165
- knownParts.add(candidate);
166
- additions.push(candidate);
167
- }
168
- if (additions.length === 0)
169
- return currentPath;
170
- return currentPath
171
- ? `${currentPath}${path.delimiter}${additions.join(path.delimiter)}`
172
- : additions.join(path.delimiter);
131
+ const additions = [];
132
+ for (const candidate of shellPath.split(path.delimiter).filter(Boolean)) {
133
+ if (knownParts.has(candidate)) continue;
134
+ knownParts.add(candidate);
135
+ additions.push(candidate);
136
+ }
137
+ if (additions.length === 0) return currentPath;
138
+ return currentPath ? `${currentPath}${path.delimiter}${additions.join(path.delimiter)}` : additions.join(path.delimiter);
173
139
  }
174
- //# sourceMappingURL=platform-support.js.map
140
+ // Annotate the CommonJS export names for ESM import in node:
141
+ 0 && (module.exports = {
142
+ findCommandPath,
143
+ getProviderCliCommand,
144
+ inheritShellPath,
145
+ resolveCmdNodeScript
146
+ });