fix: align okf output with google v0.1#373
Conversation
|
|
||
| const OKF_STRING_FIELDS = ["type", "title", "description", "resource"]; | ||
| const OKF_FIELDS = new Set([...OKF_STRING_FIELDS, "tags"]); | ||
| const OKF_STRING_FIELDS = [ |
There was a problem hiding this comment.
are we losing tags here?
There was a problem hiding this comment.
No, tags is still validated — it just isn't part of the OKF_STRING_FIELDS list because it's a list, not a string. It has its own dedicated check further down (unchanged by this PR):
if (
Object.hasOwn(fields, "tags") &&
(!Array.isArray(fields.tags) ||
fields.tags.some((tag) => typeof tag !== "string" || !tag.trim()))
) {
issues.push(issue("invalid_tags", "Field `tags` must be a YAML list of non-empty strings."));
}What went away is the old OKF_FIELDS allowlist that produced the unsupported_field error. That removal is intentional: OKF v0.1 permits producer-defined extension fields, so we can no longer reject unknown keys.
One conscious trade-off worth flagging: without the allowlist, a typo in a standard field (e.g. descriptoin:) now passes silently as an "extension" instead of erroring. Erroring would violate the spec, so I left it as-is — happy to open a follow-up issue for a heuristic "did you mean" warning if you think it's worth it.
| const LOG_FILE = "log.md"; | ||
| const EXCLUDED_FILES = new Set([ | ||
| INDEX_FILE, | ||
| LOG_FILE, |
There was a problem hiding this comment.
nice - good catch.
| .filter(Boolean) | ||
| .join("\n\n"); | ||
| return `---\ntype: Documentation Index\ntitle: ${JSON.stringify(title)}\ndescription: ${JSON.stringify(`Files and subdirectories in ${title}.`)}\n---\n\n${sections}\n`; | ||
| const version = isRoot ? '---\nokf_version: "0.1"\n---\n\n' : ""; |
There was a problem hiding this comment.
also a great catch.
Colin Francis (colifran)
left a comment
There was a problem hiding this comment.
Looks great and thank you! I have one question about tags before we merge.
…-conformance # Conflicts: # openwiki/index.md
Colin Francis (colifran)
left a comment
There was a problem hiding this comment.
Thank you for this Ruan Barroso (@ruanbarroso)!
Summary
Follow-up to #345 and #84 that aligns OpenWiki with the canonical Google OKF v0.1 specification.
timestampfield and producer-defined extension fieldstypefor conceptsindex.mdandlog.mdas reserved documents, not conceptsokf_version: "0.1"only in the root index and no frontmatter in nested indexestitle,description, andtagsTests
pnpm run format:checkpnpm run lint:checkpnpm run typecheckpnpm run test— 338 tests passed across 32 filespnpm run buildopenwiki/with an independent OKF v0.1 validator — 7 concepts, 0 errors, 0 warnings