-
Notifications
You must be signed in to change notification settings - Fork 6
fix(pipeline): register pipeline-volume-cover-concepts stage #262
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
+95
−0
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
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,84 @@ | ||
| /** | ||
| * Seed the `pipeline-volume-cover-concepts` stage into existing installs. | ||
| * | ||
| * Commit d802eb18 ("feat(pipeline): issue back covers + volume covers + | ||
| * trade-paperback PDF") shipped the per-season cover-concept LLM step | ||
| * (`arcPlanner.generateVolumeCoverConcepts` → `runStagedLLM('pipeline-volume-cover-concepts', …)`) | ||
| * and added `data.sample/prompts/stages/pipeline-volume-cover-concepts.md` | ||
| * but forgot two things existing installs need: | ||
| * | ||
| * 1. A `stage-config.json` entry — `setup-data.js` only merges | ||
| * `JSON_MERGE_TARGETS` on fresh setup, so existing installs that | ||
| * upgrade-and-restart never get the new entry and `prompts.getStage()` | ||
| * throws "Stage pipeline-volume-cover-concepts not found". | ||
| * 2. The `.md` template — `ensureSampleContent` copies *missing* prompt | ||
| * files on next run so a fresh install gets it, but an upgrade that | ||
| * skips re-running setup-data leaves it absent. | ||
| * | ||
| * This migration fixes both for existing installs. Modeled on the same | ||
| * idempotent pattern as `015-importer-stage-prompts.js`. | ||
| */ | ||
|
|
||
| import { access, copyFile, mkdir, readFile, writeFile, constants } from 'fs/promises'; | ||
| import { dirname, join } from 'path'; | ||
|
|
||
| const FILENAME = 'pipeline-volume-cover-concepts.md'; | ||
| const STAGE_KEY = 'pipeline-volume-cover-concepts'; | ||
|
|
||
| export default { | ||
| async up({ rootDir }) { | ||
| const stagesDir = join(rootDir, 'data', 'prompts', 'stages'); | ||
| await mkdir(stagesDir, { recursive: true }); | ||
|
|
||
| const dataPath = join(stagesDir, FILENAME); | ||
| const samplePath = join(rootDir, 'data.sample', 'prompts', 'stages', FILENAME); | ||
|
|
||
| const exists = await access(dataPath, constants.F_OK).then(() => true, () => false); | ||
| if (exists) { | ||
| console.log(`📝 volume-cover-concepts prompt: already present`); | ||
| } else { | ||
| const sampleExists = await access(samplePath, constants.F_OK).then(() => true, () => false); | ||
| if (!sampleExists) { | ||
| console.warn(`⚠️ volume-cover-concepts: sample missing for ${FILENAME} — skipping copy`); | ||
| } else { | ||
| try { | ||
| await copyFile(samplePath, dataPath); | ||
| console.log(`✅ seeded ${FILENAME}`); | ||
| } catch (err) { | ||
| console.warn(`⚠️ volume-cover-concepts: copy failed for ${FILENAME}: ${err.message}`); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const installedConfigPath = join(rootDir, 'data', 'prompts', 'stage-config.json'); | ||
| const sampleConfigPath = join(rootDir, 'data.sample', 'prompts', 'stage-config.json'); | ||
| const sampleConfigExists = await access(sampleConfigPath, constants.F_OK).then(() => true, () => false); | ||
| if (!sampleConfigExists) { | ||
| console.warn('⚠️ volume-cover-concepts: data.sample stage-config.json missing — cannot resolve entry; skipping config write'); | ||
| return; | ||
| } | ||
| try { | ||
| const sample = JSON.parse(await readFile(sampleConfigPath, 'utf8')); | ||
| const installedExists = await access(installedConfigPath, constants.F_OK).then(() => true, () => false); | ||
| const installed = installedExists | ||
| ? JSON.parse(await readFile(installedConfigPath, 'utf8')) | ||
| : { stages: {} }; | ||
| installed.stages = installed.stages || {}; | ||
| if (installed.stages[STAGE_KEY]) { | ||
| console.log(`📝 volume-cover-concepts stage-config: already present`); | ||
| return; | ||
| } | ||
| if (!sample?.stages?.[STAGE_KEY]) { | ||
| console.warn(`⚠️ volume-cover-concepts: sample stage-config missing ${STAGE_KEY} — skipping`); | ||
| return; | ||
| } | ||
| installed.stages[STAGE_KEY] = sample.stages[STAGE_KEY]; | ||
| await mkdir(dirname(installedConfigPath), { recursive: true }); | ||
| await writeFile(installedConfigPath, JSON.stringify(installed, null, 2) + '\n', 'utf8'); | ||
| const action = installedExists ? 'merged' : 'created'; | ||
| console.log(`📝 volume-cover-concepts stage-config (${action}): 1 added`); | ||
| } catch (err) { | ||
| console.warn(`⚠️ volume-cover-concepts: stage-config merge failed: ${err.message}`); | ||
| } | ||
| }, | ||
| }; | ||
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.