Repository navigation
refactor: move the helpers the CLI and the executor share out of internal/cmd - #19
Merged
Merged
Conversation
internal/cmd/work_proc.go moves whole to internal/proc (GroupCmd, RunGroupCmd and the WaitDelay/KillGrace tunables), so the CLI and the executor can share it without importing each other. The one call back into the executor - journaling a forwarded terminal signal - becomes the OnTerminalSignal hook, which the crash journal sets at init.
The codes and the error that pins one on a failure live in internal/exitcode now; cmd keeps ExitCode, its Exit* constants (aliases of the leaf's) and the usageErr/notFoundErr/conflictErr shorthands. The acceptance claim's conflict errors in finish.go use the leaf directly, since that code is not going to stay in cmd.
…nternal/cmd Only these functions move, the rest of their files stays: resolveProjectSlugArg and resolveProjectArg (executor_show.go) become projectarg.Slug and projectarg.Load, detectProjectFromCwd (board.go) becomes projectarg.FromCwd. The CLI commands and the executor commands both resolve their [project] argument through them.
…rnal/cmd Only encodeProjectPath and its test move out of sessionid.go and sessionid_test.go, as ccpath.Encode: `pm session-id` and the worker transcript lookup both use it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #18.
Four helpers that both the CLI and the executor use move out of
internal/cmdinto small packages of their own, so the executor can leaveinternal/cmdwithout importing it:internal/proc- the process-group runner (GroupCmd,RunGroupCmd,WaitDelay,KillGrace), also used bypm serveandpm runs.internal/exitcode- the coded exit error and the codes 1-4.internal/cmd'sExitCodestill classifies it.internal/projectarg- resolving the optional[project]argument.internal/ccpath- Claude Code's project-directory name for a path.internal/procmust not import the executor. On a terminal signal it used to call the executor's crash journal directly; now it calls aproc.OnTerminalSignalhook, a no-op by default, which the executor sets in aninit. Everypmbinary links the executor, so the behaviour is the same.Apart from comments, the moved code changes only in names: the exported names of the moved functions and fields, and the names they call (the renamed variables, the exit-code helper, the hook). The contract tests from #18 pass unchanged. CLAUDE.md and the current docs (not the dated
docs/design-log.md) nameinternal/procandinternal/exitcodewhere they named the old helpers.