@aexol/spectral 0.9.230 → 0.9.231

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 (172) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/designer/data/skills/blog-post.d.ts +3 -0
  3. package/dist/designer/data/skills/blog-post.d.ts.map +1 -0
  4. package/dist/designer/data/skills/blog-post.js +84 -0
  5. package/dist/designer/data/skills/blog-post.ts +87 -0
  6. package/dist/designer/data/skills/critique.d.ts +3 -0
  7. package/dist/designer/data/skills/critique.d.ts.map +1 -0
  8. package/dist/designer/data/skills/critique.js +109 -0
  9. package/dist/designer/data/skills/critique.ts +112 -0
  10. package/dist/designer/data/skills/dashboard.d.ts +3 -0
  11. package/dist/designer/data/skills/dashboard.d.ts.map +1 -0
  12. package/dist/designer/data/skills/dashboard.js +165 -0
  13. package/dist/designer/data/skills/dashboard.ts +168 -0
  14. package/dist/designer/data/skills/design-brief.d.ts +3 -0
  15. package/dist/designer/data/skills/design-brief.d.ts.map +1 -0
  16. package/dist/designer/data/skills/design-brief.js +141 -0
  17. package/dist/designer/data/skills/design-brief.ts +144 -0
  18. package/dist/designer/data/skills/design-skill.d.ts +10 -0
  19. package/dist/designer/data/skills/design-skill.d.ts.map +1 -0
  20. package/dist/designer/data/skills/design-skill.js +1 -0
  21. package/dist/designer/data/skills/design-skill.ts +9 -0
  22. package/dist/designer/data/skills/docs-page.d.ts +3 -0
  23. package/dist/designer/data/skills/docs-page.d.ts.map +1 -0
  24. package/dist/designer/data/skills/docs-page.js +68 -0
  25. package/dist/designer/data/skills/docs-page.ts +71 -0
  26. package/dist/designer/data/skills/index.d.ts +3 -0
  27. package/dist/designer/data/skills/index.d.ts.map +1 -0
  28. package/dist/designer/data/skills/index.js +28 -0
  29. package/dist/designer/data/skills/index.ts +30 -0
  30. package/dist/designer/data/skills/magazine-poster.d.ts +3 -0
  31. package/dist/designer/data/skills/magazine-poster.d.ts.map +1 -0
  32. package/dist/designer/data/skills/magazine-poster.js +70 -0
  33. package/dist/designer/data/skills/magazine-poster.ts +73 -0
  34. package/dist/designer/data/skills/mobile-app.d.ts +3 -0
  35. package/dist/designer/data/skills/mobile-app.d.ts.map +1 -0
  36. package/dist/designer/data/skills/mobile-app.js +229 -0
  37. package/dist/designer/data/skills/mobile-app.ts +232 -0
  38. package/dist/designer/data/skills/motion-frames.d.ts +3 -0
  39. package/dist/designer/data/skills/motion-frames.d.ts.map +1 -0
  40. package/dist/designer/data/skills/motion-frames.js +121 -0
  41. package/dist/designer/data/skills/motion-frames.ts +124 -0
  42. package/dist/designer/data/skills/pricing-page.d.ts +3 -0
  43. package/dist/designer/data/skills/pricing-page.d.ts.map +1 -0
  44. package/dist/designer/data/skills/pricing-page.js +76 -0
  45. package/dist/designer/data/skills/pricing-page.ts +79 -0
  46. package/dist/designer/data/skills/saas-landing.d.ts +3 -0
  47. package/dist/designer/data/skills/saas-landing.d.ts.map +1 -0
  48. package/dist/designer/data/skills/saas-landing.js +71 -0
  49. package/dist/designer/data/skills/saas-landing.ts +74 -0
  50. package/dist/designer/data/skills/slide-deck.d.ts +3 -0
  51. package/dist/designer/data/skills/slide-deck.d.ts.map +1 -0
  52. package/dist/designer/data/skills/slide-deck.js +213 -0
  53. package/dist/designer/data/skills/slide-deck.ts +216 -0
  54. package/dist/designer/data/skills/social-carousel.d.ts +3 -0
  55. package/dist/designer/data/skills/social-carousel.d.ts.map +1 -0
  56. package/dist/designer/data/skills/social-carousel.js +135 -0
  57. package/dist/designer/data/skills/social-carousel.ts +138 -0
  58. package/dist/designer/data/skills/web-prototype.d.ts +3 -0
  59. package/dist/designer/data/skills/web-prototype.d.ts.map +1 -0
  60. package/dist/designer/data/skills/web-prototype.js +159 -0
  61. package/dist/designer/data/skills/web-prototype.ts +162 -0
  62. package/dist/designer/skills.d.ts +4 -10
  63. package/dist/designer/skills.d.ts.map +1 -1
  64. package/dist/designer/skills.js +2 -1643
  65. package/dist/extensions/wizard/index.js +9 -1
  66. package/dist/generated/parser/ast/nodes.d.ts +115 -0
  67. package/dist/generated/parser/ast/nodes.d.ts.map +1 -0
  68. package/dist/generated/parser/ast/nodes.js +8 -0
  69. package/dist/generated/parser/lexer/lexer.d.ts +28 -0
  70. package/dist/generated/parser/lexer/lexer.d.ts.map +1 -0
  71. package/dist/generated/parser/{lexer.js → lexer/lexer.js} +1 -180
  72. package/dist/generated/parser/{lexer.d.ts → lexer/tokens.d.ts} +5 -24
  73. package/dist/generated/parser/lexer/tokens.d.ts.map +1 -0
  74. package/dist/generated/parser/lexer/tokens.js +187 -0
  75. package/dist/generated/parser/mod.d.ts +5 -7
  76. package/dist/generated/parser/mod.d.ts.map +1 -1
  77. package/dist/generated/parser/mod.js +2 -1
  78. package/dist/generated/parser/parser/cursor.d.ts +47 -0
  79. package/dist/generated/parser/parser/cursor.d.ts.map +1 -0
  80. package/dist/generated/parser/parser/cursor.js +12 -0
  81. package/dist/generated/parser/parser/definitions.d.ts +16 -0
  82. package/dist/generated/parser/parser/definitions.d.ts.map +1 -0
  83. package/dist/generated/parser/parser/definitions.js +353 -0
  84. package/dist/generated/parser/parser/expressions.d.ts +17 -0
  85. package/dist/generated/parser/parser/expressions.d.ts.map +1 -0
  86. package/dist/generated/parser/parser/expressions.js +165 -0
  87. package/dist/generated/parser/parser.d.ts +18 -133
  88. package/dist/generated/parser/parser.d.ts.map +1 -1
  89. package/dist/generated/parser/parser.js +9 -505
  90. package/dist/generated/parser/tokenizer.d.ts +1 -2
  91. package/dist/generated/parser/tokenizer.d.ts.map +1 -1
  92. package/dist/generated/parser/tokenizer.js +2 -1
  93. package/dist/generated/parser/validator.d.ts +1 -1
  94. package/dist/generated/parser/validator.d.ts.map +1 -1
  95. package/dist/mcp/glimpse-ui.js +9 -1
  96. package/dist/relay/dispatcher.d.ts +11 -104
  97. package/dist/relay/dispatcher.d.ts.map +1 -1
  98. package/dist/relay/dispatcher.js +10 -1130
  99. package/dist/relay/rest.d.ts +31 -0
  100. package/dist/relay/rest.d.ts.map +1 -0
  101. package/dist/relay/rest.js +85 -0
  102. package/dist/relay/routing.d.ts +109 -0
  103. package/dist/relay/routing.d.ts.map +1 -0
  104. package/dist/relay/routing.js +669 -0
  105. package/dist/relay/wizard-login.d.ts +17 -0
  106. package/dist/relay/wizard-login.d.ts.map +1 -0
  107. package/dist/relay/wizard-login.js +419 -0
  108. package/dist/sdk/agent-core/agent-loop.d.ts +2 -9
  109. package/dist/sdk/agent-core/agent-loop.d.ts.map +1 -1
  110. package/dist/sdk/agent-core/agent-loop.js +4 -288
  111. package/dist/sdk/agent-core/tool-execution.d.ts +33 -0
  112. package/dist/sdk/agent-core/tool-execution.d.ts.map +1 -0
  113. package/dist/sdk/agent-core/tool-execution.js +300 -0
  114. package/dist/sdk/ai/env-api-keys.js +9 -1
  115. package/dist/sdk/ai/providers/openai/reasoning-replay.d.ts +48 -0
  116. package/dist/sdk/ai/providers/openai/reasoning-replay.d.ts.map +1 -0
  117. package/dist/sdk/ai/providers/openai/reasoning-replay.js +209 -0
  118. package/dist/sdk/ai/providers/openai-completions.d.ts.map +1 -1
  119. package/dist/sdk/ai/providers/openai-completions.js +1 -203
  120. package/dist/sdk/coding-agent/core/compaction/compaction.d.ts +6 -118
  121. package/dist/sdk/coding-agent/core/compaction/compaction.d.ts.map +1 -1
  122. package/dist/sdk/coding-agent/core/compaction/compaction.js +11 -733
  123. package/dist/sdk/coding-agent/core/compaction/cut-points.d.ts +58 -0
  124. package/dist/sdk/coding-agent/core/compaction/cut-points.d.ts.map +1 -0
  125. package/dist/sdk/coding-agent/core/compaction/cut-points.js +191 -0
  126. package/dist/sdk/coding-agent/core/compaction/dedupe.d.ts +28 -0
  127. package/dist/sdk/coding-agent/core/compaction/dedupe.d.ts.map +1 -0
  128. package/dist/sdk/coding-agent/core/compaction/dedupe.js +156 -0
  129. package/dist/sdk/coding-agent/core/compaction/summarize.d.ts +21 -0
  130. package/dist/sdk/coding-agent/core/compaction/summarize.d.ts.map +1 -0
  131. package/dist/sdk/coding-agent/core/compaction/summarize.js +181 -0
  132. package/dist/sdk/coding-agent/core/compaction/tokens.d.ts +47 -0
  133. package/dist/sdk/coding-agent/core/compaction/tokens.d.ts.map +1 -0
  134. package/dist/sdk/coding-agent/core/compaction/tokens.js +224 -0
  135. package/dist/sdk/coding-agent/core/extensions/session-events.d.ts +157 -0
  136. package/dist/sdk/coding-agent/core/extensions/session-events.d.ts.map +1 -0
  137. package/dist/sdk/coding-agent/core/extensions/session-events.js +13 -0
  138. package/dist/sdk/coding-agent/core/extensions/types.d.ts +6 -365
  139. package/dist/sdk/coding-agent/core/extensions/types.d.ts.map +1 -1
  140. package/dist/sdk/coding-agent/core/extensions/types.js +2 -10
  141. package/dist/sdk/coding-agent/core/extensions/ui-types.d.ts +219 -0
  142. package/dist/sdk/coding-agent/core/extensions/ui-types.d.ts.map +1 -0
  143. package/dist/sdk/coding-agent/core/extensions/ui-types.js +4 -0
  144. package/dist/sdk/coding-agent/core/package/default-package-manager.d.ts +115 -0
  145. package/dist/sdk/coding-agent/core/package/default-package-manager.d.ts.map +1 -0
  146. package/dist/sdk/coding-agent/core/package/default-package-manager.js +1184 -0
  147. package/dist/sdk/coding-agent/core/package/discovery.d.ts +20 -0
  148. package/dist/sdk/coding-agent/core/package/discovery.d.ts.map +1 -0
  149. package/dist/sdk/coding-agent/core/package/discovery.js +283 -0
  150. package/dist/sdk/coding-agent/core/package/ignore.d.ts +29 -0
  151. package/dist/sdk/coding-agent/core/package/ignore.d.ts.map +1 -0
  152. package/dist/sdk/coding-agent/core/package/ignore.js +235 -0
  153. package/dist/sdk/coding-agent/core/package/types.d.ts +128 -0
  154. package/dist/sdk/coding-agent/core/package/types.d.ts.map +1 -0
  155. package/dist/sdk/coding-agent/core/package/types.js +18 -0
  156. package/dist/sdk/coding-agent/core/package/update-check.d.ts +43 -0
  157. package/dist/sdk/coding-agent/core/package/update-check.d.ts.map +1 -0
  158. package/dist/sdk/coding-agent/core/package/update-check.js +253 -0
  159. package/dist/sdk/coding-agent/core/package-manager.d.ts +2 -188
  160. package/dist/sdk/coding-agent/core/package-manager.d.ts.map +1 -1
  161. package/dist/sdk/coding-agent/core/package-manager.js +1 -1940
  162. package/dist/sdk/coding-agent/core/session/migrate.d.ts +18 -0
  163. package/dist/sdk/coding-agent/core/session/migrate.d.ts.map +1 -0
  164. package/dist/sdk/coding-agent/core/session/migrate.js +78 -0
  165. package/dist/sdk/coding-agent/core/session/types.d.ts +165 -0
  166. package/dist/sdk/coding-agent/core/session/types.d.ts.map +1 -0
  167. package/dist/sdk/coding-agent/core/session/types.js +4 -0
  168. package/dist/sdk/coding-agent/core/session-manager.d.ts +3 -161
  169. package/dist/sdk/coding-agent/core/session-manager.d.ts.map +1 -1
  170. package/dist/sdk/coding-agent/core/session-manager.js +4 -72
  171. package/package.json +2 -2
  172. package/dist/generated/parser/lexer.d.ts.map +0 -1
@@ -7,7 +7,9 @@
7
7
  * workflows, and agent structures.
8
8
  */
9
9
  import { Tokenizer } from "./tokenizer.js";
10
- import { TokenType } from "./lexer.js";
10
+ import { TokenType } from "./lexer/tokens.js";
11
+ import { parseAgent, parseRole, parseTypeDefinition, parseVisitor, parseWorkflow, } from "./parser/definitions.js";
12
+ import { parseCondition } from "./parser/expressions.js";
11
13
  export class Parser {
12
14
  tokenizer;
13
15
  currentToken;
@@ -126,20 +128,20 @@ export class Parser {
126
128
  // Check for description before any definition
127
129
  const description = this.parseDescriptionIfPresent();
128
130
  if (this.check(TokenType.VISITOR)) {
129
- body.push(this.parseVisitor(description));
131
+ body.push(parseVisitor(this, description));
130
132
  }
131
133
  else if (this.check(TokenType.ROLE)) {
132
- body.push(this.parseRole(description));
134
+ body.push(parseRole(this, description));
133
135
  }
134
136
  else if (this.check(TokenType.WORKFLOW)) {
135
- body.push(this.parseWorkflow(description));
137
+ body.push(parseWorkflow(this, description));
136
138
  }
137
139
  else if (this.check(TokenType.AGENT)) {
138
- body.push(this.parseAgent(description));
140
+ body.push(parseAgent(this, description));
139
141
  }
140
142
  else if (this.check(TokenType.TYPE) || this.check(TokenType.ENUM) ||
141
143
  this.check(TokenType.INTERFACE)) {
142
- body.push(this.parseTypeDefinition(description));
144
+ body.push(parseTypeDefinition(this, description));
143
145
  }
144
146
  else {
145
147
  this.throwUnexpectedTopLevelToken(description);
@@ -157,34 +159,6 @@ export class Parser {
157
159
  },
158
160
  };
159
161
  }
160
- parseVisitor(description) {
161
- const startToken = this.consume(TokenType.VISITOR);
162
- let name;
163
- if (this.check(TokenType.IDENTIFIER)) {
164
- name = this.advance().value;
165
- }
166
- this.skipNewlines();
167
- this.consume(TokenType.LBRACE, "Expected '{' after visitor");
168
- this.skipNewlines();
169
- const capabilities = [];
170
- while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
171
- capabilities.push(this.parseCapability());
172
- this.skipNewlines();
173
- }
174
- this.consume(TokenType.RBRACE, "Expected '}' after visitor body");
175
- return {
176
- type: "VisitorDefinition",
177
- name,
178
- description,
179
- capabilities,
180
- location: {
181
- start: startToken.location.offset,
182
- end: this.currentToken.location.offset,
183
- line: startToken.location.line,
184
- column: startToken.location.column,
185
- },
186
- };
187
- }
188
162
  parseCapability() {
189
163
  // Check for description before capability
190
164
  const description = this.parseDescriptionIfPresent();
@@ -236,7 +210,7 @@ export class Parser {
236
210
  // Check for inline conditions
237
211
  if (this.check(TokenType.IF) || this.check(TokenType.WHEN)) {
238
212
  this.advance();
239
- conditions.push(this.parseCondition());
213
+ conditions.push(parseCondition(this));
240
214
  }
241
215
  return {
242
216
  type: "Capability",
@@ -253,476 +227,6 @@ export class Parser {
253
227
  },
254
228
  };
255
229
  }
256
- parseCondition() {
257
- const startToken = this.currentToken;
258
- const expression = this.parseExpression();
259
- return {
260
- type: "Condition",
261
- expression,
262
- location: {
263
- start: startToken.location.offset,
264
- end: this.currentToken.location.offset,
265
- line: startToken.location.line,
266
- column: startToken.location.column,
267
- },
268
- };
269
- }
270
- parseExpression() {
271
- return this.parseOrExpression();
272
- }
273
- parseOrExpression() {
274
- const startToken = this.currentToken;
275
- let left = this.parseAndExpression();
276
- while (this.check(TokenType.OR)) {
277
- this.advance();
278
- const right = this.parseAndExpression();
279
- left = {
280
- type: "Expression",
281
- operator: "or",
282
- left,
283
- right,
284
- location: {
285
- start: startToken.location.offset,
286
- end: this.currentToken.location.offset,
287
- line: startToken.location.line,
288
- column: startToken.location.column,
289
- },
290
- };
291
- }
292
- return left;
293
- }
294
- parseAndExpression() {
295
- const startToken = this.currentToken;
296
- let left = this.parseComparisonExpression();
297
- while (this.check(TokenType.AND)) {
298
- this.advance();
299
- const right = this.parseComparisonExpression();
300
- left = {
301
- type: "Expression",
302
- operator: "and",
303
- left,
304
- right,
305
- location: {
306
- start: startToken.location.offset,
307
- end: this.currentToken.location.offset,
308
- line: startToken.location.line,
309
- column: startToken.location.column,
310
- },
311
- };
312
- }
313
- return left;
314
- }
315
- parseComparisonExpression() {
316
- const startToken = this.currentToken;
317
- let left = this.parsePrimaryExpression();
318
- while (this.checkAny(TokenType.EQ, TokenType.NEQ, TokenType.LT, TokenType.LTE, TokenType.GT, TokenType.GTE)) {
319
- const op = this.advance().value;
320
- const right = this.parsePrimaryExpression();
321
- left = {
322
- type: "Expression",
323
- operator: op,
324
- left,
325
- right,
326
- location: {
327
- start: startToken.location.offset,
328
- end: this.currentToken.location.offset,
329
- line: startToken.location.line,
330
- column: startToken.location.column,
331
- },
332
- };
333
- }
334
- return left;
335
- }
336
- parsePrimaryExpression() {
337
- const startToken = this.currentToken;
338
- if (this.check(TokenType.TRUE)) {
339
- this.advance();
340
- return {
341
- type: "Expression",
342
- value: true,
343
- location: {
344
- start: startToken.location.offset,
345
- end: this.currentToken.location.offset,
346
- line: startToken.location.line,
347
- column: startToken.location.column,
348
- },
349
- };
350
- }
351
- if (this.check(TokenType.FALSE)) {
352
- this.advance();
353
- return {
354
- type: "Expression",
355
- value: false,
356
- location: {
357
- start: startToken.location.offset,
358
- end: this.currentToken.location.offset,
359
- line: startToken.location.line,
360
- column: startToken.location.column,
361
- },
362
- };
363
- }
364
- if (this.check(TokenType.NUMBER)) {
365
- const value = Number(this.advance().value);
366
- return {
367
- type: "Expression",
368
- value,
369
- location: {
370
- start: startToken.location.offset,
371
- end: this.currentToken.location.offset,
372
- line: startToken.location.line,
373
- column: startToken.location.column,
374
- },
375
- };
376
- }
377
- if (this.check(TokenType.STRING)) {
378
- const value = this.advance().value;
379
- return {
380
- type: "Expression",
381
- value,
382
- location: {
383
- start: startToken.location.offset,
384
- end: this.currentToken.location.offset,
385
- line: startToken.location.line,
386
- column: startToken.location.column,
387
- },
388
- };
389
- }
390
- if (this.check(TokenType.IDENTIFIER)) {
391
- const value = this.advance().value;
392
- return {
393
- type: "Expression",
394
- value,
395
- location: {
396
- start: startToken.location.offset,
397
- end: this.currentToken.location.offset,
398
- line: startToken.location.line,
399
- column: startToken.location.column,
400
- },
401
- };
402
- }
403
- if (this.check(TokenType.LPAREN)) {
404
- this.advance();
405
- const expr = this.parseExpression();
406
- this.consume(TokenType.RPAREN, "Expected ')' after expression");
407
- return expr;
408
- }
409
- throw new SyntaxError(`Unexpected token in expression: ${this.currentToken.type}`);
410
- }
411
- parseRole(description) {
412
- const startToken = this.consume(TokenType.ROLE);
413
- const name = this.consume(TokenType.IDENTIFIER, "Expected role name").value;
414
- this.skipNewlines();
415
- this.consume(TokenType.LBRACE, "Expected '{' after role name");
416
- this.skipNewlines();
417
- const permissions = [];
418
- const inherits = [];
419
- while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
420
- const loopStart = this.currentToken.location.offset;
421
- // Check for description before permission
422
- const permissionDescription = this.parseDescriptionIfPresent();
423
- if (this.check(TokenType.PERMISSION)) {
424
- this.advance();
425
- const resource = this.consume(TokenType.IDENTIFIER, "Expected resource name").value;
426
- const actions = [];
427
- if (this.check(TokenType.LBRACE)) {
428
- this.advance();
429
- this.skipNewlines();
430
- while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
431
- actions.push(this.consume(TokenType.IDENTIFIER, "Expected action name").value);
432
- if (this.check(TokenType.COMMA)) {
433
- this.advance();
434
- this.skipNewlines();
435
- }
436
- this.skipNewlines();
437
- }
438
- this.consume(TokenType.RBRACE, "Expected '}' after actions");
439
- }
440
- permissions.push({
441
- type: "Permission",
442
- resource,
443
- description: permissionDescription,
444
- actions,
445
- location: {
446
- start: startToken.location.offset,
447
- end: this.currentToken.location.offset,
448
- line: startToken.location.line,
449
- column: startToken.location.column,
450
- },
451
- });
452
- }
453
- else {
454
- // If we hit an unexpected token, throw an error instead of hanging
455
- throw new SyntaxError(`Unexpected token '${this.currentToken.value}' (type: ${this.currentToken.type}) at line ${this.currentToken.location.line}. ` +
456
- `Expected 'permission' keyword or '}' to close role definition. ` +
457
- `Note: Role definitions use 'permission resource { actions }' syntax, not field syntax with colons.`);
458
- }
459
- this.skipNewlines();
460
- // Safety: ensure we're advancing
461
- if (this.currentToken.location.offset === loopStart &&
462
- !this.check(TokenType.RBRACE)) {
463
- throw new SyntaxError(`Parser stuck in role definition at line ${this.currentToken.location.line}`);
464
- }
465
- }
466
- this.consume(TokenType.RBRACE, "Expected '}' after role body");
467
- return {
468
- type: "RoleDefinition",
469
- name,
470
- description,
471
- permissions,
472
- inherits: inherits.length > 0 ? inherits : undefined,
473
- location: {
474
- start: startToken.location.offset,
475
- end: this.currentToken.location.offset,
476
- line: startToken.location.line,
477
- column: startToken.location.column,
478
- },
479
- };
480
- }
481
- parseWorkflow(description) {
482
- const startToken = this.consume(TokenType.WORKFLOW);
483
- const name = this.consume(TokenType.IDENTIFIER, "Expected workflow name").value;
484
- this.skipNewlines();
485
- this.consume(TokenType.LBRACE, "Expected '{' after workflow name");
486
- this.skipNewlines();
487
- const steps = [];
488
- let initialState = "";
489
- const finalStates = [];
490
- while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
491
- // Check for description before state
492
- const stepDescription = this.parseDescriptionIfPresent();
493
- // Handle 'initial <stateName>' to set the initial state
494
- if (this.check(TokenType.INITIAL)) {
495
- this.advance();
496
- initialState = this.consume(TokenType.IDENTIFIER, "Expected state name after 'initial'").value;
497
- this.skipNewlines();
498
- continue;
499
- }
500
- if (this.check(TokenType.STATE)) {
501
- this.advance();
502
- const stateName = this.consume(TokenType.IDENTIFIER, "Expected state name").value;
503
- if (this.match(TokenType.ARROW)) {
504
- const transitions = [];
505
- while (!this.check(TokenType.NEWLINE) && !this.check(TokenType.RBRACE) &&
506
- !this.isAtEnd()) {
507
- const toState = this.consume(TokenType.IDENTIFIER, "Expected target state").value;
508
- transitions.push({
509
- type: "Transition",
510
- from: stateName,
511
- to: toState,
512
- location: {
513
- start: startToken.location.offset,
514
- end: this.currentToken.location.offset,
515
- line: startToken.location.line,
516
- column: startToken.location.column,
517
- },
518
- });
519
- if (this.match(TokenType.COMMA)) {
520
- // Continue parsing transitions
521
- }
522
- else {
523
- break;
524
- }
525
- }
526
- steps.push({
527
- type: "WorkflowStep",
528
- name: stateName,
529
- description: stepDescription,
530
- action: "transition",
531
- transitions,
532
- location: {
533
- start: startToken.location.offset,
534
- end: this.currentToken.location.offset,
535
- line: startToken.location.line,
536
- column: startToken.location.column,
537
- },
538
- });
539
- }
540
- this.skipNewlines();
541
- continue;
542
- }
543
- // If we reach here, we have an unexpected token in the workflow body
544
- throw new SyntaxError(`Unexpected token '${this.currentToken.type}' in workflow definition at line ${this.currentToken.location.line}:${this.currentToken.location.column}. ` +
545
- `Workflows should contain 'initial <state>' or 'state <name> -> <transitions>' declarations. ` +
546
- `Note: Workflows use state machine syntax, not method declarations.`);
547
- }
548
- this.consume(TokenType.RBRACE, "Expected '}' after workflow body");
549
- return {
550
- type: "WorkflowDefinition",
551
- name,
552
- description,
553
- steps,
554
- initialState,
555
- finalStates,
556
- location: {
557
- start: startToken.location.offset,
558
- end: this.currentToken.location.offset,
559
- line: startToken.location.line,
560
- column: startToken.location.column,
561
- },
562
- };
563
- }
564
- parseAgent(description) {
565
- const startToken = this.consume(TokenType.AGENT);
566
- const name = this.consume(TokenType.IDENTIFIER, "Expected agent name").value;
567
- let role = "";
568
- if (this.match(TokenType.COLON)) {
569
- role = this.consume(TokenType.IDENTIFIER, "Expected role name").value;
570
- }
571
- this.skipNewlines();
572
- this.consume(TokenType.LBRACE, "Expected '{' after agent name");
573
- this.skipNewlines();
574
- const capabilities = [];
575
- const responsibilities = [];
576
- let skills;
577
- let model;
578
- let maxConcurrent;
579
- while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
580
- if (this.check(TokenType.CAPABILITIES)) {
581
- this.advance();
582
- this.consume(TokenType.COLON, "Expected ':' after capabilities");
583
- const capList = this.parseStringArray();
584
- // Convert to capability nodes
585
- for (const cap of capList) {
586
- capabilities.push({
587
- type: "Capability",
588
- verb: "can",
589
- action: cap,
590
- location: {
591
- start: startToken.location.offset,
592
- end: this.currentToken.location.offset,
593
- line: startToken.location.line,
594
- column: startToken.location.column,
595
- },
596
- });
597
- }
598
- }
599
- else if (this.check(TokenType.SKILLS)) {
600
- this.advance();
601
- this.consume(TokenType.COLON, "Expected ':' after skills");
602
- skills = this.parseStringArray();
603
- }
604
- else if (this.check(TokenType.MODEL)) {
605
- this.advance();
606
- this.consume(TokenType.COLON, "Expected ':' after model");
607
- model = this.consume(TokenType.STRING, "Expected string value").value;
608
- }
609
- else if (this.check(TokenType.MAX_CONCURRENT)) {
610
- this.advance();
611
- this.consume(TokenType.COLON, "Expected ':' after max_concurrent");
612
- maxConcurrent = parseInt(this.consume(TokenType.NUMBER, "Expected number value").value);
613
- }
614
- else if (this.check(TokenType.STRING) || this.check(TokenType.IDENTIFIER) ||
615
- this.check(TokenType.PROMPT)) {
616
- // Parse the full capability with nested capabilities support (including descriptions)
617
- capabilities.push(this.parseCapability());
618
- }
619
- else {
620
- this.advance();
621
- }
622
- this.skipNewlines();
623
- }
624
- this.consume(TokenType.RBRACE, "Expected '}' after agent body");
625
- // Determine agent kind based on properties
626
- // Builder agents have skills, model, or maxConcurrent properties
627
- // Domain agents have business logic capabilities and may have roles
628
- const agentKind = (skills !== undefined || model !== undefined ||
629
- maxConcurrent !== undefined)
630
- ? "builder"
631
- : "domain";
632
- return {
633
- type: "AgentDefinition",
634
- name,
635
- description,
636
- agentKind,
637
- role,
638
- responsibilities,
639
- capabilities,
640
- skills,
641
- model,
642
- maxConcurrent,
643
- location: {
644
- start: startToken.location.offset,
645
- end: this.currentToken.location.offset,
646
- line: startToken.location.line,
647
- column: startToken.location.column,
648
- },
649
- };
650
- }
651
- parseTypeDefinition(description) {
652
- const startToken = this.currentToken;
653
- let kind = "type";
654
- if (this.check(TokenType.TYPE)) {
655
- kind = "type";
656
- this.advance();
657
- }
658
- else if (this.check(TokenType.ENUM)) {
659
- kind = "enum";
660
- this.advance();
661
- }
662
- else if (this.check(TokenType.INTERFACE)) {
663
- kind = "interface";
664
- this.advance();
665
- }
666
- this.skipNewlines();
667
- const name = this.consumeIdentifierOrKeyword(`Expected type name after '${kind}' keyword at line ${this.currentToken.location.line}:${this.currentToken.location.column}. Got '${this.currentToken.value || this.currentToken.type}' instead.`).value;
668
- this.skipNewlines();
669
- this.consume(TokenType.LBRACE, "Expected '{' after type name");
670
- this.skipNewlines();
671
- const fields = [];
672
- const values = [];
673
- while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
674
- if (kind === "enum") {
675
- // Enum values remain plain strings (no descriptions)
676
- values.push(this.consumeIdentifierOrKeyword("Expected enum value").value);
677
- }
678
- else {
679
- // Check for description before field
680
- const fieldDescription = this.parseDescriptionIfPresent();
681
- const fieldName = this.consumeIdentifierOrKeyword("Expected field name").value;
682
- this.consume(TokenType.COLON, "Expected ':' after field name");
683
- // Parse field type with optional array syntax
684
- let fieldType = this.consumeIdentifierOrKeyword("Expected field type").value;
685
- // Handle array syntax: string[], TypeName[], TypeName[][]
686
- while (this.check(TokenType.LBRACKET)) {
687
- this.advance(); // consume '['
688
- this.consume(TokenType.RBRACKET, "Expected ']' after '['");
689
- fieldType += "[]";
690
- }
691
- fields.push({
692
- type: "TypeField",
693
- name: fieldName,
694
- description: fieldDescription,
695
- fieldType,
696
- required: true,
697
- location: {
698
- start: startToken.location.offset,
699
- end: this.currentToken.location.offset,
700
- line: startToken.location.line,
701
- column: startToken.location.column,
702
- },
703
- });
704
- }
705
- if (this.check(TokenType.COMMA)) {
706
- this.advance();
707
- }
708
- this.skipNewlines();
709
- }
710
- this.consume(TokenType.RBRACE, "Expected '}' after type body");
711
- return {
712
- type: "TypeDefinition",
713
- name,
714
- description,
715
- kind,
716
- fields: fields.length > 0 ? fields : undefined,
717
- values: values.length > 0 ? values : undefined,
718
- location: {
719
- start: startToken.location.offset,
720
- end: this.currentToken.location.offset,
721
- line: startToken.location.line,
722
- column: startToken.location.column,
723
- },
724
- };
725
- }
726
230
  /**
727
231
  * Parse string array: [item1, item2, item3]
728
232
  */
@@ -4,8 +4,7 @@
4
4
  * Provides a stream-like interface for token consumption and lookahead.
5
5
  * Builds on the Lexer to handle token stream management.
6
6
  */
7
- import { TokenType } from "./lexer.js";
8
- import type { Token } from "./lexer.js";
7
+ import { type Token, TokenType } from "./lexer/tokens.js";
9
8
  export declare class Tokenizer {
10
9
  private tokens;
11
10
  private position;
@@ -1 +1 @@
1
- {"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../../../src/generated/parser/tokenizer.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,EAAS,SAAS,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,QAAQ,CAAa;gBAEjB,MAAM,EAAE,MAAM;IAS1B;;OAEG;IACI,OAAO,IAAI,KAAK;IAIvB;;OAEG;IACI,IAAI,CAAC,MAAM,SAAI,GAAG,KAAK;IAK9B;;OAEG;IACI,QAAQ,CAAC,MAAM,SAAI,GAAG,KAAK;IAIlC;;OAEG;IACI,OAAO,IAAI,KAAK;IAQvB;;OAEG;IACI,KA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EAAE,MAAM,GAAG,KAAK,EAAE;IAIjD;;OAEG;IACI,YAAY,IAAI,IAAI;IAM3B;;OAEG;IACI,eAAe,IAAI,IAAI;IAM9B;;OAEG;IACI,cAAc,IAAI;QACvB,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,YAAY,EAAE,KAAK,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;KACzB;CAQF"}
@@ -5,7 +5,8 @@
5
5
  * Provides a stream-like interface for token consumption and lookahead.
6
6
  * Builds on the Lexer to handle token stream management.
7
7
  */
8
- import { Lexer, TokenType } from "./lexer.js";
8
+ import { Lexer } from "./lexer/lexer.js";
9
+ import { TokenType } from "./lexer/tokens.js";
9
10
  export class Tokenizer {
10
11
  tokens;
11
12
  position = 0;
@@ -4,7 +4,7 @@
4
4
  * Validates the AST and provides semantic analysis.
5
5
  * Checks for errors, warnings, and best practices.
6
6
  */
7
- import type { ASTNode, Program } from "./parser.js";
7
+ import type { ASTNode, Program } from "./ast/nodes.js";
8
8
  export interface ValidationError {
9
9
  type: "error" | "warning" | "info";
10
10
  message: string;
@@ -1 +1 @@
1
- {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../src/generated/parser/validator.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,KAAK,EAEV,OAAO,EAEP,OAAO,EAKR,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,KAAK,EAAE,eAAe,EAAE,CAAC;CAC1B;AAED,qBAAa,SAA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,OAAO,CAAU;IACzB,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,KAAK,CAAyB;IACtC,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,qBAAqB,CAAK;IAClC,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,gBAAgB,CAA0B;IAClD,OAAO,CAAC,aAAa,CAA0B;gBAEnC,OAAO,EAAE,OAAO;IAIrB,QAAQ,IAAI,gBAAgB;IAgEnC,OAAO,CAAC,eAAe;IAiCvB,OAAO,CAAC,kBAAkB;IAgB1B,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,gBAAgB;IA+BxB,OAAO,CAAC,aAAa;IAkCrB,OAAO,CAAC,mBAAmB;IAmB3B,OAAO,CAAC,oBAAoB;IA2B5B,OAAO,CAAC,YAAY;IA2BpB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,OAAO;CAGhB"}
@@ -1,3 +1,11 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
1
9
  import { existsSync } from "node:fs";
2
10
  import { execFileSync } from "node:child_process";
3
11
  import { join, dirname } from "node:path";
@@ -43,7 +51,7 @@ export async function openGlimpseWindow(html, options) {
43
51
  const modulePath = resolvedBinaryPath
44
52
  ? join(dirname(resolvedBinaryPath), "glimpse.mjs")
45
53
  : "glimpseui";
46
- const glimpse = await import(modulePath);
54
+ const glimpse = await import(__rewriteRelativeImportExtension(modulePath));
47
55
  let active = true;
48
56
  const win = glimpse.open(html, {
49
57
  width: options.width ?? 900,