Skip to content

feat(docs): docs llms-txt CLI for the static llms.txt check - #1132

Merged
xaleryb merged 50 commits into
intel:mainfrom
napetrov:claude/docs-llms-txt-cli
Nov 28, 2026
Merged

xaleryb merged 50 commits into
intel:mainfrom
napetrov:claude/docs-llms-txt-cli

Conversation

@napetrov

@napetrov napetrov commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Scope: This PR adds the static checker and its CLI directly against main. #1082 owns the separate report command. This PR can land independently.

Adds dokimi docs llms-txt <path-or-file> [--json] [--token-budget N], the CLI over the static llms.txt check (dokimi.llms_txt.check).

  • If you give it a directory, it checks the llms.txt at the top of that directory. It makes no network or model call.
  • Text output: one tab-separated row per finding (severity, check, file:line, message, fix), then a verdict line.
  • --json: prints cli_output.v1 with kind docs llms-txt and verdict pass/fail. The findings go under data and also as the subject's findings. Tested against the schema.
  • Exit codes: 1 when a fail finding exists, 0 when there are only warnings, 2 when the input is missing or unreadable.
  • --token-budget is a new canonical spelling in the tokens concept: an integer ceiling. It is distinct from --token-budgets, which takes fractions.
  • Wiring: a LEAVES route, registration under the docs group (commands/run.py), and the cli-interface.json hunk for the new leaf only.
  • Docs: a feature card under "Will the agent use it?", the guide docs/llms-txt.md, a documentation-index entry and a changelog fragment.

The checker accepts labeled inline and reference-style Markdown links. Bare autolinks do not satisfy the link check. It skips fenced and indented code examples and HTML comments, including code spans that cross a soft line break. It reports physical line numbers. Link warnings retain code-formatted labels and inline destinations as written so existing opportunity keys stay stable.

The Markdown parser is a direct runtime dependency. The Intel CI lock re-solve retained every existing package artifact.

…Lightsage-inspired proposal

Prototype only, not wired into the CLI: dokimi.opportunities turns novelty,
repo_static and llms.txt findings into a ranked impact x effort queue with
stable source keys and execution prompts; dokimi.llms_txt statically checks
an llms.txt. docs/proposals/lightsage-inspired-features.md maps the competitor's
features, ranks the gaps and lists next steps.

Signed-off-by: Petrov, Nikolay A <nikolay.a.petrov@intel.com>
Inputs are detected by content (novelty JSON, repo_static.v1, llms.txt);
--format json writes an opportunities.v1 artifact (new schema + fixture),
markdown prints the ranked table. Proposal next steps updated.

Signed-off-by: Petrov, Nikolay A <nikolay.a.petrov@intel.com>
…s an input error, escape table cells

Signed-off-by: Petrov, Nikolay A <nikolay.a.petrov@intel.com>
Signed-off-by: Petrov, Nikolay A <nikolay.a.petrov@intel.com>
…s by check, links by message

Signed-off-by: Petrov, Nikolay A <nikolay.a.petrov@intel.com>
Signed-off-by: Petrov, Nikolay A <nikolay.a.petrov@intel.com>
…hot uses the Linux type hash

Signed-off-by: Petrov, Nikolay A <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
…ure-ideas-2aea58

Signed-off-by: Petrov, Nikolay A <nikolay.a.petrov@intel.com>

# Conflicts:
#	dokimi/docs/reference/cli-interface.json
…tput; user docs page

