@polka-codes/cli-shared 0.8.22 → 0.8.24

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 +200 -79
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -36777,6 +36777,7 @@ __export(exports_allTools, {
36777
36777
  readFile: () => readFile_default,
36778
36778
  listFiles: () => listFiles_default,
36779
36779
  handOver: () => handOver_default,
36780
+ fetchUrl: () => fetchUrl_default,
36780
36781
  executeCommand: () => executeCommand_default,
36781
36782
  delegate: () => delegate_default,
36782
36783
  attemptCompletion: () => attemptCompletion_default,
@@ -37235,8 +37236,89 @@ var executeCommand_default = {
37235
37236
  handler: handler4,
37236
37237
  isAvailable: isAvailable4
37237
37238
  };
37238
- // ../core/src/tools/listFiles.ts
37239
+ // ../core/src/tools/fetchUrl.ts
37239
37240
  var toolInfo5 = {
37241
+ name: "fetch_url",
37242
+ description: "Fetch the content located at one or more HTTP(S) URLs and return it in Markdown format. This works for standard web pages as well as raw files (e.g. README.md, source code) hosted on platforms like GitHub.",
37243
+ parameters: [
37244
+ {
37245
+ name: "url",
37246
+ description: "One or more URLs to fetch, separated by commas if multiple.",
37247
+ required: true
37248
+ }
37249
+ ],
37250
+ examples: [
37251
+ {
37252
+ description: "Fetch a single webpage",
37253
+ parameters: [
37254
+ {
37255
+ name: "url",
37256
+ value: "https://example.com"
37257
+ }
37258
+ ]
37259
+ },
37260
+ {
37261
+ description: "Fetch multiple webpages",
37262
+ parameters: [
37263
+ {
37264
+ name: "url",
37265
+ value: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP"
37266
+ }
37267
+ ]
37268
+ },
37269
+ {
37270
+ description: "Fetch a raw file from GitHub",
37271
+ parameters: [
37272
+ {
37273
+ name: "url",
37274
+ value: "https://raw.githubusercontent.com/user/repo/main/README.md"
37275
+ }
37276
+ ]
37277
+ }
37278
+ ],
37279
+ permissionLevel: 1 /* Read */
37280
+ };
37281
+ var handler5 = async (provider, args) => {
37282
+ if (!provider.fetchUrl) {
37283
+ return {
37284
+ type: "Error" /* Error */,
37285
+ message: "Not possible to fetch url. Abort."
37286
+ };
37287
+ }
37288
+ const urls = getStringArray(args, "url");
37289
+ if (urls.length === 0) {
37290
+ return {
37291
+ type: "Error" /* Error */,
37292
+ message: "No URLs provided. Please provide at least one URL to fetch."
37293
+ };
37294
+ }
37295
+ const results = [];
37296
+ for (const url of urls) {
37297
+ try {
37298
+ const content = provider.fetchUrl(url).then((res) => `<fetch_url_content url="${url}">${res}</fetch_url_content>`);
37299
+ results.push(content);
37300
+ } catch (error) {
37301
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
37302
+ results.push(Promise.resolve(`<fetch_url_error url="${url}">${errorMessage}</fetch_url_error>`));
37303
+ }
37304
+ }
37305
+ const resolvedResults = await Promise.all(results);
37306
+ return {
37307
+ type: "Reply" /* Reply */,
37308
+ message: resolvedResults.join(`
37309
+ `)
37310
+ };
37311
+ };
37312
+ var isAvailable5 = (provider) => {
37313
+ return typeof provider.fetchUrl === "function";
37314
+ };
37315
+ var fetchUrl_default = {
37316
+ ...toolInfo5,
37317
+ handler: handler5,
37318
+ isAvailable: isAvailable5
37319
+ };
37320
+ // ../core/src/tools/listFiles.ts
37321
+ var toolInfo6 = {
37240
37322
  name: "list_files",
37241
37323
  description: "Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.",
37242
37324
  parameters: [
@@ -37276,7 +37358,7 @@ var toolInfo5 = {
37276
37358
  ],
37277
37359
  permissionLevel: 1 /* Read */
37278
37360
  };
37279
- var handler5 = async (provider, args) => {
37361
+ var handler6 = async (provider, args) => {
37280
37362
  if (!provider.listFiles) {
37281
37363
  return {
37282
37364
  type: "Error" /* Error */,
@@ -37297,16 +37379,16 @@ ${files.join(`
37297
37379
  <list_files_truncated>${limitReached}</list_files_truncated>`
37298
37380
  };
37299
37381
  };
37300
- var isAvailable5 = (provider) => {
37382
+ var isAvailable6 = (provider) => {
37301
37383
  return !!provider.listFiles;
37302
37384
  };
37303
37385
  var listFiles_default = {
37304
- ...toolInfo5,
37305
- handler: handler5,
37306
- isAvailable: isAvailable5
37386
+ ...toolInfo6,
37387
+ handler: handler6,
37388
+ isAvailable: isAvailable6
37307
37389
  };
37308
37390
  // ../core/src/tools/readFile.ts
37309
- var toolInfo6 = {
37391
+ var toolInfo7 = {
37310
37392
  name: "read_file",
37311
37393
  description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string. Try to list all the potential files are relevent to the task, and then use this tool to read all the relevant files.",
37312
37394
  parameters: [
@@ -37339,7 +37421,7 @@ var toolInfo6 = {
37339
37421
  ],
37340
37422
  permissionLevel: 1 /* Read */
37341
37423
  };
37342
- var handler6 = async (provider, args) => {
37424
+ var handler7 = async (provider, args) => {
37343
37425
  if (!provider.readFile) {
37344
37426
  return {
37345
37427
  type: "Error" /* Error */,
@@ -37367,16 +37449,16 @@ var handler6 = async (provider, args) => {
37367
37449
  `)
37368
37450
  };
37369
37451
  };
37370
- var isAvailable6 = (provider) => {
37452
+ var isAvailable7 = (provider) => {
37371
37453
  return !!provider.readFile;
37372
37454
  };
37373
37455
  var readFile_default = {
37374
- ...toolInfo6,
37375
- handler: handler6,
37376
- isAvailable: isAvailable6
37456
+ ...toolInfo7,
37457
+ handler: handler7,
37458
+ isAvailable: isAvailable7
37377
37459
  };
37378
37460
  // ../core/src/tools/replaceInFile.ts
37379
- var toolInfo7 = {
37461
+ var toolInfo8 = {
37380
37462
  name: "replace_in_file",
37381
37463
  description: "Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.",
37382
37464
  parameters: [
@@ -37528,7 +37610,7 @@ function oldFeature() {
37528
37610
  ],
37529
37611
  permissionLevel: 2 /* Write */
37530
37612
  };
37531
- var handler7 = async (provider, args) => {
37613
+ var handler8 = async (provider, args) => {
37532
37614
  if (!provider.readFile || !provider.writeFile) {
37533
37615
  return {
37534
37616
  type: "Error" /* Error */,
@@ -37551,16 +37633,16 @@ var handler7 = async (provider, args) => {
37551
37633
  message: `<replace_in_file_path>${path}</replace_in_file_path>`
37552
37634
  };
37553
37635
  };
37554
- var isAvailable7 = (provider) => {
37636
+ var isAvailable8 = (provider) => {
37555
37637
  return !!provider.readFile && !!provider.writeFile;
37556
37638
  };
37557
37639
  var replaceInFile_default = {
37558
- ...toolInfo7,
37559
- handler: handler7,
37560
- isAvailable: isAvailable7
37640
+ ...toolInfo8,
37641
+ handler: handler8,
37642
+ isAvailable: isAvailable8
37561
37643
  };
37562
37644
  // ../core/src/tools/searchFiles.ts
37563
- var toolInfo8 = {
37645
+ var toolInfo9 = {
37564
37646
  name: "search_files",
37565
37647
  description: "Request to perform a regex search across files in a specified directory, outputting context-rich results that include surrounding lines. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.",
37566
37648
  parameters: [
@@ -37604,7 +37686,7 @@ var toolInfo8 = {
37604
37686
  ],
37605
37687
  permissionLevel: 1 /* Read */
37606
37688
  };
37607
- var handler8 = async (provider, args) => {
37689
+ var handler9 = async (provider, args) => {
37608
37690
  if (!provider.searchFiles) {
37609
37691
  return {
37610
37692
  type: "Error" /* Error */,
@@ -37627,13 +37709,13 @@ ${files.join(`
37627
37709
  `
37628
37710
  };
37629
37711
  };
37630
- var isAvailable8 = (provider) => {
37712
+ var isAvailable9 = (provider) => {
37631
37713
  return !!provider.searchFiles;
37632
37714
  };
37633
37715
  var searchFiles_default = {
37634
- ...toolInfo8,
37635
- handler: handler8,
37636
- isAvailable: isAvailable8
37716
+ ...toolInfo9,
37717
+ handler: handler9,
37718
+ isAvailable: isAvailable9
37637
37719
  };
37638
37720
  // ../core/src/tools/updateKnowledge.ts
37639
37721
  var import_yaml = __toESM(require_dist(), 1);
@@ -37679,7 +37761,7 @@ function join(...parts) {
37679
37761
  }
37680
37762
 
37681
37763
  // ../core/src/tools/updateKnowledge.ts
37682
- var toolInfo9 = {
37764
+ var toolInfo10 = {
37683
37765
  name: "update_knowledge",
37684
37766
  description: "Update knowledge in a knowledge.ai.yml file with smart merging capabilities. This tool lets you add, update, or remove information using path-based updates and special directives.",
37685
37767
  parameters: [
@@ -37856,7 +37938,7 @@ function deepMerge(target, source) {
37856
37938
  }
37857
37939
  return output;
37858
37940
  }
37859
- var handler9 = async (provider, args) => {
37941
+ var handler10 = async (provider, args) => {
37860
37942
  if (!provider.readFile || !provider.writeFile) {
37861
37943
  return {
37862
37944
  type: "Error" /* Error */,
@@ -37928,18 +38010,18 @@ var handler9 = async (provider, args) => {
37928
38010
  };
37929
38011
  }
37930
38012
  };
37931
- var isAvailable9 = (provider) => {
38013
+ var isAvailable10 = (provider) => {
37932
38014
  return !!provider.readFile && !!provider.writeFile;
37933
38015
  };
37934
38016
  var updateKnowledge_default = {
37935
- ...toolInfo9,
37936
- handler: handler9,
37937
- isAvailable: isAvailable9
38017
+ ...toolInfo10,
38018
+ handler: handler10,
38019
+ isAvailable: isAvailable10
37938
38020
  };
37939
38021
  // ../core/src/tools/writeToFile.ts
37940
- var toolInfo10 = {
38022
+ var toolInfo11 = {
37941
38023
  name: "write_to_file",
37942
- description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `&lt;` and `&gt;`.",
38024
+ description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `&lt;`, `&gt;`, or `&amp;`. Also ensure there is no unwanted CDATA tags in the content.",
37943
38025
  parameters: [
37944
38026
  {
37945
38027
  name: "path",
@@ -37982,7 +38064,7 @@ export default App;
37982
38064
  ],
37983
38065
  permissionLevel: 2 /* Write */
37984
38066
  };
37985
- var handler10 = async (provider, args) => {
38067
+ var handler11 = async (provider, args) => {
37986
38068
  if (!provider.writeFile) {
37987
38069
  return {
37988
38070
  type: "Error" /* Error */,
@@ -37990,23 +38072,26 @@ var handler10 = async (provider, args) => {
37990
38072
  };
37991
38073
  }
37992
38074
  const path = getString(args, "path");
37993
- const content = getString(args, "content");
38075
+ let content = getString(args, "content");
38076
+ const trimmedContent = content.trim();
38077
+ if (trimmedContent.startsWith("<![CDATA[") && content.endsWith("]]>"))
38078
+ content = trimmedContent.slice(9, -3);
37994
38079
  await provider.writeFile(path, content);
37995
38080
  return {
37996
38081
  type: "Reply" /* Reply */,
37997
38082
  message: `<write_to_file_path>${path}</write_to_file_path><status>Success</status>`
37998
38083
  };
37999
38084
  };
38000
- var isAvailable10 = (provider) => {
38085
+ var isAvailable11 = (provider) => {
38001
38086
  return !!provider.writeFile;
38002
38087
  };
38003
38088
  var writeToFile_default = {
38004
- ...toolInfo10,
38005
- handler: handler10,
38006
- isAvailable: isAvailable10
38089
+ ...toolInfo11,
38090
+ handler: handler11,
38091
+ isAvailable: isAvailable11
38007
38092
  };
38008
38093
  // ../core/src/tools/handOver.ts
38009
- var toolInfo11 = {
38094
+ var toolInfo12 = {
38010
38095
  name: "hand_over",
38011
38096
  description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.",
38012
38097
  parameters: [
@@ -38060,7 +38145,7 @@ var toolInfo11 = {
38060
38145
  ],
38061
38146
  permissionLevel: 0 /* None */
38062
38147
  };
38063
- var handler11 = async (_provider, args) => {
38148
+ var handler12 = async (_provider, args) => {
38064
38149
  const agentName = getString(args, "agent_name");
38065
38150
  const task = getString(args, "task");
38066
38151
  const context = getString(args, "context", undefined);
@@ -38073,16 +38158,16 @@ var handler11 = async (_provider, args) => {
38073
38158
  files
38074
38159
  };
38075
38160
  };
38076
- var isAvailable11 = (_provider) => {
38161
+ var isAvailable12 = (_provider) => {
38077
38162
  return true;
38078
38163
  };
38079
38164
  var handOver_default = {
38080
- ...toolInfo11,
38081
- handler: handler11,
38082
- isAvailable: isAvailable11
38165
+ ...toolInfo12,
38166
+ handler: handler12,
38167
+ isAvailable: isAvailable12
38083
38168
  };
38084
38169
  // ../core/src/tools/removeFile.ts
38085
- var toolInfo12 = {
38170
+ var toolInfo13 = {
38086
38171
  name: "remove_file",
38087
38172
  description: "Request to remove a file at the specified path.",
38088
38173
  parameters: [
@@ -38106,7 +38191,7 @@ var toolInfo12 = {
38106
38191
  ],
38107
38192
  permissionLevel: 2 /* Write */
38108
38193
  };
38109
- var handler12 = async (provider, args) => {
38194
+ var handler13 = async (provider, args) => {
38110
38195
  if (!provider.removeFile) {
38111
38196
  return {
38112
38197
  type: "Error" /* Error */,
@@ -38120,16 +38205,16 @@ var handler12 = async (provider, args) => {
38120
38205
  message: `<remove_file_path>${path}</remove_file_path><status>Success</status>`
38121
38206
  };
38122
38207
  };
38123
- var isAvailable12 = (provider) => {
38208
+ var isAvailable13 = (provider) => {
38124
38209
  return !!provider.removeFile;
38125
38210
  };
38126
38211
  var removeFile_default = {
38127
- ...toolInfo12,
38128
- handler: handler12,
38129
- isAvailable: isAvailable12
38212
+ ...toolInfo13,
38213
+ handler: handler13,
38214
+ isAvailable: isAvailable13
38130
38215
  };
38131
38216
  // ../core/src/tools/renameFile.ts
38132
- var toolInfo13 = {
38217
+ var toolInfo14 = {
38133
38218
  name: "rename_file",
38134
38219
  description: "Request to rename a file from source path to target path.",
38135
38220
  parameters: [
@@ -38163,7 +38248,7 @@ var toolInfo13 = {
38163
38248
  ],
38164
38249
  permissionLevel: 2 /* Write */
38165
38250
  };
38166
- var handler13 = async (provider, args) => {
38251
+ var handler14 = async (provider, args) => {
38167
38252
  if (!provider.renameFile) {
38168
38253
  return {
38169
38254
  type: "Error" /* Error */,
@@ -38178,13 +38263,13 @@ var handler13 = async (provider, args) => {
38178
38263
  message: `<rename_file_path>${targetPath}</rename_file_path><status>Success</status>`
38179
38264
  };
38180
38265
  };
38181
- var isAvailable13 = (provider) => {
38266
+ var isAvailable14 = (provider) => {
38182
38267
  return !!provider.renameFile;
38183
38268
  };
38184
38269
  var renameFile_default = {
38185
- ...toolInfo13,
38186
- handler: handler13,
38187
- isAvailable: isAvailable13
38270
+ ...toolInfo14,
38271
+ handler: handler14,
38272
+ isAvailable: isAvailable14
38188
38273
  };
38189
38274
  // ../core/src/getAvailableTools.ts
38190
38275
  var getAvailableTools = ({
@@ -38542,13 +38627,34 @@ ${joined}`;
38542
38627
  };
38543
38628
  var responsePrompts = {
38544
38629
  errorInvokeTool: (tool, error) => `An error occurred while invoking the tool "${tool}": ${error}`,
38545
- requireUseTool: "Error: You MUST use a tool before proceeding using XCM tags. e.g. <tool_tool_name>tool_name</tool_tool_name>",
38546
- toolResults: (tool, result) => `<tool_response>
38547
- <tool_name>${tool}</tool_name>
38548
- <tool_result>
38549
- ${result}
38550
- </tool_result>
38551
- </tool_response>`,
38630
+ requireUseTool: `Error: No tool use detected. You MUST use a tool before proceeding.
38631
+ e.g. <tool_tool_name>tool_name</tool_tool_name>
38632
+
38633
+ Ensure the opening and closing tags are correctly nested and closed, and that you are using the correct tool name.
38634
+ Avoid unnecessary text or symbols before or after the tool use.
38635
+ Avoid unnecessary escape characters or special characters.
38636
+ `,
38637
+ toolResults: (tool, result) => {
38638
+ if (typeof result === "string") {
38639
+ return [
38640
+ {
38641
+ type: "text",
38642
+ text: `<tool_response name=${tool}>${result}</tool_response>`
38643
+ }
38644
+ ];
38645
+ }
38646
+ return [
38647
+ {
38648
+ type: "text",
38649
+ text: `<tool_response name=${tool}>`
38650
+ },
38651
+ ...result,
38652
+ {
38653
+ type: "text",
38654
+ text: "</tool_response>"
38655
+ }
38656
+ ];
38657
+ },
38552
38658
  commandResult: (command, exitCode, stdout, stderr) => `<command>${command}</command>
38553
38659
  <command_exit_code>${exitCode}</command_exit_code>
38554
38660
  <command_stdout>
@@ -38712,23 +38818,26 @@ ${instance.prompt}`;
38712
38818
  await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name });
38713
38819
  const toolResp = await this.#invokeTool(content.name, content.params);
38714
38820
  switch (toolResp.type) {
38715
- case "Reply" /* Reply */:
38821
+ case "Reply" /* Reply */: {
38716
38822
  await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
38717
38823
  toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
38718
38824
  break;
38825
+ }
38719
38826
  case "Exit" /* Exit */:
38720
38827
  if (toolResponses.length > 0) {
38721
38828
  break outer;
38722
38829
  }
38723
38830
  return { type: "exit", reason: toolResp };
38724
- case "Invalid" /* Invalid */:
38831
+ case "Invalid" /* Invalid */: {
38725
38832
  await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
38726
38833
  toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
38727
38834
  break outer;
38728
- case "Error" /* Error */:
38835
+ }
38836
+ case "Error" /* Error */: {
38729
38837
  await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
38730
38838
  toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
38731
38839
  break outer;
38840
+ }
38732
38841
  case "Interrupted" /* Interrupted */:
38733
38842
  await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
38734
38843
  return { type: "exit", reason: toolResp };
@@ -38778,15 +38887,13 @@ ${instance.prompt}`;
38778
38887
  if (toolResponses.length === 0) {
38779
38888
  return { type: "reply", message: responsePrompts.requireUseTool };
38780
38889
  }
38781
- const finalResp = toolResponses.filter((resp) => resp.type === "response").map(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2)).join(`
38782
-
38783
- `);
38890
+ const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2));
38784
38891
  return { type: "reply", message: finalResp };
38785
38892
  }
38786
38893
  async#invokeTool(name, args) {
38787
38894
  try {
38788
- const handler14 = this.handlers[name]?.handler;
38789
- if (!handler14) {
38895
+ const handler15 = this.handlers[name]?.handler;
38896
+ if (!handler15) {
38790
38897
  return {
38791
38898
  type: "Error" /* Error */,
38792
38899
  message: responsePrompts.errorInvokeTool(name, "Tool not found"),
@@ -38805,7 +38912,7 @@ ${instance.prompt}`;
38805
38912
  if (resp) {
38806
38913
  return resp;
38807
38914
  }
38808
- return await handler14(this.config.provider, args);
38915
+ return await handler15(this.config.provider, args);
38809
38916
  } catch (error) {
38810
38917
  return {
38811
38918
  type: "Error" /* Error */,
@@ -48014,15 +48121,15 @@ function useKeypress(userHandler) {
48014
48121
  signal.current = userHandler;
48015
48122
  useEffect((rl) => {
48016
48123
  let ignore = false;
48017
- const handler14 = withUpdates((_input, event) => {
48124
+ const handler15 = withUpdates((_input, event) => {
48018
48125
  if (ignore)
48019
48126
  return;
48020
48127
  signal.current(event, rl);
48021
48128
  });
48022
- rl.input.on("keypress", handler14);
48129
+ rl.input.on("keypress", handler15);
48023
48130
  return () => {
48024
48131
  ignore = true;
48025
- rl.input.removeListener("keypress", handler14);
48132
+ rl.input.removeListener("keypress", handler15);
48026
48133
  };
48027
48134
  }, []);
48028
48135
  }
@@ -48204,16 +48311,16 @@ class Emitter {
48204
48311
 
48205
48312
  class SignalExitBase {
48206
48313
  }
48207
- var signalExitWrap = (handler14) => {
48314
+ var signalExitWrap = (handler15) => {
48208
48315
  return {
48209
48316
  onExit(cb, opts) {
48210
- return handler14.onExit(cb, opts);
48317
+ return handler15.onExit(cb, opts);
48211
48318
  },
48212
48319
  load() {
48213
- return handler14.load();
48320
+ return handler15.load();
48214
48321
  },
48215
48322
  unload() {
48216
- return handler14.unload();
48323
+ return handler15.unload();
48217
48324
  }
48218
48325
  };
48219
48326
  };
@@ -48979,6 +49086,20 @@ var getProvider = (agentName, config2, options = {}) => {
48979
49086
  },
48980
49087
  attemptCompletion: async (result) => {
48981
49088
  return;
49089
+ },
49090
+ fetchUrl: async (url) => {
49091
+ const isRaw = url.startsWith("https://raw.githubusercontent.com/");
49092
+ const urlToFetch = isRaw ? url : `https://r.jina.ai/${url}`;
49093
+ try {
49094
+ const response = await fetch(urlToFetch);
49095
+ if (!response.ok) {
49096
+ throw new Error(`HTTP error! status: ${response.status}`);
49097
+ }
49098
+ return await response.text();
49099
+ } catch (error) {
49100
+ console.error("Error fetching URL:", error);
49101
+ throw error;
49102
+ }
48982
49103
  }
48983
49104
  };
48984
49105
  if (checkRipgrep()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli-shared",
3
- "version": "0.8.22",
3
+ "version": "0.8.24",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",
@@ -15,7 +15,7 @@
15
15
  "build": "bun build src/index.ts --outdir dist --target node"
16
16
  },
17
17
  "dependencies": {
18
- "@polka-codes/core": "0.8.10",
18
+ "@polka-codes/core": "0.8.22",
19
19
  "ignore": "^7.0.3",
20
20
  "lodash": "^4.17.21",
21
21
  "yaml": "^2.7.0",