@synergenius/flow-weaver 0.31.0 → 0.32.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.
@@ -412,6 +412,177 @@ const handlers = {
412
412
  return { data: { authenticated: false, message: err instanceof Error ? err.message : String(err) } };
413
413
  }
414
414
  },
415
+ // ─── doctor ─────────────────────────────────────────────────────
416
+ doctor: async (args) => {
417
+ const cwd = args.cwd || process.cwd();
418
+ const checks = [];
419
+ // Check package.json exists
420
+ const pkgPath = path.join(cwd, 'package.json');
421
+ const hasPkg = fs.existsSync(pkgPath);
422
+ checks.push({ name: 'package.json', ok: hasPkg, message: hasPkg ? 'Found' : 'Not found' });
423
+ // Check flow-weaver dependency
424
+ if (hasPkg) {
425
+ try {
426
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
427
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
428
+ const hasFw = !!deps['@synergenius/flow-weaver'];
429
+ checks.push({ name: 'flow-weaver dependency', ok: hasFw, message: hasFw ? deps['@synergenius/flow-weaver'] : 'Not installed' });
430
+ }
431
+ catch {
432
+ checks.push({ name: 'flow-weaver dependency', ok: false, message: 'Could not parse package.json' });
433
+ }
434
+ }
435
+ // Check node_modules
436
+ const hasModules = fs.existsSync(path.join(cwd, 'node_modules'));
437
+ checks.push({ name: 'node_modules', ok: hasModules, message: hasModules ? 'Found' : 'Run npm install' });
438
+ // Check tsconfig
439
+ const hasTsConfig = fs.existsSync(path.join(cwd, 'tsconfig.json'));
440
+ checks.push({ name: 'tsconfig.json', ok: hasTsConfig, message: hasTsConfig ? 'Found' : 'Not found (optional)' });
441
+ const allOk = checks.every((c) => c.ok);
442
+ return { data: { healthy: allOk, checks } };
443
+ },
444
+ // ─── init ───────────────────────────────────────────────────────
445
+ init: async (args) => {
446
+ const directory = path.resolve(String(args.directory || 'flow-weaver-project'));
447
+ const template = args.template || 'hello';
448
+ // Create directory
449
+ fs.mkdirSync(directory, { recursive: true });
450
+ // Create package.json
451
+ const name = path.basename(directory);
452
+ const pkg = {
453
+ name,
454
+ version: '1.0.0',
455
+ type: 'module',
456
+ scripts: { build: 'fw compile src/**/*.ts', dev: 'fw dev src/**/*.ts' },
457
+ dependencies: { '@synergenius/flow-weaver': 'latest' },
458
+ };
459
+ fs.writeFileSync(path.join(directory, 'package.json'), JSON.stringify(pkg, null, 2));
460
+ // Create src directory and a starter workflow via scaffold
461
+ const srcDir = path.join(directory, 'src');
462
+ fs.mkdirSync(srcDir, { recursive: true });
463
+ try {
464
+ const wfPath = path.join(srcDir, `${name}-workflow.ts`);
465
+ const code = generateWorkflowFromTemplate(template, { workflowName: name });
466
+ fs.writeFileSync(wfPath, code);
467
+ return { data: { directory, template, files: [wfPath], message: `Project created. Run: cd ${name} && npm install` } };
468
+ }
469
+ catch {
470
+ return { data: { directory, template, files: [], message: `Project directory created but template '${template}' failed. Run: fw create workflow sequential src/workflow.ts` } };
471
+ }
472
+ },
473
+ // ─── grammar ────────────────────────────────────────────────────
474
+ grammar: async (args) => {
475
+ const { getAllGrammars, serializedToEBNF } = await import('../chevrotain-parser/grammar-diagrams.js');
476
+ const format = args.format || 'ebnf';
477
+ const grammars = getAllGrammars();
478
+ const allProductions = [
479
+ ...grammars.node, ...grammars.port, ...grammars.connect,
480
+ ...grammars.path, ...grammars.map, ...grammars.fan,
481
+ ...grammars.triggerCancel, ...grammars.position, ...grammars.scope,
482
+ ];
483
+ const grammar = serializedToEBNF(allProductions);
484
+ return { data: { grammar, format } };
485
+ },
486
+ // ─── apikey ─────────────────────────────────────────────────────
487
+ apikey: async (args) => {
488
+ try {
489
+ const { isLoggedIn, loadCredentials } = await import('../cli/config/credentials.js');
490
+ if (!isLoggedIn()) {
491
+ return { data: { authenticated: false, message: 'Not logged in. Use fw login first.' } };
492
+ }
493
+ const action = args.action || 'list';
494
+ const creds = loadCredentials();
495
+ const { PlatformClient } = await import('../cli/config/platform-client.js');
496
+ const client = new PlatformClient(creds);
497
+ if (action === 'list') {
498
+ const keys = await client.listApiKeys?.() ?? [];
499
+ return { data: { authenticated: true, keys } };
500
+ }
501
+ if (action === 'create') {
502
+ const key = await client.createApiKey?.(String(args.name || 'default')) ?? null;
503
+ return { data: { authenticated: true, key } };
504
+ }
505
+ if (action === 'revoke') {
506
+ await client.revokeApiKey?.(String(args.keyId));
507
+ return { data: { authenticated: true, revoked: args.keyId } };
508
+ }
509
+ return { data: { authenticated: true, message: `Unknown action: ${action}` } };
510
+ }
511
+ catch (err) {
512
+ return { data: { authenticated: false, message: err instanceof Error ? err.message : String(err) } };
513
+ }
514
+ },
515
+ // ─── ai ─────────────────────────────────────────────────────────
516
+ ai: async (args) => {
517
+ try {
518
+ const action = args.action || 'list';
519
+ const configDir = path.join(process.env.HOME || '~', '.fw');
520
+ const aiConfigPath = path.join(configDir, 'ai-providers.json');
521
+ if (action === 'list') {
522
+ if (!fs.existsSync(aiConfigPath)) {
523
+ return { data: { providers: [] } };
524
+ }
525
+ const providers = JSON.parse(fs.readFileSync(aiConfigPath, 'utf-8'));
526
+ return { data: { providers: Object.keys(providers) } };
527
+ }
528
+ if (action === 'set') {
529
+ fs.mkdirSync(configDir, { recursive: true });
530
+ const existing = fs.existsSync(aiConfigPath) ? JSON.parse(fs.readFileSync(aiConfigPath, 'utf-8')) : {};
531
+ existing[String(args.provider)] = { apiKey: String(args.apiKey) };
532
+ fs.writeFileSync(aiConfigPath, JSON.stringify(existing, null, 2));
533
+ return { data: { providers: Object.keys(existing), set: args.provider } };
534
+ }
535
+ if (action === 'remove') {
536
+ if (fs.existsSync(aiConfigPath)) {
537
+ const existing = JSON.parse(fs.readFileSync(aiConfigPath, 'utf-8'));
538
+ delete existing[String(args.provider)];
539
+ fs.writeFileSync(aiConfigPath, JSON.stringify(existing, null, 2));
540
+ return { data: { providers: Object.keys(existing), removed: args.provider } };
541
+ }
542
+ return { data: { providers: [] } };
543
+ }
544
+ return { data: { message: `Unknown action: ${action}` } };
545
+ }
546
+ catch (err) {
547
+ return { data: { message: err instanceof Error ? err.message : String(err) } };
548
+ }
549
+ },
550
+ // ─── org ────────────────────────────────────────────────────────
551
+ org: async (args) => {
552
+ try {
553
+ const { isLoggedIn, loadCredentials } = await import('../cli/config/credentials.js');
554
+ if (!isLoggedIn()) {
555
+ return { data: { authenticated: false, message: 'Not logged in. Use fw login first.' } };
556
+ }
557
+ const action = args.action || 'list';
558
+ const creds = loadCredentials();
559
+ const { PlatformClient } = await import('../cli/config/platform-client.js');
560
+ const client = new PlatformClient(creds);
561
+ if (action === 'list') {
562
+ const orgs = await client.listOrgs?.() ?? [];
563
+ return { data: { authenticated: true, orgs } };
564
+ }
565
+ return { data: { authenticated: true, message: `Action '${action}' requires the CLI: fw org ${action}` } };
566
+ }
567
+ catch (err) {
568
+ return { data: { authenticated: false, message: err instanceof Error ? err.message : String(err) } };
569
+ }
570
+ },
571
+ // ─── connect ────────────────────────────────────────────────────
572
+ connect: async (args) => {
573
+ try {
574
+ const { isLoggedIn, loadCredentials } = await import('../cli/config/credentials.js');
575
+ if (!isLoggedIn()) {
576
+ return { data: { authenticated: false, message: 'Not logged in. Use fw login first.' } };
577
+ }
578
+ const directory = path.resolve(String(args.directory || process.cwd()));
579
+ const creds = loadCredentials();
580
+ return { data: { authenticated: true, directory, platformUrl: creds?.platformUrl, connected: true } };
581
+ }
582
+ catch (err) {
583
+ return { data: { authenticated: false, message: err instanceof Error ? err.message : String(err) } };
584
+ }
585
+ },
415
586
  };
416
587
  export async function runCommand(name, args) {
417
588
  const handler = handlers[name];
@@ -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.31.0";
5990
+ VERSION = "0.32.0";
5991
5991
  }
5992
5992
  });
5993
5993
 
@@ -88937,7 +88937,7 @@ function parseIntStrict(value) {
88937
88937
  // src/cli/index.ts
88938
88938
  init_logger();
88939
88939
  init_error_utils();
88940
- var version2 = true ? "0.31.0" : "0.0.0-dev";
88940
+ var version2 = true ? "0.32.0" : "0.0.0-dev";
88941
88941
  var program2 = new Command();
88942
88942
  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", () => {
88943
88943
  logger.banner(version2);
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.31.0";
1
+ export declare const VERSION = "0.32.0";
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.31.0';
2
+ export const VERSION = '0.32.0';
3
3
  //# sourceMappingURL=generated-version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synergenius/flow-weaver",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
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",