rhachet-roles-bhuild 0.4.1 → 0.5.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.
Files changed (72) hide show
  1. package/dist/domain.objects/BehaviorDecompositionContextAnalysis.d.ts +22 -0
  2. package/dist/domain.objects/BehaviorDecompositionContextAnalysis.js +8 -0
  3. package/dist/domain.objects/BehaviorDecompositionContextAnalysis.js.map +1 -0
  4. package/dist/domain.objects/BehaviorDecompositionPlan.d.ts +34 -0
  5. package/dist/domain.objects/BehaviorDecompositionPlan.js +16 -0
  6. package/dist/domain.objects/BehaviorDecompositionPlan.js.map +1 -0
  7. package/dist/domain.objects/BehaviorDecompositionProposed.d.ts +31 -0
  8. package/dist/domain.objects/BehaviorDecompositionProposed.js +8 -0
  9. package/dist/domain.objects/BehaviorDecompositionProposed.js.map +1 -0
  10. package/dist/domain.objects/BehaviorPersisted.d.ts +18 -0
  11. package/dist/domain.objects/BehaviorPersisted.js +8 -0
  12. package/dist/domain.objects/BehaviorPersisted.js.map +1 -0
  13. package/dist/domain.operations/behavior/decompose/applyPlan.cli.d.ts +2 -0
  14. package/dist/domain.operations/behavior/decompose/applyPlan.cli.js +36 -0
  15. package/dist/domain.operations/behavior/decompose/applyPlan.cli.js.map +1 -0
  16. package/dist/domain.operations/behavior/decompose/applyPlan.d.ts +11 -0
  17. package/dist/domain.operations/behavior/decompose/applyPlan.js +171 -0
  18. package/dist/domain.operations/behavior/decompose/applyPlan.js.map +1 -0
  19. package/dist/domain.operations/behavior/decompose/computeContextConsumption.cli.d.ts +2 -0
  20. package/dist/domain.operations/behavior/decompose/computeContextConsumption.cli.js +44 -0
  21. package/dist/domain.operations/behavior/decompose/computeContextConsumption.cli.js.map +1 -0
  22. package/dist/domain.operations/behavior/decompose/computeContextConsumption.d.ts +9 -0
  23. package/dist/domain.operations/behavior/decompose/computeContextConsumption.js +77 -0
  24. package/dist/domain.operations/behavior/decompose/computeContextConsumption.js.map +1 -0
  25. package/dist/domain.operations/behavior/decompose/computePlanFromFile.d.ts +8 -0
  26. package/dist/domain.operations/behavior/decompose/computePlanFromFile.js +69 -0
  27. package/dist/domain.operations/behavior/decompose/computePlanFromFile.js.map +1 -0
  28. package/dist/domain.operations/behavior/decompose/imaginePlan.cli.d.ts +2 -0
  29. package/dist/domain.operations/behavior/decompose/imaginePlan.cli.js +89 -0
  30. package/dist/domain.operations/behavior/decompose/imaginePlan.cli.js.map +1 -0
  31. package/dist/domain.operations/behavior/decompose/imaginePlan.d.ts +15 -0
  32. package/dist/domain.operations/behavior/decompose/imaginePlan.js +127 -0
  33. package/dist/domain.operations/behavior/decompose/imaginePlan.js.map +1 -0
  34. package/dist/domain.roles/behaver/briefs/practices/behavior.criteria/define.behavior-thoughtroute-hierarchy.md +81 -0
  35. package/dist/domain.roles/behaver/briefs/practices/behavior.criteria/define.criteria-blackbox-vs-blueprint.md +91 -0
  36. package/dist/domain.roles/behaver/briefs/practices/behavior.criteria/define.criteria-blackbox.md +67 -0
  37. package/dist/domain.roles/behaver/briefs/practices/behavior.criteria/define.criteria-blueprint.md +89 -0
  38. package/dist/domain.roles/behaver/briefs/practices/behavior.criteria/rule.require.blackbox-no-implementation.md +51 -0
  39. package/dist/domain.roles/behaver/briefs/practices/behavior.criteria/rule.require.blueprint-contract-layer-only.md +65 -0
  40. package/dist/domain.roles/behaver/inits/claude.hooks/sessionstart.boot-behavior.sh +8 -2
  41. package/dist/domain.roles/behaver/skills/init.behavior.sh +109 -19
  42. package/dist/domain.roles/decomposer/briefs/decompose/rule.require.contexts.bounded.md +18 -0
  43. package/dist/domain.roles/decomposer/briefs/decompose/rule.require.dependencies.directional.md +14 -0
  44. package/dist/domain.roles/decomposer/briefs/decompose/rule.require.names.ubiquitous.md +17 -0
  45. package/dist/domain.roles/decomposer/briefs/decompose/rule.require.vision.scoped.md +18 -0
  46. package/dist/domain.roles/decomposer/briefs/decompose/rule.require.wish.scoped.md +18 -0
  47. package/dist/domain.roles/decomposer/briefs/review/rule.require.context.threshold.md +17 -0
  48. package/dist/domain.roles/decomposer/briefs/review/rule.require.domain.bounded.md +15 -0
  49. package/dist/domain.roles/decomposer/getDecomposerRole.d.ts +2 -0
  50. package/dist/domain.roles/decomposer/getDecomposerRole.js +24 -0
  51. package/dist/domain.roles/decomposer/getDecomposerRole.js.map +1 -0
  52. package/dist/domain.roles/decomposer/getDecomposerRole.readme.d.ts +1 -0
  53. package/dist/domain.roles/decomposer/getDecomposerRole.readme.js +9 -0
  54. package/dist/domain.roles/decomposer/getDecomposerRole.readme.js.map +1 -0
  55. package/dist/domain.roles/decomposer/skills/decompose.behavior.sh +291 -0
  56. package/dist/domain.roles/decomposer/skills/review.behavior.sh +169 -0
  57. package/dist/domain.roles/getRoleRegistry.d.ts +1 -1
  58. package/dist/domain.roles/getRoleRegistry.js +3 -2
  59. package/dist/domain.roles/getRoleRegistry.js.map +1 -1
  60. package/dist/domain.roles/getRoleRegistry.readme.js +6 -0
  61. package/dist/domain.roles/getRoleRegistry.readme.js.map +1 -1
  62. package/dist/infra/brain/BrainReplContext.d.ts +29 -0
  63. package/dist/infra/brain/BrainReplContext.js +3 -0
  64. package/dist/infra/brain/BrainReplContext.js.map +1 -0
  65. package/dist/infra/brain/invokeBrainRepl.d.ts +11 -0
  66. package/dist/infra/brain/invokeBrainRepl.js +37 -0
  67. package/dist/infra/brain/invokeBrainRepl.js.map +1 -0
  68. package/dist/infra/brain/loadBriefs.d.ts +10 -0
  69. package/dist/infra/brain/loadBriefs.js +58 -0
  70. package/dist/infra/brain/loadBriefs.js.map +1 -0
  71. package/package.json +1 -1
  72. package/readme.md +1 -1
