Skip to content

feat: improvements batch 1 — doctor command, conflict-ahead status, better API errors, auto-stash pull-merge, version fix#48

Open
rgonek wants to merge 1 commit intomainfrom
feature/improvements-batch-1
Open

feat: improvements batch 1 — doctor command, conflict-ahead status, better API errors, auto-stash pull-merge, version fix#48
rgonek wants to merge 1 commit intomainfrom
feature/improvements-batch-1

Conversation

@rgonek
Copy link
Owner

@rgonek rgonek commented Feb 27, 2026

Summary

Five targeted improvements to conf CLI reliability and observability:

1. Auto-Stash for pull-merge (cmd/push.go)

When push --on-conflict=pull-merge triggers an automatic pull, flagPullDiscardLocal is temporarily set to true so remote deletions are applied cleanly instead of being skipped with a warning.

2. Version Fix After Stash Restore (cmd/pull.go)

After a pull that stashed local changes, if the stash restore reintroduces an old version frontmatter value, fixPulledVersionsAfterStashRestore() patches each affected file on disk to match the version that was committed by the pull (read from git show HEAD:<path>). This prevents a stale version from causing an immediate conflict on the next push.

3. ConflictAhead in conf status (cmd/status.go)

StatusReport now includes a ConflictAhead []string field — pages that are both locally modified and ahead on the remote. These are the highest-priority conflicts. Printed as a dedicated Conflict ahead section in conf status output.

4. conf doctor command (cmd/doctor.go)

New command for consistency checking between .confluence-state.json, the actual filesystem, and page id frontmatter.

Detects:

  • Files in state that no longer exist on disk
  • State entries with empty page IDs
  • id frontmatter that doesn't match the state index
  • Git conflict markers (<<<<<<<) in file bodies
  • Files with an id in frontmatter that are not tracked in state

--repair flag auto-fixes: removes stale/empty state entries, adds untracked IDs to state. Non-repairable issues (id-mismatch, conflict markers) are listed for manual resolution.

5. Better API Error Messages (internal/confluence/client.go)

  • confluenceStatusHint(code int) — actionable hints for 401, 403, 409, 422, 429, 503, 413
  • mapConfluenceErrorCode(code string) — enriches known Confluence error codes (INVALID_IMAGE, MACRO_NOT_FOUND, TITLE_ALREADY_EXISTS, PERMISSION_DENIED, CONTENT_STALE, PARENT_PAGE_NOT_FOUND, INVALID_REQUEST_PARAMETER)
  • APIError.Error() falls back to confluenceStatusHint before the generic http.StatusText
  • decodeAPIErrorMessage checks code/errorKey/status fields and runs message strings through the mapper

Tests

  • cmd/doctor_test.go — 11 new tests covering all detection and repair cases
  • cmd/status_test.go — 5 new TestComputeConflictAhead sub-cases
  • cmd/pull_test.go — 2 new tests for fixPulledVersionsAfterStashRestore
  • internal/confluence/client_test.go — 5 new tests for error hint/mapping functions

All tests pass (go test ./...), linter clean (go vet ./...).

…uto-stash pull-merge, and version fix after stash restore

- push: auto-set flagPullDiscardLocal=true during pull-merge conflict path so remote deletions apply cleanly
- pull: fix version frontmatter after stash restore to reflect remote-pulled version, not pre-pull local version
- status: add ConflictAhead field and section for pages that are both locally modified and remote-ahead
- doctor: new command to check state/filesystem/frontmatter consistency with --repair flag
- confluence client: add confluenceStatusHint() and mapConfluenceErrorCode() for richer API error messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant