Skip to content

feat(cli): interactive shell UX improvements#1159

Merged
davincios merged 4 commits intomainfrom
interactive-shell-prompting
Apr 30, 2026
Merged

feat(cli): interactive shell UX improvements#1159
davincios merged 4 commits intomainfrom
interactive-shell-prompting

Conversation

@davincios
Copy link
Copy Markdown
Contributor

Summary

Reorganizes flat modules in app/cli/ and app/deployment/ into focused subpackages so each area has one clear purpose, and renames the terminal loop from REPL to interactive_shell.

  • app/cli/interactive_shell/ (renamed from app/cli/repl/) now hosts the interactive terminal loop, plus new cli_agent.py, cli_help.py, and router.py.
  • app/cli/support/ centralizes CLI infrastructure (args, constants, context, errors, exit_codes, health_view, layout, prompt_support, update).
  • app/cli/investigation/ groups alert/investigation entrypoints (alert_templates, investigate, investigate_input, payload).
  • app/deployment/methods/ holds how we ship (railway, langsmith); app/deployment/operations/ holds runtime/infra around a deployment (ec2_config, health, provider_config).
  • All imports and tests (including e2e/deploy paths and tests/cli/interactive_shell/) updated to the new locations.

Test plan

  • make lint
  • make format-check
  • make typecheck
  • make test-cov
  • Smoke opensre interactive shell locally

Made with Cursor

…ployment modules

Reorganize flat `app/cli/` helpers into focused subpackages:

- `app/cli/interactive_shell/` (renamed from `app/cli/repl/`) with new
  `cli_agent.py`, `cli_help.py`, and `router.py` for the interactive terminal loop
- `app/cli/support/` for CLI infrastructure (args, constants, context, errors,
  exit_codes, health_view, layout, prompt_support, update)
- `app/cli/investigation/` for alert/investigation entrypoints
  (alert_templates, investigate, investigate_input, payload)

Reorganize `app/deployment/` by concern:

- `app/deployment/methods/` for how we ship (railway, langsmith)
- `app/deployment/operations/` for runtime/infra around a deployment
  (ec2_config, health, provider_config)

Update all imports and tests (including e2e/deploy paths) to the new module
locations.

Made-with: Cursor
@mintlify
Copy link
Copy Markdown

mintlify Bot commented Apr 30, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
tracer 🟢 Ready View Preview Apr 30, 2026, 10:02 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

Comment thread app/cli/interactive_shell/cli_help.py Fixed
Comment thread app/cli/interactive_shell/cli_agent.py Fixed
Comment thread app/cli/interactive_shell/cli_help.py Fixed
Comment thread app/cli/interactive_shell/cli_help.py Fixed
@davincios davincios changed the title refactor(cli): rename REPL to interactive_shell and reorganize CLI/deployment modules feat(cli): interactive shell UX improvements Apr 30, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Greptile Summary

This PR reorganizes flat app/cli/ and app/deployment/ modules into focused subpackages (interactive_shell/, support/, investigation/, methods/, operations/) and renames the REPL to interactive_shell. It also introduces two new modules — cli_agent.py (a LangGraph-free terminal assistant) and cli_help.py (reference-grounded CLI Q&A) — along with a richer input classifier in router.py. All 97 files have been updated with no stale app.cli.repl imports remaining in the codebase. The migration is clean and backward-compatible through the re-exporting __init__.py files.

Confidence Score: 5/5

Safe to merge — refactoring is complete and all import paths are correctly updated with no broken references remaining.

All 97 files are updated consistently; no stale app.cli.repl imports remain anywhere in the codebase; backward-compatible re-exporting init.py files ensure downstream callers are unaffected. The three remaining findings are all P2 style/naming suggestions that do not affect runtime behavior.

No files require special attention. Minor terminology cleanup in router.py docstring and loop.py public symbol name would be nice-to-have follow-ups.

Important Files Changed

