agentic-kdd 2.0.7 → 2.1.1
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/akdd.js +10 -5
- package/package.json +7 -3
- package/src/dashboard-template.cjs +1730 -0
- package/src/dashboard-template.js +1345 -0
- package/src/dashboard.js +57 -0
- package/src/graph.js +27 -36
- package/src/init.js +280 -125
- package/templates/.agentic/grafo/grafo.cjs +524 -0
- package/templates/.agentic/grafo/schema.sql +95 -0
- package/templates/.agentic/grafo/watch-errors.cjs +238 -0
package/src/dashboard.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs-extra');
|
|
5
|
+
const chalk = require('chalk');
|
|
6
|
+
const { execSync } = require('child_process');
|
|
7
|
+
|
|
8
|
+
async function dashboard() {
|
|
9
|
+
const projectPath = process.cwd();
|
|
10
|
+
const configPath = path.join(projectPath, '.agentic', 'config.md');
|
|
11
|
+
const grafoCjs = path.join(projectPath, '.agentic', 'grafo', 'grafo.cjs');
|
|
12
|
+
const grafoJs = path.join(projectPath, '.agentic', 'grafo', 'grafo.js');
|
|
13
|
+
|
|
14
|
+
if (!fs.existsSync(configPath)) {
|
|
15
|
+
console.log(chalk.yellow('\n Agentic KDD not installed in this project.'));
|
|
16
|
+
console.log(chalk.gray(' Run: akdd init\n'));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Sync graph
|
|
21
|
+
const grafoPath = fs.existsSync(grafoCjs) ? grafoCjs : grafoJs;
|
|
22
|
+
if (fs.existsSync(grafoPath)) {
|
|
23
|
+
try {
|
|
24
|
+
process.stdout.write(chalk.gray(' Syncing knowledge graph... '));
|
|
25
|
+
execSync(`node "${grafoPath}" sync`, { stdio: 'pipe', cwd: projectPath });
|
|
26
|
+
console.log(chalk.green('✓'));
|
|
27
|
+
} catch (e) {}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Check for local dashboard first
|
|
31
|
+
const localCjs = path.join(projectPath, 'dashboard.cjs');
|
|
32
|
+
const localJs = path.join(projectPath, 'dashboard.js');
|
|
33
|
+
const template = path.join(__dirname, 'dashboard-template.cjs');
|
|
34
|
+
|
|
35
|
+
const dashPath = fs.existsSync(localCjs) ? localCjs
|
|
36
|
+
: fs.existsSync(localJs) ? localJs
|
|
37
|
+
: fs.existsSync(template) ? template
|
|
38
|
+
: null;
|
|
39
|
+
|
|
40
|
+
if (!dashPath) {
|
|
41
|
+
console.log(chalk.yellow('\n Dashboard not found.'));
|
|
42
|
+
console.log(chalk.gray(' Copy dashboard.cjs to your project root.\n'));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log(chalk.blue('\n Agentic KDD Dashboard v4'));
|
|
47
|
+
const origCwd = process.cwd();
|
|
48
|
+
process.chdir(projectPath);
|
|
49
|
+
try {
|
|
50
|
+
require(dashPath);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.log(chalk.red(' Error: ' + e.message));
|
|
53
|
+
process.chdir(origCwd);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = { dashboard };
|
package/src/graph.js
CHANGED
|
@@ -7,64 +7,55 @@ const { execSync } = require('child_process');
|
|
|
7
7
|
|
|
8
8
|
async function graph() {
|
|
9
9
|
const projectPath = process.cwd();
|
|
10
|
-
const grafoPath = path.join(projectPath, '.agentic', 'grafo', 'grafo.
|
|
11
|
-
const
|
|
12
|
-
const
|
|
10
|
+
const grafoPath = path.join(projectPath, '.agentic', 'grafo', 'grafo.cjs');
|
|
11
|
+
const grafoOld = path.join(projectPath, '.agentic', 'grafo', 'grafo.js');
|
|
12
|
+
const dbPath = path.join(projectPath, '.agentic', 'memoria.db');
|
|
13
13
|
|
|
14
|
-
// Verificar que Agentic está instalado
|
|
15
14
|
if (!fs.existsSync(path.join(projectPath, '.agentic', 'config.md'))) {
|
|
16
15
|
console.log(chalk.yellow('\n Agentic KDD no está instalado en este proyecto.'));
|
|
17
16
|
console.log(chalk.gray(' Corre akdd init para instalarlo.\n'));
|
|
18
17
|
return;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
if (!
|
|
23
|
-
console.log(chalk.yellow('\n El grafo no está disponible
|
|
20
|
+
const grafo = fs.existsSync(grafoPath) ? grafoPath : fs.existsSync(grafoOld) ? grafoOld : null;
|
|
21
|
+
if (!grafo) {
|
|
22
|
+
console.log(chalk.yellow('\n El grafo no está disponible.'));
|
|
24
23
|
console.log(chalk.gray(' Actualiza con: akdd update\n'));
|
|
25
24
|
return;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
console.log('\n' + chalk.bold.
|
|
27
|
+
console.log('\n' + chalk.bold.hex('#8b5cf6')(' Agentic KDD') + chalk.gray(' — grafo de conocimiento\n'));
|
|
29
28
|
|
|
30
|
-
// Sincronizar primero
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
console.log(chalk.yellow('⚠ No se pudo sincronizar'));
|
|
38
|
-
}
|
|
29
|
+
// Sincronizar primero
|
|
30
|
+
try {
|
|
31
|
+
process.stdout.write(chalk.gray(' Sincronizando memoria... '));
|
|
32
|
+
execSync(`node "${grafo}" sync`, { stdio: 'pipe', cwd: projectPath });
|
|
33
|
+
console.log(chalk.green('✓'));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.log(chalk.yellow('⚠ No se pudo sincronizar'));
|
|
39
36
|
}
|
|
40
37
|
|
|
41
|
-
//
|
|
38
|
+
// Stats
|
|
42
39
|
if (fs.existsSync(dbPath)) {
|
|
43
40
|
try {
|
|
44
|
-
const output = execSync(`node "${
|
|
45
|
-
stdio: 'pipe',
|
|
46
|
-
cwd: projectPath
|
|
47
|
-
}).toString();
|
|
41
|
+
const output = execSync(`node "${grafo}" stats`, { stdio: 'pipe', cwd: projectPath }).toString();
|
|
48
42
|
console.log(output);
|
|
49
43
|
} catch (e) {
|
|
50
|
-
console.log(chalk.red(' Error
|
|
44
|
+
console.log(chalk.red(' Error: ' + e.message));
|
|
51
45
|
}
|
|
52
46
|
} else {
|
|
53
|
-
console.log(chalk.gray(' Sin datos aún —
|
|
54
|
-
console.log(chalk.gray(' Tip: después de cada tarea con aa:, el sistema actualiza el grafo solo.\n'));
|
|
47
|
+
console.log(chalk.gray(' Sin datos aún — usa aa: para empezar\n'));
|
|
55
48
|
}
|
|
56
49
|
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
console.log('');
|
|
67
|
-
}
|
|
50
|
+
// Métricas si hay ciclos
|
|
51
|
+
try {
|
|
52
|
+
const m = JSON.parse(execSync(`node "${grafo}" metricas`, { stdio: 'pipe', cwd: projectPath }).toString());
|
|
53
|
+
if (m.total > 0) {
|
|
54
|
+
console.log(chalk.bold(' Métricas del agente:'));
|
|
55
|
+
console.log(` Goal Attainment: ${chalk.green(m.goal_attainment+'%')} | Autonomy: ${chalk.cyan(m.autonomy_ratio+'%')} | Handoff: ${chalk.green(m.handoff_integrity+'%')}`);
|
|
56
|
+
console.log(` Patrones aplicados: ${m.patrones_aplicados} | Errores evitados: ${m.errores_evitados}\n`);
|
|
57
|
+
}
|
|
58
|
+
} catch(e) {}
|
|
68
59
|
}
|
|
69
60
|
|
|
70
61
|
module.exports = { graph };
|