@synergenius/flow-weaver 0.30.1 → 0.30.3

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.
@@ -202,6 +202,49 @@ export class AnnotationGenerator {
202
202
  line += ` period="${t.period}"`;
203
203
  lines.push(line);
204
204
  }
205
+ // CI/CD annotations round-trip (from pack-contributed tag handlers)
206
+ if (workflow.options?.cicd) {
207
+ const cicd = workflow.options.cicd;
208
+ // @trigger (CI/CD style: push, pull_request, etc.)
209
+ if (cicd.triggers && Array.isArray(cicd.triggers)) {
210
+ for (const trigger of cicd.triggers) {
211
+ const parts = [String(trigger.type || '')];
212
+ if (trigger.branches)
213
+ parts.push(`branches="${trigger.branches}"`);
214
+ if (trigger.types)
215
+ parts.push(`types="${trigger.types}"`);
216
+ if (trigger.pattern)
217
+ parts.push(`pattern="${trigger.pattern}"`);
218
+ if (trigger.cron)
219
+ parts.push(`cron="${trigger.cron}"`);
220
+ lines.push(` * @trigger ${parts.join(' ')}`);
221
+ }
222
+ }
223
+ // @secret
224
+ if (cicd.secrets && Array.isArray(cicd.secrets)) {
225
+ for (const secret of cicd.secrets) {
226
+ let line = ` * @secret ${secret.name}`;
227
+ if (secret.description)
228
+ line += ` - ${secret.description}`;
229
+ lines.push(line);
230
+ }
231
+ }
232
+ // @runner
233
+ if (cicd.runner) {
234
+ lines.push(` * @runner ${cicd.runner}`);
235
+ }
236
+ // @cache
237
+ if (cicd.caches && Array.isArray(cicd.caches)) {
238
+ for (const cache of cicd.caches) {
239
+ let line = ` * @cache ${cache.strategy || 'npm'}`;
240
+ if (cache.key)
241
+ line += ` key="${cache.key}"`;
242
+ if (cache.path)
243
+ line += ` path="${cache.path}"`;
244
+ lines.push(line);
245
+ }
246
+ }
247
+ }
205
248
  // Add name if different from export name
206
249
  if (workflow.name && workflow.name !== workflow.functionName) {
207
250
  lines.push(` * @name ${workflow.name}`);
@@ -627,7 +670,17 @@ export function generateNodeInstanceTag(instance) {
627
670
  if (instance.config?.x !== undefined && instance.config?.y !== undefined) {
628
671
  positionAttr = ` [position: ${Math.round(instance.config.x)} ${Math.round(instance.config.y)}]`;
629
672
  }
630
- return ` * @node ${instance.id} ${instance.nodeType}${parent}${labelAttr}${portOrderAttr}${portLabelAttr}${exprAttr}${pullExecutionAttr}${minimizedAttr}${colorAttr}${iconAttr}${tagsAttr}${suppressAttr}${sizeAttr}${positionAttr}`;
673
+ // Generate [job: "name"] attribute if present (CI/CD job group)
674
+ let jobAttr = '';
675
+ if (instance.job) {
676
+ jobAttr = ` [job: "${instance.job}"]`;
677
+ }
678
+ // Generate [environment: "name"] attribute if present (CI/CD environment)
679
+ let environmentAttr = '';
680
+ if (instance.environment) {
681
+ environmentAttr = ` [environment: "${instance.environment}"]`;
682
+ }
683
+ return ` * @node ${instance.id} ${instance.nodeType}${parent}${labelAttr}${portOrderAttr}${portLabelAttr}${exprAttr}${pullExecutionAttr}${minimizedAttr}${colorAttr}${iconAttr}${tagsAttr}${suppressAttr}${sizeAttr}${positionAttr}${jobAttr}${environmentAttr}`;
631
684
  }
632
685
  /**
633
686
  * Generate a TypeScript function signature from a node type definition.
@@ -42,9 +42,19 @@ export function generateInPlace(sourceCode, ast, options = {}) {
42
42
  }
43
43
  // Skip node types imported from other files — the import statement handles them.
44
44
  // Inlining would create duplicate declarations (TS2440) and duplicate node type names.
45
- if (nodeType.sourceLocation?.file &&
46
- path.resolve(nodeType.sourceLocation.file) !== path.resolve(ast.sourceFile)) {
47
- continue;
45
+ // Compare basenames as a fallback: after a client roundtrip (JSON serialization),
46
+ // sourceLocation.file may contain a virtual path ("/testing.ts") instead of the
47
+ // real workspace path. Full-path comparison would incorrectly skip the node type.
48
+ // Normalize separators for cross-platform (Windows backslash → forward slash).
49
+ if (nodeType.sourceLocation?.file) {
50
+ const ntFile = nodeType.sourceLocation.file.replace(/\\/g, '/');
51
+ const astFile = ast.sourceFile.replace(/\\/g, '/');
52
+ const ntBase = ntFile.split('/').filter(Boolean).pop() ?? '';
53
+ const astBase = astFile.split('/').filter(Boolean).pop() ?? '';
54
+ if (path.resolve(ntFile) !== path.resolve(astFile) &&
55
+ ntBase !== astBase) {
56
+ continue;
57
+ }
48
58
  }
49
59
  // Skip built-in auto-injected nodes — step 1.2 handles their insertion
50
60
  if (!nodeType.sourceLocation && nodeType.helperText != null) {
@@ -5987,7 +5987,7 @@ var VERSION;
5987
5987
  var init_generated_version = __esm({
5988
5988
  "src/generated-version.ts"() {
5989
5989
  "use strict";
5990
- VERSION = "0.30.1";
5990
+ VERSION = "0.30.3";
5991
5991
  }
5992
5992
  });
5993
5993
 
@@ -14894,7 +14894,15 @@ function generateNodeInstanceTag(instance) {
14894
14894
  if (instance.config?.x !== void 0 && instance.config?.y !== void 0) {
14895
14895
  positionAttr = ` [position: ${Math.round(instance.config.x)} ${Math.round(instance.config.y)}]`;
14896
14896
  }
14897
- return ` * @node ${instance.id} ${instance.nodeType}${parent}${labelAttr}${portOrderAttr}${portLabelAttr}${exprAttr}${pullExecutionAttr}${minimizedAttr}${colorAttr}${iconAttr}${tagsAttr}${suppressAttr}${sizeAttr}${positionAttr}`;
14897
+ let jobAttr = "";
14898
+ if (instance.job) {
14899
+ jobAttr = ` [job: "${instance.job}"]`;
14900
+ }
14901
+ let environmentAttr = "";
14902
+ if (instance.environment) {
14903
+ environmentAttr = ` [environment: "${instance.environment}"]`;
14904
+ }
14905
+ return ` * @node ${instance.id} ${instance.nodeType}${parent}${labelAttr}${portOrderAttr}${portLabelAttr}${exprAttr}${pullExecutionAttr}${minimizedAttr}${colorAttr}${iconAttr}${tagsAttr}${suppressAttr}${sizeAttr}${positionAttr}${jobAttr}${environmentAttr}`;
14898
14906
  }
14899
14907
  function generateFunctionSignature(nodeType) {
14900
14908
  const lines = [];
@@ -15124,6 +15132,37 @@ var init_annotation_generator = __esm({
15124
15132
  if (t.period) line += ` period="${t.period}"`;
15125
15133
  lines.push(line);
15126
15134
  }
15135
+ if (workflow.options?.cicd) {
15136
+ const cicd = workflow.options.cicd;
15137
+ if (cicd.triggers && Array.isArray(cicd.triggers)) {
15138
+ for (const trigger of cicd.triggers) {
15139
+ const parts = [String(trigger.type || "")];
15140
+ if (trigger.branches) parts.push(`branches="${trigger.branches}"`);
15141
+ if (trigger.types) parts.push(`types="${trigger.types}"`);
15142
+ if (trigger.pattern) parts.push(`pattern="${trigger.pattern}"`);
15143
+ if (trigger.cron) parts.push(`cron="${trigger.cron}"`);
15144
+ lines.push(` * @trigger ${parts.join(" ")}`);
15145
+ }
15146
+ }
15147
+ if (cicd.secrets && Array.isArray(cicd.secrets)) {
15148
+ for (const secret of cicd.secrets) {
15149
+ let line = ` * @secret ${secret.name}`;
15150
+ if (secret.description) line += ` - ${secret.description}`;
15151
+ lines.push(line);
15152
+ }
15153
+ }
15154
+ if (cicd.runner) {
15155
+ lines.push(` * @runner ${cicd.runner}`);
15156
+ }
15157
+ if (cicd.caches && Array.isArray(cicd.caches)) {
15158
+ for (const cache of cicd.caches) {
15159
+ let line = ` * @cache ${cache.strategy || "npm"}`;
15160
+ if (cache.key) line += ` key="${cache.key}"`;
15161
+ if (cache.path) line += ` path="${cache.path}"`;
15162
+ lines.push(line);
15163
+ }
15164
+ }
15165
+ }
15127
15166
  if (workflow.name && workflow.name !== workflow.functionName) {
15128
15167
  lines.push(` * @name ${workflow.name}`);
15129
15168
  }
@@ -15285,8 +15324,14 @@ function generateInPlace(sourceCode, ast, options = {}) {
15285
15324
  if (nodeType.variant === "IMPORTED_WORKFLOW" || nodeType.variant === "WORKFLOW" || nodeType.variant === "MAP_ITERATOR") {
15286
15325
  continue;
15287
15326
  }
15288
- if (nodeType.sourceLocation?.file && path2.resolve(nodeType.sourceLocation.file) !== path2.resolve(ast.sourceFile)) {
15289
- continue;
15327
+ if (nodeType.sourceLocation?.file) {
15328
+ const ntFile = nodeType.sourceLocation.file.replace(/\\/g, "/");
15329
+ const astFile = ast.sourceFile.replace(/\\/g, "/");
15330
+ const ntBase = ntFile.split("/").filter(Boolean).pop() ?? "";
15331
+ const astBase = astFile.split("/").filter(Boolean).pop() ?? "";
15332
+ if (path2.resolve(ntFile) !== path2.resolve(astFile) && ntBase !== astBase) {
15333
+ continue;
15334
+ }
15290
15335
  }
15291
15336
  if (!nodeType.sourceLocation && nodeType.helperText != null) {
15292
15337
  continue;
@@ -26949,22 +26994,24 @@ var init_jsdoc_parser = __esm({
26949
26994
  */
26950
26995
  parseTriggerTag(tag, config2, warnings, tagRegistry) {
26951
26996
  const comment = (tag.getCommentText() || "").trim();
26997
+ const cicdKeywords = ["push", "pull_request", "dispatch", "tag", "schedule"];
26998
+ const firstToken = comment.split(/\s/)[0];
26999
+ if (cicdKeywords.includes(firstToken) && tagRegistry && tagRegistry.has("_cicdTrigger")) {
27000
+ if (!config2.deploy) config2.deploy = {};
27001
+ tagRegistry.handle("_cicdTrigger", comment, "workflow", config2.deploy, warnings);
27002
+ return;
27003
+ }
26952
27004
  const result = parseTriggerLine(`@trigger ${comment}`, warnings);
26953
27005
  if (result) {
26954
- const cicdKeywords = ["push", "pull_request", "dispatch", "tag", "schedule"];
26955
- if (result.event && cicdKeywords.includes(result.event)) {
26956
- warnings.push(
26957
- `@trigger event="${result.event}" is treated as an Inngest event trigger, not a CI/CD trigger. For CI/CD, use: @trigger ${result.event}`
26958
- );
26959
- }
26960
27006
  config2.trigger = config2.trigger || {};
26961
27007
  if (result.event) config2.trigger.event = result.event;
26962
27008
  if (result.cron) config2.trigger.cron = result.cron;
26963
27009
  return;
26964
27010
  }
26965
- if (tagRegistry && tagRegistry.has("_cicdTrigger")) {
26966
- if (!config2.deploy) config2.deploy = {};
26967
- tagRegistry.handle("_cicdTrigger", comment, "workflow", config2.deploy, warnings);
27011
+ if (cicdKeywords.includes(firstToken)) {
27012
+ warnings.push(
27013
+ `@trigger ${firstToken} looks like a CI/CD trigger but no CI/CD pack is installed. Install @synergenius/flow-weaver-pack-cicd to enable CI/CD pipeline annotations.`
27014
+ );
26968
27015
  return;
26969
27016
  }
26970
27017
  warnings.push(`Invalid @trigger format: @trigger ${comment}`);
@@ -88846,7 +88893,7 @@ function parseIntStrict(value) {
88846
88893
  // src/cli/index.ts
88847
88894
  init_logger();
88848
88895
  init_error_utils();
88849
- var version2 = true ? "0.30.1" : "0.0.0-dev";
88896
+ var version2 = true ? "0.30.3" : "0.0.0-dev";
88850
88897
  var program2 = new Command();
88851
88898
  program2.name("fw").description("Flow Weaver Annotations - Compile and validate workflow files").option("-v, --version", "Output the current version").option("--no-color", "Disable colors").option("--color", "Force colors").on("option:version", () => {
88852
88899
  logger.banner(version2);
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.30.1";
1
+ export declare const VERSION = "0.30.3";
2
2
  //# sourceMappingURL=generated-version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Auto-generated by scripts/generate-version.ts — do not edit manually
2
- export const VERSION = '0.30.1';
2
+ export const VERSION = '0.30.3';
3
3
  //# sourceMappingURL=generated-version.js.map
@@ -1059,15 +1059,19 @@ export class JSDocParser {
1059
1059
  */
1060
1060
  parseTriggerTag(tag, config, warnings, tagRegistry) {
1061
1061
  const comment = (tag.getCommentText() || '').trim();
1062
- // Try core FW trigger parsing first (event= and/or cron=)
1062
+ // Check if the trigger looks like a CI/CD keyword (push, pull_request, etc.)
1063
+ const cicdKeywords = ['push', 'pull_request', 'dispatch', 'tag', 'schedule'];
1064
+ const firstToken = comment.split(/\s/)[0];
1065
+ // CI/CD triggers: delegate to pack handler if registered
1066
+ if (cicdKeywords.includes(firstToken) && tagRegistry && tagRegistry.has('_cicdTrigger')) {
1067
+ if (!config.deploy)
1068
+ config.deploy = {};
1069
+ tagRegistry.handle('_cicdTrigger', comment, 'workflow', config.deploy, warnings);
1070
+ return;
1071
+ }
1072
+ // Core FW trigger parsing (event= and/or cron=)
1063
1073
  const result = parseTriggerLine(`@trigger ${comment}`, warnings);
1064
1074
  if (result) {
1065
- // Warn if the event name matches a CI/CD trigger keyword (likely user error)
1066
- const cicdKeywords = ['push', 'pull_request', 'dispatch', 'tag', 'schedule'];
1067
- if (result.event && cicdKeywords.includes(result.event)) {
1068
- warnings.push(`@trigger event="${result.event}" is treated as an Inngest event trigger, not a CI/CD trigger. ` +
1069
- `For CI/CD, use: @trigger ${result.event}`);
1070
- }
1071
1075
  // Merge: multiple @trigger tags accumulate (event + cron can be separate tags)
1072
1076
  config.trigger = config.trigger || {};
1073
1077
  if (result.event)
@@ -1076,11 +1080,10 @@ export class JSDocParser {
1076
1080
  config.trigger.cron = result.cron;
1077
1081
  return;
1078
1082
  }
1079
- // Not a core trigger. Delegate to domain-specific handlers (e.g. CI/CD).
1080
- if (tagRegistry && tagRegistry.has('_cicdTrigger')) {
1081
- if (!config.deploy)
1082
- config.deploy = {};
1083
- tagRegistry.handle('_cicdTrigger', comment, 'workflow', config.deploy, warnings);
1083
+ // Not a core trigger and no CI/CD handler available. Try CI/CD keywords as fallback hint.
1084
+ if (cicdKeywords.includes(firstToken)) {
1085
+ warnings.push(`@trigger ${firstToken} looks like a CI/CD trigger but no CI/CD pack is installed. ` +
1086
+ `Install @synergenius/flow-weaver-pack-cicd to enable CI/CD pipeline annotations.`);
1084
1087
  return;
1085
1088
  }
1086
1089
  warnings.push(`Invalid @trigger format: @trigger ${comment}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synergenius/flow-weaver",
3
- "version": "0.30.1",
3
+ "version": "0.30.3",
4
4
  "description": "Flow Weaver: deterministic TypeScript workflow compiler. Define workflows with JSDoc annotations, compile to standalone functions with zero runtime dependencies.",
5
5
  "private": false,
6
6
  "type": "module",