0xray 2.1.4 → 2.2.1

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 (186) hide show
  1. package/.opencode/codex.codex +1 -1
  2. package/.opencode/commands/dependency-audit.md +3 -3
  3. package/.opencode/enforcer-config.json +2 -2
  4. package/.opencode/init.sh +1 -1
  5. package/AGENTS.md +6 -6
  6. package/README.md +4 -4
  7. package/dist/AGENTS.md +6 -6
  8. package/dist/CHANGELOG.md +39 -0
  9. package/dist/README.md +4 -4
  10. package/dist/agents/code-reviewer.js +1 -1
  11. package/dist/analytics/routing-refiner.js +1 -1
  12. package/dist/cli/commands/govern.d.ts +29 -0
  13. package/dist/cli/commands/govern.js +152 -0
  14. package/dist/cli/index.js +29 -216
  15. package/dist/core/boot-orchestrator.js +2 -2
  16. package/dist/core/features-config.js +1 -1
  17. package/dist/core/framework-logger.d.ts +1 -0
  18. package/dist/core/framework-logger.js +57 -2
  19. package/dist/delegation/index.d.ts +1 -2
  20. package/dist/delegation/index.js +1 -2
  21. package/dist/enforcement/enforcer-tools.js +1 -1
  22. package/dist/execution/proposal-applier.d.ts +1 -9
  23. package/dist/execution/proposal-applier.js +18 -173
  24. package/dist/governance/codex-policy.service.d.ts +7 -25
  25. package/dist/governance/codex-policy.service.js +8 -26
  26. package/dist/governance/governance-core.d.ts +22 -28
  27. package/dist/governance/governance-core.js +31 -101
  28. package/dist/governance/governance-service.d.ts +1 -0
  29. package/dist/governance/governance-service.js +67 -4
  30. package/dist/governance/governance-types.d.ts +5 -2
  31. package/dist/inference/index.d.ts +3 -4
  32. package/dist/inference/inference-accumulator.js +1 -1
  33. package/dist/inference/inference-cycle.d.ts +12 -18
  34. package/dist/inference/inference-cycle.js +120 -335
  35. package/dist/integrations/base/index.d.ts +0 -1
  36. package/dist/integrations/base/index.js +0 -2
  37. package/dist/integrations/grok/hooks/pre-tool-use.js +4 -18
  38. package/dist/integrations/hermes-agent/bridge.mjs +9 -0
  39. package/dist/mcps/config/server-config-registry.js +1 -1
  40. package/dist/mcps/governance.server.js +4 -5
  41. package/dist/mcps/knowledge-skills/api-design.server.js +10 -0
  42. package/dist/mcps/knowledge-skills/architecture-patterns.server.js +10 -0
  43. package/dist/mcps/knowledge-skills/bug-triage-specialist.server.js +10 -0
  44. package/dist/mcps/knowledge-skills/code-analyzer.server.js +10 -0
  45. package/dist/mcps/knowledge-skills/code-review.server.js +10 -0
  46. package/dist/mcps/knowledge-skills/content-creator.server.js +10 -0
  47. package/dist/mcps/knowledge-skills/database-design.server.js +10 -0
  48. package/dist/mcps/knowledge-skills/devops-deployment.server.js +10 -0
  49. package/dist/mcps/knowledge-skills/git-workflow.server.js +10 -0
  50. package/dist/mcps/knowledge-skills/growth-strategist.server.js +10 -0
  51. package/dist/mcps/knowledge-skills/log-monitor.server.js +10 -0
  52. package/dist/mcps/knowledge-skills/mobile-development.server.js +10 -0
  53. package/dist/mcps/knowledge-skills/multimodal-looker.server.js +10 -0
  54. package/dist/mcps/knowledge-skills/performance-optimization.server.js +10 -0
  55. package/dist/mcps/knowledge-skills/project-analysis.server.js +10 -0
  56. package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +10 -0
  57. package/dist/mcps/knowledge-skills/security-audit.server.js +10 -0
  58. package/dist/mcps/knowledge-skills/seo-consultant.server.js +10 -0
  59. package/dist/mcps/knowledge-skills/skill-invocation.server.d.ts +4 -0
  60. package/dist/mcps/knowledge-skills/skill-invocation.server.js +33 -14
  61. package/dist/mcps/knowledge-skills/strategist.server.js +10 -0
  62. package/dist/mcps/knowledge-skills/tech-writer.server.js +11 -1
  63. package/dist/mcps/knowledge-skills/testing-strategy.server.js +10 -0
  64. package/dist/mcps/knowledge-skills/ui-ux-design.server.js +10 -0
  65. package/dist/mcps/registry.json +1 -1
  66. package/dist/mcps/simulation/server-simulations.js +1 -1
  67. package/dist/metrics/agent-metrics.d.ts +2 -1
  68. package/dist/nucleus/govern-http.d.ts +59 -0
  69. package/dist/nucleus/govern-http.js +172 -0
  70. package/dist/nucleus/index.d.ts +14 -0
  71. package/dist/nucleus/index.js +9 -0
  72. package/dist/nucleus/kernel.d.ts +51 -0
  73. package/dist/nucleus/kernel.js +62 -0
  74. package/dist/nucleus/plugin-registry.d.ts +104 -0
  75. package/dist/nucleus/plugin-registry.js +147 -0
  76. package/dist/orchestrator/orchestrator.d.ts +0 -1
  77. package/dist/orchestrator/orchestrator.js +0 -21
  78. package/dist/postprocessor/PostProcessor.d.ts +13 -1
  79. package/dist/postprocessor/PostProcessor.js +41 -1
  80. package/dist/postprocessor/autofix/AutoFixEngine.d.ts +0 -8
  81. package/dist/postprocessor/autofix/AutoFixEngine.js +0 -54
  82. package/dist/postprocessor/metamorphosis/MetamorphosisEngine.d.ts +25 -0
  83. package/dist/postprocessor/metamorphosis/MetamorphosisEngine.js +10 -0
  84. package/dist/postprocessor/metamorphosis/SelfProposalEngine.d.ts +68 -0
  85. package/dist/postprocessor/metamorphosis/SelfProposalEngine.js +371 -0
  86. package/dist/skills/orchestrator/SKILL.md +1 -1
  87. package/dist/skills/registry.json +1 -1
  88. package/dist/state/index.d.ts +0 -2
  89. package/package.json +4 -3
  90. package/scripts/node/universal-version-manager.js +9 -9
  91. package/scripts/node/validate-mcp-connectivity.js +1 -1
  92. package/src/mcps/config/__tests__/server-config-registry.test.ts +6 -15
  93. package/src/mcps/config/server-config-registry.ts +1 -1
  94. package/src/mcps/governance.server.ts +4 -6
  95. package/src/mcps/knowledge-skills/api-design.server.ts +9 -0
  96. package/src/mcps/knowledge-skills/architecture-patterns.server.ts +9 -0
  97. package/src/mcps/knowledge-skills/bug-triage-specialist.server.ts +9 -0
  98. package/src/mcps/knowledge-skills/code-analyzer.server.ts +9 -0
  99. package/src/mcps/knowledge-skills/code-review.server.ts +9 -0
  100. package/src/mcps/knowledge-skills/content-creator.server.ts +9 -0
  101. package/src/mcps/knowledge-skills/database-design.server.ts +9 -0
  102. package/src/mcps/knowledge-skills/devops-deployment.server.ts +9 -0
  103. package/src/mcps/knowledge-skills/git-workflow.server.ts +9 -0
  104. package/src/mcps/knowledge-skills/growth-strategist.server.ts +9 -0
  105. package/src/mcps/knowledge-skills/log-monitor.server.ts +9 -0
  106. package/src/mcps/knowledge-skills/mobile-development.server.ts +9 -0
  107. package/src/mcps/knowledge-skills/multimodal-looker.server.ts +9 -0
  108. package/src/mcps/knowledge-skills/performance-optimization.server.ts +9 -0
  109. package/src/mcps/knowledge-skills/project-analysis.server.ts +9 -0
  110. package/src/mcps/knowledge-skills/refactoring-strategies.server.ts +9 -0
  111. package/src/mcps/knowledge-skills/security-audit.server.ts +9 -0
  112. package/src/mcps/knowledge-skills/seo-consultant.server.ts +9 -0
  113. package/src/mcps/knowledge-skills/session-management.server.ts +1 -0
  114. package/src/mcps/knowledge-skills/skill-invocation.server.ts +44 -29
  115. package/src/mcps/knowledge-skills/strategist.server.ts +9 -0
  116. package/src/mcps/knowledge-skills/tech-writer.server.ts +10 -1
  117. package/src/mcps/knowledge-skills/testing-strategy.server.ts +9 -0
  118. package/src/mcps/knowledge-skills/ui-ux-design.server.ts +9 -0
  119. package/src/mcps/registry.json +1 -1
  120. package/src/mcps/simulation/server-simulations.ts +1 -1
  121. package/src/opencode/codex.codex +1 -1
  122. package/src/opencode/commands/dependency-audit.md +3 -3
  123. package/src/opencode/enforcer-config.json +2 -2
  124. package/src/skills/orchestrator/SKILL.md +1 -1
  125. package/src/skills/registry.json +1 -1
  126. package/xray/codex.json +1 -1
  127. package/xray/config.json +1 -1
  128. package/xray/features.json +1 -1
  129. package/xray/integrations.json +3 -3
  130. package/.opencode/agents/testing-best-practices.yml +0 -12
  131. package/dist/analytics/consent-manager.d.ts +0 -93
  132. package/dist/analytics/consent-manager.js +0 -258
  133. package/dist/analytics/simple-pattern-analyzer.d.ts +0 -80
  134. package/dist/analytics/simple-pattern-analyzer.js +0 -297
  135. package/dist/cli/commands/analytics-disable.d.ts +0 -9
  136. package/dist/cli/commands/analytics-disable.js +0 -72
  137. package/dist/cli/commands/analytics-enable-action.d.ts +0 -8
  138. package/dist/cli/commands/analytics-enable-action.js +0 -82
  139. package/dist/cli/commands/analytics-preview.d.ts +0 -9
  140. package/dist/cli/commands/analytics-preview.js +0 -106
  141. package/dist/cli/commands/analytics-status.d.ts +0 -9
  142. package/dist/cli/commands/analytics-status.js +0 -68
  143. package/dist/cli/server.d.ts +0 -1
  144. package/dist/cli/server.js +0 -147
  145. package/dist/core/errors.d.ts +0 -3
  146. package/dist/core/errors.js +0 -10
  147. package/dist/core/logging-config.d.ts +0 -11
  148. package/dist/core/logging-config.js +0 -43
  149. package/dist/core/trace-context.d.ts +0 -12
  150. package/dist/core/trace-context.js +0 -33
  151. package/dist/delegation/voting-coordinator.d.ts +0 -49
  152. package/dist/delegation/voting-coordinator.js +0 -375
  153. package/dist/enforcement/test-auto-healing.d.ts +0 -83
  154. package/dist/enforcement/test-auto-healing.js +0 -325
  155. package/dist/integrations/base/ExampleIntegration.d.ts +0 -47
  156. package/dist/integrations/base/ExampleIntegration.js +0 -181
  157. package/dist/mcps/knowledge-skills/testing-best-practices.server.d.ts +0 -34
  158. package/dist/mcps/knowledge-skills/testing-best-practices.server.js +0 -831
  159. package/dist/mcps/orchestrator.server.d.ts +0 -10
  160. package/dist/mcps/orchestrator.server.js +0 -19
  161. package/dist/orchestrator/self-direction-activation.d.ts +0 -109
  162. package/dist/orchestrator/self-direction-activation.js +0 -245
  163. package/dist/orchestrator/universal-librarian-consultation.d.ts +0 -98
  164. package/dist/orchestrator/universal-librarian-consultation.js +0 -216
  165. package/dist/orchestrator/universal-registry-bridge.d.ts +0 -85
  166. package/dist/orchestrator/universal-registry-bridge.js +0 -247
  167. package/dist/performance/performance-budget-enforcer.d.ts +0 -158
  168. package/dist/performance/performance-budget-enforcer.js +0 -434
  169. package/dist/performance/performance-regression-tester.d.ts +0 -108
  170. package/dist/performance/performance-regression-tester.js +0 -342
  171. package/dist/skills/testing-best-practices/SKILL.md +0 -37
  172. package/dist/state/context-providers.d.ts +0 -4
  173. package/dist/state/context-providers.js +0 -1
  174. package/dist/state/state-types.d.ts +0 -5
  175. package/dist/state/state-types.js +0 -1
  176. package/dist/utils/batch-operations.d.ts +0 -25
  177. package/dist/utils/batch-operations.js +0 -292
  178. package/dist/utils/test-template-generator.d.ts +0 -25
  179. package/dist/utils/test-template-generator.js +0 -178
  180. package/dist/utils/token-manager.d.ts +0 -48
  181. package/dist/utils/token-manager.js +0 -163
  182. package/src/mcps/knowledge-skills/testing-best-practices.server.test.ts +0 -136
  183. package/src/mcps/knowledge-skills/testing-best-practices.server.ts +0 -1183
  184. package/src/mcps/orchestrator.server.ts +0 -34
  185. package/src/opencode/agents/testing-best-practices.yml +0 -12
  186. package/src/skills/testing-best-practices/SKILL.md +0 -37
