MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / parseExampleFile

Function parseExampleFile

dev/local/env-sync/parse.ts:129–177  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

127 }
128 default:
129 return undefined;
130 }
131}
132
133function parseExampleFile(content: string): ExampleEntry[] {
134 const entries: ExampleEntry[] = [];
135 let pendingAnnotation: Annotation | undefined;
136
137 for (const rawLine of content.split('\n')) {
138 const line = rawLine.trim();
139
140 // Blank lines clear pending annotations
141 if (line === '') {
142 pendingAnnotation = undefined;
143 continue;
144 }
145
146 // Comment lines
147 if (line.startsWith('#')) {
148 // Commented-out keys like #KILOCODE_TOKEN_OVERRIDE=... are just comments
149 const directiveMatch = line.match(/^#\s*@(\w+)\s*(.*)$/);
150 if (directiveMatch) {
151 const [, directive, args] = directiveMatch;
152 if (KNOWN_DIRECTIVES.has(directive)) {
153 pendingAnnotation = parseAnnotation(directive, args);
154 }
155 // Unknown @directives are treated as regular comments (no effect)
156 }
157 // Regular comments without @directive don't affect pending annotations
158 continue;
159 }
160
161 // KEY=VALUE line
162 const eqIdx = line.indexOf('=');
163 if (eqIdx === -1) {
164 pendingAnnotation = undefined;
165 continue;
166 }
167
168 const key = line.slice(0, eqIdx).trim();
169 const defaultValue = stripEnvQuotes(line.slice(eqIdx + 1).trim());
170
171 entries.push({
172 key,
173 defaultValue,
174 annotation: pendingAnnotation ?? { type: 'passthrough' },
175 });
176
177 pendingAnnotation = undefined;
178 }
179
180 return entries;

Callers 2

computePlanFunction · 0.90

Calls 4

parseAnnotationFunction · 0.85
hasMethod · 0.80
pushMethod · 0.80
stripEnvQuotesFunction · 0.70

Tested by

no test coverage detected