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