Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions skills/ce-compound-refresh/scripts/validate-doc-claims.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,11 @@ def head_has_path(path: str) -> bool:
f"working tree or {upstream}" if upstream else "working tree"
)
flags.append(
f"FLAG path `{token}`{loc} — not found in {where}. Fix the "
"citation, or annotate it as historical (e.g. removed by this fix)."
f"FLAG path `{token}`{loc} — not found in {where}, under "
f"{base}. This check only looks in this repository; check "
"other stores before treating the citation as wrong. "
"Otherwise, fix the citation, or annotate it as historical "
"(e.g. removed by this fix)."
)

# --- 2. Cited commit SHAs ----------------------------------------------
Expand Down
7 changes: 5 additions & 2 deletions skills/ce-compound/scripts/validate-doc-claims.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,11 @@ def head_has_path(path: str) -> bool:
f"working tree or {upstream}" if upstream else "working tree"
)
flags.append(
f"FLAG path `{token}`{loc} — not found in {where}. Fix the "
"citation, or annotate it as historical (e.g. removed by this fix)."
f"FLAG path `{token}`{loc} — not found in {where}, under "
f"{base}. This check only looks in this repository; check "
"other stores before treating the citation as wrong. "
Comment on lines +280 to +281

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid calling the CWD a repository outside Git

When the document is outside a Git repository, in_git is false and base is the process CWD, yet this branch now says the check only inspected “this repository.” Running the validator from this checkout against a /tmp/doc.md containing missing/file.md reproduces a contradictory report: it first says the document is not in a Git repository, then names this checkout and calls it the repository searched. Make the repository-scoped wording conditional on in_git; otherwise describe the base as the current working directory (or skip repo-path classification as the preceding INFO claims).

Useful? React with 👍 / 👎.

"Otherwise, fix the citation, or annotate it as historical "
"(e.g. removed by this fix)."
)

# --- 2. Cited commit SHAs ----------------------------------------------
Expand Down
29 changes: 22 additions & 7 deletions tests/doc-claims-validator.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { beforeAll, describe, expect, test } from "bun:test"
import { spawnSync } from "node:child_process"
import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs"
import {
mkdirSync,
mkdtempSync,
readFileSync,
realpathSync,
writeFileSync,
} from "node:fs"
import { tmpdir } from "node:os"
import path from "node:path"

Expand Down Expand Up @@ -66,7 +72,7 @@ function mixedShaPrefix(sha: string): string {
}

beforeAll(() => {
repo = mkdtempSync(path.join(tmpdir(), "doc-claims-repo-"))
repo = realpathSync(mkdtempSync(path.join(tmpdir(), "doc-claims-repo-")))
sh(repo, "git", ["init", "-b", "main"])
sh(repo, "git", ["config", "user.email", "test@example.com"])
sh(repo, "git", ["config", "user.name", "Test"])
Expand Down Expand Up @@ -140,14 +146,20 @@ describe("validate-doc-claims script", () => {
expect(result.stdout).not.toContain("FLAG")
})

test("flags a cited path that exists nowhere", () => {
test("flags a cited path that exists nowhere, naming the search base", () => {
const docPath = writeRepoDoc(
"The handler is `src/does-not-exist.ts` in the tree.\n",
)
const result = runValidator(skillDir, docPath)
expect(result.code).toBe(1)
expect(result.stdout).toContain("FLAG path `src/does-not-exist.ts`")
expect(result.stdout).toContain("not found")
expect(result.stdout).toContain(
`not found in working tree or origin/main, under ${repo}`,
)
expect(result.stdout).toContain(
"This check only looks in this repository; check other stores " +
"before treating the citation as wrong.",
)
})

test("classifies a path that only exists upstream as stale-checkout", () => {
Expand Down Expand Up @@ -176,8 +188,9 @@ describe("validate-doc-claims script", () => {
)
const result = runValidator(skillDir, docPath)
expect(result.code).toBe(1)
expect(result.stdout).toContain("FLAG path `src/nonexistent-helper`")
expect(result.stdout).toContain("not found")
expect(result.stdout).toContain(
`not found in working tree or origin/main, under ${repo}`,
)
})

test("ignores placeholder and URL-like tokens", () => {
Expand Down Expand Up @@ -345,7 +358,9 @@ describe("validate-doc-claims script", () => {
expect(result.stdout).toContain(
"FLAG path `../best-practices/does-not-exist.md`",
)
expect(result.stdout).toContain("not found")
expect(result.stdout).toContain(
`not found in working tree or origin/main, under ${repo}`,
)
})

test("skips a `../` token that escapes the repository", () => {
Expand Down