feat(KB-635): add Mission system integration across CLI, engine, and dashboard
- Add mission CLI commands: create, list, show, delete, activate-slice - Add pi extension tools for mission management - Add MissionStore helper methods and Mission types - Add scheduler mission awareness for automatic slice activation - Add engine integration wiring for mission-aware task execution - Add dashboard mission routes and API endpoints - Link tasks to missions via sliceId field with autoAdvance support
This commit is contained in:
@@ -90,6 +90,16 @@ describe("kb pi extension", () => {
|
||||
"kb_task_unarchive",
|
||||
"kb_task_delete",
|
||||
"kb_task_plan",
|
||||
// Mission tools
|
||||
"kb_mission_create",
|
||||
"kb_mission_list",
|
||||
"kb_mission_show",
|
||||
"kb_mission_delete",
|
||||
"kb_milestone_add",
|
||||
"kb_slice_add",
|
||||
"kb_feature_add",
|
||||
"kb_slice_activate",
|
||||
"kb_feature_link_task",
|
||||
];
|
||||
|
||||
for (const name of expected) {
|
||||
@@ -105,9 +115,9 @@ describe("kb pi extension", () => {
|
||||
expect(api.tools.has("kb_task_merge")).toBe(false);
|
||||
});
|
||||
|
||||
it("registers the /kb command", () => {
|
||||
expect(api.commands.has("kb")).toBe(true);
|
||||
expect(api.commands.get("kb")!.description).toContain("dashboard");
|
||||
it("registers the /fn command", () => {
|
||||
expect(api.commands.has("fn")).toBe(true);
|
||||
expect(api.commands.get("fn")!.description).toContain("dashboard");
|
||||
});
|
||||
|
||||
it("registers session_shutdown listener", () => {
|
||||
@@ -391,4 +401,144 @@ describe("kb pi extension", () => {
|
||||
expect(unpauseResult.content[0].text).toContain("Unpaused FN-001");
|
||||
});
|
||||
});
|
||||
|
||||
describe("kb_mission_create", () => {
|
||||
it("creates mission and returns mission data", async () => {
|
||||
const tool = api.tools.get("kb_mission_create")!;
|
||||
const result = await tool.execute(
|
||||
"call-1",
|
||||
{ title: "Test Mission", description: "Test description" },
|
||||
undefined,
|
||||
undefined,
|
||||
makeCtx(tmpDir),
|
||||
);
|
||||
|
||||
expect(result.details.missionId).toBeDefined();
|
||||
expect(result.details.title).toBe("Test Mission");
|
||||
expect(result.content[0].text).toContain("Created");
|
||||
expect(result.content[0].text).toContain("Test Mission");
|
||||
});
|
||||
});
|
||||
|
||||
describe("kb_mission_list", () => {
|
||||
it("returns formatted list of missions", async () => {
|
||||
// First create a mission
|
||||
const createTool = api.tools.get("kb_mission_create")!;
|
||||
await createTool.execute(
|
||||
"c1",
|
||||
{ title: "Mission A" },
|
||||
undefined,
|
||||
undefined,
|
||||
makeCtx(tmpDir),
|
||||
);
|
||||
|
||||
const listTool = api.tools.get("kb_mission_list")!;
|
||||
const result = await listTool.execute(
|
||||
"call-1",
|
||||
{},
|
||||
undefined,
|
||||
undefined,
|
||||
makeCtx(tmpDir),
|
||||
);
|
||||
|
||||
expect(result.details.count).toBeGreaterThanOrEqual(1);
|
||||
expect(result.content[0].text).toContain("Missions");
|
||||
});
|
||||
});
|
||||
|
||||
describe("kb_mission_show", () => {
|
||||
it("returns mission with hierarchy", async () => {
|
||||
// Create mission
|
||||
const createTool = api.tools.get("kb_mission_create")!;
|
||||
const created = await createTool.execute(
|
||||
"c1",
|
||||
{ title: "Test Mission" },
|
||||
undefined,
|
||||
undefined,
|
||||
makeCtx(tmpDir),
|
||||
);
|
||||
|
||||
const showTool = api.tools.get("kb_mission_show")!;
|
||||
const result = await showTool.execute(
|
||||
"call-1",
|
||||
{ id: created.details.missionId },
|
||||
undefined,
|
||||
undefined,
|
||||
makeCtx(tmpDir),
|
||||
);
|
||||
|
||||
expect(result.details.mission).toBeDefined();
|
||||
expect(result.content[0].text).toContain("Test Mission");
|
||||
});
|
||||
|
||||
it("returns error when mission not found", async () => {
|
||||
const showTool = api.tools.get("kb_mission_show")!;
|
||||
const result = await showTool.execute(
|
||||
"call-1",
|
||||
{ id: "M-999" },
|
||||
undefined,
|
||||
undefined,
|
||||
makeCtx(tmpDir),
|
||||
);
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
expect(result.content[0].text).toContain("not found");
|
||||
});
|
||||
});
|
||||
|
||||
describe("kb_mission_delete", () => {
|
||||
it("deletes mission and confirms", async () => {
|
||||
// Create mission
|
||||
const createTool = api.tools.get("kb_mission_create")!;
|
||||
const created = await createTool.execute(
|
||||
"c1",
|
||||
{ title: "Mission to Delete" },
|
||||
undefined,
|
||||
undefined,
|
||||
makeCtx(tmpDir),
|
||||
);
|
||||
|
||||
const deleteTool = api.tools.get("kb_mission_delete")!;
|
||||
const result = await deleteTool.execute(
|
||||
"call-1",
|
||||
{ id: created.details.missionId },
|
||||
undefined,
|
||||
undefined,
|
||||
makeCtx(tmpDir),
|
||||
);
|
||||
|
||||
expect(result.details.missionId).toBe(created.details.missionId);
|
||||
expect(result.content[0].text).toContain("Deleted");
|
||||
});
|
||||
});
|
||||
|
||||
describe("kb_slice_activate", () => {
|
||||
it("activates slice and updates status", async () => {
|
||||
// This test would need a full mission hierarchy setup
|
||||
// For now, verify the tool exists and has correct parameters
|
||||
const tool = api.tools.get("kb_slice_activate")!;
|
||||
expect(tool).toBeDefined();
|
||||
expect(tool.parameters.properties.id).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("kb_feature_link_task", () => {
|
||||
it("links feature to task", async () => {
|
||||
// Create a task first
|
||||
const createTaskTool = api.tools.get("kb_task_create")!;
|
||||
const taskResult = await createTaskTool.execute(
|
||||
"c1",
|
||||
{ description: "Task for feature" },
|
||||
undefined,
|
||||
undefined,
|
||||
makeCtx(tmpDir),
|
||||
);
|
||||
|
||||
// Verify the tool exists with correct parameters
|
||||
const tool = api.tools.get("kb_feature_link_task")!;
|
||||
expect(tool).toBeDefined();
|
||||
expect(tool.parameters.properties.featureId).toBeDefined();
|
||||
expect(tool.parameters.properties.taskId).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -45,6 +45,7 @@ const { runSettingsExport } = await import("./commands/settings-export.js");
|
||||
const { runSettingsImport } = await import("./commands/settings-import.js");
|
||||
const { runGitStatus, runGitFetch, runGitPull, runGitPush } = await import("./commands/git.js");
|
||||
const { runBackupCreate, runBackupList, runBackupRestore, runBackupCleanup } = await import("./commands/backup.js");
|
||||
const { runMissionCreate, runMissionList, runMissionShow, runMissionDelete, runMissionActivateSlice } = await import("./commands/mission.js");
|
||||
const { runProjectList, runProjectAdd, runProjectRemove, runProjectShow, runProjectSetDefault, runProjectDetect } = await import("./commands/project.js");
|
||||
|
||||
const HELP = `
|
||||
@@ -100,10 +101,11 @@ Usage:
|
||||
fn backup --list List all database backups
|
||||
fn backup --restore <file> Restore database from a backup file
|
||||
fn backup --cleanup Remove old backups exceeding retention limit
|
||||
fn project list [--json] List all registered projects
|
||||
fn project add [dir] [--name <name>] [--isolation <mode>] Register a project
|
||||
fn project remove <name> [--force] Unregister a project
|
||||
fn project info [name] Show project details
|
||||
fn mission create [title] [description] Create a new mission
|
||||
fn mission list List all missions
|
||||
fn mission show <id> Show mission with hierarchy
|
||||
fn mission delete <id> [--force] Delete a mission
|
||||
fn mission activate-slice <slice-id> Activate a pending slice
|
||||
|
||||
Options:
|
||||
--project, -P <name> Target a specific project (for task/settings commands)
|
||||
@@ -697,46 +699,65 @@ async function main() {
|
||||
break;
|
||||
}
|
||||
|
||||
case "project": {
|
||||
case "mission": {
|
||||
const subcommand = args[1];
|
||||
switch (subcommand) {
|
||||
case "create": {
|
||||
const titleParts: string[] = [];
|
||||
for (let i = 2; i < args.length; i++) {
|
||||
titleParts.push(args[i]);
|
||||
}
|
||||
const fullInput = titleParts.join(" ");
|
||||
// Split on first space to separate title and description if provided
|
||||
const firstSpaceIdx = fullInput.indexOf(" ");
|
||||
let title: string | undefined;
|
||||
let description: string | undefined;
|
||||
if (firstSpaceIdx > 0) {
|
||||
title = fullInput.slice(0, firstSpaceIdx);
|
||||
description = fullInput.slice(firstSpaceIdx + 1).trim();
|
||||
} else {
|
||||
title = fullInput || undefined;
|
||||
}
|
||||
await runMissionCreate(title, description, projectName);
|
||||
break;
|
||||
}
|
||||
case "list":
|
||||
case "ls": {
|
||||
const json = args.includes("--json");
|
||||
await runProjectList({ json });
|
||||
case "ls":
|
||||
await runMissionList(projectName);
|
||||
break;
|
||||
case "show":
|
||||
case "info": {
|
||||
const id = args[2];
|
||||
if (!id) {
|
||||
console.error("Usage: fn mission show <id>");
|
||||
process.exit(1);
|
||||
}
|
||||
await runMissionShow(id, projectName);
|
||||
break;
|
||||
}
|
||||
case "add": {
|
||||
const dir = args[2];
|
||||
const nameIdx = args.indexOf("--name");
|
||||
const name = nameIdx !== -1 && nameIdx + 1 < args.length ? args[nameIdx + 1] : undefined;
|
||||
const isolationIdx = args.indexOf("--isolation");
|
||||
const isolation = isolationIdx !== -1 && isolationIdx + 1 < args.length
|
||||
? args[isolationIdx + 1] as "in-process" | "child-process"
|
||||
: undefined;
|
||||
await runProjectAdd(dir, { name, isolation });
|
||||
break;
|
||||
}
|
||||
case "remove":
|
||||
case "delete":
|
||||
case "rm": {
|
||||
const name = args[2];
|
||||
if (!name) {
|
||||
console.error("Usage: fn project remove <name> [--force]");
|
||||
const id = args[2];
|
||||
if (!id) {
|
||||
console.error("Usage: fn mission delete <id> [--force]");
|
||||
process.exit(1);
|
||||
}
|
||||
const force = args.includes("--force");
|
||||
await runProjectRemove(name, { force });
|
||||
await runMissionDelete(id, force, projectName);
|
||||
break;
|
||||
}
|
||||
case "info":
|
||||
case "show": {
|
||||
const name = args[2];
|
||||
await runProjectInfo(name);
|
||||
case "activate-slice": {
|
||||
const id = args[2];
|
||||
if (!id) {
|
||||
console.error("Usage: fn mission activate-slice <slice-id>");
|
||||
process.exit(1);
|
||||
}
|
||||
await runMissionActivateSlice(id, projectName);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
console.error(`Unknown subcommand: project ${subcommand || ""}`);
|
||||
console.error("Try: fn project list | add [dir] | remove <name> | info [name]");
|
||||
console.error(`Unknown subcommand: mission ${subcommand || ""}`);
|
||||
console.error("Try: fn mission create | list | show <id> | delete <id> | activate-slice <id>");
|
||||
process.exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -975,6 +975,445 @@ export default function kbExtension(pi: ExtensionAPI) {
|
||||
},
|
||||
});
|
||||
|
||||
// ── Mission Tools ───────────────────────────────────────────────
|
||||
// Mission hierarchy management for multi-phase project planning
|
||||
|
||||
// ── kb_mission_create ───────────────────────────────────────────
|
||||
|
||||
pi.registerTool({
|
||||
name: "kb_mission_create",
|
||||
label: "KB: Create Mission",
|
||||
description:
|
||||
"Create a new mission — a high-level objective that can span multiple milestones. " +
|
||||
"Missions contain milestones that break down work into phases.",
|
||||
promptSnippet: "Create a new mission for high-level project planning",
|
||||
promptGuidelines: [
|
||||
"Use for high-level project objectives that span multiple work phases",
|
||||
"Missions are broken down into milestones → slices → features → tasks",
|
||||
"Be descriptive so the mission purpose is clear",
|
||||
],
|
||||
parameters: Type.Object({
|
||||
title: Type.String({ description: "Mission title — brief but descriptive" }),
|
||||
description: Type.Optional(
|
||||
Type.String({ description: "Detailed mission objectives and context" })
|
||||
),
|
||||
}),
|
||||
|
||||
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
||||
const store = await getStore(ctx.cwd);
|
||||
const missionStore = store.getMissionStore();
|
||||
|
||||
const mission = missionStore.createMission({
|
||||
title: params.title.trim(),
|
||||
description: params.description?.trim(),
|
||||
});
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: `Created ${mission.id}: ${mission.title}\nStatus: ${mission.status}`,
|
||||
},
|
||||
],
|
||||
details: { missionId: mission.id, title: mission.title, status: mission.status },
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// ── kb_mission_list ──────────────────────────────────────────────
|
||||
|
||||
pi.registerTool({
|
||||
name: "kb_mission_list",
|
||||
label: "KB: List Missions",
|
||||
description: "List all missions with their current status.",
|
||||
promptSnippet: "List all missions",
|
||||
promptGuidelines: [
|
||||
"Use to see all missions and their current status",
|
||||
"Missions are grouped by status (active, planning, complete, etc.)",
|
||||
"Use before kb_mission_show to find a specific mission ID",
|
||||
],
|
||||
parameters: Type.Object({}),
|
||||
|
||||
async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
|
||||
const store = await getStore(ctx.cwd);
|
||||
const missionStore = store.getMissionStore();
|
||||
|
||||
const missions = missionStore.listMissions();
|
||||
|
||||
if (missions.length === 0) {
|
||||
return {
|
||||
content: [{ type: "text", text: "No missions yet." }],
|
||||
details: { count: 0 },
|
||||
};
|
||||
}
|
||||
|
||||
const lines: string[] = [];
|
||||
lines.push(`Missions (${missions.length}):\n`);
|
||||
|
||||
for (const mission of missions) {
|
||||
const statusIcon = mission.status === "complete" ? "✓" : mission.status === "active" ? "●" : "○";
|
||||
lines.push(` ${statusIcon} ${mission.id}: ${mission.title} (${mission.status})`);
|
||||
}
|
||||
|
||||
return {
|
||||
content: [{ type: "text", text: lines.join("\n") }],
|
||||
details: { count: missions.length, missions: missions.map((m) => ({ id: m.id, title: m.title, status: m.status })) },
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// ── kb_mission_show ──────────────────────────────────────────────
|
||||
|
||||
pi.registerTool({
|
||||
name: "kb_mission_show",
|
||||
label: "KB: Show Mission",
|
||||
description: "Show mission details with full hierarchy: milestones → slices → features.",
|
||||
promptSnippet: "Show mission details with hierarchy",
|
||||
promptGuidelines: [
|
||||
"Use to see the full mission structure before planning work",
|
||||
"Shows milestones, slices, and features in hierarchical order",
|
||||
"Check slice status to see if features can be linked to tasks",
|
||||
],
|
||||
parameters: Type.Object({
|
||||
id: Type.String({ description: "Mission ID (e.g., M-001)" }),
|
||||
}),
|
||||
|
||||
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
||||
const store = await getStore(ctx.cwd);
|
||||
const missionStore = store.getMissionStore();
|
||||
|
||||
const mission = missionStore.getMissionWithHierarchy(params.id);
|
||||
if (!mission) {
|
||||
return {
|
||||
content: [{ type: "text", text: `Mission ${params.id} not found` }],
|
||||
isError: true,
|
||||
details: { error: "Mission not found" },
|
||||
};
|
||||
}
|
||||
|
||||
const lines: string[] = [];
|
||||
lines.push(`${mission.id}: ${mission.title}`);
|
||||
lines.push(`Status: ${mission.status}`);
|
||||
if (mission.description) {
|
||||
lines.push(`Description: ${mission.description}`);
|
||||
}
|
||||
lines.push("");
|
||||
|
||||
if (mission.milestones.length === 0) {
|
||||
lines.push("No milestones yet.");
|
||||
} else {
|
||||
lines.push("Milestones:");
|
||||
for (const milestone of mission.milestones) {
|
||||
const mIcon = milestone.status === "complete" ? "✓" : milestone.status === "active" ? "●" : "○";
|
||||
lines.push(` ${mIcon} ${milestone.id}: ${milestone.title} (${milestone.status})`);
|
||||
|
||||
for (const slice of milestone.slices) {
|
||||
const sIcon = slice.status === "complete" ? "✓" : slice.status === "active" ? "●" : "○";
|
||||
lines.push(` ${sIcon} ${slice.id}: ${slice.title} (${slice.status})`);
|
||||
|
||||
for (const feature of slice.features) {
|
||||
const fIcon = feature.status === "done" ? "✓" : feature.status === "in-progress" ? "▸" : feature.status === "triaged" ? "●" : "○";
|
||||
const taskLink = feature.taskId ? ` → ${feature.taskId}` : "";
|
||||
lines.push(` ${fIcon} ${feature.id}: ${feature.title} (${feature.status})${taskLink}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
content: [{ type: "text", text: lines.join("\n") }],
|
||||
details: { mission },
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// ── kb_mission_delete ───────────────────────────────────────────
|
||||
|
||||
pi.registerTool({
|
||||
name: "kb_mission_delete",
|
||||
label: "KB: Delete Mission",
|
||||
description: "Delete a mission and all its milestones, slices, and features. Cannot be undone.",
|
||||
promptSnippet: "Delete a mission and all its contents",
|
||||
promptGuidelines: [
|
||||
"Use for cleaning up test missions or mistakenly created missions",
|
||||
"Permanently deletes all milestones, slices, and features within the mission",
|
||||
"Tasks linked to features are NOT deleted — only the feature links are removed",
|
||||
],
|
||||
parameters: Type.Object({
|
||||
id: Type.String({ description: "Mission ID to delete (e.g., M-001)" }),
|
||||
}),
|
||||
|
||||
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
||||
const store = await getStore(ctx.cwd);
|
||||
const missionStore = store.getMissionStore();
|
||||
|
||||
const mission = missionStore.getMission(params.id);
|
||||
if (!mission) {
|
||||
return {
|
||||
content: [{ type: "text", text: `Mission ${params.id} not found` }],
|
||||
isError: true,
|
||||
details: { error: "Mission not found" },
|
||||
};
|
||||
}
|
||||
|
||||
missionStore.deleteMission(params.id);
|
||||
|
||||
return {
|
||||
content: [{ type: "text", text: `Deleted ${params.id}: "${mission.title}"` }],
|
||||
details: { missionId: params.id, title: mission.title },
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// ── kb_milestone_add ────────────────────────────────────────────
|
||||
|
||||
pi.registerTool({
|
||||
name: "kb_milestone_add",
|
||||
label: "KB: Add Milestone",
|
||||
description: "Add a milestone to a mission. Milestones represent phases of work.",
|
||||
promptSnippet: "Add a milestone to a mission",
|
||||
promptGuidelines: [
|
||||
"Use to break down a mission into manageable phases",
|
||||
"Milestones are ordered and contain slices (work units)",
|
||||
],
|
||||
parameters: Type.Object({
|
||||
missionId: Type.String({ description: "Parent mission ID (e.g., M-001)" }),
|
||||
title: Type.String({ description: "Milestone title" }),
|
||||
description: Type.Optional(Type.String({ description: "Milestone description" })),
|
||||
}),
|
||||
|
||||
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
||||
const store = await getStore(ctx.cwd);
|
||||
const missionStore = store.getMissionStore();
|
||||
|
||||
const mission = missionStore.getMission(params.missionId);
|
||||
if (!mission) {
|
||||
return {
|
||||
content: [{ type: "text", text: `Mission ${params.missionId} not found` }],
|
||||
isError: true,
|
||||
details: { error: "Mission not found" },
|
||||
};
|
||||
}
|
||||
|
||||
const milestone = missionStore.addMilestone(params.missionId, {
|
||||
title: params.title.trim(),
|
||||
description: params.description?.trim(),
|
||||
});
|
||||
|
||||
return {
|
||||
content: [
|
||||
{ type: "text", text: `Added ${milestone.id}: "${milestone.title}" to ${params.missionId}` },
|
||||
],
|
||||
details: { milestoneId: milestone.id, missionId: params.missionId, title: milestone.title },
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// ── kb_slice_add ─────────────────────────────────────────────────
|
||||
|
||||
pi.registerTool({
|
||||
name: "kb_slice_add",
|
||||
label: "KB: Add Slice",
|
||||
description: "Add a slice to a milestone. Slices are work units that can be activated for implementation.",
|
||||
promptSnippet: "Add a work slice to a milestone",
|
||||
promptGuidelines: [
|
||||
"Slices represent work units within a milestone",
|
||||
"Slices are activated for implementation, linking features to tasks",
|
||||
"Order slices by priority — they execute in sequence",
|
||||
],
|
||||
parameters: Type.Object({
|
||||
milestoneId: Type.String({ description: "Parent milestone ID (e.g., MS-001)" }),
|
||||
title: Type.String({ description: "Slice title" }),
|
||||
description: Type.Optional(Type.String({ description: "Slice description" })),
|
||||
}),
|
||||
|
||||
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
||||
const store = await getStore(ctx.cwd);
|
||||
const missionStore = store.getMissionStore();
|
||||
|
||||
const milestone = missionStore.getMilestone(params.milestoneId);
|
||||
if (!milestone) {
|
||||
return {
|
||||
content: [{ type: "text", text: `Milestone ${params.milestoneId} not found` }],
|
||||
isError: true,
|
||||
details: { error: "Milestone not found" },
|
||||
};
|
||||
}
|
||||
|
||||
const slice = missionStore.addSlice(params.milestoneId, {
|
||||
title: params.title.trim(),
|
||||
description: params.description?.trim(),
|
||||
});
|
||||
|
||||
return {
|
||||
content: [
|
||||
{ type: "text", text: `Added ${slice.id}: "${slice.title}" to ${params.milestoneId}` },
|
||||
],
|
||||
details: { sliceId: slice.id, milestoneId: params.milestoneId, title: slice.title },
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// ── kb_feature_add ────────────────────────────────────────────────
|
||||
|
||||
pi.registerTool({
|
||||
name: "kb_feature_add",
|
||||
label: "KB: Add Feature",
|
||||
description: "Add a feature to a slice. Features are deliverables that can be linked to tasks.",
|
||||
promptSnippet: "Add a feature to a slice",
|
||||
promptGuidelines: [
|
||||
"Features represent deliverables within a slice",
|
||||
"Features start as 'defined' and progress through 'triaged' → 'in-progress' → 'done'",
|
||||
"Link features to tasks using kb_feature_link_task",
|
||||
],
|
||||
parameters: Type.Object({
|
||||
sliceId: Type.String({ description: "Parent slice ID (e.g., SL-001)" }),
|
||||
title: Type.String({ description: "Feature title" }),
|
||||
description: Type.Optional(Type.String({ description: "Feature description" })),
|
||||
acceptanceCriteria: Type.Optional(
|
||||
Type.String({ description: "Acceptance criteria for completing the feature" })
|
||||
),
|
||||
}),
|
||||
|
||||
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
||||
const store = await getStore(ctx.cwd);
|
||||
const missionStore = store.getMissionStore();
|
||||
|
||||
const slice = missionStore.getSlice(params.sliceId);
|
||||
if (!slice) {
|
||||
return {
|
||||
content: [{ type: "text", text: `Slice ${params.sliceId} not found` }],
|
||||
isError: true,
|
||||
details: { error: "Slice not found" },
|
||||
};
|
||||
}
|
||||
|
||||
const feature = missionStore.addFeature(params.sliceId, {
|
||||
title: params.title.trim(),
|
||||
description: params.description?.trim(),
|
||||
acceptanceCriteria: params.acceptanceCriteria?.trim(),
|
||||
});
|
||||
|
||||
return {
|
||||
content: [
|
||||
{ type: "text", text: `Added ${feature.id}: "${feature.title}" to ${params.sliceId}` },
|
||||
],
|
||||
details: { featureId: feature.id, sliceId: params.sliceId, title: feature.title },
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// ── kb_slice_activate ────────────────────────────────────────────
|
||||
|
||||
pi.registerTool({
|
||||
name: "kb_slice_activate",
|
||||
label: "KB: Activate Slice",
|
||||
description:
|
||||
"Activate a pending slice for implementation. " +
|
||||
"Sets status to 'active' and enables task linking for its features.",
|
||||
promptSnippet: "Activate a slice for implementation",
|
||||
promptGuidelines: [
|
||||
"Activating a slice allows its features to be linked to tasks",
|
||||
"Only pending slices can be activated",
|
||||
"Slice activation triggers auto-advance when linked tasks complete",
|
||||
],
|
||||
parameters: Type.Object({
|
||||
id: Type.String({ description: "Slice ID to activate (e.g., SL-001)" }),
|
||||
}),
|
||||
|
||||
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
||||
const store = await getStore(ctx.cwd);
|
||||
const missionStore = store.getMissionStore();
|
||||
|
||||
const slice = missionStore.getSlice(params.id);
|
||||
if (!slice) {
|
||||
return {
|
||||
content: [{ type: "text", text: `Slice ${params.id} not found` }],
|
||||
isError: true,
|
||||
details: { error: "Slice not found" },
|
||||
};
|
||||
}
|
||||
|
||||
if (slice.status !== "pending") {
|
||||
return {
|
||||
content: [{ type: "text", text: `Slice ${params.id} is not pending (status: ${slice.status})` }],
|
||||
isError: true,
|
||||
details: { error: "Slice not pending", currentStatus: slice.status },
|
||||
};
|
||||
}
|
||||
|
||||
const activated = missionStore.activateSlice(params.id);
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: `Activated ${activated.id}: "${activated.title}"\nStatus: ${activated.status}`,
|
||||
},
|
||||
],
|
||||
details: { sliceId: activated.id, title: activated.title, status: activated.status },
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// ── kb_feature_link_task ──────────────────────────────────────────
|
||||
|
||||
pi.registerTool({
|
||||
name: "kb_feature_link_task",
|
||||
label: "KB: Link Feature to Task",
|
||||
description:
|
||||
"Link a feature to a kb task for implementation. " +
|
||||
"Updates the feature status to 'triaged' and associates it with the task.",
|
||||
promptSnippet: "Link a feature to a task",
|
||||
promptGuidelines: [
|
||||
"Use when a feature is ready for implementation and has a corresponding task",
|
||||
"The feature's slice must be active to link tasks",
|
||||
"Linking updates the feature status to 'triaged'",
|
||||
"When the linked task moves to 'done', the feature status becomes 'done'",
|
||||
],
|
||||
parameters: Type.Object({
|
||||
featureId: Type.String({ description: "Feature ID to link (e.g., F-001)" }),
|
||||
taskId: Type.String({ description: "Task ID to link to (e.g., KB-001)" }),
|
||||
}),
|
||||
|
||||
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
||||
const store = await getStore(ctx.cwd);
|
||||
const missionStore = store.getMissionStore();
|
||||
|
||||
const feature = missionStore.getFeature(params.featureId);
|
||||
if (!feature) {
|
||||
return {
|
||||
content: [{ type: "text", text: `Feature ${params.featureId} not found` }],
|
||||
isError: true,
|
||||
details: { error: "Feature not found" },
|
||||
};
|
||||
}
|
||||
|
||||
// Check if task exists
|
||||
try {
|
||||
await store.getTask(params.taskId);
|
||||
} catch {
|
||||
return {
|
||||
content: [{ type: "text", text: `Task ${params.taskId} not found` }],
|
||||
isError: true,
|
||||
details: { error: "Task not found" },
|
||||
};
|
||||
}
|
||||
|
||||
const updated = missionStore.linkFeatureToTask(params.featureId, params.taskId);
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: `Linked ${updated.id}: "${updated.title}" → ${params.taskId}\nStatus: ${updated.status}`,
|
||||
},
|
||||
],
|
||||
details: { featureId: updated.id, taskId: params.taskId, title: updated.title, status: updated.status },
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// ── /fn command — start the dashboard + engine ───────────────────
|
||||
|
||||
let dashboardProcess: ChildProcess | null = null;
|
||||
|
||||
Reference in New Issue
Block a user