From e497ddcaf5eefd59fbd427e741c3c94b09053f6b Mon Sep 17 00:00:00 2001 From: Snider Date: Tue, 3 Feb 2026 03:52:09 +0000 Subject: [PATCH] feat: CI improvements and release channels (#266) * 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 * feat(io): batch implementation placeholder Co-Authored-By: Claude Opus 4.5 * feat(errors): batch implementation placeholder Co-Authored-By: Claude Opus 4.5 * feat(log): batch implementation placeholder Co-Authored-By: Claude Opus 4.5 * 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 * feat(io): extend Medium interface with Delete, Rename, List, Stat operations Adds the following methods to the Medium interface: - Delete(path) - remove a file or empty directory - DeleteAll(path) - recursively remove a file or directory - Rename(old, new) - move/rename a file or directory - List(path) - list directory entries (returns []fs.DirEntry) - Stat(path) - get file information (returns fs.FileInfo) - Exists(path) - check if path exists - IsDir(path) - check if path is a directory Implements these methods in both local.Medium (using os package) and MockMedium (in-memory for testing). Includes FileInfo and DirEntry types for mock implementations. This enables migration of direct os.* calls to the Medium abstraction for consistent path validation and testability. Refs #101 Co-Authored-By: Claude Opus 4.5 * chore(io): Migrate internal/cmd/sdk, pkgcmd, and workspace to Medium abstraction * chore(io): migrate internal/cmd/docs and internal/cmd/dev to Medium - internal/cmd/docs: Replace os.Stat, os.ReadFile, os.WriteFile, os.MkdirAll, os.RemoveAll with io.Local equivalents - internal/cmd/dev: Replace os.Stat, os.ReadFile, os.WriteFile, os.MkdirAll, os.ReadDir with io.Local equivalents - Fix local.Medium to allow absolute paths when root is "/" for full filesystem access (io.Local use case) Refs #113, #114 Co-Authored-By: Claude Opus 4.5 * chore(io): migrate internal/cmd/setup to Medium abstraction Migrated all direct os.* filesystem calls to use io.Local: - cmd_repo.go: os.MkdirAll -> io.Local.EnsureDir, os.WriteFile -> io.Local.Write, os.Stat -> io.Local.IsFile - cmd_bootstrap.go: os.MkdirAll -> io.Local.EnsureDir, os.Stat -> io.Local.IsDir/Exists, os.ReadDir -> io.Local.List - cmd_registry.go: os.MkdirAll -> io.Local.EnsureDir, os.Stat -> io.Local.Exists - cmd_ci.go: os.ReadFile -> io.Local.Read - github_config.go: os.ReadFile -> io.Local.Read, os.Stat -> io.Local.Exists Refs #116 Co-Authored-By: Claude Opus 4.5 * feat(log): add error creation and log-and-return helpers Implements issues #129 and #132: - Add Err struct with Op, Msg, Err, Code fields for structured errors - Add E(), Wrap(), WrapCode(), NewCode() for error creation - Add Is(), As(), NewError(), Join() as stdlib wrappers - Add Op(), ErrCode(), Message(), Root() for introspection - Add LogError(), LogWarn(), Must() for combined log-and-return Closes #129 Closes #132 Co-Authored-By: Claude Opus 4.5 * chore(errors): create deprecation alias pointing to pkg/log Makes pkg/errors a thin compatibility layer that re-exports from pkg/log. All error handling functions now have canonical implementations in pkg/log. Migration guide in package documentation: - errors.Error -> log.Err - errors.E -> log.E - errors.Code -> log.NewCode - errors.New -> log.NewError Fixes behavior consistency: - E(op, msg, nil) now creates an error (for errors without cause) - Wrap(nil, op, msg) returns nil (for conditional wrapping) - WrapCode returns nil only when both err is nil AND code is empty Closes #128 Co-Authored-By: Claude Opus 4.5 * chore(log): migrate pkg/errors imports to pkg/log Migrates all internal packages from pkg/errors to pkg/log: - internal/cmd/monitor - internal/cmd/qa - internal/cmd/dev - pkg/agentic Closes #130 Co-Authored-By: Claude Opus 4.5 * fix(io): address Copilot review feedback - Fix MockMedium.Rename: collect keys before mutating maps during iteration - Fix .git checks to use Exists instead of List (handles worktrees/submodules) - Fix cmd_sync.go: use DeleteAll for recursive directory removal Files updated: - pkg/io/io.go: safe map iteration in Rename - internal/cmd/setup/cmd_bootstrap.go: Exists for .git checks - internal/cmd/setup/cmd_registry.go: Exists for .git checks - internal/cmd/pkgcmd/cmd_install.go: Exists for .git checks - internal/cmd/pkgcmd/cmd_manage.go: Exists for .git checks - internal/cmd/docs/cmd_sync.go: DeleteAll for recursive delete Co-Authored-By: Claude Opus 4.5 * 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 * style: fix formatting in internal/variants Co-Authored-By: Claude Opus 4.5 * style: fix formatting across migrated files Co-Authored-By: Claude Opus 4.5 * 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 * 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 * 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 * 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 * fix: address CodeRabbit review issues - Fix critical sandbox escape in local.Medium.path() - Absolute paths now constrained to sandbox root when root != "/" - Only allow absolute path passthrough when root is "/" - Fix weak test assertion in TestMust_Ugly_Panics - Use assert.Contains instead of weak OR condition - Remove unused issues.json file - Add TestPath_RootFilesystem test for absolute path handling Co-Authored-By: Claude Opus 4.5 * fix(io): sandbox absolute paths under root in Medium.path * ci(workflows): use host-uk/build@dev for releases - Replace manual Go bootstrap with host-uk/build@dev action - Add matrix builds for linux/amd64, linux/arm64, darwin/universal, windows/amd64 - Update README URLs from Snider/Core to host-uk/core - Simplify artifact handling with merge-multiple Co-Authored-By: Claude Opus 4.5 * fix(io): sandbox absolute paths under root in Medium.path Security fix: Remove Windows drive root bypass and properly strip volume names before sandboxing. Paths like C:\Windows are now correctly sandboxed under root instead of escaping. Co-Authored-By: Claude Opus 4.5 --------- Co-authored-by: Claude Opus 4.5 --- .github/workflows/dev-release.yml | 65 +++++++++++-------------------- .github/workflows/release.yml | 65 +++++++++++-------------------- README.md | 11 +++--- pkg/io/local/client.go | 11 +++--- 4 files changed, 56 insertions(+), 96 deletions(-) diff --git a/.github/workflows/dev-release.yml b/.github/workflows/dev-release.yml index 86577377..10aeda83 100644 --- a/.github/workflows/dev-release.yml +++ b/.github/workflows/dev-release.yml @@ -13,62 +13,46 @@ env: jobs: build: - runs-on: ubuntu-latest + strategy: + matrix: + include: + - os: ubuntu-latest + platform: linux/amd64 + - os: ubuntu-latest + platform: linux/arm64 + - os: macos-latest + platform: darwin/universal + - os: windows-latest + platform: windows/amd64 + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 + - name: Build + uses: host-uk/build@dev with: - go-version-file: 'go.mod' - - - name: Install core CLI - run: | - curl -fsSL "https://github.com/host-uk/core/releases/download/${{ env.CORE_VERSION }}/core-linux-amd64" -o /tmp/core - chmod +x /tmp/core - sudo mv /tmp/core /usr/local/bin/core - core --version - - - name: Generate code - run: go generate ./internal/cmd/updater/... - - - name: Build all targets - run: core build --targets=linux/amd64,linux/arm64,darwin/amd64,darwin/arm64,windows/amd64,windows/arm64 --ci - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: binaries - path: dist/ + build-name: core + build-platform: ${{ matrix.platform }} + build: true + package: true + sign: false release: needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v4 - name: Download artifacts uses: actions/download-artifact@v4 with: - name: binaries path: dist + merge-multiple: true - name: Prepare release files run: | mkdir -p release - cp dist/*.tar.gz dist/*.zip dist/CHECKSUMS.txt release/ 2>/dev/null || true - # Also copy raw binaries for direct download - for dir in dist/*/; do - if [ -d "$dir" ]; then - platform=$(basename "$dir") - for bin in "$dir"*; do - if [ -f "$bin" ]; then - name=$(basename "$bin") - cp "$bin" "release/core-${platform//_/-}${name##core}" - fi - done - fi - done + cp dist/* release/ 2>/dev/null || true ls -la release/ - name: Delete existing dev release @@ -96,9 +80,6 @@ jobs: # macOS/Linux curl -fsSL https://github.com/host-uk/core/releases/download/dev/core-linux-amd64 -o core chmod +x core && sudo mv core /usr/local/bin/ - - # Or with Homebrew - brew tap host-uk/tap && brew install host-uk/tap/core \`\`\` This is a pre-release for testing. Use tagged releases for production." \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 61b5c532..b09ba4e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,67 +8,48 @@ on: permissions: contents: write -env: - CORE_VERSION: dev - jobs: build: - runs-on: ubuntu-latest + strategy: + matrix: + include: + - os: ubuntu-latest + platform: linux/amd64 + - os: ubuntu-latest + platform: linux/arm64 + - os: macos-latest + platform: darwin/universal + - os: windows-latest + platform: windows/amd64 + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 + - name: Build + uses: host-uk/build@dev with: - go-version-file: 'go.mod' - - - name: Install core CLI - run: | - curl -fsSL "https://github.com/host-uk/core/releases/download/${{ env.CORE_VERSION }}/core-linux-amd64" -o /tmp/core - chmod +x /tmp/core - sudo mv /tmp/core /usr/local/bin/core - core --version - - - name: Generate code - run: go generate ./internal/cmd/updater/... - - - name: Build all targets - run: core build --targets=linux/amd64,linux/arm64,darwin/amd64,darwin/arm64,windows/amd64,windows/arm64 --ci - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: binaries - path: dist/ + build-name: core + build-platform: ${{ matrix.platform }} + build: true + package: true + sign: false release: needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v4 - name: Download artifacts uses: actions/download-artifact@v4 with: - name: binaries path: dist + merge-multiple: true - name: Prepare release files run: | mkdir -p release - cp dist/*.tar.gz dist/*.zip dist/CHECKSUMS.txt release/ 2>/dev/null || true - # Also copy raw binaries for direct download - for dir in dist/*/; do - if [ -d "$dir" ]; then - platform=$(basename "$dir") - for bin in "$dir"*; do - if [ -f "$bin" ]; then - name=$(basename "$bin") - cp "$bin" "release/core-${platform//_/-}${name##core}" - fi - done - fi - done + cp dist/* release/ 2>/dev/null || true ls -la release/ - name: Create release diff --git a/README.md b/README.md index 0ea31d4f..23d45c06 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,7 @@ Core is a Web3 Framework, written in Go using Wails.io to replace Electron and the bloat of browsers that, at their core, still live in their mum's basement. -- Discord: http://discord.dappco.re -- Repo: https://github.com/Snider/Core +- Repo: https://github.com/host-uk/core ## Vision @@ -26,7 +25,7 @@ Core is an **opinionated Web3 desktop application framework** providing: ## Quick Start ```go -import core "github.com/Snider/Core" +import core "github.com/host-uk/core" app := core.New( core.WithServiceLock(), @@ -144,7 +143,7 @@ app.RegisterService(application.NewService(coreService)) // Only Core is regist **Currently exposed** (see `cmd/core-gui/public/bindings/`): ```typescript // From frontend: -import { ACTION, Config, Service } from './bindings/github.com/Snider/Core/pkg/core' +import { ACTION, Config, Service } from './bindings/github.com/host-uk/core/pkg/core' ACTION(msg) // Broadcast IPC message Config() // Get config service reference @@ -159,7 +158,7 @@ Sub-services are accessed via Core's **IPC/ACTION system**, not direct Wails bin ```typescript // Frontend calls Core.ACTION() with typed messages -import { ACTION } from './bindings/github.com/Snider/Core/pkg/core' +import { ACTION } from './bindings/github.com/host-uk/core/pkg/core' // Open a window ACTION({ action: "display.open_window", name: "settings", options: { Title: "Settings", Width: 800 } }) @@ -198,7 +197,7 @@ cd cmd/core-gui wails3 generate bindings # Regenerate after Go changes ``` -Bindings output to `cmd/core-gui/public/bindings/github.com/Snider/Core/` mirroring Go package structure. +Bindings output to `cmd/core-gui/public/bindings/github.com/host-uk/core/` mirroring Go package structure. --- diff --git a/pkg/io/local/client.go b/pkg/io/local/client.go index 189c1223..88145927 100644 --- a/pkg/io/local/client.go +++ b/pkg/io/local/client.go @@ -32,16 +32,15 @@ func (m *Medium) path(p string) string { } clean := strings.ReplaceAll(p, "..", ".") if filepath.IsAbs(clean) { - // Handle Windows drive root (e.g. "C:\") - if len(clean) == 3 && clean[1] == ':' && (clean[2] == '\\' || clean[2] == '/') { - return clean - } // If root is "/", allow absolute paths through if m.root == "/" { return filepath.Clean(clean) } - // Otherwise, sandbox absolute paths by stripping leading / - return filepath.Join(m.root, strings.TrimPrefix(clean, "/")) + // Otherwise, sandbox absolute paths by stripping volume + leading separators + vol := filepath.VolumeName(clean) + clean = strings.TrimPrefix(clean, vol) + clean = strings.TrimLeft(clean, string(os.PathSeparator)+"/") + return filepath.Join(m.root, clean) } return filepath.Join(m.root, clean) }