picocode-core 0.9.164 → 0.9.165

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "picocode-core",
3
- "version": "0.9.164",
3
+ "version": "0.9.165",
4
4
  "description": "The agent runtime behind pico: sessions, tools, subagents, MCP, memory, and model access",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -75,7 +75,11 @@ export const selectionLabel = (part) => `[selection: ${part.path}:${part.fromLin
75
75
  export const commitLabel = (part) => `[commit: ${part.hash.slice(0, 7)} ${JSON.stringify(part.subject ?? '')}]`
76
76
  // a page element the user picked in a browser: where it is, what it is,
77
77
  // and its markup, so the model can find it in the source
78
- export const elementLabel = (part) => `[element: <${part.tag}> ${part.selector} on ${part.url}${part.component ? ` in component ${part.component}` : ''}]\n${part.html}\n[/element]`
78
+ export function elementLabel(part) {
79
+ const styles = part.styles && Object.keys(part.styles).length ? `\ncomputed style: ${Object.entries(part.styles).map(([k, v]) => `${k}: ${v}`).join('; ')}` : ''
80
+ const rules = part.rules?.length ? `\nmatched css rules:\n${part.rules.join('\n')}` : ''
81
+ return `[element: <${part.tag}> ${part.selector} on ${part.url}${part.component ? ` in component ${part.component}` : ''}]\n${part.html}${styles}${rules}\n[/element]`
82
+ }
79
83
 
80
84
  // [Image #n] and [File #n] placeholders in the composed text stand for
81
85
  // attachments; they become image, file, or selection parts of the user message
@@ -93,7 +97,7 @@ export function buildUserContent(text, attachments) {
93
97
  : attachment.kind === 'commit'
94
98
  ? { type: 'commit', hash: attachment.hash, subject: attachment.subject, root: attachment.root }
95
99
  : attachment.kind === 'element'
96
- ? { type: 'element', url: attachment.url, selector: attachment.selector, tag: attachment.tag, text: attachment.text, html: attachment.html, rect: attachment.rect, component: attachment.component ?? null }
100
+ ? { type: 'element', url: attachment.url, selector: attachment.selector, tag: attachment.tag, text: attachment.text, html: attachment.html, rect: attachment.rect, component: attachment.component ?? null, styles: attachment.styles ?? null, rules: attachment.rules ?? [] }
97
101
  : attachment.kind === 'file'
98
102
  ? { type: 'file', path: attachment.path }
99
103
  : { type: 'image', source: { kind: 'path', path: attachment.path, mediaType: attachment.mediaType } })
@@ -138,7 +142,7 @@ export function inputTextFromContent(content, { attachments, nextId }) {
138
142
  out += placeholder
139
143
  } else if (part.type === 'element' && part.selector) {
140
144
  const placeholder = `[File #${nextId()}]`
141
- attachments.set(placeholder, { url: part.url, selector: part.selector, tag: part.tag, text: part.text, html: part.html, rect: part.rect, component: part.component ?? null, kind: 'element' })
145
+ attachments.set(placeholder, { url: part.url, selector: part.selector, tag: part.tag, text: part.text, html: part.html, rect: part.rect, component: part.component ?? null, styles: part.styles ?? null, rules: part.rules ?? [], kind: 'element' })
142
146
  out += placeholder
143
147
  } else if (part.type === 'commit' && part.hash) {
144
148
  const placeholder = `[File #${nextId()}]`
package/src/controller.js CHANGED
@@ -900,10 +900,10 @@ export function createController({ boot }) {
900
900
  }
901
901
 
902
902
  // an element picked in a browser page; the message carries its markup
903
- function attachElement({ url, selector, tag, text = '', html = '', rect = null, component = null }) {
903
+ function attachElement({ url, selector, tag, text = '', html = '', rect = null, component = null, styles = null, rules = [] }) {
904
904
  if (!selector || !tag) return null
905
905
  const placeholder = `[File #${++state.imageCount}]`
906
- state.attachments.set(placeholder, { url: String(url ?? ''), selector: String(selector), tag: String(tag), text: String(text).slice(0, 400), html: String(html).slice(0, 4000), rect, component: component ? String(component) : null, kind: 'element' })
906
+ state.attachments.set(placeholder, { url: String(url ?? ''), selector: String(selector), tag: String(tag), text: String(text).slice(0, 400), html: String(html).slice(0, 4000), rect, component: component ? String(component) : null, styles: styles && typeof styles === 'object' ? styles : null, rules: Array.isArray(rules) ? rules.slice(0, 20).map(String) : [], kind: 'element' })
907
907
  return placeholder
908
908
  }
909
909