@synergenius/flow-weaver 0.7.0 → 0.8.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 (31) hide show
  1. package/dist/annotation-generator.js +7 -7
  2. package/dist/api/generate-in-place.js +25 -20
  3. package/dist/api/patterns.js +12 -15
  4. package/dist/chevrotain-parser/node-parser.d.ts +4 -0
  5. package/dist/chevrotain-parser/node-parser.js +24 -1
  6. package/dist/chevrotain-parser/tokens.d.ts +1 -0
  7. package/dist/chevrotain-parser/tokens.js +5 -0
  8. package/dist/cli/flow-weaver.mjs +106 -107
  9. package/dist/cli/templates/workflows/aggregator.js +3 -6
  10. package/dist/cli/templates/workflows/ai-agent-durable.js +4 -8
  11. package/dist/cli/templates/workflows/ai-agent.js +3 -6
  12. package/dist/cli/templates/workflows/ai-chat.js +3 -6
  13. package/dist/cli/templates/workflows/ai-pipeline-durable.js +4 -8
  14. package/dist/cli/templates/workflows/ai-rag.js +2 -4
  15. package/dist/cli/templates/workflows/ai-react.js +3 -6
  16. package/dist/cli/templates/workflows/conditional.js +3 -6
  17. package/dist/cli/templates/workflows/error-handler.js +2 -4
  18. package/dist/cli/templates/workflows/foreach.js +3 -6
  19. package/dist/cli/templates/workflows/sequential.js +7 -8
  20. package/dist/cli/templates/workflows/webhook.js +3 -6
  21. package/dist/doc-metadata/extractors/annotations.js +9 -6
  22. package/dist/editor-completions/jsDocAnnotations.js +5 -3
  23. package/dist/jsdoc-parser.d.ts +2 -0
  24. package/dist/jsdoc-parser.js +6 -1
  25. package/dist/parser.js +1 -0
  26. package/docs/reference/concepts.md +8 -7
  27. package/docs/reference/iterative-development.md +2 -3
  28. package/docs/reference/jsdoc-grammar.md +8 -3
  29. package/docs/reference/patterns.md +2 -4
  30. package/docs/reference/tutorial.md +8 -14
  31. package/package.json +1 -1
@@ -30993,11 +30993,6 @@ var AnnotationGenerator = class {
30993
30993
  if (workflow.ui?.startNode?.x !== void 0 && workflow.ui?.startNode?.y !== void 0) {
30994
30994
  lines.push(` * @position Start ${Math.round(workflow.ui.startNode.x)} ${Math.round(workflow.ui.startNode.y)}`);
30995
30995
  }
30996
- workflow.instances.forEach((instance) => {
30997
- if (instance.config?.x !== void 0 && instance.config?.y !== void 0) {
30998
- lines.push(` * @position ${instance.id} ${Math.round(instance.config.x)} ${Math.round(instance.config.y)}`);
30999
- }
31000
- });
31001
30996
  if (workflow.ui?.exitNode?.x !== void 0 && workflow.ui?.exitNode?.y !== void 0) {
31002
30997
  lines.push(` * @position Exit ${Math.round(workflow.ui.exitNode.x)} ${Math.round(workflow.ui.exitNode.y)}`);
31003
30998
  }
@@ -31212,7 +31207,11 @@ function generateNodeInstanceTag(instance) {
31212
31207
  if (instance.config?.width !== void 0 && instance.config?.height !== void 0) {
31213
31208
  sizeAttr = ` [size: ${Math.round(instance.config.width)} ${Math.round(instance.config.height)}]`;
31214
31209
  }
31215
- return ` * @node ${instance.id} ${instance.nodeType}${parent}${labelAttr}${portOrderAttr}${portLabelAttr}${exprAttr}${pullExecutionAttr}${minimizedAttr}${colorAttr}${iconAttr}${tagsAttr}${sizeAttr}`;
31210
+ let positionAttr = "";
31211
+ if (instance.config?.x !== void 0 && instance.config?.y !== void 0) {
31212
+ positionAttr = ` [position: ${Math.round(instance.config.x)} ${Math.round(instance.config.y)}]`;
31213
+ }
31214
+ return ` * @node ${instance.id} ${instance.nodeType}${parent}${labelAttr}${portOrderAttr}${portLabelAttr}${exprAttr}${pullExecutionAttr}${minimizedAttr}${colorAttr}${iconAttr}${tagsAttr}${sizeAttr}${positionAttr}`;
31216
31215
  }
31217
31216
  var annotationGenerator = new AnnotationGenerator();
31218
31217
 
@@ -32067,13 +32066,28 @@ function generateWorkflowJSDoc(ast, options = {}) {
32067
32066
  }
32068
32067
  lines.push(` * @fwImport ${npmType.name} ${actualFunctionName} from "${npmType.importSource}"`);
32069
32068
  }
