rhachet 1.7.1 → 1.8.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/cli/invoke.js +2 -0
- package/dist/contract/cli/invoke.js.map +1 -1
- package/dist/contract/cli/invokeChoose.d.ts +8 -0
- package/dist/contract/cli/invokeChoose.integration.test.d.ts +1 -0
- package/dist/contract/cli/invokeChoose.integration.test.js +111 -0
- package/dist/contract/cli/invokeChoose.integration.test.js.map +1 -0
- package/dist/contract/cli/invokeChoose.js +111 -0
- package/dist/contract/cli/invokeChoose.js.map +1 -0
- package/dist/domain/objects/index.d.ts +1 -0
- package/dist/domain/objects/index.js +1 -0
- package/dist/domain/objects/index.js.map +1 -1
- package/dist/logic/invoke/getPeerQualifiersOfOutputChoice.d.ts +23 -0
- package/dist/logic/invoke/getPeerQualifiersOfOutputChoice.js +52 -0
- package/dist/logic/invoke/getPeerQualifiersOfOutputChoice.js.map +1 -0
- package/dist/logic/invoke/getPeerQualifiersOfOutputChoice.test.d.ts +1 -0
- package/dist/logic/invoke/getPeerQualifiersOfOutputChoice.test.js +77 -0
- package/dist/logic/invoke/getPeerQualifiersOfOutputChoice.test.js.map +1 -0
- package/package.json +2 -1
|
@@ -8,6 +8,7 @@ const rhachet_artifact_git_1 = require("rhachet-artifact-git");
|
|
|
8
8
|
const assureUniqueRoles_1 = require("../../logic/invoke/assureUniqueRoles");
|
|
9
9
|
const getRegistriesByOpts_1 = require("../../logic/invoke/getRegistriesByOpts");
|
|
10
10
|
const invokeAsk_1 = require("./invokeAsk");
|
|
11
|
+
const invokeChoose_1 = require("./invokeChoose");
|
|
11
12
|
const invokeList_1 = require("./invokeList");
|
|
12
13
|
const invokeReadme_1 = require("./invokeReadme");
|
|
13
14
|
/**
|
|
@@ -47,6 +48,7 @@ const invoke = async (input) => {
|
|
|
47
48
|
.option('-c, --config <path>', 'where to find the rhachet.use.ts config'); // tell commander that we expect the config input and not to complain about it
|
|
48
49
|
(0, invokeReadme_1.invokeReadme)({ program, registries });
|
|
49
50
|
(0, invokeList_1.invokeList)({ program, registries });
|
|
51
|
+
(0, invokeChoose_1.invokeChoose)({ program });
|
|
50
52
|
(0, invokeAsk_1.invokeAsk)({ program, config: { path: configPath }, registries });
|
|
51
53
|
// invoke it
|
|
52
54
|
await program.parseAsync(input.args, { from: 'user' }).catch((error) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke.js","sourceRoot":"","sources":["../../../src/contract/cli/invoke.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AACpC,mDAAiD;AACjD,yCAAoC;AACpC,+DAAsD;AAEtD,4EAAyE;AACzE,gFAA6E;AAC7E,2CAAwC;AACxC,6CAA0C;AAC1C,iDAA8C;AAE9C;;;;;;;;GAQG;AACI,MAAM,MAAM,GAAG,KAAK,EAAE,KAAyB,EAAiB,EAAE;IACvE,6BAA6B;IAC7B,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;IAC9E,MAAM,kBAAkB,GACtB,SAAS,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACzC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAE;QAC5B,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE;IAC7B,MAAM,UAAU,GAAG,kBAAkB;QACnC,CAAC,CAAC,IAAA,mBAAO,EAAC,GAAG,EAAE,kBAAkB,CAAC;QAClC,CAAC,CAAC,IAAA,mBAAO,EAAC,MAAM,IAAA,qCAAc,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC;IACnE,MAAM,UAAU,GAAG,MAAM,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OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAhDW,QAAA,MAAM,UAgDjB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* .what = adds the "choose" command to the CLI
|
|
4
|
+
* .why = allows users to choose a specific attempt file, archive its peer files, and clean up unrelated ones
|
|
5
|
+
*/
|
|
6
|
+
export declare const invokeChoose: ({ program }: {
|
|
7
|
+
program: Command;
|
|
8
|
+
}) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const commander_1 = require("commander");
|
|
27
|
+
const promises_1 = require("node:fs/promises");
|
|
28
|
+
const path = __importStar(require("node:path"));
|
|
29
|
+
const test_fns_1 = require("test-fns");
|
|
30
|
+
const invokeChoose_1 = require("./invokeChoose");
|
|
31
|
+
// tiny fs helpers
|
|
32
|
+
const exists = async (p) => (0, promises_1.stat)(p)
|
|
33
|
+
.then(() => true)
|
|
34
|
+
.catch(() => false);
|
|
35
|
+
const read = async (p) => (await (0, promises_1.readFile)(p, 'utf8')).trim();
|
|
36
|
+
describe('invokeChoose (integration)', () => {
|
|
37
|
+
(0, test_fns_1.given)('a fixture directory with peer files', () => {
|
|
38
|
+
const fixtureRoot = path.resolve(__dirname + '/.temp/invokeChoose/');
|
|
39
|
+
const peerPrefix = 'provider.scene_6.loyalty_build.v1i2.[stories]';
|
|
40
|
+
const choiceDir = path.join(fixtureRoot);
|
|
41
|
+
const archiveDir = path.join(fixtureRoot, '.archive');
|
|
42
|
+
const peerNames = [
|
|
43
|
+
`${peerPrefix}._.md`,
|
|
44
|
+
`${peerPrefix}.v1._.md`,
|
|
45
|
+
`${peerPrefix}.v1.md`,
|
|
46
|
+
`${peerPrefix}.v1.i1.md`,
|
|
47
|
+
`${peerPrefix}.v1.i2.md`,
|
|
48
|
+
`${peerPrefix}.v1.i3.md`,
|
|
49
|
+
`${peerPrefix}.choice.v1.i3.md`,
|
|
50
|
+
`${peerPrefix}.v1.src`,
|
|
51
|
+
];
|
|
52
|
+
const peerChosen = peerNames[3]; // lets say we're choosing this one
|
|
53
|
+
const unrelated = 'random.txt'; // lets include a non peer too
|
|
54
|
+
const prepareTheScene = async () => {
|
|
55
|
+
// refresh the fixture
|
|
56
|
+
await (0, promises_1.rm)(fixtureRoot, { recursive: true, force: true });
|
|
57
|
+
await (0, promises_1.mkdir)(choiceDir, { recursive: true });
|
|
58
|
+
await (0, promises_1.mkdir)(archiveDir, { recursive: true });
|
|
59
|
+
// write peers with recognizable contents
|
|
60
|
+
await Promise.all(peerNames.map((name, index) => (0, promises_1.writeFile)(path.join(choiceDir, name), `content-${index}`)));
|
|
61
|
+
// an unrelated file that should remain untouched
|
|
62
|
+
await (0, promises_1.writeFile)(path.join(choiceDir, unrelated), 'unrelated-content');
|
|
63
|
+
console.log('🧹 fixture prepared', fixtureRoot);
|
|
64
|
+
};
|
|
65
|
+
beforeAll(async () => {
|
|
66
|
+
await prepareTheScene();
|
|
67
|
+
});
|
|
68
|
+
(0, test_fns_1.when)('invoking choose with a valid chosen attempt', () => {
|
|
69
|
+
// register command
|
|
70
|
+
const program = new commander_1.Command();
|
|
71
|
+
(0, invokeChoose_1.invokeChoose)({ program });
|
|
72
|
+
// declare the choice
|
|
73
|
+
const choicePath = path.join(choiceDir, peerChosen);
|
|
74
|
+
(0, test_fns_1.then)('it should succeed', async () => {
|
|
75
|
+
await program.parseAsync(['choose', '--choice', choicePath, '--archive', '@choice/.archive'], { from: 'user' });
|
|
76
|
+
});
|
|
77
|
+
(0, test_fns_1.then)('it should archive the peers', async () => {
|
|
78
|
+
for (const name of peerNames) {
|
|
79
|
+
const archivedPath = path.join(archiveDir, path.basename(name));
|
|
80
|
+
expect(await exists(archivedPath)).toBe(true);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
(0, test_fns_1.then)('it should archive the peer choice with label', async () => {
|
|
84
|
+
// it should have been archived directly already
|
|
85
|
+
const choiceArchived = path.join(archiveDir, path.basename(peerChosen));
|
|
86
|
+
expect(await exists(choiceArchived)).toBe(true);
|
|
87
|
+
// it should ALSO have been archived with .choice label
|
|
88
|
+
const choiceArchivedLabeled = path.join(archiveDir, path
|
|
89
|
+
.basename(peerChosen)
|
|
90
|
+
.replace(`${peerPrefix}`, `${peerPrefix}.choice`));
|
|
91
|
+
expect(await exists(choiceArchivedLabeled)).toBe(true);
|
|
92
|
+
expect(await read(choiceArchivedLabeled)).toBe(await read(path.join(choiceDir, peerChosen)));
|
|
93
|
+
});
|
|
94
|
+
(0, test_fns_1.then)('it should keep only the .src and choice in the choice directory', async () => {
|
|
95
|
+
// chosen remains in place
|
|
96
|
+
expect(await exists(choicePath)).toBe(true);
|
|
97
|
+
// .src peers remain in place
|
|
98
|
+
expect(await exists(path.join(choiceDir, `${peerPrefix}.v1.src`))).toBe(true);
|
|
99
|
+
// non-source, non-chosen peers should be deleted from workdir
|
|
100
|
+
const shouldBeDeleted = peerNames.filter((p) => !p.endsWith('.src') && p !== peerChosen);
|
|
101
|
+
for (const name of shouldBeDeleted) {
|
|
102
|
+
expect(await exists(path.join(choiceDir, name))).toBe(false);
|
|
103
|
+
}
|
|
104
|
+
// unrelated file should remain untouched
|
|
105
|
+
expect(await exists(path.join(choiceDir, unrelated))).toBe(true);
|
|
106
|
+
expect(await read(path.join(choiceDir, unrelated))).toBe('unrelated-content');
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=invokeChoose.integration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invokeChoose.integration.test.js","sourceRoot":"","sources":["../../../src/contract/cli/invokeChoose.integration.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAoC;AACpC,+CAAwE;AACxE,gDAAkC;AAClC,uCAA6C;AAE7C,iDAA8C;AAE9C,kBAAkB;AAClB,MAAM,MAAM,GAAG,KAAK,EAAE,CAAS,EAAE,EAAE,CACjC,IAAA,eAAI,EAAC,CAAC,CAAC;KACJ,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;KAChB,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AAExB,MAAM,IAAI,GAAG,KAAK,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,MAAM,IAAA,mBAAQ,EAAC,CAAC,EAAE,MA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KAAK,UAAU,CAC/C,CAAC;gBACF,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE,CAAC;oBACnC,MAAM,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC/D,CAAC;gBAED,yCAAyC;gBACzC,MAAM,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACjE,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CACtD,mBAAmB,CACpB,CAAC;YACJ,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.invokeChoose = void 0;
|
|
30
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
31
|
+
const fs = __importStar(require("fs"));
|
|
32
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
33
|
+
const path = __importStar(require("path"));
|
|
34
|
+
const rhachet_artifact_git_1 = require("rhachet-artifact-git");
|
|
35
|
+
const getPeerQualifiersOfOutputChoice_1 = require("../../logic/invoke/getPeerQualifiersOfOutputChoice");
|
|
36
|
+
/**
|
|
37
|
+
* .what = adds the "choose" command to the CLI
|
|
38
|
+
* .why = allows users to choose a specific attempt file, archive its peer files, and clean up unrelated ones
|
|
39
|
+
*/
|
|
40
|
+
const invokeChoose = ({ program }) => {
|
|
41
|
+
program
|
|
42
|
+
.command('choose')
|
|
43
|
+
.requiredOption('--choice <path>', 'path to chosen attempt file (relative)')
|
|
44
|
+
.requiredOption('--archive <dir>', 'directory where peers will be archived')
|
|
45
|
+
.description('select one attempt file, archive its peer files, and remove unrelated ones')
|
|
46
|
+
.action(async (opts) => {
|
|
47
|
+
// standardize the path declarations
|
|
48
|
+
const choicePath = path.resolve(opts.choice);
|
|
49
|
+
const choiceFile = path.basename(choicePath);
|
|
50
|
+
const choiceDir = path.dirname(choicePath);
|
|
51
|
+
// resolve archive dir:
|
|
52
|
+
// - if starts with "@choice/", make it relative to choiceDir
|
|
53
|
+
// - otherwise, resolve relative to cwd as normal
|
|
54
|
+
const archiveDir = opts.archive.startsWith('@choice/')
|
|
55
|
+
? path.join(choiceDir, opts.archive.replace(/^@choice\//, ''))
|
|
56
|
+
: path.resolve(opts.archive);
|
|
57
|
+
// verify choice exists and is valid
|
|
58
|
+
if (!fs.existsSync(choicePath))
|
|
59
|
+
helpful_errors_1.BadRequestError.throw(`choice file not found: ${choicePath}`, { opts });
|
|
60
|
+
if (choiceFile.endsWith('.src'))
|
|
61
|
+
helpful_errors_1.BadRequestError.throw(`--choice cannot be a .src file`, { opts });
|
|
62
|
+
// grab the peer qualifiers
|
|
63
|
+
const peerQualifier = (0, getPeerQualifiersOfOutputChoice_1.getPeerQualifiersOfOutputChoice)(choiceFile);
|
|
64
|
+
if (!peerQualifier.prefix)
|
|
65
|
+
helpful_errors_1.BadRequestError.throw(`unrecognized file naming pattern: ${choiceFile}`);
|
|
66
|
+
// build glob patterns
|
|
67
|
+
const globPeersByExt = path.join(choiceDir, `${peerQualifier.prefix}*.${peerQualifier.extension}`);
|
|
68
|
+
const globPeersBySrc = path.join(choiceDir, `${peerQualifier.prefix}*.src`);
|
|
69
|
+
// collect all peer paths
|
|
70
|
+
const peerPaths = await (0, fast_glob_1.default)([globPeersByExt, globPeersBySrc], {
|
|
71
|
+
cwd: choiceDir,
|
|
72
|
+
onlyFiles: true,
|
|
73
|
+
dot: false,
|
|
74
|
+
absolute: true,
|
|
75
|
+
});
|
|
76
|
+
// copy peer files to archive dir; remove the non.source and the non.chosen
|
|
77
|
+
await Promise.all(peerPaths.map(async (peerPath) => {
|
|
78
|
+
// declare the .into and .from archive files
|
|
79
|
+
const peerDetected = (0, rhachet_artifact_git_1.genArtifactGitFile)({ uri: peerPath });
|
|
80
|
+
const peerArchived = (0, rhachet_artifact_git_1.genArtifactGitFile)({
|
|
81
|
+
uri: path.join(archiveDir, path.basename(peerPath)),
|
|
82
|
+
});
|
|
83
|
+
// grab the detected content
|
|
84
|
+
const peerContent = (await peerDetected.get())?.content ??
|
|
85
|
+
helpful_errors_1.UnexpectedCodePathError.throw('how could a peer detected by prefix not have contents?', {
|
|
86
|
+
path,
|
|
87
|
+
peerQualifier,
|
|
88
|
+
});
|
|
89
|
+
// move into archive
|
|
90
|
+
await peerArchived.set({
|
|
91
|
+
content: peerContent,
|
|
92
|
+
});
|
|
93
|
+
// label the choice file and archive that too
|
|
94
|
+
const isChosen = peerPath.endsWith(opts.choice); // equal to choice (overlap by suffix)
|
|
95
|
+
if (isChosen) {
|
|
96
|
+
const peerArchivedAsChoice = (0, rhachet_artifact_git_1.genArtifactGitFile)({
|
|
97
|
+
uri: peerArchived.ref.uri.replace(peerQualifier.prefix, peerQualifier.prefix + '.choice'),
|
|
98
|
+
});
|
|
99
|
+
await peerArchivedAsChoice.set({ content: peerContent });
|
|
100
|
+
}
|
|
101
|
+
// drop if non source and non chosen .from files
|
|
102
|
+
const isSource = peerPath.endsWith('.src');
|
|
103
|
+
if (!isSource && !isChosen)
|
|
104
|
+
await peerDetected.del();
|
|
105
|
+
}));
|
|
106
|
+
console.log(``);
|
|
107
|
+
console.log(`🏆 choice assigned (${peerPaths.length} archived)`);
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
exports.invokeChoose = invokeChoose;
|
|
111
|
+
//# sourceMappingURL=invokeChoose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invokeChoose.js","sourceRoot":"","sources":["../../../src/contract/cli/invokeChoose.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0DAA6B;AAC7B,uCAAyB;AACzB,mDAA0E;AAC1E,2CAA6B;AAC7B,+DAA0D;AAE1D,wGAAqG;AAErG;;;GAGG;AACI,MAAM,YAAY,GAAG,CAAC,EAAE,OAAO,EAAwB,EAAQ,EAAE;IACtE,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,cAAc,CAAC,iBAAiB,EAAE,wCAAwC,CAAC;SAC3E,cAAc,CAAC,iBAAiB,EAAE,wCA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C/B,aAAa,CAAC,MAAM,EACpB,aAAa,CAAC,MAAM,GAAG,SAAS,CACjC;iBACF,CAAC,CAAC;gBACH,MAAM,oBAAoB,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;YAC3D,CAAC;YAED,gDAAgD;YAChD,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC3C,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ;gBAAE,MAAM,YAAY,CAAC,GAAG,EAAE,CAAC;QACvD,CAAC,CAAC,CACH,CAAC;QAEF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,uBAAuB,SAAS,CAAC,MAAM,YAAY,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAlGW,QAAA,YAAY,gBAkGvB"}
|
|
@@ -34,4 +34,5 @@ __exportStar(require("./RoleSkill"), exports);
|
|
|
34
34
|
__exportStar(require("./RoleSkillArgGetter"), exports);
|
|
35
35
|
__exportStar(require("./RoleTrait"), exports);
|
|
36
36
|
__exportStar(require("./Template"), exports);
|
|
37
|
+
__exportStar(require("./InvokeOpts"), exports);
|
|
37
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -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;AAE5B,yCAAuB;AACvB,gDAA8B;AAC9B,iDAA+B;AAC/B,8CAA4B;AAC5B,uDAAqC;AACrC,8CAA4B;AAE5B,6CAA2B"}
|
|
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;AAC3B,+CAA6B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = extracts the peer prefix and extension from a chosen file
|
|
3
|
+
* .why = used to identify all peer files sharing the same base name
|
|
4
|
+
*
|
|
5
|
+
* supports trailing qualifier tokens (zero or more) before the final extension:
|
|
6
|
+
* - .v{number}
|
|
7
|
+
* - .i{number}
|
|
8
|
+
* - ._
|
|
9
|
+
* - .{word} (e.g., .choice)
|
|
10
|
+
*
|
|
11
|
+
* examples (prefix ► extension):
|
|
12
|
+
* - foo.[stories]._.md ► foo.[stories] ► md
|
|
13
|
+
* - foo.[stories].v1._.md ► foo.[stories] ► md
|
|
14
|
+
* - foo.[stories].v1.i3.md ► foo.[stories] ► md
|
|
15
|
+
* - foo.[stories].choice.v1.i3.md ► foo.[stories] ► md
|
|
16
|
+
* - foo.[stories].src ► foo.[stories] ► src
|
|
17
|
+
* - foo.[stories].v1.src ► foo.[stories] ► src
|
|
18
|
+
* - foo.[notes].i2.txt ► foo.[notes] ► txt
|
|
19
|
+
*/
|
|
20
|
+
export declare const getPeerQualifiersOfOutputChoice: (choice: string) => {
|
|
21
|
+
prefix: string;
|
|
22
|
+
extension: string;
|
|
23
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPeerQualifiersOfOutputChoice = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
/**
|
|
6
|
+
* .what = extracts the peer prefix and extension from a chosen file
|
|
7
|
+
* .why = used to identify all peer files sharing the same base name
|
|
8
|
+
*
|
|
9
|
+
* supports trailing qualifier tokens (zero or more) before the final extension:
|
|
10
|
+
* - .v{number}
|
|
11
|
+
* - .i{number}
|
|
12
|
+
* - ._
|
|
13
|
+
* - .{word} (e.g., .choice)
|
|
14
|
+
*
|
|
15
|
+
* examples (prefix ► extension):
|
|
16
|
+
* - foo.[stories]._.md ► foo.[stories] ► md
|
|
17
|
+
* - foo.[stories].v1._.md ► foo.[stories] ► md
|
|
18
|
+
* - foo.[stories].v1.i3.md ► foo.[stories] ► md
|
|
19
|
+
* - foo.[stories].choice.v1.i3.md ► foo.[stories] ► md
|
|
20
|
+
* - foo.[stories].src ► foo.[stories] ► src
|
|
21
|
+
* - foo.[stories].v1.src ► foo.[stories] ► src
|
|
22
|
+
* - foo.[notes].i2.txt ► foo.[notes] ► txt
|
|
23
|
+
*/
|
|
24
|
+
const getPeerQualifiersOfOutputChoice = (choice) => {
|
|
25
|
+
// grab the last dotted segment as the extension
|
|
26
|
+
const extMatch = choice.match(/^(.+)\.([A-Za-z0-9]+)$/);
|
|
27
|
+
if (!extMatch)
|
|
28
|
+
helpful_errors_1.BadRequestError.throw(`unrecognized file naming pattern`, { choice });
|
|
29
|
+
// instantiate a mutable base
|
|
30
|
+
let base = extMatch[1] ??
|
|
31
|
+
helpful_errors_1.UnexpectedCodePathError.throw('how is there no base?', {
|
|
32
|
+
extMatch,
|
|
33
|
+
choice,
|
|
34
|
+
});
|
|
35
|
+
const extension = extMatch[2];
|
|
36
|
+
// strip trailing qualifier tokens like .v1, .i3, ._, .choice (in that order, repeatedly)
|
|
37
|
+
const QUALIFIER_RE = /\.(?:v\d+|i\d+|_|[a-z][a-z0-9_-]*)$/i;
|
|
38
|
+
while (QUALIFIER_RE.test(base)) {
|
|
39
|
+
base = base.replace(QUALIFIER_RE, '');
|
|
40
|
+
}
|
|
41
|
+
const prefix = base ??
|
|
42
|
+
helpful_errors_1.BadRequestError.throw('could not extract prefix from output choice', {
|
|
43
|
+
choice,
|
|
44
|
+
});
|
|
45
|
+
const ext = extension ??
|
|
46
|
+
helpful_errors_1.BadRequestError.throw('could not extract extension from output choice', {
|
|
47
|
+
choice,
|
|
48
|
+
});
|
|
49
|
+
return { prefix, extension: ext };
|
|
50
|
+
};
|
|
51
|
+
exports.getPeerQualifiersOfOutputChoice = getPeerQualifiersOfOutputChoice;
|
|
52
|
+
//# sourceMappingURL=getPeerQualifiersOfOutputChoice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPeerQualifiersOfOutputChoice.js","sourceRoot":"","sources":["../../../src/logic/invoke/getPeerQualifiersOfOutputChoice.ts"],"names":[],"mappings":";;;AAAA,mDAA0E;AAE1E;;;;;;;;;;;;;;;;;;GAkBG;AACI,MAAM,+BAA+B,GAAG,CAC7C,MAAc,EACyB,EAAE;IACzC,gDAAgD;IAChD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACxD,IAAI,CAAC,QAAQ;QACX,gCAAe,CAAC,KAAK,CAAC,kCAAkC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAExE,6BAA6B;IAC7B,IAAI,IAAI,GACN,QAAQ,CAAC,CAAC,CAAC;QACX,wCAAuB,CAAC,KAAK,CAAC,uBAAuB,EAAE;YACrD,QAAQ;YACR,MAAM;SACP,CAAC,CAAC;IACL,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE9B,yFAAyF;IACzF,MAAM,YAAY,GAAG,sCAAsC,CAAC;IAC5D,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,MAAM,GACV,IAAI;QACJ,gCAAe,CAAC,KAAK,CAAC,6CAA6C,EAAE;YACnE,MAAM;SACP,CAAC,CAAC;IAEL,MAAM,GAAG,GACP,SAAS;QACT,gCAAe,CAAC,KAAK,CAAC,gDAAgD,EAAE;YACtE,MAAM;SACP,CAAC,CAAC;IAEL,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;AACpC,CAAC,CAAC;AApCW,QAAA,+BAA+B,mCAoC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
4
|
+
const getPeerQualifiersOfOutputChoice_1 = require("./getPeerQualifiersOfOutputChoice");
|
|
5
|
+
const validCases = [
|
|
6
|
+
{
|
|
7
|
+
peers: [
|
|
8
|
+
'provider.scene_6.loyalty_build.v1i2.[stories]._.md',
|
|
9
|
+
'provider.scene_6.loyalty_build.v1i2.[stories].v1._.md',
|
|
10
|
+
'provider.scene_6.loyalty_build.v1i2.[stories].v1.md',
|
|
11
|
+
'provider.scene_6.loyalty_build.v1i2.[stories].v1.i1.md',
|
|
12
|
+
'provider.scene_6.loyalty_build.v1i2.[stories].v1.i2.md',
|
|
13
|
+
'provider.scene_6.loyalty_build.v1i2.[stories].v1.i3.md',
|
|
14
|
+
'provider.scene_6.loyalty_build.v1i2.[stories].choice.v1.i3.md',
|
|
15
|
+
'provider.scene_6.loyalty_build.v1i2.[stories].choice.i5.md',
|
|
16
|
+
],
|
|
17
|
+
output: {
|
|
18
|
+
prefix: 'provider.scene_6.loyalty_build.v1i2.[stories]',
|
|
19
|
+
extension: 'md',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
peers: [
|
|
24
|
+
'provider.scene_6.loyalty_build.v1i2.[stories].src',
|
|
25
|
+
'provider.scene_6.loyalty_build.v1i2.[stories].v1.src',
|
|
26
|
+
],
|
|
27
|
+
output: {
|
|
28
|
+
prefix: 'provider.scene_6.loyalty_build.v1i2.[stories]',
|
|
29
|
+
extension: 'src',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
peers: [
|
|
34
|
+
'provider.scene_6.loyalty_build.v2i5.[notes].i1.txt',
|
|
35
|
+
'provider.scene_6.loyalty_build.v2i5.[notes].i2.txt',
|
|
36
|
+
],
|
|
37
|
+
output: {
|
|
38
|
+
prefix: 'provider.scene_6.loyalty_build.v2i5.[notes]',
|
|
39
|
+
extension: 'txt',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
peers: [
|
|
44
|
+
'provider.scene_6.loyalty_build.v1i0.[draft]._.md',
|
|
45
|
+
'provider.scene_6.loyalty_build.v1i0.[draft].i1.md',
|
|
46
|
+
],
|
|
47
|
+
output: {
|
|
48
|
+
prefix: 'provider.scene_6.loyalty_build.v1i0.[draft]',
|
|
49
|
+
extension: 'md',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
describe('getPeerQualifiersOfOutputChoice', () => {
|
|
54
|
+
validCases.forEach(({ peers, output }) => {
|
|
55
|
+
describe(`peers ${output.prefix}`, () => {
|
|
56
|
+
peers.forEach((choice) => {
|
|
57
|
+
test(`returns correct prefix and extension for choice "${choice}"`, () => {
|
|
58
|
+
expect((0, getPeerQualifiersOfOutputChoice_1.getPeerQualifiersOfOutputChoice)(choice)).toEqual(output);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
const invalidCases = [
|
|
64
|
+
// 'provider.scene_6.loyalty_build.v1i2.[stories]', // no extension
|
|
65
|
+
// 'provider.scene_6.loyalty_build.v1i2.[stories]', // no extension
|
|
66
|
+
// 'just_something_random', // completely malformed
|
|
67
|
+
// 'file.without.any.structure', // another malformed
|
|
68
|
+
];
|
|
69
|
+
describe('invalid input cases', () => {
|
|
70
|
+
invalidCases.forEach((input) => {
|
|
71
|
+
test(`throws BadRequestError for "${input}"`, () => {
|
|
72
|
+
expect(() => (0, getPeerQualifiersOfOutputChoice_1.getPeerQualifiersOfOutputChoice)(input)).toThrow(helpful_errors_1.BadRequestError);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=getPeerQualifiersOfOutputChoice.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPeerQualifiersOfOutputChoice.test.js","sourceRoot":"","sources":["../../../src/logic/invoke/getPeerQualifiersOfOutputChoice.test.ts"],"names":[],"mappings":";;AAAA,mDAAiD;AAEjD,uFAAoF;AAEpF,MAAM,UAAU,GAGV;IACJ;QACE,KAAK,EAAE;YACL,oDAAoD;YACpD,uDAAuD;YACvD,qDAAqD;YACrD,wDAAwD;YACxD,wDAAwD;YACxD,wDAAwD;YACxD,+DAA+D;YAC/D,4DAA4D;SAC7D;QACD,MAAM,EAAE;YACN,MAAM,EAAE,+CAA+C;YACvD,SAAS,EAAE,IAAI;SAChB;KACF;IACD;QACE,KAAK,EAAE;YACL,mDAAmD;YACnD,sDAAsD;SACvD;QACD,MAAM,EAAE;YACN,MAAM,EAAE,+CAA+C;YACvD,SAAS,EAAE,KAAK;SACjB;KACF;IACD;QACE,KAAK,EAAE;YACL,oDAAoD;YACpD,oDAAoD;SACrD;QACD,MAAM,EAAE;YACN,MAAM,EAAE,6CAA6C;YACrD,SAAS,EAAE,KAAK;SACjB;KACF;IACD;QACE,KAAK,EAAE;YACL,kDAAkD;YAClD,mDAAmD;SACpD;QACD,MAAM,EAAE;YACN,MAAM,EAAE,6CAA6C;YACrD,SAAS,EAAE,IAAI;SAChB;KACF;CACF,CAAC;AAEF,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC/C,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;QACvC,QAAQ,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE;YACtC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;gBACvB,IAAI,CAAC,oDAAoD,MAAM,GAAG,EAAE,GAAG,EAAE;oBACvE,MAAM,CAAC,IAAA,iEAA+B,EAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClE,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,YAAY,GAAa;IAC7B,mEAAmE;IACnE,mEAAmE;IACnE,mDAAmD;IACnD,qDAAqD;KACtD,CAAC;IAEF,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACnC,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC7B,IAAI,CAAC,+BAA+B,KAAK,GAAG,EAAE,GAAG,EAAE;gBACjD,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,iEAA+B,EAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAC1D,gCAAe,CAChB,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
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.8.0",
|
|
6
6
|
"repository": "ehmpathy/rhachet",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/rhachet",
|
|
8
8
|
"keywords": [
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"chalk": "4.1.2",
|
|
58
58
|
"commander": "14.0.0",
|
|
59
59
|
"domain-objects": "0.25.2",
|
|
60
|
+
"fast-glob": "3.3.3",
|
|
60
61
|
"flattie": "1.1.1",
|
|
61
62
|
"helpful-errors": "1.3.8",
|
|
62
63
|
"openai": "5.8.2",
|