Skip to content
Draft
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
15 changes: 4 additions & 11 deletions packages/cli/src/ayo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { readFileSync, writeFileSync, existsSync, rmSync } from "node:fs";
import { join } from "node:path";
import { Command, Help } from "commander";
import pc from "picocolors";
import { pkgVersion } from "@ayo-dev/core/node";
import {
AYO_DIR,
DAEMON_META_PATH,
Expand Down Expand Up @@ -42,16 +43,8 @@ import { soundList, soundMute, soundPreview, soundSet, soundStatus, soundUnmute,

// Read the real version from package.json (dist/ayo.js → ../package.json, which
// npm always includes in the tarball). Fall back so `--version` can never throw.
function pkgVersion(): string {
try {
return JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version ?? "0.0.0";
} catch {
return "0.0.0";
}
}

const program = new Command();
program.name("ayo").description("Ping your teammates from inside Codex and Claude.").version(pkgVersion());
program.name("ayo").description("Ping your teammates from inside Codex and Claude.").version(pkgVersion(import.meta.url));
program.showSuggestionAfterError(true);

// Help lists everyday commands before plumbing — beloved CLIs teach the primary
Expand Down Expand Up @@ -1119,9 +1112,9 @@ program
} catch {
/* older daemon wrote no meta */
}
const skew = dv && dv !== pkgVersion();
const skew = dv && dv !== pkgVersion(import.meta.url);
console.log(pc.green(`✓ daemon running (ayod${dv ? ` v${dv}` : ""})`));
if (skew) console.log(pc.yellow(`⚠ daemon is v${dv} but the CLI is v${pkgVersion()} — restart it: \`ayo daemon stop && ayo daemon start\``));
if (skew) console.log(pc.yellow(`⚠ daemon is v${dv} but the CLI is v${pkgVersion(import.meta.url)} — restart it: \`ayo daemon stop && ayo daemon start\``));
else if (!dv) console.log(pc.dim(" (daemon predates version reporting — restart it once so doctor can check for skew)"));
} else {
console.log(pc.yellow("⚠ daemon not running — `ayo daemon install` (or `ayo daemon start`)"));
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
export * from "./files.js";
export * from "./http.js";
export * from "./git-context.js";
export * from "./version.js";
18 changes: 18 additions & 0 deletions packages/core/src/node/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { readFileSync } from "node:fs";

/**
* Read the package version beside a compiled package entry point.
*
* Callers pass their own `import.meta.url` so this works for every package in
* the monorepo while keeping the package manifest out of the module graph.
*/
export function pkgVersion(importMetaUrl: string): string {
try {
const manifest = JSON.parse(
readFileSync(new URL("../package.json", importMetaUrl), "utf8"),
) as { version?: unknown };
return typeof manifest.version === "string" ? manifest.version : "0.0.0";
} catch {
return "0.0.0";
}
}
12 changes: 2 additions & 10 deletions packages/mcp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,16 @@
* send + pull. Identity is shared with the CLI via ~/.ayo (see relay.ts).
*/

import { readFileSync } from "node:fs";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
import type { AyoContext, SendAyoResponse } from "@ayo-dev/core";
import { pkgVersion } from "@ayo-dev/core/node";
import { loadAuth, relay } from "./relay.js";
import { captureContext } from "./context.js";

// Real version from package.json (dist/index.js → ../package.json, always packed).
function pkgVersion(): string {
try {
return JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version ?? "0.0.0";
} catch {
return "0.0.0";
}
}

const server = new McpServer({ name: "ayo", version: pkgVersion() });
const server = new McpServer({ name: "ayo", version: pkgVersion(import.meta.url) });

const recipients = z.array(z.string().min(1)).min(1).describe('Handles to ping. Use ["*"] for the whole team.');

Expand Down