@litmers/cursorflow-orchestrator 0.1.40 → 0.2.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.
Files changed (207) hide show
  1. package/CHANGELOG.md +0 -2
  2. package/README.md +7 -3
  3. package/commands/cursorflow-init.md +0 -4
  4. package/dist/cli/logs.js +108 -9
  5. package/dist/cli/logs.js.map +1 -1
  6. package/dist/cli/models.js +20 -3
  7. package/dist/cli/models.js.map +1 -1
  8. package/dist/cli/monitor.d.ts +7 -10
  9. package/dist/cli/monitor.js +1088 -1240
  10. package/dist/cli/monitor.js.map +1 -1
  11. package/dist/cli/resume.js +21 -1
  12. package/dist/cli/resume.js.map +1 -1
  13. package/dist/cli/run.js +28 -9
  14. package/dist/cli/run.js.map +1 -1
  15. package/dist/cli/signal.d.ts +6 -1
  16. package/dist/cli/signal.js +94 -12
  17. package/dist/cli/signal.js.map +1 -1
  18. package/dist/cli/tasks.js +3 -46
  19. package/dist/cli/tasks.js.map +1 -1
  20. package/dist/core/agent-supervisor.d.ts +23 -0
  21. package/dist/core/agent-supervisor.js +42 -0
  22. package/dist/core/agent-supervisor.js.map +1 -0
  23. package/dist/core/auto-recovery.d.ts +2 -1
  24. package/dist/core/auto-recovery.js +6 -1
  25. package/dist/core/auto-recovery.js.map +1 -1
  26. package/dist/core/failure-policy.d.ts +0 -1
  27. package/dist/core/failure-policy.js +0 -1
  28. package/dist/core/failure-policy.js.map +1 -1
  29. package/dist/core/git-lifecycle-manager.d.ts +284 -0
  30. package/dist/core/git-lifecycle-manager.js +778 -0
  31. package/dist/core/git-lifecycle-manager.js.map +1 -0
  32. package/dist/core/git-pipeline-coordinator.d.ts +21 -0
  33. package/dist/core/git-pipeline-coordinator.js +205 -0
  34. package/dist/core/git-pipeline-coordinator.js.map +1 -0
  35. package/dist/core/intervention.d.ts +176 -0
  36. package/dist/core/intervention.js +424 -0
  37. package/dist/core/intervention.js.map +1 -0
  38. package/dist/core/lane-state-machine.d.ts +423 -0
  39. package/dist/core/lane-state-machine.js +890 -0
  40. package/dist/core/lane-state-machine.js.map +1 -0
  41. package/dist/core/orchestrator.d.ts +4 -1
  42. package/dist/core/orchestrator.js +29 -62
  43. package/dist/core/orchestrator.js.map +1 -1
  44. package/dist/core/runner/agent.d.ts +7 -1
  45. package/dist/core/runner/agent.js +45 -30
  46. package/dist/core/runner/agent.js.map +1 -1
  47. package/dist/core/runner/pipeline.js +283 -123
  48. package/dist/core/runner/pipeline.js.map +1 -1
  49. package/dist/core/runner/task.d.ts +4 -5
  50. package/dist/core/runner/task.js +6 -80
  51. package/dist/core/runner/task.js.map +1 -1
  52. package/dist/core/runner.js +8 -2
  53. package/dist/core/runner.js.map +1 -1
  54. package/dist/core/stall-detection.d.ts +11 -4
  55. package/dist/core/stall-detection.js +62 -27
  56. package/dist/core/stall-detection.js.map +1 -1
  57. package/dist/hooks/contexts/index.d.ts +104 -0
  58. package/dist/hooks/contexts/index.js +134 -0
  59. package/dist/hooks/contexts/index.js.map +1 -0
  60. package/dist/hooks/data-accessor.d.ts +86 -0
  61. package/dist/hooks/data-accessor.js +410 -0
  62. package/dist/hooks/data-accessor.js.map +1 -0
  63. package/dist/hooks/flow-controller.d.ts +136 -0
  64. package/dist/hooks/flow-controller.js +351 -0
  65. package/dist/hooks/flow-controller.js.map +1 -0
  66. package/dist/hooks/index.d.ts +68 -0
  67. package/dist/hooks/index.js +105 -0
  68. package/dist/hooks/index.js.map +1 -0
  69. package/dist/hooks/manager.d.ts +129 -0
  70. package/dist/hooks/manager.js +389 -0
  71. package/dist/hooks/manager.js.map +1 -0
  72. package/dist/hooks/types.d.ts +463 -0
  73. package/dist/hooks/types.js +45 -0
  74. package/dist/hooks/types.js.map +1 -0
  75. package/dist/services/logging/buffer.d.ts +2 -2
  76. package/dist/services/logging/buffer.js +95 -42
  77. package/dist/services/logging/buffer.js.map +1 -1
  78. package/dist/services/logging/console.js +6 -1
  79. package/dist/services/logging/console.js.map +1 -1
  80. package/dist/services/logging/formatter.d.ts +9 -4
  81. package/dist/services/logging/formatter.js +64 -18
  82. package/dist/services/logging/formatter.js.map +1 -1
  83. package/dist/services/logging/index.d.ts +0 -1
  84. package/dist/services/logging/index.js +0 -1
  85. package/dist/services/logging/index.js.map +1 -1
  86. package/dist/services/logging/paths.d.ts +8 -0
  87. package/dist/services/logging/paths.js +48 -0
  88. package/dist/services/logging/paths.js.map +1 -0
  89. package/dist/services/logging/raw-log.d.ts +6 -0
  90. package/dist/services/logging/raw-log.js +37 -0
  91. package/dist/services/logging/raw-log.js.map +1 -0
  92. package/dist/services/process/index.js +1 -1
  93. package/dist/services/process/index.js.map +1 -1
  94. package/dist/types/agent.d.ts +15 -0
  95. package/dist/types/config.d.ts +22 -1
  96. package/dist/types/event-categories.d.ts +601 -0
  97. package/dist/types/event-categories.js +233 -0
  98. package/dist/types/event-categories.js.map +1 -0
  99. package/dist/types/events.d.ts +0 -20
  100. package/dist/types/flow.d.ts +10 -6
  101. package/dist/types/index.d.ts +1 -1
  102. package/dist/types/index.js +17 -3
  103. package/dist/types/index.js.map +1 -1
  104. package/dist/types/lane.d.ts +1 -1
  105. package/dist/types/logging.d.ts +1 -1
  106. package/dist/types/task.d.ts +12 -1
  107. package/dist/ui/log-viewer.d.ts +3 -0
  108. package/dist/ui/log-viewer.js +3 -0
  109. package/dist/ui/log-viewer.js.map +1 -1
  110. package/dist/utils/config.js +10 -1
  111. package/dist/utils/config.js.map +1 -1
  112. package/dist/utils/cursor-agent.d.ts +11 -1
  113. package/dist/utils/cursor-agent.js +63 -16
  114. package/dist/utils/cursor-agent.js.map +1 -1
  115. package/dist/utils/enhanced-logger.d.ts +5 -1
  116. package/dist/utils/enhanced-logger.js +98 -19
  117. package/dist/utils/enhanced-logger.js.map +1 -1
  118. package/dist/utils/event-registry.d.ts +222 -0
  119. package/dist/utils/event-registry.js +463 -0
  120. package/dist/utils/event-registry.js.map +1 -0
  121. package/dist/utils/events.d.ts +1 -13
  122. package/dist/utils/events.js.map +1 -1
  123. package/dist/utils/flow.d.ts +10 -0
  124. package/dist/utils/flow.js +75 -0
  125. package/dist/utils/flow.js.map +1 -1
  126. package/dist/utils/log-constants.d.ts +1 -0
  127. package/dist/utils/log-constants.js +2 -1
  128. package/dist/utils/log-constants.js.map +1 -1
  129. package/dist/utils/log-formatter.d.ts +2 -1
  130. package/dist/utils/log-formatter.js +10 -10
  131. package/dist/utils/log-formatter.js.map +1 -1
  132. package/dist/utils/logger.d.ts +11 -0
  133. package/dist/utils/logger.js +82 -3
  134. package/dist/utils/logger.js.map +1 -1
  135. package/dist/utils/repro-thinking-logs.js +0 -13
  136. package/dist/utils/repro-thinking-logs.js.map +1 -1
  137. package/dist/utils/run-service.js +1 -1
  138. package/dist/utils/run-service.js.map +1 -1
  139. package/examples/README.md +0 -2
  140. package/examples/demo-project/README.md +1 -2
  141. package/package.json +18 -28
  142. package/scripts/setup-security.sh +0 -1
  143. package/scripts/test-log-parser.ts +171 -0
  144. package/scripts/verify-change.sh +272 -0
  145. package/src/cli/logs.ts +121 -10
  146. package/src/cli/models.ts +20 -3
  147. package/src/cli/monitor.ts +1257 -1342
  148. package/src/cli/resume.ts +27 -1
  149. package/src/cli/run.ts +29 -11
  150. package/src/cli/signal.ts +115 -17
  151. package/src/cli/tasks.ts +2 -59
  152. package/src/core/agent-supervisor.ts +64 -0
  153. package/src/core/auto-recovery.ts +7 -1
  154. package/src/core/failure-policy.ts +0 -1
  155. package/src/core/git-lifecycle-manager.ts +1011 -0
  156. package/src/core/git-pipeline-coordinator.ts +221 -0
  157. package/src/core/intervention.ts +481 -0
  158. package/src/core/lane-state-machine.ts +1097 -0
  159. package/src/core/orchestrator.ts +35 -61
  160. package/src/core/runner/agent.ts +66 -33
  161. package/src/core/runner/pipeline.ts +318 -138
  162. package/src/core/runner/task.ts +12 -97
  163. package/src/core/runner.ts +8 -2
  164. package/src/core/stall-detection.ts +72 -27
  165. package/src/hooks/contexts/index.ts +256 -0
  166. package/src/hooks/data-accessor.ts +488 -0
  167. package/src/hooks/flow-controller.ts +425 -0
  168. package/src/hooks/index.ts +154 -0
  169. package/src/hooks/manager.ts +434 -0
  170. package/src/hooks/types.ts +544 -0
  171. package/src/services/logging/buffer.ts +104 -43
  172. package/src/services/logging/console.ts +7 -1
  173. package/src/services/logging/formatter.ts +74 -18
  174. package/src/services/logging/index.ts +0 -2
  175. package/src/services/logging/paths.ts +14 -0
  176. package/src/services/logging/raw-log.ts +43 -0
  177. package/src/services/process/index.ts +1 -1
  178. package/src/types/agent.ts +15 -0
  179. package/src/types/config.ts +23 -1
  180. package/src/types/event-categories.ts +663 -0
  181. package/src/types/events.ts +0 -25
  182. package/src/types/flow.ts +10 -6
  183. package/src/types/index.ts +50 -4
  184. package/src/types/lane.ts +1 -2
  185. package/src/types/logging.ts +2 -1
  186. package/src/types/task.ts +12 -1
  187. package/src/ui/log-viewer.ts +3 -0
  188. package/src/utils/config.ts +11 -1
  189. package/src/utils/cursor-agent.ts +68 -16
  190. package/src/utils/enhanced-logger.ts +105 -19
  191. package/src/utils/event-registry.ts +595 -0
  192. package/src/utils/events.ts +0 -16
  193. package/src/utils/flow.ts +83 -0
  194. package/src/utils/log-constants.ts +2 -1
  195. package/src/utils/log-formatter.ts +10 -11
  196. package/src/utils/logger.ts +49 -3
  197. package/src/utils/repro-thinking-logs.ts +0 -15
  198. package/src/utils/run-service.ts +1 -1
  199. package/dist/services/logging/file-writer.d.ts +0 -71
  200. package/dist/services/logging/file-writer.js +0 -516
  201. package/dist/services/logging/file-writer.js.map +0 -1
  202. package/dist/types/review.d.ts +0 -17
  203. package/dist/types/review.js +0 -6
  204. package/dist/types/review.js.map +0 -1
  205. package/scripts/ai-security-check.js +0 -233
  206. package/src/services/logging/file-writer.ts +0 -526
  207. package/src/types/review.ts +0 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litmers/cursorflow-orchestrator",
3
- "version": "0.1.40",
3
+ "version": "0.2.2",
4
4
  "description": "Git worktree-based parallel AI agent orchestration system for Cursor",
5
5
  "main": "dist/cli/index.js",
6
6
  "bin": {
@@ -14,7 +14,6 @@
14
14
  "orchestration",
15
15
  "git-worktree",
16
16
  "parallel-execution",
17
- "code-review",
18
17
  "automation",
19
18
  "devops",
20
19
  "ci-cd"
@@ -55,45 +54,36 @@
55
54
  "scripts": {
56
55
  "build": "tsc",
57
56
  "watch": "tsc -w",
58
- "test": "jest",
59
- "test:unit": "jest --testPathIgnorePatterns=tests/e2e",
57
+ "test": "jest --selectProjects unit",
58
+ "test:unit": "jest --selectProjects unit",
59
+ "test:contract": "jest --selectProjects contract",
60
+ "test:integration": "jest --selectProjects integration",
61
+ "test:e2e": "jest --selectProjects e2e",
62
+ "test:e2e:real": "jest tests/e2e/real-e2e.test.ts --runInBand --testTimeout=300000",
63
+ "test:smoke": "jest tests/smoke --runInBand --testTimeout=120000",
64
+ "test:all": "jest",
65
+ "test:verify": "./scripts/verify-change.sh",
66
+ "test:quick": "pnpm run test:verify:quick",
67
+ "test:verify:quick": "./scripts/verify-change.sh --quick",
68
+ "test:verify:full": "./scripts/verify-change.sh --full",
69
+ "test:pipeline": "pnpm test:unit && pnpm test:contract && pnpm test:integration && pnpm test:smoke",
70
+ "test:ci": "pnpm run build && pnpm run test:unit && pnpm run test:contract && pnpm run test:integration && pnpm run test:smoke",
60
71
  "postinstall": "node scripts/postinstall.js",
61
72
  "validate": "pnpm pack",
62
73
  "release": "scripts/release.sh",
63
74
  "release:patch": "scripts/release.sh patch",
64
75
  "release:minor": "scripts/release.sh minor",
65
76
  "release:major": "scripts/release.sh major",
77
+ "prerelease": "pnpm run build && pnpm run test && pnpm run test:smoke && pnpm run security:check",
66
78
  "security:check": "scripts/local-security-gate.sh",
67
79
  "security:audit": "pnpm audit",
68
80
  "security:audit:fix": "pnpm audit --fix",
69
- "security:setup": "scripts/setup-security.sh",
70
- "verify": "scripts/verify-and-fix.sh",
71
- "monitor": "scripts/monitor-lanes.sh",
72
- "monitor:watch": "scripts/monitor-lanes.sh --watch",
73
- "monitor:stream": "scripts/stream-logs.sh",
74
81
  "cf": "node dist/cli/index.js",
75
- "cf:init": "node dist/cli/index.js init",
76
- "cf:setup": "node dist/cli/index.js setup",
77
- "cf:prepare": "node dist/cli/index.js prepare",
82
+ "cf:doctor": "node dist/cli/index.js doctor",
78
83
  "cf:run": "node dist/cli/index.js run",
79
84
  "cf:monitor": "node dist/cli/index.js monitor",
80
85
  "cf:clean": "node dist/cli/index.js clean",
81
- "cf:stop": "node dist/cli/index.js stop",
82
86
  "cf:resume": "node dist/cli/index.js resume",
83
- "cf:doctor": "node dist/cli/index.js doctor",
84
- "cf:signal": "node dist/cli/index.js signal",
85
- "cf:logs": "node dist/cli/index.js logs",
86
- "cf:models": "node dist/cli/index.js models",
87
- "test:all": "tests/scripts/run-all-tests.sh",
88
- "test:quick": "tests/scripts/run-all-tests.sh --quick",
89
- "test:cli": "tests/scripts/run-all-tests.sh --module cli-doctor --module cli-commands",
90
- "test:prepare": "tests/scripts/run-all-tests.sh --module prepare",
91
- "test:validation": "tests/scripts/run-all-tests.sh --module validation",
92
- "test:templates": "tests/scripts/run-all-tests.sh --module templates",
93
- "test:git": "tests/scripts/run-all-tests.sh --module git",
94
- "test:integration": "tests/scripts/run-all-tests.sh --module integration-lifecycle --module integration-logging --module integration-parallel",
95
- "test:lifecycle": "tests/scripts/run-all-tests.sh --module integration-lifecycle --skip-agent",
96
- "test:lifecycle:local": "tests/scripts/run-all-tests.sh --module integration-lifecycle-local",
97
- "prerelease": "npm run build && npm run test && npm run test:quick && npm run security:check"
87
+ "cf:logs": "node dist/cli/index.js logs"
98
88
  }
99
89
  }
