rhachet 1.6.0 โ†’ 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/.test/directory.d.ts +1 -0
  2. package/dist/.test/directory.js +2 -1
  3. package/dist/.test/directory.js.map +1 -1
  4. package/dist/{contract/cli/.test โ†’ .test/example.use.repo}/example.echoRegistry.d.ts +1 -1
  5. package/dist/.test/example.use.repo/example.echoRegistry.js +104 -0
  6. package/dist/.test/example.use.repo/example.echoRegistry.js.map +1 -0
  7. package/dist/contract/cli/invoke.integration.test.js +2 -1
  8. package/dist/contract/cli/invoke.integration.test.js.map +1 -1
  9. package/dist/contract/cli/invoke.js +10 -33
  10. package/dist/contract/cli/invoke.js.map +1 -1
  11. package/dist/contract/cli/invokeAsk.d.ts +4 -1
  12. package/dist/contract/cli/invokeAsk.integration.test.js +29 -2
  13. package/dist/contract/cli/invokeAsk.integration.test.js.map +1 -1
  14. package/dist/contract/cli/invokeAsk.js +14 -44
  15. package/dist/contract/cli/invokeAsk.js.map +1 -1
  16. package/dist/contract/cli/invokeReadme.integration.test.js +1 -1
  17. package/dist/contract/cli/invokeReadme.integration.test.js.map +1 -1
  18. package/dist/directory.d.ts +1 -0
  19. package/dist/directory.js +5 -0
  20. package/dist/directory.js.map +1 -0
  21. package/dist/domain/objects/InvokeOpts.d.ts +11 -0
  22. package/dist/domain/objects/InvokeOpts.js +3 -0
  23. package/dist/domain/objects/InvokeOpts.js.map +1 -0
  24. package/dist/domain/objects/InvokeOpts.test.d.ts +1 -0
  25. package/dist/domain/objects/InvokeOpts.test.js +41 -0
  26. package/dist/domain/objects/InvokeOpts.test.js.map +1 -0
  27. package/dist/logic/invoke/addAttemptQualifierToOutputPath.d.ts +13 -0
  28. package/dist/logic/invoke/addAttemptQualifierToOutputPath.js +30 -0
  29. package/dist/logic/invoke/addAttemptQualifierToOutputPath.js.map +1 -0
  30. package/dist/logic/invoke/addAttemptQualifierToOutputPath.test.d.ts +1 -0
  31. package/dist/logic/invoke/addAttemptQualifierToOutputPath.test.js +130 -0
  32. package/dist/logic/invoke/addAttemptQualifierToOutputPath.test.js.map +1 -0
  33. package/dist/logic/invoke/getRegistriesByOpts.d.ts +13 -0
  34. package/dist/logic/invoke/getRegistriesByOpts.js +40 -0
  35. package/dist/logic/invoke/getRegistriesByOpts.js.map +1 -0
  36. package/dist/logic/invoke/getSkillThread.test.js.map +1 -1
  37. package/dist/logic/invoke/getSkillThreads.d.ts +4 -1
  38. package/dist/logic/invoke/getSkillThreads.js +1 -1
  39. package/dist/logic/invoke/getSkillThreads.js.map +1 -1
  40. package/dist/logic/invoke/performInCurrentThread.d.ts +16 -0
  41. package/dist/logic/invoke/performInCurrentThread.js +56 -0
  42. package/dist/logic/invoke/performInCurrentThread.js.map +1 -0
  43. package/dist/logic/invoke/performInIsolatedThread.execute.d.ts +14 -0
  44. package/dist/logic/invoke/performInIsolatedThread.execute.js +48 -0
  45. package/dist/logic/invoke/performInIsolatedThread.execute.js.map +1 -0
  46. package/dist/logic/invoke/performInIsolatedThread.invoke.d.ts +31 -0
  47. package/dist/logic/invoke/performInIsolatedThread.invoke.integration.test.d.ts +1 -0
  48. package/dist/logic/invoke/performInIsolatedThread.invoke.integration.test.js +74 -0
  49. package/dist/logic/invoke/performInIsolatedThread.invoke.integration.test.js.map +1 -0
  50. package/dist/logic/invoke/performInIsolatedThread.invoke.js +93 -0
  51. package/dist/logic/invoke/performInIsolatedThread.invoke.js.map +1 -0
  52. package/dist/logic/invoke/performInIsolatedThreads.d.ts +19 -0
  53. package/dist/logic/invoke/performInIsolatedThreads.integration.test.d.ts +1 -0
  54. package/dist/logic/invoke/performInIsolatedThreads.integration.test.js +75 -0
  55. package/dist/logic/invoke/performInIsolatedThreads.integration.test.js.map +1 -0
  56. package/dist/logic/invoke/performInIsolatedThreads.js +99 -0
  57. package/dist/logic/invoke/performInIsolatedThreads.js.map +1 -0
  58. package/package.json +7 -4
  59. package/readme.md +27 -8
  60. package/dist/contract/cli/.test/example.echoRegistry.js +0 -54
  61. package/dist/contract/cli/.test/example.echoRegistry.js.map +0 -1
