@pharn-dev/pharn 0.12.0 → 0.14.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 +130 -55
- package/dist/index.js +71 -60
- package/package.json +5 -5
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
|
|
|
@@ -36,6 +36,7 @@ npx @pharn-dev/pharn@latest init
|
|
|
36
36
|
- [After install](#after-install)
|
|
37
37
|
- [Day-to-day workflow](#day-to-day-workflow)
|
|
38
38
|
- [CLI commands](#cli-commands)
|
|
39
|
+
- [Agent skills](#agent-skills)
|
|
39
40
|
- [Safety model](#safety-model)
|
|
40
41
|
- [Current scope](#current-scope)
|
|
41
42
|
- [Documentation](#documentation)
|
|
@@ -130,13 +131,13 @@ upstream's
|
|
|
130
131
|
`pharn init` is archetype-driven. There is no stack questionnaire and no module
|
|
131
132
|
catalog.
|
|
132
133
|
|
|
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.
|
|
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. 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)). |
|
|
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. |
|
|
140
141
|
|
|
141
142
|
The current upstream install layout places most runtime surfaces under `pharn/`
|
|
142
143
|
and Claude Code integration under `.claude/`. Older flat-layout installs are
|
|
@@ -144,18 +145,18 @@ still understood through the recorded `layout` field.
|
|
|
144
145
|
|
|
145
146
|
## What gets installed
|
|
146
147
|
|
|
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`
|
|
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.
|
|
148
|
+
| Artifact | Purpose |
|
|
149
|
+
| --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
|
|
150
|
+
| `pharn/pharn-pipeline/grillers/<name>/`, `pharn/pharn-review/<name>/` | Pipeline grillers and review lenses selected for your project archetype(s). |
|
|
151
|
+
| `.claude/commands/`, `.claude/hooks/` | The installed `/pharn-*` Claude Code slash commands and deterministic `.cjs`/`.mjs` 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
|
+
| `pharn/THREAT-MODEL.md`, `pharn/LIMITS.md` | The other two trusted docs (at the project root from a pharn-oss older than 7.0.0). |
|
|
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. |
|
|
159
160
|
|
|
160
161
|
An existing `.claude/settings.json` is preserved. PHARN may create it when
|
|
161
162
|
absent, but it never overwrites your Claude Code settings.
|
|
@@ -166,9 +167,19 @@ As you run the workflow, PHARN writes one directory per increment —
|
|
|
166
167
|
`SHIP.md` + `BRIEFING.md` (`/pharn-ship`) or `LOOP.md` (`/pharn-loop`), a
|
|
167
168
|
`RUN-REPORT.md`, and the machine-readable records beside them
|
|
168
169
|
(`AC-TESTS.lock.json`, `cost.json`, the `*-report.json` files). Those are the
|
|
169
|
-
durable record; commit them.
|
|
170
|
-
[Safety model](#safety-model)) and
|
|
171
|
-
`.gitignore`. PHARN never edits
|
|
170
|
+
durable record; commit them. `pharn/.run/` (runtime scratch; `.pharn/` before
|
|
171
|
+
pharn-oss 7.0.0), `pharn/.backup/` (see [Safety model](#safety-model)) and
|
|
172
|
+
`pharn/.lock*` are not — add them to your `.gitignore`. PHARN never edits
|
|
173
|
+
`.gitignore` for you; `pharn update` prints the replacement lines when yours still
|
|
174
|
+
names the old `.pharn/`, `.pharn-backup` or `.pharn.lock`.
|
|
175
|
+
|
|
176
|
+
Everything PHARN keeps in your project lives under `.claude/` and `pharn/`, plus
|
|
177
|
+
the two JSON files at the root. An install made from a pharn-oss older than 7.0.0
|
|
178
|
+
also has `THREAT-MODEL.md` and `LIMITS.md` at the root, and may have
|
|
179
|
+
`memory-bank/` and `pharn.spec-template.md` there: the first `pharn update` to
|
|
180
|
+
7.0.0 or later deletes the two docs if you never edited them and moves the other
|
|
181
|
+
two under `pharn/` (backed up first, never merged) — see
|
|
182
|
+
[update](docs/commands/update.md#the-root-footprint-migration).
|
|
172
183
|
|
|
173
184
|
**Two version numbers, on purpose.** The npm package `@pharn-dev/pharn` carries
|
|
174
185
|
the installer's version. The content it installs carries its own,
|
|
@@ -181,9 +192,10 @@ are keyed to the latter.
|
|
|
181
192
|
Three things about the installed hooks are worth knowing on day one.
|
|
182
193
|
|
|
183
194
|
**Hooks enforce only once they are registered in `.claude/settings.json`.** If
|
|
184
|
-
your project already had that file, PHARN preserved it
|
|
185
|
-
|
|
186
|
-
|
|
195
|
+
your project already had that file, PHARN preserved it instead of overwriting
|
|
196
|
+
it and printed a `HOOKS` note listing each hook it does not wire, as
|
|
197
|
+
paste-ready JSON — until you copy those entries across, every guarantee that
|
|
198
|
+
depends on a `PreToolUse` hook is inactive, and `pharn status --strict` fails.
|
|
187
199
|
|
|
188
200
|
**Once wired, the default depends on your tree (pharn-oss 6.24.0+).** With no
|
|
189
201
|
active scope, `enforce-writes-scope.cjs` applies that default.
|
|
@@ -216,7 +228,8 @@ also does nothing until registered — under `Stop`, with no matcher. The
|
|
|
216
228
|
`settings.json` upstream ships has registered it since pharn-oss 6.12.0, but a
|
|
217
229
|
file PHARN preserved, or one created by an earlier install, lacks the entry:
|
|
218
230
|
copy it across by hand. `pharn update` never edits `.claude/settings.json`;
|
|
219
|
-
`pharn status` and `pharn update` name the missing entry in a
|
|
231
|
+
`pharn init`, `pharn status` and `pharn update` name the missing entry in a
|
|
232
|
+
`HOOKS` note.
|
|
220
233
|
|
|
221
234
|
The full set of bounds lives in upstream's
|
|
222
235
|
[`LIMITS.md`](https://github.com/pharn-dev/pharn-oss/blob/main/LIMITS.md) and
|
|
@@ -262,36 +275,67 @@ Two commands sit outside the pipeline:
|
|
|
262
275
|
|
|
263
276
|
| Command | Description |
|
|
264
277
|
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
265
|
-
| `pharn init` | Detect archetypes and install matching capabilities. This is also the default when no command is given.
|
|
278
|
+
| `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
279
|
| `pharn add [capability]` | Add one capability manually, for example `a11y` or `lens:n-plus-one`. With no argument, opens an interactive picker. |
|
|
267
280
|
| `pharn remove [capability]` | Remove one installed capability. With no argument, opens an interactive picker. |
|
|
268
281
|
| `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
282
|
| `pharn list` | Show installed archetypes and capabilities. Use `--json` for machine-readable output. |
|
|
270
283
|
| `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
|
|
284
|
+
| `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. |
|
|
285
|
+
| `pharn --help` | Show every command, option and environment variable. `pharn <command> --help` shows one command and only the options it takes. |
|
|
272
286
|
| `pharn --version` | Show the installed CLI version. |
|
|
273
287
|
|
|
274
|
-
`init` also
|
|
275
|
-
archetype
|
|
288
|
+
`init` also takes `--archetype <list>` (for example `--archetype backend` or
|
|
289
|
+
`--archetype ssr,backend`) to install for those archetypes instead of the
|
|
290
|
+
detected ones — the in-product correction for a misdetected project. The value
|
|
291
|
+
must be a comma-separated list of `ssr`, `backend` and `spa`, or `lib` alone,
|
|
292
|
+
each at most once; anything else exits 1. The choice is recorded, so `update`
|
|
293
|
+
keeps it. The install summary shows what triggered each detected archetype
|
|
294
|
+
(`backend ← src/app/api/`), or that they came from the flag.
|
|
276
295
|
|
|
277
296
|
Three behaviours matter if you script the CLI:
|
|
278
297
|
|
|
279
298
|
- **Options are per-command.** Passing one a command does not take prints
|
|
280
|
-
``Unsupported option for `status`: "--force"`` to stderr with
|
|
299
|
+
``Unsupported option for `status`: "--force"`` to stderr with ``Run `pharn --help` for usage.``
|
|
281
300
|
and exits **1**; an extra positional is refused the same way. Both previously
|
|
282
301
|
parsed, were silently dropped, and exited 0.
|
|
283
|
-
- **`init` and `update`
|
|
284
|
-
|
|
285
|
-
`init`
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
302
|
+
- **`init` and `update` prompt.** Off a TTY a plain run exits 1 rather than
|
|
303
|
+
prompting into a dead stream. `update --yes` is the way through in CI. For
|
|
304
|
+
`init`, `--yes` skips the summary confirm but never the overwrite one: it
|
|
305
|
+
installs only into a project where none of its files exists yet, and
|
|
306
|
+
otherwise exits 1 — so a re-install always refuses it (use `update`). Both
|
|
307
|
+
commands' `--dry-run` needs no terminal and writes nothing. `uninstall`
|
|
308
|
+
likewise exits 1 off a TTY unless it is given `--yes`.
|
|
309
|
+
- **One writer at a time.** `init`, `add`, `remove`, `update` and `uninstall`
|
|
310
|
+
take an advisory lock at `pharn/.lock`; a second run refuses rather than
|
|
311
|
+
queueing. `add`, `remove`, `update` and `uninstall` also re-read
|
|
312
|
+
`pharn.config.json` once they hold the lock, and refuse — writing nothing —
|
|
313
|
+
if another run changed it after they read it (for example while a confirm
|
|
314
|
+
prompt was open).
|
|
292
315
|
`list` and `status` never take it and are never blocked by one, so
|
|
293
316
|
`pharn status --strict` stays runnable in CI while an update is in flight.
|
|
294
317
|
|
|
318
|
+
## Agent skills
|
|
319
|
+
|
|
320
|
+
If you would rather ask than remember flags, the
|
|
321
|
+
[`pharn-dev/skills`](https://github.com/pharn-dev/skills) repository ships a
|
|
322
|
+
`pharn-cli` skill that operates this CLI for you. Ask your agent "Is PHARN up to
|
|
323
|
+
date in this project?" or "What would an update change?" and it runs the
|
|
324
|
+
read-only checks and a `--dry-run` preview first, applies the update without
|
|
325
|
+
overwriting your edits, and adds or removes grillers and lenses. The same
|
|
326
|
+
repository also carries `phargus` skills for setting up and diagnosing Node.js
|
|
327
|
+
applications with [Phargus](https://github.com/pharn-dev/phargus).
|
|
328
|
+
|
|
329
|
+
In Claude Code:
|
|
330
|
+
|
|
331
|
+
```text
|
|
332
|
+
/plugin marketplace add pharn-dev/skills
|
|
333
|
+
/plugin install pharn@pharn-dev
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
Or with the Skills CLI: `npx skills add pharn-dev/skills --skill pharn-cli`.
|
|
337
|
+
The skills are optional; every command above works without them.
|
|
338
|
+
|
|
295
339
|
## Safety model
|
|
296
340
|
|
|
297
341
|
PHARN is intentionally conservative about writes:
|
|
@@ -300,15 +344,27 @@ PHARN is intentionally conservative about writes:
|
|
|
300
344
|
and refuses the whole install — writing nothing — when a destination path
|
|
301
345
|
crosses a symlinked directory.
|
|
302
346
|
- `update` uses `pharn.records.json` to skip files it cannot prove are
|
|
303
|
-
untouched.
|
|
304
|
-
|
|
347
|
+
untouched. The only thing it deletes is the directory of a capability it
|
|
348
|
+
drops from `pharn.config.json` (PHARN runs whatever capability directories
|
|
349
|
+
are on disk), after backing up any file in it that `pharn` cannot prove it
|
|
350
|
+
wrote; it never touches `.claude/settings.json`. A re-run `init` does the
|
|
351
|
+
same, after listing those directories in its prompt.
|
|
352
|
+
- `update --force` backs up overwritten files under `pharn/.backup/<timestamp>/`
|
|
305
353
|
before writing. `add` does the same for any destination file that differs from
|
|
306
354
|
upstream, and refuses the whole install — writing nothing — when a destination
|
|
307
355
|
path crosses a symlinked directory.
|
|
308
356
|
- `status` and `list` are read-only.
|
|
309
|
-
- `remove` deletes only the selected capability directory and prunes its records
|
|
357
|
+
- `remove` deletes only the selected capability directory and prunes its records,
|
|
358
|
+
after backing up to `pharn/.backup/<timestamp>/` any file in it that `pharn`
|
|
359
|
+
cannot prove it wrote unchanged;
|
|
310
360
|
it never touches `CONSTITUTION.md`, `memory-bank/`, or your detected
|
|
311
361
|
archetypes, and refuses when that directory's path crosses a symlink.
|
|
362
|
+
- `uninstall` deletes only files recorded in `pharn.records.json` that still
|
|
363
|
+
match their recorded hash, inside `pharn`'s install paths; it keeps every file
|
|
364
|
+
you changed or added and lists the ones it kept, backs up `pharn.config.json`
|
|
365
|
+
before deleting it, never writes `.claude/settings.json` (it prints the hooks
|
|
366
|
+
you need to unwire instead), and refuses — deleting nothing — without a usable
|
|
367
|
+
record store.
|
|
312
368
|
|
|
313
369
|
PHARN can also refuse to install at all: if upstream declares a minimum CLI
|
|
314
370
|
version newer than yours, `init`/`add`/`update` stop with a named error before
|
|
@@ -334,15 +390,33 @@ PHARN is intentionally scoped:
|
|
|
334
390
|
written, and `pharn status` prints the floor beside the Node you are running.
|
|
335
391
|
CI runs on Node 24, and a smoke job starts the packed CLI on exactly 24.2.0.
|
|
336
392
|
- **Archetype detection is JS/TS-shaped.** The signals are `package.json`
|
|
337
|
-
dependency names
|
|
338
|
-
`
|
|
339
|
-
|
|
340
|
-
|
|
393
|
+
dependency names, `.tsx`/`.jsx` files, and — in a Next.js app only —
|
|
394
|
+
`next.config.*`, `app/` route handlers and `app/api`/`pages/api`. A root
|
|
395
|
+
`api/`, a `migrations/` directory and `.sql` files in a database directory
|
|
396
|
+
count only when the project has a root `package.json`. A Python, Go, Rust,
|
|
397
|
+
Ruby or PHP repo without one produces no signal, resolves to `lib`, and
|
|
398
|
+
receives the universal capabilities only — a correct outcome, not a failure.
|
|
399
|
+
One that also has a root `package.json` (a Vite frontend, or tooling only)
|
|
400
|
+
can resolve `backend` from its migrations; `pharn init --archetype` corrects
|
|
401
|
+
either way.
|
|
402
|
+
- **Server and database packages count only as runtime dependencies.** A
|
|
403
|
+
runtime database driver dependency (`pg`, `mongodb`, an ORM) means `backend`,
|
|
404
|
+
like a server framework; the same package only in `devDependencies` (a mock
|
|
405
|
+
server, a test database) does not. A backend bundled so that its framework is
|
|
406
|
+
only a devDependency needs `pharn init --archetype backend`. SSR and UI
|
|
407
|
+
frameworks count from `devDependencies` too.
|
|
408
|
+
- **Detection is bounded.** The file-tree scan examines at most 50,000 entries,
|
|
409
|
+
24 directories deep (skipped directories such as `node_modules` do not
|
|
410
|
+
count). When it stops at a bound before its result is settled, the install
|
|
411
|
+
summary says `detection stopped early` and `init --dry-run --json` reports
|
|
412
|
+
`"detectionTruncated": true`; check the archetypes and pass `--archetype` if
|
|
413
|
+
they are wrong.
|
|
341
414
|
- It does not scaffold your application or install framework packages.
|
|
342
415
|
- It does not replace tests, human review, or release judgment. It gives those
|
|
343
416
|
activities a structured record and repeatable workflow.
|
|
344
|
-
- `status` reports modified, missing, and unreadable PHARN-owned paths
|
|
345
|
-
|
|
417
|
+
- `status` reports modified, missing, and unreadable PHARN-owned paths, and
|
|
418
|
+
the files upstream stopped shipping that are still in your project
|
|
419
|
+
(orphans). Nothing deletes an orphan; that is yours to do by hand.
|
|
346
420
|
|
|
347
421
|
See the [roadmap](docs/roadmap.md) for shipped versus planned work.
|
|
348
422
|
|
|
@@ -377,7 +451,8 @@ Useful scripts:
|
|
|
377
451
|
| `npm run test:coverage` | Run the Vitest coverage gate used by CI. |
|
|
378
452
|
| `npm run build:install-local` | Build and install the local CLI into local test apps. |
|
|
379
453
|
|
|
380
|
-
Set `PHARN_DEBUG=1` for verbose fetch and install errors
|
|
454
|
+
Set `PHARN_DEBUG=1` for verbose fetch and install errors; `NO_COLOR` / `FORCE_COLOR`
|
|
455
|
+
control colour (see [Colour](docs/troubleshooting.md#colour)). See
|
|
381
456
|
[CONTRIBUTING.md](CONTRIBUTING.md) for contributor notes and release discipline.
|
|
382
457
|
|
|
383
458
|
## Security
|