0xray 2.1.3 → 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 (178) 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/README.md +3 -3
  5. package/dist/CHANGELOG.md +43 -0
  6. package/dist/README.md +3 -3
  7. package/dist/analytics/routing-refiner.js +1 -1
  8. package/dist/cli/commands/govern.d.ts +29 -0
  9. package/dist/cli/commands/govern.js +152 -0
  10. package/dist/cli/index.js +29 -216
  11. package/dist/core/boot-orchestrator.js +1 -1
  12. package/dist/core/features-config.js +1 -1
  13. package/dist/core/framework-logger.js +30 -1
  14. package/dist/delegation/index.d.ts +1 -2
  15. package/dist/delegation/index.js +1 -2
  16. package/dist/enforcement/enforcer-tools.js +1 -1
  17. package/dist/execution/proposal-applier.d.ts +1 -9
  18. package/dist/execution/proposal-applier.js +18 -173
  19. package/dist/governance/codex-policy.service.d.ts +7 -25
  20. package/dist/governance/codex-policy.service.js +8 -26
  21. package/dist/governance/governance-core.d.ts +22 -28
  22. package/dist/governance/governance-core.js +31 -101
  23. package/dist/governance/governance-service.d.ts +1 -0
  24. package/dist/governance/governance-service.js +67 -4
  25. package/dist/governance/governance-types.d.ts +5 -2
  26. package/dist/inference/index.d.ts +3 -4
  27. package/dist/inference/inference-accumulator.js +1 -1
  28. package/dist/inference/inference-cycle.d.ts +12 -18
  29. package/dist/inference/inference-cycle.js +120 -335
  30. package/dist/integrations/base/index.d.ts +0 -1
  31. package/dist/integrations/base/index.js +0 -2
  32. package/dist/integrations/grok/hooks/pre-tool-use.js +4 -18
  33. package/dist/integrations/hermes-agent/bridge.mjs +10 -1
  34. package/dist/mcps/config/server-config-registry.js +1 -1
  35. package/dist/mcps/governance.server.js +4 -5
  36. package/dist/mcps/knowledge-skills/api-design.server.js +10 -0
  37. package/dist/mcps/knowledge-skills/architecture-patterns.server.js +10 -0
  38. package/dist/mcps/knowledge-skills/bug-triage-specialist.server.js +10 -0
  39. package/dist/mcps/knowledge-skills/code-analyzer.server.js +10 -0
  40. package/dist/mcps/knowledge-skills/code-review.server.js +10 -0
  41. package/dist/mcps/knowledge-skills/content-creator.server.js +10 -0
  42. package/dist/mcps/knowledge-skills/database-design.server.js +10 -0
  43. package/dist/mcps/knowledge-skills/devops-deployment.server.js +10 -0
  44. package/dist/mcps/knowledge-skills/git-workflow.server.js +10 -0
  45. package/dist/mcps/knowledge-skills/growth-strategist.server.js +10 -0
  46. package/dist/mcps/knowledge-skills/log-monitor.server.js +10 -0
  47. package/dist/mcps/knowledge-skills/mobile-development.server.js +10 -0
  48. package/dist/mcps/knowledge-skills/multimodal-looker.server.js +10 -0
  49. package/dist/mcps/knowledge-skills/performance-optimization.server.js +10 -0
  50. package/dist/mcps/knowledge-skills/project-analysis.server.js +10 -0
  51. package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +10 -0
  52. package/dist/mcps/knowledge-skills/security-audit.server.js +10 -0
  53. package/dist/mcps/knowledge-skills/seo-consultant.server.js +10 -0
  54. package/dist/mcps/knowledge-skills/skill-invocation.server.d.ts +4 -0
  55. package/dist/mcps/knowledge-skills/skill-invocation.server.js +33 -14
  56. package/dist/mcps/knowledge-skills/strategist.server.js +10 -0
  57. package/dist/mcps/knowledge-skills/tech-writer.server.js +11 -1
  58. package/dist/mcps/knowledge-skills/testing-strategy.server.js +10 -0
  59. package/dist/mcps/knowledge-skills/ui-ux-design.server.js +10 -0
  60. package/dist/mcps/registry.json +1 -1
  61. package/dist/metrics/agent-metrics.d.ts +2 -1
  62. package/dist/nucleus/govern-http.d.ts +59 -0
  63. package/dist/nucleus/govern-http.js +172 -0
  64. package/dist/nucleus/index.d.ts +14 -0
  65. package/dist/nucleus/index.js +9 -0
  66. package/dist/nucleus/kernel.d.ts +51 -0
  67. package/dist/nucleus/kernel.js +62 -0
  68. package/dist/nucleus/plugin-registry.d.ts +104 -0
  69. package/dist/nucleus/plugin-registry.js +147 -0
  70. package/dist/orchestrator/orchestrator.d.ts +0 -1
  71. package/dist/orchestrator/orchestrator.js +0 -21
  72. package/dist/postprocessor/PostProcessor.d.ts +13 -1
  73. package/dist/postprocessor/PostProcessor.js +41 -1
  74. package/dist/postprocessor/autofix/AutoFixEngine.d.ts +0 -8
  75. package/dist/postprocessor/autofix/AutoFixEngine.js +0 -54
  76. package/dist/postprocessor/metamorphosis/MetamorphosisEngine.d.ts +25 -0
  77. package/dist/postprocessor/metamorphosis/MetamorphosisEngine.js +10 -0
  78. package/dist/postprocessor/metamorphosis/SelfProposalEngine.d.ts +68 -0
  79. package/dist/postprocessor/metamorphosis/SelfProposalEngine.js +371 -0
  80. package/dist/skills/orchestrator/SKILL.md +1 -1
  81. package/dist/skills/registry.json +1 -1
  82. package/dist/state/index.d.ts +0 -2
  83. package/package.json +4 -3
  84. package/scripts/node/universal-version-manager.js +3 -3
  85. package/src/mcps/config/__tests__/server-config-registry.test.ts +6 -15
  86. package/src/mcps/config/server-config-registry.ts +1 -1
  87. package/src/mcps/governance.server.ts +4 -6
  88. package/src/mcps/knowledge-skills/api-design.server.ts +9 -0
  89. package/src/mcps/knowledge-skills/architecture-patterns.server.ts +9 -0
  90. package/src/mcps/knowledge-skills/bug-triage-specialist.server.ts +9 -0
  91. package/src/mcps/knowledge-skills/code-analyzer.server.ts +9 -0
  92. package/src/mcps/knowledge-skills/code-review.server.ts +9 -0
  93. package/src/mcps/knowledge-skills/content-creator.server.ts +9 -0
  94. package/src/mcps/knowledge-skills/database-design.server.ts +9 -0
  95. package/src/mcps/knowledge-skills/devops-deployment.server.ts +9 -0
  96. package/src/mcps/knowledge-skills/git-workflow.server.ts +9 -0
  97. package/src/mcps/knowledge-skills/growth-strategist.server.ts +9 -0
  98. package/src/mcps/knowledge-skills/log-monitor.server.ts +9 -0
  99. package/src/mcps/knowledge-skills/mobile-development.server.ts +9 -0
  100. package/src/mcps/knowledge-skills/multimodal-looker.server.ts +9 -0
  101. package/src/mcps/knowledge-skills/performance-optimization.server.ts +9 -0
  102. package/src/mcps/knowledge-skills/project-analysis.server.ts +9 -0
  103. package/src/mcps/knowledge-skills/refactoring-strategies.server.ts +9 -0
  104. package/src/mcps/knowledge-skills/security-audit.server.ts +9 -0
  105. package/src/mcps/knowledge-skills/seo-consultant.server.ts +9 -0
  106. package/src/mcps/knowledge-skills/session-management.server.ts +1 -0
  107. package/src/mcps/knowledge-skills/skill-invocation.server.ts +44 -29
  108. package/src/mcps/knowledge-skills/strategist.server.ts +9 -0
  109. package/src/mcps/knowledge-skills/tech-writer.server.ts +10 -1
  110. package/src/mcps/knowledge-skills/testing-strategy.server.ts +9 -0
  111. package/src/mcps/knowledge-skills/ui-ux-design.server.ts +9 -0
  112. package/src/mcps/registry.json +1 -1
  113. package/src/opencode/codex.codex +1 -1
  114. package/src/opencode/commands/dependency-audit.md +3 -3
  115. package/src/opencode/enforcer-config.json +2 -2
  116. package/src/skills/orchestrator/SKILL.md +1 -1
  117. package/src/skills/registry.json +1 -1
  118. package/xray/codex.json +1 -1
  119. package/xray/config.json +1 -1
  120. package/xray/features.json +1 -1
  121. package/xray/integrations.json +3 -3
  122. package/.opencode/agents/testing-best-practices.yml +0 -12
  123. package/dist/analytics/consent-manager.d.ts +0 -93
  124. package/dist/analytics/consent-manager.js +0 -258
  125. package/dist/analytics/simple-pattern-analyzer.d.ts +0 -80
  126. package/dist/analytics/simple-pattern-analyzer.js +0 -297
  127. package/dist/cli/commands/analytics-disable.d.ts +0 -9
  128. package/dist/cli/commands/analytics-disable.js +0 -72
  129. package/dist/cli/commands/analytics-enable-action.d.ts +0 -8
  130. package/dist/cli/commands/analytics-enable-action.js +0 -82
  131. package/dist/cli/commands/analytics-preview.d.ts +0 -9
  132. package/dist/cli/commands/analytics-preview.js +0 -106
  133. package/dist/cli/commands/analytics-status.d.ts +0 -9
  134. package/dist/cli/commands/analytics-status.js +0 -68
  135. package/dist/cli/server.d.ts +0 -1
  136. package/dist/cli/server.js +0 -147
  137. package/dist/core/errors.d.ts +0 -3
  138. package/dist/core/errors.js +0 -10
  139. package/dist/core/logging-config.d.ts +0 -11
  140. package/dist/core/logging-config.js +0 -43
  141. package/dist/core/trace-context.d.ts +0 -12
  142. package/dist/core/trace-context.js +0 -33
  143. package/dist/delegation/voting-coordinator.d.ts +0 -49
  144. package/dist/delegation/voting-coordinator.js +0 -375
  145. package/dist/enforcement/test-auto-healing.d.ts +0 -83
  146. package/dist/enforcement/test-auto-healing.js +0 -325
  147. package/dist/integrations/base/ExampleIntegration.d.ts +0 -47
  148. package/dist/integrations/base/ExampleIntegration.js +0 -181
  149. package/dist/mcps/knowledge-skills/testing-best-practices.server.d.ts +0 -34
  150. package/dist/mcps/knowledge-skills/testing-best-practices.server.js +0 -831
  151. package/dist/mcps/orchestrator.server.d.ts +0 -10
  152. package/dist/mcps/orchestrator.server.js +0 -19
  153. package/dist/orchestrator/self-direction-activation.d.ts +0 -109
  154. package/dist/orchestrator/self-direction-activation.js +0 -245
  155. package/dist/orchestrator/universal-librarian-consultation.d.ts +0 -98
  156. package/dist/orchestrator/universal-librarian-consultation.js +0 -216
  157. package/dist/orchestrator/universal-registry-bridge.d.ts +0 -85
  158. package/dist/orchestrator/universal-registry-bridge.js +0 -247
  159. package/dist/performance/performance-budget-enforcer.d.ts +0 -158
  160. package/dist/performance/performance-budget-enforcer.js +0 -434
  161. package/dist/performance/performance-regression-tester.d.ts +0 -108
  162. package/dist/performance/performance-regression-tester.js +0 -342
  163. package/dist/skills/testing-best-practices/SKILL.md +0 -37
  164. package/dist/state/context-providers.d.ts +0 -4
  165. package/dist/state/context-providers.js +0 -1
  166. package/dist/state/state-types.d.ts +0 -5
  167. package/dist/state/state-types.js +0 -1
  168. package/dist/utils/batch-operations.d.ts +0 -25
  169. package/dist/utils/batch-operations.js +0 -292
  170. package/dist/utils/test-template-generator.d.ts +0 -25
  171. package/dist/utils/test-template-generator.js +0 -178
  172. package/dist/utils/token-manager.d.ts +0 -48
  173. package/dist/utils/token-manager.js +0 -163
  174. package/src/mcps/knowledge-skills/testing-best-practices.server.test.ts +0 -136
  175. package/src/mcps/knowledge-skills/testing-best-practices.server.ts +0 -1183
  176. package/src/mcps/orchestrator.server.ts +0 -34
  177. package/src/opencode/agents/testing-best-practices.yml +0 -12
  178. package/src/skills/testing-best-practices/SKILL.md +0 -37
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "framework": "xray 2.0",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Codex-compliant framework configuration for Credible UI project",
5
5
  "thresholds": {
6
6
  "bundleSize": {
@@ -220,7 +220,7 @@
220
220
  }
221
221
  },
