@aisa-one/cli 0.0.1 → 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.
Files changed (45) hide show
  1. package/README.md +203 -0
  2. package/dist/api.d.ts +11 -0
  3. package/dist/api.js +61 -0
  4. package/dist/commands/account.d.ts +5 -0
  5. package/dist/commands/account.js +47 -0
  6. package/dist/commands/api.d.ts +10 -0
  7. package/dist/commands/api.js +116 -0
  8. package/dist/commands/auth.d.ts +5 -0
  9. package/dist/commands/auth.js +29 -0
  10. package/dist/commands/chat.d.ts +8 -0
  11. package/dist/commands/chat.js +78 -0
  12. package/dist/commands/configCmd.d.ts +4 -0
  13. package/dist/commands/configCmd.js +36 -0
  14. package/dist/commands/finance.d.ts +13 -0
  15. package/dist/commands/finance.js +85 -0
  16. package/dist/commands/mcp.d.ts +4 -0
  17. package/dist/commands/mcp.js +67 -0
  18. package/dist/commands/models.d.ts +4 -0
  19. package/dist/commands/models.js +65 -0
  20. package/dist/commands/run.d.ts +7 -0
  21. package/dist/commands/run.js +70 -0
  22. package/dist/commands/search.d.ts +9 -0
  23. package/dist/commands/search.js +43 -0
  24. package/dist/commands/skills.d.ts +22 -0
  25. package/dist/commands/skills.js +555 -0
  26. package/dist/commands/twitter.d.ts +14 -0
  27. package/dist/commands/twitter.js +85 -0
  28. package/dist/commands/video.d.ts +9 -0
  29. package/dist/commands/video.js +73 -0
  30. package/dist/config.d.ts +10 -0
  31. package/dist/config.js +56 -0
  32. package/dist/constants.d.ts +14 -0
  33. package/dist/constants.js +43 -0
  34. package/dist/index.d.ts +2 -0
  35. package/dist/index.js +291 -0
  36. package/dist/types.d.ts +100 -0
  37. package/dist/types.js +1 -0
  38. package/dist/utils/display.d.ts +8 -0
  39. package/dist/utils/display.js +33 -0
  40. package/dist/utils/file.d.ts +12 -0
  41. package/dist/utils/file.js +70 -0
  42. package/dist/utils/streaming.d.ts +5 -0
  43. package/dist/utils/streaming.js +37 -0
  44. package/package.json +53 -5
  45. package/index.js +0 -3
@@ -0,0 +1,70 @@
1
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
2
+ import { join, resolve, relative, sep } from "node:path";
3
+ import { homedir } from "node:os";
4
+ export function expandHome(p) {
5
+ if (p.startsWith("~/") || p === "~") {
6
+ return join(homedir(), p.slice(1));
7
+ }
8
+ return p;
9
+ }
10
+ export function ensureDir(dirPath) {
11
+ if (!existsSync(dirPath)) {
12
+ mkdirSync(dirPath, { recursive: true });
13
+ }
14
+ }
15
+ export function writeSkillFiles(targetDir, files) {
16
+ for (const file of files) {
17
+ const safePath = sanitizePath(file.path);
18
+ const fullPath = join(targetDir, safePath);
19
+ ensureDir(join(fullPath, ".."));
20
+ writeFileSync(fullPath, file.content, "utf-8");
21
+ }
22
+ }
23
+ export function readSkillDir(dirPath) {
24
+ const files = [];
25
+ function walk(dir) {
26
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
27
+ const fullPath = join(dir, entry.name);
28
+ if (entry.isDirectory()) {
29
+ if (entry.name === "node_modules" || entry.name === ".git")
30
+ continue;
31
+ walk(fullPath);
32
+ }
33
+ else {
34
+ const relPath = relative(dirPath, fullPath);
35
+ const stat = statSync(fullPath);
36
+ if (stat.size > 1024 * 1024)
37
+ continue; // skip files > 1MB
38
+ files.push({
39
+ path: relPath,
40
+ content: readFileSync(fullPath, "utf-8"),
41
+ });
42
+ }
43
+ }
44
+ }
45
+ walk(dirPath);
46
+ return files;
47
+ }
48
+ export function removeDir(dirPath) {
49
+ if (existsSync(dirPath)) {
50
+ rmSync(dirPath, { recursive: true, force: true });
51
+ }
52
+ }
53
+ function sanitizePath(filePath) {
54
+ const resolved = resolve("/", filePath);
55
+ const rel = relative("/", resolved);
56
+ if (rel.startsWith("..") || rel.includes(`..${sep}`)) {
57
+ throw new Error(`Invalid file path: ${filePath}`);
58
+ }
59
+ return rel;
60
+ }
61
+ export function detectAgents(agentDirs) {
62
+ const detected = [];
63
+ for (const [name, dir] of Object.entries(agentDirs)) {
64
+ const parent = expandHome(dir).replace(/\/skills\/?$/, "");
65
+ if (existsSync(parent)) {
66
+ detected.push(name);
67
+ }
68
+ }
69
+ return detected;
70
+ }
@@ -0,0 +1,5 @@
1
+ import type { Response } from "node-fetch";
2
+ export declare function handleSSEStream(res: Response, onToken: (token: string) => void, onDone?: (usage?: {
3
+ prompt_tokens: number;
4
+ completion_tokens: number;
5
+ }) => void): Promise<void>;
@@ -0,0 +1,37 @@
1
+ export async function handleSSEStream(res, onToken, onDone) {
2
+ const body = res.body;
3
+ if (!body)
4
+ throw new Error("No response body");
5
+ let buffer = "";
6
+ let usage;
7
+ for await (const chunk of body) {
8
+ buffer += chunk.toString();
9
+ const lines = buffer.split("\n");
10
+ buffer = lines.pop() || "";
11
+ for (const line of lines) {
12
+ const trimmed = line.trim();
13
+ if (!trimmed || trimmed.startsWith(":"))
14
+ continue;
15
+ if (trimmed === "data: [DONE]") {
16
+ onDone?.(usage);
17
+ return;
18
+ }
19
+ if (trimmed.startsWith("data: ")) {
20
+ try {
21
+ const json = JSON.parse(trimmed.slice(6));
22
+ const delta = json.choices?.[0]?.delta;
23
+ if (delta?.content) {
24
+ onToken(delta.content);
25
+ }
26
+ if (json.usage) {
27
+ usage = json.usage;
28
+ }
29
+ }
30
+ catch {
31
+ // skip malformed JSON chunks
32
+ }
33
+ }
34
+ }
35
+ }
36
+ onDone?.(usage);
37
+ }
package/package.json CHANGED
@@ -1,11 +1,59 @@
1
1
  {
2
2
  "name": "@aisa-one/cli",
3
- "version": "0.0.1",
4
- "description": "AIsa One CLI - AI-powered command line tools.",
5
- "main": "index.js",
3
+ "version": "0.1.0",
4
+ "description": "CLI for the AISA unified AI infrastructure platform - access 70+ LLMs, web search, finance, Twitter, and video generation APIs",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
6
8
  "bin": {
7
- "aisa-one": "index.js"
9
+ "aisa": "dist/index.js"
8
10
  },
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "dev": "tsc -w",
14
+ "start": "node dist/index.js",
15
+ "test": "vitest run",
16
+ "test:watch": "vitest",
17
+ "prepublishOnly": "npm run build"
18
+ },
19
+ "engines": {
20
+ "node": ">=18"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "dependencies": {
26
+ "chalk": "^5.3.0",
27
+ "commander": "^12.0.0",
28
+ "conf": "^12.0.0",
29
+ "node-fetch": "^3.3.2",
30
+ "ora": "^8.0.1"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^20.0.0",
34
+ "typescript": "^5.0.0",
35
+ "vitest": "^3.2.4"
36
+ },
37
+ "keywords": [
38
+ "aisa",
39
+ "ai",
40
+ "llm",
41
+ "cli",
42
+ "api",
43
+ "gateway",
44
+ "skills",
45
+ "mcp",
46
+ "openai-compatible",
47
+ "ai-agents"
48
+ ],
9
49
  "license": "MIT",
10
- "keywords": ["ai", "aisa", "cli"]
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/AIsa-team/cli.git"
53
+ },
54
+ "bugs": {
55
+ "url": "https://github.com/AIsa-team/cli/issues"
56
+ },
57
+ "homepage": "https://aisa.one",
58
+ "author": "AISA Team <support@aisa.one> (https://aisa.one)"
11
59
  }
package/index.js DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- /** AIsa One CLI - AI-powered command line tools. */
3
- console.log("AIsa One CLI v0.0.1");