Skip to content

Commit c9dee3c

Browse files
0xranxclaude
andcommitted
Deploy skills to native engine paths for auto-discovery (v0.3.0)
Skills are now symlinked to all engine-native directories: - .claude/skills/ (Claude Code) - .agents/skills/ (Codex) - .cursor/skills/ (Cursor, also discovered by OpenCode) This means agents auto-discover skills at startup without relying on CLAUDE.md text references. The CLAUDE.md references are kept as fallback. Eject cleanly removes all symlinks. Falls back to copy if symlinks aren't supported (e.g. Windows). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a2f61f9 commit c9dee3c

3 files changed

Lines changed: 72 additions & 3 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "agentbrief",
3-
"version": "0.2.2",
3+
"version": "0.3.0",
44
"description": "One command turns your AI coding agent into a domain specialist",
55
"type": "module",
66
"main": "./dist/index.js",

‎src/cli.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const program = new Command();
77
program
88
.name("agentbrief")
99
.description("One command turns your AI coding agent into a domain specialist")
10-
.version("0.2.2");
10+
.version("0.3.0");
1111

1212
program.addHelpText(
1313
"after",

‎src/index.ts‎

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { existsSync, readdirSync, statSync } from "node:fs";
2-
import { cp, mkdir, readFile, writeFile } from "node:fs/promises";
2+
import { cp, mkdir, readFile, symlink, writeFile } from "node:fs/promises";
33
import { dirname, join, resolve } from "node:path";
44
import { fileURLToPath } from "node:url";
55
import yaml from "js-yaml";
@@ -156,6 +156,9 @@ export async function use(opts: UseOpts): Promise<UseResult> {
156156
applied_at: new Date().toISOString(),
157157
});
158158

159+
// 8. Deploy skills to engine-native directories for auto-discovery
160+
await deployNativeSkills(projectDir, spec.name, briefDataDir);
161+
159162
// Count CLAUDE.md lines for context bloat warning
160163
const claudeMdPath = join(projectDir, "CLAUDE.md");
161164
const claudeLines = existsSync(claudeMdPath) ? (await readFile(claudeMdPath, "utf-8")).split("\n").length : 0;
@@ -177,6 +180,69 @@ export async function use(opts: UseOpts): Promise<UseResult> {
177180
};
178181
}
179182

183+
// ── Native skill paths for engine discovery ─────────────
184+
185+
/**
186+
* Engine-native skill directories. Skills placed here are
187+
* auto-discovered by each agent without needing CLAUDE.md references.
188+
*/
189+
const NATIVE_SKILL_DIRS = [
190+
".claude/skills", // Claude Code
191+
".agents/skills", // Codex
192+
".cursor/skills", // Cursor (also discovered by OpenCode)
193+
];
194+
195+
/**
196+
* Deploy skills to engine-native directories so agents auto-discover them.
197+
* Creates symlinks from native paths → .agentbrief/{brief}/skills/{skill}
198+
*/
199+
async function deployNativeSkills(projectDir: string, briefName: string, briefDataDir: string): Promise<void> {
200+
const deployedSkillsDir = join(briefDataDir, "skills");
201+
if (!existsSync(deployedSkillsDir)) return;
202+
203+
const skills = readdirSync(deployedSkillsDir).filter(
204+
(f) => !f.startsWith(".") && statSync(join(deployedSkillsDir, f)).isDirectory(),
205+
);
206+
207+
for (const dir of NATIVE_SKILL_DIRS) {
208+
const nativeDir = join(projectDir, dir);
209+
await mkdir(nativeDir, { recursive: true });
210+
for (const skill of skills) {
211+
const target = join(nativeDir, skill);
212+
if (existsSync(target)) continue; // don't overwrite existing skills
213+
const source = join(deployedSkillsDir, skill);
214+
try {
215+
await symlink(source, target, "dir");
216+
} catch {
217+
// Symlink failed (e.g. Windows) — fall back to copy
218+
await cp(source, target, { recursive: true });
219+
}
220+
}
221+
}
222+
}
223+
224+
/**
225+
* Clean up engine-native skill symlinks/copies for a brief on eject.
226+
*/
227+
async function cleanNativeSkills(projectDir: string, briefName: string, briefDataDir: string): Promise<void> {
228+
const deployedSkillsDir = join(briefDataDir, "skills");
229+
if (!existsSync(deployedSkillsDir)) return;
230+
231+
const skills = readdirSync(deployedSkillsDir).filter(
232+
(f) => !f.startsWith(".") && statSync(join(deployedSkillsDir, f)).isDirectory(),
233+
);
234+
235+
for (const dir of NATIVE_SKILL_DIRS) {
236+
for (const skill of skills) {
237+
const target = join(projectDir, dir, skill);
238+
if (existsSync(target)) {
239+
const { rm } = await import("node:fs/promises");
240+
await rm(target, { recursive: true });
241+
}
242+
}
243+
}
244+
}
245+
180246
// ── eject ───────────────────────────────────────────────
181247

182248
export interface EjectResult {
@@ -186,6 +252,9 @@ export interface EjectResult {
186252

187253
export async function eject(name: string, projectDir?: string): Promise<EjectResult> {
188254
const dir = resolve(projectDir || ".");
255+
// Clean native skill symlinks/copies before removing brief data
256+
const briefDataDir = join(dir, ".agentbrief", name);
257+
await cleanNativeSkills(dir, name, briefDataDir);
189258
const ejectedFiles = await ejectFromFiles(dir, name);
190259
await cleanBriefData(dir, name);
191260
await removeEntry(dir, name);

0 commit comments

Comments
 (0)