Filename Overview
app/cli/interactive_shell/router.py New input classifier with richer routing (cli_help, cli_agent, new_alert, follow_up, slash); module docstring still uses old "REPL" terminology.
app/cli/interactive_shell/cli_agent.py New LangGraph-free terminal assistant; _GroundingMode should be declared as a proper TypeAlias.
app/cli/interactive_shell/loop.py Async REPL loop extended to dispatch new cli_help and cli_agent kinds; exported symbol run_repl still uses old REPL naming.
app/cli/interactive_shell/cli_help.py New module that assembles CLI --help reference text and delegates to cli_agent with reference_only grounding; clean implementation.
app/deployment/init.py Top-level re-export shim for both methods and operations subpackages; all symbols correctly re-exported for backward compatibility.
app/deployment/methods/init.py Clean aggregation of railway and langsmith deploy exports into the methods subpackage.
app/deployment/operations/init.py Clean aggregation of ec2_config, health, and provider_config into the operations subpackage.
app/cli/investigation/init.py New subpackage re-exporting all investigation entrypoints; cleanly replaces the old flat cli.investigate imports.
app/cli/commands/general.py All imports updated to new subpackage paths; write_json imported from both app.cli and app.cli.support.args in different functions (both resolve to the same object via re-export).
app/cli/commands/deploy.py Import paths updated from flat cli modules to deployment.methods and deployment.operations subpackages; no logic changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Input["User input (text)"] --> R{router.classify_input}

    R -->|starts with /| Slash["dispatch_slash()\napp/cli/interactive_shell/commands.py"]
    R -->|bare alias e.g. help/exit| Slash
    R -->|CLI how-to pattern| CLIHelp["answer_cli_help()\napp/cli/interactive_shell/cli_help.py"]
    R -->|no prior state + incident vocab| NewAlert["_run_new_alert()\nLangGraph investigation pipeline"]
    R -->|short question + prior state| FollowUp["answer_follow_up()\napp/cli/interactive_shell/follow_up.py"]
    R -->|long/alert text + prior state| NewAlert
    R -->|chat / general| CLIAgent["answer_cli_agent()\napp/cli/interactive_shell/cli_agent.py"]

    CLIHelp -->|grounding=reference_only| CLIAgent
    CLIAgent --> LLM["get_llm_for_reasoning()\napp/services/llm_client.py"]
    NewAlert --> LangGraph["LangGraph pipeline\napp/cli/investigation/"]

    subgraph new_subpackages ["New subpackages (this PR)"]
        direction LR
        IS["app/cli/interactive_shell/\nloop · router · cli_agent\ncli_help · commands · session"]
        INV["app/cli/investigation/\ninvestigate · payload\nalert_templates"]
        SUP["app/cli/support/\nargs · context · errors\nexit_codes · health_view · update"]
        DM["app/deployment/methods/\nrailway · langsmith"]
        DO["app/deployment/operations/\nec2_config · health · provider_config"]
    end
Loading

Comments Outside Diff (1)

  1. app/cli/interactive_shell/loop.py, line 131-132 (link)

    P2 Public symbol still uses old run_repl name

    run_repl is the public export (__all__) and is called from app/cli/__main__.py and app/cli/commands/agent.py. The rename goal of the PR is only half-realized here — ReplSession, _repl_main, and run_repl all carry the old REPL prefix. Callers outside this module would need to be updated too if the symbol is eventually renamed, so noting this as a follow-up item.

Reviews (1): Last reviewed commit: "refactor(cli): rename REPL to interactiv..." | Re-trigger Greptile

Comment thread app/cli/interactive_shell/router.py Outdated
@@ -0,0 +1,218 @@
"""Classify REPL input: slash, CLI help, LangGraph-free agent, investigation, or follow-up."""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Stale REPL terminology in module docstring

