Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Releases 0.4.0 and older are in [CHANGELOG-ARCHIVE.md](CHANGELOG-ARCHIVE.md).

## [Unreleased]

## [0.21.7] — 2026-11-25

### Fixed

- **A pharn-oss archive that `pharn` refuses now says which one, whose fault it is, and what to try.** When the downloaded archive failed a check (an entry the extractor does not admit, such as a symbolic link, or an install manifest whose files do not match their sha256s), `init`, `add`, `update` and `status` printed only the check, for example `tar entry has an unsupported type '2': …`. The message now names what was fetched (the release tag and its commit, or `main` and its commit), says the problem is in that pharn-oss archive and that nothing in your project was changed, keeps the original check as `Reason:`, says that no option skips the check (`update --force` and `--yes` included), and lists the next steps the CLI supports: `--ref main` on a release, `--ref latest` on `main`, upgrading `pharn`, and reporting it at <https://github.com/pharn-dev/pharn-oss/issues>. The spinner of `init`, `add` and `status` now stops with `pharn-oss archive refused` instead of a failure to fetch or reach. `PHARN_DEBUG=1` prints the original error. What is refused is unchanged. See [The pharn-oss archive was refused](docs/troubleshooting.md#the-pharn-oss-archive-was-refused).

## [0.21.6] — 2026-11-25

### Fixed
Expand Down Expand Up @@ -529,7 +535,8 @@ _Never released: 0.9.0 followed on the same day, so `0.8.0` was neither tagged n
matcher that silently stopped matching, or a comparator read in the wrong direction, would otherwise
leave every assertion green.

[Unreleased]: https://github.com/pharn-dev/pharn-cli/compare/v0.21.6...HEAD
[Unreleased]: https://github.com/pharn-dev/pharn-cli/compare/v0.21.7...HEAD
[0.21.7]: https://github.com/pharn-dev/pharn-cli/compare/v0.21.6...v0.21.7
[0.21.6]: https://github.com/pharn-dev/pharn-cli/compare/v0.21.5...v0.21.6
[0.21.5]: https://github.com/pharn-dev/pharn-cli/compare/v0.21.4...v0.21.5
[0.21.4]: https://github.com/pharn-dev/pharn-cli/compare/v0.21.3...v0.21.4
Expand Down
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ PHARN_DEBUG=1 npm run dev -- init # full error output for fetch/install failur
- `src/index.ts`: dispatch only. `lib/cli-args.ts`: the command/option tables, help text and the argv parse (`init` default).
- `commands/`: one verb each (`init`, `add`, `remove`/`rm`, `update`, `list`, `status`, `uninstall`).
- `steps/`: init stages (`node-prereq`, `prereqs`, `archetype-summary`, `overwrite-check`, `install-archetype`), `add-picker`.
- Fetch boundary: `fetch-capped` (the one bounded GET), `release` (which commit), `repo` + `tar-extract`, `skills-version`,
- Fetch boundary: `fetch-capped` (the one bounded GET), `release` (which commit), `repo` + `tar-extract`, `archive-refusal`
(the refused-archive message), `skills-version`,
`min-cli-gate`, `upstream-manifest` (the upstream install manifest's one parser), `capability-index` (manifest →
typed index), `upstream-models`.
- Selection: `detect-archetype` + `archetype` (detection), `resolve-capabilities`, `merge-capabilities`,
Expand Down
3 changes: 2 additions & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pharn-cli/
index.ts CLI entry, command routing
commands/ init, add, remove, update, list, status, uninstall
steps/ init stages (prereqs, node-prereq, overwrite-check, archetype-summary, install-archetype), add-picker
lib/ install-capabilities, install-manifest, capability-index, resolve-capabilities, detect-archetype, node-floor, release, archetype, layout, repo, tar-extract, diff, skills-version, min-cli-gate, semver, older-cli, pharn-config, model-config(-format), models-update, upstream-models, install-records, update-decision, update-render, apply-update, merge-capabilities, dest-drift, backup, atomic-write, project-lock, proxy-env(-format), symlink-guard, capability-address, capability-groups, capability-picker, unknown-capabilities, cli-error, report-error, hash, validate, constants, banner, format
lib/ install-capabilities, install-manifest, capability-index, resolve-capabilities, detect-archetype, node-floor, release, archetype, layout, repo, tar-extract, archive-refusal, diff, skills-version, min-cli-gate, semver, older-cli, pharn-config, model-config(-format), models-update, upstream-models, install-records, update-decision, update-render, apply-update, merge-capabilities, dest-drift, backup, atomic-write, project-lock, proxy-env(-format), symlink-guard, capability-address, capability-groups, capability-picker, unknown-capabilities, cli-error, report-error, hash, validate, constants, banner, format
types.ts Archetype / CapabilityEntry / Selection / PharnConfig
tests/ vitest specs
docs/ user + maintainer documentation
Expand Down Expand Up @@ -230,6 +230,7 @@ Two rules that are easy to get wrong:
| `models-update.test.ts` / `upstream-models.test.ts` | `update`'s rows for the `models` block; reading pharn-oss's block |
| `confirm.test.ts` / `repo.test.ts` / `banner.test.ts` / `format.test.ts` | helpers; the codeload fetch boundary; banner; format |
| `tar-extract.test.ts` | The ustar reader: selection (unlisted entries skipped), strip-1, prefix reassembly, every rejection at a listed path |
| `archive-refusal.test.ts` | The refused-archive message: which errors are noted, the ref named, and only `--ref` values the CLI accepts |
| `index.test.ts` | argv dispatch: the per-command option allowlist, the arity gate, and their exit codes |
| `project-lock.test.ts` + `-break` / `commands/lock.test.ts` | The single-writer lock: acquire/release, stale-break single-winner, and which commands take it |
| `min-cli-gate.test.ts` / `semver.test.ts` | The `MIN_CLI` forward-compat gate and its version comparison |
Expand Down
62 changes: 49 additions & 13 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@

