120 lines
4.5 KiB
JavaScript
120 lines
4.5 KiB
JavaScript
#!/usr/bin/env node
|
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
|
|
import {
|
|
parseNasCodexBootstrapCliArgs,
|
|
parseDeployObservationCliArgs,
|
|
parseGlobalReviewCliArgs,
|
|
parseNapcatRemoteDevHandoffCliArgs,
|
|
parseNapcatRuntimeReleaseReadinessCliArgs,
|
|
parseNapcatSyncCandidateReviewCliArgs,
|
|
parseNapcatUpstreamAuditCliArgs,
|
|
parseObsidianContextCliArgs,
|
|
parseObsidianCliArgs,
|
|
parseObsidianSyncCliArgs,
|
|
parseWorkstreamCloseoutCliArgs,
|
|
} from './core/cli.js';
|
|
import { cleanupHistoryArtifacts, parseCliCleanupArgs } from './tools/cleanup.js';
|
|
import { buildWorkstreamCloseout } from './tools/closeout.js';
|
|
import { buildDeployObservation } from './tools/deployObservation.js';
|
|
import { readObsidianContext, syncObsidianWorkflow, validateObsidianVault } from './tools/obsidian.js';
|
|
import { buildGlobalCodeReview } from './tools/review.js';
|
|
import { registerTools } from './registerTools.js';
|
|
import { runSelfTest } from './selfTest.js';
|
|
import { buildNapcatDeviceProfileCheck } from './tools/testing.js';
|
|
import {
|
|
buildNapcatRemoteDevHandoff,
|
|
buildNapcatRuntimeReleaseReadiness,
|
|
buildNapcatSyncCandidateReview,
|
|
buildNapcatUpstreamAudit,
|
|
buildNasCodexBootstrapPlan,
|
|
shouldFailNapcatAutomationCli,
|
|
} from './tools/napcatAutomation.js';
|
|
|
|
/**
|
|
* Prints a NapCat automation result and turns blocked classifications into a failing CLI exit code.
|
|
* @param result - Structured NapCat automation result that must remain visible on stdout for Jenkins artifacts and manual diagnostics.
|
|
* @returns Nothing; writes JSON evidence and mutates `process.exitCode` when the result blocks safe continuation.
|
|
*/
|
|
function printNapcatAutomationCliResult(result: {
|
|
classification?: unknown;
|
|
recommendedAction?: unknown;
|
|
}): void {
|
|
console.log(JSON.stringify(result, null, 2));
|
|
if (shouldFailNapcatAutomationCli(result)) {
|
|
process.exitCode = 1;
|
|
}
|
|
}
|
|
|
|
if (process.argv.includes('--cleanup-history')) {
|
|
console.log(JSON.stringify(cleanupHistoryArtifacts(parseCliCleanupArgs(process.argv)), null, 2));
|
|
} else if (process.argv.includes('--global-review')) {
|
|
console.log(
|
|
JSON.stringify(
|
|
await buildGlobalCodeReview(parseGlobalReviewCliArgs(process.argv)),
|
|
null,
|
|
2,
|
|
),
|
|
);
|
|
} else if (process.argv.includes('--obsidian-validate')) {
|
|
console.log(JSON.stringify(validateObsidianVault(parseObsidianCliArgs(process.argv)), null, 2));
|
|
} else if (process.argv.includes('--obsidian-context')) {
|
|
console.log(JSON.stringify(readObsidianContext(parseObsidianContextCliArgs(process.argv)), null, 2));
|
|
} else if (process.argv.includes('--obsidian-sync')) {
|
|
console.log(JSON.stringify(syncObsidianWorkflow(parseObsidianSyncCliArgs(process.argv)), null, 2));
|
|
} else if (process.argv.includes('--deploy-observation')) {
|
|
console.log(
|
|
JSON.stringify(
|
|
await buildDeployObservation(parseDeployObservationCliArgs(process.argv)),
|
|
null,
|
|
2,
|
|
),
|
|
);
|
|
} else if (process.argv.includes('--napcat-upstream-audit')) {
|
|
printNapcatAutomationCliResult(
|
|
buildNapcatUpstreamAudit(parseNapcatUpstreamAuditCliArgs(process.argv)),
|
|
);
|
|
} else if (process.argv.includes('--napcat-sync-candidate-review')) {
|
|
console.log(
|
|
JSON.stringify(
|
|
buildNapcatSyncCandidateReview(parseNapcatSyncCandidateReviewCliArgs(process.argv)),
|
|
null,
|
|
2,
|
|
),
|
|
);
|
|
} else if (process.argv.includes('--napcat-runtime-release-readiness')) {
|
|
console.log(
|
|
JSON.stringify(
|
|
buildNapcatRuntimeReleaseReadiness(parseNapcatRuntimeReleaseReadinessCliArgs(process.argv)),
|
|
null,
|
|
2,
|
|
),
|
|
);
|
|
} else if (process.argv.includes('--napcat-remote-dev-handoff')) {
|
|
console.log(
|
|
JSON.stringify(
|
|
buildNapcatRemoteDevHandoff(parseNapcatRemoteDevHandoffCliArgs(process.argv)),
|
|
null,
|
|
2,
|
|
),
|
|
);
|
|
} else if (process.argv.includes('--nas-codex-bootstrap')) {
|
|
console.log(
|
|
JSON.stringify(buildNasCodexBootstrapPlan(parseNasCodexBootstrapCliArgs(process.argv)), null, 2),
|
|
);
|
|
} else if (process.argv.includes('--self-test')) {
|
|
await runSelfTest();
|
|
} else if (process.argv.includes('--workstream-closeout')) {
|
|
console.log(JSON.stringify(buildWorkstreamCloseout(parseWorkstreamCloseoutCliArgs(process.argv)), null, 2));
|
|
} else if (process.argv.includes('--napcat-device-profile-check')) {
|
|
console.log(JSON.stringify(buildNapcatDeviceProfileCheck({ project: 'api' }), null, 2));
|
|
} else {
|
|
const server = new McpServer({
|
|
name: 'kt-workflow',
|
|
version: '0.6.2',
|
|
});
|
|
registerTools(server);
|
|
await server.connect(new StdioServerTransport());
|
|
}
|