wormclaude 1.0.0
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 +147 -0
- package/dist/agent.js +61 -0
- package/dist/api.js +163 -0
- package/dist/auth.js +108 -0
- package/dist/cli.js +851 -0
- package/dist/commands.js +540 -0
- package/dist/compact.js +53 -0
- package/dist/i18n.js +177 -0
- package/dist/learn.js +47 -0
- package/dist/links.js +31 -0
- package/dist/mcp.js +104 -0
- package/dist/memory.js +135 -0
- package/dist/skills.js +275 -0
- package/dist/tasks.js +63 -0
- package/dist/theme.js +11 -0
- package/dist/tips.js +60 -0
- package/dist/toolSummary.js +24 -0
- package/dist/tools.js +1136 -0
- package/dist/usage.js +71 -0
- package/package.json +44 -0
package/dist/usage.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Billing / kullanım ölçümü — aylık abonelik için çekirdek.
|
|
2
|
+
// Her istekte usage (token) yakalanır, model bazlı maliyet hesaplanır,
|
|
3
|
+
// oturum + kümülatif toplamlar .wormclaude/usage.json'a yazılır.
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
// 1M token başına USD. Yerel model için 0; ticari satışta kendi fiyatını koy.
|
|
7
|
+
// Örnek: bir bulut modeli ekleyeceksen { in: 3, out: 15 } gibi.
|
|
8
|
+
const PRICING = {
|
|
9
|
+
wormclaude: { in: 0, out: 0 },
|
|
10
|
+
default: { in: 0, out: 0 },
|
|
11
|
+
};
|
|
12
|
+
export function setPricing(model, p) {
|
|
13
|
+
PRICING[model] = p;
|
|
14
|
+
}
|
|
15
|
+
function priceFor(model) {
|
|
16
|
+
return PRICING[model] || PRICING.default;
|
|
17
|
+
}
|
|
18
|
+
export function approxTokens(obj) {
|
|
19
|
+
return Math.round(JSON.stringify(obj).length / 4);
|
|
20
|
+
}
|
|
21
|
+
const empty = () => ({ requests: 0, input: 0, output: 0, cacheRead: 0, costUSD: 0 });
|
|
22
|
+
const session = empty();
|
|
23
|
+
let lifetime = empty();
|
|
24
|
+
const USAGE_FILE = path.join(process.cwd(), '.wormclaude', 'usage.json');
|
|
25
|
+
function loadLifetime() {
|
|
26
|
+
try {
|
|
27
|
+
lifetime = { ...empty(), ...JSON.parse(fs.readFileSync(USAGE_FILE, 'utf8')) };
|
|
28
|
+
}
|
|
29
|
+
catch { }
|
|
30
|
+
}
|
|
31
|
+
loadLifetime();
|
|
32
|
+
function persist() {
|
|
33
|
+
try {
|
|
34
|
+
fs.mkdirSync(path.dirname(USAGE_FILE), { recursive: true });
|
|
35
|
+
fs.writeFileSync(USAGE_FILE, JSON.stringify(lifetime, null, 2));
|
|
36
|
+
}
|
|
37
|
+
catch { }
|
|
38
|
+
}
|
|
39
|
+
function costOf(model, u) {
|
|
40
|
+
const p = priceFor(model);
|
|
41
|
+
const billedInput = Math.max(0, u.input - u.cacheRead);
|
|
42
|
+
return ((billedInput * p.in + u.cacheRead * (p.cacheIn ?? p.in) + u.output * p.out) / 1_000_000);
|
|
43
|
+
}
|
|
44
|
+
// Bir istek tamamlandığında çağrılır.
|
|
45
|
+
export function record(model, u) {
|
|
46
|
+
if (!u)
|
|
47
|
+
return;
|
|
48
|
+
const cost = costOf(model, u);
|
|
49
|
+
for (const t of [session, lifetime]) {
|
|
50
|
+
t.requests += 1;
|
|
51
|
+
t.input += u.input;
|
|
52
|
+
t.output += u.output;
|
|
53
|
+
t.cacheRead += u.cacheRead;
|
|
54
|
+
t.costUSD += cost;
|
|
55
|
+
}
|
|
56
|
+
persist();
|
|
57
|
+
}
|
|
58
|
+
export function getSession() { return { ...session }; }
|
|
59
|
+
export function getLifetime() { return { ...lifetime }; }
|
|
60
|
+
// Oturum bütçe limiti (USD). 0 = sınırsız. Ticari: müşteri başına maliyet tavanı.
|
|
61
|
+
const BUDGET_USD = Number(process.env.WORMCLAUDE_BUDGET_USD) || 0;
|
|
62
|
+
export function getBudget() { return BUDGET_USD; }
|
|
63
|
+
export function isOverBudget() {
|
|
64
|
+
return BUDGET_USD > 0 && session.costUSD >= BUDGET_USD;
|
|
65
|
+
}
|
|
66
|
+
export function formatTotals(t) {
|
|
67
|
+
return (`istek: ${t.requests}\n` +
|
|
68
|
+
`girdi: ${t.input.toLocaleString()} tok (cache: ${t.cacheRead.toLocaleString()})\n` +
|
|
69
|
+
`çıktı: ${t.output.toLocaleString()} tok\n` +
|
|
70
|
+
`maliyet: $${t.costUSD.toFixed(4)}`);
|
|
71
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "wormclaude",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "WormClaude CLI - uncensored security+code assistant (ink TUI, Claude-style)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"wormclaude": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "tsx src/cli.tsx",
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"start": "node dist/cli.js",
|
|
13
|
+
"prepublishOnly": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
17
|
+
"ink": "^5.0.1",
|
|
18
|
+
"ink-spinner": "^5.0.0",
|
|
19
|
+
"ink-text-input": "^6.0.0",
|
|
20
|
+
"react": "^18.3.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^22.10.2",
|
|
24
|
+
"@types/react": "^18.3.18",
|
|
25
|
+
"tsx": "^4.19.2",
|
|
26
|
+
"typescript": "^5.7.2"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"keywords": [
|
|
37
|
+
"wormclaude",
|
|
38
|
+
"cli",
|
|
39
|
+
"ai",
|
|
40
|
+
"assistant",
|
|
41
|
+
"agent",
|
|
42
|
+
"terminal"
|
|
43
|
+
]
|
|
44
|
+
}
|