From 800007907ab4efcda0eca35e7826e8be46cd88a5 Mon Sep 17 00:00:00 2001 From: Virgil Date: Tue, 31 Mar 2026 18:58:40 +0000 Subject: [PATCH] feat(agentic): apply default plan list limit Co-Authored-By: Virgil --- pkg/agentic/plan.go | 9 ++++++++- pkg/agentic/plan_crud_test.go | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/pkg/agentic/plan.go b/pkg/agentic/plan.go index c140cab..a221ce8 100644 --- a/pkg/agentic/plan.go +++ b/pkg/agentic/plan.go @@ -127,6 +127,8 @@ type PlanListOutput struct { Plans []Plan `json:"plans"` } +const planListDefaultLimit = 20 + // result := c.Action("plan.create").Run(ctx, core.NewOptions( // // core.Option{Key: "title", Value: "AX RFC follow-up"}, @@ -468,6 +470,11 @@ func (s *PrepSubsystem) planList(_ context.Context, _ *mcp.CallToolRequest, inpu return nil, PlanListOutput{}, core.E("planList", "failed to access plans directory", err) } + limit := input.Limit + if limit <= 0 { + limit = planListDefaultLimit + } + jsonFiles := core.PathGlob(core.JoinPath(dir, "*.json")) var plans []Plan @@ -490,7 +497,7 @@ func (s *PrepSubsystem) planList(_ context.Context, _ *mcp.CallToolRequest, inpu } plans = append(plans, *plan) - if input.Limit > 0 && len(plans) >= input.Limit { + if len(plans) >= limit { break } } diff --git a/pkg/agentic/plan_crud_test.go b/pkg/agentic/plan_crud_test.go index a5eabda..ce02a61 100644 --- a/pkg/agentic/plan_crud_test.go +++ b/pkg/agentic/plan_crud_test.go @@ -421,6 +421,25 @@ func TestPlan_PlanList_Good_IgnoresNonJSON(t *testing.T) { assert.Equal(t, 1, out.Count, "should skip non-JSON files") } +func TestPlan_PlanList_Good_DefaultLimit(t *testing.T) { + dir := t.TempDir() + t.Setenv("CORE_WORKSPACE", dir) + + s := newTestPrep(t) + for i := 0; i < 21; i++ { + _, _, err := s.planCreate(context.Background(), nil, PlanCreateInput{ + Title: core.Sprintf("Plan %d", i+1), + Objective: "Test default list limit", + }) + require.NoError(t, err) + } + + _, out, err := s.planList(context.Background(), nil, PlanListInput{}) + require.NoError(t, err) + assert.Equal(t, 20, out.Count) + assert.Len(t, out.Plans, 20) +} + // --- planPath edge cases --- func TestPlan_PlanPath_Bad_PathTraversal(t *testing.T) {