Skip to content

Migrate route selection and state reading to gsd-adapter.cjs #139

@snipcodeit

Description

@snipcodeit

Context

Phase 34 — GSD Adapter, completion. After #138 creates the adapter with utility functions, this issue adds the most valuable new function: selectGsdRoute(issue, projectState) — the routing decision that currently lives implicitly in LLM prompts scattered across run.md (1282 lines). Centralizing it makes the routing logic auditable, testable (Phase 32 test suite can cover it), and consistent across pipeline commands.

What Already Exists

  • lib/gsd-adapter.cjs — created by Create lib/gsd-adapter.cjs with path resolution and tool invocation #138; has getGsdToolsPath, invokeGsdTool, getTimestamp, generateSlug, resolveModel, historyDigest, roadmapAnalyze
  • commands/run.md (1282 lines) — routing decision logic is prose in the LLM context: "if quick → quick path, if plan-phase needed → standard path, if diagnose needed → diagnose path"; not a structured function
  • commands/milestone.md (952 lines) — milestone execution loop; references pipeline_stage values but has no adapter calls
  • .mgw/active/*.json — issue state files with pipeline_stage, labels, assignees fields used for routing
  • Pipeline stages: new → triaged → planning → executing → verifying → pr-created → done (plus blocked, failed, diagnosing)

Description

Complete lib/gsd-adapter.cjs by adding selectGsdRoute() and getGsdState(), then update command files to use them.

Technical Approach

  • selectGsdRoute(issue, projectState): decision priority: 1. Explicit label (quick, needs-diagnosis), 2. Pipeline stage continuation, 3. Milestone position (first vs subsequent), 4. Default (plan-phase)
  • Returns one of: 'quick', 'plan-phase', 'diagnose', 'execute-only', 'verify-only'
  • getGsdState(): reads .planning/STATE.md + ROADMAP.md via gsd-tools roadmap analyze; returns { activeMilestone, currentPhase, planCount }
  • Update run.md to call selectGsdRoute() in validate_and_load step
  • Update milestone.md to call getGsdState() for GSD linkage check

Done When

  • lib/gsd-adapter.cjs exports selectGsdRoute(issue, projectState) returning one of the 5 route strings
  • selectGsdRoute() decision priority order is documented with inline comments: labels → stage → milestone position → default
  • lib/gsd-adapter.cjs exports getGsdState() returning { activeMilestone, currentPhase, planCount } or null
  • commands/run.md validate_and_load step uses selectGsdRoute() to determine execution path
  • commands/milestone.md GSD linkage check uses getGsdState() from adapter

GSD Route

Quick task or GSD Phase 34 plan.

Phase Context

Phase 34 of 36 — GSD Adapter. Issues: #138 (blocks this), #139 (this).

Depends on

#138 — gsd-adapter.cjs must exist with base functions before route selection is added.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions