agent-mp 0.5.1 → 0.5.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.
- package/dist/commands/repl.js +20 -0
- package/dist/utils/config.d.ts +4 -3
- package/dist/utils/config.js +16 -33
- package/package.json +1 -1
package/dist/commands/repl.js
CHANGED
|
@@ -994,6 +994,16 @@ export async function runRepl(resumeSession) {
|
|
|
994
994
|
const dir = await resolveProjectDir(process.cwd());
|
|
995
995
|
const config = await loadProjectConfig(dir);
|
|
996
996
|
if (args[0] === 'orch' || args[0] === 'orchestrator') {
|
|
997
|
+
// Ensure documentation exists before orchestrator runs
|
|
998
|
+
const contextDir = path.join(dir, '.agent', 'context');
|
|
999
|
+
const archPath = path.join(contextDir, 'architecture.md');
|
|
1000
|
+
if (!(await fileExists(archPath))) {
|
|
1001
|
+
fi.println(chalk.yellow('\n ── Generando documentación del proyecto ──'));
|
|
1002
|
+
fi.println(chalk.dim(' El orquestador necesita conocer la estructura del proyecto primero.\n'));
|
|
1003
|
+
const prepEngine = new AgentEngine(config, dir, gCoordinatorCmd, rl, fi, handleCmd);
|
|
1004
|
+
await prepEngine.runExplorer('Document the complete project structure, services, dependencies, and entry points. Create/update .agent/context/architecture.md');
|
|
1005
|
+
fi.println(chalk.green(' ✓ Documentación del proyecto generada.\n'));
|
|
1006
|
+
}
|
|
997
1007
|
const task = args.slice(1).join(' ');
|
|
998
1008
|
const engine = new AgentEngine(config, dir, gCoordinatorCmd, rl, fi, handleCmd);
|
|
999
1009
|
const result = await engine.runOrchestrator(task);
|
|
@@ -1106,6 +1116,16 @@ export async function runRepl(resumeSession) {
|
|
|
1106
1116
|
fi.println(chalk.red(' No roles configured. Run /config-multi first.'));
|
|
1107
1117
|
}
|
|
1108
1118
|
else {
|
|
1119
|
+
// Before running the orchestrator, ensure project documentation exists
|
|
1120
|
+
const contextDir = path.join(dir, '.agent', 'context');
|
|
1121
|
+
const archPath = path.join(contextDir, 'architecture.md');
|
|
1122
|
+
if (!(await fileExists(archPath))) {
|
|
1123
|
+
fi.println(chalk.yellow('\n ── Generando documentación del proyecto ──'));
|
|
1124
|
+
fi.println(chalk.dim(' El orquestador necesita conocer la estructura del proyecto primero.\n'));
|
|
1125
|
+
const engine = new AgentEngine(config, dir, gCoordinatorCmd, rl, fi, handleCmd);
|
|
1126
|
+
await engine.runExplorer('Document the complete project structure, services, dependencies, and entry points. Create/update .agent/context/architecture.md');
|
|
1127
|
+
fi.println(chalk.green(' ✓ Documentación del proyecto generada.\n'));
|
|
1128
|
+
}
|
|
1109
1129
|
const engine = new AgentEngine(config, dir, gCoordinatorCmd, rl, fi, handleCmd);
|
|
1110
1130
|
await engine.runFullCycle(trimmed);
|
|
1111
1131
|
session.messages.push({ role: 'agent', content: `[task cycle completed for: ${trimmed}]`, ts: new Date().toISOString() });
|
package/dist/utils/config.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AgentConfig } from '../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Resolve the actual project root starting from a given directory.
|
|
4
|
-
* If .agent/config.json exists in the start dir,
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* If .agent/config.json exists in the start dir, use it directly
|
|
5
|
+
* (the user already configured this as the project root).
|
|
6
|
+
* If not, walk up the directory tree looking for .agent/config.json.
|
|
7
|
+
* Returns the resolved project root.
|
|
7
8
|
*/
|
|
8
9
|
export declare function resolveProjectDir(startDir: string): Promise<string>;
|
|
9
10
|
export declare const PKG_NAME: string;
|
package/dist/utils/config.js
CHANGED
|
@@ -3,46 +3,29 @@ import * as fsSync from 'fs';
|
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import * as os from 'os';
|
|
5
5
|
const KNOWN_PKGS = ['agent-mp', 'agent-orch', 'agent-impl', 'agent-rev', 'agent-explorer'];
|
|
6
|
-
// Files/dirs that indicate a directory is the real project root
|
|
7
|
-
const PROJECT_INDICATORS = [
|
|
8
|
-
'package.json', 'pyproject.toml', 'requirements.txt', 'setup.py', 'setup.cfg',
|
|
9
|
-
'Cargo.toml', 'go.mod', 'Gemfile', 'pom.xml', 'build.gradle', 'build.gradle.kts',
|
|
10
|
-
'CMakeLists.txt', 'Makefile', 'composer.json', 'mix.exs', 'pubspec.yaml',
|
|
11
|
-
'src', 'app', 'lib', 'main.py', 'app.py', 'index.js', 'index.ts',
|
|
12
|
-
'main.go', 'main.rs', 'lib.rs', 'app.js', 'app.ts',
|
|
13
|
-
];
|
|
14
6
|
/**
|
|
15
7
|
* Resolve the actual project root starting from a given directory.
|
|
16
|
-
* If .agent/config.json exists in the start dir,
|
|
17
|
-
*
|
|
18
|
-
*
|
|
8
|
+
* If .agent/config.json exists in the start dir, use it directly
|
|
9
|
+
* (the user already configured this as the project root).
|
|
10
|
+
* If not, walk up the directory tree looking for .agent/config.json.
|
|
11
|
+
* Returns the resolved project root.
|
|
19
12
|
*/
|
|
20
13
|
export async function resolveProjectDir(startDir) {
|
|
21
|
-
|
|
22
|
-
if (
|
|
14
|
+
// If .agent/config.json exists in current dir, use it — user already configured this
|
|
15
|
+
if (await fileExists(path.join(startDir, '.agent', 'config.json'))) {
|
|
23
16
|
return startDir;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
continue;
|
|
32
|
-
const subDir = path.join(startDir, entry.name);
|
|
33
|
-
let score = 0;
|
|
34
|
-
for (const indicator of PROJECT_INDICATORS) {
|
|
35
|
-
if (await fileExists(path.join(subDir, indicator)))
|
|
36
|
-
score++;
|
|
37
|
-
}
|
|
38
|
-
if (score > bestScore) {
|
|
39
|
-
bestScore = score;
|
|
40
|
-
bestDir = subDir;
|
|
41
|
-
}
|
|
17
|
+
}
|
|
18
|
+
// Walk up the directory tree looking for .agent/config.json
|
|
19
|
+
let current = startDir;
|
|
20
|
+
while (current !== path.dirname(current)) {
|
|
21
|
+
const parent = path.dirname(current);
|
|
22
|
+
if (await fileExists(path.join(parent, '.agent', 'config.json'))) {
|
|
23
|
+
return parent;
|
|
42
24
|
}
|
|
25
|
+
current = parent;
|
|
43
26
|
}
|
|
44
|
-
|
|
45
|
-
return
|
|
27
|
+
// No .agent/config.json found — return original dir (will fail gracefully)
|
|
28
|
+
return startDir;
|
|
46
29
|
}
|
|
47
30
|
async function fileExists(p) {
|
|
48
31
|
try {
|