Agent-JAE/default-extensions/jae-rules.ts
jae a1b6e22c01 feat: add 16 default extensions for Agent JAE
New extensions shipping with Agent JAE:
- jae-rules: Per-project .jae/rules.md injection
- cost-tracker: Token/cost tracking with budget limits
- project-dna: Auto-analyze project fingerprint
- teach-mode: Pedagogical explanation mode
- bookmarks: File bookmark management
- replay: Session recording and asciicast export
- checkpoints: Git-based undo/time-travel
- pr-review: Autonomous PR diff review
- auto-docs: Auto-generate README and docs
- screenshot-context: Vision analysis for screenshots
- deploy: One-command deploy (Docker/Vercel/rsync/static)
- pair-programming: Real-time file watching with feedback
- dashboard: Terminal HUD with live stats
- swarm: Multi-agent parallel task execution
- skill-marketplace: Search/install/publish skills
- widget-api-demo: TUI widget API demonstration
2026-03-23 20:14:41 +01:00

48 lines
1.7 KiB
TypeScript

import type { ExtensionAPI } from "@jaeswift/jae-coding-agent";
import { existsSync, readFileSync, mkdirSync, writeFileSync } from "node:fs";
import { join } from "node:path";
export default function (pi: ExtensionAPI) {
pi.on("before_agent_start", async (_event, ctx) => {
const rulesPath = join(ctx.cwd, ".jae", "rules.md");
if (existsSync(rulesPath)) {
const rules = readFileSync(rulesPath, "utf-8").trim();
if (rules.length > 0) {
return { systemPrompt: `\n\n# Project Rules (.jae/rules.md)\n\n${rules}` };
}
}
});
pi.registerCommand("rules", {
description: "Show, create, or edit project rules (.jae/rules.md)",
handler: async (args, ctx) => {
const jaeDir = join(ctx.cwd, ".jae");
const rulesPath = join(jaeDir, "rules.md");
if (args.trim() === "init") {
if (!existsSync(jaeDir)) mkdirSync(jaeDir, { recursive: true });
if (!existsSync(rulesPath)) {
writeFileSync(
rulesPath,
"# Project Rules\n\nAdd your project-specific rules here.\nThese will be injected into JAE's system prompt.\n",
"utf-8",
);
ctx.ui.notify("Created .jae/rules.md - edit it to set project rules.", "info");
} else {
ctx.ui.notify(".jae/rules.md already exists.", "info");
}
return;
}
if (existsSync(rulesPath)) {
const rules = readFileSync(rulesPath, "utf-8");
ctx.ui.notify(
`\u{1F4CB} Project Rules (${rules.length} chars):\n${rules.substring(0, 500)}${rules.length > 500 ? "..." : ""}`,
"info",
);
} else {
ctx.ui.notify("No .jae/rules.md found. Run /rules init to create one.", "warning");
}
},
});
}