@bluelibs/runner-dev 4.1.1 → 4.2.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 (152) hide show
  1. package/AI.md +40 -43
  2. package/README.md +70 -0
  3. package/dist/architect/core/errors.d.ts +39 -0
  4. package/dist/architect/core/errors.js +143 -0
  5. package/dist/architect/core/errors.js.map +1 -0
  6. package/dist/architect/core/index.d.ts +3 -0
  7. package/dist/architect/core/index.js +21 -0
  8. package/dist/architect/core/index.js.map +1 -0
  9. package/dist/architect/core/interfaces.d.ts +158 -0
  10. package/dist/architect/core/interfaces.js +3 -0
  11. package/dist/architect/core/interfaces.js.map +1 -0
  12. package/dist/architect/core/types.d.ts +544 -0
  13. package/dist/architect/core/types.js +49 -0
  14. package/dist/architect/core/types.js.map +1 -0
  15. package/dist/architect/execution/executor.d.ts +23 -0
  16. package/dist/architect/execution/executor.js +476 -0
  17. package/dist/architect/execution/executor.js.map +1 -0
  18. package/dist/architect/execution/index.d.ts +1 -0
  19. package/dist/architect/execution/index.js +19 -0
  20. package/dist/architect/execution/index.js.map +1 -0
  21. package/dist/architect/executor.d.ts +7 -0
  22. package/dist/architect/executor.js +150 -0
  23. package/dist/architect/executor.js.map +1 -0
  24. package/dist/architect/index.d.ts +45 -0
  25. package/dist/architect/index.js +76 -0
  26. package/dist/architect/index.js.map +1 -0
  27. package/dist/architect/llmClient.d.ts +10 -0
  28. package/dist/architect/llmClient.js +33 -0
  29. package/dist/architect/llmClient.js.map +1 -0
  30. package/dist/architect/models/base.d.ts +16 -0
  31. package/dist/architect/models/base.js +68 -0
  32. package/dist/architect/models/base.js.map +1 -0
  33. package/dist/architect/models/factory.d.ts +16 -0
  34. package/dist/architect/models/factory.js +73 -0
  35. package/dist/architect/models/factory.js.map +1 -0
  36. package/dist/architect/models/index.d.ts +3 -0
  37. package/dist/architect/models/index.js +21 -0
  38. package/dist/architect/models/index.js.map +1 -0
  39. package/dist/architect/models/openai.d.ts +7 -0
  40. package/dist/architect/models/openai.js +71 -0
  41. package/dist/architect/models/openai.js.map +1 -0
  42. package/dist/architect/planner.d.ts +9 -0
  43. package/dist/architect/planner.js +42 -0
  44. package/dist/architect/planner.js.map +1 -0
  45. package/dist/architect/planning/index.d.ts +4 -0
  46. package/dist/architect/planning/index.js +22 -0
  47. package/dist/architect/planning/index.js.map +1 -0
  48. package/dist/architect/planning/optimizer.d.ts +14 -0
  49. package/dist/architect/planning/optimizer.js +275 -0
  50. package/dist/architect/planning/optimizer.js.map +1 -0
  51. package/dist/architect/planning/planner.d.ts +15 -0
  52. package/dist/architect/planning/planner.js +124 -0
  53. package/dist/architect/planning/planner.js.map +1 -0
  54. package/dist/architect/planning/prompts.d.ts +6 -0
  55. package/dist/architect/planning/prompts.js +111 -0
  56. package/dist/architect/planning/prompts.js.map +1 -0
  57. package/dist/architect/planning/validator.d.ts +16 -0
  58. package/dist/architect/planning/validator.js +331 -0
  59. package/dist/architect/planning/validator.js.map +1 -0
  60. package/dist/architect/prompt.d.ts +1 -0
  61. package/dist/architect/prompt.js +13 -0
  62. package/dist/architect/prompt.js.map +1 -0
  63. package/dist/architect/types.d.ts +4 -0
  64. package/dist/architect/types.js +24 -0
  65. package/dist/architect/types.js.map +1 -0
  66. package/dist/cli/format.d.ts +19 -0
  67. package/dist/cli/format.js +62 -0
  68. package/dist/cli/format.js.map +1 -0
  69. package/dist/cli/init.d.ts +1 -0
  70. package/dist/cli/init.js +279 -0
  71. package/dist/cli/init.js.map +1 -0
  72. package/dist/cli/query.js +69 -0
  73. package/dist/cli/query.js.map +1 -1
  74. package/dist/cli.js +48 -21
  75. package/dist/cli.js.map +1 -1
  76. package/dist/code.d.ts +50 -0
  77. package/dist/code.js +357 -0
  78. package/dist/code.js.map +1 -0
  79. package/dist/generated/resolvers-types.d.ts +150 -29
  80. package/dist/index.d.ts +6 -0
  81. package/dist/index.js +2 -0
  82. package/dist/index.js.map +1 -1
  83. package/dist/resources/cli.config.resource.d.ts +7 -0
  84. package/dist/resources/cli.config.resource.js +11 -0
  85. package/dist/resources/cli.config.resource.js.map +1 -0
  86. package/dist/resources/coverage.resource.d.ts +19 -0
  87. package/dist/resources/coverage.resource.js +213 -0
  88. package/dist/resources/coverage.resource.js.map +1 -0
  89. package/dist/resources/dev.resource.js +0 -2
  90. package/dist/resources/dev.resource.js.map +1 -1
  91. package/dist/resources/graphql.cli.resource.d.ts +4 -0
  92. package/dist/resources/graphql.cli.resource.js +27 -0
  93. package/dist/resources/graphql.cli.resource.js.map +1 -0
  94. package/dist/resources/graphql.query.cli.task.d.ts +47 -0
  95. package/dist/resources/graphql.query.cli.task.js +54 -0
  96. package/dist/resources/graphql.query.cli.task.js.map +1 -0
  97. package/dist/resources/introspector.cli.resource.d.ts +6 -0
  98. package/dist/resources/introspector.cli.resource.js +17 -0
  99. package/dist/resources/introspector.cli.resource.js.map +1 -0
  100. package/dist/resources/live.resource.d.ts +2 -1
  101. package/dist/resources/live.resource.js +4 -2
  102. package/dist/resources/live.resource.js.map +1 -1
  103. package/dist/resources/models/Introspector.d.ts +1 -1
  104. package/dist/resources/models/Introspector.js +5 -34
  105. package/dist/resources/models/Introspector.js.map +1 -1
  106. package/dist/resources/models/initializeFromStore.js +26 -34
  107. package/dist/resources/models/initializeFromStore.js.map +1 -1
  108. package/dist/resources/models/initializeFromStore.utils.js +12 -3
  109. package/dist/resources/models/initializeFromStore.utils.js.map +1 -1
  110. package/dist/resources/routeHandlers/getDocsData.d.ts +6 -0
  111. package/dist/resources/routeHandlers/getDocsData.js +106 -0
  112. package/dist/resources/routeHandlers/getDocsData.js.map +1 -1
  113. package/dist/resources/routeHandlers/registerHttpRoutes.hook.d.ts +4 -0
  114. package/dist/resources/routeHandlers/registerHttpRoutes.hook.js +9 -7
  115. package/dist/resources/routeHandlers/registerHttpRoutes.hook.js.map +1 -1
  116. package/dist/resources/server.resource.d.ts +3 -0
  117. package/dist/resources/server.resource.js +8 -1
  118. package/dist/resources/server.resource.js.map +1 -1
  119. package/dist/resources/swap.cli.resource.d.ts +11 -0
  120. package/dist/resources/swap.cli.resource.js +54 -0
  121. package/dist/resources/swap.cli.resource.js.map +1 -0
  122. package/dist/schema/context.d.ts +2 -0
  123. package/dist/schema/model.d.ts +4 -1
  124. package/dist/schema/model.js.map +1 -1
  125. package/dist/schema/mutation.js +38 -0
  126. package/dist/schema/mutation.js.map +1 -1
  127. package/dist/schema/query.js +15 -14
  128. package/dist/schema/query.js.map +1 -1
  129. package/dist/schema/types/BaseElementCommon.d.ts +2 -4
  130. package/dist/schema/types/BaseElementCommon.js +28 -0
  131. package/dist/schema/types/BaseElementCommon.js.map +1 -1
  132. package/dist/schema/types/CoverageType.d.ts +7 -0
  133. package/dist/schema/types/CoverageType.js +54 -0
  134. package/dist/schema/types/CoverageType.js.map +1 -0
  135. package/dist/schema/types/LiveType.js +4 -0
  136. package/dist/schema/types/LiveType.js.map +1 -1
  137. package/dist/schema/types/ResourceType.js +6 -0
  138. package/dist/schema/types/ResourceType.js.map +1 -1
  139. package/dist/schema/types/TagType.js +4 -3
  140. package/dist/schema/types/TagType.js.map +1 -1
  141. package/dist/schema/types/index.d.ts +1 -0
  142. package/dist/schema/types/index.js +3 -1
  143. package/dist/schema/types/index.js.map +1 -1
  144. package/dist/ui/.vite/manifest.json +2 -2
  145. package/dist/ui/assets/docs-DR80KoAA.js +416 -0
  146. package/dist/ui/assets/docs-DR80KoAA.js.map +1 -0
  147. package/dist/ui/assets/docs-WKK9Zcu5.css +1 -0
  148. package/dist/utils/path.js +10 -0
  149. package/dist/utils/path.js.map +1 -1
  150. package/package.json +11 -7
  151. package/dist/ui/assets/docs-B_YMa-Rg.js +0 -174
  152. package/dist/ui/assets/docs-DVEzFAJo.css +0 -1
