@aisa-one/cli 0.0.1 → 0.1.1
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 +203 -0
- package/dist/api.d.ts +11 -0
- package/dist/api.js +61 -0
- package/dist/commands/account.d.ts +5 -0
- package/dist/commands/account.js +47 -0
- package/dist/commands/api.d.ts +10 -0
- package/dist/commands/api.js +116 -0
- package/dist/commands/auth.d.ts +5 -0
- package/dist/commands/auth.js +29 -0
- package/dist/commands/chat.d.ts +8 -0
- package/dist/commands/chat.js +78 -0
- package/dist/commands/configCmd.d.ts +4 -0
- package/dist/commands/configCmd.js +36 -0
- package/dist/commands/finance.d.ts +13 -0
- package/dist/commands/finance.js +85 -0
- package/dist/commands/mcp.d.ts +4 -0
- package/dist/commands/mcp.js +67 -0
- package/dist/commands/models.d.ts +4 -0
- package/dist/commands/models.js +65 -0
- package/dist/commands/run.d.ts +7 -0
- package/dist/commands/run.js +70 -0
- package/dist/commands/search.d.ts +9 -0
- package/dist/commands/search.js +43 -0
- package/dist/commands/skills.d.ts +22 -0
- package/dist/commands/skills.js +555 -0
- package/dist/commands/twitter.d.ts +14 -0
- package/dist/commands/twitter.js +85 -0
- package/dist/commands/video.d.ts +9 -0
- package/dist/commands/video.js +73 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.js +56 -0
- package/dist/constants.d.ts +14 -0
- package/dist/constants.js +43 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +291 -0
- package/dist/types.d.ts +100 -0
- package/dist/types.js +1 -0
- package/dist/utils/display.d.ts +8 -0
- package/dist/utils/display.js +33 -0
- package/dist/utils/file.d.ts +12 -0
- package/dist/utils/file.js +70 -0
- package/dist/utils/streaming.d.ts +5 -0
- package/dist/utils/streaming.js +37 -0
- package/package.json +53 -5
- package/index.js +0 -3
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import ora from "ora";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { requireApiKey } from "../config.js";
|
|
4
|
+
import { apiRequest } from "../api.js";
|
|
5
|
+
import { error, success } from "../utils/display.js";
|
|
6
|
+
export async function videoCreateAction(prompt, options) {
|
|
7
|
+
const key = requireApiKey();
|
|
8
|
+
const spinner = ora("Creating video generation task...").start();
|
|
9
|
+
const body = { prompt };
|
|
10
|
+
if (options.model)
|
|
11
|
+
body.model = options.model;
|
|
12
|
+
const res = await apiRequest(key, "services/aigc/video-generation/video-synthesis", {
|
|
13
|
+
method: "POST",
|
|
14
|
+
body,
|
|
15
|
+
});
|
|
16
|
+
if (!res.success || !res.data) {
|
|
17
|
+
spinner.fail("Failed to create video task");
|
|
18
|
+
error(res.error || "Unknown error");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const task = res.data;
|
|
22
|
+
spinner.stop();
|
|
23
|
+
success(`Task created: ${task.taskId}`);
|
|
24
|
+
if (!options.wait) {
|
|
25
|
+
console.log(chalk.gray(` Check status: aisa video status ${task.taskId}`));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// Poll for completion
|
|
29
|
+
const pollSpinner = ora("Generating video...").start();
|
|
30
|
+
let result = task;
|
|
31
|
+
while (result.status === "pending" || result.status === "processing") {
|
|
32
|
+
await new Promise((r) => setTimeout(r, 5000));
|
|
33
|
+
const pollRes = await apiRequest(key, `services/aigc/tasks/${result.taskId}`);
|
|
34
|
+
if (!pollRes.success || !pollRes.data) {
|
|
35
|
+
pollSpinner.fail("Failed to check status");
|
|
36
|
+
error(pollRes.error || "Unknown error");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
result = pollRes.data;
|
|
40
|
+
pollSpinner.text = `Generating video... (${result.status})`;
|
|
41
|
+
}
|
|
42
|
+
if (result.status === "completed") {
|
|
43
|
+
pollSpinner.succeed("Video generated!");
|
|
44
|
+
if (result.resultUrl) {
|
|
45
|
+
console.log(` URL: ${chalk.cyan(result.resultUrl)}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
pollSpinner.fail(`Video generation ${result.status}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export async function videoStatusAction(taskId, options) {
|
|
53
|
+
const key = requireApiKey();
|
|
54
|
+
const spinner = ora("Checking status...").start();
|
|
55
|
+
const res = await apiRequest(key, `services/aigc/tasks/${taskId}`);
|
|
56
|
+
if (!res.success || !res.data) {
|
|
57
|
+
spinner.fail("Failed to check status");
|
|
58
|
+
error(res.error || "Unknown error");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
spinner.stop();
|
|
62
|
+
if (options.raw) {
|
|
63
|
+
console.log(JSON.stringify(res.data));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const t = res.data;
|
|
67
|
+
console.log(` Task: ${t.taskId}`);
|
|
68
|
+
console.log(` Status: ${t.status}`);
|
|
69
|
+
console.log(` Prompt: ${t.prompt}`);
|
|
70
|
+
if (t.resultUrl)
|
|
71
|
+
console.log(` URL: ${chalk.cyan(t.resultUrl)}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function getApiKey(): string | undefined;
|
|
2
|
+
export declare function requireApiKey(): string;
|
|
3
|
+
export declare function setApiKey(key: string): void;
|
|
4
|
+
export declare function clearApiKey(): void;
|
|
5
|
+
export declare function getKeySource(): "env" | "config" | "none";
|
|
6
|
+
export declare function getConfig(key: string): unknown;
|
|
7
|
+
export declare function setConfig(key: string, value: string): void;
|
|
8
|
+
export declare function listConfig(): Record<string, unknown>;
|
|
9
|
+
export declare function resetConfig(): void;
|
|
10
|
+
export declare function maskKey(key: string): string;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import Conf from "conf";
|
|
2
|
+
import { ENV_VAR_NAME } from "./constants.js";
|
|
3
|
+
const config = new Conf({
|
|
4
|
+
projectName: "aisa-cli",
|
|
5
|
+
schema: {
|
|
6
|
+
apiKey: { type: "string", default: "" },
|
|
7
|
+
defaultModel: { type: "string", default: "gpt-4.1" },
|
|
8
|
+
baseUrl: { type: "string", default: "https://api.aisa.one/v1" },
|
|
9
|
+
outputFormat: { type: "string", default: "text" },
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
export function getApiKey() {
|
|
13
|
+
const envKey = process.env[ENV_VAR_NAME];
|
|
14
|
+
if (envKey)
|
|
15
|
+
return envKey;
|
|
16
|
+
const stored = config.get("apiKey");
|
|
17
|
+
return stored || undefined;
|
|
18
|
+
}
|
|
19
|
+
export function requireApiKey() {
|
|
20
|
+
const key = getApiKey();
|
|
21
|
+
if (!key) {
|
|
22
|
+
console.error(`No API key found. Run "aisa login --key <key>" or set ${ENV_VAR_NAME}.`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
return key;
|
|
26
|
+
}
|
|
27
|
+
export function setApiKey(key) {
|
|
28
|
+
config.set("apiKey", key);
|
|
29
|
+
}
|
|
30
|
+
export function clearApiKey() {
|
|
31
|
+
config.delete("apiKey");
|
|
32
|
+
}
|
|
33
|
+
export function getKeySource() {
|
|
34
|
+
if (process.env[ENV_VAR_NAME])
|
|
35
|
+
return "env";
|
|
36
|
+
if (config.get("apiKey"))
|
|
37
|
+
return "config";
|
|
38
|
+
return "none";
|
|
39
|
+
}
|
|
40
|
+
export function getConfig(key) {
|
|
41
|
+
return config.get(key);
|
|
42
|
+
}
|
|
43
|
+
export function setConfig(key, value) {
|
|
44
|
+
config.set(key, value);
|
|
45
|
+
}
|
|
46
|
+
export function listConfig() {
|
|
47
|
+
return config.store;
|
|
48
|
+
}
|
|
49
|
+
export function resetConfig() {
|
|
50
|
+
config.clear();
|
|
51
|
+
}
|
|
52
|
+
export function maskKey(key) {
|
|
53
|
+
if (key.length <= 8)
|
|
54
|
+
return "****";
|
|
55
|
+
return key.slice(0, 4) + "..." + key.slice(-4);
|
|
56
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const VERSION = "0.1.1";
|
|
2
|
+
export declare const BASE_URL = "https://api.aisa.one";
|
|
3
|
+
export declare const CLI_BASE_URL = "https://api.aisa.one/v1";
|
|
4
|
+
export declare const ENV_VAR_NAME = "AISA_API_KEY";
|
|
5
|
+
export declare const MCP_URL = "https://docs.aisa.one/mcp";
|
|
6
|
+
export declare const AGENT_DIRS: Record<string, string>;
|
|
7
|
+
export declare const MCP_CONFIGS: Record<string, {
|
|
8
|
+
path: string;
|
|
9
|
+
key: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const API_CATEGORIES: readonly ["llm", "search", "finance", "twitter", "video", "scholar"];
|
|
12
|
+
export type ApiCategory = (typeof API_CATEGORIES)[number];
|
|
13
|
+
export declare const MODEL_PROVIDERS: readonly ["openai", "anthropic", "google", "deepseek", "xai", "moonshot", "alibaba", "bytedance"];
|
|
14
|
+
export type ModelProvider = (typeof MODEL_PROVIDERS)[number];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const VERSION = "0.1.1";
|
|
2
|
+
export const BASE_URL = "https://api.aisa.one";
|
|
3
|
+
export const CLI_BASE_URL = `${BASE_URL}/v1`;
|
|
4
|
+
export const ENV_VAR_NAME = "AISA_API_KEY";
|
|
5
|
+
export const MCP_URL = "https://docs.aisa.one/mcp";
|
|
6
|
+
export const AGENT_DIRS = {
|
|
7
|
+
claude: "~/.claude/skills/",
|
|
8
|
+
cursor: "~/.cursor/skills/",
|
|
9
|
+
copilot: "~/.github/skills/",
|
|
10
|
+
windsurf: "~/.codeium/windsurf/skills/",
|
|
11
|
+
codex: "~/.agents/skills/",
|
|
12
|
+
gemini: "~/.gemini/skills/",
|
|
13
|
+
openclaw: "~/.openclaw/skills/",
|
|
14
|
+
};
|
|
15
|
+
export const MCP_CONFIGS = {
|
|
16
|
+
cursor: { path: "~/.cursor/mcp.json", key: "mcpServers" },
|
|
17
|
+
"claude-desktop": {
|
|
18
|
+
path: "~/Library/Application Support/Claude/claude_desktop_config.json",
|
|
19
|
+
key: "mcpServers",
|
|
20
|
+
},
|
|
21
|
+
windsurf: {
|
|
22
|
+
path: "~/.codeium/windsurf/mcp_config.json",
|
|
23
|
+
key: "mcpServers",
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
export const API_CATEGORIES = [
|
|
27
|
+
"llm",
|
|
28
|
+
"search",
|
|
29
|
+
"finance",
|
|
30
|
+
"twitter",
|
|
31
|
+
"video",
|
|
32
|
+
"scholar",
|
|
33
|
+
];
|
|
34
|
+
export const MODEL_PROVIDERS = [
|
|
35
|
+
"openai",
|
|
36
|
+
"anthropic",
|
|
37
|
+
"google",
|
|
38
|
+
"deepseek",
|
|
39
|
+
"xai",
|
|
40
|
+
"moonshot",
|
|
41
|
+
"alibaba",
|
|
42
|
+
"bytedance",
|
|
43
|
+
];
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { VERSION } from "./constants.js";
|
|
4
|
+
// Auth
|
|
5
|
+
import { loginAction, logoutAction, whoamiAction } from "./commands/auth.js";
|
|
6
|
+
// Account
|
|
7
|
+
import { balanceAction, usageAction } from "./commands/account.js";
|
|
8
|
+
// API
|
|
9
|
+
import { apiListAction, apiSearchAction, apiShowAction, apiCodeAction } from "./commands/api.js";
|
|
10
|
+
// Run
|
|
11
|
+
import { runAction } from "./commands/run.js";
|
|
12
|
+
// Chat
|
|
13
|
+
import { chatAction } from "./commands/chat.js";
|
|
14
|
+
// Models
|
|
15
|
+
import { modelsListAction, modelsShowAction } from "./commands/models.js";
|
|
16
|
+
// Search
|
|
17
|
+
import { webSearchAction, scholarAction } from "./commands/search.js";
|
|
18
|
+
// Finance
|
|
19
|
+
import { stockAction, cryptoAction, screenerAction } from "./commands/finance.js";
|
|
20
|
+
// Twitter
|
|
21
|
+
import { tweetAction, twitterSearchAction, twitterUserAction, twitterTrendsAction } from "./commands/twitter.js";
|
|
22
|
+
// Video
|
|
23
|
+
import { videoCreateAction, videoStatusAction } from "./commands/video.js";
|
|
24
|
+
// Skills
|
|
25
|
+
import { skillsListAction, skillsSearchAction, skillsShowAction, skillsAddAction, skillsRemoveAction, skillsUpdateAction, skillsInitAction, skillsSubmitAction, skillsPushAction, skillsVerifyAction, } from "./commands/skills.js";
|
|
26
|
+
// MCP
|
|
27
|
+
import { mcpSetupAction, mcpStatusAction } from "./commands/mcp.js";
|
|
28
|
+
// Config
|
|
29
|
+
import { configSetAction, configGetAction, configListAction, configResetAction } from "./commands/configCmd.js";
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
function wrap(fn) {
|
|
32
|
+
return (...args) => {
|
|
33
|
+
fn(...args).catch((err) => {
|
|
34
|
+
console.error(`Error: ${err.message}`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const program = new Command();
|
|
40
|
+
program
|
|
41
|
+
.name("aisa")
|
|
42
|
+
.description("AISA CLI - Unified AI infrastructure platform")
|
|
43
|
+
.version(VERSION);
|
|
44
|
+
// ── Auth ──
|
|
45
|
+
program
|
|
46
|
+
.command("login")
|
|
47
|
+
.description("Authenticate with your AISA API key")
|
|
48
|
+
.option("--key <key>", "API key")
|
|
49
|
+
.action(loginAction);
|
|
50
|
+
program
|
|
51
|
+
.command("logout")
|
|
52
|
+
.description("Remove stored API key")
|
|
53
|
+
.action(logoutAction);
|
|
54
|
+
program
|
|
55
|
+
.command("whoami")
|
|
56
|
+
.description("Show authentication status")
|
|
57
|
+
.action(whoamiAction);
|
|
58
|
+
// ── Account ──
|
|
59
|
+
program
|
|
60
|
+
.command("balance")
|
|
61
|
+
.description("Show credit balance")
|
|
62
|
+
.action(wrap(balanceAction));
|
|
63
|
+
program
|
|
64
|
+
.command("usage")
|
|
65
|
+
.description("Show usage history")
|
|
66
|
+
.option("--limit <n>", "Max records")
|
|
67
|
+
.option("--days <n>", "Lookback days")
|
|
68
|
+
.action(wrap(usageAction));
|
|
69
|
+
// ── API ──
|
|
70
|
+
const api = program.command("api").description("Discover and inspect APIs");
|
|
71
|
+
api
|
|
72
|
+
.command("list")
|
|
73
|
+
.description("List available API endpoints")
|
|
74
|
+
.option("--category <cat>", "Filter by category (llm, search, finance, twitter, video, scholar)")
|
|
75
|
+
.action(wrap(apiListAction));
|
|
76
|
+
api
|
|
77
|
+
.command("search <query>")
|
|
78
|
+
.description("Search APIs by keyword")
|
|
79
|
+
.option("--limit <n>", "Max results")
|
|
80
|
+
.action(wrap(apiSearchAction));
|
|
81
|
+
api
|
|
82
|
+
.command("show <slug> [path]")
|
|
83
|
+
.description("Show API endpoint details")
|
|
84
|
+
.action(wrap(apiShowAction));
|
|
85
|
+
api
|
|
86
|
+
.command("code <slug> <path>")
|
|
87
|
+
.description("Generate code snippet")
|
|
88
|
+
.option("--lang <language>", "Language: typescript, python, curl", "typescript")
|
|
89
|
+
.action(wrap(apiCodeAction));
|
|
90
|
+
// ── Run ──
|
|
91
|
+
program
|
|
92
|
+
.command("run <slug> <path>")
|
|
93
|
+
.description("Execute an API call")
|
|
94
|
+
.option("-q, --query <params...>", "Query parameters (key=value)")
|
|
95
|
+
.option("-d, --data <json>", "JSON request body")
|
|
96
|
+
.option("--method <method>", "HTTP method")
|
|
97
|
+
.option("--raw", "Raw JSON output")
|
|
98
|
+
.option("--stream", "Stream response")
|
|
99
|
+
.action((slug, path, opts) => wrap(runAction)(slug, path, {
|
|
100
|
+
q: opts.query,
|
|
101
|
+
d: opts.data,
|
|
102
|
+
method: opts.method,
|
|
103
|
+
raw: opts.raw,
|
|
104
|
+
stream: opts.stream,
|
|
105
|
+
}));
|
|
106
|
+
// ── Chat (LLM Gateway) ──
|
|
107
|
+
program
|
|
108
|
+
.command("chat [message]")
|
|
109
|
+
.description("Chat with AI models via the AISA gateway")
|
|
110
|
+
.option("--model <model>", "Model ID (default: gpt-4.1)")
|
|
111
|
+
.option("--system <prompt>", "System prompt")
|
|
112
|
+
.option("--no-stream", "Disable streaming")
|
|
113
|
+
.option("--json", "Output raw JSON response")
|
|
114
|
+
.option("--max-tokens <n>", "Max output tokens")
|
|
115
|
+
.option("--temperature <t>", "Sampling temperature (0-2)")
|
|
116
|
+
.action(wrap(chatAction));
|
|
117
|
+
// ── Models ──
|
|
118
|
+
const models = program.command("models").description("Browse available LLM models");
|
|
119
|
+
models
|
|
120
|
+
.command("list", { isDefault: true })
|
|
121
|
+
.description("List all models")
|
|
122
|
+
.option("--provider <provider>", "Filter by provider")
|
|
123
|
+
.action(wrap(modelsListAction));
|
|
124
|
+
models
|
|
125
|
+
.command("show <model-id>")
|
|
126
|
+
.description("Show model details and pricing")
|
|
127
|
+
.action(wrap(modelsShowAction));
|
|
128
|
+
// ── Search shortcuts ──
|
|
129
|
+
program
|
|
130
|
+
.command("web-search <query>")
|
|
131
|
+
.description("Search the web")
|
|
132
|
+
.option("--type <type>", "Search type: smart, full, youtube, scholar, tavily", "smart")
|
|
133
|
+
.option("--limit <n>", "Max results")
|
|
134
|
+
.option("--raw", "Raw JSON output")
|
|
135
|
+
.action(wrap(webSearchAction));
|
|
136
|
+
program
|
|
137
|
+
.command("scholar <query>")
|
|
138
|
+
.description("Search academic papers")
|
|
139
|
+
.option("--limit <n>", "Max results")
|
|
140
|
+
.option("--raw", "Raw JSON output")
|
|
141
|
+
.action(wrap(scholarAction));
|
|
142
|
+
// ── Finance shortcuts ──
|
|
143
|
+
program
|
|
144
|
+
.command("stock <symbol>")
|
|
145
|
+
.description("Look up stock data")
|
|
146
|
+
.option("--field <field>", "Data field: price, earnings, financials, filings, insider, institutional", "price")
|
|
147
|
+
.option("--raw", "Raw JSON output")
|
|
148
|
+
.action(wrap(stockAction));
|
|
149
|
+
program
|
|
150
|
+
.command("crypto <symbol>")
|
|
151
|
+
.description("Look up crypto price")
|
|
152
|
+
.option("--period <period>", "Time period: current, 1d, 7d, 30d, 1y")
|
|
153
|
+
.option("--raw", "Raw JSON output")
|
|
154
|
+
.action(wrap(cryptoAction));
|
|
155
|
+
program
|
|
156
|
+
.command("screener")
|
|
157
|
+
.description("Screen stocks by criteria")
|
|
158
|
+
.option("--sector <sector>", "Filter by sector")
|
|
159
|
+
.option("--limit <n>", "Max results")
|
|
160
|
+
.option("--raw", "Raw JSON output")
|
|
161
|
+
.action(wrap(screenerAction));
|
|
162
|
+
// ── Twitter shortcuts ──
|
|
163
|
+
program
|
|
164
|
+
.command("tweet <text>")
|
|
165
|
+
.description("Post a tweet")
|
|
166
|
+
.option("--reply-to <id>", "Reply to tweet ID")
|
|
167
|
+
.option("--raw", "Raw JSON output")
|
|
168
|
+
.action(wrap(tweetAction));
|
|
169
|
+
const twitter = program.command("twitter").description("Twitter/X operations");
|
|
170
|
+
twitter
|
|
171
|
+
.command("search <query>")
|
|
172
|
+
.description("Search tweets")
|
|
173
|
+
.option("--limit <n>", "Max results")
|
|
174
|
+
.option("--raw", "Raw JSON output")
|
|
175
|
+
.action(wrap(twitterSearchAction));
|
|
176
|
+
twitter
|
|
177
|
+
.command("user <username>")
|
|
178
|
+
.description("Get user profile")
|
|
179
|
+
.option("--raw", "Raw JSON output")
|
|
180
|
+
.action(wrap(twitterUserAction));
|
|
181
|
+
twitter
|
|
182
|
+
.command("trends")
|
|
183
|
+
.description("Get trending topics")
|
|
184
|
+
.option("--raw", "Raw JSON output")
|
|
185
|
+
.action(wrap(twitterTrendsAction));
|
|
186
|
+
// ── Video shortcuts ──
|
|
187
|
+
const video = program.command("video").description("AI video generation");
|
|
188
|
+
video
|
|
189
|
+
.command("create <prompt>")
|
|
190
|
+
.description("Create a video generation task")
|
|
191
|
+
.option("--model <model>", "Generation model")
|
|
192
|
+
.option("--wait", "Wait for completion")
|
|
193
|
+
.option("--output <path>", "Download output path")
|
|
194
|
+
.option("--raw", "Raw JSON output")
|
|
195
|
+
.action(wrap(videoCreateAction));
|
|
196
|
+
video
|
|
197
|
+
.command("status <task-id>")
|
|
198
|
+
.description("Check video task status")
|
|
199
|
+
.option("--raw", "Raw JSON output")
|
|
200
|
+
.action(wrap(videoStatusAction));
|
|
201
|
+
// ── Skills ──
|
|
202
|
+
const skills = program.command("skills").description("Browse and manage agent skills");
|
|
203
|
+
skills
|
|
204
|
+
.command("list")
|
|
205
|
+
.description("List available skills")
|
|
206
|
+
.option("--category <cat>", "Filter by category")
|
|
207
|
+
.option("--limit <n>", "Max results")
|
|
208
|
+
.action(wrap(skillsListAction));
|
|
209
|
+
skills
|
|
210
|
+
.command("search <query>")
|
|
211
|
+
.description("Search skills")
|
|
212
|
+
.option("--limit <n>", "Max results")
|
|
213
|
+
.action(wrap(skillsSearchAction));
|
|
214
|
+
skills
|
|
215
|
+
.command("show <slug>")
|
|
216
|
+
.description("Show skill details")
|
|
217
|
+
.action(wrap(skillsShowAction));
|
|
218
|
+
skills
|
|
219
|
+
.command("add <slug>")
|
|
220
|
+
.description("Install a skill to agent directories")
|
|
221
|
+
.option("--agent <agent>", "Target agent: claude, cursor, copilot, windsurf, codex, gemini, openclaw, all")
|
|
222
|
+
.action(wrap(skillsAddAction));
|
|
223
|
+
skills
|
|
224
|
+
.command("remove <slug>")
|
|
225
|
+
.description("Remove an installed skill")
|
|
226
|
+
.option("--agent <agent>", "Target agent")
|
|
227
|
+
.action(skillsRemoveAction);
|
|
228
|
+
skills
|
|
229
|
+
.command("update [slug]")
|
|
230
|
+
.description("Update installed skill(s)")
|
|
231
|
+
.action(wrap(skillsUpdateAction));
|
|
232
|
+
skills
|
|
233
|
+
.command("init <name>")
|
|
234
|
+
.description("Initialize a new skill")
|
|
235
|
+
.option("--template <template>", "Template: llm, search, finance, twitter, video")
|
|
236
|
+
.option("--bare", "Minimal template")
|
|
237
|
+
.action(skillsInitAction);
|
|
238
|
+
skills
|
|
239
|
+
.command("submit <path>")
|
|
240
|
+
.description("Submit a skill to AISA")
|
|
241
|
+
.action(wrap(skillsSubmitAction));
|
|
242
|
+
skills
|
|
243
|
+
.command("push <slug>")
|
|
244
|
+
.description("Push local changes to a submitted skill")
|
|
245
|
+
.action(wrap(skillsPushAction));
|
|
246
|
+
skills
|
|
247
|
+
.command("request-verification <slug>")
|
|
248
|
+
.description("Request skill verification")
|
|
249
|
+
.action(wrap(skillsVerifyAction));
|
|
250
|
+
// ── MCP ──
|
|
251
|
+
const mcp = program.command("mcp").description("MCP server integration");
|
|
252
|
+
mcp
|
|
253
|
+
.command("setup")
|
|
254
|
+
.description("Configure AISA MCP server for AI agents")
|
|
255
|
+
.option("--agent <agent>", "Target agent: cursor, claude-desktop, windsurf, all")
|
|
256
|
+
.action(mcpSetupAction);
|
|
257
|
+
mcp
|
|
258
|
+
.command("status")
|
|
259
|
+
.description("Check MCP server configuration status")
|
|
260
|
+
.action(mcpStatusAction);
|
|
261
|
+
// ── Config ──
|
|
262
|
+
const configCmd = program.command("config").description("Manage CLI configuration");
|
|
263
|
+
configCmd
|
|
264
|
+
.command("set <key> <value>")
|
|
265
|
+
.description("Set a config value")
|
|
266
|
+
.action(configSetAction);
|
|
267
|
+
configCmd
|
|
268
|
+
.command("get <key>")
|
|
269
|
+
.description("Get a config value")
|
|
270
|
+
.action(configGetAction);
|
|
271
|
+
configCmd
|
|
272
|
+
.command("list")
|
|
273
|
+
.description("List all config values")
|
|
274
|
+
.action(configListAction);
|
|
275
|
+
configCmd
|
|
276
|
+
.command("reset")
|
|
277
|
+
.description("Reset config to defaults")
|
|
278
|
+
.action(configResetAction);
|
|
279
|
+
// ── Top-level aliases ──
|
|
280
|
+
program
|
|
281
|
+
.command("search <query>")
|
|
282
|
+
.description("Search APIs (alias for 'api search')")
|
|
283
|
+
.option("--limit <n>", "Max results")
|
|
284
|
+
.action(wrap(apiSearchAction));
|
|
285
|
+
program
|
|
286
|
+
.command("code <slug> <path>")
|
|
287
|
+
.description("Generate code (alias for 'api code')")
|
|
288
|
+
.option("--lang <language>", "Language", "typescript")
|
|
289
|
+
.action(wrap(apiCodeAction));
|
|
290
|
+
// ── Parse ──
|
|
291
|
+
program.parse();
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export interface ApiEndpoint {
|
|
2
|
+
method: string;
|
|
3
|
+
path: string;
|
|
4
|
+
description: string;
|
|
5
|
+
category: string;
|
|
6
|
+
parameters?: Parameter[];
|
|
7
|
+
}
|
|
8
|
+
export interface Parameter {
|
|
9
|
+
name: string;
|
|
10
|
+
type: string;
|
|
11
|
+
required: boolean;
|
|
12
|
+
description: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ApiGroup {
|
|
15
|
+
slug: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
category: string;
|
|
19
|
+
endpoints: ApiEndpoint[];
|
|
20
|
+
}
|
|
21
|
+
export interface Model {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
provider: string;
|
|
25
|
+
contextWindow: number;
|
|
26
|
+
maxTokens: number;
|
|
27
|
+
pricing: {
|
|
28
|
+
input: number;
|
|
29
|
+
output: number;
|
|
30
|
+
};
|
|
31
|
+
capabilities: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface SkillMeta {
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
owner: string;
|
|
37
|
+
slug: string;
|
|
38
|
+
tags: string[];
|
|
39
|
+
category: string;
|
|
40
|
+
verified: boolean;
|
|
41
|
+
installs: number;
|
|
42
|
+
}
|
|
43
|
+
export interface SkillDetail extends SkillMeta {
|
|
44
|
+
files: Array<{
|
|
45
|
+
path: string;
|
|
46
|
+
content: string;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
export interface BalanceResponse {
|
|
50
|
+
balance: number;
|
|
51
|
+
currency: string;
|
|
52
|
+
}
|
|
53
|
+
export interface UsageRecord {
|
|
54
|
+
timestamp: string;
|
|
55
|
+
api: string;
|
|
56
|
+
endpoint: string;
|
|
57
|
+
cost: number;
|
|
58
|
+
tokens?: {
|
|
59
|
+
input: number;
|
|
60
|
+
output: number;
|
|
61
|
+
};
|
|
62
|
+
status: "success" | "error";
|
|
63
|
+
}
|
|
64
|
+
export interface ChatOptions {
|
|
65
|
+
model: string;
|
|
66
|
+
messages: Array<{
|
|
67
|
+
role: string;
|
|
68
|
+
content: string;
|
|
69
|
+
}>;
|
|
70
|
+
stream: boolean;
|
|
71
|
+
max_tokens?: number;
|
|
72
|
+
temperature?: number;
|
|
73
|
+
}
|
|
74
|
+
export interface ChatResponse {
|
|
75
|
+
id: string;
|
|
76
|
+
choices: Array<{
|
|
77
|
+
message: {
|
|
78
|
+
role: string;
|
|
79
|
+
content: string;
|
|
80
|
+
};
|
|
81
|
+
finish_reason: string;
|
|
82
|
+
}>;
|
|
83
|
+
usage: {
|
|
84
|
+
prompt_tokens: number;
|
|
85
|
+
completion_tokens: number;
|
|
86
|
+
total_tokens: number;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export interface VideoTask {
|
|
90
|
+
taskId: string;
|
|
91
|
+
status: "pending" | "processing" | "completed" | "failed";
|
|
92
|
+
prompt: string;
|
|
93
|
+
resultUrl?: string;
|
|
94
|
+
createdAt: string;
|
|
95
|
+
}
|
|
96
|
+
export interface ApiResponse<T = unknown> {
|
|
97
|
+
success: boolean;
|
|
98
|
+
data?: T;
|
|
99
|
+
error?: string;
|
|
100
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function table(headers: string[], rows: string[][]): string;
|
|
2
|
+
export declare function badge(text: string, color?: "green" | "blue" | "yellow" | "red" | "gray"): string;
|
|
3
|
+
export declare function success(msg: string): void;
|
|
4
|
+
export declare function error(msg: string): void;
|
|
5
|
+
export declare function info(msg: string): void;
|
|
6
|
+
export declare function hint(msg: string): void;
|
|
7
|
+
export declare function formatJson(data: unknown): string;
|
|
8
|
+
export declare function truncate(str: string, maxLen: number): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
export function table(headers, rows) {
|
|
3
|
+
const widths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => (r[i] || "").length)));
|
|
4
|
+
const sep = widths.map((w) => "─".repeat(w + 2)).join("┼");
|
|
5
|
+
const headerLine = headers
|
|
6
|
+
.map((h, i) => ` ${chalk.bold(h.padEnd(widths[i]))} `)
|
|
7
|
+
.join("│");
|
|
8
|
+
const dataLines = rows.map((row) => row.map((cell, i) => ` ${(cell || "").padEnd(widths[i])} `).join("│"));
|
|
9
|
+
return [headerLine, sep, ...dataLines].join("\n");
|
|
10
|
+
}
|
|
11
|
+
export function badge(text, color = "blue") {
|
|
12
|
+
return chalk[color](`[${text}]`);
|
|
13
|
+
}
|
|
14
|
+
export function success(msg) {
|
|
15
|
+
console.log(chalk.green("✓") + " " + msg);
|
|
16
|
+
}
|
|
17
|
+
export function error(msg) {
|
|
18
|
+
console.error(chalk.red("✗") + " " + msg);
|
|
19
|
+
}
|
|
20
|
+
export function info(msg) {
|
|
21
|
+
console.log(chalk.blue("ℹ") + " " + msg);
|
|
22
|
+
}
|
|
23
|
+
export function hint(msg) {
|
|
24
|
+
console.log(chalk.gray(" " + msg));
|
|
25
|
+
}
|
|
26
|
+
export function formatJson(data) {
|
|
27
|
+
return JSON.stringify(data, null, 2);
|
|
28
|
+
}
|
|
29
|
+
export function truncate(str, maxLen) {
|
|
30
|
+
if (str.length <= maxLen)
|
|
31
|
+
return str;
|
|
32
|
+
return str.slice(0, maxLen - 3) + "...";
|
|
33
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function expandHome(p: string): string;
|
|
2
|
+
export declare function ensureDir(dirPath: string): void;
|
|
3
|
+
export declare function writeSkillFiles(targetDir: string, files: Array<{
|
|
4
|
+
path: string;
|
|
5
|
+
content: string;
|
|
6
|
+
}>): void;
|
|
7
|
+
export declare function readSkillDir(dirPath: string): Array<{
|
|
8
|
+
path: string;
|
|
9
|
+
content: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function removeDir(dirPath: string): void;
|
|
12
|
+
export declare function detectAgents(agentDirs: Record<string, string>): string[];
|