rhachet 1.16.0 → 1.17.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/dist/contract/sdk.d.ts +1 -0
- package/dist/contract/sdk.js +3 -1
- package/dist/contract/sdk.js.map +1 -1
- package/dist/domain.operations/role/getRoleBriefs.d.ts +24 -0
- package/dist/domain.operations/role/getRoleBriefs.js +95 -0
- package/dist/domain.operations/role/getRoleBriefs.js.map +1 -0
- package/package.json +2 -2
package/dist/contract/sdk.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from '../domain.objects';
|
|
|
3
3
|
export { genContextStitchTrail } from '../domain.operations/context/genContextStitchTrail';
|
|
4
4
|
export { enrollThread } from '../domain.operations/role/enrollThread';
|
|
5
5
|
export { genRoleSkill } from '../domain.operations/role/genRoleSkill';
|
|
6
|
+
export { getRoleBriefs } from '../domain.operations/role/getRoleBriefs';
|
|
6
7
|
export type { ContextStitchTrail } from '../domain.operations/stitch/withStitchTrail';
|
|
7
8
|
export { genStepImagineViaTemplate } from '../domain.operations/template/genStepImagineViaTemplate';
|
|
8
9
|
export { genTemplate } from '../domain.operations/template/genTemplate';
|
package/dist/contract/sdk.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.enweaveOneStitcher = exports.genStitchRoute = exports.genStitchFanout = exports.genStitchCycle = exports.genStitchChoice = exports.asStitcherFlat = exports.asStitcher = exports.getStitch = exports.useTemplate = exports.getTemplateVarsFromRoleInherit = exports.getTemplateValFromArtifacts = exports.getTemplatePathByCallerPath = exports.genTemplate = exports.genStepImagineViaTemplate = exports.genRoleSkill = exports.enrollThread = exports.genContextStitchTrail = exports.withImmute = void 0;
|
|
17
|
+
exports.enweaveOneStitcher = exports.genStitchRoute = exports.genStitchFanout = exports.genStitchCycle = exports.genStitchChoice = exports.asStitcherFlat = exports.asStitcher = exports.getStitch = exports.useTemplate = exports.getTemplateVarsFromRoleInherit = exports.getTemplateValFromArtifacts = exports.getTemplatePathByCallerPath = exports.genTemplate = exports.genStepImagineViaTemplate = exports.getRoleBriefs = exports.genRoleSkill = exports.enrollThread = exports.genContextStitchTrail = exports.withImmute = void 0;
|
|
18
18
|
var domain_objects_1 = require("domain-objects");
|
|
19
19
|
Object.defineProperty(exports, "withImmute", { enumerable: true, get: function () { return domain_objects_1.withImmute; } });
|
|
20
20
|
__exportStar(require("../domain.objects"), exports);
|
|
@@ -24,6 +24,8 @@ var enrollThread_1 = require("../domain.operations/role/enrollThread");
|
|
|
24
24
|
Object.defineProperty(exports, "enrollThread", { enumerable: true, get: function () { return enrollThread_1.enrollThread; } });
|
|
25
25
|
var genRoleSkill_1 = require("../domain.operations/role/genRoleSkill");
|
|
26
26
|
Object.defineProperty(exports, "genRoleSkill", { enumerable: true, get: function () { return genRoleSkill_1.genRoleSkill; } });
|
|
27
|
+
var getRoleBriefs_1 = require("../domain.operations/role/getRoleBriefs");
|
|
28
|
+
Object.defineProperty(exports, "getRoleBriefs", { enumerable: true, get: function () { return getRoleBriefs_1.getRoleBriefs; } });
|
|
27
29
|
var genStepImagineViaTemplate_1 = require("../domain.operations/template/genStepImagineViaTemplate");
|
|
28
30
|
Object.defineProperty(exports, "genStepImagineViaTemplate", { enumerable: true, get: function () { return genStepImagineViaTemplate_1.genStepImagineViaTemplate; } });
|
|
29
31
|
var genTemplate_1 = require("../domain.operations/template/genTemplate");
|
package/dist/contract/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/contract/sdk.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAAnC,4GAAA,UAAU,OAAA;AAEnB,sDAAoC;AACpC,8FAA6F;AAApF,8HAAA,qBAAqB,OAAA;AAC9B,yEAAwE;AAA/D,4GAAA,YAAY,OAAA;AACrB,yEAAwE;AAA/D,4GAAA,YAAY,OAAA;
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/contract/sdk.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAAnC,4GAAA,UAAU,OAAA;AAEnB,sDAAoC;AACpC,8FAA6F;AAApF,8HAAA,qBAAqB,OAAA;AAC9B,yEAAwE;AAA/D,4GAAA,YAAY,OAAA;AACrB,yEAAwE;AAA/D,4GAAA,YAAY,OAAA;AACrB,2EAA0E;AAAjE,8GAAA,aAAa,OAAA;AAEtB,uGAAsG;AAA7F,sIAAA,yBAAyB,OAAA;AAClC,2EAA0E;AAAjE,0GAAA,WAAW,OAAA;AACpB,2GAA0G;AAAjG,0IAAA,2BAA2B,OAAA;AACpC,2GAA0G;AAAjG,0IAAA,2BAA2B,OAAA;AACpC,iHAAgH;AAAvG,gJAAA,8BAA8B,OAAA;AACvC,2EAA0E;AAAjE,0GAAA,WAAW,OAAA;AACpB,qEAAoE;AAA3D,sGAAA,SAAS,OAAA;AAClB,8EAA6E;AAApE,wGAAA,UAAU,OAAA;AACnB,sFAAqF;AAA5E,gHAAA,cAAc,OAAA;AACvB,wFAAuF;AAA9E,kHAAA,eAAe,OAAA;AACxB,sFAAqF;AAA5E,gHAAA,cAAc,OAAA;AACvB,wFAAuF;AAA9E,kHAAA,eAAe,OAAA;AACxB,sFAAqF;AAA5E,gHAAA,cAAc,OAAA;AACvB,sFAAqF;AAA5E,wHAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Artifact } from 'rhachet-artifact';
|
|
2
|
+
import { type GitFile } from 'rhachet-artifact-git';
|
|
3
|
+
/**
|
|
4
|
+
* .what = finds and returns briefs from a linked role directory as lazy-loadable artifacts
|
|
5
|
+
* .why = enables role composition by allowing procedures to programmatically access briefs
|
|
6
|
+
*
|
|
7
|
+
* .note = this procedure looks into `.agent/*` directories for linked roles.
|
|
8
|
+
* if you just wrote a brief in the repo the role is defined in,
|
|
9
|
+
* you must run `npm run build && npx rhachet roles link` before it can be used.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getRoleBriefs: (input: {
|
|
12
|
+
by: {
|
|
13
|
+
role: {
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
repo?: {
|
|
17
|
+
name: string;
|
|
18
|
+
};
|
|
19
|
+
briefs: {
|
|
20
|
+
name?: string[];
|
|
21
|
+
glob?: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}) => Promise<Artifact<typeof GitFile>[]>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getRoleBriefs = void 0;
|
|
7
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
8
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
9
|
+
const rhachet_artifact_git_1 = require("rhachet-artifact-git");
|
|
10
|
+
const node_fs_1 = require("node:fs");
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
|
+
/**
|
|
13
|
+
* .what = finds and returns briefs from a linked role directory as lazy-loadable artifacts
|
|
14
|
+
* .why = enables role composition by allowing procedures to programmatically access briefs
|
|
15
|
+
*
|
|
16
|
+
* .note = this procedure looks into `.agent/*` directories for linked roles.
|
|
17
|
+
* if you just wrote a brief in the repo the role is defined in,
|
|
18
|
+
* you must run `npm run build && npx rhachet roles link` before it can be used.
|
|
19
|
+
*/
|
|
20
|
+
const getRoleBriefs = async (input) => {
|
|
21
|
+
// resolve agent directory
|
|
22
|
+
const dirAgent = (0, node_path_1.resolve)(process.cwd(), '.agent');
|
|
23
|
+
if (!(0, node_fs_1.existsSync)(dirAgent))
|
|
24
|
+
throw new helpful_errors_1.BadRequestError('no .agent directory found. did you forget to `npx rhachet roles link`?');
|
|
25
|
+
// scan for repo directories
|
|
26
|
+
const dirsRepo = (0, node_fs_1.readdirSync)(dirAgent)
|
|
27
|
+
.filter((d) => d.startsWith('repo='))
|
|
28
|
+
.map((d) => ({ slug: d.replace('repo=', ''), path: (0, node_path_1.resolve)(dirAgent, d) }));
|
|
29
|
+
const rolesMatching = [];
|
|
30
|
+
for (const dirRepo of dirsRepo) {
|
|
31
|
+
// filter by repo if specified
|
|
32
|
+
if (input.by.repo?.name && dirRepo.slug !== input.by.repo.name)
|
|
33
|
+
continue;
|
|
34
|
+
// scan for role directories matching the requested name
|
|
35
|
+
const dirsRole = (0, node_fs_1.readdirSync)(dirRepo.path)
|
|
36
|
+
.filter((d) => d.startsWith('role='))
|
|
37
|
+
.filter((d) => d.replace('role=', '') === input.by.role.name);
|
|
38
|
+
// collect matching roles
|
|
39
|
+
for (const dirRole of dirsRole) {
|
|
40
|
+
const pathRole = (0, node_path_1.resolve)(dirRepo.path, dirRole);
|
|
41
|
+
rolesMatching.push({
|
|
42
|
+
slugRepo: dirRepo.slug,
|
|
43
|
+
slugRole: input.by.role.name,
|
|
44
|
+
pathRole,
|
|
45
|
+
pathBriefs: (0, node_path_1.resolve)(pathRole, 'briefs'),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// reject if no matching role found
|
|
50
|
+
if (rolesMatching.length === 0)
|
|
51
|
+
throw new helpful_errors_1.BadRequestError(`role "${input.by.role.name}" not found in .agent/ directory. did you forget to \`npx rhachet roles link --role ${input.by.role.name}\`?`);
|
|
52
|
+
// reject if multiple roles match without disambiguation
|
|
53
|
+
if (rolesMatching.length > 1) {
|
|
54
|
+
const locations = rolesMatching
|
|
55
|
+
.map((r) => ` - repo=${r.slugRepo}`)
|
|
56
|
+
.join('\n');
|
|
57
|
+
throw new helpful_errors_1.BadRequestError(`multiple roles found with name "${input.by.role.name}":\n${locations}\n\nuse by.repo.name to disambiguate`);
|
|
58
|
+
}
|
|
59
|
+
// extract the single matching role
|
|
60
|
+
const roleLinked = rolesMatching[0];
|
|
61
|
+
// reject if briefs directory doesn't exist
|
|
62
|
+
if (!(0, node_fs_1.existsSync)(roleLinked.pathBriefs))
|
|
63
|
+
throw new helpful_errors_1.BadRequestError(`briefs directory not found for role "${roleLinked.slugRole}" in repo="${roleLinked.slugRepo}". ` +
|
|
64
|
+
`did you forget to \`npx rhachet roles link --role ${roleLinked.slugRole}\`? ` +
|
|
65
|
+
`(if you just wrote a brief, run: npm run build && npx rhachet roles link)`);
|
|
66
|
+
// match briefs by name or glob
|
|
67
|
+
const pathsBrief = [];
|
|
68
|
+
if (input.by.briefs.name?.length) {
|
|
69
|
+
// exact name matching
|
|
70
|
+
for (const name of input.by.briefs.name) {
|
|
71
|
+
const pathsMatching = await (0, fast_glob_1.default)(`**/${name}*`, {
|
|
72
|
+
cwd: roleLinked.pathBriefs,
|
|
73
|
+
absolute: true,
|
|
74
|
+
onlyFiles: true,
|
|
75
|
+
});
|
|
76
|
+
if (pathsMatching.length === 0)
|
|
77
|
+
throw new helpful_errors_1.BadRequestError(`brief "${name}" not found in role "${roleLinked.slugRole}" (repo="${roleLinked.slugRepo}")`);
|
|
78
|
+
pathsBrief.push(...pathsMatching);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (input.by.briefs.glob) {
|
|
82
|
+
// glob pattern matching
|
|
83
|
+
const pathsMatching = await (0, fast_glob_1.default)(input.by.briefs.glob, {
|
|
84
|
+
cwd: roleLinked.pathBriefs,
|
|
85
|
+
absolute: true,
|
|
86
|
+
onlyFiles: true,
|
|
87
|
+
});
|
|
88
|
+
pathsBrief.push(...pathsMatching);
|
|
89
|
+
}
|
|
90
|
+
// dedupe and create artifacts
|
|
91
|
+
const pathsUnique = [...new Set(pathsBrief)];
|
|
92
|
+
return pathsUnique.map((uri) => (0, rhachet_artifact_git_1.genArtifactGitFile)({ uri }));
|
|
93
|
+
};
|
|
94
|
+
exports.getRoleBriefs = getRoleBriefs;
|
|
95
|
+
//# sourceMappingURL=getRoleBriefs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRoleBriefs.js","sourceRoot":"","sources":["../../../src/domain.operations/role/getRoleBriefs.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,mDAAiD;AAEjD,+DAAwE;AAExE,qCAAkD;AAClD,yCAAoC;AAEpC;;;;;;;GAOG;AACI,MAAM,aAAa,GAAG,KAAK,EAAE,KAMnC,EAAuC,EAAE;IACxC,0BAA0B;IAC1B,MAAM,QAAQ,GAAG,IAAA,mBAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;IAClD,IAAI,CAAC,IAAA,oBAAU,EAAC,QAAQ,CAAC;QACvB,MAAM,IAAI,gCAAe,CACvB,wEAAwE,CACzE,CAAC;IAEJ,4BAA4B;IAC5B,MAAM,QAAQ,GAAG,IAAA,qBAAW,EAAC,QAAQ,CAAC;SACnC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;SACpC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,IAAA,mBAAO,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAS9E,MAAM,aAAa,GAAiB,EAAE,CAAC;IACvC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,8BAA8B;QAC9B,IAAI,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC,IAAI,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AU,CAAC,UAAU;YAC1B,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;QACH,UAAU,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;IACpC,CAAC;IAED,8BAA8B;IAC9B,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IAC7C,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,yCAAkB,EAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC,CAAC;AAxGW,QAAA,aAAa,iBAwGxB"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "rhachet",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "A framework for reliable, thorough thought. Weave threads of thought via stitches.",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.17.0",
|
|
6
6
|
"repository": "ehmpathy/rhachet",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/rhachet",
|
|
8
8
|
"keywords": [
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"rhachet": "1.15.2",
|
|
93
93
|
"rhachet-roles-bhrain": "0.5.5",
|
|
94
94
|
"rhachet-roles-bhuild": "0.4.2",
|
|
95
|
-
"rhachet-roles-ehmpathy": "1.15.
|
|
95
|
+
"rhachet-roles-ehmpathy": "1.15.21",
|
|
96
96
|
"test-fns": "1.7.0",
|
|
97
97
|
"tsc-alias": "1.8.10",
|
|
98
98
|
"tsx": "~4.20.6",
|