faf-scoring-kernel
Advanced tools
+1
-1
| { | ||
| "name": "faf-scoring-kernel", | ||
| "version": "2.0.0", | ||
| "version": "2.0.1", | ||
| "description": "FAF Mk4 Scoring Kernel — WASM-compiled Rust engine for scoring .faf files and compiling .fafb binaries. The Foundry.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
+58
-92
@@ -1,129 +0,95 @@ | ||
| # FAF WASM SDK | ||
| # faf-scoring-kernel | ||
| AI Context Format for Browsers and Edge Compute. Sub-10ms context loads globally. | ||
| FAF Mk4 Scoring Kernel — WASM-compiled Rust engine for scoring `.faf` files and compiling `.fafb` binaries. | ||
| ## Features | ||
| **The Foundry.** 281KB. 136 tests. In Rust We Trust. | ||
| - YAML parsing via serde_yaml (WASM-proven) | ||
| - Glass Hood AI-readiness scoring | ||
| - 8-tier rating system (🤍 to 🏆) | ||
| - Cloudflare Workers / Vercel Edge ready | ||
| - <2ms parse + score performance | ||
| ## Install | ||
| ## Installation | ||
| ```bash | ||
| npm install @faf/wasm-sdk | ||
| npm install faf-scoring-kernel | ||
| ``` | ||
| Works in Node.js and Bun. | ||
| ## Usage | ||
| ### Browser / Node.js | ||
| ```javascript | ||
| import { initialize, createFAF, scoreFAF } from '@faf/wasm-sdk'; | ||
| const kernel = require('faf-scoring-kernel'); | ||
| await initialize(); | ||
| const faf = createFAF(` | ||
| // Score a .faf file | ||
| const result = JSON.parse(kernel.score_faf(` | ||
| project: | ||
| name: my-project | ||
| stack: typescript | ||
| `); | ||
| goal: Ship fast | ||
| main_language: TypeScript | ||
| `)); | ||
| console.log(faf.weighted_score); // 45.0 | ||
| console.log(faf.tier); // 🟢 | ||
| console.log(result.score); // 14 | ||
| console.log(result.tier); // 🔴 | ||
| console.log(result.populated, '/', result.active); // 3 / 21 | ||
| ``` | ||
| ### Cloudflare Workers | ||
| ## API | ||
| ```javascript | ||
| import init, { FAF } from '@faf/wasm-sdk'; | ||
| 8 pure-function exports. No classes. No state. | ||
| export default { | ||
| async fetch(request) { | ||
| await init(); | ||
| const faf = new FAF(yamlContent); | ||
| return Response.json({ score: faf.weighted_score }); | ||
| } | ||
| }; | ||
| ``` | ||
| | Function | Input | Output | Description | | ||
| |----------|-------|--------|-------------| | ||
| | `sdk_version()` | — | `string` | Engine version | | ||
| | `score_faf(yaml)` | YAML string | JSON string | Mk4 base scoring (21 slots) | | ||
| | `score_faf_enterprise(yaml)` | YAML string | JSON string | Mk4 enterprise scoring (33 slots) | | ||
| | `validate_faf(yaml)` | YAML string | `boolean` | Check if valid YAML mapping | | ||
| | `compile_fafb(yaml)` | YAML string | `Uint8Array` | Compile .faf to .fafb binary | | ||
| | `decompile_fafb(bytes)` | `Uint8Array` | JSON string | Decompile .fafb to JSON | | ||
| | `score_fafb(bytes)` | `Uint8Array` | JSON string | Read score from .fafb binary | | ||
| | `fafb_info(bytes)` | `Uint8Array` | JSON string | Header/section metadata | | ||
| ## API | ||
| ## Tier System | ||
| ### FAF Class | ||
| | Score | Tier | Status | | ||
| |-------|------|--------| | ||
| | 100% | Trophy | Perfect | | ||
| | 95-99% | Gold | Exceptional | | ||
| | 85-94% | Silver | Top tier | | ||
| | 70-84% | Bronze | Production ready | | ||
| | 55-69% | Green | Solid foundation | | ||
| | 40-54% | Yellow | Needs improvement | | ||
| | <40% | Red | Major work needed | | ||
| | 0% | White | Empty | | ||
| - `new FAF(yamlContent)` - Parse and score FAF content | ||
| - `name` - Project name | ||
| - `stack` - Technology stack | ||
| - `weighted_score` - Weighted AI-readiness (0-100) | ||
| - `truth_score` - Unweighted average (0-100) | ||
| - `tier` - Tier emoji (🤍🔴🟡🟢🥉🥈🥇🏆) | ||
| - `completeness` - Core DNA score (40% weight) | ||
| - `clarity` - Instructions score (35% weight) | ||
| - `structure` - Context score (15% weight) | ||
| - `metadata` - Metadata score (10% weight) | ||
| ## Compile .fafb | ||
| ### Hot Path Functions | ||
| For maximum edge performance: | ||
| ```javascript | ||
| import { score_weights_fast, WEIGHTS_F32 } from '@faf/wasm-sdk'; | ||
| const kernel = require('faf-scoring-kernel'); | ||
| const values = new Float32Array([80, 70, 60, 50]); | ||
| const score = score_weights_fast(WEIGHTS_F32, values); | ||
| ``` | ||
| // Compile YAML to FAFb binary | ||
| const yaml = 'faf_version: "1.0"\nproject_name: my-project'; | ||
| const bytes = kernel.compile_fafb(yaml); | ||
| // bytes[0..4] === "FAFB" (magic bytes) | ||
| ## Build | ||
| // Decompile back | ||
| const json = kernel.decompile_fafb(bytes); | ||
| ```bash | ||
| # Install wasm-pack | ||
| cargo install wasm-pack | ||
| # Build WASM | ||
| wasm-pack build --target web --release | ||
| # Run tests | ||
| wasm-pack test --headless --chrome | ||
| // Read score from binary | ||
| const score = kernel.score_fafb(bytes); | ||
| ``` | ||
| ## Deploy to Cloudflare | ||
| ## What Is This? | ||
| ```bash | ||
| npm install -g wrangler | ||
| wrangler deploy | ||
| ``` | ||
| This is the universal FAF scoring and compilation engine, compiled from Rust to WebAssembly. It implements: | ||
| ## Scoring Algorithm | ||
| - **Mk4 Engine** — 33-slot scoring with placeholder rejection and tier calculation | ||
| - **FAFb Binary Format** — 32-byte header, CRC32 checksum, priority sections | ||
| Glass Hood - Full transparency scoring: | ||
| One binary. Same scores everywhere. The code is the spec. | ||
| | Category | Weight | Description | | ||
| |----------|--------|-------------| | ||
| | Completeness | 40% | Core project DNA fields | | ||
| | Clarity | 35% | AI instructions quality | | ||
| | Structure | 15% | Context organization | | ||
| | Metadata | 10% | Versioning and tags | | ||
| ## Links | ||
| ### Tier System | ||
| - [FAF Format](https://faf.one) | ||
| - [Source](https://github.com/Wolfe-Jam/faf-wasm-sdk) | ||
| - [IANA Registration](https://www.iana.org/assignments/media-types/application/vnd.faf+yaml) | ||
| | Score | Tier | Emoji | | ||
| |-------|------|-------| | ||
| | 0-12 | White | 🤍 | | ||
| | 13-25 | Red | 🔴 | | ||
| | 26-38 | Yellow | 🟡 | | ||
| | 39-51 | Green | 🟢 | | ||
| | 52-64 | Bronze | 🥉 | | ||
| | 65-77 | Silver | 🥈 | | ||
| | 78-90 | Gold | 🥇 | | ||
| | 91-100 | Championship | 🏆 | | ||
| ## License | ||
| MIT | ||
| ## Links | ||
| - [FAF Format](https://faf.one) | ||
| - [IANA Registration](https://www.iana.org/assignments/media-types/application/vnd.faf+yaml) |
301962
0.03%96
-26.15%