describe_garden: list each plop's position, so a move can keep the layout #128

Merged
steve merged 2 commits from fix/describe-plop-coordinates into main 2026-08-23 04:43:48 +00:00
3 changed files with 21 additions and 9 deletions
Showing only changes of commit 8b161c5f6d - Show all commits
+7 -5
View File
@@ -33,13 +33,15 @@ func NewToolbox(svc *service.Service, actorID int64, today string) *llm.Toolbox
"Summarize a garden: its dimensions, objects (with sizes/positions/version), and each "+
"object's active plantings grouped by plant — how many, roughly where, when they went in, "+
"and days to maturity when known. A small group lists its plops individually (id + "+
"version, for move_planting/remove_planting); a large one (a grid-filled bed) does not — "+
"use list_plantings for those ids, or act on the whole group with remove_plantings.",
"version for move_planting/remove_planting, and xCm/yCm in the object's local frame so a "+
"move can keep their layout); a large one (a grid-filled bed) does not — use "+
"list_plantings for those, or act on the whole group with remove_plantings.",
a.describeGarden),
llm.DefineTool("list_plantings",
"List one object's active plops one by one, each with its id, version, location, count and "+
"planting date — the detail describe_garden leaves out for a large group. Narrow to one "+
"plant with plantId. Use it only when you need to address individual plops.",
"List one object's active plops one by one, each with its id, version, position (xCm/yCm "+
"in the object's local frame), location, count and planting date — the detail "+
"describe_garden leaves out for a large group. Narrow to one plant with plantId. Use it "+
"only when you need to address individual plops.",
a.listPlantings),
llm.DefineTool("create_object",
"Add an object (bed, grow_bag, container, in_ground, tree, path, structure) to a garden, positioned by its center in garden cm.",
+10 -4
View File
@@ -610,15 +610,20 @@ type DescribeGroup struct {
Each []DescribePlanting `json:"each,omitempty"`
}
// DescribePlanting is one plop with a rough compass location. ID + Version let
// an agent address a single plop — remove it or move it — the same way
// DescribeObject.Version lets it edit an object.
// DescribePlanting is one plop with its position and a rough compass location.
// ID + Version let an agent address a single plop — remove it or move it — the
// same way DescribeObject.Version lets it edit an object; XCM/YCM (the object's
// local frame) let a move keep the layout the plops had, which "north, south"
// alone cannot: asked to move four tomatoes in a column "keeping the same
// spacing", the live assistant re-laid them as two pairs for want of these.
type DescribePlanting struct {
ID int64 `json:"id"`
Version int64 `json:"version"`
PlantID int64 `json:"plantId"`
Plant string `json:"plant"`
Count int `json:"count"`
XCM float64 `json:"xCm"`
YCM float64 `json:"yCm"`
Location string `json:"location"`
RadiusCM float64 `json:"radiusCm"`
PlantedAt string `json:"plantedAt,omitempty"`
@@ -736,7 +741,8 @@ func describeGroups(o *domain.GardenObject, plops []domain.Planting, plantByID m
func describePlanting(pl domain.Planting, plantName string) DescribePlanting {
d := DescribePlanting{
ID: pl.ID, Version: pl.Version, PlantID: pl.PlantID, Plant: plantName,
Count: effectiveCount(pl), Location: describeLocation(pl.XCM, pl.YCM), RadiusCM: pl.RadiusCM,
Count: effectiveCount(pl), XCM: pl.XCM, YCM: pl.YCM,
Location: describeLocation(pl.XCM, pl.YCM), RadiusCM: pl.RadiusCM,
}
if pl.PlantedAt != nil {
d.PlantedAt = *pl.PlantedAt
+4
View File
@@ -632,6 +632,10 @@ func TestDescribeGardenGroupsByPlant(t *testing.T) {
if e.PlantedAt == "" || e.Version == 0 || e.ID == 0 {
t.Errorf("listed plop %+v is missing id, version or date", e)
}
// The position is what lets a move keep the layout; "south" alone can't.
if e.YCM < 100 || (e.XCM != -100 && e.XCM != 0 && e.XCM != 100) {
t.Errorf("listed plop %+v doesn't carry the position it was placed at", e)
}
}
// The big group's ids are a call away, narrowed to one plant.