@boshu2/vibe-check 0.1.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 (143) hide show
  1. package/.dockerignore +46 -0
  2. package/.gitattributes +3 -0
  3. package/.pre-commit-hooks.yaml +11 -0
  4. package/AGENTS.md +40 -0
  5. package/CHANGELOG.md +322 -0
  6. package/CLAUDE.md +342 -0
  7. package/CONTRIBUTING.md +227 -0
  8. package/Dockerfile +26 -0
  9. package/LICENSE +201 -0
  10. package/Makefile +213 -0
  11. package/README.md +165 -0
  12. package/SECURITY.md +182 -0
  13. package/action.yml +270 -0
  14. package/assets/logo-dark.svg +47 -0
  15. package/assets/logo.svg +47 -0
  16. package/bin/vc.js +2 -0
  17. package/bin/vibe-check.js +2 -0
  18. package/claude-progress.json +312 -0
  19. package/claude-progress.txt +572 -0
  20. package/dist/cli.d.ts +3 -0
  21. package/dist/cli.d.ts.map +1 -0
  22. package/dist/cli.js +70 -0
  23. package/dist/cli.js.map +1 -0
  24. package/dist/commands/analyze-helpers.d.ts +43 -0
  25. package/dist/commands/analyze-helpers.d.ts.map +1 -0
  26. package/dist/commands/analyze-helpers.js +124 -0
  27. package/dist/commands/analyze-helpers.js.map +1 -0
  28. package/dist/commands/analyze.d.ts +21 -0
  29. package/dist/commands/analyze.d.ts.map +1 -0
  30. package/dist/commands/analyze.js +114 -0
  31. package/dist/commands/analyze.js.map +1 -0
  32. package/dist/commands/index.d.ts +2 -0
  33. package/dist/commands/index.d.ts.map +1 -0
  34. package/dist/commands/index.js +2 -0
  35. package/dist/commands/index.js.map +1 -0
  36. package/dist/errors.d.ts +100 -0
  37. package/dist/errors.d.ts.map +1 -0
  38. package/dist/errors.js +208 -0
  39. package/dist/errors.js.map +1 -0
  40. package/dist/git.d.ts +39 -0
  41. package/dist/git.d.ts.map +1 -0
  42. package/dist/git.js +206 -0
  43. package/dist/git.js.map +1 -0
  44. package/dist/inner-loop/context-amnesia.d.ts +20 -0
  45. package/dist/inner-loop/context-amnesia.d.ts.map +1 -0
  46. package/dist/inner-loop/context-amnesia.js +246 -0
  47. package/dist/inner-loop/context-amnesia.js.map +1 -0
  48. package/dist/inner-loop/index.d.ts +39 -0
  49. package/dist/inner-loop/index.d.ts.map +1 -0
  50. package/dist/inner-loop/index.js +181 -0
  51. package/dist/inner-loop/index.js.map +1 -0
  52. package/dist/inner-loop/instruction-drift.d.ts +36 -0
  53. package/dist/inner-loop/instruction-drift.d.ts.map +1 -0
  54. package/dist/inner-loop/instruction-drift.js +270 -0
  55. package/dist/inner-loop/instruction-drift.js.map +1 -0
  56. package/dist/inner-loop/logging-only.d.ts +64 -0
  57. package/dist/inner-loop/logging-only.d.ts.map +1 -0
  58. package/dist/inner-loop/logging-only.js +292 -0
  59. package/dist/inner-loop/logging-only.js.map +1 -0
  60. package/dist/inner-loop/tests-passing-lie.d.ts +34 -0
  61. package/dist/inner-loop/tests-passing-lie.d.ts.map +1 -0
  62. package/dist/inner-loop/tests-passing-lie.js +213 -0
  63. package/dist/inner-loop/tests-passing-lie.js.map +1 -0
  64. package/dist/inner-loop/types.d.ts +125 -0
  65. package/dist/inner-loop/types.d.ts.map +1 -0
  66. package/dist/inner-loop/types.js +27 -0
  67. package/dist/inner-loop/types.js.map +1 -0
  68. package/dist/internal/context/index.d.ts +74 -0
  69. package/dist/internal/context/index.d.ts.map +1 -0
  70. package/dist/internal/context/index.js +151 -0
  71. package/dist/internal/context/index.js.map +1 -0
  72. package/dist/internal/context/types.d.ts +75 -0
  73. package/dist/internal/context/types.d.ts.map +1 -0
  74. package/dist/internal/context/types.js +8 -0
  75. package/dist/internal/context/types.js.map +1 -0
  76. package/dist/internal/output/contract.d.ts +81 -0
  77. package/dist/internal/output/contract.d.ts.map +1 -0
  78. package/dist/internal/output/contract.js +112 -0
  79. package/dist/internal/output/contract.js.map +1 -0
  80. package/dist/internal/output/index.d.ts +7 -0
  81. package/dist/internal/output/index.d.ts.map +1 -0
  82. package/dist/internal/output/index.js +7 -0
  83. package/dist/internal/output/index.js.map +1 -0
  84. package/dist/metrics/flow.d.ts +20 -0
  85. package/dist/metrics/flow.d.ts.map +1 -0
  86. package/dist/metrics/flow.js +85 -0
  87. package/dist/metrics/flow.js.map +1 -0
  88. package/dist/metrics/index.d.ts +4 -0
  89. package/dist/metrics/index.d.ts.map +1 -0
  90. package/dist/metrics/index.js +161 -0
  91. package/dist/metrics/index.js.map +1 -0
  92. package/dist/metrics/rework.d.ts +12 -0
  93. package/dist/metrics/rework.d.ts.map +1 -0
  94. package/dist/metrics/rework.js +51 -0
  95. package/dist/metrics/rework.js.map +1 -0
  96. package/dist/metrics/spirals.d.ts +17 -0
  97. package/dist/metrics/spirals.d.ts.map +1 -0
  98. package/dist/metrics/spirals.js +157 -0
  99. package/dist/metrics/spirals.js.map +1 -0
  100. package/dist/metrics/trust.d.ts +12 -0
  101. package/dist/metrics/trust.d.ts.map +1 -0
  102. package/dist/metrics/trust.js +175 -0
  103. package/dist/metrics/trust.js.map +1 -0
  104. package/dist/metrics/velocity.d.ts +25 -0
  105. package/dist/metrics/velocity.d.ts.map +1 -0
  106. package/dist/metrics/velocity.js +120 -0
  107. package/dist/metrics/velocity.js.map +1 -0
  108. package/dist/output/index.d.ts +10 -0
  109. package/dist/output/index.d.ts.map +1 -0
  110. package/dist/output/index.js +20 -0
  111. package/dist/output/index.js.map +1 -0
  112. package/dist/output/json.d.ts +3 -0
  113. package/dist/output/json.d.ts.map +1 -0
  114. package/dist/output/json.js +48 -0
  115. package/dist/output/json.js.map +1 -0
  116. package/dist/output/markdown.d.ts +3 -0
  117. package/dist/output/markdown.d.ts.map +1 -0
  118. package/dist/output/markdown.js +84 -0
  119. package/dist/output/markdown.js.map +1 -0
  120. package/dist/output/terminal.d.ts +10 -0
  121. package/dist/output/terminal.d.ts.map +1 -0
  122. package/dist/output/terminal.js +153 -0
  123. package/dist/output/terminal.js.map +1 -0
  124. package/dist/types.d.ts +75 -0
  125. package/dist/types.d.ts.map +1 -0
  126. package/dist/types.js +5 -0
  127. package/dist/types.js.map +1 -0
  128. package/docs/ARCHITECTURE.md +450 -0
  129. package/docs/DEPLOYMENT.md +394 -0
  130. package/docs/METRICS-EXPLAINED.md +394 -0
  131. package/docs/REFERENCE.md +230 -0
  132. package/docs/images/dashboard.png +0 -0
  133. package/drivers/README.md +327 -0
  134. package/drivers/go.sh +131 -0
  135. package/drivers/java.sh +137 -0
  136. package/drivers/javascript.sh +134 -0
  137. package/drivers/php.sh +132 -0
  138. package/drivers/python.sh +90 -0
  139. package/drivers/rust.sh +132 -0
  140. package/feature-list.json +273 -0
  141. package/hooks/pre-push +107 -0
  142. package/package.json +47 -0
  143. package/vitest.config.ts +25 -0
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Inner Loop Failure Pattern Types
3
+ *
4
+ * These detect the 4 "Inner Loop Disasters" from vibe coding:
5
+ * 1. "Tests Passing" Lie - AI claims success but code doesn't work
6
+ * 2. Context Amnesia - Forgets instructions, re-does work
7
+ * 3. Instruction Drift - "Improves" things not asked for
8
+ * 4. Debug Loop Spiral - Adds logging instead of fixing
9
+ */
10
+ export interface TestsPassingLieResult {
11
+ detected: boolean;
12
+ lies: TestsPassingLie[];
13
+ totalLies: number;
14
+ message: string;
15
+ }
16
+ export interface TestsPassingLie {
17
+ commitHash: string;
18
+ commitMessage: string;
19
+ timestamp: Date;
20
+ claimedSuccess: boolean;
21
+ /**
22
+ * Actual verification result:
23
+ * - 'build_failed': Build command failed
24
+ * - 'tests_failed': Test command failed
25
+ * - 'inferred': Detected from commit patterns (no actual verification)
26
+ * - 'unknown': Verification attempted but result unclear
27
+ */
28
+ actualResult: 'build_failed' | 'tests_failed' | 'inferred' | 'unknown';
29
+ verificationMethod: 'npm_test' | 'npm_build' | 'make_test' | 'inferred';
30
+ }
31
+ export interface ContextAmnesiaResult {
32
+ detected: boolean;
33
+ incidents: ContextAmnesiaIncident[];
34
+ totalIncidents: number;
35
+ totalTimeWasted: number;
36
+ message: string;
37
+ }
38
+ export interface ContextAmnesiaIncident {
39
+ type: 'revert' | 'reimplementation' | 'forgotten_change';
40
+ originalCommit: {
41
+ hash: string;
42
+ message: string;
43
+ timestamp: Date;
44
+ };
45
+ repeatCommit: {
46
+ hash: string;
47
+ message: string;
48
+ timestamp: Date;
49
+ };
50
+ scope: string | null;
51
+ filesAffected: string[];
52
+ gapMinutes: number;
53
+ description: string;
54
+ }
55
+ export interface InstructionDriftResult {
56
+ detected: boolean;
57
+ drifts: InstructionDrift[];
58
+ totalDriftCommits: number;
59
+ totalUnauthorizedFiles: number;
60
+ message: string;
61
+ }
62
+ export interface InstructionDrift {
63
+ commitHash: string;
64
+ commitMessage: string;
65
+ timestamp: Date;
66
+ driftType: 'scope_creep' | 'unrequested_refactor' | 'unrequested_improvement' | 'style_change';
67
+ unauthorizedFiles: string[];
68
+ authorizedScope: string[];
69
+ description: string;
70
+ }
71
+ export interface SessionScope {
72
+ intendedFiles: string[];
73
+ intendedDirs: string[];
74
+ taskDescription?: string;
75
+ startTime: Date;
76
+ }
77
+ export interface LoggingOnlyResult {
78
+ detected: boolean;
79
+ loggingCommits: LoggingOnlyCommit[];
80
+ consecutiveLoggingCount: number;
81
+ totalLoggingCommits: number;
82
+ message: string;
83
+ }
84
+ export interface LoggingOnlyCommit {
85
+ hash: string;
86
+ message: string;
87
+ timestamp: Date;
88
+ loggingStatements: number;
89
+ actualFixes: number;
90
+ isLoggingOnly: boolean;
91
+ loggingPatterns: string[];
92
+ /**
93
+ * How this commit was analyzed:
94
+ * - 'inferred': Lightweight mode - loggingStatements/actualFixes are estimates from message patterns
95
+ * - 'diff_analysis': Full mode - accurate counts from git diff inspection
96
+ */
97
+ detectionMode?: 'inferred' | 'diff_analysis';
98
+ }
99
+ export interface InnerLoopAnalysis {
100
+ testsPassingLie: TestsPassingLieResult;
101
+ contextAmnesia: ContextAmnesiaResult;
102
+ instructionDrift: InstructionDriftResult;
103
+ loggingOnly: LoggingOnlyResult;
104
+ summary: {
105
+ totalIssuesDetected: number;
106
+ criticalIssues: number;
107
+ warningIssues: number;
108
+ overallHealth: 'healthy' | 'warning' | 'critical';
109
+ };
110
+ recommendations: string[];
111
+ }
112
+ export interface InnerLoopConfig {
113
+ runTestsAfterCommit: boolean;
114
+ testCommand?: string;
115
+ buildCommand?: string;
116
+ amnesiaWindowMinutes: number;
117
+ similarityThreshold: number;
118
+ sessionScope?: SessionScope;
119
+ allowedDriftFiles: string[];
120
+ workingSetCommitCount: number;
121
+ maxConsecutiveLoggingCommits: number;
122
+ loggingPatterns: RegExp[];
123
+ }
124
+ export declare const DEFAULT_INNER_LOOP_CONFIG: InnerLoopConfig;
125
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/inner-loop/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,IAAI,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;IACH,YAAY,EAAE,cAAc,GAAG,cAAc,GAAG,UAAU,GAAG,SAAS,CAAC;IACvE,kBAAkB,EAAE,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,UAAU,CAAC;CACzE;AAMD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,sBAAsB,EAAE,CAAC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EA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loop Failure Pattern Types
3
+ *
4
+ * These detect the 4 "Inner Loop Disasters" from vibe coding:
5
+ * 1. "Tests Passing" Lie - AI claims success but code doesn't work
6
+ * 2. Context Amnesia - Forgets instructions, re-does work
7
+ * 3. Instruction Drift - "Improves" things not asked for
8
+ * 4. Debug Loop Spiral - Adds logging instead of fixing
9
+ */
10
+ export const DEFAULT_INNER_LOOP_CONFIG = {
11
+ runTestsAfterCommit: false,
12
+ amnesiaWindowMinutes: 60,
13
+ similarityThreshold: 0.7,
14
+ allowedDriftFiles: ['package.json', 'package-lock.json', 'tsconfig.json', '.gitignore'],
15
+ workingSetCommitCount: 3, // First 3 commits define working set for drift detection
16
+ maxConsecutiveLoggingCommits: 3,
17
+ loggingPatterns: [
18
+ /console\.(log|error|warn|debug|info)\(/,
19
+ /print\s*\(/,
20
+ /logger\.(log|error|warn|debug|info)\(/,
21
+ /System\.out\.print/,
22
+ /fmt\.Print/,
23
+ /debug!\(/,
24
+ /println!\(/,
25
+ ],
26
+ };
27
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/inner-loop/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAqKH,MAAM,CAAC,MAAM,yBAAyB,GAAoB;IACxD,mBAAmB,EAAE,KAAK;IAC1B,oBAAoB,EAAE,EAAE;IACxB,mBAAmB,EAAE,GAAG;IACxB,iBAAiB,EAAE,CAAC,cAAc,EAAE,mBAAmB,EAAE,eAAe,EAAE,YAAY,CAAC;IACvF,qBAAqB,EAAE,CAAC,EAAE,yDAAyD;IACnF,4BAA4B,EAAE,CAAC;IAC/B,eAAe,EAAE;QACf,wCAAwC;QACxC,YAAY;QACZ,uCAAuC;QACvC,oBAAoB;QACpB,YAAY;QACZ,UAAU;QACV,YAAY;KACb;CACF,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Global CLI Context Module
3
+ *
4
+ * Manages shared state across all vibe-check commands.
5
+ * This is the foundation for global hooks and cross-command coordination.
6
+ *
7
+ * Usage:
8
+ * import { createContext, getContext, setContext } from '@/internal/context';
9
+ *
10
+ * // Create and set initial context
11
+ * const ctx = createContext({ repo: '/path/to/repo', verbose: true });
12
+ * setContext(ctx);
13
+ *
14
+ * // Access context from anywhere
15
+ * const ctx = getContext();
16
+ * console.log(ctx.repo);
17
+ */
18
+ import { CLIContext, CreateContextOptions } from './types.js';
19
+ export * from './types.js';
20
+ /**
21
+ * Create a new CLI context with the given options
22
+ *
23
+ * Applies sensible defaults for any missing options.
24
+ *
25
+ * @param options - Context configuration options
26
+ * @returns Fully initialized CLIContext
27
+ */
28
+ export declare function createContext(options?: CreateContextOptions): CLIContext;
29
+ /**
30
+ * Get the current global context
31
+ *
32
+ * @throws Error if context has not been initialized
33
+ * @returns The global CLIContext
34
+ */
35
+ export declare function getContext(): CLIContext;
36
+ /**
37
+ * Set the global context
38
+ *
39
+ * Used by hooks and the CLI bootstrap to establish global state.
40
+ *
41
+ * @param ctx - The context to set as global
42
+ */
43
+ export declare function setContext(ctx: CLIContext): void;
44
+ /**
45
+ * Check if context has been initialized
46
+ *
47
+ * @returns true if context is available, false otherwise
48
+ */
49
+ export declare function hasContext(): boolean;
50
+ /**
51
+ * Clear the global context
52
+ *
53
+ * Primarily used for testing or resetting state.
54
+ */
55
+ export declare function clearContext(): void;
56
+ /**
57
+ * Debug logging utility
58
+ *
59
+ * Only logs when debug mode is enabled (--debug flag or DEBUG=1 env var).
60
+ * Prefixes all output with [DEBUG] for easy filtering.
61
+ *
62
+ * @param ctx - CLI context (or just check ctx.debug)
63
+ * @param args - Arguments to log (same as console.log)
64
+ */
65
+ export declare function debugLog(ctx: CLIContext, ...args: unknown[]): void;
66
+ /**
67
+ * Debug logging utility that works without context
68
+ *
69
+ * Checks environment variable directly. Use when context is not available.
70
+ *
71
+ * @param args - Arguments to log (same as console.log)
72
+ */
73
+ export declare function debugLogEnv(...args: unknown[]): void;
74
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/context/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAmB,MAAM,YAAY,CAAC;AAG/E,cAAc,YAAY,CAAC;AAwC3B;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,UAAU,CAyB5E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAOvC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAEnC;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAIlE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAIpD"}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Global CLI Context Module
3
+ *
4
+ * Manages shared state across all vibe-check commands.
5
+ * This is the foundation for global hooks and cross-command coordination.
6
+ *
7
+ * Usage:
8
+ * import { createContext, getContext, setContext } from '@/internal/context';
9
+ *
10
+ * // Create and set initial context
11
+ * const ctx = createContext({ repo: '/path/to/repo', verbose: true });
12
+ * setContext(ctx);
13
+ *
14
+ * // Access context from anywhere
15
+ * const ctx = getContext();
16
+ * console.log(ctx.repo);
17
+ */
18
+ import { existsSync } from 'fs';
19
+ import { join } from 'path';
20
+ // Export types
21
+ export * from './types.js';
22
+ /**
23
+ * Default configuration values (minimal)
24
+ */
25
+ const DEFAULT_CONFIG = {
26
+ output: {
27
+ format: 'terminal',
28
+ simple: false,
29
+ verbose: false,
30
+ quiet: false,
31
+ },
32
+ };
33
+ /**
34
+ * Global context singleton
35
+ * Initialized on first createContext() call or explicitly via setContext()
36
+ */
37
+ let globalContext = null;
38
+ /**
39
+ * Check if a directory is a git repository
40
+ */
41
+ function isGitRepository(repoPath) {
42
+ try {
43
+ const gitDir = join(repoPath, '.git');
44
+ return existsSync(gitDir);
45
+ }
46
+ catch {
47
+ return false;
48
+ }
49
+ }
50
+ /**
51
+ * Check if debug mode is enabled via environment variable
52
+ */
53
+ function isDebugEnabled() {
54
+ const debugEnv = process.env.DEBUG;
55
+ return debugEnv === '1' || debugEnv === 'true' || debugEnv === 'vibe-check';
56
+ }
57
+ /**
58
+ * Create a new CLI context with the given options
59
+ *
60
+ * Applies sensible defaults for any missing options.
61
+ *
62
+ * @param options - Context configuration options
63
+ * @returns Fully initialized CLIContext
64
+ */
65
+ export function createContext(options = {}) {
66
+ const repo = options.repo ?? process.cwd();
67
+ const isGitRepo = options.isGitRepo ?? isGitRepository(repo);
68
+ // Use provided config or defaults (no file loading)
69
+ const config = options.config ?? DEFAULT_CONFIG;
70
+ // Apply config defaults to context options (CLI flags override config)
71
+ // Debug mode: CLI flag takes precedence, then env var
72
+ const debug = options.debug ?? isDebugEnabled();
73
+ const context = {
74
+ repo,
75
+ outputMode: options.outputMode ?? (config.output?.format === 'json' ? 'json' : 'terminal'),
76
+ verbose: options.verbose ?? config.output?.verbose ?? false,
77
+ quiet: options.quiet ?? config.output?.quiet ?? false,
78
+ debug,
79
+ timeout: options.timeout,
80
+ maxCommits: options.maxCommits,
81
+ version: options.version ?? '0.0.0', // Will be overridden by CLI
82
+ isGitRepo,
83
+ config,
84
+ };
85
+ return context;
86
+ }
87
+ /**
88
+ * Get the current global context
89
+ *
90
+ * @throws Error if context has not been initialized
91
+ * @returns The global CLIContext
92
+ */
93
+ export function getContext() {
94
+ if (!globalContext) {
95
+ throw new Error('CLI context not initialized. Call createContext() or setContext() first.');
96
+ }
97
+ return globalContext;
98
+ }
99
+ /**
100
+ * Set the global context
101
+ *
102
+ * Used by hooks and the CLI bootstrap to establish global state.
103
+ *
104
+ * @param ctx - The context to set as global
105
+ */
106
+ export function setContext(ctx) {
107
+ globalContext = ctx;
108
+ }
109
+ /**
110
+ * Check if context has been initialized
111
+ *
112
+ * @returns true if context is available, false otherwise
113
+ */
114
+ export function hasContext() {
115
+ return globalContext !== null;
116
+ }
117
+ /**
118
+ * Clear the global context
119
+ *
120
+ * Primarily used for testing or resetting state.
121
+ */
122
+ export function clearContext() {
123
+ globalContext = null;
124
+ }
125
+ /**
126
+ * Debug logging utility
127
+ *
128
+ * Only logs when debug mode is enabled (--debug flag or DEBUG=1 env var).
129
+ * Prefixes all output with [DEBUG] for easy filtering.
130
+ *
131
+ * @param ctx - CLI context (or just check ctx.debug)
132
+ * @param args - Arguments to log (same as console.log)
133
+ */
134
+ export function debugLog(ctx, ...args) {
135
+ if (ctx.debug) {
136
+ console.log('[DEBUG]', ...args);
137
+ }
138
+ }
139
+ /**
140
+ * Debug logging utility that works without context
141
+ *
142
+ * Checks environment variable directly. Use when context is not available.
143
+ *
144
+ * @param args - Arguments to log (same as console.log)
145
+ */
146
+ export function debugLogEnv(...args) {
147
+ if (isDebugEnabled()) {
148
+ console.log('[DEBUG]', ...args);
149
+ }
150
+ }
151
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internal/context/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,eAAe;AACf,cAAc,YAAY,CAAC;AAE3B;;GAEG;AACH,MAAM,cAAc,GAA8B;IAChD,MAAM,EAAE;QACN,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,K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AE,KAAK,IAAI,KAAK;QACrD,KAAK;QACL,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,OAAO,EAAE,4BAA4B;QACjE,SAAS;QACT,MAAM;KACP,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU;IACxB,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAC;IACJ,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,GAAe;IACxC,aAAa,GAAG,GAAG,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,aAAa,KAAK,IAAI,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,aAAa,GAAG,IAAI,CAAC;AACvB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAe,EAAE,GAAG,IAAe;IAC1D,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,GAAG,IAAe;IAC5C,IAAI,cAAc,EAAE,EAAE,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Global CLI Context Types
3
+ *
4
+ * This module defines the shared context available across all commands.
5
+ * The context is initialized at CLI startup and can be accessed by hooks and commands.
6
+ */
7
+ /**
8
+ * Output configuration
9
+ */
10
+ export interface OutputConfig {
11
+ /** Default output format */
12
+ format?: 'terminal' | 'json' | 'markdown';
13
+ /** Use simple output by default */
14
+ simple?: boolean;
15
+ /** Enable verbose output by default */
16
+ verbose?: boolean;
17
+ /** Suppress non-essential output */
18
+ quiet?: boolean;
19
+ }
20
+ /**
21
+ * Minimal configuration for CLI context
22
+ */
23
+ export interface VibeCheckConfig {
24
+ /** Output preferences */
25
+ output?: OutputConfig;
26
+ }
27
+ /**
28
+ * Main CLI context interface
29
+ *
30
+ * Contains global state and configuration that persists across command execution:
31
+ * - Repository information
32
+ * - Output formatting preferences
33
+ * - Verbosity settings
34
+ * - CLI version
35
+ */
36
+ export interface CLIContext {
37
+ /** Repository path (absolute) */
38
+ repo: string;
39
+ /** Output format mode */
40
+ outputMode: 'terminal' | 'json';
41
+ /** Enable verbose logging */
42
+ verbose: boolean;
43
+ /** Suppress non-essential output */
44
+ quiet: boolean;
45
+ /** Enable debug logging (--debug flag or DEBUG=1 env var) */
46
+ debug: boolean;
47
+ /** Timeout for git operations in seconds */
48
+ timeout?: number;
49
+ /** Maximum number of commits to analyze */
50
+ maxCommits?: number;
51
+ /** CLI version */
52
+ version: string;
53
+ /** Whether the current directory is a git repository */
54
+ isGitRepo: boolean;
55
+ /** Loaded configuration (minimal) */
56
+ config: Required<VibeCheckConfig>;
57
+ }
58
+ /**
59
+ * Options for creating a new context
60
+ *
61
+ * All fields are optional - defaults will be applied.
62
+ */
63
+ export interface CreateContextOptions {
64
+ repo?: string;
65
+ outputMode?: 'terminal' | 'json';
66
+ verbose?: boolean;
67
+ quiet?: boolean;
68
+ debug?: boolean;
69
+ timeout?: number;
70
+ maxCommits?: number;
71
+ version?: string;
72
+ isGitRepo?: boolean;
73
+ config?: Required<VibeCheckConfig>;
74
+ }
75
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/internal/context/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AAC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AAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;CACpC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Global CLI Context Types
3
+ *
4
+ * This module defines the shared context available across all commands.
5
+ * The context is initialized at CLI startup and can be accessed by hooks and commands.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/internal/context/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Standardized Output Contract
3
+ *
4
+ * All commands should use this format when --json is set.
5
+ * This provides consistent structure for agent consumption:
6
+ * - success: boolean indicating command success
7
+ * - data: the actual command output (type varies by command)
8
+ * - metadata: command context (name, timestamp, version)
9
+ * - error: optional error message if success is false
10
+ *
11
+ * Usage:
12
+ * import { wrapOutput, outputJson } from '@/internal/output/contract';
13
+ *
14
+ * // In command:
15
+ * const result = { spiraling: false, ... };
16
+ * outputJson(wrapOutput('spiral', result));
17
+ */
18
+ /**
19
+ * Standard metadata included in all outputs
20
+ */
21
+ export interface OutputMetadata {
22
+ command: string;
23
+ timestamp: string;
24
+ version: string;
25
+ repo?: string;
26
+ }
27
+ /**
28
+ * Standard output contract for all commands
29
+ */
30
+ export interface CommandOutput<T> {
31
+ success: boolean;
32
+ data: T;
33
+ metadata: OutputMetadata;
34
+ error?: string;
35
+ }
36
+ /**
37
+ * Wrap command output in the standard contract format
38
+ *
39
+ * @param command - The command name (e.g., 'spiral', 'diagnose')
40
+ * @param data - The command's output data
41
+ * @param error - Optional error message (sets success to false)
42
+ * @returns Wrapped output in standard format
43
+ */
44
+ export declare function wrapOutput<T>(command: string, data: T, error?: string): CommandOutput<T>;
45
+ /**
46
+ * Create an error output in standard format
47
+ *
48
+ * @param command - The command name
49
+ * @param error - The error message
50
+ * @param partialData - Optional partial data to include
51
+ * @returns Error output in standard format
52
+ */
53
+ export declare function wrapError<T>(command: string, error: string, partialData?: Partial<T>): CommandOutput<Partial<T> | null>;
54
+ /**
55
+ * Output JSON to stdout in standard format
56
+ *
57
+ * @param output - The wrapped command output
58
+ * @param pretty - Whether to pretty-print (default: true)
59
+ */
60
+ export declare function outputJson<T>(output: CommandOutput<T>, pretty?: boolean): void;
61
+ /**
62
+ * Check if we should use standard contract output
63
+ *
64
+ * Returns true if:
65
+ * - Global --json flag is set
66
+ * - Context is initialized with json output mode
67
+ */
68
+ export declare function shouldUseContract(): boolean;
69
+ /**
70
+ * Higher-order function to wrap command output in contract
71
+ *
72
+ * Usage:
73
+ * const result = await runSpiral(options);
74
+ * withContract('spiral', result); // Outputs wrapped if --json
75
+ *
76
+ * @param command - The command name
77
+ * @param data - The command's output data
78
+ * @param error - Optional error message
79
+ */
80
+ export declare function withContract<T>(command: string, data: T, error?: string): void;
81
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../src/internal/output/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC;IACR,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,CAAC,EACP,KAAK,CAAC,EAAE,MAAM,GACb,aAAa,CAAC,CAAC,CAAC,CAyBlB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GACvB,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAElC;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,MAAM,UAAO,GAAG,IAAI,CAM3E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAU3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,CAAC,EACP,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAIN"}