fix(FN-2107): normalize task ID handling for task creation tools
- Return the created task ID directly from runTaskPlan and propagate it through fn_task_plan - Remove hardcoded FN-### log parsing so CLI extension supports structured IDs like PROJ-042 - Add heartbeat fallback parsing from task_create text output when details.taskId is absent - Expand engine and CLI tests to cover structured task IDs and updated task-plan return behavior
This commit is contained in:
@@ -10,9 +10,14 @@ vi.mock("@fusion/core/gh-cli", () => ({
|
||||
getGhErrorMessage: vi.fn((error: unknown) => (error instanceof Error ? error.message : String(error))),
|
||||
}));
|
||||
|
||||
vi.mock("../commands/task.js", () => ({
|
||||
runTaskPlan: vi.fn(),
|
||||
}));
|
||||
|
||||
import kbExtension from "../extension.js";
|
||||
import { TaskStore } from "@fusion/core";
|
||||
import { isGhAvailable, isGhAuthenticated, runGhJsonAsync } from "@fusion/core/gh-cli";
|
||||
import { runTaskPlan } from "../commands/task.js";
|
||||
|
||||
// ── Mock ExtensionAPI that captures registrations ──────────────────
|
||||
|
||||
@@ -73,6 +78,7 @@ describe("fn pi extension", () => {
|
||||
vi.mocked(isGhAvailable).mockReturnValue(true);
|
||||
vi.mocked(isGhAuthenticated).mockReturnValue(true);
|
||||
vi.mocked(runGhJsonAsync).mockReset();
|
||||
vi.mocked(runTaskPlan).mockReset();
|
||||
|
||||
tmpDir = await mkdtemp(join(tmpdir(), "kb-ext-test-"));
|
||||
api = createMockAPI();
|
||||
@@ -144,6 +150,25 @@ describe("fn pi extension", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("fn_task_plan", () => {
|
||||
it("uses runTaskPlan return value for taskId regardless of prefix", async () => {
|
||||
vi.mocked(runTaskPlan).mockResolvedValueOnce("PROJ-042");
|
||||
const tool = api.tools.get("fn_task_plan")!;
|
||||
|
||||
const result = await tool.execute(
|
||||
"plan-1",
|
||||
{ description: "Plan a project task" },
|
||||
undefined,
|
||||
undefined,
|
||||
makeCtx(tmpDir),
|
||||
);
|
||||
|
||||
expect(runTaskPlan).toHaveBeenCalledWith("Plan a project task", true);
|
||||
expect(result.details.taskId).toBe("PROJ-042");
|
||||
expect(result.content[0].text).toContain("Task PROJ-042");
|
||||
});
|
||||
});
|
||||
|
||||
describe("fn_task_create", () => {
|
||||
it("creates a task and returns its ID", async () => {
|
||||
const tool = api.tools.get("fn_task_create")!;
|
||||
|
||||
Reference in New Issue
Block a user