@shepai/cli 1.8.2 → 1.9.1
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 +39 -0
- 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.map +1 -1
- package/dist/src/infrastructure/persistence/sqlite/migrations.js +27 -0
- 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/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 +11 -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/.tsbuildinfo +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/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/version.html +2 -2
- package/web/.next/server/app/version.rsc +2 -2
- package/web/.next/server/app/version.segments/_full.segment.rsc +2 -2
- 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 +2 -2
- 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/chunks/ssr/src_presentation_web_app_version_version-page-client_tsx_bd5ab0cf._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_app_version_version-page-client_tsx_bd5ab0cf._.js.map +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/static/chunks/{c004e386ce1b8d26.js → 8ec8e211eedf31cc.js} +1 -1
- package/web/.next/trace +1 -1
- package/web/.next/trace-build +1 -1
- /package/web/.next/static/{grFKAJxfDM8ro--FQzN2H → epWWK05VFCCYNcyWzkvdc}/_buildManifest.js +0 -0
- /package/web/.next/static/{grFKAJxfDM8ro--FQzN2H → epWWK05VFCCYNcyWzkvdc}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/static/{grFKAJxfDM8ro--FQzN2H → epWWK05VFCCYNcyWzkvdc}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { type BaseCheckpointSaver } from '@langchain/langgraph';
|
|
2
|
+
import type { IAgentExecutor } from '../../../../application/ports/output/agent-executor.interface.js';
|
|
3
|
+
/**
|
|
4
|
+
* State annotation for the analyze-repository graph.
|
|
5
|
+
*
|
|
6
|
+
* Uses LangGraph's Annotation API to define state channels with
|
|
7
|
+
* last-value semantics (default behavior — each update replaces the value).
|
|
8
|
+
*/
|
|
9
|
+
export declare const AnalyzeRepositoryState: import("@langchain/langgraph").AnnotationRoot<{
|
|
10
|
+
repositoryPath: {
|
|
11
|
+
(): import("@langchain/langgraph").LastValue<string>;
|
|
12
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string, string>): import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
13
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
14
|
+
};
|
|
15
|
+
analysisMarkdown: {
|
|
16
|
+
(): import("@langchain/langgraph").LastValue<string>;
|
|
17
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string, string>): import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
18
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
19
|
+
};
|
|
20
|
+
sessionId: {
|
|
21
|
+
(): import("@langchain/langgraph").LastValue<string | undefined>;
|
|
22
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string | undefined, string | undefined>): import("@langchain/langgraph").BinaryOperatorAggregate<string | undefined, string | undefined>;
|
|
23
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
24
|
+
};
|
|
25
|
+
error: {
|
|
26
|
+
(): import("@langchain/langgraph").LastValue<string | undefined>;
|
|
27
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string | undefined, string | undefined>): import("@langchain/langgraph").BinaryOperatorAggregate<string | undefined, string | undefined>;
|
|
28
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
29
|
+
};
|
|
30
|
+
}>;
|
|
31
|
+
export type AnalyzeRepositoryStateType = typeof AnalyzeRepositoryState.State;
|
|
32
|
+
/**
|
|
33
|
+
* Factory function that creates and compiles the analyze-repository LangGraph.
|
|
34
|
+
*
|
|
35
|
+
* The graph has a single node (`analyze`) that calls the provided IAgentExecutor
|
|
36
|
+
* to generate a repository analysis document. An optional checkpointer enables
|
|
37
|
+
* persistence of graph state across invocations.
|
|
38
|
+
*
|
|
39
|
+
* @param executor - The agent executor to delegate prompt execution to
|
|
40
|
+
* @param checkpointer - Optional checkpoint saver for state persistence
|
|
41
|
+
* @returns A compiled LangGraph ready to be invoked
|
|
42
|
+
*/
|
|
43
|
+
export declare function createAnalyzeRepositoryGraph(executor: IAgentExecutor, checkpointer?: BaseCheckpointSaver): import("@langchain/langgraph").CompiledStateGraph<{
|
|
44
|
+
repositoryPath: string;
|
|
45
|
+
analysisMarkdown: string;
|
|
46
|
+
sessionId: string | undefined;
|
|
47
|
+
error: string | undefined;
|
|
48
|
+
}, {
|
|
49
|
+
repositoryPath?: string | undefined;
|
|
50
|
+
analysisMarkdown?: string | undefined;
|
|
51
|
+
sessionId?: string | undefined;
|
|
52
|
+
error?: string | undefined;
|
|
53
|
+
}, "__start__" | "analyze", {
|
|
54
|
+
repositoryPath: {
|
|
55
|
+
(): import("@langchain/langgraph").LastValue<string>;
|
|
56
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string, string>): import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
57
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
58
|
+
};
|
|
59
|
+
analysisMarkdown: {
|
|
60
|
+
(): import("@langchain/langgraph").LastValue<string>;
|
|
61
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string, string>): import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
62
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
63
|
+
};
|
|
64
|
+
sessionId: {
|
|
65
|
+
(): import("@langchain/langgraph").LastValue<string | undefined>;
|
|
66
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string | undefined, string | undefined>): import("@langchain/langgraph").BinaryOperatorAggregate<string | undefined, string | undefined>;
|
|
67
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
68
|
+
};
|
|
69
|
+
error: {
|
|
70
|
+
(): import("@langchain/langgraph").LastValue<string | undefined>;
|
|
71
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string | undefined, string | undefined>): import("@langchain/langgraph").BinaryOperatorAggregate<string | undefined, string | undefined>;
|
|
72
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
73
|
+
};
|
|
74
|
+
}, {
|
|
75
|
+
repositoryPath: {
|
|
76
|
+
(): import("@langchain/langgraph").LastValue<string>;
|
|
77
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string, string>): import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
78
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
79
|
+
};
|
|
80
|
+
analysisMarkdown: {
|
|
81
|
+
(): import("@langchain/langgraph").LastValue<string>;
|
|
82
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string, string>): import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
83
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
84
|
+
};
|
|
85
|
+
sessionId: {
|
|
86
|
+
(): import("@langchain/langgraph").LastValue<string | undefined>;
|
|
87
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string | undefined, string | undefined>): import("@langchain/langgraph").BinaryOperatorAggregate<string | undefined, string | undefined>;
|
|
88
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
89
|
+
};
|
|
90
|
+
error: {
|
|
91
|
+
(): import("@langchain/langgraph").LastValue<string | undefined>;
|
|
92
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string | undefined, string | undefined>): import("@langchain/langgraph").BinaryOperatorAggregate<string | undefined, string | undefined>;
|
|
93
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
94
|
+
};
|
|
95
|
+
}, import("@langchain/langgraph").StateDefinition, {
|
|
96
|
+
analyze: Partial<import("@langchain/langgraph").StateType<{
|
|
97
|
+
repositoryPath: {
|
|
98
|
+
(): import("@langchain/langgraph").LastValue<string>;
|
|
99
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string, string>): import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
100
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
101
|
+
};
|
|
102
|
+
analysisMarkdown: {
|
|
103
|
+
(): import("@langchain/langgraph").LastValue<string>;
|
|
104
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string, string>): import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
105
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
106
|
+
};
|
|
107
|
+
sessionId: {
|
|
108
|
+
(): import("@langchain/langgraph").LastValue<string | undefined>;
|
|
109
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string | undefined, string | undefined>): import("@langchain/langgraph").BinaryOperatorAggregate<string | undefined, string | undefined>;
|
|
110
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
111
|
+
};
|
|
112
|
+
error: {
|
|
113
|
+
(): import("@langchain/langgraph").LastValue<string | undefined>;
|
|
114
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string | undefined, string | undefined>): import("@langchain/langgraph").BinaryOperatorAggregate<string | undefined, string | undefined>;
|
|
115
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
116
|
+
};
|
|
117
|
+
}>>;
|
|
118
|
+
}, unknown, unknown>;
|
|
119
|
+
//# sourceMappingURL=analyze-repository-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze-repository-graph.d.ts","sourceRoot":"","sources":["../../../../../../src/infrastructure/services/agents/langgraph/analyze-repository-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AAI7F;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;EAKjC,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,OAAO,sBAAsB,CAAC,KAAK,CAAC;AA+B7E;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,cAAc,EACxB,YAAY,CAAC,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAQnC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Annotation, StateGraph, START, END } from '@langchain/langgraph';
|
|
2
|
+
import { AgentFeature } from '../../../../domain/generated/output.js';
|
|
3
|
+
import { buildAnalyzePrompt } from './prompts/analyze-repository.prompt.js';
|
|
4
|
+
/**
|
|
5
|
+
* State annotation for the analyze-repository graph.
|
|
6
|
+
*
|
|
7
|
+
* Uses LangGraph's Annotation API to define state channels with
|
|
8
|
+
* last-value semantics (default behavior — each update replaces the value).
|
|
9
|
+
*/
|
|
10
|
+
export const AnalyzeRepositoryState = Annotation.Root({
|
|
11
|
+
repositoryPath: (Annotation),
|
|
12
|
+
analysisMarkdown: (Annotation),
|
|
13
|
+
sessionId: (Annotation),
|
|
14
|
+
error: (Annotation),
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Creates the analyze node function that calls the agent-agnostic executor.
|
|
18
|
+
*
|
|
19
|
+
* The node receives the current state, builds a prompt from the repository path,
|
|
20
|
+
* and delegates execution to the injected IAgentExecutor. Session resume is
|
|
21
|
+
* attempted if the executor supports it and a sessionId exists in state.
|
|
22
|
+
*/
|
|
23
|
+
function createAnalyzeNode(executor) {
|
|
24
|
+
return async (state) => {
|
|
25
|
+
const prompt = buildAnalyzePrompt(state.repositoryPath);
|
|
26
|
+
const options = {
|
|
27
|
+
cwd: state.repositoryPath,
|
|
28
|
+
};
|
|
29
|
+
if (state.sessionId && executor.supportsFeature(AgentFeature.sessionResume)) {
|
|
30
|
+
options.resumeSession = state.sessionId;
|
|
31
|
+
}
|
|
32
|
+
const result = await executor.execute(prompt, options);
|
|
33
|
+
return {
|
|
34
|
+
analysisMarkdown: result.result,
|
|
35
|
+
sessionId: result.sessionId ?? state.sessionId,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Factory function that creates and compiles the analyze-repository LangGraph.
|
|
41
|
+
*
|
|
42
|
+
* The graph has a single node (`analyze`) that calls the provided IAgentExecutor
|
|
43
|
+
* to generate a repository analysis document. An optional checkpointer enables
|
|
44
|
+
* persistence of graph state across invocations.
|
|
45
|
+
*
|
|
46
|
+
* @param executor - The agent executor to delegate prompt execution to
|
|
47
|
+
* @param checkpointer - Optional checkpoint saver for state persistence
|
|
48
|
+
* @returns A compiled LangGraph ready to be invoked
|
|
49
|
+
*/
|
|
50
|
+
export function createAnalyzeRepositoryGraph(executor, checkpointer) {
|
|
51
|
+
const graph = new StateGraph(AnalyzeRepositoryState)
|
|
52
|
+
.addNode('analyze', createAnalyzeNode(executor))
|
|
53
|
+
.addEdge(START, 'analyze')
|
|
54
|
+
.addEdge('analyze', END);
|
|
55
|
+
return graph.compile({ checkpointer });
|
|
56
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SqliteSaver } from '@langchain/langgraph-checkpoint-sqlite';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a SQLite-backed checkpoint saver for LangGraph state persistence.
|
|
4
|
+
*
|
|
5
|
+
* @param dbPath - Path to the SQLite database file (e.g., ':memory:' or a file path)
|
|
6
|
+
* @returns A SqliteSaver instance ready for use as a LangGraph checkpointer
|
|
7
|
+
*/
|
|
8
|
+
export declare function createCheckpointer(dbPath: string): SqliteSaver;
|
|
9
|
+
//# sourceMappingURL=checkpointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpointer.d.ts","sourceRoot":"","sources":["../../../../../../src/infrastructure/services/agents/langgraph/checkpointer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAErE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAE9D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SqliteSaver } from '@langchain/langgraph-checkpoint-sqlite';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a SQLite-backed checkpoint saver for LangGraph state persistence.
|
|
4
|
+
*
|
|
5
|
+
* @param dbPath - Path to the SQLite database file (e.g., ':memory:' or a file path)
|
|
6
|
+
* @returns A SqliteSaver instance ready for use as a LangGraph checkpointer
|
|
7
|
+
*/
|
|
8
|
+
export function createCheckpointer(dbPath) {
|
|
9
|
+
return SqliteSaver.fromConnString(dbPath);
|
|
10
|
+
}
|
package/dist/src/infrastructure/services/agents/langgraph/prompts/analyze-repository.prompt.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const ANALYZE_REPOSITORY_PROMPT = "You are analyzing a software repository.\nExamine the codebase structure, dependencies, architecture patterns, and conventions.\nGenerate a comprehensive analysis document in Markdown format.\n\nRepository path: {{repositoryPath}}\n\nYour analysis should include:\n1. Project overview and purpose\n2. Technology stack and dependencies\n3. Architecture patterns and code organization\n4. Key conventions and patterns\n5. Build system and development workflow\n6. Testing strategy\n\nOutput a complete shep-analysis.md document.";
|
|
2
|
+
export declare function buildAnalyzePrompt(repositoryPath: string): string;
|
|
3
|
+
//# sourceMappingURL=analyze-repository.prompt.d.ts.map
|
package/dist/src/infrastructure/services/agents/langgraph/prompts/analyze-repository.prompt.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze-repository.prompt.d.ts","sourceRoot":"","sources":["../../../../../../../src/infrastructure/services/agents/langgraph/prompts/analyze-repository.prompt.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,mhBAcO,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAEjE"}
|
package/dist/src/infrastructure/services/agents/langgraph/prompts/analyze-repository.prompt.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const ANALYZE_REPOSITORY_PROMPT = `You are analyzing a software repository.
|
|
2
|
+
Examine the codebase structure, dependencies, architecture patterns, and conventions.
|
|
3
|
+
Generate a comprehensive analysis document in Markdown format.
|
|
4
|
+
|
|
5
|
+
Repository path: {{repositoryPath}}
|
|
6
|
+
|
|
7
|
+
Your analysis should include:
|
|
8
|
+
1. Project overview and purpose
|
|
9
|
+
2. Technology stack and dependencies
|
|
10
|
+
3. Architecture patterns and code organization
|
|
11
|
+
4. Key conventions and patterns
|
|
12
|
+
5. Build system and development workflow
|
|
13
|
+
6. Testing strategy
|
|
14
|
+
|
|
15
|
+
Output a complete shep-analysis.md document.`;
|
|
16
|
+
export function buildAnalyzePrompt(repositoryPath) {
|
|
17
|
+
return ANALYZE_REPOSITORY_PROMPT.replace('{{repositoryPath}}', repositoryPath);
|
|
18
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventChannel - Generic Async Push/Pull Queue
|
|
3
|
+
*
|
|
4
|
+
* Bridges event producers (push) and async iteration consumers (for-await-of).
|
|
5
|
+
* Used by the streaming infrastructure to forward agent execution events
|
|
6
|
+
* from the StreamingExecutorProxy to the AgentRunnerService caller.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const channel = new EventChannel<string>();
|
|
11
|
+
*
|
|
12
|
+
* // Producer side
|
|
13
|
+
* channel.push('progress update');
|
|
14
|
+
* channel.push('done');
|
|
15
|
+
* channel.close();
|
|
16
|
+
*
|
|
17
|
+
* // Consumer side
|
|
18
|
+
* for await (const event of channel) {
|
|
19
|
+
* console.log(event);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class EventChannel<T> implements AsyncIterable<T> {
|
|
24
|
+
private queue;
|
|
25
|
+
private closed;
|
|
26
|
+
private resolve;
|
|
27
|
+
/**
|
|
28
|
+
* Push an event into the channel.
|
|
29
|
+
* Ignored if the channel is already closed.
|
|
30
|
+
*/
|
|
31
|
+
push(event: T): void;
|
|
32
|
+
/**
|
|
33
|
+
* Close the channel, signaling no more events will be pushed.
|
|
34
|
+
* Safe to call multiple times.
|
|
35
|
+
*/
|
|
36
|
+
close(): void;
|
|
37
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=event-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-channel.d.ts","sourceRoot":"","sources":["../../../../../../src/infrastructure/services/agents/streaming/event-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,YAAY,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IACtD,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAA6B;IAE5C;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IASpB;;;OAGG;IACH,KAAK,IAAI,IAAI;IAQN,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;CAYlD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventChannel - Generic Async Push/Pull Queue
|
|
3
|
+
*
|
|
4
|
+
* Bridges event producers (push) and async iteration consumers (for-await-of).
|
|
5
|
+
* Used by the streaming infrastructure to forward agent execution events
|
|
6
|
+
* from the StreamingExecutorProxy to the AgentRunnerService caller.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const channel = new EventChannel<string>();
|
|
11
|
+
*
|
|
12
|
+
* // Producer side
|
|
13
|
+
* channel.push('progress update');
|
|
14
|
+
* channel.push('done');
|
|
15
|
+
* channel.close();
|
|
16
|
+
*
|
|
17
|
+
* // Consumer side
|
|
18
|
+
* for await (const event of channel) {
|
|
19
|
+
* console.log(event);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export class EventChannel {
|
|
24
|
+
queue = [];
|
|
25
|
+
closed = false;
|
|
26
|
+
resolve = null;
|
|
27
|
+
/**
|
|
28
|
+
* Push an event into the channel.
|
|
29
|
+
* Ignored if the channel is already closed.
|
|
30
|
+
*/
|
|
31
|
+
push(event) {
|
|
32
|
+
if (this.closed)
|
|
33
|
+
return;
|
|
34
|
+
this.queue.push(event);
|
|
35
|
+
if (this.resolve) {
|
|
36
|
+
this.resolve();
|
|
37
|
+
this.resolve = null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Close the channel, signaling no more events will be pushed.
|
|
42
|
+
* Safe to call multiple times.
|
|
43
|
+
*/
|
|
44
|
+
close() {
|
|
45
|
+
this.closed = true;
|
|
46
|
+
if (this.resolve) {
|
|
47
|
+
this.resolve();
|
|
48
|
+
this.resolve = null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async *[Symbol.asyncIterator]() {
|
|
52
|
+
while (true) {
|
|
53
|
+
if (this.queue.length > 0) {
|
|
54
|
+
yield this.queue.shift();
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (this.closed)
|
|
58
|
+
return;
|
|
59
|
+
await new Promise((r) => {
|
|
60
|
+
this.resolve = r;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Streaming Module
|
|
3
|
+
*
|
|
4
|
+
* Provides the streaming infrastructure for transparent real-time
|
|
5
|
+
* event delivery from agent executors through the graph pipeline.
|
|
6
|
+
*/
|
|
7
|
+
export { EventChannel } from './event-channel.js';
|
|
8
|
+
export { StreamingExecutorProxy } from './streaming-executor-proxy.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/infrastructure/services/agents/streaming/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Streaming Module
|
|
3
|
+
*
|
|
4
|
+
* Provides the streaming infrastructure for transparent real-time
|
|
5
|
+
* event delivery from agent executors through the graph pipeline.
|
|
6
|
+
*/
|
|
7
|
+
export { EventChannel } from './event-channel.js';
|
|
8
|
+
export { StreamingExecutorProxy } from './streaming-executor-proxy.js';
|
|
@@ -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
|
+
}
|
|
@@ -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"}
|