sessioncast-cli 2.0.2 → 2.0.3
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/agent/runner.js +23 -0
- package/dist/agent/session-handler.d.ts +1 -2
- package/dist/agent/session-handler.js +34 -79
- package/dist/agent/tmux-executor.d.ts +3 -33
- package/dist/agent/tmux-executor.js +3 -50
- package/dist/agent/tmux.d.ts +2 -6
- package/dist/agent/tmux.js +2 -9
- package/dist/agent/types.d.ts +0 -10
- package/dist/agent/websocket.d.ts +2 -21
- package/dist/agent/websocket.js +10 -46
- package/dist/commands/agent.js +3 -0
- package/dist/index.js +14 -0
- package/dist/sentry.d.ts +4 -0
- package/dist/sentry.js +87 -0
- package/package.json +2 -1
- package/dist/autopilot/index.d.ts +0 -94
- package/dist/autopilot/index.js +0 -322
- package/dist/autopilot/mission-analyzer.d.ts +0 -27
- package/dist/autopilot/mission-analyzer.js +0 -232
- package/dist/autopilot/project-detector.d.ts +0 -12
- package/dist/autopilot/project-detector.js +0 -326
- package/dist/autopilot/source-scanner.d.ts +0 -26
- package/dist/autopilot/source-scanner.js +0 -285
- package/dist/autopilot/speckit-generator.d.ts +0 -60
- package/dist/autopilot/speckit-generator.js +0 -511
- package/dist/autopilot/types.d.ts +0 -110
- package/dist/autopilot/types.js +0 -6
- package/dist/autopilot/workflow-generator.d.ts +0 -33
- package/dist/autopilot/workflow-generator.js +0 -278
- package/dist/commands/autopilot.d.ts +0 -30
- package/dist/commands/autopilot.js +0 -262
- package/dist/commands/project.d.ts +0 -33
- package/dist/commands/project.js +0 -350
- package/dist/project/executor.d.ts +0 -73
- package/dist/project/executor.js +0 -437
- package/dist/project/index.d.ts +0 -4
- package/dist/project/index.js +0 -20
- package/dist/project/manager.d.ts +0 -66
- package/dist/project/manager.js +0 -290
- package/dist/project/relay-client.d.ts +0 -37
- package/dist/project/relay-client.js +0 -204
- package/dist/project/types.d.ts +0 -48
- package/dist/project/types.js +0 -3
- package/dist/utils/fileUtils.d.ts +0 -28
- package/dist/utils/fileUtils.js +0 -159
package/dist/sentry.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.initSentry = initSentry;
|
|
37
|
+
exports.captureException = captureException;
|
|
38
|
+
exports.setUser = setUser;
|
|
39
|
+
exports.flush = flush;
|
|
40
|
+
const Sentry = __importStar(require("@sentry/node"));
|
|
41
|
+
const os = __importStar(require("os"));
|
|
42
|
+
const SENTRY_DSN = process.env.SESSIONCAST_SENTRY_DSN || 'https://ee8894c0f54e651031b49f21a5bf8dc4@o4510832077701120.ingest.us.sentry.io/4510861067681792';
|
|
43
|
+
let initialized = false;
|
|
44
|
+
function initSentry() {
|
|
45
|
+
if (initialized || !SENTRY_DSN)
|
|
46
|
+
return;
|
|
47
|
+
Sentry.init({
|
|
48
|
+
dsn: SENTRY_DSN,
|
|
49
|
+
environment: process.env.NODE_ENV || 'production',
|
|
50
|
+
release: `sessioncast-cli@${getVersion()}`,
|
|
51
|
+
beforeSend(event) {
|
|
52
|
+
// Strip sensitive data: tokens, paths with usernames
|
|
53
|
+
if (event.extra) {
|
|
54
|
+
delete event.extra['token'];
|
|
55
|
+
delete event.extra['apiKey'];
|
|
56
|
+
}
|
|
57
|
+
return event;
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
Sentry.setTag('platform', os.platform());
|
|
61
|
+
Sentry.setTag('arch', os.arch());
|
|
62
|
+
Sentry.setTag('node', process.version);
|
|
63
|
+
initialized = true;
|
|
64
|
+
}
|
|
65
|
+
function captureException(error) {
|
|
66
|
+
if (!initialized)
|
|
67
|
+
return;
|
|
68
|
+
Sentry.captureException(error);
|
|
69
|
+
}
|
|
70
|
+
function setUser(email) {
|
|
71
|
+
if (!initialized)
|
|
72
|
+
return;
|
|
73
|
+
Sentry.setUser({ email });
|
|
74
|
+
}
|
|
75
|
+
async function flush() {
|
|
76
|
+
if (!initialized)
|
|
77
|
+
return;
|
|
78
|
+
await Sentry.flush(2000);
|
|
79
|
+
}
|
|
80
|
+
function getVersion() {
|
|
81
|
+
try {
|
|
82
|
+
return require('../package.json').version;
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return 'unknown';
|
|
86
|
+
}
|
|
87
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sessioncast-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "SessionCast CLI - Control your agents from anywhere",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@sentry/node": "^10.38.0",
|
|
29
30
|
"chalk": "^4.1.2",
|
|
30
31
|
"commander": "^12.1.0",
|
|
31
32
|
"conf": "^10.2.0",
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AutoPilot - Single-prompt execution layer for SessionCast
|
|
3
|
-
*
|
|
4
|
-
* Enables opencode-style experience: one prompt → auto-detect → auto-analyze → auto-execute
|
|
5
|
-
*/
|
|
6
|
-
import { EventEmitter } from 'events';
|
|
7
|
-
import { AutoPilotContext, AutoPilotOptions, GeneratedWorkflow } from './types';
|
|
8
|
-
import { toExecutableWorkflow } from './workflow-generator';
|
|
9
|
-
import { generateSpeckit } from './speckit-generator';
|
|
10
|
-
export * from './types';
|
|
11
|
-
export { generateSpeckit, generateQuickSpeckit, saveSpeckit } from './speckit-generator';
|
|
12
|
-
export type { SpeckitOutput } from './speckit-generator';
|
|
13
|
-
export declare class AutoPilot extends EventEmitter {
|
|
14
|
-
private options;
|
|
15
|
-
private context;
|
|
16
|
-
private llmClient?;
|
|
17
|
-
constructor(options: AutoPilotOptions);
|
|
18
|
-
/**
|
|
19
|
-
* Create initial context
|
|
20
|
-
*/
|
|
21
|
-
private createInitialContext;
|
|
22
|
-
/**
|
|
23
|
-
* Set LLM client for mission analysis
|
|
24
|
-
*/
|
|
25
|
-
setLlmClient(client: {
|
|
26
|
-
chat: (messages: {
|
|
27
|
-
role: string;
|
|
28
|
-
content: string;
|
|
29
|
-
}[]) => Promise<string>;
|
|
30
|
-
}): void;
|
|
31
|
-
/**
|
|
32
|
-
* Get current context
|
|
33
|
-
*/
|
|
34
|
-
getContext(): AutoPilotContext;
|
|
35
|
-
/**
|
|
36
|
-
* Main entry point: execute a single prompt
|
|
37
|
-
*/
|
|
38
|
-
execute(prompt: string): Promise<GeneratedWorkflow>;
|
|
39
|
-
/**
|
|
40
|
-
* Quick execute without LLM analysis
|
|
41
|
-
*/
|
|
42
|
-
quickExecute(prompt: string): Promise<GeneratedWorkflow>;
|
|
43
|
-
/**
|
|
44
|
-
* Phase 1: Detect project type
|
|
45
|
-
*/
|
|
46
|
-
private detectProject;
|
|
47
|
-
/**
|
|
48
|
-
* Phase 2: Scan sources
|
|
49
|
-
*/
|
|
50
|
-
private scanProject;
|
|
51
|
-
/**
|
|
52
|
-
* Phase 3: Analyze mission
|
|
53
|
-
*/
|
|
54
|
-
private analyzeMission;
|
|
55
|
-
/**
|
|
56
|
-
* Phase 4: Generate workflow
|
|
57
|
-
*/
|
|
58
|
-
private generateWorkflow;
|
|
59
|
-
/**
|
|
60
|
-
* Convert to executable workflow format (compatible with existing ProjectManager)
|
|
61
|
-
*/
|
|
62
|
-
toExecutableFormat(): ReturnType<typeof toExecutableWorkflow> | null;
|
|
63
|
-
/**
|
|
64
|
-
* Convert to Speckit format (plan.md + tasks.md)
|
|
65
|
-
*/
|
|
66
|
-
toSpeckit(): ReturnType<typeof generateSpeckit>;
|
|
67
|
-
/**
|
|
68
|
-
* Generate and save Speckit files
|
|
69
|
-
*/
|
|
70
|
-
saveSpeckit(outputDir?: string): {
|
|
71
|
-
planPath: string;
|
|
72
|
-
tasksPath: string;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Update status and emit event
|
|
76
|
-
*/
|
|
77
|
-
private updateStatus;
|
|
78
|
-
/**
|
|
79
|
-
* Get a summary of the analysis for display
|
|
80
|
-
*/
|
|
81
|
-
getSummary(): string;
|
|
82
|
-
/**
|
|
83
|
-
* Save workflow to file
|
|
84
|
-
*/
|
|
85
|
-
saveWorkflow(outputPath?: string): Promise<string>;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Convenience function for one-shot execution
|
|
89
|
-
*/
|
|
90
|
-
export declare function autoPilot(prompt: string, options: AutoPilotOptions): Promise<GeneratedWorkflow>;
|
|
91
|
-
/**
|
|
92
|
-
* Quick version without LLM
|
|
93
|
-
*/
|
|
94
|
-
export declare function autoPilotQuick(prompt: string, options: AutoPilotOptions): Promise<GeneratedWorkflow>;
|
package/dist/autopilot/index.js
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* AutoPilot - Single-prompt execution layer for SessionCast
|
|
4
|
-
*
|
|
5
|
-
* Enables opencode-style experience: one prompt → auto-detect → auto-analyze → auto-execute
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
41
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.AutoPilot = exports.saveSpeckit = exports.generateQuickSpeckit = exports.generateSpeckit = void 0;
|
|
45
|
-
exports.autoPilot = autoPilot;
|
|
46
|
-
exports.autoPilotQuick = autoPilotQuick;
|
|
47
|
-
const path = __importStar(require("path"));
|
|
48
|
-
const fs = __importStar(require("fs"));
|
|
49
|
-
const events_1 = require("events");
|
|
50
|
-
const project_detector_1 = require("./project-detector");
|
|
51
|
-
const source_scanner_1 = require("./source-scanner");
|
|
52
|
-
const mission_analyzer_1 = require("./mission-analyzer");
|
|
53
|
-
const workflow_generator_1 = require("./workflow-generator");
|
|
54
|
-
const speckit_generator_1 = require("./speckit-generator");
|
|
55
|
-
// Re-export types
|
|
56
|
-
__exportStar(require("./types"), exports);
|
|
57
|
-
// Re-export Speckit functions
|
|
58
|
-
var speckit_generator_2 = require("./speckit-generator");
|
|
59
|
-
Object.defineProperty(exports, "generateSpeckit", { enumerable: true, get: function () { return speckit_generator_2.generateSpeckit; } });
|
|
60
|
-
Object.defineProperty(exports, "generateQuickSpeckit", { enumerable: true, get: function () { return speckit_generator_2.generateQuickSpeckit; } });
|
|
61
|
-
Object.defineProperty(exports, "saveSpeckit", { enumerable: true, get: function () { return speckit_generator_2.saveSpeckit; } });
|
|
62
|
-
class AutoPilot extends events_1.EventEmitter {
|
|
63
|
-
constructor(options) {
|
|
64
|
-
super();
|
|
65
|
-
this.options = options;
|
|
66
|
-
this.context = this.createInitialContext(options);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Create initial context
|
|
70
|
-
*/
|
|
71
|
-
createInitialContext(options) {
|
|
72
|
-
return {
|
|
73
|
-
prompt: '',
|
|
74
|
-
workingDir: options.workingDir,
|
|
75
|
-
projectType: 'unknown',
|
|
76
|
-
projectName: path.basename(options.workingDir),
|
|
77
|
-
sources: [],
|
|
78
|
-
projectStructure: '',
|
|
79
|
-
mission: '',
|
|
80
|
-
status: 'idle'
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Set LLM client for mission analysis
|
|
85
|
-
*/
|
|
86
|
-
setLlmClient(client) {
|
|
87
|
-
this.llmClient = client;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Get current context
|
|
91
|
-
*/
|
|
92
|
-
getContext() {
|
|
93
|
-
return { ...this.context };
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Main entry point: execute a single prompt
|
|
97
|
-
*/
|
|
98
|
-
async execute(prompt) {
|
|
99
|
-
this.context.prompt = prompt;
|
|
100
|
-
this.context.mission = prompt;
|
|
101
|
-
try {
|
|
102
|
-
// Phase 1: Detect project type
|
|
103
|
-
await this.detectProject();
|
|
104
|
-
// Phase 2: Scan sources
|
|
105
|
-
await this.scanProject();
|
|
106
|
-
// Phase 3: Analyze mission
|
|
107
|
-
await this.analyzeMission();
|
|
108
|
-
// Phase 4: Generate workflow
|
|
109
|
-
const workflow = await this.generateWorkflow();
|
|
110
|
-
this.updateStatus('ready');
|
|
111
|
-
return workflow;
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
this.context.error = error instanceof Error ? error.message : 'Unknown error';
|
|
115
|
-
this.updateStatus('error');
|
|
116
|
-
throw error;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Quick execute without LLM analysis
|
|
121
|
-
*/
|
|
122
|
-
async quickExecute(prompt) {
|
|
123
|
-
this.context.prompt = prompt;
|
|
124
|
-
this.context.mission = prompt;
|
|
125
|
-
try {
|
|
126
|
-
// Phase 1: Detect project type
|
|
127
|
-
await this.detectProject();
|
|
128
|
-
// Phase 2: Generate simple workflow
|
|
129
|
-
const workflow = (0, workflow_generator_1.createQuickWorkflow)(prompt, {
|
|
130
|
-
projectType: this.context.projectType,
|
|
131
|
-
projectName: this.context.projectName,
|
|
132
|
-
workingDir: this.context.workingDir
|
|
133
|
-
});
|
|
134
|
-
this.context.workflow = workflow;
|
|
135
|
-
this.updateStatus('ready');
|
|
136
|
-
return workflow;
|
|
137
|
-
}
|
|
138
|
-
catch (error) {
|
|
139
|
-
this.context.error = error instanceof Error ? error.message : 'Unknown error';
|
|
140
|
-
this.updateStatus('error');
|
|
141
|
-
throw error;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Phase 1: Detect project type
|
|
146
|
-
*/
|
|
147
|
-
async detectProject() {
|
|
148
|
-
this.updateStatus('detecting');
|
|
149
|
-
this.emit('phase', 'detecting', 'Detecting project type...');
|
|
150
|
-
const detection = await (0, project_detector_1.detectProjectType)(this.context.workingDir);
|
|
151
|
-
this.context.projectType = detection.type;
|
|
152
|
-
this.context.projectName = detection.name;
|
|
153
|
-
if (this.options.verbose) {
|
|
154
|
-
console.log(` Project: ${detection.name}`);
|
|
155
|
-
console.log(` Type: ${detection.type} (${(detection.confidence * 100).toFixed(0)}% confidence)`);
|
|
156
|
-
console.log(` Language: ${detection.mainLanguage || 'unknown'}`);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Phase 2: Scan sources
|
|
161
|
-
*/
|
|
162
|
-
async scanProject() {
|
|
163
|
-
this.updateStatus('scanning');
|
|
164
|
-
this.emit('phase', 'scanning', 'Scanning source files...');
|
|
165
|
-
// Get project structure
|
|
166
|
-
this.context.projectStructure = (0, project_detector_1.getProjectStructure)(this.context.workingDir);
|
|
167
|
-
// Scan source files
|
|
168
|
-
this.context.sources = await (0, source_scanner_1.scanSources)(this.context.workingDir, this.context.projectType, { maxFiles: 50, maxFileSize: 100 * 1024 });
|
|
169
|
-
if (this.options.verbose) {
|
|
170
|
-
console.log(` Found ${this.context.sources.length} relevant source files`);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Phase 3: Analyze mission
|
|
175
|
-
*/
|
|
176
|
-
async analyzeMission() {
|
|
177
|
-
this.updateStatus('analyzing');
|
|
178
|
-
this.emit('phase', 'analyzing', 'Analyzing mission...');
|
|
179
|
-
const analyzerContext = {
|
|
180
|
-
projectType: this.context.projectType,
|
|
181
|
-
projectName: this.context.projectName,
|
|
182
|
-
projectStructure: this.context.projectStructure,
|
|
183
|
-
sources: this.context.sources,
|
|
184
|
-
keyFilesContent: (0, source_scanner_1.getKeyFilesContent)(this.context.sources)
|
|
185
|
-
};
|
|
186
|
-
if (this.llmClient) {
|
|
187
|
-
// Full LLM-powered analysis
|
|
188
|
-
this.context.analysis = await (0, mission_analyzer_1.analyzeMission)(this.context.prompt, analyzerContext, this.llmClient);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
// Quick heuristic analysis
|
|
192
|
-
this.context.analysis = (0, mission_analyzer_1.analyzeQuick)(this.context.prompt, analyzerContext);
|
|
193
|
-
}
|
|
194
|
-
if (this.options.verbose && this.context.analysis) {
|
|
195
|
-
console.log(` Complexity: ${this.context.analysis.complexity}`);
|
|
196
|
-
console.log(` Steps: ${this.context.analysis.steps.length}`);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Phase 4: Generate workflow
|
|
201
|
-
*/
|
|
202
|
-
async generateWorkflow() {
|
|
203
|
-
this.updateStatus('generating');
|
|
204
|
-
this.emit('phase', 'generating', 'Generating workflow...');
|
|
205
|
-
if (!this.context.analysis) {
|
|
206
|
-
// Fallback: create simple workflow
|
|
207
|
-
return (0, workflow_generator_1.createQuickWorkflow)(this.context.prompt, {
|
|
208
|
-
projectType: this.context.projectType,
|
|
209
|
-
projectName: this.context.projectName,
|
|
210
|
-
workingDir: this.context.workingDir
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
const workflow = (0, workflow_generator_1.generateWorkflow)(this.context.analysis, {
|
|
214
|
-
projectType: this.context.projectType,
|
|
215
|
-
projectName: this.context.projectName,
|
|
216
|
-
workingDir: this.context.workingDir
|
|
217
|
-
});
|
|
218
|
-
this.context.workflow = workflow;
|
|
219
|
-
if (this.options.verbose) {
|
|
220
|
-
console.log(` Workflow: ${workflow.name}`);
|
|
221
|
-
console.log(` Agents: ${workflow.agents.length}`);
|
|
222
|
-
console.log(` Steps: ${workflow.steps.length}`);
|
|
223
|
-
}
|
|
224
|
-
return workflow;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Convert to executable workflow format (compatible with existing ProjectManager)
|
|
228
|
-
*/
|
|
229
|
-
toExecutableFormat() {
|
|
230
|
-
if (!this.context.workflow)
|
|
231
|
-
return null;
|
|
232
|
-
return (0, workflow_generator_1.toExecutableWorkflow)(this.context.workflow);
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Convert to Speckit format (plan.md + tasks.md)
|
|
236
|
-
*/
|
|
237
|
-
toSpeckit() {
|
|
238
|
-
return (0, speckit_generator_1.generateSpeckit)(this.context);
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Generate and save Speckit files
|
|
242
|
-
*/
|
|
243
|
-
saveSpeckit(outputDir) {
|
|
244
|
-
const speckit = this.toSpeckit();
|
|
245
|
-
if (outputDir) {
|
|
246
|
-
speckit.outputDir = outputDir;
|
|
247
|
-
}
|
|
248
|
-
return (0, speckit_generator_1.saveSpeckit)(speckit);
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Update status and emit event
|
|
252
|
-
*/
|
|
253
|
-
updateStatus(status, message) {
|
|
254
|
-
this.context.status = status;
|
|
255
|
-
this.emit('status', status, message);
|
|
256
|
-
if (this.options.verbose) {
|
|
257
|
-
console.log(`[AutoPilot] ${status}${message ? ': ' + message : ''}`);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Get a summary of the analysis for display
|
|
262
|
-
*/
|
|
263
|
-
getSummary() {
|
|
264
|
-
const lines = [];
|
|
265
|
-
lines.push(`Project: ${this.context.projectName} (${this.context.projectType})`);
|
|
266
|
-
lines.push(`Mission: ${this.context.mission}`);
|
|
267
|
-
if (this.context.analysis) {
|
|
268
|
-
lines.push(`Complexity: ${this.context.analysis.complexity}`);
|
|
269
|
-
lines.push(`\nSteps:`);
|
|
270
|
-
for (let i = 0; i < this.context.analysis.steps.length; i++) {
|
|
271
|
-
const step = this.context.analysis.steps[i];
|
|
272
|
-
lines.push(` ${i + 1}. ${step.name} [${step.type}]`);
|
|
273
|
-
if (step.dependsOn?.length) {
|
|
274
|
-
lines.push(` depends on: ${step.dependsOn.join(', ')}`);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (this.context.workflow) {
|
|
279
|
-
lines.push(`\nWorkflow: ${this.context.workflow.name}`);
|
|
280
|
-
lines.push(`Agents:`);
|
|
281
|
-
for (const agent of this.context.workflow.agents) {
|
|
282
|
-
lines.push(` - ${agent.name} (${agent.id})`);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return lines.join('\n');
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Save workflow to file
|
|
289
|
-
*/
|
|
290
|
-
async saveWorkflow(outputPath) {
|
|
291
|
-
if (!this.context.workflow) {
|
|
292
|
-
throw new Error('No workflow generated yet');
|
|
293
|
-
}
|
|
294
|
-
const workflow = this.toExecutableFormat();
|
|
295
|
-
if (!workflow) {
|
|
296
|
-
throw new Error('Failed to convert workflow');
|
|
297
|
-
}
|
|
298
|
-
const filePath = outputPath || path.join(this.context.workingDir, '.sessioncast', 'workflows', `${workflow.name}.json`);
|
|
299
|
-
// Ensure directory exists
|
|
300
|
-
const dir = path.dirname(filePath);
|
|
301
|
-
if (!fs.existsSync(dir)) {
|
|
302
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
303
|
-
}
|
|
304
|
-
fs.writeFileSync(filePath, JSON.stringify(workflow, null, 2));
|
|
305
|
-
return filePath;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
exports.AutoPilot = AutoPilot;
|
|
309
|
-
/**
|
|
310
|
-
* Convenience function for one-shot execution
|
|
311
|
-
*/
|
|
312
|
-
async function autoPilot(prompt, options) {
|
|
313
|
-
const pilot = new AutoPilot(options);
|
|
314
|
-
return pilot.execute(prompt);
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Quick version without LLM
|
|
318
|
-
*/
|
|
319
|
-
async function autoPilotQuick(prompt, options) {
|
|
320
|
-
const pilot = new AutoPilot(options);
|
|
321
|
-
return pilot.quickExecute(prompt);
|
|
322
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MissionAnalyzer - LLM-based analysis of user prompts
|
|
3
|
-
* Breaks down a single prompt into structured workflow steps
|
|
4
|
-
*/
|
|
5
|
-
import { MissionAnalysis, ProjectType, SourceInfo } from './types';
|
|
6
|
-
interface AnalyzerContext {
|
|
7
|
-
projectType: ProjectType;
|
|
8
|
-
projectName: string;
|
|
9
|
-
projectStructure: string;
|
|
10
|
-
sources: SourceInfo[];
|
|
11
|
-
keyFilesContent?: string;
|
|
12
|
-
}
|
|
13
|
-
interface LlmClient {
|
|
14
|
-
chat: (messages: {
|
|
15
|
-
role: string;
|
|
16
|
-
content: string;
|
|
17
|
-
}[]) => Promise<string>;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Analyze user prompt and generate mission breakdown
|
|
21
|
-
*/
|
|
22
|
-
export declare function analyzeMission(prompt: string, context: AnalyzerContext, llmClient: LlmClient): Promise<MissionAnalysis>;
|
|
23
|
-
/**
|
|
24
|
-
* Analyze mission without LLM (for quick mode or when LLM is unavailable)
|
|
25
|
-
*/
|
|
26
|
-
export declare function analyzeQuick(prompt: string, context: AnalyzerContext): MissionAnalysis;
|
|
27
|
-
export {};
|