fix(hook,mcp): no-op hook outside zg repos + clear draft pin on tick - #15
Merged
Merged
Conversation
Two surgical fixes for issues hit during real use: - packages/git-hook: pre-commit hook now exits 0 silently when .zettelgeist.yaml is missing, instead of failing every commit with "error: not a zettelgeist repo". This unblocks repos where a stale install (or a partial init) left the hook behind. Users with broken hooks today must re-run `zettelgeist install-hook` to pick this up. - packages/mcp-server: tick_task now strips a `status: draft` frontmatter override on requirements.md as part of the same commit. The board's "+" button pins `status: draft` so new cards land in the draft column; without this, the override beat the derived status and cards stayed stuck on "draft" even after every task was ticked. Other override values are intentionally left alone; untick_task does not clear (lets users reset cards back to draft).
Read-side counterpart to the tick-side fix in this PR. Without this, specs already stuck (every task ticked, frontmatter still pins draft) required a manual frontmatter edit to unstick — the tick-clear path only fires on a fresh tick, which never happens once everything's done. deriveStatus now ignores `status: draft` when at least one counted task exists and every counted task is checked. Render-time fix — no file mutation, no migration. Other override values and partial- progress draft pins are untouched. Conformance fixture 19-all-statuses/a-draft is unaffected: its spec has zero counted tasks, so the override branch still wins.
Code review caught that the previous shape wrote requirements.md
directly (no temp+rename, before conformance ran), so a conformance
throw between the two writes would leave a half-applied state.
Refactor: replace `extraFiles` (caller pre-writes) with `extraWrites`
({ relPath, content }; helper writes via temp+rename inside its own
flow, before regen). Now both files reach disk via the same atomic
pattern as the primary write, and the failure mode is symmetric with
the existing single-file case — a conformance throw leaves a
consistent working-tree diff rather than a torn state.
Add a test for the status-only-frontmatter case (no other keys) so
the dump-empty-then-drop-fence branch is covered.
morrieinmaas
added a commit
that referenced
this pull request
Jun 1, 2026
- Version bump for the marketplace publish carrying the hook + tick + deriveStatus fixes from #15 (via @zettelgeist/core and @zettelgeist/git-hook workspace deps). Already published to Open VSX as morrieinmaas.zettelgeist@0.4.2; Microsoft Marketplace gets the vsix uploaded manually. - .env to .gitignore so local publish tokens (npm, ovsx) can't be committed accidentally.
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
Three real-use bugs surfaced by a user on
sensor-sender:Pre-commit hook blocks every commit in non-zg repos. A stale install (or a partial init) left a hook that ran
zettelgeist regen --check, which hard-errors withnot a zettelgeist repowhenever.zettelgeist.yamlis missing. Fix: the installed hook block now exits 0 silently when the config file is missing. Existing broken installs heal on the nextzettelgeist install-hook/zettelgeist initrun.Spec stuck in
draftafter all tasks ticked (write-side prevention). The board's "+" button pinsstatus: draftin frontmatter so the new card lands in the draft column. Nothing ever cleared the pin, so the frontmatter override beat the derived status forever. Fix:tick_taskstrips astatus: draftoverride onrequirements.mdas part of the same commit (other override values left alone;untick_taskdoes not clear, so reset-to-draft still works).Existing stuck specs self-heal on next render (read-side rescue). The write-side fix only helps if the user ticks ANOTHER task — useless for the spec already in the bug state (every task ticked, override pinned). Fix:
deriveStatusnow ignores astatus: draftoverride when at least one counted task exists and every counted task is checked. No file mutation, no migration, no user action — stuck specs unstick on next viewer/extension load.Changes
packages/git-hook/src/install-hook.ts— add[ -f .zettelgeist.yaml ] || exit 0toHOOK_BLOCK.packages/mcp-server/src/tools/write.ts—tickOrUntickstrips astatus: draftoverride on tick via a multi-file atomic write.packages/mcp-server/src/util/write-and-commit.ts— newextraWrites?: ReadonlyArray<{ relPath, content }>option. Helper writes all files via temp+rename before running conformance, so a conformance throw leaves a consistent working-tree diff rather than a torn state (failure mode symmetric with the existing single-file case).packages/core/src/status.ts—deriveStatusignoresstatus: draftoverride when all counted tasks are checked.19-all-statuses/a-draftunaffected becausecounted.length === 0).git-hookis inignoreso its change ships via the cli'sinstall-hookcommand.Code review
Independent code-reviewer agent flagged one real issue: the original write-side patch wrote
requirements.mdto disk beforewriteFileAndCommitran conformance — an asymmetric write pattern with a half-applied failure mode. Addressed in commit 4dadf60 (atomic multi-file write viaextraWrites). Also added a test for the status-only-frontmatter edge case that the reviewer noted was uncovered.Reviewer-noted concerns acknowledged but not changed:
drafton a single-task spec deliberately — narrow enough we accept it; the alternative is users with stuck cards.Test plan
pnpm -r typecheck— cleanpnpm -r test— all 9 packages, all green (190 core / 45 mcp / 117 cli / +others)pnpm conformance— 46 fixtures pass