@magpie-community/opencode-agy-tui-auth 0.1.19 → 0.1.20

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/seed.mjs +18 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-agy-tui-auth",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Magpie/OpenCode model provider that runs Antigravity's models through agy's own interactive mode: each request is typed into the real agy TUI and its answer streamed from agy's own conversation store as the model writes it",
5
5
  "type": "module",
6
6
  "main": "./opencode.mjs",
package/seed.mjs CHANGED
@@ -90,6 +90,22 @@ function loadOpener() {
90
90
  return opener
91
91
  }
92
92
 
93
+ // workspaceUri is a folder as the file URI agy keeps a conversation's
94
+ // workspace under. On Windows a path is C:\Users\…, and file:// before it
95
+ // as it is gave file://C:\Users\…, which agy reads as a host C with a port
96
+ // ":\Users\…" and turns the conversation away (lijiho96940561 on X, every
97
+ // seeded chat on Windows from 0.1.16): there the drive goes after
98
+ // file:/// with forward slashes, and a share (\\server\share) is the
99
+ // URI's host. The characters a URI reads as its own (%, # and ?) are
100
+ // escaped on every system.
101
+ export function workspaceUri(dir, win = process.platform === "win32") {
102
+ const esc = (p) => p.replace(/[%#?]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`)
103
+ if (!win) return `file://${esc(dir)}`
104
+ const p = dir.replace(/^\\\\[?.]\\(?:UNC\\)?/i, (m) => (/UNC/i.test(m) ? "\\\\" : "")).replace(/\\/g, "/")
105
+ if (p.startsWith("//")) return `file:${esc(p)}`
106
+ return `file:///${esc(p.replace(/^\/+/, ""))}`
107
+ }
108
+
93
109
  // canSeed is whether a store can be written here
94
110
  export function canSeed() {
95
111
  return Boolean(loadOpener())
@@ -109,7 +125,7 @@ CREATE TABLE battle_mode_infos (idx integer,data blob,PRIMARY KEY (idx));`
109
125
  // order) as a conversation in the account's store (home), with its brain
110
126
  // folder, and gives its id; null when no store can be written here. A
111
127
  // conversation half written is taken away again.
112
- export function writeConversation(home, steps, { ws = home, now = Date.now() } = {}) {
128
+ export function writeConversation(home, steps, { ws = home, now = Date.now(), win = process.platform === "win32" } = {}) {
113
129
  const open = loadOpener()
114
130
  if (!open) return null
115
131
  const ac = path.join(home, ".gemini", "antigravity-cli")
@@ -126,7 +142,7 @@ export function writeConversation(home, steps, { ws = home, now = Date.now() } =
126
142
  db.exec(SCHEMA)
127
143
  db.exec("BEGIN")
128
144
  db.run("INSERT INTO trajectory_meta VALUES (?,?,4,17)", traj, id)
129
- const uri = `file://${ws}`
145
+ const uri = workspaceUri(ws, win)
130
146
  db.run("INSERT INTO trajectory_metadata_blob (id, data) VALUES ('main', ?)", encode([[1, [[1, uri], [3, ""]]], [2, stamp(now)], [3, randomUUID()], [6, id], [7, uri], [25, 1]]))
131
147
  let turn = -1
132
148
  steps.forEach((s, idx) => {