jev-dev-harness 0.1.2 → 0.1.5

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.
@@ -0,0 +1,19 @@
1
+ export interface DashboardOptions {
2
+ port?: number;
3
+ open?: boolean;
4
+ clear?: boolean;
5
+ json?: boolean;
6
+ }
7
+ /**
8
+ * Cross-platform open browser helper
9
+ */
10
+ export declare function openBrowser(url: string): void;
11
+ /**
12
+ * Locate dashboard/index.html across local dev and packaged npm installs
13
+ */
14
+ export declare function getDashboardHtmlPath(): string;
15
+ /**
16
+ * Start the local Live Telemetry Dashboard HTTP server
17
+ */
18
+ export declare function startDashboardServer(options?: DashboardOptions): Promise<void>;
19
+ //# sourceMappingURL=dashboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/cli/dashboard.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAY7C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAmB7C;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwKxF"}
@@ -0,0 +1,197 @@
1
+ import * as http from "http";
2
+ import * as fs from "fs";
3
+ import * as path from "path";
4
+ import { exec } from "child_process";
5
+ import { fileURLToPath } from "url";
6
+ import { getTelemetryEvents, getTelemetrySummary, clearTelemetryEvents, telemetryEmitter, getTelemetryFilePath, } from "../shared/telemetry.js";
7
+ import { checkForUpdates } from "../shared/update-checker.js";
8
+ /**
9
+ * Cross-platform open browser helper
10
+ */
11
+ export function openBrowser(url) {
12
+ const start = process.platform === "darwin"
13
+ ? "open"
14
+ : process.platform === "win32"
15
+ ? "start"
16
+ : "xdg-open";
17
+ try {
18
+ exec(`${start} ${url}`);
19
+ }
20
+ catch {
21
+ // Non-critical if browser open fails
22
+ }
23
+ }
24
+ /**
25
+ * Locate dashboard/index.html across local dev and packaged npm installs
26
+ */
27
+ export function getDashboardHtmlPath() {
28
+ try {
29
+ const currentDir = path.dirname(fileURLToPath(import.meta.url));
30
+ const candidates = [
31
+ path.resolve(currentDir, "../../dashboard/index.html"),
32
+ path.resolve(currentDir, "../dashboard/index.html"),
33
+ path.resolve(currentDir, "dashboard/index.html"),
34
+ path.resolve(process.cwd(), "dashboard/index.html"),
35
+ ];
36
+ for (const candidate of candidates) {
37
+ if (fs.existsSync(candidate)) {
38
+ return candidate;
39
+ }
40
+ }
41
+ }
42
+ catch {
43
+ // Fallback if URL resolution fails
44
+ }
45
+ return "";
46
+ }
47
+ /**
48
+ * Start the local Live Telemetry Dashboard HTTP server
49
+ */
50
+ export async function startDashboardServer(options = {}) {
51
+ if (options.clear) {
52
+ clearTelemetryEvents();
53
+ console.log("Telemetry history cleared successfully.");
54
+ return;
55
+ }
56
+ if (options.json) {
57
+ const summary = getTelemetrySummary();
58
+ console.log(JSON.stringify(summary, null, 2));
59
+ return;
60
+ }
61
+ const port = options.port || 3741;
62
+ const htmlPath = getDashboardHtmlPath();
63
+ const server = http.createServer((req, res) => {
64
+ // Enable CORS for API
65
+ res.setHeader("Access-Control-Allow-Origin", "*");
66
+ res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
67
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
68
+ if (req.method === "OPTIONS") {
69
+ res.writeHead(204);
70
+ res.end();
71
+ return;
72
+ }
73
+ const parsedUrl = new URL(req.url || "/", `http://${req.headers.host || "localhost"}`);
74
+ const pathname = parsedUrl.pathname;
75
+ // API: Summary
76
+ if (pathname === "/api/summary" && req.method === "GET") {
77
+ const summary = getTelemetrySummary();
78
+ res.writeHead(200, { "Content-Type": "application/json" });
79
+ res.end(JSON.stringify(summary));
80
+ return;
81
+ }
82
+ // API: Update Status
83
+ if (pathname === "/api/update-status" && req.method === "GET") {
84
+ checkForUpdates("0.1.5")
85
+ .then((info) => {
86
+ res.writeHead(200, { "Content-Type": "application/json" });
87
+ res.end(JSON.stringify(info));
88
+ })
89
+ .catch(() => {
90
+ res.writeHead(200, { "Content-Type": "application/json" });
91
+ res.end(JSON.stringify({
92
+ currentVersion: "0.1.5",
93
+ latestVersion: "0.1.5",
94
+ updateAvailable: false,
95
+ }));
96
+ });
97
+ return;
98
+ }
99
+ // API: Events List
100
+ if (pathname === "/api/events" && req.method === "GET") {
101
+ const limit = Number(parsedUrl.searchParams.get("limit")) || 100;
102
+ const events = getTelemetryEvents(limit);
103
+ res.writeHead(200, { "Content-Type": "application/json" });
104
+ res.end(JSON.stringify(events));
105
+ return;
106
+ }
107
+ // API: Clear History
108
+ if (pathname === "/api/clear" && req.method === "POST") {
109
+ clearTelemetryEvents();
110
+ res.writeHead(200, { "Content-Type": "application/json" });
111
+ res.end(JSON.stringify({ ok: true, message: "History cleared" }));
112
+ return;
113
+ }
114
+ // API: Live Server-Sent Events (SSE)
115
+ if (pathname === "/api/live" && req.method === "GET") {
116
+ res.writeHead(200, {
117
+ "Content-Type": "text/event-stream",
118
+ "Cache-Control": "no-cache, no-transform",
119
+ Connection: "keep-alive",
120
+ });
121
+ // Send initial state
122
+ const initialPayload = JSON.stringify({
123
+ type: "init",
124
+ summary: getTelemetrySummary(),
125
+ events: getTelemetryEvents(50),
126
+ });
127
+ res.write(`data: ${initialPayload}\n\n`);
128
+ // Stream new events as they arrive
129
+ const onEvent = (event) => {
130
+ try {
131
+ const payload = JSON.stringify({
132
+ type: "event",
133
+ event,
134
+ summary: getTelemetrySummary(),
135
+ });
136
+ res.write(`data: ${payload}\n\n`);
137
+ }
138
+ catch {
139
+ // Client disconnected
140
+ }
141
+ };
142
+ telemetryEmitter.on("event", onEvent);
143
+ // Heartbeat ping every 15s to keep connection open
144
+ const interval = setInterval(() => {
145
+ try {
146
+ res.write(": ping\n\n");
147
+ }
148
+ catch {
149
+ clearInterval(interval);
150
+ }
151
+ }, 15000);
152
+ req.on("close", () => {
153
+ telemetryEmitter.off("event", onEvent);
154
+ clearInterval(interval);
155
+ });
156
+ return;
157
+ }
158
+ // Serve HTML Dashboard
159
+ if (pathname === "/" || pathname === "/index.html") {
160
+ if (htmlPath && fs.existsSync(htmlPath)) {
161
+ res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
162
+ fs.createReadStream(htmlPath).pipe(res);
163
+ return;
164
+ }
165
+ // Basic fallback if HTML file is missing
166
+ res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
167
+ res.end(`<!DOCTYPE html><html><body><h1>Jev Live Dashboard</h1><p>Telemetry recorded in ${getTelemetryFilePath()}</p></body></html>`);
168
+ return;
169
+ }
170
+ // 404
171
+ res.writeHead(404, { "Content-Type": "text/plain" });
172
+ res.end("Not Found");
173
+ });
174
+ server.listen(port, () => {
175
+ const url = `http://localhost:${port}`;
176
+ console.log("\n=======================================================");
177
+ console.log(" JEV DEVELOPER HARNESS — LIVE DASHBOARD ");
178
+ console.log("=======================================================\n");
179
+ console.log(`🌐 Live Dashboard: ${url}`);
180
+ console.log(`šŸ“ Telemetry File: ${getTelemetryFilePath()}`);
181
+ console.log(`⚔ Live Stream: Connected via Server-Sent Events (SSE)`);
182
+ console.log("\nPress Ctrl+C to stop the dashboard server.\n");
183
+ if (options.open !== false) {
184
+ openBrowser(url);
185
+ }
186
+ });
187
+ // Graceful shutdown
188
+ const shutdown = () => {
189
+ console.log("\nStopping Jev Live Dashboard...");
190
+ server.close(() => {
191
+ process.exit(0);
192
+ });
193
+ };
194
+ process.on("SIGINT", shutdown);
195
+ process.on("SIGTERM", shutdown);
196
+ }
197
+ //# sourceMappingURL=dashboard.js.map
@@ -0,0 +1 @@
1
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C,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,51 @@
1
+ export interface DoctorOptions {
2
+ initRules?: boolean;
3
+ json?: boolean;
4
+ }
5
+ export interface DoctorReport {
6
+ timestamp: string;
7
+ environment: {
8
+ nodeVersion: string;
9
+ platform: string;
10
+ arch: string;
11
+ harnessVersion: string;
12
+ };
13
+ config: {
14
+ globalConfigPath: string;
15
+ globalConfigExists: boolean;
16
+ provider: string;
17
+ hasApiKey: boolean;
18
+ };
19
+ connection: {
20
+ tested: boolean;
21
+ ok: boolean;
22
+ latencyMs: number;
23
+ provider?: string;
24
+ error?: string;
25
+ };
26
+ mcpAgents: Array<{
27
+ name: string;
28
+ path: string;
29
+ configured: boolean;
30
+ }>;
31
+ rules: {
32
+ hasGeminiMd: boolean;
33
+ hasCursorRules: boolean;
34
+ hasClaudeMd: boolean;
35
+ };
36
+ telemetry: {
37
+ filePath: string;
38
+ eventsCount: number;
39
+ writable: boolean;
40
+ pingEmitted: boolean;
41
+ };
42
+ }
43
+ /**
44
+ * Generate standard instructions for AI coding agents
45
+ */
46
+ export declare function getAgentRuleContent(): string;
47
+ /**
48
+ * Execute comprehensive diagnostic health check
49
+ */
50
+ export declare function runDoctorCommand(options?: DoctorOptions): Promise<DoctorReport>;
51
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE;QACX,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,MAAM,EAAE;QACN,gBAAgB,EAAE,MAAM,CAAC;QACzB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,OAAO,CAAC;KACpB,CAAC;IACF,UAAU,EAAE;QACV,MAAM,EAAE,OAAO,CAAC;QAChB,EAAE,EAAE,OAAO,CAAC;QACZ,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,SAAS,EAAE,KAAK,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC,CAAC;IACH,KAAK,EAAE;QACL,WAAW,EAAE,OAAO,CAAC;QACrB,cAAc,EAAE,OAAO,CAAC;QACxB,WAAW,EAAE,OAAO,CAAC;KACtB,CAAC;IACF,SAAS,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,OAAO,CAAC;QAClB,WAAW,EAAE,OAAO,CAAC;KACtB,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CA+C5C;AAoID;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAoMzF"}
@@ -0,0 +1,380 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { SafeJevClient, noul } from "../shared/typesafe-client.js";
5
+ import { getTelemetryFilePath, getTelemetrySummary, recordTelemetryEvent, } from "../shared/telemetry.js";
6
+ /**
7
+ * Generate standard instructions for AI coding agents
8
+ */
9
+ export function getAgentRuleContent() {
10
+ return `# Jev Developer Harness — Diretrizes de Operação do Agente
11
+
12
+ Este projeto Ć© monitorado e acelerado pelo **Jev Developer Harness** (\`jev-dev-harness\`).
13
+ Como agente de codificação de IA, siga rigorosamente o fluxo de trabalho abaixo para garantir proteção de integridade, economia massiva de tokens e auditoria contínua:
14
+
15
+ ---
16
+
17
+ ### 1. šŸ›”ļø SeguranƧa de Comandos (Tool Call Guard)
18
+ Antes de executar qualquer comando de terminal (\`run_command\`) que crie, modifique, remova arquivos, instale dependĆŖncias, ou acesse redes externas:
19
+ - Execute a validação prévia via MCP (\`jev_guard_check\`) ou via CLI:
20
+ \`\`\`bash
21
+ npx jev-dev guard check -c "<comando>"
22
+ \`\`\`
23
+ - Se o veredito for **BLOCKED** ou exigir confirmação humana, alerte o usuÔrio imediatamente antes de rodar.
24
+
25
+ ---
26
+
27
+ ### 2. šŸŽÆ Otimização CirĆŗrgica de Contexto (Context Ranker)
28
+ Ao iniciar tarefas de implementação que exijam entender o repositório ou antes de ler dezenas de arquivos:
29
+ - Filtre o contexto com o Context Ranker via MCP (\`jev_rank_context\`) ou via CLI:
30
+ \`\`\`bash
31
+ npx jev-dev context rank -t "<descrição da tarefa>" --top 10
32
+ \`\`\`
33
+ - Foque a leitura estritamente nos arquivos ranqueados com maior relevância.
34
+
35
+ ---
36
+
37
+ ### 3. šŸ” Auditoria de Diffs e Patches (Patch Reviewer)
38
+ Antes de concluir alterações de código ou sugerir commits:
39
+ - Audite o diff gerado para detectar riscos de regressão, arquivos fora de escopo ou credenciais expostas via MCP (\`jev_review_patch\`) ou via CLI:
40
+ \`\`\`bash
41
+ npx jev-dev patch review -t "<descrição da tarefa>" --staged
42
+ \`\`\`
43
+
44
+ ---
45
+
46
+ ### 4. ⚔ Bloco de Telemetria e Eficiência
47
+ Ao concluir com sucesso cada tarefa de desenvolvimento de software, apresente o bloco de resumo de eficiĆŖncia ao final da sua resposta:
48
+
49
+ \`\`\`markdown
50
+ ### ⚔ Eficiência Jev
51
+ - **Contexto Otimizado:** [X] arquivos selecionados cirurgicamente de [Y] analisados ([Z]% de redução).
52
+ - **Economia Estimada:** ~[N] tokens economizados nesta tarefa (~$[V]).
53
+ - **SeguranƧa & Velocidade:** Comandos e diffs auditados pelo Jev System One (<1s).
54
+ \`\`\`
55
+ `;
56
+ }
57
+ /**
58
+ * Audit all IDE and agent MCP configurations
59
+ */
60
+ function checkMcpConfigs() {
61
+ const home = os.homedir();
62
+ const results = [];
63
+ // 1. Codex Desktop
64
+ const codexPath = path.join(home, ".codex", "config.toml");
65
+ let codexOk = false;
66
+ if (fs.existsSync(codexPath)) {
67
+ try {
68
+ const content = fs.readFileSync(codexPath, "utf8");
69
+ codexOk = content.includes("jev-dev") || content.includes("jev-dev-harness") || content.includes("jev-mcp");
70
+ }
71
+ catch { }
72
+ }
73
+ results.push({ name: "Codex Desktop", path: codexPath, configured: codexOk });
74
+ // 2. Antigravity IDE
75
+ const antigravityPath = path.join(home, ".gemini", "antigravity", "mcp_config.json");
76
+ let antigravityOk = false;
77
+ if (fs.existsSync(antigravityPath)) {
78
+ try {
79
+ const content = fs.readFileSync(antigravityPath, "utf8");
80
+ antigravityOk = content.includes("jev-dev");
81
+ }
82
+ catch { }
83
+ }
84
+ results.push({ name: "Antigravity IDE", path: antigravityPath, configured: antigravityOk });
85
+ // 3. Claude Desktop
86
+ let claudePath = "";
87
+ if (process.platform === "win32") {
88
+ claudePath = path.join(process.env.APPDATA || path.join(home, "AppData", "Roaming"), "Claude", "claude_desktop_config.json");
89
+ }
90
+ else if (process.platform === "darwin") {
91
+ claudePath = path.join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json");
92
+ }
93
+ else {
94
+ claudePath = path.join(home, ".config", "Claude", "claude_desktop_config.json");
95
+ }
96
+ let claudeOk = false;
97
+ if (fs.existsSync(claudePath)) {
98
+ try {
99
+ const content = fs.readFileSync(claudePath, "utf8");
100
+ claudeOk = content.includes("jev-dev");
101
+ }
102
+ catch { }
103
+ }
104
+ results.push({ name: "Claude Desktop", path: claudePath, configured: claudeOk });
105
+ // 4. Cursor
106
+ const cursorPath = path.join(home, ".cursor", "mcp.json");
107
+ let cursorOk = false;
108
+ if (fs.existsSync(cursorPath)) {
109
+ try {
110
+ const content = fs.readFileSync(cursorPath, "utf8");
111
+ cursorOk = content.includes("jev-dev");
112
+ }
113
+ catch { }
114
+ }
115
+ results.push({ name: "Cursor", path: cursorPath, configured: cursorOk });
116
+ // 5. Windsurf
117
+ const windsurfPath = path.join(home, ".codeium", "windsurf", "mcp_config.json");
118
+ let windsurfOk = false;
119
+ if (fs.existsSync(windsurfPath)) {
120
+ try {
121
+ const content = fs.readFileSync(windsurfPath, "utf8");
122
+ windsurfOk = content.includes("jev-dev");
123
+ }
124
+ catch { }
125
+ }
126
+ results.push({ name: "Windsurf", path: windsurfPath, configured: windsurfOk });
127
+ // 6. Trae
128
+ const traePath = path.join(home, ".trae", "mcp.json");
129
+ let traeOk = false;
130
+ if (fs.existsSync(traePath)) {
131
+ try {
132
+ const content = fs.readFileSync(traePath, "utf8");
133
+ traeOk = content.includes("jev-dev");
134
+ }
135
+ catch { }
136
+ }
137
+ results.push({ name: "Trae", path: traePath, configured: traeOk });
138
+ // 7. VSCode Cline
139
+ let clinePath = "";
140
+ if (process.platform === "win32") {
141
+ clinePath = path.join(process.env.APPDATA || path.join(home, "AppData", "Roaming"), "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json");
142
+ }
143
+ else if (process.platform === "darwin") {
144
+ clinePath = path.join(home, "Library", "Application Support", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json");
145
+ }
146
+ else {
147
+ clinePath = path.join(home, ".config", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings", "cline_mcp_settings.json");
148
+ }
149
+ let clineOk = false;
150
+ if (fs.existsSync(clinePath)) {
151
+ try {
152
+ const content = fs.readFileSync(clinePath, "utf8");
153
+ clineOk = content.includes("jev-dev");
154
+ }
155
+ catch { }
156
+ }
157
+ results.push({ name: "VSCode (Cline)", path: clinePath, configured: clineOk });
158
+ // 8. VSCode Roo Code
159
+ let rooPath = "";
160
+ if (process.platform === "win32") {
161
+ rooPath = path.join(process.env.APPDATA || path.join(home, "AppData", "Roaming"), "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json");
162
+ }
163
+ else if (process.platform === "darwin") {
164
+ rooPath = path.join(home, "Library", "Application Support", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json");
165
+ }
166
+ else {
167
+ rooPath = path.join(home, ".config", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings", "cline_mcp_settings.json");
168
+ }
169
+ let rooOk = false;
170
+ if (fs.existsSync(rooPath)) {
171
+ try {
172
+ const content = fs.readFileSync(rooPath, "utf8");
173
+ rooOk = content.includes("jev-dev");
174
+ }
175
+ catch { }
176
+ }
177
+ results.push({ name: "VSCode (Roo Code)", path: rooPath, configured: rooOk });
178
+ // 9. Continue.dev
179
+ const continuePath = path.join(home, ".continue", "config.json");
180
+ let continueOk = false;
181
+ if (fs.existsSync(continuePath)) {
182
+ try {
183
+ const content = fs.readFileSync(continuePath, "utf8");
184
+ continueOk = content.includes("jev-dev");
185
+ }
186
+ catch { }
187
+ }
188
+ results.push({ name: "VSCode (Continue)", path: continuePath, configured: continueOk });
189
+ return results;
190
+ }
191
+ /**
192
+ * Execute comprehensive diagnostic health check
193
+ */
194
+ export async function runDoctorCommand(options = {}) {
195
+ const cwd = process.cwd();
196
+ const home = os.homedir();
197
+ // If user requested --init-rules, generate them now
198
+ if (options.initRules) {
199
+ const ruleContent = getAgentRuleContent();
200
+ const githubDir = path.join(cwd, ".github");
201
+ if (!fs.existsSync(githubDir)) {
202
+ try {
203
+ fs.mkdirSync(githubDir, { recursive: true });
204
+ }
205
+ catch { }
206
+ }
207
+ const targets = [
208
+ { name: "GEMINI.md (Antigravity)", file: path.join(cwd, "GEMINI.md") },
209
+ { name: "CLAUDE.md (Claude Code)", file: path.join(cwd, "CLAUDE.md") },
210
+ { name: ".cursorrules (Cursor)", file: path.join(cwd, ".cursorrules") },
211
+ { name: "copilot-instructions.md (GitHub Copilot / VSCode)", file: path.join(githubDir, "copilot-instructions.md") },
212
+ ];
213
+ console.log("\nšŸ“ Initializing AI agent rule files in current workspace...\n");
214
+ for (const t of targets) {
215
+ try {
216
+ fs.writeFileSync(t.file, ruleContent, "utf8");
217
+ console.log(` āœ“ Created ${t.name} at ${t.file}`);
218
+ }
219
+ catch (err) {
220
+ console.error(` āŒ Failed to create ${t.name}: ${err.message}`);
221
+ }
222
+ }
223
+ console.log("\n✨ Agent rule files created successfully!\n");
224
+ }
225
+ // 1. Environment
226
+ let harnessVersion = "0.1.4";
227
+ try {
228
+ const pkgPath = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, "$1")), "../../package.json");
229
+ if (fs.existsSync(pkgPath)) {
230
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
231
+ harnessVersion = pkg.version || harnessVersion;
232
+ }
233
+ }
234
+ catch { }
235
+ const environment = {
236
+ nodeVersion: process.version,
237
+ platform: process.platform,
238
+ arch: process.arch,
239
+ harnessVersion,
240
+ };
241
+ // 2. Configuration & API
242
+ const globalConfigPath = path.join(home, ".jev-dev", "config.json");
243
+ let globalConfigExists = false;
244
+ let provider = "offline";
245
+ let hasApiKey = false;
246
+ if (fs.existsSync(globalConfigPath)) {
247
+ globalConfigExists = true;
248
+ try {
249
+ const cfg = JSON.parse(fs.readFileSync(globalConfigPath, "utf8"));
250
+ provider = cfg.provider || "typesafe";
251
+ hasApiKey = Boolean(cfg.apiKey || process.env.TYPESAFE_API_KEY || process.env.OPENROUTER_API_KEY);
252
+ }
253
+ catch { }
254
+ }
255
+ else {
256
+ hasApiKey = Boolean(process.env.TYPESAFE_API_KEY || process.env.OPENROUTER_API_KEY);
257
+ if (process.env.OPENROUTER_API_KEY)
258
+ provider = "openrouter";
259
+ else if (process.env.TYPESAFE_API_KEY)
260
+ provider = "typesafe";
261
+ }
262
+ // 3. Live Connection Test
263
+ let connectionOk = false;
264
+ let connectionLatency = 0;
265
+ let connectionError;
266
+ const client = new SafeJevClient({ timeoutMs: 3000 });
267
+ const startTime = Date.now();
268
+ try {
269
+ const pingResult = await client.systemOne({ ping: true, task: "health_check" }, { is_healthy: noul("Is the Jev developer harness operating normally?") });
270
+ connectionLatency = Date.now() - startTime;
271
+ if (pingResult.ok) {
272
+ connectionOk = true;
273
+ }
274
+ else {
275
+ connectionError = pingResult.reason || "System One returned fallback";
276
+ }
277
+ }
278
+ catch (err) {
279
+ connectionLatency = Date.now() - startTime;
280
+ connectionError = err.message;
281
+ }
282
+ // 4. MCP Agents
283
+ const mcpAgents = checkMcpConfigs();
284
+ // 5. Rules in current directory
285
+ const hasGeminiMd = fs.existsSync(path.join(cwd, "GEMINI.md")) || fs.existsSync(path.join(cwd, "AGENTS.md"));
286
+ const hasCursorRules = fs.existsSync(path.join(cwd, ".cursorrules")) || fs.existsSync(path.join(cwd, ".cursor", "rules"));
287
+ const hasClaudeMd = fs.existsSync(path.join(cwd, "CLAUDE.md"));
288
+ // 6. Telemetry & Emit Ping
289
+ const telemetryPath = getTelemetryFilePath();
290
+ const summary = getTelemetrySummary();
291
+ let pingEmitted = false;
292
+ try {
293
+ recordTelemetryEvent({
294
+ type: "guard_check",
295
+ command: "jev-dev doctor --ping",
296
+ category: "read-only",
297
+ allowed: true,
298
+ riskLevel: "low",
299
+ reason: "Diagnostic health check ping from jev-dev doctor",
300
+ latencyMs: connectionLatency || 1,
301
+ });
302
+ pingEmitted = true;
303
+ }
304
+ catch { }
305
+ const report = {
306
+ timestamp: new Date().toISOString(),
307
+ environment,
308
+ config: {
309
+ globalConfigPath,
310
+ globalConfigExists,
311
+ provider,
312
+ hasApiKey,
313
+ },
314
+ connection: {
315
+ tested: true,
316
+ ok: connectionOk,
317
+ latencyMs: connectionLatency,
318
+ provider,
319
+ error: connectionError,
320
+ },
321
+ mcpAgents,
322
+ rules: {
323
+ hasGeminiMd,
324
+ hasCursorRules,
325
+ hasClaudeMd,
326
+ },
327
+ telemetry: {
328
+ filePath: telemetryPath,
329
+ eventsCount: summary.totalEvents + (pingEmitted ? 1 : 0),
330
+ writable: fs.existsSync(path.dirname(telemetryPath)),
331
+ pingEmitted,
332
+ },
333
+ };
334
+ if (options.json) {
335
+ console.log(JSON.stringify(report, null, 2));
336
+ return report;
337
+ }
338
+ // Terminal UI formatting
339
+ console.log("\n" + "=".repeat(65));
340
+ console.log(" šŸ”® JEV DEVELOPER HARNESS DOCTOR ");
341
+ console.log("=".repeat(65) + "\n");
342
+ console.log("--- šŸ’» ENVIRONMENT ---");
343
+ console.log(` Node.js: ${environment.nodeVersion}`);
344
+ console.log(` Platform: ${environment.platform} (${environment.arch})`);
345
+ console.log(` Harness Version: v${environment.harnessVersion}\n`);
346
+ console.log("--- šŸ”‘ CONFIGURATION & AI CONNECTIVITY ---");
347
+ console.log(` Global Config: ${globalConfigExists ? `āœ“ Found (${globalConfigPath})` : `āœ— Not found (run 'jev-dev setup')`}`);
348
+ console.log(` Active Provider: ${provider.toUpperCase()}`);
349
+ console.log(` API Key: ${hasApiKey ? "āœ“ Configured" : "⚠ Not detected (running in deterministic fallback mode)"}`);
350
+ if (connectionOk) {
351
+ console.log(` Live AI Ping: āœ“ SUCCESS (Latency: ${connectionLatency}ms, provider: ${provider})\n`);
352
+ }
353
+ else {
354
+ console.log(` Live AI Ping: ⚠ Offline/Fallback (${connectionError || "Local deterministic engine active"})\n`);
355
+ }
356
+ console.log("--- šŸ¤– AGENT MCP INTEGRATIONS ---");
357
+ for (const agent of mcpAgents) {
358
+ const status = agent.configured ? "āœ“ Configured" : "ā—‹ Not detected / Not configured";
359
+ console.log(` ${agent.name.padEnd(18)}: ${status}`);
360
+ }
361
+ console.log("");
362
+ console.log("--- šŸ“œ AGENT INSTRUCTION RULES (Current Directory) ---");
363
+ console.log(` Antigravity (GEMINI.md) : ${hasGeminiMd ? "āœ“ Present" : "ā—‹ Missing (run 'jev-dev doctor --init-rules')"}`);
364
+ console.log(` Cursor (.cursorrules) : ${hasCursorRules ? "āœ“ Present" : "ā—‹ Missing (run 'jev-dev doctor --init-rules')"}`);
365
+ console.log(` Claude Code (CLAUDE.md) : ${hasClaudeMd ? "āœ“ Present" : "ā—‹ Missing (run 'jev-dev doctor --init-rules')"}\n`);
366
+ console.log("--- šŸ“Š TELEMETRY & LIVE DASHBOARD ---");
367
+ console.log(` Telemetry Store: ${telemetryPath} (${report.telemetry.eventsCount} events recorded)`);
368
+ console.log(` Live Ping Event: ${pingEmitted ? "āœ“ Emitted (live feed updated on dashboard)" : "āœ— Failed"}`);
369
+ console.log(` Web Dashboard: Run 'jev-dev dashboard' to view live metrics in browser\n`);
370
+ console.log("=".repeat(65));
371
+ if (!hasGeminiMd && !hasCursorRules && !hasClaudeMd) {
372
+ console.log("\nšŸ’” TIP: Run 'jev-dev doctor --init-rules' to automatically instruct your");
373
+ console.log(" AI agent to use Jev tools and print efficiency summaries on every prompt!\n");
374
+ }
375
+ else {
376
+ console.log("\nšŸš€ All systems operational! Your AI agent is actively protected by Jev.\n");
377
+ }
378
+ return report;
379
+ }
380
+ //# sourceMappingURL=doctor.js.map