0xray 2.1.4 → 2.2.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 (159) hide show
  1. package/dist/CHANGELOG.md +31 -0
  2. package/dist/cli/commands/govern.d.ts +29 -0
  3. package/dist/cli/commands/govern.js +152 -0
  4. package/dist/cli/index.js +29 -216
  5. package/dist/core/framework-logger.js +30 -1
  6. package/dist/delegation/index.d.ts +1 -2
  7. package/dist/delegation/index.js +1 -2
  8. package/dist/enforcement/enforcer-tools.js +1 -1
  9. package/dist/execution/proposal-applier.d.ts +1 -9
  10. package/dist/execution/proposal-applier.js +18 -173
  11. package/dist/governance/codex-policy.service.d.ts +7 -25
  12. package/dist/governance/codex-policy.service.js +8 -26
  13. package/dist/governance/governance-core.d.ts +22 -28
  14. package/dist/governance/governance-core.js +31 -101
  15. package/dist/governance/governance-service.d.ts +1 -0
  16. package/dist/governance/governance-service.js +67 -4
  17. package/dist/governance/governance-types.d.ts +5 -2
  18. package/dist/inference/index.d.ts +3 -4
  19. package/dist/inference/inference-accumulator.js +1 -1
  20. package/dist/inference/inference-cycle.d.ts +12 -18
  21. package/dist/inference/inference-cycle.js +120 -335
  22. package/dist/integrations/base/index.d.ts +0 -1
  23. package/dist/integrations/base/index.js +0 -2
  24. package/dist/integrations/grok/hooks/pre-tool-use.js +4 -18
  25. package/dist/integrations/hermes-agent/bridge.mjs +9 -0
  26. package/dist/mcps/config/server-config-registry.js +1 -1
  27. package/dist/mcps/governance.server.js +3 -4
  28. package/dist/mcps/knowledge-skills/api-design.server.js +10 -0
  29. package/dist/mcps/knowledge-skills/architecture-patterns.server.js +10 -0
  30. package/dist/mcps/knowledge-skills/bug-triage-specialist.server.js +10 -0
  31. package/dist/mcps/knowledge-skills/code-analyzer.server.js +10 -0
  32. package/dist/mcps/knowledge-skills/code-review.server.js +10 -0
  33. package/dist/mcps/knowledge-skills/content-creator.server.js +10 -0
  34. package/dist/mcps/knowledge-skills/database-design.server.js +10 -0
  35. package/dist/mcps/knowledge-skills/devops-deployment.server.js +10 -0
  36. package/dist/mcps/knowledge-skills/git-workflow.server.js +10 -0
  37. package/dist/mcps/knowledge-skills/growth-strategist.server.js +10 -0
  38. package/dist/mcps/knowledge-skills/log-monitor.server.js +10 -0
  39. package/dist/mcps/knowledge-skills/mobile-development.server.js +10 -0
  40. package/dist/mcps/knowledge-skills/multimodal-looker.server.js +10 -0
  41. package/dist/mcps/knowledge-skills/performance-optimization.server.js +10 -0
  42. package/dist/mcps/knowledge-skills/project-analysis.server.js +10 -0
  43. package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +10 -0
  44. package/dist/mcps/knowledge-skills/security-audit.server.js +10 -0
  45. package/dist/mcps/knowledge-skills/seo-consultant.server.js +10 -0
  46. package/dist/mcps/knowledge-skills/skill-invocation.server.d.ts +4 -0
  47. package/dist/mcps/knowledge-skills/skill-invocation.server.js +33 -14
  48. package/dist/mcps/knowledge-skills/strategist.server.js +10 -0
  49. package/dist/mcps/knowledge-skills/tech-writer.server.js +10 -0
  50. package/dist/mcps/knowledge-skills/testing-strategy.server.js +10 -0
  51. package/dist/mcps/knowledge-skills/ui-ux-design.server.js +10 -0
  52. package/dist/metrics/agent-metrics.d.ts +2 -1
  53. package/dist/nucleus/govern-http.d.ts +59 -0
  54. package/dist/nucleus/govern-http.js +172 -0
  55. package/dist/nucleus/index.d.ts +14 -0
  56. package/dist/nucleus/index.js +9 -0
  57. package/dist/nucleus/kernel.d.ts +51 -0
  58. package/dist/nucleus/kernel.js +62 -0
  59. package/dist/nucleus/plugin-registry.d.ts +104 -0
  60. package/dist/nucleus/plugin-registry.js +147 -0
  61. package/dist/orchestrator/orchestrator.d.ts +0 -1
  62. package/dist/orchestrator/orchestrator.js +0 -21
  63. package/dist/postprocessor/PostProcessor.d.ts +13 -1
  64. package/dist/postprocessor/PostProcessor.js +41 -1
  65. package/dist/postprocessor/autofix/AutoFixEngine.d.ts +0 -8
  66. package/dist/postprocessor/autofix/AutoFixEngine.js +0 -54
  67. package/dist/postprocessor/metamorphosis/MetamorphosisEngine.d.ts +25 -0
  68. package/dist/postprocessor/metamorphosis/MetamorphosisEngine.js +10 -0
  69. package/dist/postprocessor/metamorphosis/SelfProposalEngine.d.ts +68 -0
  70. package/dist/postprocessor/metamorphosis/SelfProposalEngine.js +371 -0
  71. package/dist/skills/orchestrator/SKILL.md +1 -1
  72. package/dist/state/index.d.ts +0 -2
  73. package/package.json +4 -3
  74. package/scripts/node/universal-version-manager.js +2 -2
  75. package/src/mcps/config/__tests__/server-config-registry.test.ts +6 -15
  76. package/src/mcps/config/server-config-registry.ts +1 -1
  77. package/src/mcps/governance.server.ts +3 -5
  78. package/src/mcps/knowledge-skills/api-design.server.ts +9 -0
  79. package/src/mcps/knowledge-skills/architecture-patterns.server.ts +9 -0
  80. package/src/mcps/knowledge-skills/bug-triage-specialist.server.ts +9 -0
  81. package/src/mcps/knowledge-skills/code-analyzer.server.ts +9 -0
  82. package/src/mcps/knowledge-skills/code-review.server.ts +9 -0
  83. package/src/mcps/knowledge-skills/content-creator.server.ts +9 -0
  84. package/src/mcps/knowledge-skills/database-design.server.ts +9 -0
  85. package/src/mcps/knowledge-skills/devops-deployment.server.ts +9 -0
  86. package/src/mcps/knowledge-skills/git-workflow.server.ts +9 -0
  87. package/src/mcps/knowledge-skills/growth-strategist.server.ts +9 -0
  88. package/src/mcps/knowledge-skills/log-monitor.server.ts +9 -0
  89. package/src/mcps/knowledge-skills/mobile-development.server.ts +9 -0
  90. package/src/mcps/knowledge-skills/multimodal-looker.server.ts +9 -0
  91. package/src/mcps/knowledge-skills/performance-optimization.server.ts +9 -0
  92. package/src/mcps/knowledge-skills/project-analysis.server.ts +9 -0
  93. package/src/mcps/knowledge-skills/refactoring-strategies.server.ts +9 -0
  94. package/src/mcps/knowledge-skills/security-audit.server.ts +9 -0
  95. package/src/mcps/knowledge-skills/seo-consultant.server.ts +9 -0
  96. package/src/mcps/knowledge-skills/session-management.server.ts +1 -0
  97. package/src/mcps/knowledge-skills/skill-invocation.server.ts +44 -29
  98. package/src/mcps/knowledge-skills/strategist.server.ts +9 -0
  99. package/src/mcps/knowledge-skills/tech-writer.server.ts +9 -0
  100. package/src/mcps/knowledge-skills/testing-strategy.server.ts +9 -0
  101. package/src/mcps/knowledge-skills/ui-ux-design.server.ts +9 -0
  102. package/src/skills/orchestrator/SKILL.md +1 -1
  103. package/.opencode/agents/testing-best-practices.yml +0 -12
  104. package/dist/analytics/consent-manager.d.ts +0 -93
  105. package/dist/analytics/consent-manager.js +0 -258
  106. package/dist/analytics/simple-pattern-analyzer.d.ts +0 -80
  107. package/dist/analytics/simple-pattern-analyzer.js +0 -297
  108. package/dist/cli/commands/analytics-disable.d.ts +0 -9
  109. package/dist/cli/commands/analytics-disable.js +0 -72
  110. package/dist/cli/commands/analytics-enable-action.d.ts +0 -8
  111. package/dist/cli/commands/analytics-enable-action.js +0 -82
  112. package/dist/cli/commands/analytics-preview.d.ts +0 -9
  113. package/dist/cli/commands/analytics-preview.js +0 -106
  114. package/dist/cli/commands/analytics-status.d.ts +0 -9
  115. package/dist/cli/commands/analytics-status.js +0 -68
  116. package/dist/cli/server.d.ts +0 -1
  117. package/dist/cli/server.js +0 -147
  118. package/dist/core/errors.d.ts +0 -3
  119. package/dist/core/errors.js +0 -10
  120. package/dist/core/logging-config.d.ts +0 -11
  121. package/dist/core/logging-config.js +0 -43
  122. package/dist/core/trace-context.d.ts +0 -12
  123. package/dist/core/trace-context.js +0 -33
  124. package/dist/delegation/voting-coordinator.d.ts +0 -49
  125. package/dist/delegation/voting-coordinator.js +0 -375
  126. package/dist/enforcement/test-auto-healing.d.ts +0 -83
  127. package/dist/enforcement/test-auto-healing.js +0 -325
  128. package/dist/integrations/base/ExampleIntegration.d.ts +0 -47
  129. package/dist/integrations/base/ExampleIntegration.js +0 -181
  130. package/dist/mcps/knowledge-skills/testing-best-practices.server.d.ts +0 -34
  131. package/dist/mcps/knowledge-skills/testing-best-practices.server.js +0 -831
  132. package/dist/mcps/orchestrator.server.d.ts +0 -10
  133. package/dist/mcps/orchestrator.server.js +0 -19
  134. package/dist/orchestrator/self-direction-activation.d.ts +0 -109
  135. package/dist/orchestrator/self-direction-activation.js +0 -245
  136. package/dist/orchestrator/universal-librarian-consultation.d.ts +0 -98
  137. package/dist/orchestrator/universal-librarian-consultation.js +0 -216
  138. package/dist/orchestrator/universal-registry-bridge.d.ts +0 -85
  139. package/dist/orchestrator/universal-registry-bridge.js +0 -247
  140. package/dist/performance/performance-budget-enforcer.d.ts +0 -158
  141. package/dist/performance/performance-budget-enforcer.js +0 -434
  142. package/dist/performance/performance-regression-tester.d.ts +0 -108
  143. package/dist/performance/performance-regression-tester.js +0 -342
  144. package/dist/skills/testing-best-practices/SKILL.md +0 -37
  145. package/dist/state/context-providers.d.ts +0 -4
  146. package/dist/state/context-providers.js +0 -1
  147. package/dist/state/state-types.d.ts +0 -5
  148. package/dist/state/state-types.js +0 -1
  149. package/dist/utils/batch-operations.d.ts +0 -25
  150. package/dist/utils/batch-operations.js +0 -292
  151. package/dist/utils/test-template-generator.d.ts +0 -25
  152. package/dist/utils/test-template-generator.js +0 -178
  153. package/dist/utils/token-manager.d.ts +0 -48
  154. package/dist/utils/token-manager.js +0 -163
  155. package/src/mcps/knowledge-skills/testing-best-practices.server.test.ts +0 -136
  156. package/src/mcps/knowledge-skills/testing-best-practices.server.ts +0 -1183
  157. package/src/mcps/orchestrator.server.ts +0 -34
  158. package/src/opencode/agents/testing-best-practices.yml +0 -12
  159. package/src/skills/testing-best-practices/SKILL.md +0 -37
package/dist/CHANGELOG.md CHANGED
@@ -4,6 +4,37 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Conventional Commits](https://www.conventionalcommits.org/).
6
6
 
7
+ ## [2.2.0] - 2026-06-10
8
+
9
+ ### 🚀 Features
10
+ - feat: add Codex terms 69-72 covering self-evolution constraints (proposal governance, metamorphosis threshold, safety controls, traceability) (codex.json)
11
+ - feat: long-running governed agent session verification E2E (11 tests, self-evolution-e2e.test.ts)
12
+ - feat: Plugin API documentation — SkillPlugin, MetamorphosisEngine, SelfProposalEngine interfaces (docs/api/plugin-api.md)
13
+ - feat: SelfProposalEngine with unit + E2E tests (postprocessor/metamorphosis/SelfProposalEngine.ts)
14
+ - feat: nucleus kernel facade — handleGovernRequest, governViaNucleus, pluginRegistry (src/nucleus/)
15
+ - feat: CLI govern command — status, audit, proposals, MCP management, storyteller (src/cli/commands/govern.ts)
16
+ - feat: consumer verification script (scripts/verify-consumer.sh)
17
+
18
+ ### ♻️ Refactoring
19
+ - refactor: 12-review subtract pass across all subsystems — ~16k LOC removed (Core, Nucleus, Governance, MCP, Inference, Orchestration, Delegation, Processors, Postprocessor, Enforcement, Integrations, CLI, Supporting)
20
+ - refactor: delete trace-context.ts, errors.ts, logging-config.ts (inlined into framework-logger)
21
+ - refactor: delete applyDecisionMatrix dead PHI/TAU matrix from governance-core
22
+ - refactor: delete testing-best-practices.server.ts (1,183 LOC unregistered MCP bloat), orchestrator.server.ts shim
23
+ - refactor: delete 4 dead orchestrator/delegation files (universal-registry-bridge, universal-librarian-consultation, self-direction-activation, task-skill-router.d.ts)
24
+ - refactor: delete RetryHandler.ts, ComprehensiveValidator.ts from postprocessor
25
+ - refactor: delete test-auto-healing.ts, cross-language-bridge.ts
26
+ - refactor: delete 5 CLI dead files (4 analytics commands, server.ts)
27
+ - refactor: delete 19 dead source + 6 stale test files across analytics, infrastructure, performance, reporting, utils, validation, state
28
+ - refactor: delete dead expertise barrel exports (getAgentsWithExpertiseDomain, getTopExpertsForDomain)
29
+ - refactor: update Codex references from 68 to 72 terms across docs
30
+ - refactor: clean dead test script references in package.json
31
+
32
+ ### 🐛 Bug Fixes
33
+ - fix: repair syntax from STRRAY_ cleanup (setup.ts, hermes bridge) so tests and release guard pass (87f3613ad)
34
+ - fix: E2E test references to applyDecisionMatrix updated to mergeVotes
35
+
36
+ ---
37
+
7
38
  ## [2.1.4] - 2026-06-09
8
39
 
9
40
  ### 🔄 Changes
@@ -0,0 +1,29 @@
1
+ /**
2
+ * xray govern — the primary CLI command for the v3 nucleus
3
+ *
4
+ * Usage:
5
+ * xray govern [options]
6
+ *
7
+ * All existing direct commands still work (backward compat with deprecation notice).
8
+ */
9
+ interface GovernOptions {
10
+ status?: boolean;
11
+ audit?: boolean;
12
+ mcp?: string;
13
+ pluginInstall?: string;
14
+ proposals?: string;
15
+ skillInstall?: string;
16
+ skillRegistry?: string;
17
+ storyteller?: string;
18
+ mcpList?: boolean;
19
+ mcpStatus?: boolean;
20
+ mcpInstall?: string;
21
+ mcpRemove?: string;
22
+ publishAgent?: boolean;
23
+ archiveLogs?: boolean;
24
+ credibleInit?: string;
25
+ antigravityStatus?: boolean;
26
+ [key: string]: unknown;
27
+ }
28
+ export declare function governCommand(options: GovernOptions): Promise<void>;
29
+ export {};
@@ -0,0 +1,152 @@
1
+ /**
2
+ * xray govern — the primary CLI command for the v3 nucleus
3
+ *
4
+ * Usage:
5
+ * xray govern [options]
6
+ *
7
+ * All existing direct commands still work (backward compat with deprecation notice).
8
+ */
9
+ import { resolve, join } from 'path';
10
+ import { readFileSync, existsSync } from 'fs';
11
+ import { spawn } from 'child_process';
12
+ export async function governCommand(options) {
13
+ if (options.status) {
14
+ const { statusCommand } = await import('./status.js');
15
+ await statusCommand();
16
+ return;
17
+ }
18
+ if (options.audit) {
19
+ const { securityAuditCommand } = await import('./security-audit.js');
20
+ await securityAuditCommand();
21
+ return;
22
+ }
23
+ if (options.mcp) {
24
+ const serverMap = {
25
+ governance: 'dist/mcps/governance.server.js',
26
+ skills: 'dist/mcps/knowledge-skills/skill-invocation.server.js',
27
+ };
28
+ const relPath = serverMap[options.mcp];
29
+ if (!relPath) {
30
+ console.error(`Unknown MCP server: ${options.mcp}. Use: governance, skills`);
31
+ process.exit(1);
32
+ }
33
+ const packageJsonPath = resolve(import.meta.url.replace(/^file:/, ''), '..', '..', 'package.json');
34
+ const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
35
+ const packageRoot = resolve(packageJsonPath, '..', pkg.xray?.dist ? join('', pkg.xray.dist) : 'dist', '..');
36
+ const serverPath = resolve(join(packageRoot, relPath));
37
+ if (!existsSync(serverPath)) {
38
+ console.error(`MCP server not found at ${serverPath}. Is xray installed correctly?`);
39
+ process.exit(1);
40
+ }
41
+ const env = { ...process.env };
42
+ if (options.mcp === 'governance') {
43
+ env.XRAY_FORCE_MCP_GOVERNANCE = 'true';
44
+ }
45
+ const child = spawn(process.execPath, [serverPath], { stdio: 'inherit', env });
46
+ child.on('exit', (code) => process.exit(code ?? 0));
47
+ return;
48
+ }
49
+ if (options.pluginInstall) {
50
+ const { pluginInstallCommand } = await import('./plugin-commands.js');
51
+ await pluginInstallCommand(options.pluginInstall);
52
+ return;
53
+ }
54
+ if (options.proposals) {
55
+ const { handleGovernRequest } = await import('../../nucleus/index.js');
56
+ let proposals;
57
+ try {
58
+ proposals = JSON.parse(options.proposals);
59
+ }
60
+ catch {
61
+ console.error('Invalid JSON in --proposals. Expected a JSON string with a "proposals" array.');
62
+ console.error('Example: xray govern --proposals \'[{"type":"fix","title":"Test","description":"A test"}]\'');
63
+ process.exit(1);
64
+ }
65
+ const result = await handleGovernRequest(proposals);
66
+ console.log(JSON.stringify(result, null, 2));
67
+ return;
68
+ }
69
+ if (options.skillInstall !== undefined) {
70
+ const { skillInstallCommand } = await import('./skill-install.js');
71
+ await skillInstallCommand(options.skillInstall || undefined);
72
+ return;
73
+ }
74
+ if (options.skillRegistry !== undefined) {
75
+ const { skillRegistryCommand } = await import('./skill-install.js');
76
+ await skillRegistryCommand(options.skillRegistry || undefined);
77
+ return;
78
+ }
79
+ if (options.storyteller) {
80
+ const { storytellerCommand } = await import('./storyteller.js');
81
+ await storytellerCommand(options.storyteller);
82
+ return;
83
+ }
84
+ if (options.mcpList) {
85
+ const { listMCPsCommand } = await import('./mcp-install.js');
86
+ listMCPsCommand();
87
+ return;
88
+ }
89
+ if (options.mcpStatus) {
90
+ const { showMCPStatusCommand } = await import('./mcp-install.js');
91
+ showMCPStatusCommand();
92
+ return;
93
+ }
94
+ if (options.mcpInstall) {
95
+ const { installMCPCommand } = await import('./mcp-install.js');
96
+ await installMCPCommand(options.mcpInstall);
97
+ return;
98
+ }
99
+ if (options.mcpRemove) {
100
+ const { removeMCPCommand } = await import('./mcp-install.js');
101
+ removeMCPCommand(options.mcpRemove);
102
+ return;
103
+ }
104
+ if (options.publishAgent) {
105
+ const { publishAgentCommand } = await import('./publish-agent.js');
106
+ await publishAgentCommand();
107
+ return;
108
+ }
109
+ if (options.archiveLogs) {
110
+ const { archiveLogFiles } = await import('./archive-logs.js');
111
+ const result = await archiveLogFiles(undefined, `govern-${Date.now()}`);
112
+ console.log(`\nResults:`);
113
+ console.log(` Archived: ${result.archived} files`);
114
+ if (result.errors.length > 0) {
115
+ console.log(` Errors: ${result.errors.length}`);
116
+ result.errors.forEach((e) => console.log(` - ${e}`));
117
+ process.exit(1);
118
+ }
119
+ return;
120
+ }
121
+ if (options.credibleInit !== undefined) {
122
+ const { credibleInitCommand } = await import('./credible-init.js');
123
+ await credibleInitCommand();
124
+ return;
125
+ }
126
+ if (options.antigravityStatus) {
127
+ const { antigravityStatusCommand } = await import('./antigravity-status.js');
128
+ await antigravityStatusCommand();
129
+ return;
130
+ }
131
+ console.log('xray govern — the governance kernel\n');
132
+ console.log('Usage: xray govern [options]\n');
133
+ console.log('Options:');
134
+ console.log(' --status Show framework status');
135
+ console.log(' --audit Run security audit');
136
+ console.log(' --mcp <server> Run an MCP server (governance, skills)');
137
+ console.log(' --plugin-install <name> Install a plugin');
138
+ console.log(' --proposals <json> Run governance on JSON proposals');
139
+ console.log(' --skill-install [source] Install skills from registry');
140
+ console.log(' --skill-registry [action] Manage skill registry sources');
141
+ console.log(' --storyteller <type> Write a story (reflection, saga, journey, narrative)');
142
+ console.log(' --mcp-list List available MCP servers');
143
+ console.log(' --mcp-status Show installed MCP servers');
144
+ console.log(' --mcp-install <name> Install an MCP server');
145
+ console.log(' --mcp-remove <name> Remove an MCP server');
146
+ console.log(' --publish-agent Publish an agent to AgentStore');
147
+ console.log(' --archive-logs Archive log files');
148
+ console.log(' --credible-init [name] Initialize Credible Pod');
149
+ console.log(' --antigravity-status Show installed skills status');
150
+ console.log(' -h, --help Show this help\n');
151
+ console.log('All existing commands still work: xray status, xray security-audit, etc.');
152
+ }
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
  `);
@@ -1,4 +1,3 @@
1
- import { isLoggingEnabled, shouldLog, } from "./logging-config.js";
2
1
  import { promises as fs, existsSync, mkdirSync } from "fs";
3
2
  import { join } from "path";
4
3
  /**
@@ -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;
@@ -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;