← Back to Pull requests

feat: shell discovery, session metadata and full command help (1/5) #338

Closed
unknown closed this pull request without merging on Nov 06, 2026 01:49 UTC
View on GitHub
unknown unknown commented on Nov 05, 2026 18:03 UTC
Author

Summary

First implementation PR of OpenSpec change add-agent-shell-control (spec: #337, stacked on it). Scope: tasks.md §1, §2B and §7.1–7.2.

Discovery (US-S01)


  • Every session process — PTY and ACP sidecars alike — gets WEBMUX_SOCKET (local API socket) and WEBMUX_BIN (the running server's os.Executable()), reserved like WEBMUX_SESSION_ID: rejected in create requests and launch configs, skipped when run forwards the caller's environment. PATH is untouched.

  • CLI locates the server by --socket, --config, WEBMUX_SOCKET, then the default config. A named socket that does not answer is "not running" (exit 3), never a fallback to another instance.

  • self resolves to $WEBMUX_SESSION_ID; contract.ExitTimeout = 124; local status gains bin.

  • An old CLI hitting an endpoint the server lacks reports both versions and points to $WEBMUX_BIN.
  • Session metadata (US-S02, US-S03)


  • GET /api/sessions/{id}/details → SessionDetails (repository, worktree, launch config, hybrid record, existing artifacts dir, forwards, parent, children, labels, link). No token or env values; it never creates the artifacts folder.

  • parentId is recorded from the local socket's peer process (Manager.ProcessSession); the request body cannot set it and TCP creates have none.

  • Labels: create-request labels (validated before anything starts) and PATCH /api/sessions/{id}/labels ({set, remove}, atomic). In memory only; the Web UI does not show them yet.

  • CLI: webmux get [SESSION] [--json|--field PATH], webmux label, ls --label/--parent/--status.
  • Help framework (US-S04)


  • One command table (internal/sessioncmd/command.go) drives parsing, --help (English, 80 columns, usage/args/options/env/output/exit/examples/see also) and help --json.

  • --help/-h/help CMD go to stdout with exit 0 without connecting; usage errors exit 2 and point to --help; a bare group (webmux config) lists its subcommands on stderr with exit 2. This fixes run/attach/ls/open --help returning 2.

  • Flags may follow positional arguments (webmux get self --json); run stays strict and keeps everything after --.

  • Operations commands keep their parsers; their help comes from cmd/webmux/commands.go, and TestOpsCommandFlagsMatchTable compares each implementation's flags with the table. The top-level help keeps the -log-file line the Windows client probes.

  • The Windows console client dispatches through the same registry.
  • Contract / UI


  • SessionInfo.parentId, SessionInfo.labels, CreateSessionRequest.labels, LabelsUpdate, SessionDetails; web/src/schemas.ts updated (optional fields only, no visible UI change); wire snapshots re-recorded.
  • Verification


  • make check passes locally (frontend build, format, docs/persistence guards, Oxlint, arch guard, go vet, golangci-lint v2.15.0).

  • go test -race for internal/session, internal/api, internal/sessioncmd, cmd/..., internal/archtest, internal/contract, internal/wire, internal/launch, internal/docguard. Locally TestWireSnapshots differs only in repository-commits.json because git 2.43 prints +00:00; this also fails on a clean main here, so the snapshot is left as is and CI decides.
  • User stories


    New group S: US-S01–US-S04 (docs/user-stories/shell-control.md); US-M05 updated; coverage index and a new verification log added. New usage page docs/usage/shell-control.md.

    ---
    _Generated by Claude Code_

    Diff: 441 lines (+330 / -111) across 5 files Reviewer: mzdluo123 Review duration: 466m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 441 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.364
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #338"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.3% (MEDIUM) · Higher = larger blast radius
    45.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.9% · Safe to merge
    17.9%