@@ -92,7 +92,6 @@ echo "✅ Semgrep Static Analysis (automatic)"
92
92
  echo "✅ Trivy Filesystem Scan (automatic)"
93
93
  echo "✅ CodeQL Analysis (automatic)"
94
94
  echo "⚙️ Snyk Scan (requires SNYK_TOKEN)"
95
- echo "⚙️ AI Security Review (requires OPENAI_API_KEY)"
96
95
 
97
96
  echo -e "\n${BLUE}Test security scan locally:${NC}"
98
97
  echo -e "${GREEN}npm audit${NC}"
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Test script for log parsing using existing LogBufferService
3
+ *
4
+ * Uses the production logging modules to parse and display logs,
5
+ * comparing with actual terminal output.
6
+ *
7
+ * Usage: npx ts-node scripts/test-log-parser.ts
8
+ */
9
+
10
+ import * as fs from 'fs';
11
+ import * as path from 'path';
12
+ import { createLogBuffer } from '../src/services/logging/buffer';
13
+ import { StreamingMessageParser } from '../src/services/logging/parser';
14
+ import { formatMessageForConsole, stripAnsi } from '../src/services/logging/formatter';
15
+ import { ParsedMessage } from '../src/types/logging';
16
+
17
+ const FIXTURES_DIR = path.join(__dirname, '../tests/fixtures/real-agent-logs/sample-run');
18
+
19
+ async function main() {
20
+ console.log('='.repeat(80));
21
+ console.log('📋 Log Parser Test - Using Production Modules');
22
+ console.log('='.repeat(80));
23
+ console.log(`\nFixtures directory: ${FIXTURES_DIR}\n`);
24
+
25
+ // Check if fixtures exist
26
+ if (!fs.existsSync(FIXTURES_DIR)) {
27
+ console.error('❌ Fixtures not found! Run E2E tests first to generate logs.');
28
+ console.error(' npm run test:e2e:real');
29
+ process.exit(1);
30
+ }
31
+
32
+ // ===========================================================================
33
+ // Test 1: LogBufferService (Production streaming service)
34
+ // ===========================================================================
35
+ console.log('━'.repeat(80));
36
+ console.log(' 📦 Test 1: LogBufferService (Production Module)');
37
+ console.log('━'.repeat(80) + '\n');
38
+
39
+ const logBuffer = createLogBuffer(FIXTURES_DIR);
40
+
41
+ // Start streaming to read logs
42
+ logBuffer.startStreaming();
43
+
44
+ // Wait a moment for initial poll
45
+ await new Promise(resolve => setTimeout(resolve, 200));
46
+
47
+ const entries = logBuffer.getEntries({ limit: 1000, fromEnd: false });
48
+ const state = logBuffer.getState();
49
+
50
+ console.log(`📊 LogBufferService Stats:`);
51
+ console.log(` Total entries: ${state.totalEntries}`);
52
+ console.log(` Lanes: ${state.lanes.join(', ') || 'none'}`);
53
+ console.log(` Streaming: ${state.isStreaming}`);
54
+
55
+ logBuffer.stopStreaming();
56
+
57
+ if (entries.length > 0) {
58
+ console.log(`\n📝 First 15 entries (formatted by LogBufferService):`);
59
+ console.log('-'.repeat(60));
60
+ for (const entry of entries.slice(0, 15)) {
61
+ const formatted = logBuffer.formatEntry(entry, { showLane: true, showTimestamp: true });
62
+ console.log(stripAnsi(formatted).substring(0, 100));
63
+ }
64
+ }
65
+
66
+ // ===========================================================================
67
+ // Test 2: StreamingMessageParser (JSONL parsing)
68
+ // ===========================================================================
69
+ console.log('\n' + '━'.repeat(80));
70
+ console.log(' 📦 Test 2: StreamingMessageParser (JSONL Parsing)');
71
+ console.log('━'.repeat(80) + '\n');
72
+
73
+ const rawLogPath = path.join(FIXTURES_DIR, 'lanes/test-lane/terminal-raw.log');
74
+ if (fs.existsSync(rawLogPath)) {
75
+ const rawLog = fs.readFileSync(rawLogPath, 'utf8');
76
+ const lines = rawLog.split('\n');
77
+ const jsonLines = lines.filter(l => l.trim().startsWith('{') && l.trim().endsWith('}'));
78
+
79
+ console.log(`📄 Raw log: ${rawLogPath}`);
80
+ console.log(` Total lines: ${lines.length}`);
81
+ console.log(` JSON lines: ${jsonLines.length}`);
82
+
83
+ // Parse with StreamingMessageParser
84
+ const parsedMessages: ParsedMessage[] = [];
85
+ const parser = new StreamingMessageParser((msg) => {
86
+ parsedMessages.push(msg);
87
+ });
88
+
89
+ for (const line of jsonLines) {
90
+ parser.parseLine(line);
91
+ }
92
+ parser.flush();
93
+
94
+ console.log(` Parsed messages: ${parsedMessages.length}\n`);
95
+
96
+ // Type distribution
97
+ const typeCount: Record<string, number> = {};
98
+ for (const msg of parsedMessages) {
99
+ typeCount[msg.type] = (typeCount[msg.type] || 0) + 1;
100
+ }
101
+
102
+ console.log('Message types:');
103
+ for (const [type, count] of Object.entries(typeCount).sort((a, b) => b[1] - a[1])) {
104
+ console.log(` ${type.padEnd(15)}: ${count}`);
105
+ }
106
+
107
+ // Show formatted messages
108
+ console.log(`\n📝 Formatted output (using formatMessageForConsole):`);
109
+ console.log('-'.repeat(60));
110
+ for (const msg of parsedMessages.slice(0, 15)) {
111
+ const formatted = formatMessageForConsole(msg, {
112
+ includeTimestamp: true,
113
+ laneLabel: '[1-1-test-lan]',
114
+ compact: true,
115
+ showBorders: false,
116
+ });
117
+ console.log(stripAnsi(formatted).substring(0, 100));
118
+ }
119
+ } else {
120
+ console.log('⚠️ Raw log not found at:', rawLogPath);
121
+ }
122
+
123
+ // ===========================================================================
124
+ // Test 3: Compare with actual readable log
125
+ // ===========================================================================
126
+ console.log('\n' + '━'.repeat(80));
127
+ console.log(' 🔍 Test 3: Compare Parser Output with Actual Log');
128
+ console.log('━'.repeat(80) + '\n');
129
+
130
+ const readableLogPath = path.join(FIXTURES_DIR, 'lanes/test-lane/terminal-readable.log');
131
+ if (fs.existsSync(readableLogPath)) {
132
+ const readableLog = fs.readFileSync(readableLogPath, 'utf8');
133
+ const readableLines = readableLog.split('\n');
134
+
135
+ // Find agent message lines
136
+ const agentLines = readableLines.filter(line =>
137
+ line.includes('⚙️ SYS') ||
138
+ line.includes('🧑 USER') ||
139
+ line.includes('🤖 ASST') ||
140
+ line.includes('🔧 TOOL') ||
141
+ line.includes('📄 RESL')
142
+ );
143
+
144
+ console.log(`📄 Readable log: ${readableLogPath}`);
145
+ console.log(` Total lines: ${readableLines.length}`);
146
+ console.log(` Agent message lines: ${agentLines.length}`);
147
+
148
+ console.log(`\n📝 Actual terminal output (first 15 agent messages):`);
149
+ console.log('-'.repeat(60));
150
+ for (const line of agentLines.slice(0, 15)) {
151
+ console.log(stripAnsi(line).substring(0, 100));
152
+ }
153
+ }
154
+
155
+ // ===========================================================================
156
+ // Summary
157
+ // ===========================================================================
158
+ console.log('\n' + '='.repeat(80));
159
+ console.log('✅ Log Parser Test Complete');
160
+ console.log('='.repeat(80));
161
+ console.log('\n📁 Modules used:');
162
+ console.log(' - LogBufferService: src/services/logging/buffer.ts');
163
+ console.log(' - StreamingMessageParser: src/services/logging/parser.ts');
164
+ console.log(' - formatMessageForConsole: src/services/logging/formatter.ts');
165
+ }
166
+
167
+ // Run the tests
168
+ main().catch(err => {
169
+ console.error('Error:', err);
170
+ process.exit(1);
171
+ });
@@ -0,0 +1,272 @@
1
+ #!/bin/bash
2
+ #
3
+ # verify-change.sh - Post-change verification script
4
+ #
5
+ # Runs a series of checks to verify that code changes don't break functionality.
6
+ # Use this after making changes to ensure everything still works.
7
+ #
8
+ # Usage:
9
+ # ./scripts/verify-change.sh # Run all checks
10
+ # ./scripts/verify-change.sh --quick # Skip slow tests
11
+ # ./scripts/verify-change.sh --smoke # Only run smoke tests
12
+ #
13
+
14
+ set -e
15
+
16
+ # Colors for output
17
+ RED='\033[0;31m'
18
+ GREEN='\033[0;32m'
19
+ YELLOW='\033[1;33m'
20
+ BLUE='\033[0;34m'
21
+ NC='\033[0m' # No Color
22
+
23
+ # Script directory
24
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
25
+ ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
26
+
27
+ # Parse arguments
28
+ QUICK_MODE=false
29
+ SMOKE_ONLY=false
30
+ VERBOSE=false
31
+
32
+ while [[ $# -gt 0 ]]; do
33
+ case $1 in
34
+ --quick|-q)
35
+ QUICK_MODE=true
36
+ shift
37
+ ;;
38
+ --smoke|-s)
39
+ SMOKE_ONLY=true
40
+ shift
41
+ ;;
42
+ --verbose|-v)
43
+ VERBOSE=true
44
+ shift
45
+ ;;
46
+ --help|-h)
47
+ echo "Usage: $0 [options]"
48
+ echo ""
49
+ echo "Options:"
50
+ echo " --quick, -q Skip slow tests (integration, e2e)"
51
+ echo " --smoke, -s Only run smoke tests"
52
+ echo " --verbose, -v Show detailed output"
53
+ echo " --help, -h Show this help message"
54
+ exit 0
55
+ ;;
56
+ *)
57
+ echo -e "${RED}Unknown option: $1${NC}"
58
+ exit 1
59
+ ;;
60
+ esac
61
+ done
62
+
63
+ # Logging functions
64
+ log_step() {
65
+ echo -e "\n${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
66
+ echo -e "${BLUE}▶ $1${NC}"
67
+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
68
+ }
69
+
70
+ log_success() {
71
+ echo -e "${GREEN}✓ $1${NC}"
72
+ }
73
+
74
+ log_error() {
75
+ echo -e "${RED}✗ $1${NC}"
76
+ }
77
+
78
+ log_warning() {
79
+ echo -e "${YELLOW}⚠ $1${NC}"
80
+ }
81
+
82
+ # Track results
83
+ RESULTS=()
84
+ FAILED=false
85
+
86
+ run_check() {
87
+ local name="$1"
88
+ local command="$2"
89
+
90
+ if $VERBOSE; then
91
+ echo -e "${YELLOW}Running: $command${NC}"
92
+ fi
93
+
94
+ if eval "$command"; then
95
+ log_success "$name"
96
+ RESULTS+=("✓ $name")
97
+ else
98
+ log_error "$name"
99
+ RESULTS+=("✗ $name")
100
+ FAILED=true
101
+ fi
102
+ }
103
+
104
+ cd "$ROOT_DIR"
105
+
106
+ echo -e "${BLUE}"
107
+ echo "╔═══════════════════════════════════════════════════════════╗"
108
+ echo "║ CursorFlow Change Verification ║"
109
+ echo "╚═══════════════════════════════════════════════════════════╝"
110
+ echo -e "${NC}"
111
+
112
+ # Step 1: TypeScript Compilation
113
+ log_step "Step 1: TypeScript Compilation"
114
+
115
+ BUILD_OUTPUT=$(mktemp)
116
+ if npm run build > "$BUILD_OUTPUT" 2>&1; then
117
+ log_success "TypeScript compilation passed"
118
+ RESULTS+=("✓ TypeScript compilation")
119
+ else
120
+ log_error "TypeScript compilation failed"
121
+ echo "Build output:"
122
+ cat "$BUILD_OUTPUT"
123
+ RESULTS+=("✗ TypeScript compilation")
124
+ FAILED=true
125
+ fi
126
+ rm -f "$BUILD_OUTPUT"
127
+
128
+ # Exit early if build failed
129
+ if $FAILED; then
130
+ log_error "Build failed, skipping further checks"
131
+ exit 1
132
+ fi
133
+
134
+ # Step 2: Lint Check (if available)
135
+ log_step "Step 2: Lint Check"
136
+ if command -v eslint &> /dev/null && [ -f ".eslintrc.js" ] || [ -f ".eslintrc.json" ]; then
137
+ run_check "ESLint" "npx eslint src/ --quiet 2>/dev/null || true"
138
+ else
139
+ log_warning "ESLint not configured, skipping"
140
+ RESULTS+=("⚠ ESLint (skipped)")
141
+ fi
142
+
143
+ # Step 3: Unit Tests (unless smoke-only mode)
144
+ if ! $SMOKE_ONLY; then
145
+ log_step "Step 3: Unit Tests"
146
+ run_check "Unit tests" "npm run test:unit -- --passWithNoTests --silent"
147
+ fi
148
+
149
+ # Step 4: CLI Smoke Tests
150
+ log_step "Step 4: CLI Smoke Tests"
151
+
152
+ # Test 1: Version command
153
+ echo -e "${YELLOW}Testing: cursorflow --version${NC}"
154
+ VERSION_OUTPUT=$(node dist/cli/index.js --version 2>&1 || true)
155
+ if echo "$VERSION_OUTPUT" | grep -qE '[0-9]+\.[0-9]+\.[0-9]+'; then
156
+ log_success "Version command works"
157
+ RESULTS+=("✓ Version command")
158
+ else
159
+ log_error "Version command failed"
160
+ echo "Output: $VERSION_OUTPUT"
161
+ RESULTS+=("✗ Version command")
162
+ FAILED=true
163
+ fi
164
+
165
+ # Test 2: Help command
166
+ echo -e "${YELLOW}Testing: cursorflow --help${NC}"
167
+ HELP_OUTPUT=$(node dist/cli/index.js --help 2>&1 || true)
168
+ if echo "$HELP_OUTPUT" | grep -qiE 'usage|commands|options'; then
169
+ log_success "Help command works"
170
+ RESULTS+=("✓ Help command")
171
+ else
172
+ log_error "Help command failed"
173
+ echo "Output: $HELP_OUTPUT"
174
+ RESULTS+=("✗ Help command")
175
+ FAILED=true
176
+ fi
177
+
178
+ # Test 3: Doctor command (in a temp directory to avoid git issues)
179
+ echo -e "${YELLOW}Testing: cursorflow doctor${NC}"
180
+ TEMP_DIR=$(mktemp -d)
181
+ cd "$TEMP_DIR"
182
+ git init -q 2>/dev/null || true
183
+ git config user.email "test@test.com" 2>/dev/null || true
184
+ git config user.name "Test" 2>/dev/null || true
185
+ touch README.md
186
+ git add . 2>/dev/null || true
187
+ git commit -m "init" -q 2>/dev/null || true
188
+
189
+ DOCTOR_OUTPUT=$(node "$ROOT_DIR/dist/cli/index.js" doctor 2>&1 || true)
190
+ cd "$ROOT_DIR"
191
+ rm -rf "$TEMP_DIR"
192
+
193
+ # Doctor should produce some output (even if checks fail)
194
+ if [ -n "$DOCTOR_OUTPUT" ] && ! echo "$DOCTOR_OUTPUT" | grep -qiE 'undefined is not|cannot read'; then
195
+ log_success "Doctor command works"
196
+ RESULTS+=("✓ Doctor command")
197
+ else
198
+ log_error "Doctor command has runtime errors"
199
+ echo "Output: $DOCTOR_OUTPUT"
200
+ RESULTS+=("✗ Doctor command")
201
+ FAILED=true
202
+ fi
203
+
204
+ # Step 5: Output Format Verification
205
+ log_step "Step 5: Output Format Verification"
206
+
207
+ # Check for common issues in CLI output
208
+ check_output_format() {
209
+ local cmd="$1"
210
+ local name="$2"
211
+
212
+ OUTPUT=$(node dist/cli/index.js $cmd 2>&1 || true)
213
+
214
+ # Check for runtime errors
215
+ if echo "$OUTPUT" | grep -qiE 'undefined is not|cannot read propert|null is not'; then
216
+ log_error "$name has JavaScript runtime errors"
217
+ return 1
218
+ fi
219
+
220
+ # Check for unhandled stack traces (but allow intentional error messages)
221
+ if echo "$OUTPUT" | grep -qE 'at\s+Object\.<anonymous>|at\s+Module\._compile'; then
222
+ log_warning "$name may have unhandled errors (stack trace detected)"
223
+ fi
224
+
225
+ return 0
226
+ }
227
+
228
+ run_check "Version output format" "check_output_format '--version' 'Version'"
229
+ run_check "Help output format" "check_output_format '--help' 'Help'"
230
+
231
+ # Step 6: Integration Tests (unless quick or smoke-only mode)
232
+ if ! $QUICK_MODE && ! $SMOKE_ONLY; then
233
+ log_step "Step 6: Integration Tests"
234
+ run_check "Integration tests" "npm run test:integration -- --passWithNoTests 2>/dev/null || true"
235
+ fi
236
+
237
+ # Step 7: Jest Smoke Tests
238
+ log_step "Step 7: Jest Smoke Tests"
239
+ if [ -f "tests/smoke/smoke.test.ts" ]; then
240
+ run_check "Jest smoke tests" "npx jest tests/smoke --passWithNoTests --runInBand 2>/dev/null"
241
+ else
242
+ log_warning "Smoke test file not found"
243
+ RESULTS+=("⚠ Jest smoke tests (skipped)")
244
+ fi
245
+
246
+ # Summary
247
+ echo -e "\n${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
248
+ echo -e "${BLUE} VERIFICATION SUMMARY ${NC}"
249
+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
250
+
251
+ for result in "${RESULTS[@]}"; do
252
+ if [[ "$result" == ✓* ]]; then
253
+ echo -e "${GREEN}$result${NC}"
254
+ elif [[ "$result" == ✗* ]]; then
255
+ echo -e "${RED}$result${NC}"
256
+ else
257
+ echo -e "${YELLOW}$result${NC}"
258
+ fi
259
+ done
260
+
261
+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
262
+
263
+ if $FAILED; then
264
+ echo -e "\n${RED}❌ Verification FAILED${NC}"
265
+ echo -e "${RED}Some checks did not pass. Please fix the issues before committing.${NC}"
266
+ exit 1
267
+ else
268
+ echo -e "\n${GREEN}✅ All verifications PASSED${NC}"
269
+ echo -e "${GREEN}Your changes look good!${NC}"
270
+ exit 0
271
+ fi
272
+