@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.
- package/dist/annotation-generator.js +7 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/modify-operation.d.ts +15 -0
- package/dist/api/modify-operation.js +177 -0
- package/dist/ast/types.d.ts +2 -0
- package/dist/chevrotain-parser/node-parser.d.ts +2 -0
- package/dist/chevrotain-parser/node-parser.js +27 -1
- package/dist/chevrotain-parser/tokens.d.ts +1 -0
- package/dist/chevrotain-parser/tokens.js +5 -0
- package/dist/cli/commands/modify.d.ts +29 -0
- package/dist/cli/commands/modify.js +57 -0
- package/dist/cli/flow-weaver.mjs +45538 -45330
- package/dist/cli/index.js +73 -2
- package/dist/cli/pack-commands.js +2 -14
- package/dist/diagram/geometry.js +6 -6
- package/dist/generated-version.d.ts +1 -1
- package/dist/generated-version.js +1 -1
- package/dist/jsdoc-parser.d.ts +1 -0
- package/dist/jsdoc-parser.js +2 -1
- package/dist/mcp/pack-tools.js +2 -14
- package/dist/mcp/tools-pattern.js +1 -180
- package/dist/parser.js +1 -0
- package/dist/validator.js +15 -0
- package/docs/reference/advanced-annotations.md +11 -0
- package/docs/reference/cli-reference.md +118 -1
- package/docs/reference/error-codes.md +1 -1
- package/docs/reference/jsdoc-grammar.md +4 -2
- package/docs/reference/marketplace.md +74 -0
- package/package.json +1 -1
|
@@ -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