add-skill-kit 3.2.3 → 3.2.4
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/lib/agent-cli/lib/audit.js +154 -0
- package/lib/agent-cli/lib/audit.test.js +100 -0
- package/lib/agent-cli/lib/auto-learn.js +319 -0
- package/lib/agent-cli/lib/auto_preview.py +148 -0
- package/lib/agent-cli/lib/backup.js +138 -0
- package/lib/agent-cli/lib/backup.test.js +78 -0
- package/lib/agent-cli/lib/checklist.py +222 -0
- package/lib/agent-cli/lib/cognitive-lesson.js +476 -0
- package/lib/agent-cli/lib/completion.js +149 -0
- package/lib/agent-cli/lib/config.js +35 -0
- package/lib/agent-cli/lib/eslint-fix.js +238 -0
- package/lib/agent-cli/lib/evolution-signal.js +215 -0
- package/lib/agent-cli/lib/export.js +86 -0
- package/lib/agent-cli/lib/export.test.js +65 -0
- package/lib/agent-cli/lib/fix.js +337 -0
- package/lib/agent-cli/lib/fix.test.js +80 -0
- package/lib/agent-cli/lib/gemini-export.js +83 -0
- package/lib/agent-cli/lib/generate-registry.js +42 -0
- package/lib/agent-cli/lib/hooks/install-hooks.js +152 -0
- package/lib/agent-cli/lib/hooks/lint-learn.js +172 -0
- package/lib/agent-cli/lib/ignore.js +116 -0
- package/lib/agent-cli/lib/ignore.test.js +58 -0
- package/lib/agent-cli/lib/init.js +124 -0
- package/lib/agent-cli/lib/learn.js +255 -0
- package/lib/agent-cli/lib/learn.test.js +70 -0
- package/lib/agent-cli/lib/migrate-to-v4.js +322 -0
- package/lib/agent-cli/lib/proposals.js +199 -0
- package/lib/agent-cli/lib/proposals.test.js +56 -0
- package/lib/agent-cli/lib/recall.js +820 -0
- package/lib/agent-cli/lib/recall.test.js +107 -0
- package/lib/agent-cli/lib/selfevolution-bridge.js +167 -0
- package/lib/agent-cli/lib/session_manager.py +120 -0
- package/lib/agent-cli/lib/settings.js +203 -0
- package/lib/agent-cli/lib/skill-learn.js +296 -0
- package/lib/agent-cli/lib/stats.js +132 -0
- package/lib/agent-cli/lib/stats.test.js +94 -0
- package/lib/agent-cli/lib/types.js +33 -0
- package/lib/agent-cli/lib/ui/audit-ui.js +146 -0
- package/lib/agent-cli/lib/ui/backup-ui.js +107 -0
- package/lib/agent-cli/lib/ui/clack-helpers.js +317 -0
- package/lib/agent-cli/lib/ui/common.js +83 -0
- package/lib/agent-cli/lib/ui/completion-ui.js +126 -0
- package/lib/agent-cli/lib/ui/custom-select.js +69 -0
- package/lib/agent-cli/lib/ui/dashboard-ui.js +123 -0
- package/lib/agent-cli/lib/ui/evolution-signals-ui.js +107 -0
- package/lib/agent-cli/lib/ui/export-ui.js +94 -0
- package/lib/agent-cli/lib/ui/fix-all-ui.js +191 -0
- package/lib/agent-cli/lib/ui/help-ui.js +49 -0
- package/lib/agent-cli/lib/ui/index.js +169 -0
- package/lib/agent-cli/lib/ui/init-ui.js +56 -0
- package/lib/agent-cli/lib/ui/knowledge-ui.js +55 -0
- package/lib/agent-cli/lib/ui/learn-ui.js +706 -0
- package/lib/agent-cli/lib/ui/lessons-ui.js +148 -0
- package/lib/agent-cli/lib/ui/pretty.js +145 -0
- package/lib/agent-cli/lib/ui/proposals-ui.js +99 -0
- package/lib/agent-cli/lib/ui/recall-ui.js +342 -0
- package/lib/agent-cli/lib/ui/routing-demo.js +79 -0
- package/lib/agent-cli/lib/ui/routing-ui.js +325 -0
- package/lib/agent-cli/lib/ui/settings-ui.js +381 -0
- package/lib/agent-cli/lib/ui/stats-ui.js +123 -0
- package/lib/agent-cli/lib/ui/watch-ui.js +236 -0
- package/lib/agent-cli/lib/verify_all.py +327 -0
- package/lib/agent-cli/lib/watcher.js +181 -0
- package/lib/agent-cli/lib/watcher.test.js +85 -0
- package/lib/agent-cli/package.json +51 -0
- package/lib/agentskillskit-cli/README.md +21 -0
- package/lib/agentskillskit-cli/ag-smart.js +158 -0
- package/lib/agentskillskit-cli/package.json +51 -0
- package/package.json +10 -6
- /package/{node_modules/agentskillskit-cli → lib/agent-cli}/README.md +0 -0
- /package/{node_modules/agentskillskit-cli → lib/agent-cli}/bin/ag-smart.js +0 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Auto Preview - Agent Skill Kit
|
|
4
|
+
==============================
|
|
5
|
+
Manages (start/stop/status) the local development server for previewing the application.
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
python .agent/scripts/auto_preview.py start [port]
|
|
9
|
+
python .agent/scripts/auto_preview.py stop
|
|
10
|
+
python .agent/scripts/auto_preview.py status
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import os
|
|
14
|
+
import sys
|
|
15
|
+
import time
|
|
16
|
+
import json
|
|
17
|
+
import signal
|
|
18
|
+
import argparse
|
|
19
|
+
import subprocess
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
|
|
22
|
+
AGENT_DIR = Path(".agent")
|
|
23
|
+
PID_FILE = AGENT_DIR / "preview.pid"
|
|
24
|
+
LOG_FILE = AGENT_DIR / "preview.log"
|
|
25
|
+
|
|
26
|
+
def get_project_root():
|
|
27
|
+
return Path(".").resolve()
|
|
28
|
+
|
|
29
|
+
def is_running(pid):
|
|
30
|
+
try:
|
|
31
|
+
os.kill(pid, 0)
|
|
32
|
+
return True
|
|
33
|
+
except OSError:
|
|
34
|
+
return False
|
|
35
|
+
|
|
36
|
+
def get_start_command(root):
|
|
37
|
+
pkg_file = root / "package.json"
|
|
38
|
+
if not pkg_file.exists():
|
|
39
|
+
return None
|
|
40
|
+
|
|
41
|
+
with open(pkg_file, 'r') as f:
|
|
42
|
+
data = json.load(f)
|
|
43
|
+
|
|
44
|
+
scripts = data.get("scripts", {})
|
|
45
|
+
if "dev" in scripts:
|
|
46
|
+
return ["npm", "run", "dev"]
|
|
47
|
+
elif "start" in scripts:
|
|
48
|
+
return ["npm", "start"]
|
|
49
|
+
return None
|
|
50
|
+
|
|
51
|
+
def start_server(port=3000):
|
|
52
|
+
if PID_FILE.exists():
|
|
53
|
+
try:
|
|
54
|
+
pid = int(PID_FILE.read_text().strip())
|
|
55
|
+
if is_running(pid):
|
|
56
|
+
print(f"⚠️ Preview already running (PID: {pid})")
|
|
57
|
+
return
|
|
58
|
+
except:
|
|
59
|
+
pass # Invalid PID file
|
|
60
|
+
|
|
61
|
+
root = get_project_root()
|
|
62
|
+
cmd = get_start_command(root)
|
|
63
|
+
|
|
64
|
+
if not cmd:
|
|
65
|
+
print("❌ No 'dev' or 'start' script found in package.json")
|
|
66
|
+
sys.exit(1)
|
|
67
|
+
|
|
68
|
+
# Add port env var if needed (simple heuristic)
|
|
69
|
+
env = os.environ.copy()
|
|
70
|
+
env["PORT"] = str(port)
|
|
71
|
+
|
|
72
|
+
print(f"🚀 Starting preview on port {port}...")
|
|
73
|
+
|
|
74
|
+
with open(LOG_FILE, "w") as log:
|
|
75
|
+
process = subprocess.Popen(
|
|
76
|
+
cmd,
|
|
77
|
+
cwd=str(root),
|
|
78
|
+
stdout=log,
|
|
79
|
+
stderr=log,
|
|
80
|
+
env=env,
|
|
81
|
+
shell=True # Required for npm on windows often, or consistent path handling
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
PID_FILE.write_text(str(process.pid))
|
|
85
|
+
print(f"✅ Preview started! (PID: {process.pid})")
|
|
86
|
+
print(f" Logs: {LOG_FILE}")
|
|
87
|
+
print(f" URL: http://localhost:{port}")
|
|
88
|
+
|
|
89
|
+
def stop_server():
|
|
90
|
+
if not PID_FILE.exists():
|
|
91
|
+
print("ℹ️ No preview server found.")
|
|
92
|
+
return
|
|
93
|
+
|
|
94
|
+
try:
|
|
95
|
+
pid = int(PID_FILE.read_text().strip())
|
|
96
|
+
if is_running(pid):
|
|
97
|
+
# Try gentle kill first
|
|
98
|
+
os.kill(pid, signal.SIGTERM) if sys.platform != 'win32' else subprocess.call(['taskkill', '/F', '/T', '/PID', str(pid)])
|
|
99
|
+
print(f"🛑 Preview stopped (PID: {pid})")
|
|
100
|
+
else:
|
|
101
|
+
print("ℹ️ Process was not running.")
|
|
102
|
+
except Exception as e:
|
|
103
|
+
print(f"❌ Error stopping server: {e}")
|
|
104
|
+
finally:
|
|
105
|
+
if PID_FILE.exists():
|
|
106
|
+
PID_FILE.unlink()
|
|
107
|
+
|
|
108
|
+
def status_server():
|
|
109
|
+
running = False
|
|
110
|
+
pid = None
|
|
111
|
+
url = "Unknown"
|
|
112
|
+
|
|
113
|
+
if PID_FILE.exists():
|
|
114
|
+
try:
|
|
115
|
+
pid = int(PID_FILE.read_text().strip())
|
|
116
|
+
if is_running(pid):
|
|
117
|
+
running = True
|
|
118
|
+
# Heuristic for URL, strictly we should save it
|
|
119
|
+
url = "http://localhost:3000"
|
|
120
|
+
except:
|
|
121
|
+
pass
|
|
122
|
+
|
|
123
|
+
print("\n=== Preview Status ===")
|
|
124
|
+
if running:
|
|
125
|
+
print(f"✅ Status: Running")
|
|
126
|
+
print(f"🔢 PID: {pid}")
|
|
127
|
+
print(f"🌐 URL: {url} (Likely)")
|
|
128
|
+
print(f"📝 Logs: {LOG_FILE}")
|
|
129
|
+
else:
|
|
130
|
+
print("⚪ Status: Stopped")
|
|
131
|
+
print("===================\n")
|
|
132
|
+
|
|
133
|
+
def main():
|
|
134
|
+
parser = argparse.ArgumentParser()
|
|
135
|
+
parser.add_argument("action", choices=["start", "stop", "status"])
|
|
136
|
+
parser.add_argument("port", nargs="?", default="3000")
|
|
137
|
+
|
|
138
|
+
args = parser.parse_args()
|
|
139
|
+
|
|
140
|
+
if args.action == "start":
|
|
141
|
+
start_server(int(args.port))
|
|
142
|
+
elif args.action == "stop":
|
|
143
|
+
stop_server()
|
|
144
|
+
elif args.action == "status":
|
|
145
|
+
status_server()
|
|
146
|
+
|
|
147
|
+
if __name__ == "__main__":
|
|
148
|
+
main()
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Backup and Restore for Agent Skill Kit
|
|
3
|
+
* Protects lessons before changes
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import { KNOWLEDGE_DIR, LESSONS_PATH } from "./config.js";
|
|
9
|
+
import { SETTINGS_PATH } from "./settings.js";
|
|
10
|
+
|
|
11
|
+
/** Backup directory */
|
|
12
|
+
const BACKUPS_DIR = path.join(KNOWLEDGE_DIR, "backups");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Create a timestamped backup of lessons and settings
|
|
16
|
+
* @returns {{ path: string, timestamp: string } | null}
|
|
17
|
+
*/
|
|
18
|
+
export function createBackup() {
|
|
19
|
+
try {
|
|
20
|
+
fs.mkdirSync(BACKUPS_DIR, { recursive: true });
|
|
21
|
+
|
|
22
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
23
|
+
const backupDir = path.join(BACKUPS_DIR, timestamp);
|
|
24
|
+
fs.mkdirSync(backupDir, { recursive: true });
|
|
25
|
+
|
|
26
|
+
// Backup lessons
|
|
27
|
+
if (fs.existsSync(LESSONS_PATH)) {
|
|
28
|
+
fs.copyFileSync(
|
|
29
|
+
LESSONS_PATH,
|
|
30
|
+
path.join(backupDir, "lessons-learned.yaml")
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Backup settings
|
|
35
|
+
if (fs.existsSync(SETTINGS_PATH)) {
|
|
36
|
+
fs.copyFileSync(
|
|
37
|
+
SETTINGS_PATH,
|
|
38
|
+
path.join(backupDir, "settings.yaml")
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return { path: backupDir, timestamp };
|
|
43
|
+
} catch (e) {
|
|
44
|
+
console.error("Failed to create backup:", e.message);
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* List available backups
|
|
51
|
+
* @returns {Array<{ name: string, date: Date, path: string }>}
|
|
52
|
+
*/
|
|
53
|
+
export function listBackups() {
|
|
54
|
+
try {
|
|
55
|
+
if (!fs.existsSync(BACKUPS_DIR)) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const entries = fs.readdirSync(BACKUPS_DIR, { withFileTypes: true });
|
|
60
|
+
return entries
|
|
61
|
+
.filter(e => e.isDirectory())
|
|
62
|
+
.map(e => ({
|
|
63
|
+
name: e.name,
|
|
64
|
+
date: parseBackupDate(e.name),
|
|
65
|
+
path: path.join(BACKUPS_DIR, e.name)
|
|
66
|
+
}))
|
|
67
|
+
.sort((a, b) => b.date - a.date); // Newest first
|
|
68
|
+
} catch (e) {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Parse backup folder name to date
|
|
75
|
+
* @param {string} name - Folder name (ISO timestamp with - instead of :)
|
|
76
|
+
* @returns {Date}
|
|
77
|
+
*/
|
|
78
|
+
function parseBackupDate(name) {
|
|
79
|
+
try {
|
|
80
|
+
// Convert 2026-01-25T17-30-00-000Z back to valid ISO
|
|
81
|
+
const iso = name.replace(/-(\d{2})-(\d{2})-(\d{3})Z/, ":$1:$2.$3Z");
|
|
82
|
+
return new Date(iso);
|
|
83
|
+
} catch (e) {
|
|
84
|
+
return new Date(0);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Restore from a backup
|
|
90
|
+
* @param {string} backupPath - Path to backup folder
|
|
91
|
+
* @returns {boolean}
|
|
92
|
+
*/
|
|
93
|
+
export function restoreBackup(backupPath) {
|
|
94
|
+
try {
|
|
95
|
+
const lessonsBackup = path.join(backupPath, "lessons-learned.yaml");
|
|
96
|
+
const settingsBackup = path.join(backupPath, "settings.yaml");
|
|
97
|
+
|
|
98
|
+
if (fs.existsSync(lessonsBackup)) {
|
|
99
|
+
fs.copyFileSync(lessonsBackup, LESSONS_PATH);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (fs.existsSync(settingsBackup)) {
|
|
103
|
+
fs.copyFileSync(settingsBackup, SETTINGS_PATH);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return true;
|
|
107
|
+
} catch (e) {
|
|
108
|
+
console.error("Failed to restore backup:", e.message);
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Delete old backups, keep last N
|
|
115
|
+
* @param {number} keep - Number of backups to keep
|
|
116
|
+
*/
|
|
117
|
+
export function pruneBackups(keep = 5) {
|
|
118
|
+
const backups = listBackups();
|
|
119
|
+
|
|
120
|
+
if (backups.length <= keep) return;
|
|
121
|
+
|
|
122
|
+
const toDelete = backups.slice(keep);
|
|
123
|
+
for (const backup of toDelete) {
|
|
124
|
+
try {
|
|
125
|
+
fs.rmSync(backup.path, { recursive: true, force: true });
|
|
126
|
+
} catch (e) {
|
|
127
|
+
// Ignore deletion errors
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export default {
|
|
133
|
+
createBackup,
|
|
134
|
+
listBackups,
|
|
135
|
+
restoreBackup,
|
|
136
|
+
pruneBackups,
|
|
137
|
+
BACKUPS_DIR
|
|
138
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Tests for backup module
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import os from "os";
|
|
9
|
+
|
|
10
|
+
describe("backup", () => {
|
|
11
|
+
const testDir = path.join(os.tmpdir(), "test-backup-" + Date.now());
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
fs.mkdirSync(testDir, { recursive: true });
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
if (fs.existsSync(testDir)) {
|
|
19
|
+
fs.rmSync(testDir, { recursive: true, force: true });
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe("backup file format", () => {
|
|
24
|
+
it("creates timestamped filename", () => {
|
|
25
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
26
|
+
const filename = `backup-${timestamp}.yaml`;
|
|
27
|
+
|
|
28
|
+
expect(filename).toMatch(/^backup-\d{4}-\d{2}-\d{2}/);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("backup contains valid YAML", () => {
|
|
32
|
+
const backupContent = `lessons:\n - id: TEST\n pattern: "x"`;
|
|
33
|
+
const backupPath = path.join(testDir, "backup.yaml");
|
|
34
|
+
fs.writeFileSync(backupPath, backupContent);
|
|
35
|
+
|
|
36
|
+
expect(fs.existsSync(backupPath)).toBe(true);
|
|
37
|
+
expect(fs.readFileSync(backupPath, "utf8")).toContain("lessons:");
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe("listBackups", () => {
|
|
42
|
+
it("returns empty array when no backups", () => {
|
|
43
|
+
const backupDir = path.join(testDir, "backups");
|
|
44
|
+
fs.mkdirSync(backupDir, { recursive: true });
|
|
45
|
+
|
|
46
|
+
const files = fs.readdirSync(backupDir);
|
|
47
|
+
expect(files).toHaveLength(0);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("lists backup files", () => {
|
|
51
|
+
const backupDir = path.join(testDir, "backups");
|
|
52
|
+
fs.mkdirSync(backupDir, { recursive: true });
|
|
53
|
+
fs.writeFileSync(path.join(backupDir, "backup-2024.yaml"), "test");
|
|
54
|
+
|
|
55
|
+
const files = fs.readdirSync(backupDir);
|
|
56
|
+
expect(files).toHaveLength(1);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe("pruneBackups", () => {
|
|
61
|
+
it("keeps specified number of backups", () => {
|
|
62
|
+
const backupDir = path.join(testDir, "backups");
|
|
63
|
+
fs.mkdirSync(backupDir, { recursive: true });
|
|
64
|
+
|
|
65
|
+
// Create 5 backups
|
|
66
|
+
for (let i = 1; i <= 5; i++) {
|
|
67
|
+
fs.writeFileSync(path.join(backupDir, `backup-${i}.yaml`), "test");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Simulate pruning to keep 2
|
|
71
|
+
const files = fs.readdirSync(backupDir).sort().reverse();
|
|
72
|
+
const toDelete = files.slice(2);
|
|
73
|
+
toDelete.forEach(f => fs.unlinkSync(path.join(backupDir, f)));
|
|
74
|
+
|
|
75
|
+
expect(fs.readdirSync(backupDir)).toHaveLength(2);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Master Checklist Runner - Agent Skill Kit
|
|
4
|
+
==========================================
|
|
5
|
+
|
|
6
|
+
Orchestrates all validation scripts in priority order.
|
|
7
|
+
Use this for incremental validation during development.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
python scripts/checklist.py . # Run core checks
|
|
11
|
+
python scripts/checklist.py . --url <URL> # Include performance checks
|
|
12
|
+
|
|
13
|
+
Priority Order:
|
|
14
|
+
P0: Security Scan (vulnerabilities, secrets)
|
|
15
|
+
P1: Lint & Type Check (code quality)
|
|
16
|
+
P2: Schema Validation (if database exists)
|
|
17
|
+
P3: Test Runner (unit/integration tests)
|
|
18
|
+
P4: UX Audit (psychology laws, accessibility)
|
|
19
|
+
P5: SEO Check (meta tags, structure)
|
|
20
|
+
P6: Performance (lighthouse - requires URL)
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
import sys
|
|
24
|
+
import subprocess
|
|
25
|
+
import argparse
|
|
26
|
+
from pathlib import Path
|
|
27
|
+
from typing import List, Tuple, Optional
|
|
28
|
+
|
|
29
|
+
# ANSI colors for terminal output
|
|
30
|
+
class Colors:
|
|
31
|
+
HEADER = '\033[95m'
|
|
32
|
+
BLUE = '\033[94m'
|
|
33
|
+
CYAN = '\033[96m'
|
|
34
|
+
GREEN = '\033[92m'
|
|
35
|
+
YELLOW = '\033[93m'
|
|
36
|
+
RED = '\033[91m'
|
|
37
|
+
ENDC = '\033[0m'
|
|
38
|
+
BOLD = '\033[1m'
|
|
39
|
+
|
|
40
|
+
def print_header(text: str):
|
|
41
|
+
print(f"\n{Colors.BOLD}{Colors.CYAN}{'='*60}{Colors.ENDC}")
|
|
42
|
+
print(f"{Colors.BOLD}{Colors.CYAN}{text.center(60)}{Colors.ENDC}")
|
|
43
|
+
print(f"{Colors.BOLD}{Colors.CYAN}{'='*60}{Colors.ENDC}\n")
|
|
44
|
+
|
|
45
|
+
def print_step(text: str):
|
|
46
|
+
print(f"{Colors.BOLD}{Colors.BLUE}🔄 {text}{Colors.ENDC}")
|
|
47
|
+
|
|
48
|
+
def print_success(text: str):
|
|
49
|
+
print(f"{Colors.GREEN}✅ {text}{Colors.ENDC}")
|
|
50
|
+
|
|
51
|
+
def print_warning(text: str):
|
|
52
|
+
print(f"{Colors.YELLOW}⚠️ {text}{Colors.ENDC}")
|
|
53
|
+
|
|
54
|
+
def print_error(text: str):
|
|
55
|
+
print(f"{Colors.RED}❌ {text}{Colors.ENDC}")
|
|
56
|
+
|
|
57
|
+
# Define priority-ordered checks
|
|
58
|
+
CORE_CHECKS = [
|
|
59
|
+
("Security Scan", ".agent/skills/vulnerability-scanner/scripts/security_scan.py", True),
|
|
60
|
+
("Smart Audit", ".agent/scripts/audit.js", True),
|
|
61
|
+
("Lint Check", ".agent/skills/lint-and-validate/scripts/lint_runner.py", True),
|
|
62
|
+
("Schema Validation", ".agent/skills/database-design/scripts/schema_validator.py", False),
|
|
63
|
+
("Test Runner", ".agent/skills/testing-patterns/scripts/test_runner.py", False),
|
|
64
|
+
("UX Audit", ".agent/skills/frontend-design/scripts/ux_audit.py", False),
|
|
65
|
+
("SEO Check", ".agent/skills/seo-fundamentals/scripts/seo_checker.py", False),
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
PERFORMANCE_CHECKS = [
|
|
69
|
+
("Lighthouse Audit", ".agent/skills/performance-profiling/scripts/lighthouse_audit.py", True),
|
|
70
|
+
("Playwright E2E", ".agent/skills/webapp-testing/scripts/playwright_runner.py", False),
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
def check_script_exists(script_path: Path) -> bool:
|
|
74
|
+
"""Check if script file exists"""
|
|
75
|
+
return script_path.exists() and script_path.is_file()
|
|
76
|
+
|
|
77
|
+
def run_script(name: str, script_path: Path, project_path: str, url: Optional[str] = None) -> dict:
|
|
78
|
+
"""
|
|
79
|
+
Run a validation script and capture results
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
dict with keys: name, passed, output, skipped
|
|
83
|
+
"""
|
|
84
|
+
if not check_script_exists(script_path):
|
|
85
|
+
print_warning(f"{name}: Script not found, skipping")
|
|
86
|
+
return {"name": name, "passed": True, "output": "", "skipped": True}
|
|
87
|
+
|
|
88
|
+
print_step(f"Running: {name}")
|
|
89
|
+
|
|
90
|
+
# Build command
|
|
91
|
+
if str(script_path).endswith('.js'):
|
|
92
|
+
cmd = ["node", str(script_path), project_path]
|
|
93
|
+
else:
|
|
94
|
+
cmd = ["python", str(script_path), project_path]
|
|
95
|
+
|
|
96
|
+
if url and ("lighthouse" in script_path.name.lower() or "playwright" in script_path.name.lower()):
|
|
97
|
+
cmd.append(url)
|
|
98
|
+
|
|
99
|
+
# Run script
|
|
100
|
+
try:
|
|
101
|
+
result = subprocess.run(
|
|
102
|
+
cmd,
|
|
103
|
+
capture_output=True,
|
|
104
|
+
text=True,
|
|
105
|
+
timeout=300 # 5 minute timeout
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
passed = result.returncode == 0
|
|
109
|
+
|
|
110
|
+
if passed:
|
|
111
|
+
print_success(f"{name}: PASSED")
|
|
112
|
+
else:
|
|
113
|
+
print_error(f"{name}: FAILED")
|
|
114
|
+
if result.stderr:
|
|
115
|
+
print(f" Error: {result.stderr[:200]}")
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
"name": name,
|
|
119
|
+
"passed": passed,
|
|
120
|
+
"output": result.stdout,
|
|
121
|
+
"error": result.stderr,
|
|
122
|
+
"skipped": False
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
except subprocess.TimeoutExpired:
|
|
126
|
+
print_error(f"{name}: TIMEOUT (>5 minutes)")
|
|
127
|
+
return {"name": name, "passed": False, "output": "", "error": "Timeout", "skipped": False}
|
|
128
|
+
|
|
129
|
+
except Exception as e:
|
|
130
|
+
print_error(f"{name}: ERROR - {str(e)}")
|
|
131
|
+
return {"name": name, "passed": False, "output": "", "error": str(e), "skipped": False}
|
|
132
|
+
|
|
133
|
+
def print_summary(results: List[dict]):
|
|
134
|
+
"""Print final summary report"""
|
|
135
|
+
print_header("📊 CHECKLIST SUMMARY")
|
|
136
|
+
|
|
137
|
+
passed_count = sum(1 for r in results if r["passed"] and not r.get("skipped"))
|
|
138
|
+
failed_count = sum(1 for r in results if not r["passed"] and not r.get("skipped"))
|
|
139
|
+
skipped_count = sum(1 for r in results if r.get("skipped"))
|
|
140
|
+
|
|
141
|
+
print(f"Total Checks: {len(results)}")
|
|
142
|
+
print(f"{Colors.GREEN}✅ Passed: {passed_count}{Colors.ENDC}")
|
|
143
|
+
print(f"{Colors.RED}❌ Failed: {failed_count}{Colors.ENDC}")
|
|
144
|
+
print(f"{Colors.YELLOW}⏭️ Skipped: {skipped_count}{Colors.ENDC}")
|
|
145
|
+
print()
|
|
146
|
+
|
|
147
|
+
# Detailed results
|
|
148
|
+
for r in results:
|
|
149
|
+
if r.get("skipped"):
|
|
150
|
+
status = f"{Colors.YELLOW}⏭️ {Colors.ENDC}"
|
|
151
|
+
elif r["passed"]:
|
|
152
|
+
status = f"{Colors.GREEN}✅{Colors.ENDC}"
|
|
153
|
+
else:
|
|
154
|
+
status = f"{Colors.RED}❌{Colors.ENDC}"
|
|
155
|
+
|
|
156
|
+
print(f"{status} {r['name']}")
|
|
157
|
+
|
|
158
|
+
print()
|
|
159
|
+
|
|
160
|
+
if failed_count > 0:
|
|
161
|
+
print_error(f"{failed_count} check(s) FAILED - Please fix before proceeding")
|
|
162
|
+
return False
|
|
163
|
+
else:
|
|
164
|
+
print_success("All checks PASSED ✨")
|
|
165
|
+
return True
|
|
166
|
+
|
|
167
|
+
def main():
|
|
168
|
+
parser = argparse.ArgumentParser(
|
|
169
|
+
description="Run Agent Skill Kit validation checklist",
|
|
170
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
171
|
+
epilog="""
|
|
172
|
+
Examples:
|
|
173
|
+
python scripts/checklist.py . # Core checks only
|
|
174
|
+
python scripts/checklist.py . --url http://localhost:3000 # Include performance
|
|
175
|
+
"""
|
|
176
|
+
)
|
|
177
|
+
parser.add_argument("project", help="Project path to validate")
|
|
178
|
+
parser.add_argument("--url", help="URL for performance checks (lighthouse, playwright)")
|
|
179
|
+
parser.add_argument("--skip-performance", action="store_true", help="Skip performance checks even if URL provided")
|
|
180
|
+
|
|
181
|
+
args = parser.parse_args()
|
|
182
|
+
|
|
183
|
+
project_path = Path(args.project).resolve()
|
|
184
|
+
|
|
185
|
+
if not project_path.exists():
|
|
186
|
+
print_error(f"Project path does not exist: {project_path}")
|
|
187
|
+
sys.exit(1)
|
|
188
|
+
|
|
189
|
+
print_header("🚀 AGENT SKILLS KIT - MASTER CHECKLIST")
|
|
190
|
+
print(f"Project: {project_path}")
|
|
191
|
+
print(f"URL: {args.url if args.url else 'Not provided (performance checks skipped)'}")
|
|
192
|
+
|
|
193
|
+
results = []
|
|
194
|
+
|
|
195
|
+
# Run core checks
|
|
196
|
+
print_header("📋 CORE CHECKS")
|
|
197
|
+
for name, script_path, required in CORE_CHECKS:
|
|
198
|
+
script = project_path / script_path
|
|
199
|
+
result = run_script(name, script, str(project_path))
|
|
200
|
+
results.append(result)
|
|
201
|
+
|
|
202
|
+
# If required check fails, stop
|
|
203
|
+
if required and not result["passed"] and not result.get("skipped"):
|
|
204
|
+
print_error(f"CRITICAL: {name} failed. Stopping checklist.")
|
|
205
|
+
print_summary(results)
|
|
206
|
+
sys.exit(1)
|
|
207
|
+
|
|
208
|
+
# Run performance checks if URL provided
|
|
209
|
+
if args.url and not args.skip_performance:
|
|
210
|
+
print_header("⚡ PERFORMANCE CHECKS")
|
|
211
|
+
for name, script_path, required in PERFORMANCE_CHECKS:
|
|
212
|
+
script = project_path / script_path
|
|
213
|
+
result = run_script(name, script, str(project_path), args.url)
|
|
214
|
+
results.append(result)
|
|
215
|
+
|
|
216
|
+
# Print summary
|
|
217
|
+
all_passed = print_summary(results)
|
|
218
|
+
|
|
219
|
+
sys.exit(0 if all_passed else 1)
|
|
220
|
+
|
|
221
|
+
if __name__ == "__main__":
|
|
222
|
+
main()
|