Skip to content

Add sm tinker REPL (interactive C# shell with app DI loaded) #172

@antosubash

Description

@antosubash

Background

There is no interactive REPL with the app's DI container, EF context, services, and modules already wired up. Today, ad-hoc inspection means writing a throwaway endpoint or a one-off console project. Laravel Tinker drops you straight into a fully-bootstrapped session.

Motivation

  • Quick one-off queries: db.Users.Count(), notifier.SendAsync(...), cache.SetAsync(...)
  • Reproduce bug states fast
  • Onboarding tool — devs poke at the framework live

Design sketch

New CLI command sm tinker:

  • Uses dotnet-script (or Microsoft.CodeAnalysis.CSharp.Scripting directly)
  • Boots the host (Host.CreateApplicationBuilder().Build()) so DI is identical to runtime
  • Pre-imports common namespaces (SimpleModule.Core, all module Contracts, System.Linq)
  • Pre-binds well-known services to globals: db, notifier, cache, events, currentUser (impersonate via flag)
  • Multiline editor with history (Ctrl+R), tab-completion, color output
  • --exec "<expr>" for non-interactive single-shot execution
  • --user <id> to impersonate a user / tenant

Safety:

  • Refuses to run against production unless --allow-prod and env var SM_TINKER_ALLOW_PROD=1

Acceptance criteria

  • sm tinker command in cli/SimpleModule.Cli
  • DI fully booted; common globals available
  • History across sessions stored in ~/.simplemodule/tinker_history
  • Tab-completion for type names + members
  • --exec non-interactive mode
  • Production guard
  • Docs page with examples

References

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions