@christianmaf80/agentic-workflow 1.21.0-beta.2 → 1.21.0-beta.3

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.
@@ -0,0 +1,89 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ export class ContextManager {
4
+ projectRoot;
5
+ corePath;
6
+ constructor(projectRoot, corePath) {
7
+ this.projectRoot = projectRoot;
8
+ this.corePath = corePath;
9
+ }
10
+ /**
11
+ * Resuelve un alias (ej: 'rules.constitution') a un conjunto de ficheros.
12
+ */
13
+ async resolveAlias(aliasPath) {
14
+ const parts = aliasPath.split('.');
15
+ let currentPath = path.join(this.projectRoot, '.agent/index.md');
16
+ let currentContext = null;
17
+ // Si el alias empieza por 'agent.core', saltamos al core
18
+ if (aliasPath.startsWith('agent.core')) {
19
+ currentPath = path.join(this.corePath, 'index.md');
20
+ }
21
+ const files = [];
22
+ // Esta es una implementación simplificada que busca en los índices conocidos
23
+ // Para una implementación completa, se requeriría un crawler de YAML
24
+ if (aliasPath.includes('constitution')) {
25
+ const constitutions = [
26
+ { file: 'clean-code.md', alias: 'constitution.clean_code' },
27
+ { file: 'agents-behavior.md', alias: 'constitution.agents_behavior' },
28
+ ];
29
+ for (const c of constitutions) {
30
+ const p = path.join(this.corePath, 'rules/constitution', c.file);
31
+ if (await this.exists(p)) {
32
+ files.push(await this.readFile(p, c.alias));
33
+ }
34
+ }
35
+ }
36
+ else if (aliasPath.includes('roles')) {
37
+ const rolesDir = path.join(this.corePath, 'rules/roles');
38
+ const roleFiles = await fs.readdir(rolesDir);
39
+ for (const f of roleFiles) {
40
+ if (f.endsWith('.md') && f !== 'index.md') {
41
+ files.push(await this.readFile(path.join(rolesDir, f), `roles.${f.replace('.md', '')}`));
42
+ }
43
+ }
44
+ }
45
+ return files;
46
+ }
47
+ async readFile(filePath, alias) {
48
+ const content = await fs.readFile(filePath, 'utf-8');
49
+ return { path: filePath, content, alias };
50
+ }
51
+ async exists(p) {
52
+ try {
53
+ await fs.access(p);
54
+ return true;
55
+ }
56
+ catch {
57
+ return false;
58
+ }
59
+ }
60
+ formatBundle(files, isBootstrap = false) {
61
+ let bundle = isBootstrap ? "# BOOTSTRAP CONTEXT BUNDLE\n\n" : "# CONTEXT BUNDLE\n\n";
62
+ // 1. Manifiesto de Carga (Best Practice)
63
+ bundle += "## MANIFIESTO DE CARGA\n";
64
+ bundle += "Este bundle contiene los siguientes dominios de contexto:\n";
65
+ for (const file of files) {
66
+ bundle += `- [x] \`${file.alias || path.basename(file.path)}\` (v1.0)\n`;
67
+ }
68
+ bundle += "\n---\n\n";
69
+ for (const file of files) {
70
+ bundle += `## FILE: ${file.alias || file.path}\n`;
71
+ bundle += `Path: \`file://${file.path}\`\n\n`;
72
+ bundle += "```markdown\n";
73
+ bundle += file.content;
74
+ if (!file.content.endsWith('\n')) {
75
+ bundle += '\n';
76
+ }
77
+ bundle += "```\n\n---\n\n";
78
+ }
79
+ // 2. Siguientes Pasos / Discovery (Best Practice)
80
+ if (isBootstrap) {
81
+ bundle += "## SIGUIENTES PASOS (DISCOVERY)\n";
82
+ bundle += "El sistema está inicializado. Puedes profundizar en dominios específicos usando:\n";
83
+ bundle += "- `tool: hydrate_context({ alias: \"agent.domains.rules.index\" })` para cargar reglas disponibles.\n";
84
+ bundle += "- `tool: hydrate_context({ alias: \"agent.domains.workflows.index\" })` para ver workflows disponibles.\n";
85
+ }
86
+ return bundle;
87
+ }
88
+ }
89
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../src/infrastructure/context/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B,MAAM,OAAO,cAAc;IACH;IAA6B;IAAjD,YAAoB,WAAmB,EAAU,QAAgB;QAA7C,gBAAW,GAAX,WAAW,CAAQ;QAAU,aAAQ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,IAAI,WAAW,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;QAC7E,CAAC;QACD,MAAM,IAAI,WAAW,CAAC;QAEtB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,MAAM,IAAI,YAAY,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC;YAClD,MAAM,IAAI,kBAAkB,IAAI,CAAC,IAAI,QAAQ,CAAC;YAC9C,MAAM,IAAI,eAAe,CAAC;YAC1B,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBAAA,MAAM,IAAI,IAAI,CAAC;YAAA,CAAC;YACnD,MAAM,IAAI,gBAAgB,CAAC;QAC/B,CAAC;QAED,kDAAkD;QAClD,IAAI,WAAW,EAAE,CAAC;YACd,MAAM,IAAI,mCAAmC,CAAC;YAC9C,MAAM,IAAI,oFAAoF,CAAC;YAC/F,MAAM,IAAI,uGAAuG,CAAC;YAClH,MAAM,IAAI,2GAA2G,CAAC;QAC1H,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export const AGENT_ROOT = '.agent';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/infrastructure/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC"}
@@ -0,0 +1,108 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import path from 'node:path';
3
+ import fs from 'node:fs/promises';
4
+ import { createRequire } from 'node:module';
5
+ /**
6
+ * Resuelve la ruta absoluta del core del framework agentic-workflow.
7
+ * Busca las carpetas 'rules', 'workflows' y 'templates' desde la ubicación del script.
8
+ */
9
+ export async function resolveCorePath() {
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+ // Intentamos buscar el root del paquete subiendo niveles desde src/infrastructure/mapping
13
+ // En desarrollo: agent-workflow/src/infrastructure/mapping -> ../../..
14
+ // En producción (dist): agent-workflow/dist/infrastructure/mapping -> ../../..
15
+ return resolveCorePathFromDir(__dirname);
16
+ }
17
+ /**
18
+ * Intenta resolver el core instalado en node_modules desde el cwd.
19
+ * Devuelve null si no hay instalación local.
20
+ */
21
+ export async function resolveInstalledCorePath(cwd = process.cwd()) {
22
+ try {
23
+ const directNodeModules = path.join(cwd, 'node_modules', '@christianmaf80', 'agentic-workflow');
24
+ try {
25
+ await fs.access(path.join(directNodeModules, 'package.json'));
26
+ return await resolveCorePathFromPackageRoot(directNodeModules);
27
+ }
28
+ catch {
29
+ // Fall back to node resolution from cwd.
30
+ }
31
+ const requireFromCwd = createRequire(path.join(cwd, 'package.json'));
32
+ const pkgPath = requireFromCwd.resolve('@christianmaf80/agentic-workflow/package.json');
33
+ const pkgRoot = path.dirname(pkgPath);
34
+ return await resolveCorePathFromPackageRoot(pkgRoot);
35
+ }
36
+ catch {
37
+ return null;
38
+ }
39
+ }
40
+ async function resolveCorePathFromDir(startDir) {
41
+ let currentDir = startDir;
42
+ const maxRetries = 5;
43
+ for (let i = 0; i < maxRetries; i++) {
44
+ const legacyRoot = {
45
+ root: currentDir,
46
+ rules: path.join(currentDir, 'rules'),
47
+ workflows: path.join(currentDir, 'workflows'),
48
+ };
49
+ const agentStructureRoot = {
50
+ root: path.join(currentDir, 'agent'),
51
+ rules: path.join(currentDir, 'agent', 'rules'),
52
+ workflows: path.join(currentDir, 'agent', 'workflows'),
53
+ };
54
+ const agenticStructureRoot = {
55
+ root: path.join(currentDir, 'agentic-system-structure'),
56
+ rules: path.join(currentDir, 'agentic-system-structure', 'rules'),
57
+ workflows: path.join(currentDir, 'agentic-system-structure', 'workflows'),
58
+ };
59
+ try {
60
+ await fs.access(legacyRoot.rules);
61
+ await fs.access(legacyRoot.workflows);
62
+ return legacyRoot.root;
63
+ }
64
+ catch {
65
+ // keep checking other variants
66
+ }
67
+ try {
68
+ await fs.access(agentStructureRoot.rules);
69
+ await fs.access(agentStructureRoot.workflows);
70
+ return agentStructureRoot.root;
71
+ }
72
+ catch {
73
+ // keep checking other variants
74
+ }
75
+ try {
76
+ await fs.access(agenticStructureRoot.rules);
77
+ await fs.access(agenticStructureRoot.workflows);
78
+ return agenticStructureRoot.root;
79
+ }
80
+ catch {
81
+ currentDir = path.dirname(currentDir);
82
+ }
83
+ }
84
+ throw new Error('No se pudo localizar el core del framework (@christianmaf80/agentic-workflow). Asegúrate de que el paquete está correctamente instalado.');
85
+ }
86
+ async function resolveCorePathFromPackageRoot(pkgRoot) {
87
+ const candidates = [
88
+ pkgRoot,
89
+ path.join(pkgRoot, 'dist'),
90
+ path.join(pkgRoot, 'dist', 'agent'),
91
+ path.join(pkgRoot, 'src'),
92
+ path.join(pkgRoot, 'src', 'agentic-system-structure'),
93
+ ];
94
+ for (const candidate of candidates) {
95
+ try {
96
+ const rulesPath = path.join(candidate, 'rules');
97
+ const workflowsPath = path.join(candidate, 'workflows');
98
+ await fs.access(rulesPath);
99
+ await fs.access(workflowsPath);
100
+ return candidate;
101
+ }
102
+ catch {
103
+ // Not a core root, try next.
104
+ }
105
+ }
106
+ throw new Error('No se pudo localizar el core instalado en node_modules.');
107
+ }
108
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../src/infrastructure/mapping/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe;IAC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+ export async function createBackup(cwd) {
4
+ const agentDir = path.join(cwd, '.agent');
5
+ const backupsContainer = path.join(cwd, '.backups');
6
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
7
+ const backupDir = path.join(backupsContainer, `.agent.backup_${timestamp}`);
8
+ try {
9
+ await fs.cp(agentDir, backupDir, { recursive: true });
10
+ return backupDir;
11
+ }
12
+ catch (error) {
13
+ throw new Error(`Failed to create backup: ${error instanceof Error ? error.message : String(error)}`);
14
+ }
15
+ }
16
+ //# sourceMappingURL=backup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup.js","sourceRoot":"","sources":["../../../src/infrastructure/migration/backup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAW;IAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC1C,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACjE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,iBAAiB,SAAS,EAAE,CAAC,CAAC;IAE5E,IAAI,CAAC;QACD,MAAM,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,OAAO,SAAS,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,4BAA4B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC1G,CAAC;AACL,CAAC"}
@@ -0,0 +1,33 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ export async function detectAgentSystem(cwd) {
4
+ const agentDir = path.join(cwd, '.agent');
5
+ try {
6
+ await fs.access(agentDir);
7
+ }
8
+ catch {
9
+ return 'none';
10
+ }
11
+ // Comprobar si es el sistema actual (Portable)
12
+ try {
13
+ const rootIndex = await fs.readFile(path.join(agentDir, 'index.md'), 'utf-8');
14
+ if (rootIndex.includes('id: agent.index')) {
15
+ return 'current';
16
+ }
17
+ }
18
+ catch {
19
+ // No hay index.md global
20
+ }
21
+ // Comprobar si es legacy
22
+ try {
23
+ const rulesIndex = await fs.readFile(path.join(agentDir, 'rules', 'index.md'), 'utf-8');
24
+ if (rulesIndex.includes('id: rules.index')) {
25
+ return 'legacy';
26
+ }
27
+ }
28
+ catch {
29
+ // No hay rules/index.md
30
+ }
31
+ return 'legacy'; // Si existe .agent pero no es actual, lo tratamos como legacy para migrar
32
+ }
33
+ //# sourceMappingURL=detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detector.js","sourceRoot":"","sources":["../../../src/infrastructure/migration/detector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,GAAW;IAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAE1C,IAAI,CAAC;QACD,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,+CAA+C;IAC/C,IAAI,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC;QAC9E,IAAI,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACxC,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACL,yBAAyB;IAC7B,CAAC;IAED,yBAAyB;IACzB,IAAI,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC;QACxF,IAAI,UAAU,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACzC,OAAO,QAAQ,CAAC;QACpB,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACL,wBAAwB;IAC5B,CAAC;IAED,OAAO,QAAQ,CAAC,CAAC,0EAA0E;AAC/F,CAAC"}
@@ -0,0 +1,12 @@
1
+ import matter from 'gray-matter';
2
+ export function transformMarkdownContent(content, newMeta) {
3
+ const { data, content: body } = matter(content);
4
+ // Merge existing metadata with new metadata
5
+ const mergedData = {
6
+ ...data,
7
+ ...newMeta
8
+ };
9
+ // Return the stringified version with the triple dash separators
10
+ return matter.stringify(body, mergedData);
11
+ }
12
+ //# sourceMappingURL=transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformer.js","sourceRoot":"","sources":["../../../src/infrastructure/migration/transformer.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,UAAU,wBAAwB,CAAC,OAAe,EAAE,OAA4B;IAClF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAEhD,4CAA4C;IAC5C,MAAM,UAAU,GAAG;QACf,GAAG,IAAI;QACP,GAAG,OAAO;KACb,CAAC;IAEF,iEAAiE;IACjE,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,22 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ /**
4
+ * Utility to manage backups of the .agent directory.
5
+ */
6
+ export async function performBackup(cwd) {
7
+ const agentDir = path.join(cwd, '.agent');
8
+ const backupsContainer = path.join(cwd, '.backups');
9
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
10
+ const backupDir = path.join(backupsContainer, `.agent.backup_${timestamp}`);
11
+ // Check if .agent exists
12
+ try {
13
+ await fs.access(agentDir);
14
+ }
15
+ catch {
16
+ // No .agent folder, nothing to backup
17
+ return '';
18
+ }
19
+ await fs.cp(agentDir, backupDir, { recursive: true });
20
+ return backupDir;
21
+ }
22
+ //# sourceMappingURL=backup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup.js","sourceRoot":"","sources":["../../../src/infrastructure/utils/backup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAW;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC1C,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACjE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,iBAAiB,SAAS,EAAE,CAAC,CAAC;IAE5E,yBAAyB;IACzB,IAAI,CAAC;QACD,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACL,sCAAsC;QACtC,OAAO,EAAE,CAAC;IACd,CAAC;IAED,MAAM,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,OAAO,SAAS,CAAC;AACrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@christianmaf80/agentic-workflow",
3
- "version": "1.21.0-beta.2",
3
+ "version": "1.21.0-beta.3",
4
4
  "description": "Portable agentic workflow orchestration system with strict identity and gate discipline",
5
5
  "type": "module",
6
6
  "displayName": "Agentic Workflow",
@@ -41,6 +41,7 @@
41
41
  "files": [
42
42
  "dist/cli",
43
43
  "dist/core",
44
+ "dist/infrastructure",
44
45
  "dist/agent",
45
46
  "dist/extension",
46
47
  "bin",