Files
mcpctl/src/cli/src/formatters/output.ts
Michal 705df06996
Some checks failed
CI / lint (pull_request) Has been cancelled
CI / typecheck (pull_request) Has been cancelled
CI / test (pull_request) Has been cancelled
CI / build (pull_request) Has been cancelled
CI / package (pull_request) Has been cancelled
feat: gated project experience & prompt intelligence
Implements the full gated session flow and prompt intelligence system:

- Prisma schema: add gated, priority, summary, chapters, linkTarget fields
- Session gate: state machine (gated → begin_session → ungated) with LLM-powered
  tool selection based on prompt index
- Tag matcher: intelligent prompt-to-tool matching with project/server/action tags
- LLM selector: tiered provider selection (fast for gating, heavy for complex tasks)
- Link resolver: cross-project MCP resource references (project/server:uri format)
- Prompt summary service: LLM-generated summaries and chapter extraction
- System project bootstrap: ensures default project exists on startup
- Structural link health checks: enrichWithLinkStatus on prompt GET endpoints
- CLI: create prompt --priority/--link, create project --gated/--no-gated,
  describe project shows prompts section, get prompts shows PRI/LINK/STATUS
- Apply/edit: priority, linkTarget, gated fields supported
- Shell completions: fish updated with new flags
- 1,253 tests passing across all packages

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 23:22:42 +00:00

35 lines
1.0 KiB
TypeScript

import yaml from 'js-yaml';
export type OutputFormat = 'table' | 'json' | 'yaml';
export function formatJson(data: unknown): string {
return JSON.stringify(data, null, 2);
}
/**
* Reorder object keys so that long text fields (like `content`, `prompt`)
* come last. This makes YAML output more readable when content spans
* multiple lines.
*/
export function reorderKeys(obj: unknown): unknown {
if (Array.isArray(obj)) return obj.map(reorderKeys);
if (obj !== null && typeof obj === 'object') {
const rec = obj as Record<string, unknown>;
const lastKeys = ['content', 'prompt'];
const ordered: Record<string, unknown> = {};
for (const key of Object.keys(rec)) {
if (!lastKeys.includes(key)) ordered[key] = reorderKeys(rec[key]);
}
for (const key of lastKeys) {
if (key in rec) ordered[key] = rec[key];
}
return ordered;
}
return obj;
}
export function formatYaml(data: unknown): string {
const reordered = reorderKeys(data);
return yaml.dump(reordered, { lineWidth: 120, noRefs: true }).trimEnd();
}