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
@@ -1,297 +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 * as fs from "fs";
11
- import * as path from "path";
12
- export class SimplePatternAnalyzer {
13
- logPath;
14
- outcomesPath;
15
- constructor(logPath) {
16
- const cwd = process.cwd();
17
- this.logPath =
18
- logPath || path.join(cwd, "logs", "framework", "activity.log");
19
- // Only use outcomes path when using default log path
20
- this.outcomesPath = logPath ? "" : path.join(cwd, "logs", "framework", "routing-outcomes.json");
21
- }
22
- /**
23
- * Main analysis method - reads log and returns insights
24
- */
25
- async analyze(limit) {
26
- const entries = [];
27
- // Try to read from routing-outcomes.json first (has more complete data)
28
- // Only when using default paths
29
- if (this.outcomesPath && fs.existsSync(this.outcomesPath)) {
30
- try {
31
- const outcomes = JSON.parse(fs.readFileSync(this.outcomesPath, "utf-8"));
32
- const outcomesToAnalyze = limit ? outcomes.slice(-limit) : outcomes;
33
- for (const outcome of outcomesToAnalyze) {
34
- entries.push({
35
- timestamp: outcome.timestamp || new Date().toISOString(),
36
- jobId: outcome.taskId || "",
37
- component: outcome.routedAgent || "unknown",
38
- action: "routing-outcome",
39
- status: outcome.success ? "success" : "error",
40
- agentUsed: outcome.routedAgent,
41
- operationType: outcome.routedSkill,
42
- outcome: outcome.success ? "success" : "fail",
43
- complexityScore: outcome.complexity,
44
- });
45
- }
46
- }
47
- catch {
48
- // Fall back to activity log parsing
49
- }
50
- }
51
- // Fall back to activity log parsing if no outcomes
52
- if (entries.length === 0 && fs.existsSync(this.logPath)) {
53
- const content = fs.readFileSync(this.logPath, "utf-8");
54
- const lines = content.split("\n").filter((l) => l.trim());
55
- // Filter to task completion entries
56
- const completionLines = lines.filter((line) => line.includes("complex-task-completed") ||
57
- line.includes("job-completed") ||
58
- line.includes("task-completed"));
59
- const entriesToAnalyze = limit ? completionLines.slice(-limit) : completionLines;
60
- const parsedEntries = entriesToAnalyze
61
- .map((line) => this.parseLine(line))
62
- .filter((e) => e !== null);
63
- entries.push(...parsedEntries);
64
- }
65
- if (entries.length === 0) {
66
- return this.emptyInsights();
67
- }
68
- return this.calculateStats(entries);
69
- }
70
- /**
71
- * Parse a single log line
72
- */
73
- parseLine(line) {
74
- // Format: 2026-02-24T10:30:00.000Z [job-123-abc] [component] action - STATUS | {"details": "..."}
75
- const match = line.match(/^(\d{4}-\d{2}-\d{2}T[\d:.]+Z)\s+\[([^\]]+)\]\s+\[([^\]]+)\]\s+(.+?)\s+-\s+(\w+)(?:\s*\|\s*(.+))?$/);
76
- if (!match) {
77
- return null;
78
- }
79
- const [, timestamp, jobId, component, actionRaw, statusRaw, detailsRaw] = match;
80
- // Parse action and any embedded details
81
- const action = actionRaw?.trim() || "unknown";
82
- const status = statusRaw?.toLowerCase() || "info";
83
- // Parse JSON details if present
84
- let details = {};
85
- if (detailsRaw) {
86
- try {
87
- details = JSON.parse(detailsRaw.trim());
88
- }
89
- catch {
90
- // Not JSON, ignore
91
- }
92
- }
93
- return {
94
- timestamp: timestamp || "",
95
- jobId: jobId || "",
96
- component: component || "unknown",
97
- action,
98
- status,
99
- duration: details.duration,
100
- complexityScore: details.complexityScore,
101
- agentUsed: details.agentUsed || details.agent || details.taskType,
102
- operationType: details.operationType || details.taskType,
103
- outcome: details.outcome,
104
- complexityAccuracy: details.complexityAccuracy,
105
- };
106
- }
107
- /**
108
- * Calculate statistics from parsed entries
109
- */
110
- calculateStats(entries) {
111
- const agentStats = new Map();
112
- const taskTypeStats = new Map();
113
- const complexityStats = {
114
- underestimated: 0,
115
- accurate: 0,
116
- overestimated: 0,
117
- total: 0,
118
- };
119
- // Filter to entries with analytics data (task completions or routing outcomes)
120
- const relevantEntries = entries.filter((e) => e.action === "job-completed" ||
121
- e.action === "routing-outcome" ||
122
- e.action.includes("completed") ||
123
- e.outcome !== undefined);
124
- for (const entry of relevantEntries) {
125
- const agent = entry.agentUsed || entry.component || "unknown";
126
- // Agent stats
127
- if (!agentStats.has(agent)) {
128
- agentStats.set(agent, {
129
- attempts: 0,
130
- successes: 0,
131
- failures: 0,
132
- escalated: 0,
133
- autoFixed: 0,
134
- avgDuration: 0,
135
- totalDuration: 0,
136
- });
137
- }
138
- const stats = agentStats.get(agent);
139
- stats.attempts++;
140
- if (entry.duration) {
141
- stats.totalDuration += entry.duration;
142
- stats.avgDuration = stats.totalDuration / stats.attempts;
143
- }
144
- // Outcome tracking
145
- const outcome = entry.outcome || (entry.status === "success" ? "success" : "fail");
146
- switch (outcome) {
147
- case "success":
148
- stats.successes++;
149
- break;
150
- case "fail":
151
- stats.failures++;
152
- break;
153
- case "escalated":
154
- stats.escalated++;
155
- break;
156
- case "auto-fixed":
157
- stats.autoFixed++;
158
- break;
159
- }
160
- // Task type stats
161
- const taskType = entry.operationType || "unknown";
162
- if (!taskTypeStats.has(taskType)) {
163
- taskTypeStats.set(taskType, {
164
- count: 0,
165
- successRate: 0,
166
- avgComplexity: 0,
167
- });
168
- }
169
- const taskStat = taskTypeStats.get(taskType);
170
- taskStat.count++;
171
- if (entry.complexityScore) {
172
- taskStat.avgComplexity =
173
- (taskStat.avgComplexity * (taskStat.count - 1) +
174
- entry.complexityScore) /
175
- taskStat.count;
176
- }
177
- // Complexity accuracy
178
- if (entry.complexityAccuracy) {
179
- complexityStats.total++;
180
- switch (entry.complexityAccuracy) {
181
- case "underestimated":
182
- complexityStats.underestimated++;
183
- break;
184
- case "accurate":
185
- complexityStats.accurate++;
186
- break;
187
- case "overestimated":
188
- complexityStats.overestimated++;
189
- break;
190
- }
191
- }
192
- }
193
- // Calculate success rates
194
- for (const [agent, stats] of agentStats) {
195
- if (stats.attempts > 0) {
196
- // We'll calculate in the output
197
- }
198
- }
199
- for (const [taskType, stats] of taskTypeStats) {
200
- const agentStatsForTask = Array.from(agentStats.values()).reduce((acc, s) => ({
201
- attempts: acc.attempts + s.attempts,
202
- successes: acc.successes + s.successes,
203
- }), { attempts: 0, successes: 0 });
204
- stats.successRate =
205
- agentStatsForTask.attempts > 0
206
- ? (agentStatsForTask.successes / agentStatsForTask.attempts) * 100
207
- : 0;
208
- }
209
- const sortedEntries = [...entries].sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
210
- return {
211
- agentStats,
212
- taskTypeStats,
213
- complexityStats,
214
- totalEntries: entries.length,
215
- dateRange: {
216
- start: sortedEntries[0]?.timestamp || "",
217
- end: sortedEntries[sortedEntries.length - 1]?.timestamp || "",
218
- },
219
- };
220
- }
221
- /**
222
- * Generate human-readable insights
223
- */
224
- generateInsights(insights) {
225
- const output = [];
226
- if (insights.totalEntries === 0) {
227
- return ["No activity log entries found."];
228
- }
229
- // Agent performance
230
- output.push("=== Agent Performance ===");
231
- for (const [agent, stats] of insights.agentStats) {
232
- const successRate = stats.attempts > 0
233
- ? ((stats.successes / stats.attempts) * 100).toFixed(1)
234
- : "0.0";
235
- const avgDuration = stats.avgDuration > 0
236
- ? (stats.avgDuration / 1000).toFixed(1) + "s"
237
- : "N/A";
238
- output.push(`- ${agent}: ${successRate}% success (${stats.attempts} tasks), avg ${avgDuration}`);
239
- }
240
- // Complexity accuracy
241
- output.push("");
242
- output.push("=== Complexity Accuracy ===");
243
- const { underestimated, accurate, overestimated, total } = insights.complexityStats;
244
- if (total > 0) {
245
- output.push(`- Underestimated: ${((underestimated / total) * 100).toFixed(1)}% (tasks took longer than predicted)`);
246
- output.push(`- Accurate: ${((accurate / total) * 100).toFixed(1)}% (predictions within 50%)`);
247
- output.push(`- Overestimated: ${((overestimated / total) * 100).toFixed(1)}% (tasks completed faster than predicted)`);
248
- }
249
- else {
250
- output.push("- Not enough data to determine accuracy");
251
- }
252
- // Task type breakdown
253
- output.push("");
254
- output.push("=== Task Types ===");
255
- for (const [taskType, stats] of insights.taskTypeStats) {
256
- output.push(`- ${taskType}: ${stats.count} tasks, avg complexity ${stats.avgComplexity.toFixed(0)}`);
257
- }
258
- return output;
259
- }
260
- /**
261
- * Generate insights as a formatted report
262
- */
263
- async generateReport() {
264
- const insights = await this.analyze();
265
- const insightsLines = this.generateInsights(insights);
266
- const report = [
267
- "╔════════════════════════════════════════════════════════════╗",
268
- "ā•‘ 0xRay Pattern Analytics Report ā•‘",
269
- "ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•",
270
- "",
271
- `Analyzed: ${insights.totalEntries} log entries`,
272
- `Date Range: ${insights.dateRange.start || "N/A"} to ${insights.dateRange.end || "N/A"}`,
273
- "",
274
- ...insightsLines,
275
- "",
276
- "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
277
- "Generated by 0xRay Simple Pattern Analyzer",
278
- ];
279
- return report.join("\n");
280
- }
281
- emptyInsights() {
282
- return {
283
- agentStats: new Map(),
284
- taskTypeStats: new Map(),
285
- complexityStats: {
286
- underestimated: 0,
287
- accurate: 0,
288
- overestimated: 0,
289
- total: 0,
290
- },
291
- totalEntries: 0,
292
- dateRange: { start: "", end: "" },
293
- };
294
- }
295
- }
296
- // Export singleton for easy use
297
- export const patternAnalyzer = new SimplePatternAnalyzer();
@@ -1,9 +0,0 @@
1
- /**
2
- * Analytics Disable CLI Command
3
- *
4
- * Disables 0xRay Central Analytics with immediate opt-out
5
- *
6
- * Usage: npx 0xray analytics disable
7
- */
8
- export declare const analyticsDisableCommand: import("commander").Command;
9
- export default analyticsDisableCommand;
@@ -1,72 +0,0 @@
1
- /**
2
- * Analytics Disable CLI Command
3
- *
4
- * Disables 0xRay Central Analytics with immediate opt-out
5
- *
6
- * Usage: npx 0xray analytics disable
7
- */
8
- import { program } from "commander";
9
- import { ConsentManager } from "../../analytics/consent-manager.js";
10
- export const analyticsDisableCommand = program
11
- .command("analytics disable")
12
- .description("Disable 0xRay Central Analytics (opt-out)")
13
- .option("-y, --yes", "Skip confirmation prompts", false)
14
- .action(async (options) => {
15
- console.log("šŸ”’ Disabling 0xRay Central Analytics...\n");
16
- try {
17
- const consentManager = new ConsentManager();
18
- const currentStatus = await consentManager.initialize();
19
- // Check if already disabled
20
- if (!currentStatus.analyticsEnabled) {
21
- console.log("āœ… Analytics is already disabled!");
22
- return;
23
- }
24
- // Show what will be disabled
25
- console.log("šŸ“‹ Current Status:");
26
- console.log(` Project ID: ${currentStatus.projectId}`);
27
- console.log(` Enabled Categories: ${Object.entries(currentStatus.categories)
28
- .filter(([_, enabled]) => enabled)
29
- .map(([cat]) => cat)
30
- .join(', ')}`);
31
- console.log(` Submissions will: STOP IMMEDIATELY`);
32
- // Confirmation
33
- if (!options.yes) {
34
- console.log(`\nāš ļø This will immediately stop all data submission.`);
35
- console.log(` • Existing submission queue will be cleared`);
36
- console.log(` • Your project ID will be preserved in config`);
37
- console.log(` • You can re-enable anytime: npx 0xray analytics enable\n`);
38
- const readline = await import('readline');
39
- const rl = readline.createInterface({
40
- input: process.stdin,
41
- output: process.stdout
42
- });
43
- const answer = await new Promise((resolve) => {
44
- rl.question("Do you want to proceed? (yes/no): ", resolve);
45
- });
46
- rl.close();
47
- if (answer.toLowerCase() !== 'yes' && answer.toLowerCase() !== 'y') {
48
- console.log("āŒ Consent not disabled. Aborted.");
49
- return;
50
- }
51
- }
52
- // Disable consent
53
- await consentManager.disableConsent();
54
- // Show success
55
- console.log("\nāœ… Analytics successfully disabled!");
56
- console.log(`\nšŸ”’ All data submission has stopped.`);
57
- console.log(`\nšŸ“‹ Your consent configuration:`);
58
- const updatedStatus = await consentManager.getStatus();
59
- console.log(` Project ID: ${updatedStatus.projectId}`);
60
- console.log(` Opt-Out Date: ${updatedStatus.lastOptOut?.toISOString()}`);
61
- console.log(` Analytics Enabled: ${updatedStatus.analyticsEnabled}`);
62
- console.log(`\nšŸ’” Re-enable anytime:`);
63
- console.log(` npx 0xray analytics enable`);
64
- console.log(`\nšŸ“– Learn more: docs/architecture/central-analytics-store.md`);
65
- }
66
- catch (error) {
67
- console.error("āŒ Failed to disable analytics:", error instanceof Error ? error.message : String(error));
68
- console.error("\nšŸ’” Try: npx 0xray analytics disable --help");
69
- process.exit(1);
70
- }
71
- });
72
- export default analyticsDisableCommand;
@@ -1,8 +0,0 @@
1
- /**
2
- * Analytics Enable Action
3
- *
4
- * Enables 0xRay Central Analytics with opt-in consent
5
- *
6
- * Usage: npx 0xray analytics enable [--categories reflections,logs,metrics,patterns]
7
- */
8
- export declare function analyticsEnableAction(options: any): Promise<void>;
@@ -1,82 +0,0 @@
1
- /**
2
- * Analytics Enable Action
3
- *
4
- * Enables 0xRay Central Analytics with opt-in consent
5
- *
6
- * Usage: npx 0xray analytics enable [--categories reflections,logs,metrics,patterns]
7
- */
8
- import { ConsentManager } from "../../analytics/consent-manager.js";
9
- export async function analyticsEnableAction(options) {
10
- console.log("šŸ”“ Enabling 0xRay Central Analytics...\n");
11
- try {
12
- const consentManager = new ConsentManager();
13
- const currentStatus = await consentManager.initialize();
14
- // Check if already enabled
15
- if (currentStatus.analyticsEnabled) {
16
- console.log("āœ… Analytics is already enabled!");
17
- console.log(`\nCurrent Status:`);
18
- console.log(` Project ID: ${currentStatus.projectId}`);
19
- console.log(` Categories: ${Object.entries(currentStatus.categories)
20
- .filter(([_, enabled]) => enabled)
21
- .map(([cat]) => cat)
22
- .join(', ')}`);
23
- return;
24
- }
25
- // Parse categories
26
- let categories;
27
- if (options.all) {
28
- categories = ["reflections", "logs", "metrics", "patterns"];
29
- }
30
- else if (options.categories) {
31
- categories = options.categories.split(',').map((c) => c.trim());
32
- }
33
- // Show what will be enabled
34
- console.log("šŸ“‹ Configuration:");
35
- console.log(` Categories to enable: ${categories ? categories.join(', ') : 'all'}`);
36
- console.log(` Project ID will be: ${currentStatus.projectId}`);
37
- console.log(` Consent version: 1.0`);
38
- // Confirmation
39
- if (!options.yes) {
40
- console.log(`\nāš ļø This will enable anonymous data submission to 0xRay Central Analytics.`);
41
- console.log(` • Data is anonymized before submission`);
42
- console.log(` • You can disable anytime with: npx 0xray analytics disable`);
43
- console.log(` • Preview what would be submitted: npx 0xray analytics preview`);
44
- console.log(` • Learn more: docs/architecture/central-analytics-store.md\n`);
45
- const readline = await import('readline');
46
- const rl = readline.createInterface({
47
- input: process.stdin,
48
- output: process.stdout
49
- });
50
- const answer = await new Promise((resolve) => {
51
- rl.question("Do you want to proceed? (yes/no): ", resolve);
52
- });
53
- rl.close();
54
- if (answer.toLowerCase() !== 'yes' && answer.toLowerCase() !== 'y') {
55
- console.log("āŒ Consent not enabled. Aborted.");
56
- return;
57
- }
58
- }
59
- // Enable consent
60
- await consentManager.enableConsent(categories);
61
- // Show success
62
- console.log("\nāœ… Analytics successfully enabled!");
63
- console.log(`\nšŸŽ‰ Your project can now contribute to community learning!`);
64
- console.log(`\nšŸ“‹ Your consent configuration:`);
65
- const updatedStatus = await consentManager.getStatus();
66
- console.log(` Project ID: ${updatedStatus.projectId}`);
67
- console.log(` Consent Date: ${updatedStatus.consentDate.toISOString()}`);
68
- console.log(` Categories Enabled: ${Object.entries(updatedStatus.categories)
69
- .filter(([_, enabled]) => enabled)
70
- .map(([cat]) => cat)
71
- .join(', ')}`);
72
- console.log(`\nšŸ’” Next steps:`);
73
- console.log(` 1. Check what will be submitted: npx 0xray analytics preview`);
74
- console.log(` 2. View current status: npx 0xray analytics status`);
75
- console.log(` 3. Disable anytime: npx 0xray analytics disable`);
76
- }
77
- catch (error) {
78
- console.error("āŒ Failed to enable analytics:", error instanceof Error ? error.message : String(error));
79
- console.error("\nšŸ’” Try: npx 0xray analytics enable --help");
80
- process.exit(1);
81
- }
82
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Analytics Preview CLI Command
3
- *
4
- * Shows what data would be submitted without actually submitting it
5
- *
6
- * Usage: npx 0xray analytics preview [--type reflections|logs|metrics|patterns] [--all]
7
- */
8
- export declare const analyticsPreviewCommand: import("commander").Command;
9
- export default analyticsPreviewCommand;
@@ -1,106 +0,0 @@
1
- /**
2
- * Analytics Preview CLI Command
3
- *
4
- * Shows what data would be submitted without actually submitting it
5
- *
6
- * Usage: npx 0xray analytics preview [--type reflections|logs|metrics|patterns] [--all]
7
- */
8
- import { program } from "commander";
9
- import { ConsentManager } from "../../analytics/consent-manager.js";
10
- export const analyticsPreviewCommand = program
11
- .command("analytics preview")
12
- .description("Preview what data would be submitted (without submitting)")
13
- .option("-t, --type <type>", "Specific data type to preview", "all")
14
- .option("--all", "Preview all data types", false)
15
- .action(async (options) => {
16
- console.log("šŸ‘ļø 0xRay Central Analytics - Data Preview\n");
17
- try {
18
- const consentManager = new ConsentManager();
19
- const status = await consentManager.initialize();
20
- // Check if analytics is enabled
21
- if (!status.analyticsEnabled) {
22
- console.log("āŒ Analytics is currently disabled.");
23
- console.log(`\nšŸ’” Enable analytics first: npx 0xray analytics enable`);
24
- console.log(` Then preview what would be submitted: npx 0xray analytics preview`);
25
- return;
26
- }
27
- console.log("šŸ” This preview shows what anonymized data would be submitted.\n");
28
- // Show what gets anonymized vs preserved
29
- console.log("šŸ”’ What Gets REMOVED (Privacy Protection):");
30
- console.log(" āŒ Project names and company information");
31
- console.log(" āŒ Repository URLs and file paths");
32
- console.log(" āŒ User names, emails, and personal identifiers");
33
- console.log(" āŒ IP addresses and precise timestamps");
34
- console.log(" āŒ API keys, secrets, and credentials");
35
- console.log(" āŒ Actual code snippets and proprietary logic");
36
- console.log("\nāœ… What Gets PRESERVED (For Learning):");
37
- console.log(" āœ… Agent performance metrics (success rates, confidence scores)");
38
- console.log(" āœ… Complexity ratings and outcomes");
39
- console.log(" āœ… Pattern effectiveness data");
40
- console.log(" āœ… Anonymized emotional/struggle patterns");
41
- console.log(" āœ… Counterfactual analysis structures");
42
- // Show anonymization example
43
- console.log("\nšŸ“Š Anonymization Example:");
44
- console.log(" šŸ“„ Before (Local - Never Submitted):");
45
- console.log(" {");
46
- console.log(` "project": "acme-corp/legacy-system",`);
47
- console.log(` "reflection": "Fixed bug in user authentication...",`);
48
- console.log(` "filePath": "/Users/john/projects/legacy/src/auth.ts",`);
49
- console.log(` "author": "john.doe@acme.com",`);
50
- console.log(` "code": "function authenticate(user) { ... }"`);
51
- console.log(" }");
52
- console.log("\n šŸ“¤ After (Anonymized - What Gets Submitted):");
53
- console.log(" {");
54
- console.log(` "submissionId": "uuid-v4",`);
55
- console.log(` "taskType": "bug_fix",`);
56
- console.log(` "complexity": 75,`);
57
- console.log(` "routedAgent": "bug-triage-specialist",`);
58
- console.log(` "success": true,`);
59
- console.log(` "emotionalContext": {`);
60
- console.log(` "struggleLevel": "medium",`);
61
- console.log(` "hasCounterfactualAnalysis": true,`);
62
- console.log(` "depthScore": 4`);
63
- console.log(" },");
64
- console.log(` "patterns": {`);
65
- console.log(` "keywords": ["bug", "authentication", "critical"],`);
66
- console.log(` "successRate": 0.85`);
67
- console.log(" }");
68
- console.log(" }");
69
- // Show enabled categories
70
- const categories = consentManager.getCategories();
71
- const enabledCategories = categories.filter(c => c.enabled);
72
- console.log("\nšŸ“‚ Currently Enabled Categories:");
73
- enabledCategories.forEach(cat => {
74
- console.log(` āœ… ${cat.name.padEnd(20)} ${cat.description}`);
75
- });
76
- const disabledCategories = categories.filter(c => !c.enabled);
77
- if (disabledCategories.length > 0) {
78
- console.log("\nāŒ Disabled Categories (Will Not Be Submitted):");
79
- disabledCategories.forEach(cat => {
80
- console.log(` āŒ ${cat.name.padEnd(20)} ${cat.description}`);
81
- });
82
- }
83
- // Show privacy guarantees
84
- console.log("\nšŸ” Privacy Guarantees:");
85
- console.log(" āœ… Your data is anonymized before leaving your machine");
86
- console.log(" āœ… All submissions encrypted in transit (HTTPS/TLS)");
87
- console.log(" āœ… You can disable anytime: npx 0xray analytics disable");
88
- console.log(" āœ… Request data deletion anytime");
89
- console.log(" āœ… Full transparency - see exactly what's submitted");
90
- console.log("\nšŸ’” Next Steps:");
91
- console.log(" 1. Review this preview carefully");
92
- console.log(" 2. Enable specific categories: npx 0xray analytics enable --categories reflections,metrics");
93
- console.log(" 3. View current status: npx 0xray analytics status");
94
- console.log(" 4. Learn more: docs/architecture/central-analytics-store.md");
95
- console.log("\nšŸ“– Documentation:");
96
- console.log(" • Architecture: docs/architecture/central-analytics-store.md");
97
- console.log(" • Privacy Policy: [To be published]");
98
- console.log(" • FAQ: docs/quickstart/central-analytics-quickstart.md");
99
- }
100
- catch (error) {
101
- console.error("āŒ Failed to preview analytics:", error instanceof Error ? error.message : String(error));
102
- console.error("\nšŸ’” Try: npx 0xray analytics preview --help");
103
- process.exit(1);
104
- }
105
- });
106
- export default analyticsPreviewCommand;
@@ -1,9 +0,0 @@
1
- /**
2
- * Analytics Status CLI Command
3
- *
4
- * Shows current consent and analytics status
5
- *
6
- * Usage: npx 0xray analytics status
7
- */
8
- export declare const analyticsStatusCommand: import("commander").Command;
9
- export default analyticsStatusCommand;
@@ -1,68 +0,0 @@
1
- /**
2
- * Analytics Status CLI Command
3
- *
4
- * Shows current consent and analytics status
5
- *
6
- * Usage: npx 0xray analytics status
7
- */
8
- import { program } from "commander";
9
- import { ConsentManager } from "../../analytics/consent-manager.js";
10
- import { getConfigDir } from "../../core/config-paths.js";
11
- export const analyticsStatusCommand = program
12
- .command("analytics status")
13
- .description("Show current analytics consent status")
14
- .option("-v, --verbose", "Show detailed information", false)
15
- .action(async (options) => {
16
- console.log("šŸ“Š 0xRay Central Analytics Status\n");
17
- try {
18
- const consentManager = new ConsentManager();
19
- const status = await consentManager.getStatus();
20
- // Show main status
21
- const enabledEmoji = status.analyticsEnabled ? "āœ… ENABLED" : "āŒ DISABLED";
22
- console.log(`šŸŽÆ Status: ${enabledEmoji}\n`);
23
- // Show project ID
24
- console.log(`šŸ“‹ Project Information:`);
25
- console.log(` Project ID: ${status.projectId}`);
26
- console.log(` Consent Version: ${status.consentVersion}`);
27
- console.log(` Consent Date: ${status.consentDate.toISOString()}`);
28
- if (status.lastOptOut) {
29
- console.log(` Last Opt-Out: ${status.lastOptOut.toISOString()}`);
30
- }
31
- // Show category status
32
- console.log(`\nšŸ“‚ Categories Status:`);
33
- const categories = consentManager.getCategories();
34
- categories.forEach(cat => {
35
- const emoji = cat.enabled ? "āœ…" : "āŒ";
36
- console.log(` ${emoji} ${cat.name.padEnd(15)} ${cat.description}`);
37
- });
38
- if (options.verbose) {
39
- // Show configuration file location
40
- const configDir = getConfigDir();
41
- console.log(`\nšŸ“ Configuration Files:`);
42
- console.log(` Consent Config: ${configDir}/consent.json`);
43
- console.log(` Submission Queue: ${configDir}/analytics/submission-queue.json`);
44
- // Show detailed information
45
- console.log(`\nšŸ“Š Detailed Information:`);
46
- const enabledCats = categories.filter(c => c.enabled);
47
- console.log(` Enabled Categories: ${enabledCats.length}/${categories.length}`);
48
- console.log(` Analytics Active: ${status.analyticsEnabled}`);
49
- if (status.analyticsEnabled) {
50
- console.log(`\nšŸ’” Your project is contributing to community learning!`);
51
- console.log(` • View what's being submitted: npx 0xray analytics preview`);
52
- console.log(` • Get community insights: npx 0xray analytics recommendations`);
53
- console.log(` • Check performance: npx 0xray analytics`);
54
- }
55
- else {
56
- console.log(`\nšŸ’” Analytics is currently disabled.`);
57
- console.log(` • Enable anytime: npx 0xray analytics enable`);
58
- console.log(` • Learn more: docs/architecture/central-analytics-store.md`);
59
- }
60
- }
61
- }
62
- catch (error) {
63
- console.error("āŒ Failed to get analytics status:", error instanceof Error ? error.message : String(error));
64
- console.error("\nšŸ’” Try: npx 0xray analytics status --help");
65
- process.exit(1);
66
- }
67
- });
68
- export default analyticsStatusCommand;
@@ -1 +0,0 @@
1
- export {};