smart-spec-kit-mcp 2.0.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.
Files changed (51) hide show
  1. package/README.md +262 -0
  2. package/dist/engine/sessionManager.d.ts +137 -0
  3. package/dist/engine/sessionManager.d.ts.map +1 -0
  4. package/dist/engine/sessionManager.js +128 -0
  5. package/dist/engine/sessionManager.js.map +1 -0
  6. package/dist/engine/workflowEngine.d.ts +57 -0
  7. package/dist/engine/workflowEngine.d.ts.map +1 -0
  8. package/dist/engine/workflowEngine.js +400 -0
  9. package/dist/engine/workflowEngine.js.map +1 -0
  10. package/dist/index.d.ts +14 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +122 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/prompts/agents.d.ts +61 -0
  15. package/dist/prompts/agents.d.ts.map +1 -0
  16. package/dist/prompts/agents.js +236 -0
  17. package/dist/prompts/agents.js.map +1 -0
  18. package/dist/schemas/workflowSchema.d.ts +70 -0
  19. package/dist/schemas/workflowSchema.d.ts.map +1 -0
  20. package/dist/schemas/workflowSchema.js +42 -0
  21. package/dist/schemas/workflowSchema.js.map +1 -0
  22. package/dist/tools/agentTools.d.ts +11 -0
  23. package/dist/tools/agentTools.d.ts.map +1 -0
  24. package/dist/tools/agentTools.js +119 -0
  25. package/dist/tools/agentTools.js.map +1 -0
  26. package/dist/tools/orchestrationTools.d.ts +12 -0
  27. package/dist/tools/orchestrationTools.d.ts.map +1 -0
  28. package/dist/tools/orchestrationTools.js +375 -0
  29. package/dist/tools/orchestrationTools.js.map +1 -0
  30. package/dist/tools/workflowTools.d.ts +11 -0
  31. package/dist/tools/workflowTools.d.ts.map +1 -0
  32. package/dist/tools/workflowTools.js +236 -0
  33. package/dist/tools/workflowTools.js.map +1 -0
  34. package/dist/utils/markdownGenerator.d.ts +70 -0
  35. package/dist/utils/markdownGenerator.d.ts.map +1 -0
  36. package/dist/utils/markdownGenerator.js +206 -0
  37. package/dist/utils/markdownGenerator.js.map +1 -0
  38. package/dist/utils/vsCodeConfigGenerator.d.ts +32 -0
  39. package/dist/utils/vsCodeConfigGenerator.d.ts.map +1 -0
  40. package/dist/utils/vsCodeConfigGenerator.js +88 -0
  41. package/dist/utils/vsCodeConfigGenerator.js.map +1 -0
  42. package/dist/utils/workflowLoader.d.ts +99 -0
  43. package/dist/utils/workflowLoader.d.ts.map +1 -0
  44. package/dist/utils/workflowLoader.js +281 -0
  45. package/dist/utils/workflowLoader.js.map +1 -0
  46. package/package.json +61 -0
  47. package/templates/bugfix-report.md +184 -0
  48. package/templates/functional-spec.md +191 -0
  49. package/workflows/bugfix.yaml +99 -0
  50. package/workflows/feature-full.yaml +344 -0
  51. package/workflows/feature-standard.yaml +92 -0
