Skip to content

feat: make default workflow domain configurable at runtime#281

Open
mrsimpson wants to merge 3 commits into
mainfrom
refactor/configurable-default-domain
Open

feat: make default workflow domain configurable at runtime#281
mrsimpson wants to merge 3 commits into
mainfrom
refactor/configurable-default-domain

Conversation

@mrsimpson
Copy link
Copy Markdown
Collaborator

@mrsimpson mrsimpson commented May 23, 2026

Summary

Eliminate hardcoded 'code' default domain in WorkflowManager and provide runtime domain switching for long-lived processes (MCP server, OpenCode plugin).

Changes

  • Four-level env var chain: constructor param > WORKFLOW_DOMAINS > DEFAULT_DOMAINS > VIBE_WORKFLOW_DOMAINS > empty Set (all workflows)
  • defaultDomains constructor parameter for programmatic override (library consumers, testing)
  • DEFAULT_ALL_DOMAINS env var for getAllAvailableWorkflows() — replaces incomplete hardcoded list
  • setDomains() method for runtime domain switching with validation against known domains
  • DOMAIN_DESCRIPTIONS constant with meaningful summaries of what each domain is suitable for
  • load_workflows tool — simple enum parameter, domain descriptions exposed via domain:// resource
  • domain:// resource — exposes all available domains with descriptions for LLM discovery
  • Bug fix: loadPredefinedWorkflows() now clears maps before reloading (prevents workflow accumulation)

Tests

  • 18 new tests: 9 for env var precedence chain, 9 for setDomains()
  • All existing tests pass (except 1 pre-existing unrelated failure in game-beginner.yaml)

Architecture Decision

Domain descriptions are exposed as a resource (domain://) rather than embedded in the tool parameter. This keeps the tool schema lean and reduces LLM context usage. The LLM can query the resource to discover domains before calling load_workflows.

Affected Files

  • packages/core/src/workflow-manager.ts — core changes
  • packages/core/test/unit/workflow-domains-precedence.test.ts — 9 new tests
  • packages/core/test/unit/workflow-domain-switching.test.ts — 9 new tests (new file)
  • packages/core/test/unit/workflow-domain-filtering.test.ts — updated for empty Set default
  • packages/mcp-server/src/server-config.ts — register load_workflows tool + domain:// resource
  • packages/mcp-server/src/tool-handlers/load-workflows.ts — simplified handler (new file)
  • packages/mcp-server/src/tool-handlers/index.ts — register handler
  • packages/opencode-plugin/src/plugin.ts — register load_workflows tool
  • packages/opencode-plugin/src/tool-handlers/load-workflows.ts — simplified handler (new file)

Backward Compatibility

  • VIBE_WORKFLOW_DOMAINS still works as lowest-priority env var
  • Adding options?: WorkflowManagerOptions to constructor is backward compatible
  • Empty Set fallback loads ALL workflows (superset of old code default)

UX: No Active Workflow Prompt

When no workflow is active, the plugin injects this message (unchanged):

No Active Workflow Detected. You MUST initiate a new development workflow before proceeding. First, create a new branch with a meaningful name using a conventional commit prefix (e.g., feat/add-new-feature, fix/bug-description, refactor/improve-logic). Then call the start_development tool to begin. Do NOT attempt any file edits or tool executions until a workflow is active.

mrsimpson added 3 commits May 23, 2026 20:31
Eliminate hardcoded 'code' defaults in WorkflowManager through:

- Four-level env var chain: constructor param > WORKFLOW_DOMAINS >
  DEFAULT_DOMAINS > VIBE_WORKFLOW_DOMAINS > empty Set (all workflows)
- defaultDomains constructor parameter for programmatic override
- DEFAULT_ALL_DOMAINS env var for getAllAvailableWorkflows()
- setDomains() method for runtime domain switching with validation
- DOMAIN_DESCRIPTIONS constant with meaningful domain summaries
- load_workflows tool in MCP server and OpenCode plugin for LLM
  to dynamically load domains without restarting the process

Fix pre-existing bug: loadPredefinedWorkflows() now clears maps
before reloading, preventing workflow accumulation across domain
switches.

Add 18 new tests: 9 for env var precedence chain, 9 for setDomains().
Update existing domain filtering test for new empty Set default.
Simplify load_workflows tool parameter to use domain name enums
instead of embedding full descriptions. This keeps the tool schema
lean and reduces LLM context usage.

- load_workflows(domains: string[]) now uses a simple enum
- New domain-info:// resource exposes full domain descriptions
- OpenCode plugin uses enum with inline domain list in description
- Domain descriptions kept in DOMAIN_DESCRIPTIONS constant (core)
@mrsimpson
Copy link
Copy Markdown
Collaborator Author

@claude Review once

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.

1 participant