From 7f2f9849ba5a68192d19f7508508a0389da0a989 Mon Sep 17 00:00:00 2001 From: geobelsky Date: Wed, 8 Apr 2026 13:31:02 +0000 Subject: [PATCH] fix: revert to binary commands, add setup --force, add npm publish CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revert npx-based commands back to binary "axme-code" for .mcp.json, templates/mcp.json, and hook commands in cli.ts. Plugin marketplace uses npm source type which installs binary globally — no npx needed. Changes: - .mcp.json, templates/mcp.json: "axme-code serve" (was npx) - src/cli.ts hooks: "axme-code hook ..." (was npx) - src/cli.ts setup: --force flag for re-scan, skip output when already initialized, fixed mcpEntry (was still hardcoded) - .github/workflows/npm-publish.yml: auto-publish to npm on GitHub release (build + lint + test + publish) Verified: binary flow (status, hooks), npm install -g flow (status, hooks), 413 tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/npm-publish.yml | 26 ++++++++++++++++++++++++++ .mcp.json | 4 ++-- src/cli.ts | 31 +++++++++++++++++++------------ templates/mcp.json | 4 ++-- 4 files changed, 49 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..83f35e5 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,26 @@ +name: Publish to npm + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org' + + - run: npm ci + - run: npm run build + - run: npm run lint + - run: npm test + - run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.mcp.json b/.mcp.json index 633d91c..dee5f06 100644 --- a/.mcp.json +++ b/.mcp.json @@ -1,8 +1,8 @@ { "mcpServers": { "axme": { - "command": "npx", - "args": ["-y", "@axme/code", "serve"] + "command": "axme-code", + "args": ["serve"] } } } diff --git a/src/cli.ts b/src/cli.ts index bf65fb6..bf3d235 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -183,7 +183,7 @@ function configureHooks(projectPath: string): void { settings.hooks.PreToolUse.push({ hooks: [{ type: "command", - command: `npx -y @axme/code hook pre-tool-use --workspace ${projectPath}`, + command: `axme-code hook pre-tool-use --workspace ${projectPath}`, timeout: 5, }], }); @@ -195,7 +195,7 @@ function configureHooks(projectPath: string): void { matcher: "Edit|Write|NotebookEdit", hooks: [{ type: "command", - command: `npx -y @axme/code hook post-tool-use --workspace ${projectPath}`, + command: `axme-code hook post-tool-use --workspace ${projectPath}`, timeout: 10, }], }); @@ -205,7 +205,7 @@ function configureHooks(projectPath: string): void { settings.hooks.SessionEnd.push({ hooks: [{ type: "command", - command: `npx -y @axme/code hook session-end --workspace ${projectPath}`, + command: `axme-code hook session-end --workspace ${projectPath}`, timeout: 120, }], }); @@ -248,7 +248,7 @@ function usage(): void { console.log(`AXME Code - Persistent memory, decisions, and safety guardrails for Claude Code Usage: - axme-code setup [path] Initialize project (LLM scan + .mcp.json + CLAUDE.md) + axme-code setup [path] [--force] Initialize project (LLM scan + .mcp.json + CLAUDE.md) axme-code serve Start MCP server (stdio transport) axme-code status [path] Show project status axme-code cleanup legacy-artifacts [--dry-run] Remove pre-PR#7 sessions/logs @@ -263,7 +263,9 @@ After setup, run 'claude' as usual. AXME tools are available automatically.`); async function main() { switch (command) { case "setup": { - const projectPath = resolve(args[1] || "."); + const forceSetup = args.includes("--force"); + const setupArgs = args.filter(a => a !== "--force"); + const projectPath = resolve(setupArgs[1] || "."); const hasGitDir = existsSync(join(projectPath, ".git")); const ws = detectWorkspace(projectPath); const isWorkspace = hasGitDir ? false : ws.type !== "single"; @@ -299,13 +301,18 @@ async function main() { } generateWorkspaceYaml(projectPath, ws); } else { - const result = await initProjectWithLLM(projectPath, { onProgress: console.log }); - console.log(` Oracle: ${result.oracle.files} files (${result.oracle.llm ? "LLM scan" : "deterministic fallback"})`); - console.log(` Decisions: ${result.decisions.count} (${result.decisions.fromScan} LLM + ${result.decisions.fromPresets} presets)`); - console.log(` Memories: ${result.memories.count} (${result.memories.fromPresets} from presets)`); - console.log(` Safety: ${result.safety.llm ? "LLM scan" : "defaults + presets"}`); - if (result.cost.costUsd > 0) console.log(` Cost: $${result.cost.costUsd.toFixed(2)}, ${(result.durationMs / 1000).toFixed(1)}s`); - for (const e of result.errors) console.log(` Warning: ${e}`); + const result = await initProjectWithLLM(projectPath, { onProgress: console.log, force: forceSetup }); + if (!result.created && result.durationMs === 0) { + console.log(` Already initialized (skipped LLM scan). Use --force to re-scan.`); + console.log(` Decisions: ${result.decisions.count}, Memories: ${result.memories.count}`); + } else { + console.log(` Oracle: ${result.oracle.files} files (${result.oracle.llm ? "LLM scan" : "deterministic fallback"})`); + console.log(` Decisions: ${result.decisions.count} (${result.decisions.fromScan} LLM + ${result.decisions.fromPresets} presets)`); + console.log(` Memories: ${result.memories.count} (${result.memories.fromPresets} from presets)`); + console.log(` Safety: ${result.safety.llm ? "LLM scan" : "defaults + presets"}`); + if (result.cost.costUsd > 0) console.log(` Cost: $${result.cost.costUsd.toFixed(2)}, ${(result.durationMs / 1000).toFixed(1)}s`); + for (const e of result.errors) console.log(` Warning: ${e}`); + } } // Create or update .mcp.json (workspace root + each child repo) diff --git a/templates/mcp.json b/templates/mcp.json index 633d91c..dee5f06 100644 --- a/templates/mcp.json +++ b/templates/mcp.json @@ -1,8 +1,8 @@ { "mcpServers": { "axme": { - "command": "npx", - "args": ["-y", "@axme/code", "serve"] + "command": "axme-code", + "args": ["serve"] } } }