Signed-off-by: Petrov, Nikolay A <nikolay.a.petrov@intel.com>
Runs dokimi.llms_txt.check on a file or a directory holding llms.txt,
prints a row per finding or cli_output.v1 with --json, and exits 1 when a
fail finding exists. --token-budget sets the size ceiling (allowlisted:
tokens' --token-budgets means fractions). Adds a feature card under
'Will the agent use it?', a guide page, a changelog fragment and tests.

Signed-off-by: Petrov, Nikolay A <nikolay.a.petrov@intel.com>
…de wording

Drop the extra brace the hand-spliced snapshot hunk added; register
--token-budget in the tokens concept instead of the allowlist; say that
report opportunities takes the file and checks at the default budget.

Signed-off-by: Petrov, Nikolay A <nikolay.a.petrov@intel.com>
@napetrov
napetrov requested a review from a team as a code owner November 22, 2026 20:48
@github-actions github-actions Bot added the cli-interface-change Changes dokimi's user-facing CLI surface label Nov 22, 2026
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

CLI interface change detected

This PR changes dokimi's user-facing CLI surface (commands and/or options):

+ added command `dokimi docs llms-txt`
    + argument `path`
    + option `--help/-h`
    + option `--json`
    + option `--token-budget`

Updated on every push; the cli-interface-change label is on while the diff is non-empty.

@exai-bot

exai-bot commented Nov 22, 2026 •

Copy link
Copy Markdown

OpenCodeReview: Commit 06cdc08 was not reviewed. This PR has reached its review limit (6 reviews).

CI at `06cdc08`: 8 still running, 20 passing, 4 skipped
Check Status
Fidelity golden (claude-code 2.1.318) still running
Mutation of changed lines still running
Package install smoke test (py3.11) still running
Test Linux Python 3.14 still running
Test Linux Wheels Python 3.14 still running
Tests (py3.14) still running
Windows smoke test (py3.13) still running
self / repo tasks check fix-degrade-pre still running

To review this commit: re-request review from exai-bot in the Reviewers list.

Last review (212c176): 2 medium

Open threads from the bot: 1

Comment thread dokimi/docs/llms-txt.md Resolved
Comment thread dokimi/dokimi/commands/opportunities.py Resolved
Comment thread dokimi/dokimi/commands/opportunities.py Resolved
Comment thread dokimi/dokimi/commands/opportunities.py Resolved
Comment thread dokimi/dokimi/llms_txt.py Resolved
Comment thread dokimi/dokimi/llms_txt.py Resolved
Comment thread dokimi/dokimi/llms_txt.py Resolved
Comment thread dokimi/dokimi/llms_txt.py Resolved
Comment thread dokimi/dokimi/opportunities.py Resolved
Comment thread dokimi/dokimi/opportunities.py Resolved
@codecov-commenter

codecov-commenter commented Nov 22, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 96.03960% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.21%. Comparing base (74eeae1) to head (06cdc08).

Files with missing lines Patch % Lines
dokimi/dokimi/llms_txt.py 96.10% 2 Missing and 4 partials ⚠️
dokimi/dokimi/commands/llms_txt.py 95.65% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1132      +/-   ##
==========================================
- Coverage   96.21%   96.21%   -0.01%     
==========================================
  Files         502      503       +1     
  Lines       67062    67250     +188     
  Branches    11645    11678      +33     
==========================================
+ Hits        64524    64704     +180     
- Misses       1565     1568       +3     
- Partials      973      978       +5     
Files with missing lines Coverage Δ
dokimi/dokimi/cli_flags.py 100.00% <ø> (ø)
dokimi/dokimi/cli_routes.py 97.96% <ø> (ø)
dokimi/dokimi/commands/run.py 97.22% <100.00%> (+0.03%) ⬆️
dokimi/dokimi/commands/llms_txt.py 95.65% <95.65%> (ø)
dokimi/dokimi/llms_txt.py 97.05% <96.10%> (-2.95%) ⬇️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Petrov, Nikolay A <nikolay.a.petrov@intel.com>

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes needed · reviewed 6134334

To fix: a valid llms.txt saved with a BOM fails the new gate (line comment). Also answer the @exai-bot threads below. This branch carries #1082 at an older head (dcf5ad5), so it should merge after #1082, rebased on it.

✅ make ci-local --offline: 25,987 passed · ✅ Windows (Server 2025, Python 3.13): tests/test_llms_txt_command.py, tests/test_llms_txt.py 14 passed · ✅ strict docs build with the new nav entry

The CLI fits the docs group well: input errors exit 2, a fail exits 1 and --json gives a valid cli_output.v1.

Agreed with @exai-bot on the checker's false verdicts (indented headings, titled links and images, empty >, and 2 more) and on the report opportunities input handling and novelty rates; those fixes belong in #1082.

Comment thread dokimi/dokimi/commands/llms_txt.py Resolved
Comment thread dokimi/tests/test_llms_txt_command.py Resolved
PRRT_kwDOVBg7g866cEp6
PRRT_kwDOVBg7g866cEp9
PRRT_kwDOVBg7g866cEqA
PRRT_kwDOVBg7g866cEqE
PRRT_kwDOVBg7g866cEqH
PRRT_kwDOVBg7g866cEqK
PRRT_kwDOVBg7g866cEqM
PRRT_kwDOVBg7g866cEqO
PRRT_kwDOVBg7g866cEqQ
PRRT_kwDOVBg7g866cLbk
PRRT_kwDOVBg7g866cLbr
PRRT_kwDOVBg7g866cLb0
PRRT_kwDOVBg7g866cLb9
PRRT_kwDOVBg7g866eKTw
PRRT_kwDOVBg7g866eKTz
PRRT_kwDOVBg7g866eKT0
PRRT_kwDOVBg7g866eKT1
PRRT_kwDOVBg7g866fpza
PRRT_kwDOVBg7g866x5qy
PRRT_kwDOVBg7g866x5q2
PRRT_kwDOVBg7g866x5q5
PRRT_kwDOVBg7g866x5q6
PRRT_kwDOVBg7g866x5q9

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
PRRT_kwDOVBg7g866oHaY
PRRT_kwDOVBg7g866oHaZ
PRRT_kwDOVBg7g866oHaa
PRRT_kwDOVBg7g866oHab
PRRT_kwDOVBg7g866oHad
PRRT_kwDOVBg7g866oHah
PRRT_kwDOVBg7g866oHak
PRRT_kwDOVBg7g866oHap
PRRT_kwDOVBg7g866oHat
PRRT_kwDOVBg7g866oHaw
PRRT_kwDOVBg7g866oHaz
PRRT_kwDOVBg7g866x7iN
PRRT_kwDOVBg7g866x7iP

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov

Copy link
Copy Markdown
Contributor Author

db1c03f accepts a UTF-8 BOM on an llms.txt index and covers that input in the gate regression tests.

Comment thread dokimi/dokimi/commands/opportunities.py Resolved
Comment thread dokimi/dokimi/llms_txt.py Resolved
Comment thread dokimi/dokimi/llms_txt.py Resolved
Comment thread dokimi/dokimi/llms_txt.py Resolved
Comment thread dokimi/dokimi/opportunities.py Resolved
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g867yZ_n
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g867yZ_v
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRR_kwDOVBg7g88AAAABaNZe2w
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov

Copy link
Copy Markdown
Contributor Author

Re: review by vchamarthi

change the table row in dokimi/docs/llms-txt.md so it says only the heading is checked
7d57d5d documents the heading check.

@napetrov

Copy link
Copy Markdown
Contributor Author

Re: review by vlad-perevezentsev

since #1082 landed, it conflicts with main in llms_txt.py and test_llms_txt.py
Merged main in a315c4c. The fixes and probes are mapped below.

@napetrov

Copy link
Copy Markdown
Contributor Author
  • Merged main in a315c4c. The checker and report command now share the same implementation.
  • e2fd561 handles defined references, nested labels, angle-bracket destinations, and parenthesized titles. A local repeated link-start probe took 0.06 s for 2,000 starts and 0.23 s for 8,000.
  • 54e1920 preserves physical line numbers with Unicode line separators. 7d57d5d describes the heading check in the guide.
  • f391d46 preserves distinct opportunity keys for code-formatted labels and keeps inline destinations as written.
  • a8bc54e promotes the Markdown parser to a runtime dependency in the Intel CI locks, retaining the existing package builds.

@vchamarthi vchamarthi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@napetrov, could you fix the 2 new problems I found and the 2 small things I've marked fix before merge (in the line comments) and answer my question below? Then push and I'll take another look.

My question before I approve:

  • An autolink such as <https://acme.test/quickstart.md> is not counted as a link, so an index whose only link is an autolink fails the links check with exit 1. State in docs/llms-txt.md that autolinks are not counted, or count them in the check.

What I checked on a8bc54e:

  • When I broke the changed code on purpose, the tests missed 1 of 12 breakages.
  • The 65 changed tests pass, and fail on main as expected.
  • The full test suite passes with main merged in (30,993 tests), apart from failures main has too.
  • It merges cleanly onto main.

Comment thread dokimi/dokimi/llms_txt.py Resolved
Comment thread dokimi/dokimi/commands/llms_txt.py Resolved
Comment thread dokimi/dokimi/llms_txt.py Resolved
Comment thread dokimi/dokimi/llms_txt.py Resolved
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g868Oxqy
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g868Oxq1
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g868Oxq_
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g868OxrF
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRR_kwDOVBg7g88AAAABab4Tqw
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov

Copy link
Copy Markdown
Contributor Author

Re: review by vchamarthi

An autolink such as <https://acme.test/quickstart.md> is not counted as a link
6cf158d documents the existing rule.

@napetrov

Copy link
Copy Markdown
Contributor Author

The inline fixes cover indented examples, unreadable paths, raw HTML and paragraph links. The guide spells out the autolink rule.

@vchamarthi vchamarthi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@napetrov, could you fix the small thing I've marked fix before merge (in the line comments)? I'll approve once that's done.

What I checked on 6cf158d: the 71 changed tests pass, and fail on main as expected; the full test suite passes with main merged in (31,323 tests), apart from failures main has too; it merges cleanly onto main; when I changed the code on purpose, the tests caught all 12 changes.

Comment thread dokimi/dokimi/llms_txt.py
links, code_lines = _structure_lines(visible, keep_code=True)
found = _title_findings(lines) + _section_findings(lines) + _link_findings("\n".join(links), code_lines)
tokens = estimate_tokens(text)
if tokens > token_budget:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fix before merge (blocking): A file of exactly --token-budget tokens gets a size warning, and no test checks that size, so changing > to >= passes every test.

Suggestion: Add a case where --token-budget equals the estimate of a short file and check that there is no size row.

I tested this patch: it fixes the problem, and the tests still pass.

Patch
--- a/dokimi/tests/test_llms_txt.py
+++ b/dokimi/tests/test_llms_txt.py
@@ -62,6 +62,11 @@
 def test_size_over_budget_is_flagged():
     assert "size" in _checks(GOOD + "x" * 9000) - _checks(GOOD)
     assert "size" not in {f.check for f in llms_txt.check(GOOD + "x" * 9000, token_budget=10_000)}
+
+
+def test_size_at_exactly_the_budget_is_not_flagged():
+    budget = llms_txt.estimate_tokens(GOOD)
+    assert "size" not in {f.check for f in llms_txt.check(GOOD, token_budget=budget)}
 
 
 def test_fenced_examples_and_images_do_not_supply_document_structure():
Details

If I change if tokens > token_budget: to if tokens >= token_budget:, the tests in tests/test_llms_txt.py and tests/test_llms_txt_command.py still pass. A file of exactly the budget then gets a size warning, though docs/llms-txt.md says the limit is "at most" --token-budget tokens. test_size_over_budget_is_flagged uses a budget of 10,000 and never lands on the boundary.

…of the file

An inline `<!--` with no `-->` after it is literal text in CommonMark, but the
checker treated it as a comment to the end of the file and failed a valid index.
It now opens a comment only when a `-->` follows or when it starts an HTML block.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
Each closing fence searched for the next code span again, walking every later
backtick run, so an index with 2000 fenced examples took seconds. The inline
scanner now reuses its last search when the next query comes before its result.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
… the budget edge

A non-UTF-8 llms.txt must exit 2 without a traceback, the --json data.tokens and
summary.warn must match the findings, and a file of exactly --token-budget tokens
must not get a size warning.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
@xaleryb

xaleryb commented Nov 28, 2026

Copy link
Copy Markdown
Contributor
  • Ran: the head merged with main 8d9d1ea on Python 3.13, with the full suite, ruff, mypy, bandit, growth, the comment-block check, the CLI snapshot and docs check --strict.
  • Open, for the author: merged with current main, tests/test_cli_output.py::test_every_json_leaf_gives_a_next_step_or_none_by_design fails with Extra items in the left set: ("docs", "llms-txt"). Expected: it passes. Fix: merge main and add ("docs", "llms-txt") to LEAVES_WITHOUT_NEXT_BY_DESIGN, since the leaf prints next: [].
  • Commits we will push:
    • b9d08c6: an unclosed inline <!-- in prose (Write <!-- to open a comment.) hid every later section and link, so the index failed with exit 1. Main exits 0 on it. A <!-- now opens a comment only when a --> follows it or when it starts an HTML block.
    • da61d36: 4000 fenced examples took 33 s; they now take 0.15 s. The inline scanner reuses its last code-span search.
    • 7f8b318: tests for exit 2 on non-UTF-8 input, for data.tokens and summary.warn in --json, and for a file of exactly --token-budget tokens.

p.add_argument("path", metavar="PATH", help="an llms.txt file, or a directory with llms.txt at its top")
cli_flags.add(p, "tokens", "--token-budget", type=positive_int, default=llms_txt.TOKEN_BUDGET, metavar="N",
help=f"Warn when the file is over ~N tokens (default {llms_txt.TOKEN_BUDGET})")
cli_flags.add(p, "output", "--json", action="store_true",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CI check Tests (py3.14) fails: Registering docs llms-txt with --json adds a leaf that is absent from both next-step classification sets. The contract test requires every JSON leaf to belong to exactly one set; the needed inventory definitions are not present in the file version available through the tools, so an exact replacement cannot safely be supplied.

Evidence: tests/test_cli_output.py::test_every_json_leaf_gives_a_next_step_or_none_by_design: Extra items in the left set: ('docs', 'llms-txt')

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
The leaf prints next: [] by design; the intel#941 inventory test needs it in one set.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
@xaleryb

xaleryb commented Nov 28, 2026

Copy link
Copy Markdown
Contributor
  • Pushed 7d20374: merged main 74eeae1. The only conflict was in docs/documentation-index.md, and both entries are kept (llms-txt.md and pr-command.md). The regenerated CLI snapshot is byte-identical to the merged one.
  • Pushed 06cdc08: added ("docs", "llms-txt") to LEAVES_WITHOUT_NEXT_BY_DESIGN, because the leaf prints next: []. This fixes Tests (py3.14), where test_every_json_leaf_gives_a_next_step_or_none_by_design failed with Extra items in the left set.
  • Checked on Python 3.13: 30,548 passed, with 1 failure that main has too (test_agent_arm_dependencies, no mcp). ruff, mypy, bandit, the ratchets, the changelog, comment-block and narrowing checks, and docs check --strict all pass.
  • Nothing is left for the author.

@xaleryb xaleryb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved on 06cdc08. docs llms-txt checks the repository's llms.txt and prints next: []; we merged main, listed the leaf in LEAVES_WITHOUT_NEXT_BY_DESIGN, and our earlier commits fix a stray <!-- hiding the rest of the file, the quadratic scan over fenced examples and the exact-budget edge (both open threads). Full suite and gates are green on the merged tree. Windows smoke had not started (the hosted Windows queue was stuck); every other check passed.

@xaleryb
xaleryb merged commit 5f6bd14 into intel:main Nov 28, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli-interface-change Changes dokimi's user-facing CLI surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants