Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
feat(core): refresh unchanged shipped skills [I2]
Corey Olsonb143edb63de6
diff --git a/docs/api.md b/docs/api.mdindex daa7eff2..52cd0654 100644--- a/docs/api.md+++ b/docs/api.md@@ -47,6 +47,7 @@ The board-state API's item projection includes `check` and, when recorded, `chec| `stats` | `version:number`, `stats:object` || `status` | `version:number`, `me:object`, `mine:array`, `stats:object`, `reviewQueue:object`, `unread:number` || `doctor` | `version:number`, `problems:array` |+| `skills` | `version:number`, `updated:array`, `current:array`, `customized:array` || `inbox` | `version:number`, `shouts:array` || `decisions` | `version:number`, `decisions:array` || `ledger` | `version:number`, `items:array`, `stats:object` |diff --git a/src/cli.js b/src/cli.jsindex 4d9de0fb..260c0f8b 100644--- a/src/cli.js+++ b/src/cli.js@@ -32,7 +32,7 @@ import { productLine, productProblems, productSummaries } from './products.js';import { isLane, laneNames, laneOf, outOfLane } from './lanes.js';import { Refused } from './refused.js';import { commitCitations, committedIds } from './history.js';-import { promptFor } from './skills.js';+import { promptFor, skillProblems, updateSkills } from './skills.js';import {frozenCriterion,idProblems,@@ -171,6 +171,7 @@ Workrename or update a milestone notepullboard milestone remove <name> remove a milestone without changing its itemspullboard doctor check board integrity without changing it+ pullboard skills --update refresh unchanged Claude Code skills from shipped versionspullboard show <id> [--history] an item, the criterion frozen at claim, its verdicts: the latest in full,earlier ones as one line; --history prints every note in fullpullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha]@@ -240,7 +241,7 @@ Reject reasons: TEST_FAILURE, BEHAVIOR_MISMATCH, INSUFFICIENT_EVIDENCE, STALE_HEconst HELP_NAMES = ['tour', 'init', 'worktree', 'join', 'takeover', 'whoami', 'lanes', 'status', 'resources', 'settings', 'view', 'view export',- 'serve', 'relay', 'resume', 'hooks', 'add', 'edit', 'escalate', 'run', 'list', 'doctor', 'show', 'next',+ 'serve', 'relay', 'resume', 'hooks', 'add', 'edit', 'escalate', 'run', 'list', 'doctor', 'skills', 'show', 'next','check', 'claim', 'release', 'submit', 'done', 'verify', 'fact', 'shout', 'answer', 'pass', 'decisions', 'inbox', 'export', 'import','sweep', 'merged', 'withdraw', 'refreeze', 'hold', 'stats', 'ledger', 'log', 'spec', 'spec check', 'spec view','spec show', 'spec unmet', 'spec signoff', 'spec signers', 'spec signers add', 'forget', 'prompt', 'gate', 'hook',@@ -480,6 +481,7 @@ const OPTIONS = {run: { type: 'string' },max: { type: 'string' },'dry-run': { type: 'boolean' },+ update: { type: 'boolean' },before: { type: 'string' },add: { type: 'string' },remove: { type: 'string' },@@ -748,7 +750,7 @@ async function bindCheckoutSession(io, positionals, values) {if (command === 'takeover' && (positionals.length !== 1 || Object.keys(values).some((key) => key !== 'json'))) {throw new Refused('USAGE', 'pullboard takeover takes no arguments; run pullboard takeover [--json]');}- const writes = ['init', 'join', 'worktree', 'hooks', 'hook', 'add', 'edit', 'fact', 'escalate', 'run', 'sweep',+ const writes = ['init', 'join', 'worktree', 'hooks', 'hook', 'skills', 'add', 'edit', 'fact', 'escalate', 'run', 'sweep','next', 'claim', 'hold', 'release', 'submit', 'done', 'verify', 'merged', 'withdraw', 'refreeze', 'shout', 'answer', 'pass', 'import', 'milestone', 'takeover', 'forget'];if (!writes.includes(command) && !(command === 'settings' && first) && !(command === 'spec' && first === 'apply') && !(command === 'relay' && ['on', 'off'].includes(first))) return;if (command === 'answer' && values.as === 'person') return;@@ -1450,6 +1452,19 @@ function refuseUncommittedSetup(mainRoot, config) {*/function readCommands(io, { first, second, rest, values }) {return {+ skills: () => {+ if (first || second || rest.length || !values.update) throw new Refused('USAGE', 'pullboard skills --update');+ const ctx = context(io);+ const result = updateSkills(ctx.info.root);+ io.result?.(result);+ if (result.updated.length) io.say(`updated Claude Code skills: ${result.updated.map((file) => file.split('/')[2]).join(', ')}`);+ else io.say('Claude Code skills are current or customized; no files were replaced');+ for (const item of result.customized) {+ const change = item.missing.length ? `; missing changes: ${item.missing.join('; ')}` : '';+ io.say(`kept customized skill ${item.path}${change}`);+ }+ return 0;+ },export: () => {if (first) throw new Refused('USAGE', 'pullboard export takes no arguments');const ctx = context(io);@@ -1625,7 +1640,7 @@ function readCommands(io, { first, second, rest, values }) {return 1;}const ctx = context(io);- const problems = [...doctorProblems(ctx.file, ctx.info.root, tryGit, ctx.config), ...doctrineProblems(ctx.info.root, ctx.config), ...unlinkedRelayProjects()];+ const problems = [...doctorProblems(ctx.file, ctx.info.root, tryGit, ctx.config), ...skillProblems(ctx.info.root), ...doctrineProblems(ctx.info.root, ctx.config), ...unlinkedRelayProjects()];const checkpointProblem = pendingCheckpointProblem(ctx.info.root);if (checkpointProblem) problems.push(checkpointProblem);const oversizedSnapshot = checkpointProblem ? null : pendingSnapshotSize(ctx.info.root);diff --git a/src/json.js b/src/json.jsindex 3ded1a14..e8f7b3d1 100644--- a/src/json.js+++ b/src/json.js@@ -33,6 +33,7 @@ export const JSON_SHAPES = {stats: shape({ stats: 'object' }),status: shape({ me: 'object', mine: 'array', stats: 'object', reviewQueue: 'object', unread: 'number' }),doctor: shape({ problems: 'array' }),+ skills: shape({ updated: 'array', current: 'array', customized: 'array' }),inbox: shape({ shouts: 'array' }),decisions: shape({ decisions: 'array' }),ledger: shape({ items: 'array', stats: 'object' }),diff --git a/src/skills.js b/src/skills.jsindex f31d7b4a..d2878948 100644--- a/src/skills.js+++ b/src/skills.js@@ -4,12 +4,57 @@* three ways in: Claude Code skills that init installs, `pullboard prompt <role>` for any other* agent, and a repo's own override in `.pullboard/prompts/<role>.md`.*/+import { createHash } from 'node:crypto';import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { Refused } from './refused.js';+const SKILL_VERSIONS = [+ '0.5.0', '0.6.0', '0.6.1', '0.7.0', '0.8.0', '0.8.1', '0.8.2', '0.8.3', '0.8.4',+];++/** Every digest shipped for each Claude role, grouped only when releases shipped identical bytes. */+export const SHIPPED_SKILL_DIGESTS = Object.freeze({+ decompose: Object.freeze({+ '1fc167b251f9887e097dbef73e190bc13ad164129c1adcf6e8a226620428c3f8': Object.freeze(SKILL_VERSIONS.slice(0, 5)),+ '5fe4e52c4759579ff0a05fcc5f973b459068fdbf9a6e3dc19d141ce7efe4c90b': Object.freeze(SKILL_VERSIONS.slice(5)),+ }),+ plan: Object.freeze({+ '3f4c4ad64e2b2993b081f1a87a32ff0c649dd72954d79aadaf8ef94ce655a212': Object.freeze(SKILL_VERSIONS.slice(0, 5)),+ 'b433637ac6e85dd3b5b30c3a82404a6ba3de28d3525d63dd184e086a9af64214': Object.freeze(SKILL_VERSIONS.slice(5)),+ }),+ signoff: Object.freeze({+ '892d4a635dc59ec175152da7ee9e9d69bb42a54592ffdb561c4c10c435ca0e13': Object.freeze(SKILL_VERSIONS),+ }),+ review: Object.freeze({+ '7171d937b30dc711386ff07222656530164e071c4704804f8a95434d9f86407d': Object.freeze(SKILL_VERSIONS.slice(0, 5)),+ '0d141e40eddaa4dbb9124e7abd0ae5fbb154d0ea256505ab79e094c62ae91667': Object.freeze(SKILL_VERSIONS.slice(5)),+ }),+ verify: Object.freeze({+ '99278a7596f50c25b9f1e4764faa58ea48fd4450af95a30992f7421dafac3351': Object.freeze(SKILL_VERSIONS.slice(0, 5)),+ '4bd6901d72935cb2d04f34e6e3bfce64bbbec4043eba4dfdd43b8ab03cf52f24': Object.freeze(SKILL_VERSIONS.slice(5)),+ }),+ run: Object.freeze({+ '5ba87afa7e77fb09e69aa0e27838c933b51557f0c5241a7ca7e5bf2cd6faa5c1': Object.freeze(SKILL_VERSIONS),+ }),+});++const LEGACY_SKILL_TEXT = Object.freeze({+ decompose: 'SPEC.md and PRACTICE.md if they exist.',+ plan: 'PRACTICE.md and `pullboard lanes`.',+ review: 'SPEC.md, PRACTICE.md and the README.',+ verify: 'approved rows of PRACTICE.md that the change touches.',+});+const CURRENT_SKILL_TEXT = Object.freeze({+ decompose: 'SPEC.md and DOCTRINE.md (or PRACTICE.md when it is the only legacy file) if they exist.',+ plan: 'DOCTRINE.md (or PRACTICE.md when it is the only legacy file) and `pullboard lanes`.',+ review: 'SPEC.md, DOCTRINE.md (or PRACTICE.md when it is the only legacy file) and the README.',+ verify: 'approved rows of DOCTRINE.md (or PRACTICE.md when it is the only legacy file) that the change touches.',+});+const SKILLS_DIR = fileURLToPath(new URL('../skills/', import.meta.url));+const PACKAGE_VERSION = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;/*** Each role and the skill that carries it.@@ -37,6 +82,81 @@ function shippedSkill(role) {return readFileSync(join(SKILLS_DIR, name, 'SKILL.md'), 'utf8');}+/** Hash skill bytes so an update can distinguish a released file from a local edit. */+function skillDigest(text) {+ return createHash('sha256').update(text).digest('hex');+}++/** Find the newest release that shipped these exact bytes for a role. */+function shippedVersion(role, digest) {+ return SHIPPED_SKILL_DIGESTS[role]?.[digest]?.at(-1) ?? null;+}++/** Describe known guidance that differs between an old shipped line and this package. */+function missingSkillChanges(role, text) {+ const oldLine = LEGACY_SKILL_TEXT[role];+ const currentLine = CURRENT_SKILL_TEXT[role];+ return oldLine && text.includes(oldLine)+ ? [`replace “${oldLine}” with “${currentLine}”`]+ : [];+}++/** Find outdated shipped or edited-old skill files without treating unknown edits as history. */+export function skillProblems(root) {+ const problems = [];+ for (const [role, name] of Object.entries(ROLES)) {+ const relativePath = `.claude/skills/${name}/SKILL.md`;+ const file = join(root, relativePath);+ if (!existsSync(file)) continue;+ const text = readFileSync(file, 'utf8');+ const digest = skillDigest(text);+ const currentDigest = skillDigest(shippedSkill(role));+ if (digest === currentDigest) continue;+ const version = shippedVersion(role, digest);+ const changes = missingSkillChanges(role, text);+ if (version && version !== PACKAGE_VERSION) {+ problems.push({+ code: 'SKILL_OUTDATED',+ message: `${relativePath} matches Claude skill shipped in Pullboard ${version}; missing changes: ${changes.join('; ') || 'the current shipped skill content'}`,+ next: 'run pullboard skills --update',+ });+ } else if (changes.length) {+ problems.push({+ code: 'SKILL_EDITED_OUTDATED',+ message: `${relativePath} is closest to the Pullboard ${SKILL_VERSIONS[4]} skill, edited by you; missing changes: ${changes.join('; ')}`,+ next: 'review the current skill and merge its missing changes by hand; pullboard skills --update will preserve this edit',+ });+ }+ }+ return problems;+}++/** Update only exact previously shipped files; unknown local edits are preserved. */+export function updateSkills(root) {+ const updated = [];+ const current = [];+ const customized = [];+ for (const [role, name] of Object.entries(ROLES)) {+ const relativePath = `.claude/skills/${name}/SKILL.md`;+ const file = join(root, relativePath);+ if (!existsSync(file)) continue;+ const text = readFileSync(file, 'utf8');+ const digest = skillDigest(text);+ const currentText = shippedSkill(role);+ if (digest === skillDigest(currentText)) {+ current.push(relativePath);+ continue;+ }+ if (shippedVersion(role, digest)) {+ writeFileSync(file, currentText);+ updated.push(relativePath);+ continue;+ }+ customized.push({ path: relativePath, missing: missingSkillChanges(role, text) });+ }+ return { updated, current, customized };+}+/*** A skill's text without its front matter, for agents that read plain instructions.*diff --git a/test/api.test.js b/test/api.test.jsindex 46df3d18..62548258 100644--- a/test/api.test.js+++ b/test/api.test.js@@ -244,6 +244,7 @@ test('[A1] command results match the catalog across roots and subcommands', () =json(box, repo, 'status');json(box, repo, 'stats');json(box, repo, 'doctor');+ json(box, repo, 'skills', ['--update']);const plainStatus = box.run(repo, 'status');assert.equal(plainStatus.status, 0, plainStatus.stderr);assert.equal(plainStatus.stderr, '');diff --git a/test/skills.test.js b/test/skills.test.jsnew file mode 100644index 00000000..ae721d34--- /dev/null+++ b/test/skills.test.js@@ -0,0 +1,156 @@+/** Shipped Claude skills can be diagnosed and refreshed without overwriting local edits [I2]. */+import assert from 'node:assert/strict';+import { createHash } from 'node:crypto';+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { delimiter, join, resolve } from 'node:path';+import { after, test } from 'node:test';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';+import { ROLES, SHIPPED_SKILL_DIGESTS } from '../src/skills.js';++const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');+const RELEASES = ['0.5.0', '0.6.0', '0.6.1', '0.7.0', '0.8.0', '0.8.1', '0.8.2', '0.8.3', '0.8.4'];+const LEGACY_SNIPPETS = {+ decompose: ['SPEC.md and DOCTRINE.md (or PRACTICE.md when it is the only legacy file) if they exist.', 'SPEC.md and PRACTICE.md if they exist.'],+ plan: ['DOCTRINE.md (or PRACTICE.md when it is the only legacy file) and `pullboard lanes`.', 'PRACTICE.md and `pullboard lanes`.'],+ review: ['SPEC.md, DOCTRINE.md (or PRACTICE.md when it is the only legacy file) and the README.', 'SPEC.md, PRACTICE.md and the README.'],+ verify: ['approved rows of DOCTRINE.md (or PRACTICE.md when it is the only legacy file) that the change touches.', 'approved rows of PRACTICE.md that the change touches.'],+};+const TEMP_DIRS = [];++after(() => {+ for (const dir of TEMP_DIRS) rmSync(dir, { recursive: true, force: true });+});++/** Build an isolated real Git repo and board for a CLI behavior. */+function project() {+ const dir = mkdtempSync(join(tmpdir(), 'pullboard-skills-'));+ TEMP_DIRS.push(dir);+ const root = join(dir, 'repo');+ mkdirSync(root);+ const env = {+ ...process.env,+ PULLBOARD_HOME: join(dir, 'home'),+ GIT_CONFIG_GLOBAL: '/dev/null',+ GIT_CONFIG_NOSYSTEM: '1',+ GIT_AUTHOR_NAME: 'Skills Test',+ GIT_AUTHOR_EMAIL: '[email protected]',+ GIT_COMMITTER_NAME: 'Skills Test',+ GIT_COMMITTER_EMAIL: '[email protected]',+ };+ /** Run Git with this fixture's private identity and home. */+ const git = (...args) => runFixtureGit(args, { cwd: root, env, encoding: 'utf8' });+ /** Run the actual Pullboard CLI in the initialized fixture repository. */+ const run = (...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8' });+ git('init', '-q', '-b', 'main');+ writeFileSync(join(root, 'pullboard.json'), JSON.stringify({ gate: 'true', lanes: {} }, null, 2));+ writeFileSync(join(root, 'SPEC.md'), '# Skills fixture\n');+ writeFileSync(join(root, 'DOCTRINE.md'), '# Doctrine fixture\n');+ git('add', '-A');+ git('commit', '-q', '-m', 'chore: initialize skills fixture');+ assert.equal(run('status').status, 0, 'the fixture opens a real local board');+ return { dir, root, env, git, run };+}++/** Return the exact legacy file bytes for the four skills changed in 0.8.1. */+function legacySkill(role) {+ const name = ROLES[role];+ const file = resolve(import.meta.dirname, `../skills/${name}/SKILL.md`);+ const current = readFileSync(file, 'utf8');+ const [currentSnippet, oldSnippet] = LEGACY_SNIPPETS[role];+ assert.ok(current.includes(currentSnippet), `${role} ships the doctrine migration phrase`);+ return current.replace(currentSnippet, oldSnippet);+}++/** Hash the file bytes using the release catalog's SHA-256 contract. */+function digest(text) {+ return createHash('sha256').update(text).digest('hex');+}++/** Write role files after normal setup so the fixture models an earlier installation. */+function installText(box, role, text) {+ const name = ROLES[role];+ const file = join(box.root, '.claude', 'skills', name, 'SKILL.md');+ mkdirSync(join(box.root, '.claude', 'skills', name), { recursive: true });+ writeFileSync(file, text);+ return file;+}++/** Parse one JSON command result and assert the CLI succeeded. */+function json(box, ...args) {+ const result = box.run(...args, '--json');+ assert.equal(result.status, 0, result.stderr || result.stdout);+ assert.equal(result.stderr, '');+ return JSON.parse(result.stdout);+}++test('doctor names a skill older than this Pullboard [I2]', () => {+ const box = project();+ const expectedOld = {+ decompose: '1fc167b251f9887e097dbef73e190bc13ad164129c1adcf6e8a226620428c3f8',+ plan: '3f4c4ad64e2b2993b081f1a87a32ff0c649dd72954d79aadaf8ef94ce655a212',+ review: '7171d937b30dc711386ff07222656530164e071c4704804f8a95434d9f86407d',+ verify: '99278a7596f50c25b9f1e4764faa58ea48fd4450af95a30992f7421dafac3351',+ };+ for (const [role, shippedDigest] of Object.entries(expectedOld)) {+ const oldText = legacySkill(role);+ assert.equal(digest(oldText), shippedDigest, `${role} fixture matches exact shipped bytes`);+ assert.ok(SHIPPED_SKILL_DIGESTS[role][shippedDigest].includes('0.8.0'));+ installText(box, role, oldText);+ }+ for (const digests of Object.values(SHIPPED_SKILL_DIGESTS)) {+ assert.deepEqual([...new Set(Object.values(digests).flat())].sort(), RELEASES, 'catalog records each tagged shipped version');+ }+ const doctor = box.run('doctor', '--json');+ assert.equal(doctor.status, 1, doctor.stdout);+ assert.equal(doctor.stderr, '');+ const result = JSON.parse(doctor.stdout);+ const skillFindings = result.problems.filter((problem) => problem.code.startsWith('SKILL_'));+ assert.equal(skillFindings.length, 4);+ for (const [index, role] of ['decompose', 'plan', 'review', 'verify'].entries()) {+ const problem = skillFindings[index];+ assert.equal(problem.code, 'SKILL_OUTDATED');+ assert.ok(problem.message.includes(ROLES[role]));+ assert.match(problem.message, /Pullboard 0\.8\.0/u);+ assert.match(problem.message, /missing changes: replace/u);+ assert.equal(problem.next, 'run pullboard skills --update');+ }+});++test('skills --update refreshes an unmodified old skill [I2]', () => {+ const box = project();+ const oldRoles = ['decompose', 'plan', 'review', 'verify'];+ const files = new Map(oldRoles.map((role) => [role, installText(box, role, legacySkill(role))]));+ const result = json(box, 'skills', '--update');+ assert.deepEqual(result.updated, oldRoles.map((role) => `.claude/skills/${ROLES[role]}/SKILL.md`));+ assert.deepEqual(result.customized, []);+ for (const [role, file] of files) {+ const current = readFileSync(resolve(import.meta.dirname, `../skills/${ROLES[role]}/SKILL.md`), 'utf8');+ assert.equal(readFileSync(file, 'utf8'), current, `${role} now matches current shipped bytes`);+ }+});++test('skills --update never replaces an edited skill [I2]', () => {+ const box = project();+ const edited = `${legacySkill('decompose')}\nLocal instruction: keep this repo's extra review step.\n`;+ const file = installText(box, 'decompose', edited);+ const before = readFileSync(file);+ const doctor = box.run('doctor', '--json');+ assert.equal(doctor.status, 1, doctor.stdout);+ assert.equal(doctor.stderr, '');+ const skillFinding = JSON.parse(doctor.stdout).problems.find((problem) => problem.code.startsWith('SKILL_'));+ assert.equal(skillFinding.code, 'SKILL_EDITED_OUTDATED');+ assert.match(skillFinding.message, /closest to the Pullboard 0\.8\.0 skill, edited by you/u);+ assert.match(skillFinding.message, /replace .*PRACTICE\.md.*DOCTRINE\.md/u);+ const update = json(box, 'skills', '--update');+ assert.deepEqual(readFileSync(file), before, 'an edited skill is never replaced');+ assert.deepEqual(update.customized, [{+ path: '.claude/skills/pullboard-decompose/SKILL.md',+ missing: [expectMissingChange()],+ }]);+});++/** Keep the CLI's displayed action stable without copying a second formatter into the assertion. */+function expectMissingChange() {+ return 'replace “SPEC.md and PRACTICE.md if they exist.” with “SPEC.md and DOCTRINE.md (or PRACTICE.md when it is the only legacy file) if they exist.”';+}