Move harness profiles between host and Docker and stop silent draft retargeting

Native installs left Docker-era harness profiles in harnesses.json, so every
authoring launch failed trying to reach a Docker service, and a retained draft
bound to the old Docker server was silently projected onto the configured one.

- harness: add Profile.Mode and VerifyDockerLink as the single mode/verification
  helpers. `harness setup --host` configures or converts a host profile and
  clears docker_directory; reconfiguring a Docker-linked profile re-verifies the
  recorded directory still owns compose.yaml and fails naming it instead of
  saving a link that cannot launch. Setup's summary and `harness list` (via the
  new List/ListView shape) report the resulting mode and, for Docker, the
  directory, without changing the stored Config schema.
- setup-native.py: after build/install-skill it writes host (no docker_directory)
  profiles for the detected harnesses, defaulting to the detected OpenCode profile
  rather than a stale pi default, taking models from --model or the existing valid
  profile and never inventing one; it clears a stale Docker link and preserves
  unrelated keys/profiles. Detection-only: no harness install, upgrade or download.
- draft: add Draft.Resolve, the shared mismatch helper, which projects a draft
  onto the configured server and returns a dual-URL notice. CLI validate/submit
  and the TUI draft browser use it so a foreign draft is never silently
  retargeted; the TUI pre-wraps the notice to the panel width.
- Tests cover the Docker->host and host->host transitions, the missing-directory
  failure, installer write/migration (Python), and the CLI/TUI notice, using the
  real config file path in a temp dir.
- Update help text, README, docs and the packaged authoring skill reference to
  describe host as the default and the Docker-linked case.
This commit is contained in:
2026-10-15 19:53:10 +01:00
parent d00bd37833
commit 914345cb31
21 changed files with 732 additions and 141 deletions
+29 -11
View File
@@ -38,28 +38,38 @@ func (m Model) openDrafts() (tea.Model, tea.Cmd) {
func (m *Model) loadDraftPreview() {
m.draftTop = 0
m.draftSource = ""
m.draftNotice = ""
if len(m.draftItems) == 0 {
return
}
source, err := draft.Read(m.draftItems[m.draftIndex].Path)
_, source, notice, err := m.readDraft(m.draftIndex)
if err != nil {
m.draftError = err.Error()
return
}
m.draftSource = source
m.draftNotice = notice
}
func (m Model) selectedDraft() (draft.Draft, string, error) {
if len(m.draftItems) == 0 {
return draft.Draft{}, "", fmt.Errorf("no drafts")
}
d, err := draft.Load(m.draftItems[m.draftIndex].Path)
// readDraft loads one retained draft's metadata and source once, projecting it
// onto the configured server. It returns the shared dual-URL notice when the
// draft was created against a different server so no caller silently retargets
// a foreign draft.
func (m *Model) readDraft(index int) (draft.Draft, string, string, error) {
d, err := draft.Load(m.draftItems[index].Path)
if err != nil {
return d, "", err
return d, "", "", err
}
d = d.ForServer(m.url)
d, notice := d.Resolve(m.url)
source, err := draft.Read(d.Path)
return d, source, err
return d, source, notice, err
}
func (m Model) selectedDraft() (draft.Draft, string, string, error) {
if len(m.draftItems) == 0 {
return draft.Draft{}, "", "", fmt.Errorf("no drafts")
}
return m.readDraft(m.draftIndex)
}
func (m Model) updateDrafts(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
@@ -123,11 +133,12 @@ func (m Model) updateDrafts(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
case "k", "up":
m.draftTop = max(0, m.draftTop-1)
case "enter", "e", "s", "v":
d, source, err := m.selectedDraft()
d, source, notice, err := m.selectedDraft()
if err != nil {
m.draftError = err.Error()
return m, nil
}
m.draftNotice = notice
switch msg.String() {
case "enter", "e":
return m.confirmMutation("Edit retained draft?", func() tea.Cmd { return editDraftMode(d.Name, source, true, d.CreateOnly, d) })
@@ -173,7 +184,14 @@ func (m Model) draftsView(height int) string {
if name == "" {
name = "Unnamed draft"
}
lines := []string{fmt.Sprintf("Drafts · %d/%d · %s", m.draftIndex+1, len(m.draftItems), name), d.Path, fmt.Sprintf("Create-only: %t · Base version: %d", d.CreateOnly, d.BaseVersion), m.draftError, ""}
lines := []string{fmt.Sprintf("Drafts · %d/%d · %s", m.draftIndex+1, len(m.draftItems), name), d.Path, fmt.Sprintf("Create-only: %t · Base version: %d", d.CreateOnly, d.BaseVersion)}
if m.draftNotice != "" {
// Pre-wrap the dual-URL notice to the panel width: fitBlock truncates a
// single long line, so an unwrapped notice would cut off the configured
// endpoint and the TUI would not actually name both servers.
lines = append(lines, strings.Split(ansi.Wrap("Warning: "+m.draftNotice, max(1, m.width), ""), "\n")...)
}
lines = append(lines, m.draftError, "")
source := strings.Split(m.draftSource, "\n")
rows := max(0, height-len(lines)-1)
top := min(m.draftTop, max(0, len(source)-rows))