MCPcopy Index your code
hub / github.com/Doorman11991/smallcode / runNonInteractive

Function runNonInteractive

bin/smallcode.js:2783–2832  ·  view source on GitHub ↗
(config, prompt)

Source from the content-addressed store, hash-verified

2781// ─── Non-Interactive Mode ────────────────────────────────────────────────────
2782
2783async function runNonInteractive(config, prompt) {
2784 if (!prompt) {
2785 // Read from stdin
2786 const chunks = [];
2787 for await (const chunk of process.stdin) {
2788 chunks.push(chunk);
2789 }
2790 prompt = Buffer.concat(chunks).toString().trim();
2791 }
2792
2793 if (!prompt) {
2794 console.error('No prompt provided.');
2795 process.exit(1);
2796 }
2797
2798 await runAgentLoop(prompt, config);
2799
2800 // Explicit cleanup so the process exits cleanly. The persistent shell holds
2801 // a child cmd.exe with open stdio pipes that would otherwise keep the
2802 // Node event loop alive even after the agent loop returns.
2803 try {
2804 const { resetShell } = require('../src/tools/shell_session');
2805 resetShell();
2806 } catch {}
2807 try {
2808 const { resetReadTracker } = require('../src/tools/read_tracker');
2809 resetReadTracker();
2810 } catch {}
2811 try {
2812 const { resetFileStateTracker } = require('../src/session/file_state');
2813 resetFileStateTracker();
2814 } catch {}
2815 try {
2816 const { resetDedup, resetIdempotentWriteSet } = require('../src/tools/dedup');
2817 resetDedup();
2818 resetIdempotentWriteSet();
2819 } catch {}
2820 try {
2821 const { resetSnapshotManager } = require('../src/session/snapshot');
2822 resetSnapshotManager();
2823 } catch {}
2824 try {
2825 const { resetTrustDecay } = require('../src/tools/trust_decay');
2826 resetTrustDecay();
2827 } catch {}
2828 killMCP();
2829 if (_lspClient) { try { _lspClient.stop(); } catch {} }
2830 // Force exit after a short tick to let any pending log writes flush.
2831 setTimeout(() => process.exit(0), 100).unref();
2832}
2833
2834// ─── MCP Server Mode ─────────────────────────────────────────────────────────
2835

Callers 1

mainFunction · 0.85

Calls 11

runAgentLoopFunction · 0.85
resetShellFunction · 0.85
resetReadTrackerFunction · 0.85
resetFileStateTrackerFunction · 0.85
resetDedupFunction · 0.85
resetIdempotentWriteSetFunction · 0.85
resetSnapshotManagerFunction · 0.85
resetTrustDecayFunction · 0.85
killMCPFunction · 0.85
errorMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected