rhachet-roles-bhuild 0.5.1 → 0.5.3
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/bind.behavior.d.ts +16 -0
- package/dist/contract/cli/bind.behavior.js +96 -0
- package/dist/contract/cli/bind.behavior.js.map +1 -0
- package/dist/contract/cli/boot.behavior.d.ts +10 -0
- package/dist/contract/cli/boot.behavior.js +90 -0
- package/dist/contract/cli/boot.behavior.js.map +1 -0
- package/dist/contract/cli/decompose.behavior.d.ts +19 -0
- package/dist/contract/cli/decompose.behavior.js +231 -0
- package/dist/contract/cli/decompose.behavior.js.map +1 -0
- package/dist/contract/cli/init.behavior.d.ts +27 -0
- package/dist/contract/cli/init.behavior.js +99 -0
- package/dist/contract/cli/init.behavior.js.map +1 -0
- package/dist/contract/cli/review.behavior.d.ts +16 -0
- package/dist/contract/cli/review.behavior.js +91 -0
- package/dist/contract/cli/review.behavior.js.map +1 -0
- package/dist/domain.operations/behavior/bind/delBranchBehaviorBind.d.ts +16 -0
- package/dist/domain.operations/behavior/bind/delBranchBehaviorBind.js +37 -0
- package/dist/domain.operations/behavior/bind/delBranchBehaviorBind.js.map +1 -0
- package/dist/domain.operations/behavior/bind/{getBoundBehaviorByBranch.d.ts → getBranchBehaviorBind.d.ts} +4 -3
- package/dist/domain.operations/behavior/bind/{getBoundBehaviorByBranch.js → getBranchBehaviorBind.js} +18 -18
- package/dist/domain.operations/behavior/bind/getBranchBehaviorBind.js.map +1 -0
- package/dist/domain.operations/behavior/bind/getCurrentBranch.d.ts +8 -0
- package/dist/domain.operations/behavior/bind/getCurrentBranch.js +17 -0
- package/dist/domain.operations/behavior/bind/getCurrentBranch.js.map +1 -0
- package/dist/domain.operations/behavior/bind/index.d.ts +4 -1
- package/dist/domain.operations/behavior/bind/index.js +9 -3
- package/dist/domain.operations/behavior/bind/index.js.map +1 -1
- package/dist/domain.operations/behavior/bind/setBranchBehaviorBind.d.ts +18 -0
- package/dist/domain.operations/behavior/bind/setBranchBehaviorBind.js +50 -0
- package/dist/domain.operations/behavior/bind/setBranchBehaviorBind.js.map +1 -0
- package/dist/domain.operations/behavior/decompose/applyPlan.d.ts +1 -1
- package/dist/domain.operations/behavior/decompose/applyPlan.js +2 -2
- package/dist/domain.operations/behavior/decompose/applyPlan.js.map +1 -1
- package/dist/domain.operations/behavior/decompose/computePlanFromFile.js +4 -4
- package/dist/domain.operations/behavior/decompose/computePlanFromFile.js.map +1 -1
- package/dist/domain.operations/behavior/getBehaviorDir.d.ts +11 -0
- package/dist/domain.operations/behavior/getBehaviorDir.js +38 -0
- package/dist/domain.operations/behavior/getBehaviorDir.js.map +1 -0
- package/dist/domain.operations/behavior/index.d.ts +1 -0
- package/dist/domain.operations/behavior/index.js +6 -0
- package/dist/domain.operations/behavior/index.js.map +1 -0
- package/dist/domain.operations/behavior/init/index.d.ts +1 -0
- package/dist/domain.operations/behavior/init/index.js +6 -0
- package/dist/domain.operations/behavior/init/index.js.map +1 -0
- package/dist/domain.operations/behavior/init/initBehaviorDir.d.ts +18 -0
- package/dist/domain.operations/behavior/init/initBehaviorDir.js +43 -0
- package/dist/domain.operations/behavior/init/initBehaviorDir.js.map +1 -0
- package/dist/domain.operations/behavior/init/templates/.ref.[feedback].v1.[given].by_human.md +27 -0
- package/dist/domain.operations/behavior/init/templates/0.wish.md +2 -0
- package/dist/domain.operations/behavior/init/templates/1.vision.md +1 -0
- package/dist/domain.operations/behavior/init/templates/2.criteria.blackbox.md +16 -0
- package/dist/domain.operations/behavior/init/templates/2.criteria.blackbox.src +31 -0
- package/dist/domain.operations/behavior/init/templates/2.criteria.blueprint.md +26 -0
- package/dist/domain.operations/behavior/init/templates/2.criteria.blueprint.src +34 -0
- package/dist/domain.operations/behavior/init/templates/3.1.research.domain._.v1.src +35 -0
- package/dist/domain.operations/behavior/init/templates/3.2.distill.domain._.v1.src +14 -0
- package/dist/domain.operations/behavior/init/templates/3.3.blueprint.v1.src +29 -0
- package/dist/domain.operations/behavior/init/templates/4.1.roadmap.v1.src +20 -0
- package/dist/domain.operations/behavior/init/templates/5.1.execution.phase0_to_phaseN.v1.src +22 -0
- package/dist/domain.roles/behaver/inits/claude.hooks/sessionstart.boot-behavior.sh +2 -96
- package/dist/domain.roles/behaver/skills/bind.behavior.sh +2 -229
- package/dist/domain.roles/behaver/skills/init.behavior.sh +2 -449
- package/dist/domain.roles/decomposer/skills/decompose.behavior.sh +2 -284
- package/dist/domain.roles/decomposer/skills/review.behavior.sh +2 -162
- package/dist/index.d.ts +7 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/infra/cli/getCliArgs.d.ts +52 -0
- package/dist/infra/cli/getCliArgs.js +95 -0
- package/dist/infra/cli/getCliArgs.js.map +1 -0
- package/dist/infra/cli/index.d.ts +1 -0
- package/dist/infra/cli/index.js +7 -0
- package/dist/infra/cli/index.js.map +1 -0
- package/package.json +13 -9
- package/readme.md +75 -25
- package/dist/domain.operations/behavior/bind/flattenBranchName.cli.d.ts +0 -2
- package/dist/domain.operations/behavior/bind/flattenBranchName.cli.js +0 -19
- package/dist/domain.operations/behavior/bind/flattenBranchName.cli.js.map +0 -1
- package/dist/domain.operations/behavior/bind/getBoundBehaviorByBranch.cli.d.ts +0 -2
- package/dist/domain.operations/behavior/bind/getBoundBehaviorByBranch.cli.js +0 -18
- package/dist/domain.operations/behavior/bind/getBoundBehaviorByBranch.cli.js.map +0 -1
- package/dist/domain.operations/behavior/bind/getBoundBehaviorByBranch.js.map +0 -1
- package/dist/domain.operations/behavior/bind/getLatestBlueprintByBehavior.cli.d.ts +0 -2
- package/dist/domain.operations/behavior/bind/getLatestBlueprintByBehavior.cli.js +0 -20
- package/dist/domain.operations/behavior/bind/getLatestBlueprintByBehavior.cli.js.map +0 -1
- package/dist/domain.operations/behavior/decompose/applyPlan.cli.d.ts +0 -2
- package/dist/domain.operations/behavior/decompose/applyPlan.cli.js +0 -36
- package/dist/domain.operations/behavior/decompose/applyPlan.cli.js.map +0 -1
- package/dist/domain.operations/behavior/decompose/computeContextConsumption.cli.d.ts +0 -2
- package/dist/domain.operations/behavior/decompose/computeContextConsumption.cli.js +0 -44
- package/dist/domain.operations/behavior/decompose/computeContextConsumption.cli.js.map +0 -1
- package/dist/domain.operations/behavior/decompose/imaginePlan.cli.d.ts +0 -2
- package/dist/domain.operations/behavior/decompose/imaginePlan.cli.js +0 -89
- package/dist/domain.operations/behavior/decompose/imaginePlan.cli.js.map +0 -1
- package/dist/domain.roles/behaver/readme.md +0 -3
- package/dist/domain.roles/behaver/skills/review.behavior.test.utils.d.ts +0 -12
- package/dist/domain.roles/behaver/skills/review.behavior.test.utils.js +0 -63
- package/dist/domain.roles/behaver/skills/review.behavior.test.utils.js.map +0 -1
- package/dist/domain.roles/decomposer/readme.md +0 -3
- package/dist/domain.roles/readme.md +0 -21
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = bind, unbind, or query branch-to-behavior bound
|
|
3
|
+
*
|
|
4
|
+
* .why = explicit user control over which behavior applies to current branch
|
|
5
|
+
*
|
|
6
|
+
* usage:
|
|
7
|
+
* bind.behavior.sh set --behavior <name> bind current branch
|
|
8
|
+
* bind.behavior.sh del unbind current branch
|
|
9
|
+
* bind.behavior.sh get query current bound
|
|
10
|
+
*
|
|
11
|
+
* guarantee:
|
|
12
|
+
* - fail-fast if behavior not found or ambiguous
|
|
13
|
+
* - fail-fast if set to different behavior (suggest del or worktree)
|
|
14
|
+
* - idempotent: set to same behavior succeeds, del when unbound succeeds
|
|
15
|
+
*/
|
|
16
|
+
export declare const bindBehavior: () => void;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* .what = bind, unbind, or query branch-to-behavior bound
|
|
4
|
+
*
|
|
5
|
+
* .why = explicit user control over which behavior applies to current branch
|
|
6
|
+
*
|
|
7
|
+
* usage:
|
|
8
|
+
* bind.behavior.sh set --behavior <name> bind current branch
|
|
9
|
+
* bind.behavior.sh del unbind current branch
|
|
10
|
+
* bind.behavior.sh get query current bound
|
|
11
|
+
*
|
|
12
|
+
* guarantee:
|
|
13
|
+
* - fail-fast if behavior not found or ambiguous
|
|
14
|
+
* - fail-fast if set to different behavior (suggest del or worktree)
|
|
15
|
+
* - idempotent: set to same behavior succeeds, del when unbound succeeds
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.bindBehavior = void 0;
|
|
19
|
+
const path_1 = require("path");
|
|
20
|
+
const zod_1 = require("zod");
|
|
21
|
+
const behavior_1 = require("../../domain.operations/behavior");
|
|
22
|
+
const bind_1 = require("../../domain.operations/behavior/bind");
|
|
23
|
+
const cli_1 = require("../../infra/cli");
|
|
24
|
+
// ────────────────────────────────────────────────────────────────────
|
|
25
|
+
// schema
|
|
26
|
+
// ────────────────────────────────────────────────────────────────────
|
|
27
|
+
const schemaOfArgs = zod_1.z.object({
|
|
28
|
+
named: zod_1.z.object({
|
|
29
|
+
// skill-specific args
|
|
30
|
+
behavior: zod_1.z.string().optional(),
|
|
31
|
+
dir: zod_1.z.string().optional(),
|
|
32
|
+
// rhachet passthrough args (optional, ignored)
|
|
33
|
+
repo: zod_1.z.string().optional(),
|
|
34
|
+
role: zod_1.z.string().optional(),
|
|
35
|
+
skill: zod_1.z.string().optional(),
|
|
36
|
+
s: zod_1.z.string().optional(),
|
|
37
|
+
}),
|
|
38
|
+
ordered: zod_1.z.array(zod_1.z.string()).default([]),
|
|
39
|
+
});
|
|
40
|
+
// ────────────────────────────────────────────────────────────────────
|
|
41
|
+
// exported CLI entry point
|
|
42
|
+
// ────────────────────────────────────────────────────────────────────
|
|
43
|
+
const bindBehavior = () => {
|
|
44
|
+
const { named, ordered } = (0, cli_1.getCliArgs)({ schema: schemaOfArgs });
|
|
45
|
+
// action is first ordered arg
|
|
46
|
+
const action = ordered[0];
|
|
47
|
+
const cwd = named.dir ?? process.cwd();
|
|
48
|
+
if (!action) {
|
|
49
|
+
console.error('error: no action specified');
|
|
50
|
+
console.error('usage: bind.behavior.sh <set|get|del> [--behavior <name>] [--dir <path>]');
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
if (!['set', 'get', 'del'].includes(action)) {
|
|
54
|
+
console.error(`error: unknown action '${action}'`);
|
|
55
|
+
console.error('usage: bind.behavior.sh <set|get|del> [--behavior <name>] [--dir <path>]');
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
const context = { cwd };
|
|
59
|
+
const branchName = (0, bind_1.getCurrentBranch)({}, context);
|
|
60
|
+
// dispatch
|
|
61
|
+
if (action === 'get') {
|
|
62
|
+
const result = (0, bind_1.getBranchBehaviorBind)({ branchName }, context);
|
|
63
|
+
if (!result.behaviorDir) {
|
|
64
|
+
console.log('not bound');
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
console.log(`bound to: ${(0, path_1.basename)(result.behaviorDir)}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (action === 'set') {
|
|
71
|
+
const behaviorName = named.behavior;
|
|
72
|
+
if (!behaviorName) {
|
|
73
|
+
console.error('error: --behavior is required with set');
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
const behaviorDir = (0, behavior_1.getBehaviorDir)({ name: behaviorName, targetDir: cwd });
|
|
77
|
+
const result = (0, bind_1.setBranchBehaviorBind)({ branchName, behaviorDir }, context);
|
|
78
|
+
if (!result.success) {
|
|
79
|
+
console.error(`error: ${result.message}`);
|
|
80
|
+
console.error('');
|
|
81
|
+
console.error('to rebind, first unbind with:');
|
|
82
|
+
console.error(' bind.behavior.sh del');
|
|
83
|
+
console.error('');
|
|
84
|
+
console.error('or use a new worktree for the new behavior:');
|
|
85
|
+
console.error(' git worktree add ../<new-branch> -b <new-branch>');
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
console.log(`✓ ${result.message}`);
|
|
89
|
+
}
|
|
90
|
+
else if (action === 'del') {
|
|
91
|
+
const result = (0, bind_1.delBranchBehaviorBind)({ branchName }, context);
|
|
92
|
+
console.log(`✓ ${result.message}`);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
exports.bindBehavior = bindBehavior;
|
|
96
|
+
//# sourceMappingURL=bind.behavior.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind.behavior.js","sourceRoot":"","sources":["../../../src/contract/cli/bind.behavior.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,+BAAgC;AAChC,6BAAwB;AAExB,8DAAiE;AACjE,+DAK8C;AAC9C,wCAA4C;AAE5C,uEAAuE;AACvE,SAAS;AACT,uEAAuE;AAEvE,MAAM,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,sBAAsB;QACtB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC/B,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC1B,+CAA+C;QAC/C,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC3B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC3B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC5B,CAAC,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACzB,CAAC;IACF,OAAO,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CACzC,CAAC,CAAC;AAEH,uEAAuE;AACvE,2BAA2B;AAC3B,uEAAuE;AAEhE,MAAM,YAAY,GAAG,GAAS,EAAE;IACrC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GA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6DvB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = output bound behavior context for session start
|
|
3
|
+
* .why = agent starts with full awareness of current behavior
|
|
4
|
+
*
|
|
5
|
+
* guarantee:
|
|
6
|
+
* ✔ exits 0 silently if branch not bound (unbound = normal work)
|
|
7
|
+
* ✔ exits 0 with warning if multiple binds (don't block session)
|
|
8
|
+
* ✔ never blocks session start (exit 0 always)
|
|
9
|
+
*/
|
|
10
|
+
export declare const bootBehavior: () => void;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* .what = output bound behavior context for session start
|
|
4
|
+
* .why = agent starts with full awareness of current behavior
|
|
5
|
+
*
|
|
6
|
+
* guarantee:
|
|
7
|
+
* ✔ exits 0 silently if branch not bound (unbound = normal work)
|
|
8
|
+
* ✔ exits 0 with warning if multiple binds (don't block session)
|
|
9
|
+
* ✔ never blocks session start (exit 0 always)
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.bootBehavior = void 0;
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const path_1 = require("path");
|
|
15
|
+
const bind_1 = require("../../domain.operations/behavior/bind");
|
|
16
|
+
// ────────────────────────────────────────────────────────────────────
|
|
17
|
+
// helpers
|
|
18
|
+
// ────────────────────────────────────────────────────────────────────
|
|
19
|
+
const outputBehaviorFile = (tag, filepath, isRequired) => {
|
|
20
|
+
if ((0, fs_1.existsSync)(filepath)) {
|
|
21
|
+
const relpath = (0, path_1.relative)(process.cwd(), filepath);
|
|
22
|
+
console.log(`<behavior-${tag} path="${relpath}">`);
|
|
23
|
+
console.log((0, fs_1.readFileSync)(filepath, 'utf-8'));
|
|
24
|
+
console.log(`</behavior-${tag}>`);
|
|
25
|
+
console.log('');
|
|
26
|
+
}
|
|
27
|
+
else if (isRequired) {
|
|
28
|
+
console.error(`⚠️ required file not found: ${filepath}`);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
// ────────────────────────────────────────────────────────────────────
|
|
32
|
+
// exported CLI entry point
|
|
33
|
+
// ────────────────────────────────────────────────────────────────────
|
|
34
|
+
const bootBehavior = () => {
|
|
35
|
+
// get current branch (exit silently if not in git repo)
|
|
36
|
+
let currentBranch;
|
|
37
|
+
try {
|
|
38
|
+
currentBranch = (0, bind_1.getCurrentBranch)({});
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
process.exit(0);
|
|
42
|
+
}
|
|
43
|
+
if (!currentBranch) {
|
|
44
|
+
process.exit(0);
|
|
45
|
+
}
|
|
46
|
+
// check if bound
|
|
47
|
+
const bindResult = (0, bind_1.getBranchBehaviorBind)({ branchName: currentBranch });
|
|
48
|
+
const behaviorDir = bindResult.behaviorDir;
|
|
49
|
+
const bindsCount = bindResult.binds.length;
|
|
50
|
+
// if not bound, exit silently
|
|
51
|
+
if (!behaviorDir) {
|
|
52
|
+
// check for multiple binds (conflict)
|
|
53
|
+
if (bindsCount > 1) {
|
|
54
|
+
console.error(`⚠️ warning: branch '${currentBranch}' has conflicting binds:`);
|
|
55
|
+
bindResult.binds.forEach((bind) => {
|
|
56
|
+
console.error(` - ${(0, path_1.basename)(bind)}`);
|
|
57
|
+
});
|
|
58
|
+
console.error("use 'bind.behavior.sh --del' to unbind and 'bind.behavior.sh --set' to rebind");
|
|
59
|
+
}
|
|
60
|
+
process.exit(0);
|
|
61
|
+
}
|
|
62
|
+
// extract behavior name from path
|
|
63
|
+
const behaviorName = (0, path_1.basename)(behaviorDir);
|
|
64
|
+
// output behavior context
|
|
65
|
+
console.log('==================================================');
|
|
66
|
+
console.log(`BOUND BEHAVIOR: ${behaviorName}`);
|
|
67
|
+
console.log('==================================================');
|
|
68
|
+
console.log('');
|
|
69
|
+
// output wish (required)
|
|
70
|
+
outputBehaviorFile('wish', `${behaviorDir}/0.wish.md`, true);
|
|
71
|
+
// output vision (optional)
|
|
72
|
+
outputBehaviorFile('vision', `${behaviorDir}/1.vision.md`, false);
|
|
73
|
+
// output criteria (optional - check for both new and legacy formats)
|
|
74
|
+
if ((0, fs_1.existsSync)(`${behaviorDir}/2.criteria.blackbox.md`)) {
|
|
75
|
+
outputBehaviorFile('criteria-blackbox', `${behaviorDir}/2.criteria.blackbox.md`, false);
|
|
76
|
+
outputBehaviorFile('criteria-blueprint', `${behaviorDir}/2.criteria.blueprint.md`, false);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// fallback to legacy single criteria file
|
|
80
|
+
outputBehaviorFile('criteria', `${behaviorDir}/2.criteria.md`, false);
|
|
81
|
+
}
|
|
82
|
+
// output latest blueprint (optional)
|
|
83
|
+
const latestBlueprint = (0, bind_1.getLatestBlueprintByBehavior)({ behaviorDir });
|
|
84
|
+
if (latestBlueprint && (0, fs_1.existsSync)(latestBlueprint)) {
|
|
85
|
+
outputBehaviorFile('blueprint', latestBlueprint, false);
|
|
86
|
+
}
|
|
87
|
+
console.log('==================================================');
|
|
88
|
+
};
|
|
89
|
+
exports.bootBehavior = bootBehavior;
|
|
90
|
+
//# sourceMappingURL=boot.behavior.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boot.behavior.js","sourceRoot":"","sources":["../../../src/contract/cli/boot.behavior.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,2BAA8C;AAC9C,+BAA0C;AAE1C,+DAI8C;AAE9C,uEAAuE;AACvE,UAAU;AACV,uEAAuE;AAEvE,MAAM,kBAAkB,GAAG,CACzB,GAAW,EACX,QAAgB,EAChB,UAAmB,EACb,EAAE;IACR,IAAI,IAAA,eAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,IAAA,eAAQ,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,UAAU,OAAO,IAAI,CAAC,CAAC;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D,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC;AACpE,CAAC,CAAC;AA1EW,QAAA,YAAY,gBA0EvB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = decompose a behavior into focused sub-behaviors
|
|
3
|
+
*
|
|
4
|
+
* .why = enables large behaviors to be split into independent,
|
|
5
|
+
* focused sub-behaviors that fit within context window limits
|
|
6
|
+
* and respect bounded context boundaries
|
|
7
|
+
*
|
|
8
|
+
* usage:
|
|
9
|
+
* npx tsx decompose.behavior.ts --of <behavior-name> --mode plan [--dir <path>]
|
|
10
|
+
* npx tsx decompose.behavior.ts --of <behavior-name> --mode apply --plan <plan-file> [--dir <path>]
|
|
11
|
+
*
|
|
12
|
+
* guarantee:
|
|
13
|
+
* - fail-fast if behavior not found or ambiguous
|
|
14
|
+
* - fail-fast if behavior has no criteria
|
|
15
|
+
* - fail-fast if --mode apply without --plan
|
|
16
|
+
* - fail-fast if behavior already decomposed (z.decomposed.md present)
|
|
17
|
+
* - idempotent: safe to rerun
|
|
18
|
+
*/
|
|
19
|
+
export declare const decomposeBehavior: () => Promise<void>;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* .what = decompose a behavior into focused sub-behaviors
|
|
4
|
+
*
|
|
5
|
+
* .why = enables large behaviors to be split into independent,
|
|
6
|
+
* focused sub-behaviors that fit within context window limits
|
|
7
|
+
* and respect bounded context boundaries
|
|
8
|
+
*
|
|
9
|
+
* usage:
|
|
10
|
+
* npx tsx decompose.behavior.ts --of <behavior-name> --mode plan [--dir <path>]
|
|
11
|
+
* npx tsx decompose.behavior.ts --of <behavior-name> --mode apply --plan <plan-file> [--dir <path>]
|
|
12
|
+
*
|
|
13
|
+
* guarantee:
|
|
14
|
+
* - fail-fast if behavior not found or ambiguous
|
|
15
|
+
* - fail-fast if behavior has no criteria
|
|
16
|
+
* - fail-fast if --mode apply without --plan
|
|
17
|
+
* - fail-fast if behavior already decomposed (z.decomposed.md present)
|
|
18
|
+
* - idempotent: safe to rerun
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
32
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
33
|
+
}) : function(o, v) {
|
|
34
|
+
o["default"] = v;
|
|
35
|
+
});
|
|
36
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.decomposeBehavior = void 0;
|
|
45
|
+
const fs_1 = require("fs");
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
const zod_1 = require("zod");
|
|
48
|
+
const BehaviorPersisted_1 = require("../../domain.objects/BehaviorPersisted");
|
|
49
|
+
const behavior_1 = require("../../domain.operations/behavior");
|
|
50
|
+
const applyPlan_1 = require("../../domain.operations/behavior/decompose/applyPlan");
|
|
51
|
+
const computePlanFromFile_1 = require("../../domain.operations/behavior/decompose/computePlanFromFile");
|
|
52
|
+
const imaginePlan_1 = require("../../domain.operations/behavior/decompose/imaginePlan");
|
|
53
|
+
const invokeBrainRepl_1 = require("../../infra/brain/invokeBrainRepl");
|
|
54
|
+
const loadBriefs_1 = require("../../infra/brain/loadBriefs");
|
|
55
|
+
const cli_1 = require("../../infra/cli");
|
|
56
|
+
// ────────────────────────────────────────────────────────────────────
|
|
57
|
+
// schema
|
|
58
|
+
// ────────────────────────────────────────────────────────────────────
|
|
59
|
+
const schemaOfArgs = zod_1.z.object({
|
|
60
|
+
named: zod_1.z.object({
|
|
61
|
+
// skill-specific args
|
|
62
|
+
of: zod_1.z.string(),
|
|
63
|
+
mode: zod_1.z.enum(['plan', 'apply']),
|
|
64
|
+
plan: zod_1.z.string().optional(),
|
|
65
|
+
dir: zod_1.z.string().optional(),
|
|
66
|
+
// rhachet passthrough args (optional, ignored)
|
|
67
|
+
repo: zod_1.z.string().optional(),
|
|
68
|
+
role: zod_1.z.string().optional(),
|
|
69
|
+
skill: zod_1.z.string().optional(),
|
|
70
|
+
s: zod_1.z.string().optional(),
|
|
71
|
+
}),
|
|
72
|
+
ordered: zod_1.z.array(zod_1.z.string()).default([]),
|
|
73
|
+
});
|
|
74
|
+
// ────────────────────────────────────────────────────────────────────
|
|
75
|
+
// mode: plan
|
|
76
|
+
// ────────────────────────────────────────────────────────────────────
|
|
77
|
+
const modePlan = async (behaviorDir, behaviorName) => {
|
|
78
|
+
const behaviorDirRel = path.relative(process.cwd(), behaviorDir);
|
|
79
|
+
console.log('');
|
|
80
|
+
console.log("🦫 let's decompose!");
|
|
81
|
+
console.log('');
|
|
82
|
+
console.log('🍄 decompose.behavior --mode plan');
|
|
83
|
+
console.log(`├── behavior = ${behaviorDirRel}`);
|
|
84
|
+
console.log('├── criteria = found');
|
|
85
|
+
console.log('└── status = plan in progress...');
|
|
86
|
+
console.log('');
|
|
87
|
+
// construct behavior domain object
|
|
88
|
+
const behavior = new BehaviorPersisted_1.BehaviorPersisted({
|
|
89
|
+
name: behaviorName,
|
|
90
|
+
path: behaviorDir,
|
|
91
|
+
});
|
|
92
|
+
// load decompose briefs
|
|
93
|
+
const roleDir = path.join(__dirname, '../../domain.roles/decomposer');
|
|
94
|
+
const briefs = await (0, loadBriefs_1.loadBriefs)({
|
|
95
|
+
roleDir,
|
|
96
|
+
skillName: 'decompose',
|
|
97
|
+
});
|
|
98
|
+
const role = { briefs };
|
|
99
|
+
// construct context with brain.repl
|
|
100
|
+
const context = {
|
|
101
|
+
brain: {
|
|
102
|
+
repl: {
|
|
103
|
+
imagine: (input) => (0, invokeBrainRepl_1.invokeBrainRepl)({
|
|
104
|
+
prompt: input.prompt,
|
|
105
|
+
role: input.role,
|
|
106
|
+
outputFormat: input.outputFormat,
|
|
107
|
+
}),
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
// invoke imaginePlan
|
|
112
|
+
const plan = await (0, imaginePlan_1.imaginePlan)({ behavior, role }, context);
|
|
113
|
+
// write plan to file
|
|
114
|
+
const planOutput = path.join(behaviorDir, 'z.plan.decomposition.v1.json');
|
|
115
|
+
(0, fs_1.writeFileSync)(planOutput, JSON.stringify(plan, null, 2));
|
|
116
|
+
const planOutputRel = path.relative(process.cwd(), planOutput);
|
|
117
|
+
// output summary
|
|
118
|
+
console.log('🌲 plan generated');
|
|
119
|
+
console.log(`├── file = ${planOutputRel}`);
|
|
120
|
+
console.log(`├── behaviors proposed = ${plan.behaviorsProposed.length}`);
|
|
121
|
+
console.log(`├── context window = ${plan.contextAnalysis.usage.window.percentage}%`);
|
|
122
|
+
console.log(`└── recommendation = ${plan.contextAnalysis.recommendation}`);
|
|
123
|
+
console.log('');
|
|
124
|
+
console.log('🌲 proposed behaviors');
|
|
125
|
+
plan.behaviorsProposed.forEach((b, i) => {
|
|
126
|
+
const deps = b.dependsOn.length === 0 ? 'none' : b.dependsOn.join(', ');
|
|
127
|
+
const prefix = i === plan.behaviorsProposed.length - 1 ? '└──' : '├──';
|
|
128
|
+
console.log(`${prefix} ${b.name} (depends on: ${deps})`);
|
|
129
|
+
});
|
|
130
|
+
console.log('');
|
|
131
|
+
console.log('🌲 next step');
|
|
132
|
+
console.log('├── review the plan');
|
|
133
|
+
console.log(`└── decompose.behavior --of ${behaviorName} --mode apply --plan ${planOutputRel}`);
|
|
134
|
+
console.log('');
|
|
135
|
+
};
|
|
136
|
+
// ────────────────────────────────────────────────────────────────────
|
|
137
|
+
// mode: apply
|
|
138
|
+
// ────────────────────────────────────────────────────────────────────
|
|
139
|
+
const modeApply = async (behaviorDir, planFile) => {
|
|
140
|
+
const behaviorDirRel = path.relative(process.cwd(), behaviorDir);
|
|
141
|
+
console.log('');
|
|
142
|
+
console.log("🦫 let's decompose!");
|
|
143
|
+
console.log('');
|
|
144
|
+
console.log('🍄 decompose.behavior --mode apply');
|
|
145
|
+
console.log(`├── behavior = ${behaviorDirRel}`);
|
|
146
|
+
console.log(`├── plan = ${planFile}`);
|
|
147
|
+
console.log('└── status = apply in progress...');
|
|
148
|
+
console.log('');
|
|
149
|
+
// load plan from file
|
|
150
|
+
const plan = await (0, computePlanFromFile_1.computePlanFromFile)({ planPath: planFile });
|
|
151
|
+
// apply the plan
|
|
152
|
+
const result = await (0, applyPlan_1.applyPlan)({ plan });
|
|
153
|
+
// output summary
|
|
154
|
+
console.log('🌲 plan applied');
|
|
155
|
+
console.log(`├── behaviors created = ${result.behaviorsCreated.length}`);
|
|
156
|
+
console.log(`└── marker = ${result.decomposedMarkerPath}`);
|
|
157
|
+
console.log('');
|
|
158
|
+
console.log('🌲 created behaviors');
|
|
159
|
+
result.behaviorsCreated.forEach((behaviorPath, i) => {
|
|
160
|
+
const prefix = i === result.behaviorsCreated.length - 1 ? '└──' : '├──';
|
|
161
|
+
console.log(`${prefix} ${path.basename(behaviorPath)}`);
|
|
162
|
+
});
|
|
163
|
+
console.log('');
|
|
164
|
+
console.log('🌲 next steps');
|
|
165
|
+
console.log('├── define criteria for each sub-behavior');
|
|
166
|
+
console.log('└── execute each sub-behavior independently');
|
|
167
|
+
console.log('');
|
|
168
|
+
};
|
|
169
|
+
// ────────────────────────────────────────────────────────────────────
|
|
170
|
+
// exported CLI entry point
|
|
171
|
+
// ────────────────────────────────────────────────────────────────────
|
|
172
|
+
const decomposeBehavior = async () => {
|
|
173
|
+
const { named } = (0, cli_1.getCliArgs)({ schema: schemaOfArgs });
|
|
174
|
+
const behaviorName = named.of;
|
|
175
|
+
const mode = named.mode;
|
|
176
|
+
const planFile = named.plan ?? '';
|
|
177
|
+
const targetDir = named.dir ?? process.cwd();
|
|
178
|
+
// validate apply mode requires plan
|
|
179
|
+
if (mode === 'apply' && !planFile) {
|
|
180
|
+
console.error('error: --plan required for apply mode');
|
|
181
|
+
console.error('hint: produce one via --mode plan first');
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
184
|
+
if (mode === 'apply' && planFile && !(0, fs_1.existsSync)(planFile)) {
|
|
185
|
+
console.error(`error: plan file not found: ${planFile}`);
|
|
186
|
+
process.exit(1);
|
|
187
|
+
}
|
|
188
|
+
// get behavior directory
|
|
189
|
+
const behaviorDir = (0, behavior_1.getBehaviorDir)({ name: behaviorName, targetDir });
|
|
190
|
+
const behaviorDirRel = path.relative(process.cwd(), behaviorDir);
|
|
191
|
+
// criteria validation
|
|
192
|
+
const filesInDir = (0, fs_1.readdirSync)(behaviorDir);
|
|
193
|
+
const criteriaFile = filesInDir.find((f) => f.endsWith('.criteria.md'));
|
|
194
|
+
if (!criteriaFile) {
|
|
195
|
+
console.error('error: criteria required for decomposition');
|
|
196
|
+
console.error(`behavior: ${behaviorDirRel}`);
|
|
197
|
+
console.error('hint: run behaver bind.criteria first');
|
|
198
|
+
process.exit(1);
|
|
199
|
+
}
|
|
200
|
+
// already decomposed check
|
|
201
|
+
const decomposedFile = path.join(behaviorDir, 'z.decomposed.md');
|
|
202
|
+
if ((0, fs_1.existsSync)(decomposedFile)) {
|
|
203
|
+
if (mode === 'plan') {
|
|
204
|
+
console.log('warn: behavior already decomposed');
|
|
205
|
+
console.log(`behavior: ${behaviorDirRel}`);
|
|
206
|
+
console.log('');
|
|
207
|
+
console.log('peer sub-behaviors:');
|
|
208
|
+
const content = (0, fs_1.readFileSync)(decomposedFile, 'utf-8');
|
|
209
|
+
const lines = content.split('\n').filter((l) => l.startsWith('- '));
|
|
210
|
+
lines.forEach((l) => console.log(` ${l}`));
|
|
211
|
+
console.log('');
|
|
212
|
+
console.log('hint: remove z.decomposed.md to re-decompose');
|
|
213
|
+
process.exit(0);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
console.error('error: behavior already decomposed');
|
|
217
|
+
console.error(`behavior: ${behaviorDirRel}`);
|
|
218
|
+
console.error('hint: remove z.decomposed.md to re-decompose');
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// dispatch to mode
|
|
223
|
+
if (mode === 'plan') {
|
|
224
|
+
await modePlan(behaviorDir, behaviorName);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
await modeApply(behaviorDir, planFile);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
exports.decomposeBehavior = decomposeBehavior;
|
|
231
|
+
//# sourceMappingURL=decompose.behavior.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decompose.behavior.js","sourceRoot":"","sources":["../../../src/contract/cli/decompose.behavior.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2BAA0E;AAC1E,2CAA6B;AAC7B,6BAAwB;AAExB,6EAA0E;AAC1E,8DAAiE;AACjE,mFAAgF;AAChF,uGAAoG;AACpG,uFAAoF;AACpF,sEAAmE;AACnE,4DAAyD;AACzD,wCAA4C;AAE5C,uEAAuE;AACvE,SAAS;AACT,uEAAuE;AAEvE,MAAM,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IA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AO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;YACnC,MAAM,OAAO,GAAG,IAAA,iBAAY,EAAC,cAAc,EAAE,OAAO,CAAC,CAAC;YACtD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;YACpE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;YAC5C,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;YAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;YACpD,OAAO,CAAC,KAAK,CAAC,aAAa,cAAc,EAAE,CAAC,CAAC;YAC7C,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;YAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,mBAAmB;IACnB,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,MAAM,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAC5C,CAAC;SAAM,CAAC;QACN,MAAM,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;AACH,CAAC,CAAC;AA7DW,QAAA,iBAAiB,qBA6D5B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = initialize a .behavior directory for bhuild thoughtroute
|
|
3
|
+
*
|
|
4
|
+
* .why = standardize the behavior-driven development thoughtroute
|
|
5
|
+
* by creating a structured directory with:
|
|
6
|
+
* - wish definition
|
|
7
|
+
* - vision statement
|
|
8
|
+
* - blackbox criteria (user-facing behavioral requirements)
|
|
9
|
+
* - blueprint criteria (implementation requirements)
|
|
10
|
+
* - research prompts
|
|
11
|
+
* - distillation prompts
|
|
12
|
+
* - blueprint prompts
|
|
13
|
+
* - roadmap prompts
|
|
14
|
+
* - execution prompts
|
|
15
|
+
* - feedback template
|
|
16
|
+
*
|
|
17
|
+
* usage:
|
|
18
|
+
* npx tsx src/contract/cli/init.behavior.ts --name <behaviorname> [--dir <directory>]
|
|
19
|
+
*
|
|
20
|
+
* guarantee:
|
|
21
|
+
* - creates .behavior/ if not found
|
|
22
|
+
* - creates versioned behavior directory
|
|
23
|
+
* - findserts all thoughtroute files (creates if not found, skips if exists)
|
|
24
|
+
* - idempotent: safe to rerun
|
|
25
|
+
* - fail-fast on errors
|
|
26
|
+
*/
|
|
27
|
+
export declare const initBehavior: () => void;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* .what = initialize a .behavior directory for bhuild thoughtroute
|
|
4
|
+
*
|
|
5
|
+
* .why = standardize the behavior-driven development thoughtroute
|
|
6
|
+
* by creating a structured directory with:
|
|
7
|
+
* - wish definition
|
|
8
|
+
* - vision statement
|
|
9
|
+
* - blackbox criteria (user-facing behavioral requirements)
|
|
10
|
+
* - blueprint criteria (implementation requirements)
|
|
11
|
+
* - research prompts
|
|
12
|
+
* - distillation prompts
|
|
13
|
+
* - blueprint prompts
|
|
14
|
+
* - roadmap prompts
|
|
15
|
+
* - execution prompts
|
|
16
|
+
* - feedback template
|
|
17
|
+
*
|
|
18
|
+
* usage:
|
|
19
|
+
* npx tsx src/contract/cli/init.behavior.ts --name <behaviorname> [--dir <directory>]
|
|
20
|
+
*
|
|
21
|
+
* guarantee:
|
|
22
|
+
* - creates .behavior/ if not found
|
|
23
|
+
* - creates versioned behavior directory
|
|
24
|
+
* - findserts all thoughtroute files (creates if not found, skips if exists)
|
|
25
|
+
* - idempotent: safe to rerun
|
|
26
|
+
* - fail-fast on errors
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.initBehavior = void 0;
|
|
30
|
+
const path_1 = require("path");
|
|
31
|
+
const zod_1 = require("zod");
|
|
32
|
+
const bind_1 = require("../../domain.operations/behavior/bind");
|
|
33
|
+
const init_1 = require("../../domain.operations/behavior/init");
|
|
34
|
+
const cli_1 = require("../../infra/cli");
|
|
35
|
+
// ────────────────────────────────────────────────────────────────────
|
|
36
|
+
// schema
|
|
37
|
+
// ────────────────────────────────────────────────────────────────────
|
|
38
|
+
const schemaOfArgs = zod_1.z.object({
|
|
39
|
+
named: zod_1.z.object({
|
|
40
|
+
// skill-specific args
|
|
41
|
+
name: zod_1.z.string(),
|
|
42
|
+
dir: zod_1.z.string().optional(),
|
|
43
|
+
// rhachet passthrough args (optional, ignored)
|
|
44
|
+
repo: zod_1.z.string().optional(),
|
|
45
|
+
role: zod_1.z.string().optional(),
|
|
46
|
+
skill: zod_1.z.string().optional(),
|
|
47
|
+
s: zod_1.z.string().optional(),
|
|
48
|
+
}),
|
|
49
|
+
ordered: zod_1.z.array(zod_1.z.string()).default([]),
|
|
50
|
+
});
|
|
51
|
+
// ────────────────────────────────────────────────────────────────────
|
|
52
|
+
// exported CLI entry point
|
|
53
|
+
// ────────────────────────────────────────────────────────────────────
|
|
54
|
+
const initBehavior = () => {
|
|
55
|
+
const { named } = (0, cli_1.getCliArgs)({ schema: schemaOfArgs });
|
|
56
|
+
const behaviorName = named.name;
|
|
57
|
+
const rawTargetDir = named.dir ?? process.cwd();
|
|
58
|
+
const context = { cwd: rawTargetDir };
|
|
59
|
+
// get current branch
|
|
60
|
+
const currentBranch = (0, bind_1.getCurrentBranch)({}, context);
|
|
61
|
+
// check if branch already bound
|
|
62
|
+
const bindResult = (0, bind_1.getBranchBehaviorBind)({ branchName: currentBranch }, context);
|
|
63
|
+
if (bindResult.behaviorDir) {
|
|
64
|
+
console.error(`⛈️ error: branch '${currentBranch}' is already bound to: ${(0, path_1.basename)(bindResult.behaviorDir)}`);
|
|
65
|
+
console.error('');
|
|
66
|
+
console.error('to create a new behavior, use a new tree:');
|
|
67
|
+
console.error(' git tree set --from main --open <branch-name-new>');
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
// normalize target dir (trim trailing .behavior)
|
|
71
|
+
const targetDir = rawTargetDir.replace(/\/?\.behavior\/?$/, '');
|
|
72
|
+
// generate isodate in format YYYY_MM_DD
|
|
73
|
+
const now = new Date();
|
|
74
|
+
const isoDate = `${now.getFullYear()}_${String(now.getMonth() + 1).padStart(2, '0')}_${String(now.getDate()).padStart(2, '0')}`;
|
|
75
|
+
// construct behavior directory path (absolute)
|
|
76
|
+
const behaviorDir = (0, path_1.join)(targetDir, '.behavior', `v${isoDate}.${behaviorName}`);
|
|
77
|
+
// compute relative path from caller's PWD for file contents
|
|
78
|
+
let behaviorDirRel = (0, path_1.join)((0, path_1.relative)(process.cwd(), targetDir), '.behavior', `v${isoDate}.${behaviorName}`);
|
|
79
|
+
// normalize: remove leading ./ if present
|
|
80
|
+
behaviorDirRel = behaviorDirRel.replace(/^\.\//, '');
|
|
81
|
+
// initialize behavior directory with template files
|
|
82
|
+
const result = (0, init_1.initBehaviorDir)({ behaviorDir, behaviorDirRel });
|
|
83
|
+
// log results
|
|
84
|
+
for (const file of result.kept) {
|
|
85
|
+
console.log(` [KEEP] ${file}`);
|
|
86
|
+
}
|
|
87
|
+
for (const file of result.created) {
|
|
88
|
+
console.log(` [CREATE] ${file}`);
|
|
89
|
+
}
|
|
90
|
+
// auto-bind: bind current branch to newly created behavior
|
|
91
|
+
(0, bind_1.setBranchBehaviorBind)({ branchName: currentBranch, behaviorDir, boundBy: 'init.behavior skill' }, context);
|
|
92
|
+
console.log('');
|
|
93
|
+
console.log('behavior thoughtroute initialized!');
|
|
94
|
+
console.log(` ${behaviorDir}`);
|
|
95
|
+
console.log('');
|
|
96
|
+
console.log(`branch '${currentBranch}' bound to: v${isoDate}.${behaviorName}`);
|
|
97
|
+
};
|
|
98
|
+
exports.initBehavior = initBehavior;
|
|
99
|
+
//# sourceMappingURL=init.behavior.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.behavior.js","sourceRoot":"","sources":["../../../src/contract/cli/init.behavior.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAEH,+BAAgD;AAChD,6BAAwB;AAExB,+DAI8C;AAC9C,+DAAuE;AACvE,wCAA4C;AAE5C,uEAAuE;AACvE,SAAS;AACT,uEAAuE;AAEvE,MAAM,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,sBAAsB;QACtB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;QAChB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC1B,+CAA+C;QAC/C,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC3B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC3B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC5B,CAAC,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACzB,CAAC;IACF,OAAO,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CACzC,CAAC,CAAC;AAEH,uEAAuE;AACvE,2BAA2B;AAC3B,uEAAuE;AAEhE,MAAM,YAAY,GAAG,GAAS,EAAE;IACrC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,gBAAU,EAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IACvD,MAAM,YAAY,GAAG,KAAK,CAAC,I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*
|
|
4
|
+
* .why = enables detection of behaviors that have grown too large
|
|
5
|
+
* for reliable execution, by measurement of context pressure
|
|
6
|
+
* and domain breadth, with recommendation to decompose
|
|
7
|
+
*
|
|
8
|
+
* usage:
|
|
9
|
+
* npx tsx src/contract/cli/review.behavior.ts --of <behavior-name> [--dir <path>]
|
|
10
|
+
*
|
|
11
|
+
* guarantee:
|
|
12
|
+
* - fail-fast if behavior not found or ambiguous
|
|
13
|
+
* - fail-fast if behavior has no criteria (required for analysis)
|
|
14
|
+
* - idempotent: safe to rerun
|
|
15
|
+
*/
|
|
16
|
+
export declare const reviewBehavior: () => Promise<void>;
|