@pharn-dev/pharn 0.11.0 → 0.13.0

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 +97 -56
  2. package/dist/index.js +63 -59
  3. package/package.json +2 -3
package/README.md CHANGED
@@ -1,17 +1,16 @@
1
1
  <div align="center">
2
2
 
3
- <picture>
4
- <source media="(prefers-color-scheme: dark)" srcset="assets/pharn-logo-dark-transparent.svg">
5
- <source media="(prefers-color-scheme: light)" srcset="assets/pharn-logo-light-transparent.svg">
6
- <img alt="Pharn" src="assets/pharn-logo-light-transparent.svg" width="420">
7
- </picture>
3
+ <p align="center">
4
+ <img src="./assets/pharn-logo.svg" alt="Pharn CLI" width="96">
5
+ </p>
8
6
 
9
- **Install PHARN into an existing project: a reviewable workflow for AI-written code.**
7
+ <h1 align="center">Pharn CLI</h1>
10
8
 
11
- PHARN is an open, audit-grade methodology for Claude Code. It keeps the intent,
12
- constraints, plans, checks, and review trail for AI-assisted changes in plain
13
- files inside your repo, so the reasoning behind a change survives beyond the
14
- chat window.
9
+ **Install and update PHARN in any git project.**
10
+
11
+ PHARN gets features shipped right with Claude Code. The spec, plan, and checks
12
+ stay in plain files in Git, so months later you can answer "what was done and
13
+ why?".
15
14
 
16
15
  [![npm](https://img.shields.io/npm/v/@pharn-dev/pharn)](https://www.npmjs.com/package/@pharn-dev/pharn)
17
16
  [![CI](https://github.com/pharn-dev/pharn-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/pharn-dev/pharn-cli/actions/workflows/ci.yml)
@@ -70,7 +69,7 @@ be committed beside the change.
70
69
  - **Preserve intent.** Specs, plans, constraints, and review notes live in the
71
70
  repository, not only in an agent transcript.
72
71
  - **Make work inspectable.** PHARN installs grillers and lenses: pipeline
73
- auditors and review perspectives that help interrogate a plan or diff before
72
+ checks and review perspectives that help interrogate a plan or diff before
74
73
  it ships.
75
74
  - **Keep updates safe.** `pharn update` uses per-file hashes to avoid
76
75
  overwriting local edits unless you explicitly choose `--force`.
@@ -131,13 +130,13 @@ upstream's
131
130
  `pharn init` is archetype-driven. There is no stack questionnaire and no module
132
131
  catalog.
133
132
 
134
- | Step | What happens |
135
- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
136
- | Detect | Reads `package.json` dependency names and performs a bounded, symlink-safe file-tree scan to classify the project as `ssr`, `backend`, `spa`, `lib`, or a combination. |
137
- | Fetch | Resolves the tip of `pharn-dev/pharn-oss` `main` to its commit, downloads that commit's GitHub codeload tarball, and extracts it into a temp directory. `--ref latest` installs the newest **verified release** instead (a tag pharn-oss creates only after its post-merge CI passed), checking its `SKILLS_VERSION` matches the tag. |
138
- | Resolve | Selects capabilities whose `applies` value is `universal` or intersects your detected archetypes. Skipped capabilities are named with the reason. |
139
- | Install | Copies the selected capabilities plus fixed PHARN product surfaces into your repo, mirroring the upstream layout. |
140
- | Record | Writes `pharn.config.json` and `pharn.records.json` so future updates can tell PHARN-owned files from local edits. |
133
+ | Step | What happens |
134
+ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
135
+ | Detect | Reads `package.json` dependency names and performs a bounded, symlink-safe file-tree scan to classify the project as `ssr`, `backend`, `spa`, `lib`, or a combination. |
136
+ | Fetch | Resolves the tip of `pharn-dev/pharn-oss` `main` to its commit, downloads that commit's GitHub codeload tarball, and extracts it into a temp directory. `--ref latest` installs the newest **verified release** instead (a tag pharn-oss creates only after its post-merge CI passed), checking its `SKILLS_VERSION` matches the tag. pharn-oss has not published a release yet, so until it does `--ref latest` exits 1 and the default `main` is the channel that works ([details](docs/troubleshooting.md#no-verified-release-could-be-resolved)). |
137
+ | Resolve | Selects capabilities whose `applies` value is `universal` or intersects your detected archetypes. Skipped capabilities are named with the reason. |
138
+ | Install | Copies the selected capabilities plus fixed PHARN product surfaces into your repo, mirroring the upstream layout. |
139
+ | Record | Writes `pharn.config.json` and `pharn.records.json` so future updates can tell PHARN-owned files from local edits. |
141
140
 
142
141
  The current upstream install layout places most runtime surfaces under `pharn/`
143
142
  and Claude Code integration under `.claude/`. Older flat-layout installs are
@@ -145,18 +144,18 @@ still understood through the recorded `layout` field.
145
144
 
146
145
  ## What gets installed
147
146
 
148
- | Artifact | Purpose |
149
- | --------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
150
- | `pharn/pharn-pipeline/grillers/<name>/`, `pharn/pharn-review/<name>/` | Pipeline auditors and review lenses selected for your project archetype(s). |
151
- | `.claude/commands/`, `.claude/hooks/` | The installed `/pharn-*` Claude Code slash commands and deterministic `.cjs` hooks. |
152
- | `pharn/pharn-contracts/`, `pharn/floor/` | Schemas shared across PHARN stages and floor checkers invoked by the workflow. |
153
- | `pharn/pharn-core/` | Agent-readable mechanism skills, including the seam resolver. |
154
- | `pharn/CONSTITUTION.md`, `pharn/ARCHITECTURE.md` | Trusted PHARN docs copied from upstream in the current layout. |
155
- | `THREAT-MODEL.md`, `LIMITS.md` | Trusted PHARN docs copied at the project root in the current layout. |
156
- | `pharn/LICENSE` (flat: `PHARN-LICENSE`) | PHARN's Apache-2.0 license copy. Your root `LICENSE` is never overwritten. |
157
- | `pharn/features/README.md` | The feature-loop boundary contract referenced by installed commands (pharn layout). |
158
- | `pharn.config.json` | Installed version, commit, layout, archetypes, capabilities, and defaults. |
159
- | `pharn.records.json` | Per-file hashes for drift-safe updates. Commit this with the config. |
147
+ | Artifact | Purpose |
148
+ | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
149
+ | `pharn/pharn-pipeline/grillers/<name>/`, `pharn/pharn-review/<name>/` | Pipeline grillers and review lenses selected for your project archetype(s). |
150
+ | `.claude/commands/`, `.claude/hooks/` | The installed `/pharn-*` Claude Code slash commands and deterministic `.cjs`/`.mjs` hooks. |
151
+ | `pharn/pharn-contracts/`, `pharn/floor/` | Schemas shared across PHARN stages and floor checkers invoked by the workflow. |
152
+ | `pharn/pharn-core/` | Agent-readable mechanism skills, including the seam resolver. |
153
+ | `pharn/CONSTITUTION.md`, `pharn/ARCHITECTURE.md` | Trusted PHARN docs copied from upstream in the current layout. |
154
+ | `THREAT-MODEL.md`, `LIMITS.md` | Trusted PHARN docs copied at the project root in the current layout. |
155
+ | `pharn/LICENSE` (flat: `PHARN-LICENSE`) | PHARN's Apache-2.0 license copy. Your root `LICENSE` is never overwritten. |
156
+ | `pharn/features/README.md` | The feature-loop boundary contract referenced by installed commands (pharn layout). |
157
+ | `pharn.config.json` | Installed version, commit, layout, archetypes, capabilities, and defaults. |
158
+ | `pharn.records.json` | Per-file hashes for drift-safe updates. Commit this with the config. |
160
159
 
161
160
  An existing `.claude/settings.json` is preserved. PHARN may create it when
162
161
  absent, but it never overwrites your Claude Code settings.
@@ -182,9 +181,10 @@ are keyed to the latter.
182
181
  Three things about the installed hooks are worth knowing on day one.
183
182
 
184
183
  **Hooks enforce only once they are registered in `.claude/settings.json`.** If
185
- your project already had that file, PHARN preserved it and printed a warning
186
- instead of overwriting it — so until you copy the hook wiring across, every
187
- guarantee that depends on a `PreToolUse` hook is inactive.
184
+ your project already had that file, PHARN preserved it instead of overwriting
185
+ it and printed a `HOOKS` note listing each hook it does not wire, as
186
+ paste-ready JSON — until you copy those entries across, every guarantee that
187
+ depends on a `PreToolUse` hook is inactive, and `pharn status --strict` fails.
188
188
 
189
189
  **Once wired, the default depends on your tree (pharn-oss 6.24.0+).** With no
190
190
  active scope, `enforce-writes-scope.cjs` applies that default.
@@ -217,7 +217,8 @@ also does nothing until registered — under `Stop`, with no matcher. The
217
217
  `settings.json` upstream ships has registered it since pharn-oss 6.12.0, but a
218
218
  file PHARN preserved, or one created by an earlier install, lacks the entry:
219
219
  copy it across by hand. `pharn update` never edits `.claude/settings.json`;
220
- `pharn status` and `pharn update` name the missing entry in a `HOOKS` note.
220
+ `pharn init`, `pharn status` and `pharn update` name the missing entry in a
221
+ `HOOKS` note.
221
222
 
222
223
  The full set of bounds lives in upstream's
223
224
  [`LIMITS.md`](https://github.com/pharn-dev/pharn-oss/blob/main/LIMITS.md) and
@@ -263,33 +264,43 @@ Two commands sit outside the pipeline:
263
264
 
264
265
  | Command | Description |
265
266
  | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
266
- | `pharn init` | Detect archetypes and install matching capabilities. This is also the default when no command is given. |
267
+ | `pharn init` | Detect archetypes and install matching capabilities. This is also the default when no command is given. `--dry-run` prints what it would install and writes nothing (add `--json` for one machine-readable object); `--yes`/`-y` installs without prompts, but only when no file would be overwritten. |
267
268
  | `pharn add [capability]` | Add one capability manually, for example `a11y` or `lens:n-plus-one`. With no argument, opens an interactive picker. |
268
269
  | `pharn remove [capability]` | Remove one installed capability. With no argument, opens an interactive picker. |
269
270
  | `pharn update` | Re-fetch and apply the latest PHARN content using drift-safe per-file decisions. `--force` overwrites files you changed; `--yes`/`-y` skips the confirmation prompt; `--dry-run` prints what it would do and writes nothing (add `--json` for the plan as one machine-readable object, and `--compact` to leave the unchanged files out of it). |
270
271
  | `pharn list` | Show installed archetypes and capabilities. Use `--json` for machine-readable output. |
271
272
  | `pharn status` | Read-only version and drift report. Use `--strict` to make drift fail CI, `--no-drift` to skip byte comparison, or `--json` for one machine-readable report. |
272
- | `pharn --help` | Show command help. |
273
+ | `pharn uninstall` | Remove PHARN: deletes only the files `pharn` recorded and you did not change, then `pharn.records.json` and `pharn.config.json` (backed up first). Never touches `.claude/settings.json` or `.pharn-backup/`. `--yes`/`-y` skips the confirmation prompt. |
274
+ | `pharn --help` | Show every command, option and environment variable. `pharn <command> --help` shows one command and only the options it takes. |
273
275
  | `pharn --version` | Show the installed CLI version. |
274
276
 
275
- `init` also accepts `--archetype`, a deprecated no-op kept for one release —
276
- archetype detection is now the default.
277
+ `init` also takes `--archetype <list>` (for example `--archetype backend` or
278
+ `--archetype ssr,backend`) to install for those archetypes instead of the
279
+ detected ones — the in-product correction for a misdetected project. The value
280
+ must be a comma-separated list of `ssr`, `backend` and `spa`, or `lib` alone,
281
+ each at most once; anything else exits 1. The choice is recorded, so `update`
282
+ keeps it. The install summary shows what triggered each detected archetype
283
+ (`backend ← src/app/api/`), or that they came from the flag.
277
284
 
278
285
  Three behaviours matter if you script the CLI:
279
286
 
280
287
  - **Options are per-command.** Passing one a command does not take prints
281
- ``Unsupported option for `status`: "--force"`` to stderr with the usage text
288
+ ``Unsupported option for `status`: "--force"`` to stderr with ``Run `pharn --help` for usage.``
282
289
  and exits **1**; an extra positional is refused the same way. Both previously
283
290
  parsed, were silently dropped, and exited 0.
284
- - **`init` and `update` are interactive-only.** Off a TTY they exit 1 rather
285
- than prompting into a dead stream. `update --yes` is the way through in CI;
286
- `init` deliberately has no `--yes`, because its second prompt is the
287
- destructive overwrite confirmation.
288
- - **One writer at a time.** `init`, `add`, `remove` and `update` take an
289
- advisory lock at `.pharn.lock`; a second run refuses rather than queueing.
290
- `add`, `remove` and `update` also re-read `pharn.config.json` once they hold
291
- the lock, and refuse — writing nothing — if another run changed it after they
292
- read it (for example while a confirm prompt was open).
291
+ - **`init` and `update` prompt.** Off a TTY a plain run exits 1 rather than
292
+ prompting into a dead stream. `update --yes` is the way through in CI. For
293
+ `init`, `--yes` skips the summary confirm but never the overwrite one: it
294
+ installs only into a project where none of its files exists yet, and
295
+ otherwise exits 1 — so a re-install always refuses it (use `update`). Both
296
+ commands' `--dry-run` needs no terminal and writes nothing. `uninstall`
297
+ likewise exits 1 off a TTY unless it is given `--yes`.
298
+ - **One writer at a time.** `init`, `add`, `remove`, `update` and `uninstall`
299
+ take an advisory lock at `.pharn.lock`; a second run refuses rather than
300
+ queueing. `add`, `remove`, `update` and `uninstall` also re-read
301
+ `pharn.config.json` once they hold the lock, and refuse — writing nothing —
302
+ if another run changed it after they read it (for example while a confirm
303
+ prompt was open).
293
304
  `list` and `status` never take it and are never blocked by one, so
294
305
  `pharn status --strict` stays runnable in CI while an update is in flight.
295
306
 
@@ -301,15 +312,27 @@ PHARN is intentionally conservative about writes:
301
312
  and refuses the whole install — writing nothing — when a destination path
302
313
  crosses a symlinked directory.
303
314
  - `update` uses `pharn.records.json` to skip files it cannot prove are
304
- untouched.
315
+ untouched. The only thing it deletes is the directory of a capability it
316
+ drops from `pharn.config.json` (PHARN runs whatever capability directories
317
+ are on disk), after backing up any file in it that `pharn` cannot prove it
318
+ wrote; it never touches `.claude/settings.json`. A re-run `init` does the
319
+ same, after listing those directories in its prompt.
305
320
  - `update --force` backs up overwritten files under `.pharn-backup/<timestamp>/`
306
321
  before writing. `add` does the same for any destination file that differs from
307
322
  upstream, and refuses the whole install — writing nothing — when a destination
308
323
  path crosses a symlinked directory.
309
324
  - `status` and `list` are read-only.
310
- - `remove` deletes only the selected capability directory and prunes its records;
325
+ - `remove` deletes only the selected capability directory and prunes its records,
326
+ after backing up to `.pharn-backup/<timestamp>/` any file in it that `pharn`
327
+ cannot prove it wrote unchanged;
311
328
  it never touches `CONSTITUTION.md`, `memory-bank/`, or your detected
312
329
  archetypes, and refuses when that directory's path crosses a symlink.
330
+ - `uninstall` deletes only files recorded in `pharn.records.json` that still
331
+ match their recorded hash, inside `pharn`'s install paths; it keeps every file
332
+ you changed or added and lists the ones it kept, backs up `pharn.config.json`
333
+ before deleting it, never writes `.claude/settings.json` (it prints the hooks
334
+ you need to unwire instead), and refuses — deleting nothing — without a usable
335
+ record store.
313
336
 
314
337
  PHARN can also refuse to install at all: if upstream declares a minimum CLI
315
338
  version newer than yours, `init`/`add`/`update` stop with a named error before
@@ -335,15 +358,33 @@ PHARN is intentionally scoped:
335
358
  written, and `pharn status` prints the floor beside the Node you are running.
336
359
  CI runs on Node 24, and a smoke job starts the packed CLI on exactly 24.2.0.
337
360
  - **Archetype detection is JS/TS-shaped.** The signals are `package.json`
338
- dependency names plus `next.config.*`, `app/` route handlers, `.tsx`/`.jsx`,
339
- `migrations/` and `.sql`. A Python, Go or Rust repo produces no signal,
340
- resolves to `lib`, and receives the universal capabilities only — a correct
341
- outcome, not a failure.
361
+ dependency names, `.tsx`/`.jsx` files, and — in a Next.js app only —
362
+ `next.config.*`, `app/` route handlers and `app/api`/`pages/api`. A root
363
+ `api/`, a `migrations/` directory and `.sql` files in a database directory
364
+ count only when the project has a root `package.json`. A Python, Go, Rust,
365
+ Ruby or PHP repo without one produces no signal, resolves to `lib`, and
366
+ receives the universal capabilities only — a correct outcome, not a failure.
367
+ One that also has a root `package.json` (a Vite frontend, or tooling only)
368
+ can resolve `backend` from its migrations; `pharn init --archetype` corrects
369
+ either way.
370
+ - **Server and database packages count only as runtime dependencies.** A
371
+ runtime database driver dependency (`pg`, `mongodb`, an ORM) means `backend`,
372
+ like a server framework; the same package only in `devDependencies` (a mock
373
+ server, a test database) does not. A backend bundled so that its framework is
374
+ only a devDependency needs `pharn init --archetype backend`. SSR and UI
375
+ frameworks count from `devDependencies` too.
376
+ - **Detection is bounded.** The file-tree scan examines at most 50,000 entries,
377
+ 24 directories deep (skipped directories such as `node_modules` do not
378
+ count). When it stops at a bound before its result is settled, the install
379
+ summary says `detection stopped early` and `init --dry-run --json` reports
380
+ `"detectionTruncated": true`; check the archetypes and pass `--archetype` if
381
+ they are wrong.
342
382
  - It does not scaffold your application or install framework packages.
343
383
  - It does not replace tests, human review, or release judgment. It gives those
344
384
  activities a structured record and repeatable workflow.
345
- - `status` reports modified, missing, and unreadable PHARN-owned paths;
346
- orphaned-file detection is still planned.
385
+ - `status` reports modified, missing, and unreadable PHARN-owned paths, and
386
+ the files upstream stopped shipping that are still in your project
387
+ (orphans). Nothing deletes an orphan; that is yours to do by hand.
347
388
 
348
389
  See the [roadmap](docs/roadmap.md) for shipped versus planned work.
349
390