mrvn-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,284 @@
1
+ import { SdkMcpToolDefinition, McpSdkServerConfigWithInstance } from '@anthropic-ai/claude-agent-sdk';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { Command } from 'commander';
4
+
5
+ interface MarvinUserConfig {
6
+ apiKey?: string;
7
+ defaultModel?: string;
8
+ defaultPersona?: string;
9
+ }
10
+ interface GitConfig {
11
+ remote?: string;
12
+ }
13
+ interface MarvinProjectConfig {
14
+ name: string;
15
+ methodology?: string;
16
+ personas?: Record<string, PersonaConfigOverride>;
17
+ documentTypes?: string[];
18
+ git?: GitConfig;
19
+ skills?: Record<string, string[]>;
20
+ }
21
+ interface PersonaConfigOverride {
22
+ enabled?: boolean;
23
+ extraInstructions?: string;
24
+ }
25
+ interface MergedConfig {
26
+ apiKey?: string;
27
+ defaultModel: string;
28
+ defaultPersona: string;
29
+ project: MarvinProjectConfig;
30
+ }
31
+ declare function loadUserConfig(): MarvinUserConfig;
32
+ declare function saveUserConfig(config: MarvinUserConfig): void;
33
+ declare function getConfig(marvinDir: string): MergedConfig;
34
+
35
+ interface MarvinProject {
36
+ root: string;
37
+ marvinDir: string;
38
+ config: MarvinProjectConfig;
39
+ }
40
+ declare function findProjectRoot(from?: string): string;
41
+ declare function isMarvinProject(dir?: string): boolean;
42
+ declare function loadProject(from?: string): MarvinProject;
43
+
44
+ declare class MarvinError extends Error {
45
+ constructor(message: string);
46
+ }
47
+ declare class ProjectNotFoundError extends MarvinError {
48
+ constructor(searchedFrom: string);
49
+ }
50
+ declare class ConfigError extends MarvinError {
51
+ constructor(message: string);
52
+ }
53
+ declare class ApiKeyMissingError extends MarvinError {
54
+ constructor();
55
+ }
56
+
57
+ type DocumentType = string;
58
+ declare const CORE_DOCUMENT_TYPES: readonly ["decision", "action", "question"];
59
+ interface DocumentTypeRegistration {
60
+ type: string;
61
+ dirName: string;
62
+ idPrefix: string;
63
+ }
64
+ interface DocumentFrontmatter {
65
+ id: string;
66
+ title: string;
67
+ type: DocumentType;
68
+ status: string;
69
+ created: string;
70
+ updated: string;
71
+ owner?: string;
72
+ priority?: string;
73
+ tags?: string[];
74
+ source?: string;
75
+ [key: string]: unknown;
76
+ }
77
+ interface Document {
78
+ frontmatter: DocumentFrontmatter;
79
+ content: string;
80
+ filePath: string;
81
+ }
82
+ interface DocumentQuery {
83
+ type?: DocumentType;
84
+ status?: string;
85
+ owner?: string;
86
+ tag?: string;
87
+ }
88
+
89
+ declare class DocumentStore {
90
+ private docsDir;
91
+ private index;
92
+ private typeDirs;
93
+ private idPrefixes;
94
+ constructor(marvinDir: string, registrations?: DocumentTypeRegistration[]);
95
+ get registeredTypes(): string[];
96
+ private buildIndex;
97
+ list(query?: DocumentQuery): Document[];
98
+ get(id: string): Document | undefined;
99
+ create(type: DocumentType, frontmatter: Partial<DocumentFrontmatter>, content?: string): Document;
100
+ importDocument(type: DocumentType, frontmatter: DocumentFrontmatter, content?: string): Document;
101
+ update(id: string, updates: Partial<DocumentFrontmatter>, content?: string): Document;
102
+ nextId(type: DocumentType): string;
103
+ counts(): Record<string, number>;
104
+ }
105
+
106
+ declare function parseDocument(raw: string, filePath: string): Document;
107
+ declare function serializeDocument(doc: Document): string;
108
+
109
+ interface PersonaDefinition {
110
+ id: string;
111
+ name: string;
112
+ shortName: string;
113
+ description: string;
114
+ systemPrompt: string;
115
+ focusAreas: string[];
116
+ documentTypes: string[];
117
+ }
118
+
119
+ declare function getPersona(idOrShortName: string): PersonaDefinition | undefined;
120
+ declare function listPersonas(): PersonaDefinition[];
121
+ declare function resolvePersonaId(input: string): string;
122
+
123
+ declare function buildSystemPrompt(persona: PersonaDefinition, projectConfig: MarvinProjectConfig, pluginPromptFragment?: string, skillPromptFragment?: string): string;
124
+
125
+ interface SessionEntry {
126
+ id: string;
127
+ name: string;
128
+ persona: string;
129
+ created: string;
130
+ lastUsed: string;
131
+ turnCount: number;
132
+ }
133
+ declare class SessionStore {
134
+ private filePath;
135
+ constructor(marvinDir: string);
136
+ list(): SessionEntry[];
137
+ get(name: string): SessionEntry | undefined;
138
+ getById(sessionId: string): SessionEntry | undefined;
139
+ save(entry: SessionEntry): void;
140
+ delete(name: string): boolean;
141
+ updateLastUsed(name: string, turnCount: number): void;
142
+ private load;
143
+ private write;
144
+ }
145
+
146
+ type SourceFileStatus = "pending" | "processing" | "completed" | "error";
147
+ interface SourceFileEntry {
148
+ hash: string;
149
+ addedAt: string;
150
+ processedAt: string | null;
151
+ status: SourceFileStatus;
152
+ artifacts: string[];
153
+ error: string | null;
154
+ }
155
+ interface SourceManifest {
156
+ version: 1;
157
+ files: Record<string, SourceFileEntry>;
158
+ }
159
+ interface IngestOptions {
160
+ marvinDir: string;
161
+ fileName: string;
162
+ draft: boolean;
163
+ persona: string;
164
+ }
165
+ interface IngestResult {
166
+ fileName: string;
167
+ artifacts: string[];
168
+ draft: boolean;
169
+ }
170
+
171
+ declare class SourceManifestManager {
172
+ private manifest;
173
+ private manifestPath;
174
+ readonly sourcesDir: string;
175
+ constructor(marvinDir: string);
176
+ private load;
177
+ save(): void;
178
+ scan(): {
179
+ added: string[];
180
+ changed: string[];
181
+ removed: string[];
182
+ };
183
+ list(status?: SourceFileStatus): Array<{
184
+ name: string;
185
+ entry: SourceFileEntry;
186
+ }>;
187
+ get(fileName: string): SourceFileEntry | undefined;
188
+ unprocessed(): string[];
189
+ markProcessing(fileName: string): void;
190
+ markCompleted(fileName: string, artifacts: string[]): void;
191
+ markError(fileName: string, error: string): void;
192
+ private hashFile;
193
+ }
194
+
195
+ interface McpServerOptions {
196
+ manifest?: SourceManifestManager;
197
+ sourcesDir?: string;
198
+ sessionStore?: SessionStore;
199
+ pluginTools?: SdkMcpToolDefinition<any>[];
200
+ skillTools?: SdkMcpToolDefinition<any>[];
201
+ }
202
+ declare function createMarvinMcpServer(store: DocumentStore, options?: McpServerOptions): McpSdkServerConfigWithInstance;
203
+
204
+ interface SessionOptions {
205
+ persona: PersonaDefinition;
206
+ config: MergedConfig;
207
+ marvinDir: string;
208
+ projectRoot: string;
209
+ initialPrompt?: string;
210
+ sessionName?: string;
211
+ }
212
+ declare function startSession(options: SessionOptions): Promise<void>;
213
+
214
+ interface MarvinPlugin {
215
+ id: string;
216
+ name: string;
217
+ description: string;
218
+ version: string;
219
+ /** Additional personas provided by this plugin */
220
+ personas?: PersonaDefinition[];
221
+ /** Additional MCP tools provided by this plugin */
222
+ tools?: (store: DocumentStore, marvinDir?: string) => SdkMcpToolDefinition[];
223
+ /** Additional document types this plugin handles */
224
+ documentTypes?: string[];
225
+ /** Document type registrations for extending the storage layer */
226
+ documentTypeRegistrations?: DocumentTypeRegistration[];
227
+ /** Prompt fragments injected per persona. Key is persona ID; "*" applies to all. */
228
+ promptFragments?: Record<string, string>;
229
+ /** Lifecycle hook: called when plugin is loaded */
230
+ onLoad?: () => Promise<void>;
231
+ }
232
+
233
+ declare function resolvePlugin(methodologyId?: string): MarvinPlugin | undefined;
234
+ declare function getPluginTools(plugin: MarvinPlugin, store: DocumentStore, marvinDir?: string): SdkMcpToolDefinition<any>[];
235
+ declare function getPluginPromptFragment(plugin: MarvinPlugin, personaId: string): string | undefined;
236
+
237
+ declare const COMMON_REGISTRATIONS: DocumentTypeRegistration[];
238
+ declare function createCommonTools(store: DocumentStore): SdkMcpToolDefinition<any>[];
239
+
240
+ interface SkillDefinition {
241
+ id: string;
242
+ name: string;
243
+ description: string;
244
+ version: string;
245
+ personas?: string[];
246
+ tools?: (store: DocumentStore) => SdkMcpToolDefinition<any>[];
247
+ promptFragments?: Record<string, string>;
248
+ actions?: SkillAction[];
249
+ }
250
+ interface SkillAction {
251
+ id: string;
252
+ name: string;
253
+ description: string;
254
+ systemPrompt: string;
255
+ maxTurns?: number;
256
+ allowGovernanceTools?: boolean;
257
+ }
258
+
259
+ declare function loadAllSkills(marvinDir?: string): Map<string, SkillDefinition>;
260
+ declare function resolveSkillsForPersona(personaId: string, skillsConfig: Record<string, string[]> | undefined, allSkills: Map<string, SkillDefinition>): string[];
261
+ declare function getSkillTools(skillIds: string[], allSkills: Map<string, SkillDefinition>, store: DocumentStore): SdkMcpToolDefinition<any>[];
262
+ declare function getSkillPromptFragment(skillIds: string[], allSkills: Map<string, SkillDefinition>, personaId: string): string | undefined;
263
+
264
+ interface StdioServerOptions {
265
+ marvinDir: string;
266
+ }
267
+ /**
268
+ * Collect all governance tool definitions from the existing tool creators.
269
+ * Reuses the same tool factories as the agent MCP server.
270
+ */
271
+ declare function collectTools(marvinDir: string): SdkMcpToolDefinition<any>[];
272
+ /**
273
+ * Register SdkMcpToolDefinition objects onto an McpServer instance.
274
+ * The adapter is nearly 1:1 since both use Zod raw shapes and CallToolResult.
275
+ */
276
+ declare function registerSdkTools(server: McpServer, tools: SdkMcpToolDefinition<any>[]): void;
277
+ /**
278
+ * Create an McpServer with all governance tools and connect it via stdio transport.
279
+ */
280
+ declare function startStdioServer(options: StdioServerOptions): Promise<void>;
281
+
282
+ declare function createProgram(): Command;
283
+
284
+ export { ApiKeyMissingError, COMMON_REGISTRATIONS, CORE_DOCUMENT_TYPES, ConfigError, type Document, type DocumentFrontmatter, type DocumentQuery, DocumentStore, type DocumentType, type DocumentTypeRegistration, type IngestOptions, type IngestResult, MarvinError, type MarvinPlugin, type MarvinProjectConfig, type MarvinUserConfig, type MergedConfig, type PersonaDefinition, ProjectNotFoundError, type SessionEntry, type SessionOptions, SessionStore, type SkillAction, type SkillDefinition, type SourceFileEntry, type SourceFileStatus, type SourceManifest, SourceManifestManager, type StdioServerOptions, buildSystemPrompt, collectTools, createCommonTools, createMarvinMcpServer, createProgram, findProjectRoot, getConfig, getPersona, getPluginPromptFragment, getPluginTools, getSkillPromptFragment, getSkillTools, isMarvinProject, listPersonas, loadAllSkills, loadProject, loadUserConfig, parseDocument, registerSdkTools, resolvePersonaId, resolvePlugin, resolveSkillsForPersona, saveUserConfig, serializeDocument, startSession, startStdioServer };