Skip to content

CLI runtime environment port #556

Description

@flyingrobots

Migrated from a local Wesley Method backlog card after adopting METHOD v2.1.0 tracker doctrine.

  • Source path: docs/method/backlog/bad-code/RUNTIME_cli-runtime-environment-port.md
  • Original filesystem lane: bad-code
  • Canonical Method lane label: lane:bad-code
  • Legend: RUNTIME
  • Migration issue: Migrate Wesley Method backlog to GitHub Issues #548
  • Migrated on: 2026-06-04

Original Local Backlog Card

CLI runtime environment port

  • Lane: bad-code
  • Legend: RUNTIME

Why now

The CLI can inject cwd/env in important paths, but production entrypoints still
default directly to process.cwd() and process.env. WesleyCommand.execute
also mutates process.env.WESLEY_LOG_FORMAT for JSON mode, which is awkward for
in-process command tests and repeated program invocations.

Hill

CLI startup uses an explicit runtime environment object so tests and embedded
callers can run commands without leaking process state.

Done looks like

  • a RuntimeEnvironment or equivalent object carries cwd, env, streams, logger,
    fs, shell, importer, clock, and log-format settings
  • program(), module discovery, and WesleyCommand accept the runtime
    environment while preserving default host-binary behavior
  • JSON/log-format handling no longer mutates global process env
  • tests prove repeated in-process command invocations do not leak env state
  • module discovery still works through injected cwd/env/importer fixtures

Repo Evidence

  • packages/wesley-cli/src/program.mjs
  • packages/wesley-cli/src/framework/WesleyCommand.mjs
  • packages/wesley-cli/src/framework/module-loader.mjs
  • packages/wesley-runtime-node/src/ModuleEntryLoader.mjs
  • docs/audit/2026-05-05_code-quality.md

Activity

  1. added
    triage:bad-codeDebt intake that still needs scheduling, closure, or a repo move
    legend:RUNTIMERuntime/tooling/host/operator flow work
    on Jun 4, 2026
  2. coderabbitai commented on Jun 4, 2026

    @coderabbitai
    🔗 Related PRs

    #187 - fix(ci): repair holmes comment template indentation [merged]
    #270 - feat(host-browser): browser host + browser/deno/bun smokes [merged]
    #369 - fix(holmes): make CLI tests deterministic by disabling git activity [merged]
    #521 - Add Rust IR performance baseline [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    legend:RUNTIMERuntime/tooling/host/operator flow worktriage:bad-codeDebt intake that still needs scheduling, closure, or a repo move

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions