@polka-codes/cli 0.9.101 → 0.9.102

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.
Files changed (2) hide show
  1. package/dist/index.js +318 -104
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16767,6 +16767,184 @@ var init_fs = __esm(() => {
16767
16767
  // ../core/src/memory/index.ts
16768
16768
  var init_memory2 = () => {};
16769
16769
 
16770
+ // ../core/src/pricing/converter.ts
16771
+ function convertPortkeyToModelInfo(portkey) {
16772
+ return {
16773
+ inputPrice: (portkey.request_token?.price ?? 0) * 10,
16774
+ outputPrice: (portkey.response_token?.price ?? 0) * 10,
16775
+ cacheWritesPrice: (portkey.cache_write_input_token?.price ?? 0) * 10,
16776
+ cacheReadsPrice: (portkey.cache_read_input_token?.price ?? 0) * 10
16777
+ };
16778
+ }
16779
+
16780
+ // ../core/src/pricing/portkey-client.ts
16781
+ async function fetchWithTimeout(url2, timeoutMs) {
16782
+ const controller = new AbortController;
16783
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
16784
+ try {
16785
+ const response = await fetch(url2, { signal: controller.signal });
16786
+ return response;
16787
+ } finally {
16788
+ clearTimeout(timeout);
16789
+ }
16790
+ }
16791
+ async function sleep(ms) {
16792
+ return new Promise((resolve) => setTimeout(resolve, ms));
16793
+ }
16794
+ function shouldRetry(response, error48) {
16795
+ if (error48)
16796
+ return true;
16797
+ if (response.status >= 500)
16798
+ return true;
16799
+ return false;
16800
+ }
16801
+ async function fetchPricing(provider, model) {
16802
+ const url2 = `${PORTKEY_BASE_URL}/${provider}/${model}`;
16803
+ for (let attempt = 0;attempt <= MAX_RETRIES; attempt++) {
16804
+ try {
16805
+ const response = await fetchWithTimeout(url2, TIMEOUT_MS);
16806
+ if (!response.ok) {
16807
+ if (!shouldRetry(response, null)) {
16808
+ return null;
16809
+ }
16810
+ if (attempt < MAX_RETRIES) {
16811
+ await sleep(2 ** attempt * 1000);
16812
+ continue;
16813
+ }
16814
+ return null;
16815
+ }
16816
+ const data = await response.json();
16817
+ return data;
16818
+ } catch (error48) {
16819
+ if (attempt < MAX_RETRIES && shouldRetry(new Response(null, { status: 500 }), error48)) {
16820
+ await sleep(2 ** attempt * 1000);
16821
+ continue;
16822
+ }
16823
+ return null;
16824
+ }
16825
+ }
16826
+ return null;
16827
+ }
16828
+ var PORTKEY_BASE_URL = "https://api.portkey.ai/model-configs/pricing", TIMEOUT_MS = 5000, MAX_RETRIES = 2;
16829
+
16830
+ // ../core/src/pricing/pricing-service.ts
16831
+ import { randomUUID } from "node:crypto";
16832
+ import { mkdir, readFile as readFile2, rename, writeFile } from "node:fs/promises";
16833
+ import { homedir } from "node:os";
16834
+ import { dirname, join as join2 } from "node:path";
16835
+
16836
+ class PricingService {
16837
+ #fallbackPrices;
16838
+ #cacheFile;
16839
+ #cache = null;
16840
+ #loadPromise = null;
16841
+ constructor(fallbackPrices = {}) {
16842
+ const normalized = {};
16843
+ for (const [provider, providerInfo] of Object.entries(fallbackPrices)) {
16844
+ const normalizedProvider = provider.split("-")[0];
16845
+ normalized[normalizedProvider] = {};
16846
+ for (const [model, modelInfo] of Object.entries(providerInfo)) {
16847
+ const normalizedModel = model.replace(/[.-]/g, "");
16848
+ normalized[normalizedProvider][normalizedModel] = {
16849
+ inputPrice: modelInfo.inputPrice ?? 0,
16850
+ outputPrice: modelInfo.outputPrice ?? 0,
16851
+ cacheWritesPrice: modelInfo.cacheWritesPrice ?? 0,
16852
+ cacheReadsPrice: modelInfo.cacheReadsPrice ?? 0
16853
+ };
16854
+ }
16855
+ }
16856
+ this.#fallbackPrices = normalized;
16857
+ this.#cacheFile = join2(homedir(), ".config", "polkacodes", "pricing-cache.json");
16858
+ }
16859
+ async#load() {
16860
+ if (this.#loadPromise) {
16861
+ return this.#loadPromise;
16862
+ }
16863
+ this.#loadPromise = (async () => {
16864
+ this.#cache = new Map;
16865
+ try {
16866
+ const content = await readFile2(this.#cacheFile, "utf-8");
16867
+ const data = JSON.parse(content);
16868
+ for (const [key, value] of Object.entries(data)) {
16869
+ this.#cache.set(key, value);
16870
+ }
16871
+ } catch {}
16872
+ })();
16873
+ return this.#loadPromise;
16874
+ }
16875
+ async#get(provider, model) {
16876
+ await this.#load();
16877
+ const key = `${provider}:${model}`;
16878
+ const entry = this.#cache?.get(key);
16879
+ if (!entry) {
16880
+ return null;
16881
+ }
16882
+ if (Date.now() - entry.timestamp > CACHE_TTL_MS) {
16883
+ this.#cache?.delete(key);
16884
+ return null;
16885
+ }
16886
+ return entry.pricing;
16887
+ }
16888
+ async#set(provider, model, pricing) {
16889
+ await this.#load();
16890
+ const key = `${provider}:${model}`;
16891
+ this.#cache?.set(key, {
16892
+ pricing,
16893
+ timestamp: Date.now()
16894
+ });
16895
+ await this.#save();
16896
+ }
16897
+ async#save() {
16898
+ if (!this.#cache) {
16899
+ return;
16900
+ }
16901
+ try {
16902
+ const dir = dirname(this.#cacheFile);
16903
+ await mkdir(dir, { recursive: true });
16904
+ const data = {};
16905
+ for (const [key, value] of this.#cache.entries()) {
16906
+ data[key] = value;
16907
+ }
16908
+ const tempFile = `${this.#cacheFile}.${randomUUID()}.tmp`;
16909
+ await writeFile(tempFile, JSON.stringify(data, null, 2), "utf-8");
16910
+ await rename(tempFile, this.#cacheFile);
16911
+ } catch {}
16912
+ }
16913
+ async getPricing(provider, model) {
16914
+ const normalizedProvider = provider.split("-")[0];
16915
+ const normalizedModel = model.replace(/[.-]/g, "");
16916
+ const cached2 = await this.#get(normalizedProvider, normalizedModel);
16917
+ if (cached2) {
16918
+ return cached2;
16919
+ }
16920
+ const fallbackPrice = this.#fallbackPrices[normalizedProvider]?.[normalizedModel];
16921
+ if (fallbackPrice) {
16922
+ return fallbackPrice;
16923
+ }
16924
+ const portkeyPricing = await fetchPricing(normalizedProvider, model);
16925
+ if (portkeyPricing) {
16926
+ const modelInfo = convertPortkeyToModelInfo(portkeyPricing);
16927
+ await this.#set(normalizedProvider, normalizedModel, modelInfo);
16928
+ return modelInfo;
16929
+ }
16930
+ return {
16931
+ inputPrice: 0,
16932
+ outputPrice: 0,
16933
+ cacheWritesPrice: 0,
16934
+ cacheReadsPrice: 0
16935
+ };
16936
+ }
16937
+ }
16938
+ var CACHE_TTL_MS;
16939
+ var init_pricing_service = __esm(() => {
16940
+ CACHE_TTL_MS = 7 * 24 * 60 * 60 * 1000;
16941
+ });
16942
+
16943
+ // ../core/src/pricing/index.ts
16944
+ var init_pricing = __esm(() => {
16945
+ init_pricing_service();
16946
+ });
16947
+
16770
16948
  // ../core/src/skills/constants.ts
