@tiens.nguyen/gu-cli 1.0.845 → 1.0.847
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/browser-extension/actions.js +85 -0
- package/browser-extension/manifest.json +1 -1
- package/gu-repl.mjs +13 -15
- package/gu_browser.py +26 -5
- package/package.json +1 -1
- package/terminal-layout.mjs +22 -0
|
@@ -168,6 +168,88 @@ async function point(host, tabId, cmd) {
|
|
|
168
168
|
throw new Error("say where: ref (a number from read) or x and y");
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
// ── the visible gu cursor ───────────────────────────────────────────────────────────────────
|
|
172
|
+
// Runs IN the page. The DevTools input events move no real mouse pointer, so the user could not
|
|
173
|
+
// see where gu acts. This draws a purple "gu" arrow that glides to each point before gu clicks,
|
|
174
|
+
// hovers, types or scrolls there, and ripples on a click. It sits in a shadow root on <html> with
|
|
175
|
+
// pointer-events:none: it never takes a click, elementFromPoint looks through it, and read (which
|
|
176
|
+
// reads body.innerText) never sees it. Built with DOM calls only (no innerHTML), so pages with
|
|
177
|
+
// Trusted Types or strict CSP still show it. Returns how long the glide takes, in ms.
|
|
178
|
+
function guCursor(o) {
|
|
179
|
+
try {
|
|
180
|
+
const d = document;
|
|
181
|
+
const ID = "__gu_cursor";
|
|
182
|
+
let h = d.getElementById(ID);
|
|
183
|
+
if (!h || !h.__p) {
|
|
184
|
+
if (h) h.remove();
|
|
185
|
+
h = d.createElement("div");
|
|
186
|
+
h.id = ID;
|
|
187
|
+
h.style.cssText = "all:initial;position:fixed;left:0;top:0;width:0;height:0;overflow:visible;z-index:2147483647;pointer-events:none";
|
|
188
|
+
const root = h.attachShadow ? h.attachShadow({ mode: "open" }) : h;
|
|
189
|
+
const p = d.createElement("div");
|
|
190
|
+
p.style.cssText = "position:fixed;left:0;top:0;width:0;height:0;overflow:visible;pointer-events:none;will-change:transform;filter:drop-shadow(0 2px 3px rgba(0,0,0,.45))";
|
|
191
|
+
const NS = "http://www.w3.org/2000/svg";
|
|
192
|
+
const svg = d.createElementNS(NS, "svg");
|
|
193
|
+
svg.setAttribute("width", "28");
|
|
194
|
+
svg.setAttribute("height", "28");
|
|
195
|
+
svg.setAttribute("viewBox", "0 0 28 28");
|
|
196
|
+
svg.style.cssText = "display:block;position:absolute;left:0;top:0;overflow:visible";
|
|
197
|
+
const path = d.createElementNS(NS, "path");
|
|
198
|
+
path.setAttribute("d", "M3 2 L3 22 L8.5 17 L12 25.5 L15.5 24 L12 15.8 L19.5 15.8 Z");
|
|
199
|
+
path.setAttribute("fill", "#7c3aed");
|
|
200
|
+
path.setAttribute("stroke", "#ffffff");
|
|
201
|
+
path.setAttribute("stroke-width", "2");
|
|
202
|
+
path.setAttribute("stroke-linejoin", "round");
|
|
203
|
+
svg.appendChild(path);
|
|
204
|
+
const tag = d.createElement("div");
|
|
205
|
+
tag.textContent = "gu";
|
|
206
|
+
tag.style.cssText = "position:absolute;left:20px;top:24px;background:#7c3aed;color:#fff;font:600 11px/1 -apple-system,system-ui,sans-serif;padding:3px 6px;border-radius:8px;border:1.5px solid #fff;white-space:nowrap";
|
|
207
|
+
p.append(svg, tag);
|
|
208
|
+
root.appendChild(p);
|
|
209
|
+
h.__p = p;
|
|
210
|
+
h.__root = root;
|
|
211
|
+
}
|
|
212
|
+
if (!h.isConnected) (d.documentElement || d.body).appendChild(h);
|
|
213
|
+
const p = h.__p;
|
|
214
|
+
const x = Number(o.x), y = Number(o.y);
|
|
215
|
+
const first = h.dataset.x === undefined;
|
|
216
|
+
const fx = first ? x : Number(h.dataset.x), fy = first ? y : Number(h.dataset.y);
|
|
217
|
+
const at = (px, py) => `translate(${px - 3}px,${py - 2}px)`; // the arrow's tip is at (3,2)
|
|
218
|
+
const dist = Math.hypot(x - fx, y - fy);
|
|
219
|
+
const ms = first || dist < 2 ? 0 : Math.round(Math.min(450, Math.max(150, dist * 0.6)));
|
|
220
|
+
p.style.transform = at(x, y);
|
|
221
|
+
if (ms && p.animate) p.animate([{ transform: at(fx, fy) }, { transform: at(x, y) }], { duration: ms, easing: "cubic-bezier(.3,.7,.4,1)" });
|
|
222
|
+
h.dataset.x = String(x);
|
|
223
|
+
h.dataset.y = String(y);
|
|
224
|
+
const ripples = o.kind === "double_click" ? 2 : ["click", "right_click", "type"].includes(o.kind) ? 1 : 0;
|
|
225
|
+
const color = o.kind === "right_click" ? "#f59e0b" : "#a78bfa";
|
|
226
|
+
for (let i = 0; i < ripples; i++) {
|
|
227
|
+
setTimeout(() => {
|
|
228
|
+
const r = d.createElement("div");
|
|
229
|
+
r.style.cssText = `position:fixed;left:${x - 18}px;top:${y - 18}px;width:36px;height:36px;box-sizing:border-box;border:3px solid ${color};border-radius:50%;pointer-events:none;opacity:0`;
|
|
230
|
+
h.__root.appendChild(r);
|
|
231
|
+
if (r.animate) {
|
|
232
|
+
const an = r.animate([{ transform: "scale(.3)", opacity: 1 }, { transform: "scale(1.5)", opacity: 0 }], { duration: 550, easing: "ease-out" });
|
|
233
|
+
an.onfinish = () => r.remove();
|
|
234
|
+
} else setTimeout(() => r.remove(), 600);
|
|
235
|
+
}, ms + i * 160);
|
|
236
|
+
}
|
|
237
|
+
return ms;
|
|
238
|
+
} catch (e) {
|
|
239
|
+
return 0;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Shows the gu cursor at x,y and waits for its glide, so the user sees where gu acts. Never fails. */
|
|
244
|
+
async function showCursor(host, tabId, x, y, kind = "move") {
|
|
245
|
+
try {
|
|
246
|
+
const ms = await evaluate(host, tabId, `(${guCursor})(${JSON.stringify({ x, y, kind })})`);
|
|
247
|
+
if (ms) await sleep(Math.min(Number(ms) || 0, 500) + 40);
|
|
248
|
+
} catch {
|
|
249
|
+
// a page that refuses scripts still gets the click
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
171
253
|
async function mouse(host, tabId, x, y, button = "left", clicks = 1) {
|
|
172
254
|
await host.cdp(tabId, "Input.dispatchMouseEvent", { type: "mouseMoved", x, y });
|
|
173
255
|
for (let i = 1; i <= clicks; i++) {
|
|
@@ -263,6 +345,7 @@ export async function runAction(cmd, host) {
|
|
|
263
345
|
case "hover": {
|
|
264
346
|
const p = await point(host, id, cmd);
|
|
265
347
|
const hit = await hitAt(host, id, p.x, p.y);
|
|
348
|
+
await showCursor(host, id, p.x, p.y, a);
|
|
266
349
|
if (a === "hover") await host.cdp(id, "Input.dispatchMouseEvent", { type: "mouseMoved", x: p.x, y: p.y });
|
|
267
350
|
else await mouse(host, id, p.x, p.y, a === "right_click" ? "right" : "left", a === "double_click" ? 2 : 1);
|
|
268
351
|
await settle(host, id);
|
|
@@ -271,6 +354,7 @@ export async function runAction(cmd, host) {
|
|
|
271
354
|
case "type": {
|
|
272
355
|
if (hasRef(cmd)) {
|
|
273
356
|
const p = await refPoint(host, id, cmd.ref);
|
|
357
|
+
await showCursor(host, id, p.x, p.y, "type");
|
|
274
358
|
await mouse(host, id, p.x, p.y);
|
|
275
359
|
if (cmd.clear) await pressKey(host, id, "ctrl+a");
|
|
276
360
|
}
|
|
@@ -292,6 +376,7 @@ export async function runAction(cmd, host) {
|
|
|
292
376
|
const dir = String(cmd.direction || "down").toLowerCase();
|
|
293
377
|
const dx = dir === "left" ? -amount : dir === "right" ? amount : 0;
|
|
294
378
|
const dy = dir === "up" ? -amount : dir === "down" ? amount : 0;
|
|
379
|
+
await showCursor(host, id, x, y, "scroll");
|
|
295
380
|
await host.cdp(id, "Input.dispatchMouseEvent", { type: "mouseWheel", x, y, deltaX: dx, deltaY: dy });
|
|
296
381
|
await sleep(300);
|
|
297
382
|
return after(host, id, { scroll: await evaluate(host, id, "Math.round(scrollY) + ' of ' + Math.max(0, document.documentElement.scrollHeight - innerHeight)") });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "gu browser",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"description": "Lets the gu coding agent open, see and operate web pages in its own tabs (tab group \"gu\") with a real mouse and keyboard.",
|
|
6
6
|
"minimum_chrome_version": "116",
|
|
7
7
|
"icons": {
|
package/gu-repl.mjs
CHANGED
|
@@ -121,6 +121,7 @@ import {
|
|
|
121
121
|
NO_MODEL_LINES,
|
|
122
122
|
resizeRepaintTarget,
|
|
123
123
|
workspaceSyncQuestion,
|
|
124
|
+
workspaceAccessQuestion,
|
|
124
125
|
workspaceSyncLabel,
|
|
125
126
|
activeCoderName,
|
|
126
127
|
easeCount,
|
|
@@ -5133,24 +5134,21 @@ async function ensureWorkspace() {
|
|
|
5133
5134
|
console.log(GUTTER + dim("RAG cannot index a folder this size, and file tools would range"));
|
|
5134
5135
|
console.log(GUTTER + dim("over all of it. Answer n, then re-run gu inside a project."));
|
|
5135
5136
|
}
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
);
|
|
5137
|
+
// ONE question covers register + run-commands + browser (GitHub #192). Yes = all three,
|
|
5138
|
+
// persisted, so gu never asks again for this folder.
|
|
5139
|
+
const access = workspaceAccessQuestion({ scopeWarning });
|
|
5140
|
+
for (const l of access.intro) console.log(GUTTER + dim(l));
|
|
5141
|
+
const register = await askYesNo(access.question, access.defaultYes);
|
|
5142
5142
|
if (!register) {
|
|
5143
5143
|
console.log(GUTTER + dim("Skipped — the agent will not be able to touch files here."));
|
|
5144
5144
|
return;
|
|
5145
5145
|
}
|
|
5146
|
-
const allowRun =
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
keep a workspace read/edit-only. */
|
|
5153
|
-
);
|
|
5146
|
+
const allowRun = true;
|
|
5147
|
+
try {
|
|
5148
|
+
allowIn(cwd, true); // the browser's "always allow in this folder" list
|
|
5149
|
+
} catch (e) {
|
|
5150
|
+
console.log(GUTTER + yellow(`Could not save the browser permission (${e?.message || e}) — gu will ask when it first needs it.`));
|
|
5151
|
+
}
|
|
5154
5152
|
// On Client Expert there is no cloud to sync TO — see workspaceSyncQuestion.
|
|
5155
5153
|
const syncQ = workspaceSyncQuestion({ clientExpert: isClientExpert() });
|
|
5156
5154
|
const allowSync = syncQ.ask
|
|
@@ -5175,7 +5173,7 @@ async function ensureWorkspace() {
|
|
|
5175
5173
|
console.log(
|
|
5176
5174
|
GUTTER +
|
|
5177
5175
|
accent(`✓ workspace registered: ${basename(cwd)}`) +
|
|
5178
|
-
(allowRun ? accent(" (run-commands enabled)") : dim(" (run-commands disabled)")) +
|
|
5176
|
+
(allowRun ? accent(" (run-commands + browser enabled)") : dim(" (run-commands disabled)")) +
|
|
5179
5177
|
(isClientExpert()
|
|
5180
5178
|
? ""
|
|
5181
5179
|
: allowSync
|
package/gu_browser.py
CHANGED
|
@@ -221,6 +221,22 @@ def _is_gu(ext_id, entry):
|
|
|
221
221
|
return False
|
|
222
222
|
|
|
223
223
|
|
|
224
|
+
# Chrome keeps an EMPTY record ({}) for an extension ID it once saw (e.g. removed, or a store page
|
|
225
|
+
# visited) — no location, path or manifest. That is not an install (task #401: the agent said
|
|
226
|
+
# "installed but not connected" when the user had never clicked "Add to Chrome").
|
|
227
|
+
_RECORD_KEYS = ("location", "path", "manifest", "state", "install_time", "first_install_time", "disable_reasons")
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _is_real_record(entry, profile_dir=None, ext_id=None):
|
|
231
|
+
if not any(k in entry for k in _RECORD_KEYS):
|
|
232
|
+
return False
|
|
233
|
+
path = entry.get("path")
|
|
234
|
+
if profile_dir and isinstance(path, str) and path and not os.path.isabs(path):
|
|
235
|
+
# a store install lives in <profile>/Extensions/<id>/<version>
|
|
236
|
+
return os.path.isdir(os.path.join(profile_dir, "Extensions", path))
|
|
237
|
+
return True
|
|
238
|
+
|
|
239
|
+
|
|
224
240
|
def find_installs(roots=None):
|
|
225
241
|
"""→ [{browser, profile, id, kind: "store"|"developer", enabled}] for every browser profile with
|
|
226
242
|
the gu extension. Reads the profiles' Preferences only — gu never writes a browser's files."""
|
|
@@ -239,7 +255,8 @@ def find_installs(roots=None):
|
|
|
239
255
|
except (OSError, ValueError, AttributeError):
|
|
240
256
|
continue
|
|
241
257
|
for ext_id, e in settings.items():
|
|
242
|
-
if ext_id in seen or not isinstance(e, dict) or not _is_gu(ext_id, e)
|
|
258
|
+
if ext_id in seen or not isinstance(e, dict) or not _is_gu(ext_id, e) \
|
|
259
|
+
or not _is_real_record(e, os.path.join(d, prof), ext_id):
|
|
243
260
|
continue
|
|
244
261
|
seen.add(ext_id)
|
|
245
262
|
reasons = e.get("disable_reasons")
|
|
@@ -250,10 +267,14 @@ def find_installs(roots=None):
|
|
|
250
267
|
|
|
251
268
|
|
|
252
269
|
def diagnose(installs):
|
|
253
|
-
"""→ "missing" (not in any browser), "disabled" (only turned-off copies) or "installed".
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
270
|
+
"""→ "missing" (not in any browser), "disabled" (only turned-off copies) or "installed".
|
|
271
|
+
A turned-off DEVELOPER (unpacked) copy alone counts as missing: the fix is the store's
|
|
272
|
+
"Add to Chrome", not switching an old unpacked copy back on."""
|
|
273
|
+
if any(i["enabled"] for i in installs):
|
|
274
|
+
return "installed"
|
|
275
|
+
if any(i.get("kind") == "store" for i in installs):
|
|
276
|
+
return "disabled"
|
|
277
|
+
return "missing"
|
|
257
278
|
|
|
258
279
|
|
|
259
280
|
def _offered_path():
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiens.nguyen/gu-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.847",
|
|
4
4
|
"description": "Gu CLI — the gu terminal plus the local worker that runs agent / OCR / PDF / embedding jobs on your Mac (Ollama / MLX / OpenAI-compatible).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/terminal-layout.mjs
CHANGED
|
@@ -2571,6 +2571,28 @@ export function workspaceSyncQuestion({ clientExpert }) {
|
|
|
2571
2571
|
: { ask: true, value: null, note: "" };
|
|
2572
2572
|
}
|
|
2573
2573
|
|
|
2574
|
+
/**
|
|
2575
|
+
* The ONE first-run question for a new folder (GitHub #192). It used to be two or three separate
|
|
2576
|
+
* Y/n prompts (register, trust to run commands, then the browser on first use). They are one
|
|
2577
|
+
* decision, "may gu work in this folder?", so the answer covers all three, and the list says
|
|
2578
|
+
* exactly what Yes grants. A too-broad folder (home, /) flips the default to No.
|
|
2579
|
+
*/
|
|
2580
|
+
export function workspaceAccessQuestion({ scopeWarning = "" } = {}) {
|
|
2581
|
+
return {
|
|
2582
|
+
intro: [
|
|
2583
|
+
"With your OK, gu can do these in this folder:",
|
|
2584
|
+
" • read and edit your code",
|
|
2585
|
+
" • run build/test commands (npm test, mvn, pytest…)",
|
|
2586
|
+
" • open and click web pages in your browser (UI tests)",
|
|
2587
|
+
"You can undo the browser part any time with /browser forget.",
|
|
2588
|
+
],
|
|
2589
|
+
question: scopeWarning
|
|
2590
|
+
? "Register it anyway and allow all of that?"
|
|
2591
|
+
: "Register this folder and allow all of that?",
|
|
2592
|
+
defaultYes: !scopeWarning,
|
|
2593
|
+
};
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2574
2596
|
/**
|
|
2575
2597
|
* A counter that CLIMBS to its new value instead of jumping (user, 2026-09-05: "lets make it
|
|
2576
2598
|
* dynamically going up so we can see it increase slowly… like 400 then 410, then 440, then 470
|