Skip to content

Add writ migrate command with install infrastructure - #12

Merged
David-Noble-at-work merged 12 commits into
developfrom
feature/writ-migrate-command
Jan 25, 2026
Merged

David-Noble-at-work merged 12 commits into
developfrom
feature/writ-migrate-command

Conversation

@David-Noble-at-work

Copy link
Copy Markdown
Contributor

Summary

  • Add writ migrate command for migrating existing dotfile repos to writ conventions
  • Add registry client for syncing AI assets from devlore-registry
  • Add AI provider package with lazy configuration (Ollama, Anthropic, OpenAI)
  • Add install script and GoReleaser configuration for binary distribution
  • Deploy binaries to devlore.noblefactor.com (auth-protected) for testing

Features

writ migrate

  • Auto-detects source system (Tuckr, Stow, chezmoi, yadm, bare-git, script-based)
  • AI-assisted file classification and secret detection
  • Renames project-Platform directories to project.Platform
  • Registers repo in config with layer (base/team/personal)
  • Output formats: text, yaml, json

Install Infrastructure

  • install.sh - curl-based installer downloading from website
  • .goreleaser.yaml - cross-platform binary builds
  • make dist - local distribution builds with version control
  • GitHub workflow deploys to devlore.noblefactor.com on push to develop/main/release/*

Test plan

  1. Merge this PR
  2. Wait for workflow to complete
  3. Authenticate to devlore.noblefactor.com
  4. Run: curl -sSL https://devlore.noblefactor.com/install.sh | bash
  5. Run: writ migrate ~/your-dotfiles

David Noble added 12 commits January 24, 2026 15:48
writ migrate:
- Analyzes existing environment repos and produces migration plan
- Auto-detects source system (Tuckr, Stow, chezmoi, yadm, bare-git, script-based)
- Renames <project>-<Platform> dirs to <project>.<Platform> with --execute
- Classifies files (configs, scripts, secrets, fonts, completions, etc.)
- Parses lifecycle scripts for package manager usage
- Outputs text/yaml/json format

SOPS secrets (ADR-050):
- Replaces raw age decryption with SOPS library
- Both .age and .sops files decrypt via SOPS
- SOPS handles key resolution (SOPS_AGE_KEY, ~/.config/sops/age/keys.txt)
- Supports all SOPS backends (age, GPG, AWS KMS, GCP KMS, Azure KV, Vault)
- Engine DecryptOp now accepts source path for format detection
Implements the registry client per ADR-025 with a Git provider for the
demo phase (ADR-014). Uses shallow clone and hard reset cache semantics.

Key features:
- Sync() clones or updates from GitHub (develop branch for AI assets)
- ReadFile/AIPrompt/AISchema helpers for cache access
- MigrationGuide helper for writ migrate
- Cache at ~/.local/share/lore/cache/central/

All AI asset access goes through this API per ADR-052.
Implements AI provider abstraction per ADR-017:
- Provider interface for chat completions
- Ollama provider (default, local, free)
- Anthropic provider (Claude)
- OpenAI provider (GPT-4, compatible APIs)

Configuration:
- Lazy prompting when AI first needed (not during install)
- Saves to ~/.config/devlore/config.yaml
- Expands ${ENV_VAR} in API keys

AI is the default; --no-ai opts out per ADR-052.
Updates writ migrate to use AI-assisted analysis per ADR-052:
- AI is the default; --no-ai opts out for basic structural analysis
- Syncs registry for AI prompts and migration guides
- Prompts for AI provider configuration when first needed
- Falls back to basic mode if AI unavailable

Structural detection kept:
- Source system detection (Tuckr, Stow, chezmoi, yadm, etc.)
- Encryption system detection (git-crypt, SOPS, etc.)
- Directory rename mappings

Content pattern matching removed in favor of AI analysis:
- Secret detection delegated to AI
- File classification enhanced by AI
- Recommendations generated by AI using registry guides
- Add RepoLayer type with base/team/personal constants
- Parse repo_layer and unencrypted_secrets from AI response
- Register repo in config after successful --execute
- install.sh: curl-based installer that downloads pre-built binaries
- .goreleaser.yaml: builds writ/lore for linux/darwin/windows × amd64/arm64
- release.yaml workflow: runs GoReleaser on tags, syncs install.sh to website

Usage: curl -sSL https://devlore.noblefactor.com/install.sh | bash
- Makefile: add `make dist` for cross-platform builds with DEVLORE_VERSION
- install.sh: download from devlore.noblefactor.com/releases/
- release.yaml: build and deploy binaries to website on push

Enables testing behind auth-protected website before public release.
- Remove unused generateObservations and generateWarnings functions in plan.go
- Remove unnecessary nil check in commands.go
- Add error checks for os.WriteFile/os.Symlink/os.MkdirAll in test files
- builder_test.go: check os.WriteFile error
- engine_test.go: check os.WriteFile errors in expand/copy tests
- migrate_test.go: check os.Mkdir error
Add error checks for os.WriteFile in TestEngineDryRun,
TestPreflightNoConflict, TestPreflightConflictRegularFile,
TestEngineRunLinkPipeline, TestEngineTopologicalSort, and
TestBackupOperation.
Add error checks for os.WriteFile in TestDetectTuckr,
TestDetectStow, TestDetectYadm, and TestAlreadyMigrated.
@David-Noble-at-work
David-Noble-at-work merged commit 47323ab into develop Jan 25, 2026
@David-Noble-at-work
David-Noble-at-work deleted the feature/writ-migrate-command branch January 25, 2026 02:20
David-Noble-at-work pushed a commit that referenced this pull request Jun 6, 2026
A subgraph run through the flow.subgraph verb threw away its children's output: dispatchWithRetry
(helpers.go) returned only an error, discarding DispatchChild's result, and flow.Provider.Subgraph
(provider.go) returned nil unconditionally. So a flow.subgraph-bound subgraph's terminal result never
reached GraphExecutor.Run. (#10 confirmed this; the structural op.Subgraph path, the executor, and
flow.Complete were already correct.)

Fix:
- helpers.go: dispatchWithRetry returns (any, error), capturing DispatchChild's result on the succeeding
  attempt (nil on cancel/exhaustion). This matches dispatchBodyChildren, which already returns `last`.
- provider.go: flow.Provider.Subgraph carries lastResult across the children loop and returns it instead
  of nil.

Tests (#11):
- result_flow_test.go: TestSubgraphBoundAction_FlowsLeafResult builds root → flow.subgraph subgraph →
  flow.complete leaf (output = sentinel), runs it, asserts Run returns the sentinel. RED before the fix
  (result = nil), GREEN after; logs the bubbled value. TestStructuralSubgraph_FlowsLeafResult is a control
  that passes throughout. integration_test.go's inventory import swapped to flow/gen to free the flow test
  binary from the #6-blocked inventory.
- result_flow_starlark_test.go: the Starlark mirror, t.Skip'd, gated on #12 (plan.Provider.Assemble nil-
  origin panic, an unrelated plan bug surfaced here).

TEMP mitigation: inventory.gen.go disables the provider/pkg/gen + provider/service/gen registrations (the
#6-broken packages) so the inventory + star build during the migration. Marked TEMP in-file; `make
generate` regenerates and restores them. The local build/star.lkg was refreshed off this state (reduced:
no pkg/service providers).

flow tests green; tree still red on out-of-scope consumers (#6).
David-Noble-at-work pushed a commit that referenced this pull request Jun 7, 2026
unify-subgraph-execution.md and subgraph-result-flow.md were left at status: draft though their work
landed (the foundation in be7b85a, the rest in the 524fade checkpoint). Set both to complete:
- unify-subgraph-execution.md: #13 done (action-by-name, root via flow.subgraph, structural path deleted,
  child-walks converged, retry intrinsic to DispatchChild).
- subgraph-result-flow.md: #10 confirmed + #11 fix and Go guard landed; the Starlark guard remains
  t.Skip'd pending #12 (plan.Provider.Assemble nil-origin).
David-Noble-at-work pushed a commit that referenced this pull request Jun 7, 2026
… guard (#12)

plan.Provider.Assemble dereferenced a nil op.Origin (origin.Scope()/Annotations(), provider.go:176) when
plan.assemble is invoked from Starlark with the default origin=. Default a nil origin to the zero OriginBase
before the tool-stamping, so the scope/annotations read is safe.

- provider/plan/provider.go: `if origin == nil { origin = op.OriginBase{} }` ahead of the tool stamp.
- provider/flow/result_flow_starlark_test.go: removed the t.Skip; TestSubgraphBoundAction_FlowsLeafResult_Starlark
  now runs and passes -- the result-flow proven end to end through the Starlark plan path (plan.subgraph ->
  flow.subgraph -> plan.run).
- subgraph-result-flow.md: Resolution + Status record the Starlark guard green and #10/#11 fully closed.

pkg/op + flow + plan green (scoped); whole-tree still red on #6.
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