tycono 0.1.96-beta.50 → 0.1.96-beta.52
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/bin/tycono.ts +22 -14
- package/package.json +1 -1
package/bin/tycono.ts
CHANGED
|
@@ -219,22 +219,16 @@ async function startServerForTui(): Promise<void> {
|
|
|
219
219
|
const logFd = fs.openSync(logFile, 'a');
|
|
220
220
|
const logStream = fs.createWriteStream(logFile, { fd: logFd });
|
|
221
221
|
const origStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
222
|
-
// Redirect ALL non-Ink output to log file.
|
|
223
|
-
// Ink uses stdout.write with ANSI sequences. Server uses console.log (which calls stdout.write).
|
|
224
|
-
// We must intercept stdout.write but ALWAYS pass through to real stdout,
|
|
225
|
-
// just also copy non-Ink output to log file.
|
|
226
|
-
// The key insight: DON'T BLOCK anything — just copy server output to log file.
|
|
227
|
-
// Ink can handle interleaved output by re-rendering.
|
|
228
|
-
console.log = (...args: unknown[]) => { logStream.write(args.join(' ') + '\n'); };
|
|
229
|
-
console.error = (...args: unknown[]) => { logStream.write(args.join(' ') + '\n'); };
|
|
230
|
-
console.warn = (...args: unknown[]) => { logStream.write(args.join(' ') + '\n'); };
|
|
231
|
-
// Also intercept direct stderr.write (used by our debug logging)
|
|
232
|
-
process.stderr.write = ((chunk: any, ...args: any[]) => {
|
|
233
|
-
logStream.write(typeof chunk === 'string' ? chunk : chunk.toString());
|
|
234
|
-
return true;
|
|
235
|
-
}) as any;
|
|
236
222
|
const origLog = (...args: unknown[]) => origStdoutWrite(args.join(' ') + '\n');
|
|
237
223
|
|
|
224
|
+
// Suppress ALL server output BEFORE importing server code
|
|
225
|
+
// Override console methods globally — affects all subsequently imported modules
|
|
226
|
+
const _log = console.log, _err = console.error, _warn = console.warn, _info = console.info;
|
|
227
|
+
console.log = (...a: unknown[]) => logStream.write(a.join(' ') + '\n');
|
|
228
|
+
console.error = (...a: unknown[]) => logStream.write(a.join(' ') + '\n');
|
|
229
|
+
console.warn = (...a: unknown[]) => logStream.write(a.join(' ') + '\n');
|
|
230
|
+
console.info = (...a: unknown[]) => logStream.write(a.join(' ') + '\n');
|
|
231
|
+
|
|
238
232
|
const { createHttpServer } = await import('../src/api/src/create-server.js');
|
|
239
233
|
const server = createHttpServer();
|
|
240
234
|
|
|
@@ -247,6 +241,20 @@ async function startServerForTui(): Promise<void> {
|
|
|
247
241
|
origLog(` API server started on port ${port}`);
|
|
248
242
|
origLog(` Logs: ${logFile}`);
|
|
249
243
|
|
|
244
|
+
// Now hijack stdout.write AFTER server started but BEFORE Ink
|
|
245
|
+
// Block non-Ink output from reaching terminal
|
|
246
|
+
// Ink always writes ANSI escape sequences — server text output doesn't
|
|
247
|
+
process.stdout.write = ((chunk: any, ...args: any[]) => {
|
|
248
|
+
const str = typeof chunk === 'string' ? chunk : chunk.toString();
|
|
249
|
+
// Ink output: contains ANSI CSI sequences
|
|
250
|
+
if (str.includes('\x1b[') || str.includes('\x1b(')) {
|
|
251
|
+
return origStdoutWrite(chunk, ...args);
|
|
252
|
+
}
|
|
253
|
+
// Non-Ink (server log leaked): redirect to file
|
|
254
|
+
logStream.write(str);
|
|
255
|
+
return true;
|
|
256
|
+
}) as any;
|
|
257
|
+
|
|
250
258
|
// Graceful shutdown
|
|
251
259
|
const shutdown = () => {
|
|
252
260
|
server.close(() => process.exit(0));
|