34 Commits
Author SHA1 Message Date
lukaszraczyloandGitHub e01f3419ea fix(apply): propagate read errors, auto-open repo, dedupe adapter base (#6)
Three robustness fixes for the apply pipeline:

1. Silent read errors on state/target files treated 'file absent' as
   'file empty' and fast-forward-overwrote user edits. Add
   common.ReadExistingFile that returns (nil,nil) only on
   os.IsNotExist; other I/O errors propagate. Use it from apply.Run
   and from every adapter's Render (claudecode, crush, kilo,
   opencode, goose, zed).

2. apply.Run required callers to pre-construct *gitx.Repo; passing
   nil silently skipped the commit. Run now auto-opens a repo from
   Bundle.Root, gracefully no-ops when the root is not a git repo,
   and uses a new gitx.HasStagedChanges() check to skip the no-op
   'nothing to commit' that triggered the original silent-skip.

3. Each of 7 adapter packages re-implemented the same 25-line
   Option/WithHome/New constructor. Hoist into adapter.Base +
   adapter.BaseOption + NewBase. Each adapter embeds *Base and
   reduces to a 9-line constructor. Public New(WithHome(h)) API
   preserved; a.home becomes a.Home.

Tests:
  - apply: 5 new (propagates-read-error, auto-opens-repo,
    no-repo-skips-commit, skips-no-op-commit, commit-message-counts)
  - gitx: 2 new (HasStagedChanges empty/after-add)
  - adapter/common: 3 new (ReadExistingFile missing/content/perm)
  - adapter: 4 new (NewBase default/WithHome/order/typed)
  - existing adapter tests unchanged — verify a.Home still honoured.
2026-06-01 13:11:07 +01:00
lukaszraczylo 6483eb8044 refactor: remove dead code, deduplicate defaultHome, simplify mcpEntry + kilo render
Dead code removed:
- BuildProviders, buildModels, ProviderEntry (no production callers)
- ZedLanguageModels (shadowed by adapter-local version, wrong schema)
- GatewayProviderID deprecated constant (zero references)
- Corresponding dead tests for BuildProviders

Deduplication:
- Extract common.DefaultHome() to internal/adapter/common/home.go
- All 7 adapters call common.DefaultHome() instead of local copies (-49 lines)

Simplification:
- mcp.go: merge MCPClaudeStyle/MCPCrushStyle branches (identical URL path,
  one-line difference in stdio path) — clearer intent, fewer lines
- kilo.go: extract opencode.jsonc merge to mergeOpenCodeJSONC() helper,
  Render() drops from 92 to ~55 lines
- goose.go: strings.IndexByte → strings.Cut in splitProviderModel
2026-05-23 21:22:49 +01:00
lukaszraczylo 21a86c084f feat: profile rename subcommand + expand all model display names 2026-05-23 21:13:27 +01:00
lukaszraczylo fb02b165d7 feat: URL-derived provider keys (hs-<hostname>) + dedup providers sharing same gateway URL
- GatewayProviderKey() derives stable key from gateway URL hostname
  e.g. https://llmgw.h.raczylo.com/v1 → hs-llmgw-h-raczylo-com
- AbsorbDuplicateProviders() merges providers sharing the same baseURL
  into our canonical entry; user-crafted model metadata wins for overlaps
- kilo: renders to opencode.jsonc (primary config), deep-merges providers,
  deletes enabled_providers filter that was hiding our gateway
- opencode: absorbs duplicate providers from existing config
- All adapters use GatewayProviderKey() instead of hardcoded string
- Fix goose URL doubling (was /v1/v1/chat/completions → /chat/completions)
- Fix token propagation: api_key written directly (not env var ref)
- Zed: adds prompt_cache_key capability, deletes context_servers key
  to avoid ContextServerSettingsContent serde untagged-enum parse error
2026-05-23 21:13:16 +01:00
lukaszraczylo 77158d9f2b fix: propagate gateway token; kilo targets opencode.jsonc; goose URL + api_key fix 2026-05-23 21:12:47 +01:00
lukaszraczylo 7716c180e7 zed: add prompt_cache_key capability field to model entries 2026-05-23 21:12:47 +01:00
lukaszraczylo 00ba950cd9 zed: delete context_servers key to fix serde parse error; update tests 2026-05-23 21:12:47 +01:00
lukaszraczylo bde3128dba fix(zed): switch to language_models.openai_compatible for Agent panel visibility
The Zed Agent panel (new ACP-based UI) only discovers providers registered
under language_models.openai_compatible.<name>, not language_models.openai.
Each named entry appears as its own provider in the LLM Providers list.