32069
+ const autoPositions = computeAutoPositions(ast);
32070
32070
  for (const instance of ast.instances) {
32071
32071
  if (macroInstanceIds.has(instance.id)) continue;
32072
- if (macroChildIds.has(instance.id) && instance.parent) {
32073
- const stripped = { ...instance, parent: void 0 };
32072
+ let inst = instance;
32073
+ if (inst.config?.x === void 0 || inst.config?.y === void 0) {
32074
+ const autoPos = autoPositions.get(inst.id);
32075
+ if (autoPos) {
32076
+ inst = {
32077
+ ...inst,
32078
+ config: {
32079
+ ...inst.config,
32080
+ x: inst.config?.x ?? autoPos.x,
32081
+ y: inst.config?.y ?? autoPos.y
32082
+ }
32083
+ };
32084
+ }
32085
+ }
32086
+ if (macroChildIds.has(inst.id) && inst.parent) {
32087
+ const stripped = { ...inst, parent: void 0 };
32074
32088
  lines.push(generateNodeInstanceTag(stripped));
32075
32089
  } else {
32076
- lines.push(generateNodeInstanceTag(instance));
32090
+ lines.push(generateNodeInstanceTag(inst));
32077
32091
  }
32078
32092
  }
32079
32093
  const existingMacros = filterStaleMacros(
@@ -32116,22 +32130,11 @@ function generateWorkflowJSDoc(ast, options = {}) {
32116
32130
  }
32117
32131
  }
32118
32132
  }
32119
- const autoPositions = computeAutoPositions(ast);
32120
32133
  const startX = ast.ui?.startNode?.x ?? autoPositions.get("Start")?.x;
32121
32134
  const startY = ast.ui?.startNode?.y ?? autoPositions.get("Start")?.y;
32122
32135
  if (startX !== void 0 && startY !== void 0) {
32123
32136
  lines.push(` * @position Start ${Math.round(startX)} ${Math.round(startY)}`);
32124
32137
  }
32125
- for (const instance of ast.instances) {
32126
- const explicitX = instance.config?.x;
32127
- const explicitY = instance.config?.y;
32128
- const autoPos = autoPositions.get(instance.id);
32129
- const x = explicitX ?? autoPos?.x;
32130
- const y = explicitY ?? autoPos?.y;
32131
- if (x !== void 0 && y !== void 0) {
32132
- lines.push(` * @position ${instance.id} ${Math.round(x)} ${Math.round(y)}`);
32133
- }
32134
- }
32135
32138
  const exitX = ast.ui?.exitNode?.x ?? autoPositions.get("Exit")?.x;
32136
32139
  const exitY = ast.ui?.exitNode?.y ?? autoPositions.get("Exit")?.y;
