mulch-cli 0.4.2 → 0.4.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.
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Returns the number of successful outcomes for a record.
3
+ * Successful outcomes indicate confirmed, working applications of the record.
4
+ */
5
+ export function getSuccessCount(record) {
6
+ if (!record.outcomes || record.outcomes.length === 0)
7
+ return 0;
8
+ return record.outcomes.filter((o) => o.status === "success").length;
9
+ }
10
+ /**
11
+ * Returns the number of failed outcomes for a record.
12
+ */
13
+ export function getFailureCount(record) {
14
+ if (!record.outcomes || record.outcomes.length === 0)
15
+ return 0;
16
+ return record.outcomes.filter((o) => o.status === "failure").length;
17
+ }
18
+ /**
19
+ * Returns the total number of recorded outcomes (applications) for a record.
20
+ */
21
+ export function getTotalApplications(record) {
22
+ return record.outcomes?.length ?? 0;
23
+ }
24
+ /**
25
+ * Returns the success rate (0-1) for a record.
26
+ * Partial outcomes are counted as 0.5 (half success).
27
+ * Returns 0 for records with no outcomes.
28
+ */
29
+ export function getSuccessRate(record) {
30
+ const total = getTotalApplications(record);
31
+ if (total === 0)
32
+ return 0;
33
+ const partialCount = record.outcomes?.filter((o) => o.status === "partial").length ?? 0;
34
+ const successCount = getSuccessCount(record);
35
+ return (successCount + partialCount * 0.5) / total;
36
+ }
37
+ /**
38
+ * Computes the confirmation-frequency score for a record.
39
+ *
40
+ * The score is the count of successful confirmations (applications where
41
+ * the record's guidance was applied and the outcome was "success").
42
+ * Partial outcomes contribute 0.5 to the score.
43
+ *
44
+ * Records with no outcomes return 0.
45
+ * Records with only failures return 0.
46
+ */
47
+ export function computeConfirmationScore(record) {
48
+ if (!record.outcomes || record.outcomes.length === 0)
49
+ return 0;
50
+ const successCount = getSuccessCount(record);
51
+ const partialCount = record.outcomes.filter((o) => o.status === "partial").length;
52
+ return successCount + partialCount * 0.5;
53
+ }
54
+ /**
55
+ * Applies a confirmation-frequency boost to a base score (e.g., a BM25 relevance score).
56
+ *
57
+ * Records with no outcomes (score = 0) are returned unchanged.
58
+ * Records with confirmed applications receive a multiplicative boost proportional
59
+ * to their confirmation score.
60
+ *
61
+ * @param baseScore - The base relevance score (e.g., from BM25)
62
+ * @param record - The record to score
63
+ * @param boostFactor - Multiplier controlling boost magnitude (default: 0.1)
64
+ * @returns The boosted score
65
+ */
66
+ export function applyConfirmationBoost(baseScore, record, boostFactor = 0.1) {
67
+ const confirmationScore = computeConfirmationScore(record);
68
+ if (confirmationScore === 0)
69
+ return baseScore;
70
+ return baseScore * (1 + boostFactor * confirmationScore);
71
+ }
72
+ /**
73
+ * Sorts records by confirmation-frequency score, highest first.
74
+ * Records with equal scores maintain their original relative order (stable sort).
75
+ * Records with no outcomes (score = 0) sort to the end.
76
+ */
77
+ export function sortByConfirmationScore(records) {
78
+ return [...records].sort((a, b) => computeConfirmationScore(b) - computeConfirmationScore(a));
79
+ }
80
+ //# sourceMappingURL=scoring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoring.js","sourceRoot":"","sources":["../../src/utils/scoring.ts"],"names":[],"mappings":"AA0BA;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,MAAoB;IAClD,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC;AACtE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAoB;IAClD,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC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CAAC,CAAC;IAC3D,IAAI,iBAAiB,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC9C,OAAO,SAAS,GAAG,CAAC,CAAC,GAAG,WAAW,GAAG,iBAAiB,CAAC,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAyB,OAAY;IAC1E,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CACtB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,wBAAwB,CAAC,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAAC,CAAC,CACpE,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulch-cli",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Let your agents grow 🌱 — structured expertise files that accumulate over time, live in git, work with any agent",
5
5
  "type": "module",
6
6
  "bin": {