## Common problems

| Symptom | See |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| `update` listed files under `SKIPPED` or `held` | [`pharn update` skipped my files](#pharn-update-skipped-my-files) |
| `Another pharn process is writing to this project` | [Another pharn process is running](#another-pharn-process-is-running) |
| `No pharn.config.json found. Run pharn init first.` | [`add` / `update` say to run init first](#add--update-say-to-run-init-first) |
| `Could not resolve the latest verified … release` | [No verified release could be resolved](#no-verified-release-could-be-resolved) |
| `Failed to fetch`, a timeout, or a proxy notice | [Capabilities could not be fetched](#capabilities-could-not-be-fetched) |
| `… outside the paths pharn installs; refusing this release` | [A pharn-oss release was refused](#a-pharn-oss-release-was-refused) |
| The wrong archetypes were detected | [Detection picked the wrong archetype](#detection-picked-the-wrong-archetype) |
| `Unknown option` / ``Unsupported option for `<command>` `` | [Unsupported option for this command](#unsupported-option-for-this-command) |
| Your Prettier check fails on PHARN's files | [My Prettier check fails on PHARN's files](#my-prettier-check-fails-on-pharns-files) |
| Symptom | See |
| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| `update` listed files under `SKIPPED` or `held` | [`pharn update` skipped my files](#pharn-update-skipped-my-files) |
| `Another pharn process is writing to this project` | [Another pharn process is running](#another-pharn-process-is-running) |
| `No pharn.config.json found. Run pharn init first.` | [`add` / `update` say to run init first](#add--update-say-to-run-init-first) |
| `Could not resolve the latest verified … release` | [No verified release could be resolved](#no-verified-release-could-be-resolved) |
| `Failed to fetch`, a timeout, or a proxy notice | [Capabilities could not be fetched](#capabilities-could-not-be-fetched) |
| `pharn-oss release … was refused` / `pharn-oss main … was refused` | [The pharn-oss archive was refused](#the-pharn-oss-archive-was-refused) |
| `… outside the paths pharn installs; refusing this release` | [A pharn-oss release was refused](#a-pharn-oss-release-was-refused) |
| The wrong archetypes were detected | [Detection picked the wrong archetype](#detection-picked-the-wrong-archetype) |
| `Unknown option` / ``Unsupported option for `<command>` `` | [Unsupported option for this command](#unsupported-option-for-this-command) |
| Your Prettier check fails on PHARN's files | [My Prettier check fails on PHARN's files](#my-prettier-check-fails-on-pharns-files) |

## Node version

Expand Down Expand Up @@ -220,10 +221,44 @@ installs only the newest pharn-oss **GitHub release**, never the tip of `main`.
A release whose tree carries another `SKILLS_VERSION` than its tag is refused too
(`Release vX.Y.Z (…) ships SKILLS_VERSION …`). `pharn update --ref main` moves an install to `main`.

## The pharn-oss archive was refused

```text
⚠ pharn-oss release v7.25.5 (commit 1755d6b8…) was refused: its published archive failed pharn's checks.
The problem is in that pharn-oss archive, not in your project; nothing in your project was changed.
Reason: tar entry has an unsupported type '2' at a path pharn installs (only a regular file is accepted there):
pharn-oss-1755d6b/.claude/commands/pharn-plan.md
No option skips this check: forcing an update or answering yes does not help. Next steps:
- install the tip of main instead: `pharn init --ref main` (`pharn update --ref main` for an existing install)
- upgrade pharn (`npm install -g @pharn-dev/pharn@latest`): a newer pharn may accept this archive
- or re-run once pharn-oss publishes a fixed release, and report this at https://github.com/pharn-dev/pharn-oss/issues
Re-run with PHARN_DEBUG=1 for full error output.
```

`init`, `add`, `update` and `status` exit 1 when the pharn-oss archive they downloaded fails a check: the
extractor unpacks only the files `pharn-install.json` lists (plus the few it reads itself), and one of those
that is not a regular file (a symbolic link, a hard link, a device) is refused; the tree must carry a valid `pharn-install.json` whose every file
matches its sha256 (a release must also ship the `SKILLS_VERSION` its tag names). The first line names what was
fetched: the release tag and its commit, or `main` and its commit (`commit not resolved` when GitHub did not
say). `Reason:` is the check that failed, as `pharn` found it. The download happens before any write, so
nothing in your project is changed and an existing install keeps working.

No option gets past the check, and re-running the same release refuses the same bytes. What `pharn` offers:

- on a release (the default, `--ref latest`): try the tip of `main` with `pharn init --ref main` (`pharn update
--ref main` for an existing install);
- on `main`: go back to verified releases with `--ref latest`, or re-run once `main` is fixed;
- either way: upgrade `pharn` (`npm install -g @pharn-dev/pharn@latest`), which helps only when a newer
`pharn` accepts what this one refused (not for a manifest path outside what `pharn` installs, [below](#a-pharn-oss-release-was-refused)),
and report the archive at the [pharn-oss issues](https://github.com/pharn-dev/pharn-oss/issues).

`PHARN_DEBUG=1` prints the original error (for example `TarExtractError: …`) instead of the hint.

## A pharn-oss release was refused

```text
⚠ pharn-oss's pharn-install.json files[N] would write pharn/floor/.eslintrc.json, outside the paths pharn
⚠ pharn-oss release vX.Y.Z (commit …) was refused: its published archive failed pharn's checks. …
Reason: pharn-oss's pharn-install.json files[N] would write pharn/floor/.eslintrc.json, outside the paths pharn
installs; refusing this release. This is a problem in the pharn-oss release, not in your project: …
```

Expand Down Expand Up @@ -264,7 +299,8 @@ difference or a missing or malformed `pharnVersion` never warns ([support policy

## Install failed

"Failed to install capabilities", exit 1: a fetch failure, an archive `pharn` refused to extract, or a
"Failed to install capabilities", exit 1: a fetch failure, an archive `pharn` refused to extract ([The
pharn-oss archive was refused](#the-pharn-oss-archive-was-refused)), or a
selected capability missing in the fetched repo (`Capability "<name>" (<role>) is missing at
<subtree>/<name> in the fetched repo.`; one whose `<name>.md` is absent is refused earlier, at the index
parse). What the extractor rejects is in `THREAT-MODEL.md` §2. `PHARN_DEBUG=1 npx @pharn-dev/pharn init` shows the full error.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pharn-dev/pharn",
"version": "0.21.6",
"version": "0.21.7",
"description": "Install and update PHARN in any git project. PHARN gets features shipped right with Claude Code, with spec, plan and checks kept in Git.",
"keywords": [
"claude-code",
Expand Down
18 changes: 15 additions & 3 deletions src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import {
writeRecords,
} from '../lib/install-records.js';
import { fetchRepo } from '../lib/repo.js';
import {
ARCHIVE_REFUSED_SPINNER,
archiveRefusalMessage,
} from '../lib/archive-refusal.js';
import {
channelOf,
resolveSource,
Expand Down Expand Up @@ -175,7 +179,11 @@ async function runArchetypeAdd(
repo = await fetchRepo(await resolveSource(channelOf(config)));
s.stop(`Capabilities fetched from ${sourceLabel(repo.source)}`);
} catch (err) {
s.stop('Failed to fetch capabilities');
s.stop(
archiveRefusalMessage(err) === undefined
? 'Failed to fetch capabilities'
: ARCHIVE_REFUSED_SPINNER,
);
// Unwinds through the lock's release; runAdd's catch labels it.
throw err;
}
Expand Down Expand Up @@ -256,7 +264,11 @@ async function runAddPicker(
repo = await fetchRepo(await resolveSource(channelOf(config)));
s.stop(`Capabilities fetched from ${sourceLabel(repo.source)}`);
} catch (err) {
s.stop('Failed to fetch capabilities');
s.stop(
archiveRefusalMessage(err) === undefined
? 'Failed to fetch capabilities'
: ARCHIVE_REFUSED_SPINNER,
);
throw err;
}
let outcome: PickerAddOutcome;
Expand Down Expand Up @@ -315,7 +327,7 @@ function plural(n: number): string {
// anything else is a failure, which earns the hint.
function addError(err: unknown): CliError {
if (err instanceof ProjectLockedError) return CliError.refusal(err.message);
return CliError.failure(err);
return CliError.failure(err, { message: archiveRefusalMessage(err) });
}

// Resolve the arg against the fetched index and, if it uniquely names a
Expand Down
15 changes: 12 additions & 3 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import { minCliGate } from '../lib/min-cli-gate.js';
import { PHARN_VERSION } from '../version.js';
import { warnIfOlderCli } from '../lib/older-cli.js';
import { fetchRepo } from '../lib/repo.js';
import {
ARCHIVE_REFUSED_SPINNER,
archiveRefusalMessage,
} from '../lib/archive-refusal.js';
import { UpstreamManifestError } from '../lib/upstream-manifest.js';
import {
DEFAULT_INIT_REF,
Expand Down Expand Up @@ -213,14 +217,19 @@ async function runInitArchetype(mode: RunMode): Promise<void> {
// `--ref main`.
repo = await fetchRepo(await resolveSource(channel));
} catch (err) {
s.stop('Failed to fetch PHARN');
s.stop(
archiveRefusalMessage(err) === undefined
? 'Failed to fetch PHARN'
: ARCHIVE_REFUSED_SPINNER,
);
throw CliError.failure(err, {
json,
message:
err instanceof ReleaseResolveError ||
archiveRefusalMessage(err) ??
(err instanceof ReleaseResolveError ||
err instanceof UpstreamManifestError
? err.message
: `Could not reach ${REPO_URL}: ${errorMessage(err)}`,
: `Could not reach ${REPO_URL}: ${errorMessage(err)}`),
});
}

Expand Down
15 changes: 13 additions & 2 deletions src/commands/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { intro, log, note, outro, spinner } from '@clack/prompts';
import pc from '../lib/color.js';
import { REPO } from '../lib/constants.js';
import { fetchRepo, type FetchedRepo } from '../lib/repo.js';
import {
ARCHIVE_REFUSED_SPINNER,
archiveRefusalMessage,
} from '../lib/archive-refusal.js';
import {
channelOf,
resolveLatestReleaseVersion,
Expand Down Expand Up @@ -132,8 +136,15 @@ export async function runStatus(
repo = await fetchRepo(await resolveSource(channel));
s?.stop(`Compared against ${sourceLabel(repo.source)}`);
} catch (err) {
s?.stop(`Failed to reach ${REPO}`);
throw CliError.failure(err, { json });
s?.stop(
archiveRefusalMessage(err) === undefined
? `Failed to reach ${REPO}`
: ARCHIVE_REFUSED_SPINNER,
);
throw CliError.failure(err, {
json,
message: archiveRefusalMessage(err),
});
}
try {
input = cloneInput(repo, { node, config, channel, strict }, cwd);
Expand Down
8 changes: 6 additions & 2 deletions src/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
import { buildRecords, writeRecords } from '../lib/install-records.js';
import { terminalSafe } from '../lib/terminal-safe.js';
import { fetchRepo, type FetchedRepo } from '../lib/repo.js';
import { archiveRefusalMessage } from '../lib/archive-refusal.js';
import {
channelOf,
resolveSource,
Expand Down Expand Up @@ -309,7 +310,7 @@ async function runArchetypeUpdate(
repo = await fetchRepo(source);
} catch (err) {
pre.stop('Update failed');
throw CliError.failure(err);
throw CliError.failure(err, { message: archiveRefusalMessage(err) });
}

let outcome: UpdateOutcome;
Expand Down Expand Up @@ -785,7 +786,10 @@ async function fetchAndPlan(
repo = await fetchRepo(source);
} catch (err) {
ui.spin.stop('Planning failed');
throw CliError.failure(err, { json: ui.json });
throw CliError.failure(err, {
json: ui.json,
message: archiveRefusalMessage(err),
});
}
try {
return planFromClone(repo, config, cwd, force, channel, ui);
Expand Down
Loading