16771
16949
  var SKILL_LIMITS, IGNORED_DIRECTORIES, SUSPICIOUS_PATTERNS, SKILL_ERROR_MESSAGES, SOURCE_ICONS;
16772
16950
  var init_constants = __esm(() => {
@@ -23791,7 +23969,7 @@ var init_types = __esm(() => {
23791
23969
  });
23792
23970
 
23793
23971
  // ../core/src/skills/discovery.ts
23794
- import { homedir } from "node:os";
23972
+ import { homedir as homedir2 } from "node:os";
23795
23973
  function isBinaryFile(filename) {
23796
23974
  const ext = filename.toLowerCase().slice(filename.lastIndexOf("."));
23797
23975
  return BINARY_EXTENSIONS.includes(ext);
@@ -23831,7 +24009,7 @@ class SkillDiscoveryService {
23831
24009
  pluginSkillsDirs;
23832
24010
  constructor(options) {
23833
24011
  this.fs = options.fs ?? new NodeFileSystemProvider;
23834
- this.personalSkillsDir = options.personalSkillsDir ?? this.fs.join(homedir(), ".claude", "skills");
24012
+ this.personalSkillsDir = options.personalSkillsDir ?? this.fs.join(homedir2(), ".claude", "skills");
23835
24013
  this.projectSkillsDir = this.fs.join(options.cwd, ".claude", "skills");
23836
24014
  this.pluginSkillsDirs = options.pluginSkillsDirs ?? [];
23837
24015
  }
@@ -24075,19 +24253,19 @@ var init_discovery = __esm(() => {
24075
24253
  });
24076
24254
 
24077
24255
  // ../core/src/skills/validation.ts
24078
- import { join as join2, normalize as normalize2 } from "node:path";
24256
+ import { join as join3, normalize as normalize2 } from "node:path";
24079
24257
  function validateSkillSecurity(skill) {
24080
24258
  const { MAX_FILE_SIZE, MAX_SKILL_SIZE } = SKILL_LIMITS;
24081
24259
  let totalSize = 0;
24082
24260
  const contentSize = Buffer.byteLength(skill.content, "utf8");
24083
24261
  if (contentSize > MAX_FILE_SIZE) {
24084
- throw new SkillValidationError(`SKILL.md content exceeds size limit (${contentSize} > ${MAX_FILE_SIZE})`, join2(skill.path, "SKILL.md"));
24262
+ throw new SkillValidationError(`SKILL.md content exceeds size limit (${contentSize} > ${MAX_FILE_SIZE})`, join3(skill.path, "SKILL.md"));
24085
24263
  }
24086
24264
  totalSize += contentSize;
24087
24265
  for (const [filename, content] of skill.files) {
24088
24266
  const fileSize = Buffer.byteLength(content, "utf8");
24089
24267
  if (fileSize > MAX_FILE_SIZE) {
24090
- throw new SkillValidationError(`File ${filename} exceeds size limit (${fileSize} > ${MAX_FILE_SIZE})`, join2(skill.path, filename));
24268
+ throw new SkillValidationError(`File ${filename} exceeds size limit (${fileSize} > ${MAX_FILE_SIZE})`, join3(skill.path, filename));
24091
24269
  }
24092
24270
  totalSize += fileSize;
24093
24271
  }
@@ -24096,7 +24274,7 @@ function validateSkillSecurity(skill) {
24096
24274
  }
24097
24275
  validateContentSecurity(skill.content, skill.path);
24098
24276
  for (const [filename, content] of skill.files) {
24099
- validateContentSecurity(content, join2(skill.path, filename));
24277
+ validateContentSecurity(content, join3(skill.path, filename));
24100
24278
  }
24101
24279
  }
24102
24280
  function validateContentSecurity(content, path) {
@@ -25519,9 +25697,11 @@ var init_tools2 = __esm(() => {
25519
25697
  class UsageMeter {
25520
25698
  #totals = { input: 0, output: 0, cachedRead: 0, cost: 0, messageCount: 0 };
25521
25699
  #providerMetadataEntries = [];
25700
+ #pendingUpdates = new Set;
25522
25701
  #modelInfos;
25523
25702
  #maxMessages;
25524
25703
  #maxCost;
25704
+ #pricingService;
25525
25705
  constructor(modelInfos = {}, opts = {}) {
25526
25706
  const infos = {};
25527
25707
  for (const [provider2, providerInfo] of Object.entries(modelInfos)) {
@@ -25537,6 +25717,7 @@ class UsageMeter {
25537
25717
  this.#modelInfos = infos;
25538
25718
  this.#maxMessages = opts.maxMessages ?? 1000;
25539
25719
  this.#maxCost = opts.maxCost ?? 100;
25720
+ this.#pricingService = opts.pricingService;
25540
25721
  }
25541
25722
  #calculateUsage(usage, providerMetadata, modelInfo) {
25542
25723
  const providerMetadataKey = Object.keys(providerMetadata ?? {})[0];
@@ -25587,28 +25768,52 @@ class UsageMeter {
25587
25768
  }
25588
25769
  }
25589
25770
  addUsage(llm, resp, options = {}) {
25590
- const modelInfo = options.modelInfo ?? this.#modelInfos[`${llm.provider.split(".")[0]}:${llm.modelId.replace(/[.-]/g, "")}`] ?? {
25591
- inputPrice: 0,
25592
- outputPrice: 0,
25593
- cacheWritesPrice: 0,
25594
- cacheReadsPrice: 0
25595
- };
25596
- const usage = "totalUsage" in resp ? resp.totalUsage : resp.usage;
25597
- const result = this.#calculateUsage(usage, resp.providerMetadata, modelInfo);
25598
- this.#totals.input += result.input || 0;
25599
- this.#totals.output += result.output || 0;
25600
- this.#totals.cachedRead += result.cachedRead || 0;
25601
- this.#totals.cost += result.cost || 0;
25602
- this.#totals.messageCount += 1;
25603
- if (resp.providerMetadata && Object.keys(resp.providerMetadata).length > 0) {
25604
- const providerKey = Object.keys(resp.providerMetadata)[0];
25605
- this.#providerMetadataEntries.push({
25606
- provider: providerKey || llm.provider,
25607
- model: llm.modelId,
25608
- metadata: resp.providerMetadata[providerKey] || resp.providerMetadata,
25609
- timestamp: Date.now()
25610
- });
25611
- }
25771
+ const provider2 = llm.provider.split(".")[0];
25772
+ const normalizedModel = llm.modelId.replace(/[.-]/g, "");
25773
+ const key = `${provider2}:${normalizedModel}`;
25774
+ let modelInfo = options.modelInfo ?? this.#modelInfos[key];
25775
+ const updatePromise = (async () => {
25776
+ try {
25777
+ if (!modelInfo && this.#pricingService) {
25778
+ modelInfo = await this.#pricingService.getPricing(provider2, llm.modelId);
25779
+ this.#modelInfos[key] = modelInfo;
25780
+ }
25781
+ } catch {
25782
+ modelInfo = {
25783
+ inputPrice: 0,
25784
+ outputPrice: 0,
25785
+ cacheWritesPrice: 0,
25786
+ cacheReadsPrice: 0
25787
+ };
25788
+ }
25789
+ modelInfo = modelInfo ?? {
25790
+ inputPrice: 0,
25791
+ outputPrice: 0,
25792
+ cacheWritesPrice: 0,
25793
+ cacheReadsPrice: 0
25794
+ };
25795
+ const usage = "totalUsage" in resp ? resp.totalUsage : resp.usage;
25796
+ const result = this.#calculateUsage(usage, resp.providerMetadata, modelInfo);
25797
+ this.#totals.input += result.input || 0;
25798
+ this.#totals.output += result.output || 0;
25799
+ this.#totals.cachedRead += result.cachedRead || 0;
25800
+ this.#totals.cost += result.cost || 0;
25801
+ this.#totals.messageCount += 1;
25802
+ if (resp.providerMetadata && Object.keys(resp.providerMetadata).length > 0) {
25803
+ const providerKey = Object.keys(resp.providerMetadata)[0];
25804
+ this.#providerMetadataEntries.push({
25805
+ provider: providerKey || llm.provider,
25806
+ model: llm.modelId,
25807
+ metadata: resp.providerMetadata[providerKey] || resp.providerMetadata,
25808
+ timestamp: Date.now()
25809
+ });
25810
+ }
25811
+ })();
25812
+ this.#pendingUpdates.add(updatePromise);
25813
+ updatePromise.finally(() => {
25814
+ this.#pendingUpdates.delete(updatePromise);
25815
+ });
25816
+ return updatePromise;
25612
25817
  }
25613
25818
  setUsage(newUsage, options = {}) {
25614
25819
  if (newUsage.input != null)
@@ -25692,13 +25897,17 @@ class UsageMeter {
25692
25897
  this.#totals.messageCount += otherUsage.messageCount;
25693
25898
  this.#providerMetadataEntries.push(...other.providerMetadata);
25694
25899
  }
25900
+ async waitForPending() {
25901
+ const pending = Array.from(this.#pendingUpdates);
25902
+ await Promise.allSettled(pending);
25903
+ }
25695
25904
  getUsageText() {
25696
25905
  const u = this.usage;
25697
25906
  return `Usage - messages: ${u.messageCount}, input: ${u.input}, cached: ${u.cachedRead}, output: ${u.output}, cost: $${u.cost.toFixed(4)}`;
25698
25907
  }
25699
25908
  onFinishHandler(llm) {
25700
- return (evt) => {
25701
- this.addUsage(llm, evt);
25909
+ return async (evt) => {
25910
+ await this.addUsage(llm, evt);
25702
25911
  };
25703
25912
  }
25704
25913
  }
@@ -40926,6 +41135,7 @@ var init_src = __esm(() => {
40926
41135
  init_errors3();
40927
41136
  init_fs();
40928
41137
  init_memory2();
41138
+ init_pricing();
40929
41139
  init_skills();
40930
41140
  init_tools();
40931
41141
  init_tools2();
@@ -43311,11 +43521,11 @@ var init_lodash = __esm(() => {
43311
43521
 
43312
43522
  // ../cli-shared/src/config.ts
43313
43523
  import { existsSync as existsSync2, readFileSync } from "node:fs";
43314
- import { readFile as readFile2 } from "node:fs/promises";
43315
- import { homedir as homedir2 } from "node:os";
43316
- import { join as join3 } from "node:path";
43317
- function getGlobalConfigPath(home = homedir2()) {
43318
- return join3(home, ".config", "polkacodes", "config.yml");
43524
+ import { readFile as readFile3 } from "node:fs/promises";
43525
+ import { homedir as homedir3 } from "node:os";
43526
+ import { join as join4 } from "node:path";
43527
+ function getGlobalConfigPath(home = homedir3()) {
43528
+ return join4(home, ".config", "polkacodes", "config.yml");
43319
43529
  }
43320
43530
  function loadConfigAtPath(path) {
43321
43531
  try {
@@ -43390,7 +43600,7 @@ async function resolveRules(rules) {
43390
43600
  }
43391
43601
  } else if ("path" in rule) {
43392
43602
  if (existsSync2(rule.path)) {
43393
- return await readFile2(rule.path, "utf-8");
43603
+ return await readFile3(rule.path, "utf-8");
43394
43604
  }
43395
43605
  console.warn(`Rule file not found: ${rule.path}`);
43396
43606
  }
@@ -43400,7 +43610,7 @@ async function resolveRules(rules) {
43400
43610
 
43401
43611
  `);
43402
43612
  }
43403
- async function loadConfig2(paths, cwd = process.cwd(), home = homedir2()) {
43613
+ async function loadConfig2(paths, cwd = process.cwd(), home = homedir3()) {
43404
43614
  const configs = [];
43405
43615
  const globalConfigPath = getGlobalConfigPath(home);
43406
43616
  if (existsSync2(globalConfigPath)) {
@@ -43429,7 +43639,7 @@ ${error48}`);
43429
43639
  }
43430
43640
  }
43431
43641
  } else {
43432
- const configPath = join3(cwd, localConfigFileName);
43642
+ const configPath = join4(cwd, localConfigFileName);
43433
43643
  try {
43434
43644
  const projectConfig = readConfig(configPath);
43435
43645
  configs.push(projectConfig);
@@ -43520,7 +43730,7 @@ class MemoryManager {
43520
43730
 
43521
43731
  // ../cli-shared/src/project-scope.ts
43522
43732
  import { existsSync as existsSync3 } from "node:fs";
43523
- import { dirname, normalize as normalize3, resolve as resolve2, sep } from "node:path";
43733
+ import { dirname as dirname2, normalize as normalize3, resolve as resolve2, sep } from "node:path";
43524
43734
  function detectProjectScope(cwd) {
43525
43735
  const projectPath = findProjectRoot(cwd);
43526
43736
  if (!projectPath) {
@@ -43554,7 +43764,7 @@ function findProjectRoot(dir) {
43554
43764
  return dir;
43555
43765
  }
43556
43766
  }
43557
- const parent = dirname(dir);
43767
+ const parent = dirname2(dir);
43558
43768
  if (parent === dir) {
43559
43769
  return null;
43560
43770
  }
@@ -51317,7 +51527,7 @@ var require_gaxios = __commonJS((exports) => {
51317
51527
  var retry_js_1 = require_retry();
51318
51528
  var stream_1 = __require("stream");
51319
51529
  var interceptor_js_1 = require_interceptor();
51320
- var randomUUID = async () => globalThis.crypto?.randomUUID() || (await import("crypto")).randomUUID();
51530
+ var randomUUID2 = async () => globalThis.crypto?.randomUUID() || (await import("crypto")).randomUUID();
51321
51531
  var HTTP_STATUS_NO_CONTENT = 204;
51322
51532
 
51323
51533
  class Gaxios {
@@ -51407,8 +51617,8 @@ var require_gaxios = __commonJS((exports) => {
51407
51617
  } else {
51408
51618
  err = new common_js_1.GaxiosError("Unexpected Gaxios Error", opts, undefined, e2);
51409
51619
  }
51410
- const { shouldRetry, config: config3 } = await (0, retry_js_1.getRetryConfig)(err);
51411
- if (shouldRetry && config3) {
51620
+ const { shouldRetry: shouldRetry2, config: config3 } = await (0, retry_js_1.getRetryConfig)(err);
51621
+ if (shouldRetry2 && config3) {
51412
51622
  err.config.retryConfig.currentRetryAttempt = config3.retryConfig.currentRetryAttempt;
51413
51623
  opts.retryConfig = err.config?.retryConfig;
51414
51624
  this.#appendTimeoutToSignal(opts);
@@ -51528,7 +51738,7 @@ var require_gaxios = __commonJS((exports) => {
51528
51738
  }
51529
51739
  const shouldDirectlyPassData = typeof opts.data === "string" || opts.data instanceof ArrayBuffer || opts.data instanceof Blob || globalThis.File && opts.data instanceof File || opts.data instanceof FormData || opts.data instanceof stream_1.Readable || opts.data instanceof ReadableStream || opts.data instanceof String || opts.data instanceof URLSearchParams || ArrayBuffer.isView(opts.data) || ["Blob", "File", "FormData"].includes(opts.data?.constructor?.name || "");
51530
51740
  if (opts.multipart?.length) {
51531
- const boundary = await randomUUID();
51741
+ const boundary = await randomUUID2();
51532
51742
  preparedHeaders.set("content-type", `multipart/related; boundary=${boundary}`);
51533
51743
  opts.body = stream_1.Readable.from(this.getMultipartRequest(opts.multipart, boundary));
51534
51744
  } else if (shouldDirectlyPassData) {
@@ -56668,7 +56878,7 @@ var require_src6 = __commonJS((exports) => {
56668
56878
  });
56669
56879
  };
56670
56880
  }
56671
- var readFile3 = fs3.readFile ? (0, _util.promisify)(fs3.readFile) : /* @__PURE__ */ _asyncToGenerator(/* @__PURE__ */ _regenerator().m(function _callee() {
56881
+ var readFile4 = fs3.readFile ? (0, _util.promisify)(fs3.readFile) : /* @__PURE__ */ _asyncToGenerator(/* @__PURE__ */ _regenerator().m(function _callee() {
56672
56882
  return _regenerator().w(function(_context) {
56673
56883
  while (true)
56674
56884
  switch (_context.n) {
@@ -56795,7 +57005,7 @@ var require_src6 = __commonJS((exports) => {
56795
57005
  break;
56796
57006
  case 1:
56797
57007
  _context2.n = 2;
56798
- return readFile3(keyFile, "utf8");
57008
+ return readFile4(keyFile, "utf8");
56799
57009
  case 2:
56800
57010
  key = _context2.v;
56801
57011
  body = JSON.parse(key);
@@ -56813,7 +57023,7 @@ var require_src6 = __commonJS((exports) => {
56813
57023
  });
56814
57024
  case 4:
56815
57025
  _context2.n = 5;
56816
- return readFile3(keyFile, "utf8");
57026
+ return readFile4(keyFile, "utf8");
56817
57027
  case 5:
56818
57028
  _privateKey = _context2.v;
56819
57029
  return _context2.a(2, {
@@ -58051,7 +58261,7 @@ var require_filesubjecttokensupplier = __commonJS((exports) => {
58051
58261
  exports.FileSubjectTokenSupplier = undefined;
58052
58262
  var util_1 = __require("util");
58053
58263
  var fs3 = __require("fs");
58054
- var readFile3 = (0, util_1.promisify)(fs3.readFile ?? (() => {}));
58264
+ var readFile4 = (0, util_1.promisify)(fs3.readFile ?? (() => {}));
58055
58265
  var realpath = (0, util_1.promisify)(fs3.realpath ?? (() => {}));
58056
58266
  var lstat = (0, util_1.promisify)(fs3.lstat ?? (() => {}));
58057
58267
 
@@ -58078,7 +58288,7 @@ var require_filesubjecttokensupplier = __commonJS((exports) => {
58078
58288
  throw err;
58079
58289
  }
58080
58290
  let subjectToken;
58081
- const rawText = await readFile3(parsedFilePath, { encoding: "utf8" });
58291
+ const rawText = await readFile4(parsedFilePath, { encoding: "utf8" });
58082
58292
  if (this.formatType === "text") {
58083
58293
  subjectToken = rawText;
58084
58294
  } else if (this.formatType === "json" && this.subjectTokenFieldName) {
@@ -73731,10 +73941,10 @@ var init_checkRipgrep = __esm(() => {
73731
73941
 
73732
73942
  // ../cli-shared/src/utils/listFiles.ts
73733
73943
  import { promises as fs3 } from "node:fs";
73734
- import { join as join4, relative, resolve as resolve3 } from "node:path";
73944
+ import { join as join5, relative, resolve as resolve3 } from "node:path";
73735
73945
  async function extendPatterns(basePatterns, dirPath) {
73736
73946
  try {
73737
- const gitignorePath = join4(dirPath, ".gitignore");
73947
+ const gitignorePath = join5(dirPath, ".gitignore");
73738
73948
  const content = await fs3.readFile(gitignorePath, "utf8");
73739
73949
  const lines = content.split(/\r?\n/).filter(Boolean);
73740
73950
  return [...basePatterns, ...lines];
@@ -73750,7 +73960,7 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles, includ
73750
73960
  if (!includeIgnored) {
73751
73961
  rootPatterns.push(...DEFAULT_IGNORES);
73752
73962
  try {
73753
- const rootGitignore = await fs3.readFile(join4(cwd, ".gitignore"), "utf8");
73963
+ const rootGitignore = await fs3.readFile(join5(cwd, ".gitignore"), "utf8");
73754
73964
  const lines = rootGitignore.split(/\r?\n/).filter(Boolean);
73755
73965
  rootPatterns = [...rootPatterns, ...lines];
73756
73966
  } catch {}
@@ -73772,7 +73982,7 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles, includ
73772
73982
  const entries = await fs3.readdir(currentPath, { withFileTypes: true });
73773
73983
  entries.sort((a, b) => a.name.localeCompare(b.name));
73774
73984
  for (const entry of entries) {
73775
- const fullPath = join4(currentPath, entry.name);
73985
+ const fullPath = join5(currentPath, entry.name);
73776
73986
  const relPath = relative(cwd, fullPath).replace(/\\/g, "/");
73777
73987
  if (folderIg.ignores(relPath)) {
73778
73988
  continue;
@@ -73789,7 +73999,7 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles, includ
73789
73999
  results.push(relPath);
73790
74000
  if (results.length >= maxCount) {
73791
74001
  const remainingEntries = entries.slice(entries.indexOf(entry) + 1);
73792
- const hasRemainingFiles = remainingEntries.some((e2) => !e2.isDirectory() && !folderIg.ignores(relative(cwd, join4(currentPath, e2.name)).replace(/\\/g, "/")));
74002
+ const hasRemainingFiles = remainingEntries.some((e2) => !e2.isDirectory() && !folderIg.ignores(relative(cwd, join5(currentPath, e2.name)).replace(/\\/g, "/")));
73793
74003
  if (hasRemainingFiles) {
73794
74004
  const marker16 = `${currentRelPath}/(files omitted)`;
73795
74005
  results.push(marker16);
@@ -73891,8 +74101,8 @@ var init_searchFiles2 = __esm(() => {
73891
74101
 
73892
74102
  // ../cli-shared/src/provider.ts
73893
74103
  import { spawn as spawn2 } from "node:child_process";
73894
- import { mkdir, readFile as readFile3, rename, unlink, writeFile } from "node:fs/promises";
73895
- import { dirname as dirname2, normalize as normalize4, resolve as resolve4 } from "node:path";
74104
+ import { mkdir as mkdir2, readFile as readFile4, rename as rename2, unlink, writeFile as writeFile2 } from "node:fs/promises";
74105
+ import { dirname as dirname3, normalize as normalize4, resolve as resolve4 } from "node:path";
73896
74106
 
73897
74107
  class InMemoryStore {
73898
74108
  #data;
@@ -74068,7 +74278,7 @@ ${content}`;
74068
74278
  throw new Error(`Not allow to access file ${path}`);
74069
74279
  }
74070
74280
  try {
74071
- return await readFile3(path, "utf8");
74281
+ return await readFile4(path, "utf8");
74072
74282
  } catch (_e) {
74073
74283
  return;
74074
74284
  }
@@ -74077,8 +74287,8 @@ ${content}`;
74077
74287
  if (ig.ignores(path)) {
74078
74288
  throw new Error(`Not allow to access file ${path}`);
74079
74289
  }
74080
- await mkdir(dirname2(path), { recursive: true });
74081
- return await writeFile(path, content, "utf8");
74290
+ await mkdir2(dirname3(path), { recursive: true });
74291
+ return await writeFile2(path, content, "utf8");
74082
74292
  },
74083
74293
  removeFile: async (path) => {
74084
74294
  if (ig.ignores(path)) {
@@ -74090,7 +74300,7 @@ ${content}`;
74090
74300
  if (ig.ignores(sourcePath) || ig.ignores(targetPath)) {
74091
74301
  throw new Error(`Not allow to access file ${sourcePath} or ${targetPath}`);
74092
74302
  }
74093
- return await rename(sourcePath, targetPath);
74303
+ return await rename2(sourcePath, targetPath);
74094
74304
  },
74095
74305
  listFiles: async (path, recursive, maxCount, includeIgnored) => {
74096
74306
  return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles, includeIgnored);
@@ -74102,7 +74312,7 @@ ${content}`;
74102
74312
  if (!resolvedPath.startsWith(process.cwd())) {
74103
74313
  throw new Error(`Access to file path "${filePath}" is restricted.`);
74104
74314
  }
74105
- const data2 = await readFile3(resolvedPath);
74315
+ const data2 = await readFile4(resolvedPath);
74106
74316
  const mediaType2 = $lookup(resolvedPath) || "application/octet-stream";
74107
74317
  return {
74108
74318
  base64Data: data2.toString("base64"),
@@ -76525,10 +76735,10 @@ var require_sql_wasm = __commonJS((exports, module) => {
76525
76735
 
76526
76736
  // ../cli-shared/src/sqlite-memory-store.ts
76527
76737
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
76528
- import { randomUUID } from "node:crypto";
76738
+ import { randomUUID as randomUUID2 } from "node:crypto";
76529
76739
  import { existsSync as existsSync4 } from "node:fs";
76530
- import { mkdir as mkdir2, readdir as readdir2, readFile as readFile4, rename as rename2, unlink as unlink2, writeFile as writeFile2 } from "node:fs/promises";
76531
- import { basename as basename2, dirname as dirname3, resolve as resolve5 } from "node:path";
76740
+ import { mkdir as mkdir3, readdir as readdir2, readFile as readFile5, rename as rename3, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
76741
+ import { basename as basename2, dirname as dirname4, resolve as resolve5 } from "node:path";
76532
76742
  import { fileURLToPath } from "node:url";
76533
76743
 
76534
76744
  class FileLock {
@@ -76550,7 +76760,7 @@ class FileLock {
76550
76760
  }
76551
76761
  FileLock.lastCleanupTime = now2;
76552
76762
  try {
76553
- const lockDir = dirname3(dbPath);
76763
+ const lockDir = dirname4(dbPath);
76554
76764
  const dbBaseName = basename2(dbPath);
76555
76765
  const files = await readdir2(lockDir);
76556
76766
  const now3 = Date.now();
@@ -76587,7 +76797,7 @@ class FileLock {
76587
76797
  pid: process.pid,
76588
76798
  acquiredAt: Date.now()
76589
76799
  });
76590
- await writeFile2(this.lockfilePath, lockData, {
76800
+ await writeFile3(this.lockfilePath, lockData, {
76591
76801
  flag: "wx",
76592
76802
  mode: 384
76593
76803
  });
@@ -76596,23 +76806,23 @@ class FileLock {
76596
76806
  const errorCode = error48?.code;
76597
76807
  if (errorCode === "EEXIST") {
76598
76808
  try {
76599
- const lockContent = await readFile4(this.lockfilePath, "utf-8");
76809
+ const lockContent = await readFile5(this.lockfilePath, "utf-8");
76600
76810
  const lockData = JSON.parse(lockContent);
76601
76811
  if (!lockData || typeof lockData.acquiredAt !== "number" || lockData.acquiredAt <= 0) {
76602
76812
  console.warn(`[FileLock] Lock file has invalid acquiredAt, treating as stale`);
76603
- await rename2(this.lockfilePath, `${this.lockfilePath}.invalid.${Date.now()}`);
76813
+ await rename3(this.lockfilePath, `${this.lockfilePath}.invalid.${Date.now()}`);
76604
76814
  continue;
76605
76815
  }
76606
76816
  const lockAge = Date.now() - lockData.acquiredAt;
76607
76817
  if (lockAge > FileLock.LOCK_TIMEOUT) {
76608
76818
  console.warn(`[FileLock] Breaking stale lock (age: ${lockAge}ms)`);
76609
- await rename2(this.lockfilePath, `${this.lockfilePath}.stale.${Date.now()}`);
76819
+ await rename3(this.lockfilePath, `${this.lockfilePath}.stale.${Date.now()}`);
76610
76820
  continue;
76611
76821
  }
76612
76822
  } catch (readError) {
76613
76823
  if (readError instanceof SyntaxError) {
76614
76824
  console.warn(`[FileLock] Lock file contains invalid JSON, treating as stale`);
76615
- await rename2(this.lockfilePath, `${this.lockfilePath}.corrupt.${Date.now()}`);
76825
+ await rename3(this.lockfilePath, `${this.lockfilePath}.corrupt.${Date.now()}`);
76616
76826
  continue;
76617
76827
  }
76618
76828
  }
@@ -76629,7 +76839,7 @@ class FileLock {
76629
76839
  }
76630
76840
  async release() {
76631
76841
  try {
76632
- await rename2(this.lockfilePath, `${this.lockfilePath}.released.${Date.now()}`);
76842
+ await rename3(this.lockfilePath, `${this.lockfilePath}.released.${Date.now()}`);
76633
76843
  const dbPath = this.lockfilePath.slice(0, -5);
76634
76844
  FileLock.cleanupOldLockFiles(dbPath).catch(() => {});
76635
76845
  } catch (error48) {
@@ -76681,7 +76891,7 @@ async function getSqlJs() {
76681
76891
  if (SqlJsInitPromise) {
76682
76892
  return SqlJsInitPromise;
76683
76893
  }
76684
- const moduleDir = dirname3(fileURLToPath(import.meta.url));
76894
+ const moduleDir = dirname4(fileURLToPath(import.meta.url));
76685
76895
  const candidates = [
76686
76896
  resolve5(moduleDir, "sql-wasm.wasm"),
76687
76897
  resolve5(moduleDir, "..", "dist", "sql-wasm.wasm"),
@@ -76750,9 +76960,9 @@ var init_sqlite_memory_store = __esm(() => {
76750
76960
  }
76751
76961
  const dbPath = this.resolvePath(this.getDbPath());
76752
76962
  try {
76753
- const dir = dirname3(dbPath);
76963
+ const dir = dirname4(dbPath);
76754
76964
  if (!existsSync4(dir)) {
76755
- await mkdir2(dir, { recursive: true, mode: 448 });
76965
+ await mkdir3(dir, { recursive: true, mode: 448 });
76756
76966
  }
76757
76967
  FileLock.cleanupOldLockFiles(dbPath).catch(() => {});
76758
76968
  let dbData;
@@ -76761,7 +76971,7 @@ var init_sqlite_memory_store = __esm(() => {
76761
76971
  await lock.acquire();
76762
76972
  try {
76763
76973
  try {
76764
- dbData = await readFile4(dbPath);
76974
+ dbData = await readFile5(dbPath);
76765
76975
  if (dbData.length >= 16) {
76766
76976
  const header = String.fromCharCode(...dbData.subarray(0, 15));
76767
76977
  if (header !== "SQLite format 3") {
@@ -76794,7 +77004,7 @@ var init_sqlite_memory_store = __esm(() => {
76794
77004
  const backupPath = `${dbPath}.corrupted.${Date.now()}`;
76795
77005
  console.warn(`[SQLiteMemoryStore] Backing up corrupted database to: ${backupPath}`);
76796
77006
  try {
76797
- await rename2(dbPath, backupPath);
77007
+ await rename3(dbPath, backupPath);
76798
77008
  } catch (backupError) {
76799
77009
  console.error("[SQLiteMemoryStore] Failed to backup corrupted database:", backupError);
76800
77010
  this.dbPromise = null;
@@ -76819,8 +77029,8 @@ var init_sqlite_memory_store = __esm(() => {
76819
77029
  const dbPath = this.resolvePath(this.getDbPath());
76820
77030
  const tempPath = `${dbPath}.tmp`;
76821
77031
  const data = this.db.export();
76822
- await writeFile2(tempPath, data, { mode: 384 });
76823
- await rename2(tempPath, dbPath);
77032
+ await writeFile3(tempPath, data, { mode: 384 });
77033
+ await rename3(tempPath, dbPath);
76824
77034
  } finally {
76825
77035
  await lock.release();
76826
77036
  }
@@ -76874,7 +77084,7 @@ var init_sqlite_memory_store = __esm(() => {
76874
77084
  return resolve5(resolved);
76875
77085
  }
76876
77086
  generateUUID() {
76877
- return randomUUID();
77087
+ return randomUUID2();
76878
77088
  }
76879
77089
  now() {
76880
77090
  return Date.now();
@@ -112381,12 +112591,12 @@ var {
112381
112591
  Help
112382
112592
  } = import__.default;
112383
112593
  // package.json
112384
- var version = "0.9.101";
112594
+ var version = "0.9.102";
112385
112595
 
112386
112596
  // src/commands/agent.ts
112387
112597
  init_src();
112388
112598
  import { exec as exec3 } from "node:child_process";
112389
- import { randomUUID as randomUUID2 } from "node:crypto";
112599
+ import { randomUUID as randomUUID3 } from "node:crypto";
112390
112600
  import * as fs11 from "node:fs/promises";
112391
112601
  import * as path10 from "node:path";
112392
112602
  import { promisify as promisify3 } from "node:util";
@@ -116423,7 +116633,7 @@ async function runAgent(goal, options, _command) {
116423
116633
  const config4 = await loadConfig(configOptions, options.config);
116424
116634
  const workingDir = process.cwd();
116425
116635
  const stateDir = path10.join(workingDir, ".polka", "agent-state");
116426
- const sessionId = `agent-${Date.now()}-${randomUUID2()}`;
116636
+ const sessionId = `agent-${Date.now()}-${randomUUID3()}`;
116427
116637
  const asyncExec = promisify3(exec3);
116428
116638
  const tools3 = {
116429
116639
  executeCommand: async (input) => {
@@ -116530,7 +116740,7 @@ ${errorStdout}` : ""}`);
116530
116740
  var agentCommand = new Command("agent").description("Run autonomous agent (experimental)").argument("[goal]", "Goal to achieve", "").option("--continuous", "Run in continuous improvement mode").option("--preset <name>", "Configuration preset", "balanced").option("--config <path>", "Configuration file path").option("--approval-level <level>", "Approval level (none|destructive|commits|all)", "destructive").action(runAgent);
116531
116741
 
116532
116742
  // src/commands/code.ts
116533
- import { readFile as readFile12 } from "node:fs/promises";
116743
+ import { readFile as readFile13 } from "node:fs/promises";
116534
116744
  init_mime_types();
116535
116745
 
116536
116746
  // src/runWorkflow.ts
@@ -116539,8 +116749,8 @@ init_src();
116539
116749
  init_lodash();
116540
116750
  init_errors6();
116541
116751
  init_getModel();
116542
- import { mkdir as mkdir8 } from "node:fs/promises";
116543
- import { dirname as dirname7 } from "node:path";
116752
+ import { mkdir as mkdir9 } from "node:fs/promises";
116753
+ import { dirname as dirname8 } from "node:path";
116544
116754
 
116545
116755
  // src/getProviderOptions.ts
116546
116756
  init_getModel();
@@ -117474,9 +117684,11 @@ async function runWorkflow(workflow2, workflowInput, options) {
117474
117684
  additionalTools,
117475
117685
  config: config4
117476
117686
  };
117477
- const usage = new UsageMeter(merge_default(prices_default, config4.prices ?? {}), {
117687
+ const pricingService = new PricingService(merge_default({}, prices_default, config4.prices ?? {}));
117688
+ const usage = new UsageMeter(merge_default({}, prices_default, config4.prices ?? {}), {
117478
117689
  maxMessages: config4.maxMessageCount,
117479
- maxCost: config4.budget
117690
+ maxCost: config4.budget,
117691
+ pricingService
117480
117692
  });
117481
117693
  options.onUsageMeterCreated?.(usage);
117482
117694
  const onEvent = printEvent(verbose, usage, process.stderr);
@@ -117521,8 +117733,8 @@ async function runWorkflow(workflow2, workflowInput, options) {
117521
117733
  const scope = detectProjectScope(cwd);
117522
117734
  const dbPath = memoryConfig.path || DEFAULT_MEMORY_CONFIG.path;
117523
117735
  const resolvedDbPath = resolveHomePath(dbPath);
117524
- const dbDir = dirname7(resolvedDbPath);
117525
- await mkdir8(dbDir, { recursive: true, mode: 448 });
117736
+ const dbDir = dirname8(resolvedDbPath);
117737
+ await mkdir9(dbDir, { recursive: true, mode: 448 });
117526
117738
  const sqliteStore = new SQLiteMemoryStore({ enabled: true, type: "sqlite", path: dbPath }, scope);
117527
117739
  const memoryManager = new MemoryManager(sqliteStore);
117528
117740
  memoryStore = memoryManager;
@@ -117603,6 +117815,7 @@ async function runWorkflow(workflow2, workflowInput, options) {
117603
117815
  }
117604
117816
  logger.info("Running workflow...");
117605
117817
  const output = await workflow2(finalWorkflowInput, workflowContext);
117818
+ await usage.waitForPending();
117606
117819
  logger.info(`
117607
117820
 
117608
117821
  Workflow completed successfully.`);
@@ -117689,6 +117902,7 @@ Workflow completed successfully.`);
117689
117902
  }
117690
117903
  });
117691
117904
  }
117905
+ await usage.waitForPending();
117692
117906
  logger.info(usage.getUsageText());
117693
117907
  return;
117694
117908
  } finally {
@@ -118151,7 +118365,7 @@ async function runCode(task3, _options, command) {
118151
118365
  try {
118152
118366
  const mimeType = $lookup(file2);
118153
118367
  if (mimeType) {
118154
- const buffer = await readFile12(file2);
118368
+ const buffer = await readFile13(file2);
118155
118369
  if (mimeType.startsWith("image/")) {
118156
118370
  fileContents.push({
118157
118371
  type: "image",
@@ -118221,7 +118435,7 @@ var fixCommand = new Command("fix").description("Fix issues by running a command
118221
118435
  init_dist18();
118222
118436
  init_src3();
118223
118437
  import { existsSync as existsSync5, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
118224
- import { join as join14 } from "node:path";
118438
+ import { join as join15 } from "node:path";
118225
118439
  init_lodash();
118226
118440
  init_dist();
118227
118441
 
@@ -118314,7 +118528,7 @@ init_src();
118314
118528
  init_dist();
118315
118529
  init_zod();
118316
118530
  init_prompts2();
118317
- import { join as join13 } from "node:path";
118531
+ import { join as join14 } from "node:path";
118318
118532
  var scriptGenerationSystemPrompt = `Role: Expert TypeScript Developer and Automation Specialist
118319
118533
 
118320
118534
  Goal: Generate a custom polka script based on user requirements.
@@ -118477,7 +118691,7 @@ Please:
118477
118691
  }
118478
118692
  const scriptDir = ".polka-scripts";
118479
118693
  const scriptFileName = `${scriptName}.ts`;
118480
- const scriptFilePath = join13(scriptDir, scriptFileName);
118694
+ const scriptFilePath = join14(scriptDir, scriptFileName);
118481
118695
  await step("save-script", async () => {
118482
118696
  await tools3.writeToFile({ path: scriptFilePath, content: script });
118483
118697
  logger.info(`
@@ -118512,7 +118726,7 @@ async function createSkill(name18, logger, interactive) {
118512
118726
  if (BUILT_IN_COMMANDS.includes(name18)) {
118513
118727
  throw new Error(`Skill name '${name18}' conflicts with a built-in command. ` + `Please choose a different name (e.g., '${name18}-skill' or 'my-${name18}')`);
118514
118728
  }
118515
- const skillDir = join14(".claude", "skills", name18);
118729
+ const skillDir = join15(".claude", "skills", name18);
118516
118730
  if (existsSync5(skillDir)) {
118517
118731
  if (interactive) {
118518
118732
  const proceed = await dist_default4({
@@ -118530,7 +118744,7 @@ async function createSkill(name18, logger, interactive) {
118530
118744
  mkdirSync(skillDir, { recursive: true });
118531
118745
  logger.info(`Created skill directory: ${skillDir}`);
118532
118746
  const template = generateSkillTemplate(name18);
118533
- writeFileSync(join14(skillDir, "SKILL.md"), template);
118747
+ writeFileSync(join15(skillDir, "SKILL.md"), template);
118534
118748
  logger.info(`Created SKILL.md`);
118535
118749
  logger.info("");
118536
118750
  logger.info(`Skill '${name18}' created successfully!`);
@@ -118601,7 +118815,7 @@ Add additional files like:
118601
118815
  async function createScript(name18, logger, interactive, isGlobal = false) {
118602
118816
  const scriptDir = ".polka-scripts";
118603
118817
  const scriptPathConfig = `${scriptDir}/${name18}.ts`;
118604
- const scriptPathActual = join14(scriptDir, `${name18}.ts`);
118818
+ const scriptPathActual = join15(scriptDir, `${name18}.ts`);
118605
118819
  if (existsSync5(scriptPathActual)) {
118606
118820
  if (interactive) {
118607
118821
  const proceed = await dist_default4({
@@ -118765,7 +118979,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
118765
118979
  process.exit(1);
118766
118980
  }
118767
118981
  const scriptDir = ".polka-scripts";
118768
- const scriptPath = join14(scriptDir, `${name18}.ts`);
118982
+ const scriptPath = join15(scriptDir, `${name18}.ts`);
118769
118983
  if (existsSync5(scriptPath)) {
118770
118984
  if (interactive) {
118771
118985
  const proceed = await dist_default4({
@@ -121032,8 +121246,8 @@ var mcpServerCommand = new Command("mcp-server").description("Start polka-codes
121032
121246
  // src/commands/memory.ts
121033
121247
  init_src3();
121034
121248
  init_src();
121035
- import { mkdir as mkdir9, readFile as readFile13, writeFile as writeFile8 } from "node:fs/promises";
121036
- import { dirname as dirname8, resolve as resolve8 } from "node:path";
121249
+ import { mkdir as mkdir10, readFile as readFile14, writeFile as writeFile9 } from "node:fs/promises";
121250
+ import { dirname as dirname9, resolve as resolve8 } from "node:path";
121037
121251
  async function getMemoryStore2() {
121038
121252
  const globalConfigPath = getGlobalConfigPath();
121039
121253
  const config4 = await loadConfigAtPath(globalConfigPath);
@@ -121196,8 +121410,8 @@ async function memoryExport(options) {
121196
121410
  return;
121197
121411
  }
121198
121412
  const outputPath = options.output ? resolve8(process.cwd(), options.output) : resolve8(process.cwd(), `memory-export-${Date.now()}.json`);
121199
- await mkdir9(dirname8(outputPath), { recursive: true });
121200
- await writeFile8(outputPath, JSON.stringify(entries, null, 2));
121413
+ await mkdir10(dirname9(outputPath), { recursive: true });
121414
+ await writeFile9(outputPath, JSON.stringify(entries, null, 2));
121201
121415
  console.log(`Exported ${entries.length} entries to ${outputPath}`);
121202
121416
  } finally {
121203
121417
  store.close();
@@ -121207,7 +121421,7 @@ async function memoryImport(inputFile, options) {
121207
121421
  const store = await getMemoryStore2();
121208
121422
  try {
121209
121423
  const inputPath = resolve8(process.cwd(), inputFile);
121210
- const data = await readFile13(inputPath, "utf-8");
121424
+ const data = await readFile14(inputPath, "utf-8");
121211
121425
  let entries;
121212
121426
  try {
121213
121427
  entries = JSON.parse(data);
@@ -122058,7 +122272,7 @@ var taskCommand = new Command("task").description("Run a generic task using an A
122058
122272
 
122059
122273
  // src/commands/workflow.ts
122060
122274
  init_src();
122061
- import { readFile as readFile14 } from "node:fs/promises";
122275
+ import { readFile as readFile15 } from "node:fs/promises";
122062
122276
  async function runWorkflowCommand(task3, _options, command) {
122063
122277
  const workflowOpts = getBaseWorkflowOptions(command);
122064
122278
  const { verbose } = workflowOpts;
@@ -122071,7 +122285,7 @@ async function runWorkflowCommand(task3, _options, command) {
122071
122285
  logger.info(`Loading workflow from '${file2}'...`);
122072
122286
  let content;
122073
122287
  try {
122074
- content = await readFile14(file2, "utf-8");
122288
+ content = await readFile15(file2, "utf-8");
122075
122289
  } catch (error48) {
122076
122290
  const errorMessage = error48 instanceof Error ? error48.message : String(error48);
122077
122291
  logger.error(`Error reading file '${file2}': ${errorMessage}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.9.101",
3
+ "version": "0.9.102",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",