arcana-ai 0.2.3 → 0.2.5

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/bin/arcana.js +18 -16
  2. package/package.json +1 -1
package/bin/arcana.js CHANGED
@@ -10,7 +10,7 @@ const crypto = require("crypto")
10
10
  const os = require("os")
11
11
 
12
12
  const REPO = "Lento47/arcana"
13
- const VERSION = "v0.2.3"
13
+ const VERSION = "v0.2.5"
14
14
 
15
15
  const PLATFORM_MAP = {
16
16
  "win32-x64": { asset: "arcana-windows-x64.zip", binary: "arcana.exe" },
@@ -32,16 +32,14 @@ if (!entry) {
32
32
 
33
33
  const CACHE_DIR = process.env.ARCANA_CACHE || path.join(os.homedir(), ".arcana", "bin")
34
34
  const CACHED_BINARY = path.join(CACHE_DIR, entry.binary)
35
+ const VERSION_FILE = path.join(CACHE_DIR, ".version")
35
36
 
36
37
  async function downloadAndExtract() {
37
- const ext = entry.asset.endsWith(".tar.gz") ? ".tar.gz" : ".zip"
38
- const zipName = `arcana-${platform}${ext}`
39
-
40
38
  // Clean up any stale temp file from previous failed attempts
41
- try { unlinkSync(path.join(CACHE_DIR, zipName)) } catch {}
39
+ try { unlinkSync(path.join(CACHE_DIR, entry.asset)) } catch {}
42
40
 
43
41
  const url = `https://github.com/${REPO}/releases/download/${VERSION}/${entry.asset}`
44
- console.error(`arcana: downloading ${zipName}...`)
42
+ console.error(`arcana: ${VERSION} — downloading ${entry.asset}...`)
45
43
 
46
44
  mkdirSync(CACHE_DIR, { recursive: true })
47
45
 
@@ -51,12 +49,12 @@ async function downloadAndExtract() {
51
49
  process.exit(1)
52
50
  }
53
51
 
54
- const tmp = path.join(CACHE_DIR, zipName)
52
+ const tmp = path.join(CACHE_DIR, entry.asset)
55
53
  const buf = Buffer.from(await res.arrayBuffer())
56
54
  writeFileSync(tmp, buf)
57
- console.error(`arcana: ${(buf.length / 1e6).toFixed(1)}MB, verifying checksum...`)
55
+ console.error(`arcana: ${(buf.length / 1e6).toFixed(1)}MB, verifying...`)
58
56
 
59
- // Verify binary integrity — checksum is mandatory, GitHub generates .sha256 for every asset
57
+ // Verify binary integrity — checksum is mandatory
60
58
  const shaUrl = url + ".sha256"
61
59
  const shaRes = await fetch(shaUrl)
62
60
  if (!shaRes.ok) {
@@ -69,24 +67,22 @@ async function downloadAndExtract() {
69
67
  const expectedHash = shaText.split(/\s+/)[0]
70
68
  const actualHash = crypto.createHash("sha256").update(buf).digest("hex")
71
69
  if (expectedHash !== actualHash) {
72
- console.error(`arcana: CHECKSUM MISMATCH for ${zipName}`)
70
+ console.error(`arcana: CHECKSUM MISMATCH`)
73
71
  console.error(` expected: ${expectedHash}`)
74
72
  console.error(` actual: ${actualHash}`)
75
73
  console.error(`arcana: binary may be corrupted or tampered — deleting`)
76
74
  try { unlinkSync(tmp) } catch {}
77
75
  process.exit(1)
78
76
  }
79
- console.error(`arcana: checksum OK (SHA256: ${actualHash.slice(0, 16)}...)`)
77
+ console.error(`arcana: checksum OK`)
80
78
 
81
79
  console.error(`arcana: extracting...`)
82
-
83
80
  try {
84
81
  if (entry.asset.endsWith(".tar.gz")) {
85
82
  execSync(`tar xzf "${tmp}" -C "${CACHE_DIR}"`, { stdio: "pipe" })
86
83
  unlinkSync(tmp)
87
84
  } else if (entry.asset.endsWith(".zip")) {
88
85
  if (os.platform() === "win32") {
89
- // .NET ZipFile — built into .NET, no PowerShell module needed
90
86
  const safeTmp = tmp.replace(/'/g, "''")
91
87
  const safeDir = CACHE_DIR.replace(/'/g, "''")
92
88
  execSync(
@@ -107,16 +103,22 @@ async function downloadAndExtract() {
107
103
  try { chmodSync(CACHED_BINARY, 0o755) } catch {}
108
104
  }
109
105
 
110
- console.error(`arcana: ready ${CACHED_BINARY}`)
106
+ // Write version file so we can detect staleness on next run
107
+ try { writeFileSync(VERSION_FILE, VERSION, "utf8") } catch {}
108
+ console.error(`arcana: ready`)
111
109
  }
112
110
 
113
111
  async function main() {
114
- if (!existsSync(CACHED_BINARY)) {
112
+ // Check if cached binary is stale (wrong version)
113
+ let cachedVersion = ""
114
+ try { cachedVersion = require("fs").readFileSync(VERSION_FILE, "utf8").trim() } catch {}
115
+
116
+ if (!existsSync(CACHED_BINARY) || cachedVersion !== VERSION) {
115
117
  await downloadAndExtract()
116
118
  }
117
119
 
118
120
  if (!existsSync(CACHED_BINARY)) {
119
- console.error(`arcana: binary not found: ${CACHED_BINARY}`)
121
+ console.error(`arcana: binary not found after download`)
120
122
  process.exit(1)
121
123
  }
122
124
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arcana-ai",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Self-improving AI agent CLI — opencode TUI + skills. Installs the arcana binary.",
5
5
  "bin": {
6
6
  "arcana": "./bin/arcana.js"