@@ -0,0 +1,19 @@
1
+ import { InvokeOpts } from '../../domain/objects/InvokeOpts';
2
+ /**
3
+ * .what = performs a skill in one-or-more isolated threads concurrently
4
+ * .why =
5
+ * - enables multiple attempts of the same performance, to compare different takes of the same skill
6
+ * - given llm's may produce divergent results on reinvocation, this is useful to...
7
+ * - support the attempt-&-blend pattern
8
+ * - evaluate the consistency of a skill applied to your ask
9
+ * - etc
10
+ * .how =
11
+ * - spawns isolated child threads and performs the skill within each of those threads
12
+ */
13
+ export declare const performInIsolatedThreads: (input: {
14
+ opts: InvokeOpts<{
15
+ config: string;
16
+ ask: string;
17
+ output?: string;
18
+ }>;
19
+ }) => Promise<void>;
@@ -0,0 +1,75 @@
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
+ const node_path_1 = __importDefault(require("node:path"));
7
+ const rhachet_artifact_git_1 = require("rhachet-artifact-git");
8
+ const test_fns_1 = require("test-fns");
9
+ const directory_1 = require("../../.test/directory");
10
+ const performInIsolatedThreads_1 = require("./performInIsolatedThreads");
11
+ describe('performInIsolatedThreads', () => {
12
+ // observe stdout
13
+ let stdoutObserved = '';
14
+ const originalWrite = process.stdout.write;
15
+ beforeAll(() => {
16
+ process.stdout.write = (chunk, ...args) => {
17
+ stdoutObserved += chunk.toString();
18
+ return originalWrite.call(process.stdout, chunk, ...args);
19
+ };
20
+ });
21
+ afterAll(() => {
22
+ process.stdout.write = originalWrite;
23
+ });
24
+ (0, test_fns_1.given)('a simple echo demo', () => {
25
+ // declare the demo config via path
26
+ const configPath = node_path_1.default.resolve(directory_1.TEST_FIXTURE_DIRECTORY, './example.use.repo/example.rhachet.use.ts');
27
+ (0, test_fns_1.when)('asked to perform a skill registered in the config 3 times', () => {
28
+ const opts = {
29
+ config: configPath,
30
+ role: 'echoer',
31
+ skill: 'echo',
32
+ attempts: 3,
33
+ ask: 'do it',
34
+ };
35
+ (0, test_fns_1.then)('it should successfully execute do so', async () => {
36
+ await (0, performInIsolatedThreads_1.performInIsolatedThreads)({ opts });
37
+ });
38
+ (0, test_fns_1.then)('it should have logged with observable prefixes', async () => {
39
+ expect(stdoutObserved).toContain('โ—‹ i1 โ€บ');
40
+ expect(stdoutObserved).toContain(`๐Ÿซก on it!`);
41
+ });
42
+ });
43
+ });
44
+ (0, test_fns_1.given)('a simple file write', () => {
45
+ // declare the demo config via path
46
+ const configPath = node_path_1.default.resolve(directory_1.TEST_FIXTURE_DIRECTORY, './example.use.repo/example.rhachet.use.ts');
47
+ (0, test_fns_1.when)('asked to perform a skill registered in the config 3 times', () => {
48
+ const opts = {
49
+ config: configPath,
50
+ output: directory_1.TEST_FIXTURE_DIRECTORY +
51
+ `/example.use.repo/.tmp/performInIsolatedThreads/${Date.now()}.demo.md`,
52
+ role: 'echoer',
53
+ skill: 'write',
54
+ attempts: 3,
55
+ ask: 'do it',
56
+ };
57
+ (0, test_fns_1.then)('it should successfully execute do so', async () => {
58
+ await (0, performInIsolatedThreads_1.performInIsolatedThreads)({ opts });
59
+ });
60
+ (0, test_fns_1.then)('it should have logged with observable prefixes', async () => {
61
+ expect(stdoutObserved).toContain('โ—‹ i1 โ€บ');
62
+ expect(stdoutObserved).toContain(`๐Ÿซก on it!`);
63
+ });
64
+ (0, test_fns_1.then)('it should written files to the expected paths', async () => {
65
+ const artifactsExpected = [
66
+ (0, rhachet_artifact_git_1.genArtifactGitFile)({ uri: opts.output.replace(/\.md$/, '.i1.md') }),
67
+ (0, rhachet_artifact_git_1.genArtifactGitFile)({ uri: opts.output.replace(/\.md$/, '.i2.md') }),
68
+ (0, rhachet_artifact_git_1.genArtifactGitFile)({ uri: opts.output.replace(/\.md$/, '.i3.md') }),
69
+ ];
70
+ await Promise.all(artifactsExpected.map(async (art) => expect((await art.get())?.content).toEqual(opts.ask)));
71
+ });
72
+ });
73
+ });
74
+ });
75
+ //# sourceMappingURL=performInIsolatedThreads.integration.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"performInIsolatedThreads.integration.test.js","sourceRoot":"","sources":["../../../src/logic/invoke/performInIsolatedThreads.integration.test.ts"],"names":[],"mappings":";;;;;AAAA,0DAA6B;AAC7B,+DAA0D;AAC1D,uCAA6C;AAE7C,qDAA+D;AAC/D,yEAAsE;AAEtE,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,iBAAiB;IACjB,IAAI,cAAc,GAAG,EAAE,CAAC;IACxB,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3C,SAAS,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,MAAM,CAAC,KAAa,GAAG,CAAC,KAAU,EAAE,GAAG,IAAW,EAAE,EAAE;YAC7D,cAAc,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnC,OAAQ,aAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;QACrE,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,MAAM,CAAC,KAAa,GAAG,aAAa,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,IAAA,gBAAK,EAAC,oBAAoB,EAAE,GAAG,EAAE;QAC/B,mCAAmC;QACnC,MAAM,UAAU,GAAG,mBAAI,CAAC,OAAO,CAC7B,kCAAsB,EACtB,2CAA2C,CAC5C,CAAC;QAEF,IAAA,eAAI,EAAC,2DAA2D,EAAE,GAAG,EAAE;YACrE,MAAM,IAAI,GAAG;gBACX,MAAM,EAAE,UAAU;gBAClB,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,MAAM;gBACb,QAAQ,EAAE,CAAC;gBACX,GAAG,EAAE,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,eAAI,EAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;gBAC/D,MAAM,iBAAiB,GAAG;oBACxB,IAAA,yCAAkB,EAAC,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;oBACnE,IAAA,yCAAkB,EAAC,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;oBACnE,IAAA,yCAAkB,EAAC,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;iBACpE,CAAC;gBACF,MAAM,OAAO,CAAC,GAAG,CACf,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAClC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CACrD,CACF,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,99 @@
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.performInIsolatedThreads = void 0;
7
+ const uni_time_1 = require("@ehmpathy/uni-time");
8
+ const bottleneck_1 = __importDefault(require("bottleneck"));
9
+ const helpful_errors_1 = require("helpful-errors");
10
+ const addAttemptQualifierToOutputPath_1 = require("./addAttemptQualifierToOutputPath");
11
+ const performInIsolatedThread_invoke_1 = require("./performInIsolatedThread.invoke");
12
+ /**
13
+ * .what = performs a skill in one-or-more isolated threads concurrently
14
+ * .why =
15
+ * - enables multiple attempts of the same performance, to compare different takes of the same skill
16
+ * - given llm's may produce divergent results on reinvocation, this is useful to...
17
+ * - support the attempt-&-blend pattern
18
+ * - evaluate the consistency of a skill applied to your ask
19
+ * - etc
20
+ * .how =
21
+ * - spawns isolated child threads and performs the skill within each of those threads
22
+ */
23
+ const performInIsolatedThreads = async (input) => {
24
+ // validate that attempts were requested
25
+ if (!input.opts.attempts)
26
+ helpful_errors_1.BadRequestError.throw('--attempts was not provided', {
27
+ argv: input.opts,
28
+ });
29
+ // validate that more than one attempt was declared
30
+ const attempts = Number(input.opts.attempts);
31
+ if (!Number.isInteger(attempts))
32
+ helpful_errors_1.BadRequestError.throw('--attempts must be an integer', {
33
+ attempts: { input: input.opts.attempts, asNum: input.opts.attempts },
34
+ });
35
+ if (attempts < 1)
36
+ helpful_errors_1.BadRequestError.throw('--attempts must be greater than one', {
37
+ attempts: { input: input.opts.attempts, asNum: input.opts.attempts },
38
+ });
39
+ // parse concurrency (defaults to 3 if unset); concurrency governs parallelism, not the number of attempts
40
+ const concurrency = input.opts.concurrency
41
+ ? Number(input.opts.concurrency)
42
+ : 3;
43
+ if (!Number.isInteger(concurrency))
44
+ helpful_errors_1.BadRequestError.throw('--concurrency must be an integer', {
45
+ concurrency: {
46
+ input: input.opts.concurrency,
47
+ asNum: input.opts.concurrency,
48
+ },
49
+ });
50
+ if (concurrency < 1)
51
+ helpful_errors_1.BadRequestError.throw('--concurrency must be greater than one', {
52
+ concurrency: {
53
+ input: input.opts.concurrency,
54
+ asNum: input.opts.concurrency,
55
+ },
56
+ });
57
+ // cast the argv per attempt; i.e., replace the output in each
58
+ const attemptArgvs = Array.from({ length: attempts }, (_, i) => ({
59
+ ...input.opts,
60
+ attempt: i + 1,
61
+ // qualify the output, if output was specified
62
+ output: input.opts.output
63
+ ? (0, addAttemptQualifierToOutputPath_1.addAttemptQualifierToOutputPath)({
64
+ path: input.opts.output,
65
+ attempt: i + 1,
66
+ })
67
+ : undefined,
68
+ }));
69
+ // orchestrate the child processes using bottleneck for concurrency control
70
+ const bottleneck = new bottleneck_1.default({ maxConcurrent: concurrency });
71
+ const beganAt = Date.now();
72
+ const results = await Promise.all(attemptArgvs.map((argv) => bottleneck.schedule(() => (0, performInIsolatedThread_invoke_1.performInIsolatedThread)({
73
+ opts: argv,
74
+ peer: { attempts },
75
+ }))));
76
+ const wallTime = ((Date.now() - beganAt) / 1000).toFixed(1) + 's';
77
+ // print summary: per-attempt status + durations
78
+ const rows = results.map((r) => ({
79
+ // attempt: r.attempt, // ?: console.table already includes an "index" column which we cant remove, so this is redundant in display
80
+ status: r.code === 0 ? 'ok' : 'fail',
81
+ duration: (0, uni_time_1.asDurationInWords)(r.clock.duration),
82
+ }));
83
+ console.log(`\nsummary (${results.length} attempts):`);
84
+ console.table(rows);
85
+ // print overall outcome banner
86
+ const ok = rows.filter((r) => r.status === 'ok').length;
87
+ const fail = rows.length - ok;
88
+ console.log(`\n${ok} succeeded, ${fail} failed โ€ข total wall time: ${wallTime}`);
89
+ // print output file paths in order
90
+ if (input.opts.output) {
91
+ console.log('\noutputs:');
92
+ for (const argv of attemptArgvs)
93
+ console.log('-', argv.output);
94
+ }
95
+ // parent exit code: 0 iff all succeed; non-zero if any fail
96
+ process.exitCode = fail > 0 ? 1 : 0;
97
+ };
98
+ exports.performInIsolatedThreads = performInIsolatedThreads;
99
+ //# sourceMappingURL=performInIsolatedThreads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"performInIsolatedThreads.js","sourceRoot":"","sources":["../../../src/logic/invoke/performInIsolatedThreads.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAuD;AACvD,4DAAoC;AACpC,mDAAiD;AAGjD,uFAAoF;AACpF,qFAA2E;AAE3E;;;;;;;;;;GAUG;AACI,MAAM,wBAAwB,GAAG,KAAK,EAAE,KAE9C,EAAiB,EAAE;IAClB,wCAAwC;IACxC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;QACtB,gCAAe,CAAC,KAAK,CAAC,6BAA6B,EAAE;YACnD,IA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AM;QACpC,QAAQ,EAAE,IAAA,4BAAiB,EAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;KAC9C,CAAC,CAAC,CAAC;IACJ,OAAO,CAAC,GAAG,CAAC,cAAc,OAAO,CAAC,MAAM,aAAa,CAAC,CAAC;IACvD,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEpB,+BAA+B;IAC/B,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC;IACxD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IAC9B,OAAO,CAAC,GAAG,CACT,KAAK,EAAE,eAAe,IAAI,8BAA8B,QAAQ,EAAE,CACnE,CAAC;IAEF,mCAAmC;IACnC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC1B,KAAK,MAAM,IAAI,IAAI,YAAY;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;IAED,4DAA4D;IAC5D,OAAO,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC,CAAC;AA5FW,QAAA,wBAAwB,4BA4FnC"}
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.6.0",
5
+ "version": "1.7.1",
6
6
  "repository": "ehmpathy/rhachet",
