atabey 0.0.20 → 0.0.22

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.
@@ -1,145 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from "fs";
4
- import yaml from "js-yaml";
5
- import path from "path";
6
-
7
- /**
8
- * AL-compatible agent folder names across all adapters (after init).
9
- */
10
- const AGENT_FOLDER_NAMES = ["agents", "skills", "plugins"];
11
- const FRAMEWORK_CANDIDATES = [
12
- ".atabey",
13
- ".cursor",
14
- ".claude",
15
- ".github",
16
- ".grok",
17
- ".antigravity",
18
- ".agent",
19
- ".gemini/antigravity-cli",
20
- ".gemini",
21
- ".agents",
22
- "antigravity-cli"
23
- ];
24
-
25
- function detectFrameworkDir() {
26
- const projectRoot = process.cwd();
27
- for (const dir of FRAMEWORK_CANDIDATES) {
28
- const dirPath = path.resolve(projectRoot, dir);
29
- if (!fs.existsSync(dirPath)) continue;
30
-
31
- for (const folderName of AGENT_FOLDER_NAMES) {
32
- const agentsPath = path.join(dirPath, folderName);
33
- if (fs.existsSync(agentsPath)) {
34
- return { frameworkDir: dir, agentsDir: agentsPath };
35
- }
36
- }
37
- }
38
- return null;
39
- }
40
-
41
- /**
42
- * Helper to parse YAML-like Frontmatter from Markdown.
43
- */
44
- function parseFrontmatter(content) {
45
- let fm = {};
46
- const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
47
- if (match) {
48
- try {
49
- fm = yaml.load(match[1]) || {};
50
- } catch (e) {
51
- process.stderr.write(`[ERROR] Error parsing YAML frontmatter: ${e}\n`);
52
- }
53
- }
54
-
55
- // Also parse from HTML comments in the body as fallback/complement
56
- const commentMatches = content.matchAll(/<!--\s*(\w+)\s*:\s*(.*?)\s*-->/g);
57
- for (const m of commentMatches) {
58
- let value = m[2].trim();
59
- if (value.startsWith("[") && value.endsWith("]")) {
60
- value = value.slice(1, -1).split(",").map(s => s.trim().replace(/"/g, "").replace(/'/g, ""));
61
- } else if (value.startsWith("\"") && value.endsWith("\"")) {
62
- value = value.slice(1, -1);
63
- }
64
- fm[m[1]] = value;
65
- }
66
-
67
- return Object.keys(fm).length > 0 ? fm : null;
68
- }
69
-
70
-
71
- const detected = detectFrameworkDir();
72
- if (!detected) {
73
- process.stderr.write("ℹ️ No framework agents/ dir found for AL validation. Skipping.");
74
- process.exit(0);
75
- }
76
-
77
- const { agentsDir } = detected;
78
-
79
- try {
80
- const files = [];
81
- const walk = (dir) => {
82
- if (!fs.existsSync(dir)) return;
83
- const list = fs.readdirSync(dir);
84
- for (const item of list) {
85
- const fullPath = path.join(dir, item);
86
- if (fs.statSync(fullPath).isDirectory()) {
87
- walk(fullPath);
88
- } else if (item.endsWith(".json") || item.endsWith(".md")) {
89
- files.push({ name: item, path: fullPath });
90
- }
91
- }
92
- };
93
- walk(agentsDir);
94
-
95
- let totalFailed = 0;
96
-
97
- process.stderr.write(`\n[SECURITY] STARTING AL REGISTRY VALIDATION (${detected.frameworkDir})...\n`);
98
- process.stderr.write("--------------------------------------------------\n");
99
- process.stderr.write("| Agent ID | Format | Status | Category |\n");
100
- process.stderr.write("--------------------------------------------------\n");
101
-
102
- for (const file of files) {
103
- const fileName = file.name;
104
- const filePath = file.path;
105
- if (fileName === "agent_AL_schema.json" || fileName === "schema") continue;
106
-
107
- const content = fs.readFileSync(filePath, "utf8");
108
- const isMd = fileName.endsWith(".md");
109
-
110
- let agent;
111
- try {
112
- agent = isMd ? parseFrontmatter(content) : JSON.parse(content);
113
- if (!agent && isMd) throw new Error("Missing Frontmatter");
114
- } catch (e) {
115
- process.stderr.write(`| ${fileName.padEnd(9)} | ${isMd ? "MD " : "JSON"} | [ERROR] INVALID | ${String(e.message).slice(0, 14)} |\n`);
116
- totalFailed++;
117
- continue;
118
- }
119
-
120
- // Validate AL compliance fields
121
- const missing = [];
122
- if (!agent.name) missing.push("name");
123
- if (agent.capability === undefined) missing.push("capability");
124
- if (!agent.tags) missing.push("tags");
125
-
126
- if (missing.length > 0) {
127
- process.stderr.write(`| ${fileName.padEnd(9)} | ${isMd ? "MD " : "JSON"} | [ERROR] FAILED | ${missing.join(",").slice(0, 14)} |\n`);
128
- totalFailed++;
129
- } else {
130
- const cat = Array.isArray(agent.tags) ? agent.tags[0] : "core";
131
- process.stderr.write(`| ${agent.name.padEnd(9)} | ${isMd ? "MD " : "JSON"} | [OK] PASSED | ${cat.padEnd(14)} |\n`);
132
- }
133
- }
134
-
135
- process.stderr.write("--------------------------------------------------\n");
136
- if (totalFailed > 0) {
137
- process.stderr.write(`[ERROR] Validation failed! Detected ${totalFailed} invalid agent configurations.\n`);
138
- process.exit(1);
139
- } else {
140
- process.stderr.write("🎉 SUCCESS: All core agents are AL-Compliant!\n");
141
- }
142
- } catch (e) {
143
- process.stderr.write(`[ERROR] Critical error during validation: ${e}\n`);
144
- process.exit(1);
145
- }