@manehorizons/cadence-core 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/cli/commands/assumption.d.ts.map +1 -1
  2. package/dist/cli/commands/assumption.js +2 -1
  3. package/dist/cli/commands/assumption.js.map +1 -1
  4. package/dist/cli/commands/decision.d.ts.map +1 -1
  5. package/dist/cli/commands/decision.js +2 -1
  6. package/dist/cli/commands/decision.js.map +1 -1
  7. package/dist/cli/commands/draft-new.d.ts.map +1 -1
  8. package/dist/cli/commands/draft-new.js +2 -1
  9. package/dist/cli/commands/draft-new.js.map +1 -1
  10. package/dist/cli/commands/intelligence.d.ts.map +1 -1
  11. package/dist/cli/commands/intelligence.js +4 -1
  12. package/dist/cli/commands/intelligence.js.map +1 -1
  13. package/dist/cli/commands/milestone.js +1 -1
  14. package/dist/cli/commands/milestone.js.map +1 -1
  15. package/dist/cli/commands/recommendation.d.ts.map +1 -1
  16. package/dist/cli/commands/recommendation.js +2 -1
  17. package/dist/cli/commands/recommendation.js.map +1 -1
  18. package/dist/cli/commands/spec.d.ts.map +1 -1
  19. package/dist/cli/commands/spec.js +2 -1
  20. package/dist/cli/commands/spec.js.map +1 -1
  21. package/dist/intelligence/context.js +2 -1
  22. package/dist/intelligence/context.js.map +1 -1
  23. package/dist/intelligence/inspect.js +2 -1
  24. package/dist/intelligence/inspect.js.map +1 -1
  25. package/dist/intelligence/milestone.d.ts.map +1 -1
  26. package/dist/intelligence/milestone.js +2 -1
  27. package/dist/intelligence/milestone.js.map +1 -1
  28. package/dist/intelligence/recommend.d.ts.map +1 -1
  29. package/dist/intelligence/recommend.js +2 -1
  30. package/dist/intelligence/recommend.js.map +1 -1
  31. package/dist/intelligence/render-intelligence-audit.d.ts +1 -1
  32. package/dist/intelligence/render-intelligence-audit.d.ts.map +1 -1
  33. package/dist/intelligence/render-intelligence-stats.d.ts +1 -1
  34. package/dist/intelligence/render-intelligence-stats.d.ts.map +1 -1
  35. package/dist/intelligence/store/assumptions.d.ts +17 -0
  36. package/dist/intelligence/store/assumptions.d.ts.map +1 -0
  37. package/dist/intelligence/store/assumptions.js +63 -0
  38. package/dist/intelligence/store/assumptions.js.map +1 -0
  39. package/dist/intelligence/store/audit.d.ts +42 -0
  40. package/dist/intelligence/store/audit.d.ts.map +1 -0
  41. package/dist/intelligence/store/audit.js +88 -0
  42. package/dist/intelligence/store/audit.js.map +1 -0
  43. package/dist/intelligence/store/decisions.d.ts +19 -0
  44. package/dist/intelligence/store/decisions.d.ts.map +1 -0
  45. package/dist/intelligence/store/decisions.js +147 -0
  46. package/dist/intelligence/store/decisions.js.map +1 -0
  47. package/dist/intelligence/store/ids.d.ts +6 -0
  48. package/dist/intelligence/store/ids.d.ts.map +1 -0
  49. package/dist/intelligence/store/ids.js +44 -0
  50. package/dist/intelligence/store/ids.js.map +1 -0
  51. package/dist/intelligence/store/io.d.ts +10 -0
  52. package/dist/intelligence/store/io.d.ts.map +1 -0
  53. package/dist/intelligence/store/io.js +70 -0
  54. package/dist/intelligence/store/io.js.map +1 -0
  55. package/dist/intelligence/store/milestones.d.ts +4 -0
  56. package/dist/intelligence/store/milestones.d.ts.map +1 -0
  57. package/dist/intelligence/store/milestones.js +20 -0
  58. package/dist/intelligence/store/milestones.js.map +1 -0
  59. package/dist/intelligence/store/paths.d.ts +11 -0
  60. package/dist/intelligence/store/paths.d.ts.map +1 -0
  61. package/dist/intelligence/store/paths.js +42 -0
  62. package/dist/intelligence/store/paths.js.map +1 -0
  63. package/dist/intelligence/store/recommendations.d.ts +23 -0
  64. package/dist/intelligence/store/recommendations.d.ts.map +1 -0
  65. package/dist/intelligence/store/recommendations.js +115 -0
  66. package/dist/intelligence/store/recommendations.js.map +1 -0
  67. package/dist/intelligence/store/reconcile.d.ts +8 -0
  68. package/dist/intelligence/store/reconcile.d.ts.map +1 -0
  69. package/dist/intelligence/store/reconcile.js +42 -0
  70. package/dist/intelligence/store/reconcile.js.map +1 -0
  71. package/dist/intelligence/store/stats.d.ts +36 -0
  72. package/dist/intelligence/store/stats.d.ts.map +1 -0
  73. package/dist/intelligence/store/stats.js +106 -0
  74. package/dist/intelligence/store/stats.js.map +1 -0
  75. package/package.json +2 -2
  76. package/dist/intelligence/store.d.ts +0 -143
  77. package/dist/intelligence/store.d.ts.map +0 -1
  78. package/dist/intelligence/store.js +0 -701
  79. package/dist/intelligence/store.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../../src/intelligence/store/ids.ts"],"names":[],"mappings":"AAOA,SAAS,QAAQ,CAAC,GAAS;IACzB,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAA4B,EAAE,GAAS;IAC1E,MAAM,MAAM,GAAG,OAAO,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;IACvC,MAAM,GAAG,GAAG,MAAM,CAAC,eAAe;SAC/B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChB,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;SACrC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;SACzD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SACjC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAA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E,CAAC,CAAC,CAAC;IACvC,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACxD,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type AssumptionLedger, type EvidenceLedger, type IntelligenceDecisionLedger, type RecommendationLedger } from '@manehorizons/cadence-types';
