diff --git a/packages/mosaic/framework/runtime/pi/mosaic-extension.ts b/packages/mosaic/framework/runtime/pi/mosaic-extension.ts index d4749be..cbf783f 100644 --- a/packages/mosaic/framework/runtime/pi/mosaic-extension.ts +++ b/packages/mosaic/framework/runtime/pi/mosaic-extension.ts @@ -10,6 +10,7 @@ */ import type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent'; +import { Type } from 'typebox'; import { existsSync, readFileSync, @@ -342,4 +343,32 @@ export default function register(pi: ExtensionAPI) { } }, }); + + // ── Register mosaic_mission_status tool (model-callable) ────────────── + // R14 "proper tool usage": give the agent a first-class tool to load its + // active Mosaic mission, milestone progress, task counts, and latest + // scratchpad — so it self-orients on in-flight work before planning, + // instead of shelling out or guessing. Mirrors the /mosaic-status command + // but returns the summary as tool output the LLM can read. + pi.registerTool({ + name: 'mosaic_mission_status', + label: 'Mosaic Mission Status', + description: + 'Return the active Mosaic mission, milestone progress, task counts, and latest scratchpad for the current project. Returns a note when no mission is active.', + promptSnippet: 'Read the active Mosaic mission + task state for the current project', + promptGuidelines: [ + 'Use mosaic_mission_status at the start of a session or task to load the active mission, milestone progress, and open tasks before planning work.', + ], + parameters: Type.Object({}), + async execute(_toolCallId, _params, _signal, _onUpdate, _ctx) { + const mission = detectMission(sessionCwd); + const text = mission + ? buildMissionSummary(sessionCwd, mission) + : 'No active Mosaic mission in this project.'; + return { + content: [{ type: 'text', text }], + details: mission ? { ...mission } : { active: false }, + }; + }, + }); }