A session log that parallel agents never conflict on
@slashclone/parallel-session-log
Keep a project log that several Claude Code sessions can write at once without merge conflicts. Each session writes its own dated file, an index is generated instead of hand edited, and a small CI check makes sure every entry carries the line your team requires. Writes the files for you to review; never commits or pushes.
SkillDevOpsv0.1.0 (latest)
- Activity
- New: be the first to try it
- Installs
- 0 installs
- Likes
- 0 likes
- Clones
- 0 clones
- 1#!/usr/bin/env node
- 2// Rebuilds the session index in docs/PROGRESS.md from the files in docs/progress/.
- 3// Each session writes its own docs/progress/YYYY-MM-DD-slug.md and never edits PROGRESS.md,
- 4// so parallel pull requests do not conflict. Run this now and then (an upkeep pull request,
- 5// or before a release) to refresh the index: `node .github/scripts/session-log-index.mjs`.
- 6// Node standard library only. Edit LOG and DIR if your log lives elsewhere.
- 7import { readFileSync, readdirSync, writeFileSync } from "node:fs";
- 9const LOG = "docs/PROGRESS.md";
- 10const DIR = "docs/progress";
- 11const START = "<!-- progress-index:start -->";
- 12const END = "<!-- progress-index:end -->";
- 13const NAME = /^(\d{4}-\d{2}-\d{2})-[a-z0-9]+(?:-[a-z0-9]+)*\.md$/;
- 15const rows = readdirSync(DIR)
- 16 .filter((name) => NAME.test(name))
- 17 .sort()
- 18 .reverse()
- 19 .map((name) => {
- 20 const text = readFileSync(`${DIR}/${name}`, "utf8");
- 21 const heading = text.split("\n").find((line) => line.startsWith("## "));
- 22 const title = heading ? heading.slice(3).trim() : name.replace(/\.md$/, "");
- 23 return `- [${title}](progress/${name})`;
- 24 });
- 26const log = readFileSync(LOG, "utf8");
- 27const from = log.indexOf(START);
- 28const to = log.indexOf(END);
- 29if (from < 0 || to < from) {
- 30 console.error(`${LOG}: index markers not found (${START} ... ${END}).`);
- 31 process.exit(1);
- 32}
- 33const body = rows.length > 0 ? rows.join("\n") : "_No session files yet._";
- 34const next = `${log.slice(0, from + START.length)}\n\n${body}\n\n${log.slice(to)}`;
- 35if (next === log) console.log(`${LOG}: index already up to date (${rows.length} sessions).`);
- 36else {
- 37 writeFileSync(LOG, next);
- 38 console.log(`${LOG}: index rebuilt (${rows.length} sessions).`);
- 39}
