donkicode 0.1.1 → 0.1.3

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/bin/donkicode CHANGED
@@ -35,6 +35,43 @@ import { fileURLToPath } from "node:url"
35
35
 
36
36
  const __filename = fileURLToPath(import.meta.url)
37
37
 
38
+ // Localiza el bundle del frontend (`<pkg>/dist/index.html`) que `build.ts` deja
39
+ // junto al binario. Robusto ante el cache `.donkicode` del postinstall: si el
40
+ // binario que arranca es un hard-link/copia dentro del META (cuyo path NO trae
41
+ // `dist/`), cae a buscar el paquete de plataforma `donkicode-*` en node_modules.
42
+ function resolveStaticDir(target) {
43
+ // 1) Hermano del binario REAL — binario de plataforma directo, o un symlink
44
+ // que `realpath` resuelve al paquete de plataforma.
45
+ try {
46
+ const real = fs.realpathSync(target)
47
+ const sibling = path.join(path.dirname(path.dirname(real)), "dist")
48
+ if (fs.existsSync(path.join(sibling, "index.html"))) return sibling
49
+ } catch {
50
+ /* ignore */
51
+ }
52
+ // 2) Fallback: el frontend vive en el paquete de plataforma. Subimos por
53
+ // node_modules buscando cualquier `donkicode-*/dist/index.html`.
54
+ try {
55
+ let current = path.dirname(fs.realpathSync(__filename))
56
+ for (;;) {
57
+ const modules = path.join(current, "node_modules")
58
+ if (fs.existsSync(modules)) {
59
+ for (const entry of fs.readdirSync(modules)) {
60
+ if (!entry.startsWith("donkicode-")) continue
61
+ const guess = path.join(modules, entry, "dist")
62
+ if (fs.existsSync(path.join(guess, "index.html"))) return guess
63
+ }
64
+ }
65
+ const parent = path.dirname(current)
66
+ if (parent === current) break
67
+ current = parent
68
+ }
69
+ } catch {
70
+ /* ignore */
71
+ }
72
+ return undefined
73
+ }
74
+
38
75
  function run(target, args) {
39
76
  // DEC-041 (T-238b / Cabo 5) — si al lado del binario nativo vive un bundle
40
77
  // de frontend estático (`<pkg-dir>/dist/index.html`), el shim exporta
@@ -44,11 +81,8 @@ function run(target, args) {
44
81
  // definió la env var, no la sobreescribimos.
45
82
  const env = { ...process.env }
46
83
  if (!env.DONKICODE_STATIC_DIR) {
47
- const pkgDir = path.dirname(path.dirname(fs.realpathSync(target)))
48
- const staticDir = path.join(pkgDir, "dist")
49
- if (fs.existsSync(path.join(staticDir, "index.html"))) {
50
- env.DONKICODE_STATIC_DIR = staticDir
51
- }
84
+ const staticDir = resolveStaticDir(target)
85
+ if (staticDir) env.DONKICODE_STATIC_DIR = staticDir
52
86
  }
53
87
  const result = childProcess.spawnSync(target, args, {
54
88
  stdio: "inherit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "donkicode",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "DonkiCode — el estudio de agentes con memoria memodonki.",
5
5
  "bin": {
6
6
  "donkicode": "./bin/donkicode"
@@ -10,16 +10,16 @@
10
10
  },
11
11
  "license": "UNLICENSED",
12
12
  "optionalDependencies": {
13
- "donkicode-linux-arm64": "0.1.1",
14
- "donkicode-linux-x64-baseline": "0.1.1",
15
- "donkicode-linux-x64-baseline-musl": "0.1.1",
16
- "donkicode-windows-x64": "0.1.1",
17
- "donkicode-windows-x64-baseline": "0.1.1",
18
- "donkicode-darwin-arm64": "0.1.1",
19
- "donkicode-linux-x64-musl": "0.1.1",
20
- "donkicode-linux-arm64-musl": "0.1.1",
21
- "donkicode-darwin-x64-baseline": "0.1.1",
22
- "donkicode-linux-x64": "0.1.1",
23
- "donkicode-darwin-x64": "0.1.1"
13
+ "donkicode-linux-x64-baseline": "0.1.3",
14
+ "donkicode-linux-x64": "0.1.3",
15
+ "donkicode-linux-arm64": "0.1.3",
16
+ "donkicode-darwin-x64-baseline": "0.1.3",
17
+ "donkicode-linux-x64-musl": "0.1.3",
18
+ "donkicode-linux-arm64-musl": "0.1.3",
19
+ "donkicode-windows-x64": "0.1.3",
20
+ "donkicode-linux-x64-baseline-musl": "0.1.3",
21
+ "donkicode-windows-x64-baseline": "0.1.3",
22
+ "donkicode-darwin-x64": "0.1.3",
23
+ "donkicode-darwin-arm64": "0.1.3"
24
24
  }
25
25
  }
package/postinstall.mjs CHANGED
@@ -118,12 +118,24 @@ async function main() {
118
118
  // cache con el nombre viejo; ahora es el que el shim espera.
119
119
  const target = path.join(__dirname, "bin", ".donkicode")
120
120
  if (fs.existsSync(target)) fs.unlinkSync(target)
121
+ // SYMLINK, no hard link (bug 404 del 2026-07-24): el shim deriva la carpeta
122
+ // del frontend estático del PATH del binario que arranca. Un hard link
123
+ // comparte el inode pero su path sigue siendo `<meta>/bin/.donkicode`, y el
124
+ // meta NO trae `dist/` → el shim buscaba la UI en `<meta>/dist` (inexistente)
125
+ // y servía 404. Un symlink hace que `fs.realpathSync` resuelva al paquete de
126
+ // plataforma (`donkicode-<plat>-<arch>/bin/donkicode`), cuyo hermano `dist/`
127
+ // SÍ es el frontend. Fallbacks (hard link / copia) los cubre el shim, que
128
+ // además localiza el bundle en el paquete de plataforma por su cuenta.
121
129
  try {
122
- fs.linkSync(binaryPath, target)
130
+ fs.symlinkSync(binaryPath, target)
123
131
  } catch {
124
- fs.copyFileSync(binaryPath, target)
132
+ try {
133
+ fs.linkSync(binaryPath, target)
134
+ } catch {
135
+ fs.copyFileSync(binaryPath, target)
136
+ }
125
137
  }
126
- fs.chmodSync(target, 0o755)
138
+ if (!fs.lstatSync(target).isSymbolicLink()) fs.chmodSync(target, 0o755)
127
139
  console.log(`donkicode: binario nativo enlazado (${binaryPath})`)
128
140
  } catch (error) {
129
141
  console.error("No pude preparar el binario de donkicode:", error.message)