aistorehub 0.0.0-stage → 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/README.md CHANGED
@@ -1,3 +1,28 @@
1
- # Temporary Holding Version
1
+ # aistorehub (Node.js CLI)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Zero-dependency Node.js / TypeScript CLI for [AIStoreHub](https://www.aistorehub.in). Search, inspect, pull, security-scan, and 1-click install AI agents, skills, prompts, and MCP servers directly via `npx`.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Search the catalog
9
+ npx aistorehub search "aws agent"
10
+
11
+ # Inspect system metadata, license, and security posture
12
+ npx aistorehub info community/context-mode
13
+
14
+ # Pull complete package source files locally
15
+ npx aistorehub pull community/context-mode
16
+
17
+ # Auto-configure an MCP server into Cursor, Claude Desktop, Windsurf, or Zed
18
+ npx aistorehub mcp install community/context-mode --client cursor
19
+ npx aistorehub mcp install community/context-mode --client claude
20
+ npx aistorehub mcp install community/context-mode --client all
21
+
22
+ # Run static secret-leak and prompt-injection security scan locally
23
+ npx aistorehub scan ./my-agent
24
+ ```
25
+
26
+ ## Requirements
27
+
28
+ - Node.js 18 or higher (zero runtime npm dependencies)
package/dist/api.js ADDED
@@ -0,0 +1,83 @@
1
+ export const DEFAULT_API_BASE = process.env.AISTOREHUB_API_URL?.replace(/\/$/, "") ||
2
+ "https://aistorehub-be-cgsu.onrender.com/api/v1";
3
+ export function parseSystemRef(raw) {
4
+ const cleaned = raw.trim().replace(/^@/, "").replace(/^\/+|\/+$/g, "");
5
+ const parts = cleaned.split("/").filter(Boolean);
6
+ if (parts.length >= 3) {
7
+ return { owner: parts[0], repo: parts[1], slug: parts[2] };
8
+ }
9
+ if (parts.length === 2) {
10
+ return { owner: parts[0], repo: "catalog", slug: parts[1] };
11
+ }
12
+ return { owner: "community", repo: "catalog", slug: parts[0] || cleaned };
13
+ }
14
+ export async function searchSystems(query, options = {}) {
15
+ const params = new URLSearchParams();
16
+ if (query)
17
+ params.set("q", query);
18
+ if (options.type)
19
+ params.set("type", options.type);
20
+ params.set("page", "1");
21
+ params.set("page_size", String(Math.min(Math.max(options.limit || 10, 1), 30)));
22
+ const res = await fetch(`${DEFAULT_API_BASE}/search?${params.toString()}`, {
23
+ headers: { Accept: "application/json", "User-Agent": "aistorehub-cli-js/0.1.0" },
24
+ signal: AbortSignal.timeout(35000),
25
+ });
26
+ if (!res.ok) {
27
+ throw new Error(`Search failed (HTTP ${res.status}): ${await res.text()}`);
28
+ }
29
+ const data = (await res.json());
30
+ return {
31
+ items: Array.isArray(data.items) ? data.items : [],
32
+ total: Number(data.total || 0),
33
+ };
34
+ }
35
+ export async function getSystemDetail(rawRef) {
36
+ const { owner, repo, slug } = parseSystemRef(rawRef);
37
+ const directUrl = `${DEFAULT_API_BASE}/systems/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/${encodeURIComponent(slug)}`;
38
+ const res = await fetch(directUrl, {
39
+ headers: { Accept: "application/json", "User-Agent": "aistorehub-cli-js/0.1.0" },
40
+ signal: AbortSignal.timeout(35000),
41
+ });
42
+ if (res.ok) {
43
+ return (await res.json());
44
+ }
45
+ // Fallback: resolve via search if user passed @owner/slug with non-catalog repo or bare slug
46
+ const found = await searchSystems(slug, { limit: 10 });
47
+ const exact = found.items.find((i) => i.slug.toLowerCase() === slug.toLowerCase()) || found.items[0];
48
+ if (!exact) {
49
+ throw new Error(`System '${rawRef}' not found on AIStoreHub.`);
50
+ }
51
+ const resolvedOwner = exact.owner_username || owner;
52
+ const resolvedRepo = exact.repository_slug || repo;
53
+ const retryRes = await fetch(`${DEFAULT_API_BASE}/systems/${encodeURIComponent(resolvedOwner)}/${encodeURIComponent(resolvedRepo)}/${encodeURIComponent(exact.slug)}`, {
54
+ headers: { Accept: "application/json", "User-Agent": "aistorehub-cli-js/0.1.0" },
55
+ signal: AbortSignal.timeout(15000),
56
+ });
57
+ if (!retryRes.ok) {
58
+ throw new Error(`Failed to fetch system detail for ${resolvedOwner}/${resolvedRepo}/${exact.slug} (HTTP ${retryRes.status})`);
59
+ }
60
+ return (await retryRes.json());
61
+ }
62
+ export async function getRepoTree(owner, repo, slug, forceSync = false) {
63
+ const url = `${DEFAULT_API_BASE}/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/tree?subpath=${encodeURIComponent(`packages/${slug}`)}&system_slug=${encodeURIComponent(slug)}${forceSync ? "&force_sync=true" : ""}`;
64
+ const res = await fetch(url, {
65
+ headers: { Accept: "application/json", "User-Agent": "aistorehub-cli-js/0.1.0" },
66
+ signal: AbortSignal.timeout(25000),
67
+ });
68
+ if (!res.ok)
69
+ return [];
70
+ const data = await res.json();
71
+ return Array.isArray(data) ? data : [];
72
+ }
73
+ export async function getRepoBlob(owner, repo, filePath) {
74
+ const url = `${DEFAULT_API_BASE}/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/blob?path=${encodeURIComponent(filePath)}`;
75
+ const res = await fetch(url, {
76
+ headers: { Accept: "application/json", "User-Agent": "aistorehub-cli-js/0.1.0" },
77
+ signal: AbortSignal.timeout(12000),
78
+ });
79
+ if (!res.ok)
80
+ return null;
81
+ const data = (await res.json());
82
+ return typeof data.content === "string" ? data.content : null;
83
+ }
package/dist/cli.js ADDED
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env node
2
+ import { getSystemDetail, searchSystems } from "./api.js";
3
+ import { installMcpClientConfig } from "./mcp.js";
4
+ import { pullSystemPackage } from "./pull.js";
5
+ import { scanLocalDirectory } from "./scanner.js";
6
+ const VERSION = "0.1.0";
7
+ function printHelp() {
8
+ console.log(`AIStoreHub CLI (Node.js) v${VERSION}
9
+
10
+ Usage:
11
+ aistorehub search <query> [--type <type>] [--limit <n>]
12
+ aistorehub info <owner/slug>
13
+ aistorehub pull <owner/slug> [--dir <output_dir>]
14
+ aistorehub mcp install <owner/slug> [--client cursor|claude|windsurf|zed|all]
15
+ aistorehub scan [directory]
16
+ aistorehub --version | --help
17
+
18
+ Examples:
19
+ npx aistorehub search "aws agent"
20
+ npx aistorehub info community/context-mode
21
+ npx aistorehub pull community/context-mode
22
+ npx aistorehub mcp install community/context-mode --client cursor
23
+ npx aistorehub scan ./my-agent
24
+ `);
25
+ }
26
+ function getFlag(args, flag) {
27
+ const idx = args.indexOf(flag);
28
+ if (idx !== -1 && idx + 1 < args.length) {
29
+ return args[idx + 1];
30
+ }
31
+ return undefined;
32
+ }
33
+ async function main() {
34
+ const args = process.argv.slice(2);
35
+ if (args.length === 0 || args.includes("-h") || args.includes("--help")) {
36
+ printHelp();
37
+ return;
38
+ }
39
+ if (args.includes("-v") || args.includes("--version")) {
40
+ console.log(`aistorehub ${VERSION}`);
41
+ return;
42
+ }
43
+ const cmd = args[0].toLowerCase();
44
+ if (cmd === "search") {
45
+ const typeFlag = getFlag(args, "--type");
46
+ const limitFlag = getFlag(args, "--limit");
47
+ const queryParts = [];
48
+ for (let i = 1; i < args.length; i += 1) {
49
+ if (args[i] === "--type" || args[i] === "--limit") {
50
+ i += 1;
51
+ continue;
52
+ }
53
+ queryParts.push(args[i]);
54
+ }
55
+ const query = queryParts.join(" ").trim();
56
+ const { items, total } = await searchSystems(query, {
57
+ type: typeFlag,
58
+ limit: limitFlag ? Number(limitFlag) : 10,
59
+ });
60
+ console.log(`Found ${total} matching AI systems (showing ${items.length}):\n`);
61
+ for (const item of items) {
62
+ const owner = item.owner_username || "community";
63
+ const sec = item.security_scan_status || "not_run";
64
+ console.log(` @${owner}/${item.slug} [${item.type}] (security: ${sec})`);
65
+ if (item.description) {
66
+ console.log(` ${item.description.slice(0, 110)}${item.description.length > 110 ? "..." : ""}`);
67
+ }
68
+ }
69
+ return;
70
+ }
71
+ if (cmd === "info") {
72
+ const ref = args[1];
73
+ if (!ref) {
74
+ console.error("Error: Missing system reference. Example: aistorehub info community/context-mode");
75
+ process.exit(1);
76
+ }
77
+ const detail = await getSystemDetail(ref);
78
+ const owner = detail.repository?.owner?.username || detail.owner_username || "community";
79
+ const repo = detail.repository?.slug || detail.repository_slug || "catalog";
80
+ const ver = detail.current_version?.version || detail.latest_version || "1.0.0";
81
+ const sec = detail.current_version?.security_scan_status || detail.security_scan_status || "not_run";
82
+ console.log(`${detail.name} (@${owner}/${repo}/${detail.slug})`);
83
+ console.log(` Type: ${detail.type}`);
84
+ console.log(` Version: v${ver}`);
85
+ console.log(` Security: ${sec}`);
86
+ if (detail.license_name)
87
+ console.log(` License: ${detail.license_name}`);
88
+ if (detail.github_repo_url)
89
+ console.log(` GitHub: ${detail.github_repo_url}`);
90
+ console.log(` URL: https://www.aistorehub.in/${owner}/${repo}/${detail.slug}`);
91
+ if (detail.description)
92
+ console.log(`\n${detail.description}`);
93
+ return;
94
+ }
95
+ if (cmd === "pull") {
96
+ const ref = args[1];
97
+ if (!ref) {
98
+ console.error("Error: Missing system reference. Example: aistorehub pull community/context-mode");
99
+ process.exit(1);
100
+ }
101
+ const outDir = getFlag(args, "--dir");
102
+ console.log(`Pulling ${ref} from AIStoreHub...`);
103
+ const result = await pullSystemPackage(ref, outDir);
104
+ console.log(`Pulled '${result.name}' (${result.filesWritten} files) into ${result.targetDir}`);
105
+ return;
106
+ }
107
+ if (cmd === "mcp") {
108
+ const sub = (args[1] || "").toLowerCase();
109
+ if (sub !== "install" && sub !== "add") {
110
+ console.error("Error: Usage: aistorehub mcp install <owner/slug> [--client cursor|claude|windsurf|zed|all]");
111
+ process.exit(1);
112
+ }
113
+ const ref = args[2];
114
+ if (!ref) {
115
+ console.error("Error: Missing system reference.");
116
+ process.exit(1);
117
+ }
118
+ const client = (getFlag(args, "--client") || "cursor");
119
+ const detail = await getSystemDetail(ref);
120
+ const results = installMcpClientConfig(detail.slug, client);
121
+ if (results.length === 0) {
122
+ console.error(`Error: Unknown client '${client}'. Use cursor, claude, windsurf, zed, or all.`);
123
+ process.exit(1);
124
+ }
125
+ for (const r of results) {
126
+ const status = r.success ? "[OK]" : "[FAIL]";
127
+ console.log(`${status} ${r.client}: ${r.configPath} — ${r.message}`);
128
+ }
129
+ return;
130
+ }
131
+ if (cmd === "scan") {
132
+ const targetDir = args[1] || ".";
133
+ const report = scanLocalDirectory(targetDir);
134
+ console.log(`AIStoreHub Security Scan (${report.scannedFiles} files scanned)`);
135
+ console.log(` Status: ${report.status.toUpperCase()}`);
136
+ console.log(` Score: ${report.score}/100`);
137
+ if (report.findings.length > 0) {
138
+ console.log("\nFindings:");
139
+ for (const f of report.findings) {
140
+ console.log(` [${f.severity.toUpperCase()}] ${f.ruleId} ${f.title} (${f.file}:${f.line}) -> ${f.snippet}`);
141
+ }
142
+ }
143
+ else {
144
+ console.log(" No hardcoded secrets, exfiltration patterns, or prompt injection directives detected.");
145
+ }
146
+ if (report.status === "blocked") {
147
+ process.exit(1);
148
+ }
149
+ return;
150
+ }
151
+ console.error(`Unknown command: '${cmd}'. Run 'aistorehub --help' for usage.`);
152
+ process.exit(1);
153
+ }
154
+ main().catch((err) => {
155
+ console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
156
+ process.exit(1);
157
+ });
package/dist/mcp.js ADDED
@@ -0,0 +1,89 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ function getClaudeConfigPath() {
5
+ const home = os.homedir();
6
+ if (process.platform === "win32") {
7
+ const appData = process.env.APPDATA || path.join(home, "AppData", "Roaming");
8
+ return path.join(appData, "Claude", "claude_desktop_config.json");
9
+ }
10
+ if (process.platform === "darwin") {
11
+ return path.join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json");
12
+ }
13
+ return path.join(home, ".config", "Claude", "claude_desktop_config.json");
14
+ }
15
+ function getCursorConfigPath() {
16
+ return path.join(os.homedir(), ".cursor", "mcp.json");
17
+ }
18
+ function getWindsurfConfigPath() {
19
+ return path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
20
+ }
21
+ function getZedConfigPath() {
22
+ const home = os.homedir();
23
+ if (process.platform === "win32") {
24
+ const appData = process.env.APPDATA || path.join(home, "AppData", "Roaming");
25
+ return path.join(appData, "Zed", "settings.json");
26
+ }
27
+ return path.join(home, ".config", "zed", "settings.json");
28
+ }
29
+ function mergeJsonConfig(configPath, rootKey, serverName, serverConfig) {
30
+ fs.mkdirSync(path.dirname(configPath), { recursive: true });
31
+ let data = {};
32
+ if (fs.existsSync(configPath)) {
33
+ try {
34
+ const raw = fs.readFileSync(configPath, "utf-8");
35
+ data = JSON.parse(raw);
36
+ fs.copyFileSync(configPath, `${configPath}.bak`);
37
+ }
38
+ catch {
39
+ data = {};
40
+ }
41
+ }
42
+ if (!data[rootKey] || typeof data[rootKey] !== "object" || Array.isArray(data[rootKey])) {
43
+ data[rootKey] = {};
44
+ }
45
+ data[rootKey][serverName] = serverConfig;
46
+ fs.writeFileSync(configPath, JSON.stringify(data, null, 2) + "\n", "utf-8");
47
+ }
48
+ export function buildMcpServerConfig(slug) {
49
+ const sseUrl = `https://www.aistorehub.in/api/v1/mcp/vault/sse?package=${encodeURIComponent(slug)}`;
50
+ return {
51
+ url: sseUrl,
52
+ transport: "sse",
53
+ };
54
+ }
55
+ export function installMcpClientConfig(serverSlug, targetClient = "cursor") {
56
+ const results = [];
57
+ const serverName = `aistorehub-${serverSlug.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
58
+ const serverConfig = buildMcpServerConfig(serverSlug);
59
+ const targets = [
60
+ { id: "cursor", label: "Cursor", configPath: getCursorConfigPath(), rootKey: "mcpServers" },
61
+ { id: "claude", label: "Claude Desktop", configPath: getClaudeConfigPath(), rootKey: "mcpServers" },
62
+ { id: "windsurf", label: "Windsurf", configPath: getWindsurfConfigPath(), rootKey: "mcpServers" },
63
+ { id: "zed", label: "Zed", configPath: getZedConfigPath(), rootKey: "context_servers" },
64
+ ];
65
+ const normalized = targetClient === "all" ? "all" : targetClient.toLowerCase();
66
+ for (const t of targets) {
67
+ if (normalized !== "all" && normalized !== t.id && !(normalized === "claude-desktop" && t.id === "claude")) {
68
+ continue;
69
+ }
70
+ try {
71
+ mergeJsonConfig(t.configPath, t.rootKey, serverName, serverConfig);
72
+ results.push({
73
+ client: t.label,
74
+ configPath: t.configPath,
75
+ success: true,
76
+ message: `Configured '${serverName}' (backup saved if file existed)`,
77
+ });
78
+ }
79
+ catch (err) {
80
+ results.push({
81
+ client: t.label,
82
+ configPath: t.configPath,
83
+ success: false,
84
+ message: err instanceof Error ? err.message : String(err),
85
+ });
86
+ }
87
+ }
88
+ return results;
89
+ }
package/dist/pull.js ADDED
@@ -0,0 +1,87 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { getRepoBlob, getRepoTree, getSystemDetail } from "./api.js";
4
+ export async function pullSystemPackage(rawRef, outDir) {
5
+ const detail = await getSystemDetail(rawRef);
6
+ const owner = detail.repository?.owner?.username || detail.owner_username || "community";
7
+ const repo = detail.repository?.slug || detail.repository_slug || "catalog";
8
+ const slug = detail.slug;
9
+ const targetDir = path.resolve(outDir || slug);
10
+ fs.mkdirSync(targetDir, { recursive: true });
11
+ const tree = await getRepoTree(owner, repo, slug, false);
12
+ const upstreamUrl = detail.github_repo_url ||
13
+ (typeof detail.manifest_data?.original_repo_url === "string"
14
+ ? detail.manifest_data.original_repo_url
15
+ : "");
16
+ let filesWritten = 0;
17
+ if (tree.length > 0) {
18
+ const batchSize = 6;
19
+ for (let i = 0; i < tree.length; i += batchSize) {
20
+ const batch = tree.slice(i, i + batchSize);
21
+ await Promise.all(batch.map(async (entry) => {
22
+ const relPath = entry.path
23
+ .replace(new RegExp(`^packages/${slug}/`, "i"), "")
24
+ .replace(/^\/+/, "");
25
+ if (!relPath || relPath.includes(".."))
26
+ return;
27
+ let content = await getRepoBlob(owner, repo, entry.path);
28
+ if (content === null && upstreamUrl && upstreamUrl.includes("github.com/")) {
29
+ const rawBase = upstreamUrl
30
+ .replace(/\/$/, "")
31
+ .replace(/\.git$/i, "")
32
+ .replace("github.com", "raw.githubusercontent.com");
33
+ for (const branch of ["main", "master"]) {
34
+ try {
35
+ const r = await fetch(`${rawBase}/${branch}/${relPath}`, {
36
+ signal: AbortSignal.timeout(8000),
37
+ });
38
+ if (r.ok) {
39
+ content = await r.text();
40
+ break;
41
+ }
42
+ }
43
+ catch {
44
+ // try next branch
45
+ }
46
+ }
47
+ }
48
+ if (content !== null) {
49
+ const dest = path.join(targetDir, relPath);
50
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
51
+ fs.writeFileSync(dest, content, "utf-8");
52
+ filesWritten += 1;
53
+ }
54
+ }));
55
+ }
56
+ }
57
+ // Ensure canonical manifest & README always exist locally
58
+ const manifestPath = path.join(targetDir, "aistorehub.json");
59
+ if (!fs.existsSync(manifestPath)) {
60
+ const manifest = {
61
+ name: detail.name,
62
+ slug: detail.slug,
63
+ type: detail.type,
64
+ version: detail.current_version?.version || detail.latest_version || "1.0.0",
65
+ owner,
66
+ repository: repo,
67
+ upstream: upstreamUrl || undefined,
68
+ pulled_via: "aistorehub-cli-js",
69
+ };
70
+ fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n", "utf-8");
71
+ filesWritten += 1;
72
+ }
73
+ if (detail.current_version?.readme && !fs.existsSync(path.join(targetDir, "README.md"))) {
74
+ fs.writeFileSync(path.join(targetDir, "README.md"), detail.current_version.readme, "utf-8");
75
+ filesWritten += 1;
76
+ }
77
+ if (detail.current_version?.instructions && !fs.existsSync(path.join(targetDir, "instructions.txt"))) {
78
+ fs.writeFileSync(path.join(targetDir, "instructions.txt"), detail.current_version.instructions, "utf-8");
79
+ filesWritten += 1;
80
+ }
81
+ return {
82
+ targetDir,
83
+ filesWritten,
84
+ slug,
85
+ name: detail.name,
86
+ };
87
+ }
@@ -0,0 +1,89 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ const RULES = [
4
+ { id: "SEC001", category: "secret_leak", severity: "critical", title: "Hardcoded OpenAI API Key", pattern: /\bsk-(?:proj-)?[A-Za-z0-9_-]{24,}\b/ },
5
+ { id: "SEC002", category: "secret_leak", severity: "critical", title: "Hardcoded Anthropic API Key", pattern: /\bsk-ant-api\d{2}-[A-Za-z0-9_-]{20,}\b/ },
6
+ { id: "SEC003", category: "secret_leak", severity: "critical", title: "Hardcoded GitHub PAT", pattern: /\b(?:ghp_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{30,})\b/ },
7
+ { id: "SEC004", category: "secret_leak", severity: "critical", title: "Hardcoded AWS Access Key ID", pattern: /\bAKIA[0-9A-Z]{16}\b/ },
8
+ { id: "SEC005", category: "secret_leak", severity: "critical", title: "Hardcoded Google API Key", pattern: /\bAIza[0-9A-Za-z_-]{35}\b/ },
9
+ { id: "SEC006", category: "secret_leak", severity: "critical", title: "Hardcoded Stripe Live Key", pattern: /\bsk_live_[0-9a-zA-Z]{24,}\b/ },
10
+ { id: "SEC007", category: "secret_leak", severity: "critical", title: "Hardcoded Slack Token", pattern: /\bxox[baprs]-[0-9A-Za-z-]{16,}\b/ },
11
+ { id: "SEC008", category: "secret_leak", severity: "critical", title: "Embedded Private Key Block", pattern: /-----BEGIN (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----/ },
12
+ { id: "EXF001", category: "exfiltration", severity: "high", title: "Remote Script Piped to Shell", pattern: /\b(?:curl|wget)\b[^\n|]{0,180}\|\s*(?:sudo\s+)?(?:bash|sh|zsh)\b/i },
13
+ { id: "DNG001", category: "dangerous_exec", severity: "high", title: "Destructive Root rm -rf Command", pattern: /\brm\s+-[a-zA-Z]*r[a-zA-Z]*f[a-zA-Z]*\s+(?:\/(?:\s|$|\*)|~(?:\s|$|\/))/ },
14
+ { id: "INJ001", category: "prompt_injection", severity: "medium", title: "Prompt Injection Override Directive", pattern: /(?:ignore\s+all\s+previous\s+instructions|disregard\s+(?:all\s+)?(?:prior|previous|system)\s+(?:instructions|prompts)|exfiltrate\s+(?:all\s+)?(?:api\s+keys|secrets|credentials|tokens))/i },
15
+ ];
16
+ const PLACEHOLDERS = [
17
+ "your_api_key", "your-api-key", "placeholder", "example", "dummy",
18
+ "sk-xxxx", "sk-test", "process.env", "os.environ", "${", "{{",
19
+ ];
20
+ const SKIP_DIRS = new Set([".git", "node_modules", "__pycache__", ".venv", "venv", "dist", "build", ".next"]);
21
+ const SCAN_EXTS = new Set([
22
+ ".py", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs",
23
+ ".json", ".yaml", ".yml", ".toml", ".ini", ".env", ".sh", ".bash", ".md", ".txt", ".prompt",
24
+ ]);
25
+ function redact(val) {
26
+ if (val.length <= 10)
27
+ return "[redacted]";
28
+ return `${val.slice(0, 4)}...${val.slice(-4)}`;
29
+ }
30
+ export function scanLocalDirectory(rootDir) {
31
+ const absRoot = path.resolve(rootDir);
32
+ const findings = [];
33
+ let scannedFiles = 0;
34
+ const walk = (dir) => {
35
+ if (scannedFiles >= 200 || findings.length >= 50)
36
+ return;
37
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
38
+ for (const entry of entries) {
39
+ if (scannedFiles >= 200 || findings.length >= 50)
40
+ break;
41
+ const fullPath = path.join(dir, entry.name);
42
+ if (entry.isDirectory()) {
43
+ if (!SKIP_DIRS.has(entry.name))
44
+ walk(fullPath);
45
+ continue;
46
+ }
47
+ const ext = path.extname(entry.name).toLowerCase();
48
+ if (!SCAN_EXTS.has(ext) && !["dockerfile", "makefile"].includes(entry.name.toLowerCase())) {
49
+ continue;
50
+ }
51
+ const stat = fs.statSync(fullPath);
52
+ if (stat.size === 0 || stat.size > 256 * 1024)
53
+ continue;
54
+ const content = fs.readFileSync(fullPath, "utf-8");
55
+ const rel = path.relative(absRoot, fullPath).replace(/\\/g, "/");
56
+ scannedFiles += 1;
57
+ const lines = content.split(/\r?\n/);
58
+ for (let i = 0; i < lines.length; i += 1) {
59
+ const line = lines[i];
60
+ if (!line.trim() || line.length > 4000)
61
+ continue;
62
+ for (const rule of RULES) {
63
+ const m = rule.pattern.exec(line);
64
+ if (!m)
65
+ continue;
66
+ const lower = `${line} ${m[0]}`.toLowerCase();
67
+ if (rule.category === "secret_leak" && PLACEHOLDERS.some((p) => lower.includes(p))) {
68
+ continue;
69
+ }
70
+ findings.push({
71
+ ruleId: rule.id,
72
+ severity: rule.severity,
73
+ title: rule.title,
74
+ file: rel,
75
+ line: i + 1,
76
+ snippet: rule.category === "secret_leak" ? redact(m[0]) : m[0].slice(0, 80),
77
+ });
78
+ }
79
+ }
80
+ }
81
+ };
82
+ walk(absRoot);
83
+ const crit = findings.filter((f) => f.severity === "critical").length;
84
+ const high = findings.filter((f) => f.severity === "high").length;
85
+ const med = findings.filter((f) => f.severity === "medium").length;
86
+ const score = Math.max(0, 100 - crit * 45 - high * 20 - med * 10);
87
+ const status = crit > 0 ? "blocked" : high > 0 || med > 0 ? "review_required" : "passed";
88
+ return { status, score, scannedFiles, findings };
89
+ }
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "aistorehub",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Official Node.js / TypeScript CLI for AIStoreHub - search, pull, scan, and 1-click install AI systems, skills, and MCP servers into Cursor, Claude Desktop, Windsurf, and Zed.",
5
+ "type": "module",
6
+ "bin": {
7
+ "aistorehub": "dist/cli.js",
8
+ "aihub-js": "dist/cli.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md"
13
+ ],
14
+ "engines": {
15
+ "node": ">=18.0.0"
16
+ },
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "dev": "tsc --watch",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "keywords": [
23
+ "aistorehub",
24
+ "mcp",
25
+ "ai-agents",
26
+ "claude",
27
+ "cursor",
28
+ "windsurf",
29
+ "skills",
30
+ "cli"
31
+ ],
32
+ "author": "AIStoreHub",
33
+ "license": "MIT",
34
+ "homepage": "https://www.aistorehub.in",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/abhinavm945/AISTOREHUB-CLI.git"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^22.0.0",
41
+ "typescript": "^5.7.0"
42
+ }
43
+ }