package/dist/cli/index.js CHANGED
@@ -364,60 +364,6 @@ program
364
364
  process.exit(1);
365
365
  }
366
366
  });
367
- // Analytics command - pattern analysis, insights, and consent management
368
- program
369
- .command("analytics")
370
- .description("xray Central Analytics - Pattern analysis, insights, and consent management\n" +
371
- " In v1.7.2+: Includes consent management with granular control\n" +
372
- " Use 'npx xray analytics enable' to opt-in to data sharing\n" +
373
- " Core classes: ConsentManager, AnonymizationEngine available programmatically")
374
- .option("-l, --limit <number>", "Limit analysis to last N task completions")
375
- .option("-o, --output <file>", "Save report to file")
376
- .action(async (opts) => {
377
- console.log("📊 xray Pattern Analytics");
378
- console.log("==============================");
379
- console.log("");
380
- try {
381
- // Dynamic import to avoid loading analytics module unless needed
382
- const { SimplePatternAnalyzer } = await import("../analytics/simple-pattern-analyzer.js");
383
- // Get default limit from features.json
384
- const fs = await import("fs");
385
- const path = await import("path");
386
- let defaultLimit = 500;
387
- try {
388
- const featuresPath = path.join(process.cwd(), ".opencode", "plugins", "features.json"); // plain xray primary (min compat .xray/ handled in getConfigDir per Scope Rule)
389
- if (fs.existsSync(featuresPath)) {
390
- const features = JSON.parse(fs.readFileSync(featuresPath, "utf-8"));
391
- defaultLimit = features.analytics?.default_limit || 500;
392
- }
393
- }
394
- catch { /* use default */ }
395
- const analyzer = new SimplePatternAnalyzer();
396
- const limit = parseInt(opts.limit) || defaultLimit;
397
- console.log(`Analyzing last ${limit} task completions...`);
398
- console.log("");
399
- const insights = await analyzer.analyze(limit);
400
- const insightsLines = analyzer.generateInsights(insights);
401
- // Print insights
402
- insightsLines.forEach((line) => {
403
- console.log(line);
404
- });
405
- // Save to file if requested
406
- if (opts.output) {
407
- const fs = await import("fs");
408
- const report = await analyzer.generateReport();
409
- fs.writeFileSync(opts.output, report);
410
- console.log("");
411
- console.log(`✅ Report saved to: ${opts.output}`);
412
- }
413
- console.log("");
414
- console.log("💡 Run regularly to track agent performance and complexity accuracy");
415
- }
416
- catch (error) {
417
- console.error("❌ Analytics failed:", error instanceof Error ? error.message : String(error));
418
- process.exit(1);
419
- }
420
- });
421
367
  program
422
368
  .command("doctor")
423
369
  .description("Diagnose framework issues (does not fix them)")
@@ -494,40 +440,6 @@ program
494
440
  process.exit(1);
495
441
  }
496
442
  });
497
- // Archive logs command - standalone, no framework boot required
498
- program
499
- .command("archive-logs")
500
- .description("Archive log files without framework boot (for git hooks)")
501
- .option("--dry-run", "Show what would be archived without making changes")
502
- .option("-v, --verbose", "Verbose output")
503
- .action(async (opts) => {
504
- console.log("📦 xray Log Archive");
505
- console.log("========================");
506
- if (opts.dryRun) {
507
- console.log("(Dry run mode - no changes will be made)");
508
- }
509
- try {
510
- // Import and run standalone archiver
511
- const archiveModule = await import("./commands/archive-logs.js");
512
- const result = await archiveModule.archiveLogFiles({
513
- maxFileSizeMB: 10,
514
- rotationIntervalHours: 24,
515
- compressionEnabled: true,
516
- maxArchives: 10,
517
- }, `cli-${Date.now()}`);
518
- console.log(`\n📊 Results:`);
519
- console.log(` Archived: ${result.archived} files`);
520
- if (result.errors.length > 0) {
521
- console.log(` Errors: ${result.errors.length}`);
522
- result.errors.forEach((e) => console.log(` - ${e}`));
523
- process.exit(1);
524
- }
525
- }
526
- catch (error) {
527
- console.error("Archive failed:", error);
528
- process.exit(1);
529
- }
530
- });
531
443
  // Inference improvement command
