faf-cli 8.8.0 → 8.10.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.
@@ -0,0 +1,23 @@
1
+ /** Get a nested value from an object by dot-path (undefined when a step is missing or not a mapping). */
2
+ export declare function getNestedValue(obj: Record<string, unknown>, path: string): unknown;
3
+ /**
4
+ * The first intermediate step of `path` that holds something other than a
5
+ * mapping — a scalar or a list — as `{ at, value }`, or null when every step is
6
+ * a mapping or absent. Setting `path` would have to replace that value.
7
+ */
8
+ export declare function blockingStep(obj: Record<string, unknown>, path: string): {
9
+ at: string;
10
+ value: unknown;
11
+ } | null;
12
+ /** The refusal message for a blocked `path` — names the path, the step and what is there. */
13
+ export declare function blockedMessage(path: string, block: {
14
+ at: string;
15
+ value: unknown;
16
+ }): string;
17
+ /**
18
+ * Set a nested value by dot-path. A missing (or null) intermediate step becomes
19
+ * a new mapping. A step that already holds anything else — a scalar or a list —
20
+ * is refused with an Error naming the path: the existing value is never
21
+ * replaced with `{}`, and `obj` is left unchanged.
22
+ */
23
+ export declare function setNestedValue(obj: Record<string, unknown>, path: string, value: unknown): void;
@@ -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
@@ -6,16 +6,21 @@
6
6
  * siblings, UIs) IMPORT it — never reimplement, never copy. Decided
7
7
  * 2026-06-10: the CLI exports, CFM consumes, zero drift. (CFM's previous
8
8
  * hand-maintained registry had already drifted — e.g. its `how` asked "How
9
- * should AI assist?" while the canonical slot semantic is "How is it built /
10
- * used?". This file is the arbiter; slots.ts is its spine.)
9
+ * should AI assist?" while the canonical slot semantic is "How does it work?"
10
+ * (the faf schema). This file is the arbiter; slots.ts is its spine.)
11
11
  *
12
12
  * Shape carries what interactive consumers need: question text, a short
13
13
  * header chip, input type, required flag, select options where a closed-ish
14
14
  * vocabulary exists. Question SEMANTICS align to core/slots.ts descriptions —
15
15
  * the slot is the meaning, the question is just its interview voice.
16
16
  *
