@synergenius/flow-weaver 0.20.0 → 0.20.2

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.
@@ -159,6 +159,80 @@ The `market pack` command validates packages against additional rules beyond sta
159
159
 
160
160
  ---
161
161
 
162
+ ## Custom Tag Handlers
163
+
164
+ Tag handlers let packs extend the parser with custom JSDoc annotations. When the parser encounters a tag it doesn't recognize natively, it delegates to registered pack handlers before emitting "Unknown annotation" warnings.
165
+
166
+ The CI/CD pack (`flowweaver-pack-cicd`) is the primary example: it registers handlers for `@secret`, `@runner`, `@cache`, `@artifact`, and other CI/CD tags.
167
+
168
+ ### Writing a handler
169
+
170
+ A tag handler is a function matching the `TTagHandlerFn` signature:
171
+
172
+ ```typescript
173
+ import type { TTagHandlerFn } from '@synergenius/flow-weaver/api';
174
+
175
+ export const myHandler: TTagHandlerFn = (tagName, comment, ctx) => {
176
+ // tagName: the tag without '@', e.g. "secret"
177
+ // comment: everything after the tag on that line
178
+ // ctx.deploy: the deploy map for your namespace (mutate it directly)
179
+ // ctx.warnings: push parser warnings here
180
+
181
+ const value = comment.trim();
182
+ if (!value) {
183
+ ctx.warnings.push(`Empty @${tagName} tag`);
184
+ return;
185
+ }
186
+
187
+ const items = (ctx.deploy['items'] as string[]) ?? [];
188
+ items.push(value);
189
+ ctx.deploy['items'] = items;
190
+ };
191
+ ```
192
+
193
+ The handler receives one call per tag occurrence. Parsed data goes into `ctx.deploy`, which maps to `workflow.deploy[namespace]` or `nodeType.deploy[namespace]` in the final AST.
194
+
195
+ ### Declaring handlers in the manifest
196
+
197
+ Add a `tagHandlers` entry to your `flowweaver.manifest.json`:
198
+
199
+ ```json
200
+ {
201
+ "manifestVersion": 2,
202
+ "tagHandlers": [
203
+ {
204
+ "tags": ["secret", "runner", "cache"],
205
+ "namespace": "cicd",
206
+ "scope": "both",
207
+ "file": "dist/tag-handler.js",
208
+ "exportName": "cicdTagHandler"
209
+ }
210
+ ]
211
+ }
212
+ ```
213
+
214
+ Fields:
215
+
216
+ | Field | Description |
217
+ |-------|-------------|
218
+ | `tags` | Tag names this handler processes (without the `@` prefix) |
219
+ | `namespace` | Key in the deploy map where parsed data is stored |
220
+ | `scope` | `workflow` for workflow-level tags, `nodeType` for node type tags, `both` for either |
221
+ | `file` | Relative path to the compiled JS file exporting the handler |
222
+ | `exportName` | Named export from the file (omit for `default` export) |
223
+
224
+ ### Handler scope
225
+
226
+ A handler scoped to `workflow` only runs for tags inside `@flowWeaver workflow` blocks. A handler scoped to `nodeType` only runs inside `@flowWeaver nodeType` blocks. Use `both` when your tags are valid in either context.
227
+
228
+ If a tag appears in the wrong scope, the parser emits a warning and skips the handler call.
229
+
230
+ ### How discovery works
231
+
232
+ When `parseWorkflow()` is called with a `projectDir` option (or when the CLI runs from a project directory), the parser scans `node_modules` for installed packs with a `flowweaver.manifest.json`. It reads the `tagHandlers` array from each manifest, dynamically imports the handler files, and registers them in the `TagHandlerRegistry`. This scan runs once per project directory and is cached for subsequent parse calls.
233
+
234
+ ---
235
+
162
236
  ## External Plugins
163
237
 
164
238
  Plugins extend the Flow Weaver Studio IDE with custom UI components, system logic, and integrations.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synergenius/flow-weaver",
3
- "version": "0.20.0",
3
+ "version": "0.20.2",
4
4
  "description": "Deterministic workflow compiler for AI agents. Compiles to standalone TypeScript, no runtime dependencies.",
5
5
  "private": false,
6
6
  "type": "module",