Skip to main content
Glama

overseer.advance_phase

Advance project phases by validating deliverables and transitioning to the next phase, ensuring structured workflow progression in software development.

Instructions

Advance a phase to the next phase after validating all deliverables are complete. Marks current phase as "locked" and sets next phase as current.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_rootYesRoot path of the repository
expected_current_phaseYesPhase ID that should currently be active (e.g., "01", "02")

Implementation Reference

  • The primary handler function executing the overseer.advance_phase tool logic: checks completion of deliverables and criteria, advances phase status, updates repository files (PHASES.md and PHASE-XX.md).
    export async function handleAdvancePhase(
      args: {
        repo_root: string;
        expected_current_phase: string;
      },
      phaseManager: PhaseManager
    ): Promise<{
      success: boolean;
      message: string;
      status: 'advanced' | 'incomplete';
      current_phase: {
        id: string;
        name: string;
        status: string;
      } | null;
      next_phase: {
        id: string;
        name: string;
        status: string;
      } | null;
      missing_items: Array<{
        type: 'deliverable' | 'done_criterion';
        item: string;
        reason: string;
      }>;
      changes_applied: string[];
    }> {
      const missingItems: Array<{ type: 'deliverable' | 'done_criterion'; item: string; reason: string }> = [];
      const changesApplied: string[] = [];
    
      try {
        // Resolve repo path
        let repoPath = args.repo_root;
        if (!repoPath.startsWith('/')) {
          repoPath = join(homedir(), 'dev', repoPath);
        }
        repoPath = FSUtils.expandPath(repoPath);
    
        const expectedPhaseId = args.expected_current_phase.padStart(2, '0');
    
        // Read PHASES.md using absolute path (handles paths with spaces)
        const repoName = repoPath.split('/').pop() || 'unknown';
        const repoHandler = new RepoHandler();
        const projectPhases = repoHandler.readPhasesIndexFromPath(repoPath);
    
        if (!projectPhases) {
          return {
            success: false,
            message: 'Project not found. Run plan_project first.',
            status: 'incomplete',
            current_phase: null,
            next_phase: null,
            missing_items: [],
            changes_applied: [],
          };
        }
    
        // Find the expected phase
        const currentPhase = projectPhases.phases.find(p => p.id === expectedPhaseId);
        if (!currentPhase) {
          return {
            success: false,
            message: `Phase ${expectedPhaseId} not found`,
            status: 'incomplete',
            current_phase: null,
            next_phase: null,
            missing_items: [],
            changes_applied: [],
          };
        }
    
        // Verify this is the current phase
        if (currentPhase.status !== 'in_progress' && currentPhase.status !== 'active') {
          return {
            success: false,
            message: `Phase ${expectedPhaseId} is not currently active (status: ${currentPhase.status})`,
            status: 'incomplete',
            current_phase: {
              id: currentPhase.id,
              name: currentPhase.name,
              status: currentPhase.status,
            },
            next_phase: null,
            missing_items: [],
            changes_applied: [],
          };
        }
    
        // Read PHASE-XX.md to check deliverables and done criteria (handles paths with spaces)
        const phaseFilePath = repoHandler.getPhaseFileByIdFromPath(repoPath, expectedPhaseId);
        if (!FSUtils.fileExists(phaseFilePath)) {
          return {
            success: false,
            message: `Phase file PHASE-${expectedPhaseId}.md not found`,
            status: 'incomplete',
            current_phase: {
              id: currentPhase.id,
              name: currentPhase.name,
              status: currentPhase.status,
            },
            next_phase: null,
            missing_items: [{ type: 'deliverable', item: 'Phase file', reason: 'PHASE-XX.md file missing' }],
            changes_applied: [],
          };
        }
    
        const phaseContent = FSUtils.readFile(phaseFilePath);
    
        // Extract deliverables and check completion
        const deliverablesMatch = phaseContent.match(/## Deliverables\s*\n((?:- \[[ x]\] .+\n?)+)/);
        if (deliverablesMatch) {
          const items = deliverablesMatch[1].match(/- \[([ x])\] (.+)/g);
          if (items) {
            items.forEach(item => {
              const checked = item.startsWith('- [x]');
              const text = item.replace(/- \[[ x]\] /, '').trim();
              if (!checked) {
                missingItems.push({
                  type: 'deliverable',
                  item: text,
                  reason: 'Deliverable not marked as complete in checklist',
                });
              } else {
                // Verify the deliverable actually exists
                const verification = verifyDeliverableExists(text, repoPath);
                if (!verification.exists) {
                  missingItems.push({
                    type: 'deliverable',
                    item: text,
                    reason: verification.reason,
                  });
                }
              }
            });
          }
        }
    
        // Extract done criteria and check completion
        const doneCriteriaMatch = phaseContent.match(/## Done Criteria\s*\n((?:- \[[ x]\] .+\n?)+)/);
        if (doneCriteriaMatch) {
          const items = doneCriteriaMatch[1].match(/- \[([ x])\] (.+)/g);
          if (items) {
            items.forEach(item => {
              const checked = item.startsWith('- [x]');
              const text = item.replace(/- \[[ x]\] /, '').trim();
              if (!checked) {
                missingItems.push({
                  type: 'done_criterion',
                  item: text,
                  reason: 'Done criterion not marked as complete in checklist',
                });
              } else {
                // Verify the criterion is actually met
                const verification = verifyCriterionMet(text, repoPath);
                if (!verification.met) {
                  missingItems.push({
                    type: 'done_criterion',
                    item: text,
                    reason: verification.reason,
                  });
                }
              }
            });
          }
        }
    
        // If there are missing items, return incomplete
        if (missingItems.length > 0) {
          return {
            success: true,
            message: `Phase ${expectedPhaseId} is incomplete. ${missingItems.length} item(s) missing.`,
            status: 'incomplete',
            current_phase: {
              id: currentPhase.id,
              name: currentPhase.name,
              status: currentPhase.status,
            },
            next_phase: null,
            missing_items: missingItems,
            changes_applied: [],
          };
        }
    
        // All items complete - advance the phase
        // Mark current phase as "locked" (completed)
        currentPhase.status = 'locked';
        currentPhase.completed_at = new Date().toISOString();
        changesApplied.push(join(repoPath, 'PHASES.md'));
    
        // Update phase file with completion summary
        const updatedPhaseContent = addCompletionSummary(phaseContent, currentPhase);
        FSUtils.writeFile(phaseFilePath, updatedPhaseContent);
        changesApplied.push(phaseFilePath);
    
        // Find and activate next phase
        const currentPhaseIndex = projectPhases.phases.findIndex(p => p.id === expectedPhaseId);
        let nextPhase = null;
        
        if (currentPhaseIndex < projectPhases.phases.length - 1) {
          nextPhase = projectPhases.phases[currentPhaseIndex + 1];
          nextPhase.status = 'in_progress';
          nextPhase.started_at = new Date().toISOString();
          changesApplied.push(join(repoPath, 'PHASES.md'));
        }
    
        // Write updated PHASES.md using absolute path
        repoHandler.writePhasesIndexToPath(repoPath, projectPhases);
    
        return {
          success: true,
          message: `Phase ${expectedPhaseId} advanced successfully. ${nextPhase ? `Next phase ${nextPhase.id} activated.` : 'No more phases.'}`,
          status: 'advanced',
          current_phase: {
            id: currentPhase.id,
            name: currentPhase.name,
            status: currentPhase.status,
          },
          next_phase: nextPhase ? {
            id: nextPhase.id,
            name: nextPhase.name,
            status: nextPhase.status,
          } : null,
          missing_items: [],
          changes_applied: changesApplied,
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          success: false,
          message: `Failed to advance phase: ${errorMessage}`,
          status: 'incomplete',
          current_phase: null,
          next_phase: null,
          missing_items: [],
          changes_applied: [],
        };
      }
    }
  • Creates the Tool object defining the name, description, and input schema for overseer.advance_phase.
    export function createAdvancePhaseTool(phaseManager: PhaseManager): Tool {
      return {
        name: 'overseer.advance_phase',
        description: 'Advance a phase to the next phase after validating all deliverables are complete. Marks current phase as "locked" and sets next phase as current.',
        inputSchema: {
          type: 'object',
          required: ['repo_root', 'expected_current_phase'],
          properties: {
            repo_root: {
              type: 'string',
              description: 'Root path of the repository',
            },
            expected_current_phase: {
              type: 'string',
              description: 'Phase ID that should currently be active (e.g., "01", "02")',
            },
          },
        },
      };
    }
  • Registers the advance phase tool in the list of available tools via createTools.
    export function createTools(context: ToolContext): Tool[] {
      return [
        // Planning tools
        createPlanProjectTool(context.phaseManager),
        createInferPhasesTool(context.configLoader),
        createUpdatePhasesTool(context.phaseManager),
        // Execution tools
        createRunPhaseTool(context.phaseManager),
        createAdvancePhaseTool(context.phaseManager),
        createStatusTool(context.phaseManager),
        // QA tools
        createLintRepoTool(context.configLoader),
        createSyncDocsTool(context.phaseManager),
        createCheckComplianceTool(context.phaseManager),
        // Environment tools
        createEnvMapTool(context.phaseManager),
        createGenerateCiTool(context.phaseManager),
        createSecretsTemplateTool(context.phaseManager),
      ];
    }
  • Registers the handler for overseer.advance_phase in the tool dispatcher switch statement.
    case 'overseer.advance_phase':
      return await handleAdvancePhase(args, context.phaseManager);
  • Helper function to verify if deliverables (files/directories) actually exist in the repo.
    function verifyDeliverableExists(deliverable: string, repoPath: string): { exists: boolean; reason: string } {
      // Check for file references
      const filePattern = /([a-zA-Z0-9_\-./]+\.(md|ts|js|json|yml|yaml|txt|py|java|go|rs|php|rb|ex|exs))/g;
      const fileMatches = deliverable.match(filePattern);
    
      if (fileMatches) {
        for (const fileRef of fileMatches) {
          const filePath = join(repoPath, fileRef);
          if (!FSUtils.fileExists(filePath)) {
            return {
              exists: false,
              reason: `File ${fileRef} does not exist`,
            };
          }
        }
        return { exists: true, reason: '' };
      }
    
      // Check for directory references
      const dirPattern = /(src|app|lib|tests|docs|config|dist|build)\//;
      if (dirPattern.test(deliverable)) {
        const dirMatch = deliverable.match(dirPattern);
        if (dirMatch) {
          const dirPath = join(repoPath, dirMatch[1]);
          if (!FSUtils.dirExists(dirPath)) {
            return {
              exists: false,
              reason: `Directory ${dirMatch[1]}/ does not exist`,
            };
          }
        }
        return { exists: true, reason: '' };
      }
    
      // Generic deliverable - assume exists if we can't verify
      return { exists: true, reason: '' };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool marks the current phase as 'locked' and sets the next phase as current, which are behavioral traits. However, it lacks details on permissions required, error handling, side effects on other phases, or what happens if validation fails, leaving significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action and outcome without unnecessary words. Every part earns its place by specifying the validation condition and the state changes, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity as a mutation tool with no annotations and no output schema, the description is incomplete. It covers the basic purpose and behavior but lacks details on validation criteria, error responses, or what 'locked' entails, which are crucial for safe usage. It is minimally adequate but has clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters ('repo_root' and 'expected_current_phase') fully. The description does not add any meaning beyond the schema, such as explaining the format of 'expected_current_phase' or how 'repo_root' is used in validation. Baseline 3 is appropriate as the schema handles parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('advance a phase') and the outcome ('marks current phase as "locked" and sets next phase as current'), which is specific and actionable. However, it does not explicitly differentiate this tool from sibling tools like 'overseer.update_phases' or 'overseer.run_phase', which might involve phase management, leaving some ambiguity in sibling context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by mentioning 'after validating all deliverables are complete,' suggesting it should be used when deliverables are ready, but it does not provide explicit guidance on when to use this tool versus alternatives like 'overseer.update_phases' or 'overseer.run_phase.' No exclusions or clear alternatives are stated, relying on implied context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/freqkflag/PROJECT-OVERSEER-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server