The module docstring and several internal docstrings still reference "REPL" (lines 1, 179, 184) despite the explicit goal of this PR to replace that term with "interactive shell." The system-prompt in cli_agent.py even instructs the LLM to never say "REPL" to users (issue #604), so the mismatch with the source code docstrings is worth cleaning up.

Suggested change
"""Classify REPL input: slash, CLI help, LangGraph-free agent, investigation, or follow-up."""
"""Classify interactive-shell input: slash, CLI help, LangGraph-free agent, investigation, or follow-up."""

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment thread app/cli/interactive_shell/cli_agent.py Outdated

# Cap stored (user, assistant) pairs; list holds 2 entries per turn.
_MAX_CLI_AGENT_TURNS = 12
_GroundingMode = Literal["reference_only", "conversational"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 _GroundingMode should be declared as a TypeAlias

Assigning a Literal to a plain variable makes mypy and pyright treat it as a type[Literal[...]] value, not a type alias. This can cause unexpected type-narrowing issues when the variable is used in annotation positions.

Suggested change
_GroundingMode = Literal["reference_only", "conversational"]
_GroundingMode: TypeAlias = Literal["reference_only", "conversational"]

@Ghraven
Copy link
Copy Markdown

Ghraven commented Apr 30, 2026

Hey @davincios, really impressive refactor — the separation into app/cli/interactive_shell/, app/cli/investigation/, and app/cli/support/ is a big readability win. The old flat layout made it hard to tell which module owned what, so grouping by concern (shell loop, investigation pipeline, shared support) makes the structure self-documenting.

A couple of small observations while reading through:

  1. router.py in interactive_shell gained two new input kinds: cli_help and cli_agent on top of the original slash / new_alert / follow_up. The old app/cli/repl/router.py has been deleted. Just worth confirming that any external code that imported from app.cli.repl.router import InputKind or classify_input has been updated — the app/cli/repl/__init__.py compat shim might need a note or a deprecation warning for anyone importing directly from the old path.

  2. In cli_agent.py the _MAX_CLI_AGENT_TURNS = 12 cap stores 2 entries per turn (user + assistant), so the actual history is 6 turns of back-and-forth. The comment already says this — just wondering if a docstring clarification like "stores up to 12 messages (6 user/assistant pairs)" would help future readers.

  3. The _TERMINOLOGY_RULE and _MARKDOWN_RULE constants in cli_agent.py are strings that get appended to every system prompt — nice approach for enforcing consistency. Are these also applied in answer_cli_help, or only in answer_cli_agent? If they differ, it might be worth noting why.

Really clean work — the direction is clearly right. 🙏

@davincios
Copy link
Copy Markdown
Contributor Author

really impressive refactor — the separation into app/cli/interactive_shell/, app/cli/investigation/, and app/cli/support/ is a big readability win. The old flat layout made it hard to tell which module owned what, so grouping by con

Thanks @Ghraven that is very kind of you :)

Comment thread app/cli/interactive_shell/cli_agent.py Fixed
Comment thread tests/cli/interactive_shell/test_cli_agent.py Fixed
Comment thread tests/cli/interactive_shell/test_cli_agent.py Fixed
@davincios davincios merged commit 24205ea into main Apr 30, 2026
14 of 15 checks passed
@davincios davincios deleted the interactive-shell-prompting branch April 30, 2026 23:47
@github-actions
Copy link
Copy Markdown
Contributor

😤 @davincios said "I will fix this" and then actually fixed it. Legendary behavior.


👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome.

Sarah-Salah added a commit to Sarah-Salah/opensre that referenced this pull request May 5, 2026
Resolves conflicts in auto-generated bot files: docs/daily-updates/overview.mdx, docs/daily-updates/2026-04-30.mdx, docs/daily-updates/2026-05-01.mdx, and README.md (contributors section). All four are produced by scheduled bot workflows in main and have no relationship to this PR; resolved by accepting the upstream main version verbatim.

Pulls in 35+ commits from main since this PR was opened, including: refactor of integrations module (Tracer-Cloud#1165), Splunk integration (Tracer-Cloud#791), interactive shell improvements (Tracer-Cloud#1159, Tracer-Cloud#1167), Claude Code CLI provider (Tracer-Cloud#1168), and CI quality gate restoration. None of these touch the OpenSearch wizard, detect_sources, or the validation modules this PR modifies.

Refs: Tracer-Cloud#1143
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants