Compare commits
1 Commits
release/mo
...
cb6f61cf82
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb6f61cf82 |
@@ -21,6 +21,9 @@
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run --passWithNoTests"
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": "^13.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"@vitest/coverage-v8": "^2.0.0",
|
||||
|
||||
77
packages/macp/src/cli.spec.ts
Normal file
77
packages/macp/src/cli.spec.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { Command } from 'commander';
|
||||
import { registerMacpCommand } from './cli.js';
|
||||
|
||||
describe('registerMacpCommand', () => {
|
||||
function buildProgram(): Command {
|
||||
const program = new Command();
|
||||
program.exitOverride(); // prevent process.exit in tests
|
||||
registerMacpCommand(program);
|
||||
return program;
|
||||
}
|
||||
|
||||
it('registers a "macp" command on the parent', () => {
|
||||
const program = buildProgram();
|
||||
const macpCmd = program.commands.find((c) => c.name() === 'macp');
|
||||
expect(macpCmd).toBeDefined();
|
||||
});
|
||||
|
||||
it('registers "macp tasks" subcommand group', () => {
|
||||
const program = buildProgram();
|
||||
const macpCmd = program.commands.find((c) => c.name() === 'macp')!;
|
||||
const tasksCmd = macpCmd.commands.find((c) => c.name() === 'tasks');
|
||||
expect(tasksCmd).toBeDefined();
|
||||
});
|
||||
|
||||
it('registers "macp tasks list" subcommand with --status and --type flags', () => {
|
||||
const program = buildProgram();
|
||||
const macpCmd = program.commands.find((c) => c.name() === 'macp')!;
|
||||
const tasksCmd = macpCmd.commands.find((c) => c.name() === 'tasks')!;
|
||||
const listCmd = tasksCmd.commands.find((c) => c.name() === 'list');
|
||||
expect(listCmd).toBeDefined();
|
||||
const optionNames = listCmd!.options.map((o) => o.long);
|
||||
expect(optionNames).toContain('--status');
|
||||
expect(optionNames).toContain('--type');
|
||||
});
|
||||
|
||||
it('registers "macp submit" subcommand', () => {
|
||||
const program = buildProgram();
|
||||
const macpCmd = program.commands.find((c) => c.name() === 'macp')!;
|
||||
const submitCmd = macpCmd.commands.find((c) => c.name() === 'submit');
|
||||
expect(submitCmd).toBeDefined();
|
||||
});
|
||||
|
||||
it('registers "macp gate" subcommand with --fail-on flag', () => {
|
||||
const program = buildProgram();
|
||||
const macpCmd = program.commands.find((c) => c.name() === 'macp')!;
|
||||
const gateCmd = macpCmd.commands.find((c) => c.name() === 'gate');
|
||||
expect(gateCmd).toBeDefined();
|
||||
const optionNames = gateCmd!.options.map((o) => o.long);
|
||||
expect(optionNames).toContain('--fail-on');
|
||||
});
|
||||
|
||||
it('registers "macp events" subcommand group', () => {
|
||||
const program = buildProgram();
|
||||
const macpCmd = program.commands.find((c) => c.name() === 'macp')!;
|
||||
const eventsCmd = macpCmd.commands.find((c) => c.name() === 'events');
|
||||
expect(eventsCmd).toBeDefined();
|
||||
});
|
||||
|
||||
it('registers "macp events tail" subcommand', () => {
|
||||
const program = buildProgram();
|
||||
const macpCmd = program.commands.find((c) => c.name() === 'macp')!;
|
||||
const eventsCmd = macpCmd.commands.find((c) => c.name() === 'events')!;
|
||||
const tailCmd = eventsCmd.commands.find((c) => c.name() === 'tail');
|
||||
expect(tailCmd).toBeDefined();
|
||||
});
|
||||
|
||||
it('has all required top-level subcommands', () => {
|
||||
const program = buildProgram();
|
||||
const macpCmd = program.commands.find((c) => c.name() === 'macp')!;
|
||||
const topLevel = macpCmd.commands.map((c) => c.name());
|
||||
expect(topLevel).toContain('tasks');
|
||||
expect(topLevel).toContain('submit');
|
||||
expect(topLevel).toContain('gate');
|
||||
expect(topLevel).toContain('events');
|
||||
});
|
||||
});
|
||||
92
packages/macp/src/cli.ts
Normal file
92
packages/macp/src/cli.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
import type { Command } from 'commander';
|
||||
|
||||
/**
|
||||
* Register macp subcommands on an existing Commander program.
|
||||
* This avoids cross-package Commander version mismatches by using the
|
||||
* caller's Command instance directly.
|
||||
*/
|
||||
export function registerMacpCommand(parent: Command): void {
|
||||
const macp = parent.command('macp').description('MACP task and gate management');
|
||||
|
||||
// ─── tasks ───────────────────────────────────────────────────────────────
|
||||
|
||||
const tasks = macp.command('tasks').description('Manage MACP tasks');
|
||||
|
||||
tasks
|
||||
.command('list')
|
||||
.description('List MACP tasks')
|
||||
.option(
|
||||
'--status <status>',
|
||||
'Filter by task status (pending|running|gated|completed|failed|escalated)',
|
||||
)
|
||||
.option(
|
||||
'--type <type>',
|
||||
'Filter by task type (coding|deploy|research|review|documentation|infrastructure)',
|
||||
)
|
||||
.action((opts: { status?: string; type?: string }) => {
|
||||
// not yet wired — task persistence layer is not present in @mosaicstack/macp
|
||||
console.log('[macp] tasks list: not yet wired — use macp package programmatically');
|
||||
if (opts.status) {
|
||||
console.log(` status filter: ${opts.status}`);
|
||||
}
|
||||
if (opts.type) {
|
||||
console.log(` type filter: ${opts.type}`);
|
||||
}
|
||||
process.exitCode = 0;
|
||||
});
|
||||
|
||||
// ─── submit ──────────────────────────────────────────────────────────────
|
||||
|
||||
macp
|
||||
.command('submit <path>')
|
||||
.description('Submit a task from a JSON/YAML spec file')
|
||||
.action((specPath: string) => {
|
||||
// not yet wired — task submission requires a running MACP server
|
||||
console.log('[macp] submit: not yet wired — use macp package programmatically');
|
||||
console.log(` spec path: ${specPath}`);
|
||||
console.log(' task id: (unavailable — no MACP server connected)');
|
||||
console.log(' status: (unavailable — no MACP server connected)');
|
||||
process.exitCode = 0;
|
||||
});
|
||||
|
||||
// ─── gate ────────────────────────────────────────────────────────────────
|
||||
|
||||
macp
|
||||
.command('gate <spec>')
|
||||
.description('Run a gate from a spec string or file path (wraps runGate/runGates)')
|
||||
.option('--fail-on <mode>', 'Gate fail-on mode: ai|fail|both|none', 'fail')
|
||||
.option('--cwd <path>', 'Working directory for gate execution', process.cwd())
|
||||
.option('--log <path>', 'Path to write gate log output', '/tmp/macp-gate.log')
|
||||
.option('--timeout <seconds>', 'Gate timeout in seconds', '60')
|
||||
.action((spec: string, opts: { failOn: string; cwd: string; log: string; timeout: string }) => {
|
||||
// not yet wired — gate execution requires a task context and event sink
|
||||
console.log('[macp] gate: not yet wired — use macp package programmatically');
|
||||
console.log(` spec: ${spec}`);
|
||||
console.log(` fail-on: ${opts.failOn}`);
|
||||
console.log(` cwd: ${opts.cwd}`);
|
||||
console.log(` log: ${opts.log}`);
|
||||
console.log(` timeout: ${opts.timeout}s`);
|
||||
process.exitCode = 0;
|
||||
});
|
||||
|
||||
// ─── events ──────────────────────────────────────────────────────────────
|
||||
|
||||
const events = macp.command('events').description('Stream MACP events');
|
||||
|
||||
events
|
||||
.command('tail')
|
||||
.description('Tail MACP events from the event log (wraps event emitter)')
|
||||
.option('--file <path>', 'Path to the MACP events NDJSON file')
|
||||
.option('--follow', 'Follow the file for new events (like tail -f)')
|
||||
.action((opts: { file?: string; follow?: boolean }) => {
|
||||
// not yet wired — event streaming requires a live event source
|
||||
console.log('[macp] events tail: not yet wired — use macp package programmatically');
|
||||
if (opts.file) {
|
||||
console.log(` file: ${opts.file}`);
|
||||
}
|
||||
if (opts.follow) {
|
||||
console.log(' mode: follow');
|
||||
}
|
||||
process.exitCode = 0;
|
||||
});
|
||||
}
|
||||
@@ -41,3 +41,6 @@ export type { NormalizedGate } from './gate-runner.js';
|
||||
|
||||
// Event emitter
|
||||
export { nowISO, appendEvent, emitEvent } from './event-emitter.js';
|
||||
|
||||
// CLI
|
||||
export { registerMacpCommand } from './cli.js';
|
||||
|
||||
@@ -4,6 +4,7 @@ import { createRequire } from 'module';
|
||||
import { Command } from 'commander';
|
||||
import { registerBrainCommand } from '@mosaicstack/brain';
|
||||
import { registerLogCommand } from '@mosaicstack/log';
|
||||
import { registerMacpCommand } from '@mosaicstack/macp';
|
||||
import { registerMemoryCommand } from '@mosaicstack/memory';
|
||||
import { registerQualityRails } from '@mosaicstack/quality-rails';
|
||||
import { registerQueueCommand } from '@mosaicstack/queue';
|
||||
@@ -347,6 +348,10 @@ registerMissionCommand(program);
|
||||
|
||||
registerBrainCommand(program);
|
||||
|
||||
// ─── macp ────────────────────────────────────────────────────────────────
|
||||
|
||||
registerMacpCommand(program);
|
||||
|
||||
// ─── quality-rails ──────────────────────────────────────────────────────
|
||||
|
||||
registerQualityRails(program);
|
||||
|
||||
4
pnpm-lock.yaml
generated
4
pnpm-lock.yaml
generated
@@ -419,6 +419,10 @@ importers:
|
||||
version: 2.1.9(@types/node@24.12.0)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1)
|
||||
|
||||
packages/macp:
|
||||
dependencies:
|
||||
commander:
|
||||
specifier: ^13.0.0
|
||||
version: 13.1.0
|
||||
devDependencies:
|
||||
'@types/node':
|
||||
specifier: ^22.0.0
|
||||
|
||||
Reference in New Issue
Block a user