11import path from "node:path" ;
22import * as fsPromises from "node:fs/promises" ;
3- import { discoverPlans } from "@poe-code/agent-harness-tools" ;
3+ import {
4+ comparePlanReadiness ,
5+ discoverPlans ,
6+ formatPlanReadinessLabel
7+ } from "@poe-code/agent-harness-tools" ;
48import { UserError } from "@poe-code/user-error" ;
59import { parsePlan } from "./parser.js" ;
610import type { PipelineFileStat , PipelineFileSystem } from "../types.js" ;
@@ -92,7 +96,13 @@ async function listPlanCandidates(
9296 return countCompletedTasks ( plan . displayPath , content , plan . readiness === "ready" ) ;
9397 } )
9498 ) ;
95- candidates . sort ( ( left , right ) => Number ( right . ready ) - Number ( left . ready ) || left . path . localeCompare ( right . path ) ) ;
99+ candidates . sort (
100+ ( left , right ) =>
101+ comparePlanReadiness (
102+ { readiness : left . ready ? "ready" : "draft" } ,
103+ { readiness : right . ready ? "ready" : "draft" }
104+ ) || left . path . localeCompare ( right . path )
105+ ) ;
96106 return candidates ;
97107}
98108
@@ -209,7 +219,10 @@ export async function resolvePlanPaths(options: {
209219 return options . selectPlans ( {
210220 message : "Select pipeline plans to run" ,
211221 options : candidates . map ( ( candidate ) => ( {
212- label : `${ candidate . path } ${ candidate . ready ? " ✓" : "" } (${ candidate . done } /${ candidate . total } )` ,
222+ label : `${ formatPlanReadinessLabel (
223+ candidate . path ,
224+ candidate . ready ? "ready" : "draft"
225+ ) } (${ candidate . done } /${ candidate . total } )`,
213226 value : candidate . path
214227 } ) ) ,
215228 required : true
@@ -221,7 +234,10 @@ export async function resolvePlanPaths(options: {
221234 const selectedPlan = await options . selectPlan ( {
222235 message : "Select a pipeline plan to run" ,
223236 options : candidates . map ( ( candidate ) => ( {
224- label : `${ candidate . path } ${ candidate . ready ? " ✓" : "" } (${ candidate . done } /${ candidate . total } )` ,
237+ label : `${ formatPlanReadinessLabel (
238+ candidate . path ,
239+ candidate . ready ? "ready" : "draft"
240+ ) } (${ candidate . done } /${ candidate . total } )`,
225241 value : candidate . path
226242 } ) )
227243 } ) ;
0 commit comments