Skip to main content
Glama

aide_discover

Scan your project for .aide spec files to reveal intent architecture. Use without a path for a project-wide map, or with a path to drill into a directory and view the ancestor chain with summaries.

Instructions

Scan for .aide spec files in this project. Returns a tree map of where specs live, following progressive disclosure.

Without a path: returns a lightweight project-wide map — file locations and types only, no content. Use this once to understand the project's spec architecture.

With a path: the response opens with the ancestor chain — the cascading intent lineage from project root down to the target directory, with each ancestor showing its description and alignment status (aligned/misaligned when set). The ancestor chain gives you the full inherited context before you read a single spec body. After the ancestor chain comes the detailed subtree of the target directory — summaries extracted from file content and anomaly warnings. Use this to drill into the area you're working on.

.aide files are progressive disclosure specs that live next to orchestrator code — they contain intent (strategy, implementation contracts, anti-patterns), research (sources, data, patterns), or QA checklists (todo). Read .aide files BEFORE reading code — they are the context layer between folder structure and implementation details.

File types (.aide, intent.aide, research.aide, plan.aide, todo.aide):

  • .aide — Intent spec (default). Strategy, contracts, anti-patterns.

  • intent.aide — Same as .aide, used only when research.aide exists in the same folder.

  • research.aide — Raw research. Sources, data points, pattern synthesis.

  • plan.aide -- Architect's implementation plan. Checkboxed steps for the implementor.

  • todo.aide — QA re-alignment document. Captures where implementation drifted from intent.

Never have both .aide and intent.aide in the same folder.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoSubdirectory to drill into. When provided, the response opens with the ancestor chain — the cascading intent lineage from root to target, each ancestor showing its description and alignment status — followed by the detailed subtree with summaries and warnings. When omitted, returns a shallow project-wide map (locations and types only).