32137
32140
  if (exitX !== void 0 && exitY !== void 0) {
@@ -41796,6 +41799,10 @@ var SizePrefix = createToken({
41796
41799
  name: "SizePrefix",
41797
41800
  pattern: /size:/
41798
41801
  });
41802
+ var PositionPrefix = createToken({
41803
+ name: "PositionPrefix",
41804
+ pattern: /position:/
41805
+ });
41799
41806
  var ColorPrefix = createToken({
41800
41807
  name: "ColorPrefix",
41801
41808
  pattern: /color:/
@@ -41970,6 +41977,7 @@ var allTokens = [
41970
41977
  MergeStrategyPrefix,
41971
41978
  PullExecutionPrefix,
41972
41979
  SizePrefix,
41980
+ PositionPrefix,
41973
41981
  ColorPrefix,
41974
41982
  IconPrefix,
41975
41983
  TagsPrefix,
@@ -42408,6 +42416,7 @@ var NodeParser = class extends CstParser {
42408
42416
  { ALT: () => this.SUBRULE(this.minimizedAttr) },
42409
42417
  { ALT: () => this.SUBRULE(this.pullExecutionAttr) },
42410
42418
  { ALT: () => this.SUBRULE(this.sizeAttr) },
42419
+ { ALT: () => this.SUBRULE(this.positionAttr) },
42411
42420
  { ALT: () => this.SUBRULE(this.colorAttr) },
42412
42421
  { ALT: () => this.SUBRULE(this.iconAttr) },
42413
42422
  { ALT: () => this.SUBRULE(this.tagsAttr) }
@@ -42500,6 +42509,12 @@ var NodeParser = class extends CstParser {
42500
42509
  this.CONSUME(Integer, { LABEL: "widthValue" });
42501
42510
  this.CONSUME2(Integer, { LABEL: "heightValue" });
42502
42511
  });
42512
+ // position: x y
42513
+ positionAttr = this.RULE("positionAttr", () => {
42514
+ this.CONSUME(PositionPrefix);
42515
+ this.CONSUME(Integer, { LABEL: "xValue" });
42516
+ this.CONSUME2(Integer, { LABEL: "yValue" });
42517
+ });
42503
42518
  // color: "value"
42504
42519
  colorAttr = this.RULE("colorAttr", () => {
42505
42520
  this.CONSUME(ColorPrefix);
@@ -42546,6 +42561,7 @@ var NodeVisitor = class extends BaseVisitor2 {
42546
42561
  let minimized;
42547
42562
  let pullExecution;
42548
42563
  let size;
42564
+ let position;
42549
42565
  let color;
42550
42566
  let icon;
42551
42567
  let tags;
@@ -42562,6 +42578,7 @@ var NodeVisitor = class extends BaseVisitor2 {
42562
42578
  if (attrs.minimized) minimized = attrs.minimized;
42563
42579
  if (attrs.pullExecution) pullExecution = attrs.pullExecution;
42564
42580
  if (attrs.size) size = attrs.size;
42581
+ if (attrs.position) position = attrs.position;
42565
42582
  if (attrs.color) color = attrs.color;
42566
42583
  if (attrs.icon) icon = attrs.icon;
42567
42584
  if (attrs.tags) tags = [...tags || [], ...attrs.tags];
@@ -42578,6 +42595,7 @@ var NodeVisitor = class extends BaseVisitor2 {
42578
42595
  ...minimized && { minimized },
42579
42596
  ...pullExecution && { pullExecution },
42580
42597
  ...size && { size },
42598
+ ...position && { position },
42581
42599
  ...color && { color },
42582
42600
  ...icon && { icon },
42583
42601
  ...tags && { tags }
@@ -42596,6 +42614,7 @@ var NodeVisitor = class extends BaseVisitor2 {
42596
42614
  let minimized;
42597
42615
  let pullExecution;
42598
42616
  let size;
42617
+ let position;
42599
42618
  let color;
42600
42619
  let icon;
42601
42620
  let tags;
@@ -42635,6 +42654,11 @@ var NodeVisitor = class extends BaseVisitor2 {
42635
42654
  size = this.visit(attr);
42636
42655
  }
42637
42656
  }
42657
+ if (ctx.positionAttr) {
42658
+ for (const attr of ctx.positionAttr) {
42659
+ position = this.visit(attr);
42660
+ }
42661
+ }
42638
42662
  if (ctx.colorAttr) {
42639
42663
  for (const attr of ctx.colorAttr) {
42640
42664
  color = this.visit(attr);
@@ -42659,6 +42683,7 @@ var NodeVisitor = class extends BaseVisitor2 {
42659
42683
  minimized,
42660
42684
  pullExecution,
42661
42685
  size,
42686
+ position,
42662
42687
  color,
42663
42688
  icon,
42664
42689
  tags
@@ -42732,6 +42757,11 @@ var NodeVisitor = class extends BaseVisitor2 {
42732
42757
  const height4 = parseInt(ctx.heightValue[0].image, 10);
42733
42758
  return { width, height: height4 };
42734
42759
  }
42760
+ positionAttr(ctx) {
42761
+ const x = parseInt(ctx.xValue[0].image, 10);
42762
+ const y = parseInt(ctx.yValue[0].image, 10);
42763
+ return { x, y };
42764
+ }
42735
42765
  colorAttr(ctx) {
42736
42766
  return this.unescapeString(ctx.colorValue[0].image);
42737
42767
  }
@@ -44417,6 +44447,7 @@ var JSDocParser = class {
44417
44447
  minimized,
44418
44448
  pullExecution,
44419
44449
  size,
44450
+ position,
44420
44451
  color,
44421
44452
  icon,
44422
44453
  tags
@@ -44463,6 +44494,7 @@ var JSDocParser = class {
44463
44494
  ...icon && { icon },
44464
44495
  ...tags && tags.length > 0 && { tags },
44465
44496
  ...size && { width: size.width, height: size.height },
44497
+ ...position && { x: position.x, y: position.y },
44466
44498
  sourceLocation: { line, column: 0 }
44467
44499
  });
44468
44500
  }
@@ -44479,6 +44511,11 @@ var JSDocParser = class {
44479
44511
  }
44480
44512
  const { nodeId, x, y } = result;
44481
44513
  config2.positions[nodeId] = { x, y };
44514
+ if (nodeId !== "Start" && nodeId !== "Exit") {
44515
+ warnings.push(
44516
+ `Deprecated: @position ${nodeId} \u2014 use [position: ${x} ${y}] on the @node declaration instead.`
44517
+ );
44518
+ }
44482
44519
  }
44483
44520
  /**
44484
44521
  * Parse @connect tag using Chevrotain parser.
@@ -45670,6 +45707,7 @@ ${fn.getText()}` : fn.getText();
45670
45707
  ...parent && { parent },
45671
45708
  config: {
45672
45709
  ...inst.label && { label: inst.label },
45710
+ ...inst.x !== void 0 && inst.y !== void 0 && { x: inst.x, y: inst.y },
45673
45711
  ...position && { x: position.x, y: position.y },
45674
45712
  ...portConfigs && portConfigs.length > 0 && { portConfigs },
45675
45713
  ...inst.pullExecution && { pullExecution: inst.pullExecution },
@@ -48585,13 +48623,10 @@ function outputResult(data: any): { result: any } {
48585
48623
 
48586
48624
  /**
48587
48625
  * @flowWeaver workflow
48588
- * @node validator validateData
48589
- * @node transformer transformData
48590
- * @node outputter outputResult
48626
+ * @node validator validateData [position: -300 0]
48627
+ * @node transformer transformData [position: 0 0]
48628
+ * @node outputter outputResult [position: 300 0]
48591
48629
  * @position Start -600 0
48592
- * @position validator -300 0
48593
- * @position transformer 0 0
48594
- * @position outputter 300 0
48595
48630
  * @position Exit 600 0
48596
48631
  * @path Start -> validator -> transformer -> outputter -> Exit
48597
48632
  * @connect validator.onFailure -> Exit.onFailure
@@ -48631,12 +48666,14 @@ function ${name}(${inputPortName}: any): { ${outputPortName}: any } {
48631
48666
  return { ${outputPortName}: ${inputPortName} };
48632
48667
  }`;
48633
48668
  });
48634
- const nodeAnnotations = nodeNames.map((name, i) => ` * @node step${i} ${name}`).join("\n");
48635
48669
  const spacing = 300;
48636
48670
  const startX = -(nodeNames.length * (spacing / 2) + spacing / 2);
48671
+ const nodeAnnotations = nodeNames.map((name, i) => {
48672
+ const x = startX + (i + 1) * spacing;
48673
+ return ` * @node step${i} ${name} [position: ${x} 0]`;
48674
+ }).join("\n");
48637
48675
  const positionAnnotations = [
48638
48676
  ` * @position Start ${startX} 0`,
48639
- ...nodeNames.map((_, i) => ` * @position step${i} ${startX + (i + 1) * spacing} 0`),
48640
48677
  ` * @position Exit ${startX + (nodeNames.length + 1) * spacing} 0`
48641
48678
  ].join("\n");
48642
48679
  const pathNodes = ["Start", ...nodeNames.map((_, i) => `step${i}`), "Exit"];
@@ -48799,13 +48836,10 @@ function aggregateResults(
48799
48836
 
48800
48837
  /**
48801
48838
  * @flowWeaver workflow
48802
- * @node iterator forEachItem [size: 300 200]
48803
- * @node processor processItem iterator.processItem
48804
- * @node aggregator aggregateResults
48839
+ * @node iterator forEachItem [size: 300 200] [position: -90 0]
48840
+ * @node processor processItem iterator.processItem [position: 90 0]
48841
+ * @node aggregator aggregateResults [position: 270 0]
48805
48842
  * @position Start -450 0
48806
- * @position iterator -90 0
48807
- * @position processor 90 0
48808
- * @position aggregator 270 0
48809
48843
  * @position Exit 450 0
48810
48844
  * @connect Start.execute -> iterator.execute
48811
48845
  * @connect Start.items -> iterator.items
@@ -48936,13 +48970,10 @@ function handleFailure(
48936
48970
 
48937
48971
  /**
48938
48972
  * @flowWeaver workflow
48939
- * @node router evaluateCondition
48940
- * @node successHandler handleSuccess
48941
- * @node failureHandler handleFailure
48973
+ * @node router evaluateCondition [position: -180 0]
48974
+ * @node successHandler handleSuccess [position: 90 -90]
48975
+ * @node failureHandler handleFailure [position: 90 90]
48942
48976
  * @position Start -450 0
48943
- * @position router -180 0
48944
- * @position successHandler 90 -90
48945
- * @position failureHandler 90 90
48946
48977
  * @position Exit 360 0
48947
48978
  * @connect Start.execute -> router.execute
48948
48979
  * @connect Start.data -> router.data
@@ -49587,13 +49618,10 @@ async function executeTools(
49587
49618
  * AI Agent that uses tools to accomplish tasks
49588
49619
  *
49589
49620
  * @flowWeaver workflow
49590
- * @node loop agentLoop [size: 450 350]
49591
- * @node llm callLLM loop.iteration
49592
- * @node tools executeTools loop.iteration
49621
+ * @node loop agentLoop [size: 450 350] [position: -180 0]
49622
+ * @node llm callLLM loop.iteration [position: -40 100]
49623
+ * @node tools executeTools loop.iteration [position: 120 200]
49593
49624
  * @position Start -450 0
49594
- * @position loop -180 0
49595
- * @position llm -40 100
49596
- * @position tools 120 200
49597
49625
  * @position Exit 360 0
49598
49626
  * @connect Start.execute -> loop.execute
49599
49627
  * @connect Start.userMessage -> loop.userMessage
@@ -49877,13 +49905,10 @@ async function act(
49877
49905
  * ReAct Agent \u2014 iterative Thought\u2192Action\u2192Observation loop
49878
49906
  *
49879
49907
  * @flowWeaver workflow
49880
- * @node loop reactLoop [size: 450 250]
49881
- * @node thinking think loop.step
49882
- * @node acting act loop.step
49908
+ * @node loop reactLoop [size: 450 250] [position: -150 0]
49909
+ * @node thinking think loop.step [position: -80 30]
49910
+ * @node acting act loop.step [position: 130 30]
49883
49911
  * @position Start -400 0
49884
- * @position loop -150 0
49885
- * @position thinking -80 30
49886
- * @position acting 130 30
49887
49912
  * @position Exit 350 0
49888
49913
  * @connect Start.execute -> loop.execute
49889
49914
  * @connect Start.task -> loop.task
@@ -50064,11 +50089,9 @@ Answer:\`;
50064
50089
  * RAG Pipeline for knowledge-based Q&A
50065
50090
  *
50066
50091
  * @flowWeaver workflow
50067
- * @node retriever retrieve
50068
- * @node generator generate
50092
+ * @node retriever retrieve [position: -50 0]
50093
+ * @node generator generate [position: 200 0]
50069
50094
  * @position Start -300 0
50070
- * @position retriever -50 0
50071
- * @position generator 200 0
50072
50095
  * @position Exit 400 0
50073
50096
  * @connect Start.execute -> retriever.execute
50074
50097
  * @connect Start.question -> retriever.query
@@ -50227,13 +50250,10 @@ async function chat(
50227
50250
  * Stateful chat with conversation memory
50228
50251
  *
50229
50252
  * @flowWeaver workflow
50230
- * @node mem memory
50231
- * @node respond chat
50232
- * @node saveMem memory
50253
+ * @node mem memory [position: -150 0]
50254
+ * @node respond chat [position: 50 0]
50255
+ * @node saveMem memory [position: 250 0]
50233
50256
  * @position Start -350 0
50234
- * @position mem -150 0
50235
- * @position respond 50 0
50236
- * @position saveMem 250 0
50237
50257
  * @position Exit 450 0
50238
50258
  * @connect Start.execute -> mem.execute
50239
50259
  * @connect Start.conversationId -> mem.conversationId
@@ -50332,13 +50352,10 @@ function combineData(dataA: any, dataB: any): { aggregated: any } {
50332
50352
 
50333
50353
  /**
50334
50354
  * @flowWeaver workflow
50335
- * @node sourceA fetchSourceA
50336
- * @node sourceB fetchSourceB
50337
- * @node combiner combineData
50355
+ * @node sourceA fetchSourceA [position: -180 -90]
50356
+ * @node sourceB fetchSourceB [position: -180 90]
50357
+ * @node combiner combineData [position: 90 0]
50338
50358
  * @position Start -450 0
50339
- * @position sourceA -180 -90
50340
- * @position sourceB -180 90
50341
- * @position combiner 90 0
50342
50359
  * @position Exit 360 0
50343
50360
  * @connect Start.execute -> sourceA.execute
50344
50361
  * @connect Start.execute -> sourceB.execute
@@ -50483,13 +50500,10 @@ function formatResponse(
50483
50500
 
50484
50501
  /**
50485
50502
  * @flowWeaver workflow
50486
- * @node validator validateRequest
50487
- * @node processor processPayload
50488
- * @node responder formatResponse
50503
+ * @node validator validateRequest [position: -180 0]
50504
+ * @node processor processPayload [position: 90 -60]
50505
+ * @node responder formatResponse [position: 270 0]
50489
50506
  * @position Start -450 0
50490
- * @position validator -180 0
50491
- * @position processor 90 -60
50492
- * @position responder 270 0
50493
50507
  * @position Exit 450 0
50494
50508
  * @connect Start.execute -> validator.execute
50495
50509
  * @connect Start.headers -> validator.headers
@@ -50624,11 +50638,9 @@ function tryOperation(
50624
50638
 
50625
50639
  /**
50626
50640
  * @flowWeaver workflow
50627
- * @node loop retryLoop [size: 300 200]
50628
- * @node tryOp tryOperation loop.attempt
50641
+ * @node loop retryLoop [size: 300 200] [position: -90 0]
50642
+ * @node tryOp tryOperation loop.attempt [position: 90 0]
50629
50643
  * @position Start -450 0
50630
- * @position loop -90 0
50631
- * @position tryOp 90 0
50632
50644
  * @position Exit 360 0
50633
50645
  * @connect Start.execute -> loop.execute
50634
50646
  * @connect Start.data -> loop.data
@@ -50956,15 +50968,11 @@ async function respond(
50956
50968
  * @flowWeaver workflow
50957
50969
  * @trigger event="agent/request"
50958
50970
  * @retries 3
50959
- * @node cls classify
50960
- * @node tools executeTool
50961
- * @node approval approvalGate
50962
- * @node resp respond
50971
+ * @node cls classify [position: -280 0]
50972
+ * @node tools executeTool [position: -40 0]
50973
+ * @node approval approvalGate [position: 200 0]
50974
+ * @node resp respond [position: 440 0]
50963
50975
  * @position Start -500 0
50964
- * @position cls -280 0
50965
- * @position tools -40 0
50966
- * @position approval 200 0
50967
- * @position resp 440 0
50968
50976
  * @position Exit 680 0
50969
50977
  * @connect Start.execute -> cls.execute
50970
50978
  * @connect Start.userMessage -> cls.userMessage
@@ -51278,15 +51286,11 @@ async function saveResult(
51278
51286
  * @flowWeaver workflow
51279
51287
  * @trigger event="pipeline/start"
51280
51288
  * @retries 3
51281
- * @node fetch fetchData
51282
- * @node extract extractInfo
51283
- * @node validate validateResult
51284
- * @node save saveResult
51289
+ * @node fetch fetchData [position: -280 0]
51290
+ * @node extract extractInfo [position: -40 0]
51291
+ * @node validate validateResult [position: 200 0]
51292
+ * @node save saveResult [position: 440 0]
51285
51293
  * @position Start -500 0
51286
- * @position fetch -280 0
51287
- * @position extract -40 0
51288
- * @position validate 200 0
51289
- * @position save 440 0
51290
51294
  * @position Exit 680 0
51291
51295
  * @connect Start.execute -> fetch.execute
51292
51296
  * @connect Start.url -> fetch.url
@@ -52766,9 +52770,10 @@ function applyPattern(options) {
52766
52770
  conflicts.push(nodeType.name);
52767
52771
  }
52768
52772
  }
52769
- const nodeDeclarations = pattern.instances.map(
52770
- (inst) => ` * @node ${nodePrefix}${inst.id} ${inst.nodeType}`
52771
- );
52773
+ const nodeDeclarations = pattern.instances.map((inst) => {
52774
+ const posAttr = inst.config?.x !== void 0 && inst.config?.y !== void 0 ? ` [position: ${inst.config.x} ${inst.config.y}]` : "";
52775
+ return ` * @node ${nodePrefix}${inst.id} ${inst.nodeType}${posAttr}`;
52776
+ });
52772
52777
  const connectDeclarations = [];
52773
52778
  const wiringInstructions = [];
52774
52779
  const wiringOperations = [];
@@ -52803,7 +52808,6 @@ function applyPattern(options) {
52803
52808
  );
52804
52809
  }
52805
52810
  }
52806
- const positionDeclarations = pattern.instances.filter((inst) => inst.config?.x !== void 0 && inst.config?.y !== void 0).map((inst) => ` * @position ${nodePrefix}${inst.id} ${inst.config.x} ${inst.config.y}`);
52807
52811
  const nodeTypesAdded = [];
52808
52812
  const nodeTypeFunctions = [];
52809
52813
  for (const nodeType of pattern.nodeTypes) {
@@ -52815,8 +52819,7 @@ function applyPattern(options) {
52815
52819
  const annotationLines = [
52816
52820
  `// --- Pattern: ${pattern.name} ${prefix ? `(prefix: ${prefix})` : ""} ---`,
52817
52821
  ...nodeDeclarations,
52818
- ...connectDeclarations,
52819
- ...positionDeclarations
52822
+ ...connectDeclarations
52820
52823
  ];
52821
52824
  const workflowMatch = targetContent.match(/\/\*\*[\s\S]*?@flowWeaver\s+workflow[\s\S]*?\*\//);
52822
52825
  if (!workflowMatch) {
@@ -52928,7 +52931,8 @@ function extractPattern(options) {
52928
52931
  lines.push(` * @flowWeaver pattern`);
52929
52932
  lines.push(` * @name ${patternName}`);
52930
52933
  for (const inst of extractedInstances) {
52931
- lines.push(` * @node ${inst.id} ${inst.nodeType}`);
52934
+ const posAttr = inst.config?.x !== void 0 && inst.config?.y !== void 0 ? ` [position: ${inst.config.x} ${inst.config.y}]` : "";
52935
+ lines.push(` * @node ${inst.id} ${inst.nodeType}${posAttr}`);
52932
52936
  }
52933
52937
  for (const conn of internalConnections) {
52934
52938
  lines.push(
@@ -52954,11 +52958,6 @@ function extractPattern(options) {
52954
52958
  for (const port of [...new Set(outputPorts)]) {
52955
52959
  lines.push(` * @port OUT.${port}`);
52956
52960
  }
52957
- for (const inst of extractedInstances) {
52958
- if (inst.config?.x !== void 0 && inst.config?.y !== void 0) {
52959
- lines.push(` * @position ${inst.id} ${inst.config.x} ${inst.config.y}`);
52960
- }
52961
- }
52962
52961
  lines.push(" */");
52963
52962
  lines.push("function patternPlaceholder() {}");
52964
52963
  for (const nodeType of usedNodeTypes) {
@@ -95128,7 +95127,7 @@ function displayInstalledPackage(pkg) {
95128
95127
  }
95129
95128
 
95130
95129
  // src/cli/index.ts
95131
- var version2 = true ? "0.7.0" : "0.0.0-dev";
95130
+ var version2 = true ? "0.8.0" : "0.0.0-dev";
95132
95131
  var program2 = new Command();
95133
95132
  program2.name("flow-weaver").description("Flow Weaver Annotations - Compile and validate workflow files").version(version2, "-v, --version", "Output the current version");
95134
95133
  program2.configureOutput({
@@ -68,13 +68,10 @@ function combineData(dataA: any, dataB: any): { aggregated: any } {
68
68
 
69
69
  /**
70
70
  * @flowWeaver workflow
71
- * @node sourceA fetchSourceA
72
- * @node sourceB fetchSourceB
73
- * @node combiner combineData
71
+ * @node sourceA fetchSourceA [position: -180 -90]
72
+ * @node sourceB fetchSourceB [position: -180 90]
73
+ * @node combiner combineData [position: 90 0]
74
74
  * @position Start -450 0
75
- * @position sourceA -180 -90
76
- * @position sourceB -180 90
77
- * @position combiner 90 0
78
75
  * @position Exit 360 0
79
76
  * @connect Start.execute -> sourceA.execute
80
77
  * @connect Start.execute -> sourceB.execute
@@ -294,15 +294,11 @@ async function respond(
294
294
  * @flowWeaver workflow
295
295
  * @trigger event="agent/request"
296
296
  * @retries 3
297
- * @node cls classify
298
- * @node tools executeTool
299
- * @node approval approvalGate
300
- * @node resp respond
297
+ * @node cls classify [position: -280 0]
298
+ * @node tools executeTool [position: -40 0]
299
+ * @node approval approvalGate [position: 200 0]
300
+ * @node resp respond [position: 440 0]
301
301
  * @position Start -500 0
302
- * @position cls -280 0
303
- * @position tools -40 0
304
- * @position approval 200 0
305
- * @position resp 440 0
306
302
  * @position Exit 680 0
307
303
  * @connect Start.execute -> cls.execute
308
304
  * @connect Start.userMessage -> cls.userMessage
@@ -283,13 +283,10 @@ async function executeTools(
283
283
  * AI Agent that uses tools to accomplish tasks
284
284
  *
285
285
  * @flowWeaver workflow
286
- * @node loop agentLoop [size: 450 350]
287
- * @node llm callLLM loop.iteration
288
- * @node tools executeTools loop.iteration
286
+ * @node loop agentLoop [size: 450 350] [position: -180 0]
287
+ * @node llm callLLM loop.iteration [position: -40 100]
288
+ * @node tools executeTools loop.iteration [position: 120 200]
289
289
  * @position Start -450 0
290
- * @position loop -180 0
291
- * @position llm -40 100
292
- * @position tools 120 200
293
290
  * @position Exit 360 0
294
291
  * @connect Start.execute -> loop.execute
295
292
  * @connect Start.userMessage -> loop.userMessage
@@ -127,13 +127,10 @@ async function chat(
127
127
  * Stateful chat with conversation memory
128
128
  *
129
129
  * @flowWeaver workflow
130
- * @node mem memory
131
- * @node respond chat
132
- * @node saveMem memory
130
+ * @node mem memory [position: -150 0]
131
+ * @node respond chat [position: 50 0]
132
+ * @node saveMem memory [position: 250 0]
133
133
  * @position Start -350 0
134
- * @position mem -150 0
135
- * @position respond 50 0
136
- * @position saveMem 250 0
137
134
  * @position Exit 450 0
138
135
  * @connect Start.execute -> mem.execute
139
136
  * @connect Start.conversationId -> mem.conversationId
@@ -282,15 +282,11 @@ async function saveResult(
282
282
  * @flowWeaver workflow
283
283
  * @trigger event="pipeline/start"
284
284
  * @retries 3
285
- * @node fetch fetchData
286
- * @node extract extractInfo
287
- * @node validate validateResult
288
- * @node save saveResult
285
+ * @node fetch fetchData [position: -280 0]
286
+ * @node extract extractInfo [position: -40 0]
287
+ * @node validate validateResult [position: 200 0]
288
+ * @node save saveResult [position: 440 0]
289
289
  * @position Start -500 0
290
- * @position fetch -280 0
291
- * @position extract -40 0
292
- * @position validate 200 0
293
- * @position save 440 0
294
290
  * @position Exit 680 0
295
291
  * @connect Start.execute -> fetch.execute
296
292
  * @connect Start.url -> fetch.url
@@ -145,11 +145,9 @@ Answer:\`;
145
145
  * RAG Pipeline for knowledge-based Q&A
146
146
  *
147
147
  * @flowWeaver workflow
148
- * @node retriever retrieve
149
- * @node generator generate
148
+ * @node retriever retrieve [position: -50 0]
149
+ * @node generator generate [position: 200 0]
150
150
  * @position Start -300 0
151
- * @position retriever -50 0
152
- * @position generator 200 0
153
151
  * @position Exit 400 0
154
152
  * @connect Start.execute -> retriever.execute
155
153
  * @connect Start.question -> retriever.query
@@ -247,13 +247,10 @@ async function act(
247
247
  * ReAct Agent — iterative Thought→Action→Observation loop
248
248
  *
249
249
  * @flowWeaver workflow
250
- * @node loop reactLoop [size: 450 250]
251
- * @node thinking think loop.step
252
- * @node acting act loop.step
250
+ * @node loop reactLoop [size: 450 250] [position: -150 0]
251
+ * @node thinking think loop.step [position: -80 30]
252
+ * @node acting act loop.step [position: 130 30]
253
253
  * @position Start -400 0
254
- * @position loop -150 0
255
- * @position thinking -80 30
256
- * @position acting 130 30
257
254
  * @position Exit 350 0
258
255
  * @connect Start.execute -> loop.execute
259
256
  * @connect Start.task -> loop.task
@@ -105,13 +105,10 @@ function handleFailure(
105
105
 
106
106
  /**
107
107
  * @flowWeaver workflow
108
- * @node router evaluateCondition
109
- * @node successHandler handleSuccess
110
- * @node failureHandler handleFailure
108
+ * @node router evaluateCondition [position: -180 0]
109
+ * @node successHandler handleSuccess [position: 90 -90]
110
+ * @node failureHandler handleFailure [position: 90 90]
111
111
  * @position Start -450 0
112
- * @position router -180 0
113
- * @position successHandler 90 -90
114
- * @position failureHandler 90 90
115
112
  * @position Exit 360 0
116
113
  * @connect Start.execute -> router.execute
117
114
  * @connect Start.data -> router.data
@@ -105,11 +105,9 @@ function tryOperation(
105
105
 
106
106
  /**
107
107
  * @flowWeaver workflow
108
- * @node loop retryLoop [size: 300 200]
109
- * @node tryOp tryOperation loop.attempt
108
+ * @node loop retryLoop [size: 300 200] [position: -90 0]
109
+ * @node tryOp tryOperation loop.attempt [position: 90 0]
110
110
  * @position Start -450 0
111
- * @position loop -90 0
112
- * @position tryOp 90 0
113
111
  * @position Exit 360 0
114
112
  * @connect Start.execute -> loop.execute
115
113
  * @connect Start.data -> loop.data
@@ -101,13 +101,10 @@ function aggregateResults(
101
101
 
102
102
  /**
103
103
  * @flowWeaver workflow
104
- * @node iterator forEachItem [size: 300 200]
105
- * @node processor processItem iterator.processItem
106
- * @node aggregator aggregateResults
104
+ * @node iterator forEachItem [size: 300 200] [position: -90 0]
105
+ * @node processor processItem iterator.processItem [position: 90 0]
106
+ * @node aggregator aggregateResults [position: 270 0]
107
107
  * @position Start -450 0
108
- * @position iterator -90 0
109
- * @position processor 90 0
110
- * @position aggregator 270 0
111
108
  * @position Exit 450 0
112
109
  * @connect Start.execute -> iterator.execute
113
110
  * @connect Start.items -> iterator.items