- language_models.openai_compatible.harness-sync-gateway holds gateway URL + models
- agent.default_model.provider = 'harness-sync-gateway' (was 'openai')
- Model entries include capabilities {tools,images,parallel_tool_calls}
- Export common.GatewayProviderID so zed.go can reference it
- Fix staticcheck QF1001 (De Morgan's law) in io.go
- Fix struct field alignment in File (80→72 bytes)
- gofmt remaining files
2026-05-23 21:12:47 +01:00
lukaszraczylo fd97c60df2 fix(opencode/kilo): add top-level name + models Record to ProvidersAsMap
opencode/kilo require top-level 'name' and a 'models' Record<modelID,Model>
in each provider entry for the harness UI to enumerate and display models.
Without 'name', the gateway appears unlabelled; without 'models', the provider
shows no model list in the selector.
2026-05-23 21:12:46 +01:00
lukaszraczylo 7bd70bfaeb test: introduce afero-based mock filesystem for hermetic tests 2026-05-23 13:12:15 +01:00
lukaszraczylo 2334ed7922 fix(canonical): make missing-config-yaml test self-contained for CI 2026-05-23 13:06:32 +01:00
lukaszraczylo da49624b99 fix(adapters): emit correct provider/model schema per harness 2026-05-23 12:48:10 +01:00
lukaszraczylo 941b1d86c3 feat(cli): add update subcommand for in-place self-update 2026-05-23 12:42:44 +01:00
lukaszraczylo 0677223ff6 fix(apply): never substitute env vars - leave ${VAR} for harnesses to resolve 2026-05-23 12:24:26 +01:00
lukaszraczylo d5b0de12cb fix(secrets): pass through unset env vars so harness-resolved ${VARS} survive 2026-05-23 12:15:06 +01:00
lukaszraczylo 50059d7517 feat(canonical): validate profile name, apply env-var substitution before render 2026-05-23 11:55:26 +01:00
lukaszraczylo 5e35dc47fe test(apply): cover symlinks, force, dry-run, merge, errors, state round-trip 2026-05-23 11:55:01 +01:00
lukaszraczylo 8f5200a7f2 fix(mcp): read .claude.json + mcp_servers.json, handle type/transport + array commands 2026-05-23 11:41:57 +01:00
lukaszraczylo 9633f9ad4c fix: pre-select all in init prompt, preserve agent paths with slashes, fix rollback off-by-one 2026-05-23 11:25:31 +01:00
lukaszraczylo 498cdb061d feat: add internal/ui prompts + init subcommand
- internal/ui/prompts.go: MultiSelect with huh TUI + WithNonInteractive for tests
- internal/cli/init.go: NewInit cobra command with --from/--no-prompt flags
- internal/cli/init_test.go: TestInitImportWritesCanonical
- internal/cli/root.go: add resolveRoot helper (shared by profile/rollback/show/init)
- go.mod: add github.com/charmbracelet/huh v1.0.0 as direct dep
2026-05-23 03:32:40 +01:00
lukaszraczylo 68035b378c feat(cli): add apply subcommand 2026-05-23 03:32:21 +01:00
lukaszraczylo 85fbbafb71 feat(cli): wire adapters into registry and add detect subcommand 2026-05-23 03:25:50 +01:00
lukaszraczylo 63bd976f4b fix(adapters): ground native schemas, merge-not-replace, add goose/cagent/zed
- common/mcp.go: MCPStyle enum + BuildMCPMapStyled for claude/crush/opencode/zed dialects
- common/jsonmerge.go: MergeJSONKeys (JSON-first, JSONC fallback) preserves user keys;
  fix: try plain json.Unmarshal before StripJSONComments to avoid mangling URLs with //
- common/yamlmerge.go: MergeYAMLKeys for YAML configs (goose)
- common/blocks.go: add ProvidersAsMap for opencode map-shaped provider key
- claudecode: merge settings.json (preserves hooks/permissions/env); MCPClaudeStyle (no type field)
- crush: fix mcp key (was mcpServers); MCPCrushStyle entries include type field; merge crush.json; fix import key mcp
- kilo: drop providers key (kilo has none); MCPOpencodeStyle (local/remote); merge kilo.json
- opencode: fix provider (singular map) + model (not default_model); MCPOpencodeStyle; merge jsonc; fix import key mcp
- goose: new adapter — YAML merge, extensions map, splitProviderModel, import reconstructs MCP from extensions
- cagent: new adapter — renders starter default.yaml, import returns empty
- zed: new adapter — merge settings.json, context_servers (MCPZedStyle) + agent.default_model
- docs: append Grounded harness schemas section to design spec
2026-05-23 03:23:02 +01:00
lukaszraczylo a18cb1a4b7 refactor(adapters): extract common helpers + fix kilo native schema 2026-05-23 03:06:35 +01:00
lukaszraczylo 6dafb43c43 feat(opencode): adapter with opencode.jsonc render + AGENTS.md 2026-05-23 02:59:53 +01:00
lukaszraczylo 7013bada1c feat(kilo): adapter with kilo.json render + agent symlink 2026-05-23 02:59:50 +01:00
lukaszraczylo fe9206716e feat(claudecode): adapter with skills+agents symlinks, CLAUDE.md, settings.json + Import 2026-05-23 02:55:34 +01:00
lukaszraczylo 59575792be feat(apply): render+merge+write pipeline with state snapshots and .rej conflicts 2026-05-23 02:52:08 +01:00
lukaszraczylo 0e77393400 feat(merge): three-way merge via git merge-file with conflict detection 2026-05-23 02:48:36 +01:00
lukaszraczylo 95962bdf9a feat(adapter): registry with detect filtering and duplicate guard 2026-05-23 02:48:31 +01:00
lukaszraczylo 6ab8d149e1 feat(adapter): define Adapter interface and FileSet 2026-05-23 02:45:50 +01:00
lukaszraczylo e4719b78a0 feat(canonical): load YAML/markdown into Bundle 2026-05-23 02:43:56 +01:00
lukaszraczylo 45c994136f feat(canonical): introduce core domain types 2026-05-23 02:41:06 +01:00
lukaszraczylo 2977f8e679 feat: bootstrap module and cobra root command 2026-05-23 02:39:04 +01:00