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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

### Added

- **`kit agent-config` now wires GitHub Copilot** — the managed "use kit" rules
block is written to `.github/copilot-instructions.md`, Copilot's canonical
custom-instructions file (VS Code / Visual Studio). Detected when a `.vscode/`
dir is present or the file already exists; `writeAgentConfig` creates the
nested parent dir (`.github/`) as needed. Fifth rules-file target alongside
CLAUDE.md / AGENTS.md / .cursorrules / .clinerules (Antigravity is already
covered via its `AGENTS.md` support). Advisory only — memory indexing and a
blocking install-gate for Copilot still need its transcript format + pre-tool
hook surface verified against primary sources; the git-hook floor and the MCP
server (`kit mcp`) apply to Copilot today regardless.
- **Memory sync blobs are now gzip-compressed before encryption (~3× smaller).** A
SQLite store compresses well (a real store: 6.3 MB → 2.1 MB; large stores
~139 MB → ~30 MB), which keeps the blob under a git host's 100 MB file limit and
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ adapters for the surfaces each agent exposes. Support today, per agent:
| **OpenCode** | ✅ | ✅ `AGENTS.md` | ✅ `opencode.json` + `.opencode/plugin` | — | — | ✅ plugin |
| **Cursor** | ✅ | ✅ `.cursorrules` | ✅ `.cursor/mcp.json` | — | — | ✅ hook |
| **Cline** | ✅ | ✅ `.clinerules` | — | — | — | ✅ hook |
| **Copilot** | — | ✅ `copilot-instructions.md` | — | — | — | —⁸ |
| **Gemini CLI** | ✅ | — | — | — | — | ✅ hook |
| **Continue** | ✅ | — | — | — | — | n/a⁷ |
| **Amazon Q** | ✅ | — | — | — | — | ✅ hook |
Expand All @@ -311,6 +312,7 @@ adapters for the surfaces each agent exposes. Support today, per agent:
5. kit registers lifecycle hooks so memory capture happens automatically (Claude Code `settings.json` hooks today).
6. A **true blocking gate** (deny an un-triaged install before it runs) uses the agent's pre-tool hook — `kit agent-config --install-gate` wires it for Claude Code, Codex, Amazon Q, Gemini CLI, and Cursor (exit-2 hook commands); OpenCode via a generated `.opencode/plugin` that hooks `tool.execute.before` and throws; and Cline via an executable `.clinerules/hooks/PreToolUse` shim that blocks through Cline's `{cancel:true}` stdout contract. The agent-agnostic enforcement floor is **git hooks** (`kit hooks`, pre-commit/pre-push) — they fire in any agent or none. See [#146](https://github.com/sandstream/kit/issues/146).
7. **Continue** exposes only a declarative tool-permission policy (`~/.continue/permissions.yaml` allow/ask/exclude) with no way to invoke an external command before a tool runs, so a kit blocking-gate adapter isn't possible there — git hooks + the rules-file block remain its floor.
8. **GitHub Copilot** (VS Code / Visual Studio): the "use kit" rules block is written to `.github/copilot-instructions.md` (wired when a `.vscode/` dir is present or the file already exists). Memory indexing and a blocking install-gate are not yet implemented — they need Copilot's transcript format and a pre-tool-hook surface verified against primary sources first. The git-hook floor + the MCP server (`kit mcp`, added to `.vscode/mcp.json`) apply today.

> The git-hook layer enforces at the VCS boundary regardless of agent; the rules-file block is **advisory** (it reminds the agent); only the blocking-gate hook **enforces** before an action runs.

Expand Down
37 changes: 37 additions & 0 deletions src/agent-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,29 @@ describe("detectAgentTargets", () => {
rmSync(dir, { recursive: true, force: true });
}
});

it("wires Copilot via a .vscode/ dir (→ .github/copilot-instructions.md)", () => {
const dir = tmpRepo();
try {
mkdirSync(join(dir, ".vscode"));
const files = detectAgentTargets(dir).map((t) => t.file);
assert.deepEqual(files, [".github/copilot-instructions.md"]);
} finally {
rmSync(dir, { recursive: true, force: true });
}
});

it("detects Copilot via an existing .github/copilot-instructions.md", () => {
const dir = tmpRepo();
try {
mkdirSync(join(dir, ".github"));
writeFileSync(join(dir, ".github", "copilot-instructions.md"), "# instructions\n");
const agents = detectAgentTargets(dir).map((t) => t.agent);
assert.deepEqual(agents, ["Copilot"]);
} finally {
rmSync(dir, { recursive: true, force: true });
}
});
});

describe("writeAgentConfig", () => {
Expand All @@ -147,6 +170,20 @@ describe("writeAgentConfig", () => {
}
});

it("creates the parent dir for a nested target (Copilot's .github/copilot-instructions.md)", async () => {
const dir = tmpRepo();
try {
const t = [{ agent: "Copilot", file: ".github/copilot-instructions.md" }];
const results = await writeAgentConfig(dir, t);
assert.equal(results[0].action, "created");
assert.ok(existsSync(join(dir, ".github", "copilot-instructions.md")), "file created");
const written = readFileSync(join(dir, ".github", "copilot-instructions.md"), "utf-8");
assert.ok(written.includes(KIT_BLOCK_BEGIN) && written.includes(KIT_BLOCK_END));
} finally {
rmSync(dir, { recursive: true, force: true });
}
});

it("preserves an existing CLAUDE.md and appends the block", async () => {
const dir = tmpRepo();
try {
Expand Down
10 changes: 10 additions & 0 deletions src/agent-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const AGENT_TARGETS: AgentTarget[] = [
{ agent: "Codex", file: "AGENTS.md" },
{ agent: "Cursor", file: ".cursorrules" },
{ agent: "Cline", file: ".clinerules" },
{ agent: "Copilot", file: ".github/copilot-instructions.md" },
];

/**
Expand All @@ -74,6 +75,12 @@ export function detectAgentTargets(cwd: string = process.cwd()): AgentTarget[] {
);
case "Cursor":
return existsSync(resolve(cwd, ".cursor"));
case "Copilot":
// GitHub Copilot (VS Code / Visual Studio) reads
// `.github/copilot-instructions.md`. The file check above covers an
// existing one; a `.vscode/` dir marks a VS Code project where Copilot
// is the likely agent, so wire it there too.
return existsSync(resolve(cwd, ".vscode"));
default:
return false;
}
Expand Down Expand Up @@ -153,6 +160,9 @@ export async function writeAgentConfig(
results.push({ agent: t.agent, file: t.file, action, detail: "kit block already current" });
continue;
}
// Rules files can be nested (e.g. Copilot's `.github/copilot-instructions.md`);
// create the parent dir. No-op for root-level targets.
await mkdir(dirname(path), { recursive: true });
await writeFile(path, next, "utf-8");
results.push({
agent: t.agent,
Expand Down
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5251,7 +5251,7 @@ export const COMMAND_HELP: Record<string, string> = {
"env current": "Show active environment marker",
analyze: "Analyze repo + emit draft CLAUDE.md / RULES.md",
"agent-config":
"Inject a managed 'use kit' block into CLAUDE.md / AGENTS.md / .cursorrules / .clinerules",
"Inject a managed 'use kit' block into CLAUDE.md / AGENTS.md / .cursorrules / .clinerules / .github/copilot-instructions.md",
"gate-bash":
"PreToolUse install-gate: read an agent's pending Bash command on stdin, block (exit 2) un-triaged installs",
security:
Expand Down
Loading