Skip to content

AgentFilesPlugin writes md files to frontend_path subdir#6536

Open
masenf wants to merge 2 commits into
mainfrom
masenf/docs-ship-static-html
Open

AgentFilesPlugin writes md files to frontend_path subdir#6536
masenf wants to merge 2 commits into
mainfrom
masenf/docs-ship-static-html

Conversation

@masenf
Copy link
Copy Markdown
Collaborator

@masenf masenf commented May 20, 2026

This change is required because the build step that moves top-level dirs into the frontend_path subdir of the output directory uses overwrite=True by default. So any same-named directories in the output root silently overwrite the existing pre-rendered HTML files in the basename dir.

When the plugin just writes the markdown files into the basename dir itself, then there is no mv step that blows them away.

This change is required because the build step that moves top-level dirs into the frontend_path subdir of the output directory uses `overwrite=True` by default. So any same-named directories in the output root silently overwrite the existing pre-rendered HTML files in the basename dir.

When the plugin just writes the markdown files into the basename dir itself,
then there is no mv step that blows them away.
@masenf masenf requested review from a team and Alek99 as code owners May 20, 2026 02:54
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 20, 2026

Merging this PR will not alter performance

✅ 24 untouched benchmarks


Comparing masenf/docs-ship-static-html (ecc8ced) with main (5d65aa9)

Open in CodSpeed

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 20, 2026

Greptile Summary

This PR fixes a bug where AgentFilesPlugin.get_static_assets() wrote markdown files into public/ (the output root), causing a post-build step to overwrite pre-rendered HTML when frontend_path is set. The fix places the files under public/{frontend_path}/ instead, so they are already in the correct subdirectory and the overwrite no longer occurs.

  • Adds get_config() import at the top level and reads frontend_path in get_static_assets() to conditionally nest the output root.
  • When frontend_path is empty the behavior is unchanged; when it is set the markdown files land at public/{stripped_path}/ so they are served at the same URLs referenced in llms.txt.

Confidence Score: 5/5

The change is a narrow, targeted fix confined to a single method in one file, with correct logic for both the default and the frontend_path cases.

The fix correctly prepends the stripped frontend_path to the public root, ensuring markdown files land at the same URL they are referenced under in llms.txt. When frontend_path is empty the existing behavior is preserved. The only observation is that two local re-imports of get_config become redundant after the new top-level import, but this does not affect runtime behaviour.

docs/app/agent_files/_plugin.py — the redundant local imports in _llms_url_for_path and _docs_home_url are a minor cleanup opportunity.

Important Files Changed

Filename Overview
docs/app/agent_files/_plugin.py Adds a top-level import of get_config and uses it in get_static_assets() to prepend frontend_path to the public root; fixes the HTML overwrite bug, though two existing local re-imports of get_config are now redundant.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[get_static_assets called] --> B{frontend_path configured?}
    B -->|No| C[root = public]
    B -->|Yes| D[root = public/frontend_path]
    C --> E[Files written to public/url_path]
    D --> F[Files written to public/frontend_path/url_path]
    E --> G[Build step post-processes output]
    F --> G
    G --> H[Old: public dir at root moved to output/frontend_path]
    G --> I[New: files already under frontend_path subdir]
    H --> J[Overwrites pre-rendered HTML - BUG]
    I --> K[No collision with HTML - FIXED]
Loading

Comments Outside Diff (1)

  1. docs/app/agent_files/_plugin.py, line 114-118 (link)

    P2 The top-level import of get_config added by this PR makes the two existing local re-imports in _llms_url_for_path (line 116) and _docs_home_url (line 131) redundant. They shadow the module-level name with the identical object, which is harmless, but the local strip("/") approach they use also differs slightly from the lstrip("/") used here. Removing the local imports and aligning on one stripping strategy would reduce the inconsistency.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Reviews (1): Last reviewed commit: "AgentFilesPlugin writes md files to fron..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants