faf 8.8.0 → 8.9.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.
@@ -24,8 +24,13 @@
24
24
  * formatting, CRLF, reordered keys, a repeated key or a number JSON cannot hold
25
25
  * exactly (a 20-digit id) would all be lost in a rewrite, so such a file — like
26
26
  * one in another shape — is read and left exactly as it is, and
27
- * `readOnlyReason()` says why in one line. `faf init --force` starts a fresh
28
- * lineage when you ask it to.
27
+ * `readOnlyReason()` says why in one line.
28
+ *
29
+ * Write-once. The birth certificate is written once and never replaced: birth()
30
+ * writes `.faf-dna` only when there is none, and refuses (SafePathError
31
+ * `exists`) when one is there, in any shape. recordGrowth copies the birth
32
+ * block unchanged. Its permanent record is the commit that first added
33
+ * `.faf-dna`; `faf dna --verify` checks the file against it (birth-commit.ts).
29
34
  */
30
35
  export interface BirthCertificate {
31
36
  born: string;
@@ -53,10 +58,10 @@ export interface Milestone {
53
58
  emoji: string;
54
59
  }
55
60
  /**
56
- * A lineage a reset ended. `faf init --force` starts a fresh certificate, and
57
- * the life before it is kept here rather than erased — a birth score is the one
58
- * value in this format that cannot be recreated, so a reset is a REBIRTH, not a
59
- * deletion. Chains: a project reset twice keeps both earlier lives, oldest first.
61
+ * A lineage a reset ended. Before birth was write-once, `faf init --force` started a fresh
62
+ * certificate and kept the life before it here. faf no longer resets a
63
+ * certificate (birth is write-once), but files that hold earlier lives are
64
+ * still read and shown, oldest first.
60
65
  */
61
66
  export interface PriorLineage {
62
67
  born: string;
@@ -84,14 +89,18 @@ export interface FafDNA {
84
89
  /** Lives ended by a reset, oldest first. Absent when there has never been one. */
85
90
  priorLineage?: PriorLineage[];
86
91
  }
92
+ /** The birth certificate in a `.faf-dna` text, in any shape faf can read
93
+ * (including the `birthWeight` files faf wrote before 2026-05-21), or null
94
+ * when it is not JSON or has none. Used to read the one in the birth commit. */
95
+ export declare function birthCertificateOf(text: string): BirthCertificate | null;
87
96
  /**
88
97
  * The `.faf-dna` lineage of one project: birth, growth and the journey line.
89
98
  * This is the API `faf init` (birth), `faf auto` / `faf refresh` (recordGrowth)
90
99
  * and `faf dna` (getJourney, getBirthDNADisplay, getLog) use.
91
100
  *
92
- * - `birth(score)` starts a new lineage and writes it, replacing any
93
- * `.faf-dna` there (check `exists()` first unless a fresh start is meant —
94
- * `faf init` births only when there is none, or with `--force`).
101
+ * - `birth(score)` writes the birth certificate when there is no `.faf-dna`.
102
+ * It is write-once: with a `.faf-dna` there, in any shape, it refuses
103
+ * (SafePathError `exists`) and writes nothing.
95
104
  * - `recordGrowth(score, changes)` adds a version when the score changed.
96
105
  * It adds only to a file faf can prove it wrote (see the file header);
97
106
  * for any other file it writes nothing and returns null, and
@@ -115,21 +124,14 @@ export declare class FafDNAManager {
115
124
  private text;
116
125
  /** Why the file is read only, when it is; null when faf may add to it. */
117
126
  private reason;
118
- /** True once this manager found no `.faf-dna` (exists / load / birth) and
119
- * has not written one since: a birth then refuses a file that appeared
120
- * meanwhile instead of writing over it. */
121
- private sawNoFile;
122
127
  constructor(projectPath: string);
123
128
  exists(): boolean;
124
- /** Birth — the first heartbeat. Writes the birth certificate with the honest first score.
125
- * When this manager found no `.faf-dna` (now, or at an earlier exists() /
126
- * load()), a file that appeared since is refused (SafePathError `changed`)
127
- * rather than written over; over a `.faf-dna` that is there, birth starts a
128
- * fresh lineage (`faf init --force`). */
129
- /** The lives this birth is about to end, oldest first — the one already on
130
- * disk, plus any it had itself inherited. Empty when there is no readable
131
- * `.faf-dna`, so a first birth writes no `priorLineage` key at all. */
132
- private endingLineage;
129
+ /** Birth — the first heartbeat. Writes the birth certificate with the honest
130
+ * first score. Write-once: a `.faf-dna` that is there (any shape, even one
131
+ * faf cannot read) is refused with SafePathError `exists`, and one that
132
+ * appears while faf writes is refused with `changed`. Nothing is written
133
+ * either way; the file on disk is exactly as it was. A `.faf-dna` link that
134
+ * leads out of the project or dangles is refused as `outside` / `dangling`. */
133
135
  birth(birthDNA: number): FafDNA;
134
136
  /** True when `.faf-dna` exists and is one faf wrote — in faf's shape, and
135
137
  * exactly faf's own text — so recordGrowth may add to it. Any other file is
@@ -57,7 +57,7 @@
57
57
  */
58
58
  import { type Dirent, type Stats } from 'fs';
59
59
  /** Why a path was refused. */
60
- export type SafePathReason = 'outside' | 'dangling' | 'not-a-file' | 'not-faf' | 'other-file' | 'git' | 'not-utf8' | 'changed' | 'not-owned' | 'not-yaml' | 'unplaceable';
60
+ export type SafePathReason = 'outside' | 'dangling' | 'not-a-file' | 'not-faf' | 'other-file' | 'git' | 'not-utf8' | 'changed' | 'exists' | 'not-owned' | 'not-yaml' | 'unplaceable';
61
61
  /**
62
62
  * A path faf will not read or write, or a file faf will not change. Nothing
63
63
  * was written; the file on disk is exactly as it was.
@@ -66,6 +66,8 @@ export type SafePathReason = 'outside' | 'dangling' | 'not-a-file' | 'not-faf' |
66
66
  * - `not-utf8`: the file is not UTF-8 (see {@link readUtf8}).
67
67
  * - `changed`: the file changed on disk after faf read it — its bytes, or its
68
68
  * mode (see the `expect` option of {@link safeWriteFile}).
69
+ * - `exists`: a write-once file is already there, so faf does not write it
70
+ * again (`.faf-dna`, the birth certificate).
69
71
  * - `not-owned`: a whole file faf renders is already there and faf cannot
70
72
  * prove it wrote every byte of it — it has no faf mark, or it was edited
71
73
  * since faf wrote it, or it is from before faf recorded a render hash (see