@shepai/cli 1.8.1 → 1.9.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/dist/src/application/ports/output/agent-executor-factory.interface.d.ts +45 -0
- package/dist/src/application/ports/output/agent-executor-factory.interface.d.ts.map +1 -0
- package/dist/src/application/ports/output/agent-executor-factory.interface.js +19 -0
- package/dist/src/application/ports/output/agent-executor.interface.d.ts +117 -0
- package/dist/src/application/ports/output/agent-executor.interface.d.ts.map +1 -0
- package/dist/src/application/ports/output/agent-executor.interface.js +23 -0
- package/dist/src/application/ports/output/agent-registry.interface.d.ts +91 -0
- package/dist/src/application/ports/output/agent-registry.interface.d.ts.map +1 -0
- package/dist/src/application/ports/output/agent-registry.interface.js +33 -0
- package/dist/src/application/ports/output/agent-run-repository.interface.d.ts +70 -0
- package/dist/src/application/ports/output/agent-run-repository.interface.d.ts.map +1 -0
- package/dist/src/application/ports/output/agent-run-repository.interface.js +11 -0
- package/dist/src/application/ports/output/agent-runner.interface.d.ts +82 -0
- package/dist/src/application/ports/output/agent-runner.interface.d.ts.map +1 -0
- package/dist/src/application/ports/output/agent-runner.interface.js +23 -0
- package/dist/src/application/ports/output/index.d.ts +5 -0
- package/dist/src/application/ports/output/index.d.ts.map +1 -1
- package/dist/src/application/use-cases/agents/run-agent.use-case.d.ts +52 -0
- package/dist/src/application/use-cases/agents/run-agent.use-case.d.ts.map +1 -0
- package/dist/src/application/use-cases/agents/run-agent.use-case.js +77 -0
- package/dist/src/domain/generated/output.d.ts +98 -0
- package/dist/src/domain/generated/output.d.ts.map +1 -1
- package/dist/src/domain/generated/output.js +17 -0
- package/dist/src/infrastructure/di/container.d.ts.map +1 -1
- package/dist/src/infrastructure/di/container.js +42 -1
- package/dist/src/infrastructure/persistence/sqlite/mappers/agent-run.mapper.d.ts +51 -0
- package/dist/src/infrastructure/persistence/sqlite/mappers/agent-run.mapper.d.ts.map +1 -0
- package/dist/src/infrastructure/persistence/sqlite/mappers/agent-run.mapper.js +64 -0
- package/dist/src/infrastructure/persistence/sqlite/migrations.d.ts +2 -13
- package/dist/src/infrastructure/persistence/sqlite/migrations.d.ts.map +1 -1
- package/dist/src/infrastructure/persistence/sqlite/migrations.js +63 -30
- package/dist/src/infrastructure/repositories/agent-run.repository.d.ts +25 -0
- package/dist/src/infrastructure/repositories/agent-run.repository.d.ts.map +1 -0
- package/dist/src/infrastructure/repositories/agent-run.repository.js +119 -0
- package/dist/src/infrastructure/services/agents/agent-executor-factory.service.d.ts +43 -0
- package/dist/src/infrastructure/services/agents/agent-executor-factory.service.d.ts.map +1 -0
- package/dist/src/infrastructure/services/agents/agent-executor-factory.service.js +58 -0
- package/dist/src/infrastructure/services/agents/agent-registry.service.d.ts +18 -0
- package/dist/src/infrastructure/services/agents/agent-registry.service.d.ts.map +1 -0
- package/dist/src/infrastructure/services/agents/agent-registry.service.js +30 -0
- package/dist/src/infrastructure/services/agents/agent-runner.service.d.ts +27 -0
- package/dist/src/infrastructure/services/agents/agent-runner.service.d.ts.map +1 -0
- package/dist/src/infrastructure/services/agents/agent-runner.service.js +117 -0
- package/dist/src/infrastructure/services/agents/executors/claude-code-executor.service.d.ts +37 -0
- package/dist/src/infrastructure/services/agents/executors/claude-code-executor.service.d.ts.map +1 -0
- package/dist/src/infrastructure/services/agents/executors/claude-code-executor.service.js +275 -0
- package/dist/src/infrastructure/services/agents/langgraph/analyze-repository-graph.d.ts +119 -0
- package/dist/src/infrastructure/services/agents/langgraph/analyze-repository-graph.d.ts.map +1 -0
- package/dist/src/infrastructure/services/agents/langgraph/analyze-repository-graph.js +56 -0
- package/dist/src/infrastructure/services/agents/langgraph/checkpointer.d.ts +9 -0
- package/dist/src/infrastructure/services/agents/langgraph/checkpointer.d.ts.map +1 -0
- package/dist/src/infrastructure/services/agents/langgraph/checkpointer.js +10 -0
- package/dist/src/infrastructure/services/agents/langgraph/prompts/analyze-repository.prompt.d.ts +3 -0
- package/dist/src/infrastructure/services/agents/langgraph/prompts/analyze-repository.prompt.d.ts.map +1 -0
- package/dist/src/infrastructure/services/agents/langgraph/prompts/analyze-repository.prompt.js +18 -0
- package/dist/src/infrastructure/services/agents/streaming/event-channel.d.ts +39 -0
- package/dist/src/infrastructure/services/agents/streaming/event-channel.d.ts.map +1 -0
- package/dist/src/infrastructure/services/agents/streaming/event-channel.js +64 -0
- package/dist/src/infrastructure/services/agents/streaming/index.d.ts +9 -0
- package/dist/src/infrastructure/services/agents/streaming/index.d.ts.map +1 -0
- package/dist/src/infrastructure/services/agents/streaming/index.js +8 -0
- package/dist/src/infrastructure/services/agents/streaming/streaming-executor-proxy.d.ts +25 -0
- package/dist/src/infrastructure/services/agents/streaming/streaming-executor-proxy.d.ts.map +1 -0
- package/dist/src/infrastructure/services/agents/streaming/streaming-executor-proxy.js +51 -0
- package/dist/src/infrastructure/services/web-server.service.d.ts.map +1 -1
- package/dist/src/infrastructure/services/web-server.service.js +2 -3
- package/dist/src/presentation/cli/commands/run.command.d.ts +19 -0
- package/dist/src/presentation/cli/commands/run.command.d.ts.map +1 -0
- package/dist/src/presentation/cli/commands/run.command.js +130 -0
- package/dist/src/presentation/cli/index.js +2 -0
- package/dist/src/presentation/cli/ui/messages.d.ts +1 -1
- package/dist/src/presentation/cli/ui/messages.d.ts.map +1 -1
- package/dist/src/presentation/cli/ui/messages.js +9 -3
- package/dist/src/presentation/cli/ui/symbols.d.ts +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -3
- package/web/.next/BUILD_ID +1 -1
- package/web/.next/build-manifest.json +2 -2
- package/web/.next/cache/.previewinfo +1 -1
- package/web/.next/cache/.rscinfo +1 -1
- package/web/.next/cache/config.json +3 -3
- package/web/.next/fallback-build-manifest.json +2 -2
- package/web/.next/prerender-manifest.json +3 -3
- package/web/.next/required-server-files.js +1 -1
- package/web/.next/required-server-files.json +1 -1
- package/web/.next/server/app/_global-error.html +2 -2
- package/web/.next/server/app/_global-error.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/web/.next/server/app/_not-found.html +2 -2
- package/web/.next/server/app/_not-found.rsc +1 -1
- package/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/web/.next/server/app/index.html +2 -2
- package/web/.next/server/app/index.rsc +1 -1
- package/web/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/web/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/web/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/web/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/web/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/web/.next/server/app/version.html +2 -2
- package/web/.next/server/app/version.rsc +1 -1
- package/web/.next/server/app/version.segments/_full.segment.rsc +1 -1
- package/web/.next/server/app/version.segments/_head.segment.rsc +1 -1
- package/web/.next/server/app/version.segments/_index.segment.rsc +1 -1
- package/web/.next/server/app/version.segments/_tree.segment.rsc +1 -1
- package/web/.next/server/app/version.segments/version/__PAGE__.segment.rsc +1 -1
- package/web/.next/server/app/version.segments/version.segment.rsc +1 -1
- package/web/.next/server/chunks/ssr/_ccea5183._.js +1 -1
- package/web/.next/server/pages/404.html +2 -2
- package/web/.next/server/pages/500.html +2 -2
- package/web/.next/server/server-reference-manifest.js +1 -1
- package/web/.next/server/server-reference-manifest.json +1 -1
- package/web/.next/trace +1 -1
- package/web/.next/trace-build +1 -1
- package/web/next.config.mjs +1 -0
- package/web/next.config.ts +0 -47
- /package/web/.next/static/{hQhBYhX3g-lgV-ix_LYg2 → -QL3Wkz2EyCtR0S30gd0p}/_buildManifest.js +0 -0
- /package/web/.next/static/{hQhBYhX3g-lgV-ix_LYg2 → -QL3Wkz2EyCtR0S30gd0p}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/static/{hQhBYhX3g-lgV-ix_LYg2 → -QL3Wkz2EyCtR0S30gd0p}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming Executor Proxy
|
|
3
|
+
*
|
|
4
|
+
* Wraps an IAgentExecutor, transparently intercepting execute() calls
|
|
5
|
+
* and routing them through executeStream(). Stream events are forwarded
|
|
6
|
+
* to a shared EventChannel while the accumulated result is returned
|
|
7
|
+
* to the caller (the graph node) as if execute() had been called normally.
|
|
8
|
+
*
|
|
9
|
+
* This allows graph nodes to remain unaware of streaming — they call
|
|
10
|
+
* execute() and get an AgentExecutionResult back, while consumers of
|
|
11
|
+
* the EventChannel receive real-time events.
|
|
12
|
+
*/
|
|
13
|
+
import type { AgentType, AgentFeature } from '../../../../domain/generated/output.js';
|
|
14
|
+
import type { IAgentExecutor, AgentExecutionOptions, AgentExecutionResult, AgentExecutionStreamEvent } from '../../../../application/ports/output/agent-executor.interface.js';
|
|
15
|
+
import type { EventChannel } from './event-channel.js';
|
|
16
|
+
export declare class StreamingExecutorProxy implements IAgentExecutor {
|
|
17
|
+
private readonly inner;
|
|
18
|
+
private readonly channel;
|
|
19
|
+
get agentType(): AgentType;
|
|
20
|
+
constructor(inner: IAgentExecutor, channel: EventChannel<AgentExecutionStreamEvent>);
|
|
21
|
+
execute(prompt: string, options?: AgentExecutionOptions): Promise<AgentExecutionResult>;
|
|
22
|
+
executeStream(prompt: string, options?: AgentExecutionOptions): AsyncIterable<AgentExecutionStreamEvent>;
|
|
23
|
+
supportsFeature(feature: AgentFeature): boolean;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=streaming-executor-proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming-executor-proxy.d.ts","sourceRoot":"","sources":["../../../../../../src/infrastructure/services/agents/streaming/streaming-executor-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,wDAAwD,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,qBAAa,sBAAuB,YAAW,cAAc;IAMzD,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAN1B,IAAI,SAAS,IAAI,SAAS,CAEzB;gBAGkB,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,YAAY,CAAC,yBAAyB,CAAC;IAG7D,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAyBtF,aAAa,CAClB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,qBAAqB,GAC9B,aAAa,CAAC,yBAAyB,CAAC;IAI3C,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO;CAGhD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming Executor Proxy
|
|
3
|
+
*
|
|
4
|
+
* Wraps an IAgentExecutor, transparently intercepting execute() calls
|
|
5
|
+
* and routing them through executeStream(). Stream events are forwarded
|
|
6
|
+
* to a shared EventChannel while the accumulated result is returned
|
|
7
|
+
* to the caller (the graph node) as if execute() had been called normally.
|
|
8
|
+
*
|
|
9
|
+
* This allows graph nodes to remain unaware of streaming — they call
|
|
10
|
+
* execute() and get an AgentExecutionResult back, while consumers of
|
|
11
|
+
* the EventChannel receive real-time events.
|
|
12
|
+
*/
|
|
13
|
+
export class StreamingExecutorProxy {
|
|
14
|
+
inner;
|
|
15
|
+
channel;
|
|
16
|
+
get agentType() {
|
|
17
|
+
return this.inner.agentType;
|
|
18
|
+
}
|
|
19
|
+
constructor(inner, channel) {
|
|
20
|
+
this.inner = inner;
|
|
21
|
+
this.channel = channel;
|
|
22
|
+
}
|
|
23
|
+
async execute(prompt, options) {
|
|
24
|
+
let result = '';
|
|
25
|
+
try {
|
|
26
|
+
for await (const event of this.inner.executeStream(prompt, options)) {
|
|
27
|
+
this.channel.push(event);
|
|
28
|
+
if (event.type === 'result') {
|
|
29
|
+
result = event.content;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
this.channel.push({
|
|
35
|
+
type: 'error',
|
|
36
|
+
content: error instanceof Error ? error.message : String(error),
|
|
37
|
+
timestamp: new Date(),
|
|
38
|
+
});
|
|
39
|
+
this.channel.close();
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
this.channel.close();
|
|
43
|
+
return { result };
|
|
44
|
+
}
|
|
45
|
+
async *executeStream(prompt, options) {
|
|
46
|
+
yield* this.inner.executeStream(prompt, options);
|
|
47
|
+
}
|
|
48
|
+
supportsFeature(feature) {
|
|
49
|
+
return this.inner.supportsFeature(feature);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-server.service.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/services/web-server.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gEAAgE,CAAC;AAIxG,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,OAAO,IAAI,CAAC;IAC3B,gBAAgB,EAAE,OAAO,IAAI,CAAC,YAAY,CAAC;CAC5C;AAOD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,IAAI;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"web-server.service.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/services/web-server.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gEAAgE,CAAC;AAIxG,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,OAAO,IAAI,CAAC;IAC3B,gBAAgB,EAAE,OAAO,IAAI,CAAC,YAAY,CAAC;CAC5C;AAOD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,IAAI;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,CAAA;CAAE,CAqB7D;AAED,qBACa,gBAAiB,YAAW,iBAAiB;IACxD,OAAO,CAAC,GAAG,CAAwB;IACnC,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAgB;gBAEzB,IAAI,GAAE,OAAO,CAAC,aAAa,CAAM;IAI7C;;;;;OAKG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BjE;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAoB5B"}
|
|
@@ -45,14 +45,13 @@ export function resolveWebDir() {
|
|
|
45
45
|
// Production: web UI is shipped alongside dist/ in the package
|
|
46
46
|
// From dist/src/infrastructure/services/ we need 4 levels up to reach the package root
|
|
47
47
|
const prodDir = path.resolve(import.meta.dirname, '../../../../web');
|
|
48
|
-
if (fs.existsSync(path.join(prodDir, 'next
|
|
49
|
-
fs.existsSync(path.join(prodDir, '.next'))) {
|
|
48
|
+
if (fs.existsSync(path.join(prodDir, '.next'))) {
|
|
50
49
|
return { dir: prodDir, dev: false };
|
|
51
50
|
}
|
|
52
51
|
throw new Error(`Web UI directory not found. Ensure the web UI is built (pnpm build:web).\n` +
|
|
53
52
|
` Searched:\n` +
|
|
54
53
|
` dev: ${devDir} (next.config.ts: ${fs.existsSync(path.join(devDir, 'next.config.ts'))})\n` +
|
|
55
|
-
` prod: ${prodDir} (.next: ${fs.existsSync(path.join(prodDir, '.next'))}
|
|
54
|
+
` prod: ${prodDir} (.next: ${fs.existsSync(path.join(prodDir, '.next'))})\n` +
|
|
56
55
|
` import.meta.dirname: ${import.meta.dirname}`);
|
|
57
56
|
}
|
|
58
57
|
let WebServerService = class WebServerService {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command
|
|
3
|
+
*
|
|
4
|
+
* Runs an AI agent workflow against a repository.
|
|
5
|
+
*
|
|
6
|
+
* Usage: shep run <agent-name> [options]
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* $ shep run analyze-repository
|
|
10
|
+
* $ shep run analyze-repository --prompt "Focus on security"
|
|
11
|
+
* $ shep run analyze-repository --repo /path/to/repo
|
|
12
|
+
* $ shep run analyze-repository --stream
|
|
13
|
+
*/
|
|
14
|
+
import { Command } from 'commander';
|
|
15
|
+
/**
|
|
16
|
+
* Create the run command
|
|
17
|
+
*/
|
|
18
|
+
export declare function createRunCommand(): Command;
|
|
19
|
+
//# sourceMappingURL=run.command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.command.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/cli/commands/run.command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmCpC;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CA+B1C"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command
|
|
3
|
+
*
|
|
4
|
+
* Runs an AI agent workflow against a repository.
|
|
5
|
+
*
|
|
6
|
+
* Usage: shep run <agent-name> [options]
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* $ shep run analyze-repository
|
|
10
|
+
* $ shep run analyze-repository --prompt "Focus on security"
|
|
11
|
+
* $ shep run analyze-repository --repo /path/to/repo
|
|
12
|
+
* $ shep run analyze-repository --stream
|
|
13
|
+
*/
|
|
14
|
+
import { Command } from 'commander';
|
|
15
|
+
import { container } from '../../../infrastructure/di/container.js';
|
|
16
|
+
import { RunAgentUseCase } from '../../../application/use-cases/agents/run-agent.use-case.js';
|
|
17
|
+
import { colors, symbols, fmt, messages } from '../ui/index.js';
|
|
18
|
+
/**
|
|
19
|
+
* Creates a terminal spinner that shows progress while awaiting an async operation.
|
|
20
|
+
* Returns start/stop controls. The spinner writes to stderr to avoid polluting stdout.
|
|
21
|
+
*/
|
|
22
|
+
function createSpinner(text) {
|
|
23
|
+
const frames = symbols.spinner;
|
|
24
|
+
let frameIndex = 0;
|
|
25
|
+
let intervalId;
|
|
26
|
+
return {
|
|
27
|
+
start() {
|
|
28
|
+
process.stderr.write(`${colors.info(frames[0])} ${text}`);
|
|
29
|
+
intervalId = setInterval(() => {
|
|
30
|
+
frameIndex = (frameIndex + 1) % frames.length;
|
|
31
|
+
process.stderr.write(`\r${colors.info(frames[frameIndex])} ${text}`);
|
|
32
|
+
}, 80);
|
|
33
|
+
},
|
|
34
|
+
stop() {
|
|
35
|
+
if (intervalId)
|
|
36
|
+
clearInterval(intervalId);
|
|
37
|
+
process.stderr.write(`\r${' '.repeat(text.length + 4)}\r`);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create the run command
|
|
43
|
+
*/
|
|
44
|
+
export function createRunCommand() {
|
|
45
|
+
return new Command('run')
|
|
46
|
+
.description('Run an AI agent workflow')
|
|
47
|
+
.argument('<agent-name>', 'Name of the agent to run (e.g., analyze-repository)')
|
|
48
|
+
.option('-p, --prompt <prompt>', 'Prompt to send to the agent', 'Analyze this repository')
|
|
49
|
+
.option('-r, --repo <path>', 'Repository path (defaults to current directory)')
|
|
50
|
+
.option('-s, --stream', 'Stream output in real-time')
|
|
51
|
+
.action(async (agentName, options) => {
|
|
52
|
+
try {
|
|
53
|
+
const useCase = container.resolve(RunAgentUseCase);
|
|
54
|
+
const repoPath = options.repo ?? process.cwd();
|
|
55
|
+
messages.newline();
|
|
56
|
+
console.log(`${fmt.heading('Running agent:')} ${colors.accent(agentName)}`);
|
|
57
|
+
console.log(colors.muted(` Repository: ${repoPath}`));
|
|
58
|
+
console.log(colors.muted(` Prompt: ${options.prompt}`));
|
|
59
|
+
messages.newline();
|
|
60
|
+
if (options.stream) {
|
|
61
|
+
await runStreaming(useCase, agentName, options.prompt, repoPath);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
await runBlocking(useCase, agentName, options.prompt, repoPath);
|
|
65
|
+
}
|
|
66
|
+
messages.newline();
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
70
|
+
messages.error('Failed to run agent', err);
|
|
71
|
+
process.exitCode = 1;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/** Stream agent events to stdout in real-time. */
|
|
76
|
+
async function runStreaming(useCase, agentName, prompt, repoPath) {
|
|
77
|
+
let hasResult = false;
|
|
78
|
+
for await (const event of useCase.executeStream({
|
|
79
|
+
agentName,
|
|
80
|
+
prompt,
|
|
81
|
+
options: { repositoryPath: repoPath },
|
|
82
|
+
})) {
|
|
83
|
+
if (event.type === 'progress') {
|
|
84
|
+
process.stdout.write(event.content);
|
|
85
|
+
}
|
|
86
|
+
else if (event.type === 'result') {
|
|
87
|
+
hasResult = true;
|
|
88
|
+
messages.newline();
|
|
89
|
+
messages.success(`Agent ${agentName} completed`);
|
|
90
|
+
messages.newline();
|
|
91
|
+
console.log(fmt.heading('Result:'));
|
|
92
|
+
messages.newline();
|
|
93
|
+
console.log(event.content);
|
|
94
|
+
}
|
|
95
|
+
else if (event.type === 'error') {
|
|
96
|
+
messages.error(event.content);
|
|
97
|
+
process.exitCode = 1;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!hasResult) {
|
|
101
|
+
messages.success(`Agent ${agentName} completed`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** Run agent with spinner (blocking mode). */
|
|
105
|
+
async function runBlocking(useCase, agentName, prompt, repoPath) {
|
|
106
|
+
const spinner = createSpinner(`Agent ${agentName} is working...`);
|
|
107
|
+
spinner.start();
|
|
108
|
+
let run;
|
|
109
|
+
try {
|
|
110
|
+
run = await useCase.execute({
|
|
111
|
+
agentName,
|
|
112
|
+
prompt,
|
|
113
|
+
options: { repositoryPath: repoPath },
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
spinner.stop();
|
|
118
|
+
}
|
|
119
|
+
if (run.status === 'completed') {
|
|
120
|
+
messages.success(`Agent ${agentName} completed`);
|
|
121
|
+
messages.newline();
|
|
122
|
+
console.log(fmt.heading('Result:'));
|
|
123
|
+
messages.newline();
|
|
124
|
+
console.log(run.result ?? 'No output');
|
|
125
|
+
}
|
|
126
|
+
else if (run.status === 'failed') {
|
|
127
|
+
messages.error('Agent execution failed', new Error(run.error ?? 'Unknown error'));
|
|
128
|
+
process.exitCode = 1;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -23,6 +23,7 @@ import { Command } from 'commander';
|
|
|
23
23
|
import { createVersionCommand } from './commands/version.command.js';
|
|
24
24
|
import { createSettingsCommand } from './commands/settings/index.js';
|
|
25
25
|
import { createUiCommand } from './commands/ui.command.js';
|
|
26
|
+
import { createRunCommand } from './commands/run.command.js';
|
|
26
27
|
import { messages } from './ui/index.js';
|
|
27
28
|
// DI container and settings
|
|
28
29
|
import { initializeContainer, container } from '../../infrastructure/di/container.js';
|
|
@@ -68,6 +69,7 @@ async function bootstrap() {
|
|
|
68
69
|
program.addCommand(createVersionCommand());
|
|
69
70
|
program.addCommand(createSettingsCommand());
|
|
70
71
|
program.addCommand(createUiCommand());
|
|
72
|
+
program.addCommand(createRunCommand());
|
|
71
73
|
// Parse arguments (parseAsync needed for async command actions like init)
|
|
72
74
|
await program.parseAsync();
|
|
73
75
|
}
|
|
@@ -21,7 +21,7 @@ export declare const messages: {
|
|
|
21
21
|
/**
|
|
22
22
|
* Print error message
|
|
23
23
|
* @param text - Error message
|
|
24
|
-
* @param error - Optional error object
|
|
24
|
+
* @param error - Optional error object with details
|
|
25
25
|
* @example messages.error('Connection failed')
|
|
26
26
|
* // Output: ✗ Connection failed
|
|
27
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/cli/ui/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH;;GAEG;AACH,eAAO,MAAM,QAAQ;IACnB;;;;OAIG;6BACa,MAAM,KAAG,IAAI;IAI7B;;;;;;OAMG;2BACW,MAAM,UAAU,KAAK,KAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/cli/ui/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH;;GAEG;AACH,eAAO,MAAM,QAAQ;IACnB;;;;OAIG;6BACa,MAAM,KAAG,IAAI;IAI7B;;;;;;OAMG;2BACW,MAAM,UAAU,KAAK,KAAG,IAAI;IAY1C;;;;OAIG;6BACa,MAAM,KAAG,IAAI;IAI7B;;;;OAIG;0BACU,MAAM,KAAG,IAAI;IAI1B;;;;OAIG;2BACW,MAAM,KAAG,IAAI;IAM3B;;OAEG;4BACU,IAAI;IAIjB;;OAEG;yBACS,MAAM,KAAG,IAAI;CAGjB,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC"}
|
|
@@ -25,14 +25,20 @@ export const messages = {
|
|
|
25
25
|
/**
|
|
26
26
|
* Print error message
|
|
27
27
|
* @param text - Error message
|
|
28
|
-
* @param error - Optional error object
|
|
28
|
+
* @param error - Optional error object with details
|
|
29
29
|
* @example messages.error('Connection failed')
|
|
30
30
|
* // Output: ✗ Connection failed
|
|
31
31
|
*/
|
|
32
32
|
error: (text, error) => {
|
|
33
33
|
console.error(colors.error(`${symbols.error} ${text}`));
|
|
34
|
-
if (error
|
|
35
|
-
|
|
34
|
+
if (error) {
|
|
35
|
+
// Show full stack in debug mode, otherwise just the message
|
|
36
|
+
if (process.env.DEBUG) {
|
|
37
|
+
console.error(colors.muted(error.stack ?? error.message));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
console.error(colors.muted(error.message));
|
|
41
|
+
}
|
|
36
42
|
}
|
|
37
43
|
},
|
|
38
44
|
/**
|
|
@@ -23,7 +23,7 @@ export declare const symbols: {
|
|
|
23
23
|
/** Arrow/pointer */
|
|
24
24
|
readonly arrow: "→" | "->";
|
|
25
25
|
/** Bullet point */
|
|
26
|
-
readonly bullet: "
|
|
26
|
+
readonly bullet: "*" | "•";
|
|
27
27
|
/** Pointer right */
|
|
28
28
|
readonly pointer: "❯" | ">";
|
|
29
29
|
/** Ellipsis for loading/truncation */
|