kenso 0.1.206 → 0.1.207

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/CHANGELOG.md CHANGED
@@ -4,6 +4,8 @@ What changed in the kenso CLI, newest first, by the day it changed. A new versio
4
4
 
5
5
  ## 2026-11-26
6
6
 
7
+ - agent setup runs the first PATH match the OS would run, not the first that exists
8
+ - run Windows' own cmd.exe, taskkill.exe and agent shims by full path
7
9
  - skill and MCP config writes never follow a planted link and keep owner-only modes
8
10
 
9
11
  ## 2026-11-25
package/dist/kenso.js CHANGED
@@ -3540,7 +3540,7 @@ var VERSION;
3540
3540
  var init_version = __esm({
3541
3541
  "src/core/version.ts"() {
3542
3542
  "use strict";
3543
- VERSION = true ? "0.1.206" : "0.0.0-dev";
3543
+ VERSION = true ? "0.1.207" : "0.0.0-dev";
3544
3544
  }
3545
3545
  });
3546
3546
 
@@ -10568,9 +10568,22 @@ var init_install = __esm({
10568
10568
  }
10569
10569
  });
10570
10570
 
10571
+ // src/core/windows.ts
10572
+ import { win32 } from "node:path";
10573
+ function system32(program, env = process.env) {
10574
+ const key = Object.keys(env).find((name) => name.toUpperCase() === "SYSTEMROOT");
10575
+ const root3 = key === void 0 ? void 0 : env[key];
10576
+ return win32.join(root3 !== void 0 && win32.isAbsolute(root3) ? root3 : "C:\\Windows", "System32", program);
10577
+ }
10578
+ var init_windows = __esm({
10579
+ "src/core/windows.ts"() {
10580
+ "use strict";
10581
+ }
10582
+ });
10583
+
10571
10584
  // src/commands/agent/mcp-config.ts
10572
10585
  import { spawnSync } from "node:child_process";
10573
- import { existsSync as existsSync6, readFileSync as readFileSync13 } from "node:fs";
10586
+ import { accessSync, constants, existsSync as existsSync6, readFileSync as readFileSync13, statSync as statSync4 } from "node:fs";
10574
10587
  import { delimiter, join as join15 } from "node:path";
