Documentation
¶
Index ¶
- func FormatLiveError(pid int, err error) string
- func FormatTree(nodes []ProcNode, opts TreeFormatOptions) string
- func IsGrokRunner(cmd string) bool
- func LiveLsof(pid int) []string
- func ParseSessionFromPath(path string) (kind, sessionID string, ok bool)
- type Options
- type Proc
- type ProcNode
- type Result
- type TreeFormatOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatLiveError ¶
FormatLiveError is a small helper for CLI messages (kept for symmetry).
func FormatTree ¶
func FormatTree(nodes []ProcNode, opts TreeFormatOptions) string
FormatTree rebuilds a parent→child forest from node PPIDs and prints each node as connectors + "PID Cmd". Pure: does not call Resolve or Lsof.
Connector rules (matches locked P2 templates for sole-child chains):
- Non-last siblings use branch (├── / +--) and pipe continuation (│ / |).
- Last siblings that still have children also use branch + pipe (so a single intermediate child is drawn with ├──/│, not └──/spaces).
- Last siblings that are leaves use last (└── / `--) and blank continuation.
func IsGrokRunner ¶ added in v0.0.94
IsGrokRunner reports whether cmd is a grok session runner (basename grok, excluding pure `grok update` utilities).
func LiveLsof ¶
LiveLsof returns open-file paths for pid via shared go-pkgs/proc OpenFiles. On failure returns nil (soft miss for that candidate).
func ParseSessionFromPath ¶ added in v0.0.94
ParseSessionFromPath extracts a hard session hit from an open-file path. Returns kind ("grok"|"codex"), sessionID (lowercased), ok.
Types ¶
type Options ¶
type Options struct {
GrokHome string
CodexHome string
MaxDepth int
ListProcs func() []Proc
Lsof func(pid int) []string
// EnrichInfo, when true and Kind is grok with a SessionID, calls
// LookupGrokInfo to fill GrokTitle / GrokModel. Opt-in; default false.
EnrichInfo bool
// LookupGrokInfo is optional. Production CLI may default to
// agent/grok/sessions.Info; tests inject a pure stub.
LookupGrokInfo func(home, sessionID string) (title, model string, err error)
}
Options configures ResolveFromPID. ListProcs and Lsof are injectable for tests; production may wire live process listing and lsof.
type Proc ¶
Proc is one process row in a snapshot.
func ListLiveProcs ¶
func ListLiveProcs() []Proc
ListLiveProcs returns a best-effort process snapshot via shared go-pkgs/proc. On failure (ps missing or error), returns nil/empty.
type ProcNode ¶
type ProcNode struct {
PID int
PPID int
Role string // input | agent-run | agent-run-serve | grok | codex | other
Cmd string
}
ProcNode is a classified process in the descendant tree of the input pid.
type Result ¶
type Result struct {
InputPID int
Kind string // grok | codex | none
SessionID string
Source string // open-files | open-files+tree
Confidence string // hard | "" when none
RunnerPID int
RunnerCmd string
Tree []ProcNode
Warnings []string
// GrokTitle / GrokModel are filled only when EnrichInfo is true and
// LookupGrokInfo succeeds for a grok hard hit.
GrokTitle string
GrokModel string
}
Result is the outcome of ResolveFromPID.
type TreeFormatOptions ¶
type TreeFormatOptions struct {
// ASCII, when true, uses +-- / `-- / | instead of box-drawing.
ASCII bool
}
TreeFormatOptions controls FormatTree connector style.