@ginkoai/cli 1.6.1 → 1.6.2
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/README.md +34 -0
- package/dist/commands/epic.d.ts +29 -0
- package/dist/commands/epic.d.ts.map +1 -0
- package/dist/commands/epic.js +322 -0
- package/dist/commands/epic.js.map +1 -0
- package/dist/commands/graph/api-client.d.ts +201 -0
- package/dist/commands/graph/api-client.d.ts.map +1 -1
- package/dist/commands/graph/api-client.js +59 -0
- package/dist/commands/graph/api-client.js.map +1 -1
- package/dist/commands/log.d.ts.map +1 -1
- package/dist/commands/log.js +39 -4
- package/dist/commands/log.js.map +1 -1
- package/dist/commands/start/start-reflection.d.ts +11 -0
- package/dist/commands/start/start-reflection.d.ts.map +1 -1
- package/dist/commands/start/start-reflection.js +142 -12
- package/dist/commands/start/start-reflection.js.map +1 -1
- package/dist/core/session-log-manager.d.ts +1 -1
- package/dist/core/session-log-manager.d.ts.map +1 -1
- package/dist/core/session-log-manager.js +12 -3
- package/dist/core/session-log-manager.js.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/event-logger.d.ts +1 -1
- package/dist/lib/event-logger.d.ts.map +1 -1
- package/dist/lib/output-formatter.d.ts +25 -1
- package/dist/lib/output-formatter.d.ts.map +1 -1
- package/dist/lib/output-formatter.js +37 -17
- package/dist/lib/output-formatter.js.map +1 -1
- package/dist/lib/sprint-loader.d.ts +2 -0
- package/dist/lib/sprint-loader.d.ts.map +1 -1
- package/dist/lib/sprint-loader.js +81 -6
- package/dist/lib/sprint-loader.js.map +1 -1
- package/dist/templates/ai-instructions-template.d.ts +3 -2
- package/dist/templates/ai-instructions-template.d.ts.map +1 -1
- package/dist/templates/ai-instructions-template.js +104 -2
- package/dist/templates/ai-instructions-template.js.map +1 -1
- package/dist/templates/epic-template.md +319 -0
- package/dist/utils/command-helpers.d.ts +10 -0
- package/dist/utils/command-helpers.d.ts.map +1 -1
- package/dist/utils/command-helpers.js +52 -1
- package/dist/utils/command-helpers.js.map +1 -1
- package/dist/utils/pattern-confidence.d.ts +82 -0
- package/dist/utils/pattern-confidence.d.ts.map +1 -0
- package/dist/utils/pattern-confidence.js +172 -0
- package/dist/utils/pattern-confidence.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileType: utility
|
|
3
|
+
* @status: current
|
|
4
|
+
* @updated: 2025-11-25
|
|
5
|
+
* @tags: [pattern, confidence, scoring, epic-002, task-3]
|
|
6
|
+
* @related: [sprint-loader.ts, ../lib/output-formatter.ts]
|
|
7
|
+
* @priority: medium
|
|
8
|
+
* @complexity: low
|
|
9
|
+
* @dependencies: []
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Thresholds for confidence calculation
|
|
13
|
+
*/
|
|
14
|
+
const THRESHOLDS = {
|
|
15
|
+
// Usage count thresholds
|
|
16
|
+
HIGH_USAGE: 5, // 5+ usages = high confidence
|
|
17
|
+
MEDIUM_USAGE: 2, // 2-4 usages = medium confidence
|
|
18
|
+
// Age thresholds (in days)
|
|
19
|
+
HIGH_AGE: 14, // 14+ days = high age score
|
|
20
|
+
MEDIUM_AGE: 3, // 3-13 days = medium age score
|
|
21
|
+
// Score weights
|
|
22
|
+
USAGE_WEIGHT: 0.6, // Usage is most important
|
|
23
|
+
AGE_WEIGHT: 0.3, // Age contributes to trust
|
|
24
|
+
RESOLUTION_WEIGHT: 0.1, // Resolution rate (for gotchas)
|
|
25
|
+
// Confidence level boundaries
|
|
26
|
+
HIGH_THRESHOLD: 70,
|
|
27
|
+
MEDIUM_THRESHOLD: 40,
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Calculate confidence level for a pattern
|
|
31
|
+
*
|
|
32
|
+
* @param metrics - Pattern usage metrics
|
|
33
|
+
* @returns Confidence result with level, score, and contributing factors
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const confidence = calculateConfidence({
|
|
37
|
+
* usageCount: 8,
|
|
38
|
+
* createdAt: '2025-11-01',
|
|
39
|
+
* lastUsedAt: '2025-11-24'
|
|
40
|
+
* });
|
|
41
|
+
* // { level: 'high', score: 85, factors: { usage: 100, age: 75 } }
|
|
42
|
+
*/
|
|
43
|
+
export function calculateConfidence(metrics) {
|
|
44
|
+
const usageScore = calculateUsageScore(metrics.usageCount);
|
|
45
|
+
const ageScore = calculateAgeScore(metrics.createdAt);
|
|
46
|
+
const resolutionScore = metrics.encounters
|
|
47
|
+
? calculateResolutionScore(metrics.encounters, metrics.resolutions || 0)
|
|
48
|
+
: undefined;
|
|
49
|
+
// Calculate weighted score
|
|
50
|
+
let totalScore;
|
|
51
|
+
if (resolutionScore !== undefined) {
|
|
52
|
+
// Gotcha: include resolution rate
|
|
53
|
+
totalScore =
|
|
54
|
+
usageScore * THRESHOLDS.USAGE_WEIGHT +
|
|
55
|
+
ageScore * THRESHOLDS.AGE_WEIGHT +
|
|
56
|
+
resolutionScore * THRESHOLDS.RESOLUTION_WEIGHT;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// Pattern: usage and age only, rebalance weights
|
|
60
|
+
const adjustedUsageWeight = THRESHOLDS.USAGE_WEIGHT /
|
|
61
|
+
(THRESHOLDS.USAGE_WEIGHT + THRESHOLDS.AGE_WEIGHT);
|
|
62
|
+
const adjustedAgeWeight = THRESHOLDS.AGE_WEIGHT /
|
|
63
|
+
(THRESHOLDS.USAGE_WEIGHT + THRESHOLDS.AGE_WEIGHT);
|
|
64
|
+
totalScore = usageScore * adjustedUsageWeight + ageScore * adjustedAgeWeight;
|
|
65
|
+
}
|
|
66
|
+
// Determine confidence level
|
|
67
|
+
let level;
|
|
68
|
+
if (totalScore >= THRESHOLDS.HIGH_THRESHOLD) {
|
|
69
|
+
level = 'high';
|
|
70
|
+
}
|
|
71
|
+
else if (totalScore >= THRESHOLDS.MEDIUM_THRESHOLD) {
|
|
72
|
+
level = 'medium';
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
level = 'low';
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
level,
|
|
79
|
+
score: Math.round(totalScore),
|
|
80
|
+
factors: {
|
|
81
|
+
usage: usageScore,
|
|
82
|
+
age: ageScore,
|
|
83
|
+
...(resolutionScore !== undefined && { resolution: resolutionScore }),
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Calculate usage score (0-100)
|
|
89
|
+
* Higher usage = higher score
|
|
90
|
+
*/
|
|
91
|
+
function calculateUsageScore(usageCount) {
|
|
92
|
+
if (usageCount >= THRESHOLDS.HIGH_USAGE) {
|
|
93
|
+
return 100;
|
|
94
|
+
}
|
|
95
|
+
else if (usageCount >= THRESHOLDS.MEDIUM_USAGE) {
|
|
96
|
+
// Linear interpolation between medium and high
|
|
97
|
+
return 50 + ((usageCount - THRESHOLDS.MEDIUM_USAGE) / (THRESHOLDS.HIGH_USAGE - THRESHOLDS.MEDIUM_USAGE)) * 50;
|
|
98
|
+
}
|
|
99
|
+
else if (usageCount >= 1) {
|
|
100
|
+
// Linear interpolation between 1 and medium
|
|
101
|
+
return (usageCount / THRESHOLDS.MEDIUM_USAGE) * 50;
|
|
102
|
+
}
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Calculate age score (0-100)
|
|
107
|
+
* Older patterns with sustained use have higher trust
|
|
108
|
+
*/
|
|
109
|
+
function calculateAgeScore(createdAt) {
|
|
110
|
+
const created = typeof createdAt === 'string' ? new Date(createdAt) : createdAt;
|
|
111
|
+
const now = new Date();
|
|
112
|
+
const ageInDays = Math.floor((now.getTime() - created.getTime()) / (1000 * 60 * 60 * 24));
|
|
113
|
+
if (ageInDays >= THRESHOLDS.HIGH_AGE) {
|
|
114
|
+
return 100;
|
|
115
|
+
}
|
|
116
|
+
else if (ageInDays >= THRESHOLDS.MEDIUM_AGE) {
|
|
117
|
+
// Linear interpolation
|
|
118
|
+
return 50 + ((ageInDays - THRESHOLDS.MEDIUM_AGE) / (THRESHOLDS.HIGH_AGE - THRESHOLDS.MEDIUM_AGE)) * 50;
|
|
119
|
+
}
|
|
120
|
+
else if (ageInDays >= 1) {
|
|
121
|
+
return (ageInDays / THRESHOLDS.MEDIUM_AGE) * 50;
|
|
122
|
+
}
|
|
123
|
+
return 25; // Same-day patterns get base score (not zero - they exist for a reason)
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Calculate resolution score for gotchas (0-100)
|
|
127
|
+
* Higher resolution rate = more confident the gotcha warning is useful
|
|
128
|
+
*/
|
|
129
|
+
function calculateResolutionScore(encounters, resolutions) {
|
|
130
|
+
if (encounters === 0)
|
|
131
|
+
return 50; // No data, assume medium
|
|
132
|
+
const rate = resolutions / encounters;
|
|
133
|
+
return Math.round(rate * 100);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Get default confidence for new patterns
|
|
137
|
+
* New patterns start at medium to avoid cold-start issues
|
|
138
|
+
*/
|
|
139
|
+
export function getDefaultConfidence() {
|
|
140
|
+
return {
|
|
141
|
+
level: 'medium',
|
|
142
|
+
score: 50,
|
|
143
|
+
factors: {
|
|
144
|
+
usage: 25,
|
|
145
|
+
age: 25,
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Sort patterns by confidence (highest first)
|
|
151
|
+
*
|
|
152
|
+
* @param patterns - Array of patterns with confidence scores
|
|
153
|
+
* @returns Sorted array (descending by score)
|
|
154
|
+
*/
|
|
155
|
+
export function sortByConfidence(patterns) {
|
|
156
|
+
return [...patterns].sort((a, b) => {
|
|
157
|
+
const scoreA = a.confidence?.score ?? 50;
|
|
158
|
+
const scoreB = b.confidence?.score ?? 50;
|
|
159
|
+
return scoreB - scoreA;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Format confidence for display
|
|
164
|
+
*
|
|
165
|
+
* @param confidence - Confidence result
|
|
166
|
+
* @returns Human-readable string
|
|
167
|
+
*/
|
|
168
|
+
export function formatConfidence(confidence) {
|
|
169
|
+
const emoji = confidence.level === 'high' ? '✓' : confidence.level === 'medium' ? '~' : '?';
|
|
170
|
+
return `${emoji} ${confidence.level} (${confidence.score}%)`;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=pattern-confidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-confidence.js","sourceRoot":"","sources":["../../src/utils/pattern-confidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAyCH;;GAEG;AACH,MAAM,UAAU,GAAG;IACjB,yBAAyB;IACzB,UAAU,EAAE,CAAC,EAAE,8BAA8B;IAC7C,YAAY,EAAE,CAAC,EAAE,iCAAiC;IAElD,2BAA2B;IAC3B,QAAQ,EAAE,EAAE,EAAE,4BAA4B;IAC1C,UAAU,EAAE,CAAC,EAAE,+BAA+B;IAE9C,gBAAgB;IAChB,YAAY,EAAE,GAAG,EAAE,0BAA0B;IAC7C,UAAU,EAAE,GAAG,EAAE,2BAA2B;IAC5C,iBAAiB,EAAE,GAAG,EAAE,gCAAgC;IAExD,8BAA8B;IAC9B,cAAc,EAAE,EAAE;IAClB,gBAAgB,EAAE,EAAE;CACrB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAuB;IACzD,MAAM,UAAU,GAAG,mBAAmB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3D,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACtD,MAAM,eAAe,GAAG,OAAO,CAAC,UAAU;QACxC,CAAC,CAAC,wBAAwB,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;QACxE,CAAC,CAAC,SAAS,CAAC;IAEd,2BAA2B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