Implementation Reference

  • The main handler function for the aide_discover tool. Scans for .aide files, builds a tree map, optionally adds ancestor chain and anomaly warnings.
    export default async function discover(root: string, path?: string): Promise<string> {
    	const shallow = !path;
    	const result = await scan(root, path, shallow);
    	const { files } = result;
    
    	if (files.length === 0) {
    		return "No .aide files found." + (path ? ` (searched in ${path})` : "");
    	}
    
    	const projectName = basename(root);
    	const header = `${projectName} project — ${files.length} spec${files.length === 1 ? "" : "s"} found`;
    
    	const tree = buildTree(files, root);
    
    	// Only run anomaly detection and ancestor chain on deep (scoped) scans
    	let ancestorChain = "";
    	let warningBlock = "";
    	if (!shallow) {
    		ancestorChain = await buildAncestorChain(root, join(root, path));
    
    		const anomalies = await detectAnomalies(files, root);
    		if (anomalies.length > 0) {
    			const lines = anomalies.map((w) => `  ${w.path} — ${w.message}`);
    			warningBlock = `\n\n⚠ Warnings:\n${lines.join("\n")}`;
    		}
    	}
    
    	// Build output: header + optional ancestor chain + tree + optional warnings
    	// Each block separated by a blank line when present
    	const parts: string[] = [header];
    	if (ancestorChain) parts.push(ancestorChain);
    	parts.push(tree);
    
    	return parts.join("\n\n") + warningBlock;
    }
  • Zod schema for the aide_discover tool input — accepts an optional 'path' string parameter.
    export const DiscoverInput = z.object({
    	path: z.string().optional().describe("Subdirectory to scan (defaults to entire project)"),
    });
  • src/index.ts:82-95 (registration)
    Tool registration in ListToolsRequestSchema — defines the tool name, description, and inputSchema for aide_discover.
    	name: "aide_discover",
    	description:
    		"Scan for .aide spec files in this project. Returns a tree map of where specs live, following progressive disclosure.\n\nWithout a path: returns a lightweight project-wide map — file locations and types only, no content. Use this once to understand the project's spec architecture.\n\nWith a path: the response opens with the ancestor chain — the cascading intent lineage from project root down to the target directory, with each ancestor showing its description and alignment status (aligned/misaligned when set). The ancestor chain gives you the full inherited context before you read a single spec body. After the ancestor chain comes the detailed subtree of the target directory — summaries extracted from file content and anomaly warnings. Use this to drill into the area you're working on.\n\n.aide files are progressive disclosure specs that live next to orchestrator code — they contain intent (strategy, implementation contracts, anti-patterns), research (sources, data, patterns), or QA checklists (todo). Read .aide files BEFORE reading code — they are the context layer between folder structure and implementation details.\n\nFile types (.aide, intent.aide, research.aide, plan.aide, todo.aide):\n- .aide — Intent spec (default). Strategy, contracts, anti-patterns.\n- intent.aide — Same as .aide, used only when research.aide exists in the same folder.\n- research.aide — Raw research. Sources, data points, pattern synthesis.\n- plan.aide -- Architect's implementation plan. Checkboxed steps for the implementor.\n- todo.aide — QA re-alignment document. Captures where implementation drifted from intent.\n\nNever have both .aide and intent.aide in the same folder.",
    	inputSchema: {
    		type: "object" as const,
    		properties: {
    			path: {
    				type: "string",
    				description:
    					"Subdirectory to drill into. When provided, the response opens with the ancestor chain — the cascading intent lineage from root to target, each ancestor showing its description and alignment status — followed by the detailed subtree with summaries and warnings. When omitted, returns a shallow project-wide map (locations and types only).",
    			},
    		},
    	},
    },
  • src/index.ts:251-255 (registration)
    Tool call handler in CallToolRequestSchema — routes 'aide_discover' to the discover function via switch statement.
    case "aide_discover": {
    	const parsed = DiscoverInput.parse(args);
    	const result = await discover(root, parsed.path);
    	return { content: [{ type: "text", text: result }] };
    }
  • Builds the ancestor chain — walks from target directory up to root, collecting .aide spec metadata (description, status) for each level.
    export default async function buildAncestorChain(root: string, targetPath: string): Promise<string> {
    	// Normalize to absolute paths
    	const absRoot = root.replace(/\\/g, "/");
    	const absTarget = targetPath.replace(/\\/g, "/");
    
    	// No ancestors when the target IS the root
    	if (absTarget === absRoot) return "";
    
    	/** Walk upward from target's parent to root, collecting directory levels. */
    	const levels: string[] = [];
    	let current = dirname(absTarget);
    
    	while (true) {
    		levels.push(current);
    		if (current === absRoot) break;
    		const parent = dirname(current);
    		// Guard against hitting the filesystem root (should not happen in practice)
    		if (parent === current) break;
    		current = parent;
    	}
    
    	// levels is ordered target-parent → root; reverse for root-first rendering
    	levels.reverse();
    
    	/** Try to read a file, returning null if it does not exist. */
    	async function tryRead(filePath: string): Promise<string | null> {
    		try {
    			return await readFile(filePath, "utf-8");
    		} catch {
    			return null;
    		}
    	}
    
    	/** Resolve which spec file to use at a given directory level, if any. */
    	async function resolveSpec(dir: string): Promise<{ specPath: string; content: string } | null> {
    		const isRoot = dir === absRoot;
    
    		if (isRoot) {
    			// Root-level spec lives at .aide/intent.aide per AIDE placement rules
    			const rootSpec = join(dir, ".aide", "intent.aide");
    			const content = await tryRead(rootSpec);
    			if (content !== null) return { specPath: rootSpec, content };
    			return null;
    		}
    
    		// Non-root: check .aide first, then intent.aide
    		const dotAide = join(dir, ".aide");
    		const intentAide = join(dir, "intent.aide");
    
    		const dotAideContent = await tryRead(dotAide);
    		if (dotAideContent !== null) return { specPath: dotAide, content: dotAideContent };
    
    		const intentAideContent = await tryRead(intentAide);
    		if (intentAideContent !== null) return { specPath: intentAide, content: intentAideContent };
    
    		return null;
    	}
    
    	const lines: string[] = [];
    
    	for (const dir of levels) {
    		const spec = await resolveSpec(dir);
    		if (!spec) continue;
    
    		const { frontmatter, parseError } = parseFrontmatter(spec.content);
    		const description = frontmatter?.description || (frontmatter?.intent ? frontmatter.intent.split(/[.\n]/)[0] : undefined);
    		const status = frontmatter?.status;
    
    		// Compute a display path relative to the project root
    		const rel = relative(absRoot, spec.specPath).replace(/\\/g, "/");
    		const displayPath = rel || spec.specPath;
    
    		let line = `  ${displayPath}`;
    		if (description) {
    			line += ` — ${description}`;
    		}
    		// Status badge renders whenever set, regardless of whether description is present
    		if (status === "aligned" || status === "misaligned") {
    			line += ` [${status}]`;
    		}
    		if (parseError) {
    			line += ` ⚠ YAML parse error: ${parseError}`;
    		}
    		// If no description and no status, show path alone (no em-dash, no fabrication)
    
    		lines.push(line);
    	}
    
    	if (lines.length === 0) return "";
    
    	return `Ancestor chain:\n${lines.join("\n")}`;
    }
  • Builds a progressive disclosure tree string from discovered .aide files, grouped by directory with type tags and summaries.
    export default function buildTree(files: AideFile[], root: string): string {
    	if (files.length === 0) return "";
    
    	const groups = groupByDir(files);
    	const sortedDirs = [...groups.keys()].sort();
    
    	const lines: string[] = [];
    
    	for (let d = 0; d < sortedDirs.length; d++) {
    		const dir = sortedDirs[d];
    		const dirFiles = sortFiles(groups.get(dir)!);
    
    		// Directory header
    		lines.push(`${dir}/`);
    
    		for (let f = 0; f < dirFiles.length; f++) {
    			const file = dirFiles[f];
    			const isLastFile = f === dirFiles.length - 1;
    			const connector = isLastFile ? "└──" : "├──";
    			const name = basename(file.relativePath);
    			const tag = `[${file.type}]`;
    			const label =
    				file.type === "intent" || file.type === "research"
    					? file.description || ""
    					: file.summary || "";
    			const summary = label ? ` — ${label}` : "";
    			const parseWarn = file.parseError ? ` ⚠ YAML parse error: ${file.parseError}` : "";
    			lines.push(`  ${connector} ${name} ${tag}${summary}${parseWarn}`);
    		}
    
    		if (d < sortedDirs.length - 1) lines.push("");
    	}
    
    	return lines.join("\n");
    }
