@litmers/cursorflow-orchestrator 0.1.12 → 0.1.14

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 (71) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +83 -2
  3. package/commands/cursorflow-clean.md +20 -6
  4. package/commands/cursorflow-prepare.md +1 -1
  5. package/commands/cursorflow-resume.md +127 -6
  6. package/commands/cursorflow-run.md +2 -2
  7. package/commands/cursorflow-signal.md +11 -4
  8. package/dist/cli/clean.js +164 -12
  9. package/dist/cli/clean.js.map +1 -1
  10. package/dist/cli/index.d.ts +1 -0
  11. package/dist/cli/index.js +6 -1
  12. package/dist/cli/index.js.map +1 -1
  13. package/dist/cli/logs.d.ts +8 -0
  14. package/dist/cli/logs.js +746 -0
  15. package/dist/cli/logs.js.map +1 -0
  16. package/dist/cli/monitor.js +113 -30
  17. package/dist/cli/monitor.js.map +1 -1
  18. package/dist/cli/prepare.js +1 -1
  19. package/dist/cli/resume.js +367 -18
  20. package/dist/cli/resume.js.map +1 -1
  21. package/dist/cli/run.js +2 -0
  22. package/dist/cli/run.js.map +1 -1
  23. package/dist/cli/signal.js +34 -20
  24. package/dist/cli/signal.js.map +1 -1
  25. package/dist/core/orchestrator.d.ts +11 -1
  26. package/dist/core/orchestrator.js +257 -35
  27. package/dist/core/orchestrator.js.map +1 -1
  28. package/dist/core/reviewer.js +20 -0
  29. package/dist/core/reviewer.js.map +1 -1
  30. package/dist/core/runner.js +113 -13
  31. package/dist/core/runner.js.map +1 -1
  32. package/dist/utils/config.js +34 -0
  33. package/dist/utils/config.js.map +1 -1
  34. package/dist/utils/doctor.js +9 -2
  35. package/dist/utils/doctor.js.map +1 -1
  36. package/dist/utils/enhanced-logger.d.ts +209 -0
  37. package/dist/utils/enhanced-logger.js +963 -0
  38. package/dist/utils/enhanced-logger.js.map +1 -0
  39. package/dist/utils/events.d.ts +59 -0
  40. package/dist/utils/events.js +37 -0
  41. package/dist/utils/events.js.map +1 -0
  42. package/dist/utils/git.d.ts +5 -0
  43. package/dist/utils/git.js +25 -0
  44. package/dist/utils/git.js.map +1 -1
  45. package/dist/utils/types.d.ts +122 -1
  46. package/dist/utils/webhook.d.ts +5 -0
  47. package/dist/utils/webhook.js +109 -0
  48. package/dist/utils/webhook.js.map +1 -0
  49. package/examples/README.md +1 -1
  50. package/package.json +1 -1
  51. package/scripts/simple-logging-test.sh +97 -0
  52. package/scripts/test-real-logging.sh +289 -0
  53. package/scripts/test-streaming-multi-task.sh +247 -0
  54. package/src/cli/clean.ts +170 -13
  55. package/src/cli/index.ts +4 -1
  56. package/src/cli/logs.ts +848 -0
  57. package/src/cli/monitor.ts +123 -30
  58. package/src/cli/prepare.ts +1 -1
  59. package/src/cli/resume.ts +463 -22
  60. package/src/cli/run.ts +2 -0
  61. package/src/cli/signal.ts +43 -27
  62. package/src/core/orchestrator.ts +303 -37
  63. package/src/core/reviewer.ts +22 -0
  64. package/src/core/runner.ts +128 -12
  65. package/src/utils/config.ts +36 -0
  66. package/src/utils/doctor.ts +12 -2
  67. package/src/utils/enhanced-logger.ts +1097 -0
  68. package/src/utils/events.ts +117 -0
  69. package/src/utils/git.ts +25 -0
  70. package/src/utils/types.ts +150 -1
  71. package/src/utils/webhook.ts +85 -0
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Enhanced Logger - Comprehensive terminal output capture and management
3
+ *
4
+ * Features:
5
+ * - ANSI escape sequence stripping for clean logs
6
+ * - Automatic timestamps on each line
7
+ * - Log rotation and size management
8
+ * - Session headers with context
9
+ * - Raw and clean log file options
10
+ * - Structured JSON logs for programmatic access
11
+ * - Streaming output support for real-time capture
12
+ */
13
+ import { Transform, TransformCallback } from 'stream';
14
+ import { EnhancedLogConfig } from './types';
15
+ export { EnhancedLogConfig } from './types';
16
+ export declare const DEFAULT_LOG_CONFIG: EnhancedLogConfig;
17
+ /**
18
+ * Streaming JSON Parser - Parses cursor-agent stream-json output
19
+ * and combines tokens into readable messages
20
+ */
21
+ export declare class StreamingMessageParser {
22
+ private currentMessage;
23
+ private currentRole;
24
+ private messageStartTime;
25
+ private onMessage;
26
+ constructor(onMessage: (msg: ParsedMessage) => void);
27
+ /**
28
+ * Parse a line of JSON output from cursor-agent
29
+ */
30
+ parseLine(line: string): void;
31
+ private handleJsonMessage;
32
+ /**
33
+ * Flush accumulated message
34
+ */
35
+ flush(): void;
36
+ private emitMessage;
37
+ }
38
+ export interface ParsedMessage {
39
+ type: 'system' | 'user' | 'assistant' | 'tool' | 'tool_result' | 'result';
40
+ role: string;
41
+ content: string;
42
+ timestamp: number;
43
+ metadata?: Record<string, any>;
44
+ }
45
+ /**
46
+ * Strip ANSI escape sequences from text
47
+ */
48
+ export declare function stripAnsi(text: string): string;
49
+ /**
50
+ * Format timestamp based on format preference
51
+ */
52
+ export declare function formatTimestamp(format: 'iso' | 'relative' | 'short', startTime?: number): string;
53
+ /**
54
+ * JSON log entry structure
55
+ */
56
+ export interface JsonLogEntry {
57
+ timestamp: string;
58
+ level: 'stdout' | 'stderr' | 'info' | 'error' | 'debug' | 'session';
59
+ source?: string;
60
+ task?: string;
61
+ lane?: string;
62
+ message: string;
63
+ raw?: string;
64
+ metadata?: Record<string, any>;
65
+ }
66
+ /**
67
+ * Session context for logging
68
+ */
69
+ export interface LogSession {
70
+ id: string;
71
+ laneName: string;
72
+ taskName?: string;
73
+ model?: string;
74
+ startTime: number;
75
+ metadata?: Record<string, any>;
76
+ }
77
+ /**
78
+ * Transform stream that strips ANSI and adds timestamps
79
+ */
80
+ export declare class CleanLogTransform extends Transform {
81
+ private config;
82
+ private session;
83
+ private buffer;
84
+ constructor(config: EnhancedLogConfig, session: LogSession);
85
+ _transform(chunk: Buffer, encoding: BufferEncoding, callback: TransformCallback): void;
86
+ _flush(callback: TransformCallback): void;
87
+ }
88
+ /**
89
+ * Enhanced Log Manager - Manages log files with rotation and multiple outputs
90
+ */
91
+ export declare class EnhancedLogManager {
92
+ private config;
93
+ private session;
94
+ private logDir;
95
+ private cleanLogPath;
96
+ private rawLogPath;
97
+ private jsonLogPath;
98
+ private readableLogPath;
99
+ private cleanLogFd;
100
+ private rawLogFd;
101
+ private jsonLogFd;
102
+ private readableLogFd;
103
+ private cleanLogSize;
104
+ private rawLogSize;
105
+ private cleanTransform;
106
+ private streamingParser;
107
+ private lineBuffer;
108
+ constructor(logDir: string, session: LogSession, config?: Partial<EnhancedLogConfig>);
109
+ /**
110
+ * Initialize log files and write session headers
111
+ */
112
+ private initLogFiles;
113
+ /**
114
+ * Write a parsed message to the readable log
115
+ */
116
+ private writeReadableMessage;
117
+ /**
118
+ * Indent text with a prefix
119
+ */
120
+ private indentText;
121
+ /**
122
+ * Write session header to logs
123
+ */
124
+ private writeSessionHeader;
125
+ /**
126
+ * Rotate log file if it exceeds max size
127
+ */
128
+ private rotateIfNeeded;
129
+ /**
130
+ * Rotate a log file
131
+ */
132
+ private rotateLog;
133
+ /**
134
+ * Write to clean log with size tracking
135
+ */
136
+ private writeToCleanLog;
137
+ /**
138
+ * Write to raw log with size tracking
139
+ */
140
+ private writeToRawLog;
141
+ /**
142
+ * Write a JSON log entry
143
+ */
144
+ private writeJsonEntry;
145
+ /**
146
+ * Write stdout data
147
+ */
148
+ writeStdout(data: Buffer | string): void;
149
+ /**
150
+ * Parse streaming JSON data for readable log
151
+ */
152
+ private parseStreamingData;
153
+ /**
154
+ * Write stderr data
155
+ */
156
+ writeStderr(data: Buffer | string): void;
157
+ /**
158
+ * Write a custom log entry
159
+ */
160
+ log(level: 'info' | 'error' | 'debug', message: string, metadata?: Record<string, any>): void;
161
+ /**
162
+ * Add a section marker
163
+ */
164
+ section(title: string): void;
165
+ /**
166
+ * Update task context
167
+ */
168
+ setTask(taskName: string, model?: string): void;
169
+ /**
170
+ * Check if a log line is noise (progress bars, spinners, etc.)
171
+ */
172
+ private isNoiseLog;
173
+ /**
174
+ * Get paths to all log files
175
+ */
176
+ getLogPaths(): {
177
+ clean: string;
178
+ raw?: string;
179
+ json?: string;
180
+ readable: string;
181
+ };
182
+ /**
183
+ * Create file descriptors for process stdio redirection
184
+ */
185
+ getFileDescriptors(): {
186
+ stdout: number;
187
+ stderr: number;
188
+ };
189
+ /**
190
+ * Close all log files
191
+ */
192
+ close(): void;
193
+ /**
194
+ * Format duration for display
195
+ */
196
+ private formatDuration;
197
+ }
198
+ /**
199
+ * Create a log manager for a lane
200
+ */
201
+ export declare function createLogManager(laneRunDir: string, laneName: string, config?: Partial<EnhancedLogConfig>): EnhancedLogManager;
202
+ /**
203
+ * Read and parse JSON log file
204
+ */
205
+ export declare function readJsonLog(logPath: string): JsonLogEntry[];
206
+ /**
207
+ * Export logs to various formats
208
+ */
209
+ export declare function exportLogs(laneRunDir: string, format: 'text' | 'json' | 'markdown' | 'html', outputPath?: string): string;