Documentation
¶
Index ¶
- Constants
- Variables
- func CheckoutPRBranch(runner gitmod.Runner, prURL string) (string, error)
- func EvaluateTestResults(err error, output, moduleName string, msgs []string, skipRace bool) (testStatus, raceStatus string, stdTestsRan bool, newMsgs []string)
- func FindProjectRoot(startDir string) (string, error)
- func FindSlowestTest(output string, threshold float64) (string, float64)
- func FindTimedOutTests(output string) []string
- func GenerateGitignore(targetDir string) error
- func GenerateHandlerFile(repoName, targetDir string) error
- func GenerateLicense(ownerName, targetDir string) error
- func GenerateREADME(repoName, description, targetDir string) error
- func GetBadgeColor(typ, value string) string
- func GetGoVersion() string
- func HandleDone(runner gitmod.Runner, env *DotEnv, git *gitmod.Git, prURL string) error
- func HasTimeoutFlag(args []string) bool
- func HasVFlag(args []string) bool
- func InitCodejobAction(force bool, org, visibility string) error
- func IsEnvironmentValid(dotenvPath string) bool
- func JulesSessionState(sessionID, apiKey string, client HTTPClient) (msg, prURL string, done bool, err error)
- func KebabToCamel(s string) string
- func MergeAndPublish(runner gitmod.Runner, publisher Publisher, message, overrideTag string) (gitmod.PushResult, error)
- func MergePR(runner gitmod.Runner) error
- func ParseCLIArgs(args []string) (message, tag string, isHelp, isRelease bool)
- func ParseCodeJobArgs(args []string) (message, tag string, isHelp, isRelease, isResetGHToken bool)
- func ParseVerifyError(output string) (string, bool)
- func ParseWasmTestPackages(goListOut string) []string
- func PrintError(msg string)
- func PrintInfo(msg string)
- func PrintSuccess(msg string)
- func PrintWarning(msg string)
- func ResolvePublishMessage(cliMessage, cliTag string, meta PlanMeta) (message, tag string, err error)
- func SerializeFrontmatter(meta PlanMeta) string
- func ShouldEnableWasm(nativeOut, wasmOut string) bool
- func SplitMarkdown(content string) (map[string]string, string, error)
- func ValidateDescription(desc string) error
- func ValidateRepoName(name string) error
- func WritePlanMeta(path string, meta PlanMeta) error
- type AddRemoteCLIOpts
- type BackupRunner
- type Badge
- type Badges
- func (h *Badges) BadgeMarkdown() string
- func (h *Badges) BuildBadges() ([]string, error)
- func (h *Badges) Err() error
- func (h *Badges) GenerateSVG() ([]byte, int, error)
- func (h *Badges) GoHandler() *Go
- func (h *Badges) OutputFile() string
- func (h *Badges) ReadmeFile() string
- func (h *Badges) SetLog(fn func(...any))
- func (h *Badges) SetRootDir(dir string)
- func (h *Badges) UpdateBadges(...) error
- func (h *Badges) UpdateReadme() error
- type Bashrc
- type CascadeEntry
- type CascadeNode
- type CascadeOutcome
- type CascadeProcessFn
- type CascadeReport
- type CodeJob
- func (c *CodeJob) GetSteps() []*wizard.Step
- func (CodeJob) ObjectsToPublish(ctx gitmod.PublishContext) (gitmod.PublishAction, string)
- func (c *CodeJob) Run(message, tag string, isRelease bool) (string, error)
- func (c *CodeJob) RunCI(phase string) error
- func (c *CodeJob) Send(issuePromptPath string) (string, error)
- func (c *CodeJob) SetLog(fn func(...any))
- func (c *CodeJob) SetPublisher(p Publisher)
- func (c *CodeJob) SetReleaser(fn func(tag string) error)
- func (c *CodeJob) SetRunner(r gitmod.Runner)
- type CodeJobCLIOpts
- type CodeJobDriver
- type CodejobPhase
- type ConsoleFilter
- type DevBackup
- type DotEnv
- type FolderWatcher
- type Future
- type Go
- func (g *Go) AddPublishObjector(obj gitmod.PublishObjector)
- func (g *Go) BuildDependentGraph(rootModule, searchPath string) ([]CascadeNode, error)
- func (g *Go) DetectGoExecutable() (string, error)
- func (g *Go) FindDependentModules(modulePath, searchPath string) ([]string, error)
- func (g *Go) GetCurrentVersion(moduleDir, dependencyPath string) (string, error)
- func (g *Go) GetGit() gitmod.GitClient
- func (g *Go) GetLog() func(...any)
- func (g *Go) GetModulePath() (string, error)
- func (g *Go) GoVersion() (string, error)
- func (g *Go) HasDependency(gomodPath, modulePath string) bool
- func (g *Go) Install(version string) error
- func (g *Go) ModExists() bool
- func (g *Go) ModExistsInCurrentOrParent() bool
- func (g *Go) ModInit(modulePath, targetDir string) error
- func (g *Go) Publish(message, tag string, ...) (gitmod.PushResult, error)
- func (g *Go) Push(message, tag string, ...) (gitmod.PushResult, error)
- func (g *Go) RunCascade(rootModule, rootVersion, rootCause, searchPath string) CascadeReport
- func (g *Go) SetBackup(b BackupRunner)
- func (g *Go) SetCascadeProcessFn(fn CascadeProcessFn)
- func (g *Go) SetConsoleOutput(fn func(string))
- func (g *Go) SetLog(fn func(...any))
- func (g *Go) SetPublishObjectors(objs ...gitmod.PublishObjector)
- func (g *Go) SetRetryConfig(delay time.Duration, attempts int)
- func (g *Go) SetRootDir(path string)
- func (g *Go) SetSumDBClient(c gitmod.SumDBClient)
- func (g *Go) Test(opts TestOptions) (string, error)
- func (g *Go) UpdateDependentModule(depDir string, bumps []gitmod.DepBump, rootCause string) (CascadeOutcome, error)
- func (g *Go) UpdateDependents(modulePath, version, searchPath string) error
- func (g *Go) UpdateModule(moduleDir, dependency, version string) error
- func (g *Go) UseTinygo(enabled bool)
- func (g *Go) Verify() error
- func (g *Go) WaitForVersionAvailable(modulePath, version string) error
- type GoModHandler
- func (m *GoModHandler) EnsureReplace(modulePath, localPath string) bool
- func (m *GoModHandler) GetReplacePaths() ([]ReplaceEntry, error)
- func (m *GoModHandler) HasOtherReplaces(exceptModules ...string) bool
- func (g *GoModHandler) MainInputFileRelativePath() string
- func (g *GoModHandler) Name() string
- func (g *GoModHandler) NewFileEvent(fileName, extension, filePath, event string) error
- func (m *GoModHandler) ObjectsToPublish(ctx gitmod.PublishContext) (gitmod.PublishAction, string)
- func (m *GoModHandler) RemoveReplace(modulePath string) bool
- func (m *GoModHandler) RunTidy() error
- func (m *GoModHandler) Save() error
- func (g *GoModHandler) SetFolderWatcher(watcher FolderWatcher)
- func (g *GoModHandler) SetLog(fn func(messages ...any))
- func (g *GoModHandler) SetOnSSRFileChange(fn func(string))
- func (g *GoModHandler) SetRootDir(path string)
- func (g *GoModHandler) SupportedExtensions() []string
- func (g *GoModHandler) UnobservedFiles() []string
- type GoModInterface
- type GoNew
- type GoNewCLIOpts
- type GoTestArgs
- func (m *GoTestArgs) DecodeFields(r model.FieldReader)
- func (m *GoTestArgs) EncodeFields(w model.FieldWriter)
- func (m *GoTestArgs) IsNil() bool
- func (m *GoTestArgs) ModelName() string
- func (m *GoTestArgs) Pointers() []any
- func (m *GoTestArgs) Schema() []model.Field
- func (m *GoTestArgs) Validate(action byte) error
- type GoTestProvider
- type HTTPClient
- type JulesAuth
- type JulesConfig
- type JulesDriver
- type MockDevBackup
- type NewProjectOptions
- type PlanMeta
- type Publisher
- type ReplaceEntry
- type SessionProvider
- type TestOptions
- type Watchdog
Constants ¶
const ( // DefaultIssuePromptPath is the conventional location for the task description file. DefaultIssuePromptPath = "docs/PLAN.md" // CodejobStashMessage is the label for the git stash created during branch switching. CodejobStashMessage = "codejob: local drift before review" // HintManualCheckout is the message shown when automatic branch switch fails. HintManualCheckout = "⚠️ Could not switch branch automatically — run manually:" // HintManualPRCheckout is the message shown when PR branch resolution fails. HintManualPRCheckout = "⚠️ Could not resolve branch from PR — switch manually:" )
const ( ColorRed = "\033[0;31m" ColorGreen = "\033[0;32m" ColorYellow = "\033[0;33m" ColorCyan = "\033[0;36m" ColorNone = "\033[0m" )
const ( FrontmatterKeyPlan = "PLAN" // required: commit message used when closing the loop FrontmatterKeyTag = "TAG" // optional: explicit version tag FrontmatterKeyExecutor = "EXECUTOR" // optional: executor agent FrontmatterKeyReviewer = "REVIEWER" // optional: reviewer agent FrontmatterKeyCorrector = "CORRECTOR" // optional: corrector agent FrontmatterKeyReviewGuide = "REVIEW_GUIDE" // optional: path to review guidelines FrontmatterKeyStatus = "STATUS" // optional: orchestrator status FrontmatterKeySession = "SESSION" // optional: executor session ID FrontmatterKeyReviewSession = "REVIEW_SESSION" // optional: reviewer session ID FrontmatterKeyRound = "ROUND" // optional: round count FrontmatterKeyPR = "PR" // optional: pull request URL )
const ( CascadeStatusPublished = "published" CascadeStatusDepsOnly = "deps only" CascadeStatusSkipped = "skipped" CascadeStatusFailed = "failed" )
CascadeStatus constants represent the possible outcomes of a module update in a cascade.
const DevFlowRepository = "webtyp.com/devflow"
const ErrPushBlockedActiveCodejob = "" /* 160-byte string literal not displayed */
ErrPushBlockedActiveCodejob is returned by Push when the repo has an active codejob session: publishing would move the base branch under the agent.
const JulesResultPrefix = "jules: "
JulesResultPrefix is the prefix on the string returned by the Jules driver after dispatching a session. cmd/codejob uses it to format the output.
const MaxCascadeDepth = 10
Variables ¶
var ( ErrFrontmatterMissing = errors.New("plan frontmatter: file must start with a '---' line" + frontmatterHelp) ErrFrontmatterUnclosed = errors.New("plan frontmatter: opening '---' has no matching closing '---'" + frontmatterHelp) ErrFrontmatterNoPlan = errors.New("plan frontmatter: missing required 'PLAN:' field (the old 'message:' key was renamed — rename it in your plan)" + frontmatterHelp) )
var ErrNoCloseLoopMessage = errors.New("no close-loop commit message: pass one on the CLI or add 'PLAN:' to the plan frontmatter")
var GoTestArgsModel = model.Definition{ Name: "go_test_args", Fields: model.Fields{ {Name: "run", Type: model.Text()}, }, }
var GoTestCmdFn = testCommand
GoTestCmdFn creates the command used to run 'go test'. Override in tests to avoid launching a real nested go test subprocess (e.g. from Release→Push→Test).
Functions ¶
func CheckoutPRBranch ¶
CheckoutPRBranch fetches and hard-positions the working tree on the PR's head branch. A dirty working tree is handled, not feared: local drift is stashed with a labeled stash (CodejobStashMessage) and re-applied after the switch; if re-applying conflicts, the stash is KEPT, the conflict files are listed, and an error is returned. Returns the branch name on success.
func EvaluateTestResults ¶
func EvaluateTestResults(err error, output, moduleName string, msgs []string, skipRace bool) (testStatus, raceStatus string, stdTestsRan bool, newMsgs []string)
EvaluateTestResults analyzes the output of go test and decides the outcome This function is pure and can be easily tested.
func FindProjectRoot ¶
FindProjectRoot looks for go.mod in startDir or its immediate parent. Returns the absolute path to the directory containing go.mod, or an empty string and error if not found.
func FindSlowestTest ¶
FindSlowestTest parses -v test output and returns the name and duration of the slowest individual test across all packages if it exceeds the specified threshold.
func FindTimedOutTests ¶
FindTimedOutTests parses go test output and extracts test names that timed out. Handles two scenarios: 1. Go's native timeout: "panic: test timed out after Ns\n running tests:\n TestName (Ns)" 2. Process killed externally (context.WithTimeout): finds the last "=== RUN" without a matching "--- PASS/FAIL"
func GenerateGitignore ¶
GenerateGitignore generates .gitignore for Go
func GenerateHandlerFile ¶
GenerateHandlerFile generates the main handler file
func GenerateLicense ¶
GenerateLicense generates LICENSE (MIT)
func GenerateREADME ¶
GenerateREADME generates README.md
func GetBadgeColor ¶
func GetGoVersion ¶
func GetGoVersion() string
func HandleDone ¶
HandleDone executes cleanup when Jules completes: HandleDone is kept for signature compatibility but is a no-op under the new PLAN.md state model.
func HasTimeoutFlag ¶
HasTimeoutFlag checks if -timeout is already present in the args
func InitCodejobAction ¶
InitCodejobAction scaffolds the GitHub Actions workflow at .github/workflows/codejob.yml and registers the JULES_API_KEY and GH_TOKEN secrets in the repository or organization.
func IsEnvironmentValid ¶
IsEnvironmentValid reports whether the current working directory has an active codejob context: a PLAN.md to dispatch or a session in progress.
func JulesSessionState ¶
func JulesSessionState(sessionID, apiKey string, client HTTPClient) (msg, prURL string, done bool, err error)
JulesSessionState polls the Jules API for session status. Returns (message, prURL, isDone, error).
func KebabToCamel ¶
KebabToCamel converts kebab-case or snake_case to CamelCase
func MergeAndPublish ¶
func MergeAndPublish(runner gitmod.Runner, publisher Publisher, message, overrideTag string) (gitmod.PushResult, error)
MergeAndPublish merges the Jules PR, pulls the merged commit, and publishes via gopush.
func ParseCLIArgs ¶
ParseCLIArgs parses command line arguments for devflow tools (codejob, gopush). It returns the message, tag, whether help was requested, and whether -release flag is present. Flags like -release and --release are detected and excluded from message/tag assignment.
func ParseCodeJobArgs ¶
ParseCodeJobArgs parses codejob CLI: codejob [message] [tag] [--reset-gh-token] Returns message, tag, isHelp, isRelease, and isResetGHToken.
func ParseVerifyError ¶
ParseVerifyError detects known go mod verify failure patterns and returns an actionable message.
func ParseWasmTestPackages ¶
ParseWasmTestPackages keeps the packages that have tests AND can be built for wasm.
func ResolvePublishMessage ¶
func ResolvePublishMessage(cliMessage, cliTag string, meta PlanMeta) (message, tag string, err error)
ResolvePublishMessage picks the effective close-loop commit message and tag: an explicit CLI value wins; otherwise the plan frontmatter is used.
func SerializeFrontmatter ¶
SerializeFrontmatter serializes PlanMeta back to a YAML-like frontmatter string block.
func ShouldEnableWasm ¶
ShouldEnableWasm decides if WASM tests should be run based on go list output differences
func SplitMarkdown ¶
SplitMarkdown splits a markdown content into frontmatter keys and body.
func ValidateDescription ¶
ValidateDescription validates the repository description
func ValidateRepoName ¶
ValidateRepoName validates the repository name Only alphanumeric, dash, and underscore allowed
func WritePlanMeta ¶
WritePlanMeta updates or creates a PLAN.md file at path with the given meta, preserving the markdown body.
Types ¶
type AddRemoteCLIOpts ¶
AddRemoteCLIOpts holds parsed options for the gonew add-remote CLI.
func ParseAddRemoteArgs ¶
func ParseAddRemoteArgs(args []string) (AddRemoteCLIOpts, error)
ParseAddRemoteArgs parses `gonew add-remote <project-path> [flags]`.
type BackupRunner ¶
type BackupRunner interface {
SetLog(fn func(...any))
SetCommand(command string) error
GetCommand() (string, error)
Run() (string, error)
}
BackupRunner defines the interface for backup operations. Allows mocking in tests to prevent real backup execution.
type Badge ¶
type Badge struct {
Label string // The text displayed on the left side of the badge.
Value string // The text displayed on the right side of the badge.
Color string // The background color for the value part of the badge (e.g., "#4c1" or "green").
}
Badge represents a single badge with a label, value, and color. This is the primary struct used to define a badge's appearance and content.
For example, to create a "Go version" badge, you might use:
b := Badge{
Label: "Go",
Value: "1.18",
Color: "#007d9c",
}
type Badges ¶
type Badges struct {
// contains filtered or unexported fields
}
Badges is responsible for creating and managing a collection of badges. It handles parsing input arguments, generating the SVG image, and preparing the necessary markdown to embed the badges in a file.
func (*Badges) BadgeMarkdown ¶
BadgeMarkdown generates the markdown snippet for embedding the badge image.
func (*Badges) BuildBadges ¶
BuildBadges generates the SVG image, writes it to the specified output file, and returns a slice of strings intended for updating a markdown file.
func (*Badges) GenerateSVG ¶
GenerateSVG creates an SVG image from the configured badges.
It returns the SVG content as a byte slice, the number of badges included, and an error if the generation fails. This method is typically called by BuildBadges, but it can be used directly if you only need the SVG data.
Example of a generated SVG for two badges ("License:MIT:blue" and "Go:1.22:blue"):
<?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" width="168" height="20" viewBox="0 0 168 20">
<!-- Badge: License --> <g transform="translate(0, 0)"> <rect x="0" y="0" width="58" height="20" fill="#6c757d"/> <rect x="58" y="0" width="46" height="20" fill="blue"/> <text x="29" y="14" text-anchor="middle" font-family="sans-serif" font-size="11" fill="white">License</text> <text x="81" y="14" text-anchor="middle" font-family="sans-serif" font-size="11" fill="white">MIT</text> </g> <!-- Badge: Go --> <g transform="translate(109, 0)"> <rect x="0" y="0" width="34" height="20" fill="#6c757d"/> <rect x="34" y="0" width="25" height="20" fill="blue"/> <text x="17" y="14" text-anchor="middle" font-family="sans-serif" font-size="11" fill="white">Go</text> <text x="46" y="14" text-anchor="middle" font-family="sans-serif" font-size="11" fill="white">1.22</text> </g>
</svg>
func (*Badges) OutputFile ¶
OutputFile returns the configured path for the output SVG file.
func (*Badges) ReadmeFile ¶
ReadmeFile returns the configured path for the markdown file to be updated.
func (*Badges) SetRootDir ¶
SetRootDir sets the root directory for badge operations
func (*Badges) UpdateBadges ¶
func (h *Badges) UpdateBadges(readmeFile, licenseType, goVer, testStatus, coveragePercent, raceStatus, vetStatus string, quiet bool) error
UpdateBadges generates badge SVG and updates the README using the provided values.
func (*Badges) UpdateReadme ¶
UpdateReadme updates the README file with the badge image line. Detects and migrates old START_SECTION/END_SECTION markers, replaces existing badge img lines, or inserts a new one.
type Bashrc ¶
type Bashrc struct {
FilePath string
}
Bashrc handles updates to .bashrc file using markers
func (*Bashrc) ExtractValue ¶
ExtractValue extracts value from export statement Input: export KEY="value" or export KEY=value Output: value
type CascadeEntry ¶
CascadeEntry represents the result for a single module in the cascade
type CascadeNode ¶
type CascadeNode struct {
Dir string
ModulePath string
DependsOn []string // List of ModulePaths this node depends on *within the cascade*
}
CascadeNode represents a module in the dependency graph
type CascadeOutcome ¶
type CascadeOutcome struct {
Status string // CascadeStatusPublished | CascadeStatusDepsOnly | CascadeStatusSkipped
Version string // set only when Status == CascadeStatusPublished
Reason string // human-readable, e.g. "codejob session active"
}
CascadeOutcome is the typed result of processing one node. It replaces the previous convention of encoding the status inside a free-form string.
type CascadeProcessFn ¶
type CascadeProcessFn func(node CascadeNode, bumps []gitmod.DepBump, rootCause string) (CascadeOutcome, error)
CascadeProcessFn is the signature for the function that processes a single node
type CascadeReport ¶
type CascadeReport struct {
Entries []CascadeEntry
}
CascadeReport contains the full report of the cascade execution
type CodeJob ¶
type CodeJob struct {
// contains filtered or unexported fields
}
CodeJob orchestrates sending a coding task to a chain of AI agent drivers. It validates the prompt file, then tries each driver in priority order, falling back to the next on failure.
func NewCodeJob ¶
func NewCodeJob(drivers ...CodeJobDriver) *CodeJob
NewCodeJob creates a CodeJob with the given ordered drivers.
func (CodeJob) ObjectsToPublish ¶
func (CodeJob) ObjectsToPublish(ctx gitmod.PublishContext) (gitmod.PublishAction, string)
ObjectsToPublish implements PublishObjector. It is stateless.
func (*CodeJob) Run ¶
Run implements the unified API logic. isRelease indicates whether to create a GitHub Release after MergeAndPublish.
func (*CodeJob) RunCI ¶
RunCI executes a single state transition phase for the codejob orchestrator in CI.
func (*CodeJob) Send ¶
Send validates issuePromptPath, publishes pending changes, then tries each driver in order until one succeeds. Returns an error if the file is missing, empty, the publish fails, or all drivers fail.
func (*CodeJob) SetPublisher ¶
SetPublisher injects a Publisher for close-loop operations.
func (*CodeJob) SetReleaser ¶
SetReleaser injects a release function to be called after MergeAndPublish when -release flag is used.
type CodeJobCLIOpts ¶
type CodeJobCLIOpts struct {
Message string
Tag string
IsHelp bool
IsRelease bool
IsResetGHToken bool
CIPhase string // "dispatch", "review", "verdict", "publish"
InitAction bool
Force bool
Org string
Visibility string
}
CodeJobCLIOpts holds parsed options for the codejob CLI.
func ParseCodeJobFlags ¶
func ParseCodeJobFlags(args []string) CodeJobCLIOpts
ParseCodeJobFlags parses the complete set of flags and positional arguments for the codejob CLI.
type CodeJobDriver ¶
type CodeJobDriver interface {
Name() string
SetLog(fn func(...any))
Send(prompt, title string) (string, error)
}
CodeJobDriver defines the contract for an external AI coding agent. Implementations: JulesDriver, (future: OllamaDriver, etc.) title is the human-readable job name (e.g. "owner/repo"), derived by CodeJob.
type CodejobPhase ¶
type CodejobPhase string
const ( PhaseRunning CodejobPhase = "running" PhaseReview CodejobPhase = "review" )
func CodejobPhaseOf ¶
func CodejobPhaseOf(dir string) CodejobPhase
CodejobPhaseOf reports the current codejob phase for the given directory.
type ConsoleFilter ¶
type ConsoleFilter struct {
// contains filtered or unexported fields
}
func NewConsoleFilter ¶
func NewConsoleFilter(output func(string)) *ConsoleFilter
func (*ConsoleFilter) Add ¶
func (cf *ConsoleFilter) Add(input string)
func (*ConsoleFilter) Flush ¶
func (cf *ConsoleFilter) Flush()
type DevBackup ¶
type DevBackup struct {
// contains filtered or unexported fields
}
DevBackup handles backup operations
func (*DevBackup) GetCommand ¶
GetCommand retrieves the backup command First checks environment variable, then falls back to .bashrc
func (*DevBackup) Run ¶
Run executes the backup command asynchronously Returns a message for the summary or empty string if not configured
func (*DevBackup) SetCommand ¶
SetCommand sets the backup command in .bashrc and current environment
type DotEnv ¶
type DotEnv struct {
// contains filtered or unexported fields
}
DotEnv handles .env files while trying to preserve non-key=value lines (comments, empty lines).
type FolderWatcher ¶
type FolderWatcher interface {
AddDirectoriesToWatch(paths ...string) error
RemoveDirectoriesFromWatcher(paths ...string) error
}
FolderWatcher defines interface for adding/removing directories to watch
type Future ¶
type Future struct {
// contains filtered or unexported fields
}
Future holds the async result of any initialization. It uses any (interface{}) for flexibility without generic syntax.
func NewResolvedFuture ¶
NewResolvedFuture creates a Future that is already resolved with the given value. Useful for tests or when the value is already available synchronously.
type Go ¶
type Go struct {
// contains filtered or unexported fields
}
Go handler for Go operations
func (*Go) AddPublishObjector ¶
func (g *Go) AddPublishObjector(obj gitmod.PublishObjector)
AddPublishObjector appends an extra publish objector.
func (*Go) BuildDependentGraph ¶
func (g *Go) BuildDependentGraph(rootModule, searchPath string) ([]CascadeNode, error)
BuildDependentGraph finds all modules that transitively depend on rootModule. It returns them in topological order.
func (*Go) DetectGoExecutable ¶
DetectGoExecutable returns the path to the go executable
func (*Go) FindDependentModules ¶
FindDependentModules searches for modules that have modulePath as dependency. It excludes modules located inside the current project's root directory.
func (*Go) GetCurrentVersion ¶
GetCurrentVersion returns the current version of a dependency in a module
func (*Go) GetModulePath ¶
GetModulePath gets full module path
func (*Go) GoVersion ¶
GoVersion reads the Go version from the go.mod file in the current directory. It returns the version string (e.g., "1.18") or an empty string if not found.
func (*Go) HasDependency ¶
HasDependency checks if a go.mod contains a specific dependency
func (*Go) Install ¶
Install builds and installs all commands in the cmd/ directory It injects the version using ldflags if provided
func (*Go) ModExistsInCurrentOrParent ¶
ModExistsInCurrentOrParent checks if go.mod exists in the rootDir or one directory up.
func (*Go) Publish ¶
func (g *Go) Publish(message, tag string, skipTests, skipRace, skipDependents, skipBackup, skipTag, skipVerify bool) (gitmod.PushResult, error)
Publish satisfies the Publisher interface
func (*Go) Push ¶
func (g *Go) Push(message, tag string, skipTests, skipRace, skipDependents, skipBackup, skipTag, skipVerify bool, searchPath string) (gitmod.PushResult, error)
Push executes the complete workflow for Go projects Parameters:
message: Commit message tag: Optional tag skipTests: If true, skips tests skipRace: If true, skips race tests skipDependents: If true, skips updating dependent modules skipBackup: If true, skips backup skipTag: If true, skips tag generation and pushes without tags searchPath: Path to search for dependent modules (default: "..")
func (*Go) RunCascade ¶
func (g *Go) RunCascade(rootModule, rootVersion, rootCause, searchPath string) CascadeReport
RunCascade executes the topological cascade
func (*Go) SetBackup ¶
func (g *Go) SetBackup(b BackupRunner)
SetBackup replaces the backup runner (used in tests to inject a mock).
func (*Go) SetCascadeProcessFn ¶
func (g *Go) SetCascadeProcessFn(fn CascadeProcessFn)
SetCascadeProcessFn sets the function used to process each node in the cascade. This is used to inject mocks in tests.
func (*Go) SetConsoleOutput ¶
SetConsoleOutput sets the function for console output (used by ConsoleFilter)
func (*Go) SetPublishObjectors ¶
func (g *Go) SetPublishObjectors(objs ...gitmod.PublishObjector)
SetPublishObjectors replaces the extra publish objectors.
func (*Go) SetRetryConfig ¶
SetRetryConfig sets the retry configuration for network operations
func (*Go) SetRootDir ¶
SetRootDir sets the root directory for Go operations
func (*Go) SetSumDBClient ¶
func (g *Go) SetSumDBClient(c gitmod.SumDBClient)
SetSumDBClient enables the public-checksum-database guard before tagging. nil (never called) preserves the exact behavior this package had before this option existed.
func (*Go) Test ¶
func (g *Go) Test(opts TestOptions) (string, error)
Test executes the test suite for the project. The zero TestOptions runs the full suite with -race, the default timeout, and the build cache enabled.
func (*Go) UpdateDependentModule ¶
func (*Go) UpdateDependents ¶
UpdateDependents updates modules that depend on the current one
func (*Go) UpdateModule ¶
UpdateModule updates a specific module to a new version
func (*Go) UseTinygo ¶
UseTinygo makes the WASM suite compile with TinyGo.
It is opt-in because it is slow. It is also the only run that proves anything about TinyGo compatibility: the Go js/wasm backend supports the full stdlib, so the default WASM suite stays green on packages TinyGo cannot build.
func (*Go) WaitForVersionAvailable ¶
WaitForVersionAvailable waits for a module version to be available on Go proxy
type GoModHandler ¶
type GoModHandler struct {
Lines []string // all lines of the file
Modified bool // track if changes were made
OnSSRFileChange func(moduleDir string) // called when ssr.go changes in a watched module
// contains filtered or unexported fields
}
GoModHandler represents a parsed go.mod file and handles file events
func NewGoModHandler ¶
func NewGoModHandler() *GoModHandler
NewGoModHandler reads and parses a go.mod file or returns an empty handler if path is empty
func (*GoModHandler) EnsureReplace ¶
func (m *GoModHandler) EnsureReplace(modulePath, localPath string) bool
EnsureReplace ensures that a replace directive exists for the given module path pointing to the given local path. Returns true if the file was modified.
func (*GoModHandler) GetReplacePaths ¶
func (m *GoModHandler) GetReplacePaths() ([]ReplaceEntry, error)
GetReplacePaths returns absolute paths from local replace directives. Relative paths are resolved starting from the directory containing go.mod.
func (*GoModHandler) HasOtherReplaces ¶
func (m *GoModHandler) HasOtherReplaces(exceptModules ...string) bool
HasOtherReplaces returns true if there are replace directives other than the specified modules
func (*GoModHandler) MainInputFileRelativePath ¶
func (g *GoModHandler) MainInputFileRelativePath() string
func (*GoModHandler) Name ¶
func (g *GoModHandler) Name() string
func (*GoModHandler) NewFileEvent ¶
func (g *GoModHandler) NewFileEvent(fileName, extension, filePath, event string) error
NewFileEvent handles changes to go.mod and ssr.go files in watched modules
func (*GoModHandler) ObjectsToPublish ¶
func (m *GoModHandler) ObjectsToPublish(ctx gitmod.PublishContext) (gitmod.PublishAction, string)
func (*GoModHandler) RemoveReplace ¶
func (m *GoModHandler) RemoveReplace(modulePath string) bool
RemoveReplace removes a replace directive for the given module. Local replace directives (target starting with "." or "/", e.g. "=> ./") are preserved: subpackages (tests/, cmd/, etc.) commonly use a self-referencing local replace to pull in the parent module without polluting the root go.mod, and that must survive dependent-module updates. Returns true if a replace was found and removed
func (*GoModHandler) RunTidy ¶
func (m *GoModHandler) RunTidy() error
RunTidy executes 'go mod tidy' in the directory of the go.mod file
func (*GoModHandler) Save ¶
func (m *GoModHandler) Save() error
Save writes changes back to the file if modified
func (*GoModHandler) SetFolderWatcher ¶
func (g *GoModHandler) SetFolderWatcher(watcher FolderWatcher)
func (*GoModHandler) SetLog ¶
func (g *GoModHandler) SetLog(fn func(messages ...any))
func (*GoModHandler) SetOnSSRFileChange ¶
func (g *GoModHandler) SetOnSSRFileChange(fn func(string))
func (*GoModHandler) SetRootDir ¶
func (g *GoModHandler) SetRootDir(path string)
func (*GoModHandler) SupportedExtensions ¶
func (g *GoModHandler) SupportedExtensions() []string
func (*GoModHandler) UnobservedFiles ¶
func (g *GoModHandler) UnobservedFiles() []string
type GoModInterface ¶
type GoModInterface interface {
NewFileEvent(fileName, extension, filePath, event string) error
SetFolderWatcher(watcher FolderWatcher)
Name() string
SupportedExtensions() []string
MainInputFileRelativePath() string
UnobservedFiles() []string
SetLog(fn func(...any))
SetRootDir(path string)
GetReplacePaths() ([]ReplaceEntry, error)
}
GoModInterface defines interface for go.mod handling
type GoNew ¶
type GoNew struct {
// contains filtered or unexported fields
}
GoNew orchestrator
func (*GoNew) Create ¶
func (gn *GoNew) Create(opts NewProjectOptions) (string, error)
Create executes full workflow with remote (or local-only fallback)
type GoNewCLIOpts ¶
type GoNewCLIOpts struct {
Name string
Description string
Owner string
Visibility string
LocalOnly bool
License string
}
GoNewCLIOpts holds parsed options for the gonew create CLI.
func ParseGoNewArgs ¶
func ParseGoNewArgs(args []string) (GoNewCLIOpts, error)
ParseGoNewArgs parses `gonew <repo-name> <description> [flags]`. Flags may appear before or after the positional arguments.
type GoTestArgs ¶
type GoTestArgs struct {
Run string
}
GoTestArgs are the arguments accepted by the run_tests MCP tool.
func (*GoTestArgs) DecodeFields ¶
func (m *GoTestArgs) DecodeFields(r model.FieldReader)
func (*GoTestArgs) EncodeFields ¶
func (m *GoTestArgs) EncodeFields(w model.FieldWriter)
func (*GoTestArgs) IsNil ¶
func (m *GoTestArgs) IsNil() bool
func (*GoTestArgs) ModelName ¶
func (m *GoTestArgs) ModelName() string
func (*GoTestArgs) Pointers ¶
func (m *GoTestArgs) Pointers() []any
func (*GoTestArgs) Schema ¶
func (m *GoTestArgs) Schema() []model.Field
func (*GoTestArgs) Validate ¶
func (m *GoTestArgs) Validate(action byte) error
type GoTestProvider ¶
type GoTestProvider struct {
// contains filtered or unexported fields
}
GoTestProvider exposes the gotest suite as a single MCP tool.
func NewGoTestProvider ¶
func NewGoTestProvider(g *Go) *GoTestProvider
NewGoTestProvider creates a new GoTestProvider.
func (*GoTestProvider) Tools ¶
func (p *GoTestProvider) Tools() []mcp.Tool
Tools implements mcp.ToolProvider.
type HTTPClient ¶
HTTPClient defines the interface for HTTP operations (injectable for tests).
type JulesAuth ¶
type JulesAuth struct {
// contains filtered or unexported fields
}
JulesAuth manages the Jules API key via the system keyring. On first use it prompts the user to enter the key and stores it securely.
func NewJulesAuth ¶
NewJulesAuth creates a JulesAuth over the "devflow" keyring service.
func (*JulesAuth) EnsureAPIKey ¶
EnsureAPIKey returns the Jules API key from the environment or keyring. If absent, prompts the user for it once and persists it.
type JulesConfig ¶
type JulesConfig struct {
APIKey string // optional: loaded from keyring if empty
SourceID string // optional: auto-detected via gh CLI if empty
StartBranch string // optional: auto-detected via git if empty
SessionTitle string // optional: defaults to prompt filename
SourceIndexTimeout time.Duration // optional: max wait for source to appear (default 2m)
SourceIndexInterval time.Duration // optional: polling interval for source check (default 10s)
}
JulesConfig holds the configuration for the Jules driver. All fields are optional: APIKey is loaded from keyring if empty, SourceID and StartBranch are auto-detected via gh/git if empty.
type JulesDriver ¶
type JulesDriver struct {
// contains filtered or unexported fields
}
JulesDriver implements CodeJobDriver for the Jules AI agent.
func NewJulesDriver ¶
func NewJulesDriver(config JulesConfig) *JulesDriver
NewJulesDriver creates a JulesDriver. All JulesConfig fields are optional.
func (*JulesDriver) Send ¶
func (d *JulesDriver) Send(prompt, title string) (string, error)
Send creates a Jules session using the prompt and title resolved by CodeJob. Jules accesses the referenced file directly from the repository via its GitHub App access. If the source is not yet indexed in Jules (404 on new repos), it polls GET /sources until the source appears or the timeout is exceeded.
func (*JulesDriver) SessionID ¶
func (d *JulesDriver) SessionID() string
SessionID returns the last session ID created.
func (*JulesDriver) SetHTTPClient ¶
func (d *JulesDriver) SetHTTPClient(client HTTPClient)
SetHTTPClient replaces the HTTP client (for testing).
func (*JulesDriver) SetLog ¶
func (d *JulesDriver) SetLog(fn func(...any))
SetLog sets the logging function.
func (*JulesDriver) SetRunner ¶
func (d *JulesDriver) SetRunner(r gitmod.Runner)
SetRunner replaces the command runner used for the gh session check (for testing).
type MockDevBackup ¶
MockDevBackup is a no-op BackupRunner for use in tests.
func (*MockDevBackup) GetCommand ¶
func (m *MockDevBackup) GetCommand() (string, error)
func (*MockDevBackup) Run ¶
func (m *MockDevBackup) Run() (string, error)
func (*MockDevBackup) SetCommand ¶
func (m *MockDevBackup) SetCommand(cmd string) error
func (*MockDevBackup) SetLog ¶
func (m *MockDevBackup) SetLog(_ func(...any))
type NewProjectOptions ¶
type NewProjectOptions struct {
Name string // Required, must be valid (alphanumeric, dash, underscore only)
Description string // Required, max 350 chars
Owner string // GitHub owner/organization (default: detected from gh or git config)
Visibility string // "public" or "private" (default: "public")
Directory string // Supports ~/path, ./path, /abs/path (default: ./{Name})
LocalOnly bool // If true, skip remote creation
License string // Default "MIT"
}
NewProjectOptions options for creating a new project
type PlanMeta ¶
type PlanMeta struct {
Message string // required: commit message used when closing the loop
Tag string // optional: explicit version tag (e.g. "v0.1.0")
Executor string // optional: agent that implements (default "jules")
Reviewer string // optional: agent that reviews (default "none")
Corrector string // optional: agent that applies review feedback (default: executor)
ReviewGuide string // optional: path to extra review criteria
Status string // optional: dispatch -> running -> reviewing -> review
Session string // optional: executor session id
ReviewSession string // optional: reviewer session id
Round int // optional: executor<->reviewer round count (capped, default 3)
PR string // optional: URL of the PR opened by the executor
}
PlanMeta holds the parsed frontmatter of a docs/PLAN.md file.
func ParseFrontmatter ¶
ParseFrontmatter parses the leading frontmatter block of content and maps it to PlanMeta, requiring 'PLAN'. Structural parsing is delegated to webtyp/markdown; devflow only owns the "which keys are required" rule.
func ReadPlanMeta ¶
ReadPlanMeta reads and validates the frontmatter of a plan file at path.
type Publisher ¶
type Publisher interface {
Publish(message, tag string, skipTests, skipRace, skipDependents, skipBackup, skipTag, skipVerify bool) (git.PushResult, error)
}
Publisher defines the interface for publishing code changes.
type ReplaceEntry ¶
type ReplaceEntry struct {
ModulePath string // The module being replaced
LocalPath string // The local path replacement
}
ReplaceEntry represents a local replace directive found in go.mod
type SessionProvider ¶
type SessionProvider interface {
SessionID() string
}
SessionProvider is implemented by CodeJobDrivers that return a session ID after a successful Send(). CodeJob uses this to persist to .env.
type TestOptions ¶ added in v0.4.83
type TestOptions struct {
Args []string // extra `go test` arguments; nil or empty = full suite
SkipRace bool // omit -race
Timeout int // seconds; 0 = the package default
NoCache bool // add -count=1
RunAll bool // include the packages normally skipped
}
TestOptions configures a test run. The zero value runs the full suite with the race detector, the default timeout, and the build cache enabled.
Source Files
¶
- badge.go
- badge_svg.go
- badges.go
- bashrc.go
- cascade.go
- cli.go
- code_jules.go
- codejob.go
- codejob_action.go
- codejob_auth.go
- codejob_state.go
- colors.go
- console_filter.go
- devbackup.go
- dotenv.go
- frontmatter.go
- future.go
- go_handler.go
- go_mod.go
- go_selfdep.go
- gonew.go
- gonew_cli.go
- gonew_wizard.go
- gotest.go
- gotest_mcp.go
- gotest_tinygo.go
- interface.go
- mock_devbackup.go
- project_templates.go
- watchdog.go