Skip to content

Epic: Monorepo Package-Aware Commands#947

Draft
acreeger wants to merge 6 commits intomainfrom
feat/issue-938__monorepo-package-aware-commands
Draft

Epic: Monorepo Package-Aware Commands#947
acreeger wants to merge 6 commits intomainfrom
feat/issue-938__monorepo-package-aware-commands

Conversation

@acreeger
Copy link
Copy Markdown
Collaborator

Fixes #938

Epic: Monorepo Package-Aware Commands

Summary

Add monorepo awareness to iloom so that AI agents can declare which packages they're working on, and il commands (test, lint, compile, build, dev-server) automatically scope themselves to those packages.

Context

iloom currently treats every project as a single unit. In monorepos (pnpm workspaces, yarn/npm workspaces), this means validation runs against ALL packages even when changes are isolated, dev servers can't target specific packages, and agents have no structured way to communicate which packages are relevant.

Design

The AI agent (swarm orchestrator or issue implementer) is the intelligence layer. It explores the monorepo, reads the issue, and writes two metadata fields via MCP tools:

  • packagesToRun: string[] — which package to launch a dev server for (MCP accepts singular, stored as array for future compat)
  • packagesToValidate: string[] — which packages to scope test/lint/compile/build to

A new "monorepo" capability (alongside "web" and "cli") gates all monorepo behavior. It's detected during il init and stored in package.iloom.json.

A dedicated iloom-monorepo-package-detector agent runs:

  • Non-swarm mode: before implementation, to set both metadata fields
  • Swarm mode: after swarm completion, called by the orchestrator for final validation setup

All il commands read from metadata. Auto-fix agents receive --append-system-prompt instructing them to use il commands. A user-prompt-submit hook reminds agents to update metadata when touching new packages.

The dev server command, when both web and monorepo capabilities are present, watches the metadata file and launches once packagesToRun is set.

Acceptance Criteria

  • Agents can set monorepo package metadata via MCP tools
  • il test, il lint, il compile, il build scope to declared packages when metadata is set
  • il dev-server launches the correct package's dev server based on metadata
  • il init detects monorepos and sets the "monorepo" capability
  • A dedicated detection agent runs at the right lifecycle points (before impl in non-swarm, after completion in swarm)
  • Non-monorepo projects are completely unaffected
  • Works with pnpm, yarn, and npm workspace package managers

Scope Boundaries

  • v1 supports JavaScript/TypeScript monorepos only (pnpm + yarn/npm workspaces)
  • Non-JS workspace extensions (Rust, Go, Python) are tracked separately
  • Dev server supports one package at a time (reads packagesToRun[0])
  • No programmatic monorepo detection utility — the AI agent handles all detection intelligence

This PR was created automatically by iloom.

…ta fields and MCP tools

- Add optional packagesToRun and packagesToValidate string array fields to
  MetadataFile, WriteMetadataInput, and LoomMetadata (with empty-array defaults)
- Register set_package_to_run MCP tool (single string stored as single-element array)
- Register set_packages_to_validate MCP tool (string array stored directly)
- Both tools warn but don't fail when package paths don't exist on disk
- Use !== undefined guard in writeMetadata to allow clearing arrays to empty
- Fix specific error handling (SyntaxError vs ENOENT) in MCP tool catch blocks
- Also fix missing swarmTeamName conditional spread in writeMetadata
- Add 'monorepo' to ProjectCapability union type and Zod schema
- Auto-detect monorepo from pnpm-workspace.yaml and package.json workspaces field in ProjectCapabilityDetector
- Update iloom-framework-detector agent template to recognize monorepo markers
- Update init-prompt.txt to include monorepo as a project type option
- Add helpful error message in open command for monorepo-only projects
- Add docs for project capabilities including monorepo in iloom-commands.md
- Fix type-safe mock casts in ProjectCapabilityDetector tests
@acreeger acreeger force-pushed the feat/issue-938__monorepo-package-aware-commands branch from 78064ee to 49452b7 Compare March 17, 2026 23:07
…s from metadata

When packagesToValidate is set in loom metadata, il test, il lint, il compile,
and il build now scope commands to only those packages using the detected package
manager's filter syntax (pnpm --filter, npm --workspace, yarn workspaces foreach).

- Add packages option to RunScriptOptions and buildMonorepoFilterArgs helper
- ScriptCommandBase reads packagesToValidate from MetadataManager and passes to runScript
- CompileCommand.execute override updated with same scoping logic
- ValidationRunner accepts packagesToValidate in ValidationOptions and passes to all steps
- Auto-fix Claude agents receive --append-system-prompt instructing them to use il commands
- finish.ts reads packagesToValidate from metadata and passes to runValidations
- Packages missing the target script are gracefully skipped via --if-present flag
- Tests updated and new monorepo scoping tests added to ValidationRunner.test.ts
…gration

- Add `iloom-monorepo-package-detector` agent template that explores workspace structure and calls MCP tools to set packagesToRun and packagesToValidate
- Add IS_MONOREPO template variable to PromptTemplateManager derived from project capabilities
- Wire detection agent in ignite.ts for both non-swarm (runs before implementation) and swarm (orchestrator calls after completion) workflows
- Add IS_MONOREPO-conditioned detection step in issue-prompt.txt Todo Lists (swarm step 6.5, non-swarm step 15.5) and pre-implementation instruction block
- Add IS_MONOREPO-conditioned Step 5.2.8 in swarm-orchestrator-prompt.txt for post-swarm detection
- Add monorepo package reminder to UserPromptSubmit handlers in iloom-hook.js
- Exclude detection agent from standard agent auto-loading in all three load sites
- Update ignite.test.ts with new exclusion glob pattern
- Document monorepo detection workflow in docs/iloom-commands.md
When both web and monorepo capabilities are present, il dev-server now
watches the loom metadata file instead of launching immediately. Once
packagesToRun is populated by the detection agent, the dev server launches
from the correct package subdirectory.

Key behaviors:
- Detects web+monorepo capabilities and enters watch mode
- Uses fs.watch with 15s polling fallback for reliability
- Times out after 60s with an actionable error message
- Concurrency-safe (isChecking guard prevents overlapping reads)
- Only suppresses ENOENT and SyntaxError in catch (not all errors)
- Validates package path is relative to prevent path traversal
- Falls back to root-level launch when monorepo capability is absent
- Tracks is_monorepo on devServer.started telemetry event
…ection agent, and dev server watching

- Metadata fields (packagesToRun, packagesToValidate) with MCP tools (#939)
- Monorepo capability auto-detection during il init (#940)
- Scoped il test/lint/compile/build to declared packages (#942)
- Package detection agent for non-swarm and swarm workflows (#943)
- Dev server metadata watching for monorepo package target (#944)
- Fix MCP tool name mismatches (camelCase -> snake_case) and add tools to swarm allowedTools
- Add monorepo guide, README section, and command reference docs

Fixes #938
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Epic: Monorepo Package-Aware Commands

1 participant