Commit graph

622 commits

Author SHA1 Message Date
Snider
6b3e61732a fix(io): add contextual error handling with E() helper
Address CodeRabbit review feedback by wrapping raw errors with the
errors.E() helper to provide service/action context for debugging:

- pkg/cache: wrap cache.New, Get, Set, Delete, Clear errors
- pkg/devops/test: wrap LoadTestConfig path/read/parse errors
- pkg/cli/daemon: wrap PIDFile.Release path resolution error
- pkg/container/state: wrap LoadState/SaveState errors
- pkg/container/templates: wrap GetTemplate embedded/user read errors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 05:34:10 +00:00
Snider
b291ec0e62 fix: address CodeRabbit feedback - use errors.E for context
Add contextual error handling using errors.E helper as suggested:
- config.go: Wrap LoadConfig read/parse errors
- images.go: Wrap NewImageManager, loadManifest, and Manifest.Save errors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 05:25:30 +00:00
Snider
1adebbdba1 chore(io): migrate pkg/cli and pkg/container to io.Local abstraction
Continue io.Medium migration for the remaining packages:

- pkg/cli/daemon.go: PIDFile Acquire/Release now use io.Local.Read,
  Delete, and Write for managing daemon PID files.
- pkg/container/state.go: LoadState and SaveState use io.Local for
  JSON state persistence. EnsureLogsDir uses io.Local.EnsureDir.
- pkg/container/templates.go: Template loading and directory scanning
  now use io.Local.IsFile, IsDir, Read, and List.
- pkg/container/linuxkit.go: Image validation uses io.Local.IsFile,
  log file check uses io.Local.IsFile. Streaming log file creation
  (os.Create) remains unchanged as io.Local doesn't support streaming.

Closes #105, closes #107

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 05:17:12 +00:00
Snider
40451538d6 chore(io): migrate remaining packages to io.Local abstraction
Migrate filesystem operations to use the io.Local abstraction for
improved security, testability, and consistency:

- pkg/cache: Replace os.ReadFile, WriteFile, Remove, RemoveAll with
  io.Local equivalents. io.Local.Write creates parent dirs automatically.
- pkg/agentic: Migrate config.go and context.go to use io.Local for
  reading config files and gathering file context.
- pkg/repos: Use io.Local.Read, Exists, IsDir, List for registry
  operations and git repo detection.
- pkg/release: Use io.Local for config loading, existence checks,
  and artifact discovery.
- pkg/devops/sources: Use io.Local.EnsureDir for CDN download.

All paths are converted to absolute using filepath.Abs() before
calling io.Local methods to handle relative paths correctly.

Closes #104, closes #106, closes #108, closes #111

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 05:11:15 +00:00
Snider
e081869ba2 feat(devops): migrate filesystem operations to io.Local abstraction
Migrate config.go:
- os.ReadFile → io.Local.Read

Migrate devops.go:
- os.Stat → io.Local.IsFile

Migrate images.go:
- os.MkdirAll → io.Local.EnsureDir
- os.Stat → io.Local.IsFile
- os.ReadFile → io.Local.Read
- os.WriteFile → io.Local.Write

Migrate test.go:
- os.ReadFile → io.Local.Read
- os.Stat → io.Local.IsFile

Migrate claude.go:
- os.Stat → io.Local.IsDir

Updated tests to reflect improved behavior:
- Manifest.Save() now creates parent directories
- hasFile() correctly returns false for directories

Part of #101 (io.Medium migration tracking issue).

Closes #107

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 05:00:10 +00:00
Snider
dfbefeb826 feat(release): migrate filesystem operations to io.Local abstraction
Migrate config.go:
- os.ReadFile → io.Local.Read
- os.Stat → io.Local.IsFile
- os.MkdirAll → io.Local.EnsureDir
- os.WriteFile → io.Local.Write

Migrate release.go:
- os.Stat → io.Local.IsDir
- os.ReadDir → io.Local.List

Uses filepath.Abs for relative path support.

Part of #101 (io.Medium migration tracking issue).

Closes #106

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:56:07 +00:00
Snider
71115d87bf feat(build): migrate filesystem operations to io.Local abstraction
Migrate config.go:
- os.ReadFile → io.Local.Read (with filepath.Abs for relative paths)

