Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ import { detectAuthOptions } from "./utils/auth-detect.js";
import { authConfigPath, loadAuthConfig, saveAuthConfig } from "./utils/auth-config.js";
import { formatDetectionBlock, hasAnyAuth, promptAuthChoice } from "./utils/auth-prompt.js";
import type { AuthMode, WorkspaceInfo } from "./types.js";
import { AXME_CODE_DIR } from "./types.js";
import { AXME_CODE_DIR, AXME_CODE_VERSION } from "./types.js";

const args = process.argv.slice(2);
const command = args[0];

if (command === "--version" || command === "-v") {
console.log(AXME_CODE_VERSION);
process.exit(0);
}

// --- CLAUDE.md templates ---

const PENDING_AUDITS_GUIDANCE = `
Expand Down
66 changes: 40 additions & 26 deletions src/tools/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { bundlesToDecisions, bundlesToMemories, bundlesToDeployChecklists, apply
import { AXME_CODE_DIR, DEFAULT_PROJECT_CONFIG } from "../types.js";
import { addCost, zeroCost, type CostInfo } from "../utils/cost-extractor.js";
import { atomicWrite, removeFile } from "../storage/engine.js";
import { findClaudePath } from "../utils/agent-options.js";
import yaml from "js-yaml";

export interface InitResult {
Expand Down Expand Up @@ -142,39 +143,52 @@ export async function initProjectWithLLM(projectPath: string, opts?: {
// --- LLM scanners in PARALLEL ---
const log = opts?.onProgress ?? (() => {});
const projectName = projectPath.split("/").pop();
log(` [${projectName}] LLM scanning (oracle + decisions + safety + deploy)...`);

let oracleLlm = false;
let oracleFiles = 0;
let scanDecisionCount = 0;
let safetyLlm = false;
let safetySummary = "";

const scanners = await Promise.allSettled([
// Oracle scan
(async () => {
if (oracleExists(projectPath)) return { type: "oracle" as const, skipped: true };
const { runOracleScan } = await import("../agents/scanners/oracle.js");
return { type: "oracle" as const, result: await runOracleScan({ projectPath, workspaceMode: opts?.workspaceMode }) };
})(),
// Decision scan — pass existing decisions (from presets) so scanner skips same-topic
(async () => {
const { runDecisionScan } = await import("../agents/scanners/decision.js");
const existing = listDecisions(projectPath);
return { type: "decision" as const, result: await runDecisionScan({ projectPath, existingDecisions: existing }) };
})(),
// Safety scan
(async () => {
if (safetyExists(projectPath)) return { type: "safety" as const, skipped: true };
const { runSafetyScan } = await import("../agents/scanners/safety.js");
return { type: "safety" as const, result: await runSafetyScan({ projectPath }) };
})(),
// Deploy scan
(async () => {
const { runDeployScan } = await import("../agents/scanners/deploy.js");
return { type: "deploy" as const, result: await runDeployScan({ projectPath }) };
})(),
]);
// Pre-flight: require the `claude` CLI to be installed. Without it the Agent
// SDK bundled inside us crashes on `fileURLToPath(undefined)` before it can
// reach the user's OAuth/API key. Skip cleanly and surface a friendly error
// rather than leaking the SDK stack trace.
const claudePath = findClaudePath();
const scanners = claudePath
? await (async () => {
log(` [${projectName}] LLM scanning (oracle + decisions + safety + deploy)...`);
return Promise.allSettled([
// Oracle scan
(async () => {
if (oracleExists(projectPath)) return { type: "oracle" as const, skipped: true };
const { runOracleScan } = await import("../agents/scanners/oracle.js");
return { type: "oracle" as const, result: await runOracleScan({ projectPath, workspaceMode: opts?.workspaceMode }) };
})(),
// Decision scan — pass existing decisions (from presets) so scanner skips same-topic
(async () => {
const { runDecisionScan } = await import("../agents/scanners/decision.js");
const existing = listDecisions(projectPath);
return { type: "decision" as const, result: await runDecisionScan({ projectPath, existingDecisions: existing }) };
})(),
// Safety scan
(async () => {
if (safetyExists(projectPath)) return { type: "safety" as const, skipped: true };
const { runSafetyScan } = await import("../agents/scanners/safety.js");
return { type: "safety" as const, result: await runSafetyScan({ projectPath }) };
})(),
// Deploy scan
(async () => {
const { runDeployScan } = await import("../agents/scanners/deploy.js");
return { type: "deploy" as const, result: await runDeployScan({ projectPath }) };
})(),
]);
})()
: [];
if (!claudePath) {
log(` [${projectName}] Claude Code CLI not found on PATH — skipping LLM scanners (install with: npm install -g @anthropic-ai/claude-code)`);
errors.push("Claude Code CLI not installed — LLM scanners skipped, using deterministic fallback");
}

// Process results
log(` [${projectName}] Scanners complete, processing results...`);
Expand Down