oneagent 0.2.3 → 0.2.4
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/dist/index.js +99 -87
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8243,6 +8243,7 @@ var init_dist4 = __esm(() => {
|
|
|
8243
8243
|
|
|
8244
8244
|
// ../core/src/config.ts
|
|
8245
8245
|
import path from "path";
|
|
8246
|
+
import fs from "fs/promises";
|
|
8246
8247
|
function activeTargets(config) {
|
|
8247
8248
|
return ALL_AGENT_TARGETS.filter((t) => config.targets[t]);
|
|
8248
8249
|
}
|
|
@@ -8250,15 +8251,16 @@ function makeTargets(...enabled) {
|
|
|
8250
8251
|
return Object.fromEntries(ALL_AGENT_TARGETS.map((t) => [t, enabled.includes(t)]));
|
|
8251
8252
|
}
|
|
8252
8253
|
async function configExists(root) {
|
|
8253
|
-
return
|
|
8254
|
+
return fs.access(path.join(root, CONFIG_REL)).then(() => true, () => false);
|
|
8254
8255
|
}
|
|
8255
8256
|
async function readConfig(root) {
|
|
8256
|
-
const content = await
|
|
8257
|
+
const content = await fs.readFile(path.join(root, CONFIG_REL), "utf-8");
|
|
8257
8258
|
return $parse(content);
|
|
8258
8259
|
}
|
|
8259
8260
|
async function writeConfig(root, config) {
|
|
8260
8261
|
const filePath = path.join(root, CONFIG_REL);
|
|
8261
|
-
await
|
|
8262
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
8263
|
+
await fs.writeFile(filePath, $stringify(config));
|
|
8262
8264
|
}
|
|
8263
8265
|
var CONFIG_REL = ".oneagent/config.yml", ALL_AGENT_TARGETS;
|
|
8264
8266
|
var init_config = __esm(() => {
|
|
@@ -8268,18 +8270,18 @@ var init_config = __esm(() => {
|
|
|
8268
8270
|
|
|
8269
8271
|
// ../core/src/detect.ts
|
|
8270
8272
|
import path2 from "path";
|
|
8271
|
-
import
|
|
8273
|
+
import fs2 from "fs/promises";
|
|
8272
8274
|
async function readDetectedFile(root, rel) {
|
|
8273
8275
|
const absolutePath = path2.join(root, rel);
|
|
8274
8276
|
try {
|
|
8275
|
-
const stat = await
|
|
8277
|
+
const stat = await fs2.lstat(absolutePath);
|
|
8276
8278
|
if (stat.isSymbolicLink()) {
|
|
8277
|
-
const linkTarget = await
|
|
8279
|
+
const linkTarget = await fs2.readlink(absolutePath);
|
|
8278
8280
|
const resolved = path2.resolve(path2.dirname(absolutePath), linkTarget);
|
|
8279
8281
|
if (resolved.startsWith(path2.join(root, ".one")))
|
|
8280
8282
|
return null;
|
|
8281
8283
|
}
|
|
8282
|
-
const content = await
|
|
8284
|
+
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
8283
8285
|
return {
|
|
8284
8286
|
relativePath: rel,
|
|
8285
8287
|
absolutePath,
|
|
@@ -8305,16 +8307,16 @@ async function removeDeprecatedFiles(root) {
|
|
|
8305
8307
|
for (const rel of DEPRECATED_FILES) {
|
|
8306
8308
|
const absPath = path2.join(root, rel);
|
|
8307
8309
|
try {
|
|
8308
|
-
const stat = await
|
|
8310
|
+
const stat = await fs2.lstat(absPath);
|
|
8309
8311
|
if (!stat.isSymbolicLink())
|
|
8310
|
-
await
|
|
8312
|
+
await fs2.unlink(absPath);
|
|
8311
8313
|
} catch {}
|
|
8312
8314
|
}
|
|
8313
8315
|
}
|
|
8314
8316
|
async function detectDeprecatedCommandFiles(root) {
|
|
8315
8317
|
const commandsDir = path2.join(root, ".claude/commands");
|
|
8316
8318
|
try {
|
|
8317
|
-
const entries = await
|
|
8319
|
+
const entries = await fs2.readdir(commandsDir, { withFileTypes: true });
|
|
8318
8320
|
return entries.filter((e2) => e2.isFile()).map((e2) => path2.join(".claude/commands", e2.name));
|
|
8319
8321
|
} catch {
|
|
8320
8322
|
return [];
|
|
@@ -8334,7 +8336,7 @@ var init_detect = __esm(() => {
|
|
|
8334
8336
|
|
|
8335
8337
|
// ../core/src/rules.ts
|
|
8336
8338
|
import path3 from "path";
|
|
8337
|
-
import
|
|
8339
|
+
import fs3 from "fs/promises";
|
|
8338
8340
|
function parseFrontmatter(raw) {
|
|
8339
8341
|
const match = raw.match(/^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/);
|
|
8340
8342
|
if (!match)
|
|
@@ -8346,14 +8348,14 @@ function parseFrontmatter(raw) {
|
|
|
8346
8348
|
return { applyTo, content };
|
|
8347
8349
|
}
|
|
8348
8350
|
async function readRuleFile(filePath) {
|
|
8349
|
-
const raw = await
|
|
8351
|
+
const raw = await fs3.readFile(filePath, "utf-8");
|
|
8350
8352
|
const { applyTo, content } = parseFrontmatter(raw);
|
|
8351
8353
|
return { name: path3.basename(filePath, ".md"), path: filePath, applyTo, content };
|
|
8352
8354
|
}
|
|
8353
8355
|
async function readRules(root) {
|
|
8354
8356
|
const rulesDir = path3.join(root, ".oneagent/rules");
|
|
8355
8357
|
try {
|
|
8356
|
-
const files = await
|
|
8358
|
+
const files = await fs3.readdir(rulesDir);
|
|
8357
8359
|
const mdFiles = files.filter((f) => f.endsWith(".md"));
|
|
8358
8360
|
const rules = await Promise.all(mdFiles.map((f) => readRuleFile(path3.join(rulesDir, f))));
|
|
8359
8361
|
return rules.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -8365,7 +8367,7 @@ var init_rules = () => {};
|
|
|
8365
8367
|
|
|
8366
8368
|
// ../core/src/skills.ts
|
|
8367
8369
|
import path4 from "path";
|
|
8368
|
-
import
|
|
8370
|
+
import fs4 from "fs/promises";
|
|
8369
8371
|
function parseSkillFrontmatter(raw) {
|
|
8370
8372
|
const match = raw.match(/^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/);
|
|
8371
8373
|
if (!match)
|
|
@@ -8380,14 +8382,14 @@ function parseSkillFrontmatter(raw) {
|
|
|
8380
8382
|
return { description, mode, content };
|
|
8381
8383
|
}
|
|
8382
8384
|
async function readSkillFile(filePath) {
|
|
8383
|
-
const raw = await
|
|
8385
|
+
const raw = await fs4.readFile(filePath, "utf-8");
|
|
8384
8386
|
const { description, mode, content } = parseSkillFrontmatter(raw);
|
|
8385
8387
|
return { name: path4.basename(filePath, ".md"), path: filePath, description, mode, content };
|
|
8386
8388
|
}
|
|
8387
8389
|
async function readSkills(root) {
|
|
8388
8390
|
const skillsDir = path4.join(root, ".oneagent/skills");
|
|
8389
8391
|
try {
|
|
8390
|
-
const files = await
|
|
8392
|
+
const files = await fs4.readdir(skillsDir);
|
|
8391
8393
|
const mdFiles = files.filter((f) => f.endsWith(".md"));
|
|
8392
8394
|
const skills = await Promise.all(mdFiles.map((f) => readSkillFile(path4.join(skillsDir, f))));
|
|
8393
8395
|
return skills.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -8402,16 +8404,16 @@ var init_skills = __esm(() => {
|
|
|
8402
8404
|
|
|
8403
8405
|
// ../core/src/symlinks.ts
|
|
8404
8406
|
import path5 from "path";
|
|
8405
|
-
import
|
|
8407
|
+
import fs5 from "fs/promises";
|
|
8406
8408
|
async function ensureDir(dirPath) {
|
|
8407
|
-
await
|
|
8409
|
+
await fs5.mkdir(dirPath, { recursive: true });
|
|
8408
8410
|
}
|
|
8409
8411
|
async function createSymlink(symlinkPath, target) {
|
|
8410
8412
|
await ensureDir(path5.dirname(symlinkPath));
|
|
8411
8413
|
try {
|
|
8412
|
-
await
|
|
8414
|
+
await fs5.unlink(symlinkPath);
|
|
8413
8415
|
} catch {}
|
|
8414
|
-
await
|
|
8416
|
+
await fs5.symlink(target, symlinkPath);
|
|
8415
8417
|
}
|
|
8416
8418
|
function relativeTarget(symlinkPath, targetAbsPath) {
|
|
8417
8419
|
return path5.relative(path5.dirname(symlinkPath), targetAbsPath);
|
|
@@ -8480,18 +8482,19 @@ function buildRulesSymlinks(root, targets, rules) {
|
|
|
8480
8482
|
}
|
|
8481
8483
|
return entries;
|
|
8482
8484
|
}
|
|
8483
|
-
function buildSkillSymlinks(root, targets
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8485
|
+
function buildSkillSymlinks(root, targets) {
|
|
8486
|
+
const targetAbs = path5.join(root, ".oneagent/skills");
|
|
8487
|
+
const agentDirs = {
|
|
8488
|
+
claude: path5.join(root, ".claude/skills"),
|
|
8489
|
+
cursor: path5.join(root, ".cursor/skills"),
|
|
8490
|
+
windsurf: path5.join(root, ".windsurf/skills"),
|
|
8491
|
+
copilot: path5.join(root, ".github/skills")
|
|
8492
|
+
};
|
|
8493
|
+
return Object.entries(agentDirs).filter(([target]) => targets.includes(target)).map(([, dir]) => ({
|
|
8494
|
+
symlinkPath: dir,
|
|
8495
|
+
target: relativeTarget(dir, targetAbs),
|
|
8496
|
+
label: path5.relative(root, dir)
|
|
8497
|
+
}));
|
|
8495
8498
|
}
|
|
8496
8499
|
function buildAgentsDirSymlinks(root) {
|
|
8497
8500
|
const symlinkPath = path5.join(root, ".agents/skills");
|
|
@@ -8499,10 +8502,10 @@ function buildAgentsDirSymlinks(root) {
|
|
|
8499
8502
|
return [{ symlinkPath, target: relativeTarget(symlinkPath, targetAbs), label: ".agents/skills" }];
|
|
8500
8503
|
}
|
|
8501
8504
|
async function migrateFilesFromDir(srcDir, destDir, root) {
|
|
8502
|
-
await
|
|
8505
|
+
await fs5.mkdir(destDir, { recursive: true });
|
|
8503
8506
|
let entries;
|
|
8504
8507
|
try {
|
|
8505
|
-
entries = await
|
|
8508
|
+
entries = await fs5.readdir(srcDir, { withFileTypes: true });
|
|
8506
8509
|
} catch {
|
|
8507
8510
|
return;
|
|
8508
8511
|
}
|
|
@@ -8513,37 +8516,37 @@ async function migrateFilesFromDir(srcDir, destDir, root) {
|
|
|
8513
8516
|
const destFile = path5.join(destDir, entry.name);
|
|
8514
8517
|
let destExists = false;
|
|
8515
8518
|
try {
|
|
8516
|
-
await
|
|
8519
|
+
await fs5.access(destFile);
|
|
8517
8520
|
destExists = true;
|
|
8518
8521
|
} catch {}
|
|
8519
8522
|
if (destExists) {
|
|
8520
8523
|
const [srcContent, destContent] = await Promise.all([
|
|
8521
|
-
|
|
8522
|
-
|
|
8524
|
+
fs5.readFile(srcFile, "utf-8"),
|
|
8525
|
+
fs5.readFile(destFile, "utf-8")
|
|
8523
8526
|
]);
|
|
8524
8527
|
if (srcContent !== destContent) {
|
|
8525
8528
|
const backupDir = path5.join(root, ".oneagent/backup");
|
|
8526
|
-
await
|
|
8529
|
+
await fs5.mkdir(backupDir, { recursive: true });
|
|
8527
8530
|
const safeName = path5.relative(root, srcFile).replace(/\//g, "_");
|
|
8528
|
-
await
|
|
8531
|
+
await fs5.writeFile(path5.join(backupDir, safeName), srcContent);
|
|
8529
8532
|
}
|
|
8530
|
-
await
|
|
8533
|
+
await fs5.unlink(srcFile);
|
|
8531
8534
|
} else {
|
|
8532
|
-
await
|
|
8535
|
+
await fs5.rename(srcFile, destFile);
|
|
8533
8536
|
}
|
|
8534
8537
|
}
|
|
8535
8538
|
}
|
|
8536
8539
|
async function migrateAndRemoveDir(src, dest, root) {
|
|
8537
8540
|
let stat;
|
|
8538
8541
|
try {
|
|
8539
|
-
stat = await
|
|
8542
|
+
stat = await fs5.lstat(src);
|
|
8540
8543
|
} catch {
|
|
8541
8544
|
return;
|
|
8542
8545
|
}
|
|
8543
8546
|
if (stat.isSymbolicLink() || !stat.isDirectory())
|
|
8544
8547
|
return;
|
|
8545
8548
|
await migrateFilesFromDir(src, dest, root);
|
|
8546
|
-
await
|
|
8549
|
+
await fs5.rm(src, { recursive: true, force: true });
|
|
8547
8550
|
}
|
|
8548
8551
|
async function migrateRuleAndSkillFiles(root) {
|
|
8549
8552
|
const destRules = path5.join(root, ".oneagent/rules");
|
|
@@ -8558,11 +8561,11 @@ async function createAllSymlinks(entries) {
|
|
|
8558
8561
|
}
|
|
8559
8562
|
async function checkSymlink(entry) {
|
|
8560
8563
|
try {
|
|
8561
|
-
const stat = await
|
|
8564
|
+
const stat = await fs5.lstat(entry.symlinkPath);
|
|
8562
8565
|
if (!stat.isSymbolicLink()) {
|
|
8563
8566
|
return { ...entry, exists: true, valid: false };
|
|
8564
8567
|
}
|
|
8565
|
-
const linkTarget = await
|
|
8568
|
+
const linkTarget = await fs5.readlink(entry.symlinkPath);
|
|
8566
8569
|
return { ...entry, exists: true, valid: linkTarget === entry.target };
|
|
8567
8570
|
} catch {
|
|
8568
8571
|
return { ...entry, exists: false, valid: false };
|
|
@@ -8572,7 +8575,7 @@ var init_symlinks = () => {};
|
|
|
8572
8575
|
|
|
8573
8576
|
// ../core/src/copilot.ts
|
|
8574
8577
|
import path6 from "path";
|
|
8575
|
-
import
|
|
8578
|
+
import fs6 from "fs/promises";
|
|
8576
8579
|
function buildCopilotContent(rule) {
|
|
8577
8580
|
return `---
|
|
8578
8581
|
applyTo: "${rule.applyTo}"
|
|
@@ -8584,8 +8587,8 @@ function copilotFilePath(root, ruleName) {
|
|
|
8584
8587
|
}
|
|
8585
8588
|
async function generateCopilotRule(root, rule) {
|
|
8586
8589
|
const filePath = copilotFilePath(root, rule.name);
|
|
8587
|
-
await
|
|
8588
|
-
await
|
|
8590
|
+
await fs6.mkdir(path6.dirname(filePath), { recursive: true });
|
|
8591
|
+
await fs6.writeFile(filePath, buildCopilotContent(rule));
|
|
8589
8592
|
}
|
|
8590
8593
|
async function generateCopilotRules(root, rules) {
|
|
8591
8594
|
await Promise.all(rules.map((rule) => generateCopilotRule(root, rule)));
|
|
@@ -8603,8 +8606,8 @@ function copilotPromptFilePath(root, skillName) {
|
|
|
8603
8606
|
}
|
|
8604
8607
|
async function generateCopilotSkill(root, skill) {
|
|
8605
8608
|
const filePath = copilotPromptFilePath(root, skill.name);
|
|
8606
|
-
await
|
|
8607
|
-
await
|
|
8609
|
+
await fs6.mkdir(path6.dirname(filePath), { recursive: true });
|
|
8610
|
+
await fs6.writeFile(filePath, buildCopilotPromptContent(skill));
|
|
8608
8611
|
}
|
|
8609
8612
|
async function generateCopilotSkills(root, skills) {
|
|
8610
8613
|
await Promise.all(skills.map((skill) => generateCopilotSkill(root, skill)));
|
|
@@ -8613,9 +8616,10 @@ var init_copilot = () => {};
|
|
|
8613
8616
|
|
|
8614
8617
|
// ../core/src/opencode.ts
|
|
8615
8618
|
import path7 from "path";
|
|
8619
|
+
import fs7 from "fs/promises";
|
|
8616
8620
|
async function readOpencode(root) {
|
|
8617
8621
|
try {
|
|
8618
|
-
const content = await
|
|
8622
|
+
const content = await fs7.readFile(path7.join(root, "opencode.json"), "utf-8");
|
|
8619
8623
|
return JSON.parse(content);
|
|
8620
8624
|
} catch {
|
|
8621
8625
|
return null;
|
|
@@ -8630,21 +8634,21 @@ function buildOpencodeConfig(existing) {
|
|
|
8630
8634
|
async function writeOpencode(root, _rules) {
|
|
8631
8635
|
const existing = await readOpencode(root);
|
|
8632
8636
|
const config = buildOpencodeConfig(existing);
|
|
8633
|
-
await
|
|
8637
|
+
await fs7.writeFile(path7.join(root, "opencode.json"), JSON.stringify(config, null, 2) + `
|
|
8634
8638
|
`);
|
|
8635
8639
|
}
|
|
8636
8640
|
var init_opencode = () => {};
|
|
8637
8641
|
|
|
8638
8642
|
// ../core/src/generate.ts
|
|
8639
8643
|
import path8 from "path";
|
|
8640
|
-
import
|
|
8644
|
+
import fs8 from "fs/promises";
|
|
8641
8645
|
async function detectGenerateCollisions(root, config) {
|
|
8642
8646
|
const [rules, skills] = await Promise.all([readRules(root), readSkills(root)]);
|
|
8643
8647
|
const targets = activeTargets(config);
|
|
8644
8648
|
const mainEntries = buildMainSymlinks(root, targets);
|
|
8645
8649
|
const ruleSkillEntries = [
|
|
8646
8650
|
...buildRulesSymlinks(root, targets, rules),
|
|
8647
|
-
...buildSkillSymlinks(root, targets
|
|
8651
|
+
...buildSkillSymlinks(root, targets)
|
|
8648
8652
|
];
|
|
8649
8653
|
const [mainCollisions, ruleSkillSymlinkCollisions] = await Promise.all([
|
|
8650
8654
|
Promise.all(mainEntries.map((entry) => readDetectedFile(root, path8.relative(root, entry.symlinkPath)))).then((files) => files.filter((f) => f !== null)),
|
|
@@ -8656,10 +8660,10 @@ async function detectGenerateCollisions(root, config) {
|
|
|
8656
8660
|
...rules.map(async (rule) => {
|
|
8657
8661
|
const filePath = copilotFilePath(root, rule.name);
|
|
8658
8662
|
try {
|
|
8659
|
-
const content = await
|
|
8663
|
+
const content = await fs8.readFile(filePath, "utf-8");
|
|
8660
8664
|
if (content === buildCopilotContent(rule))
|
|
8661
8665
|
return null;
|
|
8662
|
-
const stat = await
|
|
8666
|
+
const stat = await fs8.lstat(filePath);
|
|
8663
8667
|
return { relativePath: path8.relative(root, filePath), absolutePath: filePath, sizeBytes: stat.size, modifiedAt: stat.mtime, content };
|
|
8664
8668
|
} catch {
|
|
8665
8669
|
return null;
|
|
@@ -8668,10 +8672,10 @@ async function detectGenerateCollisions(root, config) {
|
|
|
8668
8672
|
...skills.map(async (skill) => {
|
|
8669
8673
|
const filePath = copilotPromptFilePath(root, skill.name);
|
|
8670
8674
|
try {
|
|
8671
|
-
const content = await
|
|
8675
|
+
const content = await fs8.readFile(filePath, "utf-8");
|
|
8672
8676
|
if (content === buildCopilotPromptContent(skill))
|
|
8673
8677
|
return null;
|
|
8674
|
-
const stat = await
|
|
8678
|
+
const stat = await fs8.lstat(filePath);
|
|
8675
8679
|
return { relativePath: path8.relative(root, filePath), absolutePath: filePath, sizeBytes: stat.size, modifiedAt: stat.mtime, content };
|
|
8676
8680
|
} catch {
|
|
8677
8681
|
return null;
|
|
@@ -8688,10 +8692,10 @@ async function detectGenerateCollisions(root, config) {
|
|
|
8688
8692
|
async function generate(root, config) {
|
|
8689
8693
|
const [rules, skills] = await Promise.all([readRules(root), readSkills(root)]);
|
|
8690
8694
|
const targets = activeTargets(config);
|
|
8695
|
+
await migrateRuleAndSkillFiles(root);
|
|
8691
8696
|
const mainSymlinks = buildMainSymlinks(root, targets);
|
|
8692
8697
|
const rulesSymlinks = buildRulesSymlinks(root, targets, rules);
|
|
8693
|
-
const skillSymlinks = buildSkillSymlinks(root, targets
|
|
8694
|
-
await migrateRuleAndSkillFiles(root);
|
|
8698
|
+
const skillSymlinks = await buildSkillSymlinks(root, targets);
|
|
8695
8699
|
await createAllSymlinks([...mainSymlinks, ...rulesSymlinks, ...skillSymlinks, ...buildAgentsDirSymlinks(root)]);
|
|
8696
8700
|
if (targets.includes("copilot")) {
|
|
8697
8701
|
await Promise.all([generateCopilotRules(root, rules), generateCopilotSkills(root, skills)]);
|
|
@@ -8711,11 +8715,12 @@ var init_generate = __esm(() => {
|
|
|
8711
8715
|
});
|
|
8712
8716
|
|
|
8713
8717
|
// ../core/src/status.ts
|
|
8718
|
+
import fs9 from "fs/promises";
|
|
8714
8719
|
async function checkGeneratedFile(root, rule) {
|
|
8715
8720
|
const filePath = copilotFilePath(root, rule.name);
|
|
8716
8721
|
const expected = buildCopilotContent(rule);
|
|
8717
8722
|
try {
|
|
8718
|
-
const content = await
|
|
8723
|
+
const content = await fs9.readFile(filePath, "utf-8");
|
|
8719
8724
|
return { path: filePath, exists: true, upToDate: content === expected };
|
|
8720
8725
|
} catch {
|
|
8721
8726
|
return { path: filePath, exists: false, upToDate: false };
|
|
@@ -8731,7 +8736,7 @@ async function checkCopilotPrompt(root, skill) {
|
|
|
8731
8736
|
const filePath = copilotPromptFilePath(root, skill.name);
|
|
8732
8737
|
const expected = buildCopilotPromptContent(skill);
|
|
8733
8738
|
try {
|
|
8734
|
-
const content = await
|
|
8739
|
+
const content = await fs9.readFile(filePath, "utf-8");
|
|
8735
8740
|
return { path: filePath, exists: true, upToDate: content === expected };
|
|
8736
8741
|
} catch {
|
|
8737
8742
|
return { path: filePath, exists: false, upToDate: false };
|
|
@@ -8743,7 +8748,7 @@ async function checkStatus(root, config) {
|
|
|
8743
8748
|
const allEntries = [
|
|
8744
8749
|
...buildMainSymlinks(root, targets),
|
|
8745
8750
|
...buildRulesSymlinks(root, targets, rules),
|
|
8746
|
-
...buildSkillSymlinks(root, targets
|
|
8751
|
+
...buildSkillSymlinks(root, targets),
|
|
8747
8752
|
...buildAgentsDirSymlinks(root)
|
|
8748
8753
|
];
|
|
8749
8754
|
const symlinks = await Promise.all(allEntries.map(checkSymlink));
|
|
@@ -8765,20 +8770,22 @@ var init_status = __esm(() => {
|
|
|
8765
8770
|
|
|
8766
8771
|
// ../core/src/apply-template.ts
|
|
8767
8772
|
import path9 from "path";
|
|
8768
|
-
import
|
|
8773
|
+
import fs10 from "fs/promises";
|
|
8774
|
+
import { execFile } from "child_process";
|
|
8775
|
+
import { promisify } from "util";
|
|
8769
8776
|
async function applyTemplateFiles(root, template) {
|
|
8770
8777
|
const oneagentDir = path9.join(root, ".oneagent");
|
|
8771
|
-
await
|
|
8772
|
-
await
|
|
8773
|
-
await
|
|
8778
|
+
await fs10.mkdir(path9.join(oneagentDir, "rules"), { recursive: true });
|
|
8779
|
+
await fs10.mkdir(path9.join(oneagentDir, "skills"), { recursive: true });
|
|
8780
|
+
await fs10.writeFile(path9.join(oneagentDir, "instructions.md"), template.instructions);
|
|
8774
8781
|
for (const rule of template.rules) {
|
|
8775
|
-
await
|
|
8782
|
+
await fs10.writeFile(path9.join(oneagentDir, "rules", `${rule.name}.md`), rule.content);
|
|
8776
8783
|
}
|
|
8777
8784
|
}
|
|
8778
8785
|
async function installTemplateSkills(root, template, onSkillInstalled) {
|
|
8779
8786
|
for (const identifier of template.skills) {
|
|
8780
8787
|
try {
|
|
8781
|
-
await
|
|
8788
|
+
await execFileAsync("npx", ["skills", "add", identifier, "--agent", "universal", "--yes"], { cwd: root });
|
|
8782
8789
|
onSkillInstalled?.(identifier);
|
|
8783
8790
|
} catch (err) {
|
|
8784
8791
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -8848,7 +8855,10 @@ async function fetchGitHubRules(repoUrl) {
|
|
|
8848
8855
|
return [];
|
|
8849
8856
|
}
|
|
8850
8857
|
}
|
|
8851
|
-
var
|
|
8858
|
+
var execFileAsync;
|
|
8859
|
+
var init_apply_template = __esm(() => {
|
|
8860
|
+
execFileAsync = promisify(execFile);
|
|
8861
|
+
});
|
|
8852
8862
|
|
|
8853
8863
|
// ../core/src/index.ts
|
|
8854
8864
|
var init_src = __esm(() => {
|
|
@@ -8899,12 +8909,13 @@ var init_utils = __esm(() => {
|
|
|
8899
8909
|
|
|
8900
8910
|
// ../templates/src/index.ts
|
|
8901
8911
|
import path10 from "path";
|
|
8902
|
-
import
|
|
8912
|
+
import fs11 from "fs/promises";
|
|
8913
|
+
import { fileURLToPath } from "url";
|
|
8903
8914
|
async function loadTemplate(name) {
|
|
8904
|
-
const templateDir = path10.join(
|
|
8915
|
+
const templateDir = path10.join(__dirname2, "templates", name);
|
|
8905
8916
|
const [yamlText, instructions] = await Promise.all([
|
|
8906
|
-
|
|
8907
|
-
|
|
8917
|
+
fs11.readFile(path10.join(templateDir, "template.yml"), "utf-8"),
|
|
8918
|
+
fs11.readFile(path10.join(templateDir, "instructions.md"), "utf-8")
|
|
8908
8919
|
]);
|
|
8909
8920
|
const descMatch = yamlText.match(/^description:\s*(.+)$/m);
|
|
8910
8921
|
const description = descMatch?.[1]?.trim() ?? "";
|
|
@@ -8922,10 +8933,10 @@ async function loadTemplate(name) {
|
|
|
8922
8933
|
const rulesDir = path10.join(templateDir, "rules");
|
|
8923
8934
|
let rules2 = [];
|
|
8924
8935
|
try {
|
|
8925
|
-
const ruleFiles = await
|
|
8936
|
+
const ruleFiles = await fs11.readdir(rulesDir);
|
|
8926
8937
|
rules2 = await Promise.all(ruleFiles.filter((f) => f.endsWith(".md")).map(async (f) => ({
|
|
8927
8938
|
name: path10.basename(f, ".md"),
|
|
8928
|
-
content: await
|
|
8939
|
+
content: await fs11.readFile(path10.join(rulesDir, f), "utf-8")
|
|
8929
8940
|
})));
|
|
8930
8941
|
} catch {}
|
|
8931
8942
|
return { name, description, skills: skills2, instructions, rules: rules2 };
|
|
@@ -8935,8 +8946,9 @@ async function resolveBuiltinTemplate(name) {
|
|
|
8935
8946
|
return null;
|
|
8936
8947
|
return loadTemplate(name);
|
|
8937
8948
|
}
|
|
8938
|
-
var TEMPLATE_NAMES, BUILTIN_TEMPLATE_NAMES;
|
|
8949
|
+
var __dirname2, TEMPLATE_NAMES, BUILTIN_TEMPLATE_NAMES;
|
|
8939
8950
|
var init_src2 = __esm(() => {
|
|
8951
|
+
__dirname2 = path10.dirname(fileURLToPath(import.meta.url));
|
|
8940
8952
|
TEMPLATE_NAMES = ["default", "react", "react-native"];
|
|
8941
8953
|
BUILTIN_TEMPLATE_NAMES = TEMPLATE_NAMES;
|
|
8942
8954
|
});
|
|
@@ -8947,7 +8959,7 @@ __export(exports_init, {
|
|
|
8947
8959
|
default: () => init_default
|
|
8948
8960
|
});
|
|
8949
8961
|
import path11 from "path";
|
|
8950
|
-
import
|
|
8962
|
+
import fs12 from "fs/promises";
|
|
8951
8963
|
function cancelAndExit() {
|
|
8952
8964
|
Le("Cancelled.");
|
|
8953
8965
|
process.exit(0);
|
|
@@ -9021,10 +9033,10 @@ async function backupFiles(root, files) {
|
|
|
9021
9033
|
if (files.length === 0)
|
|
9022
9034
|
return;
|
|
9023
9035
|
const backupDir = path11.join(root, ".oneagent/backup");
|
|
9024
|
-
await
|
|
9036
|
+
await fs12.mkdir(backupDir, { recursive: true });
|
|
9025
9037
|
for (const file of files) {
|
|
9026
9038
|
const safeName = file.relativePath.replace(/\//g, "_");
|
|
9027
|
-
await
|
|
9039
|
+
await fs12.writeFile(path11.join(backupDir, safeName), file.content);
|
|
9028
9040
|
}
|
|
9029
9041
|
}
|
|
9030
9042
|
async function resolveTemplate(templateArg) {
|
|
@@ -9104,8 +9116,8 @@ var init_init = __esm(() => {
|
|
|
9104
9116
|
const selectedTargets = await pickTargets();
|
|
9105
9117
|
const s = bt2();
|
|
9106
9118
|
s.start("Setting up .oneagent/ directory...");
|
|
9107
|
-
await
|
|
9108
|
-
await
|
|
9119
|
+
await fs12.mkdir(path11.join(root, ".oneagent/rules"), { recursive: true });
|
|
9120
|
+
await fs12.mkdir(path11.join(root, ".oneagent/skills"), { recursive: true });
|
|
9109
9121
|
await backupFiles(root, detected);
|
|
9110
9122
|
await removeDeprecatedFiles(root);
|
|
9111
9123
|
await warnDeprecatedCommandFiles(root);
|
|
@@ -9119,9 +9131,9 @@ var init_init = __esm(() => {
|
|
|
9119
9131
|
|
|
9120
9132
|
Add your AI instructions here.
|
|
9121
9133
|
`;
|
|
9122
|
-
await
|
|
9134
|
+
await fs12.writeFile(path11.join(root, ".oneagent/instructions.md"), instructionsContent);
|
|
9123
9135
|
}
|
|
9124
|
-
await
|
|
9136
|
+
await fs12.writeFile(path11.join(root, ".oneagent/rules/oneagent.md"), DOTAI_META_RULE);
|
|
9125
9137
|
s.stop("Directory structure created.");
|
|
9126
9138
|
const s2 = bt2();
|
|
9127
9139
|
s2.start("Generating symlinks and agent files...");
|
|
@@ -9157,7 +9169,7 @@ __export(exports_generate, {
|
|
|
9157
9169
|
default: () => generate_default
|
|
9158
9170
|
});
|
|
9159
9171
|
import path12 from "path";
|
|
9160
|
-
import
|
|
9172
|
+
import fs13 from "fs/promises";
|
|
9161
9173
|
var generate_default;
|
|
9162
9174
|
var init_generate2 = __esm(() => {
|
|
9163
9175
|
init_dist();
|
|
@@ -9181,10 +9193,10 @@ var init_generate2 = __esm(() => {
|
|
|
9181
9193
|
const { mainFiles, ruleSkillFiles } = await detectGenerateCollisions(root, config2);
|
|
9182
9194
|
if (mainFiles.length > 0) {
|
|
9183
9195
|
const backupDir = path12.join(root, ".oneagent/backup");
|
|
9184
|
-
await
|
|
9196
|
+
await fs13.mkdir(backupDir, { recursive: true });
|
|
9185
9197
|
for (const file of mainFiles) {
|
|
9186
9198
|
const safeName = file.relativePath.replace(/\//g, "_");
|
|
9187
|
-
await
|
|
9199
|
+
await fs13.writeFile(path12.join(backupDir, safeName), file.content);
|
|
9188
9200
|
}
|
|
9189
9201
|
}
|
|
9190
9202
|
await warnDeprecatedCommandFiles(root);
|
package/package.json
CHANGED