Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mcp/src/server/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ type Annotation = {
timestamp?: number;
nearbyText?: string;
reactComponents?: string;
sourceFile?: string;
status: string;
kind?: "feedback" | "placement" | "rearrange";
placement?: {
Expand Down Expand Up @@ -345,6 +346,7 @@ function mapAnnotationForMcp(a: Annotation) {
timestamp: a.timestamp,
nearbyText: a.nearbyText,
reactComponents: a.reactComponents,
...(a.sourceFile ? { sourceFile: a.sourceFile } : {}),
...(a.kind === "placement" && a.placement ? { placement: a.placement } : {}),
...(a.kind === "rearrange" && a.rearrange ? { rearrange: a.rearrange } : {}),
};
Expand Down
9 changes: 7 additions & 2 deletions mcp/src/server/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function initDatabase(db: Database.Database): void {
is_multi_select INTEGER DEFAULT 0,
is_fixed INTEGER DEFAULT 0,
react_components TEXT,
source_file TEXT,
url TEXT,
intent TEXT,
severity TEXT,
Expand Down Expand Up @@ -215,6 +216,7 @@ function rowToAnnotation(row: Record<string, unknown>): Annotation {
isMultiSelect: Boolean(row.is_multi_select),
isFixed: Boolean(row.is_fixed),
reactComponents: row.react_components as string | undefined,
sourceFile: row.source_file as string | undefined,
kind,
...(kind === "placement" && extra?.placement ? { placement: extra.placement } : {}),
...(kind === "rearrange" && extra?.rearrange ? { rearrange: extra.rearrange } : {}),
Expand Down Expand Up @@ -243,6 +245,7 @@ export function createSQLiteStore(dbPath?: string): AFSStore {
// Safe migrations for new columns (no-ops if already exist)
try { db.exec("ALTER TABLE annotations ADD COLUMN kind TEXT DEFAULT 'feedback'"); } catch {}
try { db.exec("ALTER TABLE annotations ADD COLUMN extra TEXT"); } catch {}
try { db.exec("ALTER TABLE annotations ADD COLUMN source_file TEXT"); } catch {}

// Restore event sequence from last event
const lastEvent = db.prepare("SELECT MAX(sequence) as seq FROM events").get() as { seq: number | null };
Expand All @@ -269,13 +272,13 @@ export function createSQLiteStore(dbPath?: string): AFSStore {
id, session_id, x, y, comment, element, element_path, timestamp,
selected_text, bounding_box, nearby_text, css_classes, nearby_elements,
computed_styles, full_path, accessibility, is_multi_select, is_fixed,
react_components, url, intent, severity, status, thread, created_at,
react_components, source_file, url, intent, severity, status, thread, created_at,
updated_at, resolved_at, resolved_by, author_id, kind, extra
) VALUES (
@id, @sessionId, @x, @y, @comment, @element, @elementPath, @timestamp,
@selectedText, @boundingBox, @nearbyText, @cssClasses, @nearbyElements,
@computedStyles, @fullPath, @accessibility, @isMultiSelect, @isFixed,
@reactComponents, @url, @intent, @severity, @status, @thread, @createdAt,
@reactComponents, @sourceFile, @url, @intent, @severity, @status, @thread, @createdAt,
@updatedAt, @resolvedAt, @resolvedBy, @authorId, @kind, @extra
)
`),
Expand Down Expand Up @@ -430,6 +433,7 @@ export function createSQLiteStore(dbPath?: string): AFSStore {
isMultiSelect: annotation.isMultiSelect ? 1 : 0,
isFixed: annotation.isFixed ? 1 : 0,
reactComponents: annotation.reactComponents ?? null,
sourceFile: annotation.sourceFile ?? null,
url: annotation.url ?? null,
intent: annotation.intent ?? null,
severity: annotation.severity ?? null,
Expand Down Expand Up @@ -612,6 +616,7 @@ export function createTenantStore(dbPath?: string): TenantStore {
// Safe migrations for new columns (no-ops if already exist)
try { db.exec("ALTER TABLE annotations ADD COLUMN kind TEXT DEFAULT 'feedback'"); } catch {}
try { db.exec("ALTER TABLE annotations ADD COLUMN extra TEXT"); } catch {}
try { db.exec("ALTER TABLE annotations ADD COLUMN source_file TEXT"); } catch {}

// Restore event sequence from last event
const lastEvent = db.prepare("SELECT MAX(sequence) as seq FROM events").get() as { seq: number | null };
Expand Down
1 change: 1 addition & 0 deletions mcp/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type Annotation = {
isMultiSelect?: boolean; // true if created via drag selection
isFixed?: boolean; // true if element has fixed/sticky positioning (marker stays fixed)
reactComponents?: string; // React component hierarchy (e.g. "<App> <Dashboard> <Button>")
sourceFile?: string; // Source file from React _debugSource (dev mode)

// Annotation kind (defaults to "feedback" when undefined — backward compat)
kind?: "feedback" | "placement" | "rearrange";
Expand Down
4 changes: 4 additions & 0 deletions package/example/public/schema/annotation.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
"type": "string",
"description": "React component tree (e.g. \"App > Dashboard > Button\")"
},
"sourceFile": {
"type": "string",
"description": "Source file path and line (e.g. \"src/Button.tsx:42\")"
},
"cssClasses": {
"type": "string",
"description": "Element class list"
Expand Down
1 change: 1 addition & 0 deletions package/example/src/app/api/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function App() {

// Context (varies by output format)
reactComponents?: string; // Component tree
sourceFile?: string; // Source file:line ("src/Button.tsx:42")
cssClasses?: string;
computedStyles?: string;
accessibility?: string;
Expand Down
1 change: 1 addition & 0 deletions package/example/src/app/mcp/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ npx agentation-mcp help # Show help`}
"comment": "Button is cut off on mobile",
"element": "button",
"elementPath": "body > main > .hero > button.cta",
"sourceFile": "src/components/CTAButton.tsx:42",
"kind": "feedback",
"intent": "fix",
"severity": "blocking"
Expand Down
4 changes: 4 additions & 0 deletions package/example/src/app/schema/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default function SchemaPage() {
code={`{
// React-specific (when available)
reactComponents: string; // Component tree ("App > Dashboard > Button")
sourceFile: string; // Source file:line ("src/Button.tsx:42")

// Element details
cssClasses: string; // Class list ("btn btn-primary disabled")
Expand Down Expand Up @@ -209,6 +210,7 @@ export default function SchemaPage() {

// Optional context
reactComponents?: string;
sourceFile?: string; // Source file:line (dev mode only)
cssClasses?: string;
computedStyles?: string;
accessibility?: string;
Expand Down Expand Up @@ -318,6 +320,7 @@ type ThreadMessage = {
"required": ["x", "y", "width", "height"]
},
"reactComponents": { "type": "string" },
"sourceFile": { "type": "string", "description": "Source file:line" },
"isFixed": { "type": "boolean" },
"isMultiSelect": { "type": "boolean" },
"fullPath": { "type": "string" },
Expand Down Expand Up @@ -368,6 +371,7 @@ type ThreadMessage = {
"url": "http://localhost:3000/landing",
"boundingBox": { "x": 120, "y": 480, "width": 200, "height": 48 },
"reactComponents": "App > LandingPage > HeroSection > CTAButton",
"sourceFile": "src/components/CTAButton.tsx:42",
"cssClasses": "cta btn-primary",
"nearbyText": "Get Started Free",
"intent": "fix",
Expand Down