17
- * Authoring doctrine baked into the prompts: 6Ws answers are terse LABELS
18
- * (3-4 words, hard cap <6) — a scannable spec card, not prose.
17
+ * faf-facts: succinct, factual definitions for AI agents — every word earns
18
+ * its place. They are the human slots (the goal and six W's), not repo or
19
+ * stack slots: AI may only suggest them; a human reads, confirms and approves
20
+ * each one. Count facts, not words: one line, at most one sentence, no
21
+ * waffle. Short when the fact is short (where: "npm, Homebrew, GitHub"); a
22
+ * full line when it needs one (how: the mechanism and the choice that shapes
23
+ * the code).
19
24
  */
20
25
  import type { SeededContextDetailed } from '../detect/relentless.js';
21
26
  /** Bump when questions/options change — consumers can pin or report it. */
@@ -34,6 +39,10 @@ export interface InterviewQuestion<P extends string = string> {
34
39
  type: 'text' | 'select';
35
40
  required: boolean;
36
41
  options?: InterviewOption[];
42
+ /** What a good answer looks like — shown in gray when there's no
43
+ * suggestion. The shape of an answer, never a sample answer (sample words
44
+ * get copied). Never written to the .faf. */
45
+ help?: string;
37
46
  }
38
47
  /**
39
48
  * The human/sourced boundary, as TYPES — the load-bearing line in FAF.
@@ -79,6 +88,9 @@ export declare const INTERVIEW_PATHS: Record<string, InterviewQuestion>;
79
88
  * otherwise derived from the slot's canonical description — so slot-driven
80
89
  * flows (faf go) and registry-driven flows (faf_go) speak the same language.
81
90
  */
91
+ /** The help text for a slot (what a good answer looks like), or '' when the
92
+ * registry has none. Shown in gray by `faf go`; never written. */
93
+ export declare function helpForSlot(path: string): string;
82
94
  export declare function questionForSlot(path: string): string;
83
95
  /**
84
96
  * The questions still worth asking for a given .faf: registry order, empty
@@ -93,8 +105,8 @@ export interface GoalSeed {
93
105
  }
94
106
  /**
95
107
  * Seed the human-context slots from the Goal sentence — verbatim facts only.
96
- * Returns a partial { what?, where?, who? }; absent keys = "no fact, ask the
97
- * human". Never returns why/when/how (not verbatim-extractable from a goal).
108
+ * Returns a partial { what?, where? }; absent keys = "no fact, ask the
109
+ * human". Never returns who/why/when/how (not verbatim-extractable from a goal).
98
110
  */
99
111
  export declare function seedSixWsFromGoal(goal: string): GoalSeed;
100
112
  export type BoxStatus = 'filled' | 'seeded' | 'empty';
@@ -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
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Intent suggestions — the goal and the six W's, as the repo suggests them.
3
+ *
4
+ * "AI cannot fill human slots. It can only suggest." `faf init` and `faf auto`
5
+ * never write these slots; `faf go` shows each suggestion in gray and the
6
+ * human confirms, edits, replaces or skips it. Nothing here is stored: the
7
+ * suggestions are read from the repo (README, package.json, Cargo.toml) each
8
+ * time they're asked for, so the .faf format stays clean and a suggestion is
9
+ * never staler than the file it came from.
10
+ *
11
+ * Sourced or nothing: every suggestion names where it came from
12
+ * (`README.md § Status`, `package.json description`).
13
+ *
14
+ * Target only. Every slot has three outcomes — Target (the validated fact for
15
+ * that slot), Slop (waffle, nonsense, markup) and Misplaced (good info, wrong
16
+ * slot) — and only a Target is suggested: every candidate passes the one gate
17
+ * (isValidExtraction), headings match whole, and no text is offered for two
18
+ * slots.
19
+ *
20
+ * Exported so other surfaces can show the same suggestions (the `/faf-go`
21
+ * skill and CFM's `faf_go`, via buildTableOf8 as `detailed` + `goal`); today
22
+ * only the CLI's `faf go` reads it.
23
+ */
24
+ /** The human-authored slots: the goal and the six W's. */
25
+ export declare const INTENT_PATHS: readonly ["project.goal", "human_context.who", "human_context.what", "human_context.why", "human_context.where", "human_context.when", "human_context.how"];
26
+ export type IntentPath = (typeof INTENT_PATHS)[number];
27
+ export interface Suggestion {
28
+ value: string;
29
+ /** Where it came from: `README.md § Status`, `package.json description`. */
30
+ source: string;
31
+ }
32
+ export type IntentSuggestions = Partial<Record<IntentPath, Suggestion>>;
33
+ /** True for the goal and the six W's — slots only a human fills. */
34
+ export declare function isIntentPath(path: string): path is IntentPath;
35
+ /**
36
+ * Suggestions for the goal and the six W's in `dir`. When `faf` (the current
37
+ * .faf data) is given, a slot it already fills gets no suggestion — the
38
+ * human's words are never second-guessed. Precedence: README (sections, then
39
+ * the tagline) → package.json description → Cargo.toml description →
40
+ * Relentless (README + manifest, sourced).
41
+ */
42
+ export declare function suggestIntent(dir: string, faf?: Record<string, unknown>): IntentSuggestions;
43
+ /** Text as a person reads it: markdown links as their words, no emphasis
44
+ * markers or inline HTML tags, entities as characters, one line. Real
45
+ * brackets and underscores stay: `arr[i]`, `Foo[T]`, `[WIP]`, `__init__.py`. */
46
+ export declare function asProse(text: string, refs?: ReadonlySet<string>): string;
47
+ /** One way to name a source, whichever reader found it: Relentless says
48
+ * `README:## Why` / `README:first-paragraph` / `package.json:description`;
49
+ * people read `README.md § Why` / `README.md § first paragraph` /
50
+ * `package.json description`. */
51
+ export declare function sourceName(source: string): string;
52
+ /** The one line init and auto print when suggestions are waiting, or null:
53
+ * `3 suggestions for the goal and the six W's (README.md, package.json) —
54
+ * confirm them in 'faf go'`. */
55
+ export declare function suggestionNote(dir: string, faf?: Record<string, unknown>): string | null;
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Shared .faf assembly pipeline. The full slot-filling flow used to build a
3
3
  * FRESH .faf for a directory:
4
- * detect → interrogate → slotignore inactive categories → Turbo-Cat → Relentless
4
+ * detect → interrogate → slotignore inactive categories → Turbo-Cat
5
+ * (the goal and six W's stay empty — suggestions, confirmed in `faf go`)
5
6
  *
6
7
  * Used by BOTH `faf auto` (new-file path) and `faf git` (cloned repo) so they
7
8
  * can't drift — `faf git` previously ran detectStack alone (~33% vs ~75%).
@@ -10,7 +11,8 @@
10
11
  export declare function assembleFreshFaf(dir: string): Record<string, unknown>;
11
12
  /**
12
13
  * Update an EXISTING .faf for `dir`. Existing values win; interrogated → detected
13
- * → Turbo-Cat (formats) → Relentless (6 W's) fill only the remaining empties.
14
+ * → Turbo-Cat (formats) fill only the remaining empties. The goal and the six
15
+ * W's are never filled: they're suggested (core/suggest.ts) and `faf go` asks.
14
16
  * This is exactly the chain `faf auto` runs on an existing file — exported so
15
17
  * consumers (faf-mcp's faf_auto) compose it instead of re-deriving it and
16
18
  * drifting (they used to merge assembleFreshFaf's slotignore'd output over the
@@ -26,7 +26,8 @@ export interface SeededContext {
26
26
  * 'package.json:description' or 'README:## Why'. If we can't name a source,
27
27
  * we don't emit a value — sourced-or-empty, never invented.
28
28
  * - `confidence`: 0..1 by source quality (structured field > named section >
29
- * heuristic match). A signal for the seeded/confirm UI, not a score.
29
+ * first paragraph). A signal for the seeded/confirm UI, not a score.
30
+ * No sentence-pattern guesses: a guess is slop, and no suggestion beats one.
30
31
  */
31
32
  export interface SourcedValue {
32
33
  value: string;
@@ -47,7 +48,7 @@ export interface SeededContextDetailed {
47
48
  * human WHERE a value was relocated from before they accept it.
48
49
  */
49
50
  /** `toolingRoot`: the repo root's package.json is a tooling shell (polyglot repo
50
- * — real code is in sibling dirs), so its description/repo/scripts describe the
51
+ * — real code is in sibling dirs), so its description describes the
51
52
  * tooling, not the product. Skip package.json-sourced context; README only. */
52
53
  export interface RelentlessOpts {
53
54
  toolingRoot?: boolean;
package/dist/index.d.ts CHANGED
@@ -33,6 +33,8 @@ export type { TurboCatResult, DiscoveredFormat } from './detect/turbo-cat.js';
33
33
  export { relentlessContext, relentlessContextDetailed } from './detect/relentless.js';
34
34
  export type { SeededContext, SeededContextDetailed, SourcedValue } from './detect/relentless.js';
35
35
  export { assembleFreshFaf, updateExistingFaf, fillEmpties } from './detect/assemble.js';
36
+ export { suggestIntent, suggestionNote, isIntentPath, INTENT_PATHS } from './core/suggest.js';
37
+ export type { Suggestion, IntentSuggestions, IntentPath } from './core/suggest.js';
36
38
  export { normalizeGitUrl, repoNameFromUrl, authorFafFromRepo } from './detect/git-repo.js';
37
39
  export type { AuthorFafFromRepoOptions } from './detect/git-repo.js';
38
40
  export { FafDNAManager } from './core/faf-dna.js';