Skip to content

fix(taskctl): ctx.session.directory undefined when taskctl start called from PM MCP bridge #336

@randomm

Description

@randomm

Bug

taskctl start fails when called from the PM MCP bridge (outside an active opencode session).

Root Cause

Two problems:

  1. ctx.session.directoryctx.session is not populated from the MCP bridge
  2. Instance.directory — uses AsyncLocalStorage, only accessible within Instance.provide() callback, also unavailable from the MCP bridge

Fix

The project directory must be sourced from somewhere that IS available in the MCP tool context. Options:

  1. Add a directory parameter to taskctl start (explicit, clean) — caller passes the project root
  2. Read it from Global.Path.data or config — derive from stored project metadata
  3. Use process.cwd() — simplest, works if the MCP server is launched from the project root

Option 3 (process.cwd()) is the pragmatic fix: the opencode MCP server is always launched from the project directory, so process.cwd() returns the correct path.

Acceptance Criteria

  • taskctl start <issueNumber> works when called from PM MCP bridge
  • Feature branch is created and pushed successfully
  • Existing tests pass
  • Adversarial: APPROVED

Quality Gates

  • bun run typecheck — 0 errors
  • bun test — 0 failures

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions