@fnet/cli 0.114.0 → 0.115.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 (42) hide show
  1. package/dist/fnet/index.js +1 -1
  2. package/dist/fnode/{index.mC936qdY.js → index.Brxbka97.js} +1 -1
  3. package/dist/fnode/{index.Cl6LPgIY.js → index.CoRsFBwp.js} +1 -1
  4. package/dist/fnode/index.DIZA_GzC.js +1 -0
  5. package/dist/fnode/{index.CLPC6OJN.js → index.Dg0hAD29.js} +1 -1
  6. package/dist/fnode/index.js +1 -1
  7. package/dist/fnode/{index.qJ6fWMSj.js → index.uPDSav7E.js} +1 -1
  8. package/package.json +1 -1
  9. package/template/fnet/bun/src/cli/index.js.njk +1 -1
  10. package/template/fnet/node/rollup.config.mjs.njk +144 -11
  11. package/template/fnet/node/src/cli/index.js.njk +195 -16
  12. package/template/fnode/bun/src/cli/index.js.njk +2 -2
  13. package/template/fnode/node/rollup.config.mjs.njk +144 -11
  14. package/template/fnode/node/src/cli/index.js.njk +388 -23
  15. package/dist/fnode/index.BlhtGEKB.js +0 -1
  16. package/template/fnet/bun/fnet/flows.yaml.njk +0 -1
  17. package/template/fnet/bun/fnet.yaml.njk +0 -1
  18. package/template/fnet/node/fnet/flows.yaml.njk +0 -1
  19. package/template/fnet/node/fnet.yaml.njk +0 -1
  20. package/template/fnet/node/rollup_config_external.njk +0 -8
  21. package/template/fnet/node/rollup_config_onwarn.njk +0 -9
  22. package/template/fnet/node/rollup_config_output_banner.njk +0 -3
  23. package/template/fnet/node/rollup_config_output_footer.njk +0 -5
  24. package/template/fnet/node/rollup_config_output_globals.njk +0 -9
  25. package/template/fnet/node/rollup_config_output_name.njk +0 -3
  26. package/template/fnet/node/rollup_config_plugins.njk +0 -90
  27. package/template/fnode/bun/fnode.yaml.njk +0 -1
  28. package/template/fnode/node/fnode.yaml.njk +0 -1
  29. package/template/fnode/node/rollup_config_external.njk +0 -8
  30. package/template/fnode/node/rollup_config_onwarn.njk +0 -9
  31. package/template/fnode/node/rollup_config_output_banner.njk +0 -3
  32. package/template/fnode/node/rollup_config_output_footer.njk +0 -5
  33. package/template/fnode/node/rollup_config_output_globals.njk +0 -9
  34. package/template/fnode/node/rollup_config_output_name.njk +0 -3
  35. package/template/fnode/node/rollup_config_plugins.njk +0 -90
  36. package/template/fnode/python/fnode.yaml.njk +0 -1
  37. /package/template/fnet/bun/src/default/{to.args.js.njk → input.args.js.njk} +0 -0
  38. /package/template/fnet/node/src/default/{to.args.js.njk → input.args.js.njk} +0 -0
  39. /package/template/fnet/project/.vscode/{launch.json → launch.json.njk} +0 -0
  40. /package/template/fnet/project/.vscode/{tasks.json → tasks.json.njk} +0 -0
  41. /package/template/fnode/bun/src/default/{to.args.js.njk → input.args.js.njk} +0 -0
  42. /package/template/fnode/node/src/default/{to.args.js.njk → input.args.js.njk} +0 -0
@@ -1,42 +1,221 @@
1
1
  {% if atom.doc.features.cli.enabled===true %}
2
- import argv from '../default/to.args.js';
2
+ import argv from '../default/input.args.js';
3
3
  import { default as Engine } from '../default/{{atom.doc.features.cli_default_entry_file or atom.doc.features.main_default_entry_file}}';
4
4
 
5
+ {% if atom.doc.features.cli.mcp.enabled===true %}
6
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
7
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
8
+ {% endif %}
9
+
10
+ {% if atom.doc.features.cli.http.enabled===true %}
11
+ // Using Node.js built-in http module instead of express
12
+ {% endif %}
13
+
5
14
  {% if atom.doc.features.cli.extend===true %}
6
15
  {# TYPE 1 #}
7
16
  import { default as runExtended } from '../../../cli';
8
17
 
9
18
  const run = async () => {
10
- return await runExtended(await argv(),{ Engine });
19
+ const args = await argv();
20
+ const cliMode = args['cli-mode'] || args.cli_mode || 'default';
21
+
22
+ if (cliMode === 'default') {
23
+ // Default mode code
24
+ return await runExtended(args, { Engine });
25
+ }
26
+
27
+ {% if atom.doc.features.cli.mcp.enabled===true %}
28
+ if (cliMode === 'mcp') {
29
+ // MCP mode code
30
+ const server = new McpServer({
31
+ name: "{{atom.doc.name}}",
32
+ version: "{{atom.doc.version}}"
33
+ });
34
+
35
+ server.tool(
36
+ "{{atom.doc.name}}",
37
+ async (toolArgs) => {
38
+ try {
39
+ const result = await runExtended(toolArgs, { Engine });
40
+ return {
41
+ content: [{
42
+ type: "text",
43
+ text: JSON.stringify(result)
44
+ }]
45
+ };
46
+ } catch (error) {
47
+ return {
48
+ content: [{
49
+ type: "text",
50
+ text: `Error: ${error.message}`
51
+ }],
52
+ isError: true
53
+ };
54
+ }
55
+ }
56
+ );
57
+
58
+ const transport = new StdioServerTransport();
59
+ await server.connect(transport);
60
+ console.log("MCP server started with stdio transport");
61
+ return;
62
+ }
63
+ {% endif %}
64
+
65
+ {% if atom.doc.features.cli.http.enabled===true %}
66
+ if (cliMode === 'http') {
67
+ // HTTP mode code using built-in http module
68
+ const http = require('http');
69
+
70
+ const server = http.createServer((req, res) => {
71
+ if (req.method === 'POST' && req.url === '/{{atom.doc.name}}') {
72
+ let body = '';
73
+ req.on('data', chunk => {
74
+ body += chunk.toString();
75
+ });
76
+ req.on('end', async () => {
77
+ try {
78
+ const data = JSON.parse(body);
79
+ const result = await runExtended(data, { Engine });
80
+ res.writeHead(200, { 'Content-Type': 'application/json' });
81
+ res.end(JSON.stringify(result));
82
+ } catch (error) {
83
+ res.writeHead(500, { 'Content-Type': 'application/json' });
84
+ res.end(JSON.stringify({ error: error.message }));
85
+ }
86
+ });
87
+ } else {
88
+ res.writeHead(404);
89
+ res.end();
90
+ }
91
+ });
92
+
93
+ const port = args['cli-port'] || args.cli_port || 3000;
94
+ server.listen(port, () => {
95
+ console.log(`HTTP server started on port ${port}`);
96
+ });
97
+ return;
98
+ }
99
+ {% endif %}
100
+
101
+ console.error(`Unknown CLI mode: ${cliMode}`);
102
+ process.exit(1);
11
103
  };
12
104
 
13
105
  run()
14
- .then(() => {
106
+ .then(() => {
15
107
  {# process.exit(0); #}
16
108
  })
17
- .catch((error) => {
109
+ .catch((error) => {
18
110
  console.error(error.message);
19
111
  process.exit(1);
20
112
  });
21
113
  {% else %}
22
114
  {# TYPE 2 #}
23
115
  const run = async () => {
116
+ const args = await argv();
117
+ const cliMode = args['cli-mode'] || args.cli_mode || 'default';
24
118
  const engine = new Engine();
25
- return await engine.run(await argv());
26
- };
27
119
 
28
- run()
29
- .then((result) => {
30
- if (typeof result !== 'undefined')
31
- {
32
- // TODO: REMOVE THIS LINE
33
- const stdout_format=process.argv.slice(2).indexOf()!==-1? process.argv.slice(2)[process.argv.slice(2).indexOf('--stdout_format')+1]:null;
34
- if(stdout_format==='json') console.log(JSON.stringify(result,null,2));
120
+ if (cliMode === 'default') {
121
+ // Default mode code
122
+ const result = await engine.run(args);
123
+
124
+ if (typeof result !== 'undefined') {
125
+ const stdout_format = args['stdout-format'] || args.stdout_format || null;
126
+
127
+ if (stdout_format === 'json') console.log(JSON.stringify(result, null, 2));
35
128
  else console.log(result);
36
129
  }
37
- {# process.exit(0); #}
38
- })
39
- .catch((error) => {
130
+ return;
131
+ }
132
+
133
+ {% if atom.doc.features.cli.mcp.enabled===true %}
134
+ if (cliMode === 'mcp') {
135
+ // MCP mode code
136
+ const server = new McpServer({
137
+ name: "{{atom.doc.name}}",
138
+ version: "{{atom.doc.version}}"
139
+ });
140
+
141
+ server.tool(
142
+ "{{atom.doc.name}}",
143
+ async (toolArgs) => {
144
+ try {
145
+ const result = await engine.run(toolArgs);
146
+ return {
147
+ content: [{
148
+ type: "text",
149
+ text: JSON.stringify(result)
150
+ }]
151
+ };
152
+ } catch (error) {
153
+ return {
154
+ content: [{
155
+ type: "text",
156
+ text: `Error: ${error.message}`
157
+ }],
158
+ isError: true
159
+ };
160
+ }
161
+ }
162
+ );
163
+
164
+ // Note: Direct access to workflow nodes is not implemented in this version
165
+ // In a future version, we could expose workflow nodes as separate MCP tools
166
+
167
+ const transport = new StdioServerTransport();
168
+ await server.connect(transport);
169
+ console.log("MCP server started with stdio transport");
170
+ return;
171
+ }
172
+ {% endif %}
173
+
174
+ {% if atom.doc.features.cli.http.enabled===true %}
175
+ if (cliMode === 'http') {
176
+ // HTTP mode code using built-in http module
177
+ const http = require('http');
178
+
179
+ const server = http.createServer((req, res) => {
180
+ if (req.method === 'POST' && req.url === '/{{atom.doc.name}}') {
181
+ let body = '';
182
+ req.on('data', chunk => {
183
+ body += chunk.toString();
184
+ });
185
+ req.on('end', async () => {
186
+ try {
187
+ const data = JSON.parse(body);
188
+ const result = await engine.run(data);
189
+ res.writeHead(200, { 'Content-Type': 'application/json' });
190
+ res.end(JSON.stringify(result));
191
+ } catch (error) {
192
+ res.writeHead(500, { 'Content-Type': 'application/json' });
193
+ res.end(JSON.stringify({ error: error.message }));
194
+ }
195
+ });
196
+ } else {
197
+ res.writeHead(404);
198
+ res.end();
199
+ }
200
+ });
201
+
202
+ // Note: Direct access to workflow nodes is not implemented in this version
203
+ // In a future version, we could expose workflow nodes as separate HTTP endpoints
204
+
205
+ const port = args['cli-port'] || args.cli_port || 3000;
206
+ server.listen(port, () => {
207
+ console.log(`HTTP server started on port ${port}`);
208
+ });
209
+ return;
210
+ }
211
+ {% endif %}
212
+
213
+ console.error(`Unknown CLI mode: ${cliMode}`);
214
+ process.exit(1);
215
+ };
216
+
217
+ run()
218
+ .catch((error) => {
40
219
  console.error(error.message);
41
220
  process.exit(1);
42
221
  });
@@ -2,7 +2,7 @@
2
2
 
3
3
  {% if atom.doc.features.project.format==='esm' %}
4
4
 
5
- import argv from '../default/to.args.js';
5
+ import argv from '../default/input.args.js';
6
6
 
7
7
  {% if atom.doc.features.cli.extend===true %}
8
8
 
@@ -40,7 +40,7 @@ run()
40
40
 
41
41
  {% elif atom.doc.features.project.format==='cjs' %}
42
42
 
43
- const argv = require('../default/to.args.js');
43
+ const argv = require('../default/input.args.js');
44
44
 
45
45
  {% if atom.doc.features.cli.extend===true %}
46
46
 
@@ -182,9 +182,9 @@ const initPlugins = async (options) => {
182
182
  {% if atom.doc.features.project.format ==='esm' %}
183
183
  include: /node_modules/,
184
184
  ignore: ["fsevents"],
185
- {% endif %}
185
+ {% endif %}
186
186
  }));
187
-
187
+
188
188
 
189
189
  {# POLYFILL #}
190
190
  {% if atom.doc.features.polyfill_enabled===true %}
@@ -193,7 +193,7 @@ const initPlugins = async (options) => {
193
193
  plugins.push(polyfills(options.polyfill.options));
194
194
  }
195
195
  {% endif %}
196
-
196
+
197
197
  {# WORKBOX #}
198
198
  {% if atom.doc.features.workbox_enabled===true %}
199
199
  if (options?.workbox) {
@@ -291,7 +291,7 @@ const createConfigs = async () => {
291
291
  if (!fs.existsSync(groupDir)) {
292
292
  fs.mkdirSync(groupDir, { recursive: true });
293
293
  }
294
-
294
+
295
295
  {% for key, value in atom.doc.features.rollup_output %}
296
296
  {% if value and value.enabled !== false %}
297
297
  {
@@ -310,17 +310,150 @@ const createConfigs = async () => {
310
310
  entryFileNames: "[name].cjs",
311
311
  chunkFileNames: "[name]-[hash].cjs",
312
312
  {% endif %}
313
- {% include 'rollup_config_output_name.njk' %}
314
- {% include 'rollup_config_output_globals.njk' %}
315
- {% include 'rollup_config_output_banner.njk' %}
316
- {% include 'rollup_config_output_footer.njk' %}
313
+ {# BEGIN: rollup_config_output_name #}
314
+ {% if value.format==='iife' or value.format==='umd'%}
315
+ name: "{{atom.doc.bundleName}}",
316
+ {% endif %}
317
+ {# END: rollup_config_output_name #}
318
+ {# BEGIN: rollup_config_output_globals #}
319
+ {% if value.browser===true %}
320
+ {% if value.globals.length %}
321
+ globals: {
322
+ {% for global in value.globals %}
323
+ "{{global.key}}":"{{global.value}}" {% if not loop.last %},{% endif %}
324
+ {% endfor %}
325
+ },
326
+ {% endif %}
327
+ {% endif %}
328
+ {# END: rollup_config_output_globals #}
329
+ {# BEGIN: rollup_config_output_banner #}
330
+ {% if value.banner %}
331
+ banner:'{{value.banner}}',
332
+ {% endif %}
333
+ {# END: rollup_config_output_banner #}
334
+ {# BEGIN: rollup_config_output_footer #}
335
+ {% if value.format==='iife' %}
336
+ {% if atom.type==='workflow'%}
337
+ {# footer: "new {{atom.doc.bundleName}}().run().catch(e=>{});" #}
338
+ {% endif %}
339
+ {% endif %}
340
+ {# END: rollup_config_output_footer #}
317
341
  },
318
342
  {% if value.context %}
319
343
  context: "{{value.context}}",
320
344
  {% endif %}
321
- {% include 'rollup_config_external.njk' %}
322
- {% include 'rollup_config_onwarn.njk' %}
323
- {% include 'rollup_config_plugins.njk' %}
345
+ {# BEGIN: rollup_config_external #}
346
+ {% if value.external_enabled %}
347
+ external: [
348
+ {% for external in value.external %}
349
+ "{{external}}" {% if not loop.last %},{% endif %}
350
+ {% endfor %}
351
+ ],
352
+ {% endif %}
353
+ {# END: rollup_config_external #}
354
+ {# BEGIN: rollup_config_onwarn #}
355
+ onwarn(warning, warn) {
356
+ switch (warning.code) {
357
+ case 'MODULE_LEVEL_DIRECTIVE':
358
+ case 'CIRCULAR_DEPENDENCY':
359
+ return;
360
+ default:
361
+ warn(warning);
362
+ }
363
+ },
364
+ {# END: rollup_config_onwarn #}
365
+ {# BEGIN: rollup_config_plugins #}
366
+ plugins: await initPlugins({
367
+ delete:{ targets: [path.normalize(groupDir + '{{key}}')], runOnce: DEVELOPMENT },
368
+
369
+ format:"{{ value.format }}",
370
+
371
+ {% if value.babel===true %}
372
+ babel:{{value.babel_options | dump | safe}},
373
+ {% endif %}
374
+
375
+ {% if value.replace ===true %}
376
+ replace:{{value.replace_options | dump | safe}},
377
+ {% endif %}
378
+
379
+ {% if value.browser===true %}
380
+ browser:true,
381
+ {% endif %}
382
+
383
+ {% if value.browsersync===true and atom.doc.features.browsersync_enabled===true%}
384
+ browsersync: {{value.browsersync_options | dump | safe}},
385
+ {% endif %}
386
+
387
+ {% if value.alias_enabled===true %}
388
+ alias:{{value.alias | dump | safe}},
389
+ {% endif %}
390
+
391
+ {# OK #}
392
+ {% if value.css %}
393
+ postcss:{{value.css | dump | safe}},
394
+ {% endif %}
395
+
396
+ {# OK #}
397
+ {% if value.copy %}
398
+ copy:{{value.copy | dump | safe}},
399
+ {% endif %}
400
+
401
+ {# OK #}
402
+ {% if value.terser%}
403
+ terser:{{value.terser | dump | safe}},
404
+ {% endif %}
405
+
406
+ {# OK #}
407
+ {% if value.json %}
408
+ json:{{value.json | dump | safe}},
409
+ {% endif %}
410
+
411
+ {# OK #}
412
+ {% if value.wasm %}
413
+ wasm: {{value.wasm | dump | safe}},
414
+ {% endif %}
415
+
416
+ {# OK #}
417
+ {% if value.string %}
418
+ string:{{value.string | dump | safe}},
419
+ {% endif %}
420
+
421
+ {# OK #}
422
+ {% if value.image %}
423
+ image:{{value.image | dump | safe}},
424
+ {% endif %}
425
+
426
+ {# OK #}
427
+ {% if value.analyzer %}
428
+ analyzer:{{value.analyzer | dump | safe}},
429
+ {% endif %}
430
+
431
+ {# OK #}
432
+ {% if value.visualizer %}
433
+ visualizer:{{value.visualizer | dump | safe}},
434
+ {% endif %}
435
+
436
+ {# OK #}
437
+ {% if value.polyfill %}
438
+ polyfill:{{value.polyfill | dump | safe}},
439
+ {% endif %}
440
+
441
+ {# OK #}
442
+ {% if value.nunjucks %}
443
+ nunjucks:{{value.nunjucks | dump | safe}},
444
+ {% endif %}
445
+
446
+ {# OK #}
447
+ {% if value.workbox %}
448
+ workbox:{{value.workbox | dump | safe}},
449
+ {% endif %}
450
+
451
+ {# OK #}
452
+ {% if value.gzip %}
453
+ gzip:{{value.gzip | dump | safe}},
454
+ {% endif %}
455
+ }),
456
+ {# END: rollup_config_plugins #}
324
457
  }
325
458
  configs.push(config);
326
459
  }