Migrate checksum.go:
- os.MkdirAll → io.Local.EnsureDir
- os.WriteFile → io.Local.Write

Migrate discovery.go:
- os.Stat → io.Local.IsFile (with filepath.Abs for relative paths)

Note: os.Open for file hashing remains unchanged as it requires io.Reader.

Part of #101 (io.Medium migration tracking issue).

Closes #105

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:52:14 +00:00
Snider
6fb2713112 feat(agentic): migrate filesystem operations to io.Local abstraction
Migrate config.go:
- os.Open + bufio.Scanner → io.Local.Read + strings.Split
- os.ReadFile → io.Local.Read
- os.MkdirAll → io.Local.EnsureDir
- os.WriteFile → io.Local.Write

Migrate context.go:
- os.ReadFile → io.Local.Read

Part of #101 (io.Medium migration tracking issue).

Closes #109

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:43:27 +00:00
Snider
d6fb905dba feat(repos): migrate filesystem operations to io.Local abstraction
Replace direct os package calls with io.Local methods:
- os.ReadFile → io.Local.Read
- os.Stat → io.Local.IsFile/IsDir
- os.ReadDir → io.Local.List

Part of #101 (io.Medium migration tracking issue).

Closes #111

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:38:38 +00:00
Snider
bd665e0892 feat(container): migrate filesystem operations to io.Local abstraction
Migrate state.go:
- os.ReadFile → io.Local.Read
- os.MkdirAll → io.Local.EnsureDir
- os.WriteFile → io.Local.Write

Migrate templates.go:
- os.Stat → io.Local.IsFile/IsDir
- os.ReadFile → io.Local.Read
- os.ReadDir → io.Local.List

Part of #101 (io.Medium migration tracking issue).

Closes #108

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:35:09 +00:00
Snider
48bee731b4 feat(cache): migrate filesystem operations to io.Local abstraction
Replace direct os package calls with io.Local methods:
- os.MkdirAll → io.Local.EnsureDir
- os.ReadFile → io.Local.Read
- os.WriteFile → io.Local.Write
- os.Remove → io.Local.Delete
- os.RemoveAll → io.Local.DeleteAll

