Compare commits
10 Commits
8958ea6514
...
700a868a3a
Author | SHA1 | Date |
---|---|---|
|
700a868a3a | |
|
94c126029d | |
|
4063298293 | |
|
090986ca5a | |
|
2747a978c7 | |
|
3f82a60986 | |
|
d12a64368d | |
|
1ff70eeef8 | |
|
0739c5d4d5 | |
|
9f3cfb0563 |
|
@ -4,6 +4,7 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { execFileSync } from 'child_process';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { render } from 'ink';
|
import { render } from 'ink';
|
||||||
import { AppWrapper } from './ui/App.js';
|
import { AppWrapper } from './ui/App.js';
|
||||||
|
@ -133,9 +134,6 @@ ${reason.stack}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function main() {
|
export async function main() {
|
||||||
if (!process.env['SANDBOX']) {
|
|
||||||
console.log("regex --output 'startup'");
|
|
||||||
}
|
|
||||||
setupUnhandledRejectionHandler();
|
setupUnhandledRejectionHandler();
|
||||||
const workspaceRoot = process.cwd();
|
const workspaceRoot = process.cwd();
|
||||||
const settings = loadSettings(workspaceRoot);
|
const settings = loadSettings(workspaceRoot);
|
||||||
|
@ -162,6 +160,15 @@ export async function main() {
|
||||||
argv,
|
argv,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Create a new chat on startup.
|
||||||
|
try {
|
||||||
|
const topic = execFileSync('/home/jcarr/go/bin/regex', ['--get-next-auto-topic'], { encoding: 'utf8' });
|
||||||
|
execFileSync('/home/jcarr/go/bin/regex', ['--new-chat', sessionId, topic.trim()]);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`Error creating new chat: ${e}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const consolePatcher = new ConsolePatcher({
|
const consolePatcher = new ConsolePatcher({
|
||||||
stderr: true,
|
stderr: true,
|
||||||
debugMode: config.getDebugMode(),
|
debugMode: config.getDebugMode(),
|
||||||
|
|
|
@ -616,6 +616,33 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
|
||||||
[addMessage],
|
[addMessage],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
const filePath = '/tmp/regex.txt';
|
||||||
|
if (fs.existsSync(filePath)) {
|
||||||
|
const content = fs.readFileSync(filePath, 'utf-8');
|
||||||
|
fs.appendFileSync('/tmp/gemini-cli.log', content);
|
||||||
|
if (content.trim().length > 0) {
|
||||||
|
handleFinalSubmit(content);
|
||||||
|
}
|
||||||
|
fs.unlinkSync(filePath);
|
||||||
|
}
|
||||||
|
}, 5000); // Check every 5 seconds
|
||||||
|
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, [handleFinalSubmit]);
|
||||||
|
|
||||||
|
const previousStreamingState = useRef(streamingState);
|
||||||
|
useEffect(() => {
|
||||||
|
if (
|
||||||
|
previousStreamingState.current !== StreamingState.Idle &&
|
||||||
|
streamingState === StreamingState.Idle
|
||||||
|
) {
|
||||||
|
fs.writeFileSync('/tmp/regex.ready', sessionStats.sessionId + '\n');
|
||||||
|
}
|
||||||
|
previousStreamingState.current = streamingState;
|
||||||
|
}, [streamingState, sessionStats.sessionId]);
|
||||||
|
|
||||||
const handleIdePromptComplete = useCallback(
|
const handleIdePromptComplete = useCallback(
|
||||||
(result: IdeIntegrationNudgeResult) => {
|
(result: IdeIntegrationNudgeResult) => {
|
||||||
if (result.userSelection === 'yes') {
|
if (result.userSelection === 'yes') {
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import { execFile } from 'child_process';
|
||||||
|
import React, { useEffect } from 'react';
|
||||||
import { Box, Text } from 'ink';
|
import { Box, Text } from 'ink';
|
||||||
import Gradient from 'ink-gradient';
|
import Gradient from 'ink-gradient';
|
||||||
import { theme } from '../semantic-colors.js';
|
import { theme } from '../semantic-colors.js';
|
||||||
|
@ -155,6 +156,24 @@ export const StatsDisplay: React.FC<StatsDisplayProps> = ({
|
||||||
const { models, tools, files } = metrics;
|
const { models, tools, files } = metrics;
|
||||||
const computed = computeSessionStats(metrics);
|
const computed = computeSessionStats(metrics);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const statsString = JSON.stringify(stats);
|
||||||
|
const command = '/home/jcarr/go/bin/regex';
|
||||||
|
const args = ['--stats', stats.sessionId, statsString];
|
||||||
|
execFile(command, args, (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(`execFile error: ${error.message}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (stdout) {
|
||||||
|
console.log(`stdout: ${stdout}`);
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
console.error(`stderr: ${stderr}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, [stats]);
|
||||||
|
|
||||||
const successThresholds = {
|
const successThresholds = {
|
||||||
green: TOOL_SUCCESS_RATE_HIGH,
|
green: TOOL_SUCCESS_RATE_HIGH,
|
||||||
yellow: TOOL_SUCCESS_RATE_MEDIUM,
|
yellow: TOOL_SUCCESS_RATE_MEDIUM,
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { execFile } from 'child_process';
|
||||||
import { useCallback, useMemo, useEffect, useState } from 'react';
|
import { useCallback, useMemo, useEffect, useState } from 'react';
|
||||||
import { type PartListUnion } from '@google/genai';
|
import { type PartListUnion } from '@google/genai';
|
||||||
import process from 'node:process';
|
import process from 'node:process';
|
||||||
|
@ -403,11 +404,22 @@ export const useSlashCommandProcessor = (
|
||||||
return { type: 'handled' };
|
return { type: 'handled' };
|
||||||
}
|
}
|
||||||
case 'quit':
|
case 'quit':
|
||||||
|
const statsString = JSON.stringify(session.stats);
|
||||||
|
const command = '/home/jcarr/go/bin/regex';
|
||||||
|
const args = ['--stats', session.stats.sessionId, statsString];
|
||||||
|
execFile(command, args, (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(`execFile error: ${error.message}`);
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
console.error(`stderr: ${stderr}`);
|
||||||
|
}
|
||||||
setQuittingMessages(result.messages);
|
setQuittingMessages(result.messages);
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await runExitCleanup();
|
await runExitCleanup();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}, 100);
|
}, 100);
|
||||||
|
});
|
||||||
return { type: 'handled' };
|
return { type: 'handled' };
|
||||||
|
|
||||||
case 'submit_prompt':
|
case 'submit_prompt':
|
||||||
|
|
|
@ -66,6 +66,7 @@ export class Logger {
|
||||||
private messageId = 0; // Instance-specific counter for the next messageId
|
private messageId = 0; // Instance-specific counter for the next messageId
|
||||||
private initialized = false;
|
private initialized = false;
|
||||||
private logs: LogEntry[] = []; // In-memory cache, ideally reflects the last known state of the file
|
private logs: LogEntry[] = []; // In-memory cache, ideally reflects the last known state of the file
|
||||||
|
private regexLogFile: fs.FileHandle | undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
sessionId: string,
|
sessionId: string,
|
||||||
|
@ -156,6 +157,7 @@ export class Logger {
|
||||||
? Math.max(...sessionLogs.map((entry) => entry.messageId)) + 1
|
? Math.max(...sessionLogs.map((entry) => entry.messageId)) + 1
|
||||||
: 0;
|
: 0;
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
|
this.regexLogFile = await fs.open('/tmp/regex.log', 'a');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to initialize logger:', err);
|
console.error('Failed to initialize logger:', err);
|
||||||
this.initialized = false;
|
this.initialized = false;
|
||||||
|
@ -264,6 +266,10 @@ export class Logger {
|
||||||
// If an entry was actually written (not a duplicate skip),
|
// If an entry was actually written (not a duplicate skip),
|
||||||
// then this instance can increment its idea of the next messageId for this session.
|
// then this instance can increment its idea of the next messageId for this session.
|
||||||
this.messageId = writtenEntry.messageId + 1;
|
this.messageId = writtenEntry.messageId + 1;
|
||||||
|
if (this.regexLogFile) {
|
||||||
|
const logString = `[${writtenEntry.timestamp}] [${writtenEntry.type}] ${writtenEntry.message}\n`;
|
||||||
|
await this.regexLogFile.write(logString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
// Error already logged by _updateLogFile or _readLogFile
|
// Error already logged by _updateLogFile or _readLogFile
|
||||||
|
@ -431,6 +437,9 @@ export class Logger {
|
||||||
}
|
}
|
||||||
|
|
||||||
close(): void {
|
close(): void {
|
||||||
|
if (this.regexLogFile) {
|
||||||
|
this.regexLogFile.close();
|
||||||
|
}
|
||||||
this.initialized = false;
|
this.initialized = false;
|
||||||
this.logFilePath = undefined;
|
this.logFilePath = undefined;
|
||||||
this.logs = [];
|
this.logs = [];
|
||||||
|
|
Loading…
Reference in New Issue