-
Notifications
You must be signed in to change notification settings - Fork 882
fix: align okf output with google v0.1 #373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Colin Francis (colifran)
merged 3 commits into
langchain-ai:main
from
ruanbarroso:fix/google-okf-v0.1-conformance
Jul 17, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,13 @@ import { addFrontmatterWarning } from "./frontmatter-validator.js"; | |
| import type { OpenWikiOutputMode } from "./types.js"; | ||
|
|
||
| const INDEX_FILE = "index.md"; | ||
| const EXCLUDED_FILES = new Set([INDEX_FILE, "_plan.md", "INSTRUCTIONS.md"]); | ||
| const LOG_FILE = "log.md"; | ||
| const EXCLUDED_FILES = new Set([ | ||
| INDEX_FILE, | ||
| LOG_FILE, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice - good catch. |
||
| "_plan.md", | ||
| "INSTRUCTIONS.md", | ||
| ]); | ||
|
|
||
| interface Directory { | ||
| entries: FileInfo[]; | ||
|
|
@@ -113,11 +119,7 @@ async function synchronizeDirectory( | |
| } | ||
|
|
||
| const indexPath = path.posix.join(directory.path, INDEX_FILE); | ||
| const title = | ||
| directory.path === root | ||
| ? "OpenWiki" | ||
| : titleFromSlug(path.posix.basename(directory.path)); | ||
| const content = renderIndex(title, files, directories); | ||
| const content = renderIndex(files, directories, directory.path === root); | ||
| const existing = directory.entries.some( | ||
| (entry) => !entry.is_dir && entryName(entry) === INDEX_FILE, | ||
| ) | ||
|
|
@@ -135,17 +137,18 @@ async function synchronizeDirectory( | |
|
|
||
| /** Renders a complete deterministic index document. */ | ||
| function renderIndex( | ||
| title: string, | ||
| files: Link[], | ||
| directories: Link[], | ||
| isRoot: boolean, | ||
| ): string { | ||
| const sections = [ | ||
| renderLinks("Files", files, true), | ||
| renderLinks("Directories", directories, false), | ||
| ] | ||
| .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' : ""; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also a great catch. |
||
| return `${version}${sections || "# Files"}\n`; | ||
| } | ||
|
|
||
| /** Renders a sorted Markdown section for files or subdirectories. */ | ||
|
|
@@ -236,15 +239,6 @@ function entryName(entry: FileInfo): string { | |
| return path.posix.basename(entry.path.replace(/\/$/u, "")); | ||
| } | ||
|
|
||
| /** Converts a directory slug into a human-readable title. */ | ||
| function titleFromSlug(slug: string): string { | ||
| return slug | ||
| .split(/[-_\s]+/u) | ||
| .filter(Boolean) | ||
| .map((word) => word[0].toUpperCase() + word.slice(1)) | ||
| .join(" "); | ||
| } | ||
|
|
||
| /** Escapes a value for use as a Markdown link label. */ | ||
| function escapeLabel(value: string): string { | ||
| return value | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { describe, expect, test } from "vitest"; | ||
| import { createSystemPrompt } from "../src/agent/prompt.ts"; | ||
|
|
||
| describe("createSystemPrompt OKF guidance", () => { | ||
| test("describes Google OKF v0.1 frontmatter and preservation rules", () => { | ||
| const prompt = createSystemPrompt("init", "repository"); | ||
|
|
||
| expect(prompt).toContain("Only `type` is required"); | ||
| expect(prompt).toContain("`timestamp` is an optional ISO 8601 datetime"); | ||
| expect(prompt).toContain( | ||
| "Preserve all existing producer-defined front matter fields", | ||
| ); | ||
| expect(prompt).toContain( | ||
| "`index.md` and `log.md` are reserved OKF documents", | ||
| ); | ||
| expect(prompt).not.toContain("Required fields are: `title`"); | ||
| expect(prompt).not.toContain( | ||
| "do not add front matter fields outside the formatter above", | ||
| ); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we losing tags here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No,
tagsis still validated — it just isn't part of theOKF_STRING_FIELDSlist because it's a list, not a string. It has its own dedicated check further down (unchanged by this PR):What went away is the old
OKF_FIELDSallowlist that produced theunsupported_fielderror. 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.