Behavior4/5

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

With no annotations, the description carries full burden. It details behavioral differences between path modes, progressive disclosure, ancestor chain, alignment status, and file type meanings. It does not mention error handling or performance, but otherwise provides substantial behavioral context for a read-only scan operation.

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

Conciseness4/5

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

The description is long but front-loaded with the main action. It contains detailed file type explanations that are valuable but slightly repetitive. Every sentence earns its place, though it could be condensed without losing meaning.

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

Completeness4/5

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

Given no output schema or annotations, the description is complete: it explains two modes, response structure, file types, and usage context. It lacks error handling details but covers the core functionality thoroughly for a scanning tool.

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

Parameters5/5

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

The schema covers 100% of parameters with a description of 'path'. The description adds significant meaning: it explains the behavioral difference when path is provided vs not, and the response structure (ancestor chain, detailed subtree). This goes well beyond the schema description.

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

Purpose5/5

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

The description clearly states 'Scan for .aide spec files in this project. Returns a tree map of where specs live, following progressive disclosure.' This specific verb+resource combination distinguishes it from sibling tools like aide_read (read content) and aide_info (info). The two modes (with/without path) further clarify its scope.

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

Usage Guidelines4/5

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

The description provides explicit usage guidance: 'Without a path: returns a lightweight project-wide map... Use this once to understand the project's spec architecture.' and 'With a path: ... Use this to drill into the area you're working on.' It also advises reading .aide files before code. However, it lacks explicit when-not-to-use or comparison with sibling tools like aide_inspect.

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/aidemd-mcp/server'

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