harness-bujang 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/dist/index.js +459 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -93,6 +93,48 @@ that any agent can pick up next time they read the chat.
|
|
|
93
93
|
Requires the `sqlite3` command-line tool (preinstalled on macOS; `apt-get install
|
|
94
94
|
sqlite3` on Ubuntu/WSL; sqlite-tools binaries on Windows).
|
|
95
95
|
|
|
96
|
+
### `adapt`
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
npx harness-bujang adapt --to=<target> [options]
|
|
100
|
+
|
|
101
|
+
Targets:
|
|
102
|
+
cursor → .cursor/rules/bujang-*.mdc (Cursor IDE)
|
|
103
|
+
cline → .clinerules/bujang-*.md (Cline)
|
|
104
|
+
aider → CONVENTIONS.md + .aider.conf.yml (Aider)
|
|
105
|
+
codex → AGENTS.md (OpenAI Codex CLI / Copilot Coding Agent / Cody)
|
|
106
|
+
gemini → GEMINI.md + .gemini/styleguide.md (Antigravity / Gemini CLI / Code Assist)
|
|
107
|
+
all → all of the above
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Converts the canonical `.claude/agents/*.md` install into the file formats other
|
|
111
|
+
editor / agent harness tools expect. The `.claude/agents/` directory remains the
|
|
112
|
+
single source of truth — re-run `bujang adapt --to=<target>` after changes to
|
|
113
|
+
keep adapters in sync.
|
|
114
|
+
|
|
115
|
+
Examples:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npx harness-bujang adapt --to=cursor # just Cursor
|
|
119
|
+
npx harness-bujang adapt --to=cursor,aider # multiple
|
|
120
|
+
npx harness-bujang adapt --to=all # everything
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Tools covered (5 adapter formats → 8+ tools):
|
|
124
|
+
|
|
125
|
+
| Tool | File the adapter writes |
|
|
126
|
+
|------|-------------------------|
|
|
127
|
+
| Cursor IDE | `.cursor/rules/bujang-*.mdc` (with frontmatter) |
|
|
128
|
+
| Cline | `.clinerules/bujang-*.md` |
|
|
129
|
+
| Aider | `CONVENTIONS.md` + `.aider.conf.yml` (`read:`) |
|
|
130
|
+
| OpenAI Codex CLI | `AGENTS.md` |
|
|
131
|
+
| GitHub Copilot Coding Agent | `AGENTS.md` |
|
|
132
|
+
| Sourcegraph Cody | `AGENTS.md` (recent versions) |
|
|
133
|
+
| Google Antigravity | `GEMINI.md` (highest priority) + falls back to `AGENTS.md` |
|
|
134
|
+
| Gemini CLI | `GEMINI.md` |
|
|
135
|
+
| Gemini Code Assist (workspace) | `GEMINI.md` (precedence) + `.gemini/styleguide.md` |
|
|
136
|
+
| Gemini Code Assist (GitHub PR review) | `.gemini/styleguide.md` |
|
|
137
|
+
|
|
96
138
|
## How the harness works once installed
|
|
97
139
|
|
|
98
140
|
```
|
package/dist/index.js
CHANGED
|
@@ -380,10 +380,13 @@ async function runInit(args) {
|
|
|
380
380
|
printBackendInstructions(opts.chatBackend, opts.commitChat);
|
|
381
381
|
} else {
|
|
382
382
|
console.log(
|
|
383
|
-
`${c.yellow("\
|
|
383
|
+
`${c.yellow("\u2139\uFE0E Chat-room UI (Next.js admin route) skipped")} ` + c.dim(`\u2014 your stack is detected as ${scan.framework}.`)
|
|
384
384
|
);
|
|
385
385
|
console.log(
|
|
386
|
-
c.dim("
|
|
386
|
+
` ${c.dim("To use the chat room on this stack, run")} ${c.bold("bujang chat")} ${c.dim("\u2014 it serves the")}`
|
|
387
|
+
);
|
|
388
|
+
console.log(
|
|
389
|
+
` ${c.dim("same KakaoTalk-style viewer at http://localhost:7777, no Next.js needed.")}`
|
|
387
390
|
);
|
|
388
391
|
console.log();
|
|
389
392
|
}
|
|
@@ -394,7 +397,11 @@ async function runInit(args) {
|
|
|
394
397
|
console.log(` ${c.cyan("1.")} Open Claude Code in this project`);
|
|
395
398
|
console.log(` ${c.cyan("2.")} Run ${c.bold("/bujang-status")} (if the plugin is installed) or just`);
|
|
396
399
|
console.log(` ask ${c.bold('"Director, please add a hello-world endpoint"')}`);
|
|
397
|
-
|
|
400
|
+
if (scan.framework.startsWith("Next.js") && opts.installTemplate) {
|
|
401
|
+
console.log(` ${c.cyan("3.")} Watch ${c.bold(context.ADMIN_HARNESS_ROUTE)} for live updates (after env setup)`);
|
|
402
|
+
} else {
|
|
403
|
+
console.log(` ${c.cyan("3.")} Watch the chat room: ${c.bold("npx harness-bujang chat --create")} ${c.dim("\u2192 http://localhost:7777")}`);
|
|
404
|
+
}
|
|
398
405
|
console.log();
|
|
399
406
|
}
|
|
400
407
|
async function promptInteractive(opts, scan) {
|
|
@@ -855,11 +862,11 @@ async function upsertEnvVar(envFile, key, value) {
|
|
|
855
862
|
}
|
|
856
863
|
async function confirm2(message) {
|
|
857
864
|
process.stdout.write(`${message} [y/N] `);
|
|
858
|
-
return new Promise((
|
|
865
|
+
return new Promise((resolve6) => {
|
|
859
866
|
process.stdin.setEncoding("utf8");
|
|
860
867
|
process.stdin.once("data", (chunk) => {
|
|
861
868
|
const ans = chunk.toString().trim().toLowerCase();
|
|
862
|
-
|
|
869
|
+
resolve6(ans === "y" || ans === "yes");
|
|
863
870
|
process.stdin.pause();
|
|
864
871
|
});
|
|
865
872
|
});
|
|
@@ -1002,7 +1009,7 @@ async function runChat(args) {
|
|
|
1002
1009
|
res.writeHead(404);
|
|
1003
1010
|
res.end("not found");
|
|
1004
1011
|
});
|
|
1005
|
-
await new Promise((
|
|
1012
|
+
await new Promise((resolve6) => server.listen(port, "127.0.0.1", resolve6));
|
|
1006
1013
|
const url = `http://localhost:${port}`;
|
|
1007
1014
|
console.log();
|
|
1008
1015
|
console.log(c4.bold(c4.green("\u{1F7E2} \uD558\uB124\uC2A4 \uD1A1\uBC29 viewer")) + c4.dim(" \u2014 " + url));
|
|
@@ -1054,12 +1061,12 @@ async function findOpenPort(preferred) {
|
|
|
1054
1061
|
throw new Error(`Could not find a free port in range ${preferred}-${preferred + 19}`);
|
|
1055
1062
|
}
|
|
1056
1063
|
function portIsFree(port) {
|
|
1057
|
-
return new Promise((
|
|
1064
|
+
return new Promise((resolve6) => {
|
|
1058
1065
|
const tester = http.createServer();
|
|
1059
|
-
tester.once("error", () =>
|
|
1066
|
+
tester.once("error", () => resolve6(false));
|
|
1060
1067
|
tester.once("listening", () => {
|
|
1061
1068
|
tester.close();
|
|
1062
|
-
|
|
1069
|
+
resolve6(true);
|
|
1063
1070
|
});
|
|
1064
1071
|
tester.listen(port, "127.0.0.1");
|
|
1065
1072
|
});
|
|
@@ -1073,10 +1080,10 @@ function openBrowser(url) {
|
|
|
1073
1080
|
}
|
|
1074
1081
|
}
|
|
1075
1082
|
function readBody(req) {
|
|
1076
|
-
return new Promise((
|
|
1083
|
+
return new Promise((resolve6, reject) => {
|
|
1077
1084
|
const chunks = [];
|
|
1078
1085
|
req.on("data", (chunk) => chunks.push(chunk));
|
|
1079
|
-
req.on("end", () =>
|
|
1086
|
+
req.on("end", () => resolve6(Buffer.concat(chunks).toString("utf8")));
|
|
1080
1087
|
req.on("error", reject);
|
|
1081
1088
|
});
|
|
1082
1089
|
}
|
|
@@ -1441,7 +1448,9 @@ setInterval(refresh, 2000);
|
|
|
1441
1448
|
`
|
|
1442
1449
|
);
|
|
1443
1450
|
|
|
1444
|
-
// src/
|
|
1451
|
+
// src/adapt.ts
|
|
1452
|
+
import * as fs6 from "fs/promises";
|
|
1453
|
+
import * as path6 from "path";
|
|
1445
1454
|
var c5 = {
|
|
1446
1455
|
bold: (s) => `\x1B[1m${s}\x1B[22m`,
|
|
1447
1456
|
dim: (s) => `\x1B[2m${s}\x1B[22m`,
|
|
@@ -1450,17 +1459,418 @@ var c5 = {
|
|
|
1450
1459
|
yellow: (s) => `\x1B[33m${s}\x1B[39m`,
|
|
1451
1460
|
cyan: (s) => `\x1B[36m${s}\x1B[39m`
|
|
1452
1461
|
};
|
|
1462
|
+
async function runAdapt(args) {
|
|
1463
|
+
const opts = parseArgs4(args);
|
|
1464
|
+
const agentsDir = path6.join(opts.target, ".claude/agents");
|
|
1465
|
+
if (!await exists5(agentsDir)) {
|
|
1466
|
+
console.log();
|
|
1467
|
+
console.log(c5.red("\u2716 No .claude/agents/ directory found at " + agentsDir));
|
|
1468
|
+
console.log();
|
|
1469
|
+
console.log(" Run " + c5.bold("npx harness-bujang init") + " first to install the canonical agents,");
|
|
1470
|
+
console.log(" then re-run this command to adapt them to your editor.");
|
|
1471
|
+
console.log();
|
|
1472
|
+
process.exitCode = 1;
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
const agentFiles = await loadAgents(agentsDir);
|
|
1476
|
+
if (agentFiles.length === 0) {
|
|
1477
|
+
console.log();
|
|
1478
|
+
console.log(c5.red("\u2716 .claude/agents/ exists but contains no .md files."));
|
|
1479
|
+
console.log();
|
|
1480
|
+
process.exitCode = 1;
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
console.log();
|
|
1484
|
+
console.log(c5.bold("\u{1F501} Harness-Bujang adapt"));
|
|
1485
|
+
console.log(c5.dim(` Target: ${opts.target}`));
|
|
1486
|
+
console.log(c5.dim(` Agents: ${agentFiles.length} files at .claude/agents/`));
|
|
1487
|
+
console.log(c5.dim(` Adapting: ${opts.to.join(", ")}`));
|
|
1488
|
+
console.log();
|
|
1489
|
+
for (const target of opts.to) {
|
|
1490
|
+
if (target === "cursor") await adaptCursor(opts.target, agentFiles, opts.yes);
|
|
1491
|
+
if (target === "cline") await adaptCline(opts.target, agentFiles, opts.yes);
|
|
1492
|
+
if (target === "aider") await adaptAider(opts.target, agentFiles, opts.yes);
|
|
1493
|
+
if (target === "codex") await adaptCodex(opts.target, agentFiles, opts.yes);
|
|
1494
|
+
if (target === "gemini") await adaptGemini(opts.target, agentFiles, opts.yes);
|
|
1495
|
+
}
|
|
1496
|
+
console.log(c5.bold(c5.green("\u2705 Done.")));
|
|
1497
|
+
console.log();
|
|
1498
|
+
console.log("Next:");
|
|
1499
|
+
if (opts.to.includes("cursor")) {
|
|
1500
|
+
console.log(` ${c5.cyan("\u2022")} Cursor users: open the project \u2014 rules in ${c5.bold(".cursor/rules/")} are auto-loaded`);
|
|
1501
|
+
}
|
|
1502
|
+
if (opts.to.includes("cline")) {
|
|
1503
|
+
console.log(` ${c5.cyan("\u2022")} Cline users: rules in ${c5.bold(".clinerules/")} are auto-loaded by Cline`);
|
|
1504
|
+
}
|
|
1505
|
+
if (opts.to.includes("aider")) {
|
|
1506
|
+
console.log(` ${c5.cyan("\u2022")} Aider users: ${c5.bold("CONVENTIONS.md")} is loaded via ${c5.bold(".aider.conf.yml")} (read:)`);
|
|
1507
|
+
}
|
|
1508
|
+
if (opts.to.includes("codex")) {
|
|
1509
|
+
console.log(` ${c5.cyan("\u2022")} Codex / Copilot Coding Agent users: ${c5.bold("AGENTS.md")} at the project root is auto-loaded`);
|
|
1510
|
+
}
|
|
1511
|
+
if (opts.to.includes("gemini")) {
|
|
1512
|
+
console.log(` ${c5.cyan("\u2022")} Antigravity / Gemini CLI / Code Assist: ${c5.bold("GEMINI.md")} (highest precedence) + ${c5.bold(".gemini/styleguide.md")} (PR reviews)`);
|
|
1513
|
+
}
|
|
1514
|
+
console.log();
|
|
1515
|
+
console.log(c5.dim(" When you change .claude/agents/ later, re-run this command to refresh."));
|
|
1516
|
+
console.log();
|
|
1517
|
+
}
|
|
1518
|
+
async function adaptCursor(target, agents, overwrite) {
|
|
1519
|
+
const dst = path6.join(target, ".cursor/rules");
|
|
1520
|
+
await fs6.mkdir(dst, { recursive: true });
|
|
1521
|
+
console.log(c5.bold("\u{1F4C2} Cursor \u2014 .cursor/rules/"));
|
|
1522
|
+
for (const a of agents) {
|
|
1523
|
+
const file = path6.join(dst, `bujang-${a.slug}.mdc`);
|
|
1524
|
+
if (await exists5(file) && !overwrite) {
|
|
1525
|
+
console.log(` ${c5.yellow("\u26A0")} bujang-${a.slug}.mdc ${c5.dim("(exists, skipped \u2014 use --yes to overwrite)")}`);
|
|
1526
|
+
continue;
|
|
1527
|
+
}
|
|
1528
|
+
const description = a.frontmatter.description || `Harness-Bujang ${a.slug}`;
|
|
1529
|
+
const out = `---
|
|
1530
|
+
description: "Harness-Bujang ${a.slug}: ${escapeYamlString(description.replace(/\n/g, " ").slice(0, 240))}"
|
|
1531
|
+
alwaysApply: false
|
|
1532
|
+
---
|
|
1533
|
+
|
|
1534
|
+
# Harness-Bujang \u2014 ${a.slug} role guide
|
|
1535
|
+
|
|
1536
|
+
> Source of truth: \`.claude/agents/${a.slug}.md\` \u2014 re-run \`bujang adapt --to=cursor\` to sync.
|
|
1537
|
+
|
|
1538
|
+
When the user request matches this role's domain (see description above), follow this guide as your primary system prompt for the response. Other rules under this directory describe sibling roles in the same harness.
|
|
1539
|
+
|
|
1540
|
+
---
|
|
1541
|
+
|
|
1542
|
+
` + a.body.trim() + `
|
|
1543
|
+
`;
|
|
1544
|
+
await fs6.writeFile(file, out);
|
|
1545
|
+
console.log(` ${c5.green("\u2713")} bujang-${a.slug}.mdc`);
|
|
1546
|
+
}
|
|
1547
|
+
console.log();
|
|
1548
|
+
}
|
|
1549
|
+
async function adaptCline(target, agents, overwrite) {
|
|
1550
|
+
const dst = path6.join(target, ".clinerules");
|
|
1551
|
+
await fs6.mkdir(dst, { recursive: true });
|
|
1552
|
+
console.log(c5.bold("\u{1F4C2} Cline \u2014 .clinerules/"));
|
|
1553
|
+
for (const a of agents) {
|
|
1554
|
+
const file = path6.join(dst, `bujang-${a.slug}.md`);
|
|
1555
|
+
if (await exists5(file) && !overwrite) {
|
|
1556
|
+
console.log(` ${c5.yellow("\u26A0")} bujang-${a.slug}.md ${c5.dim("(exists, skipped \u2014 use --yes to overwrite)")}`);
|
|
1557
|
+
continue;
|
|
1558
|
+
}
|
|
1559
|
+
const description = a.frontmatter.description || "";
|
|
1560
|
+
const out = `# Harness-Bujang \u2014 ${a.slug}
|
|
1561
|
+
|
|
1562
|
+
` + (description ? `${description}
|
|
1563
|
+
|
|
1564
|
+
` : "") + `> Source of truth: \`.claude/agents/${a.slug}.md\` \u2014 re-run \`bujang adapt --to=cline\` to sync.
|
|
1565
|
+
|
|
1566
|
+
---
|
|
1567
|
+
|
|
1568
|
+
` + a.body.trim() + `
|
|
1569
|
+
`;
|
|
1570
|
+
await fs6.writeFile(file, out);
|
|
1571
|
+
console.log(` ${c5.green("\u2713")} bujang-${a.slug}.md`);
|
|
1572
|
+
}
|
|
1573
|
+
console.log();
|
|
1574
|
+
}
|
|
1575
|
+
async function adaptAider(target, agents, overwrite) {
|
|
1576
|
+
console.log(c5.bold("\u{1F4C2} Aider \u2014 CONVENTIONS.md + .aider.conf.yml"));
|
|
1577
|
+
const conventionsPath = path6.join(target, "CONVENTIONS.md");
|
|
1578
|
+
const conventionsExisted = await exists5(conventionsPath);
|
|
1579
|
+
if (conventionsExisted && !overwrite) {
|
|
1580
|
+
console.log(` ${c5.yellow("\u26A0")} CONVENTIONS.md ${c5.dim("(exists, skipped \u2014 use --yes to overwrite)")}`);
|
|
1581
|
+
} else {
|
|
1582
|
+
let body = `# Project Conventions \u2014 Harness-Bujang
|
|
1583
|
+
|
|
1584
|
+
`;
|
|
1585
|
+
body += `> Source of truth: \`.claude/agents/*.md\` \u2014 re-run \`bujang adapt --to=aider\` to sync.
|
|
1586
|
+
|
|
1587
|
+
`;
|
|
1588
|
+
body += `This file collects the multi-agent harness role guides into a single conventions file that Aider can load via \`.aider.conf.yml\`. Aider does not natively dispatch to subagents, so when the user's request matches a specific role's domain, internally adopt that role's instructions for the response.
|
|
1589
|
+
|
|
1590
|
+
`;
|
|
1591
|
+
body += `## Roles
|
|
1592
|
+
|
|
1593
|
+
`;
|
|
1594
|
+
for (const a of agents) {
|
|
1595
|
+
const desc = a.frontmatter.description || "";
|
|
1596
|
+
body += `- **${a.slug}**${desc ? ` \u2014 ${desc.replace(/\n/g, " ").slice(0, 200)}` : ""}
|
|
1597
|
+
`;
|
|
1598
|
+
}
|
|
1599
|
+
body += `
|
|
1600
|
+
---
|
|
1601
|
+
|
|
1602
|
+
`;
|
|
1603
|
+
for (const a of agents) {
|
|
1604
|
+
body += `## ${a.slug}
|
|
1605
|
+
|
|
1606
|
+
`;
|
|
1607
|
+
body += a.body.trim() + `
|
|
1608
|
+
|
|
1609
|
+
---
|
|
1610
|
+
|
|
1611
|
+
`;
|
|
1612
|
+
}
|
|
1613
|
+
await fs6.writeFile(conventionsPath, body);
|
|
1614
|
+
console.log(` ${c5.green("\u2713")} CONVENTIONS.md ${c5.dim(`(${agents.length} roles concatenated)`)}`);
|
|
1615
|
+
}
|
|
1616
|
+
const aiderConfPath = path6.join(target, ".aider.conf.yml");
|
|
1617
|
+
const existing = await exists5(aiderConfPath) ? await fs6.readFile(aiderConfPath, "utf8") : "";
|
|
1618
|
+
if (existing.includes("CONVENTIONS.md")) {
|
|
1619
|
+
console.log(` ${c5.dim("\u2022")} .aider.conf.yml already references CONVENTIONS.md \u2014 left untouched`);
|
|
1620
|
+
} else if (existing && !overwrite) {
|
|
1621
|
+
console.log(` ${c5.yellow("\u26A0")} .aider.conf.yml exists and does NOT reference CONVENTIONS.md \u2014 skipped`);
|
|
1622
|
+
console.log(` ${c5.dim("Add manually:")} read: CONVENTIONS.md`);
|
|
1623
|
+
} else {
|
|
1624
|
+
const out = existing ? existing.trimEnd() + `
|
|
1625
|
+
|
|
1626
|
+
# Added by harness-bujang adapt
|
|
1627
|
+
read: CONVENTIONS.md
|
|
1628
|
+
` : `# Aider config \u2014 auto-loads Harness-Bujang conventions
|
|
1629
|
+
read: CONVENTIONS.md
|
|
1630
|
+
`;
|
|
1631
|
+
await fs6.writeFile(aiderConfPath, out);
|
|
1632
|
+
console.log(` ${c5.green("\u2713")} .aider.conf.yml ${c5.dim("(read: CONVENTIONS.md)")}`);
|
|
1633
|
+
}
|
|
1634
|
+
console.log();
|
|
1635
|
+
}
|
|
1636
|
+
async function adaptCodex(target, agents, overwrite) {
|
|
1637
|
+
console.log(c5.bold("\u{1F4C2} Codex / Copilot Agent \u2014 AGENTS.md (project root)"));
|
|
1638
|
+
const filePath = path6.join(target, "AGENTS.md");
|
|
1639
|
+
if (await exists5(filePath) && !overwrite) {
|
|
1640
|
+
console.log(` ${c5.yellow("\u26A0")} AGENTS.md ${c5.dim("(exists, skipped \u2014 use --yes to overwrite)")}`);
|
|
1641
|
+
console.log();
|
|
1642
|
+
return;
|
|
1643
|
+
}
|
|
1644
|
+
let body = `# AGENTS.md \u2014 Harness-Bujang multi-agent harness
|
|
1645
|
+
|
|
1646
|
+
`;
|
|
1647
|
+
body += `> Source of truth: \`.claude/agents/*.md\` \u2014 re-run \`bujang adapt --to=codex\` to sync.
|
|
1648
|
+
|
|
1649
|
+
`;
|
|
1650
|
+
body += `This file follows the AGENTS.md convention adopted by OpenAI Codex CLI, GitHub Copilot Coding Agent, and several other agentic coding tools. It collects the harness role guides into a single document.
|
|
1651
|
+
|
|
1652
|
+
`;
|
|
1653
|
+
body += `When the user's request matches one of the role domains below, internally adopt that role's instructions for the response. If the request spans multiple domains, follow the **director** role's dispatch logic.
|
|
1654
|
+
|
|
1655
|
+
`;
|
|
1656
|
+
body += `## Roles
|
|
1657
|
+
|
|
1658
|
+
`;
|
|
1659
|
+
for (const a of agents) {
|
|
1660
|
+
const desc = a.frontmatter.description || "";
|
|
1661
|
+
body += `- **${a.slug}**${desc ? ` \u2014 ${desc.replace(/\n/g, " ").slice(0, 200)}` : ""}
|
|
1662
|
+
`;
|
|
1663
|
+
}
|
|
1664
|
+
body += `
|
|
1665
|
+
---
|
|
1666
|
+
|
|
1667
|
+
`;
|
|
1668
|
+
for (const a of agents) {
|
|
1669
|
+
body += `## ${a.slug}
|
|
1670
|
+
|
|
1671
|
+
`;
|
|
1672
|
+
body += a.body.trim() + `
|
|
1673
|
+
|
|
1674
|
+
---
|
|
1675
|
+
|
|
1676
|
+
`;
|
|
1677
|
+
}
|
|
1678
|
+
await fs6.writeFile(filePath, body);
|
|
1679
|
+
console.log(` ${c5.green("\u2713")} AGENTS.md ${c5.dim(`(${agents.length} roles concatenated, ${(body.length / 1024).toFixed(1)} KB)`)}`);
|
|
1680
|
+
console.log();
|
|
1681
|
+
}
|
|
1682
|
+
async function adaptGemini(target, agents, overwrite) {
|
|
1683
|
+
console.log(c5.bold("\u{1F4C2} Gemini / Antigravity \u2014 GEMINI.md + .gemini/styleguide.md"));
|
|
1684
|
+
const geminiMdPath = path6.join(target, "GEMINI.md");
|
|
1685
|
+
if (await exists5(geminiMdPath) && !overwrite) {
|
|
1686
|
+
console.log(` ${c5.yellow("\u26A0")} GEMINI.md ${c5.dim("(exists, skipped \u2014 use --yes to overwrite)")}`);
|
|
1687
|
+
} else {
|
|
1688
|
+
let body = `# GEMINI.md \u2014 Harness-Bujang multi-agent harness
|
|
1689
|
+
|
|
1690
|
+
`;
|
|
1691
|
+
body += `> Source of truth: \`.claude/agents/*.md\` \u2014 re-run \`bujang adapt --to=gemini\` to sync.
|
|
1692
|
+
|
|
1693
|
+
`;
|
|
1694
|
+
body += `This file is read by Google Antigravity (workspace highest priority), Gemini CLI, and Gemini Code Assist (workspace customization). It collects the harness role guides into a single document.
|
|
1695
|
+
|
|
1696
|
+
`;
|
|
1697
|
+
body += `When the user's request matches one of the role domains below, internally adopt that role's instructions for the response. If the request spans multiple domains, follow the **director** role's dispatch logic.
|
|
1698
|
+
|
|
1699
|
+
`;
|
|
1700
|
+
body += `## Roles
|
|
1701
|
+
|
|
1702
|
+
`;
|
|
1703
|
+
for (const a of agents) {
|
|
1704
|
+
const desc = a.frontmatter.description || "";
|
|
1705
|
+
body += `- **${a.slug}**${desc ? ` \u2014 ${desc.replace(/\n/g, " ").slice(0, 200)}` : ""}
|
|
1706
|
+
`;
|
|
1707
|
+
}
|
|
1708
|
+
body += `
|
|
1709
|
+
---
|
|
1710
|
+
|
|
1711
|
+
`;
|
|
1712
|
+
for (const a of agents) {
|
|
1713
|
+
body += `## ${a.slug}
|
|
1714
|
+
|
|
1715
|
+
`;
|
|
1716
|
+
body += a.body.trim() + `
|
|
1717
|
+
|
|
1718
|
+
---
|
|
1719
|
+
|
|
1720
|
+
`;
|
|
1721
|
+
}
|
|
1722
|
+
await fs6.writeFile(geminiMdPath, body);
|
|
1723
|
+
console.log(` ${c5.green("\u2713")} GEMINI.md ${c5.dim(`(${agents.length} roles concatenated, ${(body.length / 1024).toFixed(1)} KB)`)}`);
|
|
1724
|
+
}
|
|
1725
|
+
const styleguideDir = path6.join(target, ".gemini");
|
|
1726
|
+
await fs6.mkdir(styleguideDir, { recursive: true });
|
|
1727
|
+
const styleguidePath = path6.join(styleguideDir, "styleguide.md");
|
|
1728
|
+
if (await exists5(styleguidePath) && !overwrite) {
|
|
1729
|
+
console.log(` ${c5.yellow("\u26A0")} .gemini/styleguide.md ${c5.dim("(exists, skipped)")}`);
|
|
1730
|
+
} else {
|
|
1731
|
+
const reviewRoles = ["code-review-team", "security-team", "db-guard-team", "verifier-team"];
|
|
1732
|
+
const reviewAgents = agents.filter((a) => reviewRoles.includes(a.slug));
|
|
1733
|
+
let body = `# Code Review Style Guide \u2014 Harness-Bujang
|
|
1734
|
+
|
|
1735
|
+
`;
|
|
1736
|
+
body += `> Source of truth: \`.claude/agents/*.md\` \u2014 re-run \`bujang adapt --to=gemini\` to sync.
|
|
1737
|
+
|
|
1738
|
+
`;
|
|
1739
|
+
body += `This style guide is read by Gemini Code Assist for GitHub when reviewing PRs. It distills the review-relevant subset of the Harness-Bujang harness (code review, security, DB guard, verifier teams) into review criteria.
|
|
1740
|
+
|
|
1741
|
+
`;
|
|
1742
|
+
body += `When reviewing a PR, apply the following audit lenses in order:
|
|
1743
|
+
|
|
1744
|
+
`;
|
|
1745
|
+
for (const a of reviewAgents) {
|
|
1746
|
+
body += `## ${a.slug}
|
|
1747
|
+
|
|
1748
|
+
`;
|
|
1749
|
+
body += a.body.trim() + `
|
|
1750
|
+
|
|
1751
|
+
---
|
|
1752
|
+
|
|
1753
|
+
`;
|
|
1754
|
+
}
|
|
1755
|
+
if (reviewAgents.length === 0) {
|
|
1756
|
+
body += `_(No review-team agents found in .claude/agents/. Re-run init to install the canonical set.)_
|
|
1757
|
+
`;
|
|
1758
|
+
}
|
|
1759
|
+
await fs6.writeFile(styleguidePath, body);
|
|
1760
|
+
console.log(` ${c5.green("\u2713")} .gemini/styleguide.md ${c5.dim(`(${reviewAgents.length} review roles)`)}`);
|
|
1761
|
+
}
|
|
1762
|
+
console.log();
|
|
1763
|
+
}
|
|
1764
|
+
async function loadAgents(agentsDir) {
|
|
1765
|
+
const entries = await fs6.readdir(agentsDir);
|
|
1766
|
+
const out = [];
|
|
1767
|
+
for (const name of entries) {
|
|
1768
|
+
if (!name.endsWith(".md")) continue;
|
|
1769
|
+
const src = path6.join(agentsDir, name);
|
|
1770
|
+
const raw = await fs6.readFile(src, "utf8");
|
|
1771
|
+
const slug = name.replace(/\.md$/, "");
|
|
1772
|
+
const { frontmatter, body } = splitFrontmatter(raw);
|
|
1773
|
+
out.push({ slug, frontmatter, body, src });
|
|
1774
|
+
}
|
|
1775
|
+
out.sort((a, b) => {
|
|
1776
|
+
if (a.slug === "director") return -1;
|
|
1777
|
+
if (b.slug === "director") return 1;
|
|
1778
|
+
return a.slug.localeCompare(b.slug);
|
|
1779
|
+
});
|
|
1780
|
+
return out;
|
|
1781
|
+
}
|
|
1782
|
+
function splitFrontmatter(raw) {
|
|
1783
|
+
if (!raw.startsWith("---\n")) {
|
|
1784
|
+
return { frontmatter: {}, body: raw };
|
|
1785
|
+
}
|
|
1786
|
+
const end = raw.indexOf("\n---\n", 4);
|
|
1787
|
+
if (end < 0) {
|
|
1788
|
+
return { frontmatter: {}, body: raw };
|
|
1789
|
+
}
|
|
1790
|
+
const fmRaw = raw.slice(4, end);
|
|
1791
|
+
const body = raw.slice(end + 5);
|
|
1792
|
+
const frontmatter = {};
|
|
1793
|
+
const lines = fmRaw.split(/\r?\n/);
|
|
1794
|
+
let currentKey = null;
|
|
1795
|
+
for (const line of lines) {
|
|
1796
|
+
const m = /^([a-zA-Z_-]+):\s?(.*)$/.exec(line);
|
|
1797
|
+
if (m && m[1] && !line.startsWith(" ") && !line.startsWith(" ")) {
|
|
1798
|
+
currentKey = m[1];
|
|
1799
|
+
frontmatter[currentKey] = m[2] ?? "";
|
|
1800
|
+
} else if (currentKey && (line.startsWith(" ") || line.startsWith(" "))) {
|
|
1801
|
+
frontmatter[currentKey] = (frontmatter[currentKey] ?? "") + " " + line.trim();
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
return { frontmatter, body };
|
|
1805
|
+
}
|
|
1806
|
+
function escapeYamlString(s) {
|
|
1807
|
+
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
1808
|
+
}
|
|
1809
|
+
function parseArgs4(args) {
|
|
1810
|
+
const targetRaw = getFlag4(args, "--target") ?? ".";
|
|
1811
|
+
const toRaw = getFlag4(args, "--to");
|
|
1812
|
+
if (!toRaw) {
|
|
1813
|
+
throw new Error(
|
|
1814
|
+
`--to=<cursor|cline|aider|codex|gemini|all> is required. Examples:
|
|
1815
|
+
bujang adapt --to=cursor
|
|
1816
|
+
bujang adapt --to=codex # AGENTS.md at project root
|
|
1817
|
+
bujang adapt --to=gemini # GEMINI.md + .gemini/styleguide.md
|
|
1818
|
+
bujang adapt --to=cursor,aider # multiple
|
|
1819
|
+
bujang adapt --to=all # cursor + cline + aider + codex + gemini`
|
|
1820
|
+
);
|
|
1821
|
+
}
|
|
1822
|
+
const targets = toRaw === "all" ? ["cursor", "cline", "aider", "codex", "gemini"] : toRaw.split(",").map((t) => t.trim());
|
|
1823
|
+
for (const t of targets) {
|
|
1824
|
+
if (!["cursor", "cline", "aider", "codex", "gemini"].includes(t)) {
|
|
1825
|
+
throw new Error(`Unknown adapter target "${t}" \u2014 expected one of: cursor, cline, aider, codex, gemini, all`);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
return {
|
|
1829
|
+
target: path6.resolve(targetRaw),
|
|
1830
|
+
to: targets,
|
|
1831
|
+
yes: args.includes("--yes") || args.includes("-y")
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
function getFlag4(args, name) {
|
|
1835
|
+
for (const a of args) {
|
|
1836
|
+
if (a.startsWith(`${name}=`)) return a.slice(name.length + 1);
|
|
1837
|
+
}
|
|
1838
|
+
const idx = args.indexOf(name);
|
|
1839
|
+
if (idx >= 0 && idx + 1 < args.length && !args[idx + 1].startsWith("--")) {
|
|
1840
|
+
return args[idx + 1];
|
|
1841
|
+
}
|
|
1842
|
+
return void 0;
|
|
1843
|
+
}
|
|
1844
|
+
async function exists5(p) {
|
|
1845
|
+
try {
|
|
1846
|
+
await fs6.access(p);
|
|
1847
|
+
return true;
|
|
1848
|
+
} catch {
|
|
1849
|
+
return false;
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
// src/index.ts
|
|
1854
|
+
var c6 = {
|
|
1855
|
+
bold: (s) => `\x1B[1m${s}\x1B[22m`,
|
|
1856
|
+
dim: (s) => `\x1B[2m${s}\x1B[22m`,
|
|
1857
|
+
green: (s) => `\x1B[32m${s}\x1B[39m`,
|
|
1858
|
+
red: (s) => `\x1B[31m${s}\x1B[39m`,
|
|
1859
|
+
yellow: (s) => `\x1B[33m${s}\x1B[39m`,
|
|
1860
|
+
cyan: (s) => `\x1B[36m${s}\x1B[39m`
|
|
1861
|
+
};
|
|
1453
1862
|
var HELP = `
|
|
1454
|
-
${
|
|
1455
|
-
${
|
|
1863
|
+
${c6.bold("harness-bujang")} \u2014 Korean-style multi-agent harness director for Claude Code
|
|
1864
|
+
${c6.dim("https://github.com/bjcho4141/harness-bujang")}
|
|
1456
1865
|
|
|
1457
|
-
${
|
|
1458
|
-
npx harness-bujang ${
|
|
1459
|
-
npx harness-bujang ${
|
|
1460
|
-
npx harness-bujang ${
|
|
1461
|
-
npx harness-bujang ${
|
|
1866
|
+
${c6.bold("Usage:")}
|
|
1867
|
+
npx harness-bujang ${c6.cyan("init")} [options] Install the harness into a project
|
|
1868
|
+
npx harness-bujang ${c6.cyan("status")} [options] Verify the harness install
|
|
1869
|
+
npx harness-bujang ${c6.cyan("chat")} [options] Open the standalone chat-room viewer (any stack)
|
|
1870
|
+
npx harness-bujang ${c6.cyan("adapt")} --to=<cursor|cline|aider|codex|gemini|all> Convert .claude/agents/ for other tools
|
|
1871
|
+
npx harness-bujang ${c6.cyan("migrate")} --to=<sqlite|supabase> Move chat data between backends
|
|
1462
1872
|
|
|
1463
|
-
${
|
|
1873
|
+
${c6.bold("Options for init:")}
|
|
1464
1874
|
--lang=<ko|en> Agent language (default: en)
|
|
1465
1875
|
--chat=<sqlite|supabase> Chat-room backend (default: sqlite \u2014 local file, no setup)
|
|
1466
1876
|
--commit-chat Don't gitignore .harness/ (for solo cross-machine sync via git)
|
|
@@ -1472,37 +1882,49 @@ ${c5.bold("Options for init:")}
|
|
|
1472
1882
|
--no-learning-log Skip learning log seed
|
|
1473
1883
|
--yes, -y Skip prompts and overwrite (non-interactive \u2014 for CI / scripts)
|
|
1474
1884
|
|
|
1475
|
-
${
|
|
1885
|
+
${c6.dim("Run without --yes for an interactive setup (prompts for language, backend, etc.).")}
|
|
1476
1886
|
|
|
1477
|
-
${
|
|
1887
|
+
${c6.bold("Options for chat:")}
|
|
1478
1888
|
--target=<path> Project root (default: cwd)
|
|
1479
1889
|
--port=<number> Preferred port (default: 7777, falls forward if busy)
|
|
1480
1890
|
--no-open Don't auto-open the browser
|
|
1481
1891
|
--create Create an empty chat DB + schema if none exists yet
|
|
1482
1892
|
|
|
1483
|
-
${
|
|
1893
|
+
${c6.bold("Options for adapt:")}
|
|
1894
|
+
--to=<cursor|cline|aider|codex|gemini|all> Required \u2014 comma-separated list also OK
|
|
1895
|
+
--target=<path> Project root (default: cwd)
|
|
1896
|
+
--yes, -y Overwrite existing adapter files
|
|
1897
|
+
|
|
1898
|
+
${c6.dim("Adapter targets:")}
|
|
1899
|
+
${c6.dim(" cursor \u2192 .cursor/rules/bujang-*.mdc (Cursor IDE)")}
|
|
1900
|
+
${c6.dim(" cline \u2192 .clinerules/bujang-*.md (Cline)")}
|
|
1901
|
+
${c6.dim(" aider \u2192 CONVENTIONS.md + .aider.conf.yml (Aider)")}
|
|
1902
|
+
${c6.dim(" codex \u2192 AGENTS.md (Codex CLI / Copilot Coding Agent / Cody)")}
|
|
1903
|
+
${c6.dim(" gemini \u2192 GEMINI.md + .gemini/styleguide.md (Antigravity / Gemini CLI / Code Assist)")}
|
|
1904
|
+
|
|
1905
|
+
${c6.bold("Options for migrate:")}
|
|
1484
1906
|
--to=<sqlite|supabase> Required \u2014 target backend
|
|
1485
1907
|
--target=<path> Project root (default: cwd)
|
|
1486
1908
|
--yes, -y Skip confirmation
|
|
1487
1909
|
|
|
1488
|
-
${
|
|
1489
|
-
${
|
|
1910
|
+
${c6.bold("Examples:")}
|
|
1911
|
+
${c6.dim("# Install Korean Bujang persona, SQLite chat (default \u2014 zero setup)")}
|
|
1490
1912
|
npx harness-bujang init --lang=ko
|
|
1491
1913
|
|
|
1492
|
-
${
|
|
1914
|
+
${c6.dim("# Open the standalone chat-room \u2014 works on ANY stack (Next.js, Rails, Django, \u2026)")}
|
|
1493
1915
|
npx harness-bujang chat
|
|
1494
|
-
${
|
|
1916
|
+
${c6.dim("# \u2192 opens http://localhost:7777 in your browser")}
|
|
1495
1917
|
|
|
1496
|
-
${
|
|
1918
|
+
${c6.dim("# Solo, multiple machines \u2014 sync chat history via git")}
|
|
1497
1919
|
npx harness-bujang init --commit-chat
|
|
1498
1920
|
|
|
1499
|
-
${
|
|
1921
|
+
${c6.dim("# Production project with team sharing \u2014 Supabase backend")}
|
|
1500
1922
|
npx harness-bujang init --chat=supabase
|
|
1501
1923
|
|
|
1502
|
-
${
|
|
1924
|
+
${c6.dim("# Started solo, now scaling up \u2014 promote to cloud")}
|
|
1503
1925
|
bujang migrate --to=supabase
|
|
1504
1926
|
|
|
1505
|
-
${
|
|
1927
|
+
${c6.dim("# Going back to solo / archive \u2014 pull cloud data into local SQLite")}
|
|
1506
1928
|
bujang migrate --to=sqlite
|
|
1507
1929
|
`;
|
|
1508
1930
|
async function main() {
|
|
@@ -1518,12 +1940,15 @@ async function main() {
|
|
|
1518
1940
|
case "chat":
|
|
1519
1941
|
await runChat(args.slice(1));
|
|
1520
1942
|
break;
|
|
1943
|
+
case "adapt":
|
|
1944
|
+
await runAdapt(args.slice(1));
|
|
1945
|
+
break;
|
|
1521
1946
|
case "migrate":
|
|
1522
1947
|
await runMigrate(args.slice(1));
|
|
1523
1948
|
break;
|
|
1524
1949
|
case "--version":
|
|
1525
1950
|
case "-v":
|
|
1526
|
-
console.log("0.
|
|
1951
|
+
console.log("0.4.0");
|
|
1527
1952
|
break;
|
|
1528
1953
|
case "--help":
|
|
1529
1954
|
case "-h":
|
|
@@ -1531,13 +1956,13 @@ async function main() {
|
|
|
1531
1956
|
console.log(HELP);
|
|
1532
1957
|
break;
|
|
1533
1958
|
default:
|
|
1534
|
-
console.error(
|
|
1959
|
+
console.error(c6.red(`Unknown command: ${command}`));
|
|
1535
1960
|
console.log(HELP);
|
|
1536
1961
|
process.exit(1);
|
|
1537
1962
|
}
|
|
1538
1963
|
}
|
|
1539
1964
|
main().catch((err) => {
|
|
1540
|
-
console.error(
|
|
1965
|
+
console.error(c6.red(`
|
|
1541
1966
|
\u2716 ${err.message}`));
|
|
1542
1967
|
if (process.env.DEBUG) console.error(err.stack);
|
|
1543
1968
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "harness-bujang",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Install the Harness-Bujang multi-agent harness into any project — Director, 7 specialist teams, real-time chat-room UI. Korean and English personas. Works with Claude Code, Cursor, Cline, Aider, or any tool that reads .claude/agents/.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|