Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.
TypeScript ai-agentsanthropicclaude-codeclicode-graphcodexcontext-engineeringcursordeveloper-toolsgeminiknowledge-graphllmmcpmcp-serveropen-sourceopenaitree-sitter
fix(pair): name the look-back's skills on Trail's page, kept on this machine
Shrish Dwivediac900918b237
diff --git a/src/cli.ts b/src/cli.tsindex fed0b646..fd7e4a4a 100644--- a/src/cli.ts+++ b/src/cli.ts@@ -61,7 +61,7 @@ import { listSessionIds, readSession, sessionDir } from "./claude/state.js";import { costLabel, listNotes, noteName, notePlace, noteTargets, readingTokens, commitLines, PERSONAL_SAVED_LINE, PR_SPEEDUP, SECTIONS, tokensWorthSaying, sectionLead, shortDate, tokensLabel, writeNote, type Note, mentionedFiles } from "./notes/notes.js";import { aboutTerms, currentSessionCost } from "./notes/session-cost.js";import { flatLine, unmarkedWords } from "./notes/flatten.js";-import { beginLookBack, finishLookBack } from "./init/run.js";+import { beginLookBack, finishLookBack, type FoundSkill } from "./init/run.js";import { keepCommand } from "./init/keep.js";import { recordInit, snapInit } from "./init/install-paths.js";import { finishPair, PairRun, validPairCode } from "./cloud/pair.js";@@ -1669,8 +1669,9 @@ async function runInitCommand(dir: string, opts: InitOptions, progress?: InitPro// are, and how many there already are.let learnedNow = false;let teamSaved = 0;- // What the look-back read, for the --pair and --connect pages.+ // What the look-back read, for the --pair and --connect pages, and the skills it found (--pair names them).let sessionsRead = 0;+ let skillsFound: FoundSkill[] = [];if (lookBack) {// With --pair the person reviews what was found on Trail's page, so no screen here, as with no terminal.const screen = tty && !pair;@@ -1689,6 +1690,7 @@ async function runInitCommand(dir: string, opts: InitOptions, progress?: InitProfor (const note of fromMemory.saved) console.error(` ${note.scope === "personal" ? "just for you " : "for your team"} · ${note.title}`);}sessionsRead = learned.read?.sessions ?? 0;+ skillsFound = learned.skills ?? [];const prs = learned.read?.prs;if (pair && prs !== undefined && prs !== null) {const n = fromReviews?.saved.length ?? 0;@@ -1773,7 +1775,7 @@ async function runInitCommand(dir: string, opts: InitOptions, progress?: InitProconst teammates = teammatesChecked(repo, { learnings: teamNotes });pair.teamDone(teammates);pair.findings({ tokens, sessions: lookBack?.reads.lb ? sessionsRead : undefined, teammates });- await pair.finish(repo);+ await pair.finish(repo, skillsFound);pair.handOff(repo);console.error(`✓ Trail has what it found · review it in the browser: ${pair.url}`);if (!process.stdout.isTTY) console.error(`[trail] Tell the user, in one line: their Trail page has moved on; review what Trail found there. If it isn't open, the link is ${pair.url}`);diff --git a/src/cloud/pair.ts b/src/cloud/pair.tsindex aeb8cf9a..341c66a7 100644--- a/src/cloud/pair.ts+++ b/src/cloud/pair.ts@@ -14,14 +14,11 @@*/import { spawn } from "node:child_process";import { createHash } from "node:crypto";-import { readFileSync } from "node:fs";-import { join, resolve } from "node:path";import { graftCliPath } from "../claude/paths.js";import { noteAuthor } from "../notes/git-facts.js";import { repoName, repoPlace } from "../notes/home.js";-import type { SavedSkill } from "../skills/found-skill.js";-import { skillDirs, skillName } from "../skills/skills.js";-import { matter } from "../util/front-matter.js";+import type { FoundSkill } from "../init/run.js";+import { skillName } from "../skills/skills.js";import { newState } from "./nudge.js";import type { TeammateSummary, TokensSummary } from "./onboarding.js";import { dropActivity, reviewPayload, syncRepo } from "./workspace-sync.js";@@ -53,38 +50,42 @@ export interface PairFindings {}/**- * One team skill init just wrote as a found item. Nothing for a skill that was- * already there, a skill kept for the person alone, or a file that isn't under- * the repo's own `.claude/skills/`: only what init wrote into the repo goes up.+ * A skill the look-back found, as a found item: its title and on how many+ * days it came up, labelled kept on this machine. Never its steps: init's+ * skills are the person's own (they go to ~/.trail, and only when kept+ * through `trail keep` or the screen), so the page names them and+ * nothing more. Its path is not a repo path, so it can't be taken for one of+ * the repo's skills.*/-function foundSkillItem(checkout: string, s: SavedSkill): Record<string, unknown>[] {- const name = skillName(s.skill.name);- const expected = join(skillDirs(checkout).repo, name, "SKILL.md");- if (!s.created || s.skill.for !== "team" || !name || resolve(s.path) !== resolve(expected)) return [];- let text: string;- try {- text = readFileSync(s.path, "utf8");- } catch {- return [];- }+function machineSkillItem(s: FoundSkill, author: string): Record<string, unknown>[] {+ const name = skillName(s.name);+ const title = s.title.replace(/\s+/g, " ").trim().slice(0, 120);+ if (!name || !title) return [];+ const days = Math.max(0, Math.floor(s.days));return [{kind: "skill",- path: `.claude/skills/${name}/SKILL.md`,- title: s.skill.title,- author: noteAuthor(checkout),- body: matter(text).content.trim(),- hash: createHash("sha256").update(text).digest("hex"),+ path: `~/.trail/skills/${name}`,+ title,+ why: `kept on this machine · came up on ${days} day${days === 1 ? "" : "s"}`,+ author,+ body: "",+ hash: createHash("sha256").update(`machine-skill:${s.id}`).digest("hex"),touches: [],},];}-/** "Found 3 learnings and 1 skill for your team"; the skills part is left out when there are none. */-export function foundLine(learnings: number, skills: number): string {+/**+ * "Found 3 learnings and 1 skill for your team"; the skills part is left out+ * when there are none. Skills kept on this machine are counted apart: they+ * aren't the team's.+ */+export function foundLine(learnings: number, skills: number, mine = 0): string {const l = `${learnings} learning${learnings === 1 ? "" : "s"}`;const sk = `${skills} skill${skills === 1 ? "" : "s"}`;- return `Found ${learnings === 0 && skills > 0 ? sk : skills > 0 ? `${l} and ${sk}` : l} for your team`;+ const team = `Found ${learnings === 0 && skills > 0 ? sk : skills > 0 ? `${l} and ${sk}` : l} for your team`;+ return mine > 0 ? `${team}, and ${mine} skill${mine === 1 ? "" : "s"} kept on this machine` : team;}/** The most found learnings one progress call may carry. */@@ -177,37 +178,37 @@ export class PairRun {/*** Hand over the repo's learnings and skills, then say the read is done. A- * learning is a `decision`; a skill is a `skill`. A skill kept for the- * person alone isn't the team's, so it stays off the page.+ * learning is a `decision`; a skill is a `skill`. The skills the look-back+ * found (`found`) go last, by title and day count only, labelled kept on+ * this machine: a pick on the page saves nothing here.*/- finish(repo: string, skills: SavedSkill[] = []): Promise<void> {+ finish(repo: string, found: FoundSkill[] = []): Promise<void> {const place = repoPlace(repo);// Everything the person's agents now start from in this repo, so the page// counts what the home will: their learnings and teammates' pushed ones,- // then the skills this run wrote and the ones the repo already has.- const found: Record<string, unknown>[] = [];+ // and the skills the repo has. Then the skills found on this machine.+ const items: Record<string, unknown>[] = [];if (place.git) {const payload = reviewPayload(place.checkout);const item = (l: (typeof payload)[number]) => ({kind: l.kind === "skill" ? "skill" : "decision", path: l.path, title: l.title, author: l.author, body: l.body, hash: l.hash, touches: l.touches,});- const written = skills.flatMap((s) => foundSkillItem(place.checkout, s));- const paths = new Set(written.map((w) => w.path));- found.push(- ...payload.filter((l) => l.kind !== "skill").map(item),- ...written,- ...payload.filter((l) => l.kind === "skill" && !paths.has(l.path)).map(item),- );- found.splice(MAX_FOUND); // Trail takes this many from one read+ items.push(...payload.filter((l) => l.kind !== "skill").map(item), ...payload.filter((l) => l.kind === "skill").map(item));}- const n = found.length;- const m = found.filter((f) => f.kind === "skill").length;- const learned = n - m;+ const author = noteAuthor(repo);+ const mine = found.flatMap((s) => machineSkillItem(s, author));+ items.splice(MAX_FOUND - Math.min(mine.length, MAX_FOUND));+ items.push(...mine);+ items.splice(MAX_FOUND); // Trail takes this many from one read+ const n = items.length;+ const machine = Math.min(mine.length, MAX_FOUND);+ const m = items.filter((f) => f.kind === "skill").length - machine;+ const learned = n - m - machine;this.phases = this.phases.map((p) => (p.status === "done" ? p : { ...p, status: "done" as const }));this.phases = this.phases.map((p) => (p.id === "learnings" ? { ...p, count: String(n) } : p));for (let i = 0; i < Math.max(n, 1); i += FOUND_PER_CALL) {- const part = found.slice(i, i + FOUND_PER_CALL);- this.send({ phases: this.phases, found: part, ...(i === 0 ? { log: [foundLine(learned, m)] } : {}) });+ const part = items.slice(i, i + FOUND_PER_CALL);+ this.send({ phases: this.phases, found: part, ...(i === 0 ? { log: [foundLine(learned, m, machine)] } : {}) });}this.send({ done: true });return this.flush();diff --git a/src/init/run.ts b/src/init/run.tsindex d9582cfa..67ce5e66 100644--- a/src/init/run.ts+++ b/src/init/run.ts@@ -167,9 +167,13 @@ function itemsOf(picked: Array<InitCandidate & { n: number }>, named: Named, env/*** `team`: #662's team rows saved into `.trail/learnings/`, for the agent's commit ask; `teamKept`: what they were, with* no screen. `read`: what was looked at, for `init --pair` and `--connect` to count: the past sessions, and the merged- * PRs (null when the PR reviews weren't read).+ * PRs (null when the PR reviews weren't read). `skills`: the skills the look-back found this run, each kept (or not) on+ * this machine only, for the pair page to list by name and day count: never their steps.*/-export interface LookBackDone { kept: number; inRepo: boolean; team: number; teamKept?: TeamKept; read?: { sessions: number; prs: number | null } }+export interface LookBackDone { kept: number; inRepo: boolean; team: number; teamKept?: TeamKept; read?: { sessions: number; prs: number | null }; skills?: FoundSkill[] }++/** A skill the look-back found, as `init --pair` names it to Trail's page: its name and title, and on how many days it came up. */+export interface FoundSkill { id: string; name: string; title: string; days: number }/*** Wait for the reads, show what they found (screen, relay or the script's list), keep what the person picks, and@@ -212,6 +216,7 @@ export async function finishLookBack(repo: string, reads: LookBackReads,const read = { sessions: lb.sessions.length, prs: reviewResult ? reviewResult.prs : null };// The look-back's own five, numbered 1..k for the relay and `trail keep`.const items = itemsOf(numbered(first), named, env);+ const skills: FoundSkill[] = items.filter((i) => i.kind === 'skill').map((i) => ({ id: i.id, name: i.plainName, title: i.title, days: i.count.days }));// #662's team rows: only findings tied to code that exists, and the memory notes; never relayed.const anchored = reviewResult ? anchoredReviews(repo, reviewResult.findings) : [];const team = [...reviewItems(anchored, repoKey, new Set([...record.closed, ...record.runs.flatMap((r) => r.kept)])), ...memoryItems(reads.memory, repoKey)];@@ -282,7 +287,7 @@ export async function finishLookBack(repo: string, reads: LookBackReads,}if (reads.reviews) await finishReviewRead(repo, reads.reviews, async () => []);tele('none_found', 0);- return { ...none, read };+ return { ...none, read, skills };}if (screen) {@@ -325,7 +330,7 @@ export async function finishLookBack(repo: string, reads: LookBackReads,tele('found', result.kept.filter((i) => !isTeam(i)).length);}for (const l of afterKeepLines({ ...result, how: answer.how }, facts)) say(l);- return { kept: result.kept.length, inRepo: result.kept.some((i) => i.scope === 'repo' || isTeam(i)), team: teamSaved, read };+ return { kept: result.kept.length, inRepo: result.kept.some((i) => i.scope === 'repo' || isTeam(i)), team: teamSaved, read, skills };}// No screen: the relay (agent) or the script's list for the look-back's items. A PR-review finding is model text@@ -361,5 +366,5 @@ export async function finishLookBack(repo: string, reads: LookBackReads,if (looked && !reads.skills) say(INIT_COPY.skillsOff!);tele('relayed', kept);const teamKept = (fromTeam.fromReviews?.saved.length ?? 0) + (fromTeam.fromMemory?.saved.length ?? 0);- return { kept: kept + teamKept, inRepo: fromTeam.team > 0, team: fromTeam.team, teamKept: { fromReviews: fromTeam.fromReviews, fromMemory: fromTeam.fromMemory }, read };+ return { kept: kept + teamKept, inRepo: fromTeam.team > 0, team: fromTeam.team, teamKept: { fromReviews: fromTeam.fromReviews, fromMemory: fromTeam.fromMemory }, read, skills };}diff --git a/src/skills/found-skill.ts b/src/skills/found-skill.tsdeleted file mode 100644index c9fb5f96..00000000--- a/src/skills/found-skill.ts+++ /dev/null@@ -1,83 +0,0 @@-/**- * A skill found in past sessions: a procedure the person walked Claude through- * in two or more of them, written to a SKILL.md at `trail init` so the next- * session can follow it without being walked through it again.- *- * The team's go in the repo's `.claude/skills/`, where Claude Code loads them- * for everyone who pulls; the person's own go in this repo's skills under- * ~/.trail. A skill of that name that already exists is never touched.- */-import { existsSync, mkdirSync, writeFileSync } from "node:fs";-import { join } from "node:path";-import { ensureRepoHome } from "../notes/home.js";-import { skillDirs, skillName } from "./skills.js";--export interface FoundSkill {- name: string;- title: string;- /** `team`: written into the repo. `you`: kept on this machine. */- for: "team" | "you";- /** What to do, in order: 2 to 8 commands or actions. */- steps: string[];- /** Sessions the cited quotes were found in, newest first. */- sessions: string[];- quotes: string[];-}--/** A skill's SKILL.md: where it is, and whether this run wrote it (`false`: one of that name was already there). */-export interface SavedSkill {- skill: FoundSkill;- path: string;- created: boolean;-}--/** SKILL.md for a found skill: the frontmatter every skill has, then its steps as a numbered list. */-export function renderFoundSkill(s: FoundSkill): string {- const name = skillName(s.name);- const steps = s.steps.map((step, i) => `${i + 1}. ${step}`).join("\n");- return `---\nname: ${name}\ndescription: ${JSON.stringify(s.title)}\nversion: 1\n---\n\n# ${s.title}\n\n${steps}\n`;-}--/** The SKILL.md a skill of this name already has, in the repo or on this machine; null when there's none. */-function existingSkillFile(repo: string, name: string): string | null {- const dirs = skillDirs(repo);- for (const d of [dirs.repo, dirs.home]) {- const there = join(d, name, "SKILL.md");- if (existsSync(there)) return there;- }- return null;-}--/**- * The lines init prints for found skills it didn't write because one of that- * name already exists (in the repo or on this machine), one per skill.- */-export function skippedSkillLines(repo: string, found: FoundSkill[], written: SavedSkill[]): string[] {- const out: string[] = [];- for (const skill of found) {- const name = skillName(skill.name);- if (!name || written.some((w) => w.skill === skill) || !existingSkillFile(repo, name)) continue;- out.push(`· Skipped skill ${name}: one already exists.`);- }- return out;-}--/**- * Write the skill, and return the path of its SKILL.md and whether this call- * wrote it. A skill of that name the repo or this machine already has is left- * as it is: its path comes back with `created: false`, and it isn't ours to- * report or send anywhere.- */-export function saveFoundSkill(repo: string, s: FoundSkill): { path: string; created: boolean } {- const name = skillName(s.name);- if (!name) throw new Error("a skill needs a name");- const dirs = skillDirs(repo);- const there = existingSkillFile(repo, name);- if (there) return { path: there, created: false };- if (s.for === "you") ensureRepoHome(repo);- const dir = join(s.for === "you" ? dirs.home : dirs.repo, name);- mkdirSync(dir, { recursive: true });- const file = join(dir, "SKILL.md");- writeFileSync(file, renderFoundSkill(s));- return { path: file, created: true };-}diff --git a/test/cold-start-skills.test.ts b/test/cold-start-skills.test.tsdeleted file mode 100644index 3fcf39d5..00000000--- a/test/cold-start-skills.test.ts+++ /dev/null@@ -1,157 +0,0 @@-/**- * Found skills: a SKILL.md is never written over one that exists, and- * `init --pair` hands the page only the team skills this run wrote, as- * items of kind skill. (Finding them is the look-back's now: src/init/.)- */-import { test } from "node:test";-import assert from "node:assert/strict";-import { spawnSync } from "node:child_process";-import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";-import { tmpdir } from "node:os";-import { join } from "node:path";-import { PairRun } from "../src/cloud/pair.js";-import { saveFoundSkill, skippedSkillLines, type FoundSkill, type SavedSkill } from "../src/skills/found-skill.js";-import { skillDirs } from "../src/skills/skills.js";-import { writeNote } from "../src/notes/notes.js";-import { tmpRepo } from "./helpers.js";--const STEPS = ["Run `npm run build`", "Run `npm test`", "Bump the version in package.json", "Run `npm publish --otp` with the code from the user"];--/** Each found skill saved, keeping only the ones this call wrote (what init's old look-back did). */-function saveSkills(repo: string, skills: FoundSkill[]): SavedSkill[] {- return skills.flatMap((skill) => {- const { path, created } = saveFoundSkill(repo, skill);- return created ? [{ skill, path, created }] : [];- });-}--test("saving a skill never overwrites one of that name, the team's or this machine's", () => {- process.env.TRAIL_HOME = mkdtempSync(join(tmpdir(), "skills-nooverwrite-"));- const repo = tmpRepo("found-skill-keep");- spawnSync("git", ["init", "-q"], { cwd: repo });- const found: FoundSkill = { name: "cut a release", title: "Cut a release", for: "team", steps: STEPS, sessions: ["a", "b"], quotes: [] };- const theirs = join(repo, ".claude", "skills", "cut-a-release");- mkdirSync(theirs, { recursive: true });- writeFileSync(join(theirs, "SKILL.md"), "---\nname: cut-a-release\ndescription: theirs\n---\n\nTheirs.\n");- assert.deepEqual(saveFoundSkill(repo, found), { path: join(theirs, "SKILL.md"), created: false });- assert.match(readFileSync(join(theirs, "SKILL.md"), "utf8"), /Theirs\./);- // The same name for you finds the team's, and leaves it be.- assert.deepEqual(saveFoundSkill(repo, { ...found, for: "you" }), { path: join(theirs, "SKILL.md"), created: false });- // Saved once for you, the second save returns the first's path.- const other: FoundSkill = { ...found, name: "ship it", for: "you" };- const wrote = saveFoundSkill(repo, other);- assert.equal(wrote.created, true);- const first = wrote.path;- writeFileSync(first, "edited by hand");- assert.deepEqual(saveFoundSkill(repo, other), { path: first, created: false });- assert.equal(readFileSync(first, "utf8"), "edited by hand");-});--test("init --pair hands over found items with a kind: learnings are decisions, skills are skills", async () => {- process.env.TRAIL_HOME = mkdtempSync(join(tmpdir(), "skills-pair-"));- process.env.DO_NOT_TRACK = "1";- process.env.TRAIL_TEST_SERVER = "http://trail.test";- const dir = tmpRepo("pair-skill");- spawnSync("git", ["init", "-q", "-b", "main"], { cwd: dir });- spawnSync("git", ["remote", "add", "origin", "https://github.com/acme/billing.git"], { cwd: dir });- writeNote(dir, { title: "Keep payment retries at 4", body: "## Decided\nFour retries.", author: "Sam", date: "2026-10-07", touches: [] });- const team: FoundSkill = { name: "cut a release", title: "Cut a release", for: "team", steps: STEPS, sessions: ["a", "b"], quotes: [] };- const mine: FoundSkill = { name: "my own habit", title: "My own habit", for: "you", steps: STEPS, sessions: ["a", "b"], quotes: [] };- const saved = [team, mine].map((skill) => ({ skill, ...saveFoundSkill(dir, skill) }));-- const calls: { path: string; body: Record<string, unknown> }[] = [];- const fetchImpl = (async (url: string | URL, init?: RequestInit) => {- const u = new URL(String(url));- calls.push({ path: u.pathname, body: init?.body ? JSON.parse(String(init.body)) : {} });- return u.pathname === "/api/cli/handoffs" ? new Response(JSON.stringify({ url: "http://trail.test/c" }), { status: 201 }) : new Response("{}", { status: 202 });- }) as typeof fetch;- const run = await PairRun.start(dir, "X4GM5OQU4NIA65ZR", { agent: "claude", version: "0.23.1", fetchImpl });- assert.ok(run instanceof PairRun);- await run.finish(dir, saved);-- const found = calls.filter((c) => c.path === "/api/cli/handoffs/progress").flatMap((c) => (c.body.found as Record<string, unknown>[] | undefined) ?? []);- assert.deepEqual(found.map((f) => [f.kind, f.title]), [["decision", "Keep payment retries at 4"], ["skill", "Cut a release"]]);- const skill = found[1]!;- assert.equal(skill.path, ".claude/skills/cut-a-release/SKILL.md");- assert.match(String(skill.body), /1\. Run `npm run build`/);- assert.equal(typeof skill.hash, "string");-});--/** What init --pair sends as found items for `saved`, given a repo with one learning. */-async function pairFound(dir: string, saved: SavedSkill[]): Promise<Record<string, unknown>[]> {- process.env.DO_NOT_TRACK = "1";- process.env.TRAIL_TEST_SERVER = "http://trail.test";- const calls: { path: string; body: Record<string, unknown> }[] = [];- const fetchImpl = (async (url: string | URL, init?: RequestInit) => {- const u = new URL(String(url));- calls.push({ path: u.pathname, body: init?.body ? JSON.parse(String(init.body)) : {} });- return u.pathname === "/api/cli/handoffs" ? new Response(JSON.stringify({ url: "http://trail.test/c" }), { status: 201 }) : new Response("{}", { status: 202 });- }) as typeof fetch;- const run = await PairRun.start(dir, "X4GM5OQU4NIA65ZR", { agent: "claude", version: "0.23.1", fetchImpl });- assert.ok(run instanceof PairRun);- await run.finish(dir, saved);- return calls.filter((c) => c.path === "/api/cli/handoffs/progress").flatMap((c) => (c.body.found as Record<string, unknown>[] | undefined) ?? []);-}--function pairRepo(tag: string): string {- process.env.TRAIL_HOME = mkdtempSync(join(tmpdir(), "skills-collide-"));- const dir = tmpRepo(tag);- spawnSync("git", ["init", "-q", "-b", "main"], { cwd: dir });- spawnSync("git", ["remote", "add", "origin", "https://github.com/acme/billing.git"], { cwd: dir });- writeNote(dir, { title: "Keep payment retries at 4", body: "## Decided\nFour retries.", author: "Sam", date: "2026-10-07", touches: [] });- return dir;-}--const COLLIDING: FoundSkill = { name: "cut a release", title: "Cut a release", for: "team", steps: STEPS, sessions: ["a", "b"], quotes: [] };--test("a team skill named like one of this machine's skills sends nothing and leaves that skill alone", async () => {- const dir = pairRepo("pair-collide-home");- const mine = join(skillDirs(dir).home, "cut-a-release");- mkdirSync(mine, { recursive: true });- const personal = "---\nname: cut-a-release\ndescription: personal\n---\n\nMy private steps, with a secret.\n";- writeFileSync(join(mine, "SKILL.md"), personal);-- const saved = saveSkills(dir, [COLLIDING]);- assert.deepEqual(saved, [], "not written, so not reported");- assert.equal(existsSync(join(dir, ".claude")), false, "nothing written into the repo");- assert.equal(readFileSync(join(mine, "SKILL.md"), "utf8"), personal);-- // Even handed the existing path by a caller, the personal file never goes up.- const found = await pairFound(dir, [{ skill: COLLIDING, path: join(mine, "SKILL.md"), created: true }, ...saved]);- assert.deepEqual(found.map((f) => f.kind), ["decision"]);- assert.doesNotMatch(JSON.stringify(found), /private steps/);-});--test("a team skill named like one the repo already has is not reported as found, and the file is untouched", async () => {- const dir = pairRepo("pair-collide-repo");- const theirs = join(dir, ".claude", "skills", "cut-a-release");- mkdirSync(theirs, { recursive: true });- const text = "---\nname: cut-a-release\ndescription: theirs\n---\n\nA teammate's steps.\n";- writeFileSync(join(theirs, "SKILL.md"), text);-- const saved = saveSkills(dir, [COLLIDING]);- assert.deepEqual(saved, []);- assert.equal(readFileSync(join(theirs, "SKILL.md"), "utf8"), text);- const found = await pairFound(dir, [{ skill: COLLIDING, path: join(theirs, "SKILL.md"), created: false }]);- assert.deepEqual(found.map((f) => f.kind), ["decision"]);-});--test("a found team skill that collides with an existing one is named in one line, home or repo", () => {- const dir = pairRepo("pair-skip-line");- const theirs = join(dir, ".claude", "skills", "cut-a-release");- mkdirSync(theirs, { recursive: true });- writeFileSync(join(theirs, "SKILL.md"), "---\nname: cut-a-release\ndescription: theirs\n---\n\nSteps.\n");- const mine = join(skillDirs(dir).home, "my-own-habit");- mkdirSync(mine, { recursive: true });- writeFileSync(join(mine, "SKILL.md"), "---\nname: my-own-habit\ndescription: mine\n---\n\nSteps.\n");- const fresh: FoundSkill = { ...COLLIDING, name: "ship it", title: "Ship it" };- const homeOne: FoundSkill = { ...COLLIDING, name: "my own habit", title: "My own habit", for: "you" };-- const written = saveSkills(dir, [COLLIDING, homeOne, fresh]);- assert.deepEqual(written.map((w) => w.skill.name), ["ship it"]);- assert.deepEqual(skippedSkillLines(dir, [COLLIDING, homeOne, fresh], written), [- "· Skipped skill cut-a-release: one already exists.",- "· Skipped skill my-own-habit: one already exists.",- ]);- assert.deepEqual(skippedSkillLines(dir, [fresh], written), [], "a skill this run wrote isn't reported as skipped");-});diff --git a/test/init-run.test.ts b/test/init-run.test.tsindex 10d683a9..60c3d1e9 100644--- a/test/init-run.test.ts+++ b/test/init-run.test.ts@@ -139,6 +139,9 @@ test("an agent's init looks back without a model and relays: a claude stand-in oassert.match(out, /^3\. "always run the lint script before pushing" \(preference, your own words\) · You said this on 2 days · just for you, in this repo$/m, "the shortest of the person's lines");const rec = readInitRecord(repoPlace(w.repo, env).key, env);assert.deepEqual(rec.pending.map((p) => [p.n, p.kind]), [[1, "skill"], [2, "guardrail"], [3, "preference"]]);+ // For init --pair's page: the skill found, by name and day count, never its steps; nothing kept.+ assert.deepEqual(r.skills?.map((s) => [s.name, s.title, s.days]), [["release-npm", "release-npm", 3]]);+ assert.doesNotMatch(JSON.stringify(r.skills), /npm publish|npm run build/);assert.equal(rec.runs[0]!.by, "agent");assert.equal(rec.runs[0]!.modelWhy, "agent");for (const t of texts(w.trail)) for (const words of [PREF, "before pushing", "lint script", "npm publish", "npm run build", "time box"]) assert.ok(!t.includes(words), `no "${words}" on disk`);diff --git a/test/trail-pair.test.ts b/test/trail-pair.test.tsindex 94770993..a18d3154 100644--- a/test/trail-pair.test.ts+++ b/test/trail-pair.test.ts@@ -8,14 +8,13 @@import { test } from "node:test";import assert from "node:assert/strict";import { spawnSync } from "node:child_process";-import { mkdtempSync } from "node:fs";+import { existsSync, mkdirSync, mkdtempSync, writeFileSync } from "node:fs";import { tmpdir } from "node:os";import { join } from "node:path";import { BRAND_ENV } from "../src/brand.js";import { writeNote } from "../src/notes/notes.js";import { finishPair, foundLine, PairRun, validPairCode } from "../src/cloud/pair.js";import { teammatesChecked, teammatesFromGit } from "../src/cloud/onboarding.js";-import { saveFoundSkill } from "../src/skills/found-skill.js";import { readCloud } from "../src/cloud/workspace.js";import { tmpRepo } from "./helpers.js";@@ -232,14 +231,55 @@ test("the count line names learnings and skills apart, and pluralises", async ()assert.equal(foundLine(2, 3), "Found 2 learnings and 3 skills for your team");assert.equal(foundLine(0, 2), "Found 2 skills for your team");+ assert.equal(foundLine(1, 0, 2), "Found 1 learning for your team, and 2 skills kept on this machine");+ assert.equal(foundLine(0, 1, 1), "Found 1 skill for your team, and 1 skill kept on this machine");+});++/** The found items init --pair sent the page. */+const foundItems = (t: { calls: Call[] }) => progressCalls(t).flatMap((c) => (c.body.found as Record<string, unknown>[] | undefined) ?? []);++test("a skill the look-back found goes to the page by title and day count, labelled kept on this machine, with no steps", async () => {+ freshHome();+ const dir = repo();+ const t = okTrail();+ const run = await PairRun.start(dir, "X4GM5OQU4NIA65ZR", { agent: "claude", version: "0.23.1", fetchImpl: t.fetch });+ assert.ok(run instanceof PairRun);+ await run.finish(dir, [{ id: "i-0123456789", name: "release-npm", title: "Publish to npm", days: 3 }]);++ const found = foundItems(t);+ assert.deepEqual(found.map((f) => [f.kind, f.title]), [["decision", "Keep payment retries at 4"], ["skill", "Publish to npm"]]);+ const skill = found[1]!;+ assert.equal(skill.path, "~/.trail/skills/release-npm", "not a repo path: it can't be taken for one of the repo's skills");+ assert.equal(skill.why, "kept on this machine · came up on 3 days");+ assert.equal(skill.body, "", "never the skill's steps");+ assert.doesNotMatch(JSON.stringify(found), /npm publish/);+ const logs = progressCalls(t).flatMap((c) => (c.body.log as string[] | undefined) ?? []);+ assert.ok(logs.includes("Found 1 learning for your team, and 1 skill kept on this machine"), logs.join(" | "));+ // Nothing is saved here for it: a pick on the page keeps nothing on this machine.+ assert.equal(existsSync(join(dir, ".claude", "skills")), false);+ assert.equal(existsSync(join(process.env.TRAIL_HOME!, "skills")), false);+});++test("a skill the repo tracks goes to the page as the team's, with its body; an untracked one does not", async () => {freshHome();const dir = repo();- const skill = { name: "cut a release", title: "Cut a release", for: "team" as const, steps: ["Run `npm test`", "Run `npm publish`"], sessions: ["a", "b"], quotes: [] };- const saved = [{ skill, ...saveFoundSkill(dir, skill) }];+ const write = (name: string) => {+ mkdirSync(join(dir, ".claude", "skills", name), { recursive: true });+ writeFileSync(join(dir, ".claude", "skills", name, "SKILL.md"), `---\nname: ${name}\ndescription: ${name} steps\n---\n\n1. Run the ${name} script.\n`);+ };+ write("cut-a-release");+ git(dir, ["add", "-A", "-f"]);+ git(dir, ["commit", "-q", "-m", "skill"]);+ write("scratch-idea");const t = okTrail();const run = await PairRun.start(dir, "X4GM5OQU4NIA65ZR", { agent: "claude", version: "0.23.1", fetchImpl: t.fetch });assert.ok(run instanceof PairRun);- await run.finish(dir, saved);+ await run.finish(dir);+ const found = foundItems(t);+ assert.deepEqual(found.map((f) => f.kind), ["decision", "skill"]);+ assert.match(String(found[0]!.path), /^\.trail\/learnings\/.+\.md$/);+ assert.equal(found[1]!.path, ".claude/skills/cut-a-release/SKILL.md");+ assert.match(String(found[1]!.body), /Run the cut-a-release script/);const logs = progressCalls(t).flatMap((c) => (c.body.log as string[] | undefined) ?? []);assert.ok(logs.includes("Found 1 learning and 1 skill for your team"), logs.join(" | "));});