Skip to content
Merged
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
14 changes: 12 additions & 2 deletions .github/workflows/jekyll.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ on:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
Expand All @@ -25,9 +23,13 @@ jobs:
# Build job
build:
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
Expand All @@ -43,10 +45,15 @@ jobs:
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

- name: Run custom scripts
run: |
ruby bin/merge_md_files.rb
php bin/gen_llms.php

- name: Build with Jekyll
# Outputs to the './_site' directory by default
Expand All @@ -59,6 +66,9 @@ jobs:

# Deployment job
deploy:
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ watch
/manuals/1.0/ja/1page.md
/manuals/1.0/en/onepage.md
/manuals/1.0/ja/onepage.md
llms-full.txt
/.claude
33 changes: 28 additions & 5 deletions bin/gen_llms.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public function expand(): bool

// Read the lines from llms.txt
$lines = file($this->llmsTxt, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($lines === false) {
throw new Exception("Unable to read source file {$this->llmsTxt}.");
}

$output = fopen($this->llmsFullTxt, 'w');
if (!$output) {
Expand All @@ -59,7 +62,7 @@ public function expand(): bool

foreach ($lines as $line) {
$processedLine = $this->processLinks($line);
fwrite($output, $processedLine . "\n");
$this->write($output, $processedLine . "\n");
}

fclose($output);
Expand Down Expand Up @@ -88,9 +91,9 @@ private function processUrl(string $line, $output) : void {
$content = $this->readLocalFile($localPath);
$processedContent = $this->processLinks($content);

fwrite($output, "# Source: $url\n\n");
fwrite($output, $processedContent . "\n\n");
fwrite($output, "--------------------\n\n");
$this->write($output, "# Source: $url\n\n");
$this->write($output, $processedContent . "\n\n");
$this->write($output, "--------------------\n\n");

} catch (Exception $e) {
echo " Error processing $url: " . $e->getMessage() . "\n";
Expand Down Expand Up @@ -139,7 +142,12 @@ private function readLocalFile(string $path) : string {
throw new Exception("File not found: $path");
}

return file_get_contents($path);
$content = file_get_contents($path);
if ($content === false) {
throw new Exception("Unable to read file: $path");
}

return $content;
}

private function processLinks(string $line): string
Expand All @@ -159,6 +167,10 @@ private function processLinks(string $line): string

// Remove front matter
$content = preg_replace('/^---.*?---/s', '', $content, 1);
if ($content === null) {
throw new Exception("Unable to strip front matter from file: $localPath");
}

return $content;

} catch (Exception $e) {
Expand All @@ -170,6 +182,17 @@ private function processLinks(string $line): string

return $line; // Return original line if not a matching link
}

/**
* @param resource $output
*/
private function write($output, string $content): void
{
$bytes = fwrite($output, $content);
if ($bytes === false || $bytes !== strlen($content)) {
throw new Exception("Unable to write complete content to {$this->llmsFullTxt}.");
}
}
}

// **Configuration - EDIT THESE TO MATCH YOUR SITE**
Expand Down
1 change: 1 addition & 0 deletions bin/serve_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set -euo pipefail
# Generate combined manuals and copy markdown files for llms.txt compliance after initial build
echo "Starting Jekyll server with llms.txt compliance..."
ruby bin/merge_md_files.rb
php bin/gen_llms.php
bundle exec jekyll build
./bin/copy_markdown_files.sh
bundle exec jekyll serve --watch --port 4001
Loading