@krishivpb60/aether-ai-cli 1.3.2 → 1.3.3

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.
package/HIGHLIGHTS.md CHANGED
@@ -1,3 +1,13 @@
1
+ # Aether CLI v1.3.3 Highlights
2
+ - **Codex & Claude Code Slash Commands**: Added 7 new advanced developer experience (DX) commands:
3
+ - `/review`: Analyze staged/unstaged git changes and stream an AI-powered code review.
4
+ - `/diagnose [cmd]`: Run tests/builds and automatically debug any errors.
5
+ - `/explain <file>`: Explains design flow and patterns in code.
6
+ - `/refactor <file>`: Rewrites a target file to optimize it.
7
+ - `/bug <file>`: Scans a file to detect logical edge case failures.
8
+ - `/doc <file>`: Automatically writes documentation, inline comments, or JSDoc.
9
+ - `/translate <file> <lang>`: AI-translates file code into another target language.
10
+
1
11
  # Aether CLI v1.3.2 Highlights
2
12
  - **Manual Updater `/update`**: Added a new slash command `/update` to manually check the registry and force-upgrade Aether CLI to the latest version immediately, bypassing the 24-hour cache throttle.
3
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krishivpb60/aether-ai-cli",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Aether Core AI — A cyberpunk command-line AI assistant with multi-mode reasoning, 12-node failover mesh, file context injection, and offline fallbacks.",
5
5
  "main": "src/cli.js",
6
6
  "bin": {
package/src/chat.js CHANGED
@@ -47,6 +47,7 @@ import { runMainframeHack } from "./ai/fallback.js";
47
47
  import { AGENT_INSTRUCTIONS } from "./agent.js";
48
48
  import { checkForUpdates } from "./updater.js";
49
49
  import { getSessionTokenStats, getBreakdownByModel, resetSessionTokenStats } from "./ai/tokens.js";
50
+ import { getGitDiff } from "./git.js";
50
51
 
51
52
 
52
53
 
@@ -136,7 +137,8 @@ export async function startChat(options = {}) {
136
137
  "/help", "/mode", "/modes", "/attach", "/files", "/clear",
137
138
  "/providers", "/export", "/status", "/copy", "/exit", "/quit",
138
139
  "/theme", "/themes", "/history-clear", "/game", "/abort", "/cmd", "/write",
139
- "/commit", "/run", "/history", "/autopilot", "/tokens", "/update"
140
+ "/commit", "/run", "/history", "/autopilot", "/tokens", "/update",
141
+ "/review", "/diagnose", "/explain", "/refactor", "/bug", "/doc", "/translate"
140
142
  ];
141
143
  const customCmds = aiConfig.CUSTOM_COMMANDS || {};
142
144
  const commands = [...builtIn, ...Object.keys(customCmds)];
@@ -424,7 +426,8 @@ export async function startChat(options = {}) {
424
426
  "/providers", "/export", "/status", "/copy", "/exit", "/quit",
425
427
  "/theme", "/themes", "/history-clear", "/game", "/abort", "/cmd",
426
428
  "/guess", "/write", "/commit", "/run", "/history", "/autopilot", "/tokens",
427
- "/update"
429
+ "/update", "/review", "/diagnose", "/explain", "/refactor", "/bug", "/doc",
430
+ "/translate"
428
431
  ];
429
432
 
430
433
  const customCmds = aiConfig.CUSTOM_COMMANDS || {};
@@ -521,6 +524,22 @@ async function handleCommand(input, ctx) {
521
524
  console.log("");
522
525
  break;
523
526
 
527
+ case "/review":
528
+ await handleReviewCommand(ctx);
529
+ break;
530
+
531
+ case "/diagnose":
532
+ await handleDiagnoseCommand(args, ctx);
533
+ break;
534
+
535
+ case "/explain":
536
+ case "/refactor":
537
+ case "/bug":
538
+ case "/doc":
539
+ case "/translate":
540
+ await handleFileAICommand(cmd, args, ctx);
541
+ break;
542
+
524
543
  case "/theme":
525
544
  await handleThemeSwitch(args);
526
545
  break;
@@ -620,6 +639,13 @@ function showHelp(aiConfig) {
620
639
  console.log(keyValue("/write <filename>", "Extract last code block and save to file"));
621
640
  console.log(keyValue("/commit", "Generate conventional commit message and commit changes"));
622
641
  console.log(keyValue("/run <command>", "Execute a shell command interactively"));
642
+ console.log(keyValue("/review", "Run git diff and stream an AI code review"));
643
+ console.log(keyValue("/diagnose [cmd]", "Run build/tests and AI-debug any errors"));
644
+ console.log(keyValue("/explain <file>", "AI-explain the design and logic of a file"));
645
+ console.log(keyValue("/refactor <file>", "AI-refactor the code of a target file"));
646
+ console.log(keyValue("/bug <file>", "AI-audit a file to find potential logic bugs"));
647
+ console.log(keyValue("/doc <file>", "AI-generate documentation/docstrings for a file"));
648
+ console.log(keyValue("/translate <file> <lang>", "AI-translate code of a file to another language"));
623
649
  console.log(keyValue("/exit", "End session"));
624
650
 
625
651
  if (aiConfig && aiConfig.CUSTOM_COMMANDS) {
@@ -1402,3 +1428,190 @@ async function handleTokensDisplay(ctx) {
1402
1428
  console.log(" " + colors.accent("Total Tokens:") + colors.text(` Prompt: ${stats.prompt.toLocaleString()} | Completion: ${stats.completion.toLocaleString()} | Sum: `) + colors.brand.bold(stats.total.toLocaleString()));
1403
1429
  console.log(separator("━") + "\n");
1404
1430
  }
1431
+
1432
+ /**
1433
+ * Streams an AI query prompt and prints telemetry details at the end.
1434
+ */
1435
+ async function executeAISpecialCommand(prompt, specialLabel, ctx) {
1436
+ const systemPrompt = ctx.currentMode.systemPrompt + "\n" + AGENT_INSTRUCTIONS;
1437
+ let hasStarted = false;
1438
+ let responseText = "";
1439
+ const queryStartTime = Date.now();
1440
+ let firstTokenTime = 0;
1441
+
1442
+ const onToken = (token) => {
1443
+ if (!hasStarted) {
1444
+ hasStarted = true;
1445
+ firstTokenTime = Date.now();
1446
+ process.stdout.write("\n" + label.aether + " " + colors.accent(specialLabel) + "\n" + separator("─") + "\n\n");
1447
+ }
1448
+ process.stdout.write(colors.success(token));
1449
+ responseText += token;
1450
+ };
1451
+
1452
+ const result = await routePrompt(prompt, systemPrompt, ctx.aiConfig, onToken);
1453
+ console.log("\n");
1454
+
1455
+ const elapsedSec = ((Date.now() - queryStartTime) / 1000).toFixed(1);
1456
+ let speedText = "";
1457
+ if (firstTokenTime > 0) {
1458
+ const streamElapsed = (Date.now() - firstTokenTime) / 1000;
1459
+ if (streamElapsed > 0.05) {
1460
+ const estimatedTokens = Math.max(1, Math.round(responseText.length / 4));
1461
+ const tps = (estimatedTokens / streamElapsed).toFixed(1);
1462
+ speedText = ` • ${tps} tok/s`;
1463
+ }
1464
+ }
1465
+
1466
+ const showTokens = ctx.aiConfig.SHOW_TOKENS !== "false";
1467
+ let tokensText = "";
1468
+ if (showTokens && result.usage) {
1469
+ const { promptTokens, completionTokens } = result.usage;
1470
+ tokensText = ` • ${promptTokens.toLocaleString()} in / ${completionTokens.toLocaleString()} out tokens`;
1471
+ }
1472
+
1473
+ console.log(separator("─"));
1474
+ console.log(
1475
+ " " + colors.dim(`Node ${result.node} • ${result.provider}`) +
1476
+ (result.model ? colors.dim(` • ${result.model}`) : "") +
1477
+ colors.dim(` • ${elapsedSec}s${speedText}`) +
1478
+ colors.dim(tokensText)
1479
+ );
1480
+ console.log("");
1481
+ }
1482
+
1483
+ /**
1484
+ * Handler for the /review command (git diff analysis).
1485
+ */
1486
+ async function handleReviewCommand(ctx) {
1487
+ console.log("\n" + label.system + " " + colors.muted("Running git diff to fetch repository changes..."));
1488
+ try {
1489
+ const { diff, isStaged } = await getGitDiff();
1490
+ if (!diff) {
1491
+ console.log(label.system + " " + colors.success("✓ No changes detected in the repository to review.\n"));
1492
+ return;
1493
+ }
1494
+
1495
+ const specialLabel = `Reviewing ${isStaged ? "staged" : "unstaged"} changes...`;
1496
+ const prompt = `Review the following git diff. Identify potential bugs, logical issues, security concerns, performance problems, and recommend optimization or code cleanup. Keep it concise, practical, and highly technical:\n\n\`\`\`diff\n${diff}\n\`\`\``;
1497
+
1498
+ await executeAISpecialCommand(prompt, specialLabel, ctx);
1499
+ } catch (err) {
1500
+ console.log(label.system + " " + colors.danger(`Error: ${err.message}\n`));
1501
+ }
1502
+ }
1503
+
1504
+ /**
1505
+ * Handler for the /diagnose command (build & test diagnostics execution).
1506
+ */
1507
+ async function handleDiagnoseCommand(args, ctx) {
1508
+ const defaultCmd = ctx.aiConfig.DIAGNOSE_CMD || "npm test";
1509
+ const cmdToRun = args.join(" ").trim() || defaultCmd;
1510
+
1511
+ console.log("\n" + label.system + " " + colors.muted(`Running diagnostics command: "${cmdToRun}"...`));
1512
+
1513
+ const spinner = createSpinner("Executing diagnostics").start();
1514
+ try {
1515
+ const { exec } = await import("node:child_process");
1516
+ const { promisify } = await import("node:util");
1517
+ const execAsync = promisify(exec);
1518
+ await execAsync(cmdToRun);
1519
+ spinner.succeed("Diagnostics complete!");
1520
+ console.log("\n" + label.system + " " + colors.success("✓ Diagnostics clean! Build and tests passed successfully.\n"));
1521
+ } catch (err) {
1522
+ spinner.fail("Diagnostics failed!");
1523
+
1524
+ const output = (err.stdout || "") + "\n" + (err.stderr || "");
1525
+ console.log("\n" + label.system + " " + colors.warning(`Diagnostics returned exit code ${err.code}.`));
1526
+ console.log(colors.muted("Analyzing compiler/test output logs...\n"));
1527
+
1528
+ const prompt = `The diagnostics command "${cmdToRun}" failed with exit code ${err.code}. Analyze the following stdout and stderr logs to determine the root cause, identify the files/lines causing the failure, and provide a step-by-step resolution and debugging plan:\n\n\`\`\`\n${output.slice(0, 15000)}\n\`\`\``;
1529
+
1530
+ await executeAISpecialCommand(prompt, "Analyzing diagnostics logs...", ctx);
1531
+ }
1532
+ }
1533
+
1534
+ /**
1535
+ * Handler for file analysis commands: /explain, /refactor, /bug, /doc, /translate.
1536
+ */
1537
+ async function handleFileAICommand(cmdName, args, ctx) {
1538
+ const filePath = args[0];
1539
+ if (!filePath) {
1540
+ console.log("\n" + label.system + " " + colors.warning(`Usage: ${cmdName} <file_path>\n`));
1541
+ return;
1542
+ }
1543
+
1544
+ // Resolve path
1545
+ const resolvedPath = resolve(process.cwd(), filePath);
1546
+
1547
+ // Verify path is inside the workspace
1548
+ const { isInsideWorkspace } = await import("./agent.js");
1549
+ if (!isInsideWorkspace(resolvedPath)) {
1550
+ console.log("\n" + label.system + " " + colors.danger("Error: Path is outside the current workspace sandbox.\n"));
1551
+ return;
1552
+ }
1553
+
1554
+ if (!existsSync(resolvedPath)) {
1555
+ console.log("\n" + label.system + " " + colors.danger(`Error: File does not exist at "${filePath}"\n`));
1556
+ return;
1557
+ }
1558
+
1559
+ const stat = statSync(resolvedPath);
1560
+ if (stat.isDirectory()) {
1561
+ console.log("\n" + label.system + " " + colors.danger(`Error: "${filePath}" is a directory. File path required.\n`));
1562
+ return;
1563
+ }
1564
+
1565
+ if (stat.size > 150 * 1024) { // 150KB limit
1566
+ console.log("\n" + label.system + " " + colors.warning(`Warning: File "${filePath}" is too large (${Math.round(stat.size / 1024)}KB). Limits are 150KB to protect context limit.\n`));
1567
+ return;
1568
+ }
1569
+
1570
+ // Read file content
1571
+ let content;
1572
+ try {
1573
+ const { parseFile } = await import("./file-parser.js");
1574
+ const parsed = await parseFile(resolvedPath);
1575
+ content = parsed.content;
1576
+ } catch (err) {
1577
+ console.log("\n" + label.system + " " + colors.danger(`Error parsing file: ${err.message}\n`));
1578
+ return;
1579
+ }
1580
+
1581
+ let prompt = "";
1582
+ let labelText = "";
1583
+
1584
+ switch (cmdName.toLowerCase()) {
1585
+ case "/explain":
1586
+ labelText = `Explaining ${filePath}...`;
1587
+ prompt = `Explain the architecture, design patterns, logic flow, and purpose of the following code. Be clear, technical, and structured:\n\n\`\`\`\n${content}\n\`\`\``;
1588
+ break;
1589
+ case "/refactor":
1590
+ labelText = `Refactoring ${filePath}...`;
1591
+ prompt = `Suggest refactoring improvements for the following code. Focus on clean code design principles, optimization, readability, reducing complexity, and fixing potential logic bugs. Return both the refactored code block and explanations:\n\n\`\`\`\n${content}\n\`\`\``;
1592
+ break;
1593
+ case "/bug":
1594
+ labelText = `Auditing bugs in ${filePath}...`;
1595
+ prompt = `Perform a thorough static analysis and code review of the following code. Identify potential logical bugs, race conditions, edge case failures, performance bottlenecks, and security hazards. Suggest fixes:\n\n\`\`\`\n${content}\n\`\`\``;
1596
+ break;
1597
+ case "/doc":
1598
+ labelText = `Generating documentation for ${filePath}...`;
1599
+ prompt = `Generate comprehensive API documentation, JSDoc/docstrings, and comments for the following code. Ensure code parameters, return values, and types are documented:\n\n\`\`\`\n${content}\n\`\`\``;
1600
+ break;
1601
+ case "/translate":
1602
+ const targetLang = args[1];
1603
+ if (!targetLang) {
1604
+ console.log("\n" + label.system + " " + colors.warning(`Usage: /translate <file_path> <target_language>\n`));
1605
+ return;
1606
+ }
1607
+ labelText = `Translating ${filePath} to ${targetLang}...`;
1608
+ prompt = `Translate the following code into ${targetLang}. Return a clean, syntactically correct, and beautifully structured code block of the translated code:\n\n\`\`\`\n${content}\n\`\`\``;
1609
+ break;
1610
+ }
1611
+
1612
+ try {
1613
+ await executeAISpecialCommand(prompt, labelText, ctx);
1614
+ } catch (err) {
1615
+ console.log("\n" + label.system + " " + colors.danger(`Error: ${err.message}\n`));
1616
+ }
1617
+ }
package/src/config.js CHANGED
@@ -176,7 +176,7 @@ export function isValidConfigKey(key) {
176
176
  const allowedSpecialKeys = [
177
177
  "THEME", "CUSTOM_COMMANDS", "AUTOPILOT",
178
178
  "AUTO_UPDATE", "SHOW_HIGHLIGHTS", "LAST_UPDATE_CHECK", "LAST_NOTIFIED_VERSION",
179
- "SHOW_TOKENS"
179
+ "SHOW_TOKENS", "DIAGNOSE_CMD"
180
180
  ];
181
181
  if (upper.endsWith("_API_KEY") || upper.endsWith("_API_KEYS") || upper.endsWith("_MODEL") || allowedSpecialKeys.includes(upper)) {
182
182
  return true;
@@ -0,0 +1,10 @@
1
+ import { test } from "node:test";
2
+ import assert from "node:assert";
3
+ import { isValidConfigKey } from "../src/config.js";
4
+
5
+ test("Developer Experience (DX) Commands Suite", async (t) => {
6
+ await t.test("isValidConfigKey whitelists DIAGNOSE_CMD correctly", () => {
7
+ assert.strictEqual(isValidConfigKey("DIAGNOSE_CMD"), true);
8
+ assert.strictEqual(isValidConfigKey("diagnose_cmd"), true);
9
+ });
10
+ });