@hasna/models 0.0.1 → 0.0.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/dist/cli/index.js CHANGED
@@ -2574,13 +2574,13 @@ var source_default = chalk;
2574
2574
 
2575
2575
  // src/cli/index.ts
2576
2576
  import { randomUUID as randomUUID2 } from "crypto";
2577
- import { existsSync, readFileSync as readFileSync2, rmSync, statSync } from "fs";
2577
+ import { existsSync, readFileSync as readFileSync2, rmSync, statSync as statSync2 } from "fs";
2578
2578
  import { dirname as dirname4, join as join3 } from "path";
2579
2579
  import { fileURLToPath } from "url";
2580
2580
 
2581
2581
  // src/version.ts
2582
2582
  function getPackageVersion() {
2583
- return "0.0.1";
2583
+ return "0.0.2";
2584
2584
  }
2585
2585
 
2586
2586
  // src/auth.ts
@@ -2778,7 +2778,7 @@ function safePathSegment(value) {
2778
2778
  }
2779
2779
 
2780
2780
  // src/huggingface.ts
2781
- import { createWriteStream, mkdirSync as mkdirSync2, renameSync, unlinkSync } from "fs";
2781
+ import { createWriteStream, mkdirSync as mkdirSync2, renameSync, statSync, unlinkSync } from "fs";
2782
2782
  import { dirname as dirname2, isAbsolute, join as join2, resolve, sep } from "path";
2783
2783
  import { pipeline } from "stream/promises";
2784
2784
  import { Readable } from "stream";
@@ -3045,8 +3045,11 @@ async function downloadPlannedFiles(plan) {
3045
3045
  }
3046
3046
  try {
3047
3047
  await pipeline(Readable.fromWeb(response.body), createWriteStream(tempDestination));
3048
+ const bytes = statSync(tempDestination).size;
3049
+ if (file.size != null && bytes !== file.size) {
3050
+ throw new Error(`Downloaded size mismatch for ${file.path}: expected ${file.size} bytes, got ${bytes}`);
3051
+ }
3048
3052
  renameSync(tempDestination, destination);
3049
- const bytes = file.size ?? Bun.file(destination).size;
3050
3053
  downloaded.push({ path: file.path, bytes, destination });
3051
3054
  } catch (error) {
3052
3055
  try {
@@ -3314,8 +3317,11 @@ function planBlockedReason(plan) {
3314
3317
  return null;
3315
3318
  }
3316
3319
  function parsePositiveInt(value) {
3317
- const parsed = Number.parseInt(value, 10);
3318
- if (!Number.isFinite(parsed) || parsed < 1)
3320
+ const trimmed = value.trim();
3321
+ if (!/^\d+$/.test(trimmed))
3322
+ throw new Error(`Expected a positive integer, got ${value}`);
3323
+ const parsed = Number(trimmed);
3324
+ if (!Number.isSafeInteger(parsed) || parsed < 1)
3319
3325
  throw new Error(`Expected a positive integer, got ${value}`);
3320
3326
  return parsed;
3321
3327
  }
@@ -3730,7 +3736,7 @@ program2.command("goals").description("Print the implementation goal chain").opt
3730
3736
  const path = join3(cliDir, "..", "..", "docs", "GOALS.md");
3731
3737
  const text = existsSync(path) ? readFileSync2(path, "utf8") : "Goal chain not found.";
3732
3738
  if (isJson(opts)) {
3733
- printJson({ path, bytes: existsSync(path) ? statSync(path).size : 0, text });
3739
+ printJson({ path, bytes: existsSync(path) ? statSync2(path).size : 0, text });
3734
3740
  } else {
3735
3741
  console.log(text);
3736
3742
  }
package/dist/index.js CHANGED
@@ -424,7 +424,7 @@ function saveHuggingFaceSecretRef(secretKey) {
424
424
  return redactAuthStatus({ provider: "huggingface", available: Boolean(readSecret(secretKey)), source: "secrets", secretKey });
425
425
  }
426
426
  // src/huggingface.ts
427
- import { createWriteStream, mkdirSync as mkdirSync3, renameSync, unlinkSync } from "fs";
427
+ import { createWriteStream, mkdirSync as mkdirSync3, renameSync, statSync, unlinkSync } from "fs";
428
428
  import { dirname as dirname3, isAbsolute, join as join2, resolve, sep } from "path";
429
429
  import { pipeline } from "stream/promises";
430
430
  import { Readable } from "stream";
@@ -691,8 +691,11 @@ async function downloadPlannedFiles(plan) {
691
691
  }
692
692
  try {
693
693
  await pipeline(Readable.fromWeb(response.body), createWriteStream(tempDestination));
694
+ const bytes = statSync(tempDestination).size;
695
+ if (file.size != null && bytes !== file.size) {
696
+ throw new Error(`Downloaded size mismatch for ${file.path}: expected ${file.size} bytes, got ${bytes}`);
697
+ }
694
698
  renameSync(tempDestination, destination);
695
- const bytes = file.size ?? Bun.file(destination).size;
696
699
  downloaded.push({ path: file.path, bytes, destination });
697
700
  } catch (error) {
698
701
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/models",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "CLI-first local model and dataset lifecycle tool for open-source/open-weight catalogs",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",