2
+ export declare function readRecommendationLedger(root: string): Promise<RecommendationLedger>;
3
+ export declare function readEvidenceLedger(root: string): Promise<EvidenceLedger>;
4
+ export declare function readAssumptionLedger(root: string): Promise<AssumptionLedger>;
5
+ export declare function readIntelligenceDecisionLedger(root: string): Promise<IntelligenceDecisionLedger>;
6
+ export declare function writeIntelligenceLedgers(root: string, ledger: RecommendationLedger, evidenceLedger: EvidenceLedger): Promise<void>;
7
+ export declare function writeAssumptionLedger(root: string, ledger: AssumptionLedger): Promise<void>;
8
+ export declare function writeIntelligenceDecisionLedger(root: string, ledger: IntelligenceDecisionLedger): Promise<void>;
9
+ export declare function rerenderRecommendationsMdIfPresent(root: string): Promise<void>;
10
+ //# sourceMappingURL=io.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../../../src/intelligence/store/io.ts"],"names":[],"mappings":"AAEA,OAAO,EASL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EAC1B,MAAM,6BAA6B,CAAC;AAgBrC,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAK1F;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAK9E;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAKlF;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,0BAA0B,CAAC,CAKrC;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,oBAAoB,EAC5B,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,IAAI,CAAC,CAcf;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKjG;AAED,wBAAsB,+BAA+B,CACnD,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,IAAI,CAAC,CAKf;AAED,wBAAsB,kCAAkC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUpF"}
@@ -0,0 +1,70 @@
1
+ import { mkdir, readFile } from 'node:fs/promises';
2
+ import { existsSync } from 'node:fs';
3
+ import { AssumptionLedgerZ, EvidenceLedgerZ, IntelligenceDecisionLedgerZ, RecommendationLedgerZ, emptyAssumptionLedger, emptyEvidenceLedger, emptyIntelligenceDecisionLedger, emptyRecommendationLedger, } from '@manehorizons/cadence-types';
4
+ import { atomicWriteJSON, atomicWriteText } from '../../state/atomic-write.js';
5
+ import { renderRecommendationsMd } from '../render.js';
6
+ import { renderAssumptionsMd } from '../render-assumption.js';
7
+ import { renderDecisionsMd } from '../render-decision.js';
8
+ import { assumptionsMdPath, assumptionsPath, decisionsMdPath, decisionsPath, evidencePath, intelligenceDir, recommendationsMdPath, recommendationsPath, } from './paths.js';
9
+ export async function readRecommendationLedger(root) {
10
+ const path = recommendationsPath(root);
11
+ if (!existsSync(path))
12
+ return emptyRecommendationLedger();
13
+ const raw = await readFile(path, 'utf8');
14
+ return RecommendationLedgerZ.parse(JSON.parse(raw));
15
+ }
16
+ export async function readEvidenceLedger(root) {
17
+ const path = evidencePath(root);
18
+ if (!existsSync(path))
19
+ return emptyEvidenceLedger();
20
+ const raw = await readFile(path, 'utf8');
21
+ return EvidenceLedgerZ.parse(JSON.parse(raw));
22
+ }
23
+ export async function readAssumptionLedger(root) {
24
+ const path = assumptionsPath(root);
25
+ if (!existsSync(path))
26
+ return emptyAssumptionLedger();
27
+ const raw = await readFile(path, 'utf8');
28
+ return AssumptionLedgerZ.parse(JSON.parse(raw));
29
+ }
30
+ export async function readIntelligenceDecisionLedger(root) {
31
+ const path = decisionsPath(root);
32
+ if (!existsSync(path))
33
+ return emptyIntelligenceDecisionLedger();
34
+ const raw = await readFile(path, 'utf8');
35
+ return IntelligenceDecisionLedgerZ.parse(JSON.parse(raw));
36
+ }
37
+ export async function writeIntelligenceLedgers(root, ledger, evidenceLedger) {
38
+ const dir = intelligenceDir(root);
39
+ await mkdir(dir, { recursive: true });
40
+ RecommendationLedgerZ.parse(ledger);
41
+ EvidenceLedgerZ.parse(evidenceLedger);
42
+ await atomicWriteJSON(recommendationsPath(root), ledger);
43
+ await atomicWriteJSON(evidencePath(root), evidenceLedger);
44
+ // Read sibling ledgers so the rec MD renders status-annotated link bullets (Slice 15).
45
+ const asLedger = await readAssumptionLedger(root);
46
+ const decLedger = await readIntelligenceDecisionLedger(root);
47
+ await atomicWriteText(recommendationsMdPath(root), renderRecommendationsMd(ledger, evidenceLedger, asLedger, decLedger));
48
+ }
49
+ export async function writeAssumptionLedger(root, ledger) {
50
+ AssumptionLedgerZ.parse(ledger);
51
+ await mkdir(intelligenceDir(root), { recursive: true });
52
+ await atomicWriteJSON(assumptionsPath(root), ledger);
53
+ await atomicWriteText(assumptionsMdPath(root), renderAssumptionsMd(ledger));
54
+ }
55
+ export async function writeIntelligenceDecisionLedger(root, ledger) {
56
+ IntelligenceDecisionLedgerZ.parse(ledger);
57
+ await mkdir(intelligenceDir(root), { recursive: true });
58
+ await atomicWriteJSON(decisionsPath(root), ledger);
59
+ await atomicWriteText(decisionsMdPath(root), renderDecisionsMd(ledger));
60
+ }
61
+ export async function rerenderRecommendationsMdIfPresent(root) {
62
+ if (!existsSync(recommendationsPath(root)))
63
+ return;
64
+ const recLedger = await readRecommendationLedger(root);
65
+ const evLedger = await readEvidenceLedger(root);
66
+ const asLedger = await readAssumptionLedger(root);
67
+ const decLedger = await readIntelligenceDecisionLedger(root);
68
+ await atomicWriteText(recommendationsMdPath(root), renderRecommendationsMd(recLedger, evLedger, asLedger, decLedger));
69
+ }
70
+ //# sourceMappingURL=io.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io.js","sourceRoot":"","sources":["../../../src/intelligence/store/io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,+BAA+B,EAC/B,yBAAyB,GAK1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,aAAa,EACb,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAAY;IACzD,MAAM,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,yBAAyB,EAAE,CAAC;IAC1D,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzC,OAAO,qBAAqB,CAAC,KAAK,CAAC,IAA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,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IACnD,MAAM,eAAe,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kCAAkC,CAAC,IAAY;IACnE,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO;IACnD,MAAM,SAAS,GAAG,MAAM,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,MAAM,8BAA8B,CAAC,IAAI,CAAC,CAAC;IAC7D,MAAM,eAAe,CACnB,qBAAqB,CAAC,IAAI,CAAC,EAC3B,uBAAuB,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAClE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type MilestoneLedger } from '@manehorizons/cadence-types';
2
+ export declare function readMilestoneLedger(root: string): Promise<MilestoneLedger>;
3
+ export declare function writeMilestoneLedger(root: string, ledger: MilestoneLedger): Promise<void>;
4
+ //# sourceMappingURL=milestones.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"milestones.d.ts","sourceRoot":"","sources":["../../../src/intelligence/store/milestones.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,6BAA6B,CAAC;AAKrC,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,eAAe,CAAC,CAK1B;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,IAAI,CAAC,CAKf"}
@@ -0,0 +1,20 @@
1
+ import { mkdir, readFile } from 'node:fs/promises';
2
+ import { existsSync } from 'node:fs';
3
+ import { MilestoneLedgerZ, emptyMilestoneLedger, } from '@manehorizons/cadence-types';
4
+ import { atomicWriteJSON, atomicWriteText } from '../../state/atomic-write.js';
5
+ import { renderMilestonesMd } from '../render-milestone.js';
6
+ import { intelligenceDir, milestonesMdPath, milestonesPath } from './paths.js';
7
+ export async function readMilestoneLedger(root) {
8
+ const path = milestonesPath(root);
9
+ if (!existsSync(path))
10
+ return emptyMilestoneLedger();
11
+ const raw = await readFile(path, 'utf8');
12
+ return MilestoneLedgerZ.parse(JSON.parse(raw));
13
+ }
14
+ export async function writeMilestoneLedger(root, ledger) {
15
+ await mkdir(intelligenceDir(root), { recursive: true });
16
+ MilestoneLedgerZ.parse(ledger);
17
+ await atomicWriteJSON(milestonesPath(root), ledger);
18
+ await atomicWriteText(milestonesMdPath(root), renderMilestonesMd(ledger));
19
+ }
20
+ //# sourceMappingURL=milestones.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"milestones.js","sourceRoot":"","sources":["../../../src/intelligence/store/milestones.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,GAErB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE/E,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,IAAY;IAEZ,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,oBAAoB,EAAE,CAAC;IACrD,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzC,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAAY,EACZ,MAAuB;IAEvB,MAAM,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,MAAM,eAAe,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IACpD,MAAM,eAAe,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare function intelligenceDir(root: string): string;
2
+ export declare function recommendationsPath(root: string): string;
3
+ export declare function evidencePath(root: string): string;
4
+ export declare function assumptionsPath(root: string): string;
5
+ export declare function decisionsPath(root: string): string;
6
+ export declare function recommendationsMdPath(root: string): string;
7
+ export declare function assumptionsMdPath(root: string): string;
8
+ export declare function decisionsMdPath(root: string): string;
9
+ export declare function milestonesPath(root: string): string;
10
+ export declare function milestonesMdPath(root: string): string;
11
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/intelligence/store/paths.ts"],"names":[],"mappings":"AAaA,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD"}
@@ -0,0 +1,42 @@
1
+ import { join } from 'node:path';
2
+ const INTELLIGENCE_DIR = '.cadence/intelligence';
3
+ const RECOMMENDATIONS_JSON = 'recommendations.json';
4
+ const EVIDENCE_JSON = 'evidence.json';
5
+ const RECOMMENDATIONS_MD = 'RECOMMENDATIONS.md';
6
+ const ASSUMPTIONS_JSON = 'assumptions.json';
7
+ const DECISIONS_JSON = 'decisions.json';
8
+ const ASSUMPTIONS_MD = 'ASSUMPTIONS.md';
9
+ const DECISIONS_MD = 'DECISIONS.md';
10
+ const MILESTONES_JSON = 'milestones.json';
11
+ const MILESTONES_MD = 'MILESTONES.md';
12
+ export function intelligenceDir(root) {
13
+ return join(root, INTELLIGENCE_DIR);
14
+ }
15
+ export function recommendationsPath(root) {
16
+ return join(intelligenceDir(root), RECOMMENDATIONS_JSON);
17
+ }
18
+ export function evidencePath(root) {
19
+ return join(intelligenceDir(root), EVIDENCE_JSON);
20
+ }
21
+ export function assumptionsPath(root) {
22
+ return join(intelligenceDir(root), ASSUMPTIONS_JSON);
23
+ }
24
+ export function decisionsPath(root) {
25
+ return join(intelligenceDir(root), DECISIONS_JSON);
26
+ }
27
+ export function recommendationsMdPath(root) {
28
+ return join(intelligenceDir(root), RECOMMENDATIONS_MD);
29
+ }
30
+ export function assumptionsMdPath(root) {
31
+ return join(intelligenceDir(root), ASSUMPTIONS_MD);
32
+ }
33
+ export function decisionsMdPath(root) {
34
+ return join(intelligenceDir(root), DECISIONS_MD);
35
+ }
36
+ export function milestonesPath(root) {
37
+ return join(intelligenceDir(root), MILESTONES_JSON);
38
+ }
39
+ export function milestonesMdPath(root) {
40
+ return join(intelligenceDir(root), MILESTONES_MD);
41
+ }
42
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/intelligence/store/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AACjD,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AACpD,MAAM,aAAa,GAAG,eAAe,CAAC;AACtC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAChD,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAC5C,MAAM,cAAc,GAAG,gBAAgB,CAAC;AACxC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AACxC,MAAM,YAAY,GAAG,cAAc,CAAC;AACpC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAC1C,MAAM,aAAa,GAAG,eAAe,CAAC;AAEtC,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,kBAAkB,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { type AssumptionLedger, type IntelligenceDecisionLedger, type Recommendation, type RecommendationLedger, type RecommendationPriority, type RecommendationReadiness } from '@manehorizons/cadence-types';
2
+ export type AddRecommendationInput = {
3
+ title: string;
4
+ summary: string;
5
+ priority: RecommendationPriority;
6
+ readiness: RecommendationReadiness;
7
+ affectedAreas: string[];
8
+ affectedFiles: string[];
9
+ evidenceSummary?: string;
10
+ };
11
+ export declare function addRecommendation(root: string, input: AddRecommendationInput): Promise<Recommendation>;
12
+ export declare function deriveRecommendationLinks(recLedger: RecommendationLedger, asLedger: AssumptionLedger, decLedger: IntelligenceDecisionLedger): RecommendationLedger;
13
+ export type RecommendationTransitionAction = 'convert';
14
+ export type RecommendationTransitionResult = {
15
+ ok: true;
16
+ ledger: RecommendationLedger;
17
+ } | {
18
+ ok: false;
19
+ error: string;
20
+ };
21
+ export declare function applyRecommendationTransition(ledger: RecommendationLedger, id: string, action: RecommendationTransitionAction, toPhase: string, now: Date): RecommendationTransitionResult;
22
+ export declare function runRecommendationTransition(root: string, id: string, action: RecommendationTransitionAction, toPhase: string): Promise<RecommendationTransitionResult>;
23
+ //# sourceMappingURL=recommendations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recommendations.d.ts","sourceRoot":"","sources":["../../../src/intelligence/store/recommendations.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,gBAAgB,EAErB,KAAK,0BAA0B,EAC/B,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC7B,MAAM,6BAA6B,CAAC;AAQrC,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,sBAAsB,CAAC;IACjC,SAAS,EAAE,uBAAuB,CAAC;IACnC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,cAAc,CAAC,CAwCzB;AAED,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,oBAAoB,EAC/B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,0BAA0B,GACpC,oBAAoB,CAatB;AAKD,MAAM,MAAM,8BAA8B,GAAG,SAAS,CAAC;AAEvD,MAAM,MAAM,8BAA8B,GACtC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,GAC1C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAgBjC,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,oBAAoB,EAC5B,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,8BAA8B,EACtC,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,IAAI,GACR,8BAA8B,CAoBhC;AAcD,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,8BAA8B,EACtC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,8BAA8B,CAAC,CAczC"}
@@ -0,0 +1,115 @@
1
+ import { stat } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { nextEvidenceId, nextRecommendationId } from './ids.js';
4
+ import { readEvidenceLedger, readRecommendationLedger, writeIntelligenceLedgers, } from './io.js';
5
+ export async function addRecommendation(root, input) {
6
+ const ledger = await readRecommendationLedger(root);
7
+ const evidenceLedger = await readEvidenceLedger(root);
8
+ const now = new Date();
9
+ const ts = now.toISOString();
10
+ const recommendationId = nextRecommendationId(ledger, now);
11
+ const evidence = input.evidenceSummary
12
+ ? {
13
+ id: nextEvidenceId(evidenceLedger, now),
14
+ recommendationId,
15
+ kind: 'note',
16
+ summary: input.evidenceSummary,
17
+ createdAt: ts,
18
+ }
19
+ : null;
20
+ const rec = {
21
+ id: recommendationId,
22
+ title: input.title,
23
+ summary: input.summary,
24
+ source: 'manual',
25
+ status: 'candidate',
26
+ readiness: input.readiness,
27
+ priority: input.priority,
28
+ leverageScore: 5,
29
+ riskScore: 5,
30
+ confidence: input.evidenceSummary ? 0.7 : 0.4,
31
+ decayState: 'fresh',
32
+ affectedAreas: input.affectedAreas,
33
+ affectedFiles: input.affectedFiles,
34
+ suggestedBackendAction: 'cadence milestone propose',
35
+ evidenceIds: evidence ? [evidence.id] : [],
36
+ assumptionIds: [],
37
+ decisionIds: [],
38
+ createdAt: ts,
39
+ updatedAt: ts,
40
+ };
41
+ if (evidence)
42
+ evidenceLedger.evidence.push(evidence);
43
+ ledger.recommendations.push(rec);
44
+ await writeIntelligenceLedgers(root, ledger, evidenceLedger);
45
+ return rec;
46
+ }
47
+ export function deriveRecommendationLinks(recLedger, asLedger, decLedger) {
48
+ return {
49
+ schemaVersion: 1,
50
+ recommendations: recLedger.recommendations.map((r) => ({
51
+ ...r,
52
+ assumptionIds: asLedger.assumptions
53
+ .filter((a) => a.recommendationId === r.id)
54
+ .map((a) => a.id),
55
+ decisionIds: decLedger.decisions
56
+ .filter((d) => d.recommendationId === r.id)
57
+ .map((d) => d.id),
58
+ })),
59
+ };
60
+ }
61
+ const RECOMMENDATION_TRANSITION_ALLOWED = {
62
+ convert: ['candidate', 'accepted'],
63
+ };
64
+ const RECOMMENDATION_TRANSITION_NEXT = {
65
+ convert: 'converted',
66
+ };
67
+ export function applyRecommendationTransition(ledger, id, action, toPhase, now) {
68
+ const target = ledger.recommendations.find((r) => r.id === id);
69
+ if (!target)
70
+ return { ok: false, error: `recommendation ${id} not found` };
71
+ if (!RECOMMENDATION_TRANSITION_ALLOWED[action].includes(target.status)) {
72
+ return {
73
+ ok: false,
74
+ error: `cannot ${action} recommendation in status ${target.status}`,
75
+ };
76
+ }
77
+ const nextStatus = RECOMMENDATION_TRANSITION_NEXT[action];
78
+ const updatedAt = now.toISOString();
79
+ const ledgerOut = {
80
+ schemaVersion: 1,
81
+ recommendations: ledger.recommendations.map((r) => r.id === id
82
+ ? { ...r, status: nextStatus, convertedToPhaseId: toPhase, updatedAt }
83
+ : r),
84
+ };
85
+ return { ok: true, ledger: ledgerOut };
86
+ }
87
+ // Slice 34.1: existence check for `.cadence/phases/<phaseId>/` lives in the
88
+ // I/O wrapper deliberately — keeps the pure helper disk-free (per Slice 34
89
+ // Decision Log §10 + §11 architectural principle).
90
+ async function phaseDirectoryExists(root, phaseId) {
91
+ try {
92
+ const s = await stat(join(root, '.cadence/phases', phaseId));
93
+ return s.isDirectory();
94
+ }
95
+ catch {
96
+ return false;
97
+ }
98
+ }
99
+ export async function runRecommendationTransition(root, id, action, toPhase) {
100
+ // FK check FIRST so a missing phase is caught before any ledger read.
101
+ // Mirrors Slice 28's --by precedence: validate FK before applying transition.
102
+ if (!(await phaseDirectoryExists(root, toPhase))) {
103
+ return { ok: false, error: `cannot convert: phase ${toPhase} not found` };
104
+ }
105
+ const ledger = await readRecommendationLedger(root);
106
+ const res = applyRecommendationTransition(ledger, id, action, toPhase, new Date());
107
+ if (!res.ok)
108
+ return res;
109
+ // writeIntelligenceLedgers handles atomic JSON + RECOMMENDATIONS.md re-render
110
+ // (Slice 15 annotated form), so we don't need a separate rerender call.
111
+ const evidenceLedger = await readEvidenceLedger(root);
112
+ await writeIntelligenceLedgers(root, res.ledger, evidenceLedger);
113
+ return res;
114
+ }
115
+ //# sourceMappingURL=recommendations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recommendations.js","sourceRoot":"","sources":["../../../src/intelligence/store/recommendations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAUjC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,SAAS,CAAC;AAYjB,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAY,EACZ,KAA6B;IAE7B,MAAM,MAAM,GAAG,MAAM,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACpD,MAAM,cAAc,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAC7B,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC,CA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O,YAAY,EAAE,CAAC;IAC5E,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACpD,MAAM,GAAG,GAAG,6BAA6B,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;IACnF,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,GAAG,CAAC;IACxB,8EAA8E;IAC9E,wEAAwE;IACxE,MAAM,cAAc,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,wBAAwB,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACjE,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,8 @@
1
+ export type IntelligenceReconcileResult = {
2
+ present: boolean;
3
+ recommendations: number;
4
+ assumptions: number;
5
+ decisions: number;
6
+ };
7
+ export declare function runIntelligenceReconcile(root: string): Promise<IntelligenceReconcileResult>;
8
+ //# sourceMappingURL=reconcile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile.d.ts","sourceRoot":"","sources":["../../../src/intelligence/store/reconcile.ts"],"names":[],"mappings":"AAyBA,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,2BAA2B,CAAC,CA+BtC"}
@@ -0,0 +1,42 @@
1
+ import { mkdir } from 'node:fs/promises';
2
+ import { existsSync } from 'node:fs';
3
+ import { atomicWriteText } from '../../state/atomic-write.js';
4
+ import { renderAssumptionsMd } from '../render-assumption.js';
5
+ import { renderDecisionsMd } from '../render-decision.js';
6
+ import { assumptionsMdPath, assumptionsPath, decisionsMdPath, decisionsPath, evidencePath, intelligenceDir, recommendationsPath, } from './paths.js';
7
+ import { readAssumptionLedger, readEvidenceLedger, readIntelligenceDecisionLedger, readRecommendationLedger, writeIntelligenceDecisionLedger, writeIntelligenceLedgers, } from './io.js';
8
+ import { deriveRecommendationLinks } from './recommendations.js';
9
+ import { deriveDecisionInverseLinks } from './decisions.js';
10
+ export async function runIntelligenceReconcile(root) {
11
+ const recExists = existsSync(recommendationsPath(root));
12
+ const evExists = existsSync(evidencePath(root));
13
+ const asExists = existsSync(assumptionsPath(root));
14
+ const decExists = existsSync(decisionsPath(root));
15
+ if (!recExists && !evExists && !asExists && !decExists) {
16
+ return { present: false, recommendations: 0, assumptions: 0, decisions: 0 };
17
+ }
18
+ const recLedger = await readRecommendationLedger(root);
19
+ const evLedger = await readEvidenceLedger(root);
20
+ const asLedger = await readAssumptionLedger(root);
21
+ const decLedger = await readIntelligenceDecisionLedger(root);
22
+ // Re-derive rec link arrays from current subject ledgers (idempotent if already correct).
23
+ const derivedRec = deriveRecommendationLinks(recLedger, asLedger, decLedger);
24
+ // Slice 31: re-derive decision inverse-links (supersedes arrays) from
25
+ // current supersededBy values. Idempotent. Operator's "force re-derive"
26
+ // command fixes any drift introduced by manual JSON edits.
27
+ const derivedDec = deriveDecisionInverseLinks(decLedger);
28
+ // writeIntelligenceLedgers handles atomic JSON + RECOMMENDATIONS.md re-render (Slice 15 annotated form).
29
+ await writeIntelligenceLedgers(root, derivedRec, evLedger);
30
+ await writeIntelligenceDecisionLedger(root, derivedDec);
31
+ // Re-render subject MDs from current ledgers (source-of-truth JSON untouched).
32
+ await mkdir(intelligenceDir(root), { recursive: true });
33
+ await atomicWriteText(assumptionsMdPath(root), renderAssumptionsMd(asLedger));
34
+ await atomicWriteText(decisionsMdPath(root), renderDecisionsMd(derivedDec));
35
+ return {
36
+ present: true,
37
+ recommendations: derivedRec.recommendations.length,
38
+ assumptions: asLedger.assumptions.length,
39
+ decisions: derivedDec.decisions.length,
40
+ };
41
+ }
42
+ //# sourceMappingURL=reconcile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile.js","sourceRoot":"","sources":["../../../src/intelligence/store/reconcile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,aAAa,EACb,YAAY,EACZ,eAAe,EACf,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,8BAA8B,EAC9B,wBAAwB,EACxB,+BAA+B,EAC/B,wBAAwB,GACzB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAS5D,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,IAAY;IAEZ,MAAM,SAAS,GAAG,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,IAAI,CAAC,SAAS,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,IAAI,CAAC,SAAS,EAAE,CAAC;QACvD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,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, Evidence, EvidenceLedger, IntelligenceDecision, IntelligenceDecisionLedger, Recommendation, RecommendationLedger } from '@manehorizons/cadence-types';
2
+ export type IntelligenceStats = {
3
+ recommendations: {
4
+ total: number;
5
+ byStatus: Record<Recommendation['status'], number>;
6
+ byReadiness: Record<Recommendation['readiness'], number>;
7
+ };
8
+ evidence: {
9
+ total: number;
10
+ byKind: Record<Evidence['kind'], number>;
11
+ };
12
+ assumptions: {
13
+ total: number;
14
+ byStatus: Record<Assumption['status'], number>;
15
+ };
16
+ decisions: {
17
+ total: number;
18
+ byStatus: Record<IntelligenceDecision['status'], number>;
19
+ untied: number;
20
+ };
21
+ links: {
22
+ brokenAssumptionLinks: number;
23
+ brokenDecisionLinks: number;
24
+ brokenEvidenceLinks: number;
25
+ };
26
+ perRec: Array<{
27
+ id: string;
28
+ title: string;
29
+ status: Recommendation['status'];
30
+ assumptionsByStatus: Record<Assumption['status'], number>;
31
+ decisionsByStatus: Record<IntelligenceDecision['status'], number>;
32
+ evidenceCount: number;
33
+ }>;
34
+ };
35
+ export declare function computeIntelligenceStats(recLedger: RecommendationLedger, evLedger: EvidenceLedger, asLedger: AssumptionLedger, decLedger: IntelligenceDecisionLedger): IntelligenceStats;
36
+ //# sourceMappingURL=stats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/intelligence/store/stats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,cAAc,EACd,oBAAoB,EACrB,MAAM,6BAA6B,CAAC;AAErC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,eAAe,EAAE;QACf,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;QACnD,WAAW,EAAE,MAAM,CAAC,cAAc,CAAC,WAAW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
+ 'converted',
7
+ ];
8
+ const REC_READINESSES = [
9
+ 'raw-idea',
10
+ 'needs-evidence',
11
+ 'needs-decision',
12
+ 'ready-for-milestone',
13
+ 'ready-for-cadence-spec',
14
+ 'blocked',
15
+ ];
16
+ const EV_KINDS = ['file', 'command', 'cadence-artifact', 'note'];
17
+ const AS_STATUSES = ['open', 'validated', 'rejected'];
18
+ const DEC_STATUSES = [
19
+ 'active',
20
+ 'superseded',
21
+ 'rescinded',
22
+ ];
23
+ export function computeIntelligenceStats(recLedger, evLedger, asLedger, decLedger) {
24
+ const recByStatus = Object.fromEntries(REC_STATUSES.map((s) => [s, 0]));
25
+ const recByReadiness = Object.fromEntries(REC_READINESSES.map((r) => [r, 0]));
26
+ for (const r of recLedger.recommendations) {
27
+ recByStatus[r.status]++;
28
+ recByReadiness[r.readiness]++;
29
+ }
30
+ const evByKind = Object.fromEntries(EV_KINDS.map((k) => [k, 0]));
31
+ for (const ev of evLedger.evidence)
32
+ evByKind[ev.kind]++;
33
+ const asByStatus = Object.fromEntries(AS_STATUSES.map((s) => [s, 0]));
34
+ for (const a of asLedger.assumptions)
35
+ asByStatus[a.status]++;
36
+ const decByStatus = Object.fromEntries(DEC_STATUSES.map((s) => [s, 0]));
37
+ let decUntied = 0;
38
+ for (const d of decLedger.decisions) {
39
+ decByStatus[d.status]++;
40
+ if (d.recommendationId === undefined)
41
+ decUntied++;
42
+ }
43
+ const asById = new Map(asLedger.assumptions.map((a) => [a.id, a]));
44
+ const decById = new Map(decLedger.decisions.map((d) => [d.id, d]));
45
+ const evById = new Map(evLedger.evidence.map((e) => [e.id, e]));
46
+ let brokenAssumptionLinks = 0;
47
+ let brokenDecisionLinks = 0;
48
+ let brokenEvidenceLinks = 0;
49
+ for (const r of recLedger.recommendations) {
50
+ for (const id of r.assumptionIds)
51
+ if (!asById.has(id))
52
+ brokenAssumptionLinks++;
53
+ for (const id of r.decisionIds)
54
+ if (!decById.has(id))
55
+ brokenDecisionLinks++;
56
+ for (const id of r.evidenceIds)
57
+ if (!evById.has(id))
58
+ brokenEvidenceLinks++;
59
+ }
60
+ const perRec = recLedger.recommendations.map((r) => {
61
+ const ascount = Object.fromEntries(AS_STATUSES.map((s) => [s, 0]));
62
+ const dccount = Object.fromEntries(DEC_STATUSES.map((s) => [s, 0]));
63
+ for (const id of r.assumptionIds) {
64
+ const a = asById.get(id);
65
+ if (a)
66
+ ascount[a.status]++;
67
+ }
68
+ for (const id of r.decisionIds) {
69
+ const d = decById.get(id);
70
+ if (d)
71
+ dccount[d.status]++;
72
+ }
73
+ let evCount = 0;
74
+ for (const id of r.evidenceIds)
75
+ if (evById.has(id))
76
+ evCount++;
77
+ return {
78
+ id: r.id,
79
+ title: r.title,
80
+ status: r.status,
81
+ assumptionsByStatus: ascount,
82
+ decisionsByStatus: dccount,
83
+ evidenceCount: evCount,
84
+ };
85
+ });
86
+ return {
87
+ recommendations: {
88
+ total: recLedger.recommendations.length,
89
+ byStatus: recByStatus,
90
+ byReadiness: recByReadiness,
91
+ },
92
+ evidence: { total: evLedger.evidence.length, byKind: evByKind },
93
+ assumptions: {
94
+ total: asLedger.assumptions.length,
95
+ byStatus: asByStatus,
96
+ },
97
+ decisions: {
98
+ total: decLedger.decisions.length,
99
+ byStatus: decByStatus,
100
+ untied: decUntied,
101
+ },
102
+ links: { brokenAssumptionLinks, brokenDecisionLinks, brokenEvidenceLinks },
103
+ perRec,
104
+ };
105
+ }
106
+ //# sourceMappingURL=stats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../../src/intelligence/store/stats.ts"],"names":[],"mappings":"AA6CA,MAAM,YAAY,GAA+B;IAC/C,WAAW;IACX,UAAU;IACV,UAAU;IACV,UAAU;IACV,WAAW;CACZ,CAAC;AACF,MAAM,eAAe,GAAkC;IACrD,UAAU;IACV,gBAAgB;IAChB,gBAAgB;IAChB,qBAAqB;IACrB,wBAAwB;IACxB,SAAS;CACV,CAAC;AACF,MAAM,QAAQ,GA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CAAC,EAAE,CAAC;gBAAE,OAAO,EAAE,CAAC;QAC9D,OAAO;YACL,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,mBAAmB,EAAE,OAAO;YAC5B,iBAAiB,EAAE,OAAO;YAC1B,aAAa,EAAE,OAAO;SACvB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,eAAe,EAAE;YACf,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,MAAM;YACvC,QAAQ,EAAE,WAAW;YACrB,WAAW,EAAE,cAAc;SAC5B;QACD,QAAQ,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE;QAC/D,WAAW,EAAE;YACX,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM;YAClC,QAAQ,EAAE,UAAU;SACrB;QACD,SAAS,EAAE;YACT,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM;YACjC,QAAQ,EAAE,WAAW;YACrB,MAAM,EAAE,SAAS;SAClB;QACD,KAAK,EAAE,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE;QAC1E,MAAM;KACP,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manehorizons/cadence-core",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },
@@ -50,7 +50,7 @@
50
50
  "@anthropic-ai/sdk": "^0.96.0",
51
51
  "commander": "^13.0.0",
52
52
  "zod": "^4.4.3",
53
- "@manehorizons/cadence-types": "1.6.0"
53
+ "@manehorizons/cadence-types": "1.6.1"
54
54
  },
55
55
  "devDependencies": {
56
56
  "vitest": "^2.1.0",