@polka-codes/cli 0.9.40 → 0.9.41

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 +31 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -56846,7 +56846,7 @@ var {
56846
56846
  Help
56847
56847
  } = import__.default;
56848
56848
  // package.json
56849
- var version = "0.9.40";
56849
+ var version = "0.9.41";
56850
56850
 
56851
56851
  // src/commands/chat.ts
56852
56852
  import { readFile as readFile3 } from "node:fs/promises";
@@ -105279,22 +105279,40 @@ var runChat = async (opts, command) => {
105279
105279
  // src/runWorkflow.ts
105280
105280
  import { spawnSync as spawnSync2 } from "node:child_process";
105281
105281
  import os5 from "node:os";
105282
- // ../workflow/src/workflow.ts
105283
- async function run(workflow, input, stepFn) {
105284
- if (!stepFn) {
105282
+
105283
+ // ../workflow/src/helpers.ts
105284
+ var makeStepFn = (fns) => {
105285
+ if (!fns) {
105285
105286
  const results = {};
105286
105287
  const counts = {};
105287
- stepFn = async (name18, fn) => {
105288
- counts[name18] = (counts[name18] || 0) + 1;
105289
- const key2 = `${name18}#${counts[name18]}`;
105290
- if (key2 in results) {
105291
- return results[key2];
105292
- }
105293
- const result = await fn();
105294
- results[key2] = result;
105295
- return result;
105288
+ fns = {
105289
+ getStepResult: async (key2) => results[key2],
105290
+ setStepResult: async (key2, value) => {
105291
+ results[key2] = value;
105292
+ },
105293
+ getAndIncrementCounts: async (key2) => {
105294
+ counts[key2] = (counts[key2] || 0) + 1;
105295
+ return counts[key2];
105296
+ }
105296
105297
  };
105297
105298
  }
105299
+ return async (name18, fn) => {
105300
+ const currentCounts = await fns.getAndIncrementCounts(name18);
105301
+ const key2 = `${name18}#${currentCounts}`;
105302
+ const existingResult = await fns.getStepResult(key2);
105303
+ if (existingResult !== undefined) {
105304
+ return existingResult;
105305
+ }
105306
+ const result = await fn();
105307
+ await fns.setStepResult(key2, result ?? null);
105308
+ return result;
105309
+ };
105310
+ };
105311
+ // ../workflow/src/workflow.ts
105312
+ async function run(workflow, input, stepFn) {
105313
+ if (!stepFn) {
105314
+ stepFn = makeStepFn();
105315
+ }
105298
105316
  const tools2 = new Proxy({}, {
105299
105317
  get: (_target, tool6) => {
105300
105318
  return function* (input2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.9.40",
3
+ "version": "0.9.41",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",