MCPcopy Create free account
hub / github.com/buct2012dbl/Dorchestrator / startRepl

Function startRepl

coding-agent/src/cli/repl.ts:58–155  ·  view source on GitHub ↗
(orchestrator: Orchestrator, agentId: string)

Source from the content-addressed store, hash-verified

56}
57
58export async function startRepl(orchestrator: Orchestrator, agentId: string): Promise<void> {
59 const rl = readline.createInterface({
60 input,
61 output,
62 terminal: true
63 });
64
65 let intentionalClose = false;
66
67 rl.on('close', () => {
68 if (!intentionalClose) {
69 console.log(chalk.red('\nReadline closed unexpectedly.'));
70 console.log(chalk.gray('This usually means stdin is not attached to a live TTY.'));
71 }
72 orchestrator.shutdown();
73 });
74
75 process.on('SIGINT', () => {
76 console.log(chalk.yellow('\nUse "exit" or "quit" to leave the session.'));
77 });
78
79 const agent = orchestrator.getAgent(agentId);
80 const agentName = agent?.config.name || agentId;
81 const model = agent?.config.model || 'unknown';
82 const workspacePath = process.cwd();
83
84 renderHeader(agentName, model, workspacePath);
85
86 while (true) {
87 try {
88 const message = await rl.question(renderPrompt());
89
90 if (!message.trim()) continue;
91
92 const normalized = message.toLowerCase();
93
94 if (normalized === 'exit' || normalized === 'quit') {
95 console.log(chalk.hex('#fbbf24')('\nSession closed.'));
96 intentionalClose = true;
97 rl.close();
98 return;
99 }
100
101 if (normalized === 'stats') {
102 const stats = orchestrator.getStats();
103 console.log();
104 console.log(
105 boxen(JSON.stringify(stats, null, 2), {
106 padding: { top: 0, right: 1, bottom: 0, left: 1 },
107 borderStyle: 'round',
108 borderColor: 'blue'
109 })
110 );
111 console.log();
112 continue;
113 }
114
115 if (normalized === 'clear') {

Callers 1

index.tsFile · 0.85

Calls 11

renderHeaderFunction · 0.85
renderPromptFunction · 0.85
logMethod · 0.80
shutdownMethod · 0.80
startMethod · 0.80
stopMethod · 0.80
errorMethod · 0.80
getAgentMethod · 0.45
closeMethod · 0.45
getStatsMethod · 0.45
executeTaskMethod · 0.45

Tested by

no test coverage detected