@moskala/oneagent-core 0.4.5 → 0.4.6

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/copilot.d.ts CHANGED
@@ -1,8 +1,3 @@
1
- import type { RuleFile, SkillFile } from "./types.ts";
1
+ import type { RuleFile, SymlinkEntry } from "./types.ts";
2
2
  export declare function copilotFilePath(root: string, ruleName: string): string;
3
- export declare function generateCopilotRule(root: string, rule: RuleFile): Promise<void>;
4
- export declare function generateCopilotRules(root: string, rules: RuleFile[]): Promise<void>;
5
- export declare function buildCopilotPromptContent(skill: SkillFile): string;
6
- export declare function copilotPromptFilePath(root: string, skillName: string): string;
7
- export declare function generateCopilotSkill(root: string, skill: SkillFile): Promise<void>;
8
- export declare function generateCopilotSkills(root: string, skills: SkillFile[]): Promise<void>;
3
+ export declare function buildCopilotRulesSymlinks(root: string, rules: RuleFile[]): SymlinkEntry[];
package/dist/index.js CHANGED
@@ -405,43 +405,23 @@ async function checkSymlink(entry) {
405
405
  }
406
406
  // src/copilot.ts
407
407
  import path7 from "path";
408
- import fs7 from "fs/promises";
409
408
  function copilotFilePath(root, ruleName) {
410
409
  return path7.join(root, ".github/instructions", `${ruleName}.instructions.md`);
411
410
  }
412
- async function generateCopilotRule(root, rule) {
413
- const destPath = copilotFilePath(root, rule.name);
414
- await fs7.mkdir(path7.dirname(destPath), { recursive: true });
415
- await fs7.copyFile(rule.path, destPath);
416
- }
417
- async function generateCopilotRules(root, rules) {
418
- await Promise.all(rules.map((rule) => generateCopilotRule(root, rule)));
419
- }
420
- function buildCopilotPromptContent(skill) {
421
- const lines = ["---", `mode: "${skill.mode}"`];
422
- if (skill.description)
423
- lines.push(`description: "${skill.description}"`);
424
- lines.push("---", skill.content);
425
- return lines.join(`
426
- `);
427
- }
428
- function copilotPromptFilePath(root, skillName) {
429
- return path7.join(root, ".github/prompts", `${skillName}.prompt.md`);
430
- }
431
- async function generateCopilotSkill(root, skill) {
432
- const filePath = copilotPromptFilePath(root, skill.name);
433
- await fs7.mkdir(path7.dirname(filePath), { recursive: true });
434
- await fs7.writeFile(filePath, buildCopilotPromptContent(skill));
435
- }
436
- async function generateCopilotSkills(root, skills) {
437
- await Promise.all(skills.map((skill) => generateCopilotSkill(root, skill)));
411
+ function buildCopilotRulesSymlinks(root, rules) {
412
+ return rules.map((rule) => {
413
+ const symlinkPath = copilotFilePath(root, rule.name);
414
+ const targetAbs = path7.join(root, ONEAGENT_DIR, "rules", `${rule.name}.md`);
415
+ const target = path7.relative(path7.dirname(symlinkPath), targetAbs);
416
+ return { symlinkPath, target, label: path7.relative(root, symlinkPath) };
417
+ });
438
418
  }
439
419
  // src/opencode.ts
440
420
  import path8 from "path";
441
- import fs8 from "fs/promises";
421
+ import fs7 from "fs/promises";
442
422
  async function readOpencode(root) {
443
423
  try {
444
- const content = await fs8.readFile(path8.join(root, "opencode.json"), "utf-8");
424
+ const content = await fs7.readFile(path8.join(root, "opencode.json"), "utf-8");
445
425
  return JSON.parse(content);
446
426
  } catch {
447
427
  return null;
@@ -457,7 +437,7 @@ async function addOpenCodePlugin(root, id) {
457
437
  const filePath = path8.join(root, "opencode.json");
458
438
  let existing;
459
439
  try {
460
- existing = JSON.parse(await fs8.readFile(filePath, "utf-8"));
440
+ existing = JSON.parse(await fs7.readFile(filePath, "utf-8"));
461
441
  } catch {
462
442
  return;
463
443
  }
@@ -465,136 +445,75 @@ async function addOpenCodePlugin(root, id) {
465
445
  if (current.includes(id))
466
446
  return;
467
447
  existing.plugin = [...current, id];
468
- await fs8.writeFile(filePath, JSON.stringify(existing, null, 2) + `
448
+ await fs7.writeFile(filePath, JSON.stringify(existing, null, 2) + `
469
449
  `);
470
450
  }
471
451
  async function writeOpencode(root, _rules) {
472
452
  const existing = await readOpencode(root);
473
453
  const config = buildOpencodeConfig(existing);
474
- await fs8.writeFile(path8.join(root, "opencode.json"), JSON.stringify(config, null, 2) + `
454
+ await fs7.writeFile(path8.join(root, "opencode.json"), JSON.stringify(config, null, 2) + `
475
455
  `);
476
456
  }
477
457
  // src/generate.ts
478
458
  import path9 from "path";
479
- import fs9 from "fs/promises";
480
459
  async function detectGenerateCollisions(root, config) {
481
- const [rules, skills] = await Promise.all([readRules(root), readSkills(root)]);
460
+ const rules = await readRules(root);
482
461
  const targets = activeTargets(config);
483
462
  const mainEntries = buildMainSymlinks(root, targets);
484
463
  const ruleSkillEntries = [
485
464
  ...buildRulesSymlinks(root, targets),
486
465
  ...buildSkillSymlinks(root, targets),
487
- ...buildCommandSymlinks(root, targets)
466
+ ...buildCommandSymlinks(root, targets),
467
+ ...targets.includes("copilot") ? buildCopilotRulesSymlinks(root, rules) : []
488
468
  ];
489
- const [mainCollisions, ruleSkillSymlinkCollisions] = await Promise.all([
469
+ const [mainCollisions, ruleSkillCollisions] = await Promise.all([
490
470
  Promise.all(mainEntries.map((entry) => readDetectedFile(root, path9.relative(root, entry.symlinkPath)))).then((files) => files.filter((f) => f !== null)),
491
471
  Promise.all(ruleSkillEntries.map((entry) => readDetectedFile(root, path9.relative(root, entry.symlinkPath)))).then((files) => files.filter((f) => f !== null))
492
472
  ]);
493
- const copilotCollisions = [];
494
- if (targets.includes("copilot")) {
495
- const checks = await Promise.all([
496
- ...rules.map(async (rule) => {
497
- const filePath = copilotFilePath(root, rule.name);
498
- try {
499
- const [source, dest] = await Promise.all([
500
- fs9.readFile(rule.path, "utf-8"),
501
- fs9.readFile(filePath, "utf-8")
502
- ]);
503
- if (source === dest)
504
- return null;
505
- const stat = await fs9.lstat(filePath);
506
- return { relativePath: path9.relative(root, filePath), absolutePath: filePath, sizeBytes: stat.size, modifiedAt: stat.mtime, content: dest };
507
- } catch {
508
- return null;
509
- }
510
- }),
511
- ...skills.map(async (skill) => {
512
- const filePath = copilotPromptFilePath(root, skill.name);
513
- try {
514
- const content = await fs9.readFile(filePath, "utf-8");
515
- if (content === buildCopilotPromptContent(skill))
516
- return null;
517
- const stat = await fs9.lstat(filePath);
518
- return { relativePath: path9.relative(root, filePath), absolutePath: filePath, sizeBytes: stat.size, modifiedAt: stat.mtime, content };
519
- } catch {
520
- return null;
521
- }
522
- })
523
- ]);
524
- copilotCollisions.push(...checks.filter((c) => c !== null));
525
- }
526
473
  return {
527
474
  mainFiles: mainCollisions,
528
- ruleSkillFiles: [...ruleSkillSymlinkCollisions, ...copilotCollisions]
475
+ ruleSkillFiles: ruleSkillCollisions
529
476
  };
530
477
  }
531
478
  async function generate(root, config) {
532
- const [rules, skills] = await Promise.all([readRules(root), readSkills(root)]);
479
+ const rules = await readRules(root);
533
480
  const targets = activeTargets(config);
534
481
  await migrateRuleAndSkillFiles(root);
535
482
  const mainSymlinks = buildMainSymlinks(root, targets);
536
483
  const rulesSymlinks = buildRulesSymlinks(root, targets);
537
- const skillSymlinks = await buildSkillSymlinks(root, targets);
484
+ const skillSymlinks = buildSkillSymlinks(root, targets);
538
485
  const commandSymlinks = buildCommandSymlinks(root, targets);
539
- await createAllSymlinks([...mainSymlinks, ...rulesSymlinks, ...skillSymlinks, ...commandSymlinks, ...buildAgentsDirSymlinks(root)]);
540
- if (targets.includes("copilot")) {
541
- await Promise.all([generateCopilotRules(root, rules), generateCopilotSkills(root, skills)]);
542
- }
486
+ const copilotRulesSymlinks = targets.includes("copilot") ? buildCopilotRulesSymlinks(root, rules) : [];
487
+ await createAllSymlinks([...mainSymlinks, ...rulesSymlinks, ...skillSymlinks, ...commandSymlinks, ...copilotRulesSymlinks, ...buildAgentsDirSymlinks(root)]);
543
488
  if (targets.includes("opencode")) {
544
489
  await writeOpencode(root, rules);
545
490
  }
546
491
  }
547
492
  // src/status.ts
548
- import fs10 from "fs/promises";
549
- async function checkGeneratedFile(root, rule) {
550
- const filePath = copilotFilePath(root, rule.name);
551
- try {
552
- const [source, dest] = await Promise.all([
553
- fs10.readFile(rule.path, "utf-8"),
554
- fs10.readFile(filePath, "utf-8")
555
- ]);
556
- return { path: filePath, exists: true, upToDate: source === dest };
557
- } catch {
558
- return { path: filePath, exists: false, upToDate: false };
559
- }
560
- }
561
- async function checkOpencodeStatus(root, _rules) {
493
+ async function checkOpencodeStatus(root) {
562
494
  const existing = await readOpencode(root);
563
495
  if (!existing)
564
496
  return { exists: false, valid: false };
565
497
  return { exists: true, valid: existing["instructions"] === `${ONEAGENT_DIR}/instructions.md` };
566
498
  }
567
- async function checkCopilotPrompt(root, skill) {
568
- const filePath = copilotPromptFilePath(root, skill.name);
569
- const expected = buildCopilotPromptContent(skill);
570
- try {
571
- const content = await fs10.readFile(filePath, "utf-8");
572
- return { path: filePath, exists: true, upToDate: content === expected };
573
- } catch {
574
- return { path: filePath, exists: false, upToDate: false };
575
- }
576
- }
577
499
  async function checkStatus(root, config) {
578
- const [rules, skills] = await Promise.all([readRules(root), readSkills(root)]);
500
+ const rules = await readRules(root);
579
501
  const targets = activeTargets(config);
580
502
  const allEntries = [
581
503
  ...buildMainSymlinks(root, targets),
582
504
  ...buildRulesSymlinks(root, targets),
583
505
  ...buildSkillSymlinks(root, targets),
584
506
  ...buildCommandSymlinks(root, targets),
507
+ ...targets.includes("copilot") ? buildCopilotRulesSymlinks(root, rules) : [],
585
508
  ...buildAgentsDirSymlinks(root)
586
509
  ];
587
510
  const symlinks = await Promise.all(allEntries.map(checkSymlink));
588
- const generatedFiles = targets.includes("copilot") ? await Promise.all([
589
- ...rules.map((rule) => checkGeneratedFile(root, rule)),
590
- ...skills.map((skill) => checkCopilotPrompt(root, skill))
591
- ]) : [];
592
- const opencode = await checkOpencodeStatus(root, rules);
593
- return { symlinks, generatedFiles, opencode };
511
+ const opencode = await checkOpencodeStatus(root);
512
+ return { symlinks, opencode };
594
513
  }
595
514
  // src/apply-template.ts
596
515
  import path10 from "path";
597
- import fs11 from "fs/promises";
516
+ import fs8 from "fs/promises";
598
517
  import { execFile } from "child_process";
599
518
  import { promisify } from "util";
600
519
  var execFileAsync = promisify(execFile);
@@ -669,11 +588,11 @@ async function resolveExtends(child, resolveBuiltin) {
669
588
  }
670
589
  async function applyTemplateFiles(root, template) {
671
590
  const oneagentDir = path10.join(root, ONEAGENT_DIR);
672
- await fs11.mkdir(path10.join(oneagentDir, "rules"), { recursive: true });
673
- await fs11.mkdir(path10.join(oneagentDir, "skills"), { recursive: true });
674
- await fs11.writeFile(path10.join(oneagentDir, "instructions.md"), template.instructions);
591
+ await fs8.mkdir(path10.join(oneagentDir, "rules"), { recursive: true });
592
+ await fs8.mkdir(path10.join(oneagentDir, "skills"), { recursive: true });
593
+ await fs8.writeFile(path10.join(oneagentDir, "instructions.md"), template.instructions);
675
594
  for (const rule of template.rules) {
676
- await fs11.writeFile(path10.join(oneagentDir, "rules", `${rule.name}.md`), rule.content);
595
+ await fs8.writeFile(path10.join(oneagentDir, "rules", `${rule.name}.md`), rule.content);
677
596
  }
678
597
  }
679
598
  async function installTemplateSkills(root, template) {
@@ -819,10 +738,6 @@ export {
819
738
  installTemplatePlugins,
820
739
  installBuiltinSkill,
821
740
  getAgentDef,
822
- generateCopilotSkills,
823
- generateCopilotSkill,
824
- generateCopilotRules,
825
- generateCopilotRule,
826
741
  generate,
827
742
  filesHaveSameContent,
828
743
  fetchTemplateFromGitHub,
@@ -831,20 +746,17 @@ export {
831
746
  detectExistingFiles,
832
747
  createSymlink,
833
748
  createAllSymlinks,
834
- copilotPromptFilePath,
835
749
  copilotFilePath,
836
750
  configExists,
837
751
  cleanupAgentDir,
838
752
  checkSymlink,
839
753
  checkStatus,
840
754
  checkOpencodeStatus,
841
- checkGeneratedFile,
842
- checkCopilotPrompt,
843
755
  buildSkillSymlinks,
844
756
  buildRulesSymlinks,
845
757
  buildOpencodeConfig,
846
758
  buildMainSymlinks,
847
- buildCopilotPromptContent,
759
+ buildCopilotRulesSymlinks,
848
760
  buildCommandSymlinks,
849
761
  buildAgentsDirSymlinks,
850
762
  applyTemplateFiles,
package/dist/status.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import type { Config, GeneratedFileCheck, OpenCodeCheck, RuleFile, StatusResult } from "./types.ts";
2
- export declare function checkGeneratedFile(root: string, rule: RuleFile): Promise<GeneratedFileCheck>;
3
- export declare function checkOpencodeStatus(root: string, _rules: RuleFile[]): Promise<OpenCodeCheck>;
4
- export declare function checkCopilotPrompt(root: string, skill: import("./types.ts").SkillFile): Promise<GeneratedFileCheck>;
1
+ import type { Config, OpenCodeCheck, StatusResult } from "./types.ts";
2
+ export declare function checkOpencodeStatus(root: string): Promise<OpenCodeCheck>;
5
3
  export declare function checkStatus(root: string, config: Config): Promise<StatusResult>;
package/dist/types.d.ts CHANGED
@@ -36,14 +36,8 @@ export interface SymlinkCheck extends SymlinkEntry {
36
36
  }
37
37
  export interface StatusResult {
38
38
  symlinks: SymlinkCheck[];
39
- generatedFiles: GeneratedFileCheck[];
40
39
  opencode: OpenCodeCheck;
41
40
  }
42
- export interface GeneratedFileCheck {
43
- path: string;
44
- exists: boolean;
45
- upToDate: boolean;
46
- }
47
41
  export interface OpenCodeCheck {
48
42
  exists: boolean;
49
43
  valid: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moskala/oneagent-core",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "type": "module",
5
5
  "description": "Core library for oneagent — one source of truth for AI agent rules",
6
6
  "license": "MIT",