Journal Entries
MECA Initiative - Phase III Project Plan
2025-06-11
The capstone phase: this plan details the implementation of the full MPI system for dynamic agent operations, a smart 'integrateExperiment' command, and the final 'promote' graduation pipeline to complete the core MECA workflow.
MECA Initiative: Completion of Phases I & II
2025-06-10
A memo from project management to the development team and stakeholders announcing the successful completion of Phases I and II of the MECA Initiative and the official kickoff of Phase III.
MECA Initiative - Phase II Project Plan
2025-06-09
Actionable plan to build the MECA engine. Covers the foundational transactional context (TxContext), the first AST-based helper (addImport), and the flagship 'createExperiment' operation to enable programmatic project scaffolding.
MECA Initiative - Phase I Project Plan
2025-06-08
Actionable plan to build the foundational MECA infrastructure. Covers workspace scaffolding, the core Project abstraction, and a 'hello-world' CLI to validate the entire toolchain.
Project Kickoff: The MECA Initiative
2025-06-07
Kickoff for the Metaprogramming-Enabled Component Architecture (MECA) Initiative
On the Care and Training of Digital Apprentices
2025-06-06
A wry examination of artificial intelligence through the eyes of someone who has seen many promised revolutions come and go.
MECA Initiative - Phase III Project Plan
❦
2025-06-11
meca
project-plan
phase-3
mpi
workflow-automation
graduation-pipeline
capstone
❦
Welcome to Phase III, team. This is the capstone phase where we bring everything together. The foundational workbench and the core engine are built; now, we build the "flywheel" that makes the entire system powerful and intelligent. The objective is to implement the complete, end-to-end workflow for an agent: discovering available operations, executing complex changes, and promoting a finished experiment to production. When this phase is complete, MECA will be fully operational for its primary use case.
meca
CLI to discover and execute operations defined in any component's .meta.ts
file.web:integrateExperiment
, that composes multiple smaller operations to modify both dependencies and code.meca promote
command, which validates an experiment, moves it to the production packages
workspace, and prepares it for consumption.meca list mpi <ComponentName>
command successfully reads a .meta.ts
file and lists its exported operations.meca run <component> <operation> --params '{...}'
command can dynamically execute an MPI handler.web:integrateExperiment
operation correctly adds a dependency to the sandbox/web
app's package.json
AND adds the component's import and JSX to pages/index.tsx
.meca promote <ComponentName>
command successfully moves a package from sandbox/
to packages/
and, crucially, deletes the .meta.ts
file from the promoted version.This is the heart of the framework's dynamic nature.
Step 1.1: MPI Discovery (list mpi
).
meca-cli
, create the new command list mpi <componentName>
.sandbox
..meta.ts
file.ts-morph
script to parse the file and find the names of the top-level exports, logging them to the console. This proves the discovery mechanism.Step 1.2: The AstContext
.
meca-core
, we need to define the context object that will be passed to every MPI handler. Create a new ast-context.ts
file.AstContext
class will be a sandboxed environment. It should be initialized with the target SourceFile
(from ts-morph
) and provide access to our existing helpers (like addImport
).Step 1.3: MPI Execution (ctx.run
).
TxContext
from Phase II.{ type: 'RUN_MPI', componentName: string, opName: string, params: any }
.commit
encounters this operation, it must:
import()
the target component's .meta.ts
file.opName
.AstContext
for the component's main .tsx
file.handler(astContext, params)
.SourceFile
from the AstContext
.Let's build a high-value, real-world operation to prove the power of composition.
Step 2.1: Create a new package packages/meca-web-ops
to house web-specific, reusable operations.
Step 2.2: In this new package, define the integrateExperiment
MPI operation. The handler function will be a sequence of steps managed by the TxContext
:
// In a new meca-web-ops package...
// The handler for the 'integrateExperiment' operation
async function handler(ctx, params: { experimentName: string }) {
// 1. Modify package.json (a file system operation)
await ctx.modifyJsonFile('sandbox/web/package.json', (json) => {
json.dependencies[params.experimentName] = "workspace:*";
});
// 2. Modify the main page (an AST operation)
await ctx.modifyAstFile('sandbox/web/pages/index.tsx', (sourceFile) => {
// Use the helper from Phase II
addImport(sourceFile, { moduleSpecifier: params.experimentName, ... });
// Use another helper to find the main JSX return and add the component
insertJsxChild(sourceFile, ...);
});
}
Note: This will require adding new capabilities to TxContext
like modifyJsonFile
and modifyAstFile
.
Step 2.3: Wire up the generic meca run
command in the CLI to execute these MPIs. meca run web integrateExperiment --params '{ "experimentName": "my-timeline" }'
.
This task completes the component lifecycle.
Step 3.1: In meca-cli
, create the meca promote <componentName>
command.
Step 3.2: The handler for this command will orchestrate a multi-step transaction using project.transaction()
:
COPY_DIRECTORY
operation to copy the entire component package from sandbox/
to packages/
.DELETE_FILE
operation that targets the .meta.ts
file in the destination directory (packages/<componentName>/src/...
). This is the most critical step of the promotion.This is the final exam for the entire MECA framework.
Step 4.1: Execute the full workflow from the command line:
pnpm exec meca create:experiment cool-new-feature
pnpm exec meca list mpi cool-new-feature
(Verify it has a default empty export)pnpm exec meca run web integrateExperiment --params '{ "experimentName": "cool-new-feature" }'
sandbox/web/package.json
and sandbox/web/pages/index.tsx
.pnpm exec meca promote cool-new-feature
packages/cool-new-feature
exists and that cool-new-feature.meta.ts
is gone from the packages
version.Step 4.2: Upon successful verification, we can celebrate. The core vision of the MECA framework will have been realized.