Repository navigation
feat(extract)!: extract blocks without file= only with --update-source (#26) - #61
Merged
Merged
Conversation
|
|
The changes in this PR will be included in the next version bump.
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Closes #26
Summary
extractnow writes only blocks that havefile=. A block withoutfile=(an anonymous block) becomes a file only with--update-source, which also writes the generatedfile=back into the Markdown, so no extracted file is left linked to nothing.ExtractOptions.ignoreAnonymousandValidateOptions.ignoreAnonymousare removed.updateSourcedecides whether anonymous blocks are extracted.validate()for extract gainsupdateSource, and without it reports anonymous blocks withpath: null.--strictstill flags them asmissing_file_metadata.--update-source. So two documents that would both writeblock-1.share still refused before anything is written.examples/ci/validate-snippets.mjs: runnable blocks rarely havefile=, so it now pipes each document toextract --update-sourceon stdin. The user's Markdown is never rewritten; the updated Markdown comes back in the JSON result, which the script ignores. An unreadable document is still reported asio_error.ignore-anonymousinput.--update-source, the "Skip Anonymous Blocks" section removed, flags, JSON notes, API reference, and a breaking-change entry under Changes from Earlier Versions), CLI examples, the Agent Skill and the Intent records are updated. A pending bump file that mentionedignoreAnonymousno longer does.Evidence
Each of the brief's acceptance criteria, against the built CLI:
extract README.mdwitha.jsplus untaggedshandjsonblocksblock-2.sh,block-3.jsona.jsextract --update-source --force README.mdfile=block-2.sh,block-3.json, bothfile=addedextract a.md b.md, each with one untaggedshblockambiguous_targetonblock-1.sh--update-source --jsonambiguous_targetfor both documents, no files written, both documents unchangedextract --ignore-anonymous/validate --for extract --ignore-anonymouserror: unknown option '--ignore-anonymous', exit 1extract({ source, ignoreAnonymous: true })in TypeScriptextract.test.ts"skips blocks without file= unless updateSource names them in the markdown".validate.test.tsnow counts generated names only withupdateSource.validate --for extract, the--metatable and check-sync.--update-sourcewith--ignore-anonymousnow tests combining--update-sourcewith--check.pnpm checkpasses (pre-push).pnpm docs:examplesruns the README's 6 anonymous runnable blocks through the newvalidate-snippetspath, andintent maintainer check --base origin/mainshows 0 pending.Merge Danger
Door: two-way
Blast Radius: extract users
Scripts that relied on plain
extractwriting untagged blocks get nothing for them now. They need--update-source, which also edits their Markdown. Anyone passing--ignore-anonymousorignoreAnonymousgets an unknown-option error or a type error until they drop it. That's documented in Changes from Earlier Versions and the bump file.