-
Notifications
You must be signed in to change notification settings - Fork 163
Agent-friendly documentation: .md companions, llms.txt, coding-agent guide (HF-154) #1703
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
Open
marcin-kordas-hoc
wants to merge
31
commits into
develop
Choose a base branch
from
feat/hf-154-agent-friendly-docs
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+696
−3
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
e608c4d
chore(scripts): add extract-public-api.js for cross-repo contract che…
marcin-kordas-hoc 34c32d5
fix(scripts): make extract-public-api.js lint-clean under project ESL…
marcin-kordas-hoc 760ab4a
docs(specs): add HF-154 agent-friendly docs design spec
marcin-kordas-hoc 25a4097
docs(specs): harden HF-154 spec after brutal-honesty review
marcin-kordas-hoc 7ff9263
docs(plans): add HF-154 implementation plan
marcin-kordas-hoc c43e81a
feat(docs): add md-companions plugin for .md exports and llms-full.txt
marcin-kordas-hoc 88827ee
feat(docs): add Copy Markdown button global component
marcin-kordas-hoc 9613c94
feat(docs): add Set up your coding agent page and interactive wizard
marcin-kordas-hoc c8f3d5d
docs: add llms.txt and link llms-full.txt from robots.txt
marcin-kordas-hoc 4e8a008
fix(docs): handle :::example and any unknown container types in md-co…
marcin-kordas-hoc d3fff0c
feat(docs): wire md-companions plugin, Copy Markdown button, and setu…
marcin-kordas-hoc 89f27b2
fix(docs): address code-review findings in HF-154 components
marcin-kordas-hoc 5bb49aa
Merge remote-tracking branch 'upstream/develop' into feat/hf-154-agen…
marcin-kordas-hoc c429eeb
docs(hf-154): add context7.json + GitMCP/Context7 agent doc-access se…
marcin-kordas-hoc f49d15b
test(docs): run md-companions strip test in CI (HF-154)
marcin-kordas-hoc 062625f
docs: remove internal HF-154 plan/spec from public docs
marcin-kordas-hoc 516d5ad
docs(hf-154): drop out-of-scope extract-public-api.js + its eslint ca…
marcin-kordas-hoc d47ac0f
Merge remote-tracking branch 'upstream/develop' into feat/hf-154-agen…
marcin-kordas-hoc ddfa8f0
docs(hf-154): point CHANGELOG entry at upstream PR #1703
marcin-kordas-hoc c0cc9c5
ci(docs): bump Netlify deploy Node 18 -> 22 to match docs CI
marcin-kordas-hoc 01072d5
docs(hf-154): honest Copy-Markdown label + drop inert robots.txt comm…
marcin-kordas-hoc f0b5b28
fix(hf-154): strip inline Vue components (e.g. <Badge/>) from .md corpus
marcin-kordas-hoc c0f1ac6
refactor(hf-154): dedupe clipboard helper + strip paired block-compon…
marcin-kordas-hoc f609b42
fix(hf-154): address review findings (strip edge-cases, corpus comple…
marcin-kordas-hoc 76c3f14
fix(hf-154): make copyToClipboard fallback truly non-throwing
marcin-kordas-hoc daed5f4
docs(hf-154): clarify per-page .md wording (page URL, not any URL)
marcin-kordas-hoc c41eed6
fix(hf-154): address Cursor Bugbot review (corpus fidelity + root dis…
marcin-kordas-hoc 72b07f6
Merge remote-tracking branch 'upstream/develop' into feat/hf-154-agen…
marcin-kordas-hoc c7502f7
fix(hf-154): keep {{ }} interpolations verbatim instead of wiping them
marcin-kordas-hoc 6412a33
fix(hf-154): exclude docs/.vuepress from Context7 indexing
marcin-kordas-hoc 861c816
fix(hf-154): strip inline [[toc]] markers too
marcin-kordas-hoc 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "$schema": "https://context7.com/schema/context7.json", | ||
| "projectTitle": "HyperFormula", | ||
| "description": "Headless, Excel-compatible spreadsheet engine in TypeScript — parses and evaluates ~400 functions in the browser or Node.js. In-process library (no REST API).", | ||
| "folders": ["docs"], | ||
| "excludeFolders": ["docs/.vuepress", "docs/api"], | ||
| "rules": [ | ||
| "HyperFormula is an in-process library, not a REST API — there is no HTTP endpoint or base URL.", | ||
| "Public API cell addresses are 0-indexed: { sheet, col, row }.", | ||
| "There is no #CALC! error type.", | ||
| "EmptyValue is exported as a Symbol, not null/undefined.", | ||
| "A license key is required when constructing the engine (use 'gpl-v3' for open-source use)." | ||
| ] | ||
| } |
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,93 @@ | ||
| <template> | ||
| <div class="agent-wizard"> | ||
| <div v-if="!selected" class="agent-wizard__choices"> | ||
| <p class="agent-wizard__prompt">Which coding agent do you use?</p> | ||
| <button | ||
| v-for="opt in options" | ||
| :key="opt.id" | ||
| class="agent-wizard__choice" | ||
| type="button" | ||
| @click="selected = opt.id" | ||
| >{{ opt.label }}</button> | ||
| </div> | ||
|
|
||
| <div v-else class="agent-wizard__result"> | ||
| <button class="agent-wizard__back" type="button" @click="reset">← Change</button> | ||
| <h3>{{ current.label }}</h3> | ||
| <pre class="agent-wizard__snippet"><code>{{ current.snippet }}</code></pre> | ||
| <button class="agent-wizard__copy" type="button" @click="copy">{{ copied ? 'Copied!' : 'Copy' }}</button> | ||
| <p class="agent-wizard__note" v-html="current.note"></p> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { copyToClipboard } from './clipboard'; | ||
|
|
||
| export default { | ||
| name: 'CodingAgentWizard', | ||
| data() { | ||
| return { | ||
| selected: null, | ||
| copied: false, | ||
| options: [ | ||
| { | ||
| id: 'claude-code', | ||
| label: 'Claude Code', | ||
| snippet: '/plugin marketplace add handsontable/handsontable-skills\n/plugin install handsontable-skills@handsontable-skills', | ||
| note: 'Installs the official <code>hyperformula</code> skill. Claude Code loads it automatically.', | ||
| }, | ||
| { | ||
| id: 'cursor', | ||
| label: 'Cursor', | ||
| snippet: 'Add to your AGENTS.md / rules file:\nHyperFormula docs (LLM-friendly): https://hyperformula.handsontable.com/docs/llms-full.txt', | ||
| note: 'Cursor has no Claude-skill installer yet — point it at the full docs corpus instead.', | ||
| }, | ||
| { | ||
| id: 'copilot', | ||
| label: 'GitHub Copilot', | ||
| snippet: 'Add to .github/copilot-instructions.md:\nReference HyperFormula docs: https://hyperformula.handsontable.com/docs/llms-full.txt', | ||
| note: 'Copilot reads an instructions file — link it to the corpus so it fetches authoritative docs.', | ||
| }, | ||
| { | ||
| id: 'other', | ||
| label: 'Other / API', | ||
| snippet: 'curl -s https://hyperformula.handsontable.com/docs/llms-full.txt', | ||
| note: 'Fetch the full corpus, or upload the skill folder from <code>handsontable/handsontable-skills</code> to the Claude API.', | ||
| }, | ||
| ], | ||
| }; | ||
| }, | ||
| computed: { | ||
| current() { | ||
| return this.options.find(o => o.id === this.selected) || null; | ||
| }, | ||
| }, | ||
| methods: { | ||
| reset() { this.selected = null; this.copied = false; }, | ||
| copy() { | ||
| if (!this.current) return; | ||
| copyToClipboard(this.current.snippet).then(() => { | ||
| this.copied = true; | ||
| setTimeout(() => { this.copied = false; }, 1500); | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .agent-wizard { border: 1px solid #eaecef; border-radius: 6px; padding: 1rem 1.25rem; margin: 1.5rem 0; } | ||
| .agent-wizard__prompt { font-weight: 600; margin: 0 0 0.75rem; } | ||
| .agent-wizard__choice, | ||
| .agent-wizard__copy, | ||
| .agent-wizard__back { | ||
| cursor: pointer; border: 1px solid #3eaf7c; background: #fff; color: #3eaf7c; | ||
| border-radius: 4px; padding: 0.4rem 0.8rem; margin: 0 0.5rem 0.5rem 0; font-size: 0.9rem; | ||
| } | ||
| .agent-wizard__choice:hover, | ||
| .agent-wizard__copy:hover { background: #3eaf7c; color: #fff; } | ||
| .agent-wizard__back { border-color: #ccc; color: #666; } | ||
| .agent-wizard__snippet { background: #f6f6f6; padding: 0.75rem; border-radius: 4px; overflow-x: auto; } | ||
| .agent-wizard__note { font-size: 0.85rem; color: #666; } | ||
| </style> |
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,63 @@ | ||
| <template> | ||
| <button | ||
| v-if="mdUrl" | ||
| class="copy-md-button" | ||
| type="button" | ||
| :title="'Copy this page as Markdown URL for LLMs'" | ||
| @click="copy" | ||
| >{{ label }}</button> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { copyToClipboard } from './clipboard'; | ||
|
|
||
| export default { | ||
| name: 'CopyMarkdownButton', | ||
| data() { | ||
| return { copied: false }; | ||
| }, | ||
| computed: { | ||
| mdUrl() { | ||
| const p = this.$page && this.$page.path; | ||
| // The 404 page is excluded from companion generation — no button there. | ||
| if (!p || p === '/404.html') return null; | ||
| // `.html` page → sibling `.md`; directory / landing URL (`/`, `/guide/`) | ||
| // → its `index.md` companion. Both are emitted by the md-companions plugin, | ||
| // so the button is available on every generated page. | ||
| if (/\.html$/.test(p)) return this.$withBase(p.replace(/\.html$/, '.md')); | ||
| if (p.endsWith('/')) return this.$withBase(`${p}index.md`); | ||
| return null; | ||
| }, | ||
| label() { | ||
| return this.copied ? 'Copied!' : 'Copy Markdown link'; | ||
| }, | ||
| }, | ||
| methods: { | ||
| copy() { | ||
| const absolute = window.location.origin + this.mdUrl; | ||
| copyToClipboard(absolute).then(() => { | ||
| this.copied = true; | ||
| setTimeout(() => { this.copied = false; }, 1500); | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .copy-md-button { | ||
| position: fixed; | ||
| bottom: 1.5rem; | ||
| right: 1.5rem; | ||
| z-index: 100; | ||
| padding: 0.5rem 0.9rem; | ||
| font-size: 0.85rem; | ||
| border: 1px solid #3eaf7c; | ||
| border-radius: 4px; | ||
| background: #fff; | ||
| color: #3eaf7c; | ||
| cursor: pointer; | ||
| box-shadow: 0 1px 4px rgba(0,0,0,0.12); | ||
| } | ||
| .copy-md-button:hover { background: #3eaf7c; color: #fff; } | ||
| </style> |
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,29 @@ | ||
| /** | ||
| * Copy text to the clipboard, falling back to a hidden `<textarea>` + | ||
| * `execCommand('copy')` when the async Clipboard API is unavailable (insecure | ||
| * context / older browsers). Always resolves, so callers can chain a single | ||
| * `.then()` for their "Copied!" state regardless of which path ran. | ||
| * | ||
| * @param {string} text text to place on the clipboard | ||
| * @returns {Promise<void>} | ||
| */ | ||
| export function copyToClipboard(text) { | ||
| const fallback = () => { | ||
| // Never throw: the "always resolves" contract must hold even if the DOM | ||
| // or execCommand path fails (e.g. detached document, disabled command). | ||
| try { | ||
| const el = document.createElement('textarea'); | ||
| el.value = text; | ||
| el.style.position = 'fixed'; | ||
| el.style.opacity = '0'; | ||
| document.body.appendChild(el); | ||
| el.select(); | ||
| try { document.execCommand('copy'); } finally { document.body.removeChild(el); } | ||
| } catch (_) { /* clipboard truly unavailable — nothing more we can do */ } | ||
| }; | ||
| if (navigator.clipboard && window.isSecureContext) { | ||
| return navigator.clipboard.writeText(text).catch(fallback); | ||
| } | ||
| fallback(); | ||
| return Promise.resolve(); | ||
| } |
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,74 @@ | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const { stripVuePressSyntax } = require('./strip'); | ||
|
|
||
| /** | ||
| * VuePress plugin: after build, write a clean `.md` companion next to each | ||
| * rendered `.html`, plus an aggregate `llms-full.txt`. Respects ctx.outDir | ||
| * (which already includes the configured base segment). | ||
| * @param {object} options plugin options | ||
| * @param {object} ctx VuePress app context | ||
| */ | ||
| module.exports = (options, ctx) => ({ | ||
| name: 'md-companions', | ||
| async generated() { | ||
| const hostname = (options && options.hostname) || 'https://hyperformula.handsontable.com'; | ||
| const base = ctx.base || '/'; | ||
| // Include `.html` pages AND clean-URL / section-index pages whose path ends | ||
| // in `/` (home, directory landings) — otherwise they are silently absent | ||
| // from the corpus. Skip the 404 page (never a useful companion). | ||
| const pages = ctx.pages.filter( | ||
| p => (/\.html$/.test(p.path) || p.path.endsWith('/')) && p.path !== '/404.html' | ||
| ); | ||
| const corpus = [ | ||
| '# HyperFormula Documentation', | ||
| '', | ||
| '> Full documentation corpus for LLM consumption.', | ||
| '> Each page below is also served as clean Markdown — append `.md` to a docs page URL.', | ||
| '', | ||
| ]; | ||
|
|
||
| for (const page of pages) { | ||
| try { | ||
| const clean = stripVuePressSyntax(page._strippedContent || ''); | ||
| // `.html` → `<slug>.md`; directory URL (`/guide/`) → `<dir>/index.md`. | ||
| const relPath = page.path.endsWith('/') | ||
| ? `${page.path}index.md` | ||
| : page.path.replace(/\.html$/, '.md'); | ||
| const outFile = path.join(ctx.outDir, relPath.replace(/^\//, '')); | ||
| await fs.promises.mkdir(path.dirname(outFile), { recursive: true }); | ||
| await fs.promises.writeFile(outFile, clean, 'utf8'); | ||
|
|
||
| const url = hostname + base.replace(/\/$/, '') + page.path.replace(/\.html$/, ''); | ||
| corpus.push('---', '', `## ${page.title || page.path}`, '', `URL: ${url}`, '', clean, ''); | ||
| } catch (err) { | ||
| console.warn(`[md-companions] skipping ${page.path}: ${err.message}`); | ||
| } | ||
| } | ||
|
|
||
| // Best-effort like the per-page writes: a corpus-write failure warns rather | ||
| // than aborting the whole docs build. | ||
| const corpusText = corpus.join('\n'); | ||
| try { | ||
| await fs.promises.writeFile(path.join(ctx.outDir, 'llms-full.txt'), corpusText, 'utf8'); | ||
| } catch (err) { | ||
| console.warn(`[md-companions] failed to write llms-full.txt: ${err.message}`); | ||
| } | ||
|
|
||
| // The site is served under base `/docs/` (GH Pages in prod, Netlify preview), | ||
| // but the llms.txt convention expects the index at the domain ROOT. Mirror | ||
| // both files one level above the base dir (the served root) so `/llms.txt` | ||
| // and `/llms-full.txt` resolve on GH Pages — where netlify.toml redirects do | ||
| // not apply. Best-effort: never fail the build over the mirror. | ||
| try { | ||
| const root = path.dirname(ctx.outDir); | ||
| await fs.promises.writeFile(path.join(root, 'llms-full.txt'), corpusText, 'utf8'); | ||
| const indexTxt = await fs.promises | ||
| .readFile(path.join(ctx.outDir, 'llms.txt'), 'utf8') | ||
| .catch(() => null); | ||
| if (indexTxt) await fs.promises.writeFile(path.join(root, 'llms.txt'), indexTxt, 'utf8'); | ||
| } catch (err) { | ||
| console.warn(`[md-companions] failed to mirror llms files to site root: ${err.message}`); | ||
| } | ||
| } | ||
| }); | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.