Extract extractJsonFromFence into a shared src/utils/json-fence.js#55
Merged
Extract extractJsonFromFence into a shared src/utils/json-fence.js#55
extractJsonFromFence into a shared src/utils/json-fence.js#55Conversation
The same fence-extraction helper — find the first ```json or ``` opener and slice to the LAST closing fence so nested ``` inside JSON values (a `directory_structure` markdown tree, for instance) don't truncate the capture — was defined verbatim in `src/ai/prompts/new.js` and `src/ai/prompts/greenfield.js`. The greenfield copy carried an explanatory comment; the new.js copy didn't. Both flowed through every JSON-shaped model call (`parsePlanResponse`, `parseQuestionsResponse`, `parseStacksResponse`). New module hosts the function as a named export. Both prompt modules now import it. Adds `test/utils/json-fence.test.js` with five direct cases (no fence, ```json fence, bare fence, nested ``` inside payload, missing closing fence) so the helper has direct coverage instead of relying on the parse-response tests for indirect coverage. 312 tests passing (+5 from the new file), lint clean.
4 tasks
4nkur
added a commit
that referenced
this pull request
Apr 29, 2026
The polish + cleanup release. Half ergonomic improvements (`draftwise init` auto-detects new project vs existing codebase from the filesystem instead of asking; plain-language UX throughout init — #51), half code-quality work (five small dedup + tidy PRs that shrink the public API surface, fix two user-visible `draft` → `draftwise` typos in error messages, and consolidate drafting-command boilerplate behind shared helpers — #53/#54/#55/#56/#57). One genuinely new surface: `draftwise skills <install|uninstall|help>` drops standalone slash-command skills into Claude Code, Cursor, and Gemini CLI's user-level skill dirs (#52) — same SKILL.md, per-provider frontmatter trim — independent of the Claude Code marketplace plugin. Bumps `package.json` + `package-lock.json` from 0.2.0 → 0.2.1. Patch bump because the additive `skills` verb is non-breaking and the removed prompt aliases (`PLAN_SYSTEM`, `SPEC_SYSTEM`, `tech.SYSTEM`, `tasks.SYSTEM`) were never imported by anyone outside this repo (verified by audit). Rolls all [Unreleased] entries into [0.2.1] — 2026-04-29 — Ankur, with a fresh empty [Unreleased] block above. After merge, ritual: `git tag -a v0.2.1 -m "v0.2.1"`, `git push origin v0.2.1`, `npm publish` (interactive — OTP + login may be needed if the npm session expired).
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.
Summary
```jsonor```opener and slice to the last closing fence so nested```inside JSON values (adirectory_structuremarkdown tree, for instance) don't truncate the capture — was defined verbatim insrc/ai/prompts/new.jsandsrc/ai/prompts/greenfield.js. The greenfield copy carried an explanatory comment; the new.js copy didn't. Both flowed through every JSON-shaped model call (parsePlanResponse,parseQuestionsResponse,parseStacksResponse).src/utils/json-fence.jshosts the function as a named export. Both prompt modules now import it.test/utils/json-fence.test.jswith five direct cases (no fence,json fence, bare fence, nestedinside payload, missing closing fence) so the helper has direct coverage instead of relying on the parse-response tests for indirect coverage.Test plan
npm test— 312 passing (+5 from the new test file)npm run lint— cleanparse*Responsefunctions