faf-cli 6.7.1 → 6.8.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 +41 -5
- package/dist/cli.js +206 -194
- package/dist/cli.js.map +17 -10
- package/dist/core/slots.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/core/slots.d.ts
CHANGED
|
@@ -28,8 +28,8 @@ export declare const ENTERPRISE_SLOTS: SlotDef[];
|
|
|
28
28
|
export declare const PLACEHOLDERS: Set<string>;
|
|
29
29
|
/** Check if a value is a placeholder (empty) */
|
|
30
30
|
export declare function isPlaceholder(value: unknown): boolean;
|
|
31
|
-
/** App-type to active category mapping. The canonical
|
|
32
|
-
*
|
|
31
|
+
/** App-type to active category mapping. The canonical 22-type ladder —
|
|
32
|
+
* 20 detectable apps + `about` (non-app, 0 slots, owner-attested)
|
|
33
33
|
* + `encyclopedia` (curated knowledge surface, FAFipedia and similar).
|
|
34
34
|
* (See v6.6.md doctrine memory + fafipedia-vs-grokipedia-architecture.)
|
|
35
35
|
* Sorted ascending by active slot count for readability.
|
package/dist/index.js.map
CHANGED
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"'use strict';\n\n/**\n * Tracks newlines during parsing in order to provide an efficient API for\n * determining the one-indexed `{ line, col }` position for any offset\n * within the input.\n */\nclass LineCounter {\n constructor() {\n this.lineStarts = [];\n /**\n * Should be called in ascending order. Otherwise, call\n * `lineCounter.lineStarts.sort()` before calling `linePos()`.\n */\n this.addNewLine = (offset) => this.lineStarts.push(offset);\n /**\n * Performs a binary search and returns the 1-indexed { line, col }\n * position of `offset`. If `line === 0`, `addNewLine` has never been\n * called or `offset` is before the first known newline.\n */\n this.linePos = (offset) => {\n let low = 0;\n let high = this.lineStarts.length;\n while (low < high) {\n const mid = (low + high) >> 1; // Math.floor((low + high) / 2)\n if (this.lineStarts[mid] < offset)\n low = mid + 1;\n else\n high = mid;\n }\n if (this.lineStarts[low] === offset)\n return { line: low + 1, col: 1 };\n if (low === 0)\n return { line: 0, col: offset };\n const start = this.lineStarts[low - 1];\n return { line: low, col: offset - start + 1 };\n };\n }\n}\n\nexports.LineCounter = LineCounter;\n",
|
|
74
74
|
"'use strict';\n\nvar node_process = require('process');\nvar cst = require('./cst.js');\nvar lexer = require('./lexer.js');\n\nfunction includesToken(list, type) {\n for (let i = 0; i < list.length; ++i)\n if (list[i].type === type)\n return true;\n return false;\n}\nfunction findNonEmptyIndex(list) {\n for (let i = 0; i < list.length; ++i) {\n switch (list[i].type) {\n case 'space':\n case 'comment':\n case 'newline':\n break;\n default:\n return i;\n }\n }\n return -1;\n}\nfunction isFlowToken(token) {\n switch (token?.type) {\n case 'alias':\n case 'scalar':\n case 'single-quoted-scalar':\n case 'double-quoted-scalar':\n case 'flow-collection':\n return true;\n default:\n return false;\n }\n}\nfunction getPrevProps(parent) {\n switch (parent.type) {\n case 'document':\n return parent.start;\n case 'block-map': {\n const it = parent.items[parent.items.length - 1];\n return it.sep ?? it.start;\n }\n case 'block-seq':\n return parent.items[parent.items.length - 1].start;\n /* istanbul ignore next should not happen */\n default:\n return [];\n }\n}\n/** Note: May modify input array */\nfunction getFirstKeyStartProps(prev) {\n if (prev.length === 0)\n return [];\n let i = prev.length;\n loop: while (--i >= 0) {\n switch (prev[i].type) {\n case 'doc-start':\n case 'explicit-key-ind':\n case 'map-value-ind':\n case 'seq-item-ind':\n case 'newline':\n break loop;\n }\n }\n while (prev[++i]?.type === 'space') {\n /* loop */\n }\n return prev.splice(i, prev.length);\n}\nfunction fixFlowSeqItems(fc) {\n if (fc.start.type === 'flow-seq-start') {\n for (const it of fc.items) {\n if (it.sep &&\n !it.value &&\n !includesToken(it.start, 'explicit-key-ind') &&\n !includesToken(it.sep, 'map-value-ind')) {\n if (it.key)\n it.value = it.key;\n delete it.key;\n if (isFlowToken(it.value)) {\n if (it.value.end)\n Array.prototype.push.apply(it.value.end, it.sep);\n else\n it.value.end = it.sep;\n }\n else\n Array.prototype.push.apply(it.start, it.sep);\n delete it.sep;\n }\n }\n }\n}\n/**\n * A YAML concrete syntax tree (CST) parser\n *\n * ```ts\n * const src: string = ...\n * for (const token of new Parser().parse(src)) {\n * // token: Token\n * }\n * ```\n *\n * To use the parser with a user-provided lexer:\n *\n * ```ts\n * function* parse(source: string, lexer: Lexer) {\n * const parser = new Parser()\n * for (const lexeme of lexer.lex(source))\n * yield* parser.next(lexeme)\n * yield* parser.end()\n * }\n *\n * const src: string = ...\n * const lexer = new Lexer()\n * for (const token of parse(src, lexer)) {\n * // token: Token\n * }\n * ```\n */\nclass Parser {\n /**\n * @param onNewLine - If defined, called separately with the start position of\n * each new line (in `parse()`, including the start of input).\n */\n constructor(onNewLine) {\n /** If true, space and sequence indicators count as indentation */\n this.atNewLine = true;\n /** If true, next token is a scalar value */\n this.atScalar = false;\n /** Current indentation level */\n this.indent = 0;\n /** Current offset since the start of parsing */\n this.offset = 0;\n /** On the same line with a block map key */\n this.onKeyLine = false;\n /** Top indicates the node that's currently being built */\n this.stack = [];\n /** The source of the current token, set in parse() */\n this.source = '';\n /** The type of the current token, set in parse() */\n this.type = '';\n // Must be defined after `next()`\n this.lexer = new lexer.Lexer();\n this.onNewLine = onNewLine;\n }\n /**\n * Parse `source` as a YAML stream.\n * If `incomplete`, a part of the last line may be left as a buffer for the next call.\n *\n * Errors are not thrown, but yielded as `{ type: 'error', message }` tokens.\n *\n * @returns A generator of tokens representing each directive, document, and other structure.\n */\n *parse(source, incomplete = false) {\n if (this.onNewLine && this.offset === 0)\n this.onNewLine(0);\n for (const lexeme of this.lexer.lex(source, incomplete))\n yield* this.next(lexeme);\n if (!incomplete)\n yield* this.end();\n }\n /**\n * Advance the parser by the `source` of one lexical token.\n */\n *next(source) {\n this.source = source;\n if (node_process.env.LOG_TOKENS)\n console.log('|', cst.prettyToken(source));\n if (this.atScalar) {\n this.atScalar = false;\n yield* this.step();\n this.offset += source.length;\n return;\n }\n const type = cst.tokenType(source);\n if (!type) {\n const message = `Not a YAML token: ${source}`;\n yield* this.pop({ type: 'error', offset: this.offset, message, source });\n this.offset += source.length;\n }\n else if (type === 'scalar') {\n this.atNewLine = false;\n this.atScalar = true;\n this.type = 'scalar';\n }\n else {\n this.type = type;\n yield* this.step();\n switch (type) {\n case 'newline':\n this.atNewLine = true;\n this.indent = 0;\n if (this.onNewLine)\n this.onNewLine(this.offset + source.length);\n break;\n case 'space':\n if (this.atNewLine && source[0] === ' ')\n this.indent += source.length;\n break;\n case 'explicit-key-ind':\n case 'map-value-ind':\n case 'seq-item-ind':\n if (this.atNewLine)\n this.indent += source.length;\n break;\n case 'doc-mode':\n case 'flow-error-end':\n return;\n default:\n this.atNewLine = false;\n }\n this.offset += source.length;\n }\n }\n /** Call at end of input to push out any remaining constructions */\n *end() {\n while (this.stack.length > 0)\n yield* this.pop();\n }\n get sourceToken() {\n const st = {\n type: this.type,\n offset: this.offset,\n indent: this.indent,\n source: this.source\n };\n return st;\n }\n *step() {\n const top = this.peek(1);\n if (this.type === 'doc-end' && top?.type !== 'doc-end') {\n while (this.stack.length > 0)\n yield* this.pop();\n this.stack.push({\n type: 'doc-end',\n offset: this.offset,\n source: this.source\n });\n return;\n }\n if (!top)\n return yield* this.stream();\n switch (top.type) {\n case 'document':\n return yield* this.document(top);\n case 'alias':\n case 'scalar':\n case 'single-quoted-scalar':\n case 'double-quoted-scalar':\n return yield* this.scalar(top);\n case 'block-scalar':\n return yield* this.blockScalar(top);\n case 'block-map':\n return yield* this.blockMap(top);\n case 'block-seq':\n return yield* this.blockSequence(top);\n case 'flow-collection':\n return yield* this.flowCollection(top);\n case 'doc-end':\n return yield* this.documentEnd(top);\n }\n /* istanbul ignore next should not happen */\n yield* this.pop();\n }\n peek(n) {\n return this.stack[this.stack.length - n];\n }\n *pop(error) {\n const token = error ?? this.stack.pop();\n /* istanbul ignore if should not happen */\n if (!token) {\n const message = 'Tried to pop an empty stack';\n yield { type: 'error', offset: this.offset, source: '', message };\n }\n else if (this.stack.length === 0) {\n yield token;\n }\n else {\n const top = this.peek(1);\n if (token.type === 'block-scalar') {\n // Block scalars use their parent rather than header indent\n token.indent = 'indent' in top ? top.indent : 0;\n }\n else if (token.type === 'flow-collection' && top.type === 'document') {\n // Ignore all indent for top-level flow collections\n token.indent = 0;\n }\n if (token.type === 'flow-collection')\n fixFlowSeqItems(token);\n switch (top.type) {\n case 'document':\n top.value = token;\n break;\n case 'block-scalar':\n top.props.push(token); // error\n break;\n case 'block-map': {\n const it = top.items[top.items.length - 1];\n if (it.value) {\n top.items.push({ start: [], key: token, sep: [] });\n this.onKeyLine = true;\n return;\n }\n else if (it.sep) {\n it.value = token;\n }\n else {\n Object.assign(it, { key: token, sep: [] });\n this.onKeyLine = !it.explicitKey;\n return;\n }\n break;\n }\n case 'block-seq': {\n const it = top.items[top.items.length - 1];\n if (it.value)\n top.items.push({ start: [], value: token });\n else\n it.value = token;\n break;\n }\n case 'flow-collection': {\n const it = top.items[top.items.length - 1];\n if (!it || it.value)\n top.items.push({ start: [], key: token, sep: [] });\n else if (it.sep)\n it.value = token;\n else\n Object.assign(it, { key: token, sep: [] });\n return;\n }\n /* istanbul ignore next should not happen */\n default:\n yield* this.pop();\n yield* this.pop(token);\n }\n if ((top.type === 'document' ||\n top.type === 'block-map' ||\n top.type === 'block-seq') &&\n (token.type === 'block-map' || token.type === 'block-seq')) {\n const last = token.items[token.items.length - 1];\n if (last &&\n !last.sep &&\n !last.value &&\n last.start.length > 0 &&\n findNonEmptyIndex(last.start) === -1 &&\n (token.indent === 0 ||\n last.start.every(st => st.type !== 'comment' || st.indent < token.indent))) {\n if (top.type === 'document')\n top.end = last.start;\n else\n top.items.push({ start: last.start });\n token.items.splice(-1, 1);\n }\n }\n }\n }\n *stream() {\n switch (this.type) {\n case 'directive-line':\n yield { type: 'directive', offset: this.offset, source: this.source };\n return;\n case 'byte-order-mark':\n case 'space':\n case 'comment':\n case 'newline':\n yield this.sourceToken;\n return;\n case 'doc-mode':\n case 'doc-start': {\n const doc = {\n type: 'document',\n offset: this.offset,\n start: []\n };\n if (this.type === 'doc-start')\n doc.start.push(this.sourceToken);\n this.stack.push(doc);\n return;\n }\n }\n yield {\n type: 'error',\n offset: this.offset,\n message: `Unexpected ${this.type} token in YAML stream`,\n source: this.source\n };\n }\n *document(doc) {\n if (doc.value)\n return yield* this.lineEnd(doc);\n switch (this.type) {\n case 'doc-start': {\n if (findNonEmptyIndex(doc.start) !== -1) {\n yield* this.pop();\n yield* this.step();\n }\n else\n doc.start.push(this.sourceToken);\n return;\n }\n case 'anchor':\n case 'tag':\n case 'space':\n case 'comment':\n case 'newline':\n doc.start.push(this.sourceToken);\n return;\n }\n const bv = this.startBlockValue(doc);\n if (bv)\n this.stack.push(bv);\n else {\n yield {\n type: 'error',\n offset: this.offset,\n message: `Unexpected ${this.type} token in YAML document`,\n source: this.source\n };\n }\n }\n *scalar(scalar) {\n if (this.type === 'map-value-ind') {\n const prev = getPrevProps(this.peek(2));\n const start = getFirstKeyStartProps(prev);\n let sep;\n if (scalar.end) {\n sep = scalar.end;\n sep.push(this.sourceToken);\n delete scalar.end;\n }\n else\n sep = [this.sourceToken];\n const map = {\n type: 'block-map',\n offset: scalar.offset,\n indent: scalar.indent,\n items: [{ start, key: scalar, sep }]\n };\n this.onKeyLine = true;\n this.stack[this.stack.length - 1] = map;\n }\n else\n yield* this.lineEnd(scalar);\n }\n *blockScalar(scalar) {\n switch (this.type) {\n case 'space':\n case 'comment':\n case 'newline':\n scalar.props.push(this.sourceToken);\n return;\n case 'scalar':\n scalar.source = this.source;\n // block-scalar source includes trailing newline\n this.atNewLine = true;\n this.indent = 0;\n if (this.onNewLine) {\n let nl = this.source.indexOf('\\n') + 1;\n while (nl !== 0) {\n this.onNewLine(this.offset + nl);\n nl = this.source.indexOf('\\n', nl) + 1;\n }\n }\n yield* this.pop();\n break;\n /* istanbul ignore next should not happen */\n default:\n yield* this.pop();\n yield* this.step();\n }\n }\n *blockMap(map) {\n const it = map.items[map.items.length - 1];\n // it.sep is true-ish if pair already has key or : separator\n switch (this.type) {\n case 'newline':\n this.onKeyLine = false;\n if (it.value) {\n const end = 'end' in it.value ? it.value.end : undefined;\n const last = Array.isArray(end) ? end[end.length - 1] : undefined;\n if (last?.type === 'comment')\n end?.push(this.sourceToken);\n else\n map.items.push({ start: [this.sourceToken] });\n }\n else if (it.sep) {\n it.sep.push(this.sourceToken);\n }\n else {\n it.start.push(this.sourceToken);\n }\n return;\n case 'space':\n case 'comment':\n if (it.value) {\n map.items.push({ start: [this.sourceToken] });\n }\n else if (it.sep) {\n it.sep.push(this.sourceToken);\n }\n else {\n if (this.atIndentedComment(it.start, map.indent)) {\n const prev = map.items[map.items.length - 2];\n const end = prev?.value?.end;\n if (Array.isArray(end)) {\n Array.prototype.push.apply(end, it.start);\n end.push(this.sourceToken);\n map.items.pop();\n return;\n }\n }\n it.start.push(this.sourceToken);\n }\n return;\n }\n if (this.indent >= map.indent) {\n const atMapIndent = !this.onKeyLine && this.indent === map.indent;\n const atNextItem = atMapIndent &&\n (it.sep || it.explicitKey) &&\n this.type !== 'seq-item-ind';\n // For empty nodes, assign newline-separated not indented empty tokens to following node\n let start = [];\n if (atNextItem && it.sep && !it.value) {\n const nl = [];\n for (let i = 0; i < it.sep.length; ++i) {\n const st = it.sep[i];\n switch (st.type) {\n case 'newline':\n nl.push(i);\n break;\n case 'space':\n break;\n case 'comment':\n if (st.indent > map.indent)\n nl.length = 0;\n break;\n default:\n nl.length = 0;\n }\n }\n if (nl.length >= 2)\n start = it.sep.splice(nl[1]);\n }\n switch (this.type) {\n case 'anchor':\n case 'tag':\n if (atNextItem || it.value) {\n start.push(this.sourceToken);\n map.items.push({ start });\n this.onKeyLine = true;\n }\n else if (it.sep) {\n it.sep.push(this.sourceToken);\n }\n else {\n it.start.push(this.sourceToken);\n }\n return;\n case 'explicit-key-ind':\n if (!it.sep && !it.explicitKey) {\n it.start.push(this.sourceToken);\n it.explicitKey = true;\n }\n else if (atNextItem || it.value) {\n start.push(this.sourceToken);\n map.items.push({ start, explicitKey: true });\n }\n else {\n this.stack.push({\n type: 'block-map',\n offset: this.offset,\n indent: this.indent,\n items: [{ start: [this.sourceToken], explicitKey: true }]\n });\n }\n this.onKeyLine = true;\n return;\n case 'map-value-ind':\n if (it.explicitKey) {\n if (!it.sep) {\n if (includesToken(it.start, 'newline')) {\n Object.assign(it, { key: null, sep: [this.sourceToken] });\n }\n else {\n const start = getFirstKeyStartProps(it.start);\n this.stack.push({\n type: 'block-map',\n offset: this.offset,\n indent: this.indent,\n items: [{ start, key: null, sep: [this.sourceToken] }]\n });\n }\n }\n else if (it.value) {\n map.items.push({ start: [], key: null, sep: [this.sourceToken] });\n }\n else if (includesToken(it.sep, 'map-value-ind')) {\n this.stack.push({\n type: 'block-map',\n offset: this.offset,\n indent: this.indent,\n items: [{ start, key: null, sep: [this.sourceToken] }]\n });\n }\n else if (isFlowToken(it.key) &&\n !includesToken(it.sep, 'newline')) {\n const start = getFirstKeyStartProps(it.start);\n const key = it.key;\n const sep = it.sep;\n sep.push(this.sourceToken);\n // @ts-expect-error type guard is wrong here\n delete it.key;\n // @ts-expect-error type guard is wrong here\n delete it.sep;\n this.stack.push({\n type: 'block-map',\n offset: this.offset,\n indent: this.indent,\n items: [{ start, key, sep }]\n });\n }\n else if (start.length > 0) {\n // Not actually at next item\n it.sep = it.sep.concat(start, this.sourceToken);\n }\n else {\n it.sep.push(this.sourceToken);\n }\n }\n else {\n if (!it.sep) {\n Object.assign(it, { key: null, sep: [this.sourceToken] });\n }\n else if (it.value || atNextItem) {\n map.items.push({ start, key: null, sep: [this.sourceToken] });\n }\n else if (includesToken(it.sep, 'map-value-ind')) {\n this.stack.push({\n type: 'block-map',\n offset: this.offset,\n indent: this.indent,\n items: [{ start: [], key: null, sep: [this.sourceToken] }]\n });\n }\n else {\n it.sep.push(this.sourceToken);\n }\n }\n this.onKeyLine = true;\n return;\n case 'alias':\n case 'scalar':\n case 'single-quoted-scalar':\n case 'double-quoted-scalar': {\n const fs = this.flowScalar(this.type);\n if (atNextItem || it.value) {\n map.items.push({ start, key: fs, sep: [] });\n this.onKeyLine = true;\n }\n else if (it.sep) {\n this.stack.push(fs);\n }\n else {\n Object.assign(it, { key: fs, sep: [] });\n this.onKeyLine = true;\n }\n return;\n }\n default: {\n const bv = this.startBlockValue(map);\n if (bv) {\n if (bv.type === 'block-seq') {\n if (!it.explicitKey &&\n it.sep &&\n !includesToken(it.sep, 'newline')) {\n yield* this.pop({\n type: 'error',\n offset: this.offset,\n message: 'Unexpected block-seq-ind on same line with key',\n source: this.source\n });\n return;\n }\n }\n else if (atMapIndent) {\n map.items.push({ start });\n }\n this.stack.push(bv);\n return;\n }\n }\n }\n }\n yield* this.pop();\n yield* this.step();\n }\n *blockSequence(seq) {\n const it = seq.items[seq.items.length - 1];\n switch (this.type) {\n case 'newline':\n if (it.value) {\n const end = 'end' in it.value ? it.value.end : undefined;\n const last = Array.isArray(end) ? end[end.length - 1] : undefined;\n if (last?.type === 'comment')\n end?.push(this.sourceToken);\n else\n seq.items.push({ start: [this.sourceToken] });\n }\n else\n it.start.push(this.sourceToken);\n return;\n case 'space':\n case 'comment':\n if (it.value)\n seq.items.push({ start: [this.sourceToken] });\n else {\n if (this.atIndentedComment(it.start, seq.indent)) {\n const prev = seq.items[seq.items.length - 2];\n const end = prev?.value?.end;\n if (Array.isArray(end)) {\n Array.prototype.push.apply(end, it.start);\n end.push(this.sourceToken);\n seq.items.pop();\n return;\n }\n }\n it.start.push(this.sourceToken);\n }\n return;\n case 'anchor':\n case 'tag':\n if (it.value || this.indent <= seq.indent)\n break;\n it.start.push(this.sourceToken);\n return;\n case 'seq-item-ind':\n if (this.indent !== seq.indent)\n break;\n if (it.value || includesToken(it.start, 'seq-item-ind'))\n seq.items.push({ start: [this.sourceToken] });\n else\n it.start.push(this.sourceToken);\n return;\n }\n if (this.indent > seq.indent) {\n const bv = this.startBlockValue(seq);\n if (bv) {\n this.stack.push(bv);\n return;\n }\n }\n yield* this.pop();\n yield* this.step();\n }\n *flowCollection(fc) {\n const it = fc.items[fc.items.length - 1];\n if (this.type === 'flow-error-end') {\n let top;\n do {\n yield* this.pop();\n top = this.peek(1);\n } while (top?.type === 'flow-collection');\n }\n else if (fc.end.length === 0) {\n switch (this.type) {\n case 'comma':\n case 'explicit-key-ind':\n if (!it || it.sep)\n fc.items.push({ start: [this.sourceToken] });\n else\n it.start.push(this.sourceToken);\n return;\n case 'map-value-ind':\n if (!it || it.value)\n fc.items.push({ start: [], key: null, sep: [this.sourceToken] });\n else if (it.sep)\n it.sep.push(this.sourceToken);\n else\n Object.assign(it, { key: null, sep: [this.sourceToken] });\n return;\n case 'space':\n case 'comment':\n case 'newline':\n case 'anchor':\n case 'tag':\n if (!it || it.value)\n fc.items.push({ start: [this.sourceToken] });\n else if (it.sep)\n it.sep.push(this.sourceToken);\n else\n it.start.push(this.sourceToken);\n return;\n case 'alias':\n case 'scalar':\n case 'single-quoted-scalar':\n case 'double-quoted-scalar': {\n const fs = this.flowScalar(this.type);\n if (!it || it.value)\n fc.items.push({ start: [], key: fs, sep: [] });\n else if (it.sep)\n this.stack.push(fs);\n else\n Object.assign(it, { key: fs, sep: [] });\n return;\n }\n case 'flow-map-end':\n case 'flow-seq-end':\n fc.end.push(this.sourceToken);\n return;\n }\n const bv = this.startBlockValue(fc);\n /* istanbul ignore else should not happen */\n if (bv)\n this.stack.push(bv);\n else {\n yield* this.pop();\n yield* this.step();\n }\n }\n else {\n const parent = this.peek(2);\n if (parent.type === 'block-map' &&\n ((this.type === 'map-value-ind' && parent.indent === fc.indent) ||\n (this.type === 'newline' &&\n !parent.items[parent.items.length - 1].sep))) {\n yield* this.pop();\n yield* this.step();\n }\n else if (this.type === 'map-value-ind' &&\n parent.type !== 'flow-collection') {\n const prev = getPrevProps(parent);\n const start = getFirstKeyStartProps(prev);\n fixFlowSeqItems(fc);\n const sep = fc.end.splice(1, fc.end.length);\n sep.push(this.sourceToken);\n const map = {\n type: 'block-map',\n offset: fc.offset,\n indent: fc.indent,\n items: [{ start, key: fc, sep }]\n };\n this.onKeyLine = true;\n this.stack[this.stack.length - 1] = map;\n }\n else {\n yield* this.lineEnd(fc);\n }\n }\n }\n flowScalar(type) {\n if (this.onNewLine) {\n let nl = this.source.indexOf('\\n') + 1;\n while (nl !== 0) {\n this.onNewLine(this.offset + nl);\n nl = this.source.indexOf('\\n', nl) + 1;\n }\n }\n return {\n type,\n offset: this.offset,\n indent: this.indent,\n source: this.source\n };\n }\n startBlockValue(parent) {\n switch (this.type) {\n case 'alias':\n case 'scalar':\n case 'single-quoted-scalar':\n case 'double-quoted-scalar':\n return this.flowScalar(this.type);\n case 'block-scalar-header':\n return {\n type: 'block-scalar',\n offset: this.offset,\n indent: this.indent,\n props: [this.sourceToken],\n source: ''\n };\n case 'flow-map-start':\n case 'flow-seq-start':\n return {\n type: 'flow-collection',\n offset: this.offset,\n indent: this.indent,\n start: this.sourceToken,\n items: [],\n end: []\n };\n case 'seq-item-ind':\n return {\n type: 'block-seq',\n offset: this.offset,\n indent: this.indent,\n items: [{ start: [this.sourceToken] }]\n };\n case 'explicit-key-ind': {\n this.onKeyLine = true;\n const prev = getPrevProps(parent);\n const start = getFirstKeyStartProps(prev);\n start.push(this.sourceToken);\n return {\n type: 'block-map',\n offset: this.offset,\n indent: this.indent,\n items: [{ start, explicitKey: true }]\n };\n }\n case 'map-value-ind': {\n this.onKeyLine = true;\n const prev = getPrevProps(parent);\n const start = getFirstKeyStartProps(prev);\n return {\n type: 'block-map',\n offset: this.offset,\n indent: this.indent,\n items: [{ start, key: null, sep: [this.sourceToken] }]\n };\n }\n }\n return null;\n }\n atIndentedComment(start, indent) {\n if (this.type !== 'comment')\n return false;\n if (this.indent <= indent)\n return false;\n return start.every(st => st.type === 'newline' || st.type === 'space');\n }\n *documentEnd(docEnd) {\n if (this.type !== 'doc-mode') {\n if (docEnd.end)\n docEnd.end.push(this.sourceToken);\n else\n docEnd.end = [this.sourceToken];\n if (this.type === 'newline')\n yield* this.pop();\n }\n }\n *lineEnd(token) {\n switch (this.type) {\n case 'comma':\n case 'doc-start':\n case 'doc-end':\n case 'flow-seq-end':\n case 'flow-map-end':\n case 'map-value-ind':\n yield* this.pop();\n yield* this.step();\n break;\n case 'newline':\n this.onKeyLine = false;\n // fallthrough\n case 'space':\n case 'comment':\n default:\n // all other values are errors\n if (token.end)\n token.end.push(this.sourceToken);\n else\n token.end = [this.sourceToken];\n if (this.type === 'newline')\n yield* this.pop();\n }\n }\n}\n\nexports.Parser = Parser;\n",
|
|
75
75
|
"'use strict';\n\nvar composer = require('./compose/composer.js');\nvar Document = require('./doc/Document.js');\nvar errors = require('./errors.js');\nvar log = require('./log.js');\nvar identity = require('./nodes/identity.js');\nvar lineCounter = require('./parse/line-counter.js');\nvar parser = require('./parse/parser.js');\n\nfunction parseOptions(options) {\n const prettyErrors = options.prettyErrors !== false;\n const lineCounter$1 = options.lineCounter || (prettyErrors && new lineCounter.LineCounter()) || null;\n return { lineCounter: lineCounter$1, prettyErrors };\n}\n/**\n * Parse the input as a stream of YAML documents.\n *\n * Documents should be separated from each other by `...` or `---` marker lines.\n *\n * @returns If an empty `docs` array is returned, it will be of type\n * EmptyStream and contain additional stream information. In\n * TypeScript, you should use `'empty' in docs` as a type guard for it.\n */\nfunction parseAllDocuments(source, options = {}) {\n const { lineCounter, prettyErrors } = parseOptions(options);\n const parser$1 = new parser.Parser(lineCounter?.addNewLine);\n const composer$1 = new composer.Composer(options);\n const docs = Array.from(composer$1.compose(parser$1.parse(source)));\n if (prettyErrors && lineCounter)\n for (const doc of docs) {\n doc.errors.forEach(errors.prettifyError(source, lineCounter));\n doc.warnings.forEach(errors.prettifyError(source, lineCounter));\n }\n if (docs.length > 0)\n return docs;\n return Object.assign([], { empty: true }, composer$1.streamInfo());\n}\n/** Parse an input string into a single YAML.Document */\nfunction parseDocument(source, options = {}) {\n const { lineCounter, prettyErrors } = parseOptions(options);\n const parser$1 = new parser.Parser(lineCounter?.addNewLine);\n const composer$1 = new composer.Composer(options);\n // `doc` is always set by compose.end(true) at the very latest\n let doc = null;\n for (const _doc of composer$1.compose(parser$1.parse(source), true, source.length)) {\n if (!doc)\n doc = _doc;\n else if (doc.options.logLevel !== 'silent') {\n doc.errors.push(new errors.YAMLParseError(_doc.range.slice(0, 2), 'MULTIPLE_DOCS', 'Source contains multiple documents; please use YAML.parseAllDocuments()'));\n break;\n }\n }\n if (prettyErrors && lineCounter) {\n doc.errors.forEach(errors.prettifyError(source, lineCounter));\n doc.warnings.forEach(errors.prettifyError(source, lineCounter));\n }\n return doc;\n}\nfunction parse(src, reviver, options) {\n let _reviver = undefined;\n if (typeof reviver === 'function') {\n _reviver = reviver;\n }\n else if (options === undefined && reviver && typeof reviver === 'object') {\n options = reviver;\n }\n const doc = parseDocument(src, options);\n if (!doc)\n return null;\n doc.warnings.forEach(warning => log.warn(doc.options.logLevel, warning));\n if (doc.errors.length > 0) {\n if (doc.options.logLevel !== 'silent')\n throw doc.errors[0];\n else\n doc.errors = [];\n }\n return doc.toJS(Object.assign({ reviver: _reviver }, options));\n}\nfunction stringify(value, replacer, options) {\n let _replacer = null;\n if (typeof replacer === 'function' || Array.isArray(replacer)) {\n _replacer = replacer;\n }\n else if (options === undefined && replacer) {\n options = replacer;\n }\n if (typeof options === 'string')\n options = options.length;\n if (typeof options === 'number') {\n const indent = Math.round(options);\n options = indent < 1 ? undefined : indent > 8 ? { indent: 8 } : { indent };\n }\n if (value === undefined) {\n const { keepUndefined } = options ?? replacer ?? {};\n if (!keepUndefined)\n return undefined;\n }\n if (identity.isDocument(value) && !_replacer)\n return value.toString(options);\n return new Document.Document(value, _replacer, options).toString(options);\n}\n\nexports.parse = parse;\nexports.parseAllDocuments = parseAllDocuments;\nexports.parseDocument = parseDocument;\nexports.stringify = stringify;\n",
|
|
76
|
-
"import type { SlotDef, SlotCategory } from './types.js';\n\n/** All 33 Mk4 canonical slots */\nexport const SLOTS: SlotDef[] = [\n // Project Meta (3)\n { index: 1, path: 'project.name', description: 'Project name', category: 'project' },\n { index: 2, path: 'project.goal', description: 'Goal (use case)', category: 'project' },\n { index: 3, path: 'project.main_language', description: 'Primary language', category: 'project' },\n\n // Human Context (6)\n { index: 4, path: 'human_context.who', description: 'Who is this for?', category: 'human' },\n { index: 5, path: 'human_context.what', description: 'What are they building', category: 'human' },\n { index: 6, path: 'human_context.why', description: 'Why does it exist', category: 'human' },\n { index: 7, path: 'human_context.where', description: 'Where does it run', category: 'human' },\n { index: 8, path: 'human_context.when', description: 'When was it started / timeline', category: 'human' },\n { index: 9, path: 'human_context.how', description: 'How is it built', category: 'human' },\n\n // Frontend Stack (4)\n { index: 10, path: 'stack.frontend', canonical: 'stack.framework', description: 'Framework (React, Svelte, etc.)', category: 'frontend' },\n { index: 11, path: 'stack.css_framework', canonical: 'stack.css', description: 'CSS framework', category: 'frontend' },\n { index: 12, path: 'stack.ui_library', description: 'UI component library', category: 'frontend' },\n { index: 13, path: 'stack.state_management', canonical: 'stack.state', description: 'State management', category: 'frontend' },\n\n // Backend Stack (5)\n { index: 14, path: 'stack.backend', description: 'Backend framework', category: 'backend' },\n { index: 15, path: 'stack.api_type', canonical: 'stack.api', description: 'API style (REST, GraphQL, etc.)', category: 'backend' },\n { index: 16, path: 'stack.runtime', description: 'Runtime (Node, Bun, Python, etc.)', category: 'backend' },\n { index: 17, path: 'stack.database', canonical: 'stack.db', description: 'Database', category: 'backend' },\n { index: 18, path: 'stack.connection', description: 'Connection method (Prisma, etc.)', category: 'backend' },\n\n // Universal Stack (3)\n { index: 19, path: 'stack.hosting', description: 'Hosting platform', category: 'universal' },\n { index: 20, path: 'stack.build', description: 'Build tool', category: 'universal' },\n { index: 21, path: 'stack.cicd', description: 'CI/CD', category: 'universal' },\n\n // Enterprise Infra (5)\n { index: 22, path: 'stack.monorepo_tool', description: 'Monorepo tool', category: 'enterprise_infra' },\n { index: 23, path: 'stack.package_manager', canonical: 'stack.pkg_manager', description: 'Package manager', category: 'enterprise_infra' },\n { index: 24, path: 'stack.workspaces', description: 'Workspace configuration', category: 'enterprise_infra' },\n { index: 25, path: 'monorepo.packages_count', description: 'Number of packages', category: 'enterprise_infra' },\n { index: 26, path: 'monorepo.build_orchestrator', description: 'Build orchestration tool', category: 'enterprise_infra' },\n\n // Enterprise App (4)\n { index: 27, path: 'stack.admin', description: 'Admin panel', category: 'enterprise_app' },\n { index: 28, path: 'stack.cache', description: 'Caching layer', category: 'enterprise_app' },\n { index: 29, path: 'stack.search', description: 'Search engine', category: 'enterprise_app' },\n { index: 30, path: 'stack.storage', description: 'Object storage', category: 'enterprise_app' },\n\n // Enterprise Ops (3)\n { index: 31, path: 'monorepo.versioning_strategy', description: 'Version strategy', category: 'enterprise_ops' },\n { index: 32, path: 'monorepo.shared_configs', description: 'Shared configs', category: 'enterprise_ops' },\n { index: 33, path: 'monorepo.remote_cache', description: 'Remote build cache', category: 'enterprise_ops' },\n];\n\n/** Slot lookup by path — dual-keyed (current on-wire `path` AND Mk4 `canonical`\n * where defined) so callers can look up by either name. See issue #66. */\nexport const SLOT_BY_PATH = new Map<string, SlotDef>(\n SLOTS.flatMap(s => s.canonical ? [[s.path, s], [s.canonical, s]] : [[s.path, s]])\n);\n\n/** Mk4 canonical → current on-wire path. Used by read helpers to resolve\n * a canonical name back to the path that read/write/kernel actually uses\n * today. Empty for slots whose path is already canonical. */\nexport const CANONICAL_TO_CURRENT: ReadonlyMap<string, string> = new Map(\n SLOTS.filter(s => s.canonical).map(s => [s.canonical as string, s.path])\n);\n\n/** Current on-wire path → Mk4 canonical. Used by display helpers when the\n * UI wants to surface the forward-spec name. */\nexport const CURRENT_TO_CANONICAL: ReadonlyMap<string, string> = new Map(\n SLOTS.filter(s => s.canonical).map(s => [s.path, s.canonical as string])\n);\n\n/** Resolve any path (legacy or canonical) to the slot definition. */\nexport function getSlotByAnyPath(path: string): SlotDef | undefined {\n return SLOT_BY_PATH.get(path);\n}\n\n/** Read a value from a .faf data object, checking both the slot's current\n * `path` and its Mk4 `canonical` (if defined). Returns the first non-undefined\n * value. Lets the cli read .faf files that contain either legacy or canonical\n * keys without forcing a migration. */\nexport function readSlotValue(\n data: Record<string, unknown>,\n slot: SlotDef\n): unknown {\n const tryPath = (p: string): unknown => {\n const parts = p.split('.');\n let cur: unknown = data;\n for (const part of parts) {\n if (cur && typeof cur === 'object' && part in (cur as Record<string, unknown>)) {\n cur = (cur as Record<string, unknown>)[part];\n } else {\n return undefined;\n }\n }\n return cur;\n };\n const primary = tryPath(slot.path);\n if (primary !== undefined) return primary;\n if (slot.canonical) return tryPath(slot.canonical);\n return undefined;\n}\n\n/** Slots grouped by category */\nexport function slotsByCategory(category: SlotCategory): SlotDef[] {\n return SLOTS.filter(s => s.category === category);\n}\n\n/** Base-tier slots (1-21) — used by score_faf */\nexport const BASE_SLOTS = SLOTS.filter(s => s.index <= 21);\n\n/** Enterprise-tier slots (1-33) — used by score_faf_enterprise */\nexport const ENTERPRISE_SLOTS = SLOTS;\n\n/** Placeholder values treated as Empty */\nexport const PLACEHOLDERS = new Set([\n 'describe your project goal',\n 'development teams',\n 'cloud platform',\n 'null',\n 'none',\n 'unknown',\n 'n/a',\n 'not applicable',\n]);\n\n/** Check if a value is a placeholder (empty) */\nexport function isPlaceholder(value: unknown): boolean {\n if (value === null || value === undefined || value === '') return true;\n if (typeof value === 'string') {\n return PLACEHOLDERS.has(value.toLowerCase().trim());\n }\n if (Array.isArray(value) && value.length === 0) return true;\n if (typeof value === 'object' && Object.keys(value as object).length === 0) return true;\n return false;\n}\n\n/** App-type to active category mapping. The canonical 21-type ladder —\n * 19 detectable apps + `about` (non-app, 0 slots, owner-attested)\n * + `encyclopedia` (curated knowledge surface, FAFipedia and similar).\n * (See v6.6.md doctrine memory + fafipedia-vs-grokipedia-architecture.)\n * Sorted ascending by active slot count for readability.\n *\n * v6.5.0 changes vs prior:\n * - Added `universal` to cli / library / mcp / frontend / data-science.\n * These types ship/build/CI somewhere — slotignoring those slots was\n * losing real signal. (cli/library: 9→12; mcp/data-science: 14→17;\n * frontend: 13→16.)\n * - Order is by ascending slot count, not insertion order.\n */\nexport const APP_TYPE_CATEGORIES: Record<string, SlotCategory[]> = {\n // 0 slots — non-app representation surface. Score is INHERITED, not calculated.\n // About Repos are public faces of private codebases (private source / public\n // about pattern, same shape as Anthropic's claude-code repo). They display\n // the source's Trophy badge; they don't earn one. Required: about.represents\n // (Wolfe-Jam/<source>). Optional: about.source_score (number). Scorer\n // short-circuits when app_type === 'about' — see scorer.ts.\n // Doctrine: memory/private-source-public-about-pattern.md.\n about: [],\n\n // 9 slots — minimal (project meta + human only)\n documentation: ['project', 'human'],\n // encyclopedia: same shape as documentation — content repo with project\n // metadata + human context. Used by FAFipedia and similar curated-knowledge\n // surfaces. Per fafipedia-vs-grokipedia-architecture doctrine, this is the\n // structured, git-versioned, agent-consumable knowledge layer. Each .fafi\n // file under an encyclopedia repo is itself a valid .faf (inclusion marker).\n encyclopedia: ['project', 'human'],\n\n // 12 slots — project + human + universal (build/ci/hosting matters)\n cli: ['project', 'human', 'universal'],\n library: ['project', 'human', 'universal'],\n sdk: ['project', 'human', 'universal'],\n wasm: ['project', 'human', 'universal'],\n html: ['project', 'human', 'universal'],\n\n // 16 slots — project + frontend + human + universal\n frontend: ['project', 'frontend', 'human', 'universal'],\n website: ['project', 'frontend', 'human', 'universal'],\n mobile: ['project', 'frontend', 'human', 'universal'],\n\n // 17 slots — project + backend + universal + human\n mcp: ['project', 'backend', 'human', 'universal'],\n backend: ['project', 'backend', 'universal', 'human'],\n 'data-science': ['project', 'backend', 'human', 'universal'],\n\n // 21 slots — full base ladder\n fullstack: ['project', 'frontend', 'backend', 'universal', 'human'],\n svelte: ['project', 'frontend', 'backend', 'universal', 'human'],\n framework: ['project', 'frontend', 'backend', 'universal', 'human'],\n 'monorepo-root': ['project', 'human', 'enterprise_infra', 'enterprise_app', 'enterprise_ops'],\n\n // 24-25 slots — platform / SaaS shapes (base + selected enterprise)\n mcpaas: ['project', 'backend', 'universal', 'human', 'enterprise_app', 'enterprise_ops'],\n saas: ['project', 'frontend', 'backend', 'universal', 'human', 'enterprise_app'],\n\n // 33 slots — full enterprise\n enterprise: ['project', 'frontend', 'backend', 'universal', 'human', 'enterprise_infra', 'enterprise_app', 'enterprise_ops'],\n};\n",
|
|
76
|
+
"import type { SlotDef, SlotCategory } from './types.js';\n\n/** All 33 Mk4 canonical slots */\nexport const SLOTS: SlotDef[] = [\n // Project Meta (3)\n { index: 1, path: 'project.name', description: 'Project name', category: 'project' },\n { index: 2, path: 'project.goal', description: 'Goal (use case)', category: 'project' },\n { index: 3, path: 'project.main_language', description: 'Primary language', category: 'project' },\n\n // Human Context (6)\n { index: 4, path: 'human_context.who', description: 'Who is this for?', category: 'human' },\n { index: 5, path: 'human_context.what', description: 'What are they building', category: 'human' },\n { index: 6, path: 'human_context.why', description: 'Why does it exist', category: 'human' },\n { index: 7, path: 'human_context.where', description: 'Where does it run', category: 'human' },\n { index: 8, path: 'human_context.when', description: 'When was it started / timeline', category: 'human' },\n { index: 9, path: 'human_context.how', description: 'How is it built', category: 'human' },\n\n // Frontend Stack (4)\n { index: 10, path: 'stack.frontend', canonical: 'stack.framework', description: 'Framework (React, Svelte, etc.)', category: 'frontend' },\n { index: 11, path: 'stack.css_framework', canonical: 'stack.css', description: 'CSS framework', category: 'frontend' },\n { index: 12, path: 'stack.ui_library', description: 'UI component library', category: 'frontend' },\n { index: 13, path: 'stack.state_management', canonical: 'stack.state', description: 'State management', category: 'frontend' },\n\n // Backend Stack (5)\n { index: 14, path: 'stack.backend', description: 'Backend framework', category: 'backend' },\n { index: 15, path: 'stack.api_type', canonical: 'stack.api', description: 'API style (REST, GraphQL, etc.)', category: 'backend' },\n { index: 16, path: 'stack.runtime', description: 'Runtime (Node, Bun, Python, etc.)', category: 'backend' },\n { index: 17, path: 'stack.database', canonical: 'stack.db', description: 'Database', category: 'backend' },\n { index: 18, path: 'stack.connection', description: 'Connection method (Prisma, etc.)', category: 'backend' },\n\n // Universal Stack (3)\n { index: 19, path: 'stack.hosting', description: 'Hosting platform', category: 'universal' },\n { index: 20, path: 'stack.build', description: 'Build tool', category: 'universal' },\n { index: 21, path: 'stack.cicd', description: 'CI/CD', category: 'universal' },\n\n // Enterprise Infra (5)\n { index: 22, path: 'stack.monorepo_tool', description: 'Monorepo tool', category: 'enterprise_infra' },\n { index: 23, path: 'stack.package_manager', canonical: 'stack.pkg_manager', description: 'Package manager', category: 'enterprise_infra' },\n { index: 24, path: 'stack.workspaces', description: 'Workspace configuration', category: 'enterprise_infra' },\n { index: 25, path: 'monorepo.packages_count', description: 'Number of packages', category: 'enterprise_infra' },\n { index: 26, path: 'monorepo.build_orchestrator', description: 'Build orchestration tool', category: 'enterprise_infra' },\n\n // Enterprise App (4)\n { index: 27, path: 'stack.admin', description: 'Admin panel', category: 'enterprise_app' },\n { index: 28, path: 'stack.cache', description: 'Caching layer', category: 'enterprise_app' },\n { index: 29, path: 'stack.search', description: 'Search engine', category: 'enterprise_app' },\n { index: 30, path: 'stack.storage', description: 'Object storage', category: 'enterprise_app' },\n\n // Enterprise Ops (3)\n { index: 31, path: 'monorepo.versioning_strategy', description: 'Version strategy', category: 'enterprise_ops' },\n { index: 32, path: 'monorepo.shared_configs', description: 'Shared configs', category: 'enterprise_ops' },\n { index: 33, path: 'monorepo.remote_cache', description: 'Remote build cache', category: 'enterprise_ops' },\n];\n\n/** Slot lookup by path — dual-keyed (current on-wire `path` AND Mk4 `canonical`\n * where defined) so callers can look up by either name. See issue #66. */\nexport const SLOT_BY_PATH = new Map<string, SlotDef>(\n SLOTS.flatMap(s => s.canonical ? [[s.path, s], [s.canonical, s]] : [[s.path, s]])\n);\n\n/** Mk4 canonical → current on-wire path. Used by read helpers to resolve\n * a canonical name back to the path that read/write/kernel actually uses\n * today. Empty for slots whose path is already canonical. */\nexport const CANONICAL_TO_CURRENT: ReadonlyMap<string, string> = new Map(\n SLOTS.filter(s => s.canonical).map(s => [s.canonical as string, s.path])\n);\n\n/** Current on-wire path → Mk4 canonical. Used by display helpers when the\n * UI wants to surface the forward-spec name. */\nexport const CURRENT_TO_CANONICAL: ReadonlyMap<string, string> = new Map(\n SLOTS.filter(s => s.canonical).map(s => [s.path, s.canonical as string])\n);\n\n/** Resolve any path (legacy or canonical) to the slot definition. */\nexport function getSlotByAnyPath(path: string): SlotDef | undefined {\n return SLOT_BY_PATH.get(path);\n}\n\n/** Read a value from a .faf data object, checking both the slot's current\n * `path` and its Mk4 `canonical` (if defined). Returns the first non-undefined\n * value. Lets the cli read .faf files that contain either legacy or canonical\n * keys without forcing a migration. */\nexport function readSlotValue(\n data: Record<string, unknown>,\n slot: SlotDef\n): unknown {\n const tryPath = (p: string): unknown => {\n const parts = p.split('.');\n let cur: unknown = data;\n for (const part of parts) {\n if (cur && typeof cur === 'object' && part in (cur as Record<string, unknown>)) {\n cur = (cur as Record<string, unknown>)[part];\n } else {\n return undefined;\n }\n }\n return cur;\n };\n const primary = tryPath(slot.path);\n if (primary !== undefined) return primary;\n if (slot.canonical) return tryPath(slot.canonical);\n return undefined;\n}\n\n/** Slots grouped by category */\nexport function slotsByCategory(category: SlotCategory): SlotDef[] {\n return SLOTS.filter(s => s.category === category);\n}\n\n/** Base-tier slots (1-21) — used by score_faf */\nexport const BASE_SLOTS = SLOTS.filter(s => s.index <= 21);\n\n/** Enterprise-tier slots (1-33) — used by score_faf_enterprise */\nexport const ENTERPRISE_SLOTS = SLOTS;\n\n/** Placeholder values treated as Empty */\nexport const PLACEHOLDERS = new Set([\n 'describe your project goal',\n 'development teams',\n 'cloud platform',\n 'null',\n 'none',\n 'unknown',\n 'n/a',\n 'not applicable',\n]);\n\n/** Check if a value is a placeholder (empty) */\nexport function isPlaceholder(value: unknown): boolean {\n if (value === null || value === undefined || value === '') return true;\n if (typeof value === 'string') {\n return PLACEHOLDERS.has(value.toLowerCase().trim());\n }\n if (Array.isArray(value) && value.length === 0) return true;\n if (typeof value === 'object' && Object.keys(value as object).length === 0) return true;\n return false;\n}\n\n/** App-type to active category mapping. The canonical 22-type ladder —\n * 20 detectable apps + `about` (non-app, 0 slots, owner-attested)\n * + `encyclopedia` (curated knowledge surface, FAFipedia and similar).\n * (See v6.6.md doctrine memory + fafipedia-vs-grokipedia-architecture.)\n * Sorted ascending by active slot count for readability.\n *\n * v6.5.0 changes vs prior:\n * - Added `universal` to cli / library / mcp / frontend / data-science.\n * These types ship/build/CI somewhere — slotignoring those slots was\n * losing real signal. (cli/library: 9→12; mcp/data-science: 14→17;\n * frontend: 13→16.)\n * - Order is by ascending slot count, not insertion order.\n */\nexport const APP_TYPE_CATEGORIES: Record<string, SlotCategory[]> = {\n // 0 slots — non-app representation surface. Score is INHERITED, not calculated.\n // About Repos are public faces of private codebases (private source / public\n // about pattern, same shape as Anthropic's claude-code repo). They display\n // the source's Trophy badge; they don't earn one. Required: about.represents\n // (Wolfe-Jam/<source>). Optional: about.source_score (number). Scorer\n // short-circuits when app_type === 'about' — see scorer.ts.\n // Doctrine: memory/private-source-public-about-pattern.md.\n about: [],\n\n // 9 slots — minimal (project meta + human only)\n documentation: ['project', 'human'],\n // encyclopedia: same shape as documentation — content repo with project\n // metadata + human context. Used by FAFipedia and similar curated-knowledge\n // surfaces. Per fafipedia-vs-grokipedia-architecture doctrine, this is the\n // structured, git-versioned, agent-consumable knowledge layer. Each .fafi\n // file under an encyclopedia repo is itself a valid .faf (inclusion marker).\n encyclopedia: ['project', 'human'],\n\n // 12 slots — project + human + universal (build/ci/hosting matters)\n cli: ['project', 'human', 'universal'],\n library: ['project', 'human', 'universal'],\n sdk: ['project', 'human', 'universal'],\n wasm: ['project', 'human', 'universal'],\n html: ['project', 'human', 'universal'],\n\n // 16 slots — project + frontend + human + universal\n frontend: ['project', 'frontend', 'human', 'universal'],\n website: ['project', 'frontend', 'human', 'universal'],\n mobile: ['project', 'frontend', 'human', 'universal'],\n // browser/chrome extension — popup/content-script UI + build/CI/store\n // (manifest_version), NO backend. Detected via manifest_version in scanner.ts.\n extension: ['project', 'frontend', 'human', 'universal'],\n\n // 17 slots — project + backend + universal + human\n mcp: ['project', 'backend', 'human', 'universal'],\n backend: ['project', 'backend', 'universal', 'human'],\n 'data-science': ['project', 'backend', 'human', 'universal'],\n\n // 21 slots — full base ladder\n fullstack: ['project', 'frontend', 'backend', 'universal', 'human'],\n svelte: ['project', 'frontend', 'backend', 'universal', 'human'],\n framework: ['project', 'frontend', 'backend', 'universal', 'human'],\n 'monorepo-root': ['project', 'human', 'enterprise_infra', 'enterprise_app', 'enterprise_ops'],\n\n // 24-25 slots — platform / SaaS shapes (base + selected enterprise)\n mcpaas: ['project', 'backend', 'universal', 'human', 'enterprise_app', 'enterprise_ops'],\n saas: ['project', 'frontend', 'backend', 'universal', 'human', 'enterprise_app'],\n\n // 33 slots — full enterprise\n enterprise: ['project', 'frontend', 'backend', 'universal', 'human', 'enterprise_infra', 'enterprise_app', 'enterprise_ops'],\n};\n",
|
|
77
77
|
"// ANSI color helpers — zero deps\n// Design: black/white text by default. Cyan + orange are the only brand colors.\nconst esc = (code: string) => (s: string) => `\\x1b[${code}m${s}\\x1b[0m`;\n\nexport const bold = esc('1');\nexport const dim = esc('2');\nexport const italic = esc('3');\n\n// Brand colors only — no red/green/yellow rainbow.\n// FAF_HEX is the single source of record for brand hex — ANSI fns below\n// AND HTML renders (project.html) derive from it. Change here, propagates.\nexport const FAF_HEX = {\n cyan: '#00D4D4', // Silver tier · interaction\n cyanDeep: '#0E8C8C', // Bronze tier — same cyan lane, one rung down\n orange: '#FF6B35', // Trophy/Gold · CTAs\n} as const;\n\nexport const fafCyan = (s: string) => `\\x1b[38;2;0;212;212m${s}\\x1b[0m`; // #00D4D4\nexport const fafCyanDeep = (s: string) => `\\x1b[38;2;14;140;140m${s}\\x1b[0m`; // #0E8C8C\nexport const orange = (s: string) => `\\x1b[38;5;208m${s}\\x1b[0m`;\n",
|
|
78
78
|
"import type { TierInfo } from './types.js';\nimport { bold, dim, fafCyan, fafCyanDeep, orange } from '../ui/colors.js';\n\n/** Tier boundaries — ordered from highest to lowest\n *\n * Indicators:\n * 🏆 trophy (earned at 100%)\n * ★ filled star (gold — orange)\n * ◆ filled diamond (silver — cyan)\n * ◇ open diamond (bronze — deep cyan, one rung below silver)\n * ● filled circle (mid tiers)\n * ○ open circle (low — dim)\n * ♡ heart (empty — good luck)\n */\nexport const TIERS: TierInfo[] = [\n { name: 'TROPHY', indicator: `${orange('🏆')} ${orange('TROPHY')}`, threshold: 100 },\n { name: 'GOLD', indicator: `${orange(bold('★'))} ${orange('GOLD')}`, threshold: 99 },\n { name: 'SILVER', indicator: `${fafCyan('◆')} ${fafCyan('SILVER')}`, threshold: 95 },\n { name: 'BRONZE', indicator: `${fafCyanDeep('◇')} ${fafCyanDeep('BRONZE')}`, threshold: 85 },\n { name: 'GREEN', indicator: `${bold('●')} GREEN`, threshold: 70 },\n { name: 'YELLOW', indicator: `${dim('●')} YELLOW`, threshold: 55 },\n { name: 'RED', indicator: `${dim('○')} RED`, threshold: 1 },\n { name: 'WHITE', indicator: `${dim('♡')}`, threshold: 0 },\n];\n\n/** Get the display badge for a tier */\nexport function tierBadge(tier: TierInfo): string {\n return tier.indicator;\n}\n\n/** Get tier info for a given score */\nexport function getTier(score: number): TierInfo {\n for (const tier of TIERS) {\n if (score >= tier.threshold) return tier;\n }\n return TIERS[TIERS.length - 1]; // White\n}\n\n/** Get the next tier above the current score (for progress display) */\nexport function getNextTier(score: number): TierInfo | null {\n const current = getTier(score);\n const idx = TIERS.indexOf(current);\n return idx > 0 ? TIERS[idx - 1] : null;\n}\n",
|
|
79
79
|
"import type { KernelScoreResult, FafbInfo } from '../core/types.js';\n\n// faf-scoring-kernel is CommonJS with synchronous WASM loading\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nlet kernel: typeof import('faf-scoring-kernel') | null = null;\n\nfunction getKernel(): typeof import('faf-scoring-kernel') {\n if (kernel) return kernel;\n try {\n const loaded = require('faf-scoring-kernel') as typeof import('faf-scoring-kernel');\n kernel = loaded;\n return loaded;\n } catch {\n throw new Error(\n 'faf-scoring-kernel not installed.\\n\\n Run: npm install faf-scoring-kernel\\n'\n );\n }\n}\n\n/** Score a .faf YAML string (21 base slots) */\nexport function score(yaml: string): KernelScoreResult {\n return JSON.parse(getKernel().score_faf(yaml));\n}\n\n/** Score a .faf YAML string (33 enterprise slots) */\nexport function scoreEnterprise(yaml: string): KernelScoreResult {\n return JSON.parse(getKernel().score_faf_enterprise(yaml));\n}\n\n/** Validate .faf YAML */\nexport function validate(yaml: string): boolean {\n return getKernel().validate_faf(yaml);\n}\n\n/** Compile .faf YAML to FAFb binary */\nexport function compile(yaml: string): Uint8Array {\n return getKernel().compile_fafb(yaml);\n}\n\n/** Decompile FAFb binary to JSON info */\nexport function decompile(bytes: Uint8Array): FafbInfo {\n return JSON.parse(getKernel().decompile_fafb(bytes));\n}\n\n/** Get FAFb file metadata */\nexport function fafbInfo(bytes: Uint8Array): FafbInfo {\n return JSON.parse(getKernel().fafb_info(bytes));\n}\n\n/** Get FAFb binary metadata (name, version, source) */\nexport interface FafbMeta {\n source: string;\n name: string;\n faf_version: string;\n}\n\nexport function scoreFafb(bytes: Uint8Array): FafbMeta {\n return JSON.parse(getKernel().score_fafb(bytes));\n}\n\n/** Get WASM SDK version */\nexport function sdkVersion(): string {\n return getKernel().sdk_version();\n}\n",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "faf-cli",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.8.0",
|
|
4
4
|
"description": "Persistent AI Context Standard — project DNA for AI. IANA-registered. Anthropic-approved.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"icon": "https://faf.one/orange-smiley.svg",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
|
-
"bun": "./src/index.ts",
|
|
18
17
|
"default": "./dist/index.js"
|
|
19
18
|
}
|
|
20
19
|
},
|
|
@@ -29,8 +28,8 @@
|
|
|
29
28
|
"build": "bun build src/cli.ts --outdir dist --target=node --minify --sourcemap=linked --external faf-scoring-kernel --external open && bun build src/index.ts --outdir dist --target=node --minify --sourcemap=linked --external faf-scoring-kernel --external open && tsc -p tsconfig.build.json",
|
|
30
29
|
"compile": "bun build src/cli.ts --compile --bytecode --minify --outfile faf",
|
|
31
30
|
"compile:all": "bun build src/cli.ts --compile --bytecode --minify --target=bun-darwin-arm64 --outfile faf-darwin-arm64 && bun build src/cli.ts --compile --bytecode --minify --target=bun-darwin-x64 --outfile faf-darwin-x64 && bun build src/cli.ts --compile --bytecode --minify --target=bun-linux-x64 --outfile faf-linux-x64 && bun build src/cli.ts --compile --bytecode --minify --target=bun-windows-x64 --outfile faf-windows-x64.exe",
|
|
32
|
-
"test": "bun test --timeout=
|
|
33
|
-
"test:watch": "bun test --watch --timeout=
|
|
31
|
+
"test": "bun test --timeout=120000",
|
|
32
|
+
"test:watch": "bun test --watch --timeout=120000",
|
|
34
33
|
"lint": "eslint src/**/*.ts",
|
|
35
34
|
"format": "prettier --write 'src/**/*.ts'",
|
|
36
35
|
"check:no-hardcode": "! grep -rEln '/(Users|home/runner|private/var)/' dist/ || (echo '❌ Hardcoded build-machine path leaked into dist — see grep output above. Externalize the offending dep in the build script.'; exit 1)",
|
|
@@ -71,6 +70,8 @@
|
|
|
71
70
|
"@anthropic-ai/sdk": "^0.91.1"
|
|
72
71
|
},
|
|
73
72
|
"devDependencies": {
|
|
73
|
+
"@faf/specification": "github:Wolfe-Jam/faf",
|
|
74
|
+
"ajv": "^8.17.1",
|
|
74
75
|
"@types/node": "^22.15.0",
|
|
75
76
|
"@typescript-eslint/eslint-plugin": "^8.41.0",
|
|
76
77
|
"@typescript-eslint/parser": "^8.41.0",
|