@llm-dev-ops/agentics-cli 1.4.7 → 1.4.8

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 (43) hide show
  1. package/dist/cli/index.js +109 -0
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/contracts/adr-006-claude-code-synthesis-runner.d.ts +196 -0
  4. package/dist/contracts/adr-006-claude-code-synthesis-runner.d.ts.map +1 -0
  5. package/dist/contracts/adr-006-claude-code-synthesis-runner.js +177 -0
  6. package/dist/contracts/adr-006-claude-code-synthesis-runner.js.map +1 -0
  7. package/dist/contracts/adr-007-subcommand-synthesis-router.d.ts +273 -0
  8. package/dist/contracts/adr-007-subcommand-synthesis-router.d.ts.map +1 -0
  9. package/dist/contracts/adr-007-subcommand-synthesis-router.js +226 -0
  10. package/dist/contracts/adr-007-subcommand-synthesis-router.js.map +1 -0
  11. package/dist/contracts/adr-008-synthesis-artifact-persistence.d.ts +323 -0
  12. package/dist/contracts/adr-008-synthesis-artifact-persistence.d.ts.map +1 -0
  13. package/dist/contracts/adr-008-synthesis-artifact-persistence.js +184 -0
  14. package/dist/contracts/adr-008-synthesis-artifact-persistence.js.map +1 -0
  15. package/dist/mcp/mcp-server.d.ts +35 -0
  16. package/dist/mcp/mcp-server.d.ts.map +1 -0
  17. package/dist/mcp/mcp-server.js +692 -0
  18. package/dist/mcp/mcp-server.js.map +1 -0
  19. package/dist/runtime/claude-code-runner.d.ts +93 -0
  20. package/dist/runtime/claude-code-runner.d.ts.map +1 -0
  21. package/dist/runtime/claude-code-runner.js +588 -0
  22. package/dist/runtime/claude-code-runner.js.map +1 -0
  23. package/dist/runtime/index.d.ts +5 -0
  24. package/dist/runtime/index.d.ts.map +1 -0
  25. package/dist/runtime/index.js +5 -0
  26. package/dist/runtime/index.js.map +1 -0
  27. package/dist/synthesis/artifact-writer.d.ts +62 -0
  28. package/dist/synthesis/artifact-writer.d.ts.map +1 -0
  29. package/dist/synthesis/artifact-writer.js +603 -0
  30. package/dist/synthesis/artifact-writer.js.map +1 -0
  31. package/dist/synthesis/index.d.ts +7 -0
  32. package/dist/synthesis/index.d.ts.map +1 -0
  33. package/dist/synthesis/index.js +7 -0
  34. package/dist/synthesis/index.js.map +1 -0
  35. package/dist/synthesis/prompts/index.d.ts +50 -0
  36. package/dist/synthesis/prompts/index.d.ts.map +1 -0
  37. package/dist/synthesis/prompts/index.js +502 -0
  38. package/dist/synthesis/prompts/index.js.map +1 -0
  39. package/dist/synthesis/router.d.ts +70 -0
  40. package/dist/synthesis/router.d.ts.map +1 -0
  41. package/dist/synthesis/router.js +346 -0
  42. package/dist/synthesis/router.js.map +1 -0
  43. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adr-007-subcommand-synthesis-router.js","sourceRoot":"","sources":["../../src/contracts/adr-007-subcommand-synthesis-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqMG;AAgFH;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAwB,IAAI,GAAG,CAAC;IACrE,iBAAiB;IACjB,cAAc;IACd,aAAa;IACb,cAAc;IACd,gBAAgB;IAChB,YAAY;IACZ,iBAAiB;IACjB,kBAAkB;IAClB,mBAAmB;IACnB,YAAY;IACZ,eAAe;IACf,aAAa;IACb,eAAe;IACf,gBAAgB;IAChB,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB;IAClB,aAAa;IACb,SAAS;IACT,YAAY;CACb,CAAC,CAAC"}
@@ -0,0 +1,323 @@
1
+ /**
2
+ * ADR-008: Synthesis Artifact Persistence & Platform Handoff
3
+ *
4
+ * STATUS: Proposed
5
+ * DATE: 2026-02-07
6
+ * AUTHORS: Platform Engineering
7
+ * DEPENDS-ON: ADR-006 (Runner), ADR-007 (Router), ADR-004 (Enterprise Integration)
8
+ *
9
+ * ============================================================================
10
+ * CONTEXT
11
+ * ============================================================================
12
+ *
13
+ * After Claude Code synthesis produces a contract-validated JSON object
14
+ * (ADR-006 + ADR-007), two things must happen:
15
+ *
16
+ * 1. The result must be handed off to the platform (agentics-dev-platform)
17
+ * for execution, persistence, and governance tracking.
18
+ *
19
+ * 2. Local artifacts must be written for `agentics inspect` to read,
20
+ * providing an offline audit trail.
21
+ *
22
+ * Currently, artifacts are stored by the Ruvector-backed platform adapters
23
+ * (src/adapters/base-adapter.ts:643-1089) and local CRUD files live in
24
+ * .agentics/{command}s/ (e.g., .agentics/simulations/). The executive
25
+ * synthesis tool writes a decision-summary.md but nothing else.
26
+ *
27
+ * This ADR defines the persistence contract for synthesis runs.
28
+ *
29
+ * ============================================================================
30
+ * DECISION
31
+ * ============================================================================
32
+ *
33
+ * 1. A new module `src/synthesis/artifact-writer.ts` handles local persistence.
34
+ *
35
+ * 2. After every successful synthesis + platform handoff, the following
36
+ * artifacts are written:
37
+ *
38
+ * ```
39
+ * ~/.agentics/runs/<run-id>/
40
+ * ├── manifest.json # Run metadata (IDs, timing, command, schema)
41
+ * ├── claude_output.json # Raw Claude Code output (validated JSON)
42
+ * ├── platform_receipt.json # Platform API response (IDs, status)
43
+ * └── prompt.txt # The exact prompt sent to Claude Code
44
+ * ```
45
+ *
46
+ * 3. The manifest.json structure:
47
+ * ```typescript
48
+ * interface RunManifest {
49
+ * run_id: string;
50
+ * plan_id?: string; // If a plan was created
51
+ * deploy_id?: string; // If a deployment was created
52
+ * command: string;
53
+ * subcommand: string;
54
+ * synthesis_class: SynthesisClass;
55
+ * contract_schema: string;
56
+ * model: string;
57
+ * duration_ms: number;
58
+ * created_at: string;
59
+ * seed: number;
60
+ * user_id: string;
61
+ * org_id: string;
62
+ * trace_id: string;
63
+ * artifacts: string[]; // Relative paths to sibling files
64
+ * }
65
+ * ```
66
+ *
67
+ * 4. Platform handoff flow:
68
+ * a. Synthesis router returns SynthesisResult<T>
69
+ * b. The command handler passes the data to the existing platform adapter
70
+ * (PlannerAdapter, RunnerAdapter, etc.)
71
+ * c. The platform responds with IDs and status
72
+ * d. Artifact writer persists all three files atomically
73
+ * e. IDs are printed to stdout
74
+ *
75
+ * 5. The artifact writer is idempotent: writing the same run-id twice
76
+ * overwrites the previous artifacts (latest wins).
77
+ *
78
+ * 6. `agentics inspect run <run-id>` will be enhanced to read from
79
+ * `~/.agentics/runs/<run-id>/manifest.json` when the run is not
80
+ * found in the platform (offline inspection).
81
+ *
82
+ * ============================================================================
83
+ * ID GENERATION
84
+ * ============================================================================
85
+ *
86
+ * Every synthesis run produces:
87
+ * - run_id: `run-{uuid}` — unique per invocation
88
+ * - plan_id: `plan-{uuid}` — if the command creates a plan
89
+ * - deploy_id: `deploy-{uuid}` — if the command creates a deployment
90
+ *
91
+ * These are generated BEFORE calling Claude Code (so they can be embedded
92
+ * in the prompt for determinism) and then used as the canonical identifiers
93
+ * throughout the pipeline.
94
+ *
95
+ * ============================================================================
96
+ * STORAGE PATH
97
+ * ============================================================================
98
+ *
99
+ * Base directory: `~/.agentics/runs/`
100
+ * Override: `AGENTICS_RUNS_DIR` environment variable
101
+ *
102
+ * This is separate from the existing `.agentics/simulations/` and
103
+ * `.agentics/plans/` directories, which store CRUD records. The `runs/`
104
+ * directory stores synthesis-specific artifacts.
105
+ *
106
+ * ============================================================================
107
+ * FILE PERMISSIONS
108
+ * ============================================================================
109
+ *
110
+ * All files written with mode 0o600 (owner read/write only), matching
111
+ * the existing credentials.ts pattern (src/utils/credentials.ts:38-39).
112
+ *
113
+ * ============================================================================
114
+ * PLATFORM RECEIPT
115
+ * ============================================================================
116
+ *
117
+ * The platform_receipt.json captures the downstream response:
118
+ *
119
+ * ```typescript
120
+ * interface PlatformReceipt {
121
+ * success: boolean;
122
+ * platform_id: string; // ID assigned by platform
123
+ * platform_type: string; // e.g., "PlanReference", "SimulationReference"
124
+ * status: string; // e.g., "created", "queued", "completed"
125
+ * timestamp: string;
126
+ * trace_id: string;
127
+ * error?: string; // If platform call failed
128
+ * }
129
+ * ```
130
+ *
131
+ * ============================================================================
132
+ * WIRING INTO CLI DISPATCH
133
+ * ============================================================================
134
+ *
135
+ * The integration modifies the command handlers in src/cli/index.ts.
136
+ * For each decision-grade subcommand:
137
+ *
138
+ * ```
139
+ * BEFORE (current):
140
+ * parse args → validate gates → call command executor → print output
141
+ * → fire-and-forget synthesis
142
+ *
143
+ * AFTER (ADR-008):
144
+ * parse args → validate gates → synthesis router (Claude Code)
145
+ * → call command executor (with synthesis data)
146
+ * → persist artifacts
147
+ * → print IDs to stdout
148
+ * ```
149
+ *
150
+ * The key change: synthesis happens BEFORE the platform call, not after.
151
+ * Claude Code produces the structured plan/intent/config, which is then
152
+ * sent to the platform for execution.
153
+ *
154
+ * ============================================================================
155
+ * ALTERNATIVES CONSIDERED
156
+ * ============================================================================
157
+ *
158
+ * A. Store artifacts in the platform only (no local files):
159
+ * Rejected — offline inspection is a hard requirement. Users must be
160
+ * able to audit synthesis results without platform connectivity.
161
+ *
162
+ * B. Store artifacts in the existing .agentics/{command}s/ directories:
163
+ * Rejected — synthesis artifacts are cross-cutting (a simulation run
164
+ * may reference a plan). A dedicated `runs/` directory with run-id
165
+ * as the organizing key is cleaner.
166
+ *
167
+ * C. Use a SQLite database for local storage:
168
+ * Rejected — JSON files are simpler, greppable, and don't require
169
+ * additional dependencies. The volume is low (one run per command).
170
+ *
171
+ * ============================================================================
172
+ * CONSEQUENCES
173
+ * ============================================================================
174
+ *
175
+ * - Every synthesis run is fully auditable locally
176
+ * - The prompt sent to Claude Code is preserved for debugging
177
+ * - Platform receipts provide end-to-end traceability
178
+ * - `agentics inspect run <run-id>` works offline
179
+ * - The runs/ directory grows linearly; no automatic cleanup (user manages)
180
+ * - New decision-grade subcommands automatically get artifact persistence
181
+ * if they follow the synthesis router integration pattern
182
+ */
183
+ export interface RunManifest {
184
+ readonly run_id: string;
185
+ readonly plan_id?: string;
186
+ readonly deploy_id?: string;
187
+ readonly simulation_id?: string;
188
+ readonly command: string;
189
+ readonly subcommand: string;
190
+ readonly synthesis_class: 'SYNTHESIS_REQUIRED' | 'COMMITMENT_GRADE';
191
+ readonly contract_schema: string;
192
+ readonly model: string;
193
+ readonly duration_ms: number;
194
+ readonly created_at: string;
195
+ readonly seed: number;
196
+ readonly user_id: string;
197
+ readonly org_id: string;
198
+ readonly trace_id: string;
199
+ readonly artifacts: readonly string[];
200
+ }
201
+ export interface PlatformReceipt {
202
+ readonly success: boolean;
203
+ readonly platform_id: string;
204
+ readonly platform_type: string;
205
+ readonly status: string;
206
+ readonly timestamp: string;
207
+ readonly trace_id: string;
208
+ readonly error?: string;
209
+ }
210
+ export interface ArtifactWriterInput {
211
+ readonly manifest: RunManifest;
212
+ readonly claudeOutput: unknown;
213
+ readonly platformReceipt: PlatformReceipt;
214
+ readonly prompt: string;
215
+ }
216
+ /**
217
+ * Result of a successful artifact write operation.
218
+ * Contains the run directory path, file list, checksums, and byte count
219
+ * for verification and diagnostics.
220
+ */
221
+ export interface ArtifactWriteResult {
222
+ /** Absolute path to the run directory */
223
+ readonly runDir: string;
224
+ /** List of artifact filenames written (relative to runDir) */
225
+ readonly filesWritten: readonly string[];
226
+ /** SHA-256 checksums keyed by filename for integrity verification */
227
+ readonly checksums: Readonly<Record<string, string>>;
228
+ /** Total bytes written across all artifact files */
229
+ readonly bytesWritten: number;
230
+ }
231
+ /**
232
+ * Lightweight summary of a synthesis run for listing and filtering.
233
+ * Contains only the fields needed for discovery; use readManifest()
234
+ * to get the full RunManifest.
235
+ */
236
+ export interface RunSummary {
237
+ readonly run_id: string;
238
+ readonly command: string;
239
+ readonly subcommand: string;
240
+ readonly synthesis_class: 'SYNTHESIS_REQUIRED' | 'COMMITMENT_GRADE';
241
+ readonly created_at: string;
242
+ readonly model: string;
243
+ }
244
+ /**
245
+ * Options for listing synthesis runs with filtering and pagination.
246
+ */
247
+ export interface ListRunsOptions {
248
+ /** Maximum number of runs to return */
249
+ readonly limit?: number;
250
+ /** Number of runs to skip (for pagination) */
251
+ readonly offset?: number;
252
+ /** Filter to runs for this command */
253
+ readonly command?: string;
254
+ /** Filter to runs for this subcommand */
255
+ readonly subcommand?: string;
256
+ /** Sort order: true = newest first (default), false = oldest first */
257
+ readonly newestFirst?: boolean;
258
+ }
259
+ /** The four canonical artifact file types in every run directory */
260
+ export type ArtifactFileType = 'manifest' | 'claude_output' | 'platform_receipt' | 'prompt';
261
+ export interface IArtifactWriter {
262
+ /**
263
+ * Write all synthesis artifacts for a run.
264
+ * Creates the run directory and writes all four files atomically
265
+ * (temp-then-rename per file). Idempotent: re-writing the same
266
+ * run-id overwrites previous artifacts.
267
+ *
268
+ * @returns Write result with run directory path, checksums, and byte count
269
+ * @throws CLIError (ECLI-ART-001..003) on invalid input
270
+ * @throws CLIError (ECLI-ART-010..011) on serialization/size errors
271
+ * @throws CLIError (ECLI-ART-020..021) on I/O failures
272
+ */
273
+ write(input: ArtifactWriterInput): ArtifactWriteResult;
274
+ /**
275
+ * Read a run manifest by run-id.
276
+ * @returns The manifest or null if not found or unreadable
277
+ */
278
+ readManifest(runId: string): RunManifest | null;
279
+ /**
280
+ * Read the platform receipt for a run.
281
+ * @returns The receipt or null if not found or unreadable
282
+ */
283
+ readReceipt(runId: string): PlatformReceipt | null;
284
+ /**
285
+ * Read the raw Claude Code output for a run.
286
+ * @returns The parsed JSON output or null if not found or unreadable
287
+ */
288
+ readClaudeOutput(runId: string): unknown;
289
+ /**
290
+ * Read the prompt text that was sent to Claude Code for a run.
291
+ * @returns The prompt string or null if not found or unreadable
292
+ */
293
+ readPrompt(runId: string): string | null;
294
+ /**
295
+ * List synthesis runs with optional filtering and pagination.
296
+ * Reads manifest files from the runs directory, sorted by created_at.
297
+ * @returns Array of run summaries (may be empty if no runs or directory missing)
298
+ */
299
+ listRuns(options?: ListRunsOptions): RunSummary[];
300
+ /**
301
+ * Check if a run exists (has a readable manifest file).
302
+ * Fast stat-based check without reading the full manifest.
303
+ */
304
+ runExists(runId: string): boolean;
305
+ /**
306
+ * Get the base directory for all runs.
307
+ */
308
+ getRunsDir(): string;
309
+ /**
310
+ * Get the absolute path to a specific run's directory.
311
+ * Validates the run-id format and prevents path traversal.
312
+ * @throws CLIError (ECLI-ART-001..002) on invalid run-id
313
+ */
314
+ getRunDir(runId: string): string;
315
+ /**
316
+ * Delete a run and all its artifacts.
317
+ * Removes the entire run directory recursively.
318
+ * @returns true if the run was deleted, false if not found
319
+ * @throws CLIError (ECLI-ART-001..002) on invalid run-id
320
+ */
321
+ deleteRun(runId: string): boolean;
322
+ }
323
+ //# sourceMappingURL=adr-008-synthesis-artifact-persistence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adr-008-synthesis-artifact-persistence.d.ts","sourceRoot":"","sources":["../../src/contracts/adr-008-synthesis-artifact-persistence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqLG;AAMH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,eAAe,EAAE,oBAAoB,GAAG,kBAAk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AU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAEzC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,UAAU,EAAE,CAAC;IAElD;;;OAGG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAElC;;OAEG;IACH,UAAU,IAAI,MAAM,CAAC;IAErB;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAEjC;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACnC"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * ADR-008: Synthesis Artifact Persistence & Platform Handoff
3
+ *
4
+ * STATUS: Proposed
5
+ * DATE: 2026-02-07
6
+ * AUTHORS: Platform Engineering
7
+ * DEPENDS-ON: ADR-006 (Runner), ADR-007 (Router), ADR-004 (Enterprise Integration)
8
+ *
9
+ * ============================================================================
10
+ * CONTEXT
11
+ * ============================================================================
12
+ *
13
+ * After Claude Code synthesis produces a contract-validated JSON object
14
+ * (ADR-006 + ADR-007), two things must happen:
15
+ *
16
+ * 1. The result must be handed off to the platform (agentics-dev-platform)
17
+ * for execution, persistence, and governance tracking.
18
+ *
19
+ * 2. Local artifacts must be written for `agentics inspect` to read,
20
+ * providing an offline audit trail.
21
+ *
22
+ * Currently, artifacts are stored by the Ruvector-backed platform adapters
23
+ * (src/adapters/base-adapter.ts:643-1089) and local CRUD files live in
24
+ * .agentics/{command}s/ (e.g., .agentics/simulations/). The executive
25
+ * synthesis tool writes a decision-summary.md but nothing else.
26
+ *
27
+ * This ADR defines the persistence contract for synthesis runs.
28
+ *
29
+ * ============================================================================
30
+ * DECISION
31
+ * ============================================================================
32
+ *
33
+ * 1. A new module `src/synthesis/artifact-writer.ts` handles local persistence.
34
+ *
35
+ * 2. After every successful synthesis + platform handoff, the following
36
+ * artifacts are written:
37
+ *
38
+ * ```
39
+ * ~/.agentics/runs/<run-id>/
40
+ * ├── manifest.json # Run metadata (IDs, timing, command, schema)
41
+ * ├── claude_output.json # Raw Claude Code output (validated JSON)
42
+ * ├── platform_receipt.json # Platform API response (IDs, status)
43
+ * └── prompt.txt # The exact prompt sent to Claude Code
44
+ * ```
45
+ *
46
+ * 3. The manifest.json structure:
47
+ * ```typescript
48
+ * interface RunManifest {
49
+ * run_id: string;
50
+ * plan_id?: string; // If a plan was created
51
+ * deploy_id?: string; // If a deployment was created
52
+ * command: string;
53
+ * subcommand: string;
54
+ * synthesis_class: SynthesisClass;
55
+ * contract_schema: string;
56
+ * model: string;
57
+ * duration_ms: number;
58
+ * created_at: string;
59
+ * seed: number;
60
+ * user_id: string;
61
+ * org_id: string;
62
+ * trace_id: string;
63
+ * artifacts: string[]; // Relative paths to sibling files
64
+ * }
65
+ * ```
66
+ *
67
+ * 4. Platform handoff flow:
68
+ * a. Synthesis router returns SynthesisResult<T>
69
+ * b. The command handler passes the data to the existing platform adapter
70
+ * (PlannerAdapter, RunnerAdapter, etc.)
71
+ * c. The platform responds with IDs and status
72
+ * d. Artifact writer persists all three files atomically
73
+ * e. IDs are printed to stdout
74
+ *
75
+ * 5. The artifact writer is idempotent: writing the same run-id twice
76
+ * overwrites the previous artifacts (latest wins).
77
+ *
78
+ * 6. `agentics inspect run <run-id>` will be enhanced to read from
79
+ * `~/.agentics/runs/<run-id>/manifest.json` when the run is not
80
+ * found in the platform (offline inspection).
81
+ *
82
+ * ============================================================================
83
+ * ID GENERATION
84
+ * ============================================================================
85
+ *
86
+ * Every synthesis run produces:
87
+ * - run_id: `run-{uuid}` — unique per invocation
88
+ * - plan_id: `plan-{uuid}` — if the command creates a plan
89
+ * - deploy_id: `deploy-{uuid}` — if the command creates a deployment
90
+ *
91
+ * These are generated BEFORE calling Claude Code (so they can be embedded
92
+ * in the prompt for determinism) and then used as the canonical identifiers
93
+ * throughout the pipeline.
94
+ *
95
+ * ============================================================================
96
+ * STORAGE PATH
97
+ * ============================================================================
98
+ *
99
+ * Base directory: `~/.agentics/runs/`
100
+ * Override: `AGENTICS_RUNS_DIR` environment variable
101
+ *
102
+ * This is separate from the existing `.agentics/simulations/` and
103
+ * `.agentics/plans/` directories, which store CRUD records. The `runs/`
104
+ * directory stores synthesis-specific artifacts.
105
+ *
106
+ * ============================================================================
107
+ * FILE PERMISSIONS
108
+ * ============================================================================
109
+ *
110
+ * All files written with mode 0o600 (owner read/write only), matching
111
+ * the existing credentials.ts pattern (src/utils/credentials.ts:38-39).
112
+ *
113
+ * ============================================================================
114
+ * PLATFORM RECEIPT
115
+ * ============================================================================
116
+ *
117
+ * The platform_receipt.json captures the downstream response:
118
+ *
119
+ * ```typescript
120
+ * interface PlatformReceipt {
121
+ * success: boolean;
122
+ * platform_id: string; // ID assigned by platform
123
+ * platform_type: string; // e.g., "PlanReference", "SimulationReference"
124
+ * status: string; // e.g., "created", "queued", "completed"
125
+ * timestamp: string;
126
+ * trace_id: string;
127
+ * error?: string; // If platform call failed
128
+ * }
129
+ * ```
130
+ *
131
+ * ============================================================================
132
+ * WIRING INTO CLI DISPATCH
133
+ * ============================================================================
134
+ *
135
+ * The integration modifies the command handlers in src/cli/index.ts.
136
+ * For each decision-grade subcommand:
137
+ *
138
+ * ```
139
+ * BEFORE (current):
140
+ * parse args → validate gates → call command executor → print output
141
+ * → fire-and-forget synthesis
142
+ *
143
+ * AFTER (ADR-008):
144
+ * parse args → validate gates → synthesis router (Claude Code)
145
+ * → call command executor (with synthesis data)
146
+ * → persist artifacts
147
+ * → print IDs to stdout
148
+ * ```
149
+ *
150
+ * The key change: synthesis happens BEFORE the platform call, not after.
151
+ * Claude Code produces the structured plan/intent/config, which is then
152
+ * sent to the platform for execution.
153
+ *
154
+ * ============================================================================
155
+ * ALTERNATIVES CONSIDERED
156
+ * ============================================================================
157
+ *
158
+ * A. Store artifacts in the platform only (no local files):
159
+ * Rejected — offline inspection is a hard requirement. Users must be
160
+ * able to audit synthesis results without platform connectivity.
161
+ *
162
+ * B. Store artifacts in the existing .agentics/{command}s/ directories:
163
+ * Rejected — synthesis artifacts are cross-cutting (a simulation run
164
+ * may reference a plan). A dedicated `runs/` directory with run-id
165
+ * as the organizing key is cleaner.
166
+ *
167
+ * C. Use a SQLite database for local storage:
168
+ * Rejected — JSON files are simpler, greppable, and don't require
169
+ * additional dependencies. The volume is low (one run per command).
170
+ *
171
+ * ============================================================================
172
+ * CONSEQUENCES
173
+ * ============================================================================
174
+ *
175
+ * - Every synthesis run is fully auditable locally
176
+ * - The prompt sent to Claude Code is preserved for debugging
177
+ * - Platform receipts provide end-to-end traceability
178
+ * - `agentics inspect run <run-id>` works offline
179
+ * - The runs/ directory grows linearly; no automatic cleanup (user manages)
180
+ * - New decision-grade subcommands automatically get artifact persistence
181
+ * if they follow the synthesis router integration pattern
182
+ */
183
+ export {};
184
+ //# sourceMappingURL=adr-008-synthesis-artifact-persistence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adr-008-synthesis-artifact-persistence.js","sourceRoot":"","sources":["../../src/contracts/adr-008-synthesis-artifact-persistence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqLG"}
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Agentics CLI — MCP Server (stdio transport)
4
+ *
5
+ * Exposes every CLI command + subcommand as an MCP tool so Claude Code
6
+ * can call them directly, the same way claude-flow works.
7
+ *
8
+ * Protocol: JSON-RPC 2.0 over newline-delimited stdin/stdout
9
+ *
10
+ * Tool inventory (48 tools across 12 domains):
11
+ *
12
+ * Identity & Access login, logout, whoami
13
+ * Simulation simulate_create, simulate_run, simulate_list,
14
+ * simulate_inspect, simulate_delete
15
+ * Planning plan_create, plan_list, plan_inspect,
16
+ * plan_approve, plan_delete
17
+ * Inspect inspect_query, inspect_run, inspect_latest,
18
+ * inspect_artifacts
19
+ * Usage & Billing usage, usage_history, usage_limits, usage_reset
20
+ * ROI / Quantify quantify_create, quantify_inspect, quantify_list,
21
+ * quantify_compare
22
+ * Deployment deploy_preview, deploy_run, deploy_status,
23
+ * deploy_rollback
24
+ * Export export_terraform, export_kubernetes, export_erp
25
+ * Policy policy_list, policy_inspect, policy_create,
26
+ * policy_edit, policy_delete, policy_enable,
27
+ * policy_disable, policy_dry_run, policy_scope
28
+ * ERP Surface erp_list, erp_inspect, erp_surface, erp_map,
29
+ * erp_export
30
+ * Diligence diligence
31
+ * Audit audit
32
+ * Meta version, help
33
+ */
34
+ export {};
35
+ //# sourceMappingURL=mcp-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG"}