faf-cli 7.16.1 → 8.0.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,43 @@
1
+ /**
2
+ * A command value may carry its own note: `cmd — note`.
3
+ *
4
+ * `key_files` already works this way (`path — role`), and the authors turn
5
+ * that into a `| Path | Role |` table. Commands get the same convention, so a
6
+ * `.faf` can say what a script actually does:
7
+ *
8
+ * ```yaml
9
+ * commands:
10
+ * build: bun run build — clean, bundle cli+index, then tsc
11
+ * ```
12
+ *
13
+ * authors as:
14
+ *
15
+ * ```bash
16
+ * bun run build # clean, bundle cli+index, then tsc
17
+ * ```
18
+ *
19
+ * Without a note the behaviour is unchanged — the key is the comment, exactly
20
+ * as before. The separator is the em dash with spaces around it, matching
21
+ * `key_files`; a bare hyphen is left alone, because shell commands are full of
22
+ * them (`--force`, `-rf`).
23
+ *
24
+ * Every consumer of `data.commands` must split before it renders, or the note
25
+ * leaks into the command itself — an authored `bun run build — clean…` that a
26
+ * reader would try to run.
27
+ */
28
+ /** The separator a command value uses to carry its note. */
29
+ export declare const NOTE_SEPARATOR = " \u2014 ";
30
+ export interface CommandAndNote {
31
+ /** The command to run, with any note removed. */
32
+ cmd: string;
33
+ /** The note the value carried, or null when it carried none. */
34
+ note: string | null;
35
+ }
36
+ /**
37
+ * Split a command value into the command and its note.
38
+ *
39
+ * @param value a `commands` value, e.g. `bun run build` or `bun run build — clean, then tsc`
40
+ */
41
+ export declare function splitCommandNote(value: unknown): CommandAndNote;
42
+ /** The command alone — for prose and for authors that show no comments. */
43
+ export declare function commandOnly(value: unknown): string;
@@ -123,7 +123,14 @@ export declare function injectFafBlock(path: string, block: string, start?: stri
123
123
  * older block there is an example to faf, and stays below the new one;
124
124
  * - a whole-line START marker sits past more than MAX_OPEN_CONTAINERS
125
125
  * nested lists or quotes: faf did not read that far, and the older block
126
- * stays below the new one.
126
+ * stays below the new one;
127
+ * - a whole-line START or END marker is shown as text with no matching pair
128
+ * — a block an older faf truncated, or a pair the two readings read
129
+ * differently. faf cannot prove where that block ended, so it is left
130
+ * exactly as it is and the new block goes on top. Without this line the
131
+ * file is the one case in this family that is prefixed in silence: it
132
+ * carries faf's own marker text, so it looks most like faf's to a reader
133
+ * and least like it to faf.
127
134
  * `label` names the file (`CLAUDE.md`). `existing` is the file's text before
128
135
  * the write (null when there was none). faf-mcp and claude-faf-mcp print the
129
136
  * same line through this export.
@@ -1,9 +1,6 @@
1
1
  import type { KernelScoreResult, FafbInfo } from '../core/types.js';
2
- /** Score a .faf YAML string (21 base slots), as the file is. A typed None /
3
- * N/A / not applicable at a slot is an empty slot, as in every engine. A
4
- * leading BOM is not scored (`faf auto` and `faf score` read a BOM file). */
5
2
  export declare function score(yaml: string): KernelScoreResult;
6
- /** Score a .faf YAML string (33 enterprise slots), as the file is (a leading BOM is not scored). */
3
+ /** Same as {@link score} (always 33) — kept for existing callers (a leading BOM is not scored). */
7
4
  export declare function scoreEnterprise(yaml: string): KernelScoreResult;
8
5
  /** Validate .faf YAML (a leading BOM is left out, as in {@link score}: `faf check` reads a BOM file). */
9
6
  export declare function validate(yaml: string): boolean;
@@ -14,12 +11,7 @@ export declare function compile(yaml: string): Uint8Array;
14
11
  export declare function decompile(bytes: Uint8Array): FafbInfo;
15
12
  /** Get FAFb file metadata */
16
13
  export declare function fafbInfo(bytes: Uint8Array): FafbInfo;
17
- /** Get FAFb binary metadata (name, version, source) */
18
- export interface FafbMeta {
19
- source: string;
20
- name: string;
21
- faf_version: string;
22
- }
23
- export declare function scoreFafb(bytes: Uint8Array): FafbMeta;
14
+ /** Score a compiled .fafb — same JSON shape as {@link score}. */
15
+ export declare function scoreFafb(bytes: Uint8Array): KernelScoreResult;
24
16
  /** Get WASM SDK version */
25
17
  export declare function sdkVersion(): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "faf-cli",
3
- "version": "7.16.1",
3
+ "version": "8.0.0",
4
4
  "description": "Persistent AI context + memory — .faf and .fafm, IANA-registered. Anthropic-merged.",
5
5
  "type": "module",
6
6
  "icon": "https://faf.one/orange-smiley.svg",
@@ -25,7 +25,8 @@
25
25
  "dist/**/*",
26
26
  "README.md",
27
27
  "LICENSE",
28
- "project.faf"
28
+ "project.faf",
29
+ "vendor/faf-scoring-kernel/**"
29
30
  ],
