@deleted-ai/deleted 0.1.272 → 0.1.277

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.
Binary file
package/lib/install.js CHANGED
@@ -7,9 +7,11 @@ import { assertSupportedPlatform } from './platform.js';
7
7
  import { readManifest, releaseDownloadUrl, tarballFileName } from './manifest.js';
8
8
  import {
9
9
  cacheRoot,
10
+ cacheMatchesManifest,
10
11
  isInstalled,
11
12
  nativeBinaryPath,
12
13
  packageRoot,
14
+ writeInstallStamp,
13
15
  } from './paths.js';
14
16
 
15
17
  const ZERO_SHA256 =
@@ -185,9 +187,12 @@ export function ensureInstalled() {
185
187
  assertSupportedPlatform();
186
188
  const manifest = readManifest();
187
189
  const destDir = cacheRoot(manifest.version);
188
- if (isInstalled(destDir)) {
190
+ if (isInstalled(destDir) && cacheMatchesManifest(destDir, manifest)) {
189
191
  return destDir;
190
192
  }
193
+ if (fs.existsSync(destDir)) {
194
+ fs.rmSync(destDir, { recursive: true, force: true });
195
+ }
191
196
  fs.mkdirSync(path.dirname(destDir), { recursive: true });
192
197
  installFromRelease(manifest, destDir);
193
198
  if (!isInstalled(destDir)) {
@@ -195,5 +200,6 @@ export function ensureInstalled() {
195
200
  `install incomplete: expected ${nativeBinaryPath(destDir)} and starter harness`,
196
201
  );
197
202
  }
203
+ writeInstallStamp(destDir, manifest);
198
204
  return destDir;
199
205
  }
package/lib/paths.js CHANGED
@@ -22,6 +22,43 @@ export function nativeBinaryPath(cacheDir) {
22
22
  return path.join(cacheDir, 'bin', 'deleted');
23
23
  }
24
24
 
25
+ /** @param {string} cacheDir */
26
+ export function installStampPath(cacheDir) {
27
+ return path.join(cacheDir, '.install-stamp.json');
28
+ }
29
+
30
+ /** @param {string} cacheDir */
31
+ export function readInstallStamp(cacheDir) {
32
+ try {
33
+ return JSON.parse(fs.readFileSync(installStampPath(cacheDir), 'utf8'));
34
+ } catch {
35
+ return null;
36
+ }
37
+ }
38
+
39
+ /** @param {string} cacheDir @param {object} manifest */
40
+ export function writeInstallStamp(cacheDir, manifest) {
41
+ const stamp = {
42
+ version: manifest.version,
43
+ gitSha: manifest.gitSha,
44
+ tarballSha256: manifest.tarballSha256,
45
+ };
46
+ fs.writeFileSync(installStampPath(cacheDir), `${JSON.stringify(stamp)}\n`);
47
+ }
48
+
49
+ /** @param {string} cacheDir @param {object} manifest */
50
+ export function cacheMatchesManifest(cacheDir, manifest) {
51
+ const stamp = readInstallStamp(cacheDir);
52
+ if (!stamp) {
53
+ return false;
54
+ }
55
+ return (
56
+ stamp.version === manifest.version &&
57
+ stamp.gitSha === manifest.gitSha &&
58
+ stamp.tarballSha256 === manifest.tarballSha256
59
+ );
60
+ }
61
+
25
62
  /** @param {string} cacheDir */
26
63
  export function isInstalled(cacheDir) {
27
64
  const binary = nativeBinaryPath(cacheDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deleted-ai/deleted",
3
- "version": "0.1.272",
3
+ "version": "0.1.277",
4
4
  "description": "Deleted AI CLI wrapper — downloads the linux-arm64 native binary on install",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -1,7 +1,7 @@
1
1
  {
2
- "version": "0.1.272",
3
- "gitSha": "1f657c0",
4
- "tarballSha256": "cd78c142b011ed4eb7332d9f5ba360b95a65f3698e66f8a4cc7e6d94cf2fc03b",
2
+ "version": "0.1.277",
3
+ "gitSha": "94f0aa6",
4
+ "tarballSha256": "8f21d60a29f5d90c10ee365a549d36d3a10da713132cc6b03943421f8b4dadbb",
5
5
  "repo": "cdlconsultants/deleted-ai",
6
6
  "tarballPrefix": "deleted-linux-arm64",
7
7
  "releaseTagPrefix": "npm-v"