cliskill 1.1.6 → 1.1.8

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,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "../chunk-6PBITIPP.js";
4
+ } from "../chunk-6IZLJMAL.js";
5
5
  import "../chunk-S7IQHES2.js";
6
6
  export {
7
7
  runCli
@@ -4007,6 +4007,7 @@ function createChildAbortController(parent, maxListeners) {
4007
4007
  const weakParentRef = new WeakRef(parent);
4008
4008
  const handler = () => {
4009
4009
  const p = weakParentRef.deref();
4010
+ if (!p) return;
4010
4011
  const signal = p instanceof AbortController ? p.signal : p.signal;
4011
4012
  weakChild.deref()?.abort(signal.reason);
4012
4013
  };
@@ -4015,6 +4016,7 @@ function createChildAbortController(parent, maxListeners) {
4015
4016
  "abort",
4016
4017
  () => {
4017
4018
  const p = weakParentRef.deref();
4019
+ if (!p) return;
4018
4020
  const signal = p instanceof AbortController ? p.signal : p.signal;
4019
4021
  signal.removeEventListener("abort", handler);
4020
4022
  },
@@ -4430,11 +4432,11 @@ async function cleanup(path) {
4430
4432
  var ScreenCapture = class {
4431
4433
  lastCapture = null;
4432
4434
  async getScreenSize() {
4433
- const platform3 = getPlatform();
4434
- if (platform3 === "win32") {
4435
+ const platform4 = getPlatform();
4436
+ if (platform4 === "win32") {
4435
4437
  return this.getScreenSizeWindows();
4436
4438
  }
4437
- if (platform3 === "darwin") {
4439
+ if (platform4 === "darwin") {
4438
4440
  return this.getScreenSizeMac();
4439
4441
  }
4440
4442
  return this.getScreenSizeLinux();
@@ -4469,11 +4471,11 @@ var ScreenCapture = class {
4469
4471
  return { width: parseInt(match[1], 10), height: parseInt(match[2], 10) };
4470
4472
  }
4471
4473
  async capture(options) {
4472
- const platform3 = getPlatform();
4474
+ const platform4 = getPlatform();
4473
4475
  let result;
4474
- if (platform3 === "win32") {
4476
+ if (platform4 === "win32") {
4475
4477
  result = await this.captureWindows(options);
4476
- } else if (platform3 === "darwin") {
4478
+ } else if (platform4 === "darwin") {
4477
4479
  result = await this.captureMac(options);
4478
4480
  } else {
4479
4481
  result = await this.captureLinux(options);
@@ -4670,12 +4672,12 @@ var KEY_MAP_LINUX = {
4670
4672
  };
4671
4673
  var InputController = class {
4672
4674
  async click(options) {
4673
- const platform3 = getPlatform2();
4675
+ const platform4 = getPlatform2();
4674
4676
  const { x, y, button = "left", count = 1 } = options;
4675
- if (platform3 === "win32") {
4677
+ if (platform4 === "win32") {
4676
4678
  return this.clickWindows(x, y, button, count);
4677
4679
  }
4678
- if (platform3 === "darwin") {
4680
+ if (platform4 === "darwin") {
4679
4681
  return this.clickMac(x, y, button, count);
4680
4682
  }
4681
4683
  return this.clickLinux(x, y, button, count);
@@ -4774,13 +4776,13 @@ var InputController = class {
4774
4776
  return `Clicked ${button} at (${x}, ${y})${count > 1 ? ` x${count}` : ""}`;
4775
4777
  }
4776
4778
  async moveMouse(x, y) {
4777
- const platform3 = getPlatform2();
4778
- if (platform3 === "win32") {
4779
+ const platform4 = getPlatform2();
4780
+ if (platform4 === "win32") {
4779
4781
  await execPowerShell2(`
4780
4782
  Add-Type -AssemblyName System.Windows.Forms
4781
4783
  [System.Windows.Forms.Cursor]::Position = [System.Drawing.Point]::new(${x}, ${y})
4782
4784
  `.trim());
4783
- } else if (platform3 === "darwin") {
4785
+ } else if (platform4 === "darwin") {
4784
4786
  await execCommand2("cliclick", [`m:${x},${y}`]);
4785
4787
  } else {
4786
4788
  await execCommand2("xdotool", ["mousemove", "--sync", String(x), String(y)]);
@@ -4788,9 +4790,9 @@ var InputController = class {
4788
4790
  return `Moved cursor to (${x}, ${y})`;
4789
4791
  }
4790
4792
  async drag(options) {
4791
- const platform3 = getPlatform2();
4793
+ const platform4 = getPlatform2();
4792
4794
  const { startX, startY, endX, endY } = options;
4793
- if (platform3 === "win32") {
4795
+ if (platform4 === "win32") {
4794
4796
  await execPowerShell2(`
4795
4797
  Add-Type @'
4796
4798
  using System;
@@ -4819,7 +4821,7 @@ var InputController = class {
4819
4821
  Start-Sleep -Milliseconds 50
4820
4822
  [DragMouse]::mouse_event([DragMouse]::LEFTUP, 0, 0, 0, [IntPtr]::Zero)
4821
4823
  `.trim());
4822
- } else if (platform3 === "darwin") {
4824
+ } else if (platform4 === "darwin") {
4823
4825
  await execCommand2("cliclick", [`dd:${startX},${startY}`, `du:${endX},${endY}`]);
4824
4826
  } else {
4825
4827
  await execCommand2("xdotool", [
@@ -4840,12 +4842,12 @@ var InputController = class {
4840
4842
  return `Dragged from (${startX}, ${startY}) to (${endX}, ${endY})`;
4841
4843
  }
4842
4844
  async typeText(options) {
4843
- const platform3 = getPlatform2();
4845
+ const platform4 = getPlatform2();
4844
4846
  const { text } = options;
4845
- if (platform3 === "win32") {
4847
+ if (platform4 === "win32") {
4846
4848
  return this.typeTextWindows(text);
4847
4849
  }
4848
- if (platform3 === "darwin") {
4850
+ if (platform4 === "darwin") {
4849
4851
  return this.typeTextMac(text);
4850
4852
  }
4851
4853
  return this.typeTextLinux(text);
@@ -4869,13 +4871,13 @@ var InputController = class {
4869
4871
  return `Typed text (${text.length} chars)`;
4870
4872
  }
4871
4873
  async keyPress(options) {
4872
- const platform3 = getPlatform2();
4874
+ const platform4 = getPlatform2();
4873
4875
  const { key } = options;
4874
4876
  const normalizedKey = key.toLowerCase();
4875
- if (platform3 === "win32") {
4877
+ if (platform4 === "win32") {
4876
4878
  return this.keyPressWindows(normalizedKey);
4877
4879
  }
4878
- if (platform3 === "darwin") {
4880
+ if (platform4 === "darwin") {
4879
4881
  return this.keyPressMac(normalizedKey);
4880
4882
  }
4881
4883
  return this.keyPressLinux(normalizedKey);
@@ -4929,15 +4931,15 @@ var InputController = class {
4929
4931
  return `Pressed key: ${key}`;
4930
4932
  }
4931
4933
  async scroll(options) {
4932
- const platform3 = getPlatform2();
4934
+ const platform4 = getPlatform2();
4933
4935
  const { amount, x, y } = options;
4934
4936
  if (x !== void 0 && y !== void 0) {
4935
4937
  await this.moveMouse(x, y);
4936
4938
  }
4937
- if (platform3 === "win32") {
4939
+ if (platform4 === "win32") {
4938
4940
  return this.scrollWindows(amount);
4939
4941
  }
4940
- if (platform3 === "darwin") {
4942
+ if (platform4 === "darwin") {
4941
4943
  return this.scrollMac(amount);
4942
4944
  }
4943
4945
  return this.scrollLinux(amount);
@@ -8193,7 +8195,7 @@ function MessageList({ messages }) {
8193
8195
 
8194
8196
  // src/ui/repl.ts
8195
8197
  import { mkdir as mkdir4, appendFile } from "fs/promises";
8196
- import { join as join12 } from "path";
8198
+ import { join as join13 } from "path";
8197
8199
  import { randomUUID as randomUUID8 } from "crypto";
8198
8200
 
8199
8201
  // src/prompts/system-prompt.ts
@@ -8379,9 +8381,33 @@ function buildSystemPrompt() {
8379
8381
  // src/mcp/client.ts
8380
8382
  import { spawn as spawn2 } from "child_process";
8381
8383
  import { createInterface } from "readline";
8384
+ import { platform as platform2 } from "os";
8385
+ import { dirname as dirname4, join as join12 } from "path";
8386
+ import { existsSync as existsSync6 } from "fs";
8382
8387
  var DEFAULT_REQUEST_TIMEOUT = 3e4;
8383
8388
  var CONNECT_TIMEOUT = 3e4;
8384
8389
  var MCP_PROTOCOL_VERSION = "2024-11-05";
8390
+ var IS_WIN32 = platform2() === "win32";
8391
+ function resolveSpawnCommand(command, args) {
8392
+ if (!IS_WIN32) return { command, args };
8393
+ const cliMap = {
8394
+ npx: "npx-cli.js",
8395
+ npm: "npm-cli.js"
8396
+ };
8397
+ const cliFile = cliMap[command];
8398
+ if (!cliFile) return { command, args };
8399
+ const nodeDir = dirname4(process.execPath);
8400
+ const candidates = [
8401
+ join12(nodeDir, "node_modules", "npm", "bin", cliFile),
8402
+ join12(nodeDir, cliFile)
8403
+ ];
8404
+ for (const candidate of candidates) {
8405
+ if (existsSync6(candidate)) {
8406
+ return { command: process.execPath, args: [candidate, ...args] };
8407
+ }
8408
+ }
8409
+ return { command: "cmd", args: ["/c", command, ...args] };
8410
+ }
8385
8411
  var MCPClient = class {
8386
8412
  config;
8387
8413
  process = null;
@@ -8496,7 +8522,8 @@ var MCPClient = class {
8496
8522
  ...process.env,
8497
8523
  ...this.config.env
8498
8524
  };
8499
- this.process = spawn2(this.config.command, this.config.args, {
8525
+ const { command, args } = resolveSpawnCommand(this.config.command, this.config.args);
8526
+ this.process = spawn2(command, args, {
8500
8527
  stdio: ["pipe", "pipe", "pipe"],
8501
8528
  env
8502
8529
  });
@@ -8917,7 +8944,7 @@ var SessionSaver = class {
8917
8944
  this.sessionId = randomUUID8();
8918
8945
  const dir = getSessionsDir();
8919
8946
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
8920
- this.filePath = join12(dir, `session-${timestamp}.jsonl`);
8947
+ this.filePath = join13(dir, `session-${timestamp}.jsonl`);
8921
8948
  }
8922
8949
  async init() {
8923
8950
  const dir = getSessionsDir();
@@ -9704,8 +9731,8 @@ function colorizeAnsi(text, ansiName) {
9704
9731
  }
9705
9732
 
9706
9733
  // src/services/cron/task-store.ts
9707
- import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync6, mkdirSync as mkdirSync2 } from "fs";
9708
- import { join as join13, dirname as dirname4 } from "path";
9734
+ import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync7, mkdirSync as mkdirSync2 } from "fs";
9735
+ import { join as join14, dirname as dirname5 } from "path";
9709
9736
  import { randomUUID as randomUUID9 } from "crypto";
9710
9737
  var DEFAULT_STORE_DIR = getDataDir();
9711
9738
  var DEFAULT_STORE_FILE = "scheduled_tasks.json";
@@ -9715,10 +9742,10 @@ var TaskStore2 = class {
9715
9742
  loaded = false;
9716
9743
  constructor(storeDir) {
9717
9744
  const dir = storeDir ?? DEFAULT_STORE_DIR;
9718
- this.filePath = join13(dir, DEFAULT_STORE_FILE);
9745
+ this.filePath = join14(dir, DEFAULT_STORE_FILE);
9719
9746
  }
9720
9747
  load() {
9721
- if (!existsSync6(this.filePath)) {
9748
+ if (!existsSync7(this.filePath)) {
9722
9749
  this.tasks.clear();
9723
9750
  this.loaded = true;
9724
9751
  return;
@@ -9736,8 +9763,8 @@ var TaskStore2 = class {
9736
9763
  this.loaded = true;
9737
9764
  }
9738
9765
  save() {
9739
- const dir = dirname4(this.filePath);
9740
- if (!existsSync6(dir)) {
9766
+ const dir = dirname5(this.filePath);
9767
+ if (!existsSync7(dir)) {
9741
9768
  mkdirSync2(dir, { recursive: true });
9742
9769
  }
9743
9770
  const data = Array.from(this.tasks.values());
@@ -10052,8 +10079,8 @@ var CronScheduler = class {
10052
10079
 
10053
10080
  // src/services/doctor.ts
10054
10081
  import { execSync as execSync3 } from "child_process";
10055
- import { readFileSync as readFileSync4, existsSync as existsSync7, statSync as statSync2 } from "fs";
10056
- import { join as join14 } from "path";
10082
+ import { readFileSync as readFileSync4, existsSync as existsSync8, statSync as statSync2 } from "fs";
10083
+ import { join as join15 } from "path";
10057
10084
  var TOOLS = [
10058
10085
  { name: "git", command: "git", versionFlag: "--version", optional: false },
10059
10086
  { name: "ripgrep (rg)", command: "rg", versionFlag: "--version", optional: true },
@@ -10080,8 +10107,8 @@ var DoctorDiagnostic = class {
10080
10107
  checkInstallation() {
10081
10108
  const execPath = process.execPath;
10082
10109
  const isNpmGlobal = execPath.includes("npm") || execPath.includes("npx");
10083
- const isLocal = existsSync7(join14(process.cwd(), "node_modules", "cliskill"));
10084
- const isPackageManager = existsSync7(join14(process.cwd(), "package.json"));
10110
+ const isLocal = existsSync8(join15(process.cwd(), "node_modules", "cliskill"));
10111
+ const isPackageManager = existsSync8(join15(process.cwd(), "package.json"));
10085
10112
  let installType = "unknown";
10086
10113
  if (isNpmGlobal) installType = "npm-global";
10087
10114
  else if (isLocal) installType = "local";
@@ -10193,7 +10220,7 @@ var DoctorDiagnostic = class {
10193
10220
  checkConfig() {
10194
10221
  const configPaths = getConfigSearchPaths();
10195
10222
  for (const configPath of configPaths) {
10196
- if (existsSync7(configPath)) {
10223
+ if (existsSync8(configPath)) {
10197
10224
  try {
10198
10225
  const raw = readFileSync4(configPath, "utf-8");
10199
10226
  JSON.parse(raw);
@@ -10224,7 +10251,7 @@ var DoctorDiagnostic = class {
10224
10251
  const configPaths = getConfigSearchPaths();
10225
10252
  let baseUrl = "";
10226
10253
  for (const configPath of configPaths) {
10227
- if (existsSync7(configPath)) {
10254
+ if (existsSync8(configPath)) {
10228
10255
  try {
10229
10256
  const raw = readFileSync4(configPath, "utf-8");
10230
10257
  const config = JSON.parse(raw);
@@ -10271,7 +10298,7 @@ var DoctorDiagnostic = class {
10271
10298
  checkDiskSpace() {
10272
10299
  const memoryDir = getDataDir();
10273
10300
  const historyFile = getDiskHistoryPath();
10274
- if (!existsSync7(memoryDir)) {
10301
+ if (!existsSync8(memoryDir)) {
10275
10302
  return {
10276
10303
  name: "Disk Space",
10277
10304
  status: "ok",
@@ -10280,7 +10307,7 @@ var DoctorDiagnostic = class {
10280
10307
  };
10281
10308
  }
10282
10309
  try {
10283
- const historyStats = existsSync7(historyFile) ? statSync2(historyFile) : null;
10310
+ const historyStats = existsSync8(historyFile) ? statSync2(historyFile) : null;
10284
10311
  const historySize = historyStats ? historyStats.size : 0;
10285
10312
  return {
10286
10313
  name: "Disk Space",
@@ -10349,8 +10376,8 @@ var DoctorDiagnostic = class {
10349
10376
 
10350
10377
  // src/services/conversation-recovery.ts
10351
10378
  import { readFile as readFile10, readdir as readdir6, stat as stat4 } from "fs/promises";
10352
- import { existsSync as existsSync8 } from "fs";
10353
- import { join as join15, basename as basename3 } from "path";
10379
+ import { existsSync as existsSync9 } from "fs";
10380
+ import { join as join16, basename as basename3 } from "path";
10354
10381
  var DEFAULT_RECOVERY_OPTIONS = {
10355
10382
  sessionId: "",
10356
10383
  repairMode: false,
@@ -10364,7 +10391,7 @@ var ConversationRecovery = class {
10364
10391
  const opts = { ...DEFAULT_RECOVERY_OPTIONS, ...options };
10365
10392
  const warnings = [];
10366
10393
  const repairs = [];
10367
- if (!existsSync8(filePath)) {
10394
+ if (!existsSync9(filePath)) {
10368
10395
  return {
10369
10396
  success: false,
10370
10397
  messages: [],
@@ -10421,7 +10448,7 @@ var ConversationRecovery = class {
10421
10448
  };
10422
10449
  }
10423
10450
  async findLatestSession(historyDir) {
10424
- if (!existsSync8(historyDir)) return null;
10451
+ if (!existsSync9(historyDir)) return null;
10425
10452
  const sessions = await this.listSessions(historyDir);
10426
10453
  if (sessions.length === 0) return null;
10427
10454
  sessions.sort(
@@ -10430,7 +10457,7 @@ var ConversationRecovery = class {
10430
10457
  return sessions[0].filePath;
10431
10458
  }
10432
10459
  async findSessionById(historyDir, sessionId) {
10433
- if (!existsSync8(historyDir)) return null;
10460
+ if (!existsSync9(historyDir)) return null;
10434
10461
  const sessions = await this.listSessions(historyDir);
10435
10462
  const match = sessions.find(
10436
10463
  (s) => s.id === sessionId || s.id.startsWith(sessionId) || basename3(s.filePath).includes(sessionId)
@@ -10440,7 +10467,7 @@ var ConversationRecovery = class {
10440
10467
  async validate(filePath) {
10441
10468
  const errors = [];
10442
10469
  const warnings = [];
10443
- if (!existsSync8(filePath)) {
10470
+ if (!existsSync9(filePath)) {
10444
10471
  return { valid: false, errors: ["File not found"], warnings: [] };
10445
10472
  }
10446
10473
  let rawContent;
@@ -10480,15 +10507,15 @@ var ConversationRecovery = class {
10480
10507
  };
10481
10508
  }
10482
10509
  async listSessions(historyDir) {
10483
- if (!existsSync8(historyDir)) return [];
10510
+ if (!existsSync9(historyDir)) return [];
10484
10511
  const entries = await readdir6(historyDir);
10485
10512
  const sessions = [];
10486
10513
  for (const entry of entries) {
10487
- const filePath = join15(historyDir, entry);
10514
+ const filePath = join16(historyDir, entry);
10488
10515
  const fileStat = await stat4(filePath);
10489
10516
  if (fileStat.isDirectory()) {
10490
- const sessionFile = join15(filePath, "conversation.jsonl");
10491
- if (existsSync8(sessionFile)) {
10517
+ const sessionFile = join16(filePath, "conversation.jsonl");
10518
+ if (existsSync9(sessionFile)) {
10492
10519
  const info2 = await this.buildSessionInfo(
10493
10520
  sessionFile,
10494
10521
  fileStat.mtimeMs
@@ -10698,7 +10725,7 @@ var ConversationRecovery = class {
10698
10725
 
10699
10726
  // src/services/deep-links.ts
10700
10727
  import { execFile as execFile4 } from "child_process";
10701
- import { platform as platform2 } from "os";
10728
+ import { platform as platform3 } from "os";
10702
10729
  import { resolve as resolve9, normalize, sep } from "path";
10703
10730
  import { promisify } from "util";
10704
10731
  var execFileAsync = promisify(execFile4);
@@ -10820,7 +10847,7 @@ var DeepLinkHandler = class {
10820
10847
  }
10821
10848
  }
10822
10849
  async registerProtocol() {
10823
- const os = platform2();
10850
+ const os = platform3();
10824
10851
  switch (os) {
10825
10852
  case "win32":
10826
10853
  await this.registerWindows();
@@ -10836,7 +10863,7 @@ var DeepLinkHandler = class {
10836
10863
  }
10837
10864
  }
10838
10865
  async unregisterProtocol() {
10839
- const os = platform2();
10866
+ const os = platform3();
10840
10867
  switch (os) {
10841
10868
  case "win32":
10842
10869
  await this.unregisterWindows();
@@ -10852,7 +10879,7 @@ var DeepLinkHandler = class {
10852
10879
  }
10853
10880
  }
10854
10881
  async isRegistered() {
10855
- const os = platform2();
10882
+ const os = platform3();
10856
10883
  switch (os) {
10857
10884
  case "win32":
10858
10885
  return this.checkWindows();
@@ -11000,10 +11027,10 @@ NoDisplay=true
11000
11027
  `;
11001
11028
  const { writeFile: writeFile5, mkdir: mkdir5 } = await import("fs/promises");
11002
11029
  const { homedir } = await import("os");
11003
- const { join: join16 } = await import("path");
11004
- const dir = join16(homedir(), ".local", "share", "applications");
11030
+ const { join: join17 } = await import("path");
11031
+ const dir = join17(homedir(), ".local", "share", "applications");
11005
11032
  await mkdir5(dir, { recursive: true });
11006
- await writeFile5(join16(dir, "cliskill.desktop"), desktopContent, "utf-8");
11033
+ await writeFile5(join17(dir, "cliskill.desktop"), desktopContent, "utf-8");
11007
11034
  try {
11008
11035
  await execFileAsync("update-desktop-database", [dir]);
11009
11036
  } catch {
@@ -11020,8 +11047,8 @@ NoDisplay=true
11020
11047
  async unregisterLinux() {
11021
11048
  const { unlink: unlink4 } = await import("fs/promises");
11022
11049
  const { homedir } = await import("os");
11023
- const { join: join16 } = await import("path");
11024
- const desktopPath = join16(
11050
+ const { join: join17 } = await import("path");
11051
+ const desktopPath = join17(
11025
11052
  homedir(),
11026
11053
  ".local",
11027
11054
  "share",
@@ -11037,8 +11064,8 @@ NoDisplay=true
11037
11064
  try {
11038
11065
  const { stat: stat5 } = await import("fs/promises");
11039
11066
  const { homedir } = await import("os");
11040
- const { join: join16 } = await import("path");
11041
- const desktopPath = join16(
11067
+ const { join: join17 } = await import("path");
11068
+ const desktopPath = join17(
11042
11069
  homedir(),
11043
11070
  ".local",
11044
11071
  "share",
@@ -12263,4 +12290,4 @@ export {
12263
12290
  MCPConnectionManager,
12264
12291
  runCli
12265
12292
  };
12266
- //# sourceMappingURL=chunk-6PBITIPP.js.map
12293
+ //# sourceMappingURL=chunk-6IZLJMAL.js.map