7
7
  "homepage": "https://github.com/ehmpathy/rhachet",
8
8
  "keywords": [
@@ -51,8 +51,10 @@
51
51
  "prepare:husky": "npx husky install && chmod ug+x .husky/*"
52
52
  },
53
53
  "dependencies": {
54
- "@ehmpathy/uni-time": "1.8.2",
54
+ "@ehmpathy/uni-time": "1.9.0",
55
55
  "as-procedure": "1.1.6",
56
+ "bottleneck": "2.19.5",
57
+ "chalk": "4.1.2",
56
58
  "commander": "14.0.0",
57
59
  "domain-objects": "0.25.2",
58
60
  "flattie": "1.1.1",
@@ -60,8 +62,9 @@
60
62
  "openai": "5.8.2",
61
63
  "rhachet-artifact": "1.0.0",
62
64
  "rhachet-artifact-git": "1.1.0",
63
- "serde-fns": "1.3.0",
65
+ "serde-fns": "1.3.1",
64
66
  "test-fns": "1.5.0",
67
+ "tsx": "4.20.5",
65
68
  "type-fns": "1.19.0",
66
69
  "uuid-fns": "1.0.1"
67
70
  },
@@ -74,7 +77,7 @@
74
77
  "@typescript-eslint/eslint-plugin": "7.8.0",
