@sidecar-ai/compiler 0.1.0-alpha.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,175 @@
1
+ import { SourceFile } from 'ts-morph';
2
+ import { JsonSchema, ToolAnnotations, ToolVisibility, ToolWidgetOptions, McpToolDescriptor, ResourceAnnotations, McpResourceDescriptor, McpResourceTemplateDescriptor, PromptArgsDefinition, McpPromptDescriptor } from '@sidecar-ai/core';
3
+
4
+ /** Diagnostic severity surfaced by the CLI and future editor integrations. */
5
+ type DiagnosticSeverity = "warning" | "error";
6
+ /** Stable diagnostic emitted for a concrete project source location. */
7
+ type SidecarDiagnostic = {
8
+ severity: DiagnosticSeverity;
9
+ code: string;
10
+ message: string;
11
+ filePath: string;
12
+ line: number;
13
+ column: number;
14
+ hint?: string;
15
+ };
16
+ /** Collects project-level warnings that do not block compilation by default. */
17
+ declare function collectProjectDiagnostics(rootDir: string, input: SidecarToolManifestEntry[] | {
18
+ tools: SidecarToolManifestEntry[];
19
+ resources?: SidecarResourceManifestEntry[];
20
+ prompts?: SidecarPromptManifestEntry[];
21
+ config?: SidecarCompilerConfig;
22
+ }): Promise<SidecarDiagnostic[]>;
23
+ /** Formats diagnostics in a TypeScript-style shape understood by many editors. */
24
+ declare function formatDiagnostic(diagnostic: SidecarDiagnostic): string;
25
+
26
+ /** Manifest and option types shared across the Sidecar compiler modules. */
27
+
28
+ /** Build target profile selected by reserved platform file suffixes. */
29
+ type SidecarTarget = "mcp" | "chatgpt" | "claude";
30
+ /** Platform suffix chosen for a reserved tool or widget file. */
31
+ type SidecarSourceVariant = "shared" | "openai" | "anthropic";
32
+ /** Tool entry emitted into `manifest.sidecar.json`. */
33
+ type SidecarToolManifestEntry = {
34
+ sourceFile: string;
35
+ variant: SidecarSourceVariant;
36
+ target: SidecarTarget;
37
+ directory: string;
38
+ id: string;
39
+ name: string;
40
+ description: string;
41
+ inputSchema: JsonSchema;
42
+ outputSchema?: JsonSchema;
43
+ annotations?: ToolAnnotations;
44
+ visibility?: ToolVisibility;
45
+ widget?: SidecarWidgetManifestEntry;
46
+ descriptor: McpToolDescriptor;
47
+ };
48
+ /** Widget resource linked to a tool entry. */
49
+ type SidecarWidgetManifestEntry = {
50
+ sourceFile: string;
51
+ variant: SidecarSourceVariant;
52
+ resourceUri: string;
53
+ resourceMeta?: Record<string, unknown>;
54
+ outputFile?: string;
55
+ options?: ToolWidgetOptions;
56
+ };
57
+ /** Static resource entry emitted into `manifest.sidecar.json`. */
58
+ type SidecarResourceManifestEntry = {
59
+ sourceFile: string;
60
+ directory: string;
61
+ uri: string;
62
+ name: string;
63
+ title?: string;
64
+ description?: string;
65
+ mimeType?: string;
66
+ size?: number;
67
+ annotations?: ResourceAnnotations;
68
+ subscribe?: boolean;
69
+ descriptor: McpResourceDescriptor;
70
+ };
71
+ /** Static resource template entry emitted into `manifest.sidecar.json`. */
72
+ type SidecarResourceTemplateManifestEntry = {
73
+ uriTemplate: string;
74
+ name: string;
75
+ title?: string;
76
+ description?: string;
77
+ mimeType?: string;
78
+ annotations?: ResourceAnnotations;
79
+ descriptor: McpResourceTemplateDescriptor;
80
+ };
81
+ /** Static prompt entry emitted into `manifest.sidecar.json`. */
82
+ type SidecarPromptManifestEntry = {
83
+ sourceFile: string;
84
+ directory: string;
85
+ name: string;
86
+ title: string;
87
+ description?: string;
88
+ args?: PromptArgsDefinition;
89
+ descriptor: McpPromptDescriptor;
90
+ };
91
+ /** Serializable project config subset recorded in build manifests. */
92
+ type SidecarCompilerConfig = {
93
+ resources: {
94
+ subscribe: boolean;
95
+ listChanged: boolean;
96
+ };
97
+ prompts: {
98
+ listChanged: boolean;
99
+ };
100
+ tools: {
101
+ listChanged: boolean;
102
+ };
103
+ pagination: {
104
+ pageSize: number;
105
+ hasOverride: boolean;
106
+ };
107
+ };
108
+ /** Build manifest produced for a Sidecar MCP output. */
109
+ type SidecarManifest = {
110
+ version: 1;
111
+ target: SidecarTarget;
112
+ rootDir: string;
113
+ generatedAt: string;
114
+ config: SidecarCompilerConfig;
115
+ tools: SidecarToolManifestEntry[];
116
+ resources: SidecarResourceManifestEntry[];
117
+ resourceTemplates: SidecarResourceTemplateManifestEntry[];
118
+ prompts: SidecarPromptManifestEntry[];
119
+ diagnostics?: SidecarDiagnostic[];
120
+ };
121
+ /** Options accepted by `buildProject()`. */
122
+ type BuildProjectOptions = {
123
+ rootDir: string;
124
+ outDir?: string;
125
+ plugins?: boolean;
126
+ strict?: boolean;
127
+ target?: SidecarTarget;
128
+ };
129
+ /** Project identity used by generated plugin packages. */
130
+ type ProjectIdentity = {
131
+ name: string;
132
+ slug: string;
133
+ version: string;
134
+ description: string;
135
+ };
136
+
137
+ type AuthScopeCatalog = Record<string, {
138
+ id: string;
139
+ description: string;
140
+ }>;
141
+ /** Finds all Sidecar tool files under `server/` and returns manifest entries. */
142
+ declare function analyzeProjectTools(rootDir: string, options?: {
143
+ target?: SidecarTarget;
144
+ }): Promise<SidecarToolManifestEntry[]>;
145
+ /** Analyzes one `tool.ts` source file into a compiler manifest entry. */
146
+ declare function analyzeToolFile(sourceFile: SourceFile, rootDir: string, options?: {
147
+ target?: SidecarTarget;
148
+ variant?: SidecarSourceVariant;
149
+ authScopes?: AuthScopeCatalog;
150
+ }): SidecarToolManifestEntry;
151
+
152
+ /** Builds the MCP output, generated types, and optional plugin packages. */
153
+ declare function buildProject(options: BuildProjectOptions): Promise<SidecarManifest>;
154
+
155
+ /** Reads the serializable subset of `sidecar.config.ts` without executing app code. */
156
+ declare function analyzeProjectConfig(rootDir: string): SidecarCompilerConfig;
157
+
158
+ /** Compiler-specific errors include the source file path in their message. */
159
+
160
+ /** Error thrown when a reserved file violates Sidecar's authoring contract. */
161
+ declare class CompilerError extends Error {
162
+ constructor(sourceFile: SourceFile, message: string);
163
+ }
164
+
165
+ /** Finds all Sidecar prompt files under `prompts/`. */
166
+ declare function analyzeProjectPrompts(rootDir: string): Promise<SidecarPromptManifestEntry[]>;
167
+ /** Analyzes one `prompt.ts` source file into a compiler manifest entry. */
168
+ declare function analyzePromptFile(sourceFile: SourceFile, rootDir: string): SidecarPromptManifestEntry;
169
+
170
+ /** Finds all Sidecar resource files under `resources/`. */
171
+ declare function analyzeProjectResources(rootDir: string): Promise<SidecarResourceManifestEntry[]>;
172
+ /** Analyzes one `resource.ts` source file into a compiler manifest entry. */
173
+ declare function analyzeResourceFile(sourceFile: SourceFile, rootDir: string): SidecarResourceManifestEntry;
174
+
175
+ export { type BuildProjectOptions, CompilerError, type ProjectIdentity, type SidecarCompilerConfig, type SidecarDiagnostic, type SidecarManifest, type SidecarPromptManifestEntry, type SidecarResourceManifestEntry, type SidecarResourceTemplateManifestEntry, type SidecarSourceVariant, type SidecarTarget, type SidecarToolManifestEntry, type SidecarWidgetManifestEntry, analyzeProjectConfig, analyzeProjectPrompts, analyzeProjectResources, analyzeProjectTools, analyzePromptFile, analyzeResourceFile, analyzeToolFile, buildProject, collectProjectDiagnostics, formatDiagnostic };