From fee5c34218965e58653efc1139de96a2fed9a119 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Sun, 19 Jul 2026 21:23:44 +0800 Subject: [PATCH] fix: rename binary to ssm --- .drone.yml | 14 +++---- AGENTS.md | 6 +-- README.md | 64 ++++++++++++++--------------- cmd/{ss => ssm}/main.go | 2 +- internal/cli/root.go | 8 ++-- internal/service/service_darwin.go | 4 +- internal/service/service_windows.go | 4 +- internal/service/wrapper_darwin.go | 2 +- internal/service/wrapper_windows.go | 6 +-- templates/embed.go | 2 +- 10 files changed, 56 insertions(+), 56 deletions(-) rename cmd/{ss => ssm}/main.go (65%) diff --git a/.drone.yml b/.drone.yml index 4071729..c7846e9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -16,19 +16,19 @@ steps: CGO_ENABLED: "0" commands: - mkdir -p dist/linux-amd64 dist/darwin-arm64 dist/windows-amd64 - - GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "-s -w -X gitea.epss.net.cn/klesh/ss/internal/cli.Version=${DRONE_TAG}" -o dist/linux-amd64/ss ./cmd/ss - - GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags "-s -w -X gitea.epss.net.cn/klesh/ss/internal/cli.Version=${DRONE_TAG}" -o dist/darwin-arm64/ss ./cmd/ss - - GOOS=windows GOARCH=amd64 go build -trimpath -ldflags "-s -w -X gitea.epss.net.cn/klesh/ss/internal/cli.Version=${DRONE_TAG}" -o dist/windows-amd64/ss.exe ./cmd/ss + - GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "-s -w -X gitea.epss.net.cn/klesh/ss/internal/cli.Version=${DRONE_TAG}" -o dist/linux-amd64/ssm ./cmd/ssm + - GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags "-s -w -X gitea.epss.net.cn/klesh/ss/internal/cli.Version=${DRONE_TAG}" -o dist/darwin-arm64/ssm ./cmd/ssm + - GOOS=windows GOARCH=amd64 go build -trimpath -ldflags "-s -w -X gitea.epss.net.cn/klesh/ss/internal/cli.Version=${DRONE_TAG}" -o dist/windows-amd64/ssm.exe ./cmd/ssm - name: package image: golang:1.26 commands: - apt-get update -qq && apt-get install -qq -y zip > /dev/null - cd dist - - tar -C linux-amd64 -czf ss-${DRONE_TAG}-linux-amd64.tar.gz ss - - tar -C darwin-arm64 -czf ss-${DRONE_TAG}-darwin-arm64.tar.gz ss - - (cd windows-amd64 && zip -q ../ss-${DRONE_TAG}-windows-amd64.zip ss.exe) - - sha256sum ss-${DRONE_TAG}-linux-amd64.tar.gz ss-${DRONE_TAG}-darwin-arm64.tar.gz ss-${DRONE_TAG}-windows-amd64.zip > checksums.txt + - tar -C linux-amd64 -czf ssm-${DRONE_TAG}-linux-amd64.tar.gz ssm + - tar -C darwin-arm64 -czf ssm-${DRONE_TAG}-darwin-arm64.tar.gz ssm + - (cd windows-amd64 && zip -q ../ssm-${DRONE_TAG}-windows-amd64.zip ssm.exe) + - sha256sum ssm-${DRONE_TAG}-linux-amd64.tar.gz ssm-${DRONE_TAG}-darwin-arm64.tar.gz ssm-${DRONE_TAG}-windows-amd64.zip > checksums.txt - rm -rf linux-amd64 darwin-arm64 windows-amd64 - ls -la depends_on: diff --git a/AGENTS.md b/AGENTS.md index 21748e1..1c3cb3b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,8 +3,8 @@ ## Overview This document describes the internal "agents" (manager components) of the -scientific-surfing (`ss`) CLI and their roles. The CLI is a single Go binary -(`cmd/ss`); each agent below is a package under `internal/`. +scientific-surfing (`ssm`) CLI and their roles. The CLI is a single Go binary +(`cmd/ssm`); each agent below is a package under `internal/`. --- @@ -28,7 +28,7 @@ scientific-surfing (`ss`) CLI and their roles. The CLI is a single Go binary - **Key Methods:** `Update`, `InstallService`, `UninstallService`, `StartService`, `StopService`, `RestartService`, `GetServiceStatus`, `ReloadService` ### 5. Service Manager (`internal/service`) -- **Purpose:** Cross-platform system service integration — systemd on Linux, launchd on macOS, and a native Windows Service (via `golang.org/x/sys/windows/svc`) on Windows. On macOS and Windows, this same `ss` binary is what the generated service definition invokes (hidden `service run-macos` / `service run-windows` commands), rather than a separate wrapper process. +- **Purpose:** Cross-platform system service integration — systemd on Linux, launchd on macOS, and a native Windows Service (via `golang.org/x/sys/windows/svc`) on Windows. On macOS and Windows, this same `ssm` binary is what the generated service definition invokes (hidden `service run-macos` / `service run-windows` commands), rather than a separate wrapper process. - **Key Methods:** `Install`, `Uninstall`, `Start`, `Stop`, `Restart`, `Status` ### 6. Hook Manager (`internal/hook`) diff --git a/README.md b/README.md index d161c12..2eb2e05 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,10 @@ A CLI for surfing the internet scientifically, written in Go. ```bash git clone ssh://git@gitea.epss.net.cn:2223/klesh/ss.git cd ss -go build -o ss ./cmd/ss +go build -o ssm ./cmd/ssm ``` -This produces a single `ss` (or `ss.exe` on Windows) binary with no runtime dependencies — templates and hook scripts are embedded in the binary. +This produces a single `ssm` (or `ssm.exe` on Windows) binary with no runtime dependencies — templates and hook scripts are embedded in the binary. ### 2. Add the binary to your system PATH @@ -29,72 +29,72 @@ This produces a single `ss` (or `ss.exe` on Windows) binary with no runtime depe ### Subscription Management ```bash # add a subscription -ss subscription add +ssm subscription add # refresh a subscription (with optional backup) -ss subscription refresh [--backup] +ssm subscription refresh [--backup] # delete a subscription -ss subscription rm +ssm subscription rm # rename a subscription -ss subscription rename +ssm subscription rename # update subscription URL -ss subscription set-url +ssm subscription set-url # show the URL for a subscription -ss subscription get-url +ssm subscription get-url # activate a subscription -ss subscription activate +ssm subscription activate # list all subscriptions -ss subscription list +ssm subscription list # show storage information -ss subscription storage +ssm subscription storage ``` ### Hook Management ```bash # initialize hooks directory with template scripts -ss hook init +ssm hook init # show hooks directory location and list all scripts -ss hook list +ssm hook list # edit a hook script with system editor -ss hook edit +ssm hook edit # remove a hook script -ss hook rm +ssm hook rm ``` ### Core Configuration Management ```bash # import configuration from file -ss config import [--config-file ] +ssm config import [--config-file ] # export configuration to file -ss config export [--config-file ] +ssm config export [--config-file ] # edit configuration with system editor -ss config edit [--config-file ] +ssm config edit [--config-file ] # reset configuration to default values -ss config reset [--config-file ] +ssm config reset [--config-file ] # show current configuration -ss config show [--config-file ] +ssm config show [--config-file ] # apply subscription to generate final config (with advanced options) -ss config apply \ +ssm config apply \ [--config-file ] \ [--output-file ] \ [--subscription ] ``` -**Options** (available on every `ss config` subcommand): +**Options** (available on every `ssm config` subcommand): - `--config-file `: Use a custom config file instead of the default. - `--output-file `: Specify the output path for the generated config file. - `--subscription `: Use a specific subscription (not just the active one) for config generation. @@ -102,24 +102,24 @@ ss config apply \ ### Core Management ```bash # update mihomo core binary -ss core update [--version ] [--force] +ssm core update [--version ] [--force] ``` ### Service Management ```bash -ss service install [--name ] [--description ] -ss service uninstall [--name ] -ss service start [--name ] -ss service stop [--name ] -ss service restart [--name ] -ss service reload [--name ] # reload config via mihomo's API, no restart -ss service status [--name ] +ssm service install [--name ] [--description ] +ssm service uninstall [--name ] +ssm service start [--name ] +ssm service stop [--name ] +ssm service restart [--name ] +ssm service reload [--name ] # reload config via mihomo's API, no restart +ssm service status [--name ] ``` `install`/`uninstall`/`start`/`stop`/`restart` need root/admin privileges: -- **Linux / macOS**: just run the command directly — `ss` re-execs itself under `sudo` automatically, prompting for your password if needed. -- **Windows**: run from an elevated/Administrator shell — `ss.exe service install`. +- **Linux / macOS**: just run the command directly — `ssm` re-execs itself under `sudo` automatically, prompting for your password if needed. +- **Windows**: run from an elevated/Administrator shell — `ssm.exe service install`. ## Development diff --git a/cmd/ss/main.go b/cmd/ssm/main.go similarity index 65% rename from cmd/ss/main.go rename to cmd/ssm/main.go index cd49039..09dda8d 100644 --- a/cmd/ss/main.go +++ b/cmd/ssm/main.go @@ -1,4 +1,4 @@ -// Command ss is the CLI for scientific-surfing. +// Command ssm is the CLI for scientific-surfing. package main import "gitea.epss.net.cn/klesh/ss/internal/cli" diff --git a/internal/cli/root.go b/internal/cli/root.go index 270bc8c..6c84816 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -1,4 +1,4 @@ -// Package cli wires up the ss command-line interface, mirroring cli.py's +// Package cli wires up the ssm command-line interface, mirroring cli.py's // argparse-based command tree with cobra. package cli @@ -59,15 +59,15 @@ func newManagers(configFile, outputFile, subscriptionName string) (*managers, er }, nil } -// Version is the ss build version, injected at build time via +// Version is the ssm build version, injected at build time via // -ldflags "-X gitea.epss.net.cn/klesh/ss/internal/cli.Version=vX.Y.Z" // (see .drone.yml). Defaults to "dev" for local/unversioned builds. var Version = "dev" -// Execute runs the ss CLI. It is the Go equivalent of cli.py's main(). +// Execute runs the ssm CLI. It is the Go equivalent of cli.py's main(). func Execute() { root := &cobra.Command{ - Use: "ss", + Use: "ssm", Short: "Scientific Surfing - CLI for managing clash RSS subscriptions", Version: Version, SilenceUsage: true, diff --git a/internal/service/service_darwin.go b/internal/service/service_darwin.go index ba46087..89842a3 100644 --- a/internal/service/service_darwin.go +++ b/internal/service/service_darwin.go @@ -17,7 +17,7 @@ func newPlatformManager(configDir string) (platformManager, error) { // macosServiceManager manages services via launchd. Direct port of // MacOSServiceManager in service_manager.py. Unlike the Python version // (which shells out to a separate macos_service_wrapper.py for DNS -// handling), the generated plist invokes this same ss binary in +// handling), the generated plist invokes this same ssm binary in // "service run-macos" mode (see wrapper_darwin.go) — no second script file // is needed. type macosServiceManager struct { @@ -31,7 +31,7 @@ func (d *macosServiceManager) launchdPath(name string) string { func (d *macosServiceManager) createLaunchdPlist(cfg Config) error { selfPath, err := os.Executable() if err != nil { - return fmt.Errorf("failed to determine ss executable path: %w", err) + return fmt.Errorf("failed to determine ssm executable path: %w", err) } workingDir := filepath.Dir(cfg.ExecutablePath) diff --git a/internal/service/service_windows.go b/internal/service/service_windows.go index fabbffd..082e551 100644 --- a/internal/service/service_windows.go +++ b/internal/service/service_windows.go @@ -16,7 +16,7 @@ func newPlatformManager(configDir string) (platformManager, error) { } // windowsServiceManager manages services via sc.exe, with the service -// binPath pointing back at this same ss executable in +// binPath pointing back at this same ssm executable in // "service run-windows" mode (see wrapper_windows.go) instead of a separate // pywin32-based wrapper process. Direct port of WindowsServiceManager in // service_manager.py, minus the pywin32/JSON-config-file indirection. @@ -85,7 +85,7 @@ func runAsAdmin(cmdArgs []string, description string) error { func (w *windowsServiceManager) Install(cfg Config) error { selfPath, err := os.Executable() if err != nil { - return fmt.Errorf("failed to determine ss executable path: %w", err) + return fmt.Errorf("failed to determine ssm executable path: %w", err) } serviceCmd := fmt.Sprintf(`"%s" service run-windows --name "%s" --bin "%s" --args "%s"`, diff --git a/internal/service/wrapper_darwin.go b/internal/service/wrapper_darwin.go index 41f20c5..cce24d0 100644 --- a/internal/service/wrapper_darwin.go +++ b/internal/service/wrapper_darwin.go @@ -163,7 +163,7 @@ func (w *mihomoWrapper) run() { // RunMacOSWrapper runs the mihomo process with DNS management, blocking // until it exits or a termination signal is received. Invoked by the -// hidden `ss service run-macos [args...]` command +// hidden `ssm service run-macos [args...]` command // that the generated launchd plist points at (see service_darwin.go), // replacing the standalone macos_service_wrapper.py script. func RunMacOSWrapper(executable, configDir string, args []string) error { diff --git a/internal/service/wrapper_windows.go b/internal/service/wrapper_windows.go index 7b1efa3..019b672 100644 --- a/internal/service/wrapper_windows.go +++ b/internal/service/wrapper_windows.go @@ -15,10 +15,10 @@ import ( ) // windowsServiceHandler implements svc.Handler, hosting the mihomo -// subprocess directly inside the ss binary. Replaces +// subprocess directly inside the ssm binary. Replaces // windows_service_wrapper.py + pywin32 + the per-service JSON config file: // the equivalent configuration (bin path + args) is now passed as command -// line flags to `ss service run-windows`, and this same binary registers +// line flags to `ssm service run-windows`, and this same binary registers // itself as the service via golang.org/x/sys/windows/svc. type windowsServiceHandler struct { name string @@ -119,7 +119,7 @@ func (w *logWriter) Write(p []byte) (int, error) { // RunWindowsService registers this process as the named Windows service and // blocks until the service control manager stops it. Invoked via the hidden -// `ss service run-windows --name --bin --args ` +// `ssm service run-windows --name --bin --args ` // command that Install() points sc.exe's binPath= at. func RunWindowsService(name, binPath, args string) error { logPath := filepath.Join(filepath.Dir(binPath), name+"_service.log") diff --git a/templates/embed.go b/templates/embed.go index 509066b..11d85f7 100644 --- a/templates/embed.go +++ b/templates/embed.go @@ -1,5 +1,5 @@ // Package templates embeds the default core config and hook script -// templates into the ss binary, replacing the Python version's +// templates into the ssm binary, replacing the Python version's // Path(__file__).parent / "templates" lookup. package templates