@jixo/cli 0.13.0 → 0.20.0

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 (121) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +18 -71
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/apply.d.ts +9 -0
  6. package/dist/commands/apply.d.ts.map +1 -0
  7. package/dist/commands/apply.js +59 -0
  8. package/dist/commands/apply.js.map +1 -0
  9. package/dist/commands/gen.d.ts +9 -0
  10. package/dist/commands/gen.d.ts.map +1 -0
  11. package/dist/commands/gen.js +43 -0
  12. package/dist/commands/gen.js.map +1 -0
  13. package/dist/commands/google-aistudio.d.ts +8 -0
  14. package/dist/commands/google-aistudio.d.ts.map +1 -0
  15. package/dist/commands/google-aistudio.js +51 -0
  16. package/dist/commands/google-aistudio.js.map +1 -0
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1 -4
  20. package/dist/index.js.map +1 -1
  21. package/package.json +4 -25
  22. package/dist/commands/daemon.d.ts +0 -5
  23. package/dist/commands/daemon.d.ts.map +0 -1
  24. package/dist/commands/daemon.js +0 -20
  25. package/dist/commands/daemon.js.map +0 -1
  26. package/dist/commands/doctor/config.d.ts +0 -3
  27. package/dist/commands/doctor/config.d.ts.map +0 -1
  28. package/dist/commands/doctor/config.js +0 -17
  29. package/dist/commands/doctor/config.js.map +0 -1
  30. package/dist/commands/doctor/doctor.d.ts +0 -3
  31. package/dist/commands/doctor/doctor.d.ts.map +0 -1
  32. package/dist/commands/doctor/doctor.js +0 -158
  33. package/dist/commands/doctor/doctor.js.map +0 -1
  34. package/dist/commands/doctor/doctor.test.d.ts +0 -2
  35. package/dist/commands/doctor/doctor.test.d.ts.map +0 -1
  36. package/dist/commands/doctor/doctor.test.js +0 -14
  37. package/dist/commands/doctor/doctor.test.js.map +0 -1
  38. package/dist/commands/doctor/index.d.ts +0 -2
  39. package/dist/commands/doctor/index.d.ts.map +0 -1
  40. package/dist/commands/doctor/index.js +0 -8
  41. package/dist/commands/doctor/index.js.map +0 -1
  42. package/dist/commands/doctor/types.d.ts +0 -45
  43. package/dist/commands/doctor/types.d.ts.map +0 -1
  44. package/dist/commands/doctor/types.js +0 -3
  45. package/dist/commands/doctor/types.js.map +0 -1
  46. package/dist/commands/init.d.ts +0 -2
  47. package/dist/commands/init.d.ts.map +0 -1
  48. package/dist/commands/init.js +0 -40
  49. package/dist/commands/init.js.map +0 -1
  50. package/dist/commands/prompts/list.d.ts +0 -2
  51. package/dist/commands/prompts/list.d.ts.map +0 -1
  52. package/dist/commands/prompts/list.js +0 -14
  53. package/dist/commands/prompts/list.js.map +0 -1
  54. package/dist/commands/prompts/upgrade.d.ts +0 -4
  55. package/dist/commands/prompts/upgrade.d.ts.map +0 -1
  56. package/dist/commands/prompts/upgrade.js +0 -17
  57. package/dist/commands/prompts/upgrade.js.map +0 -1
  58. package/dist/commands/tasks/AiTaskTui.d.ts +0 -22
  59. package/dist/commands/tasks/AiTaskTui.d.ts.map +0 -1
  60. package/dist/commands/tasks/AiTaskTui.js +0 -52
  61. package/dist/commands/tasks/AiTaskTui.js.map +0 -1
  62. package/dist/commands/tasks/ai-tasl-tui.d.ts +0 -22
  63. package/dist/commands/tasks/ai-tasl-tui.d.ts.map +0 -1
  64. package/dist/commands/tasks/ai-tasl-tui.js +0 -53
  65. package/dist/commands/tasks/ai-tasl-tui.js.map +0 -1
  66. package/dist/commands/tasks/ai-tools.d.ts +0 -804
  67. package/dist/commands/tasks/ai-tools.d.ts.map +0 -1
  68. package/dist/commands/tasks/ai-tools.js +0 -140
  69. package/dist/commands/tasks/ai-tools.js.map +0 -1
  70. package/dist/commands/tasks/model-providers.d.ts +0 -13
  71. package/dist/commands/tasks/model-providers.d.ts.map +0 -1
  72. package/dist/commands/tasks/model-providers.js +0 -84
  73. package/dist/commands/tasks/model-providers.js.map +0 -1
  74. package/dist/commands/tasks/run-ai-task.d.ts +0 -4
  75. package/dist/commands/tasks/run-ai-task.d.ts.map +0 -1
  76. package/dist/commands/tasks/run-ai-task.js +0 -348
  77. package/dist/commands/tasks/run-ai-task.js.map +0 -1
  78. package/dist/commands/tasks/run.d.ts +0 -10
  79. package/dist/commands/tasks/run.d.ts.map +0 -1
  80. package/dist/commands/tasks/run.js +0 -44
  81. package/dist/commands/tasks/run.js.map +0 -1
  82. package/dist/config.d.ts +0 -15
  83. package/dist/config.d.ts.map +0 -1
  84. package/dist/config.js +0 -23
  85. package/dist/config.js.map +0 -1
  86. package/dist/env.d.ts +0 -6
  87. package/dist/env.d.ts.map +0 -1
  88. package/dist/env.js +0 -16
  89. package/dist/env.js.map +0 -1
  90. package/dist/helper/ai-retry-error.d.ts +0 -3
  91. package/dist/helper/ai-retry-error.d.ts.map +0 -1
  92. package/dist/helper/ai-retry-error.js +0 -108
  93. package/dist/helper/ai-retry-error.js.map +0 -1
  94. package/dist/helper/find-changes.d.ts +0 -3
  95. package/dist/helper/find-changes.d.ts.map +0 -1
  96. package/dist/helper/find-changes.js +0 -113
  97. package/dist/helper/find-changes.js.map +0 -1
  98. package/dist/helper/find-changes.test.d.ts +0 -2
  99. package/dist/helper/find-changes.test.d.ts.map +0 -1
  100. package/dist/helper/find-changes.test.js +0 -22
  101. package/dist/helper/find-changes.test.js.map +0 -1
  102. package/dist/helper/handle-ai-error.d.ts +0 -5
  103. package/dist/helper/handle-ai-error.d.ts.map +0 -1
  104. package/dist/helper/handle-ai-error.js +0 -122
  105. package/dist/helper/handle-ai-error.js.map +0 -1
  106. package/dist/helper/logger.d.ts +0 -3
  107. package/dist/helper/logger.d.ts.map +0 -1
  108. package/dist/helper/logger.js +0 -26
  109. package/dist/helper/logger.js.map +0 -1
  110. package/dist/helper/parse-progress.d.ts +0 -2
  111. package/dist/helper/parse-progress.d.ts.map +0 -1
  112. package/dist/helper/parse-progress.js +0 -28
  113. package/dist/helper/parse-progress.js.map +0 -1
  114. package/dist/helper/prompts-loader.d.ts +0 -11
  115. package/dist/helper/prompts-loader.d.ts.map +0 -1
  116. package/dist/helper/prompts-loader.js +0 -28
  117. package/dist/helper/prompts-loader.js.map +0 -1
  118. package/dist/helper/resolve-ai-tasks.d.ts +0 -42
  119. package/dist/helper/resolve-ai-tasks.d.ts.map +0 -1
  120. package/dist/helper/resolve-ai-tasks.js +0 -162
  121. package/dist/helper/resolve-ai-tasks.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-ai-task.js","sourceRoot":"","sources":["../../../src/commands/tasks/run-ai-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAClD,OAAO,EAAC,UAAU,EAAiF,MAAM,IAAI,CAAC;AAC9G,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,KAAK,EAAE,CAAC,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,WAAW,EAAC,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAC,mBAAmB,EAAE,cAAc,IAAI,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AAExG,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AACpC,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,MAAM,GAAG,GAAG,WAAW,CAAC,k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AAG,CAAC,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC;oBAChD,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,GAAG,CAAC,yCAAyC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC;oBACrI,OAAO,YAAY,CAAC,KAAK,CAAC;gBAC5B,CAAC;YACH,CAAC,CAAC;iBACD,SAAS,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAC,2CAA2C;YAEnE,IAAI,WAAW,KAAK,YAAY,CAAC,KAAK,EAAE,CAAC;gBACvC,MAAM,WAAW,CAAC;YACpB,CAAC;YACD,IAAI,WAAW,KAAK,YAAY,CAAC,MAAM,EAAE,CAAC;gBACxC,MAAM,IAAI,CAAC;YACb,CAAC;iBAAM,IAAI,WAAW,KAAK,YAAY,CAAC,KAAK,EAAE,CAAC;gBAC9C,MAAM;YACR,CAAC;QACH,CAAC;QACD,yHAAyH;QACzH,IAAI,IAAI,KAAK,QAAQ,GAAG,CAAC,EAAE,CAAC;YAC1B,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC;YAChD,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,GAAG,CAAC,iCAAiC,CAAC,CAAC;YACvG,MAAM;QACR,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["import {blue, cyan, FileEntry, gray, green, red, spinner, YAML, yellow} from \"@gaubee/nodekit\";\nimport {func_catch, obj_omit} from \"@gaubee/util\";\nimport {streamText, type AssistantModelMessage, type ModelMessage, type ToolCallPart, type ToolSet} from \"ai\";\nimport ms from \"ms\";\nimport {open} from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport {match, P} from \"ts-pattern\";\nimport {handleError} from \"../../helper/handle-ai-error.js\";\nimport {createDebug} from \"../../helper/logger.js\";\nimport {getAllPromptConfigs, getAllSkillMap as getAllSkillNavMap} from \"../../helper/prompts-loader.js\";\nimport type {AiTask} from \"../../helper/resolve-ai-tasks.js\";\nimport {AiTaskTui} from \"./ai-tasl-tui.js\";\nimport {tools} from \"./ai-tools.js\";\nimport {getModel} from \"./model-providers.js\";\n\nconst log = createDebug(\"jixo:run-ai-task\");\n\nexport const runAiTask = async (ai_task: AiTask, loopTimes: number, allFiles: FileEntry[], changedFilesSet: Record<string, FileEntry[]>) => {\n const tool_spinner = spinner({\n prefixText: \"🧰\",\n text: \"Preparing AI tools...\",\n });\n tool_spinner.start();\n const availableTools: ToolSet = {\n ...(await tools.fileSystem(ai_task.cwd)),\n ...(await tools.pnpm()),\n ...(await tools.jixo(ai_task)),\n ...(await tools.git(ai_task.cwd)),\n };\n tool_spinner.clear();\n tool_spinner.stop();\n\n const json_line_log_file_handle = await open(path.join(ai_task.cwd, \".jixo\", `${ai_task.runner}.log.jsonl`), \"a\");\n const __writeJsonLineLog = (...lineDatas: any[]) => {\n for (const lineData of lineDatas) {\n try {\n const log = typeof lineData === \"function\" ? lineData() : lineData;\n json_line_log_file_handle.appendFile(JSON.stringify(log) + \"\\n\");\n } catch {}\n }\n };\n\n const tui = new AiTaskTui(ai_task, spinner({text: `Initializing AI task: ${cyan(ai_task.jobName)}...`, prefixText: \"⏳ \"}));\n tui.spinner.start();\n const updateTuiState = () => {\n tui.setStatus(\"loop and time\", `${green(`[${loopTimes}]`)} ${cyan(`+${ms(Date.now() - new Date(ai_task.startTime).getTime())}`)}`);\n };\n const ti = setInterval(updateTuiState, 1000);\n updateTuiState();\n try {\n await _runAiTask(ai_task, availableTools, allFiles, changedFilesSet, tui, __writeJsonLineLog);\n } finally {\n // Fallback spinner stop if loop exits unexpectedly\n clearInterval(ti);\n tui.stop();\n json_line_log_file_handle.close();\n }\n};\n\nconst _runAiTask = async (\n ai_task: AiTask,\n availableTools: ToolSet,\n allFiles: FileEntry[],\n changedFilesSet: Record<string, FileEntry[]>,\n tui: AiTaskTui,\n __writeJsonLineLog: (...lineDatas: any[]) => void,\n) => {\n const model = getModel(ai_task.model);\n\n const initialMessages: ModelMessage[] = [];\n const maxTurns = 40; // Safeguard against infinite loops\n\n const promptConfigs = getAllPromptConfigs();\n\n for (const role of [\"system\", \"user\"] as const) {\n const promptConfig = promptConfigs[role];\n\n const promptContent = promptConfig.content //\n .replace(/\\{\\{task.([\\.\\w]+)\\}\\}/g, (_, key) => {\n if (key.includes(\".\")) {\n const paths = key.split(\".\");\n let res: any = ai_task;\n for (const p of paths) {\n res = Reflect.get(res, p);\n if (!res) {\n break;\n }\n }\n return res;\n } else {\n return Reflect.get(ai_task, key);\n }\n })\n .replace(/\\{\\{env.(\\w+)\\}\\}/g, (_, key) => {\n const envKey = key.toUpperCase();\n const envValue =\n Reflect.get(process.env, envKey) ??\n match(envKey)\n .with(\"USER\", () => os.userInfo().username)\n .otherwise(() => \"\");\n return envValue;\n })\n .replaceAll(\"{{allSkills}}\", (_, key) => {\n return YAML.stringify(getAllSkillNavMap());\n })\n .replaceAll(\n \"{{allFiles}}\",\n YAML.stringify({\n [ai_task.cwd]: {\n count: allFiles.length,\n file: allFiles.map((e) => e.relativePath),\n },\n }),\n )\n .replaceAll(\"{{maxTurns}}\", () => `${maxTurns}`)\n .replaceAll(\n \"{{changedFiles}}\",\n YAML.stringify(\n Object.entries(changedFilesSet).reduce(\n (tree, [dir, changedFiles]) => {\n tree[dir] = {\n count: changedFiles.length,\n files: changedFiles.map((e) => e.relativePath),\n };\n return tree;\n },\n {} as Record<string, {count: number; files: string[]}>,\n ),\n ),\n );\n log(`PROMPT ${role}:`, promptContent);\n initialMessages.push({\n role: role,\n content: promptContent,\n });\n }\n\n const currentMessages: ModelMessage[] = [...initialMessages];\n\n __writeJsonLineLog(...currentMessages);\n\n loop: for (let turn = 0; turn < maxTurns; turn++) {\n if (turn === 0) {\n tui.setStatus(\"turns\", `Connecting To ${model.provider}...`);\n } else {\n tui.setStatus(\"turns\", `Processing step ${turn + 1}/${maxTurns}...`);\n const userTurnMessage: ModelMessage = {\n role: \"user\",\n content: `Turns: ${turn}/${maxTurns}`,\n };\n currentMessages.push(userTurnMessage);\n __writeJsonLineLog(userTurnMessage);\n }\n const result = await streamText({\n model: model,\n messages: currentMessages,\n tools: availableTools,\n toolChoice: \"auto\", // Changed to auto for more flexibility\n onError: () => {},\n });\n\n let fullReasoningText = \"\";\n let fullText = \"\";\n let firstStreamPart = true;\n const requestedToolCalls: ToolCallPart[] = []; // Using any for now, should be ToolCallPart from 'ai'\n\n const assistantMessageContent: AssistantModelMessage[\"content\"] & unknown[] = [];\n const _currentAssistantMessage: AssistantModelMessage = {role: \"assistant\", content: assistantMessageContent};\n\n const LOOP_SIGNALS = {\n RETURN: \"RETURN\",\n BREAK: \"BREAK\",\n CONTINUE: \"CONTINUE\",\n ERROR: \"ERROR\",\n } as const;\n for await (const part of result.fullStream) {\n __writeJsonLineLog(() =>\n match(part)\n .with({type: \"start-step\"}, (p) => {\n obj_omit(p, \"request\");\n })\n .otherwise((p) => p),\n );\n\n if (firstStreamPart) {\n firstStreamPart = false;\n tui.text = \"\"; // Clear initial connecting/processing message\n }\n\n const LOOP_SIGNAL = await match(part)\n .with({type: \"text\"}, (textPart) => {\n tui.prefixText = \"🤖 \";\n let assistantTextPart = assistantMessageContent.findLast((part) => part.type === \"text\");\n if (assistantTextPart == null) {\n assistantTextPart = {type: \"text\", text: \"\"};\n assistantMessageContent.push(assistantTextPart);\n }\n assistantTextPart.text += textPart.text;\n if (fullText === \"\") tui.text = \"\";\n fullText += textPart.text;\n tui.text = \"\\n\" + fullText.split(\"\\n\").slice(-10).join(\"\\n\");\n })\n .with({type: \"tool-call\"}, (callPart) => {\n tui.prefixText = \"🛠️ \";\n tui.text = \"Requesting tool: \" + blue(callPart.toolName);\n log(\"\\nQAQ tool-call: %y\", callPart);\n requestedToolCalls.push(callPart);\n // Update assistant message to include tool calls\n assistantMessageContent.push({\n type: \"tool-call\",\n toolCallId: callPart.toolCallId,\n toolName: callPart.toolName,\n args: callPart.args,\n });\n })\n .with({type: \"error\"}, async (errorPart) => {\n tui.prefixText = tui.endInfo.prefixText = \"❌ \";\n tui.text = tui.endInfo.text = red(`${errorPart.error}`);\n const handled = await handleError(errorPart.error, tui);\n if (!handled) {\n return LOOP_SIGNALS.BREAK; // Stop processing on error\n }\n })\n .with({type: \"reasoning\"}, (reasoningPart) => {\n tui.prefixText = \"🤔 \";\n if (fullReasoningText === \"\") tui.text = \"\";\n fullReasoningText += reasoningPart.text;\n tui.text = \"\\n\" + gray(fullReasoningText.split(\"\\n\").slice(-3).join(\"\\n\"));\n })\n // Add other console logs for debugging if needed, but keep them minimal for production\n .with({type: \"file\"}, (p) => {\n tui.prefixText = \"📃 \";\n tui.text = p.file.mediaType;\n\n log(\"\\nQAQ file: %y\", p.file);\n })\n .with({type: \"source\"}, (p) => {\n tui.prefixText = \"🔗 \";\n if (p.sourceType === \"url\") {\n if (p.title) {\n tui.text = `[${p.title}](${p.url})`;\n } else {\n tui.text = p.url;\n }\n } else {\n if (p.filename) {\n tui.text = `[${p.title}](${p.filename})`;\n } else {\n tui.text = p.title;\n }\n }\n\n log(\"\\nQAQ source: %y\", p);\n })\n .with({type: \"tool-result\"}, (p) => log(\"\\nQAQ tool-result: %y\", p))\n .with({type: \"tool-call-streaming-start\"}, (p) => log(\"\\nQAQ tool-call-streaming-start: %y\", p))\n .with({type: \"tool-call-delta\"}, (p) => log(\"\\nQAQ tool-call-delta: %y\", p))\n .with({type: \"reasoning-part-finish\"}, (p) => log(\"\\nQAQ reasoning-part-finish: %y\", p))\n .with({type: \"start-step\"}, (p) => log(\"\\nQAQ start-step: %y\", p))\n .with({type: \"finish-step\"}, (p) => {\n log(\"\\nQAQ finish-step: %y\", p);\n /**\n * This event marks the end of an intermediate step, not the entire turn.\n * We handle potential issues here, but the main logic for continuing or\n * stopping the loop is in the final 'finish' event handler.\n */\n return match(p)\n .with({finishReason: P.union(\"content-filter\", \"error\")}, (part) => {\n // A step finishing due to an error or content filter is a serious issue.\n // Update the TUI to reflect this problem immediately.\n const reasonText = part.finishReason === \"content-filter\" ? \"Content filter violation\" : \"Model error\";\n tui.prefixText = tui.endInfo.prefixText = \"⚠️ \";\n tui.text = tui.endInfo.text = red(`Step failed due to ${reasonText}. Will be retry.`);\n log(red(`Step finished with critical reason: ${part.finishReason}`));\n return LOOP_SIGNALS.RETURN;\n })\n .with({finishReason: P.union(\"other\", \"unknown\")}, (part) => {\n // Log unusual finish reasons for debugging purposes.\n log(yellow(`Step finished with an unusual reason: ${part.finishReason}`));\n })\n .otherwise(() => {\n // This covers 'stop', 'length', and 'tool-calls'. These are normal\n // reasons for a step to finish. The final 'finish' event will\n // determine the overall outcome of the turn. No special action is needed here.\n log(`Step finished with normal reason: ${p.finishReason}. Awaiting end of turn.`);\n });\n })\n .with({type: \"start\"}, (p) => log(\"\\nQAQ start: %y\", p))\n .with({type: \"finish\"}, async (finishPart) => {\n log(\"\\nQAQ finish: %y\", finishPart);\n // Add the assistant's message from this step to the history\n currentMessages.push(_currentAssistantMessage);\n __writeJsonLineLog(_currentAssistantMessage);\n\n if (finishPart.finishReason === \"stop\" || finishPart.finishReason === \"length\") {\n tui.prefixText = tui.endInfo.prefixText = \"✅ \";\n tui.text = tui.endInfo.text = green(`${cyan(`[${ai_task.jobName}]`)} Completed`);\n // Task finished without tool calls or after tool calls that didn't lead to more calls.\n return LOOP_SIGNALS.RETURN; // Exit the outer loop and function\n }\n\n if (finishPart.finishReason === \"tool-calls\") {\n if (requestedToolCalls.length === 0) {\n tui.prefixText = tui.endInfo.prefixText = \"🚧 \";\n tui.text = tui.endInfo.text = yellow(`${cyan(`[${ai_task.jobName}]`)} finished with 'tool-calls' but no tools were requested.`);\n return LOOP_SIGNALS.RETURN; // Exit, something is off\n }\n\n const toolResultMessages: ModelMessage[] = [];\n for (const toolCall of requestedToolCalls) {\n const toolToExecute = availableTools[toolCall.toolName];\n if (!toolToExecute || typeof toolToExecute.execute !== \"function\") {\n console.error(`Tool ${toolCall.toolName} not found or not executable.`);\n toolResultMessages.push({\n role: \"tool\",\n content: [\n {\n type: \"tool-result\",\n toolCallId: toolCall.toolCallId,\n toolName: toolCall.toolName,\n result: JSON.stringify({error: `Tool ${toolCall.toolName} not found or not executable.`}),\n isError: true,\n },\n ],\n });\n continue;\n }\n tui.text = `Executing tool: ${toolCall.toolName}...`;\n const executionResult = await func_catch(() =>\n toolToExecute.execute!(toolCall.args, {\n toolCallId: toolCall.toolCallId,\n messages: currentMessages,\n }),\n )();\n toolResultMessages.push({\n role: \"tool\",\n content: [\n {\n type: \"tool-result\",\n toolCallId: toolCall.toolCallId,\n toolName: toolCall.toolName,\n isError: !executionResult.success,\n result: JSON.stringify(executionResult.success ? executionResult.result : executionResult.error),\n },\n ],\n });\n if (executionResult.success) {\n tui.text = `Tool ${toolCall.toolName} executed.`;\n } else {\n tui.text = `Error executing tool ${toolCall.toolName}.`;\n }\n }\n currentMessages.push(...toolResultMessages);\n __writeJsonLineLog(...toolResultMessages);\n // Loop continues for the next step\n } else {\n // Other finish reasons, potentially an error or unexpected state\n tui.prefixText = tui.endInfo.prefixText = \"🛑 \";\n tui.text = tui.endInfo.text = red(`${cyan(`[${ai_task.jobName}]`)} task finished with unhandled reason: ${finishPart.finishReason}`);\n return LOOP_SIGNALS.ERROR;\n }\n })\n .otherwise(() => {}); // Handle any other part types if necessary\n\n if (LOOP_SIGNAL === LOOP_SIGNALS.ERROR) {\n throw LOOP_SIGNAL;\n }\n if (LOOP_SIGNAL === LOOP_SIGNALS.RETURN) {\n break loop;\n } else if (LOOP_SIGNAL === LOOP_SIGNALS.BREAK) {\n break;\n }\n }\n // If the stream finishes without a 'finish' part (e.g. error thrown inside), this loop might exit. Ensure spinner stops.\n if (turn === maxTurns - 1) {\n tui.prefixText = tui.endInfo.prefixText = \"🚧 \";\n tui.text = tui.endInfo.text = yellow(`${cyan(`[${ai_task.jobName}]`)} Max interaction turns reached.`);\n break;\n }\n }\n};\n"]}
