@odarino/haren 1.2.2 → 1.2.3

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.
Files changed (3) hide show
  1. package/README.md +6 -0
  2. package/dist/index.js +125 -32
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -366,6 +366,12 @@ root.
366
366
  - **Cursor** → `.cursorrules` + `.cursor/rules/haren.mdc` + `.cursor/hooks.json`
367
367
  (registers the gate via `beforeFileEdit`/`preToolUse`).
368
368
 
369
+ Both editors also get every haren skill and agent in their native folders:
370
+ `.claude/skills/haren-<skill>/`, `.claude/agents/haren-<agent>.md`, and the same
371
+ under `.cursor/`. The `haren-` prefix keeps them apart from your own skills and
372
+ agents (for example `/haren-plan`, agent `haren-developer`). `haren upgrade`
373
+ refreshes these copies from the haren folder.
374
+
369
375
  These files go in the workspace root (the parent of the haren folder). Existing
370
376
  config files are kept: haren writes only inside its marked block.
371
377
 
package/dist/index.js CHANGED
@@ -408,7 +408,7 @@ var init_manifest = __esm(() => {
408
408
 
409
409
  // src/workspace/root-files.ts
410
410
  import { existsSync as existsSync2 } from "fs";
411
- import { mkdir as mkdir2, readFile, writeFile as writeFile2 } from "fs/promises";
411
+ import { mkdir as mkdir2, readdir, readFile, writeFile as writeFile2 } from "fs/promises";
412
412
  import { dirname, join as join3, relative, sep } from "path";
413
413
  function legacyRange(existing) {
414
414
  const start = existing.indexOf(LEGACY_HEADING);
@@ -510,14 +510,74 @@ function mergeCursorHooks(existing, command) {
510
510
  async function readOrNull(path) {
511
511
  return existsSync2(path) ? readFile(path, "utf-8") : null;
512
512
  }
513
- async function readPackagedOnboard(contentDir) {
514
- let dir;
515
- try {
516
- dir = contentDir ?? resolveContentDir();
517
- } catch {
518
- return null;
513
+ function harenName(name) {
514
+ return name.startsWith("haren-") ? name : `haren-${name}`;
515
+ }
516
+ function withFrontmatterName(text, name) {
517
+ const fm = /^---\r?\n[\s\S]*?\r?\n---/.exec(text);
518
+ if (!fm)
519
+ return text;
520
+ const head = fm[0].replace(/^name:.*$/m, `name: ${name}`);
521
+ return head + text.slice(fm[0].length);
522
+ }
523
+ function frontmatterName(text) {
524
+ const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
525
+ return fm?.[1]?.match(/^name:\s*(.+?)\s*$/m)?.[1]?.replace(/^["']|["']$/g, "");
526
+ }
527
+ async function listFiles(dir, prefix = "") {
528
+ const out = [];
529
+ for (const entry of await readdir(dir, { withFileTypes: true })) {
530
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
531
+ if (entry.isDirectory())
532
+ out.push(...await listFiles(join3(dir, entry.name), rel));
533
+ else if (entry.isFile())
534
+ out.push(rel);
535
+ }
536
+ return out.sort();
537
+ }
538
+ async function frameworkFiles(harenDir, contentDir) {
539
+ let source = harenDir;
540
+ if (!existsSync2(join3(harenDir, "skills")) && !existsSync2(join3(harenDir, "agents"))) {
541
+ try {
542
+ source = contentDir ?? resolveContentDir();
543
+ } catch {
544
+ return [];
545
+ }
546
+ }
547
+ const files = [];
548
+ const skillsDir = join3(source, "skills");
549
+ if (existsSync2(skillsDir)) {
550
+ for (const entry of await readdir(skillsDir, { withFileTypes: true })) {
551
+ if (!entry.isDirectory())
552
+ continue;
553
+ const dir = join3(skillsDir, entry.name);
554
+ const main = await readOrNull(join3(dir, "SKILL.md"));
555
+ if (main === null)
556
+ continue;
557
+ const name = harenName(frontmatterName(main) ?? entry.name);
558
+ for (const rel of await listFiles(dir)) {
559
+ const text = await readFile(join3(dir, rel), "utf-8");
560
+ files.push({
561
+ path: `skills/${name}/${rel}`,
562
+ content: rel === "SKILL.md" ? withFrontmatterName(text, name) : text,
563
+ group: "skills"
564
+ });
565
+ }
566
+ }
519
567
  }
520
- return readOrNull(join3(dir, "skills", "onboard", "SKILL.md"));
568
+ const agentsDir = join3(source, "agents");
569
+ if (existsSync2(agentsDir)) {
570
+ for (const file of (await readdir(agentsDir)).filter((f) => f.endsWith(".md")).sort()) {
571
+ const text = await readFile(join3(agentsDir, file), "utf-8");
572
+ const name = harenName(frontmatterName(text) ?? file.slice(0, -3));
573
+ files.push({
574
+ path: `agents/${name}.md`,
575
+ content: withFrontmatterName(text, name),
576
+ group: "agents"
577
+ });
578
+ }
579
+ }
580
+ return files.sort((x, y) => x.path.localeCompare(y.path));
521
581
  }
522
582
  async function computeRootFiles(o) {
523
583
  const name = relative(o.workspaceDir, o.harenDir).split(sep).join("/");
@@ -525,8 +585,17 @@ async function computeRootFiles(o) {
525
585
  const useCursor = o.editor !== "claude-code";
526
586
  const command = gateCommand(name);
527
587
  const config = renderTemplate(editorConfigTemplate, name);
528
- const onboard = await readOrNull(join3(o.harenDir, "skills", "onboard", "SKILL.md")) ?? await readPackagedOnboard(o.contentDir);
588
+ const framework = await frameworkFiles(o.harenDir, o.contentDir);
529
589
  const specs = [];
590
+ const addFramework = (editorDir) => {
591
+ for (const f of framework) {
592
+ specs.push({
593
+ path: `${editorDir}/${f.path}`,
594
+ make: () => f.content,
595
+ group: `${editorDir}/${f.group}/`
596
+ });
597
+ }
598
+ };
530
599
  if (useClaude) {
531
600
  specs.push({
532
601
  path: "CLAUDE.md",
@@ -534,8 +603,7 @@ async function computeRootFiles(o) {
534
603
  markdown: true
535
604
  });
536
605
  specs.push({ path: ".claude/settings.json", make: (old) => mergeClaudeSettings(old, command) });
537
- if (onboard !== null)
538
- specs.push({ path: ".claude/skills/haren-onboard/SKILL.md", make: () => onboard });
606
+ addFramework(".claude");
539
607
  }
540
608
  if (useCursor) {
541
609
  specs.push({
@@ -548,8 +616,7 @@ async function computeRootFiles(o) {
548
616
  make: () => renderTemplate(cursorRuleTemplate, name)
549
617
  });
550
618
  specs.push({ path: ".cursor/hooks.json", make: (old) => mergeCursorHooks(old, command) });
551
- if (onboard !== null)
552
- specs.push({ path: ".cursor/skills/haren-onboard/SKILL.md", make: () => onboard });
619
+ addFramework(".cursor");
553
620
  }
554
621
  const files = [];
555
622
  for (const spec of specs) {
@@ -560,11 +627,33 @@ async function computeRootFiles(o) {
560
627
  content,
561
628
  existed: old !== null,
562
629
  changed: old !== content,
563
- userContent: spec.markdown ? hasUserContent(old) : false
630
+ userContent: spec.markdown ? hasUserContent(old) : false,
631
+ ...spec.group ? { group: spec.group } : {}
564
632
  });
565
633
  }
566
634
  return files;
567
635
  }
636
+ function summarizeRootFiles(files) {
637
+ const out = [];
638
+ const groups = new Map;
639
+ for (const file of files) {
640
+ if (!file.group) {
641
+ out.push(file);
642
+ continue;
643
+ }
644
+ const g = groups.get(file.group);
645
+ if (!g) {
646
+ const entry = { ...file, path: file.group, content: "", count: 1 };
647
+ groups.set(file.group, entry);
648
+ out.push(entry);
649
+ } else {
650
+ g.count += 1;
651
+ g.existed ||= file.existed;
652
+ g.changed ||= file.changed;
653
+ }
654
+ }
655
+ return out;
656
+ }
568
657
  async function writeRootFiles(o) {
569
658
  const files = await computeRootFiles(o);
570
659
  for (const file of files) {
@@ -596,7 +685,7 @@ var init_root_files = __esm(() => {
596
685
 
597
686
  // src/workspace/git.ts
598
687
  import { existsSync as existsSync3 } from "fs";
599
- import { mkdir as mkdir3, readdir } from "fs/promises";
688
+ import { mkdir as mkdir3, readdir as readdir2 } from "fs/promises";
600
689
  import { dirname as dirname2, join as join4, resolve as resolve2 } from "path";
601
690
  function gitEnv(interactive = process.stdin.isTTY === true, base = process.env) {
602
691
  if (interactive)
@@ -649,7 +738,7 @@ async function gitInit(dir) {
649
738
  return runGit(["init"], dir);
650
739
  }
651
740
  async function listChildRepos(dir) {
652
- const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
741
+ const entries = await readdir2(dir, { withFileTypes: true }).catch(() => []);
653
742
  const repos = [];
654
743
  for (const entry of entries) {
655
744
  if (!entry.isDirectory() || entry.name.startsWith(".") || entry.name === "node_modules")
@@ -665,7 +754,7 @@ var init_git = () => {};
665
754
 
666
755
  // src/workspace/resolve.ts
667
756
  import { existsSync as existsSync4 } from "fs";
668
- import { readdir as readdir2, readFile as readFile2, stat } from "fs/promises";
757
+ import { readdir as readdir3, readFile as readFile2, stat } from "fs/promises";
669
758
  import { dirname as dirname3, join as join5, resolve as resolve3 } from "path";
670
759
  async function hasMarkedManifest(dir) {
671
760
  const path = join5(dir, "manifest.yaml");
@@ -710,7 +799,7 @@ async function resolveHarenDir(cwd, opts = {}) {
710
799
  }
711
800
  if (await hasMarkedManifest(cwd))
712
801
  return location(cwd, false);
713
- const entries = await readdir2(cwd, { withFileTypes: true }).catch(() => []);
802
+ const entries = await readdir3(cwd, { withFileTypes: true }).catch(() => []);
714
803
  const matches = [];
715
804
  for (const entry of entries) {
716
805
  if (entry.name.startsWith(".") || entry.name === "node_modules")
@@ -788,21 +877,24 @@ import { basename as basename2, relative as relative2, resolve as resolve4, sep
788
877
  async function buildPlan(input) {
789
878
  const items = [];
790
879
  const generatedNote = input.layout === "workspace" ? "(generated, not versioned)" : undefined;
791
- for (const file of await computeRootFiles({
880
+ const rootFiles = await computeRootFiles({
792
881
  workspaceDir: input.rootDir,
793
882
  harenDir: input.harenDir,
794
883
  editor: input.editor
795
- })) {
884
+ });
885
+ for (const file of summarizeRootFiles(rootFiles)) {
886
+ const count = file.count ? `(${file.count} files)` : undefined;
887
+ const join = (...notes) => notes.filter(Boolean).join(" ") || undefined;
796
888
  if (!file.existed)
797
- items.push({ path: file.path, action: "create", note: generatedNote });
889
+ items.push({ path: file.path, action: "create", note: join(count, generatedNote) });
798
890
  else if (file.changed)
799
891
  items.push({
800
892
  path: file.path,
801
893
  action: "modify",
802
- note: file.userContent ? "(haren block only)" : undefined
894
+ note: file.userContent ? "(haren block only)" : count
803
895
  });
804
896
  else
805
- items.push({ path: file.path, action: "keep" });
897
+ items.push({ path: file.path, action: "keep", note: count });
806
898
  }
807
899
  for (const [key, repo] of Object.entries(input.repos)) {
808
900
  const abs = resolve4(input.harenDir, repo.path);
@@ -936,7 +1028,7 @@ var init_version = __esm(() => {
936
1028
  });
937
1029
 
938
1030
  // src/commands/init.ts
939
- import { mkdir as mkdir4, writeFile as writeFile3, readdir as readdir3, copyFile, readFile as readFile3 } from "fs/promises";
1031
+ import { mkdir as mkdir4, writeFile as writeFile3, readdir as readdir4, copyFile, readFile as readFile3 } from "fs/promises";
940
1032
  import { existsSync as existsSync8, realpathSync } from "fs";
941
1033
  import { homedir } from "os";
942
1034
  import { basename as basename3, join as join6, resolve as resolve6 } from "path";
@@ -1104,7 +1196,7 @@ function getDirectories(iterations) {
1104
1196
  return dirs;
1105
1197
  }
1106
1198
  async function copyRecursive(src, dest) {
1107
- const entries = await readdir3(src, { withFileTypes: true });
1199
+ const entries = await readdir4(src, { withFileTypes: true });
1108
1200
  await mkdir4(dest, { recursive: true });
1109
1201
  for (const entry of entries) {
1110
1202
  const srcPath = join6(src, entry.name);
@@ -1627,7 +1719,7 @@ var init_init = __esm(() => {
1627
1719
  });
1628
1720
 
1629
1721
  // src/commands/upgrade.ts
1630
- import { mkdir as mkdir5, readdir as readdir4, copyFile as copyFile2, readFile as readFile4, stat as stat2, writeFile as writeFile4 } from "fs/promises";
1722
+ import { mkdir as mkdir5, readdir as readdir5, copyFile as copyFile2, readFile as readFile4, stat as stat2, writeFile as writeFile4 } from "fs/promises";
1631
1723
  import { join as join7, resolve as resolve7 } from "path";
1632
1724
  import { existsSync as existsSync9 } from "fs";
1633
1725
  async function moduleRepoKey(harenDir, moduleName) {
@@ -1698,8 +1790,9 @@ async function planMigration(location) {
1698
1790
  steps.push(`.gitignore: add ${AGENT_FILES.join(", ")}`);
1699
1791
  const editor = detectEditor(workspaceDir) ?? "claude-code";
1700
1792
  const rootFiles = await computeRootFiles({ workspaceDir, harenDir, editor });
1701
- for (const file of rootFiles.filter((f) => f.changed)) {
1702
- steps.push(`${file.path}: ${file.existed ? "update" : "create"}`);
1793
+ for (const file of summarizeRootFiles(rootFiles).filter((f) => f.changed)) {
1794
+ const count = file.count ? ` (${file.count} files)` : "";
1795
+ steps.push(`${file.path}: ${file.existed ? "update" : "create"}${count}`);
1703
1796
  }
1704
1797
  return {
1705
1798
  manifest: { before: manifestBefore, after: manifestAfter },
@@ -1726,7 +1819,7 @@ async function planGitignore(harenDir) {
1726
1819
  return `${base}${missing.join(eol)}${eol}`;
1727
1820
  }
1728
1821
  async function copyRecursive2(src, dest) {
1729
- const entries = await readdir4(src, { withFileTypes: true });
1822
+ const entries = await readdir5(src, { withFileTypes: true });
1730
1823
  await mkdir5(dest, { recursive: true });
1731
1824
  for (const entry of entries) {
1732
1825
  const srcPath = join7(src, entry.name);
@@ -1740,7 +1833,7 @@ async function copyRecursive2(src, dest) {
1740
1833
  }
1741
1834
  async function countFiles(dir) {
1742
1835
  let count = 0;
1743
- const entries = await readdir4(dir, { withFileTypes: true });
1836
+ const entries = await readdir5(dir, { withFileTypes: true });
1744
1837
  for (const entry of entries) {
1745
1838
  if (entry.isDirectory()) {
1746
1839
  count += await countFiles(join7(dir, entry.name));
@@ -1880,7 +1973,7 @@ var init_cli_detector = __esm(() => {
1880
1973
 
1881
1974
  // src/agent/artifact-reader.ts
1882
1975
  import { join as join9 } from "path";
1883
- import { readdir as readdir5 } from "fs/promises";
1976
+ import { readdir as readdir6 } from "fs/promises";
1884
1977
  async function readProgress(harenDir) {
1885
1978
  const file = Bun.file(join9(harenDir, "progress.json"));
1886
1979
  if (!await file.exists())
@@ -1896,7 +1989,7 @@ async function readArtifactTree(harenDir) {
1896
1989
  }
1897
1990
  }
1898
1991
  async function buildTree(dirPath, relativePath) {
1899
- const entries = await readdir5(dirPath, { withFileTypes: true });
1992
+ const entries = await readdir6(dirPath, { withFileTypes: true });
1900
1993
  const nodes = [];
1901
1994
  for (const entry of entries) {
1902
1995
  const entryPath = join9(relativePath, entry.name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odarino/haren",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Minimal skill-based agentic SDLC framework",
5
5
  "type": "module",
6
6
  "license": "MIT",