@@ -0,0 +1,22 @@
1
+ import { DomainLiteral } from 'domain-objects';
2
+ /**
3
+ * .what = context window consumption analysis for behavior decomposition
4
+ * .why = quantifies whether decomposition is needed based on artifact size
5
+ */
6
+ interface BehaviorDecompositionContextAnalysis {
7
+ usage: {
8
+ characters: {
9
+ quantity: number;
10
+ };
11
+ tokens: {
12
+ estimate: number;
13
+ };
14
+ window: {
15
+ percentage: number;
16
+ };
17
+ };
18
+ recommendation: 'DECOMPOSE_REQUIRED' | 'DECOMPOSE_UNNEEDED';
19
+ }
20
+ declare class BehaviorDecompositionContextAnalysis extends DomainLiteral<BehaviorDecompositionContextAnalysis> implements BehaviorDecompositionContextAnalysis {
21
+ }
22
+ export { BehaviorDecompositionContextAnalysis };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BehaviorDecompositionContextAnalysis = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class BehaviorDecompositionContextAnalysis extends domain_objects_1.DomainLiteral {
6
+ }
7
+ exports.BehaviorDecompositionContextAnalysis = BehaviorDecompositionContextAnalysis;
8
+ //# sourceMappingURL=BehaviorDecompositionContextAnalysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BehaviorDecompositionContextAnalysis.js","sourceRoot":"","sources":["../../src/domain.objects/BehaviorDecompositionContextAnalysis.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAc/C,MAAM,oCACJ,SAAQ,8BAAmD;CACT;AAE3C,oFAAoC"}
@@ -0,0 +1,34 @@
1
+ import { DomainLiteral } from 'domain-objects';
2
+ import { BehaviorDecompositionContextAnalysis } from './BehaviorDecompositionContextAnalysis';
3
+ import { BehaviorDecompositionProposed } from './BehaviorDecompositionProposed';
4
+ import { BehaviorPersisted } from './BehaviorPersisted';
5
+ /**
6
+ * .what = a plan to decompose a behavior into focused sub behaviors
7
+ * .why = enables review before apply, supports iterative refinement
8
+ */
9
+ interface BehaviorDecompositionPlan {
10
+ /**
11
+ * source behavior to decompose
12
+ */
13
+ behaviorSource: BehaviorPersisted;
14
+ /**
15
+ * proposed behaviors
16
+ */
17
+ behaviorsProposed: BehaviorDecompositionProposed[];
18
+ /**
19
+ * context window analysis
20
+ */
21
+ contextAnalysis: BehaviorDecompositionContextAnalysis;
22
+ /**
23
+ * timestamp of plan generation
24
+ */
25
+ generatedAt: string;
26
+ }
27
+ declare class BehaviorDecompositionPlan extends DomainLiteral<BehaviorDecompositionPlan> implements BehaviorDecompositionPlan {
28
+ static nested: {
29
+ behaviorSource: typeof BehaviorPersisted;
30
+ behaviorsProposed: typeof BehaviorDecompositionProposed;
31
+ contextAnalysis: typeof BehaviorDecompositionContextAnalysis;
32
+ };
33
+ }
34
+ export { BehaviorDecompositionPlan };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BehaviorDecompositionPlan = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ const BehaviorDecompositionContextAnalysis_1 = require("./BehaviorDecompositionContextAnalysis");
6
+ const BehaviorDecompositionProposed_1 = require("./BehaviorDecompositionProposed");
7
+ const BehaviorPersisted_1 = require("./BehaviorPersisted");
8
+ class BehaviorDecompositionPlan extends domain_objects_1.DomainLiteral {
9
+ }
10
+ exports.BehaviorDecompositionPlan = BehaviorDecompositionPlan;
11
+ BehaviorDecompositionPlan.nested = {
12
+ behaviorSource: BehaviorPersisted_1.BehaviorPersisted,
13
+ behaviorsProposed: BehaviorDecompositionProposed_1.BehaviorDecompositionProposed,
14
+ contextAnalysis: BehaviorDecompositionContextAnalysis_1.BehaviorDecompositionContextAnalysis,
15
+ };
16
+ //# sourceMappingURL=BehaviorDecompositionPlan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BehaviorDecompositionPlan.js","sourceRoot":"","sources":["../../src/domain.objects/BehaviorDecompositionPlan.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAE/C,iGAA8F;AAC9F,mFAAgF;AAChF,2DAAwD;AA2BxD,MAAM,yBACJ,SAAQ,8BAAwC;;AAUzC,8DAAyB;AAPlB,gCAAM,GAAG;IACrB,cAAc,EAAE,qCAAiB;IACjC,iBAAiB,EAAE,6DAA6B;IAChD,eAAe,EAAE,2EAAoC;CACtD,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { DomainLiteral } from 'domain-objects';
2
+ /**
3
+ * .what = a proposed behavior within a decomposition plan
4
+ * .why = captures the decomposed scope for a single behavior
5
+ */
6
+ interface BehaviorDecompositionProposed {
7
+ /**
8
+ * proposed name for behavior directory
9
+ */
10
+ name: string;
11
+ /**
12
+ * behaviors this one depends on (by name)
13
+ */
14
+ dependsOn: string[];
15
+ /**
16
+ * decomposed content from parent behavior
17
+ */
18
+ decomposed: {
19
+ /**
20
+ * decomposed wish content
21
+ */
22
+ wish: string;
23
+ /**
24
+ * decomposed vision content (null if source vision was empty)
25
+ */
26
+ vision: string | null;
27
+ };
28
+ }
29
+ declare class BehaviorDecompositionProposed extends DomainLiteral<BehaviorDecompositionProposed> implements BehaviorDecompositionProposed {
30
+ }
31
+ export { BehaviorDecompositionProposed };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BehaviorDecompositionProposed = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class BehaviorDecompositionProposed extends domain_objects_1.DomainLiteral {
6
+ }
7
+ exports.BehaviorDecompositionProposed = BehaviorDecompositionProposed;
8
+ //# sourceMappingURL=BehaviorDecompositionProposed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BehaviorDecompositionProposed.js","sourceRoot":"","sources":["../../src/domain.objects/BehaviorDecompositionProposed.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAgC/C,MAAM,6BACJ,SAAQ,8BAA4C;CACT;AAEpC,sEAA6B"}
@@ -0,0 +1,18 @@
1
+ import { DomainLiteral } from 'domain-objects';
2
+ /**
3
+ * .what = a behavior that has been persisted to disk
4
+ * .why = encapsulates where a behavior lives (path + name) as a cohesive domain concept
5
+ */
6
+ interface BehaviorPersisted {
7
+ /**
8
+ * behavior name (e.g., "large-feature")
9
+ */
10
+ name: string;
11
+ /**
12
+ * absolute path to behavior directory
13
+ */
14
+ path: string;
15
+ }
16
+ declare class BehaviorPersisted extends DomainLiteral<BehaviorPersisted> implements BehaviorPersisted {
17
+ }
18
+ export { BehaviorPersisted };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BehaviorPersisted = void 0;
4
+ const domain_objects_1 = require("domain-objects");
5
+ class BehaviorPersisted extends domain_objects_1.DomainLiteral {
6
+ }
7
+ exports.BehaviorPersisted = BehaviorPersisted;
8
+ //# sourceMappingURL=BehaviorPersisted.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BehaviorPersisted.js","sourceRoot":"","sources":["../../src/domain.objects/BehaviorPersisted.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAiB/C,MAAM,iBACJ,SAAQ,8BAAgC;CACT;AAExB,8CAAiB"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env npx tsx
2
+ export {};
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env npx tsx
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const applyPlan_1 = require("./applyPlan");
5
+ const computePlanFromFile_1 = require("./computePlanFromFile");
6
+ /**
7
+ * .what = CLI entry point for applyPlan
8
+ * .why = enables shell scripts to call this operation via npx tsx
9
+ */
10
+ const main = async () => {
11
+ // parse args
12
+ const args = process.argv.slice(2);
13
+ let planPath;
14
+ for (let i = 0; i < args.length; i++) {
15
+ if (args[i] === '--plan-path' && args[i + 1]) {
16
+ planPath = args[i + 1];
17
+ i++;
18
+ }
19
+ }
20
+ // validate
21
+ if (!planPath) {
22
+ console.error('usage: applyPlan.cli.ts --plan-path <path>');
23
+ process.exit(1);
24
+ }
25
+ // load plan from file
26
+ const plan = await (0, computePlanFromFile_1.computePlanFromFile)({ planPath });
27
+ // apply the plan
28
+ const result = await (0, applyPlan_1.applyPlan)({ plan });
29
+ // output as JSON
30
+ console.log(JSON.stringify(result, null, 2));
31
+ };
32
+ main().catch((err) => {
33
+ console.error('error:', err.message);
34
+ process.exit(1);
35
+ });
36
+ //# sourceMappingURL=applyPlan.cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyPlan.cli.js","sourceRoot":"","sources":["../../../../src/domain.operations/behavior/decompose/applyPlan.cli.ts"],"names":[],"mappings":";;;AAEA,2CAAwC;AACxC,+DAA4D;AAE5D;;;GAGG;AACH,MAAM,IAAI,GAAG,KAAK,IAAmB,EAAE;IACrC,aAAa;IACb,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,QAA4B,CAAC;IAEjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,aAAa,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC7C,QAAQ,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACvB,CAAC,EAAE,CAAC;QACN,CAAC;IACH,CAAC;IAED,WAAW;IACX,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,sBAAsB;IACtB,MAAM,IAAI,GAAG,MAAM,IAAA,yCAAmB,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IAErD,iBAAiB;IACjB,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAS,EAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAEzC,iBAAiB;IACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { BehaviorDecompositionPlan } from '../../../domain.objects/BehaviorDecompositionPlan';
2
+ /**
3
+ * .what = applies a decomposition plan by creating sub-behavior directories
4
+ * .why = enables --mode apply to scaffold approved sub-behaviors
5
+ */
6
+ export declare const applyPlan: (input: {
7
+ plan: BehaviorDecompositionPlan;
8
+ }) => Promise<{
9
+ behaviorsCreated: string[];
10
+ decomposedMarkerPath: string;
11
+ }>;
@@ -0,0 +1,171 @@
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
+ exports.applyPlan = void 0;
27
+ const fs = __importStar(require("fs/promises"));
28
+ const helpful_errors_1 = require("helpful-errors");
29
+ const path = __importStar(require("path"));
30
+ /**
31
+ * .what = applies a decomposition plan by creating sub-behavior directories
32
+ * .why = enables --mode apply to scaffold approved sub-behaviors
33
+ */
34
+ const applyPlan = async (input) => {
35
+ const { plan } = input;
36
+ // extract parent behavior path
37
+ const parentBehaviorPath = plan.behaviorSource.path;
38
+ if (!parentBehaviorPath)
39
+ throw new helpful_errors_1.UnexpectedCodePathError('plan.behaviorSource.path is required for apply', { plan });
40
+ // extract the .behavior root (parent of the behavior dir)
41
+ const behaviorRoot = path.dirname(parentBehaviorPath);
42
+ // validate parent behavior directory exists
43
+ const parentExists = await fs
44
+ .access(parentBehaviorPath)
45
+ .then(() => true)
46
+ .catch(() => false);
47
+ if (!parentExists)
48
+ throw new helpful_errors_1.BadRequestError('parent behavior directory not found', {
49
+ parentBehaviorPath,
50
+ });
51
+ // check for existing z.decomposed.md (fail if already decomposed)
52
+ const decomposedMarkerPath = path.join(parentBehaviorPath, 'z.decomposed.md');
53
+ const alreadyDecomposed = await fs
54
+ .access(decomposedMarkerPath)
55
+ .then(() => true)
56
+ .catch(() => false);
57
+ if (alreadyDecomposed)
58
+ throw new helpful_errors_1.BadRequestError('behavior already decomposed; remove z.decomposed.md to re-decompose', { decomposedMarkerPath });
59
+ // generate isodate for new behavior directories
60
+ const isoDate = new Date().toISOString().split('T')[0]?.replace(/-/g, '_');
61
+ if (!isoDate)
62
+ throw new helpful_errors_1.UnexpectedCodePathError('failed to generate isoDate', {});
63
+ // track created behaviors
64
+ const behaviorsCreated = [];
65
+ // create each proposed behavior
66
+ for (const proposed of plan.behaviorsProposed) {
67
+ const behaviorPath = await createSubBehavior({
68
+ proposed,
69
+ behaviorRoot,
70
+ isoDate,
71
+ parentBehaviorPath,
72
+ });
73
+ behaviorsCreated.push(behaviorPath);
74
+ }
75
+ // create z.decomposed.md in parent to mark as decomposed
76
+ const decomposedContent = generateDecomposedContent({
77
+ plan,
78
+ behaviorsCreated,
79
+ behaviorRoot,
80
+ });
81
+ await fs.writeFile(decomposedMarkerPath, decomposedContent);
82
+ return {
83
+ behaviorsCreated,
84
+ decomposedMarkerPath,
85
+ };
86
+ };
87
+ exports.applyPlan = applyPlan;
88
+ /**
89
+ * .what = creates a sub-behavior directory with wish and vision
90
+ * .why = encapsulates the directory creation logic for each proposed behavior
91
+ */
92
+ const createSubBehavior = async (input) => {
93
+ const { proposed, behaviorRoot, isoDate, parentBehaviorPath } = input;
94
+ // construct behavior directory path
95
+ const behaviorDirName = `v${isoDate}.${proposed.name}`;
96
+ const behaviorPath = path.join(behaviorRoot, behaviorDirName);
97
+ // check for name conflicts
98
+ const conflictExists = await fs
99
+ .access(behaviorPath)
100
+ .then(() => true)
101
+ .catch(() => false);
102
+ if (conflictExists)
103
+ throw new helpful_errors_1.BadRequestError(`behavior "${proposed.name}" already exists`, {
104
+ behaviorPath,
105
+ });
106
+ // create behavior directory
107
+ await fs.mkdir(behaviorPath, { recursive: true });
108
+ // compute relative path from behavior dir to parent for references
109
+ const parentRelPath = path.relative(behaviorPath, parentBehaviorPath);
110
+ // write 0.wish.md with scoped wish
111
+ const wishContent = `wish = ${proposed.decomposed.wish}\n\n---\n\ndecomposed from: ${parentRelPath}\n`;
112
+ await fs.writeFile(path.join(behaviorPath, '0.wish.md'), wishContent);
113
+ // write 1.vision.md with scoped vision (or empty if null)
114
+ const visionContent = proposed.decomposed.vision
115
+ ? `${proposed.decomposed.vision}\n\n---\n\ndecomposed from: ${parentRelPath}\n`
116
+ : `\n`;
117
+ await fs.writeFile(path.join(behaviorPath, '1.vision.md'), visionContent);
118
+ // write 2.criteria.md template (NOT copied from parent)
119
+ const criteriaTemplate = `# criteria for ${proposed.name}
120
+
121
+ ## blackbox criteria
122
+
123
+ # usecase.1 = ...
124
+ given()
125
+ when()
126
+ then()
127
+
128
+ ## blueprint criteria
129
+
130
+ (declare after blackbox criteria is complete)
131
+ `;
132
+ await fs.writeFile(path.join(behaviorPath, '2.criteria.md'), criteriaTemplate);
133
+ return behaviorPath;
134
+ };
135
+ /**
136
+ * .what = generates content for z.decomposed.md marker file
137
+ * .why = documents the decomposition for future reference
138
+ */
139
+ const generateDecomposedContent = (input) => {
140
+ const { plan, behaviorsCreated, behaviorRoot } = input;
141
+ const behaviorList = behaviorsCreated
142
+ .map((behaviorPath) => {
143
+ const dirName = path.basename(behaviorPath);
144
+ const relPath = path.relative(behaviorRoot, behaviorPath);
145
+ return `- ${relPath}`;
146
+ })
147
+ .join('\n');
148
+ const dependencyList = plan.behaviorsProposed
149
+ .filter((b) => b.dependsOn.length > 0)
150
+ .map((b) => `- ${b.name} depends on: ${b.dependsOn.join(', ')}`)
151
+ .join('\n');
152
+ return `# decomposed
153
+
154
+ this behavior has been decomposed into focused sub-behaviors.
155
+
156
+ ## sub-behaviors
157
+
158
+ ${behaviorList}
159
+
160
+ ## dependency order
161
+
162
+ ${dependencyList || '(no dependencies declared)'}
163
+
164
+ ## decomposition metadata
165
+
166
+ - generated at: ${plan.generatedAt}
167
+ - context analysis: ${plan.contextAnalysis.usage.window.percentage}% of context window
168
+ - recommendation: ${plan.contextAnalysis.recommendation}
169
+ `;
170
+ };
171
+ //# sourceMappingURL=applyPlan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyPlan.js","sourceRoot":"","sources":["../../../../src/domain.operations/behavior/decompose/applyPlan.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,mDAA0E;AAC1E,2CAA6B;AAK7B;;;GAGG;AACI,MAAM,SAAS,GAAG,KAAK,EAAE,KAE/B,EAGE,EAAE;IACH,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAEvB,+BAA+B;IAC/B,MAAM,kBAAkB,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;IACpD,IAAI,CAAC,kBAAkB;QACrB,MAAM,IAAI,wCAAuB,CAC/B,gDAAgD,EAChD,EAAE,IAAI,EAAE,CACT,CAAC;IAEJ,0DAA0D;IAC1D,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEt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AG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,gBAAgB,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SAC/D,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;;;;;;EAMP,YAAY;;;;EAIZ,cAAc,IAAI,4BAA4B;;;;kBAI9B,IAAI,CAAC,WAAW;sBACZ,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU;oBAC9C,IAAI,CAAC,eAAe,CAAC,cAAc;CACtD,CAAC;AACF,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env npx tsx
2
+ export {};
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env npx tsx
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const BehaviorPersisted_1 = require("../../../domain.objects/BehaviorPersisted");
5
+ const computeContextConsumption_1 = require("./computeContextConsumption");
6
+ /**
7
+ * .what = CLI entry point for computeContextConsumption
8
+ * .why = enables shell scripts to call this operation via npx tsx
9
+ */
10
+ const main = async () => {
11
+ // parse args (expects --behavior-path and --behavior-name)
12
+ const args = process.argv.slice(2);
13
+ let behaviorPath;
14
+ let behaviorName;
15
+ for (let i = 0; i < args.length; i++) {
16
+ if (args[i] === '--behavior-path' && args[i + 1]) {
17
+ behaviorPath = args[i + 1];
18
+ i++;
19
+ }
20
+ if (args[i] === '--behavior-name' && args[i + 1]) {
21
+ behaviorName = args[i + 1];
22
+ i++;
23
+ }
24
+ }
25
+ // validate
26
+ if (!behaviorPath || !behaviorName) {
27
+ console.error('usage: computeContextConsumption.cli.ts --behavior-path <path> --behavior-name <name>');
28
+ process.exit(1);
29
+ }
30
+ // construct domain object
31
+ const behavior = new BehaviorPersisted_1.BehaviorPersisted({
32
+ name: behaviorName,
33
+ path: behaviorPath,
34
+ });
35
+ // compute
36
+ const result = await (0, computeContextConsumption_1.computeContextConsumption)({ behavior });
37
+ // output as JSON
38
+ console.log(JSON.stringify(result, null, 2));
39
+ };
40
+ main().catch((err) => {
41
+ console.error('error:', err.message);
42
+ process.exit(1);
43
+ });
44
+ //# sourceMappingURL=computeContextConsumption.cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeContextConsumption.cli.js","sourceRoot":"","sources":["../../../../src/domain.operations/behavior/decompose/computeContextConsumption.cli.ts"],"names":[],"mappings":";;;AAEA,iFAA8E;AAC9E,2EAAwE;AAExE;;;GAGG;AACH,MAAM,IAAI,GAAG,KAAK,IAAmB,EAAE;IACrC,2DAA2D;IAC3D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,YAAgC,CAAC;IACrC,IAAI,YAAgC,CAAC;IAErC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACjD,YAAY,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3B,CAAC,EAAE,CAAC;QACN,CAAC;QACD,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACjD,YAAY,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3B,CAAC,EAAE,CAAC;QACN,CAAC;IACH,CAAC;IAED,WAAW;IACX,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,EAAE,CAAC;QACnC,OAAO,CAAC,KAAK,CACX,uFAAuF,CACxF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,0BAA0B;IAC1B,MAAM,QAAQ,GAAG,IAAI,qCAAiB,CAAC;QACrC,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,YAAY;KACnB,CAAC,CAAC;IAEH,UAAU;IACV,MAAM,MAAM,GAAG,MAAM,IAAA,qDAAyB,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IAE7D,iBAAiB;IACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { BehaviorDecompositionContextAnalysis } from '../../../domain.objects/BehaviorDecompositionContextAnalysis';
2
+ import type { BehaviorPersisted } from '../../../domain.objects/BehaviorPersisted';
3
+ /**
4
+ * .what = computes token consumption of behavior artifacts
5
+ * .why = quantifies whether decomposition is needed based on 30% threshold
6
+ */
7
+ export declare const computeContextConsumption: (input: {
8
+ behavior: BehaviorPersisted;
9
+ }) => Promise<BehaviorDecompositionContextAnalysis>;
@@ -0,0 +1,77 @@
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
+ exports.computeContextConsumption = void 0;
27
+ const fs = __importStar(require("fs/promises"));
28
+ const path = __importStar(require("path"));
29
+ const BehaviorDecompositionContextAnalysis_1 = require("../../../domain.objects/BehaviorDecompositionContextAnalysis");
30
+ /**
31
+ * .what = computes token consumption of behavior artifacts
32
+ * .why = quantifies whether decomposition is needed based on 30% threshold
33
+ */
34
+ const computeContextConsumption = async (input) => {
35
+ // gather artifact files from behavior directory
36
+ const behaviorPath = input.behavior.path;
37
+ const filesInDir = await fs.readdir(behaviorPath);
38
+ // measure total chars from criteria + research + distill
39
+ let totalChars = 0;
40
+ // criteria file
41
+ const criteriaFile = filesInDir.find((f) => f.endsWith('.criteria.md'));
42
+ if (criteriaFile) {
43
+ const content = await fs.readFile(path.join(behaviorPath, criteriaFile), 'utf-8');
44
+ totalChars += content.length;
45
+ }
46
+ // research files (3.1.research.*.md)
47
+ const researchFiles = filesInDir.filter((f) => f.includes('.research.'));
48
+ for (const file of researchFiles) {
49
+ const content = await fs.readFile(path.join(behaviorPath, file), 'utf-8');
50
+ totalChars += content.length;
51
+ }
52
+ // distill files (3.2.distill.*.md)
53
+ const distillFiles = filesInDir.filter((f) => f.includes('.distill.'));
54
+ for (const file of distillFiles) {
55
+ const content = await fs.readFile(path.join(behaviorPath, file), 'utf-8');
56
+ totalChars += content.length;
57
+ }
58
+ // estimate tokens (chars / 4)
59
+ const tokensEstimate = Math.ceil(totalChars / 4);
60
+ // context window = 200k tokens (claude opus 4)
61
+ const contextWindow = 200000;
62
+ const windowPercentage = Math.ceil((tokensEstimate * 100) / contextWindow);
63
+ // threshold = 30%
64
+ const recommendation = windowPercentage > 30
65
+ ? 'DECOMPOSE_REQUIRED'
66
+ : 'DECOMPOSE_UNNEEDED';
67
+ return new BehaviorDecompositionContextAnalysis_1.BehaviorDecompositionContextAnalysis({
68
+ usage: {
69
+ characters: { quantity: totalChars },
70
+ tokens: { estimate: tokensEstimate },
71
+ window: { percentage: windowPercentage },
72
+ },
73
+ recommendation,
74
+ });
75
+ };
76
+ exports.computeContextConsumption = computeContextConsumption;
77
+ //# sourceMappingURL=computeContextConsumption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeContextConsumption.js","sourceRoot":"","sources":["../../../../src/domain.operations/behavior/decompose/computeContextConsumption.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAE7B,uHAAoH;AAGpH;;;GAGG;AACI,MAAM,yBAAyB,GAAG,KAAK,EAAE,KAE/C,EAAiD,EAAE;IAClD,gDAAgD;IAChD,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;IACzC,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAElD,yDAAyD;IACzD,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,gBAAgB;IAChB,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC;IACxE,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAC/B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,EACrC,OAAO,CACR,CAAC;QACF,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED,qCAAqC;IACrC,MAAM,aAAa,GAAG,UAAU,CAA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EAAE,EAAE,UAAU,EAAE,gBAAgB,EAAE;SACzC;QACD,cAAc;KACf,CAAC,CAAC;AACL,CAAC,CAAC;AAvDW,QAAA,yBAAyB,6BAuDpC"}
@@ -0,0 +1,8 @@
1
+ import { BehaviorDecompositionPlan } from '../../../domain.objects/BehaviorDecompositionPlan';
2
+ /**
3
+ * .what = reads and validates a decomposition plan from a JSON file
4
+ * .why = enables --mode apply to consume approved plans from disk
5
+ */
6
+ export declare const computePlanFromFile: (input: {
7
+ planPath: string;
8
+ }) => Promise<BehaviorDecompositionPlan>;
@@ -0,0 +1,69 @@
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
+ exports.computePlanFromFile = void 0;
27
+ const fs = __importStar(require("fs/promises"));
28
+ const helpful_errors_1 = require("helpful-errors");
29
+ const BehaviorDecompositionPlan_1 = require("../../../domain.objects/BehaviorDecompositionPlan");
30
+ /**
31
+ * .what = reads and validates a decomposition plan from a JSON file
32
+ * .why = enables --mode apply to consume approved plans from disk
33
+ */
34
+ const computePlanFromFile = async (input) => {
35
+ // read the plan file
36
+ const planContent = await fs.readFile(input.planPath, 'utf-8');
37
+ // parse the JSON
38
+ let planData;
39
+ try {
40
+ planData = JSON.parse(planContent);
41
+ }
42
+ catch {
43
+ throw new helpful_errors_1.BadRequestError('plan file is not valid JSON', {
44
+ planPath: input.planPath,
45
+ });
46
+ }
47
+ // validate required fields are present
48
+ const data = planData;
49
+ if (!data.behaviorSource)
50
+ throw new helpful_errors_1.BadRequestError('plan file missing behaviorSource', {
51
+ planPath: input.planPath,
52
+ });
53
+ if (!data.behaviorsProposed)
54
+ throw new helpful_errors_1.BadRequestError('plan file missing behaviorsProposed', {
55
+ planPath: input.planPath,
56
+ });
57
+ if (!data.contextAnalysis)
58
+ throw new helpful_errors_1.BadRequestError('plan file missing contextAnalysis', {
59
+ planPath: input.planPath,
60
+ });
61
+ if (!data.generatedAt)
62
+ throw new helpful_errors_1.BadRequestError('plan file missing generatedAt', {
63
+ planPath: input.planPath,
64
+ });
65
+ // construct domain object (validates nested structure)
66
+ return new BehaviorDecompositionPlan_1.BehaviorDecompositionPlan(data);
67
+ };
68
+ exports.computePlanFromFile = computePlanFromFile;
69
+ //# sourceMappingURL=computePlanFromFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computePlanFromFile.js","sourceRoot":"","sources":["../../../../src/domain.operations/behavior/decompose/computePlanFromFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,mDAAiD;AAEjD,iGAA8F;AAE9F;;;GAGG;AACI,MAAM,mBAAmB,GAAG,KAAK,EAAE,KAEzC,EAAsC,EAAE;IACvC,qBAAqB;IACrB,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE/D,iBAAiB;IACjB,IAAI,QAAiB,CAAC;IACtB,IAAI,CAA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