This is part of the io.Medium abstraction migration (#101).

Closes #104

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:32:20 +00:00
Snider
68f2f658f4 feat(io): extend Medium interface with DeleteAll, Stat, Exists, IsDir (#240)
Add missing methods to complete the Medium interface:
- DeleteAll: recursive delete
- Stat: file information
- Exists: check if path exists
- IsDir: check if path is a directory

Also update MockMedium to implement all interface methods.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:25:30 +00:00
Snider
3caa394e15 feat(io): extend Medium interface with DeleteAll, Stat, Exists, IsDir
Add missing methods to complete the Medium interface:
- DeleteAll: recursive delete
- Stat: file information
- Exists: check if path exists
- IsDir: check if path is a directory

Also update MockMedium to implement all interface methods.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:23:52 +00:00
Snider
549e0c6035 build: add release build tasks with linker flags (#239)
* fix(container): prevent data race in State.Get and State.All

Return copies of Container structs instead of pointers to the map
entries. This prevents data races when containers are modified
concurrently by waitForExit and Stop.

Fixes #76

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(updater): resolve PkgVersion duplicate declaration

Remove var PkgVersion from updater.go since go generate creates
const PkgVersion in version.go. Track version.go in git to ensure
builds work without running go generate first.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* build: add release build tasks with linker flags for smaller binary

Add -s -w linker flags to strip debug info and symbol table:
- cli:build:release - release build to ./bin/core
- cli:install:release - release install to system PATH

Binary size reduced from 19MB to 14MB (26% reduction).

Fixes #226

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:22:00 +00:00
Snider
234bfd17f8 feat(mcp): MCP package enhancements (#177)
* fix(updater): resolve PkgVersion duplicate declaration

Remove var PkgVersion from updater.go since go generate creates
const PkgVersion in version.go. Track version.go in git to ensure
builds work without running go generate first.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* style: fix formatting in internal/variants

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(help): add CLI help command

Adds internal/cmd/help which provides enhanced help functionality.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(help): add catalog for managing help topics

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor(io): simplify local Medium implementation

Rewrote to match the simpler TypeScript pattern:
- path() sanitizes and returns string directly
- Each method calls path() once
- No complex symlink validation
- Less code, less attack surface

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:21:00 +00:00
Snider
95a980bea1 feat: Batch implementation of Gemini issues (#176)
* feat(help): Add CLI help command

Fixes #136

* chore: remove binary

* feat(mcp): Add TCP transport

Fixes #126

* feat(io): Migrate pkg/mcp to use Medium abstraction

Fixes #103

* chore(io): Migrate internal/cmd/docs/* to Medium abstraction

Fixes #113

* chore(io): Migrate internal/cmd/dev/* to Medium abstraction

Fixes #114

* chore(io): Migrate internal/cmd/setup/* to Medium abstraction

* chore(io): Complete migration of internal/cmd/dev/* to Medium abstraction

* chore(io): Migrate internal/cmd/sdk, pkgcmd, and workspace to Medium abstraction

* style: fix formatting in internal/variants

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor(io): simplify local Medium implementation

Rewrote to match the simpler TypeScript pattern:
- path() sanitizes and returns string directly
- Each method calls path() once
- No complex symlink validation
- Less code, less attack surface

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(mcp): update sandboxing tests for simplified Medium

The simplified io/local.Medium implementation:
- Sanitizes .. to . (no error, path is cleaned)
- Allows absolute paths through (caller validates if needed)
- Follows symlinks (no traversal blocking)

Update tests to match this simplified behavior.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(updater): resolve PkgVersion duplicate declaration

Remove var PkgVersion from updater.go since go generate creates
const PkgVersion in version.go. Track version.go in git to ensure
builds work without running go generate first.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:20:18 +00:00
Snider
8c4b526ef4 fix(container): prevent data race in State.Get and State.All (#238)
Return copies of Container structs instead of pointers to the map
entries. This prevents data races when containers are modified
concurrently by waitForExit and Stop.

Fixes #76

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:16:05 +00:00
Snider
dc7f22acfb fix(container): prevent data race in State.Get and State.All
Return copies of Container structs instead of pointers to the map
entries. This prevents data races when containers are modified
concurrently by waitForExit and Stop.

Fixes #76

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:13:24 +00:00
Snider
cf2a4db2d9 test(mcp): update sandboxing tests for simplified Medium
The simplified io/local.Medium implementation:
- Sanitizes .. to . (no error, path is cleaned)
- Allows absolute paths through (caller validates if needed)
- Follows symlinks (no traversal blocking)

Update tests to match this simplified behavior.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:32:38 +00:00
Snider
a61971d2b5 test(mcp): update sandboxing tests for simplified Medium
The simplified io/local.Medium implementation:
- Sanitizes .. to . (no error, path is cleaned)
- Allows absolute paths through (caller validates if needed)
- Follows symlinks (no traversal blocking)

Update tests to match this simplified behavior.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:32:37 +00:00
Snider
5be349c062 test(mcp): update sandboxing tests for simplified Medium
The simplified io/local.Medium implementation:
- Sanitizes .. to . (no error, path is cleaned)
- Allows absolute paths through (caller validates if needed)
- Follows symlinks (no traversal blocking)

Update tests to match this simplified behavior.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:32:36 +00:00
Snider
3c44ba9a11 test(mcp): update sandboxing tests for simplified Medium
The simplified io/local.Medium implementation:
- Sanitizes .. to . (no error, path is cleaned)
- Allows absolute paths through (caller validates if needed)
- Follows symlinks (no traversal blocking)

Update tests to match this simplified behavior.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:30:27 +00:00
Snider
56f6a32be7 test(io): fix traversal test to match sanitization behavior
The simplified path() sanitizes .. to . without returning errors.
Update test to verify sanitization works correctly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:27:27 +00:00
Snider
81e593f310 test(io): fix traversal test to match sanitization behavior
The simplified path() sanitizes .. to . without returning errors.
Update test to verify sanitization works correctly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:27:26 +00:00
Snider
78b7273f83 test(io): fix traversal test to match sanitization behavior
The simplified path() sanitizes .. to . without returning errors.
Update test to verify sanitization works correctly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:27:25 +00:00
Snider
a3ee94461a fix(io): remove duplicate method declarations
Clean up the client.go file that had duplicate method declarations
from a bad cherry-pick merge. Now has 127 lines of simple, clean code.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:26:27 +00:00
Snider
02c1a94b72 fix(io): remove duplicate method declarations
Clean up the client.go file that had duplicate method declarations
from a bad cherry-pick merge. Now has 127 lines of simple, clean code.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:26:26 +00:00
Snider
96b72aff52 fix(io): remove duplicate method declarations
Clean up the client.go file that had duplicate method declarations
from a bad cherry-pick merge. Now has 127 lines of simple, clean code.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:26:25 +00:00
Snider
144d5c787c fix(io): remove duplicate method declarations
Clean up the client.go file that had duplicate method declarations
from a bad cherry-pick merge. Now has 127 lines of simple, clean code.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:25:17 +00:00
Snider
025d9597a3 test(io): fix traversal test to match sanitization behavior
The simplified path() sanitizes .. to . without returning errors.
Update test to verify sanitization works correctly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:22:24 +00:00
Snider
8e55f585f3 refactor(io): simplify local Medium implementation
Rewrote to match the simpler TypeScript pattern:
- path() sanitizes and returns string directly
- Each method calls path() once
- No complex symlink validation
- Less code, less attack surface

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:17:44 +00:00
Snider
342fd2e962 refactor(io): simplify local Medium implementation
Rewrote to match the simpler TypeScript pattern:
- path() sanitizes and returns string directly
- Each method calls path() once
- No complex symlink validation
- Less code, less attack surface

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:17:43 +00:00
Snider
c0fd6ebe5f refactor(io): simplify local Medium implementation
Rewrote to match the simpler TypeScript pattern:
- path() sanitizes and returns string directly
- Each method calls path() once
- No complex symlink validation
- Less code, less attack surface

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:17:42 +00:00
Snider
564dfb160b refactor(io): simplify local Medium implementation
Rewrote to match the simpler TypeScript pattern:
- path() sanitizes and returns string directly
- Each method calls path() once
- No complex symlink validation
- Less code, less attack surface

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:17:41 +00:00
Snider
04fc222982 refactor(io): simplify local Medium implementation
Rewrote to match the simpler TypeScript pattern:
- path() sanitizes and returns string directly
- Each method calls path() once
- No complex symlink validation
- Less code, less attack surface

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:17:41 +00:00
Snider
8379695332 refactor(io): simplify local Medium implementation
Rewrote to match the simpler TypeScript pattern:
- path() sanitizes and returns string directly
- Each method calls path() once
- No complex symlink validation
- Less code, less attack surface

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:17:40 +00:00
Snider
2a870a5d7d feat(help): add catalog for managing help topics
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:04:19 +00:00
Snider
e999f390ac feat(help): add catalog for managing help topics
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:04:14 +00:00
Snider
82eb5ec054 feat(help): add CLI help command
Adds internal/cmd/help which provides enhanced help functionality.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:59:33 +00:00
Snider
bc1900a639 feat(help): add CLI help command
Adds internal/cmd/help which provides enhanced help functionality.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:59:27 +00:00
Snider
e0b1615905 style: fix formatting across migrated files
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:49:13 +00:00
Snider
00f6cdef92 style: fix formatting in internal/variants
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:46:08 +00:00
Snider
0d13f408d1 style: fix formatting in internal/variants
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:46:08 +00:00
Snider
fcfdba6cef style: fix formatting in internal/variants
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:46:07 +00:00
Snider
b66af1e183 style: fix formatting in internal/variants
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:46:06 +00:00
Snider
fa405487d6 style: fix formatting in internal/variants
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:46:05 +00:00
Snider
8c7ad6822f style: fix formatting in internal/variants
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:41:36 +00:00
Snider
d602504a56 fix(updater): resolve PkgVersion duplicate declaration
Remove var PkgVersion from updater.go since go generate creates
const PkgVersion in version.go. Track version.go in git to ensure
builds work without running go generate first.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:19:06 +00:00
Snider
fbc31b28c3 fix(updater): resolve PkgVersion duplicate declaration
Remove var PkgVersion from updater.go since go generate creates
const PkgVersion in version.go. Track version.go in git to ensure
builds work without running go generate first.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:19:05 +00:00
Snider
c1681ff672 fix(updater): resolve PkgVersion duplicate declaration
Remove var PkgVersion from updater.go since go generate creates
const PkgVersion in version.go. Track version.go in git to ensure
builds work without running go generate first.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 02:19:04 +00:00