ai-cli-mcp 2.17.0 → 2.19.0
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/CHANGELOG.md +14 -0
- package/README.ja.md +13 -9
- package/README.md +13 -9
- package/dist/__tests__/app-cli.test.js +3 -3
- package/dist/__tests__/cli-process-service.test.js +3 -2
- package/dist/__tests__/mcp-contract.test.js +1 -0
- package/dist/__tests__/parsers.test.js +290 -1
- package/dist/__tests__/peek.test.js +8 -7
- package/dist/__tests__/process-management.test.js +156 -4
- package/dist/app/cli.js +6 -5
- package/dist/app/mcp.js +11 -2
- package/dist/cli-process-service.js +11 -10
- package/dist/parsers.js +382 -25
- package/dist/peek.js +8 -5
- package/dist/process-service.js +11 -10
- package/package.json +1 -1
- package/src/__tests__/app-cli.test.ts +3 -3
- package/src/__tests__/cli-process-service.test.ts +3 -2
- package/src/__tests__/mcp-contract.test.ts +1 -0
- package/src/__tests__/parsers.test.ts +321 -1
- package/src/__tests__/peek.test.ts +8 -7
- package/src/__tests__/process-management.test.ts +172 -4
- package/src/app/cli.ts +7 -6
- package/src/app/mcp.ts +11 -2
- package/src/cli-process-service.ts +13 -12
- package/src/parsers.ts +498 -29
- package/src/peek.ts +14 -7
- package/src/process-service.ts +13 -12
package/src/peek.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PeekMessage } from './parsers.js';
|
|
1
|
+
import type { PeekEvent, PeekMessage } from './parsers.js';
|
|
2
2
|
import type { AgentType, ProcessStatus } from './process-service.js';
|
|
3
3
|
|
|
4
4
|
export const DEFAULT_PEEK_TIME_SEC = 10;
|
|
@@ -13,7 +13,7 @@ export interface PeekProcessResult {
|
|
|
13
13
|
pid: number;
|
|
14
14
|
agent: PeekAgent;
|
|
15
15
|
status: PeekStatus;
|
|
16
|
-
|
|
16
|
+
events: PeekEvent[];
|
|
17
17
|
truncated: boolean;
|
|
18
18
|
error: string | null;
|
|
19
19
|
}
|
|
@@ -67,22 +67,29 @@ export function buildNotFoundPeekProcess(pid: number): PeekProcessResult {
|
|
|
67
67
|
pid,
|
|
68
68
|
agent: null,
|
|
69
69
|
status: 'not_found',
|
|
70
|
-
|
|
70
|
+
events: [],
|
|
71
71
|
truncated: false,
|
|
72
72
|
error: 'process not found',
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
export function
|
|
77
|
-
for (const
|
|
78
|
-
if (target.
|
|
79
|
-
target.
|
|
76
|
+
export function appendPeekEvents(target: PeekProcessResult, events: PeekEvent[]): void {
|
|
77
|
+
for (const event of events) {
|
|
78
|
+
if (target.events.length < PEEK_MESSAGE_CAP) {
|
|
79
|
+
target.events.push(event);
|
|
80
80
|
} else {
|
|
81
81
|
target.truncated = true;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
export function appendPeekMessages(target: PeekProcessResult, messages: PeekMessage[]): void {
|
|
87
|
+
appendPeekEvents(
|
|
88
|
+
target,
|
|
89
|
+
messages.map((message) => ({ kind: 'message' as const, ...message })),
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
86
93
|
export function observedDurationSec(startedAtMs: number, endedAtMs = Date.now()): number {
|
|
87
94
|
return Number(((endedAtMs - startedAtMs) / 1000).toFixed(2));
|
|
88
95
|
}
|
package/src/process-service.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { spawn, type ChildProcess } from 'node:child_process';
|
|
2
2
|
import { buildCliCommand, type BuildCliCommandOptions } from './cli-builder.js';
|
|
3
|
-
import { parseClaudeOutput, parseCodexOutput, parseForgeOutput, parseGeminiOutput, parseOpenCodeOutput,
|
|
3
|
+
import { parseClaudeOutput, parseCodexOutput, parseForgeOutput, parseGeminiOutput, parseOpenCodeOutput, PeekEventExtractor } from './parsers.js';
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
appendPeekEvents,
|
|
6
6
|
buildNotFoundPeekProcess,
|
|
7
7
|
observedDurationSec,
|
|
8
8
|
validatePeekPids,
|
|
@@ -226,15 +226,15 @@ export class ProcessService {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
async peekProcesses(pids: number[], peekTimeSec = 10): Promise<PeekResponse> {
|
|
229
|
+
async peekProcesses(pids: number[], peekTimeSec = 10, includeToolCalls = false): Promise<PeekResponse> {
|
|
230
230
|
const targetPids = validatePeekPids(pids);
|
|
231
231
|
const targetPeekTimeSec = validatePeekTimeSec(peekTimeSec);
|
|
232
232
|
const processes: PeekProcessResult[] = [];
|
|
233
233
|
const observers: Array<{
|
|
234
234
|
entry: TrackedProcess;
|
|
235
235
|
result: PeekProcessResult;
|
|
236
|
-
stdoutExtractor:
|
|
237
|
-
stderrExtractor:
|
|
236
|
+
stdoutExtractor: PeekEventExtractor;
|
|
237
|
+
stderrExtractor: PeekEventExtractor;
|
|
238
238
|
onStdout: (data: Buffer | string) => void;
|
|
239
239
|
onStderr: (data: Buffer | string) => void;
|
|
240
240
|
}> = [];
|
|
@@ -250,19 +250,19 @@ export class ProcessService {
|
|
|
250
250
|
pid,
|
|
251
251
|
agent: entry.toolType,
|
|
252
252
|
status: entry.status,
|
|
253
|
-
|
|
253
|
+
events: [],
|
|
254
254
|
truncated: false,
|
|
255
255
|
error: null,
|
|
256
256
|
};
|
|
257
257
|
processes.push(result);
|
|
258
258
|
|
|
259
|
-
const stdoutExtractor = new
|
|
260
|
-
const stderrExtractor = new
|
|
259
|
+
const stdoutExtractor = new PeekEventExtractor(entry.toolType, { includeToolCalls, source: 'stdout' });
|
|
260
|
+
const stderrExtractor = new PeekEventExtractor(entry.toolType, { includeToolCalls, source: 'stderr' });
|
|
261
261
|
const onStdout = (data: Buffer | string) => {
|
|
262
|
-
|
|
262
|
+
appendPeekEvents(result, stdoutExtractor.push(data.toString(), new Date().toISOString()));
|
|
263
263
|
};
|
|
264
264
|
const onStderr = (data: Buffer | string) => {
|
|
265
|
-
|
|
265
|
+
appendPeekEvents(result, stderrExtractor.push(data.toString(), new Date().toISOString()));
|
|
266
266
|
};
|
|
267
267
|
|
|
268
268
|
if (entry.status === 'running') {
|
|
@@ -294,8 +294,9 @@ export class ProcessService {
|
|
|
294
294
|
for (const observer of observers) {
|
|
295
295
|
observer.entry.process.stdout?.off('data', observer.onStdout);
|
|
296
296
|
observer.entry.process.stderr?.off('data', observer.onStderr);
|
|
297
|
-
|
|
298
|
-
|
|
297
|
+
const terminal = observer.entry.status !== 'running';
|
|
298
|
+
appendPeekEvents(observer.result, observer.stdoutExtractor.flush(flushTs, { terminal }));
|
|
299
|
+
appendPeekEvents(observer.result, observer.stderrExtractor.flush(flushTs, { terminal }));
|
|
299
300
|
observer.result.status = observer.entry.status;
|
|
300
301
|
}
|
|
301
302
|
}
|