@pharn-dev/pharn 0.12.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.
- package/README.md +92 -50
- package/dist/index.js +63 -59
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
</
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="./assets/pharn-logo.svg" alt="Pharn CLI" width="96">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">Pharn CLI</h1>
|
|
8
8
|
|
|
9
9
|
**Install and update PHARN in any git project.**
|
|
10
10
|
|
|
@@ -130,13 +130,13 @@ upstream's
|
|
|
130
130
|
`pharn init` is archetype-driven. There is no stack questionnaire and no module
|
|
131
131
|
catalog.
|
|
132
132
|
|
|
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. |
|
|
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.
|
|
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. |
|
|
140
140
|
|
|
141
141
|
The current upstream install layout places most runtime surfaces under `pharn/`
|
|
142
142
|
and Claude Code integration under `.claude/`. Older flat-layout installs are
|
|
@@ -144,18 +144,18 @@ still understood through the recorded `layout` field.
|
|
|
144
144
|
|
|
145
145
|
## What gets installed
|
|
146
146
|
|
|
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` 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.
|
|
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. |
|
|
159
159
|
|
|
160
160
|
An existing `.claude/settings.json` is preserved. PHARN may create it when
|
|
161
161
|
absent, but it never overwrites your Claude Code settings.
|
|
@@ -181,9 +181,10 @@ are keyed to the latter.
|
|
|
181
181
|
Three things about the installed hooks are worth knowing on day one.
|
|
182
182
|
|
|
183
183
|
**Hooks enforce only once they are registered in `.claude/settings.json`.** If
|
|
184
|
-
your project already had that file, PHARN preserved it
|
|
185
|
-
|
|
186
|
-
|
|
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.
|
|
187
188
|
|
|
188
189
|
**Once wired, the default depends on your tree (pharn-oss 6.24.0+).** With no
|
|
189
190
|
active scope, `enforce-writes-scope.cjs` applies that default.
|
|
@@ -216,7 +217,8 @@ also does nothing until registered — under `Stop`, with no matcher. The
|
|
|
216
217
|
`settings.json` upstream ships has registered it since pharn-oss 6.12.0, but a
|
|
217
218
|
file PHARN preserved, or one created by an earlier install, lacks the entry:
|
|
218
219
|
copy it across by hand. `pharn update` never edits `.claude/settings.json`;
|
|
219
|
-
`pharn status` and `pharn update` name the missing entry in a
|
|
220
|
+
`pharn init`, `pharn status` and `pharn update` name the missing entry in a
|
|
221
|
+
`HOOKS` note.
|
|
220
222
|
|
|
221
223
|
The full set of bounds lives in upstream's
|
|
222
224
|
[`LIMITS.md`](https://github.com/pharn-dev/pharn-oss/blob/main/LIMITS.md) and
|
|
@@ -262,33 +264,43 @@ Two commands sit outside the pipeline:
|
|
|
262
264
|
|
|
263
265
|
| Command | Description |
|
|
264
266
|
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
265
|
-
| `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. |
|
|
266
268
|
| `pharn add [capability]` | Add one capability manually, for example `a11y` or `lens:n-plus-one`. With no argument, opens an interactive picker. |
|
|
267
269
|
| `pharn remove [capability]` | Remove one installed capability. With no argument, opens an interactive picker. |
|
|
268
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). |
|
|
269
271
|
| `pharn list` | Show installed archetypes and capabilities. Use `--json` for machine-readable output. |
|
|
270
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. |
|
|
271
|
-
| `pharn
|
|
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. |
|
|
272
275
|
| `pharn --version` | Show the installed CLI version. |
|
|
273
276
|
|
|
274
|
-
`init` also
|
|
275
|
-
archetype
|
|
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.
|
|
276
284
|
|
|
277
285
|
Three behaviours matter if you script the CLI:
|
|
278
286
|
|
|
279
287
|
- **Options are per-command.** Passing one a command does not take prints
|
|
280
|
-
``Unsupported option for `status`: "--force"`` to stderr with
|
|
288
|
+
``Unsupported option for `status`: "--force"`` to stderr with ``Run `pharn --help` for usage.``
|
|
281
289
|
and exits **1**; an extra positional is refused the same way. Both previously
|
|
282
290
|
parsed, were silently dropped, and exited 0.
|
|
283
|
-
- **`init` and `update`
|
|
284
|
-
|
|
285
|
-
`init`
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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).
|
|
292
304
|
`list` and `status` never take it and are never blocked by one, so
|
|
293
305
|
`pharn status --strict` stays runnable in CI while an update is in flight.
|
|
294
306
|
|
|
@@ -300,15 +312,27 @@ PHARN is intentionally conservative about writes:
|
|
|
300
312
|
and refuses the whole install — writing nothing — when a destination path
|
|
301
313
|
crosses a symlinked directory.
|
|
302
314
|
- `update` uses `pharn.records.json` to skip files it cannot prove are
|
|
303
|
-
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.
|
|
304
320
|
- `update --force` backs up overwritten files under `.pharn-backup/<timestamp>/`
|
|
305
321
|
before writing. `add` does the same for any destination file that differs from
|
|
306
322
|
upstream, and refuses the whole install — writing nothing — when a destination
|
|
307
323
|
path crosses a symlinked directory.
|
|
308
324
|
- `status` and `list` are read-only.
|
|
309
|
-
- `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;
|
|
310
328
|
it never touches `CONSTITUTION.md`, `memory-bank/`, or your detected
|
|
311
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.
|
|
312
336
|
|
|
313
337
|
PHARN can also refuse to install at all: if upstream declares a minimum CLI
|
|
314
338
|
version newer than yours, `init`/`add`/`update` stop with a named error before
|
|
@@ -334,15 +358,33 @@ PHARN is intentionally scoped:
|
|
|
334
358
|
written, and `pharn status` prints the floor beside the Node you are running.
|
|
335
359
|
CI runs on Node 24, and a smoke job starts the packed CLI on exactly 24.2.0.
|
|
336
360
|
- **Archetype detection is JS/TS-shaped.** The signals are `package.json`
|
|
337
|
-
dependency names
|
|
338
|
-
`
|
|
339
|
-
|
|
340
|
-
|
|
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.
|
|
341
382
|
- It does not scaffold your application or install framework packages.
|
|
342
383
|
- It does not replace tests, human review, or release judgment. It gives those
|
|
343
384
|
activities a structured record and repeatable workflow.
|
|
344
|
-
- `status` reports modified, missing, and unreadable PHARN-owned paths
|
|
345
|
-
|
|
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.
|
|
346
388
|
|
|
347
389
|
See the [roadmap](docs/roadmap.md) for shipped versus planned work.
|
|
348
390
|
|