@polka-codes/cli-shared 0.9.33 → 0.9.35

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 +11 -734
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -38267,10 +38267,10 @@ class UsageMeter {
38267
38267
  };
38268
38268
  const usage = "totalUsage" in resp ? resp.totalUsage : resp.usage;
38269
38269
  const result = this.#calculageUsage(usage, resp.providerMetadata, modelInfo);
38270
- this.#totals.input += result.input;
38271
- this.#totals.output += result.output;
38272
- this.#totals.cachedRead += result.cachedRead;
38273
- this.#totals.cost += result.cost;
38270
+ this.#totals.input += result.input || 0;
38271
+ this.#totals.output += result.output || 0;
38272
+ this.#totals.cachedRead += result.cachedRead || 0;
38273
+ this.#totals.cost += result.cost || 0;
38274
38274
  this.#totals.messageCount += 1;
38275
38275
  }
38276
38276
  setUsage(newUsage) {
@@ -46072,13 +46072,6 @@ function prepareRetries({
46072
46072
  })
46073
46073
  };
46074
46074
  }
46075
- function extractTextContent(content) {
46076
- const parts = content.filter((content2) => content2.type === "text");
46077
- if (parts.length === 0) {
46078
- return;
46079
- }
46080
- return parts.map((content2) => content2.text).join("");
46081
- }
46082
46075
  var DefaultGeneratedFile = class {
46083
46076
  constructor({
46084
46077
  data,
@@ -46370,519 +46363,6 @@ var originalGenerateId = createIdGenerator({
46370
46363
  prefix: "aitxt",
46371
46364
  size: 24
46372
46365
  });
46373
- async function generateText({
46374
- model: modelArg,
46375
- tools,
46376
- toolChoice,
46377
- system,
46378
- prompt,
46379
- messages,
46380
- maxRetries: maxRetriesArg,
46381
- abortSignal,
46382
- headers,
46383
- stopWhen = stepCountIs(1),
46384
- experimental_output: output,
46385
- experimental_telemetry: telemetry,
46386
- providerOptions,
46387
- experimental_activeTools,
46388
- activeTools = experimental_activeTools,
46389
- experimental_prepareStep,
46390
- prepareStep = experimental_prepareStep,
46391
- experimental_repairToolCall: repairToolCall,
46392
- experimental_download: download2,
46393
- experimental_context,
46394
- _internal: {
46395
- generateId: generateId3 = originalGenerateId,
46396
- currentDate = () => /* @__PURE__ */ new Date
46397
- } = {},
46398
- onStepFinish,
46399
- ...settings
46400
- }) {
46401
- const model = resolveLanguageModel(modelArg);
46402
- const stopConditions = asArray(stopWhen);
46403
- const { maxRetries, retry } = prepareRetries({
46404
- maxRetries: maxRetriesArg,
46405
- abortSignal
46406
- });
46407
- const callSettings = prepareCallSettings(settings);
46408
- const baseTelemetryAttributes = getBaseTelemetryAttributes({
46409
- model,
46410
- telemetry,
46411
- headers,
46412
- settings: { ...callSettings, maxRetries }
46413
- });
46414
- const initialPrompt = await standardizePrompt({
46415
- system,
46416
- prompt,
46417
- messages
46418
- });
46419
- const tracer = getTracer(telemetry);
46420
- try {
46421
- return await recordSpan({
46422
- name: "ai.generateText",
46423
- attributes: selectTelemetryAttributes({
46424
- telemetry,
46425
- attributes: {
46426
- ...assembleOperationName({
46427
- operationId: "ai.generateText",
46428
- telemetry
46429
- }),
46430
- ...baseTelemetryAttributes,
46431
- "ai.model.provider": model.provider,
46432
- "ai.model.id": model.modelId,
46433
- "ai.prompt": {
46434
- input: () => JSON.stringify({ system, prompt, messages })
46435
- }
46436
- }
46437
- }),
46438
- tracer,
46439
- fn: async (span) => {
46440
- var _a172, _b8, _c, _d, _e, _f, _g;
46441
- const callSettings2 = prepareCallSettings(settings);
46442
- let currentModelResponse;
46443
- let clientToolCalls = [];
46444
- let clientToolOutputs = [];
46445
- const responseMessages = [];
46446
- const steps = [];
46447
- do {
46448
- const stepInputMessages = [
46449
- ...initialPrompt.messages,
46450
- ...responseMessages
46451
- ];
46452
- const prepareStepResult = await (prepareStep == null ? undefined : prepareStep({
46453
- model,
46454
- steps,
46455
- stepNumber: steps.length,
46456
- messages: stepInputMessages
46457
- }));
46458
- const promptMessages = await convertToLanguageModelPrompt({
46459
- prompt: {
46460
- system: (_a172 = prepareStepResult == null ? undefined : prepareStepResult.system) != null ? _a172 : initialPrompt.system,
46461
- messages: (_b8 = prepareStepResult == null ? undefined : prepareStepResult.messages) != null ? _b8 : stepInputMessages
46462
- },
46463
- supportedUrls: await model.supportedUrls,
46464
- download: download2
46465
- });
46466
- const stepModel = resolveLanguageModel((_c = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _c : model);
46467
- const { toolChoice: stepToolChoice, tools: stepTools } = prepareToolsAndToolChoice({
46468
- tools,
46469
- toolChoice: (_d = prepareStepResult == null ? undefined : prepareStepResult.toolChoice) != null ? _d : toolChoice,
46470
- activeTools: (_e = prepareStepResult == null ? undefined : prepareStepResult.activeTools) != null ? _e : activeTools
46471
- });
46472
- currentModelResponse = await retry(() => {
46473
- var _a18;
46474
- return recordSpan({
46475
- name: "ai.generateText.doGenerate",
46476
- attributes: selectTelemetryAttributes({
46477
- telemetry,
46478
- attributes: {
46479
- ...assembleOperationName({
46480
- operationId: "ai.generateText.doGenerate",
46481
- telemetry
46482
- }),
46483
- ...baseTelemetryAttributes,
46484
- "ai.model.provider": stepModel.provider,
46485
- "ai.model.id": stepModel.modelId,
46486
- "ai.prompt.messages": {
46487
- input: () => stringifyForTelemetry(promptMessages)
46488
- },
46489
- "ai.prompt.tools": {
46490
- input: () => stepTools == null ? undefined : stepTools.map((tool3) => JSON.stringify(tool3))
46491
- },
46492
- "ai.prompt.toolChoice": {
46493
- input: () => stepToolChoice != null ? JSON.stringify(stepToolChoice) : undefined
46494
- },
46495
- "gen_ai.system": stepModel.provider,
46496
- "gen_ai.request.model": stepModel.modelId,
46497
- "gen_ai.request.frequency_penalty": settings.frequencyPenalty,
46498
- "gen_ai.request.max_tokens": settings.maxOutputTokens,
46499
- "gen_ai.request.presence_penalty": settings.presencePenalty,
46500
- "gen_ai.request.stop_sequences": settings.stopSequences,
46501
- "gen_ai.request.temperature": (_a18 = settings.temperature) != null ? _a18 : undefined,
46502
- "gen_ai.request.top_k": settings.topK,
46503
- "gen_ai.request.top_p": settings.topP
46504
- }
46505
- }),
46506
- tracer,
46507
- fn: async (span2) => {
46508
- var _a19, _b22, _c2, _d2, _e2, _f2, _g2, _h;
46509
- const result = await stepModel.doGenerate({
46510
- ...callSettings2,
46511
- tools: stepTools,
46512
- toolChoice: stepToolChoice,
46513
- responseFormat: output == null ? undefined : output.responseFormat,
46514
- prompt: promptMessages,
46515
- providerOptions,
46516
- abortSignal,
46517
- headers
46518
- });
46519
- const responseData = {
46520
- id: (_b22 = (_a19 = result.response) == null ? undefined : _a19.id) != null ? _b22 : generateId3(),
46521
- timestamp: (_d2 = (_c2 = result.response) == null ? undefined : _c2.timestamp) != null ? _d2 : currentDate(),
46522
- modelId: (_f2 = (_e2 = result.response) == null ? undefined : _e2.modelId) != null ? _f2 : stepModel.modelId,
46523
- headers: (_g2 = result.response) == null ? undefined : _g2.headers,
46524
- body: (_h = result.response) == null ? undefined : _h.body
46525
- };
46526
- span2.setAttributes(selectTelemetryAttributes({
46527
- telemetry,
46528
- attributes: {
46529
- "ai.response.finishReason": result.finishReason,
46530
- "ai.response.text": {
46531
- output: () => extractTextContent(result.content)
46532
- },
46533
- "ai.response.toolCalls": {
46534
- output: () => {
46535
- const toolCalls = asToolCalls(result.content);
46536
- return toolCalls == null ? undefined : JSON.stringify(toolCalls);
46537
- }
46538
- },
46539
- "ai.response.id": responseData.id,
46540
- "ai.response.model": responseData.modelId,
46541
- "ai.response.timestamp": responseData.timestamp.toISOString(),
46542
- "ai.response.providerMetadata": JSON.stringify(result.providerMetadata),
46543
- "ai.usage.promptTokens": result.usage.inputTokens,
46544
- "ai.usage.completionTokens": result.usage.outputTokens,
46545
- "gen_ai.response.finish_reasons": [result.finishReason],
46546
- "gen_ai.response.id": responseData.id,
46547
- "gen_ai.response.model": responseData.modelId,
46548
- "gen_ai.usage.input_tokens": result.usage.inputTokens,
46549
- "gen_ai.usage.output_tokens": result.usage.outputTokens
46550
- }
46551
- }));
46552
- return { ...result, response: responseData };
46553
- }
46554
- });
46555
- });
46556
- const stepToolCalls = await Promise.all(currentModelResponse.content.filter((part) => part.type === "tool-call").map((toolCall) => parseToolCall({
46557
- toolCall,
46558
- tools,
46559
- repairToolCall,
46560
- system,
46561
- messages: stepInputMessages
46562
- })));
46563
- for (const toolCall of stepToolCalls) {
46564
- if (toolCall.invalid) {
46565
- continue;
46566
- }
46567
- const tool3 = tools[toolCall.toolName];
46568
- if ((tool3 == null ? undefined : tool3.onInputAvailable) != null) {
46569
- await tool3.onInputAvailable({
46570
- input: toolCall.input,
46571
- toolCallId: toolCall.toolCallId,
46572
- messages: stepInputMessages,
46573
- abortSignal,
46574
- experimental_context
46575
- });
46576
- }
46577
- }
46578
- const invalidToolCalls = stepToolCalls.filter((toolCall) => toolCall.invalid && toolCall.dynamic);
46579
- clientToolOutputs = [];
46580
- for (const toolCall of invalidToolCalls) {
46581
- clientToolOutputs.push({
46582
- type: "tool-error",
46583
- toolCallId: toolCall.toolCallId,
46584
- toolName: toolCall.toolName,
46585
- input: toolCall.input,
46586
- error: getErrorMessage2(toolCall.error),
46587
- dynamic: true
46588
- });
46589
- }
46590
- clientToolCalls = stepToolCalls.filter((toolCall) => !toolCall.providerExecuted);
46591
- if (tools != null) {
46592
- clientToolOutputs.push(...await executeTools({
46593
- toolCalls: clientToolCalls.filter((toolCall) => !toolCall.invalid),
46594
- tools,
46595
- tracer,
46596
- telemetry,
46597
- messages: stepInputMessages,
46598
- abortSignal,
46599
- experimental_context
46600
- }));
46601
- }
46602
- const stepContent = asContent({
46603
- content: currentModelResponse.content,
46604
- toolCalls: stepToolCalls,
46605
- toolOutputs: clientToolOutputs
46606
- });
46607
- responseMessages.push(...toResponseMessages({
46608
- content: stepContent,
46609
- tools
46610
- }));
46611
- const currentStepResult = new DefaultStepResult({
46612
- content: stepContent,
46613
- finishReason: currentModelResponse.finishReason,
46614
- usage: currentModelResponse.usage,
46615
- warnings: currentModelResponse.warnings,
46616
- providerMetadata: currentModelResponse.providerMetadata,
46617
- request: (_f = currentModelResponse.request) != null ? _f : {},
46618
- response: {
46619
- ...currentModelResponse.response,
46620
- messages: structuredClone(responseMessages)
46621
- }
46622
- });
46623
- logWarnings((_g = currentModelResponse.warnings) != null ? _g : []);
46624
- steps.push(currentStepResult);
46625
- await (onStepFinish == null ? undefined : onStepFinish(currentStepResult));
46626
- } while (clientToolCalls.length > 0 && clientToolOutputs.length === clientToolCalls.length && !await isStopConditionMet({ stopConditions, steps }));
46627
- span.setAttributes(selectTelemetryAttributes({
46628
- telemetry,
46629
- attributes: {
46630
- "ai.response.finishReason": currentModelResponse.finishReason,
46631
- "ai.response.text": {
46632
- output: () => extractTextContent(currentModelResponse.content)
46633
- },
46634
- "ai.response.toolCalls": {
46635
- output: () => {
46636
- const toolCalls = asToolCalls(currentModelResponse.content);
46637
- return toolCalls == null ? undefined : JSON.stringify(toolCalls);
46638
- }
46639
- },
46640
- "ai.response.providerMetadata": JSON.stringify(currentModelResponse.providerMetadata),
46641
- "ai.usage.promptTokens": currentModelResponse.usage.inputTokens,
46642
- "ai.usage.completionTokens": currentModelResponse.usage.outputTokens
46643
- }
46644
- }));
46645
- const lastStep = steps[steps.length - 1];
46646
- return new DefaultGenerateTextResult({
46647
- steps,
46648
- resolvedOutput: await (output == null ? undefined : output.parseOutput({ text: lastStep.text }, {
46649
- response: lastStep.response,
46650
- usage: lastStep.usage,
46651
- finishReason: lastStep.finishReason
46652
- }))
46653
- });
46654
- }
46655
- });
46656
- } catch (error43) {
46657
- throw wrapGatewayError(error43);
46658
- }
46659
- }
46660
- async function executeTools({
46661
- toolCalls,
46662
- tools,
46663
- tracer,
46664
- telemetry,
46665
- messages,
46666
- abortSignal,
46667
- experimental_context
46668
- }) {
46669
- const toolOutputs = await Promise.all(toolCalls.map(async ({ toolCallId, toolName, input }) => {
46670
- const tool3 = tools[toolName];
46671
- if ((tool3 == null ? undefined : tool3.execute) == null) {
46672
- return;
46673
- }
46674
- return recordSpan({
46675
- name: "ai.toolCall",
46676
- attributes: selectTelemetryAttributes({
46677
- telemetry,
46678
- attributes: {
46679
- ...assembleOperationName({
46680
- operationId: "ai.toolCall",
46681
- telemetry
46682
- }),
46683
- "ai.toolCall.name": toolName,
46684
- "ai.toolCall.id": toolCallId,
46685
- "ai.toolCall.args": {
46686
- output: () => JSON.stringify(input)
46687
- }
46688
- }
46689
- }),
46690
- tracer,
46691
- fn: async (span) => {
46692
- try {
46693
- const stream = executeTool({
46694
- execute: tool3.execute.bind(tool3),
46695
- input,
46696
- options: {
46697
- toolCallId,
46698
- messages,
46699
- abortSignal,
46700
- experimental_context
46701
- }
46702
- });
46703
- let output;
46704
- for await (const part of stream) {
46705
- if (part.type === "final") {
46706
- output = part.output;
46707
- }
46708
- }
46709
- try {
46710
- span.setAttributes(selectTelemetryAttributes({
46711
- telemetry,
46712
- attributes: {
46713
- "ai.toolCall.result": {
46714
- output: () => JSON.stringify(output)
46715
- }
46716
- }
46717
- }));
46718
- } catch (ignored) {}
46719
- return {
46720
- type: "tool-result",
46721
- toolCallId,
46722
- toolName,
46723
- input,
46724
- output,
46725
- dynamic: tool3.type === "dynamic"
46726
- };
46727
- } catch (error43) {
46728
- recordErrorOnSpan(span, error43);
46729
- return {
46730
- type: "tool-error",
46731
- toolCallId,
46732
- toolName,
46733
- input,
46734
- error: error43,
46735
- dynamic: tool3.type === "dynamic"
46736
- };
46737
- }
46738
- }
46739
- });
46740
- }));
46741
- return toolOutputs.filter((output) => output != null);
46742
- }
46743
- var DefaultGenerateTextResult = class {
46744
- constructor(options) {
46745
- this.steps = options.steps;
46746
- this.resolvedOutput = options.resolvedOutput;
46747
- }
46748
- get finalStep() {
46749
- return this.steps[this.steps.length - 1];
46750
- }
46751
- get content() {
46752
- return this.finalStep.content;
46753
- }
46754
- get text() {
46755
- return this.finalStep.text;
46756
- }
46757
- get files() {
46758
- return this.finalStep.files;
46759
- }
46760
- get reasoningText() {
46761
- return this.finalStep.reasoningText;
46762
- }
46763
- get reasoning() {
46764
- return this.finalStep.reasoning;
46765
- }
46766
- get toolCalls() {
46767
- return this.finalStep.toolCalls;
46768
- }
46769
- get staticToolCalls() {
46770
- return this.finalStep.staticToolCalls;
46771
- }
46772
- get dynamicToolCalls() {
46773
- return this.finalStep.dynamicToolCalls;
46774
- }
46775
- get toolResults() {
46776
- return this.finalStep.toolResults;
46777
- }
46778
- get staticToolResults() {
46779
- return this.finalStep.staticToolResults;
46780
- }
46781
- get dynamicToolResults() {
46782
- return this.finalStep.dynamicToolResults;
46783
- }
46784
- get sources() {
46785
- return this.finalStep.sources;
46786
- }
46787
- get finishReason() {
46788
- return this.finalStep.finishReason;
46789
- }
46790
- get warnings() {
46791
- return this.finalStep.warnings;
46792
- }
46793
- get providerMetadata() {
46794
- return this.finalStep.providerMetadata;
46795
- }
46796
- get response() {
46797
- return this.finalStep.response;
46798
- }
46799
- get request() {
46800
- return this.finalStep.request;
46801
- }
46802
- get usage() {
46803
- return this.finalStep.usage;
46804
- }
46805
- get totalUsage() {
46806
- return this.steps.reduce((totalUsage, step) => {
46807
- return addLanguageModelUsage(totalUsage, step.usage);
46808
- }, {
46809
- inputTokens: undefined,
46810
- outputTokens: undefined,
46811
- totalTokens: undefined,
46812
- reasoningTokens: undefined,
46813
- cachedInputTokens: undefined
46814
- });
46815
- }
46816
- get experimental_output() {
46817
- if (this.resolvedOutput == null) {
46818
- throw new NoOutputSpecifiedError;
46819
- }
46820
- return this.resolvedOutput;
46821
- }
46822
- };
46823
- function asToolCalls(content) {
46824
- const parts = content.filter((part) => part.type === "tool-call");
46825
- if (parts.length === 0) {
46826
- return;
46827
- }
46828
- return parts.map((toolCall) => ({
46829
- toolCallId: toolCall.toolCallId,
46830
- toolName: toolCall.toolName,
46831
- input: toolCall.input
46832
- }));
46833
- }
46834
- function asContent({
46835
- content,
46836
- toolCalls,
46837
- toolOutputs
46838
- }) {
46839
- return [
46840
- ...content.map((part) => {
46841
- switch (part.type) {
46842
- case "text":
46843
- case "reasoning":
46844
- case "source":
46845
- return part;
46846
- case "file": {
46847
- return {
46848
- type: "file",
46849
- file: new DefaultGeneratedFile(part)
46850
- };
46851
- }
46852
- case "tool-call": {
46853
- return toolCalls.find((toolCall) => toolCall.toolCallId === part.toolCallId);
46854
- }
46855
- case "tool-result": {
46856
- const toolCall = toolCalls.find((toolCall2) => toolCall2.toolCallId === part.toolCallId);
46857
- if (toolCall == null) {
46858
- throw new Error(`Tool call ${part.toolCallId} not found.`);
46859
- }
46860
- if (part.isError) {
46861
- return {
46862
- type: "tool-error",
46863
- toolCallId: part.toolCallId,
46864
- toolName: part.toolName,
46865
- input: toolCall.input,
46866
- error: part.result,
46867
- providerExecuted: true,
46868
- dynamic: toolCall.dynamic
46869
- };
46870
- }
46871
- return {
46872
- type: "tool-result",
46873
- toolCallId: part.toolCallId,
46874
- toolName: part.toolName,
46875
- input: toolCall.input,
46876
- output: part.result,
46877
- providerExecuted: true,
46878
- dynamic: toolCall.dynamic
46879
- };
46880
- }
46881
- }
46882
- }),
46883
- ...toolOutputs
46884
- ];
46885
- }
46886
46366
  function prepareHeaders(headers, defaultHeaders) {
46887
46367
  const responseHeaders = new Headers(headers != null ? headers : {});
46888
46368
  for (const [key, value] of Object.entries(defaultHeaders)) {
@@ -51671,189 +51151,8 @@ var createNewProject_default = {
51671
51151
  agent: "architect"
51672
51152
  };
51673
51153
 
51674
- // ../core/src/AiTool/generateGitCommitMessage.ts
51675
- var prompt2 = `
51676
- You are an advanced assistant specialized in creating concise and accurate Git commit messages. When you receive:
51677
- - A Git diff inside the <tool_input> tag.
51678
- - Additional user-supplied context inside the <tool_input_context> tag (if any).
51679
-
51680
- You will produce a single commit message enclosed within <tool_output> tags. The commit message must accurately reflect the changes shown in the diff and should be clear, descriptive, and devoid of unnecessary or repeated information. If a context is provided, it MUST be incorporated into the commit message.
51681
-
51682
- Here’s an example of the input and the expected output format:
51683
-
51684
- <tool_input>
51685
- --- a/example_file.py
51686
- +++ b/example_file.py
51687
- @@ -10,7 +10,7 @@ def example_function():
51688
- - print("Old behavior")
51689
- + print("New behavior")
51690
- </tool_input>
51691
- <tool_input_context>
51692
- Changing print statement to update the user-facing message.
51693
- </tool_input_context>
51694
-
51695
- Example Output:
51696
-
51697
- <tool_output>
51698
- Update print statement for revised user-facing message
51699
- </tool_output>
51700
-
51701
- Follow the same structure for any new input. Never repeat questions; focus on generating a concise commit message that captures the essence of the changes.
51702
- `;
51703
- var generateGitCommitMessage_default = {
51704
- name: "generateGitCommitMessage",
51705
- description: "Generates git commit messages from git diff output",
51706
- prompt: prompt2,
51707
- formatInput: (params) => {
51708
- let ret = `<tool_input>
51709
- ${params.diff}
51710
- </tool_input>`;
51711
- if (params.context) {
51712
- ret += `
51713
- <tool_input_context>
51714
- ${params.context}
51715
- </tool_input_context>`;
51716
- }
51717
- return ret;
51718
- },
51719
- parseOutput: (output) => {
51720
- const regex = /<tool_output>([\s\S]*)<\/tool_output>/gm;
51721
- const match = regex.exec(output);
51722
- if (match) {
51723
- return match[1];
51724
- }
51725
- throw new Error(`Could not parse output:
51726
- ${output}`);
51727
- }
51728
- };
51729
-
51730
- // ../core/src/AiTool/generateGithubPullRequestDetails.ts
51731
- var prompt3 = `
51732
- # Generate Github Pull Request Details
51733
-
51734
- You are given:
51735
- - A branch name in <tool_input_branch_name>.
51736
- - An optional context message in <tool_input_context> (which may or may not be present).
51737
- - All commit messages combined in <tool_input_commit_messages>.
51738
- - All diffs combined in <tool_input_commit_diff>.
51739
-
51740
- Your task:
51741
- 1. Consider the optional context (if provided).
51742
- - If an issue number is found, add "Closes #xxx" at the beginning of the PR description
51743
- - IMPORTANT: Use ONLY the exact format "Closes #xxx" at the beginning of the description
51744
- - DO NOT use variations like "Closes issue #xxx" or other formats
51745
- 2. Analyze the combined commit messages and diffs.
51746
- 3. Produce a single GitHub Pull Request title.
51747
- 4. Produce a Pull Request description that explains the changes.
51748
-
51749
- Use the following template for the Pull Request description:
51750
-
51751
- ---
51752
- **Context (if provided)**:
51753
- - Acknowledge any guiding concerns or instructions.
51754
-
51755
- **Summary of Changes**:
51756
- - Provide a concise list or overview of what changed.
51757
-
51758
- **Highlights of Changed Code**:
51759
- - Mention only the specific sections or functionalities updated, without showing full surrounding context.
51760
-
51761
- **Additional Information (if needed)**:
51762
- - Testing steps (if applicable).
51763
- - Any notes or caveats.
51764
-
51765
- ---
51766
-
51767
- Output format:
51768
- <tool_output>
51769
- <tool_output_pr_title>YOUR PR TITLE HERE</tool_output_pr_title>
51770
- <tool_output_pr_description>
51771
- YOUR PR DESCRIPTION HERE
51772
- </tool_output_pr_description>
51773
- </tool_output>
51774
-
51775
- Below is an **example** of the input and output:
51776
-
51777
- Example Input:
51778
- <tool_input>
51779
- <tool_input_branch_name>feature/refactor-logging</tool_input_branch_name>
51780
- <tool_input_context>Implementing changes for issue #123 - Focus on clean code and maintainability</tool_input_context>
51781
- <tool_input_commit_messages>
51782
- Remove debug logs
51783
- Refactor order validation logic
51784
- </tool_input_commit_messages>
51785
- <tool_input_commit_diff>
51786
- diff --git a/user_service.py b/user_service.py
51787
- - print("Debug info")
51788
- + # Removed debug print statements
51789
-
51790
- diff --git a/order_service.py b/order_service.py
51791
- - if is_valid_order(order):
51792
- - process_order(order)
51793
- + validate_and_process(order)
51794
- </tool_input_commit_diff>
51795
- </tool_input>
51796
-
51797
- Example Output:
51798
- <tool_output>
51799
- <tool_output_pr_title>Refactor Order Validation and Remove Debug Logs</tool_output_pr_title>
51800
- <tool_output_pr_description>
51801
- Closes #123
51802
-
51803
- **Context**:
51804
- - Implementing changes for issue #123 - Focus on clean code and maintainability
51805
-
51806
- **Summary of Changes**:
51807
- - Refactored order validation logic to use a new \`validate_and_process\` method.
51808
- - Removed debug print statements from \`user_service.py\`.
51809
-
51810
- **Highlights of Changed Code**:
51811
- - \`order_service.py\`: Replaced direct call to \`process_order\` with \`validate_and_process\`.
51812
- - \`user_service.py\`: Removed \`print("Debug info")\`.
51813
- </tool_output_pr_description>
51814
- </tool_output>
51815
-
51816
- ---
51817
-
51818
- Use the above format whenever you receive <tool_input> that may include a branch name, an optional context, aggregated commit messages in a single tag, and a combined diff in a single tag. Provide your final output strictly in <tool_output> with <tool_output_pr_title> and <tool_output_pr_description>. Only highlight the changed code and avoid including the context around the changes in the description.
51819
- `;
51820
- var generateGithubPullRequestDetails_default = {
51821
- name: "generateGithubPullRequestDetails",
51822
- description: "Generates a GitHub pull request title and description from git commits",
51823
- prompt: prompt3,
51824
- formatInput: (params) => {
51825
- return `<tool_input>
51826
- <tool_input_branch_name>${params.branchName}</tool_input_branch_name>${params.context ? `
51827
- <tool_input_context>${params.context}</tool_input_context>` : ""}
51828
- <tool_input_commit_messages>${params.commitMessages}</tool_input_commit_messages>
51829
- <tool_input_commit_diff>${params.commitDiff}</tool_input_commit_diff>
51830
- </tool_input>`;
51831
- },
51832
- parseOutput: (output) => {
51833
- const regex = /<tool_output>([\s\S]*)<\/tool_output>/gm;
51834
- const match = regex.exec(output);
51835
- if (!match) {
51836
- throw new Error(`Could not parse output:
51837
- ${output}`);
51838
- }
51839
- const [, outputContent] = match;
51840
- const titleRegex = /<tool_output_pr_title>([\s\S]*)<\/tool_output_pr_title>/gm;
51841
- const titleMatch = titleRegex.exec(outputContent);
51842
- const descriptionRegex = /<tool_output_pr_description>([\s\S]*)<\/tool_output_pr_description>/gm;
51843
- const descriptionMatch = descriptionRegex.exec(outputContent);
51844
- if (titleMatch && descriptionMatch) {
51845
- return {
51846
- title: titleMatch[1],
51847
- description: descriptionMatch[1]
51848
- };
51849
- }
51850
- throw new Error(`Could not parse output:
51851
- ${output}`);
51852
- }
51853
- };
51854
-
51855
51154
  // ../core/src/AiTool/generateProjectConfig.ts
51856
- var prompt4 = `
51155
+ var prompt2 = `
51857
51156
  Role: Analyzer agent
51858
51157
  Goal: Produce a valid polkacodes YAML configuration for the project.
51859
51158
 
@@ -51900,7 +51199,7 @@ excludeFiles: # only files likely to hold secrets
51900
51199
  var generateProjectConfig_default = {
51901
51200
  name: "generateProjectConfig",
51902
51201
  description: "Analyzes project files to generate polkacodes config sections",
51903
- prompt: prompt4,
51202
+ prompt: prompt2,
51904
51203
  formatInput: () => {
51905
51204
  return "";
51906
51205
  },
@@ -51911,21 +51210,6 @@ var generateProjectConfig_default = {
51911
51210
  };
51912
51211
 
51913
51212
  // ../core/src/AiTool/index.ts
51914
- var executeTool2 = async (definition, ai, params, usageMeter) => {
51915
- const resp = await generateText({
51916
- model: ai,
51917
- temperature: 0,
51918
- system: definition.prompt,
51919
- messages: [
51920
- {
51921
- role: "user",
51922
- content: definition.formatInput(params)
51923
- }
51924
- ]
51925
- });
51926
- usageMeter.addUsage(ai, resp);
51927
- return definition.parseOutput(resp.text);
51928
- };
51929
51213
  var executeMultiAgentTool = async (definition, agent, params) => {
51930
51214
  const exitReason = await agent.startTask({
51931
51215
  agentName: definition.agent,
@@ -51937,18 +51221,11 @@ var executeMultiAgentTool = async (definition, agent, params) => {
51937
51221
  }
51938
51222
  throw new Error(`Tool execution failed: ${exitReason.type}`);
51939
51223
  };
51940
- var makeTool = (definition) => {
51941
- return async (ai, params, usageMeter) => {
51942
- return executeTool2(definition, ai, params, usageMeter);
51943
- };
51944
- };
51945
51224
  var makeMultiAgentTool = (definition) => {
51946
51225
  return async (agent, params) => {
51947
51226
  return executeMultiAgentTool(definition, agent, params);
51948
51227
  };
51949
51228
  };
51950
- var generateGitCommitMessage = makeTool(generateGitCommitMessage_default);
51951
- var generateGithubPullRequestDetails = makeTool(generateGithubPullRequestDetails_default);
51952
51229
  var generateProjectConfig = makeMultiAgentTool(generateProjectConfig_default);
51953
51230
  var createNewProject = makeMultiAgentTool(createNewProject_default);
51954
51231
  // ../core/src/workflow/utils.ts
@@ -56875,11 +56152,11 @@ class ScreenManager {
56875
56152
  render(content, bottomContent = "") {
56876
56153
  const promptLine = lastLine(content);
56877
56154
  const rawPromptLine = stripVTControlCharacters(promptLine);
56878
- let prompt5 = rawPromptLine;
56155
+ let prompt3 = rawPromptLine;
56879
56156
  if (this.rl.line.length > 0) {
56880
- prompt5 = prompt5.slice(0, -this.rl.line.length);
56157
+ prompt3 = prompt3.slice(0, -this.rl.line.length);
56881
56158
  }
56882
- this.rl.setPrompt(prompt5);
56159
+ this.rl.setPrompt(prompt3);
56883
56160
  this.cursorPos = this.rl.getCursorPos();
56884
56161
  const width = readlineWidth();
56885
56162
  content = breakLines(content, width);
@@ -56949,7 +56226,7 @@ function getCallSites() {
56949
56226
  }
56950
56227
  function createPrompt(view) {
56951
56228
  const callSites = getCallSites();
56952
- const prompt5 = (config3, context = {}) => {
56229
+ const prompt3 = (config3, context = {}) => {
56953
56230
  const { input = process.stdin, signal } = context;
56954
56231
  const cleanups = new Set;
56955
56232
  const output = new import_mute_stream.default;
@@ -57014,7 +56291,7 @@ function createPrompt(view) {
57014
56291
  }).then(() => promise2), { cancel });
57015
56292
  });
57016
56293
  };
57017
- return prompt5;
56294
+ return prompt3;
57018
56295
  }
57019
56296
  // ../../node_modules/@inquirer/core/dist/esm/lib/Separator.js
57020
56297
  var import_yoctocolors_cjs2 = __toESM(require_yoctocolors_cjs(), 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli-shared",
3
- "version": "0.9.33",
3
+ "version": "0.9.35",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",