fix(runner): recursively scan repository root to locate nested .vibncode/tasks directory
This commit is contained in:
39
vibn-agent-runner/dist/agent-session-runner.js
vendored
39
vibn-agent-runner/dist/agent-session-runner.js
vendored
@@ -207,11 +207,40 @@ async function autoCommitAndDeploy(opts, task, emit) {
|
||||
await patchSession(opts, { status: "done" });
|
||||
}
|
||||
}
|
||||
function findTasksDir(root) {
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
// 1. Check if root/.vibncode/tasks exists directly
|
||||
const direct = path.join(root, ".vibncode", "tasks");
|
||||
if (fs.existsSync(direct))
|
||||
return direct;
|
||||
// 2. Recursively scan subdirectories (excluding node_modules, .git, etc.)
|
||||
try {
|
||||
const files = fs.readdirSync(root);
|
||||
for (const file of files) {
|
||||
if (file === "node_modules" ||
|
||||
file === ".git" ||
|
||||
file === ".next" ||
|
||||
file === ".vibncode" ||
|
||||
file === "dist") {
|
||||
continue;
|
||||
}
|
||||
const full = path.join(root, file);
|
||||
if (fs.statSync(full).isDirectory()) {
|
||||
const found = findTasksDir(full);
|
||||
if (found)
|
||||
return found;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
return null;
|
||||
}
|
||||
function parseTaskItems(repoRoot) {
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const tasksDir = path.join(repoRoot, ".vibncode", "tasks");
|
||||
if (!fs.existsSync(tasksDir))
|
||||
const tasksDir = findTasksDir(repoRoot);
|
||||
if (!tasksDir)
|
||||
return [];
|
||||
const items = [];
|
||||
try {
|
||||
@@ -539,7 +568,7 @@ async function runSessionAgent(config, task, ctx, opts) {
|
||||
text: `Agent started offline delegation orchestrator in ${opts.appPath}`,
|
||||
});
|
||||
const repoRoot = opts.repoRoot ?? ctx.workspaceRoot;
|
||||
let tasks = parseTaskItems(ctx.workspaceRoot);
|
||||
let tasks = parseTaskItems(repoRoot);
|
||||
if (tasks.length === 0) {
|
||||
await emit({
|
||||
ts: now(),
|
||||
@@ -547,8 +576,8 @@ async function runSessionAgent(config, task, ctx, opts) {
|
||||
text: "🤖 [Orchestrator] No active tasks backlog found on disk. Analyzing prompt to plan atomic execution backlog...",
|
||||
});
|
||||
try {
|
||||
await generateBacklogFromPrompt(task, ctx.workspaceRoot);
|
||||
tasks = parseTaskItems(ctx.workspaceRoot);
|
||||
await generateBacklogFromPrompt(task, repoRoot);
|
||||
tasks = parseTaskItems(repoRoot);
|
||||
}
|
||||
catch (err) {
|
||||
await emit({
|
||||
|
||||
@@ -298,11 +298,42 @@ interface TaskItem {
|
||||
fileName: string;
|
||||
}
|
||||
|
||||
function findTasksDir(root: string): string | null {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const path = require("path") as typeof import("path");
|
||||
|
||||
// 1. Check if root/.vibncode/tasks exists directly
|
||||
const direct = path.join(root, ".vibncode", "tasks");
|
||||
if (fs.existsSync(direct)) return direct;
|
||||
|
||||
// 2. Recursively scan subdirectories (excluding node_modules, .git, etc.)
|
||||
try {
|
||||
const files = fs.readdirSync(root);
|
||||
for (const file of files) {
|
||||
if (
|
||||
file === "node_modules" ||
|
||||
file === ".git" ||
|
||||
file === ".next" ||
|
||||
file === ".vibncode" ||
|
||||
file === "dist"
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
const full = path.join(root, file);
|
||||
if (fs.statSync(full).isDirectory()) {
|
||||
const found = findTasksDir(full);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
return null;
|
||||
}
|
||||
|
||||
function parseTaskItems(repoRoot: string): TaskItem[] {
|
||||
const fs = require("fs") as typeof import("fs");
|
||||
const path = require("path") as typeof import("path");
|
||||
const tasksDir = path.join(repoRoot, ".vibncode", "tasks");
|
||||
if (!fs.existsSync(tasksDir)) return [];
|
||||
const tasksDir = findTasksDir(repoRoot);
|
||||
if (!tasksDir) return [];
|
||||
|
||||
const items: TaskItem[] = [];
|
||||
try {
|
||||
@@ -679,7 +710,7 @@ export async function runSessionAgent(
|
||||
|
||||
const repoRoot = opts.repoRoot ?? ctx.workspaceRoot;
|
||||
|
||||
let tasks = parseTaskItems(ctx.workspaceRoot);
|
||||
let tasks = parseTaskItems(repoRoot);
|
||||
if (tasks.length === 0) {
|
||||
await emit({
|
||||
ts: now(),
|
||||
@@ -687,8 +718,8 @@ export async function runSessionAgent(
|
||||
text: "🤖 [Orchestrator] No active tasks backlog found on disk. Analyzing prompt to plan atomic execution backlog...",
|
||||
});
|
||||
try {
|
||||
await generateBacklogFromPrompt(task, ctx.workspaceRoot);
|
||||
tasks = parseTaskItems(ctx.workspaceRoot);
|
||||
await generateBacklogFromPrompt(task, repoRoot);
|
||||
tasks = parseTaskItems(repoRoot);
|
||||
} catch (err: any) {
|
||||
await emit({
|
||||
ts: now(),
|
||||
|
||||
Reference in New Issue
Block a user