traderclaw-cli 1.0.51
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/bin/cli.ts +629 -0
- package/bin/gateway-persistence-linux.mjs +275 -0
- package/bin/installer-step-engine.mjs +2029 -0
- package/bin/llm-model-preference.mjs +229 -0
- package/bin/openclaw-trader.mjs +3148 -0
- package/bin/resolve-plugin-root.mjs +37 -0
- package/bin/traderclaw.cjs +13 -0
- package/package.json +34 -0
- package/scripts/sync-bin.mjs +30 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the solana-traderclaw package root (directory containing openclaw.plugin.json).
|
|
3
|
+
*
|
|
4
|
+
* - When bin/ lives inside the plugin package (git clone), parent of bin/ is the root.
|
|
5
|
+
* - When bin/ ships in a separate CLI package (traderclaw-cli), resolve via node_modules.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync } from "fs";
|
|
8
|
+
import { dirname, join } from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
import { createRequire } from "module";
|
|
11
|
+
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
|
|
14
|
+
export function resolvePluginPackageRoot(fromImportMetaUrl) {
|
|
15
|
+
const binDir = dirname(fileURLToPath(fromImportMetaUrl));
|
|
16
|
+
const parent = join(binDir, "..");
|
|
17
|
+
if (existsSync(join(parent, "openclaw.plugin.json"))) {
|
|
18
|
+
return parent;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
// `package.json` "exports" often omits `./package.json` — resolve the main entry instead.
|
|
22
|
+
const entry = require.resolve("solana-traderclaw");
|
|
23
|
+
let dir = dirname(entry);
|
|
24
|
+
for (let i = 0; i < 8; i++) {
|
|
25
|
+
if (existsSync(join(dir, "openclaw.plugin.json"))) return dir;
|
|
26
|
+
const parent = dirname(dir);
|
|
27
|
+
if (parent === dir) break;
|
|
28
|
+
dir = parent;
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
// fall through
|
|
32
|
+
}
|
|
33
|
+
throw new Error(
|
|
34
|
+
"Could not find the solana-traderclaw package. Install the CLI with its dependency " +
|
|
35
|
+
"(npm install -g traderclaw-cli) or install solana-traderclaw next to this tool.",
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* npm `bin` entry for global `traderclaw`. Delegates to `openclaw-trader.mjs` with argv preserved.
|
|
4
|
+
* Uses .cjs so npm does not strip the bin link when `package.json` has `"type": "module"`.
|
|
5
|
+
*/
|
|
6
|
+
const { spawnSync } = require("node:child_process");
|
|
7
|
+
const path = require("node:path");
|
|
8
|
+
const script = path.join(__dirname, "openclaw-trader.mjs");
|
|
9
|
+
const result = spawnSync(process.execPath, [script, ...process.argv.slice(2)], {
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
env: process.env,
|
|
12
|
+
});
|
|
13
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "traderclaw-cli",
|
|
3
|
+
"version": "1.0.51",
|
|
4
|
+
"description": "Global TraderClaw CLI (install --wizard, setup, precheck). Installs solana-traderclaw as a dependency for OpenClaw plugin files.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"traderclaw": "bin/traderclaw.cjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"scripts"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"prepare": "node scripts/sync-bin.mjs"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=22"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"solana-traderclaw": "^1.0.51"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"traderclaw",
|
|
24
|
+
"openclaw",
|
|
25
|
+
"solana",
|
|
26
|
+
"cli"
|
|
27
|
+
],
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/david021903/traderClaw_plugin.git",
|
|
32
|
+
"directory": "cli"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy repo-root bin/ into cli/bin/ for the traderclaw-cli package.
|
|
3
|
+
* Runs on prepare when developing from the monorepo; skipped when installing from npm (bin/ already packed).
|
|
4
|
+
*/
|
|
5
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, statSync } from "fs";
|
|
6
|
+
import { dirname, join } from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const rootBin = join(__dirname, "..", "..", "bin");
|
|
11
|
+
const destBin = join(__dirname, "..", "bin");
|
|
12
|
+
|
|
13
|
+
function copyRecursive(src, dest) {
|
|
14
|
+
mkdirSync(dest, { recursive: true });
|
|
15
|
+
for (const name of readdirSync(src)) {
|
|
16
|
+
const s = join(src, name);
|
|
17
|
+
const d = join(dest, name);
|
|
18
|
+
if (statSync(s).isDirectory()) copyRecursive(s, d);
|
|
19
|
+
else cpSync(s, d);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (existsSync(rootBin)) {
|
|
24
|
+
copyRecursive(rootBin, destBin);
|
|
25
|
+
console.log("traderclaw-cli: synced bin/ from repo root");
|
|
26
|
+
} else if (!existsSync(join(destBin, "openclaw-trader.mjs"))) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
"traderclaw-cli: bin scripts missing. Run `node scripts/sync-bin.mjs` from a full repo checkout before pack, or install from npm.",
|
|
29
|
+
);
|
|
30
|
+
}
|