-
Notifications
You must be signed in to change notification settings - Fork 1
Generate LLMs text during site build #29
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
Merged
Changes from all commits
Commits
Show all changes
2 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| name: Deploy Jekyll site to Pages | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["master"] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: "pages" | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-22.04 | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Setup Ruby | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.2.2' | ||
| bundler-cache: true | ||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '8.3' | ||
| - name: Setup Pages | ||
| id: pages | ||
| uses: actions/configure-pages@v5 | ||
| - name: Run custom scripts | ||
| run: | | ||
| ruby bin/merge_md_files.rb | ||
| php bin/generate_llms_full.php | ||
| - name: Build with Jekyll | ||
| run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" | ||
| env: | ||
| JEKYLL_ENV: production | ||
| - name: Upload artifact | ||
| uses: actions/upload-pages-artifact@v3 | ||
|
|
||
| deploy: | ||
| permissions: | ||
| pages: write | ||
| id-token: write | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| runs-on: ubuntu-22.04 | ||
| needs: build | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 | ||
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 |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| _site/ | ||
| watch | ||
| llms-full.txt |
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,83 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * Generate llms-full.txt from llms.txt and English manual markdown files. | ||
| */ | ||
|
|
||
| $baseDir = dirname(__DIR__); | ||
| $llmsFile = $baseDir . '/llms.txt'; | ||
| $manualDir = $baseDir . '/manuals/1.0/en'; | ||
| $outputFile = $baseDir . '/llms-full.txt'; | ||
|
|
||
| if (! is_file($llmsFile)) { | ||
| fwrite(STDERR, "llms.txt not found at {$llmsFile}\n"); | ||
| exit(1); | ||
| } | ||
|
|
||
| if (! is_dir($manualDir)) { | ||
| fwrite(STDERR, "Manual directory not found at {$manualDir}\n"); | ||
| exit(1); | ||
| } | ||
|
|
||
| $skipFiles = [ | ||
| '1page.md' => true, | ||
| 'onepage.md' => true, | ||
| 'ai-assistant.md' => true, | ||
| ]; | ||
|
|
||
| $files = []; | ||
| $iterator = new RecursiveIteratorIterator( | ||
| new RecursiveDirectoryIterator($manualDir, FilesystemIterator::SKIP_DOTS), | ||
| ); | ||
|
|
||
| foreach ($iterator as $file) { | ||
| if (! $file instanceof SplFileInfo || $file->getExtension() !== 'md') { | ||
| continue; | ||
| } | ||
|
|
||
| if (isset($skipFiles[$file->getBasename()])) { | ||
| continue; | ||
| } | ||
|
|
||
| $files[] = $file->getPathname(); | ||
| } | ||
|
|
||
| sort($files, SORT_STRING); | ||
|
|
||
| $llmsContent = file_get_contents($llmsFile); | ||
| if ($llmsContent === false) { | ||
| fwrite(STDERR, "Failed to read llms.txt at {$llmsFile}\n"); | ||
| exit(1); | ||
| } | ||
|
|
||
| $content = rtrim($llmsContent) . "\n\n---\n\n# Full Documentation\n\n"; | ||
|
|
||
| foreach ($files as $file) { | ||
| $markdown = file_get_contents($file); | ||
| if ($markdown === false) { | ||
| fwrite(STDERR, "Failed to read markdown file at {$file}\n"); | ||
| exit(1); | ||
| } | ||
|
|
||
| $markdown = preg_replace('/\A---\s*\R.*?\R---\s*\R/ms', '', $markdown, 1) ?? $markdown; | ||
| $markdown = trim($markdown); | ||
|
|
||
| if ($markdown === '') { | ||
| continue; | ||
| } | ||
|
|
||
| $relativePath = ltrim(str_replace($baseDir, '', $file), '/'); | ||
| $content .= "<!-- Source: {$relativePath} -->\n\n"; | ||
| $content .= $markdown . "\n\n"; | ||
| } | ||
|
|
||
| $bytesWritten = file_put_contents($outputFile, $content); | ||
| if ($bytesWritten === false || $bytesWritten !== strlen($content)) { | ||
| fwrite(STDERR, "Failed to write complete llms-full.txt to {$outputFile}\n"); | ||
| exit(1); | ||
| } | ||
|
|
||
| echo "Generated llms-full.txt successfully.\n"; | ||
| echo 'Included files: ' . count($files) . "\n"; |
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 |
|---|---|---|
| @@ -1,6 +1,11 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
| trap 'echo "serve_local.sh failed; check merge_md_files.rb, generate_llms_full.php, or Jekyll output above." >&2' ERR | ||
|
|
||
| # This script is used to serve the Jekyll site locally with automatic rebuilding. | ||
| # 'bundle exec' ensures we're using the correct versions of each gem according to our Gemfile.lock. | ||
| # 'jekyll serve' starts a Jekyll development server. | ||
| # '--watch' option automatically rebuilds the site when files are modified. | ||
| ruby bin/merge_md_files.rb | ||
| php bin/generate_llms_full.php | ||
| bundle exec jekyll serve --watch --trace |
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.