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
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "agent-kit",
"displayName": "Mission Kit",
"version": "6.26.2",
"version": "6.27.0",
"description": "Plan, build, ship, and keep shipping. Agent Kit for Claude Code: plans, handoff, durable memory and staging-to-prod gates for long-term projects, followed from Mission Control in your browser.",
"author": {
"name": "agent-kit-startup"
Expand Down
2 changes: 1 addition & 1 deletion .codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agent-kit",
"version": "6.26.2",
"version": "6.27.0",
"description": "Plan, build, ship, and keep shipping. Agent Kit skills for long-term projects with your own coding agents: plans, handoff, durable memory and staging-to-prod gates.",
"author": {
"name": "agent-kit-startup"
Expand Down
2 changes: 1 addition & 1 deletion .cursor-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"description": "Plan, build, ship, and keep shipping. Agent Kit slash commands, rules and skills for long-term projects with your own coding agents: plans, handoff, durable memory and staging-to-prod gates. Follow the work in Mission Control.",
"keywords": ["agents", "hitl", "handoff", "git-staging", "context", "multi-ide", "anti-slop"],
"license": "Apache-2.0",
"version": "6.26.2",
"version": "6.27.0",
"homepage": "https://github.com/agent-kit-startup/agent-kit",
"websiteURL": "https://agent.missionkit.io/",
"privacyPolicyURL": "https://github.com/agent-kit-startup/agent-kit/blob/main/PRIVACY.md",
Expand Down
2 changes: 1 addition & 1 deletion .cursor/agent-kit.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"version": "6.26.2",
"version": "6.27.0",
"protected": [
".claude/commands/agent-kit.md",
".cursor/HANDOFF.md",
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and

## [Unreleased]

## [6.27.0] - 2026-11-30

### Added

- Contributors: `pnpm build` in `packages/cli` writes `dist/build-stamp.json` with the source commit it was built from. When the repo's hooks run that `packages/cli/dist`, session start adds one line if `packages/cli/src` has commits the build does not include (or the dist has no stamp), with the fix (`pnpm build` in packages/cli), and `agent-kit doctor` reports the same. Projects that install the CLI from npm see no change.

## [6.26.2] - 2026-11-30

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion claude-directory/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "agent-kit",
"displayName": "Mission Kit",
"version": "6.26.2",
"version": "6.27.0",
"description": "Plan, build, review, ship, keep: a working routine for long-term projects with Claude Code. Plans with to-dos you approve, review agents, staging-to-production gates that wait for your yes, and a handoff and memory that survive new chats.",
"author": {
"name": "agent-kit-startup"
Expand Down
2 changes: 1 addition & 1 deletion claude-directory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ State, memory and a live view that survive new chats and new agents.

## Install

This folder is the plugin as listed in the Claude plugin directory (version 6.26.2): the commands, agents and skills above, and no hooks or scripts. The commands work on a repository prepared by the agent-kit CLI (`agent-kit install`); see [install.md](https://github.com/agent-kit-startup/agent-kit/blob/main/install.md). Mission Control comes with the CLI.
This folder is the plugin as listed in the Claude plugin directory (version 6.27.0): the commands, agents and skills above, and no hooks or scripts. The commands work on a repository prepared by the agent-kit CLI (`agent-kit install`); see [install.md](https://github.com/agent-kit-startup/agent-kit/blob/main/install.md). Mission Control comes with the CLI.

The full kit (every command, the session-start context and the shell guard hooks) installs from the repository marketplace:

Expand Down
2 changes: 1 addition & 1 deletion gemini-extension.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "agent-kit",
"version": "6.26.2",
"version": "6.27.0",
"description": "Mission Kit core skills: HITL gates, plan backlog and onboarding, QA, external plan review. The full kit (slash commands, plans, HANDOFF, staging-then-prod git flow) installs with npx @dadado/agent-kit-cli@latest install."
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agent-kit",
"version": "6.26.2",
"version": "6.27.0",
"description": "HITL framework for AI-assisted IDEs: plan, handoff, staging-to-prod, memory loop; Cursor-first with partial generators for VS Code and Windsurf.",
"private": true,
"license": "Apache-2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dadado/agent-kit-cli",
"version": "6.26.2",
"version": "6.27.0",
"description": "Agent Kit CLI: HITL framework install and tooling for AI-assisted IDEs (rules, skills, plan/handoff, context).",
"keywords": [
"pi-package"
Expand Down Expand Up @@ -37,7 +37,7 @@
"sync-dashboard": "node ../../scripts/sync-cli-dashboard.mjs",
"prepack": "node ../../scripts/sync-cli-dashboard.mjs",
"prepublishOnly": "node ../../scripts/verify-cli-dashboard-pack.mjs",
"build": "node ../../scripts/sync-cli-dashboard.mjs && tsup src/index.ts --format esm --dts --clean",
"build": "node ../../scripts/sync-cli-dashboard.mjs && tsup src/index.ts --format esm --dts --clean && (tsx src/lifecycle/write-cli-build-stamp.ts || echo build-stamp: skipped)",
"dev": "tsx src/index.ts",
"start": "tsx src/index.ts",
"lint": "biome check src pi",
Expand Down
142 changes: 142 additions & 0 deletions packages/cli/src/hooks/session-start-factory-dist.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import { execFileSync } from "node:child_process";
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import {
CLI_BUILD_STAMP_FILE,
type GitRunner,
writeCliBuildStamp,
} from "../lifecycle/cli-dist-stamp.js";
import { buildSessionStartAdditionalContext, factoryCliDistSection } from "./session-start.js";

const SHA = "b".repeat(40);
const noRoster = async (): Promise<never> => {
throw new Error("no roster in tests");
};
const gitAnswering =
(revList: string | null): GitRunner =>
async () =>
revList;

let root: string;
let cliDir: string;
let script: string;
beforeEach(async () => {
root = await mkdtemp(path.join(tmpdir(), "ak-ss-dist-"));
cliDir = path.join(root, "packages", "cli");
await mkdir(path.join(cliDir, "dist"), { recursive: true });
await mkdir(path.join(cliDir, "src"), { recursive: true });
script = path.join(cliDir, "dist", "index.js");
await writeFile(script, "// built\n");
await writeFile(
path.join(cliDir, "package.json"),
JSON.stringify({ name: "@dadado/agent-kit-cli" }),
);
});
afterEach(async () => {
await rm(root, { recursive: true, force: true });
});

async function stamp(sourceCommit: string | null): Promise<void> {
await writeFile(
path.join(cliDir, "dist", CLI_BUILD_STAMP_FILE),
JSON.stringify({ schemaVersion: 1, sourceCommit, sourceDirty: false, builtAt: "x" }),
);
}

describe("factoryCliDistSection", () => {
it("fresh dist: no line", async () => {
await stamp(SHA);
expect(await factoryCliDistSection(script, { git: gitAnswering("0\n") })).toBeNull();
});

it("stale dist: one line with the short sha, the gap and the fix", async () => {
await stamp(SHA);
expect(await factoryCliDistSection(script, { git: gitAnswering("2\n") })).toBe(
"Factory hooks: packages/cli/dist was built from bbbbbbbb and packages/cli/src is 2 commits ahead; run `pnpm build` in packages/cli.",
);
});

it("missing stamp: own wording, same fix", async () => {
const line = await factoryCliDistSection(script, { git: gitAnswering(null) });
expect(line).toMatch(/^Factory hooks: packages\/cli\/dist has no build stamp/);
expect(line).toMatch(/run `pnpm build` in packages\/cli\.$/);
});

it("no git: no line (fail-open)", async () => {
await stamp(SHA);
expect(await factoryCliDistSection(script, { git: gitAnswering(null) })).toBeNull();
});

it("not the project dist (global CLI, consumer, tsx): no line and no git call", async () => {
let called = false;
const git: GitRunner = async () => {
called = true;
return "5";
};
expect(await factoryCliDistSection("/usr/local/bin/agent-kit", { git })).toBeNull();
expect(await factoryCliDistSection(undefined, { git })).toBeNull();
expect(called).toBe(false);
});

it("consumer layout (dist without packages/cli/src): no line", async () => {
await rm(path.join(cliDir, "src"), { recursive: true });
expect(await factoryCliDistSection(script, { git: gitAnswering("5") })).toBeNull();
});
});

describe("buildSessionStartAdditionalContext factory dist line", () => {
it("adds the line when the running script is a stale project dist", async () => {
await stamp(SHA);
const { additional_context } = await buildSessionStartAdditionalContext(
root,
{},
{ cliScript: script, git: gitAnswering("3"), liveRoster: noRoster },
);
expect(additional_context).toContain("packages/cli/src is 3 commits ahead");
});

it("says nothing when cliScript is null", async () => {
const { additional_context } = await buildSessionStartAdditionalContext(
root,
{},
{ cliScript: null, liveRoster: noRoster },
);
expect(additional_context).not.toContain("Factory hooks:");
});
});

describe("real git: stale after a src commit, gone after rebuild", () => {
function git(...args: string[]): string {
return execFileSync(
"git",
[
"-c",
"user.name=t",
"-c",
"user.email=t@example.invalid",
"-c",
"commit.gpgsign=false",
...args,
],
{ cwd: root, encoding: "utf8" },
);
}

it("fresh -> stale -> fresh", async () => {
git("init", "-q");
await writeFile(path.join(cliDir, "src", "a.ts"), "export {};\n");
git("add", "packages/cli/src");
git("commit", "-q", "-m", "one");
await writeCliBuildStamp(cliDir);
expect(await factoryCliDistSection(script)).toBeNull();

await writeFile(path.join(cliDir, "src", "a.ts"), "export const x = 1;\n");
git("commit", "-q", "-am", "two");
expect(await factoryCliDistSection(script)).toMatch(/src is 1 commit ahead/);

await writeCliBuildStamp(cliDir);
expect(await factoryCliDistSection(script)).toBeNull();
});
});
38 changes: 38 additions & 0 deletions packages/cli/src/hooks/session-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import { readFile, stat } from "node:fs/promises";
import path from "node:path";
import { validateHandoffText } from "../invariants/handoff-schema.js";
import { stampLastCheckedAt } from "../lifecycle/check-updates.js";
import {
assessCliDistFreshness,
CLI_DIST_STALE_FIX,
describeCliDistFreshness,
factoryRootFromScript,
type GitRunner,
} from "../lifecycle/cli-dist-stamp.js";
import { loadContextConfig } from "../lifecycle/context-config.js";
import {
CHANGELOG_FETCH_TIMEOUT_MS,
Expand Down Expand Up @@ -908,6 +915,26 @@ export async function liveAgentsSection(
}
}

/**
* Factory only: when this process is `<root>/packages/cli/dist/index.js` (the hook
* resolver picked the project dist), one line naming a dist built from older source.
* One git call per session, never in the guard path; consumers (no packages/cli)
* and any error say nothing.
*/
export async function factoryCliDistSection(
scriptPath: string | null | undefined,
deps: { git?: GitRunner } = {},
): Promise<string | null> {
try {
const root = factoryRootFromScript(scriptPath ?? undefined);
if (!root) return null;
const gap = describeCliDistFreshness(await assessCliDistFreshness(root, deps));
return gap ? `Factory hooks: ${gap}; ${CLI_DIST_STALE_FIX}.` : null;
} catch {
return null;
}
}

export async function buildSessionStartAdditionalContext(
rootDir: string,
_payload: SessionStartPayload = {},
Expand All @@ -919,11 +946,19 @@ export async function buildSessionStartAdditionalContext(
updateNotice?: UpdateNoticeOptions;
/** Consumer host; `pi` adds the numbered-list HITL section after the hard rules. */
host?: SessionStartHookFormat;
/** Running CLI script (default `process.argv[1]`); null skips the factory dist check. */
cliScript?: string | null;
/** Git seam for the factory dist check. */
git?: GitRunner;
} = {},
): Promise<{ additional_context: string }> {
const root = path.resolve(rootDir);
// Started first so the roster's ps / git shell-outs overlap the other sections.
const liveAgentsPending = liveAgentsSection(root, { collect: deps.liveRoster });
const factoryDistPending = factoryCliDistSection(
deps.cliScript === undefined ? process.argv[1] : deps.cliScript,
{ git: deps.git },
);
const handoffPath = path.join(root, HANDOFF_REL);
const handoffFull = await readFull(handoffPath);
const handoff = capHandoffExcerpt(handoffFull);
Expand All @@ -941,6 +976,9 @@ export async function buildSessionStartAdditionalContext(
const colonyHost = colonyHostSection();
if (colonyHost) parts.push(colonyHost);

const factoryDist = await factoryDistPending.catch(() => null);
if (factoryDist) parts.push(factoryDist);

// The three spawn-backed nudges run concurrently, each capped by a deadline that
// kills its children, so one hung check cannot stall sessionStart. parts[] order
// is unchanged. Children run without --stamp: the parent is the single writer of
Expand Down
65 changes: 65 additions & 0 deletions packages/cli/src/invariants/hooks-health.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
assessClaudeCommandAdapters,
assessClaudeGuardProbe,
assessClaudeMergeAllowGuard,
assessFactoryCliDist,
assessGitHooksInstallDrift,
assessHooksHealth,
assessSignatureGateHook,
Expand Down Expand Up @@ -196,6 +197,70 @@ describe("assessGitHooksInstallDrift", () => {
});
});

describe("assessFactoryCliDist", () => {
const SHA = "c".repeat(40);
const git = (answer: string | null) => async () => answer;

beforeEach(() => {
vi.stubEnv("AGENT_KIT_HOOK_BIN", "");
vi.stubEnv("PATH", "/usr/bin:/bin");
});
afterEach(() => vi.unstubAllEnvs());

async function factory(stamp: string | null | undefined): Promise<string> {
const root = await mkdtemp(path.join(tmpdir(), "ak-factory-dist-"));
const cli = path.join(root, "packages", "cli");
await mkdir(path.join(cli, "dist"), { recursive: true });
await mkdir(path.join(cli, "src"), { recursive: true });
await writeFile(path.join(cli, "dist", "index.js"), "// built\n", "utf8");
await writeFile(
path.join(cli, "package.json"),
JSON.stringify({ name: "@dadado/agent-kit-cli" }),
"utf8",
);
if (stamp !== undefined) {
await writeFile(
path.join(cli, "dist", "build-stamp.json"),
JSON.stringify({ schemaVersion: 1, sourceCommit: stamp, sourceDirty: false, builtAt: "x" }),
"utf8",
);
}
return root;
}

it("flags a stale dist for session-start and the guard with the fix", async () => {
const tips = await assessFactoryCliDist(await factory(SHA), { git: git("4\n") });
expect(tips).toEqual([
"Factory hooks (session-start and the PreToolUse guard) run a stale CLI: packages/cli/dist was built from cccccccc and packages/cli/src is 4 commits ahead; run `pnpm build` in packages/cli.",
]);
});

it("flags an unstamped dist", async () => {
const tips = await assessFactoryCliDist(await factory(undefined), { git: git(null) });
expect(tips).toHaveLength(1);
expect(tips[0]).toMatch(/has no build stamp.*run `pnpm build` in packages\/cli\.$/);
});

it("is silent on a fresh dist and when git fails", async () => {
expect(await assessFactoryCliDist(await factory(SHA), { git: git("0") })).toEqual([]);
expect(await assessFactoryCliDist(await factory(SHA), { git: git(null) })).toEqual([]);
});

it("is silent when the resolver picks node_modules/.bin/agent-kit first", async () => {
const root = await factory(undefined);
const bin = path.join(root, "node_modules", ".bin");
await mkdir(bin, { recursive: true });
await writeFile(path.join(bin, "agent-kit"), "#!/bin/sh\n", "utf8");
await chmod(path.join(bin, "agent-kit"), 0o755);
expect(await assessFactoryCliDist(root, { git: git("4") })).toEqual([]);
});

it("is silent in a consumer (no packages/cli)", async () => {
const root = await mkdtemp(path.join(tmpdir(), "ak-consumer-"));
expect(await assessFactoryCliDist(root, { git: git("4") })).toEqual([]);
});
});

describe("assessClaudeGuardProbe", () => {
const DENY = JSON.stringify({
hookSpecificOutput: {
Expand Down
Loading