@@ -1,10 +0,0 @@
1
- interface RunOptions {
2
- jobGoal: string;
3
- workDir: string;
4
- maxLoops: number;
5
- jobName?: string;
6
- gitCommit?: boolean;
7
- }
8
- export declare const run: (options: RunOptions) => Promise<void>;
9
- export {};
10
- //# sourceMappingURL=run.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/run.ts"],"names":[],"mappings":"AAGA,UAAU,UAAU;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,GAAG,GAAU,SAAS,UAAU,kBA0C5C,CAAC"}
@@ -1,44 +0,0 @@
1
- import { cyan, green, red, yellow } from "@gaubee/nodekit";
2
- import { safeEnv } from "../../env.js";
3
- export const run = async (options) => {
4
- const { jobGoal, workDir, maxLoops, jobName, gitCommit } = options;
5
- const coreUrl = safeEnv.JIXO_CORE_URL;
6
- const apiKey = safeEnv.JIXO_API_KEY;
7
- console.log(cyan(`🚀 Starting JIXO job...`));
8
- console.log(` - Goal: ${jobGoal}`);
9
- console.log(` - Target: ${coreUrl}`);
10
- try {
11
- const response = await fetch(`${coreUrl}/jixo/v1/jobs`, {
12
- method: "POST",
13
- headers: {
14
- "Content-Type": "application/json",
15
- Authorization: `Bearer ${apiKey}`,
16
- },
17
- body: JSON.stringify({
18
- jobGoal,
19
- workspaceDir: workDir, // Updated field name
20
- maxLoops,
21
- jobName,
22
- gitCommit,
23
- }),
24
- });
25
- if (!response.ok) {
26
- const errorBody = await response.text();
27
- throw new Error(`Failed to start job. Server responded with ${response.status}: ${errorBody}`);
28
- }
29
- const result = await response.json();
30
- console.log(green(`✅ Job successfully started with Run ID: ${result.runId}`));
31
- }
32
- catch (error) {
33
- if (error instanceof TypeError && error.message.includes("fetch failed")) {
34
- console.error(red("\n❌ Error: Could not connect to the JIXO Core service."));
35
- console.error(yellow(` Please ensure the core service is running at ${coreUrl}.`));
36
- console.error(yellow(` You can start it by running 'jixo daemon start' or running the core package directly.`));
37
- }
38
- else {
39
- console.error(red("\n❌ An unexpected error occurred:"), error);
40
- }
41
- process.exit(1);
42
- }
43
- };
44
- //# sourceMappingURL=run.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/commands/tasks/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAC,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAUrC,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,EAAE,OAAmB,EAAE,EAAE;IAC/C,MAAM,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAC,GAAG,OAAO,CAAC;IACjE,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;IACtC,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAEpC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,gBAAgB,OAAO,EAAE,CAAC,CAAC;IAEvC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,eAAe,EAAE;YACtD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,UAAU,MAAM,EAAE;aAClC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,OAAO;gBACP,YAAY,EAAE,OAAO,EAAE,qBAAqB;gBAC5C,QAAQ;gBACR,OAAO;gBACP,SAAS;aACV,CAAC;SACH,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,8CAA8C,QAAQ,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC,CAAC;QACjG,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,2CAA2C,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAChF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YACzE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,wDAAwD,CAAC,CAAC,CAAC;YAC7E,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,mDAAmD,OAAO,GAAG,CAAC,CAAC,CAAC;YACrF,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,0FAA0F,CAAC,CAAC,CAAC;QACpH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,mCAAmC,CAAC,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC","sourcesContent":["import {cyan, green, red, yellow} from \"@gaubee/nodekit\";\nimport {safeEnv} from \"../../env.js\";\n\ninterface RunOptions {\n jobGoal: string;\n workDir: string;\n maxLoops: number;\n jobName?: string;\n gitCommit?: boolean;\n}\n\nexport const run = async (options: RunOptions) => {\n const {jobGoal, workDir, maxLoops, jobName, gitCommit} = options;\n const coreUrl = safeEnv.JIXO_CORE_URL;\n const apiKey = safeEnv.JIXO_API_KEY;\n\n console.log(cyan(`🚀 Starting JIXO job...`));\n console.log(` - Goal: ${jobGoal}`);\n console.log(` - Target: ${coreUrl}`);\n\n try {\n const response = await fetch(`${coreUrl}/jixo/v1/jobs`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify({\n jobGoal,\n workspaceDir: workDir, // Updated field name\n maxLoops,\n jobName,\n gitCommit,\n }),\n });\n\n if (!response.ok) {\n const errorBody = await response.text();\n throw new Error(`Failed to start job. Server responded with ${response.status}: ${errorBody}`);\n }\n\n const result = await response.json();\n console.log(green(`✅ Job successfully started with Run ID: ${result.runId}`));\n } catch (error) {\n if (error instanceof TypeError && error.message.includes(\"fetch failed\")) {\n console.error(red(\"\\n❌ Error: Could not connect to the JIXO Core service.\"));\n console.error(yellow(` Please ensure the core service is running at ${coreUrl}.`));\n console.error(yellow(` You can start it by running 'jixo daemon start' or running the core package directly.`));\n } else {\n console.error(red(\"\\n❌ An unexpected error occurred:\"), error);\n }\n process.exit(1);\n }\n};\n"]}
package/dist/config.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import z from "zod";
2
- declare const zJixoConfig: z.ZodObject<{
3
- coreUrl: z.ZodDefault<z.ZodOptional<z.ZodString>>;
4
- }, "strip", z.ZodTypeAny, {
5
- coreUrl: string;
6
- }, {
7
- coreUrl?: string | undefined;
8
- }>;
9
- export type JixoConfig = z.output<typeof zJixoConfig>;
10
- export declare const defineConfig: (config: Partial<JixoConfig>) => {
11
- coreUrl: string;
12
- };
13
- export declare const loadConfig: (dir: string) => Promise<JixoConfig>;
14
- export {};
15
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,QAAA,MAAM,WAAW;;;;;;EAEf,CAAC;AAMH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,eAAO,MAAM,YAAY,GAAI,QAAQ,OAAO,CAAC,UAAU,CAAC;;CAEvD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,UAAU,CAOhE,CAAC"}
package/dist/config.js DELETED
@@ -1,23 +0,0 @@
1
- import { cosmiconfig } from "cosmiconfig";
2
- import { defu } from "defu";
3
- import z from "zod";
4
- const DEFAULT_CORE_URL = "http://localhost:4111";
5
- const zJixoConfig = z.object({
6
- coreUrl: z.string().url().optional().default(DEFAULT_CORE_URL),
7
- });
8
- const defaultConfig = {
9
- coreUrl: DEFAULT_CORE_URL,
10
- };
11
- export const defineConfig = (config) => {
12
- return zJixoConfig.parse(config);
13
- };
14
- export const loadConfig = async (dir) => {
15
- const explorer = cosmiconfig("jixo", {
16
- searchStrategy: "global",
17
- });
18
- const loaded = await explorer.search(dir);
19
- // Use Zod to parse the loaded config, which applies defaults if properties are missing.
20
- return defu(zJixoConfig.parse(loaded?.config || {}), defaultConfig);
21
- };
22
- console.log(defineConfig({}));
23
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAC1B,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AACjD,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC;CAC/D,CAAC,CAAC;AAEH,MAAM,aAAa,GAAe;IAChC,OAAO,EAAE,gBAAgB;CAC1B,CAAC;AAIF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAA2B,EAAE,EAAE;IAC1D,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,GAAW,EAAuB,EAAE;IACnE,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE;QACnC,cAAc,EAAE,QAAQ;KACzB,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1C,wFAAwF;IACxF,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC,EAAE,aAAa,CAAC,CAAC;AACtE,CAAC,CAAC;AACF,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC","sourcesContent":["import {cosmiconfig} from \"cosmiconfig\";\nimport {defu} from \"defu\";\nimport z from \"zod\";\nconst DEFAULT_CORE_URL = \"http://localhost:4111\";\nconst zJixoConfig = z.object({\n coreUrl: z.string().url().optional().default(DEFAULT_CORE_URL),\n});\n\nconst defaultConfig: JixoConfig = {\n coreUrl: DEFAULT_CORE_URL,\n};\n\nexport type JixoConfig = z.output<typeof zJixoConfig>;\n\nexport const defineConfig = (config: Partial<JixoConfig>) => {\n return zJixoConfig.parse(config);\n};\n\nexport const loadConfig = async (dir: string): Promise<JixoConfig> => {\n const explorer = cosmiconfig(\"jixo\", {\n searchStrategy: \"global\",\n });\n const loaded = await explorer.search(dir);\n // Use Zod to parse the loaded config, which applies defaults if properties are missing.\n return defu(zJixoConfig.parse(loaded?.config || {}), defaultConfig);\n};\nconsole.log(defineConfig({}));\n"]}
package/dist/env.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export declare const loadJixoEnv: (dir: string) => void;
2
- export declare const safeEnv: import("@gaubee/node").DefineEnvChain<"JIXO", import("@gaubee/node").DefineEnv<"JIXO", {
3
- CORE_URL: string;
4
- API_KEY: string;
5
- }>>;
6
- //# sourceMappingURL=env.d.ts.map
package/dist/env.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,SAKtC,CAAC;AAKF,eAAO,MAAM,OAAO;;;GAGlB,CAAC"}
package/dist/env.js DELETED
@@ -1,16 +0,0 @@
1
- import { defineEnv } from "@gaubee/node";
2
- import fs from "node:fs";
3
- import path from "node:path";
4
- export const loadJixoEnv = (dir) => {
5
- const cwdJixoEnvFilepath = path.join(dir, ".jixo.env");
6
- if (fs.existsSync(cwdJixoEnvFilepath)) {
7
- process.loadEnvFile(cwdJixoEnvFilepath);
8
- }
9
- };
10
- // Load environment from the current working directory when the module is imported.
11
- loadJixoEnv(process.cwd());
12
- export const safeEnv = defineEnv("JIXO", {
13
- CORE_URL: "http://localhost:4111",
14
- API_KEY: "",
15
- });
16
- //# sourceMappingURL=env.js.map
package/dist/env.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE;IACzC,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IACvD,IAAI,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC,CAAC;AAEF,mFAAmF;AACnF,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAE3B,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,EAAE;IACvC,QAAQ,EAAE,uBAAuB;IACjC,OAAO,EAAE,EAAE;CACZ,CAAC,CAAC","sourcesContent":["import {defineEnv} from \"@gaubee/node\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nexport const loadJixoEnv = (dir: string) => {\n const cwdJixoEnvFilepath = path.join(dir, \".jixo.env\");\n if (fs.existsSync(cwdJixoEnvFilepath)) {\n process.loadEnvFile(cwdJixoEnvFilepath);\n }\n};\n\n// Load environment from the current working directory when the module is imported.\nloadJixoEnv(process.cwd());\n\nexport const safeEnv = defineEnv(\"JIXO\", {\n CORE_URL: \"http://localhost:4111\",\n API_KEY: \"\",\n});\n"]}
@@ -1,3 +0,0 @@
1
- import { type Spinner } from "@gaubee/nodekit";
2
- export declare const handleRetryError: (error: unknown, loading: Pick<Spinner, "prefixText" | "text">) => Promise<void>;
3
- //# sourceMappingURL=ai-retry-error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ai-retry-error.d.ts","sourceRoot":"","sources":["../../src/helper/ai-retry-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAMhE,eAAO,MAAM,gBAAgB,GAAU,OAAO,OAAO,EAAE,SAAS,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAAC,kBA0CnG,CAAC"}
@@ -1,108 +0,0 @@
1
- import { gray, red, yellow } from "@gaubee/nodekit";
2
- import { delay } from "@gaubee/util";
3
- import { APICallError, RetryError } from "ai";
4
- import ms from "ms";
5
- import { match } from "ts-pattern";
6
- import z from "zod";
7
- export const handleRetryError = async (error, loading) => {
8
- if (!RetryError.isInstance(error)) {
9
- return;
10
- }
11
- for (const inner_error of error.errors) {
12
- if (!APICallError.isInstance(inner_error)) {
13
- continue;
14
- }
15
- try {
16
- if (!inner_error.isRetryable) {
17
- const safeData = geminiErrorSchema.safeParse(inner_error.data);
18
- if (!safeData.success) {
19
- throw safeData.error;
20
- }
21
- const retryDetail = safeData.data.error.details.find((d) => "retryDelay" in d);
22
- if (retryDetail) {
23
- const retryDelay = ms(retryDetail.retryDelay);
24
- if (typeof retryDelay === "number") {
25
- await waitRetryDelay(loading, retryDelay, yellow(inner_error.message));
26
- }
27
- }
28
- }
29
- else {
30
- const safeData = commonErrorSchema.safeParse(inner_error.data);
31
- if (!safeData.success) {
32
- throw safeData.error;
33
- }
34
- console.log("QAQ response.error", safeData);
35
- await match(safeData.data.error)
36
- /// 余额不足
37
- .with({ message: "Insufficient Balance" }, async () => {
38
- /// 30s重试
39
- await waitRetryDelay(loading, 1000 * 30, red("Insufficient Balance") + "\n" + red(inner_error.url));
40
- })
41
- .otherwise(() => {
42
- throw inner_error;
43
- });
44
- }
45
- }
46
- catch {
47
- console.error("\nQAQ unknown error", inner_error);
48
- }
49
- }
50
- };
51
- // const handleError
52
- const commonErrorSchema = z.object({
53
- error: z.object({
54
- message: z.string(),
55
- type: z.string(),
56
- param: z.any(),
57
- code: z.string(),
58
- }),
59
- });
60
- const geminiErrorSchema = z.object({
61
- error: z.object({
62
- code: z.number(),
63
- message: z.string(),
64
- status: z.string(),
65
- details: z.array(z.union([
66
- z.object({
67
- "@type": z.string(),
68
- violations: z.array(z.object({
69
- quotaMetric: z.string(),
70
- quotaId: z.string(),
71
- quotaDimensions: z.object({
72
- location: z.string(),
73
- model: z.string(),
74
- }),
75
- quotaValue: z.string(),
76
- })),
77
- }),
78
- z.object({
79
- "@type": z.string(),
80
- links: z.array(z.object({ description: z.string(), url: z.string() })),
81
- }),
82
- z.object({ "@type": z.string(), retryDelay: z.string() }),
83
- ])),
84
- }),
85
- });
86
- const waitRetryDelay = async (loading, retryDelay, message) => {
87
- const { prefixText, text } = loading;
88
- let remainingDelay = retryDelay;
89
- const tickInterval = 1000;
90
- const tick = () => {
91
- loading.prefixText = "⏲️ ";
92
- loading.text = [
93
- //
94
- message,
95
- " " + gray("─".repeat(Math.max(4, process.stdout.columns - 2))),
96
- `Retrying in ${ms(remainingDelay)}...`,
97
- ].join("\n");
98
- remainingDelay -= tickInterval;
99
- };
100
- tick();
101
- const ti = setInterval(tick, tickInterval);
102
- await delay(retryDelay);
103
- clearInterval(ti);
104
- // 回滚
105
- loading.prefixText = prefixText;
106
- loading.text = text;
107
- };
108
- //# sourceMappingURL=ai-retry-error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ai-retry-error.js","sourceRoot":"","sources":["../../src/helper/ai-retry-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAe,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AACnC,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,IAAI,CAAC;AAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,KAAc,EAAE,OAA6C,EAAE,EAAE;IACtG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO;IACT,CAAC;IACD,KAAK,MAAM,WAAW,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACvC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YAC1C,SAAS;QACX,CAAC;QACD,IAAI,CAAC;YACH,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;gBAC7B,MAAM,QAAQ,GAAG,iBAAiB,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC/D,IAAI,CAAC,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esContent":["import {gray, red, yellow, type Spinner} from \"@gaubee/nodekit\";\r\nimport {delay} from \"@gaubee/util\";\r\nimport {APICallError, RetryError} from \"ai\";\r\nimport ms from \"ms\";\r\nimport {match} from \"ts-pattern\";\r\nimport z from \"zod\";\r\nexport const handleRetryError = async (error: unknown, loading: Pick<Spinner, \"prefixText\" | \"text\">) => {\r\n if (!RetryError.isInstance(error)) {\r\n return;\r\n }\r\n for (const inner_error of error.errors) {\r\n if (!APICallError.isInstance(inner_error)) {\r\n continue;\r\n }\r\n try {\r\n if (!inner_error.isRetryable) {\r\n const safeData = geminiErrorSchema.safeParse(inner_error.data);\r\n if (!safeData.success) {\r\n throw safeData.error;\r\n }\r\n const retryDetail = safeData.data.error.details.find((d) => \"retryDelay\" in d);\r\n if (retryDetail) {\r\n const retryDelay = ms(retryDetail.retryDelay as ms.StringValue);\r\n\r\n if (typeof retryDelay === \"number\") {\r\n await waitRetryDelay(loading, retryDelay, yellow(inner_error.message));\r\n }\r\n }\r\n } else {\r\n const safeData = commonErrorSchema.safeParse(inner_error.data);\r\n if (!safeData.success) {\r\n throw safeData.error;\r\n }\r\n console.log(\"QAQ response.error\", safeData);\r\n await match(safeData.data.error)\r\n /// 余额不足\r\n .with({message: \"Insufficient Balance\"}, async () => {\r\n /// 30s重试\r\n await waitRetryDelay(loading, 1000 * 30, red(\"Insufficient Balance\") + \"\\n\" + red(inner_error.url));\r\n })\r\n .otherwise(() => {\r\n throw inner_error;\r\n });\r\n }\r\n } catch {\r\n console.error(\"\\nQAQ unknown error\", inner_error);\r\n }\r\n }\r\n};\r\n\r\n// const handleError\r\n\r\n\r\nconst commonErrorSchema = z.object({\r\n error: z.object({\r\n message: z.string(),\r\n type: z.string(),\r\n param: z.any(),\r\n code: z.string(),\r\n }),\r\n});\r\n\r\nconst geminiErrorSchema = z.object({\r\n error: z.object({\r\n code: z.number(),\r\n message: z.string(),\r\n status: z.string(),\r\n details: z.array(\r\n z.union([\r\n z.object({\r\n \"@type\": z.string(),\r\n violations: z.array(\r\n z.object({\r\n quotaMetric: z.string(),\r\n quotaId: z.string(),\r\n quotaDimensions: z.object({\r\n location: z.string(),\r\n model: z.string(),\r\n }),\r\n quotaValue: z.string(),\r\n }),\r\n ),\r\n }),\r\n z.object({\r\n \"@type\": z.string(),\r\n links: z.array(z.object({description: z.string(), url: z.string()})),\r\n }),\r\n z.object({\"@type\": z.string(), retryDelay: z.string()}),\r\n ]),\r\n ),\r\n }),\r\n});\r\n\r\nconst waitRetryDelay = async (loading: Pick<Spinner, \"prefixText\" | \"text\">, retryDelay: number, message: string) => {\r\n const {prefixText, text} = loading;\r\n let remainingDelay = retryDelay;\r\n const tickInterval = 1000;\r\n const tick = () => {\r\n loading.prefixText = \"⏲️ \";\r\n loading.text = [\r\n //\r\n message,\r\n \" \" + gray(\"─\".repeat(Math.max(4, process.stdout.columns - 2))),\r\n `Retrying in ${ms(remainingDelay)}...`,\r\n ].join(\"\\n\");\r\n remainingDelay -= tickInterval;\r\n };\r\n tick();\r\n\r\n const ti = setInterval(tick, tickInterval);\r\n await delay(retryDelay);\r\n clearInterval(ti);\r\n\r\n // 回滚\r\n loading.prefixText = prefixText;\r\n loading.text = text;\r\n};\r\n"]}
@@ -1,3 +0,0 @@
1
- import { FileEntry } from "@gaubee/nodekit";
2
- export declare function findChangedFilesSinceCommit(messagePattern: string, cwd?: string): Promise<FileEntry[]>;
3
- //# sourceMappingURL=find-changes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-changes.d.ts","sourceRoot":"","sources":["../../src/helper/find-changes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAuB,MAAM,iBAAiB,CAAC;AAUhE,wBAAsB,2BAA2B,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,GAAE,MAAY,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAyGjH"}
@@ -1,113 +0,0 @@
1
- import { FileEntry, gray, red, walkFiles } from "@gaubee/nodekit";
2
- import { execSync } from "node:child_process";
3
- import path from "node:path";
4
- export async function findChangedFilesSinceCommit(messagePattern, cwd = ".") {
5
- let repoPath = cwd;
6
- try {
7
- // 获取 Git 仓库位置,同时确保在 Git 仓库中运行
8
- repoPath = execSync("git rev-parse --show-toplevel", { cwd, encoding: "utf8", stdio: "pipe" }).toString().trim();
9
- }
10
- catch (e) {
11
- return [...walkFiles(repoPath)];
12
- }
13
- const gitCommandOptions = { cwd: repoPath, encoding: "utf8", stdio: "pipe" }; // stdio: 'pipe' to access stdout/stderr on error
14
- let baseCommitForDiff = null;
15
- try {
16
- // 1. 找到包含特定标记的最新 commit SHA
17
- // 使用 --fixed-strings 来精确匹配字符串 "@jixo",而不是作为正则表达式
18
- const targetCommitSha = execSync(`git log --grep="${messagePattern}" --fixed-strings -n 1 --pretty=format:%H`, gitCommandOptions).toString().trim();
19
- if (targetCommitSha) {
20
- console.log(`Found target commit SHA: ${targetCommitSha} for message pattern: "${messagePattern}"`);
21
- baseCommitForDiff = targetCommitSha;
22
- }
23
- else {
24
- console.warn(gray(`No commit found with message pattern: "${messagePattern}". All files (includes uncommitted changes) will be listed.`));
25
- }
26
- }
27
- catch (error) {
28
- // git log --grep 通常在没有匹配时返回空输出和退出码0。
29
- // 如果这里出错,可能是更严重的问题。
30
- const gitError = error;
31
- console.warn(red(`Could not determine base commit with pattern "${messagePattern}". All files (includes uncommitted changes) will be listed. Details:`));
32
- console.error(gitError.message);
33
- }
34
- if (!baseCommitForDiff) {
35
- return execSync("git ls-tree HEAD --name-only -r", { cwd, encoding: "utf8", stdio: "pipe" })
36
- .toString()
37
- .trim()
38
- .split("\n")
39
- .map((filepath) => {
40
- return new FileEntry(path.join(cwd, filepath), { cwd });
41
- });
42
- }
43
- const changedFiles = new Set();
44
- // 2. 列出从该 commit 之后到 HEAD (最新已提交) 的所有变更文件
45
- try {
46
- const committedChangesOutput = execSync(`git diff ${baseCommitForDiff} HEAD --name-only`, gitCommandOptions).toString().trim();
47
- if (committedChangesOutput) {
48
- committedChangesOutput.split("\n").forEach((file) => {
49
- if (file.trim())
50
- changedFiles.add(file.trim());
51
- });
52
- }
53
- }
54
- catch (error) {
55
- const gitError = error;
56
- // `git diff` 在有差异时退出码为1,无差异时为0。execSync 默认在非0时抛错。
57
- if (gitError.status === 1 && gitError.stdout) {
58
- // 有差异
59
- const output = gitError.stdout ?? "";
60
- if (output) {
61
- output.split("\n").forEach((file) => {
62
- if (file.trim())
63
- changedFiles.add(file.trim());
64
- });
65
- }
66
- }
67
- else if (gitError.status !== 0) {
68
- // 其他错误
69
- console.error(`Error getting committed changes since ${baseCommitForDiff}: ${gitError.stderr || gitError.message}`);
70
- }
71
- // status 0 (无差异) 表示没有输出,是正常情况
72
- }
73
- // 3. 列出工作区中未提交的变更文件
74
- const uncommittedCommands = [
75
- { cmd: "git diff --name-only --cached", desc: "staged changes" }, // 已暂存
76
- { cmd: "git diff --name-only", desc: "unstaged changes" }, // 未暂存 (对比工作区和暂存区)
77
- { cmd: "git ls-files --others --exclude-standard", desc: "untracked files" }, // 未跟踪
78
- ];
79
- for (const item of uncommittedCommands) {
80
- try {
81
- const output = execSync(item.cmd, gitCommandOptions).toString().trim();
82
- if (output) {
83
- output.split("\n").forEach((file) => {
84
- if (file.trim())
85
- changedFiles.add(file.trim());
86
- });
87
- }
88
- }
89
- catch (error) {
90
- const gitError = error;
91
- if (item.cmd.startsWith("git diff") && gitError.status === 1 && gitError.stdout) {
92
- // git diff 有差异
93
- const output = gitError.stdout ?? "";
94
- if (output) {
95
- output.split("\n").forEach((file) => {
96
- if (file.trim())
97
- changedFiles.add(file.trim());
98
- });
99
- }
100
- }
101
- else if (gitError.status !== 0 && !(item.cmd.startsWith("git diff") && gitError.status === 1)) {
102
- // 其他错误
103
- // 对于 ls-files,如果出错,也记录
104
- console.error(`Error getting ${item.desc}: ${gitError.stderr || gitError.message}`);
105
- }
106
- // `git ls-files` 在没有文件时退出码为0,输出为空。
107
- // `git diff` 在没有差异时退出码为0,输出为空。
108
- }
109
- }
110
- // 返回相对于仓库根目录的文件路径
111
- return [...changedFiles].map((filepath) => new FileEntry(path.resolve(repoPath, filepath), { cwd: repoPath }));
112
- }
113
- //# sourceMappingURL=find-changes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-changes.js","sourceRoot":"","sources":["../../src/helper/find-changes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAqB,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAChE,OAAO,IAAI,MAAM,WAAW,CAAC;AAQ7B,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,cAAsB,EAAE,MAAc,GAAG;IACzF,IAAI,QAAQ,GAAG,GAAG,CAAC;IACnB,IAAI,CAAC;QACH,8BAA8B;QAC9B,QAAQ,GAAG,QAAQ,CAAC,+BAA+B,EAAE,EAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;IACjH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClC,CAAC;IACD,MAAM,iBAAiB,GAAG,EAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAwB,EAAE,KAAK,EAAE,MAAgB,EAAC,CAAC,CAAC,iDAAiD;IAEzJ,IAAI,iBAAiB,GAAkB,IAAI,CAAC;IAE5C,IAAI,CAAC;QACH,4BAA4B;QAC5B,iDAAiD;QACjD,MAAM,eAAe,GAAG,QAAQ,CAAC,mBAAmB,cAAc,2CAA2C,EAAE,iBAAiB,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;QAEpJ,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,4BAA4B,eAAe,0BAA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QACjC,CAAC;IACH,CAAC;IAED,kBAAkB;IAClB,OAAO,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAC,GAAG,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;AAC/G,CAAC","sourcesContent":["import {FileEntry, gray, red, walkFiles} from \"@gaubee/nodekit\";\nimport {type ExecException, execSync} from \"node:child_process\";\nimport path from \"node:path\";\n\ninterface GitError extends ExecException {\n status?: number | null;\n // stderr?: Buffer | string;\n // stdout?: Buffer | string;\n}\n\nexport async function findChangedFilesSinceCommit(messagePattern: string, cwd: string = \".\"): Promise<FileEntry[]> {\n let repoPath = cwd;\n try {\n // 获取 Git 仓库位置,同时确保在 Git 仓库中运行\n repoPath = execSync(\"git rev-parse --show-toplevel\", {cwd, encoding: \"utf8\", stdio: \"pipe\"}).toString().trim();\n } catch (e) {\n return [...walkFiles(repoPath)];\n }\n const gitCommandOptions = {cwd: repoPath, encoding: \"utf8\" as BufferEncoding, stdio: \"pipe\" as \"pipe\"}; // stdio: 'pipe' to access stdout/stderr on error\n\n let baseCommitForDiff: string | null = null;\n\n try {\n // 1. 找到包含特定标记的最新 commit SHA\n // 使用 --fixed-strings 来精确匹配字符串 \"@jixo\",而不是作为正则表达式\n const targetCommitSha = execSync(`git log --grep=\"${messagePattern}\" --fixed-strings -n 1 --pretty=format:%H`, gitCommandOptions).toString().trim();\n\n if (targetCommitSha) {\n console.log(`Found target commit SHA: ${targetCommitSha} for message pattern: \"${messagePattern}\"`);\n baseCommitForDiff = targetCommitSha;\n } else {\n console.warn(gray(`No commit found with message pattern: \"${messagePattern}\". All files (includes uncommitted changes) will be listed.`));\n }\n } catch (error) {\n // git log --grep 通常在没有匹配时返回空输出和退出码0。\n // 如果这里出错,可能是更严重的问题。\n const gitError = error as GitError;\n console.warn(red(`Could not determine base commit with pattern \"${messagePattern}\". All files (includes uncommitted changes) will be listed. Details:`));\n console.error(gitError.message);\n }\n if (!baseCommitForDiff) {\n return execSync(\"git ls-tree HEAD --name-only -r\", {cwd, encoding: \"utf8\", stdio: \"pipe\"})\n .toString()\n .trim()\n .split(\"\\n\")\n .map((filepath) => {\n return new FileEntry(path.join(cwd, filepath), {cwd});\n });\n }\n\n const changedFiles = new Set<string>();\n\n // 2. 列出从该 commit 之后到 HEAD (最新已提交) 的所有变更文件\n\n try {\n const committedChangesOutput = execSync(`git diff ${baseCommitForDiff} HEAD --name-only`, gitCommandOptions).toString().trim();\n if (committedChangesOutput) {\n committedChangesOutput.split(\"\\n\").forEach((file) => {\n if (file.trim()) changedFiles.add(file.trim());\n });\n }\n } catch (error) {\n const gitError = error as GitError;\n // `git diff` 在有差异时退出码为1,无差异时为0。execSync 默认在非0时抛错。\n if (gitError.status === 1 && gitError.stdout) {\n // 有差异\n const output = gitError.stdout ?? \"\";\n if (output) {\n output.split(\"\\n\").forEach((file) => {\n if (file.trim()) changedFiles.add(file.trim());\n });\n }\n } else if (gitError.status !== 0) {\n // 其他错误\n console.error(`Error getting committed changes since ${baseCommitForDiff}: ${gitError.stderr || gitError.message}`);\n }\n // status 0 (无差异) 表示没有输出,是正常情况\n }\n // 3. 列出工作区中未提交的变更文件\n const uncommittedCommands = [\n {cmd: \"git diff --name-only --cached\", desc: \"staged changes\"}, // 已暂存\n {cmd: \"git diff --name-only\", desc: \"unstaged changes\"}, // 未暂存 (对比工作区和暂存区)\n {cmd: \"git ls-files --others --exclude-standard\", desc: \"untracked files\"}, // 未跟踪\n ];\n\n for (const item of uncommittedCommands) {\n try {\n const output = execSync(item.cmd, gitCommandOptions).toString().trim();\n if (output) {\n output.split(\"\\n\").forEach((file) => {\n if (file.trim()) changedFiles.add(file.trim());\n });\n }\n } catch (error) {\n const gitError = error as GitError;\n if (item.cmd.startsWith(\"git diff\") && gitError.status === 1 && gitError.stdout) {\n // git diff 有差异\n const output = gitError.stdout ?? \"\";\n if (output) {\n output.split(\"\\n\").forEach((file) => {\n if (file.trim()) changedFiles.add(file.trim());\n });\n }\n } else if (gitError.status !== 0 && !(item.cmd.startsWith(\"git diff\") && gitError.status === 1)) {\n // 其他错误\n // 对于 ls-files,如果出错,也记录\n console.error(`Error getting ${item.desc}: ${gitError.stderr || gitError.message}`);\n }\n // `git ls-files` 在没有文件时退出码为0,输出为空。\n // `git diff` 在没有差异时退出码为0,输出为空。\n }\n }\n\n // 返回相对于仓库根目录的文件路径\n return [...changedFiles].map((filepath) => new FileEntry(path.resolve(repoPath, filepath), {cwd: repoPath}));\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=find-changes.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-changes.test.d.ts","sourceRoot":"","sources":["../../src/helper/find-changes.test.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- import { import_meta_ponyfill } from "import-meta-ponyfill";
2
- import path from "node:path";
3
- import { findChangedFilesSinceCommit } from "./find-changes.js";
4
- // --- 使用示例 ---
5
- async function test() {
6
- const messagePattern = "@jixo"; // 你要搜索的 commit message 内容
7
- const repoDir = "."; // Git 仓库的路径,默认为当前目录
8
- console.log(`Searching for changes since commit with message containing "${messagePattern}" in ${path.resolve(repoDir)}...`);
9
- const files = await findChangedFilesSinceCommit(messagePattern, repoDir);
10
- if (files.length > 0) {
11
- console.log("\nChanged files (relative to git root):");
12
- }
13
- else {
14
- console.log("\nNo changed files found based on the criteria.");
15
- }
16
- return files;
17
- }
18
- if (import_meta_ponyfill(import.meta).main) {
19
- const files = await test();
20
- console.log(files.map((file) => file.path));
21
- }
22
- //# sourceMappingURL=find-changes.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-changes.test.js","sourceRoot":"","sources":["../../src/helper/find-changes.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAC1D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,2BAA2B,EAAC,MAAM,mBAAmB,CAAC;AAE9D,eAAe;AACf,KAAK,UAAU,IAAI;IACjB,MAAM,cAAc,GAAG,OAAO,CAAC,CAAC,0BAA0B;IAC1D,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC,oBAAoB;IAEzC,OAAO,CAAC,GAAG,CAAC,+DAA+D,cAAc,QAAQ,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7H,MAAM,KAAK,GAAG,MAAM,2BAA2B,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEzE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;IACzD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AACD,IAAI,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,MAAM,IAAI,EAAE,CAAC;IAC3B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["import {import_meta_ponyfill} from \"import-meta-ponyfill\";\nimport path from \"node:path\";\nimport {findChangedFilesSinceCommit} from \"./find-changes.js\";\n\n// --- 使用示例 ---\nasync function test() {\n const messagePattern = \"@jixo\"; // 你要搜索的 commit message 内容\n const repoDir = \".\"; // Git 仓库的路径,默认为当前目录\n\n console.log(`Searching for changes since commit with message containing \"${messagePattern}\" in ${path.resolve(repoDir)}...`);\n const files = await findChangedFilesSinceCommit(messagePattern, repoDir);\n\n if (files.length > 0) {\n console.log(\"\\nChanged files (relative to git root):\");\n } else {\n console.log(\"\\nNo changed files found based on the criteria.\");\n }\n return files;\n}\nif (import_meta_ponyfill(import.meta).main) {\n const files = await test();\n console.log(files.map((file) => file.path));\n}\n"]}
@@ -1,5 +0,0 @@
1
- import { type Spinner } from "@gaubee/nodekit";
2
- type Loading = Pick<Spinner, "prefixText" | "text">;
3
- export declare const handleError: (error: unknown, loading: Loading) => Promise<true | undefined>;
4
- export {};
5
- //# sourceMappingURL=handle-ai-error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handle-ai-error.d.ts","sourceRoot":"","sources":["../../src/helper/handle-ai-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAMhE,KAAK,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAAC,CAAC;AAEpD,eAAO,MAAM,WAAW,GAAU,OAAO,OAAO,EAAE,SAAS,OAAO,8BAOjE,CAAC"}