rhachet 1.11.0 → 1.12.2
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.
- package/dist/contract/cli/invoke.js +10 -1
- package/dist/contract/cli/invoke.js.map +1 -1
- package/dist/contract/cli/invokeAsk.d.ts +3 -3
- package/dist/contract/cli/invokeBriefs.d.ts +2 -2
- package/dist/contract/cli/invokeBriefsBoot.d.ts +1 -1
- package/dist/contract/cli/invokeBriefsBoot.js +2 -2
- package/dist/contract/cli/invokeBriefsBoot.js.map +1 -1
- package/dist/contract/cli/invokeBriefsLink.d.ts +2 -2
- package/dist/contract/cli/invokeBriefsLink.js +9 -47
- package/dist/contract/cli/invokeBriefsLink.js.map +1 -1
- package/dist/contract/cli/invokeChoose.d.ts +1 -1
- package/dist/contract/cli/invokeInit.d.ts +9 -0
- package/dist/contract/cli/invokeInit.js +57 -0
- package/dist/contract/cli/invokeInit.js.map +1 -0
- package/dist/contract/cli/invokeList.d.ts +2 -2
- package/dist/contract/cli/invokeReadme.d.ts +2 -2
- package/dist/contract/cli/invokeRoles.d.ts +2 -2
- package/dist/contract/cli/invokeRolesBoot.d.ts +1 -1
- package/dist/contract/cli/invokeRolesBoot.js +2 -2
- package/dist/contract/cli/invokeRolesBoot.js.map +1 -1
- package/dist/contract/cli/invokeRolesLink.d.ts +2 -2
- package/dist/contract/cli/invokeRolesLink.js +17 -96
- package/dist/contract/cli/invokeRolesLink.js.map +1 -1
- package/dist/contract/sdk.d.ts +13 -13
- package/dist/contract/sdk.js +25 -25
- package/dist/contract/sdk.js.map +1 -1
- package/dist/domain/constants.d.ts +3 -0
- package/dist/domain/constants.js +5 -0
- package/dist/domain/constants.js.map +1 -0
- package/dist/domain/objects/InvokeHooks.d.ts +1 -1
- package/dist/domain/objects/InvokeOpts.d.ts +1 -1
- package/dist/domain/objects/Role.d.ts +2 -2
- package/dist/domain/objects/RoleContext.d.ts +1 -1
- package/dist/domain/objects/RoleSkill.d.ts +2 -2
- package/dist/domain/objects/RoleSkillArgGetter.d.ts +3 -3
- package/dist/domain/objects/RoleTrait.d.ts +2 -2
- package/dist/domain/objects/Stitch.d.ts +4 -4
- package/dist/domain/objects/Stitch.js.map +1 -1
- package/dist/domain/objects/StitchChoice.d.ts +2 -2
- package/dist/domain/objects/StitchChoice.js.map +1 -1
- package/dist/domain/objects/StitchCycle.d.ts +4 -4
- package/dist/domain/objects/StitchCycle.js.map +1 -1
- package/dist/domain/objects/StitchFanout.d.ts +4 -4
- package/dist/domain/objects/StitchFanout.js.map +1 -1
- package/dist/domain/objects/StitchRoute.d.ts +1 -1
- package/dist/domain/objects/StitchRoute.js.map +1 -1
- package/dist/domain/objects/StitchSetEvent.d.ts +3 -3
- package/dist/domain/objects/StitchStep.d.ts +3 -3
- package/dist/domain/objects/Stitcher.d.ts +9 -9
- package/dist/domain/objects/Stitcher.js.map +1 -1
- package/dist/domain/objects/Template.d.ts +2 -2
- package/dist/domain/objects/Template.js.map +1 -1
- package/dist/domain/objects/Thread.d.ts +2 -2
- package/dist/domain/objects/Threads.d.ts +2 -2
- package/dist/domain/objects/Threads.js.map +1 -1
- package/dist/domain/objects/index.d.ts +2 -2
- package/dist/domain/objects/index.js +2 -2
- package/dist/domain/objects/index.js.map +1 -1
- package/dist/logic/context/genContextStitchTrail.d.ts +1 -1
- package/dist/logic/context/genContextStitchTrail.js.map +1 -1
- package/dist/logic/init/discoverRolePackages.d.ts +8 -0
- package/dist/logic/init/discoverRolePackages.js +20 -0
- package/dist/logic/init/discoverRolePackages.js.map +1 -0
- package/dist/logic/init/generateRhachetConfig.d.ts +8 -0
- package/dist/logic/init/generateRhachetConfig.js +40 -0
- package/dist/logic/init/generateRhachetConfig.js.map +1 -0
- package/dist/logic/invoke/assureFindRole.d.ts +2 -2
- package/dist/logic/invoke/assureUniqueRoles.d.ts +1 -1
- package/dist/logic/invoke/getAgentReadmeTemplates.js +1 -1
- package/dist/logic/invoke/getInvokeHooksByOpts.d.ts +4 -3
- package/dist/logic/invoke/getInvokeHooksByOpts.js +11 -3
- package/dist/logic/invoke/getInvokeHooksByOpts.js.map +1 -1
- package/dist/logic/invoke/getRegistriesByOpts.d.ts +2 -2
- package/dist/logic/invoke/getSkillContext.d.ts +3 -3
- package/dist/logic/invoke/getSkillThreads.d.ts +4 -4
- package/dist/logic/invoke/hooks/onInvokeAskInput.d.ts +2 -2
- package/dist/logic/invoke/link/findsertFile.d.ts +9 -0
- package/dist/logic/invoke/link/findsertFile.js +29 -0
- package/dist/logic/invoke/link/findsertFile.js.map +1 -0
- package/dist/logic/invoke/link/symlinkResourceDirectories.d.ts +12 -0
- package/dist/logic/invoke/link/symlinkResourceDirectories.js +81 -0
- package/dist/logic/invoke/link/symlinkResourceDirectories.js.map +1 -0
- package/dist/logic/invoke/performInCurrentThread.d.ts +2 -2
- package/dist/logic/invoke/performInIsolatedThread.execute.d.ts +1 -1
- package/dist/logic/invoke/performInIsolatedThread.invoke.d.ts +2 -2
- package/dist/logic/invoke/performInIsolatedThread.invoke.js +3 -3
- package/dist/logic/invoke/performInIsolatedThread.invoke.js.map +1 -1
- package/dist/logic/invoke/performInIsolatedThreads.d.ts +1 -1
- package/dist/logic/role/addRoleTraits.d.ts +5 -5
- package/dist/logic/role/enrollThread.d.ts +4 -4
- package/dist/logic/role/genRoleSkill.d.ts +1 -1
- package/dist/logic/stitch/adapters/imagineViaOpenAI.d.ts +1 -1
- package/dist/logic/stitch/enstitch.d.ts +3 -3
- package/dist/logic/stitch/enstitch.js +1 -1
- package/dist/logic/stitch/enstitch.js.map +1 -1
- package/dist/logic/stitch/invokeImagineStitcher.d.ts +3 -3
- package/dist/logic/stitch/withStitchTrail.d.ts +4 -4
- package/dist/logic/stitch/withStitchTrail.js +1 -1
- package/dist/logic/stitch/withStitchTrail.js.map +1 -1
- package/dist/logic/template/genStepImagineViaTemplate.d.ts +2 -2
- package/dist/logic/template/genStepImagineViaTemplate.js.map +1 -1
- package/dist/logic/template/genTemplate.d.ts +3 -3
- package/dist/logic/template/getTemplatePathByCallerPath.d.ts +1 -1
- package/dist/logic/template/getTemplatePathByCallerPath.js +2 -2
- package/dist/logic/template/getTemplatePathByCallerPath.js.map +1 -1
- package/dist/logic/template/getTemplateValFromArtifacts.d.ts +2 -2
- package/dist/logic/template/getTemplateValFromArtifacts.js.map +1 -1
- package/dist/logic/template/getTemplateVarsFromInheritance.d.ts +1 -1
- package/dist/logic/template/useTemplate.d.ts +2 -2
- package/dist/logic/thread/getStitch.d.ts +1 -1
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.d.ts +3 -3
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.d.ts +4 -4
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.d.ts +6 -6
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.d.ts +4 -4
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.d.ts +1 -1
- package/dist/logic/weave/compose/ThreadsMerged.generic.d.ts +4 -4
- package/dist/logic/weave/compose/asStitcher.d.ts +3 -3
- package/dist/logic/weave/compose/asStitcherFlat.d.ts +2 -2
- package/dist/logic/weave/compose/genStitchChoice.d.ts +3 -3
- package/dist/logic/weave/compose/genStitchCycle.d.ts +5 -5
- package/dist/logic/weave/compose/genStitchFanout.d.ts +5 -5
- package/dist/logic/weave/compose/genStitchFanout.js.map +1 -1
- package/dist/logic/weave/compose/genStitchRoute.d.ts +3 -3
- package/dist/logic/weave/compose/genStitchRoute.js.map +1 -1
- package/dist/logic/weave/enweaveOneChoice.d.ts +2 -2
- package/dist/logic/weave/enweaveOneChoice.js.map +1 -1
- package/dist/logic/weave/enweaveOneCycle.d.ts +2 -2
- package/dist/logic/weave/enweaveOneCycle.js.map +1 -1
- package/dist/logic/weave/enweaveOneFanout.d.ts +2 -2
- package/dist/logic/weave/enweaveOneFanout.js.map +1 -1
- package/dist/logic/weave/enweaveOneRoute.d.ts +2 -2
- package/dist/logic/weave/enweaveOneRoute.js.map +1 -1
- package/dist/logic/weave/enweaveOneStitcher.d.ts +2 -2
- package/dist/logic/weave/enweaveOneStitcher.js.map +1 -1
- package/license.md +21 -0
- package/package.json +36 -36
- package/dist/.test/directory.d.ts +0 -2
- package/dist/.test/directory.js +0 -6
- package/dist/.test/directory.js.map +0 -1
- package/dist/.test/example.use.repo/example.echoRegistry.d.ts +0 -2
- package/dist/.test/example.use.repo/example.echoRegistry.js +0 -108
- package/dist/.test/example.use.repo/example.echoRegistry.js.map +0 -1
- package/dist/.test/genContextLogTrail.d.ts +0 -2
- package/dist/.test/genContextLogTrail.js +0 -12
- package/dist/.test/genContextLogTrail.js.map +0 -1
- package/dist/.test/getContextOpenAI.d.ts +0 -2
- package/dist/.test/getContextOpenAI.js +0 -18
- package/dist/.test/getContextOpenAI.js.map +0 -1
- package/dist/.test/stitchers/genStitcherCodeFileRead.d.ts +0 -14
- package/dist/.test/stitchers/genStitcherCodeFileRead.js +0 -23
- package/dist/.test/stitchers/genStitcherCodeFileRead.js.map +0 -1
- package/dist/.test/stitchers/genStitcherCodeFileWrite.d.ts +0 -16
- package/dist/.test/stitchers/genStitcherCodeFileWrite.js +0 -29
- package/dist/.test/stitchers/genStitcherCodeFileWrite.js.map +0 -1
- package/dist/.test/stitchers/genStitcherCodeReviewImagine.d.ts +0 -15
- package/dist/.test/stitchers/genStitcherCodeReviewImagine.js +0 -97
- package/dist/.test/stitchers/genStitcherCodeReviewImagine.js.map +0 -1
- package/dist/.test/stitchers/stitcherCodeDiffImagine.d.ts +0 -13
- package/dist/.test/stitchers/stitcherCodeDiffImagine.js +0 -33
- package/dist/.test/stitchers/stitcherCodeDiffImagine.js.map +0 -1
- package/dist/.test/stitchers/stitcherFanoutRandomSum.d.ts +0 -13
- package/dist/.test/stitchers/stitcherFanoutRandomSum.js +0 -45
- package/dist/.test/stitchers/stitcherFanoutRandomSum.js.map +0 -1
- package/dist/.test/stitchers/stitcherFanoutSubroutes.d.ts +0 -35
- package/dist/.test/stitchers/stitcherFanoutSubroutes.js +0 -76
- package/dist/.test/stitchers/stitcherFanoutSubroutes.js.map +0 -1
- package/dist/.test/threads/codeArtist.d.ts +0 -6
- package/dist/.test/threads/codeArtist.js +0 -26
- package/dist/.test/threads/codeArtist.js.map +0 -1
- package/dist/.test/threads/codeCritic.d.ts +0 -6
- package/dist/.test/threads/codeCritic.js +0 -21
- package/dist/.test/threads/codeCritic.js.map +0 -1
- package/dist/.test/threads/director.d.ts +0 -6
- package/dist/.test/threads/director.js +0 -14
- package/dist/.test/threads/director.js.map +0 -1
- package/dist/contract/cli/invoke.integration.test.d.ts +0 -1
- package/dist/contract/cli/invoke.integration.test.js +0 -39
- package/dist/contract/cli/invoke.integration.test.js.map +0 -1
- package/dist/contract/cli/invokeAsk.integration.test.d.ts +0 -1
- package/dist/contract/cli/invokeAsk.integration.test.js +0 -69
- package/dist/contract/cli/invokeAsk.integration.test.js.map +0 -1
- package/dist/contract/cli/invokeBriefsBoot.integration.test.d.ts +0 -1
- package/dist/contract/cli/invokeBriefsBoot.integration.test.js +0 -159
- package/dist/contract/cli/invokeBriefsBoot.integration.test.js.map +0 -1
- package/dist/contract/cli/invokeBriefsLink.integration.test.d.ts +0 -1
- package/dist/contract/cli/invokeBriefsLink.integration.test.js +0 -97
- package/dist/contract/cli/invokeBriefsLink.integration.test.js.map +0 -1
- package/dist/contract/cli/invokeChoose.integration.test.d.ts +0 -1
- package/dist/contract/cli/invokeChoose.integration.test.js +0 -111
- package/dist/contract/cli/invokeChoose.integration.test.js.map +0 -1
- package/dist/contract/cli/invokeReadme.integration.test.d.ts +0 -1
- package/dist/contract/cli/invokeReadme.integration.test.js +0 -62
- package/dist/contract/cli/invokeReadme.integration.test.js.map +0 -1
- package/dist/domain/objects/InvokeOpts.test.d.ts +0 -1
- package/dist/domain/objects/InvokeOpts.test.js +0 -41
- package/dist/domain/objects/InvokeOpts.test.js.map +0 -1
- package/dist/domain/objects/Stitcher.test.d.ts +0 -1
- package/dist/domain/objects/Stitcher.test.js +0 -78
- package/dist/domain/objects/Stitcher.test.js.map +0 -1
- package/dist/domain/objects/Template.test.d.ts +0 -1
- package/dist/domain/objects/Template.test.js +0 -48
- package/dist/domain/objects/Template.test.js.map +0 -1
- package/dist/logic/invoke/addAttemptQualifierToOutputPath.test.d.ts +0 -1
- package/dist/logic/invoke/addAttemptQualifierToOutputPath.test.js +0 -130
- package/dist/logic/invoke/addAttemptQualifierToOutputPath.test.js.map +0 -1
- package/dist/logic/invoke/getPeerQualifiersOfOutputChoice.test.d.ts +0 -1
- package/dist/logic/invoke/getPeerQualifiersOfOutputChoice.test.js +0 -77
- package/dist/logic/invoke/getPeerQualifiersOfOutputChoice.test.js.map +0 -1
- package/dist/logic/invoke/getSkillContext.test.d.ts +0 -1
- package/dist/logic/invoke/getSkillContext.test.js +0 -85
- package/dist/logic/invoke/getSkillContext.test.js.map +0 -1
- package/dist/logic/invoke/getSkillThread.test.d.ts +0 -1
- package/dist/logic/invoke/getSkillThread.test.js +0 -115
- package/dist/logic/invoke/getSkillThread.test.js.map +0 -1
- package/dist/logic/invoke/performInIsolatedThread.invoke.integration.test.d.ts +0 -1
- package/dist/logic/invoke/performInIsolatedThread.invoke.integration.test.js +0 -74
- package/dist/logic/invoke/performInIsolatedThread.invoke.integration.test.js.map +0 -1
- package/dist/logic/invoke/performInIsolatedThreads.integration.test.d.ts +0 -1
- package/dist/logic/invoke/performInIsolatedThreads.integration.test.js +0 -75
- package/dist/logic/invoke/performInIsolatedThreads.integration.test.js.map +0 -1
- package/dist/logic/role/addRoleTraits.test.d.ts +0 -1
- package/dist/logic/role/addRoleTraits.test.js +0 -93
- package/dist/logic/role/addRoleTraits.test.js.map +0 -1
- package/dist/logic/role/enrollThread.integration.test.d.ts +0 -1
- package/dist/logic/role/enrollThread.integration.test.js +0 -79
- package/dist/logic/role/enrollThread.integration.test.js.map +0 -1
- package/dist/logic/role/genRoleSkill.test.d.ts +0 -1
- package/dist/logic/role/genRoleSkill.test.js +0 -79
- package/dist/logic/role/genRoleSkill.test.js.map +0 -1
- package/dist/logic/stitch/enstitch.test.d.ts +0 -1
- package/dist/logic/stitch/enstitch.test.js +0 -112
- package/dist/logic/stitch/enstitch.test.js.map +0 -1
- package/dist/logic/stitch/invokeImagineStitcher.integration.test.d.ts +0 -1
- package/dist/logic/stitch/invokeImagineStitcher.integration.test.js +0 -195
- package/dist/logic/stitch/invokeImagineStitcher.integration.test.js.map +0 -1
- package/dist/logic/template/genStepImagineViaTemplate.test.d.ts +0 -1
- package/dist/logic/template/genStepImagineViaTemplate.test.js +0 -126
- package/dist/logic/template/genStepImagineViaTemplate.test.js.map +0 -1
- package/dist/logic/template/genTemplate.test.d.ts +0 -1
- package/dist/logic/template/genTemplate.test.js +0 -118
- package/dist/logic/template/genTemplate.test.js.map +0 -1
- package/dist/logic/template/useTemplate.integration.test.d.ts +0 -1
- package/dist/logic/template/useTemplate.integration.test.js +0 -28
- package/dist/logic/template/useTemplate.integration.test.js.map +0 -1
- package/dist/logic/thread/getStitch.test.d.ts +0 -1
- package/dist/logic/thread/getStitch.test.js +0 -73
- package/dist/logic/thread/getStitch.test.js.map +0 -1
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.d.ts +0 -1
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.js +0 -67
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.js.map +0 -1
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.d.ts +0 -1
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.js +0 -132
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.js.map +0 -1
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.d.ts +0 -1
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.js +0 -74
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.js.map +0 -1
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.d.ts +0 -1
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.js +0 -190
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.js.map +0 -1
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.d.ts +0 -1
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.js +0 -29
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.js.map +0 -1
- package/dist/logic/weave/compose/ThreadsMerged.generic.test.d.ts +0 -1
- package/dist/logic/weave/compose/ThreadsMerged.generic.test.js +0 -420
- package/dist/logic/weave/compose/ThreadsMerged.generic.test.js.map +0 -1
- package/dist/logic/weave/compose/asStitcher.test.d.ts +0 -1
- package/dist/logic/weave/compose/asStitcher.test.js +0 -95
- package/dist/logic/weave/compose/asStitcher.test.js.map +0 -1
- package/dist/logic/weave/compose/asStitcherFlat.test.d.ts +0 -1
- package/dist/logic/weave/compose/asStitcherFlat.test.js +0 -96
- package/dist/logic/weave/compose/asStitcherFlat.test.js.map +0 -1
- package/dist/logic/weave/compose/genStitchChoice.test.d.ts +0 -1
- package/dist/logic/weave/compose/genStitchChoice.test.js +0 -200
- package/dist/logic/weave/compose/genStitchChoice.test.js.map +0 -1
- package/dist/logic/weave/compose/genStitchCycle.test.d.ts +0 -1
- package/dist/logic/weave/compose/genStitchCycle.test.js +0 -267
- package/dist/logic/weave/compose/genStitchCycle.test.js.map +0 -1
- package/dist/logic/weave/compose/genStitchFanout.test.d.ts +0 -1
- package/dist/logic/weave/compose/genStitchFanout.test.js +0 -79
- package/dist/logic/weave/compose/genStitchFanout.test.js.map +0 -1
- package/dist/logic/weave/compose/genStitchRoute.test.d.ts +0 -1
- package/dist/logic/weave/compose/genStitchRoute.test.js +0 -120
- package/dist/logic/weave/compose/genStitchRoute.test.js.map +0 -1
- package/dist/logic/weave/enweaveOneChoice.test.d.ts +0 -1
- package/dist/logic/weave/enweaveOneChoice.test.js +0 -181
- package/dist/logic/weave/enweaveOneChoice.test.js.map +0 -1
- package/dist/logic/weave/enweaveOneCycle.test.d.ts +0 -1
- package/dist/logic/weave/enweaveOneCycle.test.js +0 -180
- package/dist/logic/weave/enweaveOneCycle.test.js.map +0 -1
- package/dist/logic/weave/enweaveOneFanout.integration.test.d.ts +0 -1
- package/dist/logic/weave/enweaveOneFanout.integration.test.js +0 -166
- package/dist/logic/weave/enweaveOneFanout.integration.test.js.map +0 -1
- package/dist/logic/weave/enweaveOneRoute.integration.test.d.ts +0 -1
- package/dist/logic/weave/enweaveOneRoute.integration.test.js +0 -159
- package/dist/logic/weave/enweaveOneRoute.integration.test.js.map +0 -1
- package/dist/logic/weave/enweaveOneStitcher.integration.test.d.ts +0 -2
- package/dist/logic/weave/enweaveOneStitcher.integration.test.js +0 -258
- package/dist/logic/weave/enweaveOneStitcher.integration.test.js.map +0 -1
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const uni_time_1 = require("@ehmpathy/uni-time");
|
|
4
|
-
const test_fns_1 = require("test-fns");
|
|
5
|
-
const genContextLogTrail_1 = require("../../.test/genContextLogTrail");
|
|
6
|
-
const getContextOpenAI_1 = require("../../.test/getContextOpenAI");
|
|
7
|
-
const StitchStep_1 = require("../../domain/objects/StitchStep");
|
|
8
|
-
const Thread_1 = require("../../domain/objects/Thread");
|
|
9
|
-
const genContextStitchTrail_1 = require("../context/genContextStitchTrail");
|
|
10
|
-
const imagineViaOpenAI_1 = require("./adapters/imagineViaOpenAI");
|
|
11
|
-
const enstitch_1 = require("./enstitch");
|
|
12
|
-
jest.setTimeout((0, uni_time_1.toMilliseconds)({ minutes: 3 }));
|
|
13
|
-
describe('invokeImagineStitcher', () => {
|
|
14
|
-
test_fns_1.given.runIf(!process.env.CI)('a representative imagine stitcher', () => {
|
|
15
|
-
const context = {
|
|
16
|
-
...(0, genContextLogTrail_1.genContextLogTrail)(),
|
|
17
|
-
...(0, genContextStitchTrail_1.genContextStitchTrail)(),
|
|
18
|
-
...(0, getContextOpenAI_1.getContextOpenAI)(),
|
|
19
|
-
};
|
|
20
|
-
const stitcher = new StitchStep_1.StitchStepImagine({
|
|
21
|
-
form: 'IMAGINE',
|
|
22
|
-
slug: 'fillout-stub',
|
|
23
|
-
readme: 'intent(fills out a stub of code); note(good example for impact of context)',
|
|
24
|
-
stitchee: 'author',
|
|
25
|
-
enprompt: ({ threads }) => [
|
|
26
|
-
'fillout the code of the given stubout',
|
|
27
|
-
'context.factset = ',
|
|
28
|
-
threads.author.context.factset.join('\n - '),
|
|
29
|
-
'',
|
|
30
|
-
'here is the stubout',
|
|
31
|
-
threads.author.stitches.slice(-1)[0]?.output,
|
|
32
|
-
'',
|
|
33
|
-
'fillout the code of the given stubout',
|
|
34
|
-
].join('\n'),
|
|
35
|
-
imagine: imagineViaOpenAI_1.imagineViaOpenAI,
|
|
36
|
-
deprompt: ({ promptOut, promptIn }) => ({
|
|
37
|
-
output: promptOut,
|
|
38
|
-
input: promptIn,
|
|
39
|
-
}),
|
|
40
|
-
});
|
|
41
|
-
const stubout = `
|
|
42
|
-
/**
|
|
43
|
-
* .what = calls the open-meteo weather api
|
|
44
|
-
* .how =
|
|
45
|
-
* - uses procedural pattern
|
|
46
|
-
* - fails fast
|
|
47
|
-
*/
|
|
48
|
-
export const sdkOpenMeteo = {
|
|
49
|
-
getWeather: (input: {...}, context: VisualogicContext & AuthContextOpenMeteo) => {
|
|
50
|
-
...
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
`.trim();
|
|
54
|
-
(0, test_fns_1.when)('thread has blank context', () => {
|
|
55
|
-
const thread = new Thread_1.Thread({
|
|
56
|
-
context: { role: 'author', factset: [] },
|
|
57
|
-
stitches: [{ output: stubout, input: null }],
|
|
58
|
-
});
|
|
59
|
-
(0, test_fns_1.then)('it should be able to stitch', async () => {
|
|
60
|
-
const { stitch, threads } = await (0, enstitch_1.enstitch)({ stitcher, threads: { author: thread } }, context);
|
|
61
|
-
console.log(stitch.input);
|
|
62
|
-
console.log(stitch.output);
|
|
63
|
-
// stitch should look right
|
|
64
|
-
expect(stitch.output).toContain('sdkOpenMeteo');
|
|
65
|
-
// stitchee should be updated, too
|
|
66
|
-
expect(threads.author.stitches.length).toEqual(thread.stitches.length + 1);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
(0, test_fns_1.when)('thread has context', () => {
|
|
70
|
-
const thread = new Thread_1.Thread({
|
|
71
|
-
context: {
|
|
72
|
-
role: 'author',
|
|
73
|
-
factset: [
|
|
74
|
-
`example of usage of open-meteo
|
|
75
|
-
|
|
76
|
-
\`\`\`ts
|
|
77
|
-
import { fetchWeatherApi } from 'openmeteo';
|
|
78
|
-
|
|
79
|
-
const params = {
|
|
80
|
-
latitude: [52.54],
|
|
81
|
-
longitude: [13.41],
|
|
82
|
-
current: 'temperature_2m,weather_code,wind_speed_10m,wind_direction_10m',
|
|
83
|
-
hourly: 'temperature_2m,precipitation',
|
|
84
|
-
daily: 'weather_code,temperature_2m_max,temperature_2m_min'
|
|
85
|
-
};
|
|
86
|
-
const url = 'https://api.open-meteo.com/v1/forecast';
|
|
87
|
-
const responses = await fetchWeatherApi(url, params);
|
|
88
|
-
|
|
89
|
-
// Helper function to form time ranges
|
|
90
|
-
const range = (start: number, stop: number, step: number) =>
|
|
91
|
-
Array.from({ length: (stop - start) / step }, (_, i) => start + i * step);
|
|
92
|
-
|
|
93
|
-
// Process first location. Add a for-loop for multiple locations or weather models
|
|
94
|
-
const response = responses[0];
|
|
95
|
-
|
|
96
|
-
// Attributes for timezone and location
|
|
97
|
-
const utcOffsetSeconds = response.utcOffsetSeconds();
|
|
98
|
-
const timezone = response.timezone();
|
|
99
|
-
const timezoneAbbreviation = response.timezoneAbbreviation();
|
|
100
|
-
const latitude = response.latitude();
|
|
101
|
-
const longitude = response.longitude();
|
|
102
|
-
|
|
103
|
-
const current = response.current()!;
|
|
104
|
-
const hourly = response.hourly()!;
|
|
105
|
-
const daily = response.daily()!;
|
|
106
|
-
|
|
107
|
-
// Note: The order of weather variables in the URL query and the indices below need to match!
|
|
108
|
-
const weatherData = {
|
|
109
|
-
current: {
|
|
110
|
-
time: new Date((Number(current.time()) + utcOffsetSeconds) * 1000),
|
|
111
|
-
temperature: current.variables(0)!.value(), // Current is only 1 value, therefore \`.value()\`
|
|
112
|
-
weatherCode: current.variables(1)!.value(),
|
|
113
|
-
windSpeed: current.variables(2)!.value(),
|
|
114
|
-
windDirection: current.variables(3)!.value()
|
|
115
|
-
},
|
|
116
|
-
hourly: {
|
|
117
|
-
time: range(Number(hourly.time()), Number(hourly.timeEnd()), hourly.interval()).map(
|
|
118
|
-
(t) => new Date((t + utcOffsetSeconds) * 1000)
|
|
119
|
-
),
|
|
120
|
-
temperature: hourly.variables(0)!.valuesArray()!, // \`.valuesArray()\` get an array of floats
|
|
121
|
-
precipitation: hourly.variables(1)!.valuesArray()!,
|
|
122
|
-
},
|
|
123
|
-
daily: {
|
|
124
|
-
time: range(Number(daily.time()), Number(daily.timeEnd()), daily.interval()).map(
|
|
125
|
-
(t) => new Date((t + utcOffsetSeconds) * 1000)
|
|
126
|
-
),
|
|
127
|
-
weatherCode: daily.variables(0)!.valuesArray()!,
|
|
128
|
-
temperatureMax: daily.variables(1)!.valuesArray()!,
|
|
129
|
-
temperatureMin: daily.variables(2)!.valuesArray()!,
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// \`weatherData\` now contains a simple structure with arrays for datetime and weather data
|
|
134
|
-
for (let i = 0; i < weatherData.daily.time.length; i++) {
|
|
135
|
-
console.log(
|
|
136
|
-
weatherData.daily.time[i].toISOString(),
|
|
137
|
-
weatherData.daily.weatherCode[i],
|
|
138
|
-
weatherData.daily.temperatureMax[i],
|
|
139
|
-
weatherData.daily.temperatureMin[i]
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
\`\`\`
|
|
144
|
-
`.trim(),
|
|
145
|
-
`open-meteo forecast response shape
|
|
146
|
-
|
|
147
|
-
On success a JSON object will be returned.
|
|
148
|
-
|
|
149
|
-
{
|
|
150
|
-
"latitude": 52.52,
|
|
151
|
-
"longitude": 13.419,
|
|
152
|
-
"elevation": 44.812,
|
|
153
|
-
"generationtime_ms": 2.2119,
|
|
154
|
-
"utc_offset_seconds": 0,
|
|
155
|
-
"timezone": "Europe/Berlin",
|
|
156
|
-
"timezone_abbreviation": "CEST",
|
|
157
|
-
"hourly": {
|
|
158
|
-
"time": ["2022-07-01T00:00", "2022-07-01T01:00", "2022-07-01T02:00", ...],
|
|
159
|
-
"temperature_2m": [13, 12.7, 12.7, 12.5, 12.5, 12.8, 13, 12.9, 13.3, ...]
|
|
160
|
-
},
|
|
161
|
-
"hourly_units": {
|
|
162
|
-
"temperature_2m": "°C"
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
Parameter Format Description
|
|
166
|
-
latitude, longitude Floating point WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be a few kilometers away from the requested coordinate.
|
|
167
|
-
elevation Floating point The elevation from a 90 meter digital elevation model. This effects which grid-cell is selected (see parameter cell_selection). Statistical downscaling is used to adapt weather conditions for this elevation. This elevation can also be controlled with the query parameter elevation. If &elevation=nan is specified, all downscaling is disabled and the averge grid-cell elevation is used.
|
|
168
|
-
generationtime_ms Floating point Generation time of the weather forecast in milliseconds. This is mainly used for performance monitoring and improvements.
|
|
169
|
-
utc_offset_seconds Integer Applied timezone offset from the &timezone= parameter.
|
|
170
|
-
timezone
|
|
171
|
-
timezone_abbreviation String Timezone identifier (e.g. Europe/Berlin) and abbreviation (e.g. CEST)
|
|
172
|
-
hourly Object For each selected weather variable, data will be returned as a floating point array. Additionally a time array will be returned with ISO8601 timestamps.
|
|
173
|
-
hourly_units Object For each selected weather variable, the unit will be listed here.
|
|
174
|
-
daily Object For each selected daily weather variable, data will be returned as a floating point array. Additionally a time array will be returned with ISO8601 timestamps.
|
|
175
|
-
daily_units Object For each selected daily weather variable, the unit will be listed here.
|
|
176
|
-
`,
|
|
177
|
-
'we want to declare an explicit output type with a simplified name pattern. for example, Weather { label: "sunny" | ..., temp: { high, low }, rain, etc }',
|
|
178
|
-
],
|
|
179
|
-
},
|
|
180
|
-
stitches: [{ output: stubout, input: null }],
|
|
181
|
-
});
|
|
182
|
-
(0, test_fns_1.then)('it should leverage the knowledge of the context', async () => {
|
|
183
|
-
const { stitch, threads } = await (0, enstitch_1.enstitch)({ stitcher, threads: { author: thread } }, context);
|
|
184
|
-
console.log(stitch.input);
|
|
185
|
-
console.log(stitch.output);
|
|
186
|
-
// stitch should look right
|
|
187
|
-
expect(stitch.output).toContain('sdkOpenMeteo');
|
|
188
|
-
expect(stitch.output).toContain('temperature_2m');
|
|
189
|
-
// stitchee should be updated, too
|
|
190
|
-
expect(threads.author.stitches.length).toEqual(thread.stitches.length + 1);
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
//# sourceMappingURL=invokeImagineStitcher.integration.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invokeImagineStitcher.integration.test.js","sourceRoot":"","sources":["../../../src/logic/stitch/invokeImagineStitcher.integration.test.ts"],"names":[],"mappings":";;AAAA,iDAAoD;AACpD,uCAA6C;AAE7C,uEAAoE;AACpE,mEAAgE;AAEhE,gEAAoE;AAEpE,wDAAqD;AAErD,4EAAyE;AACzE,kEAA8E;AAC9E,yCAAsC;AAEtC,IAAI,CAAC,UAAU,CAAC,IAAA,yBAAc,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEhD,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,gBAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,mCAAmC,EAAE,GAAG,EAAE;QACrE,MAAM,OAAO,GAAG;YACd,GAAG,IAAA,uCAAkB,GAAE;YACvB,GAAG,IAAA,6CAAqB,GAAE;YAC1B,GAAG,IAAA,mCAA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AO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAE3B,2BAA2B;gBAC3B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;gBAChD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;gBAElD,kCAAkC;gBAClC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,CAC5C,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAC3B,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const test_fns_1 = require("test-fns");
|
|
4
|
-
const genContextLogTrail_1 = require("../../.test/genContextLogTrail");
|
|
5
|
-
const genContextStitchTrail_1 = require("../context/genContextStitchTrail");
|
|
6
|
-
const genThread_1 = require("../thread/genThread");
|
|
7
|
-
const genStepImagineViaTemplate_1 = require("./genStepImagineViaTemplate");
|
|
8
|
-
const genTemplate_1 = require("./genTemplate");
|
|
9
|
-
const useTemplate_1 = require("./useTemplate");
|
|
10
|
-
jest.mock('./useTemplate', () => ({
|
|
11
|
-
useTemplate: jest.fn(),
|
|
12
|
-
}));
|
|
13
|
-
describe('genStepImagineViaTemplate', () => {
|
|
14
|
-
const context = {
|
|
15
|
-
...(0, genContextLogTrail_1.genContextLogTrail)(),
|
|
16
|
-
...(0, genContextStitchTrail_1.genContextStitchTrail)(),
|
|
17
|
-
};
|
|
18
|
-
(0, test_fns_1.given)('a prompt template and imagine step with incompatible threads', () => {
|
|
19
|
-
const threads = {
|
|
20
|
-
assistant: (0, genThread_1.genThread)({ role: 'assistant', name: 'Bert' }),
|
|
21
|
-
};
|
|
22
|
-
const template = (0, genTemplate_1.genTemplate)({
|
|
23
|
-
ref: { uri: 'path/to/template.md' },
|
|
24
|
-
getVariables: (input) => ({
|
|
25
|
-
name: input.threads.assistant.context.name,
|
|
26
|
-
}),
|
|
27
|
-
});
|
|
28
|
-
(0, test_fns_1.then)('there should be a devtime error on instantiation', async () => {
|
|
29
|
-
(0, genStepImagineViaTemplate_1.genStepImagineViaTemplate)({
|
|
30
|
-
slug: 'test-slug',
|
|
31
|
-
readme: 'testing imagine via template',
|
|
32
|
-
stitchee: 'assistant',
|
|
33
|
-
// @ts-expect-error: Property 'name' is missing in type 'ThreadContextRole<"assistant">' but required in type '{ role: "assistant"; name: string; }'.ts(2322)
|
|
34
|
-
template,
|
|
35
|
-
imagine: async (prompt) => `AI said: ${prompt}`,
|
|
36
|
-
deprompt: ({ input, output }) => ({
|
|
37
|
-
input: { prompt: input },
|
|
38
|
-
output: { content: output },
|
|
39
|
-
}),
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
(0, test_fns_1.given)('a prompt template and imagine step with compatible threads', () => {
|
|
44
|
-
const threads = {
|
|
45
|
-
assistant: (0, genThread_1.genThread)({ role: 'assistant', name: 'Casey' }),
|
|
46
|
-
};
|
|
47
|
-
const template = (0, genTemplate_1.genTemplate)({
|
|
48
|
-
ref: { uri: 'path/to/template.md' },
|
|
49
|
-
getVariables: (input) => ({
|
|
50
|
-
name: input.threads.assistant.context.name,
|
|
51
|
-
}),
|
|
52
|
-
});
|
|
53
|
-
(0, test_fns_1.when)('creating a StitchStepImagine', () => {
|
|
54
|
-
useTemplate_1.useTemplate.mockImplementation(async (input) => {
|
|
55
|
-
console.log({ input });
|
|
56
|
-
const vars = await input.variables;
|
|
57
|
-
return `hydrated: ${vars.name}`;
|
|
58
|
-
});
|
|
59
|
-
const imagineStep = (0, genStepImagineViaTemplate_1.genStepImagineViaTemplate)({
|
|
60
|
-
slug: 'test-slug',
|
|
61
|
-
readme: 'testing imagine via template',
|
|
62
|
-
stitchee: 'assistant',
|
|
63
|
-
template,
|
|
64
|
-
imagine: async (prompt) => `AI said: ${prompt}`,
|
|
65
|
-
deprompt: ({ input, output }) => ({
|
|
66
|
-
input: { prompt: input },
|
|
67
|
-
output: { content: output },
|
|
68
|
-
}),
|
|
69
|
-
});
|
|
70
|
-
(0, test_fns_1.then)('it defines a valid imagine step', async () => {
|
|
71
|
-
expect(imagineStep.form).toBe('IMAGINE');
|
|
72
|
-
expect(imagineStep.slug).toBe('test-slug');
|
|
73
|
-
expect(imagineStep.stitchee).toBe('assistant');
|
|
74
|
-
});
|
|
75
|
-
(0, test_fns_1.then)('it renders the prompt using useTemplate()', async () => {
|
|
76
|
-
const prompt = await imagineStep.enprompt({ threads });
|
|
77
|
-
expect(prompt).toBe('hydrated: Casey');
|
|
78
|
-
expect(useTemplate_1.useTemplate).toHaveBeenCalledWith({
|
|
79
|
-
ref: { uri: 'path/to/template.md' },
|
|
80
|
-
variables: { name: 'Casey' },
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
(0, test_fns_1.then)('it runs the imagine function with the prompt', async () => {
|
|
84
|
-
const result = await imagineStep.imagine('a prompt', context);
|
|
85
|
-
expect(result).toBe('AI said: a prompt');
|
|
86
|
-
});
|
|
87
|
-
(0, test_fns_1.then)('it transforms the output with deprompt', () => {
|
|
88
|
-
const deprompted = imagineStep.deprompt({
|
|
89
|
-
threads,
|
|
90
|
-
promptIn: 'abc',
|
|
91
|
-
promptOut: 'xyz',
|
|
92
|
-
});
|
|
93
|
-
expect(deprompted).toEqual({
|
|
94
|
-
input: { prompt: 'abc' },
|
|
95
|
-
output: { content: 'xyz' },
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
(0, test_fns_1.when)('passing an invalid stitchee', () => {
|
|
100
|
-
(0, test_fns_1.then)('TypeScript throws an error', () => {
|
|
101
|
-
(0, genStepImagineViaTemplate_1.genStepImagineViaTemplate)({
|
|
102
|
-
slug: 'invalid',
|
|
103
|
-
readme: 'should fail',
|
|
104
|
-
// @ts-expect-error 'ghost' is not a valid stitchee
|
|
105
|
-
stitchee: 'ghost',
|
|
106
|
-
template,
|
|
107
|
-
imagine: async (prompt) => `ghost: ${prompt}`,
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
(0, test_fns_1.when)('passing a non-literal stitchee key', () => {
|
|
112
|
-
const stitchee = 'assistant';
|
|
113
|
-
(0, test_fns_1.then)('TypeScript throws an error', () => {
|
|
114
|
-
(0, genStepImagineViaTemplate_1.genStepImagineViaTemplate)({
|
|
115
|
-
slug: 'bad-key',
|
|
116
|
-
readme: 'non-literal stitchee',
|
|
117
|
-
// @ts-expect-error stitchee must be a literal keyof threads
|
|
118
|
-
stitchee,
|
|
119
|
-
template,
|
|
120
|
-
imagine: async () => `result`,
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
//# sourceMappingURL=genStepImagineViaTemplate.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"genStepImagineViaTemplate.test.js","sourceRoot":"","sources":["../../../src/logic/template/genStepImagineViaTemplate.test.ts"],"names":[],"mappings":";;AAAA,uCAA6C;AAG7C,uEAAoE;AAEpE,4EAAyE;AACzE,mDAAgD;AAChD,2EAAwE;AACxE,+CAA4C;AAC5C,+CAA4C;AAE5C,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;IAChC,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;CACvB,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,MAAM,OAAO,GAAG;QACd,GAAG,IAAA,uCAAkB,GAAE;QACvB,GAAG,IAAA,6CAAqB,GAAE;KAC3B,CAAC;IA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BACnD,QAAQ,EAAE,OAAO;oBACjB,QAAQ;oBACR,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,UAAU,MAAM,EAAE;iBAC9C,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAA,eAAI,EAAC,oCAAoC,EAAE,GAAG,EAAE;YAC9C,MAAM,QAAQ,GAAG,WAAqB,CAAC;YAEvC,IAAA,eAAI,EAAC,4BAA4B,EAAE,GAAG,EAAE;gBACtC,IAAA,qDAAyB,EAA4B;oBACnD,IAAI,EAAE,SAAS;oBACf,MAAM,EAAE,sBAAsB;oBAC9B,4DAA4D;oBAC5D,QAAQ;oBACR,QAAQ;oBACR,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ;iBAC9B,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const rhachet_artifact_git_1 = require("rhachet-artifact-git");
|
|
4
|
-
const test_fns_1 = require("test-fns");
|
|
5
|
-
const genThread_1 = require("../thread/genThread");
|
|
6
|
-
const genTemplate_1 = require("./genTemplate");
|
|
7
|
-
const ref = { uri: __dirname + '/.temp/useTemplate.example1.md' };
|
|
8
|
-
const templateArt = (0, rhachet_artifact_git_1.genArtifactGitFile)(ref);
|
|
9
|
-
describe('genTemplate', () => {
|
|
10
|
-
(0, test_fns_1.given)('a valid template and threads with nested values', () => {
|
|
11
|
-
const threads = {
|
|
12
|
-
person: (0, genThread_1.genThread)({
|
|
13
|
-
role: 'person',
|
|
14
|
-
name: 'Casey',
|
|
15
|
-
meta: { day: 'Monday' },
|
|
16
|
-
}),
|
|
17
|
-
};
|
|
18
|
-
(0, test_fns_1.when)('calling use() on a hydrated template', () => {
|
|
19
|
-
const template = (0, genTemplate_1.genTemplate)({
|
|
20
|
-
ref,
|
|
21
|
-
getVariables: (input) => ({
|
|
22
|
-
name: input.threads.person.context.name,
|
|
23
|
-
meta: input.threads.person.context.meta,
|
|
24
|
-
}),
|
|
25
|
-
});
|
|
26
|
-
(0, test_fns_1.then)('it returns the fully hydrated string', async () => {
|
|
27
|
-
await templateArt.set({
|
|
28
|
-
content: 'Hello $.rhachet{name} — today is $.rhachet{meta.day}',
|
|
29
|
-
});
|
|
30
|
-
const result = await template.use({ threads });
|
|
31
|
-
expect(result).toBe('Hello Casey — today is Monday');
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
(0, test_fns_1.given)('a template with deeply nested async variables', () => {
|
|
36
|
-
const threads = {
|
|
37
|
-
session: (0, genThread_1.genThread)({
|
|
38
|
-
role: 'session',
|
|
39
|
-
user: { name: 'Jordan', details: { role: 'admin' } },
|
|
40
|
-
}),
|
|
41
|
-
};
|
|
42
|
-
(0, test_fns_1.when)('calling use() with async getVariables', () => {
|
|
43
|
-
const template = (0, genTemplate_1.genTemplate)({
|
|
44
|
-
ref,
|
|
45
|
-
getVariables: async (input) => ({
|
|
46
|
-
user: input.threads.session.context.user,
|
|
47
|
-
}),
|
|
48
|
-
});
|
|
49
|
-
(0, test_fns_1.then)('it correctly interpolates the nested keys', async () => {
|
|
50
|
-
await templateArt.set({
|
|
51
|
-
content: 'User: $.rhachet{user.name}, Role: $.rhachet{user.details.role}',
|
|
52
|
-
});
|
|
53
|
-
const result = await template.use({ threads });
|
|
54
|
-
expect(result).toBe('User: Jordan, Role: admin');
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
(0, test_fns_1.given)('a template that references a missing variable', () => {
|
|
59
|
-
const threads = {
|
|
60
|
-
user: (0, genThread_1.genThread)({ role: 'user', name: 'Sam' }),
|
|
61
|
-
};
|
|
62
|
-
(0, test_fns_1.when)('calling use() with missing $.rhachet{missing}', () => {
|
|
63
|
-
const template = (0, genTemplate_1.genTemplate)({
|
|
64
|
-
ref,
|
|
65
|
-
getVariables: (input) => ({
|
|
66
|
-
name: input.threads.user.context.name,
|
|
67
|
-
}),
|
|
68
|
-
});
|
|
69
|
-
(0, test_fns_1.then)('it throws a missing variable error', async () => {
|
|
70
|
-
await templateArt.set({
|
|
71
|
-
content: 'Hello $.rhachet{name} and $.rhachet{missing}',
|
|
72
|
-
});
|
|
73
|
-
await expect(template.use({ threads })).rejects.toThrow('missing variable for $.rhachet{missing} in template');
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
(0, test_fns_1.given)('a non-existent template file', () => {
|
|
78
|
-
const badRef = { uri: __dirname + '/.temp/does-not-exist.md' };
|
|
79
|
-
(0, test_fns_1.when)('calling use() on a template with a missing file', () => {
|
|
80
|
-
const threads = {
|
|
81
|
-
ghost: (0, genThread_1.genThread)({ role: 'ghost' }),
|
|
82
|
-
};
|
|
83
|
-
const template = (0, genTemplate_1.genTemplate)({
|
|
84
|
-
ref: badRef,
|
|
85
|
-
getVariables: () => ({
|
|
86
|
-
hello: 'world',
|
|
87
|
-
}),
|
|
88
|
-
});
|
|
89
|
-
(0, test_fns_1.then)('it throws a file missing error', async () => {
|
|
90
|
-
await expect(template.use({ threads })).rejects.toThrow('template artifact does not exist');
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
(0, test_fns_1.given)('an invalid getVariables that references a nonexistent thread role', () => {
|
|
95
|
-
(0, test_fns_1.when)('defining the template', () => {
|
|
96
|
-
(0, test_fns_1.then)('TypeScript throws a compile-time error', () => {
|
|
97
|
-
(0, genTemplate_1.genTemplate)({
|
|
98
|
-
ref,
|
|
99
|
-
getVariables: (input) =>
|
|
100
|
-
// @ts-expect-error - threads.ghost does not exist
|
|
101
|
-
input.threads.ghost.context.name,
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
(0, test_fns_1.given)('an invalid getVariables that returns a non-object', () => {
|
|
107
|
-
(0, test_fns_1.when)('defining the template', () => {
|
|
108
|
-
(0, test_fns_1.then)('TypeScript throws a compile-time error', () => {
|
|
109
|
-
(0, genTemplate_1.genTemplate)({
|
|
110
|
-
ref,
|
|
111
|
-
// @ts-expect-error - return must be object-like
|
|
112
|
-
getVariables: () => 'just a string',
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
//# sourceMappingURL=genTemplate.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"genTemplate.test.js","sourceRoot":"","sources":["../../../src/logic/template/genTemplate.test.ts"],"names":[],"mappings":";;AAAA,+DAA0D;AAC1D,uCAA6C;AAI7C,mDAAgD;AAChD,+CAA4C;AAE5C,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,SAAS,GAAG,gCAAgC,EAAE,CAAC;AAClE,MAAM,WAAW,GAAG,IAAA,yCAAkB,EAAC,GAAG,CAAC,CAAC;AAE5C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAA,gBAAK,EAAC,iDAAiD,EAAE,GAAG,EAAE;QAC5D,MAAM,OAAO,GAAG;YACd,MAAM,EAAE,IAAA,qBAAS,EAAC;gBAChB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;aACxB,CAAC;SACH,CAAC;QAEF,IAAA,eAAI,EAAC,sCAAsC,EAAE,GAAG,EAAE;YAChD,MAAM,QAAQ,GAAG,IAAA,yBAAW,EAAiB;gBAC3C,GAAG;gBACH,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBACxB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI;oBAC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+0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const rhachet_artifact_git_1 = require("rhachet-artifact-git");
|
|
4
|
-
const genThread_1 = require("../thread/genThread");
|
|
5
|
-
const genTemplate_1 = require("./genTemplate");
|
|
6
|
-
test('hydrates a real template using thread-derived variables', async () => {
|
|
7
|
-
const ref = { uri: __dirname + '/.temp/useTemplate.example1.md' };
|
|
8
|
-
await (0, rhachet_artifact_git_1.genArtifactGitFile)(ref).set({
|
|
9
|
-
content: 'Hello $.rhachet{name} — today is $.rhachet{meta.day}',
|
|
10
|
-
});
|
|
11
|
-
const threads = {
|
|
12
|
-
person: (0, genThread_1.genThread)({
|
|
13
|
-
role: 'person',
|
|
14
|
-
name: 'Casey',
|
|
15
|
-
meta: { day: 'Monday' },
|
|
16
|
-
}),
|
|
17
|
-
};
|
|
18
|
-
const template = (0, genTemplate_1.genTemplate)({
|
|
19
|
-
ref,
|
|
20
|
-
getVariables: (input) => ({
|
|
21
|
-
name: input.threads.person.context.name,
|
|
22
|
-
meta: input.threads.person.context.meta,
|
|
23
|
-
}),
|
|
24
|
-
});
|
|
25
|
-
const result = await template.use({ threads });
|
|
26
|
-
expect(result).toBe('Hello Casey — today is Monday');
|
|
27
|
-
});
|
|
28
|
-
//# sourceMappingURL=useTemplate.integration.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTemplate.integration.test.js","sourceRoot":"","sources":["../../../src/logic/template/useTemplate.integration.test.ts"],"names":[],"mappings":";;AAAA,+DAA0D;AAE1D,mDAAgD;AAChD,+CAA4C;AAE5C,IAAI,CAAC,yDAAyD,EAAE,KAAK,IAAI,EAAE;IACzE,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,SAAS,GAAG,gCAAgC,EAAE,CAAC;IAElE,MAAM,IAAA,yCAAkB,EAAC,GAAG,CAAC,CAAC,GAAG,CAAC;QAChC,OAAO,EAAE,sDAAsD;KAChE,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG;QACd,MAAM,EAAE,IAAA,qBAAS,EAAC;YAChB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;SACxB,CAAC;KACH,CAAC;IAEF,MAAM,QAAQ,GAAG,IAAA,yBAAW,EAAC;QAC3B,GAAG;QACH,YAAY,EAAE,CAAC,KAAkC,EAAE,EAAE,CAAC,CAAC;YACrD,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI;YACvC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI;SACxC,CAAC;KACH,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAE/C,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStitch_1 = require("./getStitch");
|
|
4
|
-
describe('getStitch', () => {
|
|
5
|
-
const makeStitch = (input) => input;
|
|
6
|
-
it('returns null for empty array', () => {
|
|
7
|
-
const result = (0, getStitch_1.getStitch)({ from: [] });
|
|
8
|
-
expect(result).toBeNull();
|
|
9
|
-
});
|
|
10
|
-
it('returns the last stitch if order is not set and no filter is provided', () => {
|
|
11
|
-
const stitches = [
|
|
12
|
-
makeStitch({ input: 'a', output: 'first' }),
|
|
13
|
-
makeStitch({ input: 'b', output: 'second' }),
|
|
14
|
-
makeStitch({ input: 'c', output: 'third' }),
|
|
15
|
-
];
|
|
16
|
-
const result = (0, getStitch_1.getStitch)({ from: stitches });
|
|
17
|
-
expect(result?.output).toBe('third');
|
|
18
|
-
});
|
|
19
|
-
it('returns the last matching stitch with DESC order and predicate', () => {
|
|
20
|
-
const stitches = [
|
|
21
|
-
makeStitch({ input: 'x', output: { form: 'A', value: 1 } }),
|
|
22
|
-
makeStitch({ input: 'y', output: { form: 'B', value: 2 } }),
|
|
23
|
-
makeStitch({ input: 'z', output: { form: 'A', value: 3 } }),
|
|
24
|
-
];
|
|
25
|
-
const result = (0, getStitch_1.getStitch)({
|
|
26
|
-
from: stitches,
|
|
27
|
-
order: 'DESC',
|
|
28
|
-
where: (s) => s.output.form === 'A',
|
|
29
|
-
});
|
|
30
|
-
expect(result?.output.form).toBe('A');
|
|
31
|
-
expect(result?.output.value).toBe(3); // latest A
|
|
32
|
-
});
|
|
33
|
-
it('returns null if no stitch matches the predicate', () => {
|
|
34
|
-
const stitches = [
|
|
35
|
-
makeStitch({ input: 'x', output: { form: 'X' } }),
|
|
36
|
-
makeStitch({ input: 'y', output: { form: 'Y' } }),
|
|
37
|
-
];
|
|
38
|
-
const result = (0, getStitch_1.getStitch)({
|
|
39
|
-
from: stitches,
|
|
40
|
-
where: (s) => s.output.form === 'Z',
|
|
41
|
-
});
|
|
42
|
-
expect(result).toBeNull();
|
|
43
|
-
});
|
|
44
|
-
it('raises a type error if the predicate type is incorrect', () => {
|
|
45
|
-
const stitches = [
|
|
46
|
-
makeStitch({ input: 'x', output: { form: 'X' } }),
|
|
47
|
-
makeStitch({ input: 'y', output: { yarn: 'Y' } }),
|
|
48
|
-
];
|
|
49
|
-
const result = (0, getStitch_1.getStitch)({
|
|
50
|
-
from: stitches,
|
|
51
|
-
where: (s) => s.output.form,
|
|
52
|
-
});
|
|
53
|
-
// should resolve the type correctly
|
|
54
|
-
expect(result.output.form);
|
|
55
|
-
// @ts-expect-error: Type 'string' is not assignable to type 'number'.
|
|
56
|
-
const check = result.output.form;
|
|
57
|
-
expect(check);
|
|
58
|
-
// @ts-expect-error: Property 'yarn' does not exist on type 'Stitch<{ form: string; }>'.ts(2339)
|
|
59
|
-
expect(result.output.yarn);
|
|
60
|
-
});
|
|
61
|
-
it('raises a type error if the predicate is not a type guard', () => {
|
|
62
|
-
const stitches = [
|
|
63
|
-
makeStitch({ input: 'a', output: 'foo' }),
|
|
64
|
-
makeStitch({ input: 'b', output: 'bar' }),
|
|
65
|
-
];
|
|
66
|
-
(0, getStitch_1.getStitch)({
|
|
67
|
-
from: stitches,
|
|
68
|
-
// @ts-expect-error - predicate must return a type guard, not boolean
|
|
69
|
-
where: (s) => typeof s.output === 'string',
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
//# sourceMappingURL=getStitch.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getStitch.test.js","sourceRoot":"","sources":["../../../src/logic/thread/getStitch.test.ts"],"names":[],"mappings":";;AACA,2CAAwC;AAExC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,MAAM,UAAU,GAAG,CAAc,KAGhC,EAAa,EAAE,CAAC,KAAkB,CAAC;IAEpC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uEAAuE,EAAE,GAAG,EAAE;QAC/E,MAAM,QAAQ,GAAG;YACf,UAAU,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;YAC3C,UAAU,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;YAC5C,UAAU,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;SAC5C,CAAC;QAEF,MAAM,MAAM,GAAG,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