@openplan/dsh-fuse 0.2.0 → 0.2.2

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/dist/connect.js +18 -2
  2. package/package.json +3 -3
package/dist/connect.js CHANGED
@@ -16,6 +16,7 @@
16
16
  * code (like `gh auth login -c`).
17
17
  */
18
18
  import { spawnSync } from "node:child_process";
19
+ import { realpathSync } from "node:fs";
19
20
  import { saveCredentials } from "./credentials.js";
20
21
  const DEFAULT_BASE_URL = "https://dsh-api.openplan.cc";
21
22
  const POLL_INTERVAL_MS = 5_000;
@@ -149,8 +150,23 @@ async function main(argv) {
149
150
  }
150
151
  // Run only when executed directly (`node dist/connect.js` / the bin entry),
151
152
  // never when the module is imported by the plugin or tests.
152
- const isDirectRun = process.argv[1] !== undefined &&
153
- import.meta.url === new URL(`file://${process.argv[1]}`).href;
153
+ //
154
+ // npm installs bins as SYMLINKS into node_modules/.bin/: node's argv[1] is
155
+ // then the symlink path while import.meta.url is the resolved real file, so
156
+ // a naive string compare would silently skip main() — the connect command
157
+ // would exit 0 and do nothing. Reconcile both sides through realpath.
158
+ const isDirectRun = (() => {
159
+ if (process.argv[1] === undefined)
160
+ return false;
161
+ try {
162
+ return (import.meta.url === new URL(`file://${process.argv[1]}`).href ||
163
+ import.meta.url ===
164
+ new URL(`file://${realpathSync(process.argv[1])}`).href);
165
+ }
166
+ catch {
167
+ return false;
168
+ }
169
+ })();
154
170
  if (isDirectRun) {
155
171
  main(process.argv.slice(2)).catch((error) => {
156
172
  console.error(`conexão falhou: ${error instanceof Error ? error.message : String(error)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openplan/dsh-fuse",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Cost policy for the DeepSeek Harness: per-call metering plus a local fuse that enforces budget, model and reasoning-effort limits before any token is spent.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -34,7 +34,7 @@
34
34
  "cordis"
35
35
  ],
36
36
  "scripts": {
37
- "build": "tsc -p tsconfig.build.json",
37
+ "build": "tsc -p tsconfig.build.json && chmod +x dist/connect.js",
38
38
  "typecheck": "tsc --noEmit",
39
39
  "test": "vitest run",
40
40
  "prepublishOnly": "pnpm build"
@@ -62,6 +62,6 @@
62
62
  "vitest": "^3.1.0"
63
63
  },
64
64
  "bin": {
65
- "dsh-fuse-connect": "./dist/connect.js"
65
+ "dsh-fuse-connect": "dist/connect.js"
66
66
  }
67
67
  }