agent-mp 0.5.1 → 0.5.2

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.
@@ -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, scan subdirectories
5
- * for a deeper project root (indicated by common project files).
6
- * Returns the deepest valid project root found, or the original dir.
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;
@@ -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, scan subdirectories
17
- * for a deeper project root (indicated by common project files).
18
- * Returns the deepest valid project root found, or the original dir.
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
- const hasAgentConfig = await fileExists(path.join(startDir, '.agent', 'config.json'));
22
- if (!hasAgentConfig)
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
- // Scan immediate subdirectories for a deeper project root
25
- let bestDir = startDir;
26
- let bestScore = 0;
27
- try {
28
- const entries = await fs.readdir(startDir, { withFileTypes: true });
29
- for (const entry of entries) {
30
- if (!entry.isDirectory() || entry.name.startsWith('.') || entry.name === 'node_modules')
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
- catch { /* ignore */ }
45
- return bestDir;
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-mp",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Deterministic multi-agent CLI orchestrator — plan, code, review",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",