532
444
  program
533
445
  .command('inference:improve')
@@ -691,7 +603,7 @@ program
691
603
  const projectRoot = process.cwd();
692
604
  const inferenceDir = `${projectRoot}/docs/inference`;
693
605
  const stateDir = `${projectRoot}/.xray/inference`;
694
- const stateFile = `${stateDir}/inference-cycle-state.json`;
606
+ const stateFile = `${stateDir}/inference-state.json`;
695
607
  if (!options.json) {
696
608
  console.log('xray Inference Cycle');
697
609
  console.log('====================');
@@ -765,35 +677,6 @@ program
765
677
  }
766
678
  }
767
679
  });
768
- // Publish agent command
769
- program
770
- .command('publish-agent')
771
- .description('Package and publish agents to AgentStore')
772
- .option('-a, --agent <name>', 'Agent name to publish')
773
- .option('-v, --version <version>', 'Version to publish (default: 1.0.0)')
774
- .option('-d, --dry-run', 'Show what would be published without publishing')
775
- .action(async () => {
776
- const { publishAgentCommand } = await import('./commands/publish-agent.js');
777
- await publishAgentCommand();
778
- });
779
- // Antigravity status command
780
- program
781
- .command('antigravity status')
782
- .description('Show status of all installed skills')
783
- .action(async () => {
784
- const { antigravityStatusCommand } = await import('./commands/antigravity-status.js');
785
- await antigravityStatusCommand();
786
- });
787
- // Credible init command
788
- program
789
- .command('credible init')
790
- .description('Initialize Credible Pod infrastructure')
791
- .option('-n, --name <name>', 'Pod name')
792
- .option('-t, --template <template>', 'Pod template to use')
793
- .action(async () => {
794
- const { credibleInitCommand } = await import('./commands/credible-init.js');
795
- await credibleInitCommand();
796
- });
797
680
  // Skill registry command