75
78
  "@typescript-eslint/parser": "7.8.0",
76
79
  "core-js": "3.26.1",
77
- "cz-conventional-changelog": "3.3.0",
80
+ "cz-conventional-changelog": "3.0.1",
78
81
  "declapract": "0.12.2",
79
82
  "declapract-typescript-ehmpathy": "0.39.9",
80
83
  "depcheck": "1.4.3",
package/readme.md CHANGED
@@ -3,15 +3,15 @@
3
3
  ![test](https://github.com/ehmpathy/rhachet/workflows/test/badge.svg)
4
4
  ![publish](https://github.com/ehmpathy/rhachet/workflows/publish/badge.svg)
5
5
 
6
- Build reusable roles with rhachet: a framework for reliable, thorough thought.
6
+ Build reusable roles with rhachet: a framework for reliable, composable, and iteratively improvable thought.
7
7
 
8
8
  > Weave threads ๐Ÿงต of thought, stitched ๐Ÿชก with a rhachet โš™๏ธ
9
9
 
10
10
  # vision
11
11
 
12
- Unlock digital clones built by you, who work even from your laptop, and work for anyone you choose.
12
+ Build or use digital actors, who work even from your laptop, and work for anyone you choose.
13
13
 
14
- Distill your skills and roles systematically, with rhachet. Use them, share them, open source them. The choice is yours.
14
+ Distill your skills and roles iteratively, with rhachet. Use them, compose them, share them, open source them. The choice is yours.
15
15
 
16
16
  - With open source top to bottom, we can raise the floor and prosper collectively.
17
17
  - With observable routes of thought, we can not only debug, but align.
@@ -23,10 +23,11 @@ Here's to a solarpunk future of abundance ๐ŸŒž๐ŸŒด
23
23
 
24
24
  1. declare thought routes, reusably and maintainably
25
25
  2. apply thought routes, observably and reliably
26
- 3. compose and accumulate reusable thought tactics
26
+ 3. compose and accumulate reusable thought skill
27
27
  4. assure slipless progress towards goals, like a ratchet (๐ŸŽผ click, click, click)
28
- 5. assure guarded budgets of money and time, with route plans, expense approvals, and circuit breakers
29
- 6. observe thought routes and weaves intuitively
28
+ 5. enable iterative improvement of skills, like a ratchet (๐ŸŽผ click, click, click)
29
+ 6. assure guarded budgets of money and time, with route plans, expense approvals, and circuit breakers
30
+ 7. observe thought routes and weaves intuitively
30
31
 
31
32
  # install
32
33
 
@@ -45,16 +46,34 @@ looks for `@gitroot/rhachet.use.ts` by default
45
46
 
46
47
  ```ts
47
48
  // @/rhachet.use.ts
49
+ import { getRoleRegistry as getBhrainRegistry } from 'rhachet-roles-bhrain';
48
50
  import { getRoleRegistry as getEhmpathyRegistry } from 'rhachet-roles-ehmpathy';
49
51
 
50
52
  export const getRoleRegistries = () => [
53
+ getBhrainRegistry(),
51
54
  getEhmpathyRegistry(),
52
55
  // whichever other registries you'd like
53
56
  ]
54
57
  ```
55
58
 
56
- ### invoke the role
59
+ ### perform a skill
57
60
 
58
61
  ```sh
59
- npx rhachet ask --role mechanic --skill upsert --ask "add endpoint to get weather"
62
+ npx rhachet act \
63
+ --repo bhrain --role skeptic --skill review \
64
+ --ask "are birds real? or are they just government drones ๐Ÿค”"
65
+ ```
66
+
67
+ ```sh
68
+ npx rhachet act \
69
+ --repo ehmpathy --role mechanic --skill review \
70
+ --input "https://github.com/ehmpathy/simple-in-memory-cache/pull/9" \
71
+ --ask "review this pr"
72
+ ```
73
+
74
+ ```sh
75
+ npx rhachet act \
76
+ --repo ehmpathy --role mechanic --skill deliver \
77
+ --input "https://github.com/ehmpathy/domain-objects/issues/7" \
78
+ --ask "push a pr to solve the issue"
60
79
  ```
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EXAMPLE_REGISTRY = void 0;
4
- const genThread_1 = require("../../../logic/thread/genThread");
5
- const sdk_1 = require("../../sdk");
6
- const stepEchoAsk = new sdk_1.StitchStepCompute({
7
- slug: 'echo.step',
8
- form: 'COMPUTE',
9
- stitchee: 'caller',
10
- readme: 'simple echo logic',
11
- invoke: async ({ threads }, context) => {
12
- context.log.info('echo:', { ask: threads.caller.context.ask });
13
- return {
14
- input: null,
15
- output: `echo: ${threads.caller.context.ask}`,
16
- };
17
- },
18
- });
19
- const echoSkill = sdk_1.RoleSkill.build({
20
- slug: 'echo',
21
- readme: 'Echoes back the ask string.',
22
- route: stepEchoAsk,
23
- threads: {
24
- lookup: {},
25
- assess: (input) => true,
26
- instantiate: (input) => ({
27
- caller: (0, genThread_1.genThread)({ role: 'caller', ask: input.ask }),
28
- }),
29
- },
30
- context: {
31
- lookup: {},
32
- assess: (input) => true,
33
- instantiate: () => ({
34
- log: console,
35
- stitch: {
36
- trail: [],
37
- },
38
- }),
39
- },
40
- });
41
- const echoRole = sdk_1.Role.build({
42
- slug: 'echoer',
43
- name: 'Echoer',
44
- purpose: 'repeat things',
45
- readme: 'knows how to echo input back to the user.',
46
- traits: [],
47
- skills: [echoSkill],
48
- });
49
- exports.EXAMPLE_REGISTRY = new sdk_1.RoleRegistry({
50
- slug: 'echo',
51
- readme: 'basic registry for testing CLI execution',
52
- roles: [echoRole],
53
- });
54
- //# sourceMappingURL=example.echoRegistry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"example.echoRegistry.js","sourceRoot":"","sources":["../../../../src/contract/cli/.test/example.echoRegistry.ts"],"names":[],"mappings":";;;AAEA,+DAA4D;AAC5D,mCAQmB;AAEnB,MAAM,WAAW,GAAG,IAAI,uBAAiB,CAEvC;IACA,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,SAAS;IAC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