feat(agentic): apply default plan list limit
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
454f7a8e96
commit
800007907a
2 changed files with 27 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue