add-skill-kit 3.2.2 → 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/bin/lib/commands/install.js +67 -45
- package/lib/agent-cli/README.md +21 -0
- package/lib/agent-cli/bin/ag-smart.js +158 -0
- 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 +11 -6
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Shell completion scripts generator
|
|
3
|
+
* Supports PowerShell, Bash, and Zsh
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* All available commands for completion
|
|
8
|
+
*/
|
|
9
|
+
const COMMANDS = [
|
|
10
|
+
{ name: "learn", description: "Teach a new pattern" },
|
|
11
|
+
{ name: "recall", description: "Scan for violations" },
|
|
12
|
+
{ name: "stats", description: "View statistics" },
|
|
13
|
+
{ name: "audit", description: "Run compliance check" },
|
|
14
|
+
{ name: "watch", description: "Real-time monitoring" },
|
|
15
|
+
{ name: "settings", description: "Configure agent behavior" },
|
|
16
|
+
{ name: "backup", description: "Backup & restore data" },
|
|
17
|
+
{ name: "export", description: "Export & import data" },
|
|
18
|
+
{ name: "proposals", description: "AI agent skill updates" },
|
|
19
|
+
{ name: "completion", description: "Shell completion scripts" },
|
|
20
|
+
{ name: "init", description: "Initialize agent config" },
|
|
21
|
+
{ name: "help", description: "Show help" }
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Generate PowerShell completion script
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
28
|
+
export function generatePowerShellCompletion() {
|
|
29
|
+
const commands = COMMANDS.map(c => `'${c.name}'`).join(", ");
|
|
30
|
+
|
|
31
|
+
return `
|
|
32
|
+
# Agent Skill Kit PowerShell Completion
|
|
33
|
+
# Add to your $PROFILE
|
|
34
|
+
|
|
35
|
+
Register-ArgumentCompleter -Native -CommandName agent -ScriptBlock {
|
|
36
|
+
param($wordToComplete, $commandAst, $cursorPosition)
|
|
37
|
+
|
|
38
|
+
$commands = @(
|
|
39
|
+
${COMMANDS.map(c => ` @{ Name = '${c.name}'; Description = '${c.description}' }`).join("\n")}
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
$commands | Where-Object { $_.Name -like "$wordToComplete*" } | ForEach-Object {
|
|
43
|
+
[System.Management.Automation.CompletionResult]::new(
|
|
44
|
+
$_.Name,
|
|
45
|
+
$_.Name,
|
|
46
|
+
'ParameterValue',
|
|
47
|
+
$_.Description
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
Write-Host "Agent Skill Kit completion loaded" -ForegroundColor Green
|
|
53
|
+
`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Generate Bash completion script
|
|
58
|
+
* @returns {string}
|
|
59
|
+
*/
|
|
60
|
+
export function generateBashCompletion() {
|
|
61
|
+
const commands = COMMANDS.map(c => c.name).join(" ");
|
|
62
|
+
|
|
63
|
+
return `
|
|
64
|
+
# Agent Skill Kit Bash Completion
|
|
65
|
+
# Add to ~/.bashrc or ~/.bash_completion
|
|
66
|
+
|
|
67
|
+
_agent_completions() {
|
|
68
|
+
local cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
69
|
+
local commands="${commands}"
|
|
70
|
+
|
|
71
|
+
COMPREPLY=($(compgen -W "$commands" -- "$cur"))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
complete -F _agent_completions agent
|
|
75
|
+
|
|
76
|
+
echo "Agent Skill Kit completion loaded"
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Generate Zsh completion script
|
|
82
|
+
* @returns {string}
|
|
83
|
+
*/
|
|
84
|
+
export function generateZshCompletion() {
|
|
85
|
+
return `
|
|
86
|
+
#compdef agent
|
|
87
|
+
|
|
88
|
+
# Agent Skill Kit Zsh Completion
|
|
89
|
+
# Add to ~/.zshrc or place in $fpath
|
|
90
|
+
|
|
91
|
+
_agent() {
|
|
92
|
+
local -a commands
|
|
93
|
+
commands=(
|
|
94
|
+
${COMMANDS.map(c => ` '${c.name}:${c.description}'`).join("\n")}
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
_describe 'command' commands
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
compdef _agent agent
|
|
101
|
+
|
|
102
|
+
echo "Agent Skill Kit completion loaded"
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Get shell type from environment
|
|
108
|
+
* @returns {string} 'powershell' | 'bash' | 'zsh' | 'unknown'
|
|
109
|
+
*/
|
|
110
|
+
export function detectShell() {
|
|
111
|
+
if (process.platform === "win32") {
|
|
112
|
+
return "powershell";
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const shell = process.env.SHELL || "";
|
|
116
|
+
if (shell.includes("zsh")) return "zsh";
|
|
117
|
+
if (shell.includes("bash")) return "bash";
|
|
118
|
+
|
|
119
|
+
return "unknown";
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Get completion script for current or specified shell
|
|
124
|
+
* @param {string} [shell] - Optional shell type
|
|
125
|
+
* @returns {{ shell: string, script: string }}
|
|
126
|
+
*/
|
|
127
|
+
export function getCompletionScript(shell) {
|
|
128
|
+
const targetShell = shell || detectShell();
|
|
129
|
+
|
|
130
|
+
switch (targetShell) {
|
|
131
|
+
case "powershell":
|
|
132
|
+
return { shell: "powershell", script: generatePowerShellCompletion() };
|
|
133
|
+
case "bash":
|
|
134
|
+
return { shell: "bash", script: generateBashCompletion() };
|
|
135
|
+
case "zsh":
|
|
136
|
+
return { shell: "zsh", script: generateZshCompletion() };
|
|
137
|
+
default:
|
|
138
|
+
return { shell: "unknown", script: "" };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export default {
|
|
143
|
+
COMMANDS,
|
|
144
|
+
generatePowerShellCompletion,
|
|
145
|
+
generateBashCompletion,
|
|
146
|
+
generateZshCompletion,
|
|
147
|
+
detectShell,
|
|
148
|
+
getCompletionScript
|
|
149
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Configuration for agent-skill-kit CLI
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
import { createRequire } from "module";
|
|
8
|
+
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
|
|
12
|
+
/** Current working directory */
|
|
13
|
+
export const cwd = process.cwd();
|
|
14
|
+
|
|
15
|
+
/** Path to .agent directory (configurable via AGENT_DIR env) */
|
|
16
|
+
export const AGENT_DIR = process.env.AGENT_DIR || path.join(cwd, ".agent");
|
|
17
|
+
|
|
18
|
+
/** Path to knowledge directory */
|
|
19
|
+
export const KNOWLEDGE_DIR = path.join(AGENT_DIR, "knowledge");
|
|
20
|
+
|
|
21
|
+
/** Path to lessons learned file */
|
|
22
|
+
export const LESSONS_PATH = path.join(KNOWLEDGE_DIR, "lessons-learned.yaml");
|
|
23
|
+
|
|
24
|
+
/** Path to rules directory */
|
|
25
|
+
export const RULES_DIR = path.join(AGENT_DIR, "rules");
|
|
26
|
+
|
|
27
|
+
/** CLI version - read from package.json */
|
|
28
|
+
export const VERSION = (() => {
|
|
29
|
+
try { return require("../package.json").version; }
|
|
30
|
+
catch { return "2.2.0"; }
|
|
31
|
+
})();
|
|
32
|
+
|
|
33
|
+
/** Debug mode */
|
|
34
|
+
export const DEBUG = process.env.DEBUG === "true";
|
|
35
|
+
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* ESLint Fix Integration
|
|
4
|
+
*
|
|
5
|
+
* Wrapper around ESLint --fix to combine with pattern-based fix.
|
|
6
|
+
* Auto-detects ESLint config and runs fixes.
|
|
7
|
+
*
|
|
8
|
+
* Usage: ag-smart fix --eslint <path>
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { execSync, spawnSync } from "child_process";
|
|
12
|
+
import fs from "fs";
|
|
13
|
+
import path from "path";
|
|
14
|
+
import { VERSION } from "./config.js";
|
|
15
|
+
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// ESLINT DETECTION
|
|
18
|
+
// ============================================================================
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Find ESLint config file in project
|
|
22
|
+
* @param {string} dir
|
|
23
|
+
* @returns {string|null}
|
|
24
|
+
*/
|
|
25
|
+
function findEslintConfig(dir) {
|
|
26
|
+
const configFiles = [
|
|
27
|
+
".eslintrc.js",
|
|
28
|
+
".eslintrc.cjs",
|
|
29
|
+
".eslintrc.json",
|
|
30
|
+
".eslintrc.yaml",
|
|
31
|
+
".eslintrc.yml",
|
|
32
|
+
".eslintrc",
|
|
33
|
+
"eslint.config.js",
|
|
34
|
+
"eslint.config.mjs"
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
let current = dir;
|
|
38
|
+
while (current !== path.dirname(current)) {
|
|
39
|
+
for (const config of configFiles) {
|
|
40
|
+
const configPath = path.join(current, config);
|
|
41
|
+
if (fs.existsSync(configPath)) {
|
|
42
|
+
return configPath;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Check package.json for eslintConfig
|
|
46
|
+
const pkgPath = path.join(current, "package.json");
|
|
47
|
+
if (fs.existsSync(pkgPath)) {
|
|
48
|
+
try {
|
|
49
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
50
|
+
if (pkg.eslintConfig) {
|
|
51
|
+
return pkgPath; // ESLint config in package.json
|
|
52
|
+
}
|
|
53
|
+
} catch (e) { }
|
|
54
|
+
}
|
|
55
|
+
current = path.dirname(current);
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Check if ESLint is available
|
|
62
|
+
* @returns {boolean}
|
|
63
|
+
*/
|
|
64
|
+
function isEslintAvailable() {
|
|
65
|
+
try {
|
|
66
|
+
execSync("npx eslint --version", { stdio: "ignore" });
|
|
67
|
+
return true;
|
|
68
|
+
} catch (e) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// ESLINT FIX
|
|
75
|
+
// ============================================================================
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Run ESLint --fix on a path
|
|
79
|
+
* @param {string} targetPath
|
|
80
|
+
* @param {object} options
|
|
81
|
+
* @returns {{ success: boolean, fixed: number, errors: number }}
|
|
82
|
+
*/
|
|
83
|
+
export function runEslintFix(targetPath, options = {}) {
|
|
84
|
+
const result = {
|
|
85
|
+
success: false,
|
|
86
|
+
fixed: 0,
|
|
87
|
+
errors: 0,
|
|
88
|
+
output: ""
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
if (!isEslintAvailable()) {
|
|
92
|
+
console.log("⚠️ ESLint not found. Install with: npm install eslint -D");
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const configPath = findEslintConfig(process.cwd());
|
|
97
|
+
if (!configPath && !options.noConfig) {
|
|
98
|
+
console.log("⚠️ No ESLint config found. Run: npx eslint --init");
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
console.log(`\n🔧 Running ESLint --fix...`);
|
|
103
|
+
if (configPath) {
|
|
104
|
+
console.log(` Config: ${path.relative(process.cwd(), configPath)}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
// Run ESLint with --fix
|
|
109
|
+
const args = [
|
|
110
|
+
"eslint",
|
|
111
|
+
targetPath,
|
|
112
|
+
"--fix",
|
|
113
|
+
"--format", "json"
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
const proc = spawnSync("npx", args, {
|
|
117
|
+
encoding: "utf8",
|
|
118
|
+
shell: true,
|
|
119
|
+
maxBuffer: 10 * 1024 * 1024
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Parse output
|
|
123
|
+
if (proc.stdout) {
|
|
124
|
+
try {
|
|
125
|
+
const results = JSON.parse(proc.stdout);
|
|
126
|
+
let totalFixed = 0;
|
|
127
|
+
let totalErrors = 0;
|
|
128
|
+
|
|
129
|
+
results.forEach(file => {
|
|
130
|
+
if (file.output) {
|
|
131
|
+
// File was fixed (output contains fixed content)
|
|
132
|
+
totalFixed++;
|
|
133
|
+
}
|
|
134
|
+
totalErrors += file.errorCount || 0;
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
result.fixed = totalFixed;
|
|
138
|
+
result.errors = totalErrors;
|
|
139
|
+
result.success = true;
|
|
140
|
+
result.output = proc.stdout;
|
|
141
|
+
|
|
142
|
+
console.log(` ✅ Fixed: ${totalFixed} file(s)`);
|
|
143
|
+
if (totalErrors > 0) {
|
|
144
|
+
console.log(` ⚠️ Remaining errors: ${totalErrors}`);
|
|
145
|
+
}
|
|
146
|
+
} catch (e) {
|
|
147
|
+
// JSON parse failed, but fix might still have worked
|
|
148
|
+
result.success = proc.status === 0;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (proc.status === 0) {
|
|
153
|
+
result.success = true;
|
|
154
|
+
console.log(" ✅ ESLint fix completed");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
} catch (error) {
|
|
158
|
+
console.error(` ❌ ESLint error: ${error.message}`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ============================================================================
|
|
165
|
+
// COMBINED FIX
|
|
166
|
+
// ============================================================================
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Run combined fix (ESLint + pattern-based)
|
|
170
|
+
* @param {string} targetPath
|
|
171
|
+
* @param {object} options
|
|
172
|
+
*/
|
|
173
|
+
export async function runCombinedFix(targetPath, options = {}) {
|
|
174
|
+
console.log(`\n🔧 Combined Fix v${VERSION}`);
|
|
175
|
+
console.log(`📂 Target: ${targetPath}`);
|
|
176
|
+
console.log("─".repeat(50));
|
|
177
|
+
|
|
178
|
+
// Step 1: ESLint fix
|
|
179
|
+
if (options.eslint !== false) {
|
|
180
|
+
runEslintFix(targetPath, options);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Step 2: Pattern-based fix (import dynamically)
|
|
184
|
+
console.log("\n🧠 Running pattern-based fix...");
|
|
185
|
+
try {
|
|
186
|
+
const { fixDirectory } = await import("./fix.js");
|
|
187
|
+
const { loadKnowledge } = await import("./recall.js");
|
|
188
|
+
|
|
189
|
+
const db = loadKnowledge();
|
|
190
|
+
const results = fixDirectory(targetPath, db, options.mode || "safe");
|
|
191
|
+
|
|
192
|
+
if (results.length > 0) {
|
|
193
|
+
let total = 0;
|
|
194
|
+
results.forEach(r => total += r.fixes);
|
|
195
|
+
console.log(` ✅ Pattern fixes: ${total}`);
|
|
196
|
+
} else {
|
|
197
|
+
console.log(" ✅ No pattern violations to fix");
|
|
198
|
+
}
|
|
199
|
+
} catch (e) {
|
|
200
|
+
console.log(` ⚠️ Pattern fix skipped: ${e.message}`);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
console.log("\n" + "─".repeat(50));
|
|
204
|
+
console.log("🎉 Combined fix completed!");
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// ============================================================================
|
|
208
|
+
// CLI
|
|
209
|
+
// ============================================================================
|
|
210
|
+
|
|
211
|
+
const args = process.argv.slice(2);
|
|
212
|
+
|
|
213
|
+
if (args.includes("--help") || args.length === 0) {
|
|
214
|
+
console.log(`
|
|
215
|
+
🔧 ESLint Fix Integration v${VERSION}
|
|
216
|
+
|
|
217
|
+
Usage:
|
|
218
|
+
node eslint-fix.js <path> [options]
|
|
219
|
+
|
|
220
|
+
Options:
|
|
221
|
+
--no-eslint Skip ESLint fix
|
|
222
|
+
--no-pattern Skip pattern-based fix
|
|
223
|
+
--mode <mode> Pattern fix mode (safe|aggressive)
|
|
224
|
+
--help Show this help
|
|
225
|
+
|
|
226
|
+
This combines ESLint --fix with pattern-based fixes.
|
|
227
|
+
`);
|
|
228
|
+
process.exit(0);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const target = args[0];
|
|
232
|
+
const options = {
|
|
233
|
+
eslint: !args.includes("--no-eslint"),
|
|
234
|
+
pattern: !args.includes("--no-pattern"),
|
|
235
|
+
mode: args.includes("--mode") ? args[args.indexOf("--mode") + 1] : "safe"
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
runCombinedFix(target, options);
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evolution Signal Layer - Backward Compatibility Adapter
|
|
3
|
+
*
|
|
4
|
+
* This file maintains the old API while delegating to the new architecture.
|
|
5
|
+
* Allows gradual migration without breaking existing code.
|
|
6
|
+
*
|
|
7
|
+
* OLD LOCATION: lib/evolution-signal.js
|
|
8
|
+
* NEW LOCATION: src/core/evolution/* + src/data/repositories/*
|
|
9
|
+
*
|
|
10
|
+
* @deprecated Use new architecture: import from 'src/core/evolution'
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Import new architecture components
|
|
14
|
+
import { EvolutionSignal } from '../src/core/evolution/evolution-signal.js';
|
|
15
|
+
import { ThresholdChecker } from '../src/core/evolution/threshold-checker.js';
|
|
16
|
+
import { ReviewGate } from '../src/core/evolution/review-gate.js';
|
|
17
|
+
import { SignalRepository } from '../src/data/repositories/signal-repository.js';
|
|
18
|
+
import { JsonStorage } from '../src/data/storage/json-storage.js';
|
|
19
|
+
import { SignalDetector as SignalService } from '../src/core/evolution/signal-detector.js';
|
|
20
|
+
import { KNOWLEDGE_DIR } from './config.js';
|
|
21
|
+
|
|
22
|
+
// ============================================================================
|
|
23
|
+
// BACKWARD COMPATIBLE EXPORTS
|
|
24
|
+
// ============================================================================
|
|
25
|
+
|
|
26
|
+
// Re-export EvolutionSignal class
|
|
27
|
+
export { EvolutionSignal };
|
|
28
|
+
|
|
29
|
+
// Lazy-initialized singleton instances
|
|
30
|
+
let _storage = null;
|
|
31
|
+
let _repository = null;
|
|
32
|
+
let _detector = null;
|
|
33
|
+
|
|
34
|
+
function getDetector() {
|
|
35
|
+
if (!_detector) {
|
|
36
|
+
_storage = new JsonStorage(KNOWLEDGE_DIR);
|
|
37
|
+
_repository = new SignalRepository(_storage);
|
|
38
|
+
_detector = new SignalService(_repository);
|
|
39
|
+
}
|
|
40
|
+
return _detector;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// ============================================================================
|
|
44
|
+
// THRESHOLD CHECKER (Backward Compatible)
|
|
45
|
+
// ============================================================================
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use ThresholdChecker.check() from src/core/evolution
|
|
49
|
+
*/
|
|
50
|
+
export function checkEvolutionThreshold(lesson, threshold = 10) {
|
|
51
|
+
return ThresholdChecker.check(lesson, threshold);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Use ThresholdChecker.calculateStability() from src/core/evolution
|
|
56
|
+
*/
|
|
57
|
+
export function calculatePatternStability(violationHistory = []) {
|
|
58
|
+
return ThresholdChecker.calculateStability(violationHistory);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// SIGNAL QUEUE (Backward Compatible)
|
|
63
|
+
// ============================================================================
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* SignalQueue - Backward compatible class
|
|
67
|
+
* @deprecated Use SignalRepository + SignalDetector from new architecture
|
|
68
|
+
*/
|
|
69
|
+
class SignalQueueCompat {
|
|
70
|
+
get signals() {
|
|
71
|
+
// Return cached signals (sync access)
|
|
72
|
+
if (!this._cachedSignals) {
|
|
73
|
+
// Synchronous fallback - load on first access
|
|
74
|
+
this._cachedSignals = [];
|
|
75
|
+
this.load().then(signals => {
|
|
76
|
+
this._cachedSignals = signals;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return this._cachedSignals;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async load() {
|
|
83
|
+
const detector = getDetector();
|
|
84
|
+
const all = await detector.signalRepository.findAll();
|
|
85
|
+
this._cachedSignals = all;
|
|
86
|
+
return all;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async save() {
|
|
90
|
+
// Auto-save through repository (no-op for compatibility)
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async add(signal) {
|
|
95
|
+
const detector = getDetector();
|
|
96
|
+
const result = await detector.queue(
|
|
97
|
+
signal.lessonId,
|
|
98
|
+
{ ready: true, reason: signal.reason, confidence: signal.confidence },
|
|
99
|
+
signal.metadata
|
|
100
|
+
);
|
|
101
|
+
await this.load(); // Refresh cache
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
getPending() {
|
|
106
|
+
return this.signals.filter(s => s.status === 'pending');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getByLesson(lessonId) {
|
|
110
|
+
return this.signals.filter(s => s.lessonId === lessonId);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async approve(signalId) {
|
|
114
|
+
const detector = getDetector();
|
|
115
|
+
const result = await detector.approve(signalId);
|
|
116
|
+
await this.load(); // Refresh cache
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async reject(signalId) {
|
|
121
|
+
const detector = getDetector();
|
|
122
|
+
const result = await detector.reject(signalId);
|
|
123
|
+
await this.load(); // Refresh cache
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async execute(signalId) {
|
|
128
|
+
const detector = getDetector();
|
|
129
|
+
const result = await detector.execute(signalId);
|
|
130
|
+
await this.load(); // Refresh cache
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async cleanup() {
|
|
135
|
+
const detector = getDetector();
|
|
136
|
+
await detector.signalRepository.cleanup();
|
|
137
|
+
await this.load(); // Refresh cache
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Singleton instance for backward compatibility
|
|
142
|
+
const signalQueueInstance = new SignalQueueCompat();
|
|
143
|
+
|
|
144
|
+
// Initialize on module load
|
|
145
|
+
signalQueueInstance.load().catch(err => {
|
|
146
|
+
console.error('Failed to initialize signal queue:', err);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
export { signalQueueInstance as signalQueue };
|
|
150
|
+
|
|
151
|
+
// ============================================================================
|
|
152
|
+
// REVIEW GATE (Backward Compatible)
|
|
153
|
+
// ============================================================================
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Use ReviewGate.evaluate() from src/core/evolution
|
|
157
|
+
*/
|
|
158
|
+
export function reviewGate(signal, settings = {}) {
|
|
159
|
+
return ReviewGate.evaluate(signal, settings);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// ============================================================================
|
|
163
|
+
// HELPER FUNCTIONS (Backward Compatible)
|
|
164
|
+
// ============================================================================
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @deprecated Use SignalDetector.queue() from new architecture
|
|
168
|
+
*/
|
|
169
|
+
export async function queueEvolutionSignal(lessonId, checkResult, metadata = {}) {
|
|
170
|
+
if (!checkResult.ready) return null;
|
|
171
|
+
|
|
172
|
+
const signal = new EvolutionSignal(
|
|
173
|
+
lessonId,
|
|
174
|
+
checkResult.reason,
|
|
175
|
+
checkResult.confidence,
|
|
176
|
+
metadata
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
return signalQueueInstance.add(signal);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @deprecated Use SignalDetector.getStats() from new architecture
|
|
184
|
+
*/
|
|
185
|
+
export async function getEvolutionStats() {
|
|
186
|
+
const detector = getDetector();
|
|
187
|
+
return detector.getStats();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// ============================================================================
|
|
191
|
+
// MIGRATION GUIDE
|
|
192
|
+
// ============================================================================
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* HOW TO MIGRATE TO NEW ARCHITECTURE:
|
|
196
|
+
*
|
|
197
|
+
* OLD CODE:
|
|
198
|
+
* ```
|
|
199
|
+
* import { signalQueue, checkEvolutionThreshold } from './evolution-signal.js';
|
|
200
|
+
*
|
|
201
|
+
* const check = checkEvolutionThreshold(lesson, 10);
|
|
202
|
+
* await signalQueue.add(signal);
|
|
203
|
+
* ```
|
|
204
|
+
*
|
|
205
|
+
* NEW CODE:
|
|
206
|
+
* ```
|
|
207
|
+
* import { ThresholdChecker } from '../src/core/evolution/threshold-checker.js';
|
|
208
|
+
* import { SignalRepository } from '../src/data/repositories/signal-repository.js';
|
|
209
|
+
* import { SignalDetector } from '../src/core/evolution/signal-detector.js';
|
|
210
|
+
*
|
|
211
|
+
* const check = ThresholdChecker.check(lesson, 10);
|
|
212
|
+
* const detector = new SignalDetector(repository);
|
|
213
|
+
* await detector.queue(lessonId, check, metadata);
|
|
214
|
+
* ```
|
|
215
|
+
*/
|