798
681
  program
799
682
  .command('skill:registry [action]')
@@ -816,51 +699,6 @@ program
816
699
  const { skillInstallCommand } = await import('./commands/skill-install.js');
817
700
  await skillInstallCommand(sourceArg, options);
818
701
  });
819
- // Storyteller command
820
- program
821
- .command('storyteller [type]')
822
- .description('Write reflections, sagas, journeys, or narratives')
823
- .option('-t, --title <title>', 'Title for the story')
824
- .option('-f, --framework <framework>', 'Storytelling framework (three_act_structure, hero_journey, spiral)')
825
- .option('-o, --output <file>', 'Output file path')
826
- .option('--dry-run', 'Show prompt without creating file')
827
- .action(async (type, options) => {
828
- const { storytellerCommand } = await import('./commands/storyteller.js');
829
- await storytellerCommand(type, options);
830
- });
831
- // MCP install commands - support both hyphen and colon formats
832
- program
833
- .command('mcp-list')
834
- .alias('mcp:list')
835
- .description('List available community MCP servers')
836
- .action(async () => {
837
- const { listMCPsCommand } = await import('./commands/mcp-install.js');
838
- listMCPsCommand();
839
- });
840
- program
841
- .command('mcp-status')
842
- .alias('mcp:status')
843
- .description('Show installed MCP servers')
844
- .action(async () => {
845
- const { showMCPStatusCommand } = await import('./commands/mcp-install.js');
846
- showMCPStatusCommand();
847
- });
848
- program
849
- .command('mcp-install <name>')
850
- .alias('mcp:install')
851
- .description('Install an MCP server from the registry')
852
- .action(async (name) => {
853
- const { installMCPCommand } = await import('./commands/mcp-install.js');
854
- await installMCPCommand(name);
855
- });
856
- program
857
- .command('mcp-remove <name>')
858
- .alias('mcp:remove')
859
- .description('Remove an installed MCP server')
860
- .action(async (name) => {
861
- const { removeMCPCommand } = await import('./commands/mcp-install.js');
862
- removeMCPCommand(name);
863
- });
864
702
  // MCP server subprocess launchers (used by Grok plugin .mcp.json via npx)
865
703
  program
866
704
  .command('mcp')
@@ -905,51 +743,6 @@ registerOpenClawCommands(openclawCmd);
905
743
  const opencodeCmd = program.command('opencode').description('OpenCode integration commands');
906
744
  const { registerOpencodeCommands } = await import('./commands/opencode-install.js');
907
745
  registerOpencodeCommands(opencodeCmd);
908
- // Analytics enable command
909
- // Plugin subcommands
910
- const pluginCmd = program.command('plugin').description('Manage plugins');
911
- pluginCmd
912
- .command('list')
913
- .description('List installed plugins')
914
- .action(async () => {
915
- const { pluginListCommand } = await import('./commands/plugin-commands.js');
916
- await pluginListCommand();
917
- });
918
- pluginCmd
919
- .command('install <name>')
920
- .description('Install a plugin')
921
- .action(async (name) => {
922
- const { pluginInstallCommand } = await import('./commands/plugin-commands.js');
923
- await pluginInstallCommand(name);
924
- });
925
- pluginCmd
926
- .command('enable <name>')
927
- .description('Enable a plugin')
928
- .action(async (name) => {
929
- const { pluginEnableCommand } = await import('./commands/plugin-commands.js');
930
- await pluginEnableCommand(name);
931
- });
932
- pluginCmd
933
- .command('disable <name>')
934
- .description('Disable a plugin')
935
- .action(async (name) => {
936
- const { pluginDisableCommand } = await import('./commands/plugin-commands.js');
937
- await pluginDisableCommand(name);
938
- });
939
- pluginCmd
940
- .command('status <name>')
941
- .description('Show plugin details')
942
- .action(async (name) => {
943
- const { pluginStatusCommand } = await import('./commands/plugin-commands.js');
944
- await pluginStatusCommand(name);
945
- });
946
- pluginCmd
947
- .command('uninstall <name>')
948
- .description('Uninstall a plugin')
949
- .action(async (name) => {
950
- const { pluginUninstallCommand } = await import('./commands/plugin-commands.js');
951
- await pluginUninstallCommand(name);
952
- });
953
746
  // Security audit command
954
747
  program
955
748
  .command("security-audit")
@@ -958,6 +751,30 @@ program
958
751
  const { securityAuditCommand } = await import("./commands/security-audit.js");
959
752
  await securityAuditCommand();
960
753
  });
754
+ // v3 nucleus: primary governance command
755
+ program
756
+ .command("govern")
757
+ .description("Run the xray governance kernel")
758
+ .option("--status", "Show framework status")
759
+ .option("--audit", "Run security audit")
760
+ .option("--mcp <server>", "Run an MCP server subprocess (governance, skills)")
761
+ .option("--plugin-install <name>", "Install a plugin")
762
+ .option("--proposals <json>", "Run governance on JSON proposals")
763
+ .option("--skill-install [source]", "Install skills from registry")
764
+ .option("--skill-registry [action]", "Manage skill registry sources")
765
+ .option("--storyteller <type>", "Write a story (reflection|saga|journey|narrative)")
766
+ .option("--mcp-list", "List available MCP servers")
767
+ .option("--mcp-status", "Show installed MCP servers")
768
+ .option("--mcp-install <name>", "Install an MCP server")
769
+ .option("--mcp-remove <name>", "Remove an MCP server")
770
+ .option("--publish-agent", "Publish an agent to AgentStore")
771
+ .option("--archive-logs", "Archive log files")
772
+ .option("--credible-init [name]", "Initialize Credible Pod")
773
+ .option("--antigravity-status", "Show installed skills status")
774
+ .action(async (options) => {
775
+ const { governCommand } = await import("./commands/govern.js");
776
+ await governCommand(options);
777
+ });
961
778
  // Add help text
962
779
  program.addHelpText("after", `
963
780
 
@@ -971,14 +788,11 @@ Examples:
971
788
  $ npx 0xray report # Generate activity and health reports
972
789
  $ npx 0xray fix # Automatically restore missing config files
973
790
  $ npx 0xray doctor # Diagnose issues (does not fix them)
974
- $ npx 0xray analytics # Pattern analytics and insights
975
791
  $ npx 0xray inference:improve # Run autonomous inference improvement
976
- $ npx 0xray skill:install agency-agents # Install 170+ agency agent skills
977
- $ npx 0xray skill:install superpowers # Install 14 agentic workflow skills
978
- $ npx 0xray skill:install <github-url> # Install from any repo
979
792
  $ npx 0xray security-audit --deep # Run deep security audit
980
- $ npx 0xray storyteller saga "v1.18.0 Journey" # Write a saga
981
- $ npx 0xray storyteller reflection "API Fix" # Write a reflection
793
+ $ npx 0xray govern # Run the governance kernel
794
+ $ npx 0xray govern --status # Show status (v3 nucleus)
795
+ $ npx 0xray govern --proposals '[{"type":"fix","title":"Test","description":"A test"}]'
982
796
 
983
797
  Quick Start:
984
798
  1. Install: npx 0xray install
@@ -986,8 +800,7 @@ Quick Start:
986
800
  3. Use agents: @security-auditor scan
987
801
  4. Generate reports: npx 0xray report
988
802
  5. Fix issues: npx 0xray fix
989
- 6. View analytics: npx 0xray analytics
990
- 7. Add skills: npx 0xray skill:install agency-agents
803
+ 6. Add skills: npx 0xray skill:install agency-agents
991
804
 
992
805
  For more information, visit: https://github.com/0xRayAI/xray
993
806
  `);
