@agent-native/pinpoint 0.1.1 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/output/agent-context.ts"],"sourcesContent":["// @agent-native/pinpoint — Split output for sendToAgentChat()\n// MIT License\n//\n// Splits annotation output into { message, context } for the agent chat bridge.\n// The message is shown in chat UI. The context is hidden, appended for the agent.\n\nimport type { Pin, OutputFormat, QueuedAnnotation } from \"../types/index.js\";\nimport { formatPins } from \"./formatter.js\";\n\nexport interface AgentOutput {\n message: string;\n context: string;\n}\n\n/**\n * Format a single pin into rich context for the agent.\n *\n * ```\n * [Annotation on <button class=\"primary\"> in <Header> component]\n * Comment: \"This button should be blue instead of gray\"\n * Element: button.primary at (120, 45)\n * Source: src/components/Header.tsx:42\n * ```\n */\nexport function formatRichPinContext(pin: Pin): string {\n const lines: string[] = [];\n\n // Build element descriptor\n const tagName = pin.element.tagName.toLowerCase();\n const classes =\n pin.element.classNames.length > 0\n ? ` class=\"${pin.element.classNames.join(\" \")}\"`\n : \"\";\n const component = pin.framework?.componentPath\n ? ` in ${pin.framework.componentPath} component`\n : \"\";\n\n lines.push(`[Annotation on <${tagName}${classes}>${component}]`);\n lines.push(`Comment: \"${pin.comment}\"`);\n\n const rect = pin.element.boundingRect;\n const classStr =\n pin.element.classNames.length > 0\n ? `.${pin.element.classNames.join(\".\")}`\n : \"\";\n lines.push(\n `Element: ${tagName}${classStr} at (${Math.round(rect.x)}, ${Math.round(rect.y)})`,\n );\n\n if (pin.framework?.sourceFile) {\n lines.push(`Source: ${pin.framework.sourceFile}`);\n }\n\n if (pin.element.textContent) {\n const truncated = pin.element.textContent.slice(0, 80);\n lines.push(\n `Text: \"${truncated}${pin.element.textContent.length > 80 ? \"...\" : \"\"}\"`,\n );\n }\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Format pins for agent chat.\n * The full formatted output goes into message (visible in chat UI) so the user\n * can see exactly what context the agent is working with.\n */\nexport function formatPinsForAgent(\n pins: Pin[],\n format: OutputFormat = \"standard\",\n): AgentOutput {\n if (pins.length === 0) {\n return { message: \"No annotations to send.\", context: \"\" };\n }\n\n // Use rich context format for each pin\n const richAnnotations = pins\n .map((pin) => formatRichPinContext(pin))\n .join(\"\\n\\n\");\n\n const instruction = `The user has annotated ${pins.length} element${pins.length === 1 ? \"\" : \"s\"} on the page with visual feedback. Review each annotation and make the requested changes.\\n\\n`;\n\n // Also include the structured format as context for the agent\n const details = formatPins(pins, format);\n const message = instruction + richAnnotations;\n\n return { message, context: details };\n}\n\n/**\n * Format queued annotations for batch sending.\n */\nexport function formatQueueForAgent(\n queue: QueuedAnnotation[],\n format: OutputFormat = \"standard\",\n): AgentOutput {\n if (queue.length === 0) {\n return { message: \"No queued annotations to send.\", context: \"\" };\n }\n\n const parts: string[] = [];\n const pins: Pin[] = [];\n\n parts.push(\n `The user has queued ${queue.length} annotation${queue.length === 1 ? \"\" : \"s\"} for batch review. Process each one:\\n`,\n );\n\n for (let i = 0; i < queue.length; i++) {\n const item = queue[i];\n parts.push(`--- Item ${i + 1} ---`);\n\n if (item.pin) {\n parts.push(formatRichPinContext(item.pin));\n pins.push(item.pin);\n }\n\n if (item.drawings && item.drawings.length > 0) {\n parts.push(`[Drawing: ${item.drawings.length} stroke(s) on the page]`);\n for (const stroke of item.drawings) {\n const startPt = stroke.points[0];\n const endPt = stroke.points[stroke.points.length - 1];\n parts.push(\n ` ${stroke.type} from (${Math.round(startPt.x)}, ${Math.round(startPt.y)}) to (${Math.round(endPt.x)}, ${Math.round(endPt.y)}) [${stroke.color}]`,\n );\n }\n }\n\n if (item.textNotes && item.textNotes.length > 0) {\n for (const note of item.textNotes) {\n parts.push(\n `[Text note at (${Math.round(note.x)}, ${Math.round(note.y)}): \"${note.text}\"]`,\n );\n }\n }\n\n parts.push(\"\");\n }\n\n const message = parts.join(\"\\n\");\n const context = pins.length > 0 ? formatPins(pins, format) : \"\";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