30
31
  "scripts": {
31
32
  "dev": "bun src/cli.ts",
@@ -74,7 +75,7 @@
74
75
  },
75
76
  "dependencies": {
76
77
  "commander": "^14.0.3",
77
- "faf-scoring-kernel": "^2.0.3",
78
+ "faf-scoring-kernel": "file:./vendor/faf-scoring-kernel",
78
79
  "open": "^11.0.0",
79
80
  "yaml": "^2.9.0"
80
81
  },
package/project.faf CHANGED
@@ -1,29 +1,32 @@
1
1
  faf_version: "3.0"
2
2
  project:
3
3
  name: faf-cli
4
- version: "7.16.1"
5
- goal: "CLI for IANA-registered `.faf` + `.fafm` — context DNA and portable agent memory. TypeScript, Bun-native since v6. package faf-cli v7.16.1 The Discoverable Edition."
4
+ version: "8.0.0"
5
+ goal: "CLI for IANA-registered `.faf` + `.fafm` — context DNA and portable agent memory. TypeScript, Bun-native since v6. package faf-cli v8.0.0 The Always33 Edition — scored by the always-33 engine."
6
6
  main_language: TypeScript
7
7
  type: cli # found: package.json bin
8
8
  # Commands + key_files feed `faf export --agents` (hand values win over detection).
9
9
  commands:
10
10
  install: bun install
11
- build: bun run build
12
- dev: bun run dev
13
- test: bun run test
14
- lint: bun run lint
11
+ build: bun run build — clean, bundle src/cli.ts to dist, then tsc
12
+ dev: bun run dev — run the CLI from source, no build
13
+ test: bun run test — must pass before a change is done
14
+ lint: bun run lint — eslint over src
15
+ check:no-hardcode: bun run check:no-hardcode — fail if a build-machine path leaked into dist
15
16
  key_files:
16
- - src/cli.ts
17
- - src/index.ts
18
- - src/commands/
19
- - src/commands/memory.ts
20
- - src/core/
21
- - src/detect/
22
- - src/fafm/
23
- - src/interop/
24
- - src/wasm/
25
- - package.json
26
- - project.faf
17
+ - src/cli.ts — CLI entry (Commander); builds to the `faf` / `faf-cli` bin
18
+ - src/index.ts — library entry; builds to `main`, plus the `./pack` export
19
+ - src/commands/ — one file per faf subcommand (39)
20
+ - src/commands/memory.ts — `faf memory`, the `.fafm` surface
21
+ - src/core/ — domain engines (drift, faf-dna, faf-source, cwd-guard)
22
+ - src/detect/ — stack and project detection, per language
23
+ - src/fafm/ — the `.fafm` library (soul, from-claude-dir, types)
24
+ - src/interop/ — the context authors (agents, claude, gemini, cards, copilot)
25
+ - src/interrogate/ — extractors that read a repo's own files for facts (readme, cargo, compose, env)
26
+ - src/ui/ — terminal output (colors, display, progress, star-nudge)
27
+ - src/wasm/ — bridge to faf-scoring-kernel; scoring lives there, not in TS
28
+ - package.json — scripts, and the bin that maps `faf` to dist/cli.js
29
+ - project.faf — this file; the DNA every author reads from
27
30
  instant_context:
28
31
  what_building: CLI for IANA-registered .faf context + .fafm memory
29
32
  tech_stack: TypeScript · Bun-native since v6
@@ -43,9 +46,9 @@ stack:
43
46
  runtime: slotignored
44
47
  database: slotignored
45
48
  connection: slotignored
46
- hosting: slotignored
47
- build: slotignored
48
- cicd: slotignored
49
+ hosting: npm + Homebrew
50
+ build: Bun (bun build) + tsc
51
+ cicd: GitHub Actions
49
52
  monorepo_tool: slotignored
50
53
  package_manager: slotignored
51
54
  workspaces: slotignored
@@ -58,7 +61,7 @@ human_context:
58
61
  what: Persistent AI Context Standard — project DNA for AI. IANA-registered. Anthropic-merged.
59
62
  why: Eliminates 91% context re-discovery tax — define once, AI remembers forever
60
63
  where: npm registry, Homebrew, GitHub
61
- when: Production since September 2025; Bun-native since v6; current package 7.16.1
64
+ when: Production since September 2025; Bun-native since v6; current package 8.0.0 (always-33 engine)
62
65
  how: bunx faf-cli auto, then project.faf versions with your code — faf show renders it human-visible
63
66
  monorepo:
64
67
  packages_count: slotignored
@@ -0,0 +1,88 @@
1
+ # faf-scoring-kernel
2
+
3
+ **faf-scoring-kernel v3.0.0 — The Always33 Edition**
4
+
5
+ One engine, one number: `score_faf` is always-33, so a repo scores the same in every FAF app.
6
+
7
+ WASM from the FAF Rust workspace. Scores `.faf` against all 33 slots and compiles `.fafb`. `.faf` is IANA-registered as `application/vnd.faf+yaml`.
8
+
9
+ ## What's New — v3.0.0
10
+
11
+ One engine, one number: `score_faf` is always-33, so a repo scores the same in every FAF app.
12
+
13
+ - `score_faf` → always-33 — the same score as faf-kernel, the Rust SDK and the MCP servers
14
+ - `score_faf_enterprise` → alias of `score_faf` (existing callers keep working)
15
+ - `score_fafb` → agrees with `score_faf`
16
+ - `tbd` / `todo` count as empty (placeholders)
17
+ - Engine `sdk_version()` is **3.1.0** (the `faf-wasm-sdk` crate this WASM was built from)
18
+
19
+ **Upgrading from 2.x:** a `.faf` without its 12 enterprise `slotignored` markers now scores against all 33 slots, so its number can drop (100 → 64). Mark the slots that don't apply as `slotignored` — a 21-slot project carries the 12 enterprise slots that way — and the score returns.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ npm install faf-scoring-kernel
25
+ ```
26
+
27
+ Node.js 16+ and Bun.
28
+
29
+ ## Usage
30
+
31
+ ```javascript
32
+ const kernel = require('faf-scoring-kernel');
33
+
34
+ const yaml = `faf_version: 2.5.0
35
+ project:
36
+ name: my-app
37
+ goal: Ship a fast CLI
38
+ main_language: Rust
39
+ `;
40
+
41
+ const result = JSON.parse(kernel.score_faf(yaml));
42
+ console.log(result.score, result.populated, '/', result.active); // active = 33 minus slotignored
43
+
44
+ const bytes = kernel.compile_fafb(yaml);
45
+ console.log(String.fromCharCode(bytes[0], bytes[1], bytes[2], bytes[3])); // FAFB
46
+ console.log(JSON.parse(kernel.decompile_fafb(bytes)).version); // 2.0
47
+ ```
48
+
49
+ ## API
50
+
51
+ 8 pure-function exports. No classes. No state.
52
+
53
+ | Function | Input | Output |
54
+ |----------|-------|--------|
55
+ | `sdk_version()` | — | engine version string (`3.1.0`) |
56
+ | `score_faf(yaml)` | YAML string | JSON — always-33 |
57
+ | `score_faf_enterprise(yaml)` | YAML string | JSON — same as `score_faf` |
58
+ | `validate_faf(yaml)` | YAML string | `boolean` |
59
+ | `compile_fafb(yaml)` | YAML string | `Uint8Array` — FAFb v2 |
60
+ | `decompile_fafb(bytes)` | `Uint8Array` | JSON string |
61
+ | `score_fafb(bytes)` | `Uint8Array` | JSON string — same score as `score_faf` |
62
+ | `fafb_info(bytes)` | `Uint8Array` | JSON — header + section table |
63
+
64
+ ## Tiers
65
+
66
+ | Score | Tier |
67
+ |-------|------|
68
+ | 100% | ✪ Trophy |
69
+ | 99% | ★ Gold |
70
+ | 95% | ◆ Silver |
71
+ | 85% | ◇ Bronze |
72
+ | 70% | ● Green |
73
+ | 55% | ● Yellow |
74
+ | 1% | ○ Red |
75
+ | 0% | ♡ White |
76
+
77
+ ✪ is the work glyph for 100%. Same score as 🏆 on social surfaces.
78
+
79
+ ## Links
80
+
81
+ - [faf.one](https://faf.one) · [the format spec](https://faf.one/spec)
82
+ - [Source](https://github.com/Wolfe-Jam/faf-rust) — `crates/faf-wasm-sdk` (engine) · `npm/faf-scoring-kernel` (this package)
83
+ - [IANA](https://www.iana.org/assignments/media-types/application/vnd.faf+yaml) — `application/vnd.faf+yaml`
84
+ - [faf-cli](https://www.npmjs.com/package/faf-cli) vendors this WASM
85
+
86
+ ## License
87
+
88
+ MIT
@@ -0,0 +1,45 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Compile YAML to a FAFb v2 binary — returns Uint8Array.
6
+ */
7
+ export function compile_fafb(yaml: string): Uint8Array;
8
+
9
+ /**
10
+ * Decompile a FAFb binary to JSON (full content) — returns JSON string.
11
+ */
12
+ export function decompile_fafb(bytes: Uint8Array): string;
13
+
14
+ /**
15
+ * Get FAFb file info (header + section metadata, no content) — returns JSON.
16
+ */
17
+ export function fafb_info(bytes: Uint8Array): string;
18
+
19
+ /**
20
+ * Score FAF YAML content with the Mk4 kernel (always-33) — returns JSON.
21
+ *
22
+ * Always 33 slots. A 21-slot file carries the 12 enterprise slots as
23
+ * `slotignored`, so it scores the same here as in every other FAF app.
24
+ */
25
+ export function score_faf(yaml: string): string;
26
+
27
+ /**
28
+ * Same as [`score_faf`] (always-33). Kept so existing callers keep working.
29
+ */
30
+ export function score_faf_enterprise(yaml: string): string;
31
+
32
+ /**
33
+ * Score a FAFb binary — returns JSON string (same shape as `score_faf`).
34
+ */
35
+ export function score_fafb(bytes: Uint8Array): string;
36
+
37
+ /**
38
+ * Get SDK version.
39
+ */
40
+ export function sdk_version(): string;
41
+
42
+ /**
43
+ * Validate FAF YAML content — true if it parses as a YAML mapping.
44
+ */
45
+ export function validate_faf(yaml: string): boolean;
@@ -0,0 +1,369 @@
1
+ /* @ts-self-types="./faf_wasm_sdk.d.ts" */
2
+
3
+ /**
4
+ * Compile YAML to a FAFb v2 binary — returns Uint8Array.
5
+ * @param {string} yaml
6
+ * @returns {Uint8Array}
7
+ */
8
+ function compile_fafb(yaml) {
9
+ try {
10
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
11
+ const ptr0 = passStringToWasm0(yaml, wasm.__wbindgen_export, wasm.__wbindgen_export2);
12
+ const len0 = WASM_VECTOR_LEN;
13
+ wasm.compile_fafb(retptr, ptr0, len0);
14
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
15
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
16
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
17
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
18
+ if (r3) {
19
+ throw takeObject(r2);
20
+ }
21
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
22
+ wasm.__wbindgen_export3(r0, r1 * 1, 1);
23
+ return v2;
24
+ } finally {
25
+ wasm.__wbindgen_add_to_stack_pointer(16);
26
+ }
27
+ }
28
+ exports.compile_fafb = compile_fafb;
29
+
30
+ /**
31
+ * Decompile a FAFb binary to JSON (full content) — returns JSON string.
32
+ * @param {Uint8Array} bytes
33
+ * @returns {string}
34
+ */
35
+ function decompile_fafb(bytes) {
36
+ let deferred3_0;
37
+ let deferred3_1;
38
+ try {
39
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
40
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
41
+ const len0 = WASM_VECTOR_LEN;
42
+ wasm.decompile_fafb(retptr, ptr0, len0);
43
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
44
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
45
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
46
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
47
+ var ptr2 = r0;
48
+ var len2 = r1;
49
+ if (r3) {
50
+ ptr2 = 0; len2 = 0;
51
+ throw takeObject(r2);
52
+ }
53
+ deferred3_0 = ptr2;
54
+ deferred3_1 = len2;
55
+ return getStringFromWasm0(ptr2, len2);
56
+ } finally {
57
+ wasm.__wbindgen_add_to_stack_pointer(16);
58
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
59
+ }
60
+ }
61
+ exports.decompile_fafb = decompile_fafb;
62
+
63
+ /**
64
+ * Get FAFb file info (header + section metadata, no content) — returns JSON.
65
+ * @param {Uint8Array} bytes
66
+ * @returns {string}
67
+ */
68
+ function fafb_info(bytes) {
69
+ let deferred3_0;
70
+ let deferred3_1;
71
+ try {
72
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
73
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
74
+ const len0 = WASM_VECTOR_LEN;
75
+ wasm.fafb_info(retptr, ptr0, len0);
76
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
77
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
78
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
79
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
80
+ var ptr2 = r0;
81
+ var len2 = r1;
82
+ if (r3) {
83
+ ptr2 = 0; len2 = 0;
84
+ throw takeObject(r2);
85
+ }
86
+ deferred3_0 = ptr2;
87
+ deferred3_1 = len2;
88
+ return getStringFromWasm0(ptr2, len2);
89
+ } finally {
90
+ wasm.__wbindgen_add_to_stack_pointer(16);
91
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
92
+ }
93
+ }
94
+ exports.fafb_info = fafb_info;
95
+
96
+ /**
97
+ * Score FAF YAML content with the Mk4 kernel (always-33) — returns JSON.
98
+ *
99
+ * Always 33 slots. A 21-slot file carries the 12 enterprise slots as
100
+ * `slotignored`, so it scores the same here as in every other FAF app.
101
+ * @param {string} yaml
102
+ * @returns {string}
103
+ */
104
+ function score_faf(yaml) {
105
+ let deferred3_0;
106
+ let deferred3_1;
107
+ try {
108
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
109
+ const ptr0 = passStringToWasm0(yaml, wasm.__wbindgen_export, wasm.__wbindgen_export2);
110
+ const len0 = WASM_VECTOR_LEN;
111
+ wasm.score_faf(retptr, ptr0, len0);
112
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
113
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
114
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
115
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
116
+ var ptr2 = r0;
117
+ var len2 = r1;
118
+ if (r3) {
119
+ ptr2 = 0; len2 = 0;
120
+ throw takeObject(r2);
121
+ }
122
+ deferred3_0 = ptr2;
123
+ deferred3_1 = len2;
124
+ return getStringFromWasm0(ptr2, len2);
125
+ } finally {
126
+ wasm.__wbindgen_add_to_stack_pointer(16);
127
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
128
+ }
129
+ }
130
+ exports.score_faf = score_faf;
131
+
132
+ /**
133
+ * Same as [`score_faf`] (always-33). Kept so existing callers keep working.
134
+ * @param {string} yaml
135
+ * @returns {string}
136
+ */
137
+ function score_faf_enterprise(yaml) {
138
+ let deferred3_0;
139
+ let deferred3_1;
140
+ try {
141
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
142
+ const ptr0 = passStringToWasm0(yaml, wasm.__wbindgen_export, wasm.__wbindgen_export2);
143
+ const len0 = WASM_VECTOR_LEN;
144
+ wasm.score_faf_enterprise(retptr, ptr0, len0);
145
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
146
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
147
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
148
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
149
+ var ptr2 = r0;
150
+ var len2 = r1;
151
+ if (r3) {
152
+ ptr2 = 0; len2 = 0;
153
+ throw takeObject(r2);
154
+ }
155
+ deferred3_0 = ptr2;
156
+ deferred3_1 = len2;
157
+ return getStringFromWasm0(ptr2, len2);
158
+ } finally {
159
+ wasm.__wbindgen_add_to_stack_pointer(16);
160
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
161
+ }
162
+ }
163
+ exports.score_faf_enterprise = score_faf_enterprise;
164
+
165
+ /**
166
+ * Score a FAFb binary — returns JSON string (same shape as `score_faf`).
167
+ * @param {Uint8Array} bytes
168
+ * @returns {string}
169
+ */
170
+ function score_fafb(bytes) {
171
+ let deferred3_0;
172
+ let deferred3_1;
173
+ try {
174
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
175
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
176
+ const len0 = WASM_VECTOR_LEN;
177
+ wasm.score_fafb(retptr, ptr0, len0);
178
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
179
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
180
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
181
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
182
+ var ptr2 = r0;
183
+ var len2 = r1;
184
+ if (r3) {
185
+ ptr2 = 0; len2 = 0;
186
+ throw takeObject(r2);
187
+ }
188
+ deferred3_0 = ptr2;
189
+ deferred3_1 = len2;
190
+ return getStringFromWasm0(ptr2, len2);
191
+ } finally {
192
+ wasm.__wbindgen_add_to_stack_pointer(16);
193
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
194
+ }
195
+ }
196
+ exports.score_fafb = score_fafb;
197
+
198
+ /**
199
+ * Get SDK version.
200
+ * @returns {string}
201
+ */
202
+ function sdk_version() {
203
+ let deferred1_0;
204
+ let deferred1_1;
205
+ try {
206
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
207
+ wasm.sdk_version(retptr);
208
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
209
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
210
+ deferred1_0 = r0;
211
+ deferred1_1 = r1;
212
+ return getStringFromWasm0(r0, r1);
213
+ } finally {
214
+ wasm.__wbindgen_add_to_stack_pointer(16);
215
+ wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
216
+ }
217
+ }
218
+ exports.sdk_version = sdk_version;
219
+
220
+ /**
221
+ * Validate FAF YAML content — true if it parses as a YAML mapping.
222
+ * @param {string} yaml
223
+ * @returns {boolean}
224
+ */
225
+ function validate_faf(yaml) {
226
+ const ptr0 = passStringToWasm0(yaml, wasm.__wbindgen_export, wasm.__wbindgen_export2);
227
+ const len0 = WASM_VECTOR_LEN;
228
+ const ret = wasm.validate_faf(ptr0, len0);
229
+ return ret !== 0;
230
+ }
231
+ exports.validate_faf = validate_faf;
232
+ function __wbg_get_imports() {
233
+ const import0 = {
234
+ __proto__: null,
235
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
236
+ // Cast intrinsic for `Ref(String) -> Externref`.
237
+ const ret = getStringFromWasm0(arg0, arg1);
238
+ return addHeapObject(ret);
239
+ },
240
+ };
241
+ return {
242
+ __proto__: null,
243
+ "./faf_wasm_sdk_bg.js": import0,
244
+ };
245
+ }
246
+
247
+ function addHeapObject(obj) {
248
+ if (heap_next === heap.length) heap.push(heap.length + 1);
249
+ const idx = heap_next;
250
+ heap_next = heap[idx];
251
+
252
+ heap[idx] = obj;
253
+ return idx;
254
+ }
255
+
256
+ function dropObject(idx) {
257
+ if (idx < 1028) return;
258
+ heap[idx] = heap_next;
259
+ heap_next = idx;
260
+ }
261
+
262
+ function getArrayU8FromWasm0(ptr, len) {
263
+ ptr = ptr >>> 0;
264
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
265
+ }
266
+
267
+ let cachedDataViewMemory0 = null;
268
+ function getDataViewMemory0() {
269
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
270
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
271
+ }
272
+ return cachedDataViewMemory0;
273
+ }
274
+
275
+ function getStringFromWasm0(ptr, len) {
276
+ return decodeText(ptr >>> 0, len);
277
+ }
278
+
279
+ let cachedUint8ArrayMemory0 = null;
280
+ function getUint8ArrayMemory0() {
281
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
282
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
283
+ }
284
+ return cachedUint8ArrayMemory0;
285
+ }
286
+
287
+ function getObject(idx) { return heap[idx]; }
288
+
289
+ let heap = new Array(1024).fill(undefined);
290
+ heap.push(undefined, null, true, false);
291
+
292
+ let heap_next = heap.length;
293
+
294
+ function passArray8ToWasm0(arg, malloc) {
295
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
296
+ getUint8ArrayMemory0().set(arg, ptr / 1);
297
+ WASM_VECTOR_LEN = arg.length;
298
+ return ptr;
299
+ }
300
+
301
+ function passStringToWasm0(arg, malloc, realloc) {
302
+ if (realloc === undefined) {
303
+ const buf = cachedTextEncoder.encode(arg);
304
+ const ptr = malloc(buf.length, 1) >>> 0;
305
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
306
+ WASM_VECTOR_LEN = buf.length;
307
+ return ptr;
308
+ }
309
+
310
+ let len = arg.length;
311
+ let ptr = malloc(len, 1) >>> 0;
312
+
313
+ const mem = getUint8ArrayMemory0();
314
+
315
+ let offset = 0;
316
+
317
+ for (; offset < len; offset++) {
318
+ const code = arg.charCodeAt(offset);
319
+ if (code > 0x7F) break;
320
+ mem[ptr + offset] = code;
321
+ }
322
+ if (offset !== len) {
323
+ if (offset !== 0) {
324
+ arg = arg.slice(offset);
325
+ }
326
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
327
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
328
+ const ret = cachedTextEncoder.encodeInto(arg, view);
329
+
330
+ offset += ret.written;
331
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
332
+ }
333
+
334
+ WASM_VECTOR_LEN = offset;
335
+ return ptr;
336
+ }
337
+
338
+ function takeObject(idx) {
339
+ const ret = getObject(idx);
340
+ dropObject(idx);
341
+ return ret;
342
+ }
343
+
344
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
345
+ cachedTextDecoder.decode();
346
+ function decodeText(ptr, len) {
347
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
348
+ }
349
+
350
+ const cachedTextEncoder = new TextEncoder();
351
+
352
+ if (!('encodeInto' in cachedTextEncoder)) {
353
+ cachedTextEncoder.encodeInto = function (arg, view) {
354
+ const buf = cachedTextEncoder.encode(arg);
355
+ view.set(buf);
356
+ return {
357
+ read: arg.length,
358
+ written: buf.length
359
+ };
360
+ };
361
+ }
362
+
363
+ let WASM_VECTOR_LEN = 0;
364
+
365
+ const wasmPath = `${__dirname}/faf_wasm_sdk_bg.wasm`;
366
+ const wasmBytes = require('fs').readFileSync(wasmPath);
367
+ const wasmModule = new WebAssembly.Module(wasmBytes);
368
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
369
+ let wasm = wasmInstance.exports;