@@ -717,9 +717,9 @@ export class BootOrchestrator {
717
717
  try {
718
718
  // Consumer runtime compat (XRAY_ env + .xray fallbacks)
719
719
  const xrayConfig = {
720
- version: "2.1.3",
720
+ version: "2.2.0",
721
721
  codex_enabled: true,
722
- codex_version: "v2.1.1",
722
+ codex_version: "v3.0.0",
723
723
  codex_terms: [
724
724
  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
725
725
  21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
@@ -286,7 +286,7 @@ export class FeaturesConfigLoader {
286
286
  */
287
287
  getDefaultConfig() {
288
288
  return {
289
- version: "2.1.3",
289
+ version: "2.2.0",
290
290
  description: "0xRay Framework - Unified Feature Configuration",
291
291
  token_optimization: {
292
292
  enabled: true,
@@ -72,5 +72,6 @@ export declare class FrameworkUsageLogger {
72
72
  getRecentLogs(count?: number): FrameworkLogEntry[];
73
73
  getComponentUsage(component: string): FrameworkLogEntry[];
74
74
  printRundown(): void;
75
+ flushSync(): void;
75
76
  }
76
77
  export declare const frameworkLogger: FrameworkUsageLogger;
@@ -1,5 +1,4 @@
1
- import { isLoggingEnabled, shouldLog, } from "./logging-config.js";
2
- import { promises as fs, existsSync, mkdirSync } from "fs";
1
+ import { promises as fs, existsSync, mkdirSync, appendFileSync } from "fs";
3
2
  import { join } from "path";
4
3
  /**
5
4
  * Generate a unique job ID for tracking work sessions
@@ -94,6 +93,36 @@ export function withJobContext(operation, jobId) {
94
93
  throw error;
95
94
  }
96
95
  }
96
+ const defaultLoggingConfig = {
97
+ enabled: (process.env.XRAY_LOGGING_ENABLED) !== "false",
98
+ level: (process.env.XRAY_LOG_LEVEL) || "info",
99
+ destinations: ["console", "file"],
100
+ performanceMode: (process.env.XRAY_PERFORMANCE_MODE) === "true",
101
+ };
102
+ const LOG_LEVELS = ["debug", "info", "warn", "error"];
103
+ let globalLoggingConfig = { ...defaultLoggingConfig };
104
+ function isLoggingEnabled() {
105
+ return globalLoggingConfig.enabled;
106
+ }
107
+ function shouldLog(level) {
108
+ if (!globalLoggingConfig.enabled)
109
+ return false;
110
+ const currentLevelIndex = LOG_LEVELS.indexOf(globalLoggingConfig.level);
111
+ const messageLevelIndex = LOG_LEVELS.indexOf(level);
112
+ if (currentLevelIndex === -1 || messageLevelIndex === -1)
113
+ return true;
114
+ return messageLevelIndex >= currentLevelIndex;
115
+ }
116
+ // Module-level side effects for env var config (previously in logging-config.ts)
117
+ if (process.env.XRAY_LOGGING_ENABLED === "false") {
118
+ globalLoggingConfig.enabled = false;
119
+ }
120
+ if (process.env.XRAY_LOG_LEVEL) {
121
+ globalLoggingConfig.level = process.env.XRAY_LOG_LEVEL;
122
+ }
123
+ if (process.env.XRAY_PERFORMANCE_MODE === "true") {
124
+ globalLoggingConfig.performanceMode = true;
125
+ }
97
126
  export class JobContext {
98
127
  jobId;
99
128
  startTime;
@@ -275,8 +304,34 @@ export class FrameworkUsageLogger {
275
304
  printRundown() {
276
305
  // Framework usage analytics placeholder
277
306
  }
307
+ flushSync() {
308
+ if (this.flushing || this.buffer.length === 0)
309
+ return;
310
+ const toWrite = this.buffer.splice(0, this.buffer.length);
311
+ const data = toWrite.join("");
312
+ try {
313
+ const cwd = process.cwd();
314
+ if (!cwd)
315
+ return;
316
+ const logDir = join(cwd, "logs", "framework");
317
+ const logFile = join(logDir, "activity.log");
318
+ if (!existsSync(logDir)) {
319
+ mkdirSync(logDir, { recursive: true });
320
+ }
321
+ appendFileSync(logFile, data);
322
+ }
323
+ catch {
324
+ // flush failure is non-fatal
325
+ }
326
+ }
278
327
  }
279
328
  export const frameworkLogger = new FrameworkUsageLogger();
329
+ // Flush buffer synchronously on exit so CLI commands don't lose log entries
330
+ if (typeof process !== "undefined" && process.env?.NODE_ENV !== "test") {
331
+ process.on("exit", () => {
332
+ frameworkLogger.flushSync();
333
+ });
334
+ }
280
335
  // Startup self-test: verify logger works
281
336
  if (typeof process !== "undefined" && process.env?.NODE_ENV !== "test") {
282
337
  frameworkLogger.log("system", "logger initialized", "info").catch(() => { });
@@ -13,10 +13,9 @@ export { SessionCoordinator, createSessionCoordinator, } from "./session-coordin
13
13
  export { RoutingOutcomeTracker, routingOutcomeTracker, } from "./analytics/index.js";
14
14
  export { RoutingAnalytics } from "./analytics/index.js";
15
15
  export { LearningEngine, learningEngine } from "./analytics/index.js";
16
- export { VotingCoordinator, createVotingCoordinator, } from "./voting-coordinator.js";
17
16
  export { WeightedVotingAggregator, createWeightedVotingAggregator, createDetailedVotingResult, DEFAULT_HISTORICAL_CONFIG, DEFAULT_CONFIDENCE_CONFIG, } from "./weighted-voting-aggregator.js";
18
17
  export { AdaptiveStrategySelector, adaptiveStrategySelector, selectVotingStrategy, } from "./strategy-selector.js";
19
- export { getAgentExpertise, getAgentExpertiseLevel, getVotingWeight, getAgentsWithExpertiseDomain, getTopExpertsForDomain, } from "./agent-expertise.js";
18
+ export { getAgentExpertise, getAgentExpertiseLevel, getVotingWeight, } from "./agent-expertise.js";
20
19
  export type { VotingSession, VotingStrategy, VoteChoice, VotingResult, VotingResultDetail, AgentExpertise, StrategySelectionContext, VotingHistoryEntry, AdaptiveStrategyConfig, VotingMetrics, ConflictResolutionRequest, ConflictResolutionResponse, } from "./voting-types.js";
21
20
  export type { ComplexityMetrics, ComplexityScore, ComplexityThresholds, } from "./complexity-analyzer.js";
22
21
  export type { DelegationRequest, DelegationResult, AgentCapability, DelegationMetrics, } from "./agent-delegator.js";
@@ -13,8 +13,7 @@ export { SessionCoordinator, createSessionCoordinator, } from "./session-coordin
13
13
  export { RoutingOutcomeTracker, routingOutcomeTracker, } from "./analytics/index.js";
14
14
  export { RoutingAnalytics } from "./analytics/index.js";
15
15
  export { LearningEngine, learningEngine } from "./analytics/index.js";
16
- export { VotingCoordinator, createVotingCoordinator, } from "./voting-coordinator.js";
17
16
  export { WeightedVotingAggregator, createWeightedVotingAggregator, createDetailedVotingResult, DEFAULT_HISTORICAL_CONFIG, DEFAULT_CONFIDENCE_CONFIG, } from "./weighted-voting-aggregator.js";
18
17
  export { AdaptiveStrategySelector, adaptiveStrategySelector, selectVotingStrategy, } from "./strategy-selector.js";
19
- export { getAgentExpertise, getAgentExpertiseLevel, getVotingWeight, getAgentsWithExpertiseDomain, getTopExpertsForDomain, } from "./agent-expertise.js";
18
+ export { getAgentExpertise, getAgentExpertiseLevel, getVotingWeight, } from "./agent-expertise.js";
20
19
  export { AgentMetricsSystem, getAgentMetricsSystem, initializeAgentMetrics, resetAgentMetricsSystem, } from "../metrics/agent-metrics.js";
@@ -20,7 +20,7 @@ const ROUTING_MAPPINGS = [
20
20
  // Core built-in skills (high confidence)
21
21
  { keywords: ["write", "file", "create"], skill: "code-review", agent: "code-reviewer", confidence: 0.9 },
22
22
  { keywords: ["review", "audit", "assess", "evaluate", "check", "inspect", "quality", "validate", "code-review"], skill: "code-review", agent: "code-reviewer", confidence: 0.9 },
23
- { keywords: ["test", "testing", "jest", "coverage", "unit", "e2e", "cypress", "spec", "verify"], skill: "testing-best-practices", agent: "testing-lead", confidence: 0.95 },
23
+ { keywords: ["test", "testing", "jest", "coverage", "unit", "e2e", "cypress", "spec", "verify"], skill: "testing-strategy", agent: "testing-lead", confidence: 0.95 },
24
24
  { keywords: ["fix", "debug", "triage", "broken", "error", "crash", "bug", "issue", "resolve"], skill: "bug-triage", agent: "bug-triage-specialist", confidence: 0.92 },
25
25
  { keywords: ["security", "vulnerability", "threat", "scan", "risk", "exploit", "secure", "pentest"], skill: "security-audit", agent: "security-auditor", confidence: 0.95 },
26
26
  { keywords: ["refactor", "cleanup", "improve", "restructure", "modernize", "debt"], skill: "refactoring-strategies", agent: "refactorer", confidence: 0.92 },
@@ -6,19 +6,11 @@ export interface ApplyResult {
6
6
  details?: string[];
7
7
  error?: string;
8
8
  }
9
- export type CodeChangeCallback = (proposal: InferenceProposal) => Promise<boolean>;
10
- export type ReviewCallback = (proposal: InferenceProposal, prUrl: string) => Promise<"go" | "no-go" | "modify">;
11
9
  export declare class ProposalApplier {
12
10
  private projectRoot;
13
- private codeChangeCallback?;
14
- private reviewCallback?;
15
- constructor(projectRoot?: string, codeChangeCallback?: CodeChangeCallback | undefined, reviewCallback?: ReviewCallback | undefined);
11
+ constructor(projectRoot?: string);
16
12
  applyProposals(proposals: InferenceProposal[]): Promise<ApplyResult[]>;
17
- private applyProposal;
18
13
  private applyCodification;
19
- private isInsideGitRepo;
20
14
  private getAppliedMarkerPath;
21
15
  private recordAppliedProposal;
22
- private createPR;
23
16
  }
24
- export declare const proposalApplier: ProposalApplier;