222
222
  "codex": {
223
- "version": "2.1.1",
223
+ "version": "2.1.3",
224
224
  "terms": [
225
225
  1,
226
226
  2,
@@ -15,7 +15,7 @@ dependencies: []
15
15
  mcp:
16
16
  orchestrator:
17
17
  command: node
18
- args: [node_modules/0xray/dist/mcps/orchestrator.server.js]
18
+ args: [node_modules/0xray/dist/mcps/orchestrator/server.js]
19
19
  ---
20
20
 
21
21
  # Orchestrator Skill
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.1.1",
2
+ "version": "2.1.3",
3
3
  "description": "0xRay Skills Registry - recommended skill sources for consumers",
4
4
  "sources": [
5
5
  {
package/xray/codex.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.1.1",
2
+ "version": "2.1.3",
3
3
  "lastUpdated": "2026-06-05",
4
4
  "errorPreventionTarget": 0.998,
5
5
  "terms": {
package/xray/config.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "./config.schema.json",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "0xRay Framework - Token Management & Performance Configuration",
5
5
  "token_management": {
6
6
  "maxPromptTokens": 20000,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "./features.schema.json",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "0xRay Framework - Unified Feature Configuration",
5
5
  "token_optimization": {
6
6
  "enabled": true,
@@ -4,19 +4,19 @@
4
4
  "openclaw": {
5
5
  "enabled": false,
6
6
  "type": "external-service",
7
- "version": "2.1.1",
7
+ "version": "2.1.3",
8
8
  "config": {}
9
9
  },
10
10
  "python-bridge": {
11
11
  "enabled": false,
12
12
  "type": "protocol-bridge",
13
- "version": "2.1.1",
13
+ "version": "2.1.3",
14
14
  "config": {}
15
15
  },
16
16
  "react": {
17
17
  "enabled": false,
18
18
  "type": "framework-adapter",
19
- "version": "2.1.1",
19
+ "version": "2.1.3",
20
20
  "config": {}
21
21
  }
22
22
  }
@@ -1,12 +0,0 @@
1
- name: testing-best-practices
2
- skill: testing-best-practices
3
- description: "testing best practices specialist"
4
- version: "1.0.0"
5
- mode: subagent
6
-
7
- capabilities:
8
- - domain_specialization
9
-
10
- quality:
11
- test_coverage: recommended
12
- type_safety: strict
@@ -1,93 +0,0 @@
1
- /**
2
- * Consent Manager for 0xRay Central Analytics
3
- *
4
- * Manages user consent for analytics data submission with granular
5
- * control over what categories can be shared.
6
- *
7
- * @version 1.0.0
8
- * @since 2026-03-06
9
- */
10
- export interface ConsentConfiguration {
11
- analyticsEnabled: boolean;
12
- consentDate: Date;
13
- consentVersion: string;
14
- lastOptOut: Date | undefined;
15
- categories: {
16
- reflections: boolean;
17
- logs: boolean;
18
- metrics: boolean;
19
- patterns: boolean;
20
- };
21
- projectId: string;
22
- }
23
- export interface ConsentCategory {
24
- name: string;
25
- description: string;
26
- enabled: boolean;
27
- }
28
- export declare class ConsentManager {
29
- private configPath;
30
- private config;
31
- private submissionQueue;
32
- constructor(configPath?: string | undefined);
33
- /**
34
- * Initialize consent manager - load existing config or create default
35
- */
36
- initialize(): Promise<ConsentConfiguration>;
37
- /**
38
- * Enable analytics (opt-in)
39
- */
40
- enableConsent(categories?: string[]): Promise<void>;
41
- /**
42
- * Disable analytics (opt-out)
43
- */
44
- disableConsent(): Promise<void>;
45
- /**
46
- * Check if submission is allowed for a category
47
- */
48
- canSubmit(category: string): boolean;
49
- /**
50
- * Get current consent status
51
- */
52
- getStatus(): Promise<ConsentConfiguration>;
53
- /**
54
- * Enable specific category
55
- */
56
- enableCategory(category: string): Promise<void>;
57
- /**
58
- * Disable specific category
59
- */
60
- disableCategory(category: string): Promise<void>;
61
- /**
62
- * Get all categories with their status
63
- */
64
- getCategories(): ConsentCategory[];
65
- /**
66
- * Generate anonymous project ID
67
- */
68
- private generateProjectId;
69
- /**
70
- * Create default disabled configuration
71
- */
72
- private createDefaultConfig;
73
- /**
74
- * Load configuration from file
75
- */
76
- private loadConfig;
77
- /**
78
- * Save configuration to file
79
- */
80
- private saveConfig;
81
- /**
82
- * Clear submission queue
83
- */
84
- private clearSubmissionQueue;
85
- /**
86
- * Add item to submission queue
87
- */
88
- queueSubmission(data: unknown): Promise<void>;
89
- /**
90
- * Save submission queue to file
91
- */
92
- private saveSubmissionQueue;
93
- }
@@ -1,258 +0,0 @@
1
- /**
2
- * Consent Manager for 0xRay Central Analytics
3
- *
4
- * Manages user consent for analytics data submission with granular
5
- * control over what categories can be shared.
6
- *
7
- * @version 1.0.0
8
- * @since 2026-03-06
9
- */
10
- import * as fs from "fs/promises";
11
- import * as path from "path";
12
- import { frameworkLogger } from "../core/framework-logger.js";
13
- import { getConfigDir, resolveConfigPath } from "../core/config-paths.js";
14
- export class ConsentManager {
15
- configPath;
16
- config = null;
17
- submissionQueue = [];
18
- constructor(configPath = undefined) {
19
- this.configPath = configPath || resolveConfigPath("consent.json") || path.join(getConfigDir(), "consent.json");
20
- }
21
- /**
22
- * Initialize consent manager - load existing config or create default
23
- */
24
- async initialize() {
25
- try {
26
- await this.loadConfig();
27
- if (!this.config) {
28
- // Create default disabled configuration
29
- this.config = this.createDefaultConfig();
30
- await this.saveConfig();
31
- }
32
- return this.config;
33
- }
34
- catch (error) {
35
- // If config doesn't exist, create default
36
- this.config = this.createDefaultConfig();
37
- await this.saveConfig();
38
- return this.config;
39
- }
40
- }
41
- /**
42
- * Enable analytics (opt-in)
43
- */
44
- async enableConsent(categories) {
45
- if (!this.config) {
46
- await this.initialize();
47
- }
48
- if (!this.config) {
49
- throw new Error("Failed to initialize consent configuration");
50
- }
51
- // Enable all categories if none specified
52
- const categoriesToEnable = categories || Object.keys(this.config.categories);
53
- // Enable main analytics flag
54
- this.config.analyticsEnabled = true;
55
- this.config.consentDate = new Date();
56
- this.config.consentVersion = "1.0";
57
- // Enable specified categories
58
- categoriesToEnable.forEach(cat => {
59
- if (this.config && cat in this.config.categories) {
60
- this.config.categories[cat] = true;
61
- }
62
- });
63
- // Generate project ID if not exists
64
- if (!this.config.projectId || this.config.projectId === "") {
65
- this.config.projectId = this.generateProjectId();
66
- }
67
- await this.saveConfig();
68
- }
69
- /**
70
- * Disable analytics (opt-out)
71
- */
72
- async disableConsent() {
73
- if (!this.config) {
74
- await this.initialize();
75
- }
76
- if (!this.config) {
77
- throw new Error("Failed to initialize consent configuration");
78
- }
79
- // Disable all analytics
80
- this.config.analyticsEnabled = false;
81
- this.config.lastOptOut = new Date();
82
- // Disable all categories
83
- Object.keys(this.config.categories).forEach(cat => {
84
- this.config.categories[cat] = false;
85
- });
86
- await this.saveConfig();
87
- // Clear submission queue
88
- await this.clearSubmissionQueue();
89
- }
90
- /**
91
- * Check if submission is allowed for a category
92
- */
93
- canSubmit(category) {
94
- if (!this.config) {
95
- return false;
96
- }
97
- return this.config.analyticsEnabled &&
98
- this.config.categories[category] === true;
99
- }
100
- /**
101
- * Get current consent status
102
- */
103
- async getStatus() {
104
- if (!this.config) {
105
- await this.initialize();
106
- }
107
- if (!this.config) {
108
- throw new Error("Failed to load consent configuration");
109
- }
110
- return { ...this.config };
111
- }
112
- /**
113
- * Enable specific category
114
- */
115
- async enableCategory(category) {
116
- if (!this.config) {
117
- await this.initialize();
118
- }
119
- if (!this.config || !(category in this.config.categories)) {
120
- throw new Error(`Invalid category: ${category}`);
121
- }
122
- this.config.categories[category] = true;
123
- await this.saveConfig();
124
- }
125
- /**
126
- * Disable specific category
127
- */
128
- async disableCategory(category) {
129
- if (!this.config) {
130
- await this.initialize();
131
- }
132
- if (!this.config || !(category in this.config.categories)) {
133
- throw new Error(`Invalid category: ${category}`);
134
- }
135
- this.config.categories[category] = false;
136
- await this.saveConfig();
137
- }
138
- /**
139
- * Get all categories with their status
140
- */
141
- getCategories() {
142
- if (!this.config) {
143
- return [];
144
- }
145
- const categoryInfo = {
146
- reflections: "Anonymized reflection data for pattern learning",
147
- logs: "Framework activity logs for performance analysis",
148
- metrics: "Agent performance and routing metrics",
149
- patterns: "P9 pattern learning data and insights"
150
- };
151
- return Object.entries(this.config.categories).map(([name, enabled]) => ({
152
- name,
153
- description: categoryInfo[name] || "",
154
- enabled: enabled
155
- }));
156
- }
157
- /**
158
- * Generate anonymous project ID
159
- */
160
- generateProjectId() {
161
- // Generate UUID-like identifier
162
- const timestamp = Date.now().toString(36);
163
- const random = Math.random().toString(36).substring(2, 8);
164
- return `project-${timestamp}-${random}`;
165
- }
166
- /**
167
- * Create default disabled configuration
168
- */
169
- createDefaultConfig() {
170
- return {
171
- analyticsEnabled: false,
172
- consentDate: new Date(),
173
- consentVersion: "1.0",
174
- lastOptOut: undefined,
175
- categories: {
176
- reflections: false,
177
- logs: false,
178
- metrics: false,
179
- patterns: false
180
- },
181
- projectId: this.generateProjectId()
182
- };
183
- }
184
- /**
185
- * Load configuration from file
186
- */
187
- async loadConfig() {
188
- try {
189
- const configData = await fs.readFile(this.configPath, "utf-8");
190
- this.config = JSON.parse(configData);
191
- // Convert date strings back to Date objects
192
- if (this.config.consentDate) {
193
- this.config.consentDate = new Date(this.config.consentDate);
194
- }
195
- if (this.config.lastOptOut) {
196
- this.config.lastOptOut = new Date(this.config.lastOptOut);
197
- }
198
- }
199
- catch (error) {
200
- // Config doesn't exist or is invalid
201
- this.config = null;
202
- }
203
- }
204
- /**
205
- * Save configuration to file
206
- */
207
- async saveConfig() {
208
- if (!this.config) {
209
- throw new Error("No configuration to save");
210
- }
211
- // Ensure directory exists
212
- const configDir = path.dirname(this.configPath);
213
- try {
214
- await fs.mkdir(configDir, { recursive: true });
215
- }
216
- catch {
217
- // Directory already exists
218
- }
219
- await fs.writeFile(this.configPath, JSON.stringify(this.config, null, 2), "utf-8");
220
- }
221
- /**
222
- * Clear submission queue
223
- */
224
- async clearSubmissionQueue() {
225
- const queuePath = path.join(path.dirname(this.configPath), "analytics", "submission-queue.json");
226
- try {
227
- await fs.writeFile(queuePath, "[]", "utf-8");
228
- this.submissionQueue = [];
229
- }
230
- catch (error) {
231
- // Queue directory doesn't exist yet, which is fine
232
- }
233
- }
234
- /**
235
- * Add item to submission queue
236
- */
237
- async queueSubmission(data) {
238
- if (!this.canSubmit("all")) {
239
- throw new Error("Analytics is disabled or category not enabled");
240
- }
241
- this.submissionQueue.push(data);
242
- await this.saveSubmissionQueue();
243
- }
244
- /**
245
- * Save submission queue to file
246
- */
247
- async saveSubmissionQueue() {
248
- const queueDir = path.join(path.dirname(this.configPath), "analytics");
249
- const queuePath = path.join(queueDir, "submission-queue.json");
250
- try {
251
- await fs.mkdir(queueDir, { recursive: true });
252
- await fs.writeFile(queuePath, JSON.stringify(this.submissionQueue, null, 2), "utf-8");
253
- }
254
- catch (error) {
255
- frameworkLogger.log("consent-manager", "save-queue-failed", "error", { error, message: "Failed to save submission queue" });
256
- }
257
- }
258
- }
@@ -1,80 +0,0 @@
1
- /**
2
- * Simple Pattern Analyzer for 0xRay
3
- *
4
- * Reads activity log → Counts patterns → Generates insights
5
- *
6
- * This is the "learning" system - simple pattern matching, not ML.
7
- *
8
- * @version 1.0.0
9
- */
10
- import type { Outcome, ComplexityAccuracy } from "../core/framework-logger.js";
11
- export interface ParsedLogEntry {
12
- timestamp: string;
13
- jobId: string;
14
- component: string;
15
- action: string;
16
- status: string;
17
- duration?: number;
18
- complexityScore?: number;
19
- agentUsed?: string;
20
- operationType?: string;
21
- outcome?: Outcome;
22
- complexityAccuracy?: ComplexityAccuracy;
23
- }
24
- export interface AgentStats {
25
- attempts: number;
26
- successes: number;
27
- failures: number;
28
- escalated: number;
29
- autoFixed: number;
30
- avgDuration: number;
31
- totalDuration: number;
32
- }
33
- export interface TaskTypeStats {
34
- count: number;
35
- successRate: number;
36
- avgComplexity: number;
37
- }
38
- export interface ComplexityStats {
39
- underestimated: number;
40
- accurate: number;
41
- overestimated: number;
42
- total: number;
43
- }
44
- export interface PatternInsights {
45
- agentStats: Map<string, AgentStats>;
46
- taskTypeStats: Map<string, TaskTypeStats>;
47
- complexityStats: ComplexityStats;
48
- totalEntries: number;
49
- dateRange: {
50
- start: string;
51
- end: string;
52
- };
53
- }
54
- export declare class SimplePatternAnalyzer {
55
- private logPath;
56
- private outcomesPath;
57
- constructor(logPath?: string);
58
- /**
59
- * Main analysis method - reads log and returns insights
60
- */
61
- analyze(limit?: number): Promise<PatternInsights>;
62
- /**
63
- * Parse a single log line
64
- */
65
- private parseLine;
66
- /**
67
- * Calculate statistics from parsed entries
68
- */
69
- private calculateStats;
70
- /**
71
- * Generate human-readable insights
72
- */
73
- generateInsights(insights: PatternInsights): string[];
74
- /**
75
- * Generate insights as a formatted report
76
- */
77
- generateReport(): Promise<string>;
78
- private emptyInsights;
79
- }
80
- export declare const patternAnalyzer: SimplePatternAnalyzer;