tokensfun 0.1.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/bin/tokensfun.js +90 -0
- package/package.json +12 -0
package/bin/tokensfun.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* tokensfun — set up tokens.fun products for your coding agent.
|
|
4
|
+
*
|
|
5
|
+
* npx tokensfun add eleven install a product's SKILL.md into your agents
|
|
6
|
+
* npx tokensfun list show available products
|
|
7
|
+
*/
|
|
8
|
+
import { mkdirSync, writeFileSync, existsSync, readFileSync, appendFileSync } from "node:fs";
|
|
9
|
+
import { homedir } from "node:os";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
|
|
12
|
+
const PRODUCTS = {
|
|
13
|
+
eleven: {
|
|
14
|
+
url: "https://eleven.tokens.fun",
|
|
15
|
+
blurb: "pay-per-call ElevenLabs-quality text-to-speech (USDC on Base via x402)",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const [, , cmd, name] = process.argv;
|
|
20
|
+
|
|
21
|
+
function list() {
|
|
22
|
+
console.log("\ntokens.fun products:\n");
|
|
23
|
+
for (const [key, p] of Object.entries(PRODUCTS)) {
|
|
24
|
+
console.log(` ${key.padEnd(10)} ${p.blurb}`);
|
|
25
|
+
console.log(` ${"".padEnd(10)} ${p.url}\n`);
|
|
26
|
+
}
|
|
27
|
+
console.log("install one: npx tokensfun add <name>\n");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function add(productName) {
|
|
31
|
+
const product = PRODUCTS[productName];
|
|
32
|
+
if (!product) {
|
|
33
|
+
console.error(`unknown product "${productName}" — run \`npx tokensfun list\``);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const skillUrl = `${product.url}/SKILL.md`;
|
|
38
|
+
process.stdout.write(`fetching ${skillUrl} ... `);
|
|
39
|
+
const res = await fetch(skillUrl);
|
|
40
|
+
if (!res.ok) {
|
|
41
|
+
console.error(`failed (HTTP ${res.status})`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
const skill = await res.text();
|
|
45
|
+
console.log("ok");
|
|
46
|
+
|
|
47
|
+
const installed = [];
|
|
48
|
+
|
|
49
|
+
// Claude Code — global skills directory
|
|
50
|
+
const claudeDir = join(homedir(), ".claude", "skills", productName);
|
|
51
|
+
mkdirSync(claudeDir, { recursive: true });
|
|
52
|
+
writeFileSync(join(claudeDir, "SKILL.md"), skill);
|
|
53
|
+
installed.push(`Claude Code ~/.claude/skills/${productName}/SKILL.md`);
|
|
54
|
+
|
|
55
|
+
// Cursor — project rules, only when run inside a Cursor project
|
|
56
|
+
if (existsSync(join(process.cwd(), ".cursor"))) {
|
|
57
|
+
const rulesDir = join(process.cwd(), ".cursor", "rules");
|
|
58
|
+
mkdirSync(rulesDir, { recursive: true });
|
|
59
|
+
writeFileSync(join(rulesDir, `${productName}.md`), skill);
|
|
60
|
+
installed.push(`Cursor .cursor/rules/${productName}.md`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// AGENTS.md — append a section if the project uses one and doesn't have it yet
|
|
64
|
+
const agentsPath = join(process.cwd(), "AGENTS.md");
|
|
65
|
+
if (existsSync(agentsPath)) {
|
|
66
|
+
const marker = `<!-- tokensfun:${productName} -->`;
|
|
67
|
+
if (!readFileSync(agentsPath, "utf8").includes(marker)) {
|
|
68
|
+
appendFileSync(agentsPath, `\n\n${marker}\n${skill}\n`);
|
|
69
|
+
installed.push(`AGENTS.md section appended`);
|
|
70
|
+
} else {
|
|
71
|
+
installed.push(`AGENTS.md already installed, skipped`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
console.log(`\ninstalled "${productName}" for:\n`);
|
|
76
|
+
for (const line of installed) console.log(` ${line}`);
|
|
77
|
+
console.log(`\nyour agent now knows how to use ${product.url} — try asking it to generate speech.\n`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (cmd === "add" && name) {
|
|
81
|
+
add(name).catch((err) => {
|
|
82
|
+
console.error(err.message ?? err);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
});
|
|
85
|
+
} else if (cmd === "list" || cmd === undefined) {
|
|
86
|
+
list();
|
|
87
|
+
} else {
|
|
88
|
+
console.error(`usage:\n npx tokensfun add <name>\n npx tokensfun list`);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tokensfun",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Set up tokens.fun products for your coding agent — installs agent-readable SKILL.md context into Claude Code, Cursor, and AGENTS.md.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": { "tokensfun": "bin/tokensfun.js" },
|
|
7
|
+
"files": ["bin"],
|
|
8
|
+
"engines": { "node": ">=18" },
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"homepage": "https://tokens.fun",
|
|
11
|
+
"keywords": ["tokens.fun", "x402", "agent", "skill", "claude-code", "tts"]
|
|
12
|
+
}
|