cclaw-cli 8.1.1 → 8.1.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.
package/dist/cli.js CHANGED
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env node
2
+ import path from "node:path";
3
+ import { realpathSync } from "node:fs";
4
+ import { fileURLToPath } from "node:url";
2
5
  import { CCLAW_VERSION } from "./constants.js";
3
6
  import { initCclaw, syncCclaw, uninstallCclaw, upgradeCclaw } from "./install.js";
4
7
  import { configureLogger, error as logError, info } from "./logger.js";
@@ -112,8 +115,36 @@ export async function runCli(argv, context) {
112
115
  return 2;
113
116
  }
114
117
  }
115
- const isMain = import.meta.url === `file://${process.argv[1]}`;
116
- if (isMain) {
118
+ /**
119
+ * True when this module is the program entry point. Resolves both the
120
+ * argv[1] path and the import.meta.url to their realpath because:
121
+ * - `npx cclaw-cli` invokes the CLI through a symlink under
122
+ * `~/.npm/_npx/<hash>/node_modules/.bin/cclaw-cli` that points at the
123
+ * real `dist/cli.js`. argv[1] keeps the symlink path, but
124
+ * import.meta.url resolves through to the real file. The naive
125
+ * `import.meta.url === \`file://${argv[1]}\`` check returns false in
126
+ * this case and the CLI silently exits 0 without doing anything.
127
+ * - On macOS `/tmp` is a symlink to `/private/tmp`, which produces the
128
+ * same mismatch even when no user-level symlink is involved.
129
+ * - `npm install -g cclaw-cli` creates a similar symlink in the global
130
+ * bin directory.
131
+ *
132
+ * Mirrors the v7.x `isDirectExecution()` check that is known to work
133
+ * across npx, global installs, and macOS path normalisation.
134
+ */
135
+ function isDirectExecution() {
136
+ if (!process.argv[1])
137
+ return false;
138
+ try {
139
+ const entryPath = realpathSync(path.resolve(process.argv[1]));
140
+ const modulePath = realpathSync(fileURLToPath(import.meta.url));
141
+ return entryPath === modulePath;
142
+ }
143
+ catch {
144
+ return false;
145
+ }
146
+ }
147
+ if (isDirectExecution()) {
117
148
  runCli(process.argv.slice(2), { cwd: process.cwd(), stdout: process.stdout, stderr: process.stderr })
118
149
  .then((code) => {
119
150
  process.exit(code);
@@ -1,4 +1,4 @@
1
- export declare const CCLAW_VERSION = "8.1.1";
1
+ export declare const CCLAW_VERSION = "8.1.2";
2
2
  export declare const RUNTIME_ROOT = ".cclaw";
3
3
  export declare const STATE_REL_PATH = ".cclaw/state";
4
4
  export declare const HOOKS_REL_PATH = ".cclaw/hooks";
package/dist/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const CCLAW_VERSION = "8.1.1";
1
+ export const CCLAW_VERSION = "8.1.2";
2
2
  export const RUNTIME_ROOT = ".cclaw";
3
3
  export const STATE_REL_PATH = `${RUNTIME_ROOT}/state`;
4
4
  export const HOOKS_REL_PATH = `${RUNTIME_ROOT}/hooks`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cclaw-cli",
3
- "version": "8.1.1",
3
+ "version": "8.1.2",
4
4
  "description": "Lightweight harness-first flow toolkit for coding agents",
5
5
  "type": "module",
6
6
  "bin": {