@9000ai/cli 0.1.0 → 0.3.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/dist/commands/skill.d.ts +2 -0
- package/dist/commands/skill.js +89 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -1
- package/package.json +2 -2
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync } from "fs";
|
|
2
|
+
import { homedir } from "os";
|
|
3
|
+
import { join, resolve } from "path";
|
|
4
|
+
const SKILLS_DIR = join(homedir(), ".9000ai", "skills");
|
|
5
|
+
function getSkillPath(name) {
|
|
6
|
+
return resolve(SKILLS_DIR, name, "SKILL.md");
|
|
7
|
+
}
|
|
8
|
+
export function registerSkillCommands(program) {
|
|
9
|
+
const skill = program.command("skill").description("Skill management");
|
|
10
|
+
// 9000ai skill list
|
|
11
|
+
skill
|
|
12
|
+
.command("list")
|
|
13
|
+
.description("List all installed skills")
|
|
14
|
+
.action(() => {
|
|
15
|
+
if (!existsSync(SKILLS_DIR)) {
|
|
16
|
+
console.log("No skills installed. Run: npm install -g @9000ai/cli");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const dirs = readdirSync(SKILLS_DIR).filter((d) => existsSync(join(SKILLS_DIR, d, "SKILL.md")));
|
|
21
|
+
if (dirs.length === 0) {
|
|
22
|
+
console.log("No skills found.");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
console.log(`Installed skills (${SKILLS_DIR}):\n`);
|
|
26
|
+
dirs.forEach((d) => {
|
|
27
|
+
const path = join(SKILLS_DIR, d, "SKILL.md");
|
|
28
|
+
let description = "";
|
|
29
|
+
try {
|
|
30
|
+
const content = readFileSync(path, "utf-8");
|
|
31
|
+
const match = content.match(/^description:\s*(.+)$/m);
|
|
32
|
+
description = match ? match[1] : "";
|
|
33
|
+
}
|
|
34
|
+
catch { }
|
|
35
|
+
console.log(` ${d.padEnd(30)} ${description}`);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
console.error("Failed to list skills:", err);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
// 9000ai skill load <name>
|
|
43
|
+
skill
|
|
44
|
+
.command("load <name>")
|
|
45
|
+
.description("Load and print a skill's SKILL.md content to stdout")
|
|
46
|
+
.action((name) => {
|
|
47
|
+
const skillPath = getSkillPath(name);
|
|
48
|
+
if (!existsSync(SKILLS_DIR)) {
|
|
49
|
+
console.error(`Error: Skills directory not found at ${SKILLS_DIR}\n` +
|
|
50
|
+
`Run: npm install -g @9000ai/cli`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
if (!existsSync(skillPath)) {
|
|
54
|
+
// Try fuzzy match
|
|
55
|
+
const available = readdirSync(SKILLS_DIR).filter((d) => existsSync(join(SKILLS_DIR, d, "SKILL.md")));
|
|
56
|
+
const matches = available.filter((d) => d.toLowerCase().includes(name.toLowerCase()));
|
|
57
|
+
if (matches.length === 1) {
|
|
58
|
+
const realPath = getSkillPath(matches[0]);
|
|
59
|
+
const content = readFileSync(realPath, "utf-8");
|
|
60
|
+
console.log(content);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
console.error(`Error: Skill '${name}' not found at ${skillPath}`);
|
|
64
|
+
if (available.length > 0) {
|
|
65
|
+
console.error(`\nAvailable skills: ${available.join(", ")}`);
|
|
66
|
+
console.error(`\nUsage: 9000ai skill load <name>\n` +
|
|
67
|
+
`Example: 9000ai skill load douyin-topic-discovery`);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
console.error(`\nNo skills installed. Run: npm install -g @9000ai/cli`);
|
|
71
|
+
}
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
const content = readFileSync(skillPath, "utf-8");
|
|
75
|
+
console.log(content);
|
|
76
|
+
});
|
|
77
|
+
// 9000ai skill path [name]
|
|
78
|
+
skill
|
|
79
|
+
.command("path [name]")
|
|
80
|
+
.description("Show skill directory path. No arg = skills root, name = specific skill path")
|
|
81
|
+
.action((name) => {
|
|
82
|
+
if (name) {
|
|
83
|
+
console.log(getSkillPath(name));
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
console.log(SKILLS_DIR);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
import { Command } from "commander";
|
|
3
2
|
import { registerConfigCommands } from "./commands/config.js";
|
|
4
3
|
import { registerAuthCommands } from "./commands/auth.js";
|
|
@@ -7,6 +6,7 @@ import { registerMonitorCommands } from "./commands/monitor.js";
|
|
|
7
6
|
import { registerTranscribeCommands } from "./commands/transcribe.js";
|
|
8
7
|
import { registerTaskCommands } from "./commands/task.js";
|
|
9
8
|
import { registerFeedbackCommands } from "./commands/feedback.js";
|
|
9
|
+
import { registerSkillCommands } from "./commands/skill.js";
|
|
10
10
|
const program = new Command();
|
|
11
11
|
program
|
|
12
12
|
.name("9000ai")
|
|
@@ -19,6 +19,7 @@ registerMonitorCommands(program);
|
|
|
19
19
|
registerTranscribeCommands(program);
|
|
20
20
|
registerTaskCommands(program);
|
|
21
21
|
registerFeedbackCommands(program);
|
|
22
|
+
registerSkillCommands(program);
|
|
22
23
|
program.parseAsync(process.argv).catch((err) => {
|
|
23
24
|
console.error(err);
|
|
24
25
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@9000ai/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "9000AI Toolbox CLI — unified command-line interface for 9000AI platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"9000ai": "./dist/index
|
|
7
|
+
"9000ai": "./dist/index"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc",
|