Skip to content

Commit ee0aac6

Browse files
cpcloudcursoragent
andcommitted
refactor(llm): use column constants in schema notes
Added missing column constants to data.models.go: - ColBudgetCents, ColTotalCents (money columns) - ColLastServicedAt (maintenance scheduling) - ColProjectTypeID (FK reference) Used these constants in LLM schema notes so column renames are caught at compile time. Left few-shot examples as raw strings since they're illustrative examples, not operational code. This follows the pattern established in b0f1942 where column constants centralize SQL column references. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 28b4150 commit ee0aac6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

internal/data/models.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,18 @@ const (
3838
ColDeletedAt = "deleted_at"
3939
ColStatus = "status"
4040
ColActualCents = "actual_cents"
41+
ColBudgetCents = "budget_cents"
4142
ColCostCents = "cost_cents"
43+
ColTotalCents = "total_cents"
4244
ColIntervalMonths = "interval_months"
45+
ColLastServicedAt = "last_serviced_at"
4346
ColWarrantyExpiry = "warranty_expiry"
4447
ColServicedAt = "serviced_at"
4548
ColReceivedDate = "received_date"
4649
ColRestoredAt = "restored_at"
4750
ColVendorID = "vendor_id"
4851
ColProjectID = "project_id"
52+
ColProjectTypeID = "project_type_id"
4953
ColApplianceID = "appliance_id"
5054
ColMaintenanceItemID = "maintenance_item_id"
5155
ColEntity = "entity"

internal/llm/prompt.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"fmt"
88
"strings"
99
"time"
10+
11+
"github.com/cpcloud/micasa/internal/data"
1012
)
1113

1214
// TableInfo describes a database table for context injection.
@@ -255,9 +257,9 @@ RULES:
255257

256258
const sqlSchemaNotes = `
257259
Notes:
258-
- Maintenance scheduling: next_due = date(last_serviced_at, '+' || interval_months || ' months')
260+
- Maintenance scheduling: next_due = date(` + data.ColLastServicedAt + `, '+' || ` + data.ColIntervalMonths + ` || ' months')
259261
- Project statuses: ideating, planned, quoted, underway, delayed, completed, abandoned
260-
- Warranty expiry is in the warranty_expiry column (date string)
262+
- Warranty expiry is in the ` + data.ColWarrantyExpiry + ` column (date string)
261263
- For case-insensitive text search, use UPPER() or LOWER() on both sides: WHERE LOWER(title) LIKE LOWER('%hvac%')`
262264

263265
const sqlFewShot = `## Examples

0 commit comments

Comments
 (0)