@0dai-dev/cli 4.3.4 → 4.3.5
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/README.md +75 -12
- package/bin/0dai.js +10 -1
- package/lib/commands/auth.js +9 -6
- package/lib/commands/doctor.js +20 -1
- package/lib/commands/init.js +64 -0
- package/lib/commands/run.js +61 -4
- package/lib/commands/status.js +4 -0
- package/lib/commands/upgrade.js +58 -0
- package/lib/utils/activation_telemetry.js +156 -0
- package/lib/utils/constants.js +7 -0
- package/lib/utils/plan.js +10 -0
- package/lib/utils/run_cost.js +91 -0
- package/package.json +7 -3
- package/lib/tui/index.mjs +0 -34994
package/lib/utils/constants.js
CHANGED
|
@@ -46,6 +46,13 @@ const SUPPORTED_CLIS = [
|
|
|
46
46
|
altAuth: null,
|
|
47
47
|
agentFiles: [".qoder/settings.json"],
|
|
48
48
|
},
|
|
49
|
+
{
|
|
50
|
+
name: "cursor", bin: "cursor-agent",
|
|
51
|
+
pkg: null, pkgType: "curl",
|
|
52
|
+
install: "curl https://cursor.com/install -fsS | bash",
|
|
53
|
+
altAuth: "Cursor Pro/Business subscription",
|
|
54
|
+
agentFiles: [".cursor/mcp.json", ".cursor/hooks.json"],
|
|
55
|
+
},
|
|
49
56
|
];
|
|
50
57
|
|
|
51
58
|
const MANIFEST_FILES = [
|
package/lib/utils/plan.js
CHANGED
|
@@ -12,6 +12,15 @@ const PLAN_LEVELS = { trial: 0, free: 0, essential: 1, pro: 2, team: 3, enterpri
|
|
|
12
12
|
const UPGRADE_URL = "https://0dai.dev/pricing";
|
|
13
13
|
const TEAM_UPGRADE_MESSAGE = `This requires the Team tier. Upgrade at ${UPGRADE_URL}`;
|
|
14
14
|
|
|
15
|
+
function buildUpgradeUrl(params = {}) {
|
|
16
|
+
const url = new URL(UPGRADE_URL);
|
|
17
|
+
const merged = { source: "cli", utm: "upgrade", ...params };
|
|
18
|
+
for (const [key, value] of Object.entries(merged)) {
|
|
19
|
+
if (value != null && value !== "") url.searchParams.set(key, String(value));
|
|
20
|
+
}
|
|
21
|
+
return url.toString();
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
function _readAuthPlan() {
|
|
16
25
|
const authFile = path.join(os.homedir(), ".0dai", "auth.json");
|
|
17
26
|
if (!fs.existsSync(authFile)) return null;
|
|
@@ -100,6 +109,7 @@ function getSwarmQuotaLocal(target) {
|
|
|
100
109
|
module.exports = {
|
|
101
110
|
PLAN_LEVELS,
|
|
102
111
|
UPGRADE_URL,
|
|
112
|
+
buildUpgradeUrl,
|
|
103
113
|
TEAM_UPGRADE_MESSAGE,
|
|
104
114
|
_readAuthPlan,
|
|
105
115
|
_detectPlanLocal,
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Rough planning defaults aligned with scripts/swarm_lib.py tier heuristics.
|
|
4
|
+
const TIER_TOKEN_BUDGET = {
|
|
5
|
+
fast: 8000,
|
|
6
|
+
balanced: 24000,
|
|
7
|
+
deep: 64000,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// Blended $/1k tokens (input+output mix) for agent × tier routing.
|
|
11
|
+
const AGENT_TIER_USD_PER_1K = {
|
|
12
|
+
claude: { fast: 0.002, balanced: 0.006, deep: 0.025 },
|
|
13
|
+
codex: { fast: 0.001, balanced: 0.004, deep: 0.012 },
|
|
14
|
+
gemini: { fast: 0.0005, balanced: 0.002, deep: 0.008 },
|
|
15
|
+
deepseek: { fast: 0.0002, balanced: 0.0006, deep: 0.002 },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Provider overrides map to a single blended rate regardless of tier.
|
|
19
|
+
const PROVIDER_USD_PER_1K = {
|
|
20
|
+
deepseek: 0.0003,
|
|
21
|
+
"gemini-direct": 0.002,
|
|
22
|
+
codex: 0.004,
|
|
23
|
+
"claude-opus": 0.025,
|
|
24
|
+
"claude-sonnet": 0.006,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function normalizeTier(tier) {
|
|
28
|
+
const key = String(tier || "").trim().toLowerCase();
|
|
29
|
+
return TIER_TOKEN_BUDGET[key] ? key : "balanced";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function resolveUsdPer1k(agent, tier, providerOverride) {
|
|
33
|
+
if (providerOverride && PROVIDER_USD_PER_1K[providerOverride] != null) {
|
|
34
|
+
return PROVIDER_USD_PER_1K[providerOverride];
|
|
35
|
+
}
|
|
36
|
+
const agentRates = AGENT_TIER_USD_PER_1K[agent] || AGENT_TIER_USD_PER_1K.claude;
|
|
37
|
+
return agentRates[tier] ?? agentRates.balanced;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function estimateTaskCost(task, options = {}) {
|
|
41
|
+
const agent = options.resolveAgent(task);
|
|
42
|
+
const tier = normalizeTier(task.model_tier);
|
|
43
|
+
const tokens = TIER_TOKEN_BUDGET[tier];
|
|
44
|
+
const usdPer1k = resolveUsdPer1k(agent, tier, options.providerOverride);
|
|
45
|
+
const estimatedUsd = (tokens / 1000) * usdPer1k;
|
|
46
|
+
return {
|
|
47
|
+
title: task.title || "",
|
|
48
|
+
agent,
|
|
49
|
+
tier,
|
|
50
|
+
tokens,
|
|
51
|
+
usdPer1k,
|
|
52
|
+
estimatedUsd,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function estimateRunCost(tasks, options = {}) {
|
|
57
|
+
const rows = (tasks || []).map((task) => estimateTaskCost(task, options));
|
|
58
|
+
const totalTokens = rows.reduce((sum, row) => sum + row.tokens, 0);
|
|
59
|
+
const totalUsd = rows.reduce((sum, row) => sum + row.estimatedUsd, 0);
|
|
60
|
+
const blendedUsdPer1k = totalTokens > 0 ? (totalUsd / totalTokens) * 1000 : 0;
|
|
61
|
+
return {
|
|
62
|
+
tasks: rows,
|
|
63
|
+
totalTokens,
|
|
64
|
+
totalUsd,
|
|
65
|
+
blendedUsdPer1k,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function formatTokens(n) {
|
|
70
|
+
return Number(n || 0).toLocaleString("en-US");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function formatUsd(n) {
|
|
74
|
+
return `$${Number(n || 0).toFixed(4)}`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function formatUsdPer1k(n) {
|
|
78
|
+
return `$${Number(n || 0).toFixed(4)}/1k`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = {
|
|
82
|
+
TIER_TOKEN_BUDGET,
|
|
83
|
+
AGENT_TIER_USD_PER_1K,
|
|
84
|
+
PROVIDER_USD_PER_1K,
|
|
85
|
+
normalizeTier,
|
|
86
|
+
estimateTaskCost,
|
|
87
|
+
estimateRunCost,
|
|
88
|
+
formatTokens,
|
|
89
|
+
formatUsd,
|
|
90
|
+
formatUsdPer1k,
|
|
91
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0dai-dev/cli",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.5",
|
|
4
4
|
"description": "One config layer for seven AI coding agents — Claude Code, Codex, OpenCode, Gemini, Aider, Qoder",
|
|
5
5
|
"bin": {
|
|
6
6
|
"0dai": "./bin/0dai.js"
|
|
@@ -19,10 +19,14 @@
|
|
|
19
19
|
"cli"
|
|
20
20
|
],
|
|
21
21
|
"author": "0dai-dev <dev@0dai.dev>",
|
|
22
|
-
"license": "
|
|
22
|
+
"license": "Apache-2.0",
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "https://github.com/0dai-dev/0dai"
|
|
25
|
+
"url": "git+https://github.com/0dai-dev/0dai.git",
|
|
26
|
+
"directory": "cli/npm-package"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/0dai-dev/0dai/issues"
|
|
26
30
|
},
|
|
27
31
|
"homepage": "https://0dai.dev",
|
|
28
32
|
"engines": {
|