10575
10588
  function parse2(text5) {
10576
10589
  try {
@@ -10640,9 +10653,23 @@ function canonical(url) {
10640
10653
  return url.trim().replace(/[?#].*$/, "").replace(/\/+$/, "");
10641
10654
  }
10642
10655
  }
10656
+ function isRunnable(path) {
10657
+ try {
10658
+ if (process.platform !== "win32") accessSync(path, constants.X_OK);
10659
+ return statSync4(path).isFile();
10660
+ } catch {
10661
+ return false;
10662
+ }
10663
+ }
10664
+ function findOnPath(names, env) {
10665
+ for (const dir3 of (env.PATH ?? env.Path ?? "").split(delimiter)) {
10666
+ const found = dir3 === "" ? void 0 : names.map((n) => join15(dir3, n)).find(isRunnable);
10667
+ if (found !== void 0) return found;
10668
+ }
10669
+ return void 0;
10670
+ }
10643
10671
  function onPath(bin, env) {
10644
- const names = process.platform === "win32" ? [`${bin}.cmd`, `${bin}.exe`, bin] : [bin];
10645
- return (env.PATH ?? env.Path ?? "").split(delimiter).some((dir3) => dir3 !== "" && names.some((n) => existsSync6(join15(dir3, n))));
10672
+ return findOnPath(process.platform === "win32" ? [`${bin}.cmd`, `${bin}.exe`, bin] : [bin], env) !== void 0;
10646
10673
  }
10647
10674
  function isPresent(client, env) {
10648
10675
  const t = TARGETS[client];
@@ -10683,10 +10710,17 @@ function addMcp(client, env, url) {
10683
10710
  if (state2.status !== "missing") return state2;
10684
10711
  if (t.command) {
10685
10712
  const [bin, ...args] = t.command(url);
10686
- if (!onPath(bin, env)) return { ...state2, status: "skipped", detail: `${bin} is not on PATH`, next };
10687
10713
  const win = process.platform === "win32";
10688
- const argv = win ? args.map((a) => /^[A-Za-z0-9_\-.:/@=+]+$/.test(a) ? a : `"${a.replace(/"/g, '""')}"`) : args;
10689
- const r = spawnSync(bin, argv, { env, encoding: "utf8", timeout: 6e4, shell: win });
10714
+ const path = findOnPath(win ? [`${bin}.cmd`, `${bin}.exe`] : [bin], env);
10715
+ if (path === void 0) return { ...state2, status: "skipped", detail: `${bin} is not on PATH`, next };
10716
+ const quote4 = (a) => /^[A-Za-z0-9_\-.:/@=+]+$/.test(a) ? a : `"${a.replace(/"/g, '""')}"`;
10717
+ const childEnv2 = Object.fromEntries(Object.entries(env).filter(([name]) => !name.toUpperCase().startsWith("KENSO_")));
10718
+ const r = spawnSync(win ? quote4(path) : path, win ? args.map(quote4) : args, {
10719
+ env: childEnv2,
10720
+ encoding: "utf8",
10721
+ timeout: 6e4,
10722
+ shell: win ? system32("cmd.exe", env) : false
10723
+ });
10690
10724
  if (r.status !== 0) {
10691
10725
  const said = `${r.stderr ?? ""}${r.stdout ?? ""}`.trim().split("\n").pop()?.slice(0, 200);
10692
10726
  return { ...state2, status: "failed", detail: `${bin} exited ${r.status ?? r.signal ?? r.error?.message}${said ? `: ${said}` : ""}`, next };
@@ -10710,6 +10744,7 @@ var SERVER_NAME, isDoc, readJson, TARGETS;
10710
10744
  var init_mcp_config = __esm({
10711
10745
  "src/commands/agent/mcp-config.ts"() {
10712
10746
  "use strict";
10747
+ init_windows();
10713
10748
  init_clients();
10714
10749
  init_install();
10715
10750
  SERVER_NAME = "kenso";
@@ -11066,7 +11101,7 @@ function openBrowser(url, deps) {
11066
11101
  deps.spawn("open", [url]);
11067
11102
  } else if (deps.platform === "win32") {
11068
11103
  if (/[&|^<>"%]/.test(url)) return;
11069
- deps.spawn("cmd", ["/c", "start", "", url]);
11104
+ deps.spawn(system32("cmd.exe"), ["/c", "start", "", url]);
11070
11105
  } else {
11071
11106
  deps.spawn("xdg-open", [url]);
11072
11107
  }
@@ -11076,6 +11111,7 @@ function openBrowser(url, deps) {
11076
11111
  var init_browser = __esm({
11077
11112
  "src/core/browser.ts"() {
11078
11113
  "use strict";
11114
+ init_windows();
11079
11115
  }
11080
11116
  });
11081
11117
 
@@ -15527,7 +15563,7 @@ var init_docs2 = __esm({
15527
15563
  });
15528
15564
 
15529
15565
  // src/commands/doctor/index.ts
15530
- import { statSync as statSync4 } from "node:fs";
15566
+ import { statSync as statSync5 } from "node:fs";
15531
15567
  function withNext(check, next) {
15532
15568
  return check.ok ? check : { ...check, next };
15533
15569
  }
@@ -15572,7 +15608,7 @@ function configCheck(env) {
15572
15608
  const file = configPath(env);
15573
15609
  let mode;
15574
15610
  try {
15575
- mode = statSync4(file).mode & 511;
15611
+ mode = statSync5(file).mode & 511;
15576
15612
  } catch (err) {
15577
15613
  if (err.code === "ENOENT") return { name: "config_permissions", ok: true, detail: `no config file at ${file}` };
15578
15614
  return { name: "config_permissions", ok: false, detail: `cannot read ${file}: ${err.message}` };
@@ -20615,7 +20651,7 @@ var init_status3 = __esm({
20615
20651
  });
20616
20652
 
20617
20653
  // src/work/files.ts
20618
- import { closeSync as closeSync3, constants, fchmodSync as fchmodSync2, fstatSync, lstatSync, openSync as openSync3, readFileSync as readFileSync18, writeFileSync as writeFileSync9 } from "node:fs";
20654
+ import { closeSync as closeSync3, constants as constants2, fchmodSync as fchmodSync2, fstatSync, lstatSync, openSync as openSync3, readFileSync as readFileSync18, writeFileSync as writeFileSync9 } from "node:fs";
20619
20655
  import { join as join23 } from "node:path";
20620
20656
  function agentName(value) {
20621
20657
  if (typeof value !== "string") return void 0;
@@ -20648,7 +20684,7 @@ function writeWorkFile(dir3, work, mode = 384) {
20648
20684
  function readRegularFile(path, what) {
20649
20685
  const notPlain = { ok: false, error: `the ${what} is not a plain file` };
20650
20686
  if (!lstatSync(path).isFile()) return notPlain;
20651
- const fd = openSync3(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
20687
+ const fd = openSync3(path, constants2.O_RDONLY | (constants2.O_NOFOLLOW ?? 0) | (constants2.O_NONBLOCK ?? 0));
20652
20688
  try {
20653
20689
  const stat4 = fstatSync(fd);
20654
20690
  if (!stat4.isFile()) return notPlain;
@@ -21588,8 +21624,8 @@ var init_egress = __esm({
21588
21624
 
21589
21625
  // src/work/job.ts
21590
21626
  import { spawn as nodeSpawn3 } from "node:child_process";
21591
- import { rmSync as rmSync6, statSync as statSync5 } from "node:fs";
21592
- import { access, constants as constants2 } from "node:fs/promises";
21627
+ import { rmSync as rmSync6, statSync as statSync6 } from "node:fs";
21628
+ import { access, constants as constants3 } from "node:fs/promises";
21593
21629
  import { delimiter as delimiter2, join as join26 } from "node:path";
21594
21630
  import { setTimeout as delay12 } from "node:timers/promises";
21595
21631
  function childEnv(parent, adapter, extra) {
@@ -21608,8 +21644,8 @@ function childEnv(parent, adapter, extra) {
21608
21644
  }
21609
21645
  async function isExecutableFile(path) {
21610
21646
  try {
21611
- await access(path, constants2.X_OK);
21612
- return statSync5(path).isFile();
21647
+ await access(path, constants3.X_OK);
21648
+ return statSync6(path).isFile();
21613
21649
  } catch {
21614
21650
  return false;
21615
21651
  }
@@ -21636,7 +21672,7 @@ async function resolveBinary(adapter, env, override2) {
21636
21672
  }
21637
21673
  return void 0;
21638
21674
  }
21639
- function signalTree(child, signal, runAs) {
21675
+ function signalTree(spawnFn, child, signal, runAs) {
21640
21676
  const pid = child.pid;
21641
21677
  if (pid === void 0) return;
21642
21678
  if (runAs) {
@@ -21647,7 +21683,7 @@ function signalTree(child, signal, runAs) {
21647
21683
  if (process.platform === "win32") {
21648
21684
  if (child.exitCode !== null || child.signalCode !== null) return;
21649
21685
  const args = ["/pid", String(pid), "/T", ...signal === "SIGKILL" ? ["/F"] : []];
21650
- nodeSpawn3("taskkill", args, { stdio: "ignore", windowsHide: true }).on("error", () => {
21686
+ spawnFn(system32("taskkill.exe"), args, { stdio: "ignore", windowsHide: true }).on("error", () => {
21651
21687
  });
21652
21688
  return;
21653
21689
  }
@@ -21737,8 +21773,8 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
21737
21773
  const stop = (why2) => {
21738
21774
  if (stopped || settled2 || exited) return;
21739
21775
  stopped = why2;
21740
- signalTree(child, "SIGTERM", runAs);
21741
- timers.push(setTimeout(() => signalTree(child, "SIGKILL", runAs), KILL_GRACE_MS));
21776
+ signalTree(spawnFn, child, "SIGTERM", runAs);
21777
+ timers.push(setTimeout(() => signalTree(spawnFn, child, "SIGKILL", runAs), KILL_GRACE_MS));
21742
21778
  };
21743
21779
  const onAbort = () => stop("abort");
21744
21780
  timers.push(setTimeout(() => stop("timeout"), Math.min(Math.max(job.timeoutMs, 1), MAX_TIMER_MS)));
@@ -21752,7 +21788,7 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
21752
21788
  child.on("exit", (code) => {
21753
21789
  exitCode = code;
21754
21790
  exited = true;
21755
- signalTree(child, "SIGKILL", runAs);
21791
+ signalTree(spawnFn, child, "SIGKILL", runAs);
21756
21792
  timers.push(
21757
21793
  setTimeout(() => {
21758
21794
  child.stdout?.destroy();
@@ -21845,6 +21881,7 @@ var OUTPUT_CAP_BYTES, KILL_GRACE_MS, KENSO_ENV_PREFIX, AGENT_ENV_NAMES, AGENT_EN
21845
21881
  var init_job = __esm({
21846
21882
  "src/work/job.ts"() {
21847
21883
  "use strict";
21884
+ init_windows();
21848
21885
  init_agent_user();
21849
21886
  init_egress();
21850
21887
  init_files();
@@ -26806,6 +26843,7 @@ var init_main = __esm({
26806
26843
  LINGERING_REQUEST_GRACE_MS = 50;
26807
26844
  JQ_HINT = "kenso has no --jq: --query filters the output with a JMESPath expression, for example --query '[].id'.";
26808
26845
  if (invokedDirectly(import.meta.url)) {
26846
+ if (process.platform === "win32") process.env.NoDefaultCurrentDirectoryInExePath = "1";
26809
26847
  const updateNotice = startUpdateNotice(process.argv.slice(2));
26810
26848
  void main(process.argv.slice(2)).then(async (code) => {
26811
26849
  process.exitCode = code;