rhachet 1.1.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 (228) hide show
  1. package/LICENSE +21 -0
  2. package/dist/__nonpublished_modules__/file-fns/src/getFile.d.ts +6 -0
  3. package/dist/__nonpublished_modules__/file-fns/src/getFile.js +14 -0
  4. package/dist/__nonpublished_modules__/file-fns/src/getFile.js.map +1 -0
  5. package/dist/__test_assets__/directory.d.ts +1 -0
  6. package/dist/__test_assets__/directory.js +5 -0
  7. package/dist/__test_assets__/directory.js.map +1 -0
  8. package/dist/__test_assets__/genContextLogTrail.d.ts +2 -0
  9. package/dist/__test_assets__/genContextLogTrail.js +12 -0
  10. package/dist/__test_assets__/genContextLogTrail.js.map +1 -0
  11. package/dist/__test_assets__/genContextStitchTrail.d.ts +2 -0
  12. package/dist/__test_assets__/genContextStitchTrail.js +8 -0
  13. package/dist/__test_assets__/genContextStitchTrail.js.map +1 -0
  14. package/dist/__test_assets__/getContextOpenAI.d.ts +2 -0
  15. package/dist/__test_assets__/getContextOpenAI.js +18 -0
  16. package/dist/__test_assets__/getContextOpenAI.js.map +1 -0
  17. package/dist/__test_assets__/stitchers/genStitcherCodeFileRead.d.ts +14 -0
  18. package/dist/__test_assets__/stitchers/genStitcherCodeFileRead.js +23 -0
  19. package/dist/__test_assets__/stitchers/genStitcherCodeFileRead.js.map +1 -0
  20. package/dist/__test_assets__/stitchers/genStitcherCodeFileWrite.d.ts +16 -0
  21. package/dist/__test_assets__/stitchers/genStitcherCodeFileWrite.js +29 -0
  22. package/dist/__test_assets__/stitchers/genStitcherCodeFileWrite.js.map +1 -0
  23. package/dist/__test_assets__/stitchers/genStitcherCodeReviewImagine.d.ts +15 -0
  24. package/dist/__test_assets__/stitchers/genStitcherCodeReviewImagine.js +97 -0
  25. package/dist/__test_assets__/stitchers/genStitcherCodeReviewImagine.js.map +1 -0
  26. package/dist/__test_assets__/stitchers/stitcherCodeDiffImagine.d.ts +13 -0
  27. package/dist/__test_assets__/stitchers/stitcherCodeDiffImagine.js +33 -0
  28. package/dist/__test_assets__/stitchers/stitcherCodeDiffImagine.js.map +1 -0
  29. package/dist/__test_assets__/stitchers/stitcherFanoutRandomSum.d.ts +13 -0
  30. package/dist/__test_assets__/stitchers/stitcherFanoutRandomSum.js +45 -0
  31. package/dist/__test_assets__/stitchers/stitcherFanoutRandomSum.js.map +1 -0
  32. package/dist/__test_assets__/stitchers/stitcherFanoutSubroutes.d.ts +29 -0
  33. package/dist/__test_assets__/stitchers/stitcherFanoutSubroutes.js +76 -0
  34. package/dist/__test_assets__/stitchers/stitcherFanoutSubroutes.js.map +1 -0
  35. package/dist/__test_assets__/threads/codeArtist.d.ts +6 -0
  36. package/dist/__test_assets__/threads/codeArtist.js +26 -0
  37. package/dist/__test_assets__/threads/codeArtist.js.map +1 -0
  38. package/dist/__test_assets__/threads/codeCritic.d.ts +6 -0
  39. package/dist/__test_assets__/threads/codeCritic.js +21 -0
  40. package/dist/__test_assets__/threads/codeCritic.js.map +1 -0
  41. package/dist/__test_assets__/threads/director.d.ts +6 -0
  42. package/dist/__test_assets__/threads/director.js +14 -0
  43. package/dist/__test_assets__/threads/director.js.map +1 -0
  44. package/dist/contract/sdk.d.ts +8 -0
  45. package/dist/contract/sdk.js +33 -0
  46. package/dist/contract/sdk.js.map +1 -0
  47. package/dist/domain/objects/Stitch.d.ts +42 -0
  48. package/dist/domain/objects/Stitch.js +9 -0
  49. package/dist/domain/objects/Stitch.js.map +1 -0
  50. package/dist/domain/objects/StitchChoice.d.ts +30 -0
  51. package/dist/domain/objects/StitchChoice.js +8 -0
  52. package/dist/domain/objects/StitchChoice.js.map +1 -0
  53. package/dist/domain/objects/StitchCycle.d.ts +44 -0
  54. package/dist/domain/objects/StitchCycle.js +8 -0
  55. package/dist/domain/objects/StitchCycle.js.map +1 -0
  56. package/dist/domain/objects/StitchFanout.d.ts +35 -0
  57. package/dist/domain/objects/StitchFanout.js +8 -0
  58. package/dist/domain/objects/StitchFanout.js.map +1 -0
  59. package/dist/domain/objects/StitchRoute.d.ts +22 -0
  60. package/dist/domain/objects/StitchRoute.js +8 -0
  61. package/dist/domain/objects/StitchRoute.js.map +1 -0
  62. package/dist/domain/objects/StitchSetEvent.d.ts +23 -0
  63. package/dist/domain/objects/StitchSetEvent.js +8 -0
  64. package/dist/domain/objects/StitchSetEvent.js.map +1 -0
  65. package/dist/domain/objects/StitchStep.d.ts +55 -0
  66. package/dist/domain/objects/StitchStep.js +11 -0
  67. package/dist/domain/objects/StitchStep.js.map +1 -0
  68. package/dist/domain/objects/StitchTrail.d.ts +26 -0
  69. package/dist/domain/objects/StitchTrail.js +19 -0
  70. package/dist/domain/objects/StitchTrail.js.map +1 -0
  71. package/dist/domain/objects/Stitcher.d.ts +105 -0
  72. package/dist/domain/objects/Stitcher.js +49 -0
  73. package/dist/domain/objects/Stitcher.js.map +1 -0
  74. package/dist/domain/objects/Stitcher.test.d.ts +1 -0
  75. package/dist/domain/objects/Stitcher.test.js +78 -0
  76. package/dist/domain/objects/Stitcher.test.js.map +1 -0
  77. package/dist/domain/objects/Thread.d.ts +31 -0
  78. package/dist/domain/objects/Thread.js +11 -0
  79. package/dist/domain/objects/Thread.js.map +1 -0
  80. package/dist/domain/objects/Threads.d.ts +56 -0
  81. package/dist/domain/objects/Threads.js +26 -0
  82. package/dist/domain/objects/Threads.js.map +1 -0
  83. package/dist/domain/objects/Weave.d.ts +0 -0
  84. package/dist/domain/objects/Weave.js +2 -0
  85. package/dist/domain/objects/Weave.js.map +1 -0
  86. package/dist/domain/objects/Weaver.d.ts +5 -0
  87. package/dist/domain/objects/Weaver.js +7 -0
  88. package/dist/domain/objects/Weaver.js.map +1 -0
  89. package/dist/domain/objects/index.d.ts +11 -0
  90. package/dist/domain/objects/index.js +30 -0
  91. package/dist/domain/objects/index.js.map +1 -0
  92. package/dist/index.d.ts +1 -0
  93. package/dist/index.js +18 -0
  94. package/dist/index.js.map +1 -0
  95. package/dist/logic/stitch/adapters/imagineViaOpenAI.d.ts +13 -0
  96. package/dist/logic/stitch/adapters/imagineViaOpenAI.js +36 -0
  97. package/dist/logic/stitch/adapters/imagineViaOpenAI.js.map +1 -0
  98. package/dist/logic/stitch/enstitch.d.ts +27 -0
  99. package/dist/logic/stitch/enstitch.js +97 -0
  100. package/dist/logic/stitch/enstitch.js.map +1 -0
  101. package/dist/logic/stitch/enstitch.test.d.ts +1 -0
  102. package/dist/logic/stitch/enstitch.test.js +87 -0
  103. package/dist/logic/stitch/enstitch.test.js.map +1 -0
  104. package/dist/logic/stitch/invokeImagineStitcher.d.ts +10 -0
  105. package/dist/logic/stitch/invokeImagineStitcher.integration.test.d.ts +1 -0
  106. package/dist/logic/stitch/invokeImagineStitcher.integration.test.js +193 -0
  107. package/dist/logic/stitch/invokeImagineStitcher.integration.test.js.map +1 -0
  108. package/dist/logic/stitch/invokeImagineStitcher.js +23 -0
  109. package/dist/logic/stitch/invokeImagineStitcher.js.map +1 -0
  110. package/dist/logic/stitch/withStitchTrail.d.ts +16 -0
  111. package/dist/logic/stitch/withStitchTrail.js +40 -0
  112. package/dist/logic/stitch/withStitchTrail.js.map +1 -0
  113. package/dist/logic/thread/enroleThread.d.ts +4 -0
  114. package/dist/logic/thread/enroleThread.js +6 -0
  115. package/dist/logic/thread/enroleThread.js.map +1 -0
  116. package/dist/logic/thread/genThread.d.ts +7 -0
  117. package/dist/logic/thread/genThread.js +10 -0
  118. package/dist/logic/thread/genThread.js.map +1 -0
  119. package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.d.ts +17 -0
  120. package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.js +3 -0
  121. package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.js.map +1 -0
  122. package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.d.ts +1 -0
  123. package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.js +67 -0
  124. package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.js.map +1 -0
  125. package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.d.ts +18 -0
  126. package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.js +3 -0
  127. package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.js.map +1 -0
  128. package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.d.ts +1 -0
  129. package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.js +132 -0
  130. package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.js.map +1 -0
  131. package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.d.ts +23 -0
  132. package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.js +3 -0
  133. package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.js.map +1 -0
  134. package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.d.ts +1 -0
  135. package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.js +74 -0
  136. package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.js.map +1 -0
  137. package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.d.ts +24 -0
  138. package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.js +3 -0
  139. package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.js.map +1 -0
  140. package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.d.ts +1 -0
  141. package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.js +190 -0
  142. package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.js.map +1 -0
  143. package/dist/logic/weave/compose/ProcedureContextMerged.generic.d.ts +36 -0
  144. package/dist/logic/weave/compose/ProcedureContextMerged.generic.js +3 -0
  145. package/dist/logic/weave/compose/ProcedureContextMerged.generic.js.map +1 -0
  146. package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.d.ts +1 -0
  147. package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.js +29 -0
  148. package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.js.map +1 -0
  149. package/dist/logic/weave/compose/ThreadsMerged.generic.d.ts +65 -0
  150. package/dist/logic/weave/compose/ThreadsMerged.generic.js +3 -0
  151. package/dist/logic/weave/compose/ThreadsMerged.generic.js.map +1 -0
  152. package/dist/logic/weave/compose/ThreadsMerged.generic.test.d.ts +1 -0
  153. package/dist/logic/weave/compose/ThreadsMerged.generic.test.js +420 -0
  154. package/dist/logic/weave/compose/ThreadsMerged.generic.test.js.map +1 -0
  155. package/dist/logic/weave/compose/asStitcher.d.ts +12 -0
  156. package/dist/logic/weave/compose/asStitcher.js +15 -0
  157. package/dist/logic/weave/compose/asStitcher.js.map +1 -0
  158. package/dist/logic/weave/compose/asStitcher.test.d.ts +1 -0
  159. package/dist/logic/weave/compose/asStitcher.test.js +95 -0
  160. package/dist/logic/weave/compose/asStitcher.test.js.map +1 -0
  161. package/dist/logic/weave/compose/asStitcherFlat.d.ts +10 -0
  162. package/dist/logic/weave/compose/asStitcherFlat.js +13 -0
  163. package/dist/logic/weave/compose/asStitcherFlat.js.map +1 -0
  164. package/dist/logic/weave/compose/asStitcherFlat.test.d.ts +1 -0
  165. package/dist/logic/weave/compose/asStitcherFlat.test.js +96 -0
  166. package/dist/logic/weave/compose/asStitcherFlat.test.js.map +1 -0
  167. package/dist/logic/weave/compose/genStitchChoice.d.ts +22 -0
  168. package/dist/logic/weave/compose/genStitchChoice.js +23 -0
  169. package/dist/logic/weave/compose/genStitchChoice.js.map +1 -0
  170. package/dist/logic/weave/compose/genStitchChoice.test.d.ts +1 -0
  171. package/dist/logic/weave/compose/genStitchChoice.test.js +200 -0
  172. package/dist/logic/weave/compose/genStitchChoice.test.js.map +1 -0
  173. package/dist/logic/weave/compose/genStitchCycle.d.ts +28 -0
  174. package/dist/logic/weave/compose/genStitchCycle.js +30 -0
  175. package/dist/logic/weave/compose/genStitchCycle.js.map +1 -0
  176. package/dist/logic/weave/compose/genStitchCycle.test.d.ts +1 -0
  177. package/dist/logic/weave/compose/genStitchCycle.test.js +152 -0
  178. package/dist/logic/weave/compose/genStitchCycle.test.js.map +1 -0
  179. package/dist/logic/weave/compose/genStitchFanout.d.ts +17 -0
  180. package/dist/logic/weave/compose/genStitchFanout.js +21 -0
  181. package/dist/logic/weave/compose/genStitchFanout.js.map +1 -0
  182. package/dist/logic/weave/compose/genStitchFanout.test.d.ts +1 -0
  183. package/dist/logic/weave/compose/genStitchFanout.test.js +79 -0
  184. package/dist/logic/weave/compose/genStitchFanout.test.js.map +1 -0
  185. package/dist/logic/weave/compose/genStitchRoute.d.ts +15 -0
  186. package/dist/logic/weave/compose/genStitchRoute.js +20 -0
  187. package/dist/logic/weave/compose/genStitchRoute.js.map +1 -0
  188. package/dist/logic/weave/compose/genStitchRoute.test.d.ts +1 -0
  189. package/dist/logic/weave/compose/genStitchRoute.test.js +120 -0
  190. package/dist/logic/weave/compose/genStitchRoute.test.js.map +1 -0
  191. package/dist/logic/weave/enweave.d.ts +0 -0
  192. package/dist/logic/weave/enweave.js +2 -0
  193. package/dist/logic/weave/enweave.js.map +1 -0
  194. package/dist/logic/weave/enweaveAllStitchers.d.ts +0 -0
  195. package/dist/logic/weave/enweaveAllStitchers.js +2 -0
  196. package/dist/logic/weave/enweaveAllStitchers.js.map +1 -0
  197. package/dist/logic/weave/enweaveOneChoice.d.ts +14 -0
  198. package/dist/logic/weave/enweaveOneChoice.js +48 -0
  199. package/dist/logic/weave/enweaveOneChoice.js.map +1 -0
  200. package/dist/logic/weave/enweaveOneChoice.test.d.ts +1 -0
  201. package/dist/logic/weave/enweaveOneChoice.test.js +181 -0
  202. package/dist/logic/weave/enweaveOneChoice.test.js.map +1 -0
  203. package/dist/logic/weave/enweaveOneCycle.d.ts +19 -0
  204. package/dist/logic/weave/enweaveOneCycle.js +98 -0
  205. package/dist/logic/weave/enweaveOneCycle.js.map +1 -0
  206. package/dist/logic/weave/enweaveOneCycle.test.d.ts +1 -0
  207. package/dist/logic/weave/enweaveOneCycle.test.js +180 -0
  208. package/dist/logic/weave/enweaveOneCycle.test.js.map +1 -0
  209. package/dist/logic/weave/enweaveOneFanout.d.ts +12 -0
  210. package/dist/logic/weave/enweaveOneFanout.integration.test.d.ts +1 -0
  211. package/dist/logic/weave/enweaveOneFanout.integration.test.js +166 -0
  212. package/dist/logic/weave/enweaveOneFanout.integration.test.js.map +1 -0
  213. package/dist/logic/weave/enweaveOneFanout.js +37 -0
  214. package/dist/logic/weave/enweaveOneFanout.js.map +1 -0
  215. package/dist/logic/weave/enweaveOneRoute.d.ts +12 -0
  216. package/dist/logic/weave/enweaveOneRoute.integration.test.d.ts +1 -0
  217. package/dist/logic/weave/enweaveOneRoute.integration.test.js +159 -0
  218. package/dist/logic/weave/enweaveOneRoute.integration.test.js.map +1 -0
  219. package/dist/logic/weave/enweaveOneRoute.js +33 -0
  220. package/dist/logic/weave/enweaveOneRoute.js.map +1 -0
  221. package/dist/logic/weave/enweaveOneStitcher.d.ts +11 -0
  222. package/dist/logic/weave/enweaveOneStitcher.integration.test.d.ts +2 -0
  223. package/dist/logic/weave/enweaveOneStitcher.integration.test.js +258 -0
  224. package/dist/logic/weave/enweaveOneStitcher.integration.test.js.map +1 -0
  225. package/dist/logic/weave/enweaveOneStitcher.js +42 -0
  226. package/dist/logic/weave/enweaveOneStitcher.js.map +1 -0
  227. package/package.json +88 -0
  228. package/readme.md +61 -0
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const uni_time_1 = require("@ehmpathy/uni-time");
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ const test_fns_1 = require("test-fns");
6
+ const genContextLogTrail_1 = require("../../__test_assets__/genContextLogTrail");
7
+ const genContextStitchTrail_1 = require("../../__test_assets__/genContextStitchTrail");
8
+ const getContextOpenAI_1 = require("../../__test_assets__/getContextOpenAI");
9
+ const stitcherCodeDiffImagine_1 = require("../../__test_assets__/stitchers/stitcherCodeDiffImagine");
10
+ const codeArtist_1 = require("../../__test_assets__/threads/codeArtist");
11
+ const director_1 = require("../../__test_assets__/threads/director");
12
+ const StitchStep_1 = require("../../domain/objects/StitchStep");
13
+ const Thread_1 = require("../../domain/objects/Thread");
14
+ const genStitchRoute_1 = require("./compose/genStitchRoute");
15
+ const enweaveOneRoute_1 = require("./enweaveOneRoute");
16
+ describe('enweaveOneRoute', () => {
17
+ const context = {
18
+ ...(0, genContextStitchTrail_1.genContextStitchTrail)(),
19
+ ...(0, genContextLogTrail_1.genContextLogTrail)(),
20
+ ...(0, getContextOpenAI_1.getContextOpenAI)(),
21
+ };
22
+ (0, test_fns_1.given)('a route with compute stitchers (fast and no api keys required); same threads required for each stitcher', () => {
23
+ const stitcherGetTime = new StitchStep_1.StitchStepCompute({
24
+ slug: 'get-time',
25
+ readme: null,
26
+ form: 'COMPUTE',
27
+ stitchee: 'main',
28
+ invoke: () => ({ input: null, output: (0, uni_time_1.asUniDateTime)(new Date()) }),
29
+ });
30
+ const stitcherAddHours = new StitchStep_1.StitchStepCompute({
31
+ slug: 'add-hours',
32
+ readme: null,
33
+ form: 'COMPUTE',
34
+ stitchee: 'main',
35
+ invoke: ({ threads }) => {
36
+ const lastStitch = threads.main.stitches.slice(-1)[0] ??
37
+ helpful_errors_1.UnexpectedCodePathError.throw('no stitches found on main thread yet.', { threads });
38
+ return {
39
+ input: lastStitch.output,
40
+ output: (0, uni_time_1.addDuration)(uni_time_1.isUniDateTime.assure(lastStitch.output), {
41
+ hours: 1,
42
+ }),
43
+ };
44
+ },
45
+ });
46
+ const route = (0, genStitchRoute_1.genStitchRoute)({
47
+ slug: 'time:get:hour+',
48
+ readme: null,
49
+ sequence: [stitcherGetTime, stitcherAddHours],
50
+ });
51
+ (0, test_fns_1.when)('the wrong thread is given as an input', () => {
52
+ const threadAuthor = new Thread_1.Thread({
53
+ context: { role: 'author' },
54
+ stitches: [],
55
+ });
56
+ (0, test_fns_1.then)('there should be a compiletime error, when the input.threads doesnt have the desired thread', async () => {
57
+ // it also throws an error; but we care about the @ts-expect-error below, since compile time is most important
58
+ await (0, helpful_errors_1.getError)((0, enweaveOneRoute_1.enweaveOneRoute)(
59
+ // @ts-expect-error: 'author' does not exist in type 'Threads<"main">'.
60
+ { stitcher: route, threads: { author: threadAuthor } }, context));
61
+ });
62
+ (0, test_fns_1.then)('there should be a compiletime error, when the input.threads does have the desired thread, but it was mislabeled', async () => {
63
+ await (0, enweaveOneRoute_1.enweaveOneRoute)(
64
+ // @ts-expect-error: Type '"author"' is not assignable to type '"main"'.
65
+ { stitcher: route, threads: { main: threadAuthor } }, context);
66
+ });
67
+ });
68
+ (0, test_fns_1.when)('invoked with desired thread', () => {
69
+ const threadMain = new Thread_1.Thread({
70
+ context: { role: 'main' },
71
+ stitches: [],
72
+ });
73
+ (0, test_fns_1.then)('it should successfully enweave the full route', async () => {
74
+ const { stitch, threads } = await (0, enweaveOneRoute_1.enweaveOneRoute)({ stitcher: route, threads: { main: threadMain } }, context);
75
+ console.log(stitch.input);
76
+ console.log(stitch.output);
77
+ // stitch should look right
78
+ expect((0, uni_time_1.isUniDateTime)(stitch.output));
79
+ expect((0, uni_time_1.isUniDateTime)(stitch.input));
80
+ expect(stitch.output).not.toEqual(stitch.input);
81
+ // stitchee should be updated, too
82
+ expect(threads.main.stitches.length).toEqual(threadMain.stitches.length + 2);
83
+ });
84
+ });
85
+ });
86
+ (0, test_fns_1.given)('a route with imagine stitchers (closer to real world usecase)', () => {
87
+ const stitcherCodeFileRead = new StitchStep_1.StitchStepCompute({
88
+ slug: 'mock:read-stubout',
89
+ readme: null,
90
+ form: 'COMPUTE',
91
+ stitchee: 'artist',
92
+ invoke: () => {
93
+ // e.g., execute tooluse:file:read
94
+ return {
95
+ input: null,
96
+ output: `
97
+ /**
98
+ * .what = calls the open-meteo weather api
99
+ * .how =
100
+ * - uses procedural pattern
101
+ * - fails fast
102
+ */
103
+ export const sdkOpenMeteo = {
104
+ getWeather: (input: {...}, context: VisualogicContext & AuthContextOpenMeteo) => {
105
+ ...
106
+ }
107
+ }
108
+ `.trim(),
109
+ };
110
+ },
111
+ });
112
+ const stitcherCodeFileWrite = new StitchStep_1.StitchStepCompute({
113
+ slug: 'mock:write-fillout',
114
+ readme: null,
115
+ form: 'COMPUTE',
116
+ stitchee: 'artist',
117
+ invoke: ({ threads }) => {
118
+ // e.g., execute tooluse:file:write
119
+ return {
120
+ input: null,
121
+ output: {
122
+ path: '@src/...', // mock that we did so
123
+ content: threads.artist.stitches.slice(-1)[0]?.output ??
124
+ helpful_errors_1.UnexpectedCodePathError.throw('expected artist to have had a stitch by now'),
125
+ },
126
+ };
127
+ },
128
+ });
129
+ const route = (0, genStitchRoute_1.genStitchRoute)({
130
+ slug: 'code:propose',
131
+ readme: null,
132
+ sequence: [
133
+ stitcherCodeFileRead,
134
+ stitcherCodeDiffImagine_1.stitcherCodeDiffImagine,
135
+ stitcherCodeFileWrite,
136
+ ],
137
+ });
138
+ (0, test_fns_1.when)('given the threads required', () => {
139
+ let threads;
140
+ beforeAll(async () => {
141
+ threads = {
142
+ artist: await (0, codeArtist_1.getExampleThreadCodeArtist)(),
143
+ director: director_1.exampleThreadDirector,
144
+ };
145
+ });
146
+ (0, test_fns_1.then)('it should successfully execute the stitches as a weave', async () => {
147
+ const output = await (0, enweaveOneRoute_1.enweaveOneRoute)({
148
+ stitcher: route,
149
+ threads,
150
+ }, context);
151
+ console.log(output);
152
+ // verify that it used conflict markers and wrote the full output
153
+ expect(output.stitch.output.content).toContain('<<<<<<< ORIGINAL'); // per the artist thread's context, it knows the tool of conflict-marker, that it should have used
154
+ expect(output.stitch.output.content).toContain('>>>>>>> MODIFIED');
155
+ });
156
+ });
157
+ });
158
+ });
159
+ //# sourceMappingURL=enweaveOneRoute.integration.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enweaveOneRoute.integration.test.js","sourceRoot":"","sources":["../../../src/logic/weave/enweaveOneRoute.integration.test.ts"],"names":[],"mappings":";;AAAA,iDAK4B;AAC5B,mDAAmE;AACnE,uCAA6C;AAG7C,iFAA8E;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AC,OAAO,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;YACrE,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enweaveOneRoute = void 0;
4
+ const uni_time_1 = require("@ehmpathy/uni-time");
5
+ const StitchSetEvent_1 = require("../../domain/objects/StitchSetEvent");
6
+ const withStitchTrail_1 = require("../stitch/withStitchTrail");
7
+ const enweaveOneStitcher_1 = require("./enweaveOneStitcher");
8
+ /**
9
+ * .what = mechanism to enweave a full stitch route
10
+ * .how =
11
+ * - executes a .sequence of stitchers
12
+ */
13
+ exports.enweaveOneRoute = (0, withStitchTrail_1.withStitchTrail)(async (input, context) => {
14
+ // track the latest state of the threads
15
+ let threadsNow = input.threads;
16
+ // track the last output
17
+ let outputNow = null;
18
+ // for each stitcher in the route.sequence, execute it one by one
19
+ for (const stitcher of input.stitcher.sequence) {
20
+ // execute the stitcher
21
+ const { stitch, threads } = await (0, enweaveOneStitcher_1.enweaveOneStitcher)({ stitcher, threads: threadsNow }, context);
22
+ // update the latest states
23
+ threadsNow = threads; // enables subsequent stitchers to leverage prior results
24
+ outputNow = stitch;
25
+ }
26
+ // return the results
27
+ return StitchSetEvent_1.StitchSetEvent.build({
28
+ occurredAt: (0, uni_time_1.asUniDateTime)(new Date()),
29
+ stitch: outputNow,
30
+ threads: threadsNow,
31
+ });
32
+ });
33
+ //# sourceMappingURL=enweaveOneRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enweaveOneRoute.js","sourceRoot":"","sources":["../../../src/logic/weave/enweaveOneRoute.ts"],"names":[],"mappings":";;;AAAA,iDAAmD;AAGnD,wEAAqE;AAErE,+DAA4D;AAC5D,6DAA0D;AAE1D;;;;GAIG;AACU,QAAA,eAAe,GAAG,IAAA,iCAAe,EAC5C,KAAK,EACH,KAGC,EACD,OAA6B,EACuC,EAAE;IACtE,wCAAwC;IACxC,IAAI,UAAU,GAAyB,KAAK,CAAC,OAAO,CAAC;IAErD,wBAAwB;IACxB,IAAI,SAAS,GAAQ,IAAI,CAAC;IAE1B,iEAAiE;IACjE,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAC/C,uBAAuB;QACvB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,uCAAkB,EAClD,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,EACjC,OAAO,CACR,CAAC;QAEF,2BAA2B;QAC3B,UAAU,GAAG,OAAO,CAAC,CAAC,yDAAyD;QAC/E,SAAS,GAAG,MAAM,CAAC;IACrB,CAAC;IAED,qBAAqB;IACrB,OAAO,+BAAc,CAAC,KAAK,CAAC;QAC1B,UAAU,EAAE,IAAA,wBAAa,EAAC,IAAI,IAAI,EAAE,CAAC;QACrC,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,UAAU;KACpB,CAAC,CAAC;AACL,CAAC,CACF,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { StitchSetEvent } from '../../domain/objects/StitchSetEvent';
2
+ import { GStitcher, Stitcher } from '../../domain/objects/Stitcher';
3
+ /**
4
+ * .what = a mechanism to enweave any stitcher
5
+ * .why =
6
+ * - figures out which mechanism to call for each stitcher
7
+ */
8
+ export declare const enweaveOneStitcher: <TStitcher extends GStitcher>(input: {
9
+ stitcher: Stitcher<TStitcher>;
10
+ threads: TStitcher['threads'];
11
+ }, context: TStitcher['context']) => Promise<StitchSetEvent<TStitcher['threads'], TStitcher['output']>>;
@@ -0,0 +1,2 @@
1
+ export declare function deepOmit(obj: unknown, keys: string[]): unknown;
2
+ export declare function deepReplaceShortUuidsWithLetters(obj: unknown): unknown;
@@ -0,0 +1,258 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deepReplaceShortUuidsWithLetters = exports.deepOmit = void 0;
4
+ const uni_time_1 = require("@ehmpathy/uni-time");
5
+ const helpful_errors_1 = require("helpful-errors");
6
+ const test_fns_1 = require("test-fns");
7
+ const uuid_fns_1 = require("uuid-fns");
8
+ const genContextLogTrail_1 = require("../../__test_assets__/genContextLogTrail");
9
+ const genContextStitchTrail_1 = require("../../__test_assets__/genContextStitchTrail");
10
+ const getContextOpenAI_1 = require("../../__test_assets__/getContextOpenAI");
11
+ const genStitcherCodeFileRead_1 = require("../../__test_assets__/stitchers/genStitcherCodeFileRead");
12
+ const genStitcherCodeFileWrite_1 = require("../../__test_assets__/stitchers/genStitcherCodeFileWrite");
13
+ const genStitcherCodeReviewImagine_1 = require("../../__test_assets__/stitchers/genStitcherCodeReviewImagine");
14
+ const stitcherCodeDiffImagine_1 = require("../../__test_assets__/stitchers/stitcherCodeDiffImagine");
15
+ const codeArtist_1 = require("../../__test_assets__/threads/codeArtist");
16
+ const codeCritic_1 = require("../../__test_assets__/threads/codeCritic");
17
+ const director_1 = require("../../__test_assets__/threads/director");
18
+ const StitchStep_1 = require("../../domain/objects/StitchStep");
19
+ const genThread_1 = require("../thread/genThread");
20
+ const asStitcher_1 = require("./compose/asStitcher");
21
+ const asStitcherFlat_1 = require("./compose/asStitcherFlat");
22
+ const genStitchCycle_1 = require("./compose/genStitchCycle");
23
+ const genStitchFanout_1 = require("./compose/genStitchFanout");
24
+ const genStitchRoute_1 = require("./compose/genStitchRoute");
25
+ const enweaveOneStitcher_1 = require("./enweaveOneStitcher");
26
+ jest.setTimeout((0, uni_time_1.toMilliseconds)({ minutes: 3 }));
27
+ describe('enweaveOneStitcher', () => {
28
+ const baseContext = {
29
+ ...(0, genContextStitchTrail_1.genContextStitchTrail)(),
30
+ ...(0, genContextLogTrail_1.genContextLogTrail)(),
31
+ };
32
+ const context = { ...baseContext, ...(0, getContextOpenAI_1.getContextOpenAI)() };
33
+ // takes a while; skip by default
34
+ test_fns_1.given.runIf(!process.env.CI)('a review loop that proposes, reviews, summarizes, and judges code improvement until blockers are gone or 3 attempts max', () => {
35
+ const stitcherCodeReviewConcluder = new StitchStep_1.StitchStepCompute({
36
+ slug: '[critic]<review:concluder>',
37
+ readme: null,
38
+ form: 'COMPUTE',
39
+ stitchee: 'critic',
40
+ invoke: ({ threads }) => {
41
+ const summary = threads.critic.peers
42
+ .map((peer) => peer.stitches.slice(-1)[0]?.output)
43
+ .filter(Boolean);
44
+ const blockers = summary.filter((x) => x.includes('blocker'));
45
+ return { input: summary, output: { blockers, summary } };
46
+ },
47
+ });
48
+ const stitcherCodeReviewFanout = (0, asStitcher_1.asStitcher)((0, genStitchFanout_1.genStitchFanout)({
49
+ slug: '[critic]<code:review>.<fanout>[[review]]',
50
+ readme: null,
51
+ parallels: [
52
+ (0, genStitcherCodeReviewImagine_1.genStitcherCodeReview)({ scope: 'technical', focus: 'blockers' }),
53
+ // genStitcherCodeReview({ scope: 'technical', focus: 'chances' }),
54
+ // genStitcherCodeReview({ scope: 'technical', focus: 'praises' }),
55
+ (0, genStitcherCodeReviewImagine_1.genStitcherCodeReview)({ scope: 'functional', focus: 'blockers' }),
56
+ // genStitcherCodeReview({ scope: 'functional', focus: 'chances' }),
57
+ // genStitcherCodeReview({ scope: 'functional', focus: 'praises' }),
58
+ ],
59
+ concluder: stitcherCodeReviewConcluder,
60
+ }));
61
+ const directorSummarize = new StitchStep_1.StitchStepCompute({
62
+ slug: '[director]<summarize>',
63
+ form: 'COMPUTE',
64
+ stitchee: 'director',
65
+ readme: 'turn critic summary into a director directive',
66
+ invoke: ({ threads }) => {
67
+ const last = threads.critic.stitches.slice(-1)[0]?.output;
68
+ return {
69
+ input: last,
70
+ output: {
71
+ directive: `resolve blockers, blockers: ${JSON.stringify(last?.blockers, null, 2)}`,
72
+ blockers: last?.blockers,
73
+ },
74
+ };
75
+ },
76
+ });
77
+ const artistCodeProposeRoute = (0, asStitcher_1.asStitcher)((0, genStitchRoute_1.genStitchRoute)({
78
+ slug: '[artist]<code:propose>',
79
+ readme: 'imagine diff, then write to file',
80
+ sequence: [
81
+ stitcherCodeDiffImagine_1.stitcherCodeDiffImagine,
82
+ (0, genStitcherCodeFileWrite_1.genStitcherCodeFileWrite)({
83
+ stitchee: 'artist',
84
+ }),
85
+ ],
86
+ }));
87
+ const criticCodeReviewRoute = (0, asStitcher_1.asStitcher)((0, genStitchRoute_1.genStitchRoute)({
88
+ slug: '[critic]<code:review>',
89
+ readme: 'review the code from multiple perspectives',
90
+ sequence: [
91
+ (0, genStitcherCodeFileRead_1.genStitcherCodeFileRead)({
92
+ stitchee: 'critic',
93
+ output: ({ threads }) => threads.artist?.stitches.slice(-1)[0]?.output ??
94
+ helpful_errors_1.UnexpectedCodePathError.throw('expected to find file write output stitch', { threads }),
95
+ }),
96
+ stitcherCodeReviewFanout,
97
+ ],
98
+ }));
99
+ const codeIterateRoute = (0, asStitcherFlat_1.asStitcherFlat)((0, genStitchRoute_1.genStitchRoute)({
100
+ slug: '[code:iterate]',
101
+ readme: 'one pass of propose + review + summarize',
102
+ sequence: [
103
+ artistCodeProposeRoute,
104
+ criticCodeReviewRoute,
105
+ directorSummarize,
106
+ ],
107
+ }));
108
+ const judgeDeciderNextStep = new StitchStep_1.StitchStepCompute({
109
+ slug: '[judge]<decide:release?>',
110
+ form: 'COMPUTE',
111
+ stitchee: 'judge',
112
+ readme: 'release if more than 3 reviews',
113
+ invoke: ({ threads }) => {
114
+ const choice = threads.critic.stitches.length >= 3 ? 'release' : 'repeat';
115
+ return {
116
+ input: { stitches: threads.critic.stitches.length },
117
+ output: { choice },
118
+ };
119
+ },
120
+ });
121
+ const mechanicCodeDiffIterateUntilRelease = (0, asStitcher_1.asStitcher)((0, genStitchCycle_1.genStitchCycle)({
122
+ slug: '[mechanic]<code:iterate-until-release>',
123
+ readme: 'iterate until no blockers or max 3 tries',
124
+ repeatee: codeIterateRoute,
125
+ decider: judgeDeciderNextStep,
126
+ }));
127
+ const stitcherRestitchLatestArtistOutput = new StitchStep_1.StitchStepCompute({
128
+ slug: '[artist]<restitch:latest>',
129
+ readme: 'Restitch artists latest output for final record',
130
+ form: 'COMPUTE',
131
+ stitchee: 'artist',
132
+ invoke: ({ threads }) => {
133
+ const latest = threads.artist.stitches.slice(-1)[0];
134
+ if (!latest?.output || typeof latest.output !== 'object')
135
+ throw new Error('No valid artist output to restitch');
136
+ return latest;
137
+ },
138
+ });
139
+ const rootRouteCodeDiff = (0, genStitchRoute_1.genStitchRoute)({
140
+ slug: '[mechanic]<code:diff>',
141
+ readme: 'read initial file, then iterate against directive until no blockers or 3 tries',
142
+ sequence: [
143
+ (0, genStitcherCodeFileRead_1.genStitcherCodeFileRead)({
144
+ stitchee: 'artist',
145
+ output: {
146
+ path: '__path__',
147
+ content: `
148
+ /**
149
+ * .what = calls the open-meteo weather api
150
+ * .how =
151
+ * - uses procedural pattern
152
+ * - fails fast
153
+ */
154
+ export const sdkOpenMeteo = {
155
+ getWeather: (input: {...}, context: VisualogicContext & AuthContextOpenMeteo) => {
156
+ ...
157
+ }
158
+ }
159
+ `.trim(),
160
+ },
161
+ }),
162
+ mechanicCodeDiffIterateUntilRelease,
163
+ stitcherRestitchLatestArtistOutput,
164
+ ],
165
+ });
166
+ console.log(JSON.stringify(rootRouteCodeDiff, null, 2));
167
+ (0, test_fns_1.when)('executing the full review loop with realistic threads for artist, critic, director, and judge', () => {
168
+ let threads;
169
+ beforeAll(async () => {
170
+ threads = {
171
+ artist: await (0, codeArtist_1.getExampleThreadCodeArtist)(),
172
+ critic: await (0, codeCritic_1.getExampleThreadCodeCritic)(),
173
+ director: director_1.exampleThreadDirector.clone({
174
+ stitches: [
175
+ {
176
+ uuid: (0, uuid_fns_1.getUuid)(),
177
+ createdAt: (0, uni_time_1.asUniDateTime)(new Date()),
178
+ input: null,
179
+ output: { directive: 'fillout the stubout' },
180
+ stitcher: null,
181
+ trail: null,
182
+ }, // start with this directive
183
+ ],
184
+ }),
185
+ judge: (0, genThread_1.genThread)({ role: 'judge' }),
186
+ };
187
+ });
188
+ (0, test_fns_1.then)('it should have a readable route plan declared', () => {
189
+ // expect(rootRouteCodeDiff).toMatchSnapshot();
190
+ expect(JSON.stringify(rootRouteCodeDiff, null, 2)).toMatchSnapshot();
191
+ });
192
+ (0, test_fns_1.then)('it should exit after 3 cycles if blockers are always returned', async () => {
193
+ const output = await (0, enweaveOneStitcher_1.enweaveOneStitcher)({ stitcher: rootRouteCodeDiff, threads }, context);
194
+ expect(output.threads.artist.stitches.length).toBeGreaterThan(0);
195
+ expect(output.threads.critic.stitches.length).toBeGreaterThan(0);
196
+ expect(output.threads.judge.stitches.length).toBeGreaterThan(0);
197
+ expect(JSON.stringify(deepReplaceShortUuidsWithLetters(deepOmit(output, [
198
+ 'occurredAt',
199
+ 'createdAt',
200
+ 'input',
201
+ 'output',
202
+ 'tools',
203
+ 'facts',
204
+ 'uuid',
205
+ 'stitchUuid',
206
+ ])), null, 2)).toMatchSnapshot();
207
+ });
208
+ });
209
+ });
210
+ });
211
+ function deepOmit(obj, keys) {
212
+ if (Array.isArray(obj)) {
213
+ return obj.map((item) => deepOmit(item, keys));
214
+ }
215
+ if (obj !== null && typeof obj === 'object') {
216
+ const raw = { ...obj };
217
+ for (const key of keys) {
218
+ delete raw[key];
219
+ }
220
+ return Object.fromEntries(Object.entries(raw).map(([k, v]) => [k, deepOmit(v, keys)]));
221
+ }
222
+ return obj;
223
+ }
224
+ exports.deepOmit = deepOmit;
225
+ const shortUuidRegex = /\(([0-9a-f]{7})\)/gi;
226
+ function getLetterLabel(index) {
227
+ let label = '';
228
+ while (index >= 0) {
229
+ label = String.fromCharCode((index % 26) + 65) + label;
230
+ index = Math.floor(index / 26) - 1;
231
+ }
232
+ return label;
233
+ }
234
+ function deepReplaceShortUuidsWithLetters(obj) {
235
+ const seen = new Map();
236
+ let index = 0;
237
+ const replace = (value) => {
238
+ if (typeof value === 'string') {
239
+ return value.replace(shortUuidRegex, (_, shortId) => {
240
+ const key = shortId.toLowerCase();
241
+ if (!seen.has(key)) {
242
+ seen.set(key, getLetterLabel(index++));
243
+ }
244
+ return `(${seen.get(key)})`;
245
+ });
246
+ }
247
+ if (Array.isArray(value)) {
248
+ return value.map(replace);
249
+ }
250
+ if (value !== null && typeof value === 'object') {
251
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, replace(v)]));
252
+ }
253
+ return value;
254
+ };
255
+ return replace(obj);
256
+ }
257
+ exports.deepReplaceShortUuidsWithLetters = deepReplaceShortUuidsWithLetters;
258
+ //# sourceMappingURL=enweaveOneStitcher.integration.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enweaveOneStitcher.integration.test.js","sourceRoot":"","sources":["../../../src/logic/weave/enweaveOneStitcher.integration.test.ts"],"names":[],"mappings":";;;AAAA,iDAAmE;AACnE,mDAAyD;AACzD,uCAA6C;AAE7C,uCAAmC;AAEnC,iFAA8E;AAC9E,uFAAoF;AACpF,6EAA0E;AAC1E,qGAAkG;AAClG,uGAAoG;AACpG,+GAAqG;AACrG,qGAAkG;AAClG,yEAAsF;AACtF,yEAAsF;AACtF,qEAA+E;AAC/E,gEAAoE;AAIpE,mDAAgD;AAChD,qDAAkD;AAClD,6DAA0D;AAC1D,6DAA0D;AAC1D,+DAA4D;AAC5D,6DAA0D;AAC1D,6DAA0D;AAE1D,IAAI,CAAC,UAAU,CAAC,IAAA,yBAAc,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEhD,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,MAAM,WAAW,GAAG;QAClB,GAAG,IAAA,6CAAqB,GAAE;QAC1B,GAAG,IAAA,uCAAkB,GAAE;KACxB,CAAC;IACF,MAAM,OAAO,GAAG,EAAE,GAAG,WAAW,EAAE,GAAG,IAAA,mCAAgB,GAAE,EAAE,CAAC;IAE1D,iCAAiC;IACjC,gBAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAC1B,y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C1C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE;gBAClD,MAAM,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;gBAClC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBACnB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBACzC,CAAC;gBACD,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAE,GAAG,CAAC;YAC/B,CAAC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;QAED,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAChD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CACvD,CAAC;QACJ,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAEF,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC;AA7BD,4EA6BC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enweaveOneStitcher = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ const Stitcher_1 = require("../../domain/objects/Stitcher");
6
+ const enstitch_1 = require("../stitch/enstitch");
7
+ const enweaveOneChoice_1 = require("./enweaveOneChoice");
8
+ const enweaveOneCycle_1 = require("./enweaveOneCycle");
9
+ const enweaveOneFanout_1 = require("./enweaveOneFanout");
10
+ const enweaveOneRoute_1 = require("./enweaveOneRoute");
11
+ /**
12
+ * .what = a mechanism to enweave any stitcher
13
+ * .why =
14
+ * - figures out which mechanism to call for each stitcher
15
+ */
16
+ const enweaveOneStitcher = async (input, context) => {
17
+ switch (input.stitcher.form) {
18
+ // support step stitchers
19
+ case Stitcher_1.StitcherForm.COMPUTE:
20
+ case Stitcher_1.StitcherForm.IMAGINE:
21
+ return (0, enstitch_1.enstitch)({ stitcher: input.stitcher, threads: input.threads }, context);
22
+ // support composite stitchers
23
+ case Stitcher_1.StitcherForm.ROUTE:
24
+ return (0, enweaveOneRoute_1.enweaveOneRoute)({ stitcher: input.stitcher, threads: input.threads }, context);
25
+ case Stitcher_1.StitcherForm.FANOUT:
26
+ return (0, enweaveOneFanout_1.enweaveOneFanout)({ stitcher: input.stitcher, threads: input.threads }, context);
27
+ case Stitcher_1.StitcherForm.CHOICE:
28
+ return (0, enweaveOneChoice_1.enweaveOneChoice)({ stitcher: input.stitcher, threads: input.threads }, context);
29
+ case Stitcher_1.StitcherForm.CYCLE:
30
+ return (0, enweaveOneCycle_1.enweaveOneCycle)({ stitcher: input.stitcher, threads: input.threads }, context);
31
+ // fail fast for todos
32
+ // case StitcherForm.SLEEP:
33
+ // fail fast for typos
34
+ default:
35
+ helpful_errors_1.UnexpectedCodePathError.throw('unsupported stitcher form in enweaveOneStitcher', {
36
+ form: input.stitcher.form,
37
+ stitcher: input.stitcher,
38
+ });
39
+ }
40
+ };
41
+ exports.enweaveOneStitcher = enweaveOneStitcher;
42
+ //# sourceMappingURL=enweaveOneStitcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enweaveOneStitcher.js","sourceRoot":"","sources":["../../../src/logic/weave/enweaveOneStitcher.ts"],"names":[],"mappings":";;;AAAA,mDAAyD;AAGzD,4DAIuC;AACvC,iDAA8C;AAC9C,yDAAsD;AACtD,uDAAo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AAQ,EAAE,KAAK,CAAC,QAAQ;aACzB,CACF,CAAC;IACN,CAAC;AACH,CAAC,CAAC;AAnDW,QAAA,kBAAkB,sBAmD7B"}
package/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "rhachet",
3
+ "author": "ehmpathy",
4
+ "description": "A framework for reliable, thorough thought. Weave threads of thought via stitches.",
5
+ "version": "1.1.0",
6
+ "repository": "ehmpathy/rhachet",
7
+ "homepage": "https://github.com/ehmpathy/rhachet",
8
+ "keywords": [
9
+ "uuid"
10
+ ],
11
+ "bugs": "https://github.com/ehmpathy/rhachet/issues",
12
+ "license": "MIT",
13
+ "main": "dist/index.js",
14
+ "engines": {
15
+ "node": ">=8.0.0"
16
+ },
17
+ "files": [
18
+ "/dist"
19
+ ],
20
+ "scripts": {
21
+ "build:ts": "tsc -p ./tsconfig.build.json",
22
+ "commit:with-cli": "npx cz",
23
+ "fix:format:prettier": "prettier --write '**/*.ts' --config ./prettier.config.js",
24
+ "fix:format": "npm run fix:format:prettier",
25
+ "fix:lint": "eslint -c ./.eslintrc.js src/**/*.ts --fix",
26
+ "build:clean": "rm dist/ -rf",
27
+ "build:compile": "tsc -p ./tsconfig.build.json",
28
+ "build": "npm run build:clean && npm run build:compile",
29
+ "test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
30
+ "test:types": "tsc -p ./tsconfig.build.json --noEmit",
31
+ "test:format:prettier": "prettier --parser typescript --check 'src/**/*.ts' --config ./prettier.config.js",
32
+ "test:format": "npm run test:format:prettier",
33
+ "test:lint:deps": "npx depcheck -c ./depcheckrc.yml",
34
+ "test:lint:eslint": "eslint -c ./.eslintrc.js src/**/*.ts",
35
+ "test:lint": "npm run test:lint:eslint && npm run test:lint:deps",
36
+ "test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main')",
37
+ "test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main')",
38
+ "test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
39
+ "test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
40
+ "test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
41
+ "prepush": "npm run test && npm run build",
42
+ "prepublish": "npm run build",
43
+ "preversion": "npm run prepush",
44
+ "postversion": "git push origin HEAD --tags --no-verify",
45
+ "postinstall": "[ -d .git ] && npm run prepare:husky || exit 0",
46
+ "prepare:husky": "npx husky install && chmod ug+x .husky/*"
47
+ },
48
+ "dependencies": {
49
+ "@ehmpathy/uni-time": "1.8.1",
50
+ "as-procedure": "1.1.6",
51
+ "domain-objects": "0.25.2",
52
+ "helpful-errors": "1.3.8",
53
+ "openai": "5.8.2",
54
+ "test-fns": "1.5.0",
55
+ "type-fns": "1.19.0",
56
+ "uuid-fns": "1.0.0"
57
+ },
58
+ "devDependencies": {
59
+ "@commitlint/cli": "19.3.0",
60
+ "@commitlint/config-conventional": "13.1.0",
61
+ "@trivago/prettier-plugin-sort-imports": "4.3.0",
62
+ "@tsconfig/node-lts-strictest": "18.12.1",
63
+ "@types/jest": "29.2.4",
64
+ "@typescript-eslint/eslint-plugin": "7.8.0",
65
+ "@typescript-eslint/parser": "7.8.0",
66
+ "core-js": "3.26.1",
67
+ "cz-conventional-changelog": "3.3.0",
68
+ "declapract": "0.10.3",
69
+ "declapract-typescript-ehmpathy": "0.19.1",
70
+ "depcheck": "1.4.3",
71
+ "eslint": "8.56.0",
72
+ "eslint-config-airbnb-typescript": "18.0.0",
73
+ "eslint-config-prettier": "8.5.0",
74
+ "eslint-plugin-import": "2.26.0",
75
+ "eslint-plugin-prettier": "4.2.1",
76
+ "husky": "8.0.3",
77
+ "jest": "29.3.1",
78
+ "prettier": "2.8.1",
79
+ "ts-jest": "29.1.3",
80
+ "ts-node": "10.9.2",
81
+ "typescript": "5.4.5"
82
+ },
83
+ "config": {
84
+ "commitizen": {
85
+ "path": "./node_modules/cz-conventional-changelog"
86
+ }
87
+ }
88
+ }