package/README.md ADDED
@@ -0,0 +1,262 @@
1
+ # 🚀 Spec-Kit MCP Server
2
+
3
+ Plateforme d'orchestration automatisée pour transformer vos work items Azure DevOps en spécifications complètes via **GitHub Copilot**.
4
+
5
+ ## ✨ Fonctionnalités
6
+
7
+ - **🤖 Orchestration Automatisée**: Un seul prompt, Copilot fait le reste
8
+ - **🔄 Workflows YAML**: Processus personnalisables étape par étape
9
+ - **🛡️ Gouvernance Intégrée**: RGPD, Sécurité, Architecture, Design System
10
+ - **📝 Templates**: Spécifications, bugfix reports, documentation
11
+ - **🔗 Azure DevOps**: Intégration native via MCP
12
+
13
+ ---
14
+
15
+ ## ⚡ Installation Express
16
+
17
+ ### Via Slash Command (Recommandé)
18
+
19
+ Dans **GitHub Copilot Chat**:
20
+
21
+ ```text
22
+ /setupSpecKit
23
+ ```
24
+
25
+ L'assistant configure tout automatiquement selon votre environnement.
26
+
27
+ ### Via NPX (Zero Config)
28
+
29
+ Ajoutez dans VS Code `settings.json`:
30
+
31
+ ```json
32
+ {
33
+ "mcp": {
34
+ "servers": {
35
+ "spec-kit": {
36
+ "command": "npx",
37
+ "args": ["-y", "spec-kit-mcp"]
38
+ }
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ Rechargez VS Code (`Ctrl+Shift+P` → "Developer: Reload Window").
45
+
46
+ ### Installation Locale
47
+
48
+ ```bash
49
+ git clone https://github.com/your-org/spec-kit-mcp.git
50
+ cd spec-kit-mcp
51
+ npm install
52
+ npm run build
53
+ ```
54
+
55
+ ```json
56
+ {
57
+ "mcp": {
58
+ "servers": {
59
+ "spec-kit": {
60
+ "command": "node",
61
+ "args": ["/path/to/spec-kit-mcp/dist/index.js"]
62
+ }
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ ---
69
+
70
+ ## 🚀 Usage
71
+
72
+ ### Démarrer un Workflow
73
+
74
+ ```text
75
+ @spec-kit start_workflow workflow_name="feature-standard" context_id="12345"
76
+ ```
77
+
78
+ Le serveur orchestre automatiquement:
79
+
80
+ 1. Récupération du work item Azure DevOps
81
+ 2. Génération de la spécification (SpecAgent)
82
+ 3. Planification technique (PlanAgent)
83
+ 4. Validation gouvernance (GovAgent)
84
+ 5. Création des artefacts
85
+
86
+ > Validez chaque étape avec "OK" - c'est tout!
87
+
88
+ ### Workflows Disponibles
89
+
90
+ | Workflow | Description |
91
+ | ------------------ | ---------------------------------------- |
92
+ | `feature-standard` | Spécification fonctionnelle (5 étapes) |
93
+ | `feature-full` | Spec + gouvernance complète (10 étapes) |
94
+ | `bugfix` | Rapport de correction de bug (5 étapes) |
95
+
96
+ ---
97
+
98
+ ## 🛠 MCP Tools
99
+
100
+ ### Orchestration
101
+
102
+ | Tool | Description |
103
+ | ----------------- | ------------------------------- |
104
+ | `start_workflow` | Démarre un workflow automatisé |
105
+ | `execute_step` | Continue à l'étape suivante |
106
+ | `workflow_status` | Statut de la session active |
107
+ | `list_workflows` | Liste les workflows disponibles |
108
+ | `abort_workflow` | Annule le workflow en cours |
109
+
110
+ ### Utilitaires
111
+
112
+ | Tool | Description |
113
+ | ------ | ----------------------- |
114
+ | `ping` | Health check du serveur |
115
+ | `help` | Aide et documentation |
116
+
117
+ ---
118
+
119
+ ## 🤖 Agents IA
120
+
121
+ | Agent | Rôle | Utilisation |
122
+ | ------------ | ------------- | -------------------------------- |
123
+ | **SpecAgent**| Rédacteur | Spécifications fonctionnelles |
124
+ | **PlanAgent**| Planificateur | Découpage en tâches techniques |
125
+ | **GovAgent** | Validateur | Conformité RGPD, Sécurité, Archi |
126
+ | **TestAgent**| Testeur | Stratégies et cas de tests |
127
+
128
+ ---
129
+
130
+ ## 📁 Structure du Projet
131
+
132
+ ```text
133
+ spec-kit-mcp/
134
+ ├── src/
135
+ │ ├── index.ts # Entrypoint MCP Server
136
+ │ ├── engine/
137
+ │ │ ├── sessionManager.ts # Gestion des sessions
138
+ │ │ └── workflowEngine.ts # Moteur d'orchestration
139
+ │ ├── tools/
140
+ │ │ └── orchestrationTools.ts # Tools MCP
141
+ │ ├── prompts/
142
+ │ │ └── agents.ts # System prompts des agents
143
+ │ ├── schemas/
144
+ │ │ └── workflowSchema.ts # Validation Zod
145
+ │ └── utils/
146
+ │ ├── workflowLoader.ts # Chargeur YAML
147
+ │ └── markdownGenerator.ts # Générateur de templates
148
+ ├── workflows/ # Définitions YAML
149
+ │ ├── feature-standard.yaml
150
+ │ ├── feature-full.yaml
151
+ │ └── bugfix.yaml
152
+ ├── templates/ # Templates Markdown
153
+ │ ├── functional-spec.md
154
+ │ └── bugfix-report.md
155
+ └── .github/
156
+ └── copilot/
157
+ └── setupSpecKit.md # Slash command setup
158
+ ```
159
+
160
+ ---
161
+
162
+ ## 🔗 Intégration Azure DevOps
163
+
164
+ Pour activer l'intégration ADO, ajoutez le serveur MCP Azure DevOps:
165
+
166
+ ```json
167
+ {
168
+ "mcp": {
169
+ "servers": {
170
+ "spec-kit": {
171
+ "command": "npx",
172
+ "args": ["-y", "spec-kit-mcp"]
173
+ },
174
+ "azure-devops": {
175
+ "command": "npx",
176
+ "args": ["-y", "@modelcontextprotocol/server-azure-devops"],
177
+ "env": {
178
+ "AZURE_DEVOPS_ORG_URL": "https://dev.azure.com/your-org",
179
+ "AZURE_DEVOPS_PAT": "your-personal-access-token"
180
+ }
181
+ }
182
+ }
183
+ }
184
+ }
185
+ ```
186
+
187
+ ---
188
+
189
+ ## 📐 Créer un Workflow Custom
190
+
191
+ ```yaml
192
+ name: mon-workflow
193
+ displayName: "Mon Workflow"
194
+ description: "Description"
195
+ template: mon-template.md
196
+ defaultAgent: SpecAgent
197
+
198
+ steps:
199
+ - id: fetch
200
+ name: "Récupération"
201
+ action: fetch_ado
202
+ description: "Récupère le work item"
203
+
204
+ - id: generate
205
+ name: "Génération"
206
+ action: call_agent
207
+ agent: SpecAgent
208
+ description: "Génère le contenu"
209
+ ```
210
+
211
+ **Actions disponibles**: `fetch_ado`, `generate_content`, `call_agent`, `review`, `create_file`
212
+
213
+ ---
214
+
215
+ ## 🧪 Développement
216
+
217
+ ```bash
218
+ npm run build # Compile TypeScript
219
+ npm run dev # Watch mode
220
+ npm run start # Lance le serveur
221
+ ```
222
+
223
+ ---
224
+
225
+ ## � Personnalisation
226
+
227
+ ### Initialiser la config locale
228
+
229
+ ```text
230
+ @spec-kit init
231
+ ```
232
+
233
+ Crée `.spec-kit/` avec des workflows et templates personnalisables.
234
+
235
+ ### Voir la configuration
236
+
237
+ ```text
238
+ @spec-kit config
239
+ ```
240
+
241
+ Affiche les chemins de recherche et workflows disponibles (locaux vs package).
242
+
243
+ ### Ordre de résolution
244
+
245
+ 1. **Local**: `.spec-kit/workflows/` et `.spec-kit/templates/`
246
+ 2. **Package**: Workflows par défaut (feature-standard, bugfix, etc.)
247
+
248
+ > 📖 Voir [docs/PACKAGING.md](docs/PACKAGING.md) pour le guide complet de personnalisation.
249
+
250
+ ---
251
+
252
+ ## �📄 License
253
+
254
+ MIT
255
+
256
+ ---
257
+
258
+ ## 🙏 Technologies
259
+
260
+ - [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/sdk) - MCP Framework
261
+ - [Zod](https://zod.dev) - Schema Validation
262
+ - [js-yaml](https://github.com/nodeca/js-yaml) - YAML Parser
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Workflow Session Manager
3
+ *
4
+ * Manages workflow execution state with persistence.
5
+ * Each session tracks: current step, collected data, and workflow context.
6
+ */
7
+ /**
8
+ * Data collected during workflow execution
9
+ */
10
+ export interface WorkflowData {
11
+ /** Raw work item data from Azure DevOps */
12
+ workItemData?: Record<string, unknown>;
13
+ /** Generated specification content */
14
+ specification?: string;
15
+ /** Technical plan */
16
+ technicalPlan?: string;
17
+ /** Validation reports */
18
+ validations?: {
19
+ rgpd?: {
20
+ status: string;
21
+ issues: string[];
22
+ };
23
+ security?: {
24
+ status: string;
25
+ issues: string[];
26
+ };
27
+ architecture?: {
28
+ status: string;
29
+ issues: string[];
30
+ };
31
+ design?: {
32
+ status: string;
33
+ issues: string[];
34
+ };
35
+ general?: {
36
+ status: string;
37
+ issues: string[];
38
+ };
39
+ [key: string]: {
40
+ status: string;
41
+ issues: string[];
42
+ } | undefined;
43
+ };
44
+ /** Generated tasks */
45
+ tasks?: Array<{
46
+ id: string;
47
+ title: string;
48
+ estimate: string;
49
+ }>;
50
+ /** Any additional data collected during steps */
51
+ [key: string]: unknown;
52
+ }
53
+ /**
54
+ * Workflow session state
55
+ */
56
+ export interface WorkflowSession {
57
+ /** Unique session identifier */
58
+ sessionId: string;
59
+ /** Workflow name being executed */
60
+ workflowName: string;
61
+ /** Context ID (e.g., Azure DevOps work item ID) */
62
+ contextId: string;
63
+ /** Current step index */
64
+ currentStepIndex: number;
65
+ /** Current step ID */
66
+ currentStepId: string;
67
+ /** Session status */
68
+ status: "active" | "paused" | "completed" | "failed";
69
+ /** Collected data from all steps */
70
+ data: WorkflowData;
71
+ /** Timestamp of session creation */
72
+ createdAt: string;
73
+ /** Timestamp of last update */
74
+ updatedAt: string;
75
+ /** History of executed steps */
76
+ history: Array<{
77
+ stepId: string;
78
+ stepName: string;
79
+ status: "completed" | "skipped" | "failed";
80
+ timestamp: string;
81
+ output?: string;
82
+ }>;
83
+ /** Pending action for Copilot */
84
+ pendingAction?: {
85
+ type: "call_tool" | "user_input" | "confirmation" | "generate";
86
+ instruction: string;
87
+ toolName?: string;
88
+ toolArgs?: Record<string, unknown>;
89
+ };
90
+ }
91
+ /**
92
+ * Session store - in-memory with file persistence
93
+ */
94
+ declare class SessionStore {
95
+ private sessions;
96
+ private persistDir;
97
+ constructor();
98
+ /**
99
+ * Initialize the session store
100
+ */
101
+ init(): Promise<void>;
102
+ /**
103
+ * Generate a unique session ID
104
+ */
105
+ generateSessionId(): string;
106
+ /**
107
+ * Create a new session
108
+ */
109
+ create(workflowName: string, contextId: string, firstStepId: string): Promise<WorkflowSession>;
110
+ /**
111
+ * Get a session by ID
112
+ */
113
+ get(sessionId: string): WorkflowSession | undefined;
114
+ /**
115
+ * Get the most recent active session
116
+ */
117
+ getActiveSession(): WorkflowSession | undefined;
118
+ /**
119
+ * Update a session
120
+ */
121
+ update(session: WorkflowSession): Promise<void>;
122
+ /**
123
+ * Persist session to disk
124
+ */
125
+ private persist;
126
+ /**
127
+ * Delete a session
128
+ */
129
+ delete(sessionId: string): Promise<void>;
130
+ /**
131
+ * List all sessions
132
+ */
133
+ list(): WorkflowSession[];
134
+ }
135
+ export declare const sessionStore: SessionStore;
136
+ export {};
137
+ //# sourceMappingURL=sessionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionManager.d.ts","sourceRoot":"","sources":["../../src/engine/sessionManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,sCAAsC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yBAAyB;IACzB,WAAW,CAAC,EAAE;QACZ,IAAI,CAAC,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,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B;AAGD,eAAO,MAAM,YAAY,cAAqB,CAAC"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Workflow Session Manager
3
+ *
4
+ * Manages workflow execution state with persistence.
5
+ * Each session tracks: current step, collected data, and workflow context.
6
+ */
7
+ import * as fs from "node:fs/promises";
8
+ import * as path from "node:path";
9
+ import * as os from "node:os";
10
+ /**
11
+ * Session store - in-memory with file persistence
12
+ */
13
+ class SessionStore {
14
+ sessions = new Map();
15
+ persistDir;
16
+ constructor() {
17
+ this.persistDir = path.join(os.tmpdir(), "spec-kit-sessions");
18
+ }
19
+ /**
20
+ * Initialize the session store
21
+ */
22
+ async init() {
23
+ try {
24
+ await fs.mkdir(this.persistDir, { recursive: true });
25
+ // Load existing sessions
26
+ const files = await fs.readdir(this.persistDir);
27
+ for (const file of files) {
28
+ if (file.endsWith(".json")) {
29
+ const content = await fs.readFile(path.join(this.persistDir, file), "utf-8");
30
+ const session = JSON.parse(content);
31
+ this.sessions.set(session.sessionId, session);
32
+ }
33
+ }
34
+ }
35
+ catch {
36
+ // Directory might not exist yet, that's fine
37
+ }
38
+ }
39
+ /**
40
+ * Generate a unique session ID
41
+ */
42
+ generateSessionId() {
43
+ const timestamp = Date.now().toString(36);
44
+ const random = Math.random().toString(36).substring(2, 8);
45
+ return `wf-${timestamp}-${random}`;
46
+ }
47
+ /**
48
+ * Create a new session
49
+ */
50
+ async create(workflowName, contextId, firstStepId) {
51
+ const sessionId = this.generateSessionId();
52
+ const now = new Date().toISOString();
53
+ const session = {
54
+ sessionId,
55
+ workflowName,
56
+ contextId,
57
+ currentStepIndex: 0,
58
+ currentStepId: firstStepId,
59
+ status: "active",
60
+ data: {},
61
+ createdAt: now,
62
+ updatedAt: now,
63
+ history: [],
64
+ };
65
+ this.sessions.set(sessionId, session);
66
+ await this.persist(session);
67
+ return session;
68
+ }
69
+ /**
70
+ * Get a session by ID
71
+ */
72
+ get(sessionId) {
73
+ return this.sessions.get(sessionId);
74
+ }
75
+ /**
76
+ * Get the most recent active session
77
+ */
78
+ getActiveSession() {
79
+ let latest;
80
+ for (const session of this.sessions.values()) {
81
+ if (session.status === "active") {
82
+ if (!latest || session.updatedAt > latest.updatedAt) {
83
+ latest = session;
84
+ }
85
+ }
86
+ }
87
+ return latest;
88
+ }
89
+ /**
90
+ * Update a session
91
+ */
92
+ async update(session) {
93
+ session.updatedAt = new Date().toISOString();
94
+ this.sessions.set(session.sessionId, session);
95
+ await this.persist(session);
96
+ }
97
+ /**
98
+ * Persist session to disk
99
+ */
100
+ async persist(session) {
101
+ const filePath = path.join(this.persistDir, `${session.sessionId}.json`);
102
+ await fs.writeFile(filePath, JSON.stringify(session, null, 2), "utf-8");
103
+ }
104
+ /**
105
+ * Delete a session
106
+ */
107
+ async delete(sessionId) {
108
+ this.sessions.delete(sessionId);
109
+ const filePath = path.join(this.persistDir, `${sessionId}.json`);
110
+ try {
111
+ await fs.unlink(filePath);
112
+ }
113
+ catch {
114
+ // File might not exist
115
+ }
116
+ }
117
+ /**
118
+ * List all sessions
119
+ */
120
+ list() {
121
+ return Array.from(this.sessions.values());
122
+ }
123
+ }
124
+ // Singleton instance
125
+ export const sessionStore = new SessionStore();
126
+ // Initialize on module load
127
+ sessionStore.init().catch(console.error);
128
+ //# sourceMappingURL=sessionManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionManager.js","sourceRoot":"","sources":["../../src/engine/sessionManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAkE9B;;GAEG;AACH,MAAM,YAAY;IACR,QAAQ,GAAiC,IAAI,GAAG,EAAE,CAAC;IACnD,UAAU,CAAS;IAE3B;QACE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,mBAAmB,CAAC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C,OAAO,CAAC,OAAwB;QAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,OAAO,CAAC,CAAC;QACzE,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC1E,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,SAAiB;QAC5B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,SAAS,OAAO,CAAC,CAAC;QACjE,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,uBAAuB;QACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF;AAED,qBAAqB;AACrB,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;AAE/C,4BAA4B;AAC5B,YAAY,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Workflow Engine
3
+ *
4
+ * Orchestrates automatic workflow execution.
5
+ * Each step returns instructions for Copilot to execute the next action.
6
+ */
7
+ import { type WorkflowSession } from "./sessionManager.js";
8
+ /**
9
+ * Result of executing a workflow step
10
+ */
11
+ export interface StepResult {
12
+ /** Whether the step completed successfully */
13
+ success: boolean;
14
+ /** Session ID for tracking */
15
+ sessionId: string;
16
+ /** Current step info */
17
+ currentStep: {
18
+ index: number;
19
+ id: string;
20
+ name: string;
21
+ };
22
+ /** Message to display to user */
23
+ userMessage: string;
24
+ /**
25
+ * Next action for Copilot to execute.
26
+ * This is the KEY for automation - Copilot will execute this instruction.
27
+ */
28
+ nextAction: {
29
+ type: "call_mcp_tool" | "user_confirmation" | "workflow_complete" | "error";
30
+ /** Human-readable description of what will happen */
31
+ description: string;
32
+ /** For call_mcp_tool: the exact instruction for Copilot */
33
+ copilotInstruction?: string;
34
+ /** For user_confirmation: what the user needs to confirm */
35
+ confirmationPrompt?: string;
36
+ /** Is this an automatic action or does it need user approval? */
37
+ requiresApproval: boolean;
38
+ };
39
+ /** Data collected/generated in this step */
40
+ data?: Record<string, unknown>;
41
+ }
42
+ /**
43
+ * Start a new workflow execution
44
+ */
45
+ export declare function startWorkflow(workflowName: string, contextId: string): Promise<StepResult>;
46
+ /**
47
+ * Execute the next step in a workflow
48
+ */
49
+ export declare function executeStep(sessionId: string, previousOutput?: string | Record<string, unknown>): Promise<StepResult>;
50
+ /**
51
+ * Get current session status
52
+ */
53
+ export declare function getSessionStatus(sessionId?: string): Promise<{
54
+ session: WorkflowSession | null;
55
+ summary: string;
56
+ }>;
57
+ //# sourceMappingURL=workflowEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflowEngine.d.ts","sourceRoot":"","sources":["../../src/engine/workflowEngine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,qBAAqB,CAAC;AAG7B;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,wBAAwB;IACxB,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,iCAAiC;IACjC,WAAW,EAAE,MAAM,CA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