MCPcopy
hub / github.com/opactorai/Claudable / runCursorOnce

Function runCursorOnce

lib/services/cli/cursor.ts:768–921  ·  view source on GitHub ↗
(params: {
  projectId: string;
  repoPath: string;
  args: string[];
  env: NodeJS.ProcessEnv;
  requestId?: string;
  initialSessionId?: string;
  placeholderMessageId?: string;
})

Source from the content-addressed store, hash-verified

766}
767
768async function runCursorOnce(params: {
769 projectId: string;
770 repoPath: string;
771 args: string[];
772 env: NodeJS.ProcessEnv;
773 requestId?: string;
774 initialSessionId?: string;
775 placeholderMessageId?: string;
776}): Promise<CursorRunResult> {
777 const { projectId, repoPath, args, env, requestId, initialSessionId, placeholderMessageId } = params;
778
779 const child = spawn(CURSOR_EXECUTABLE, args, {
780 cwd: repoPath,
781 env,
782 stdio: ['ignore', 'pipe', 'pipe'],
783 });
784
785 const stderrLines: string[] = [];
786 const assistantStreamer = createAssistantStreamer(projectId, requestId, {
787 initialMessageId: placeholderMessageId,
788 });
789 let updatedSessionId = initialSessionId;
790 let processError: Error | null = null;
791 let detectedError: CursorErrorKind | undefined;
792 let errorMessage: string | undefined;
793
794 if (child.stderr) {
795 child.stderr.setEncoding('utf8');
796 child.stderr.on('data', (chunk: string) => {
797 chunk
798 .split(/\r?\n/)
799 .map((line) => line.trim())
800 .filter(Boolean)
801 .forEach((line) => stderrLines.push(line));
802 });
803 }
804
805 child.on('error', (error) => {
806 processError = error;
807 stderrLines.push(error.message);
808 });
809
810 publishStatus(projectId, 'running', requestId);
811
812 const rl = child.stdout ? readline.createInterface({ input: child.stdout }) : null;
813
814 if (rl) {
815 try {
816 for await (const line of rl) {
817 const trimmed = line.trim();
818 if (!trimmed) {
819 continue;
820 }
821
822 let event: CursorEvent | null = null;
823 try {
824 event = JSON.parse(trimmed) as CursorEvent;
825 } catch (error) {

Callers 1

executeCursorFunction · 0.85

Calls 8

updateProjectFunction · 0.90
createAssistantStreamerFunction · 0.85
extractSessionIdFunction · 0.85
extractAssistantTextFunction · 0.85
handleToolEventFunction · 0.85
toDisplayStringFunction · 0.85
detectCursorErrorFunction · 0.85
publishStatusFunction · 0.70

Tested by

no test coverage detected