@boshu2/vibe-check 1.0.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.
- package/README.md +115 -0
- package/bin/vibe-check.js +2 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +90 -0
- package/dist/cli.js.map +1 -0
- package/dist/git.d.ts +4 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +64 -0
- package/dist/git.js.map +1 -0
- package/dist/metrics/flow.d.ts +3 -0
- package/dist/metrics/flow.d.ts.map +1 -0
- package/dist/metrics/flow.js +48 -0
- package/dist/metrics/flow.js.map +1 -0
- package/dist/metrics/index.d.ts +4 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +156 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/rework.d.ts +3 -0
- package/dist/metrics/rework.d.ts.map +1 -0
- package/dist/metrics/rework.js +45 -0
- package/dist/metrics/rework.js.map +1 -0
- package/dist/metrics/spirals.d.ts +9 -0
- package/dist/metrics/spirals.d.ts.map +1 -0
- package/dist/metrics/spirals.js +153 -0
- package/dist/metrics/spirals.js.map +1 -0
- package/dist/metrics/trust.d.ts +3 -0
- package/dist/metrics/trust.d.ts.map +1 -0
- package/dist/metrics/trust.js +71 -0
- package/dist/metrics/trust.js.map +1 -0
- package/dist/metrics/velocity.d.ts +4 -0
- package/dist/metrics/velocity.d.ts.map +1 -0
- package/dist/metrics/velocity.js +77 -0
- package/dist/metrics/velocity.js.map +1 -0
- package/dist/output/index.d.ts +6 -0
- package/dist/output/index.d.ts.map +1 -0
- package/dist/output/index.js +25 -0
- package/dist/output/index.js.map +1 -0
- package/dist/output/json.d.ts +3 -0
- package/dist/output/json.d.ts.map +1 -0
- package/dist/output/json.js +52 -0
- package/dist/output/json.js.map +1 -0
- package/dist/output/markdown.d.ts +3 -0
- package/dist/output/markdown.d.ts.map +1 -0
- package/dist/output/markdown.js +90 -0
- package/dist/output/markdown.js.map +1 -0
- package/dist/output/terminal.d.ts +3 -0
- package/dist/output/terminal.d.ts.map +1 -0
- package/dist/output/terminal.js +90 -0
- package/dist/output/terminal.js.map +1 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +42 -0
- package/src/cli.ts +96 -0
- package/src/git.ts +72 -0
- package/src/metrics/flow.ts +53 -0
- package/src/metrics/index.ts +169 -0
- package/src/metrics/rework.ts +45 -0
- package/src/metrics/spirals.ts +173 -0
- package/src/metrics/trust.ts +80 -0
- package/src/metrics/velocity.ts +86 -0
- package/src/output/index.ts +20 -0
- package/src/output/json.ts +51 -0
- package/src/output/markdown.ts +111 -0
- package/src/output/terminal.ts +109 -0
- package/src/types.ts +68 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { differenceInMinutes } from 'date-fns';
|
|
2
|
+
import { Commit, FixChain, MetricResult, Rating } from '../types';
|
|
3
|
+
|
|
4
|
+
const SPIRAL_THRESHOLD = 3; // 3+ consecutive fixes = spiral
|
|
5
|
+
|
|
6
|
+
// Pattern detection regexes
|
|
7
|
+
const PATTERNS: Record<string, RegExp> = {
|
|
8
|
+
VOLUME_CONFIG: /volume|mount|path|permission|readonly|pvc|storage/i,
|
|
9
|
+
SECRETS_AUTH: /secret|auth|oauth|token|credential|password|key/i,
|
|
10
|
+
API_MISMATCH: /api|version|field|spec|schema|crd|resource/i,
|
|
11
|
+
SSL_TLS: /ssl|tls|cert|fips|handshake|https/i,
|
|
12
|
+
IMAGE_REGISTRY: /image|pull|registry|docker|tag/i,
|
|
13
|
+
GITOPS_DRIFT: /drift|sync|argocd|reconcil|outof/i,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function detectFixChains(commits: Commit[]): FixChain[] {
|
|
17
|
+
if (commits.length === 0) return [];
|
|
18
|
+
|
|
19
|
+
// Sort by date ascending
|
|
20
|
+
const sorted = [...commits].sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
21
|
+
|
|
22
|
+
const chains: FixChain[] = [];
|
|
23
|
+
let currentChain: Commit[] = [];
|
|
24
|
+
let currentComponent: string | null = null;
|
|
25
|
+
|
|
26
|
+
for (const commit of sorted) {
|
|
27
|
+
if (commit.type === 'fix') {
|
|
28
|
+
const component = getComponent(commit);
|
|
29
|
+
|
|
30
|
+
if (component === currentComponent || currentComponent === null) {
|
|
31
|
+
currentChain.push(commit);
|
|
32
|
+
currentComponent = component;
|
|
33
|
+
} else {
|
|
34
|
+
// Different component, save current chain if valid
|
|
35
|
+
if (currentChain.length >= SPIRAL_THRESHOLD) {
|
|
36
|
+
chains.push(createFixChain(currentChain, currentComponent));
|
|
37
|
+
}
|
|
38
|
+
currentChain = [commit];
|
|
39
|
+
currentComponent = component;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
// Non-fix commit breaks the chain
|
|
43
|
+
if (currentChain.length >= SPIRAL_THRESHOLD && currentComponent) {
|
|
44
|
+
chains.push(createFixChain(currentChain, currentComponent));
|
|
45
|
+
}
|
|
46
|
+
currentChain = [];
|
|
47
|
+
currentComponent = null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Handle final chain
|
|
52
|
+
if (currentChain.length >= SPIRAL_THRESHOLD && currentComponent) {
|
|
53
|
+
chains.push(createFixChain(currentChain, currentComponent));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return chains;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function getComponent(commit: Commit): string {
|
|
60
|
+
// Use scope if available
|
|
61
|
+
if (commit.scope) {
|
|
62
|
+
return commit.scope.toLowerCase();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Extract first meaningful word from message
|
|
66
|
+
const words = commit.message
|
|
67
|
+
.replace(/^fix\s*:?\s*/i, '')
|
|
68
|
+
.split(/\s+/)
|
|
69
|
+
.filter((w) => w.length > 2);
|
|
70
|
+
|
|
71
|
+
return words[0]?.toLowerCase() || 'unknown';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function createFixChain(commits: Commit[], component: string): FixChain {
|
|
75
|
+
const firstCommit = commits[0].date;
|
|
76
|
+
const lastCommit = commits[commits.length - 1].date;
|
|
77
|
+
const duration = differenceInMinutes(lastCommit, firstCommit);
|
|
78
|
+
|
|
79
|
+
// Detect pattern from commit messages
|
|
80
|
+
const allMessages = commits.map((c) => c.message).join(' ');
|
|
81
|
+
const pattern = detectPattern(allMessages);
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
component,
|
|
85
|
+
commits: commits.length,
|
|
86
|
+
duration,
|
|
87
|
+
isSpiral: commits.length >= SPIRAL_THRESHOLD,
|
|
88
|
+
pattern,
|
|
89
|
+
firstCommit,
|
|
90
|
+
lastCommit,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function detectPattern(text: string): string | null {
|
|
95
|
+
for (const [pattern, regex] of Object.entries(PATTERNS)) {
|
|
96
|
+
if (regex.test(text)) {
|
|
97
|
+
return pattern;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function calculateDebugSpiralDuration(chains: FixChain[]): MetricResult {
|
|
104
|
+
const spirals = chains.filter((c) => c.isSpiral);
|
|
105
|
+
|
|
106
|
+
if (spirals.length === 0) {
|
|
107
|
+
return {
|
|
108
|
+
value: 0,
|
|
109
|
+
unit: 'min',
|
|
110
|
+
rating: 'elite',
|
|
111
|
+
description: 'No debug spirals detected',
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const totalDuration = spirals.reduce((sum, s) => sum + s.duration, 0);
|
|
116
|
+
const avgDuration = totalDuration / spirals.length;
|
|
117
|
+
const rating = getRating(avgDuration);
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
value: Math.round(avgDuration),
|
|
121
|
+
unit: 'min',
|
|
122
|
+
rating,
|
|
123
|
+
description: getDescription(rating, spirals.length),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function getRating(duration: number): Rating {
|
|
128
|
+
if (duration < 15) return 'elite';
|
|
129
|
+
if (duration < 30) return 'high';
|
|
130
|
+
if (duration < 60) return 'medium';
|
|
131
|
+
return 'low';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function getDescription(rating: Rating, spiralCount: number): string {
|
|
135
|
+
const spiralText = spiralCount === 1 ? '1 spiral' : `${spiralCount} spirals`;
|
|
136
|
+
|
|
137
|
+
switch (rating) {
|
|
138
|
+
case 'elite':
|
|
139
|
+
return `${spiralText} resolved quickly`;
|
|
140
|
+
case 'high':
|
|
141
|
+
return `${spiralText}, normal debugging time`;
|
|
142
|
+
case 'medium':
|
|
143
|
+
return `${spiralText}, consider using tracer tests`;
|
|
144
|
+
case 'low':
|
|
145
|
+
return `${spiralText}, extended debugging. Use tracer tests before implementation`;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function calculatePatternSummary(chains: FixChain[]): {
|
|
150
|
+
categories: Record<string, number>;
|
|
151
|
+
total: number;
|
|
152
|
+
tracerAvailable: number;
|
|
153
|
+
} {
|
|
154
|
+
const categories: Record<string, number> = {};
|
|
155
|
+
let total = 0;
|
|
156
|
+
let withTracer = 0;
|
|
157
|
+
|
|
158
|
+
for (const chain of chains) {
|
|
159
|
+
const pattern = chain.pattern || 'OTHER';
|
|
160
|
+
categories[pattern] = (categories[pattern] || 0) + chain.commits;
|
|
161
|
+
total += chain.commits;
|
|
162
|
+
|
|
163
|
+
if (chain.pattern) {
|
|
164
|
+
withTracer += chain.commits;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
categories,
|
|
170
|
+
total,
|
|
171
|
+
tracerAvailable: total > 0 ? Math.round((withTracer / total) * 100) : 0,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { differenceInMinutes } from 'date-fns';
|
|
2
|
+
import { Commit, MetricResult, Rating } from '../types';
|
|
3
|
+
|
|
4
|
+
const FOLLOWUP_WINDOW_MINUTES = 30;
|
|
5
|
+
|
|
6
|
+
export function calculateTrustPassRate(commits: Commit[]): MetricResult {
|
|
7
|
+
if (commits.length === 0) {
|
|
8
|
+
return {
|
|
9
|
+
value: 100,
|
|
10
|
+
unit: '%',
|
|
11
|
+
rating: 'elite',
|
|
12
|
+
description: 'No commits found',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Sort by date ascending
|
|
17
|
+
const sorted = [...commits].sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
18
|
+
|
|
19
|
+
let trustedCommits = 0;
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
22
|
+
const commit = sorted[i];
|
|
23
|
+
const nextCommit = sorted[i + 1];
|
|
24
|
+
|
|
25
|
+
// Check if next commit is a fix to same component within 30 min
|
|
26
|
+
const needsFollowup =
|
|
27
|
+
nextCommit &&
|
|
28
|
+
nextCommit.type === 'fix' &&
|
|
29
|
+
sameComponent(commit, nextCommit) &&
|
|
30
|
+
differenceInMinutes(nextCommit.date, commit.date) < FOLLOWUP_WINDOW_MINUTES;
|
|
31
|
+
|
|
32
|
+
if (!needsFollowup) {
|
|
33
|
+
trustedCommits++;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const rate = (trustedCommits / commits.length) * 100;
|
|
38
|
+
const rating = getRating(rate);
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
value: Math.round(rate),
|
|
42
|
+
unit: '%',
|
|
43
|
+
rating,
|
|
44
|
+
description: getDescription(rating),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function sameComponent(a: Commit, b: Commit): boolean {
|
|
49
|
+
// If both have scopes, compare them
|
|
50
|
+
if (a.scope && b.scope) {
|
|
51
|
+
return a.scope.toLowerCase() === b.scope.toLowerCase();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// If neither has scope, check if messages reference same area
|
|
55
|
+
// This is a simple heuristic - first word after type
|
|
56
|
+
const aWords = a.message.split(/\s+/).slice(0, 3);
|
|
57
|
+
const bWords = b.message.split(/\s+/).slice(0, 3);
|
|
58
|
+
|
|
59
|
+
return aWords.some((word) => bWords.includes(word) && word.length > 3);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getRating(rate: number): Rating {
|
|
63
|
+
if (rate > 95) return 'elite';
|
|
64
|
+
if (rate >= 80) return 'high';
|
|
65
|
+
if (rate >= 60) return 'medium';
|
|
66
|
+
return 'low';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getDescription(rating: Rating): string {
|
|
70
|
+
switch (rating) {
|
|
71
|
+
case 'elite':
|
|
72
|
+
return 'Code sticks on first try, high AI trust';
|
|
73
|
+
case 'high':
|
|
74
|
+
return 'Occasional fixes needed, mostly autonomous';
|
|
75
|
+
case 'medium':
|
|
76
|
+
return 'Regular intervention required';
|
|
77
|
+
case 'low':
|
|
78
|
+
return 'Heavy oversight needed, run tracer tests before implementation';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { differenceInMinutes } from 'date-fns';
|
|
2
|
+
import { Commit, MetricResult, Rating } from '../types';
|
|
3
|
+
|
|
4
|
+
const SESSION_GAP_MINUTES = 120; // 2 hours = new session
|
|
5
|
+
|
|
6
|
+
export function calculateIterationVelocity(commits: Commit[]): MetricResult {
|
|
7
|
+
if (commits.length === 0) {
|
|
8
|
+
return {
|
|
9
|
+
value: 0,
|
|
10
|
+
unit: 'commits/hour',
|
|
11
|
+
rating: 'low',
|
|
12
|
+
description: 'No commits found',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const activeHours = calculateActiveHours(commits);
|
|
17
|
+
|
|
18
|
+
if (activeHours === 0) {
|
|
19
|
+
return {
|
|
20
|
+
value: commits.length,
|
|
21
|
+
unit: 'commits/hour',
|
|
22
|
+
rating: 'high',
|
|
23
|
+
description: 'All commits in rapid succession',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const velocity = commits.length / activeHours;
|
|
28
|
+
const rating = getRating(velocity);
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
value: Math.round(velocity * 10) / 10,
|
|
32
|
+
unit: 'commits/hour',
|
|
33
|
+
rating,
|
|
34
|
+
description: getDescription(rating),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function calculateActiveHours(commits: Commit[]): number {
|
|
39
|
+
if (commits.length < 2) {
|
|
40
|
+
return 0.1; // Minimum to avoid division by zero
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Sort by date ascending
|
|
44
|
+
const sorted = [...commits].sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
45
|
+
|
|
46
|
+
let totalMinutes = 0;
|
|
47
|
+
let sessionStart = sorted[0].date;
|
|
48
|
+
|
|
49
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
50
|
+
const gap = differenceInMinutes(sorted[i].date, sorted[i - 1].date);
|
|
51
|
+
|
|
52
|
+
if (gap > SESSION_GAP_MINUTES) {
|
|
53
|
+
// End current session, start new one
|
|
54
|
+
totalMinutes += differenceInMinutes(sorted[i - 1].date, sessionStart);
|
|
55
|
+
sessionStart = sorted[i].date;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Add final session
|
|
60
|
+
totalMinutes += differenceInMinutes(sorted[sorted.length - 1].date, sessionStart);
|
|
61
|
+
|
|
62
|
+
// Minimum of 10 minutes per session to account for work between commits
|
|
63
|
+
const minMinutes = Math.max(totalMinutes, commits.length * 10);
|
|
64
|
+
|
|
65
|
+
return minMinutes / 60;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function getRating(velocity: number): Rating {
|
|
69
|
+
if (velocity > 5) return 'elite';
|
|
70
|
+
if (velocity >= 3) return 'high';
|
|
71
|
+
if (velocity >= 1) return 'medium';
|
|
72
|
+
return 'low';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getDescription(rating: Rating): string {
|
|
76
|
+
switch (rating) {
|
|
77
|
+
case 'elite':
|
|
78
|
+
return 'Excellent iteration speed, tight feedback loops';
|
|
79
|
+
case 'high':
|
|
80
|
+
return 'Good iteration speed';
|
|
81
|
+
case 'medium':
|
|
82
|
+
return 'Normal pace';
|
|
83
|
+
case 'low':
|
|
84
|
+
return 'Slow iteration, consider smaller commits';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { VibeCheckResult, OutputFormat } from '../types';
|
|
2
|
+
import { formatTerminal } from './terminal';
|
|
3
|
+
import { formatJson } from './json';
|
|
4
|
+
import { formatMarkdown } from './markdown';
|
|
5
|
+
|
|
6
|
+
export function formatOutput(result: VibeCheckResult, format: OutputFormat): string {
|
|
7
|
+
switch (format) {
|
|
8
|
+
case 'json':
|
|
9
|
+
return formatJson(result);
|
|
10
|
+
case 'markdown':
|
|
11
|
+
return formatMarkdown(result);
|
|
12
|
+
case 'terminal':
|
|
13
|
+
default:
|
|
14
|
+
return formatTerminal(result);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { formatTerminal } from './terminal';
|
|
19
|
+
export { formatJson } from './json';
|
|
20
|
+
export { formatMarkdown } from './markdown';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { VibeCheckResult } from '../types';
|
|
2
|
+
|
|
3
|
+
export function formatJson(result: VibeCheckResult): string {
|
|
4
|
+
// Create a JSON-friendly version with ISO date strings
|
|
5
|
+
const output = {
|
|
6
|
+
period: {
|
|
7
|
+
from: result.period.from.toISOString(),
|
|
8
|
+
to: result.period.to.toISOString(),
|
|
9
|
+
activeHours: result.period.activeHours,
|
|
10
|
+
},
|
|
11
|
+
commits: result.commits,
|
|
12
|
+
metrics: {
|
|
13
|
+
iterationVelocity: {
|
|
14
|
+
value: result.metrics.iterationVelocity.value,
|
|
15
|
+
unit: result.metrics.iterationVelocity.unit,
|
|
16
|
+
rating: result.metrics.iterationVelocity.rating,
|
|
17
|
+
},
|
|
18
|
+
reworkRatio: {
|
|
19
|
+
value: result.metrics.reworkRatio.value,
|
|
20
|
+
unit: result.metrics.reworkRatio.unit,
|
|
21
|
+
rating: result.metrics.reworkRatio.rating,
|
|
22
|
+
},
|
|
23
|
+
trustPassRate: {
|
|
24
|
+
value: result.metrics.trustPassRate.value,
|
|
25
|
+
unit: result.metrics.trustPassRate.unit,
|
|
26
|
+
rating: result.metrics.trustPassRate.rating,
|
|
27
|
+
},
|
|
28
|
+
debugSpiralDuration: {
|
|
29
|
+
value: result.metrics.debugSpiralDuration.value,
|
|
30
|
+
unit: result.metrics.debugSpiralDuration.unit,
|
|
31
|
+
rating: result.metrics.debugSpiralDuration.rating,
|
|
32
|
+
},
|
|
33
|
+
flowEfficiency: {
|
|
34
|
+
value: result.metrics.flowEfficiency.value,
|
|
35
|
+
unit: result.metrics.flowEfficiency.unit,
|
|
36
|
+
rating: result.metrics.flowEfficiency.rating,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
fixChains: result.fixChains.map((chain) => ({
|
|
40
|
+
component: chain.component,
|
|
41
|
+
commits: chain.commits,
|
|
42
|
+
duration: chain.duration,
|
|
43
|
+
isSpiral: chain.isSpiral,
|
|
44
|
+
pattern: chain.pattern,
|
|
45
|
+
})),
|
|
46
|
+
patterns: result.patterns,
|
|
47
|
+
overall: result.overall,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return JSON.stringify(output, null, 2);
|
|
51
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { VibeCheckResult } from '../types';
|
|
2
|
+
import { format } from 'date-fns';
|
|
3
|
+
|
|
4
|
+
export function formatMarkdown(result: VibeCheckResult): string {
|
|
5
|
+
const lines: string[] = [];
|
|
6
|
+
|
|
7
|
+
// Header
|
|
8
|
+
lines.push('# Vibe-Check Report');
|
|
9
|
+
lines.push('');
|
|
10
|
+
|
|
11
|
+
// Period
|
|
12
|
+
const fromStr = format(result.period.from, 'MMM d, yyyy');
|
|
13
|
+
const toStr = format(result.period.to, 'MMM d, yyyy');
|
|
14
|
+
lines.push(`**Period:** ${fromStr} - ${toStr} (${result.period.activeHours}h active)`);
|
|
15
|
+
lines.push(
|
|
16
|
+
`**Commits:** ${result.commits.total} total (${result.commits.feat} feat, ${result.commits.fix} fix, ${result.commits.docs} docs, ${result.commits.other} other)`
|
|
17
|
+
);
|
|
18
|
+
lines.push('');
|
|
19
|
+
|
|
20
|
+
// Overall
|
|
21
|
+
lines.push(`**Overall Rating:** ${result.overall}`);
|
|
22
|
+
lines.push('');
|
|
23
|
+
|
|
24
|
+
// Metrics table
|
|
25
|
+
lines.push('## Metrics');
|
|
26
|
+
lines.push('');
|
|
27
|
+
lines.push('| Metric | Value | Rating | Description |');
|
|
28
|
+
lines.push('|--------|-------|--------|-------------|');
|
|
29
|
+
|
|
30
|
+
const metrics = [
|
|
31
|
+
{ name: 'Iteration Velocity', metric: result.metrics.iterationVelocity },
|
|
32
|
+
{ name: 'Rework Ratio', metric: result.metrics.reworkRatio },
|
|
33
|
+
{ name: 'Trust Pass Rate', metric: result.metrics.trustPassRate },
|
|
34
|
+
{ name: 'Debug Spiral Duration', metric: result.metrics.debugSpiralDuration },
|
|
35
|
+
{ name: 'Flow Efficiency', metric: result.metrics.flowEfficiency },
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
for (const { name, metric } of metrics) {
|
|
39
|
+
const rating = metric.rating.toUpperCase();
|
|
40
|
+
lines.push(
|
|
41
|
+
`| ${name} | ${metric.value}${metric.unit} | ${rating} | ${metric.description} |`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
lines.push('');
|
|
45
|
+
|
|
46
|
+
// Debug spirals
|
|
47
|
+
if (result.fixChains.length > 0) {
|
|
48
|
+
lines.push('## Debug Spirals');
|
|
49
|
+
lines.push('');
|
|
50
|
+
lines.push('| Component | Commits | Duration | Pattern |');
|
|
51
|
+
lines.push('|-----------|---------|----------|---------|');
|
|
52
|
+
|
|
53
|
+
for (const chain of result.fixChains) {
|
|
54
|
+
const pattern = chain.pattern || '-';
|
|
55
|
+
lines.push(
|
|
56
|
+
`| ${chain.component} | ${chain.commits} | ${chain.duration}m | ${pattern} |`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
lines.push('');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Patterns
|
|
63
|
+
if (result.patterns.total > 0) {
|
|
64
|
+
lines.push('## Pattern Analysis');
|
|
65
|
+
lines.push('');
|
|
66
|
+
lines.push('| Pattern | Fix Count | Tracer Available |');
|
|
67
|
+
lines.push('|---------|-----------|------------------|');
|
|
68
|
+
|
|
69
|
+
for (const [pattern, count] of Object.entries(result.patterns.categories)) {
|
|
70
|
+
const tracer = pattern !== 'OTHER' ? 'Yes' : 'No';
|
|
71
|
+
lines.push(`| ${pattern} | ${count} | ${tracer} |`);
|
|
72
|
+
}
|
|
73
|
+
lines.push('');
|
|
74
|
+
lines.push(
|
|
75
|
+
`**${result.patterns.tracerAvailable}%** of fix patterns have tracer tests available.`
|
|
76
|
+
);
|
|
77
|
+
lines.push('');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Recommendations
|
|
81
|
+
lines.push('## Recommendations');
|
|
82
|
+
lines.push('');
|
|
83
|
+
|
|
84
|
+
if (result.metrics.reworkRatio.rating === 'low') {
|
|
85
|
+
lines.push('- High rework ratio detected. Consider running tracer tests before implementation.');
|
|
86
|
+
}
|
|
87
|
+
if (result.metrics.trustPassRate.rating === 'low' || result.metrics.trustPassRate.rating === 'medium') {
|
|
88
|
+
lines.push('- Trust pass rate below target. Validate assumptions before coding.');
|
|
89
|
+
}
|
|
90
|
+
if (result.metrics.debugSpiralDuration.rating === 'low') {
|
|
91
|
+
lines.push('- Long debug spirals detected. Break work into smaller, verifiable steps.');
|
|
92
|
+
}
|
|
93
|
+
if (result.fixChains.length > 0) {
|
|
94
|
+
const patterns = result.fixChains
|
|
95
|
+
.filter((c) => c.pattern)
|
|
96
|
+
.map((c) => c.pattern);
|
|
97
|
+
if (patterns.length > 0) {
|
|
98
|
+
lines.push(`- Consider adding tracer tests for: ${[...new Set(patterns)].join(', ')}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (lines[lines.length - 1] === '') {
|
|
103
|
+
lines.push('- All metrics healthy. Maintain current practices.');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
lines.push('');
|
|
107
|
+
lines.push('---');
|
|
108
|
+
lines.push(`*Generated by vibe-check on ${format(new Date(), 'yyyy-MM-dd HH:mm')}*`);
|
|
109
|
+
|
|
110
|
+
return lines.join('\n');
|
|
111
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { VibeCheckResult, Rating, OverallRating } from '../types';
|
|
3
|
+
import { format } from 'date-fns';
|
|
4
|
+
|
|
5
|
+
export function formatTerminal(result: VibeCheckResult): string {
|
|
6
|
+
const lines: string[] = [];
|
|
7
|
+
|
|
8
|
+
// Header
|
|
9
|
+
lines.push('');
|
|
10
|
+
lines.push(chalk.bold.cyan('=' .repeat(64)));
|
|
11
|
+
lines.push(chalk.bold.cyan(' VIBE-CHECK RESULTS'));
|
|
12
|
+
lines.push(chalk.bold.cyan('=' .repeat(64)));
|
|
13
|
+
|
|
14
|
+
// Period info
|
|
15
|
+
const fromStr = format(result.period.from, 'MMM d, yyyy');
|
|
16
|
+
const toStr = format(result.period.to, 'MMM d, yyyy');
|
|
17
|
+
lines.push('');
|
|
18
|
+
lines.push(
|
|
19
|
+
chalk.gray(` Period: ${fromStr} - ${toStr} (${result.period.activeHours}h active)`)
|
|
20
|
+
);
|
|
21
|
+
lines.push(
|
|
22
|
+
chalk.gray(
|
|
23
|
+
` Commits: ${result.commits.total} total (${result.commits.feat} feat, ${result.commits.fix} fix, ${result.commits.docs} docs, ${result.commits.other} other)`
|
|
24
|
+
)
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// Metrics table
|
|
28
|
+
lines.push('');
|
|
29
|
+
lines.push(chalk.bold.white(' METRIC VALUE RATING'));
|
|
30
|
+
lines.push(chalk.gray(' ' + '-'.repeat(50)));
|
|
31
|
+
|
|
32
|
+
const metrics = [
|
|
33
|
+
{ name: 'Iteration Velocity', metric: result.metrics.iterationVelocity },
|
|
34
|
+
{ name: 'Rework Ratio', metric: result.metrics.reworkRatio },
|
|
35
|
+
{ name: 'Trust Pass Rate', metric: result.metrics.trustPassRate },
|
|
36
|
+
{ name: 'Debug Spiral Duration', metric: result.metrics.debugSpiralDuration },
|
|
37
|
+
{ name: 'Flow Efficiency', metric: result.metrics.flowEfficiency },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
for (const { name, metric } of metrics) {
|
|
41
|
+
const valueStr = `${metric.value}${metric.unit}`.padEnd(10);
|
|
42
|
+
const ratingStr = formatRating(metric.rating);
|
|
43
|
+
lines.push(` ${name.padEnd(26)} ${valueStr} ${ratingStr}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Overall rating
|
|
47
|
+
lines.push('');
|
|
48
|
+
lines.push(chalk.bold.cyan('-'.repeat(64)));
|
|
49
|
+
lines.push(` ${chalk.bold('OVERALL:')} ${formatOverallRating(result.overall)}`);
|
|
50
|
+
lines.push(chalk.bold.cyan('-'.repeat(64)));
|
|
51
|
+
|
|
52
|
+
// Debug spirals
|
|
53
|
+
if (result.fixChains.length > 0) {
|
|
54
|
+
lines.push('');
|
|
55
|
+
lines.push(
|
|
56
|
+
chalk.bold.yellow(` DEBUG SPIRALS (${result.fixChains.length} detected):`)
|
|
57
|
+
);
|
|
58
|
+
for (const chain of result.fixChains) {
|
|
59
|
+
const patternStr = chain.pattern ? ` (${chain.pattern})` : '';
|
|
60
|
+
lines.push(
|
|
61
|
+
chalk.yellow(
|
|
62
|
+
` - ${chain.component}: ${chain.commits} commits, ${chain.duration}m${patternStr}`
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Patterns
|
|
69
|
+
if (result.patterns.total > 0) {
|
|
70
|
+
lines.push('');
|
|
71
|
+
lines.push(chalk.bold.magenta(' PATTERNS:'));
|
|
72
|
+
for (const [pattern, count] of Object.entries(result.patterns.categories)) {
|
|
73
|
+
const tracerNote = pattern !== 'OTHER' ? ' (tracer available)' : '';
|
|
74
|
+
lines.push(chalk.magenta(` - ${pattern}: ${count} fixes${tracerNote}`));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
lines.push('');
|
|
79
|
+
lines.push(chalk.bold.cyan('=' .repeat(64)));
|
|
80
|
+
lines.push('');
|
|
81
|
+
|
|
82
|
+
return lines.join('\n');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function formatRating(rating: Rating): string {
|
|
86
|
+
switch (rating) {
|
|
87
|
+
case 'elite':
|
|
88
|
+
return chalk.green.bold('ELITE');
|
|
89
|
+
case 'high':
|
|
90
|
+
return chalk.blue.bold('HIGH');
|
|
91
|
+
case 'medium':
|
|
92
|
+
return chalk.yellow.bold('MEDIUM');
|
|
93
|
+
case 'low':
|
|
94
|
+
return chalk.red.bold('LOW');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function formatOverallRating(rating: OverallRating): string {
|
|
99
|
+
switch (rating) {
|
|
100
|
+
case 'ELITE':
|
|
101
|
+
return chalk.green.bold('ELITE');
|
|
102
|
+
case 'HIGH':
|
|
103
|
+
return chalk.blue.bold('HIGH');
|
|
104
|
+
case 'MEDIUM':
|
|
105
|
+
return chalk.yellow.bold('MEDIUM');
|
|
106
|
+
case 'LOW':
|
|
107
|
+
return chalk.red.bold('LOW');
|
|
108
|
+
}
|
|
109
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export type Rating = 'elite' | 'high' | 'medium' | 'low';
|
|
2
|
+
export type OutputFormat = 'terminal' | 'json' | 'markdown';
|
|
3
|
+
export type OverallRating = 'ELITE' | 'HIGH' | 'MEDIUM' | 'LOW';
|
|
4
|
+
|
|
5
|
+
export interface Commit {
|
|
6
|
+
hash: string;
|
|
7
|
+
date: Date;
|
|
8
|
+
message: string;
|
|
9
|
+
type: 'feat' | 'fix' | 'docs' | 'chore' | 'refactor' | 'test' | 'style' | 'other';
|
|
10
|
+
scope: string | null;
|
|
11
|
+
author: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface MetricResult {
|
|
15
|
+
value: number;
|
|
16
|
+
unit: string;
|
|
17
|
+
rating: Rating;
|
|
18
|
+
description: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface FixChain {
|
|
22
|
+
component: string;
|
|
23
|
+
commits: number;
|
|
24
|
+
duration: number; // minutes
|
|
25
|
+
isSpiral: boolean;
|
|
26
|
+
pattern: string | null;
|
|
27
|
+
firstCommit: Date;
|
|
28
|
+
lastCommit: Date;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface PatternSummary {
|
|
32
|
+
categories: Record<string, number>;
|
|
33
|
+
total: number;
|
|
34
|
+
tracerAvailable: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface VibeCheckResult {
|
|
38
|
+
period: {
|
|
39
|
+
from: Date;
|
|
40
|
+
to: Date;
|
|
41
|
+
activeHours: number;
|
|
42
|
+
};
|
|
43
|
+
commits: {
|
|
44
|
+
total: number;
|
|
45
|
+
feat: number;
|
|
46
|
+
fix: number;
|
|
47
|
+
docs: number;
|
|
48
|
+
other: number;
|
|
49
|
+
};
|
|
50
|
+
metrics: {
|
|
51
|
+
iterationVelocity: MetricResult;
|
|
52
|
+
reworkRatio: MetricResult;
|
|
53
|
+
trustPassRate: MetricResult;
|
|
54
|
+
debugSpiralDuration: MetricResult;
|
|
55
|
+
flowEfficiency: MetricResult;
|
|
56
|
+
};
|
|
57
|
+
fixChains: FixChain[];
|
|
58
|
+
patterns: PatternSummary;
|
|
59
|
+
overall: OverallRating;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface CliOptions {
|
|
63
|
+
since?: string;
|
|
64
|
+
until?: string;
|
|
65
|
+
format: OutputFormat;
|
|
66
|
+
repo: string;
|
|
67
|
+
verbose: boolean;
|
|
68
|
+
}
|