@sightmap/sightkick 0.0.0 → 0.2.0

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": "@sightmap/sightkick",
3
- "version": "0.0.0",
3
+ "version": "0.2.0",
4
4
  "description": "sightkick — compile a webmcp.tools.yaml + sightmap corpus into WebMCP tool IR, and install the sightkick agent skills (native binary, no Go toolchain required)",
5
5
  "license": "MIT",
6
6
  "homepage": "https://sightmap.org",
@@ -30,15 +30,15 @@
30
30
  "README.md",
31
31
  "skills/"
32
32
  ],
33
- "optionalDependencies": {
34
- "@sightmap/sightkick-darwin-arm64": "0.0.0",
35
- "@sightmap/sightkick-darwin-x64": "0.0.0",
36
- "@sightmap/sightkick-linux-arm64": "0.0.0",
37
- "@sightmap/sightkick-linux-x64": "0.0.0",
38
- "@sightmap/sightkick-win32-arm64": "0.0.0",
39
- "@sightmap/sightkick-win32-x64": "0.0.0"
40
- },
41
33
  "publishConfig": {
42
34
  "access": "public"
35
+ },
36
+ "optionalDependencies": {
37
+ "@sightmap/sightkick-darwin-arm64": "0.2.0",
38
+ "@sightmap/sightkick-darwin-x64": "0.2.0",
39
+ "@sightmap/sightkick-linux-arm64": "0.2.0",
40
+ "@sightmap/sightkick-linux-x64": "0.2.0",
41
+ "@sightmap/sightkick-win32-arm64": "0.2.0",
42
+ "@sightmap/sightkick-win32-x64": "0.2.0"
43
43
  }
44
44
  }
@@ -0,0 +1,167 @@
1
+ ---
2
+ name: sightkick-debug
3
+ description: Drive and debug a generated sightkick WebMCP tool script on a live page via `sightmap browser`, with no bespoke sightkick extension. Use when you have a sightkick corpus + `webmcp.tools.yaml` (in the sightkick repo's `examples/` or a `sites/<name>/` dir) and want to inject its compiled tools into a running site and exercise them — either agent-driven (getTools/executeTool over `sightmap browser eval`) or Gemini-driven via the vendored WebMCP inspector.
4
+ activation:
5
+ - a sightkick `webmcp.tools.yaml` + `.sightmap/` corpus is present and you want to run its tools on a live page
6
+ - debugging why a generated WebMCP tool does/doesn't register or fire on a real site
7
+ ---
8
+
9
+ # sightkick-debug: run generated WebMCP tools on a live page
10
+
11
+ sightkick compiles a `.sightmap/` corpus + a `webmcp.tools.yaml` into an **IR**,
12
+ and a ~19 KB runtime bundle turns that IR into WebMCP tools on
13
+ `document.modelContext`. You do **not** need a bespoke extension to get them onto
14
+ a page: `sightmap browser eval` injects the runtime bundle, then
15
+ `window.__sightkick.load(ir)` registers the tools. The page's own agent surface
16
+ (native `document.modelContext`, or our polyfill) then exposes them.
17
+
18
+ ## Prerequisites
19
+
20
+ This skill uses two CLIs: **`sightkick`** (to build the IR and emit the runtime
21
+ bundle) and **`sightmap`** (to drive the live browser session). Install whichever
22
+ isn't already on your PATH, plus the supporting sightmap skills:
23
+
24
+ ```sh
25
+ npm i -g @sightmap/sightkick # the sightkick CLI (build + runtime + skills)
26
+ npx @sightmap/sightmap skills install # or: sightmap skills install (if already on PATH)
27
+ sightmap browser install # Chrome-for-Testing; needs >=152 for native document.modelContext
28
+ ```
29
+
30
+ That installs the **`sightmap-browser`** skill (driving a live session) and
31
+ **`sightmap-authoring`** skill (building the `.sightmap/` corpus) alongside this
32
+ one — everything needed to build and test a `webmcp.tools.yaml`. No repo checkout
33
+ is required; `<CORPUS_DIR>` below is any directory holding a `webmcp.tools.yaml`
34
+ + `.sightmap/` corpus.
35
+
36
+ ## 1. Build the two artifacts
37
+
38
+ Both come straight from the installed `sightkick` CLI:
39
+
40
+ ```sh
41
+ # The payload: the runtime bundle (exposes window.__sightkick.load).
42
+ sightkick runtime -o /tmp/sightkick-runtime.js
43
+
44
+ # The IR for the corpus you're testing (any dir with webmcp.tools.yaml + .sightmap/).
45
+ sightkick build <CORPUS_DIR> -o /tmp/x.ir.json
46
+ ```
47
+
48
+ Rebuild the IR whenever the corpus/manifest changes. The runtime bundle is
49
+ embedded in the CLI, so re-emit it after upgrading `sightkick`.
50
+
51
+ ## 2. Pick a mode, start the session
52
+
53
+ Both modes use the **same inject step** (§3). They differ only in whether
54
+ `document.modelContext` is the page's **native** surface or our **polyfill**, and
55
+ therefore who drives.
56
+
57
+ ### Mode A — agent-driven (polyfill; simplest)
58
+ No flags. If the page has no native `modelContext`, our runtime polyfills one, and
59
+ you drive it yourself over `eval` with the simple `{name}` call shape.
60
+
61
+ ```sh
62
+ sightmap browser start --detach --url <SITE_URL> --profile /tmp/sk-dbg
63
+ ```
64
+
65
+ ### Mode B — inspector/Gemini-driven (native WebMCP surface)
66
+ Turn on the blink flags so Chrome exposes the real `document.modelContext`, and
67
+ load the **WebMCP inspector** (a drive-with-Gemini sidebar). Our tools register on
68
+ the native surface, so the inspector reads them like any site's own. The inspector
69
+ isn't shipped with the CLI — use the vendored copy in the sightkick repo
70
+ (`vendor/webmcp-tool/unpacked`, whose `NOTES.md` explains the flag/CfT-version
71
+ rationale) or install it from the Chrome Web Store. Point `<INSPECTOR_DIR>` at its
72
+ unpacked directory:
73
+
74
+ ```sh
75
+ sightmap browser start --detach --url <SITE_URL> --profile /tmp/sk-dbg \
76
+ --extensions ~/.sightmap/extension,<INSPECTOR_DIR> \
77
+ --chrome-flag=--enable-blink-features=ModelContext,ModelContextTesting \
78
+ --chrome-flag=--enable-features=DevToolsWebMCPSupport
79
+ ```
80
+
81
+ (All `--extensions` entries must be absolute; listing any `--extensions` replaces
82
+ the auto-loaded overlay, so include `~/.sightmap/extension` explicitly.)
83
+
84
+ Then, in either mode, wait for the page and confirm readiness:
85
+
86
+ ```sh
87
+ sightmap browser wait-for --selector <SOME_SELECTOR> --timeout-ms 10000
88
+ sightmap browser eval "typeof document.modelContext" # object
89
+ ```
90
+
91
+ ## 3. Inject the runtime + IR
92
+
93
+ ```sh
94
+ sightmap browser eval "$(cat /tmp/sightkick-runtime.js)" # sets window.__sightkick
95
+ sightmap browser eval "window.__sightkick.load($(cat /tmp/x.ir.json))"
96
+ ```
97
+
98
+ The bundle fits in an `eval` arg. `load(ir)` registers the tools that are
99
+ **view-scoped to the current URL** — so tools only appear on pages whose view
100
+ route matches (an empty `getTools()` on the wrong URL is correct, not a bug).
101
+
102
+ Confirm registration (works in both modes):
103
+
104
+ ```sh
105
+ # getTools() is async — stash to a global, then read it.
106
+ sightmap browser eval "window.__t='RUN';document.modelContext.getTools().then(function(ts){window.__t=JSON.stringify(ts.map(function(x){return x.name}))});'go'"
107
+ sleep 1; sightmap browser eval "window.__t" # -> ["tool_a","tool_b",...]
108
+ ```
109
+
110
+ ## 4. Drive the tools
111
+
112
+ ### Mode A (polyfill): drive over eval
113
+ The polyfill's `executeTool(tool, args)` accepts a bare `{name}`:
114
+
115
+ ```sh
116
+ sightmap browser eval "window.__r='RUN';document.modelContext.executeTool({name:'search'},{query:'ATL to LHR'}).then(function(r){window.__r=r.content[0].text}).catch(function(e){window.__r='ERR '+e});'go'"
117
+ sleep 2; sightmap browser eval "window.__r" # the ToolResult JSON (ok/value/items/guidance)
118
+ ```
119
+
120
+ The result envelope is `{content:[{type:'text',text:<ToolResult JSON>}]}`; the
121
+ `ToolResult` carries `ok`, `value`/`items`, `skipped` (idempotency guard hit),
122
+ and `guidance` (next-step breadcrumbs). The sightkick repo's
123
+ `packages/runtime/eval/run.mjs` is a full scripted example of this loop.
124
+
125
+ ### Mode B (native): drive via the inspector
126
+ Open the inspector's sidebar and prompt Gemini — it enumerates
127
+ `document.modelContext.getTools()` (now including ours) and calls them through the
128
+ native surface. This is the "does a real WebMCP agent complete the flow" test.
129
+
130
+ > Native `executeTool` is stricter than the polyfill (it takes the full
131
+ > RegisteredTool from `getTools()` and its own argument serialization, and
132
+ > returns a **stringified** envelope). Let the inspector make those calls; for
133
+ > scripted/agent checks prefer Mode A, whose call shape is simple.
134
+
135
+ ## 5. Navigation & re-injection
136
+
137
+ `eval`-injection lives on **one document**:
138
+
139
+ - **SPA** (client-side routing — e.g. the search demo): inject once; the
140
+ runtime re-registers view-scoped tools on route changes. `wait-for --url` /
141
+ `--selector` after an action that routes.
142
+ - **MPA** (a real page load — the URL changes with a full document load): the
143
+ injected script is gone after the load. **Re-run §3** on the new page.
144
+
145
+ (When the sightmap `browser inject --persist` facility lands — CDP
146
+ `addScriptToEvaluateOnNewDocument` — inject once and it survives navigations,
147
+ retiring the per-nav re-inject. Until then, re-inject.)
148
+
149
+ ## 6. Clean up
150
+
151
+ ```sh
152
+ sightmap browser stop
153
+ rm -rf /tmp/sk-dbg
154
+ ```
155
+
156
+ ## Gotchas
157
+
158
+ - **Empty `getTools()` is usually right** — the tools are view-scoped; you're on a
159
+ URL no view matches. Check `location.pathname` against the corpus's view routes.
160
+ - **Native surface needs Chrome ≥150 and the blink flags on the command line** —
161
+ toggling `chrome://flags` in the automation profile does nothing (it's a Blink
162
+ runtime feature). `sightmap browser install` should pull ≥152.
163
+ - **The bundle is ~19 KB** — well within an `eval` arg; no hosting or fs-access
164
+ needed. Rebuild it after runtime changes.
165
+ - **A stale daemon collides** — `sightmap browser stop` before `start`, and give
166
+ `--detach` a beat for the content tab to open before page commands (poll
167
+ `status` / `wait-for`).