rhachet 1.1.0 → 1.3.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.
- package/bin/run +4 -0
- package/dist/.test/directory.js.map +1 -0
- package/dist/.test/genContextLogTrail.js.map +1 -0
- package/dist/.test/genContextStitchTrail.js.map +1 -0
- package/dist/.test/getContextOpenAI.js.map +1 -0
- package/dist/.test/stitchers/genStitcherCodeFileRead.js.map +1 -0
- package/dist/.test/stitchers/genStitcherCodeFileWrite.js.map +1 -0
- package/dist/.test/stitchers/genStitcherCodeReviewImagine.js.map +1 -0
- package/dist/.test/stitchers/stitcherCodeDiffImagine.js.map +1 -0
- package/dist/.test/stitchers/stitcherFanoutRandomSum.js.map +1 -0
- package/dist/.test/stitchers/stitcherFanoutSubroutes.js.map +1 -0
- package/dist/{__test_assets__ → .test}/threads/codeArtist.js +1 -1
- package/dist/.test/threads/codeArtist.js.map +1 -0
- package/dist/{__test_assets__ → .test}/threads/codeCritic.js +1 -1
- package/dist/.test/threads/codeCritic.js.map +1 -0
- package/dist/.test/threads/director.js.map +1 -0
- package/dist/_topublish/file-fns/src/getFile.js.map +1 -0
- package/dist/contract/cli/.test/example.echoRegistry.d.ts +2 -0
- package/dist/contract/cli/.test/example.echoRegistry.js +54 -0
- package/dist/contract/cli/.test/example.echoRegistry.js.map +1 -0
- package/dist/contract/cli/invoke.d.ts +12 -0
- package/dist/contract/cli/invoke.integration.test.d.ts +1 -0
- package/dist/contract/cli/invoke.integration.test.js +38 -0
- package/dist/contract/cli/invoke.integration.test.js.map +1 -0
- package/dist/contract/cli/invoke.js +88 -0
- package/dist/contract/cli/invoke.js.map +1 -0
- package/dist/contract/cli/invokeAsk.d.ts +10 -0
- package/dist/contract/cli/invokeAsk.integration.test.d.ts +1 -0
- package/dist/contract/cli/invokeAsk.integration.test.js +41 -0
- package/dist/contract/cli/invokeAsk.integration.test.js.map +1 -0
- package/dist/contract/cli/invokeAsk.js +78 -0
- package/dist/contract/cli/invokeAsk.js.map +1 -0
- package/dist/contract/cli/invokeList.d.ts +10 -0
- package/dist/contract/cli/invokeList.js +48 -0
- package/dist/contract/cli/invokeList.js.map +1 -0
- package/dist/contract/cli/invokeReadme.d.ts +15 -0
- package/dist/contract/cli/invokeReadme.integration.test.d.ts +1 -0
- package/dist/contract/cli/invokeReadme.integration.test.js +62 -0
- package/dist/contract/cli/invokeReadme.integration.test.js.map +1 -0
- package/dist/contract/cli/invokeReadme.js +72 -0
- package/dist/contract/cli/invokeReadme.js.map +1 -0
- package/dist/domain/objects/Role.d.ts +47 -0
- package/dist/domain/objects/Role.js +9 -0
- package/dist/domain/objects/Role.js.map +1 -0
- package/dist/domain/objects/RoleContext.d.ts +46 -0
- package/dist/domain/objects/RoleContext.js +3 -0
- package/dist/domain/objects/RoleContext.js.map +1 -0
- package/dist/domain/objects/RoleRegistry.d.ts +31 -0
- package/dist/domain/objects/RoleRegistry.js +13 -0
- package/dist/domain/objects/RoleRegistry.js.map +1 -0
- package/dist/domain/objects/RoleSkill.d.ts +38 -0
- package/dist/domain/objects/RoleSkill.js +9 -0
- package/dist/domain/objects/RoleSkill.js.map +1 -0
- package/dist/domain/objects/RoleSkillArgGetter.d.ts +137 -0
- package/dist/domain/objects/RoleSkillArgGetter.js +11 -0
- package/dist/domain/objects/RoleSkillArgGetter.js.map +1 -0
- package/dist/domain/objects/RoleTrait.d.ts +34 -0
- package/dist/domain/objects/RoleTrait.js +9 -0
- package/dist/domain/objects/RoleTrait.js.map +1 -0
- package/dist/domain/objects/StitchStep.d.ts +1 -1
- package/dist/domain/objects/StitchStep.js.map +1 -1
- package/dist/domain/objects/Template.d.ts +21 -0
- package/dist/domain/objects/Template.js +8 -0
- package/dist/domain/objects/Template.js.map +1 -0
- package/dist/domain/objects/Template.test.d.ts +1 -0
- package/dist/domain/objects/Template.test.js +48 -0
- package/dist/domain/objects/Template.test.js.map +1 -0
- package/dist/domain/objects/index.d.ts +7 -0
- package/dist/domain/objects/index.js +7 -0
- package/dist/domain/objects/index.js.map +1 -1
- package/dist/logic/invoke/assureFindRole.d.ts +10 -0
- package/dist/logic/invoke/assureFindRole.js +22 -0
- package/dist/logic/invoke/assureFindRole.js.map +1 -0
- package/dist/logic/invoke/assureUniqueRoles.d.ts +5 -0
- package/dist/logic/invoke/assureUniqueRoles.js +19 -0
- package/dist/logic/invoke/assureUniqueRoles.js.map +1 -0
- package/dist/logic/invoke/getSkillContext.d.ts +17 -0
- package/dist/logic/invoke/getSkillContext.js +44 -0
- package/dist/logic/invoke/getSkillContext.js.map +1 -0
- package/dist/logic/invoke/getSkillContext.test.d.ts +1 -0
- package/dist/logic/invoke/getSkillContext.test.js +85 -0
- package/dist/logic/invoke/getSkillContext.test.js.map +1 -0
- package/dist/logic/invoke/getSkillThread.test.d.ts +1 -0
- package/dist/logic/invoke/getSkillThread.test.js +115 -0
- package/dist/logic/invoke/getSkillThread.test.js.map +1 -0
- package/dist/logic/invoke/getSkillThreads.d.ts +16 -0
- package/dist/logic/invoke/getSkillThreads.js +46 -0
- package/dist/logic/invoke/getSkillThreads.js.map +1 -0
- package/dist/logic/role/addRoleTraits.d.ts +18 -0
- package/dist/logic/role/addRoleTraits.js +33 -0
- package/dist/logic/role/addRoleTraits.js.map +1 -0
- package/dist/logic/role/addRoleTraits.test.d.ts +1 -0
- package/dist/logic/role/addRoleTraits.test.js +93 -0
- package/dist/logic/role/addRoleTraits.test.js.map +1 -0
- package/dist/logic/role/enrollThread.d.ts +16 -0
- package/dist/logic/role/enrollThread.integration.test.d.ts +1 -0
- package/dist/logic/role/enrollThread.integration.test.js +79 -0
- package/dist/logic/role/enrollThread.integration.test.js.map +1 -0
- package/dist/logic/role/enrollThread.js +36 -0
- package/dist/logic/role/enrollThread.js.map +1 -0
- package/dist/logic/stitch/adapters/imagineViaOpenAI.js.map +1 -1
- package/dist/logic/stitch/enstitch.test.js +2 -2
- package/dist/logic/stitch/enstitch.test.js.map +1 -1
- package/dist/logic/stitch/invokeImagineStitcher.integration.test.js +5 -3
- package/dist/logic/stitch/invokeImagineStitcher.integration.test.js.map +1 -1
- package/dist/logic/stitch/invokeImagineStitcher.js +1 -1
- package/dist/logic/stitch/invokeImagineStitcher.js.map +1 -1
- package/dist/logic/template/genStepImagineViaTemplate.d.ts +22 -0
- package/dist/logic/template/genStepImagineViaTemplate.js +22 -0
- package/dist/logic/template/genStepImagineViaTemplate.js.map +1 -0
- package/dist/logic/template/genStepImagineViaTemplate.test.d.ts +1 -0
- package/dist/logic/template/genStepImagineViaTemplate.test.js +126 -0
- package/dist/logic/template/genStepImagineViaTemplate.test.js.map +1 -0
- package/dist/logic/template/genTemplate.d.ts +16 -0
- package/dist/logic/template/genTemplate.js +21 -0
- package/dist/logic/template/genTemplate.js.map +1 -0
- package/dist/logic/template/genTemplate.test.d.ts +1 -0
- package/dist/logic/template/genTemplate.test.js +118 -0
- package/dist/logic/template/genTemplate.test.js.map +1 -0
- package/dist/logic/template/getTemplateValFromArtifacts.d.ts +9 -0
- package/dist/logic/template/getTemplateValFromArtifacts.js +27 -0
- package/dist/logic/template/getTemplateValFromArtifacts.js.map +1 -0
- package/dist/logic/template/getTemplateVarsFromInheritance.d.ts +22 -0
- package/dist/logic/template/getTemplateVarsFromInheritance.js +15 -0
- package/dist/logic/template/getTemplateVarsFromInheritance.js.map +1 -0
- package/dist/logic/template/useTemplate.d.ts +10 -0
- package/dist/logic/template/useTemplate.integration.test.d.ts +1 -0
- package/dist/logic/template/useTemplate.integration.test.js +28 -0
- package/dist/logic/template/useTemplate.integration.test.js.map +1 -0
- package/dist/logic/template/useTemplate.js +26 -0
- package/dist/logic/template/useTemplate.js.map +1 -0
- package/dist/logic/thread/getStitch.d.ts +11 -0
- package/dist/logic/thread/getStitch.js +18 -0
- package/dist/logic/thread/getStitch.js.map +1 -0
- package/dist/logic/thread/getStitch.test.d.ts +1 -0
- package/dist/logic/thread/getStitch.test.js +73 -0
- package/dist/logic/thread/getStitch.test.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.js +2 -2
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.js.map +1 -1
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.js +2 -2
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.js.map +1 -1
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.js +2 -2
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.js.map +1 -1
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.js +2 -2
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.js.map +1 -1
- package/dist/logic/weave/compose/genStitchCycle.test.js +117 -2
- package/dist/logic/weave/compose/genStitchCycle.test.js.map +1 -1
- package/dist/logic/weave/compose/genStitchFanout.test.js +2 -2
- package/dist/logic/weave/compose/genStitchFanout.test.js.map +1 -1
- package/dist/logic/weave/enweaveOneChoice.test.js +2 -2
- package/dist/logic/weave/enweaveOneChoice.test.js.map +1 -1
- package/dist/logic/weave/enweaveOneCycle.test.js +2 -2
- package/dist/logic/weave/enweaveOneCycle.test.js.map +1 -1
- package/dist/logic/weave/enweaveOneFanout.integration.test.js +6 -6
- package/dist/logic/weave/enweaveOneFanout.integration.test.js.map +1 -1
- package/dist/logic/weave/enweaveOneRoute.integration.test.js +6 -6
- package/dist/logic/weave/enweaveOneRoute.integration.test.js.map +1 -1
- package/dist/logic/weave/enweaveOneStitcher.integration.test.js +10 -10
- package/dist/logic/weave/enweaveOneStitcher.integration.test.js.map +1 -1
- package/package.json +14 -4
- package/readme.md +32 -33
- package/dist/__nonpublished_modules__/file-fns/src/getFile.js.map +0 -1
- package/dist/__test_assets__/directory.js.map +0 -1
- package/dist/__test_assets__/genContextLogTrail.js.map +0 -1
- package/dist/__test_assets__/genContextStitchTrail.js.map +0 -1
- package/dist/__test_assets__/getContextOpenAI.js.map +0 -1
- package/dist/__test_assets__/stitchers/genStitcherCodeFileRead.js.map +0 -1
- package/dist/__test_assets__/stitchers/genStitcherCodeFileWrite.js.map +0 -1
- package/dist/__test_assets__/stitchers/genStitcherCodeReviewImagine.js.map +0 -1
- package/dist/__test_assets__/stitchers/stitcherCodeDiffImagine.js.map +0 -1
- package/dist/__test_assets__/stitchers/stitcherFanoutRandomSum.js.map +0 -1
- package/dist/__test_assets__/stitchers/stitcherFanoutSubroutes.js.map +0 -1
- package/dist/__test_assets__/threads/codeArtist.js.map +0 -1
- package/dist/__test_assets__/threads/codeCritic.js.map +0 -1
- package/dist/__test_assets__/threads/director.js.map +0 -1
- package/dist/logic/thread/enroleThread.d.ts +0 -4
- package/dist/logic/thread/enroleThread.js +0 -6
- package/dist/logic/thread/enroleThread.js.map +0 -1
- /package/dist/{__test_assets__ → .test}/directory.d.ts +0 -0
- /package/dist/{__test_assets__ → .test}/directory.js +0 -0
- /package/dist/{__test_assets__ → .test}/genContextLogTrail.d.ts +0 -0
- /package/dist/{__test_assets__ → .test}/genContextLogTrail.js +0 -0
- /package/dist/{__test_assets__ → .test}/genContextStitchTrail.d.ts +0 -0
- /package/dist/{__test_assets__ → .test}/genContextStitchTrail.js +0 -0
- /package/dist/{__test_assets__ → .test}/getContextOpenAI.d.ts +0 -0
- /package/dist/{__test_assets__ → .test}/getContextOpenAI.js +0 -0
- /package/dist/{__test_assets__ → .test}/stitchers/genStitcherCodeFileRead.d.ts +0 -0
- /package/dist/{__test_assets__ → .test}/stitchers/genStitcherCodeFileRead.js +0 -0
- /package/dist/{__test_assets__ → .test}/stitchers/genStitcherCodeFileWrite.d.ts +0 -0
- /package/dist/{__test_assets__ → .test}/stitchers/genStitcherCodeFileWrite.js +0 -0
- /package/dist/{__test_assets__ → .test}/stitchers/genStitcherCodeReviewImagine.d.ts +0 -0
- /package/dist/{__test_assets__ → .test}/stitchers/genStitcherCodeReviewImagine.js +0 -0
- /package/dist/{__test_assets__ → .test}/stitchers/stitcherCodeDiffImagine.d.ts +0 -0
- /package/dist/{__test_assets__ → .test}/stitchers/stitcherCodeDiffImagine.js +0 -0
- /package/dist/{__test_assets__ → .test}/stitchers/stitcherFanoutRandomSum.d.ts +0 -0
- /package/dist/{__test_assets__ → .test}/stitchers/stitcherFanoutRandomSum.js +0 -0
- /package/dist/{__test_assets__ → .test}/stitchers/stitcherFanoutSubroutes.d.ts +0 -0
- /package/dist/{__test_assets__ → .test}/stitchers/stitcherFanoutSubroutes.js +0 -0
- /package/dist/{__test_assets__ → .test}/threads/codeArtist.d.ts +0 -0
- /package/dist/{__test_assets__ → .test}/threads/codeCritic.d.ts +0 -0
- /package/dist/{__test_assets__ → .test}/threads/director.d.ts +0 -0
- /package/dist/{__test_assets__ → .test}/threads/director.js +0 -0
- /package/dist/{__nonpublished_modules__ → _topublish}/file-fns/src/getFile.d.ts +0 -0
- /package/dist/{__nonpublished_modules__ → _topublish}/file-fns/src/getFile.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/objects/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,iDAA+B;AAC/B,gDAA8B;AAC9B,6CAA2B;AAC3B,iDAA+B;AAC/B,gDAA8B;AAC9B,mDAAiC;AACjC,+CAA6B;AAC7B,gDAA8B;AAC9B,2CAAyB;AACzB,4CAA0B;AAC1B,2BAA2B;AAC3B,4BAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/objects/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,iDAA+B;AAC/B,gDAA8B;AAC9B,6CAA2B;AAC3B,iDAA+B;AAC/B,gDAA8B;AAC9B,mDAAiC;AACjC,+CAA6B;AAC7B,gDAA8B;AAC9B,2CAAyB;AACzB,4CAA0B;AAC1B,2BAA2B;AAC3B,4BAA4B;AAE5B,yCAAuB;AACvB,gDAA8B;AAC9B,iDAA+B;AAC/B,8CAA4B;AAC5B,uDAAqC;AACrC,8CAA4B;AAE5B,6CAA2B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Role } from '../../domain/objects/Role';
|
|
2
|
+
import { RoleRegistry } from '../../domain/objects/RoleRegistry';
|
|
3
|
+
/**
|
|
4
|
+
* .what = finds the first matching role across registries
|
|
5
|
+
* .why = ensures there is exactly one role match; fails if ambiguous or missing
|
|
6
|
+
*/
|
|
7
|
+
export declare const assureFindRole: ({ registries, slug, }: {
|
|
8
|
+
registries: RoleRegistry[];
|
|
9
|
+
slug: string;
|
|
10
|
+
}) => Role;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assureFindRole = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
/**
|
|
6
|
+
* .what = finds the first matching role across registries
|
|
7
|
+
* .why = ensures there is exactly one role match; fails if ambiguous or missing
|
|
8
|
+
*/
|
|
9
|
+
const assureFindRole = ({ registries, slug, }) => {
|
|
10
|
+
const matches = registries
|
|
11
|
+
.flatMap((r) => r.roles)
|
|
12
|
+
.filter((r) => r.slug === slug);
|
|
13
|
+
if (matches.length === 0)
|
|
14
|
+
helpful_errors_1.BadRequestError.throw(`no role named "${slug}" found in any registry`, {
|
|
15
|
+
slug,
|
|
16
|
+
});
|
|
17
|
+
if (matches.length > 1)
|
|
18
|
+
helpful_errors_1.BadRequestError.throw(`multiple roles named "${slug}" found across registries`, { slug });
|
|
19
|
+
return matches[0];
|
|
20
|
+
};
|
|
21
|
+
exports.assureFindRole = assureFindRole;
|
|
22
|
+
//# sourceMappingURL=assureFindRole.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assureFindRole.js","sourceRoot":"","sources":["../../../src/logic/invoke/assureFindRole.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAKjD;;;GAGG;AACI,MAAM,cAAc,GAAG,CAAC,EAC7B,UAAU,EACV,IAAI,GAIL,EAAQ,EAAE;IACT,MAAM,OAAO,GAAG,UAAU;SACvB,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;SACvB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAClC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QACtB,gCAAe,CAAC,KAAK,CAAC,kBAAkB,IAAI,yBAAyB,EAAE;YACrE,IAAI;SACL,CAAC,CAAC;IACL,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QACpB,gCAAe,CAAC,KAAK,CACnB,yBAAyB,IAAI,2BAA2B,EACxD,EAAE,IAAI,EAAE,CACT,CAAC;IACJ,OAAO,OAAO,CAAC,CAAC,CAAE,CAAC;AACrB,CAAC,CAAC;AApBW,QAAA,cAAc,kBAoBzB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assureUniqueRoles = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = ensure we fail fast upon duplicate role.slugs across registries
|
|
6
|
+
*/
|
|
7
|
+
const assureUniqueRoles = (registries) => {
|
|
8
|
+
const seen = new Map(); // slug → registry.slug
|
|
9
|
+
for (const registry of registries) {
|
|
10
|
+
for (const role of registry.roles) {
|
|
11
|
+
if (seen.has(role.slug)) {
|
|
12
|
+
throw new Error(`❌ duplicate role.slug "${role.slug}" found in registries: "${seen.get(role.slug)}" and "${registry.slug}"`);
|
|
13
|
+
}
|
|
14
|
+
seen.set(role.slug, registry.slug);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.assureUniqueRoles = assureUniqueRoles;
|
|
19
|
+
//# sourceMappingURL=assureUniqueRoles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assureUniqueRoles.js","sourceRoot":"","sources":["../../../src/logic/invoke/assureUniqueRoles.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACI,MAAM,iBAAiB,GAAG,CAAC,UAA0B,EAAQ,EAAE;IACpE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC,CAAC,uBAAuB;IAC/D,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;QAClC,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YAClC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CACb,0BACE,IAAI,CAAC,IACP,2BAA2B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAC5C,QAAQ,CAAC,IACX,GAAG,CACJ,CAAC;YACJ,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAhBW,QAAA,iBAAiB,qBAgB5B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PickOne } from 'type-fns';
|
|
2
|
+
import { RoleSkillContextGetter } from '../../domain/objects/RoleSkillArgGetter';
|
|
3
|
+
/**
|
|
4
|
+
* .what = hydrates skill context using either passin or lookup mode
|
|
5
|
+
* .why =
|
|
6
|
+
* - supports flexible skill execution via CLI, tests, or runtime composition
|
|
7
|
+
* - ensures all required env inputs are present and valid
|
|
8
|
+
*/
|
|
9
|
+
export declare const getSkillContext: <TOutput extends import("simple-log-methods").ContextLogTrail & import("../stitch/withStitchTrail").ContextStitchTrail, TVars extends Record<string, any>>(input: {
|
|
10
|
+
getter: RoleSkillContextGetter<TOutput, TVars>;
|
|
11
|
+
from: PickOne<{
|
|
12
|
+
passin: TVars;
|
|
13
|
+
lookup: {
|
|
14
|
+
env: Record<string, string | undefined>;
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
17
|
+
}) => Promise<TOutput>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSkillContext = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
/**
|
|
6
|
+
* .what = hydrates skill context using either passin or lookup mode
|
|
7
|
+
* .why =
|
|
8
|
+
* - supports flexible skill execution via CLI, tests, or runtime composition
|
|
9
|
+
* - ensures all required env inputs are present and valid
|
|
10
|
+
*/
|
|
11
|
+
const getSkillContext = async (input) => {
|
|
12
|
+
const { getter, from } = input;
|
|
13
|
+
// support passin mode: directly provided context vars
|
|
14
|
+
if ('passin' in from) {
|
|
15
|
+
if (!getter.assess(from.passin)) {
|
|
16
|
+
helpful_errors_1.BadRequestError.throw('from.passin was assessed to have incorrect shape', {
|
|
17
|
+
from,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return await getter.instantiate(from.passin);
|
|
21
|
+
}
|
|
22
|
+
// support lookup mode: pull from env vars
|
|
23
|
+
if ('lookup' in from) {
|
|
24
|
+
const env = from.lookup.env;
|
|
25
|
+
const collected = {};
|
|
26
|
+
for (const [key, spec] of Object.entries(getter.lookup)) {
|
|
27
|
+
const val = env[spec.envar];
|
|
28
|
+
if (val === undefined) {
|
|
29
|
+
helpful_errors_1.BadRequestError.throw(`missing required env var ${spec.envar}`, {
|
|
30
|
+
key,
|
|
31
|
+
spec,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
collected[key] = val;
|
|
35
|
+
}
|
|
36
|
+
if (!getter.assess(collected))
|
|
37
|
+
helpful_errors_1.UnexpectedCodePathError.throw('from.lookup -> collected was assessed to have incorrect shape. this should not be possible', { from: { env: true }, collected: Object.keys(collected) });
|
|
38
|
+
return await getter.instantiate(collected);
|
|
39
|
+
}
|
|
40
|
+
// 🛑 should be unreachable (guard for future extension)
|
|
41
|
+
throw new helpful_errors_1.UnexpectedCodePathError('unsupported context.from', { input });
|
|
42
|
+
};
|
|
43
|
+
exports.getSkillContext = getSkillContext;
|
|
44
|
+
//# sourceMappingURL=getSkillContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSkillContext.js","sourceRoot":"","sources":["../../../src/logic/invoke/getSkillContext.ts"],"names":[],"mappings":";;;AAAA,mDAA0E;AAM1E;;;;;GAKG;AACI,MAAM,eAAe,GAAG,KAAK,EAGlC,KAMD,EAAoB,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAE/B,sDAAsD;IACtD,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAChC,gCAAe,CAAC,KAAK,CACnB,kDAAkD,EAClD;gBACE,IAAI;aACL,CACF,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,0CAA0C;IAC1C,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;QAC5B,MAAM,SAAS,GAA2B,EAAE,CAAC;QAE7C,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACxD,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5B,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtB,gCAAe,CAAC,KAAK,CAAC,4BAA4B,IAAI,CAAC,KAAK,EAAE,EAAE;oBAC9D,GAAG;oBACH,IAAI;iBACL,CAAC,CAAC;YACL,CAAC;YACD,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;QACvB,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;YAC3B,wCAAuB,CAAC,KAAK,CAC3B,4FAA4F,EAC5F,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAC3D,CAAC;QAEJ,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED,wDAAwD;IACxD,MAAM,IAAI,wCAAuB,CAAC,0BAA0B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAC3E,CAAC,CAAC;AApDW,QAAA,eAAe,mBAoD1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
4
|
+
const test_fns_1 = require("test-fns");
|
|
5
|
+
const objects_1 = require("../../domain/objects");
|
|
6
|
+
const getSkillContext_1 = require("./getSkillContext");
|
|
7
|
+
const getterExample = objects_1.RoleSkillContextGetter.build({
|
|
8
|
+
lookup: {
|
|
9
|
+
openaiApiKey: {
|
|
10
|
+
source: 'process.env',
|
|
11
|
+
desc: 'your OpenAI key',
|
|
12
|
+
envar: 'OPENAI_API_KEY',
|
|
13
|
+
type: 'string',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
assess: (input) => typeof input?.openaiApiKey === 'string',
|
|
17
|
+
instantiate: (input) => ({
|
|
18
|
+
key: input.openaiApiKey,
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
describe('getSkillContext', () => {
|
|
22
|
+
(0, test_fns_1.given)('a valid context getter requiring OPENAI_API_KEY', () => {
|
|
23
|
+
const getter = getterExample.clone();
|
|
24
|
+
(0, test_fns_1.when)('called with passin: { openaiApiKey: "sk-abc" }', () => {
|
|
25
|
+
(0, test_fns_1.then)('it should return the expected context', async () => {
|
|
26
|
+
const result = await (0, getSkillContext_1.getSkillContext)({
|
|
27
|
+
getter,
|
|
28
|
+
from: { passin: { openaiApiKey: 'sk-abc' } },
|
|
29
|
+
});
|
|
30
|
+
expect(result).toEqual({ key: 'sk-abc' });
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
(0, test_fns_1.when)('called with passin: { wrongKey: "oops" }', () => {
|
|
34
|
+
(0, test_fns_1.then)('it should throw BadRequestError', async () => {
|
|
35
|
+
const error = await (0, test_fns_1.getError)(async () => (0, getSkillContext_1.getSkillContext)({
|
|
36
|
+
getter,
|
|
37
|
+
from: { passin: { wrongKey: 'oops' } },
|
|
38
|
+
}));
|
|
39
|
+
expect(error).toBeInstanceOf(helpful_errors_1.BadRequestError);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
(0, test_fns_1.when)('called with env: { OPENAI_API_KEY: "sk-env" }', () => {
|
|
43
|
+
(0, test_fns_1.then)('it should return the expected context', async () => {
|
|
44
|
+
const result = await (0, getSkillContext_1.getSkillContext)({
|
|
45
|
+
getter,
|
|
46
|
+
from: { lookup: { env: { OPENAI_API_KEY: 'sk-env' } } },
|
|
47
|
+
});
|
|
48
|
+
expect(result).toEqual({ key: 'sk-env' });
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
(0, test_fns_1.when)('called with env: {} (missing key)', () => {
|
|
52
|
+
(0, test_fns_1.then)('it should throw BadRequestError', async () => {
|
|
53
|
+
const error = await (0, test_fns_1.getError)(async () => (0, getSkillContext_1.getSkillContext)({
|
|
54
|
+
getter,
|
|
55
|
+
from: { lookup: { env: {} } },
|
|
56
|
+
}));
|
|
57
|
+
expect(error).toBeInstanceOf(helpful_errors_1.BadRequestError);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
(0, test_fns_1.given)('a rejecting getter that fails all assess checks', () => {
|
|
62
|
+
const getter = getterExample.clone({
|
|
63
|
+
assess: (() => false),
|
|
64
|
+
});
|
|
65
|
+
(0, test_fns_1.when)('called with env: { OPENAI_API_KEY: "sk-reject" }', () => {
|
|
66
|
+
(0, test_fns_1.then)('it should throw UnexpectedCodePathError', async () => {
|
|
67
|
+
const error = await (0, test_fns_1.getError)(async () => (0, getSkillContext_1.getSkillContext)({
|
|
68
|
+
getter,
|
|
69
|
+
from: { lookup: { env: { OPENAI_API_KEY: 'sk-reject' } } },
|
|
70
|
+
}));
|
|
71
|
+
expect(error).toBeInstanceOf(helpful_errors_1.UnexpectedCodePathError);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
(0, test_fns_1.when)('called with passin: { openaiApiKey: "sk-reject" }', () => {
|
|
75
|
+
(0, test_fns_1.then)('it should throw BadRequestError', async () => {
|
|
76
|
+
const error = await (0, test_fns_1.getError)(async () => (0, getSkillContext_1.getSkillContext)({
|
|
77
|
+
getter,
|
|
78
|
+
from: { passin: { openaiApiKey: 'sk-reject' } },
|
|
79
|
+
}));
|
|
80
|
+
expect(error).toBeInstanceOf(helpful_errors_1.BadRequestError);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=getSkillContext.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSkillContext.test.js","sourceRoot":"","sources":["../../../src/logic/invoke/getSkillContext.test.ts"],"names":[],"mappings":";;AAAA,mDAA0E;AAC1E,uCAAuD;AAEvD,kDAAyE;AACzE,uDAAoD;AAEpD,MAAM,aAAa,GAAG,gCAAsB,CAAC,KAAK,CAKhD;IACA,MAAM,EAAE;QACN,YAAY,EAAE;YACZ,MAAM,EAAE,aAAa;YACrB,IAAI,EAAE,iBAAiB;YACvB,KAAK,EAAE,gBAAgB;YACvB,IAAI,EAAE,QAAQ;SACf;KACF;IACD,MAAM,EAAE,CAAC,KAAU,E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EAAE,EAAE,GAAG,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,EAAE,EAAE;iBAC3D,CAAC,CACH,CAAC;gBAEF,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,wCAAuB,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAA,eAAI,EAAC,mDAAmD,EAAE,GAAG,EAAE;YAC7D,IAAA,eAAI,EAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;gBACjD,MAAM,KAAK,GAAG,MAAM,IAAA,mBAAQ,EAAC,KAAK,IAAI,EAAE,CACtC,IAAA,iCAAe,EAAC;oBACd,MAAM;oBACN,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE;iBAChD,CAAC,CACH,CAAC;gBAEF,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,gCAAe,CAAC,CAAC;YAChD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
4
|
+
const test_fns_1 = require("test-fns");
|
|
5
|
+
const RoleSkillArgGetter_1 = require("../../domain/objects/RoleSkillArgGetter");
|
|
6
|
+
const genThread_1 = require("../thread/genThread");
|
|
7
|
+
const getSkillThreads_1 = require("./getSkillThreads");
|
|
8
|
+
const getterExample = RoleSkillArgGetter_1.RoleSkillThreadsGetter.build({
|
|
9
|
+
lookup: {
|
|
10
|
+
target: {
|
|
11
|
+
source: 'process.argv',
|
|
12
|
+
desc: 'target file or dir',
|
|
13
|
+
char: 't',
|
|
14
|
+
type: 'string',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
assess: (input) => typeof input?.target === 'string' && typeof input?.ask === 'string',
|
|
18
|
+
instantiate: (input) => ({
|
|
19
|
+
caller: (0, genThread_1.genThread)({ role: 'caller', target: input.target }),
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
describe('getSkillThreads', () => {
|
|
23
|
+
(0, test_fns_1.given)('a valid threads getter for { target, ask }', () => {
|
|
24
|
+
const getter = getterExample.clone();
|
|
25
|
+
(0, test_fns_1.when)('called with passin: { target: "src/index.ts", ask: "describe" }', () => {
|
|
26
|
+
(0, test_fns_1.then)('it should return the expected caller thread', async () => {
|
|
27
|
+
const result = await (0, getSkillThreads_1.getSkillThreads)({
|
|
28
|
+
getter,
|
|
29
|
+
from: { passin: { target: 'src/index.ts', ask: 'describe' } },
|
|
30
|
+
});
|
|
31
|
+
expect(result).toEqual({
|
|
32
|
+
caller: (0, genThread_1.genThread)({ role: 'caller', target: 'src/index.ts' }),
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
(0, test_fns_1.when)('called with passin: { bad: true }', () => {
|
|
37
|
+
(0, test_fns_1.then)('it should throw BadRequestError', async () => {
|
|
38
|
+
const error = await (0, test_fns_1.getError)(() => (0, getSkillThreads_1.getSkillThreads)({
|
|
39
|
+
getter,
|
|
40
|
+
from: { passin: { bad: true } },
|
|
41
|
+
}));
|
|
42
|
+
expect(error).toBeInstanceOf(helpful_errors_1.BadRequestError);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
(0, test_fns_1.when)('called with argv: { target: "src/main.ts", ask: "go now" }', () => {
|
|
46
|
+
(0, test_fns_1.then)('it should return the expected caller thread', async () => {
|
|
47
|
+
const result = await (0, getSkillThreads_1.getSkillThreads)({
|
|
48
|
+
getter,
|
|
49
|
+
from: { lookup: { argv: { target: 'src/main.ts', ask: 'go now' } } },
|
|
50
|
+
});
|
|
51
|
+
expect(result).toEqual({
|
|
52
|
+
caller: (0, genThread_1.genThread)({ role: 'caller', target: 'src/main.ts' }),
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
(0, test_fns_1.when)('called with argv: { t: "src/main.ts", ask: "run this" }', () => {
|
|
57
|
+
(0, test_fns_1.then)('it should return the expected caller thread', async () => {
|
|
58
|
+
const result = await (0, getSkillThreads_1.getSkillThreads)({
|
|
59
|
+
getter,
|
|
60
|
+
from: { lookup: { argv: { t: 'src/main.ts', ask: 'run this' } } },
|
|
61
|
+
});
|
|
62
|
+
expect(result).toEqual({
|
|
63
|
+
caller: (0, genThread_1.genThread)({ role: 'caller', target: 'src/main.ts' }),
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
(0, test_fns_1.when)('called with argv: { ask: "missing target" }', () => {
|
|
68
|
+
(0, test_fns_1.then)('it should throw BadRequestError for missing target', async () => {
|
|
69
|
+
const error = await (0, test_fns_1.getError)(() => (0, getSkillThreads_1.getSkillThreads)({
|
|
70
|
+
getter,
|
|
71
|
+
from: { lookup: { argv: { ask: 'missing target' } } },
|
|
72
|
+
}));
|
|
73
|
+
expect(error).toBeInstanceOf(helpful_errors_1.BadRequestError);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
(0, test_fns_1.when)('called with argv: { target: "src/x.ts" } (missing ask)', () => {
|
|
77
|
+
(0, test_fns_1.then)('it should throw BadRequestError for missing ask', async () => {
|
|
78
|
+
const error = await (0, test_fns_1.getError)(() => (0, getSkillThreads_1.getSkillThreads)({
|
|
79
|
+
getter,
|
|
80
|
+
from: { lookup: { argv: { target: 'src/x.ts' } } },
|
|
81
|
+
}));
|
|
82
|
+
expect(error).toBeInstanceOf(helpful_errors_1.BadRequestError);
|
|
83
|
+
expect(error.message).toMatch(/missing.*ask/i);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
(0, test_fns_1.given)('a rejecting getter that fails all assess checks', () => {
|
|
88
|
+
const getter = getterExample.clone({
|
|
89
|
+
assess: (() => false),
|
|
90
|
+
});
|
|
91
|
+
(0, test_fns_1.when)('called with argv: { target: "src/any.ts", ask: "still fails" }', () => {
|
|
92
|
+
(0, test_fns_1.then)('it should throw UnexpectedCodePathError', async () => {
|
|
93
|
+
const error = await (0, test_fns_1.getError)(() => (0, getSkillThreads_1.getSkillThreads)({
|
|
94
|
+
getter,
|
|
95
|
+
from: {
|
|
96
|
+
lookup: {
|
|
97
|
+
argv: { target: 'src/any.ts', ask: 'still fails' },
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
}));
|
|
101
|
+
expect(error).toBeInstanceOf(helpful_errors_1.UnexpectedCodePathError);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
(0, test_fns_1.when)('called with passin: { target: "src/any.ts", ask: "bad input" }', () => {
|
|
105
|
+
(0, test_fns_1.then)('it should throw BadRequestError', async () => {
|
|
106
|
+
const error = await (0, test_fns_1.getError)(() => (0, getSkillThreads_1.getSkillThreads)({
|
|
107
|
+
getter,
|
|
108
|
+
from: { passin: { target: 'src/any.ts', ask: 'bad input' } },
|
|
109
|
+
}));
|
|
110
|
+
expect(error).toBeInstanceOf(helpful_errors_1.BadRequestError);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
//# sourceMappingURL=getSkillThread.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSkillThread.test.js","sourceRoot":"","sources":["../../../src/logic/invoke/getSkillThread.test.ts"],"names":[],"mappings":";;AAAA,mDAA0E;AAC1E,uCAAuD;AAGvD,gFAAiF;AACjF,mDAAgD;AAChD,uDAAoD;AAEpD,MAAM,aAAa,GAAG,2CAAsB,CAAC,KAAK,CAKhD;IACA,MAAM,EAAE;QACN,MAAM,EAAE;YACN,MAAM,EAAE,cAAc;YACtB,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,QAAQ;SACf;KACF;IACD,MAAM,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K,IAAI,EAAE;gBACzD,MAAM,KAAK,GAAG,MAAM,IAAA,mBAAQ,EAAC,GAAG,EAAE,CAChC,IAAA,iCAAe,EAAC;oBACd,MAAM;oBACN,IAAI,EAAE;wBACJ,MAAM,EAAE;4BACN,IAAI,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,aAAa,EAAE;yBACnD;qBACF;iBACF,CAAC,CACH,CAAC;gBACF,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,wCAAuB,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACL,CAAC,CACF,CAAC;QAEF,IAAA,eAAI,EACF,gEAAgE,EAChE,GAAG,EAAE;YACH,IAAA,eAAI,EAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;gBACjD,MAAM,KAAK,GAAG,MAAM,IAAA,mBAAQ,EAAC,GAAG,EAAE,CAChC,IAAA,iCAAe,EAAC;oBACd,MAAM;oBACN,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE;iBAC7D,CAAC,CACH,CAAC;gBACF,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,gCAAe,CAAC,CAAC;YAChD,CAAC,CAAC,CAAC;QACL,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PickOne } from 'type-fns';
|
|
2
|
+
import { Threads } from '../../domain/objects';
|
|
3
|
+
import { RoleSkillThreadsGetter } from '../../domain/objects/RoleSkillArgGetter';
|
|
4
|
+
/**
|
|
5
|
+
* .what = hydrates skill threads using either passin or lookup mode
|
|
6
|
+
* .why = enables flexible runtime use from CLI or direct invocation
|
|
7
|
+
*/
|
|
8
|
+
export declare const getSkillThreads: <TOutput extends Threads<any>, TVars extends Record<string, any>>(input: {
|
|
9
|
+
getter: RoleSkillThreadsGetter<TOutput, TVars>;
|
|
10
|
+
from: PickOne<{
|
|
11
|
+
passin: TVars;
|
|
12
|
+
lookup: {
|
|
13
|
+
argv: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
}>;
|
|
16
|
+
}) => Promise<TOutput>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSkillThreads = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
/**
|
|
6
|
+
* .what = hydrates skill threads using either passin or lookup mode
|
|
7
|
+
* .why = enables flexible runtime use from CLI or direct invocation
|
|
8
|
+
*/
|
|
9
|
+
const getSkillThreads = async (input) => {
|
|
10
|
+
const { getter, from } = input;
|
|
11
|
+
// support passin mode
|
|
12
|
+
if ('passin' in from) {
|
|
13
|
+
if (!getter.assess(from.passin))
|
|
14
|
+
helpful_errors_1.BadRequestError.throw('from.passin was assessed to have incorrect shape', { from });
|
|
15
|
+
return await getter.instantiate(from.passin);
|
|
16
|
+
}
|
|
17
|
+
// support lookup mode
|
|
18
|
+
if ('lookup' in from) {
|
|
19
|
+
const argv = from.lookup.argv;
|
|
20
|
+
// verify that ask was provided; its always required by default
|
|
21
|
+
const ask = argv.ask;
|
|
22
|
+
if (!ask)
|
|
23
|
+
helpful_errors_1.BadRequestError.throw('missing required argument: --ask', { argv });
|
|
24
|
+
// instantiate the collected input set
|
|
25
|
+
const collected = { ask };
|
|
26
|
+
// grab all the requested ones
|
|
27
|
+
for (const [key, spec] of Object.entries(getter.lookup)) {
|
|
28
|
+
const val = argv[key] ?? (spec.char ? argv[spec.char] : undefined);
|
|
29
|
+
if (val === undefined) {
|
|
30
|
+
helpful_errors_1.BadRequestError.throw(`missing required arg --${key} (-${spec.char})`, {
|
|
31
|
+
key,
|
|
32
|
+
spec,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
collected[key] = val;
|
|
36
|
+
}
|
|
37
|
+
// verify they look right
|
|
38
|
+
if (!getter.assess(collected))
|
|
39
|
+
helpful_errors_1.UnexpectedCodePathError.throw('from.lookup -> collected was assessed to have incorrect shape. this should not be possible', { from, collected });
|
|
40
|
+
// instantiate
|
|
41
|
+
return await getter.instantiate(collected);
|
|
42
|
+
}
|
|
43
|
+
throw new helpful_errors_1.UnexpectedCodePathError('unsupported lookup.from', { input });
|
|
44
|
+
};
|
|
45
|
+
exports.getSkillThreads = getSkillThreads;
|
|
46
|
+
//# sourceMappingURL=getSkillThreads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSkillThreads.js","sourceRoot":"","sources":["../../../src/logic/invoke/getSkillThreads.ts"],"names":[],"mappings":";;;AAAA,mDAA0E;AAM1E;;;GAGG;AACI,MAAM,eAAe,GAAG,KAAK,EAGlC,KAMD,EAAoB,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAE/B,sBAAsB;IACtB,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;YAC7B,gCAAe,CAAC,KAAK,CACnB,kDAAkD,EAClD,EAAE,IAAI,EAAE,CACT,CAAC;QACJ,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,sBAAsB;IACtB,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAE9B,+DAA+D;QAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACrB,IAAI,CAAC,GAAG;YACN,gCAAe,CAAC,KAAK,CAAC,kCAAkC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAEtE,sCAAsC;QACtC,MAAM,SAAS,GAA2B,EAAE,GAAG,EAAE,CAAC;QAElD,8BAA8B;QAC9B,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACxD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACnE,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtB,gCAAe,CAAC,KAAK,CAAC,0BAA0B,GAAG,MAAM,IAAI,CAAC,IAAI,GAAG,EAAE;oBACrE,GAAG;oBACH,IAAI;iBACL,CAAC,CAAC;YACL,CAAC;YACD,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;QACvB,CAAC;QAED,yBAAyB;QACzB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;YAC3B,wCAAuB,CAAC,KAAK,CAC3B,4FAA4F,EAC5F,EAAE,IAAI,EAAE,SAAS,EAAE,CACpB,CAAC;QAEJ,cAAc;QACd,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,IAAI,wCAAuB,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AA1DW,QAAA,eAAe,mBA0D1B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Artifact } from 'rhachet-artifact';
|
|
2
|
+
import { GitFile } from 'rhachet-artifact-git';
|
|
3
|
+
import { PickAny } from 'type-fns';
|
|
4
|
+
import { Thread } from '../../domain/objects';
|
|
5
|
+
import { RoleContext, RoleContextTrait } from '../../domain/objects/RoleContext';
|
|
6
|
+
/**
|
|
7
|
+
* .what = injects new RoleTrait(s) into a thread's context
|
|
8
|
+
* .why = enables dynamic role adaptation from inline traits or artifact sources
|
|
9
|
+
*/
|
|
10
|
+
export declare const addRoleTraits: <TThread extends Thread<{
|
|
11
|
+
inherit: RoleContext<any, any>['inherit'];
|
|
12
|
+
}>>({ thread, from, }: {
|
|
13
|
+
thread: TThread;
|
|
14
|
+
from: PickAny<{
|
|
15
|
+
traits: RoleContextTrait[];
|
|
16
|
+
artifacts: Artifact<typeof GitFile>[];
|
|
17
|
+
}>;
|
|
18
|
+
}) => Promise<TThread>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addRoleTraits = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = injects new RoleTrait(s) into a thread's context
|
|
6
|
+
* .why = enables dynamic role adaptation from inline traits or artifact sources
|
|
7
|
+
*/
|
|
8
|
+
const addRoleTraits = async ({ thread, from, }) => {
|
|
9
|
+
const parsed = [];
|
|
10
|
+
if ('traits' in from && from.traits) {
|
|
11
|
+
parsed.push(...from.traits);
|
|
12
|
+
}
|
|
13
|
+
if ('artifacts' in from && from.artifacts) {
|
|
14
|
+
for (const artifact of from.artifacts) {
|
|
15
|
+
const file = await artifact.get();
|
|
16
|
+
if (!file)
|
|
17
|
+
throw new Error(`trait file not found: ${artifact.ref.uri}`);
|
|
18
|
+
parsed.push({ content: file.content });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
...thread,
|
|
23
|
+
context: {
|
|
24
|
+
...thread.context,
|
|
25
|
+
inherit: {
|
|
26
|
+
...thread.context.inherit,
|
|
27
|
+
traits: [...(thread.context.inherit.traits ?? []), ...parsed],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.addRoleTraits = addRoleTraits;
|
|
33
|
+
//# sourceMappingURL=addRoleTraits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addRoleTraits.js","sourceRoot":"","sources":["../../../src/logic/role/addRoleTraits.ts"],"names":[],"mappings":";;;AAUA;;;GAGG;AACI,MAAM,aAAa,GAAG,KAAK,EAEhC,EACA,MAAM,EACN,IAAI,GAOL,EAAoB,EAAE;IACrB,MAAM,MAAM,GAAuB,EAAE,CAAC;IAEtC,IAAI,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,WAAW,IAAI,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QAC1C,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,GAAG,EAAE,CAAC;YAClC,IAAI,CAAC,IAAI;gBAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;YACxE,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,MAAM;QACT,OAAO,EAAE;YACP,GAAG,MAAM,CAAC,OAAO;YACjB,OAAO,EAAE;gBACP,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO;gBACzB,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC;aAC9D;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AApCW,QAAA,aAAa,iBAoCxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const as_procedure_1 = require("as-procedure");
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
const test_fns_1 = require("test-fns");
|
|
6
|
+
const addRoleTraits_1 = require("./addRoleTraits");
|
|
7
|
+
const makeFakeArtifact = (content) => ({
|
|
8
|
+
ref: { uri: `/fake/${Math.random()}` },
|
|
9
|
+
get: (0, as_procedure_1.withExpectOutput)(async () => ({
|
|
10
|
+
uri: '/fake/file.md',
|
|
11
|
+
hash: 'hash123',
|
|
12
|
+
content,
|
|
13
|
+
})),
|
|
14
|
+
set: () => helpful_errors_1.UnexpectedCodePathError.throw('todo'),
|
|
15
|
+
del: () => helpful_errors_1.UnexpectedCodePathError.throw('todo'),
|
|
16
|
+
});
|
|
17
|
+
describe('addRoleTraits', () => {
|
|
18
|
+
(0, test_fns_1.given)('a thread with empty traits', () => {
|
|
19
|
+
const thread = {
|
|
20
|
+
context: { inherit: { traits: [], skills: [] } },
|
|
21
|
+
stitches: [],
|
|
22
|
+
};
|
|
23
|
+
(0, test_fns_1.when)('adding traits from direct RoleTrait content', () => {
|
|
24
|
+
const traits = [
|
|
25
|
+
{ content: 'treat consistency as top priority' },
|
|
26
|
+
{ content: 'prefer ubiquitous language' },
|
|
27
|
+
];
|
|
28
|
+
(0, test_fns_1.then)('should append those traits to the context', async () => {
|
|
29
|
+
const updated = await (0, addRoleTraits_1.addRoleTraits)({ thread, from: { traits } });
|
|
30
|
+
expect(updated.context.inherit.traits).toEqual(traits);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
(0, test_fns_1.when)('adding traits from GitFile artifacts', () => {
|
|
34
|
+
const artifacts = [
|
|
35
|
+
makeFakeArtifact('treat consistency as top priority'),
|
|
36
|
+
makeFakeArtifact('prefer given/when/then structure'),
|
|
37
|
+
];
|
|
38
|
+
(0, test_fns_1.then)('should extract and append traits from files', async () => {
|
|
39
|
+
const updated = await (0, addRoleTraits_1.addRoleTraits)({ thread, from: { artifacts } });
|
|
40
|
+
expect(updated.context.inherit.traits).toEqual([
|
|
41
|
+
{ content: 'treat consistency as top priority' },
|
|
42
|
+
{ content: 'prefer given/when/then structure' },
|
|
43
|
+
]);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
(0, test_fns_1.when)('adding traits from both RoleTrait and Artifact', () => {
|
|
47
|
+
const traits = [{ content: 'always test behavior' }];
|
|
48
|
+
const artifacts = [makeFakeArtifact('capture domain terms')];
|
|
49
|
+
(0, test_fns_1.then)('should merge both sources into context.inherit.traits', async () => {
|
|
50
|
+
const updated = await (0, addRoleTraits_1.addRoleTraits)({
|
|
51
|
+
thread,
|
|
52
|
+
from: { traits, artifacts },
|
|
53
|
+
});
|
|
54
|
+
expect(updated.context.inherit.traits).toEqual([
|
|
55
|
+
{ content: 'always test behavior' },
|
|
56
|
+
{ content: 'capture domain terms' },
|
|
57
|
+
]);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
(0, test_fns_1.given)('a thread with pre-existing traits', () => {
|
|
62
|
+
const thread = {
|
|
63
|
+
context: {
|
|
64
|
+
inherit: {
|
|
65
|
+
traits: [{ content: 'existing trait' }],
|
|
66
|
+
skills: [],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
stitches: [],
|
|
70
|
+
};
|
|
71
|
+
(0, test_fns_1.when)('adding new traits via artifact', () => {
|
|
72
|
+
const artifacts = [makeFakeArtifact('new trait added')];
|
|
73
|
+
(0, test_fns_1.then)('should preserve existing traits and append new ones', async () => {
|
|
74
|
+
const updated = await (0, addRoleTraits_1.addRoleTraits)({ thread, from: { artifacts } });
|
|
75
|
+
expect(updated.context.inherit.traits).toEqual([
|
|
76
|
+
{ content: 'existing trait' },
|
|
77
|
+
{ content: 'new trait added' },
|
|
78
|
+
]);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
(0, test_fns_1.given)('an invalid input with neither traits nor artifacts', () => {
|
|
83
|
+
const thread = {
|
|
84
|
+
context: { inherit: { traits: [], skills: [] } },
|
|
85
|
+
stitches: [],
|
|
86
|
+
};
|
|
87
|
+
(0, test_fns_1.then)('should fail at type level', async () => {
|
|
88
|
+
// @ts-expect-error — atleast one key in from is required
|
|
89
|
+
await (0, addRoleTraits_1.addRoleTraits)({ thread, from: {} });
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=addRoleTraits.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addRoleTraits.test.js","sourceRoot":"","sources":["../../../src/logic/role/addRoleTraits.test.ts"],"names":[],"mappings":";;AAAA,+CAAgD;AAChD,mDAAyD;AAGzD,uCAA6C;AAG7C,mDAAgD;AAEhD,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAA4B,EAAE,CAAC,CAAC;IACvE,GAAG,EAAE,EAAE,GAAG,EAAE,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE;IACtC,GAAG,EAAE,IAAA,+BAAgB,EAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QACjC,GAAG,EAAE,eAAe;QACpB,IAAI,EAAE,SAAS;QACf,OAAO;KACR,CAAC,CAAC;IACH,GAAG,EAAE,GAAG,EAAE,CAAC,wCAAuB,CAAC,KAAK,CAAC,MAAM,CAAC;IAChD,GAAG,EAAE,GAAG,EAAE,CAAC,wCAAuB,CAAC,KAAK,CAAC,MAAM,CAAC;CACjD,CAAC,CAAC;AAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAA,gBAAK,EAAC,4BAA4B,EAAE,GAAG,EAAE;QACvC,MAAM,MAAM,GAAG;YACb,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE;YAChD,QAAQ,EAAE,EAAE;SACb,CAAC;QAEF,IAAA,eAAI,EAAC,6CAA6C,EAAE,GAAG,EAAE;YACvD,MAAM,MAAM,GAAuB;gBACjC,EAAE,OAAO,EAAE,mCAAmC,EAAE;gBAChD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E,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE;YAChD,QAAQ,EAAE,EAAE;SACb,CAAC;QAEF,IAAA,eAAI,EAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;YAC3C,yDAAyD;YACzD,MAAM,IAAA,6BAAa,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Artifact } from 'rhachet-artifact';
|
|
2
|
+
import { GitFile } from 'rhachet-artifact-git';
|
|
3
|
+
import { Thread } from '../../domain/objects';
|
|
4
|
+
import { RoleContext } from '../../domain/objects/RoleContext';
|
|
5
|
+
/**
|
|
6
|
+
* .what = creates a thread for a given role, with optional inherited traits and skills
|
|
7
|
+
* .why = eliminates boilerplate around thread setup, including `as const`, trait/skill injection, and context composition
|
|
8
|
+
*/
|
|
9
|
+
export declare const enrollThread: <TRole extends string, TStash extends Record<string, any>>({ role, inherit, stash, }: {
|
|
10
|
+
role: TRole;
|
|
11
|
+
inherit?: {
|
|
12
|
+
traits?: Artifact<typeof GitFile>[];
|
|
13
|
+
skills?: Artifact<typeof GitFile>[];
|
|
14
|
+
};
|
|
15
|
+
stash?: TStash;
|
|
16
|
+
}) => Promise<Thread<RoleContext<TRole, TStash>>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|