Resolve conflicts

From indigoai-us/hq-core · View interactive version

Resolve conflicts is an AI agent skill from the GitHub repository indigoai-us/hq-core. Resolve HQ Sync conflicts by choosing local, cloud, or discard.

How to use this skill

Skill file

/resolve-conflicts

Interactive conflict resolution for HQ Sync. When two machines (or two users) edit the same file and sync detects divergence, both versions land on disk: the original path keeps the local version, and a .conflict-<timestamp>-<machine>.<ext> file holds the cloud's version. This command walks the user through each pending conflict and applies their decision.

Note on auto-merge: the @indigoai-us/hq-cloud sync-runner may now auto-merge clean, non-overlapping text-file conflicts on the pull path when a baseline is available — those pull conflicts never reach this index or this skill. What still lands here includes: pull conflicts the runner could not safely auto-merge (overlapping edits, binary/oversized files, safety-only conflicts, or divergence with no baseline), and push-side conflicts (never auto-merged; with default --direction both / --on-conflict keep, the cloud version is mirrored to a sidecar). Resolution here therefore stays two-way (local vs. cloud) for whatever lands in the queue; this skill does not implement or duplicate any three-way merge logic itself.

What you do

Step 1 — Locate and read the index

Read ~/HQ/.hq-conflicts/index.json. The exact HQ folder path comes from ~/.hq/menubar.json hqPath (and falls back per the resolve-hq-folder discovery chain). If the file doesn't exist OR the conflicts array is empty, tell the user "No conflicts pending — your local copy is in sync with the cloud" and stop.

The index schema:

{
  "version": 1,
  "conflicts": [
    {
      "id": "...",
      "originalPath": "core/knowledge/notes.md",
      "conflictPath": "core/knowledge/notes.md.conflict-2026-04-27T22-05-14Z-abc123.md",
      "detectedAt": "2026-04-27T22:05:14Z",
      "side": "pull" | "push",
      "machineId": "abc123",
      "localHash": "...",
      "remoteHash": "...",
      "remoteVersionId": "...",
      "lastKnownVersionId": "..."
    }
  ]
}

Step 2 — Summarize the queue

Tell the user how many conflicts are pending, grouped by top-level folder. Example:

3 conflicts pending:
  core/knowledge/  (2 files)
  personal/projects/foo/  (1 file)

Walking through them oldest-first.

Step 3 — Walk each conflict (oldest detectedAt first)

For each entry:

  1. Read both files (Read on originalPath and conflictPath, both relative to HQ folder).
  2. Show the user a short preview: file path, sizes of both versions, and a unified diff (use Bash with diff -u <local> <cloud> if both are reasonable size, otherwise just first 30 lines of each).
  3. Ask: which version to keep?
  1. After applying the resolution (except skip/quit/merge-pending), remove the index entry. Re-write ~/HQ/.hq-conflicts/index.json atomically (write to .tmp, then rename).

Step 4 — Final summary

Tell the user how many conflicts were resolved this session, how many were skipped, and what's left:

Resolved 2 conflicts (1 kept local, 1 took cloud).
1 conflict skipped — run `/resolve-conflicts` again to revisit.

If there are still pending conflicts, suggest the user re-run sync afterwards so the resolved files propagate to the cloud cleanly.

Edge cases

Don't

After resolution

After the user has resolved conflicts, suggest they hit Sync in the HQ Desktop App. The runner will pick up the resolved file (now with a new local hash that differs from journal) and push it cleanly. If a new conflict happens in the meantime (someone else pushed again), they'll see a new entry in the index.

See also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.