From ba8c28ed64e638afc43b60b09d1d4ae26e7ce922 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 20 Sep 2026 11:24:38 +0000 Subject: [PATCH 1/6] Initial plan From 3640e6d8738937c1400bd1475683ecedca28ce5d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 20 Sep 2026 11:26:08 +0000 Subject: [PATCH 2/6] feat: scaffold preview workflow and copilot instructions Co-authored-by: demccormack <52194107+demccormack@users.noreply.github.com> --- docs/README.md | 6 +- src/commands/new.ts | 23 +++++++ src/templates/book.toml | 2 +- src/templates/copilot-instructions.md | 86 +++++++++++++++++++++++++++ src/templates/main.tex | 2 +- src/templates/pdf_preview.yml | 78 ++++++++++++++++++++++++ test/new.test.ts | 58 ++++++++++++++++++ test/new.test.ts.snapshot | 2 +- 8 files changed, 252 insertions(+), 5 deletions(-) create mode 100644 src/templates/copilot-instructions.md create mode 100644 src/templates/pdf_preview.yml diff --git a/docs/README.md b/docs/README.md index 3c2cba5..5f3c8f4 100644 --- a/docs/README.md +++ b/docs/README.md @@ -35,8 +35,10 @@ This creates a local directory with the following structure: ``` my-amazing-book ├── .github +│   ├── copilot-instructions.md │   └── workflows -│   └── build.yml +│   ├── build.yml +│   └── pdf_preview.yml ├── .gitignore ├── assets │   ├── figures @@ -47,7 +49,7 @@ my-amazing-book ├── main.tex └── templates -8 directories, 5 files +8 directories, 7 files ``` diff --git a/src/commands/new.ts b/src/commands/new.ts index 54e2573..3662665 100644 --- a/src/commands/new.ts +++ b/src/commands/new.ts @@ -5,6 +5,7 @@ import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const TEMPLATES_DIR = join(__dirname, '..', 'templates'); +const DEFAULT_AUTHOR = 'Your Name'; /** * Read a template file and replace placeholders with actual values @@ -80,6 +81,7 @@ export async function createNewProject(title: string): Promise { // Create main.tex file const mainTexContent = await processTemplate('main.tex', { BOOK_TITLE: title, + BOOK_AUTHOR: DEFAULT_AUTHOR, }); await writeFile(join(projectPath, 'main.tex'), mainTexContent); @@ -92,6 +94,7 @@ export async function createNewProject(title: string): Promise { // Create book.toml configuration const bookTomlContent = await processTemplate('book.toml', { BOOK_TITLE: title, + BOOK_AUTHOR: DEFAULT_AUTHOR, }); await writeFile(join(projectPath, 'book.toml'), bookTomlContent); @@ -104,6 +107,26 @@ export async function createNewProject(title: string): Promise { join(projectPath, '.github', 'workflows', 'build.yml'), ); + const pdfPreviewContent = await processTemplate('pdf_preview.yml', { + BOOK_DIRECTORY: projectName, + }); + await writeFile( + join(projectPath, '.github', 'workflows', 'pdf_preview.yml'), + pdfPreviewContent, + ); + + const copilotInstructionsContent = await processTemplate( + 'copilot-instructions.md', + { + BOOK_TITLE: title, + BOOK_AUTHOR: DEFAULT_AUTHOR, + }, + ); + await writeFile( + join(projectPath, '.github', 'copilot-instructions.md'), + copilotInstructionsContent, + ); + console.log(`✓ Created project directory structure in ${projectName}/`); console.log(''); console.log('Next steps:'); diff --git a/src/templates/book.toml b/src/templates/book.toml index b4a7b79..3618b9d 100644 --- a/src/templates/book.toml +++ b/src/templates/book.toml @@ -1,6 +1,6 @@ [book] title = "{{BOOK_TITLE}}" -author = "Your Name" +author = "{{BOOK_AUTHOR}}" language = "en" [latex] diff --git a/src/templates/copilot-instructions.md b/src/templates/copilot-instructions.md new file mode 100644 index 0000000..522b33f --- /dev/null +++ b/src/templates/copilot-instructions.md @@ -0,0 +1,86 @@ +# Copilot Instructions + +## Project overview + +This repository contains the LaTeX source for *{{BOOK_TITLE}}*, a book being written by {{BOOK_AUTHOR}}. + +The content of the book is written by the author. Copilot's role in this repository is solely technical: maintaining and improving the LaTeX code, document structure, build system, and supporting tooling. + +## Important: preserve the author's writing + +Self-expression is a sacred act. The author's words are theirs, and theirs alone. + +Do not rewrite, edit, "improve", modernise, correct, or otherwise alter the wording of the book unless the prompt or issue explicitly asks for a textual change. + +This includes apparent: +- spelling or grammatical errors +- unusual punctuation +- unconventional capitalisation +- whitespace or line-break choices +- repeated words or phrases + +These may be deliberate choices. You may provide feedback on spelling or grammar, but do not make alterations. + +When a task concerns layout or typesetting, change the LaTeX markup rather than the text wherever possible. + +## LaTeX + +The project is built using `latexmk`. + +Before completing a change, build the project and verify that the +document compiles successfully. + +Use: + + latexmk -pdf main.tex + +unless the repository's existing configuration specifies a different build command. + +Follow the existing LaTeX structure and conventions rather than introducing new packages or abstractions unnecessarily. + +Prefer: +- simple, idiomatic LaTeX +- semantic commands over repeated formatting markup +- reusable commands/environments when formatting is genuinely shared +- small changes appropriate to the issue being addressed + +Avoid: +- unnecessary dependencies +- large-scale restructuring unrelated to the issue +- generated PDF/build artifacts in Git unless the repository already intentionally tracks them + +## Scope of agent work + +Copilot may autonomously make technical changes such as: + +- document layout and typography +- page and section formatting +- poem-specific LaTeX environments and commands +- table of contents behaviour +- headers and footers +- title/front-matter formatting +- page breaks and spacing +- build configuration +- `.gitignore` +- LaTeX warnings and errors +- refactoring repeated LaTeX markup +- scripts or tooling supporting the document build + +If a technical task would require changing the actual words of the book, preserve the text and explain the limitation instead. + +## Working on issues + +Treat the GitHub issue as the specification for the task. + +Keep changes focused on that issue. Do not opportunistically rewrite unrelated parts of the project. + +Inspect the existing implementation before deciding how to solve the problem. Preserve established conventions unless the issue specifically calls for changing them. + +After making changes: + +1. Build the complete document with `latexmk`. +2. Check the build output for relevant errors or warnings. +3. Confirm that the requested behaviour has been implemented. +4. Summarise the technical changes made and any significant design decisions. + +When visual appearance is relevant, make conservative changes unless the issue provides explicit design requirements. diff --git a/src/templates/main.tex b/src/templates/main.tex index 99eeda0..f6cfd1e 100644 --- a/src/templates/main.tex +++ b/src/templates/main.tex @@ -7,7 +7,7 @@ \usepackage{geometry} \geometry{margin=1in} -\newcommand{\bookauthor}{Your Name} +\newcommand{\bookauthor}{{{BOOK_AUTHOR}}} \title{{{BOOK_TITLE}}} \author{\bookauthor} \date{} diff --git a/src/templates/pdf_preview.yml b/src/templates/pdf_preview.yml new file mode 100644 index 0000000..54ccb5b --- /dev/null +++ b/src/templates/pdf_preview.yml @@ -0,0 +1,78 @@ +name: PDF Preview + +on: + pull_request: + +jobs: + build-pdf-preview: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Build PDF + uses: xu-cheng/latex-action@v4 + with: + root_file: main.tex + + - name: Rename PDF with commit SHA + run: mv main.pdf {{BOOK_DIRECTORY}}-${GITHUB_SHA}.pdf + + - name: Upload PDF artifact + id: upload-pdf + uses: actions/upload-artifact@v7 + with: + name: {{BOOK_DIRECTORY}}-${{ github.sha }}.pdf + path: {{BOOK_DIRECTORY}}-${{ github.sha }}.pdf + archive: false + + - name: Add PDF preview to PR + uses: actions/github-script@v9 + env: + ARTIFACT_URL: ${{ steps.upload-pdf.outputs.artifact-url }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + MERGE_SHA: ${{ github.sha }} + with: + script: | + const marker = ''; + const headSha = process.env.PR_HEAD_SHA; + const mergeSha = process.env.MERGE_SHA; + + const body = `${marker} + ### 📖 PDF Preview + + **[Open PDF preview ↗](${process.env.ARTIFACT_URL})** + + Includes PR commit ${headSha.substring(0, 7)} + Built from merge commit ${mergeSha.substring(0, 7)}`; + + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + + const existingComments = comments.filter( + comment => + comment.user.type === 'Bot' && + comment.body.includes(marker) + ); + + for (const comment of existingComments) { + await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: comment.id, + }); + } + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body, + }); diff --git a/test/new.test.ts b/test/new.test.ts index 891a2da..356870f 100644 --- a/test/new.test.ts +++ b/test/new.test.ts @@ -246,6 +246,64 @@ describe('write new command', () => { content.includes(`title = "${projectTitle}"`), 'Title should be substituted in book.toml', ); + assert( + content.includes('author = "Your Name"'), + 'Default author should be substituted in book.toml', + ); + }); + + test('should create templated automation files', async () => { + const projectTitle = 'Automation Test Book'; + const projectName = 'automation-test-book'; + const projectPath = join(TEST_PATH, projectName); + + await runCreateNewProject(projectTitle, TEST_PATH); + + const pdfPreviewPath = join( + projectPath, + '.github', + 'workflows', + 'pdf_preview.yml', + ); + const pdfPreviewContent = await readFile(pdfPreviewPath, 'utf8'); + assert( + pdfPreviewContent.includes('name: PDF Preview'), + 'Generated project should include a PDF preview workflow', + ); + assert( + pdfPreviewContent.includes( + `run: mv main.pdf ${projectName}-\${GITHUB_SHA}.pdf`, + ), + 'Generated PDF preview workflow should rename the PDF using the project name', + ); + assert( + pdfPreviewContent.includes( + `name: ${projectName}-\${{ github.sha }}.pdf`, + ), + 'Generated PDF preview workflow should upload an artifact named for the project', + ); + + const copilotInstructionsPath = join( + projectPath, + '.github', + 'copilot-instructions.md', + ); + const copilotInstructionsContent = await readFile( + copilotInstructionsPath, + 'utf8', + ); + assert( + copilotInstructionsContent.includes(`*${projectTitle}*`), + 'Copilot instructions should include the generated book title', + ); + assert( + copilotInstructionsContent.includes('written by Your Name'), + 'Copilot instructions should include the generated author', + ); + assert( + copilotInstructionsContent.includes('latexmk -pdf main.tex'), + 'Copilot instructions should include the build command guidance', + ); }); test('should handle titles with special characters', async () => { diff --git a/test/new.test.ts.snapshot b/test/new.test.ts.snapshot index e9e0dea..4b51a9e 100644 --- a/test/new.test.ts.snapshot +++ b/test/new.test.ts.snapshot @@ -1,3 +1,3 @@ exports[`write new command > should create project with correct structure (snapshot) 1`] = ` -"my-amazing-book\\n├── .github\\n│   └── workflows\\n│   └── build.yml\\n├── .gitignore\\n├── assets\\n│   ├── figures\\n│   └── images\\n├── book.toml\\n├── chapters\\n│   └── chapter01.tex\\n├── main.tex\\n└── templates\\n\\n8 directories, 5 files" +"my-amazing-book\\n├── .github\\n│   ├── copilot-instructions.md\\n│   └── workflows\\n│   ├── build.yml\\n│   └── pdf_preview.yml\\n├── .gitignore\\n├── assets\\n│   ├── figures\\n│   └── images\\n├── book.toml\\n├── chapters\\n│   └── chapter01.tex\\n├── main.tex\\n└── templates\\n\\n8 directories, 7 files" `; From adf00fc0f2e490657e21a5990853c614c3e6d183 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 20 Sep 2026 11:27:57 +0000 Subject: [PATCH 3/6] test: align automation scaffolding validation Co-authored-by: demccormack <52194107+demccormack@users.noreply.github.com> --- src/templates/copilot-instructions.md | 5 ++++- src/templates/pdf_preview.yml | 4 ++-- test/new.test.ts | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/templates/copilot-instructions.md b/src/templates/copilot-instructions.md index 522b33f..c61a32e 100644 --- a/src/templates/copilot-instructions.md +++ b/src/templates/copilot-instructions.md @@ -2,7 +2,7 @@ ## Project overview -This repository contains the LaTeX source for *{{BOOK_TITLE}}*, a book being written by {{BOOK_AUTHOR}}. +This repository contains the LaTeX source for _{{BOOK_TITLE}}_, a book being written by {{BOOK_AUTHOR}}. The content of the book is written by the author. Copilot's role in this repository is solely technical: maintaining and improving the LaTeX code, document structure, build system, and supporting tooling. @@ -13,6 +13,7 @@ Self-expression is a sacred act. The author's words are theirs, and theirs alone Do not rewrite, edit, "improve", modernise, correct, or otherwise alter the wording of the book unless the prompt or issue explicitly asks for a textual change. This includes apparent: + - spelling or grammatical errors - unusual punctuation - unconventional capitalisation @@ -39,12 +40,14 @@ unless the repository's existing configuration specifies a different build comma Follow the existing LaTeX structure and conventions rather than introducing new packages or abstractions unnecessarily. Prefer: + - simple, idiomatic LaTeX - semantic commands over repeated formatting markup - reusable commands/environments when formatting is genuinely shared - small changes appropriate to the issue being addressed Avoid: + - unnecessary dependencies - large-scale restructuring unrelated to the issue - generated PDF/build artifacts in Git unless the repository already intentionally tracks them diff --git a/src/templates/pdf_preview.yml b/src/templates/pdf_preview.yml index 54ccb5b..29762f7 100644 --- a/src/templates/pdf_preview.yml +++ b/src/templates/pdf_preview.yml @@ -26,8 +26,8 @@ jobs: id: upload-pdf uses: actions/upload-artifact@v7 with: - name: {{BOOK_DIRECTORY}}-${{ github.sha }}.pdf - path: {{BOOK_DIRECTORY}}-${{ github.sha }}.pdf + name: '{{BOOK_DIRECTORY}}-${{ github.sha }}.pdf' + path: '{{BOOK_DIRECTORY}}-${{ github.sha }}.pdf' archive: false - name: Add PDF preview to PR diff --git a/test/new.test.ts b/test/new.test.ts index 356870f..2a25d47 100644 --- a/test/new.test.ts +++ b/test/new.test.ts @@ -277,9 +277,7 @@ describe('write new command', () => { 'Generated PDF preview workflow should rename the PDF using the project name', ); assert( - pdfPreviewContent.includes( - `name: ${projectName}-\${{ github.sha }}.pdf`, - ), + pdfPreviewContent.includes(`${projectName}-\${{ github.sha }}.pdf`), 'Generated PDF preview workflow should upload an artifact named for the project', ); @@ -293,7 +291,9 @@ describe('write new command', () => { 'utf8', ); assert( - copilotInstructionsContent.includes(`*${projectTitle}*`), + copilotInstructionsContent.includes( + `This repository contains the LaTeX source for _${projectTitle}_,`, + ), 'Copilot instructions should include the generated book title', ); assert( From b772481e9da5eda945aa960895a5ddfbf60ba09d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 20 Sep 2026 11:29:05 +0000 Subject: [PATCH 4/6] fix: harden generated pdf preview workflow Co-authored-by: demccormack <52194107+demccormack@users.noreply.github.com> --- src/templates/pdf_preview.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/templates/pdf_preview.yml b/src/templates/pdf_preview.yml index 29762f7..5ec8333 100644 --- a/src/templates/pdf_preview.yml +++ b/src/templates/pdf_preview.yml @@ -28,7 +28,6 @@ jobs: with: name: '{{BOOK_DIRECTORY}}-${{ github.sha }}.pdf' path: '{{BOOK_DIRECTORY}}-${{ github.sha }}.pdf' - archive: false - name: Add PDF preview to PR uses: actions/github-script@v9 @@ -50,7 +49,7 @@ jobs: Includes PR commit ${headSha.substring(0, 7)} Built from merge commit ${mergeSha.substring(0, 7)}`; - const { data: comments } = await github.rest.issues.listComments({ + const comments = await github.paginate(github.rest.issues.listComments, { owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, From 7c17b66831f37e61fe08c62436f7a6036465e20c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 20 Sep 2026 16:29:33 +0000 Subject: [PATCH 5/6] refactor: fold pdf preview into build workflow Co-authored-by: demccormack <52194107+demccormack@users.noreply.github.com> --- docs/README.md | 5 +-- src/commands/new.ts | 13 ++---- src/templates/build.yml | 74 +++++++++++++++++++++++++++++---- src/templates/pdf_preview.yml | 77 ----------------------------------- test/new.test.ts | 26 +++++++----- test/new.test.ts.snapshot | 2 +- 6 files changed, 88 insertions(+), 109 deletions(-) delete mode 100644 src/templates/pdf_preview.yml diff --git a/docs/README.md b/docs/README.md index 5f3c8f4..7e467d3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -37,8 +37,7 @@ my-amazing-book ├── .github │   ├── copilot-instructions.md │   └── workflows -│   ├── build.yml -│   └── pdf_preview.yml +│   └── build.yml ├── .gitignore ├── assets │   ├── figures @@ -49,7 +48,7 @@ my-amazing-book ├── main.tex └── templates -8 directories, 7 files +8 directories, 6 files ``` diff --git a/src/commands/new.ts b/src/commands/new.ts index 3662665..f089d02 100644 --- a/src/commands/new.ts +++ b/src/commands/new.ts @@ -101,18 +101,13 @@ export async function createNewProject(title: string): Promise { // Create .gitignore for LaTeX projects await copyTemplate('.gitignore', join(projectPath, '.gitignore')); - // Create GitHub Actions workflow for PDF builds - await copyTemplate( - 'build.yml', - join(projectPath, '.github', 'workflows', 'build.yml'), - ); - - const pdfPreviewContent = await processTemplate('pdf_preview.yml', { + // Create GitHub Actions workflow for PDF builds and previews + const buildWorkflowContent = await processTemplate('build.yml', { BOOK_DIRECTORY: projectName, }); await writeFile( - join(projectPath, '.github', 'workflows', 'pdf_preview.yml'), - pdfPreviewContent, + join(projectPath, '.github', 'workflows', 'build.yml'), + buildWorkflowContent, ); const copilotInstructionsContent = await processTemplate( diff --git a/src/templates/build.yml b/src/templates/build.yml index 568dd85..231c296 100644 --- a/src/templates/build.yml +++ b/src/templates/build.yml @@ -4,31 +4,87 @@ on: push: branches: [main] pull_request: - branches: [main] + workflow_dispatch: jobs: build: runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Setup LaTeX - uses: xu-cheng/latex-action@v3 + uses: xu-cheng/latex-action@v4 with: root_file: main.tex - - name: Upload PDF - uses: actions/upload-artifact@v4 + - name: Rename PDF with commit SHA + run: mv main.pdf {{BOOK_DIRECTORY}}-${{ github.sha }}.pdf + + - name: Upload PDF preview artifact + id: upload-pdf + uses: actions/upload-artifact@v7 + with: + name: {{BOOK_DIRECTORY}}-${{ github.sha }}.pdf + path: {{BOOK_DIRECTORY}}-${{ github.sha }}.pdf + archive: false + + - name: Add PDF preview to PR + if: github.event_name == 'pull_request' + uses: actions/github-script@v9 + env: + ARTIFACT_URL: ${{ steps.upload-pdf.outputs.artifact-url }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + MERGE_SHA: ${{ github.sha }} with: - name: ${{ github.event.repository.name }}-pdf - path: main.pdf + script: | + const marker = ''; + const headSha = process.env.PR_HEAD_SHA; + const mergeSha = process.env.MERGE_SHA; + + const body = `${marker} + ### 📖 PDF Preview + + **[Open PDF preview ↗](${process.env.ARTIFACT_URL})** + + Includes PR commit ${headSha.substring(0, 7)} + Built from merge commit ${mergeSha.substring(0, 7)}`; + + const comments = await github.paginate(github.rest.issues.listComments, { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + + const existingComments = comments.filter( + comment => + comment.user.type === 'Bot' && + comment.body.includes(marker) + ); + + for (const comment of existingComments) { + await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: comment.id, + }); + } + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body, + }); - name: Create Release (on tag) if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v3 with: - files: main.pdf + files: {{BOOK_DIRECTORY}}-${{ github.sha }}.pdf env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/src/templates/pdf_preview.yml b/src/templates/pdf_preview.yml deleted file mode 100644 index 5ec8333..0000000 --- a/src/templates/pdf_preview.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: PDF Preview - -on: - pull_request: - -jobs: - build-pdf-preview: - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - - steps: - - name: Checkout code - uses: actions/checkout@v7 - - - name: Build PDF - uses: xu-cheng/latex-action@v4 - with: - root_file: main.tex - - - name: Rename PDF with commit SHA - run: mv main.pdf {{BOOK_DIRECTORY}}-${GITHUB_SHA}.pdf - - - name: Upload PDF artifact - id: upload-pdf - uses: actions/upload-artifact@v7 - with: - name: '{{BOOK_DIRECTORY}}-${{ github.sha }}.pdf' - path: '{{BOOK_DIRECTORY}}-${{ github.sha }}.pdf' - - - name: Add PDF preview to PR - uses: actions/github-script@v9 - env: - ARTIFACT_URL: ${{ steps.upload-pdf.outputs.artifact-url }} - PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} - MERGE_SHA: ${{ github.sha }} - with: - script: | - const marker = ''; - const headSha = process.env.PR_HEAD_SHA; - const mergeSha = process.env.MERGE_SHA; - - const body = `${marker} - ### 📖 PDF Preview - - **[Open PDF preview ↗](${process.env.ARTIFACT_URL})** - - Includes PR commit ${headSha.substring(0, 7)} - Built from merge commit ${mergeSha.substring(0, 7)}`; - - const comments = await github.paginate(github.rest.issues.listComments, { - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - }); - - const existingComments = comments.filter( - comment => - comment.user.type === 'Bot' && - comment.body.includes(marker) - ); - - for (const comment of existingComments) { - await github.rest.issues.deleteComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: comment.id, - }); - } - - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - body, - }); diff --git a/test/new.test.ts b/test/new.test.ts index 2a25d47..0208ac2 100644 --- a/test/new.test.ts +++ b/test/new.test.ts @@ -259,26 +259,32 @@ describe('write new command', () => { await runCreateNewProject(projectTitle, TEST_PATH); - const pdfPreviewPath = join( + const buildWorkflowPath = join( projectPath, '.github', 'workflows', - 'pdf_preview.yml', + 'build.yml', ); - const pdfPreviewContent = await readFile(pdfPreviewPath, 'utf8'); + const buildWorkflowContent = await readFile(buildWorkflowPath, 'utf8'); assert( - pdfPreviewContent.includes('name: PDF Preview'), - 'Generated project should include a PDF preview workflow', + buildWorkflowContent.includes('name: Build LaTeX PDF'), + 'Generated project should include the build workflow', ); assert( - pdfPreviewContent.includes( - `run: mv main.pdf ${projectName}-\${GITHUB_SHA}.pdf`, + buildWorkflowContent.includes( + `run: mv main.pdf ${projectName}-\${{ github.sha }}.pdf`, ), - 'Generated PDF preview workflow should rename the PDF using the project name', + 'Generated build workflow should rename the PDF using the project name', ); assert( - pdfPreviewContent.includes(`${projectName}-\${{ github.sha }}.pdf`), - 'Generated PDF preview workflow should upload an artifact named for the project', + buildWorkflowContent.includes( + `name: ${projectName}-\${{ github.sha }}.pdf`, + ), + 'Generated build workflow should upload an artifact named for the project', + ); + assert( + buildWorkflowContent.includes("if: github.event_name == 'pull_request'"), + 'Generated build workflow should only comment on pull requests', ); const copilotInstructionsPath = join( diff --git a/test/new.test.ts.snapshot b/test/new.test.ts.snapshot index 4b51a9e..27b4b3a 100644 --- a/test/new.test.ts.snapshot +++ b/test/new.test.ts.snapshot @@ -1,3 +1,3 @@ exports[`write new command > should create project with correct structure (snapshot) 1`] = ` -"my-amazing-book\\n├── .github\\n│   ├── copilot-instructions.md\\n│   └── workflows\\n│   ├── build.yml\\n│   └── pdf_preview.yml\\n├── .gitignore\\n├── assets\\n│   ├── figures\\n│   └── images\\n├── book.toml\\n├── chapters\\n│   └── chapter01.tex\\n├── main.tex\\n└── templates\\n\\n8 directories, 7 files" +"my-amazing-book\\n├── .github\\n│   ├── copilot-instructions.md\\n│   └── workflows\\n│   └── build.yml\\n├── .gitignore\\n├── assets\\n│   ├── figures\\n│   └── images\\n├── book.toml\\n├── chapters\\n│   └── chapter01.tex\\n├── main.tex\\n└── templates\\n\\n8 directories, 6 files" `; From 2a8e8ee089a41c45cea815041cdc98c0075a049c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 20 Sep 2026 16:30:14 +0000 Subject: [PATCH 6/6] test: validate consolidated build workflow scaffold Co-authored-by: demccormack <52194107+demccormack@users.noreply.github.com> --- src/templates/build.yml | 6 +++--- test/new.test.ts | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/templates/build.yml b/src/templates/build.yml index 231c296..e1a41e2 100644 --- a/src/templates/build.yml +++ b/src/templates/build.yml @@ -29,8 +29,8 @@ jobs: id: upload-pdf uses: actions/upload-artifact@v7 with: - name: {{BOOK_DIRECTORY}}-${{ github.sha }}.pdf - path: {{BOOK_DIRECTORY}}-${{ github.sha }}.pdf + name: '{{BOOK_DIRECTORY}}-${{ github.sha }}.pdf' + path: '{{BOOK_DIRECTORY}}-${{ github.sha }}.pdf' archive: false - name: Add PDF preview to PR @@ -85,6 +85,6 @@ jobs: if: startsWith(github.ref, 'refs/tags/') uses: softprops/action-gh-release@v3 with: - files: {{BOOK_DIRECTORY}}-${{ github.sha }}.pdf + files: '{{BOOK_DIRECTORY}}-${{ github.sha }}.pdf' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/test/new.test.ts b/test/new.test.ts index 0208ac2..0696228 100644 --- a/test/new.test.ts +++ b/test/new.test.ts @@ -277,9 +277,7 @@ describe('write new command', () => { 'Generated build workflow should rename the PDF using the project name', ); assert( - buildWorkflowContent.includes( - `name: ${projectName}-\${{ github.sha }}.pdf`, - ), + buildWorkflowContent.includes(`${projectName}-\${{ github.sha }}.pdf`), 'Generated build workflow should upload an artifact named for the project', ); assert(