package/AI.md CHANGED
@@ -235,61 +235,38 @@ mutation EvalCode($code: String!, $inputJson: String, $evalInput: Boolean) {
235
235
 
236
236
  ## MCP Tools Available
237
237
 
238
- ### GraphQL Operations
239
-
240
238
  - `graphql.query` - Execute read-only GraphQL queries
241
239
  - `graphql.mutation` - Execute GraphQL mutations (if ALLOW_MUTATIONS=true)
242
240
  - `graphql.introspect` - Get full schema introspection
243
- - `graphql.schemaSdl` - Get schema as SDL string
244
241
  - `graphql.ping` - Test connectivity
242
+ - `project.overview` - Generate dynamic project overview aggregated from the API
245
243
 
246
- ### Documentation
247
-
248
- - `help.read` - Read local docs (README.md, AI.md) or package docs
249
- - `help.runner` - Read @bluelibs/runner framework documentation
250
- - `help.runnerDev` - Read Runner-Dev application documentation (README + AI guide)
251
- - `project.overview` - Generate dynamic project overview
252
-
253
- **🎯 Pro Tip: Array-Based Heading Filtering**
254
- All documentation tools support powerful array-based heading filtering:
244
+ ## Direct CLI Usage
255
245
 
256
- ```typescript
257
- // Single heading (traditional)
258
- headingIncludes: "installation";
246
+ Beyond MCP, Runner-Dev offers a powerful standalone CLI for direct interaction from your terminal. This is ideal for scripting, quick checks, or when not operating within an MCP-enabled AI assistant.
259
247
 
260
- // Multiple headings (NEW!) - Get comprehensive context in one call
261
- headingIncludes: ["installation", "configuration", "troubleshooting"];
262
- headingIncludes: ["tasks", "resources", "events", "middleware"];
263
- headingIncludes: ["hot-swapping", "live telemetry", "debugging"];
264
- ```
248
+ ### Prerequisites
265
249
 
266
- This enables gathering related information efficiently instead of making multiple sequential requests. The output shows exactly what sections were found and combines them with clear separators.
250
+ - Your app must be running with the Dev server enabled (for remote mode).
251
+ - The `@bluelibs/runner-dev` package should be installed.
267
252
 
268
- **Example Usage:**
253
+ ### Create a New Project
269
254
 
270
- ```typescript
271
- // Get comprehensive Runner framework understanding
272
- help.runner({
273
- headingIncludes: ["tasks", "resources", "events", "middleware"],
274
- });
255
+ You can scaffold a new Runner project directly from the CLI.
275
256
 
276
- // Understand development workflow
277
- help.runner_dev({
278
- headingIncludes: ["hot-swapping", "live telemetry", "debugging"],
279
- });
257
+ ```bash
258
+ # Create a new Runner project
259
+ npx @bluelibs/runner-dev new <project-name>
280
260
 
281
- // Compare installation methods
282
- help.read({ headingIncludes: ["installation", "setup", "configuration"] });
261
+ # Example
262
+ npx @bluelibs/runner-dev new my-awesome-app
283
263
  ```
264
+ This command creates a new Runner project with a complete TypeScript setup, Jest for testing, and all necessary dependencies.
284
265
 
285
- ## Direct CLI Usage
286
-
287
- Beyond MCP, Runner-Dev offers a powerful standalone CLI for direct interaction from your terminal. This is ideal for scripting, quick checks, or when not operating within an MCP-enabled AI assistant.
288
-
289
- ### Prerequisites
290
-
291
- - Your app must be running with the Dev server enabled.
292
- - The `@bluelibs/runner-dev` package should be installed.
266
+ Key flags for `new`:
267
+ - `--install`: Install dependencies after scaffolding.
268
+ - `--run-tests`: Run the generated test suite after installation.
269
+ - `--run`: Start the dev server after installation.
293
270
 
294
271
  ### Common Commands
295
272
 
@@ -300,7 +277,7 @@ All commands can be prefixed with environment variables like `ENDPOINT` and `HEA
300
277
  ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev ping
301
278
  ```
302
279
 
303
- **Execute a GraphQL query:**
280
+ **Execute a GraphQL query (Remote Mode):**
304
281
  ```bash
305
282
  # Simple query
306
283
  ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev query 'query { tasks { id } }'
@@ -313,12 +290,27 @@ ENDPOINT=http://localhost:1337/graphql \
313
290
  --format pretty
314
291
  ```
315
292
 
293
+ **Execute a GraphQL query (Dry-Run Mode):**
294
+
295
+ Run queries against a TypeScript entry file without needing a running server.
296
+
297
+ ```bash
298
+ # Using a TS entry file default export
299
+ npx @bluelibs/runner-dev query 'query { tasks { id } }' \
300
+ --entry-file ./src/main.ts
301
+
302
+ # Using a named export (e.g., exported as `app`)
303
+ npx @bluelibs/runner-dev query 'query { tasks { id } }' \
304
+ --entry-file ./src/main.ts --export app
305
+ ```
306
+
316
307
  **Generate a project overview:**
317
308
  ```bash
318
309
  ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev overview --details 10
319
310
  ```
320
311
 
321
312
  **Fetch GraphQL schema:**
313
+
322
314
  ```bash
323
315
  # As SDL
324
316
  ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev schema sdl
@@ -329,14 +321,19 @@ ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev schema json
329
321
 
330
322
  ### Key Flags
331
323
 
332
- - `--endpoint <url>`: GraphQL endpoint URL.
324
+ - `--endpoint <url>`: GraphQL endpoint URL for remote mode.
333
325
  - `--headers '<json>'`: JSON for extra headers.
334
326
  - `--variables '<json>'`: JSON variables for a query.
335
327
  - `--format data|json|pretty`: Output format.
336
328
  - `--namespace <str>`: A filter to inject `idIncludes` on top-level fields.
329
+ - `--entry-file <path>`: TypeScript entry file for dry-run mode (no server).
330
+ - `--export <name>`: Named export to use from the entry file (default export is preferred).
331
+ - `--operation <name>`: Operation name for documents with multiple operations.
332
+ - `--raw`: Print the full GraphQL envelope including errors.
337
333
 
338
334
  This direct CLI access provides a powerful way for AI assistants with shell access to script complex interactions, perform detailed introspection, and validate application state without relying on MCP tools.
339
335
 
336
+
340
337
  ## Common Use Cases
341
338
 
342
339
  ### 1. Understanding System Architecture
package/README.md CHANGED
@@ -111,6 +111,7 @@ This package also ships a CLI that can query the same GraphQL API or generate an
111
111
  Prerequisites:
112
112
 
113
113
  - Ensure your app registers the Dev GraphQL server (`dev.with({ port: 1337 })`) or otherwise expose a compatible endpoint.
114
+ - Alternatively, you can run queries in a new **dry‑run mode** with a TypeScript entry file (no server required).
114
115
  - Build this package (or install it) so the binary is available.
115
116
 
116
117
  Help:
@@ -119,6 +120,50 @@ Help:
119
120
  npx @bluelibs/runner-dev --help
120
121
  ```
121
122
 
123
+ Create new project:
124
+
125
+ ```bash
126
+ # Create a new Runner project
127
+ npx @bluelibs/runner-dev new <project-name>
128
+
129
+ # Example
130
+ npx @bluelibs/runner-dev new my-awesome-app
131
+ ```
132
+
133
+ This command creates a new Runner project with:
134
+
135
+ - Complete TypeScript setup with ts-node-dev for development
136
+ - Jest configuration for testing
137
+ - Package.json with all necessary dependencies
138
+ - Basic project structure with main.ts entry point
139
+ - README and .gitignore files
140
+
141
+ Flags for `new`:
142
+
143
+ - `--install`: install dependencies after scaffolding
144
+ - `--run-tests`: run the generated test suite (`npm test -- --runInBand`) after install
145
+ - `--run`: start the dev server (`npm run dev`) after install/tests; this keeps the process running
146
+
147
+ Examples:
148
+
149
+ ```bash
150
+ # Create and auto-install dependencies, then run tests
151
+ npx @bluelibs/runner-dev new my-awesome-app --install --run-tests
152
+
153
+ # Create and start the dev server immediately (blocks)
154
+ npx @bluelibs/runner-dev new my-awesome-app --install --run
155
+ ```
156
+
157
+ Note: the `new` command requires the target directory to be empty. If the directory exists and is not empty, the command aborts with an error.
158
+
159
+ The project name must contain only letters, numbers, dashes, and underscores.
160
+
161
+ After creation, follow the next steps:
162
+
163
+ - `cd <project-name>`
164
+ - `npm install`
165
+ - `npm run dev`
166
+
122
167
  Ping endpoint:
123
168
 
124
169
  ```bash
@@ -141,6 +186,24 @@ ENDPOINT=http://localhost:1337/graphql \
141
186
  ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev query 'query { tasks { id } }' --namespace task.
142
187
  ```
143
188
 
189
+ Dry‑run (no server):
190
+
191
+ ```bash
192
+ # Using a TS entry file default export
193
+ npx @bluelibs/runner-dev query 'query { tasks { id } }' \
194
+ --entry-file ./src/main.ts
195
+
196
+ # Using a named export (e.g., exported as `app`)
197
+ npx @bluelibs/runner-dev query 'query { tasks { id } }' \
198
+ --entry-file ./src/main.ts --export app
199
+
200
+ # Notes
201
+ # - Dry‑run compiles your entry, builds the Runner Store in-memory, and executes the query against
202
+ # an in-memory GraphQL schema. No HTTP server is started.
203
+ # - TypeScript only. Requires ts-node at runtime. If missing, you'll be prompted to install it.
204
+ # - Precedence: when --entry-file is provided, dry‑run mode is used; otherwise the CLI uses --endpoint/ENDPOINT.
205
+ ```
206
+
144
207
  Project overview (Markdown):
145
208
 
146
209
  ```bash
@@ -171,6 +234,13 @@ Flags:
171
234
  - `--format data|json|pretty`: output mode (default `data`)
172
235
  - `--raw`: print full GraphQL envelope including errors
173
236
  - `--namespace <str>`: convenience filter that injects `idIncludes` or `events(filter: { idIncludes })` at the top-level fields when possible
237
+ - `--entry-file <path>`: TypeScript entry file for dry‑run mode (no server)
238
+ - `--export <name>`: named export to use from the entry (default export preferred)
239
+
240
+ Precedence:
241
+
242
+ - If `--entry-file` is present, dry‑run mode is used.
243
+ - Otherwise, remote mode via `--endpoint`/`ENDPOINT` is used.
174
244
 
175
245
  ### Local dev playbook
176
246
 
@@ -0,0 +1,39 @@
1
+ export declare class ArchitectError extends Error {
2
+ readonly code: string;
3
+ readonly context?: Record<string, any> | undefined;
4
+ constructor(message: string, code: string, context?: Record<string, any> | undefined);
5
+ }
6
+ export declare class AIModelError extends ArchitectError {
7
+ readonly modelId?: string | undefined;
8
+ constructor(message: string, modelId?: string | undefined, context?: Record<string, any>);
9
+ }
10
+ export declare class PlanningError extends ArchitectError {
11
+ readonly prompt?: string | undefined;
12
+ constructor(message: string, prompt?: string | undefined, context?: Record<string, any>);
13
+ }
14
+ export declare class ExecutionError extends ArchitectError {
15
+ readonly actionIndex?: number | undefined;
16
+ readonly actionType?: string | undefined;
17
+ constructor(message: string, actionIndex?: number | undefined, actionType?: string | undefined, context?: Record<string, any>);
18
+ }
19
+ export declare class ValidationError extends ArchitectError {
20
+ readonly field?: string | undefined;
21
+ readonly value?: any;
22
+ constructor(message: string, field?: string | undefined, value?: any, context?: Record<string, any>);
23
+ }
24
+ export declare class ConfigurationError extends ArchitectError {
25
+ readonly configKey?: string | undefined;
26
+ constructor(message: string, configKey?: string | undefined, context?: Record<string, any>);
27
+ }
28
+ export declare class PermissionError extends ArchitectError {
29
+ readonly operation?: string | undefined;
30
+ constructor(message: string, operation?: string | undefined, context?: Record<string, any>);
31
+ }
32
+ export declare class PluginError extends ArchitectError {
33
+ readonly pluginName?: string | undefined;
34
+ readonly pluginVersion?: string | undefined;
35
+ constructor(message: string, pluginName?: string | undefined, pluginVersion?: string | undefined, context?: Record<string, any>);
36
+ }
37
+ export declare function isArchitectError(error: unknown): error is ArchitectError;
38
+ export declare function createErrorFromResponse(response: any): ArchitectError;
39
+ export declare function formatErrorForUser(error: ArchitectError): string;
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ // Custom error classes for the architect system
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PluginError = exports.PermissionError = exports.ConfigurationError = exports.ValidationError = exports.ExecutionError = exports.PlanningError = exports.AIModelError = exports.ArchitectError = void 0;
5
+ exports.isArchitectError = isArchitectError;
6
+ exports.createErrorFromResponse = createErrorFromResponse;
7
+ exports.formatErrorForUser = formatErrorForUser;
8
+ class ArchitectError extends Error {
9
+ code;
10
+ context;
11
+ constructor(message, code, context) {
12
+ super(message);
13
+ this.code = code;
14
+ this.context = context;
15
+ this.name = "ArchitectError";
16
+ Object.setPrototypeOf(this, ArchitectError.prototype);
17
+ }
18
+ }
19
+ exports.ArchitectError = ArchitectError;
20
+ class AIModelError extends ArchitectError {
21
+ modelId;
22
+ constructor(message, modelId, context) {
23
+ super(message, "AI_MODEL_ERROR", context);
24
+ this.modelId = modelId;
25
+ this.name = "AIModelError";
26
+ }
27
+ }
28
+ exports.AIModelError = AIModelError;
29
+ class PlanningError extends ArchitectError {
30
+ prompt;
31
+ constructor(message, prompt, context) {
32
+ super(message, "PLANNING_ERROR", context);
33
+ this.prompt = prompt;
34
+ this.name = "PlanningError";
35
+ }
36
+ }
37
+ exports.PlanningError = PlanningError;
38
+ class ExecutionError extends ArchitectError {
39
+ actionIndex;
40
+ actionType;
41
+ constructor(message, actionIndex, actionType, context) {
42
+ super(message, "EXECUTION_ERROR", context);
43
+ this.actionIndex = actionIndex;
44
+ this.actionType = actionType;
45
+ this.name = "ExecutionError";
46
+ }
47
+ }
48
+ exports.ExecutionError = ExecutionError;
49
+ class ValidationError extends ArchitectError {
50
+ field;
51
+ value;
52
+ constructor(message, field, value, context) {
53
+ super(message, "VALIDATION_ERROR", context);
54
+ this.field = field;
55
+ this.value = value;
56
+ this.name = "ValidationError";
57
+ }
58
+ }
59
+ exports.ValidationError = ValidationError;
60
+ class ConfigurationError extends ArchitectError {
61
+ configKey;
62
+ constructor(message, configKey, context) {
63
+ super(message, "CONFIGURATION_ERROR", context);
64
+ this.configKey = configKey;
65
+ this.name = "ConfigurationError";
66
+ }
67
+ }
68
+ exports.ConfigurationError = ConfigurationError;
69
+ class PermissionError extends ArchitectError {
70
+ operation;
71
+ constructor(message, operation, context) {
72
+ super(message, "PERMISSION_ERROR", context);
73
+ this.operation = operation;
74
+ this.name = "PermissionError";
75
+ }
76
+ }
77
+ exports.PermissionError = PermissionError;
78
+ class PluginError extends ArchitectError {
79
+ pluginName;
80
+ pluginVersion;
81
+ constructor(message, pluginName, pluginVersion, context) {
82
+ super(message, "PLUGIN_ERROR", context);
83
+ this.pluginName = pluginName;
84
+ this.pluginVersion = pluginVersion;
85
+ this.name = "PluginError";
86
+ }
87
+ }
88
+ exports.PluginError = PluginError;
89
+ // Error utilities
90
+ function isArchitectError(error) {
91
+ return error instanceof ArchitectError;
92
+ }
93
+ function createErrorFromResponse(response) {
94
+ if (response.error) {
95
+ const { message, code, type } = response.error;
96
+ switch (type) {
97
+ case "invalid_request_error":
98
+ return new ValidationError(message, undefined, undefined, { code });
99
+ case "authentication_error":
100
+ return new ConfigurationError(message, "apiKey", { code });
101
+ case "permission_error":
102
+ return new PermissionError(message, undefined, { code });
103
+ case "rate_limit_error":
104
+ return new AIModelError(message, undefined, {
105
+ code,
106
+ rateLimited: true,
107
+ });
108
+ default:
109
+ return new ArchitectError(message, code || "UNKNOWN_ERROR", response.error);
110
+ }
111
+ }
112
+ return new ArchitectError("Unknown error occurred", "UNKNOWN_ERROR", {
113
+ response,
114
+ });
115
+ }
116
+ function formatErrorForUser(error) {
117
+ switch (error.name) {
118
+ case "AIModelError":
119
+ return `AI Model Error: ${error.message}${error.code ? ` (Model: ${error.name})` : ""}`;
120
+ case "PlanningError":
121
+ return `Planning Error: ${error.message}`;
122
+ case "ExecutionError":
123
+ const execError = error;
124
+ return `Execution Error: ${error.message}${execError.actionIndex !== undefined
125
+ ? ` (Action ${execError.actionIndex})`
126
+ : ""}`;
127
+ case "ValidationError":
128
+ const valError = error;
129
+ return `Validation Error: ${error.message}${valError.field ? ` (Field: ${valError.field})` : ""}`;
130
+ case "ConfigurationError":
131
+ const configError = error;
132
+ return `Configuration Error: ${error.message}${configError.configKey ? ` (Key: ${configError.configKey})` : ""}`;
133
+ case "PermissionError":
134
+ const permError = error;
135
+ return `Permission Error: ${error.message}${permError.operation ? ` (Operation: ${permError.operation})` : ""}`;
136
+ case "PluginError":
137
+ const pluginError = error;
138
+ return `Plugin Error: ${error.message}${pluginError.pluginName ? ` (Plugin: ${pluginError.pluginName})` : ""}`;
139
+ default:
140
+ return `Architect Error: ${error.message}`;
141
+ }
142
+ }
143
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/architect/core/errors.ts"],"names":[],"mappings":";AAAA,gDAAgD;;;AA+FhD,4CAEC;AAED,0DA2BC;AAED,gDAsCC;AApKD,MAAa,cAAe,SAAQ,KAAK;IAGrB;IACA;IAHlB,YACE,OAAe,EACC,IAAY,EACZ,OAA6B;QAE7C,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAsB;QAG7C,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC;CACF;AAVD,wCAUC;AAED,MAAa,YAAa,SAAQ,cAAc;IAG5B;IAFlB,YACE,OAAe,EACC,OAAgB,EAChC,OAA6B;QAE7B,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAH1B,YAAO,GAAP,OAAO,CAAS;QAIhC,IAAI,CAAC,IAA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KAAK,CAAC,OAAO,GACvC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,SAAS,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,EACjE,EAAE,CAAC;QACL,KAAK,aAAa;YAChB,MAAM,WAAW,GAAG,KAAoB,CAAC;YACzC,OAAO,iBAAiB,KAAK,CAAC,OAAO,GACnC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,WAAW,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,EACpE,EAAE,CAAC;QACL;YACE,OAAO,oBAAoB,KAAK,CAAC,OAAO,EAAE,CAAC;IAC/C,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './interfaces';
3
+ export * from './errors';
@@ -0,0 +1,21 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Core exports for the architect system
18
+ __exportStar(require("./types"), exports);
19
+ __exportStar(require("./interfaces"), exports);
20
+ __exportStar(require("./errors"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/architect/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAwC;AACxC,0CAAwB;AACxB,+CAA6B;AAC7B,2CAAyB"}
@@ -0,0 +1,158 @@
1
+ import { AIModelConfig, ChatMessage, ChatCompletionRequest, ChatCompletionResponse, ArchitectPlan, ArchitectResult, ArchitectAction } from './types';
2
+ export interface IAIModel {
3
+ readonly config: AIModelConfig;
4
+ /**
5
+ * Send a chat completion request
6
+ */
7
+ chat(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
8
+ /**
9
+ * Simple text completion with messages
10
+ */
11
+ complete(messages: ChatMessage[]): Promise<string>;
12
+ /**
13
+ * Check if the model supports a specific feature
14
+ */
15
+ supports(feature: 'tools' | 'vision' | 'json_mode'): boolean;
16
+ /**
17
+ * Get model information
18
+ */
19
+ getInfo(): Promise<{
20
+ id: string;
21
+ contextWindow: number;
22
+ maxOutputTokens: number;
23
+ supportedFeatures: string[];
24
+ }>;
25
+ }
26
+ export interface IArchitectPlanner {
27
+ /**
28
+ * Generate a plan from a user prompt
29
+ */
30
+ plan(prompt: string, context?: PlanningContext): Promise<ArchitectPlan>;
31
+ /**
32
+ * Validate a plan before execution
33
+ */
34
+ validate(plan: ArchitectPlan): Promise<ValidationResult>;
35
+ /**
36
+ * Optimize a plan for better execution
37
+ */
38
+ optimize(plan: ArchitectPlan): Promise<ArchitectPlan>;
39
+ /**
40
+ * Estimate the complexity and duration of a plan
41
+ */
42
+ estimate(plan: ArchitectPlan): Promise<PlanEstimate>;
43
+ }
44
+ export interface IArchitectExecutor {
45
+ /**
46
+ * Execute a validated plan
47
+ */
48
+ execute(plan: ArchitectPlan, options?: ExecutionOptions): Promise<ArchitectResult>;
49
+ /**
50
+ * Execute a single action
51
+ */
52
+ executeAction(action: ArchitectAction, context?: ExecutionContext): Promise<ActionResult>;
53
+ /**
54
+ * Check if execution is allowed for the current environment
55
+ */
56
+ canExecute(action: ArchitectAction): Promise<boolean>;
57
+ /**
58
+ * Rollback executed actions if possible
59
+ */
60
+ rollback(result: ArchitectResult): Promise<RollbackResult>;
61
+ }
62
+ export interface PlanningContext {
63
+ projectRoot: string;
64
+ existingFiles: string[];
65
+ packageJson?: any;
66
+ tsConfig?: any;
67
+ runnerConfig?: any;
68
+ constraints?: string[];
69
+ preferences?: Record<string, any>;
70
+ }
71
+ export interface ExecutionOptions {
72
+ dryRun?: boolean;
73
+ allowWrites?: boolean;
74
+ allowCommands?: boolean;
75
+ allowPackageInstalls?: boolean;
76
+ continueOnError?: boolean;
77
+ maxConcurrentActions?: number;
78
+ timeout?: number;
79
+ }
80
+ export interface ExecutionContext {
81
+ projectRoot: string;
82
+ currentDirectory: string;
83
+ environment: Record<string, string>;
84
+ logger: IArchitectLogger;
85
+ }
86
+ export interface ValidationResult {
87
+ valid: boolean;
88
+ errors: ValidationError[];
89
+ warnings: ValidationWarning[];
90
+ suggestions: string[];
91
+ }
92
+ export interface ValidationError {
93
+ actionIndex: number;
94
+ field: string;
95
+ message: string;
96
+ severity: 'error' | 'warning';
97
+ }
98
+ export interface ValidationWarning {
99
+ actionIndex: number;
100
+ message: string;
101
+ recommendation?: string;
102
+ }
103
+ export interface PlanEstimate {
104
+ complexity: 'low' | 'medium' | 'high';
105
+ estimatedDuration: number;
106
+ riskFactors: string[];
107
+ prerequisites: string[];
108
+ }
109
+ export interface ActionResult {
110
+ success: boolean;
111
+ output?: any;
112
+ error?: string;
113
+ logs: string[];
114
+ sideEffects: SideEffect[];
115
+ }
116
+ export interface SideEffect {
117
+ type: 'file_created' | 'file_modified' | 'file_deleted' | 'command_executed' | 'package_installed';
118
+ target: string;
119
+ before?: any;
120
+ after?: any;
121
+ }
122
+ export interface RollbackResult {
123
+ success: boolean;
124
+ actionsRolledBack: number;
125
+ errors: string[];
126
+ warnings: string[];
127
+ }
128
+ export interface IArchitectLogger {
129
+ info(message: string, context?: Record<string, any>): void;
130
+ warn(message: string, context?: Record<string, any>): void;
131
+ error(message: string, error?: Error, context?: Record<string, any>): void;
132
+ debug(message: string, context?: Record<string, any>): void;
133
+ }
134
+ export interface IArchitectPlugin {
135
+ readonly name: string;
136
+ readonly version: string;
137
+ /**
138
+ * Initialize the plugin
139
+ */
140
+ initialize(context: PluginContext): Promise<void>;
141
+ /**
142
+ * Handle custom actions
143
+ */
144
+ handleAction?(action: ArchitectAction): Promise<ActionResult>;
145
+ /**
146
+ * Modify plans before execution
147
+ */
148
+ transformPlan?(plan: ArchitectPlan): Promise<ArchitectPlan>;
149
+ /**
150
+ * Cleanup resources
151
+ */
152
+ dispose?(): Promise<void>;
153
+ }
154
+ export interface PluginContext {
155
+ logger: IArchitectLogger;
156
+ config: Record<string, any>;
157
+ projectRoot: string;
158
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/architect/core/interfaces.ts"],"names":[],"mappings":""}