geloforge 0.0.0-stage → 0.7.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.
- package/LICENSE +21 -0
- package/README.md +72 -2
- package/THIRD_PARTY_NOTICES.md +33 -0
- package/VERSION +1 -0
- package/adapters/n8n/staging-audit-error-workflow.json +132 -0
- package/core/adopt-project.mjs +458 -0
- package/core/audit-learning.mjs +68 -0
- package/core/audit-provider.mjs +88 -0
- package/core/autonomous-audit.mjs +214 -0
- package/core/checkpoint.mjs +448 -0
- package/core/codebase-map.mjs +886 -0
- package/core/compatibility.json +16 -0
- package/core/compatibility.mjs +123 -0
- package/core/context-cache.mjs +113 -0
- package/core/context-compiler.mjs +1315 -0
- package/core/evidence-capture.mjs +347 -0
- package/core/git-utils.mjs +167 -0
- package/core/handoff.mjs +815 -0
- package/core/json-schema-lite.mjs +119 -0
- package/core/mcp-init.mjs +251 -0
- package/core/mcp-server.mjs +915 -0
- package/core/operation-approval.mjs +102 -0
- package/core/path-safety.mjs +508 -0
- package/core/project-locator.mjs +231 -0
- package/core/project-lock.mjs +438 -0
- package/core/project-status.mjs +635 -0
- package/core/project-validator.mjs +544 -0
- package/core/promotion.mjs +90 -0
- package/core/runtime-files.mjs +40 -0
- package/core/skills-history.mjs +572 -0
- package/core/skills-lifecycle.mjs +2225 -0
- package/core/skills-lint.mjs +365 -0
- package/core/skills.mjs +1449 -0
- package/core/staging-audit.mjs +454 -0
- package/core/staging-evidence.mjs +127 -0
- package/core/task-manager.mjs +1044 -0
- package/core/template-utils.mjs +190 -0
- package/core/text-utils.mjs +48 -0
- package/core/verify-task.mjs +48 -0
- package/core/worktrees.mjs +64 -0
- package/core/yaml-subset.mjs +572 -0
- package/package.json +50 -4
- package/policies/approval-boundaries.md +42 -0
- package/policies/memory-policy.md +53 -0
- package/policies/token-efficiency.md +30 -0
- package/schemas/README.md +43 -0
- package/schemas/adr.schema.json +64 -0
- package/schemas/agent-handoff.schema.json +139 -0
- package/schemas/approval-record.schema.json +110 -0
- package/schemas/conflict-record.schema.json +60 -0
- package/schemas/context-pack-manifest.schema.json +194 -0
- package/schemas/evidence-manifest.schema.json +83 -0
- package/schemas/incident-record.schema.json +53 -0
- package/schemas/project-manifest.schema.json +90 -0
- package/schemas/project-state.schema.json +64 -0
- package/schemas/recovery-checkpoint.schema.json +49 -0
- package/schemas/research-record.schema.json +76 -0
- package/schemas/task-contract.schema.json +95 -0
- package/scripts/bootstrap-project.mjs +357 -0
- package/scripts/geloforge.mjs +2512 -0
- package/templates/profiles/README.md +19 -0
- package/templates/profiles/ai-system/brain/profile.md +21 -0
- package/templates/profiles/ai-system/gitignore.append +5 -0
- package/templates/profiles/ai-system/profile.json +6 -0
- package/templates/profiles/automation/brain/profile.md +19 -0
- package/templates/profiles/automation/gitignore.append +5 -0
- package/templates/profiles/automation/profile.json +6 -0
- package/templates/profiles/desktop/brain/profile.md +21 -0
- package/templates/profiles/desktop/gitignore.append +7 -0
- package/templates/profiles/desktop/profile.json +6 -0
- package/templates/profiles/mobile/brain/profile.md +20 -0
- package/templates/profiles/mobile/gitignore.append +8 -0
- package/templates/profiles/mobile/profile.json +6 -0
- package/templates/profiles/web/brain/profile.md +21 -0
- package/templates/profiles/web/gitignore.append +6 -0
- package/templates/profiles/web/profile.json +6 -0
- package/templates/project-starter/AGENTS.md +27 -0
- package/templates/project-starter/GEMINI.md +16 -0
- package/templates/project-starter/README.md +26 -0
- package/templates/project-starter/brain/INDEX.md +40 -0
- package/templates/project-starter/brain/architecture/overview.md +30 -0
- package/templates/project-starter/brain/decisions/.gitkeep +0 -0
- package/templates/project-starter/brain/manifest.yaml +36 -0
- package/templates/project-starter/brain/requirements/constraints.md +29 -0
- package/templates/project-starter/brain/requirements/prd.md +37 -0
- package/templates/project-starter/brain/state/current.yaml +19 -0
- package/templates/project-starter/gitignore.template +25 -0
- package/templates/project-starter/src/.gitkeep +0 -0
- package/templates/project-starter/tasks/.gitkeep +0 -0
- package/templates/project-starter/tests/.gitkeep +0 -0
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strict zero-dependency YAML 1.2 subset parser and Markdown frontmatter extractor.
|
|
3
|
+
* Supports block mappings, nested mappings, block sequences (scalars and nested maps),
|
|
4
|
+
* quoted and plain scalars, numbers, booleans, null, empty []/{}, simple inline scalar
|
|
5
|
+
* arrays, and literal/folded block scalars (| and >).
|
|
6
|
+
* Rejects tab indentation, duplicate mapping keys, unclosed quotes, and unquoted {{...}}.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
function stripComment(line, lineNumber, sourceLabel) {
|
|
10
|
+
let inSingle = false;
|
|
11
|
+
let inDouble = false;
|
|
12
|
+
for (let i = 0; i < line.length; i += 1) {
|
|
13
|
+
const ch = line[i];
|
|
14
|
+
if (inSingle) {
|
|
15
|
+
if (ch === "'") {
|
|
16
|
+
if (line[i + 1] === "'") {
|
|
17
|
+
i += 1;
|
|
18
|
+
} else {
|
|
19
|
+
inSingle = false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (inDouble) {
|
|
25
|
+
if (ch === "\\") {
|
|
26
|
+
i += 1;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (ch === '"') {
|
|
30
|
+
inDouble = false;
|
|
31
|
+
}
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (ch === "'") {
|
|
35
|
+
inSingle = true;
|
|
36
|
+
} else if (ch === '"') {
|
|
37
|
+
inDouble = true;
|
|
38
|
+
} else if (ch === "#" && (i === 0 || line[i - 1] === " ")) {
|
|
39
|
+
return line.slice(0, i);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (inSingle || inDouble) {
|
|
43
|
+
throw new Error(`${sourceLabel}:${lineNumber}: Unclosed string quote`);
|
|
44
|
+
}
|
|
45
|
+
return line;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function trySplitKeyValue(trimmed, lineNumber, sourceLabel) {
|
|
49
|
+
let inSingle = false;
|
|
50
|
+
let inDouble = false;
|
|
51
|
+
for (let i = 0; i < trimmed.length; i += 1) {
|
|
52
|
+
const ch = trimmed[i];
|
|
53
|
+
if (inSingle) {
|
|
54
|
+
if (ch === "'" && trimmed[i + 1] === "'") {
|
|
55
|
+
i += 1;
|
|
56
|
+
} else if (ch === "'") {
|
|
57
|
+
inSingle = false;
|
|
58
|
+
}
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (inDouble) {
|
|
62
|
+
if (ch === "\\") {
|
|
63
|
+
i += 1;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (ch === '"') {
|
|
67
|
+
inDouble = false;
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (ch === "'") {
|
|
72
|
+
inSingle = true;
|
|
73
|
+
} else if (ch === '"') {
|
|
74
|
+
inDouble = true;
|
|
75
|
+
} else if (ch === ":" && (i + 1 === trimmed.length || trimmed[i + 1] === " ")) {
|
|
76
|
+
const rawKey = trimmed.slice(0, i).trim();
|
|
77
|
+
const rawVal = trimmed.slice(i + 1).trim();
|
|
78
|
+
if (!rawKey) {
|
|
79
|
+
throw new Error(`${sourceLabel}:${lineNumber}: Empty mapping key`);
|
|
80
|
+
}
|
|
81
|
+
const key = parseScalar(rawKey, lineNumber, sourceLabel);
|
|
82
|
+
if (typeof key !== "string" || key.length === 0) {
|
|
83
|
+
throw new Error(`${sourceLabel}:${lineNumber}: Mapping key must be a non-empty string`);
|
|
84
|
+
}
|
|
85
|
+
return { key, rawVal };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function splitKeyValue(trimmed, lineNumber, sourceLabel) {
|
|
92
|
+
const pair = trySplitKeyValue(trimmed, lineNumber, sourceLabel);
|
|
93
|
+
if (!pair) {
|
|
94
|
+
throw new Error(`${sourceLabel}:${lineNumber}: Expected mapping "key: value", got "${trimmed}"`);
|
|
95
|
+
}
|
|
96
|
+
return pair;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function unescapeDoubleQuoted(raw, lineNumber, sourceLabel) {
|
|
100
|
+
let out = "";
|
|
101
|
+
for (let i = 0; i < raw.length; i += 1) {
|
|
102
|
+
const ch = raw[i];
|
|
103
|
+
if (ch !== "\\") {
|
|
104
|
+
out += ch;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
i += 1;
|
|
108
|
+
if (i >= raw.length) {
|
|
109
|
+
throw new Error(`${sourceLabel}:${lineNumber}: Trailing backslash in double-quoted string`);
|
|
110
|
+
}
|
|
111
|
+
const esc = raw[i];
|
|
112
|
+
switch (esc) {
|
|
113
|
+
case '"':
|
|
114
|
+
out += '"';
|
|
115
|
+
break;
|
|
116
|
+
case "\\":
|
|
117
|
+
out += "\\";
|
|
118
|
+
break;
|
|
119
|
+
case "/":
|
|
120
|
+
out += "/";
|
|
121
|
+
break;
|
|
122
|
+
case "n":
|
|
123
|
+
out += "\n";
|
|
124
|
+
break;
|
|
125
|
+
case "r":
|
|
126
|
+
out += "\r";
|
|
127
|
+
break;
|
|
128
|
+
case "t":
|
|
129
|
+
out += "\t";
|
|
130
|
+
break;
|
|
131
|
+
case "u": {
|
|
132
|
+
const hex = raw.slice(i + 1, i + 5);
|
|
133
|
+
if (!/^[0-9a-fA-F]{4}$/.test(hex)) {
|
|
134
|
+
throw new Error(`${sourceLabel}:${lineNumber}: Invalid \\uXXXX escape`);
|
|
135
|
+
}
|
|
136
|
+
out += String.fromCharCode(Number.parseInt(hex, 16));
|
|
137
|
+
i += 4;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
default:
|
|
141
|
+
throw new Error(`${sourceLabel}:${lineNumber}: Unsupported escape "\\${esc}"`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return out;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function parseInlineArray(raw, lineNumber, sourceLabel) {
|
|
148
|
+
const inner = raw.slice(1, -1).trim();
|
|
149
|
+
if (inner === "") {
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
const items = [];
|
|
153
|
+
let token = "";
|
|
154
|
+
let inSingle = false;
|
|
155
|
+
let inDouble = false;
|
|
156
|
+
for (let i = 0; i < inner.length; i += 1) {
|
|
157
|
+
const ch = inner[i];
|
|
158
|
+
if (inSingle) {
|
|
159
|
+
token += ch;
|
|
160
|
+
if (ch === "'" && inner[i + 1] === "'") {
|
|
161
|
+
token += inner[i + 1];
|
|
162
|
+
i += 1;
|
|
163
|
+
} else if (ch === "'") {
|
|
164
|
+
inSingle = false;
|
|
165
|
+
}
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (inDouble) {
|
|
169
|
+
token += ch;
|
|
170
|
+
if (ch === "\\" && i + 1 < inner.length) {
|
|
171
|
+
token += inner[i + 1];
|
|
172
|
+
i += 1;
|
|
173
|
+
} else if (ch === '"') {
|
|
174
|
+
inDouble = false;
|
|
175
|
+
}
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (ch === "'") {
|
|
179
|
+
inSingle = true;
|
|
180
|
+
token += ch;
|
|
181
|
+
} else if (ch === '"') {
|
|
182
|
+
inDouble = true;
|
|
183
|
+
token += ch;
|
|
184
|
+
} else if (ch === ",") {
|
|
185
|
+
const trimmed = token.trim();
|
|
186
|
+
if (!trimmed) {
|
|
187
|
+
throw new Error(`${sourceLabel}:${lineNumber}: Empty item in inline array`);
|
|
188
|
+
}
|
|
189
|
+
items.push(parseScalar(trimmed, lineNumber, sourceLabel));
|
|
190
|
+
token = "";
|
|
191
|
+
} else {
|
|
192
|
+
token += ch;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const last = token.trim();
|
|
196
|
+
if (!last) {
|
|
197
|
+
throw new Error(`${sourceLabel}:${lineNumber}: Trailing comma in inline array`);
|
|
198
|
+
}
|
|
199
|
+
items.push(parseScalar(last, lineNumber, sourceLabel));
|
|
200
|
+
return items;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function parseScalar(raw, lineNumber, sourceLabel) {
|
|
204
|
+
const s = raw.trim();
|
|
205
|
+
if (s === "" || s === "null" || s === "~") {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
if (s === "true") {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
if (s === "false") {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
if (s === "{}") {
|
|
215
|
+
return {};
|
|
216
|
+
}
|
|
217
|
+
if (s === "[]") {
|
|
218
|
+
return [];
|
|
219
|
+
}
|
|
220
|
+
if (s.startsWith('"')) {
|
|
221
|
+
if (!s.endsWith('"') || s.length < 2) {
|
|
222
|
+
throw new Error(`${sourceLabel}:${lineNumber}: Malformed double-quoted scalar`);
|
|
223
|
+
}
|
|
224
|
+
return unescapeDoubleQuoted(s.slice(1, -1), lineNumber, sourceLabel);
|
|
225
|
+
}
|
|
226
|
+
if (s.startsWith("'")) {
|
|
227
|
+
if (!s.endsWith("'") || s.length < 2) {
|
|
228
|
+
throw new Error(`${sourceLabel}:${lineNumber}: Malformed single-quoted scalar`);
|
|
229
|
+
}
|
|
230
|
+
return s.slice(1, -1).replace(/''/g, "'");
|
|
231
|
+
}
|
|
232
|
+
if (s.startsWith("[") && s.endsWith("]")) {
|
|
233
|
+
return parseInlineArray(s, lineNumber, sourceLabel);
|
|
234
|
+
}
|
|
235
|
+
if (s.startsWith("{") || s.startsWith("[")) {
|
|
236
|
+
throw new Error(
|
|
237
|
+
`${sourceLabel}:${lineNumber}: Unsupported or unquoted flow collection (quote placeholders like "{{TOKEN}}")`
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
if (/^-?(0|[1-9][0-9]*)$/.test(s)) {
|
|
241
|
+
return Number.parseInt(s, 10);
|
|
242
|
+
}
|
|
243
|
+
if (/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/.test(s)) {
|
|
244
|
+
return Number.parseFloat(s);
|
|
245
|
+
}
|
|
246
|
+
return s;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function tokenizeLines(text, sourceLabel) {
|
|
250
|
+
const normalized = text.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
251
|
+
const rawLines = normalized.split("\n");
|
|
252
|
+
const tokens = [];
|
|
253
|
+
|
|
254
|
+
for (let idx = 0; idx < rawLines.length; idx += 1) {
|
|
255
|
+
const lineNumber = idx + 1;
|
|
256
|
+
const rawLine = rawLines[idx];
|
|
257
|
+
const indentMatch = rawLine.match(/^[ \t]*/);
|
|
258
|
+
const leading = indentMatch ? indentMatch[0] : "";
|
|
259
|
+
if (leading.includes("\t")) {
|
|
260
|
+
throw new Error(`${sourceLabel}:${lineNumber}: Tabs are forbidden in YAML indentation`);
|
|
261
|
+
}
|
|
262
|
+
const stripped = stripComment(rawLine, lineNumber, sourceLabel);
|
|
263
|
+
const trimmed = stripped.trim();
|
|
264
|
+
if (trimmed === "") {
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
if ((trimmed === "---" || trimmed === "...") && leading.length === 0) {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
tokens.push({
|
|
271
|
+
lineNumber,
|
|
272
|
+
indent: leading.length,
|
|
273
|
+
trimmed,
|
|
274
|
+
rawLine,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
return tokens;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function parseBlockScalar(tokens, startIndex, parentIndent, indicator) {
|
|
281
|
+
const mode = indicator[0]; // '|' or '>'
|
|
282
|
+
const chomp = indicator.slice(1); // '' or '-' or '+'
|
|
283
|
+
const lines = [];
|
|
284
|
+
let blockIndent = null;
|
|
285
|
+
let i = startIndex;
|
|
286
|
+
|
|
287
|
+
while (i < tokens.length) {
|
|
288
|
+
const tok = tokens[i];
|
|
289
|
+
if (tok.indent <= parentIndent) {
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
if (blockIndent === null) {
|
|
293
|
+
blockIndent = tok.indent;
|
|
294
|
+
}
|
|
295
|
+
lines.push(tok.rawLine.slice(blockIndent));
|
|
296
|
+
i += 1;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
let joined = mode === ">" ? lines.join(" ") : lines.join("\n");
|
|
300
|
+
if (chomp !== "-") {
|
|
301
|
+
joined += "\n";
|
|
302
|
+
}
|
|
303
|
+
return { value: joined, nextIndex: i };
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function parseBlockValue(tokens, index, parentIndent, sourceLabel, allowSameIndentSeq = false) {
|
|
307
|
+
if (index >= tokens.length) {
|
|
308
|
+
return { value: null, nextIndex: index };
|
|
309
|
+
}
|
|
310
|
+
const next = tokens[index];
|
|
311
|
+
const isSeqStart = next.trimmed === "-" || next.trimmed.startsWith("- ");
|
|
312
|
+
if (isSeqStart && (next.indent > parentIndent || (allowSameIndentSeq && next.indent === parentIndent))) {
|
|
313
|
+
return parseSequence(tokens, index, next.indent, sourceLabel);
|
|
314
|
+
}
|
|
315
|
+
if (next.indent <= parentIndent) {
|
|
316
|
+
return { value: null, nextIndex: index };
|
|
317
|
+
}
|
|
318
|
+
if (isSeqStart) {
|
|
319
|
+
return parseSequence(tokens, index, next.indent, sourceLabel);
|
|
320
|
+
}
|
|
321
|
+
return parseMapping(tokens, index, next.indent, sourceLabel);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function parseSequence(tokens, startIndex, seqIndent, sourceLabel) {
|
|
325
|
+
const arr = [];
|
|
326
|
+
let i = startIndex;
|
|
327
|
+
|
|
328
|
+
while (i < tokens.length) {
|
|
329
|
+
const tok = tokens[i];
|
|
330
|
+
if (tok.indent < seqIndent) {
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
if (tok.indent > seqIndent) {
|
|
334
|
+
throw new Error(`${sourceLabel}:${tok.lineNumber}: Unexpected sequence indentation (${tok.indent} > ${seqIndent})`);
|
|
335
|
+
}
|
|
336
|
+
if (tok.trimmed !== "-" && !tok.trimmed.startsWith("- ")) {
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const afterDash = tok.trimmed.slice(1).trim();
|
|
341
|
+
if (afterDash === "") {
|
|
342
|
+
const child = parseBlockValue(tokens, i + 1, seqIndent, sourceLabel, false);
|
|
343
|
+
arr.push(child.value);
|
|
344
|
+
i = child.nextIndex;
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const inlineMapping = trySplitKeyValue(afterDash, tok.lineNumber, sourceLabel);
|
|
349
|
+
if (inlineMapping) {
|
|
350
|
+
// Inline mapping entry inside a sequence item: "- key: val"
|
|
351
|
+
const obj = {};
|
|
352
|
+
const itemIndent = tok.indent + 2;
|
|
353
|
+
const { key, rawVal } = inlineMapping;
|
|
354
|
+
i += 1;
|
|
355
|
+
if (rawVal === "" || rawVal === "|" || rawVal === "|-" || rawVal === ">" || rawVal === ">-") {
|
|
356
|
+
if (rawVal === "|" || rawVal === "|-" || rawVal === ">" || rawVal === ">-") {
|
|
357
|
+
const blk = parseBlockScalar(tokens, i, itemIndent, rawVal);
|
|
358
|
+
obj[key] = blk.value;
|
|
359
|
+
i = blk.nextIndex;
|
|
360
|
+
} else {
|
|
361
|
+
const child = parseBlockValue(tokens, i, itemIndent, sourceLabel, true);
|
|
362
|
+
obj[key] = child.value;
|
|
363
|
+
i = child.nextIndex;
|
|
364
|
+
}
|
|
365
|
+
} else {
|
|
366
|
+
obj[key] = parseScalar(rawVal, tok.lineNumber, sourceLabel);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Consume remaining keys at itemIndent belonging to this same list-item object.
|
|
370
|
+
while (i < tokens.length && tokens[i].indent >= itemIndent) {
|
|
371
|
+
const subTok = tokens[i];
|
|
372
|
+
if (subTok.indent > itemIndent) {
|
|
373
|
+
throw new Error(`${sourceLabel}:${subTok.lineNumber}: Unexpected indentation inside sequence mapping`);
|
|
374
|
+
}
|
|
375
|
+
if (subTok.trimmed === "-" || subTok.trimmed.startsWith("- ")) {
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
const subKv = splitKeyValue(subTok.trimmed, subTok.lineNumber, sourceLabel);
|
|
379
|
+
if (Object.hasOwn(obj, subKv.key)) {
|
|
380
|
+
throw new Error(`${sourceLabel}:${subTok.lineNumber}: Duplicate key "${subKv.key}"`);
|
|
381
|
+
}
|
|
382
|
+
i += 1;
|
|
383
|
+
if (subKv.rawVal === "|" || subKv.rawVal === "|-" || subKv.rawVal === ">" || subKv.rawVal === ">-") {
|
|
384
|
+
const blk = parseBlockScalar(tokens, i, itemIndent, subKv.rawVal);
|
|
385
|
+
obj[subKv.key] = blk.value;
|
|
386
|
+
i = blk.nextIndex;
|
|
387
|
+
} else if (subKv.rawVal === "") {
|
|
388
|
+
const child = parseBlockValue(tokens, i, itemIndent, sourceLabel, true);
|
|
389
|
+
obj[subKv.key] = child.value;
|
|
390
|
+
i = child.nextIndex;
|
|
391
|
+
} else {
|
|
392
|
+
obj[subKv.key] = parseScalar(subKv.rawVal, subTok.lineNumber, sourceLabel);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
arr.push(obj);
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
arr.push(parseScalar(afterDash, tok.lineNumber, sourceLabel));
|
|
400
|
+
i += 1;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return { value: arr, nextIndex: i };
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function parseMapping(tokens, startIndex, mapIndent, sourceLabel) {
|
|
407
|
+
const obj = {};
|
|
408
|
+
let i = startIndex;
|
|
409
|
+
|
|
410
|
+
while (i < tokens.length) {
|
|
411
|
+
const tok = tokens[i];
|
|
412
|
+
if (tok.indent < mapIndent) {
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
if (tok.indent > mapIndent) {
|
|
416
|
+
throw new Error(`${sourceLabel}:${tok.lineNumber}: Unexpected mapping indentation (${tok.indent} > ${mapIndent})`);
|
|
417
|
+
}
|
|
418
|
+
if (tok.trimmed === "-" || tok.trimmed.startsWith("- ")) {
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const { key, rawVal } = splitKeyValue(tok.trimmed, tok.lineNumber, sourceLabel);
|
|
423
|
+
if (Object.hasOwn(obj, key)) {
|
|
424
|
+
throw new Error(`${sourceLabel}:${tok.lineNumber}: Duplicate mapping key "${key}"`);
|
|
425
|
+
}
|
|
426
|
+
i += 1;
|
|
427
|
+
|
|
428
|
+
if (rawVal === "|" || rawVal === "|-" || rawVal === ">" || rawVal === ">-") {
|
|
429
|
+
const blk = parseBlockScalar(tokens, i, mapIndent, rawVal);
|
|
430
|
+
obj[key] = blk.value;
|
|
431
|
+
i = blk.nextIndex;
|
|
432
|
+
} else if (rawVal === "") {
|
|
433
|
+
const child = parseBlockValue(tokens, i, mapIndent, sourceLabel, true);
|
|
434
|
+
obj[key] = child.value;
|
|
435
|
+
i = child.nextIndex;
|
|
436
|
+
} else {
|
|
437
|
+
obj[key] = parseScalar(rawVal, tok.lineNumber, sourceLabel);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
return { value: obj, nextIndex: i };
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export function parseYaml(text, sourceLabel = "<yaml>") {
|
|
445
|
+
const tokens = tokenizeLines(text, sourceLabel);
|
|
446
|
+
if (tokens.length === 0) {
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
const first = tokens[0];
|
|
450
|
+
if (first.indent !== 0) {
|
|
451
|
+
throw new Error(`${sourceLabel}:${first.lineNumber}: Root YAML element must start at column 0`);
|
|
452
|
+
}
|
|
453
|
+
const result =
|
|
454
|
+
first.trimmed === "-" || first.trimmed.startsWith("- ")
|
|
455
|
+
? parseSequence(tokens, 0, 0, sourceLabel)
|
|
456
|
+
: parseMapping(tokens, 0, 0, sourceLabel);
|
|
457
|
+
|
|
458
|
+
if (result.nextIndex < tokens.length) {
|
|
459
|
+
const leftover = tokens[result.nextIndex];
|
|
460
|
+
throw new Error(`${sourceLabel}:${leftover.lineNumber}: Unexpected trailing YAML token "${leftover.trimmed}"`);
|
|
461
|
+
}
|
|
462
|
+
return result.value;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
export function extractFrontmatter(markdownText, sourceLabel = "<markdown>") {
|
|
466
|
+
const normalized = markdownText.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
467
|
+
if (!normalized.startsWith("---\n")) {
|
|
468
|
+
throw new Error(`${sourceLabel}: Missing opening YAML frontmatter delimiter "---" on line 1`);
|
|
469
|
+
}
|
|
470
|
+
const closeIdx = normalized.indexOf("\n---", 3);
|
|
471
|
+
if (closeIdx === -1) {
|
|
472
|
+
throw new Error(`${sourceLabel}: Missing closing YAML frontmatter delimiter "---"`);
|
|
473
|
+
}
|
|
474
|
+
const afterClose = normalized.slice(closeIdx + 4);
|
|
475
|
+
if (afterClose.length > 0 && !afterClose.startsWith("\n")) {
|
|
476
|
+
throw new Error(`${sourceLabel}: Invalid closing YAML frontmatter delimiter`);
|
|
477
|
+
}
|
|
478
|
+
const yamlBlock = normalized.slice(4, closeIdx);
|
|
479
|
+
return parseYaml(yamlBlock, `${sourceLabel} (frontmatter)`);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function serializeScalar(val) {
|
|
483
|
+
if (val === null || val === undefined) {
|
|
484
|
+
return "null";
|
|
485
|
+
}
|
|
486
|
+
if (typeof val === "boolean" || typeof val === "number") {
|
|
487
|
+
return String(val);
|
|
488
|
+
}
|
|
489
|
+
return JSON.stringify(String(val));
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function serializeMappingLines(obj, indent) {
|
|
493
|
+
const pad = " ".repeat(indent);
|
|
494
|
+
const lines = [];
|
|
495
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
496
|
+
if (val === undefined) {
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
if (Array.isArray(val)) {
|
|
500
|
+
if (val.length === 0) {
|
|
501
|
+
lines.push(`${pad}${key}: []`);
|
|
502
|
+
} else {
|
|
503
|
+
lines.push(`${pad}${key}:`);
|
|
504
|
+
for (const item of val) {
|
|
505
|
+
if (item !== null && typeof item === "object" && !Array.isArray(item)) {
|
|
506
|
+
const entries = Object.entries(item).filter(([, v]) => v !== undefined);
|
|
507
|
+
if (entries.length === 0) {
|
|
508
|
+
lines.push(`${pad} - {}`);
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
const [firstKey, firstVal] = entries[0];
|
|
512
|
+
if (firstVal !== null && typeof firstVal === "object") {
|
|
513
|
+
if (Array.isArray(firstVal) && firstVal.length === 0) {
|
|
514
|
+
lines.push(`${pad} - ${firstKey}: []`);
|
|
515
|
+
} else if (!Array.isArray(firstVal) && Object.keys(firstVal).length === 0) {
|
|
516
|
+
lines.push(`${pad} - ${firstKey}: {}`);
|
|
517
|
+
} else {
|
|
518
|
+
lines.push(`${pad} - ${firstKey}:`);
|
|
519
|
+
if (Array.isArray(firstVal)) {
|
|
520
|
+
for (const sub of firstVal) {
|
|
521
|
+
lines.push(`${pad} - ${serializeScalar(sub)}`);
|
|
522
|
+
}
|
|
523
|
+
} else {
|
|
524
|
+
lines.push(...serializeMappingLines(firstVal, indent + 6));
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
} else {
|
|
528
|
+
lines.push(`${pad} - ${firstKey}: ${serializeScalar(firstVal)}`);
|
|
529
|
+
}
|
|
530
|
+
for (const [subKey, subVal] of entries.slice(1)) {
|
|
531
|
+
lines.push(...serializeMappingLines({ [subKey]: subVal }, indent + 4));
|
|
532
|
+
}
|
|
533
|
+
} else if (Array.isArray(item)) {
|
|
534
|
+
if (item.length === 0) {
|
|
535
|
+
lines.push(`${pad} - []`);
|
|
536
|
+
} else {
|
|
537
|
+
lines.push(`${pad} -`);
|
|
538
|
+
for (const sub of item) {
|
|
539
|
+
lines.push(`${pad} - ${serializeScalar(sub)}`);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
} else {
|
|
543
|
+
lines.push(`${pad} - ${serializeScalar(item)}`);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
} else if (val !== null && typeof val === "object") {
|
|
548
|
+
const childKeys = Object.entries(val).filter(([, v]) => v !== undefined);
|
|
549
|
+
if (childKeys.length === 0) {
|
|
550
|
+
lines.push(`${pad}${key}: {}`);
|
|
551
|
+
} else {
|
|
552
|
+
lines.push(`${pad}${key}:`);
|
|
553
|
+
lines.push(...serializeMappingLines(val, indent + 2));
|
|
554
|
+
}
|
|
555
|
+
} else {
|
|
556
|
+
lines.push(`${pad}${key}: ${serializeScalar(val)}`);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return lines;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Serializes a plain JavaScript object into strict YAML compatible with parseYaml().
|
|
564
|
+
*/
|
|
565
|
+
export function serializeYaml(obj, { headerComment = null } = {}) {
|
|
566
|
+
const lines = [];
|
|
567
|
+
if (headerComment) {
|
|
568
|
+
lines.push(`# ${headerComment}`);
|
|
569
|
+
}
|
|
570
|
+
lines.push(...serializeMappingLines(obj, 0));
|
|
571
|
+
return `${lines.join("\n")}\n`;
|
|
572
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geloforge",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Local, provider-neutral CLI for AI coding project memory, command-backed evidence, portable skills, and cross-agent handoffs.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/63L0/GeloForge.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/63L0/GeloForge#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/63L0/GeloForge/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"ai-coding",
|
|
17
|
+
"ai-harness",
|
|
18
|
+
"agent-skills",
|
|
19
|
+
"context-engineering",
|
|
20
|
+
"project-memory",
|
|
21
|
+
"cross-agent-handoff",
|
|
22
|
+
"developer-tools"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20.0.0"
|
|
26
|
+
},
|
|
27
|
+
"bin": {
|
|
28
|
+
"geloforge": "./scripts/geloforge.mjs"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"core/",
|
|
32
|
+
"adapters/n8n/staging-audit-error-workflow.json",
|
|
33
|
+
"policies/",
|
|
34
|
+
"schemas/",
|
|
35
|
+
"scripts/bootstrap-project.mjs",
|
|
36
|
+
"scripts/geloforge.mjs",
|
|
37
|
+
"templates/",
|
|
38
|
+
"THIRD_PARTY_NOTICES.md",
|
|
39
|
+
"VERSION"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"test": "node --test",
|
|
43
|
+
"validate": "node --test",
|
|
44
|
+
"validate:project": "node scripts/validate-project.mjs",
|
|
45
|
+
"bootstrap": "node scripts/bootstrap-project.mjs",
|
|
46
|
+
"geloforge": "node scripts/geloforge.mjs",
|
|
47
|
+
"benchmark": "node scripts/benchmark-context.mjs",
|
|
48
|
+
"smoke:package": "node scripts/smoke-fresh-install.mjs --packed",
|
|
49
|
+
"benchmark:cache": "node scripts/benchmark-context-cache.mjs",
|
|
50
|
+
"benchmark:audits": "node --test tests/staging-audit-worker.test.mjs"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Security and Approval Boundaries Policy
|
|
2
|
+
|
|
3
|
+
> **Enforcement scope:** GeloForge enforces the CLI checks listed below. OS permissions and provider sandbox settings govern other processes and their access.
|
|
4
|
+
|
|
5
|
+
## Technically Enforced Controls vs. Documented-Only Safeguards
|
|
6
|
+
|
|
7
|
+
| Control | Status | Mechanism / Scope |
|
|
8
|
+
| :--- | :--- | :--- |
|
|
9
|
+
| Traversal, UNC, Windows reserved names, trailing dot/space refusal | **Technically enforced** | [core/path-safety.mjs](../core/path-safety.mjs) |
|
|
10
|
+
| Symbolic link / NTFS junction ancestor refusal | **Technically enforced** | [core/path-safety.mjs](../core/path-safety.mjs) (`lstatSync` + `realpathSync`) |
|
|
11
|
+
| Overwrite refusal & transactional staging rollback | **Technically enforced** | [scripts/bootstrap-project.mjs](../scripts/bootstrap-project.mjs) |
|
|
12
|
+
| Single-pass placeholder substitution (no double-interpolation) | **Technically enforced** | [scripts/bootstrap-project.mjs](../scripts/bootstrap-project.mjs) |
|
|
13
|
+
| Secret & `.env` `.gitignore` rules + zero-network tooling | **Technically enforced** | [.gitignore](../.gitignore), verified by `tests/security.test.mjs` |
|
|
14
|
+
| `APPR-NNNN` owner approval gates | **Technically enforced for signed operations** | Canonical promotion and staging worker launches verify an owner key. See [setup](../docs/advanced-usage.md). |
|
|
15
|
+
| Specialist and retry limits | **Technically enforced for staging audits** | Up to two concurrent specialists and two report repair retries per task. Owner approval caps provider launches. |
|
|
16
|
+
|
|
17
|
+
## Authority Level `A0` — Global Harness Security Rules
|
|
18
|
+
|
|
19
|
+
1. **No Committed Secrets:** Never write or commit `.env*`, API keys, tokens, or private keys (`*.pem`, `*.key`, `*.p12`, `*.pfx`) into any Git repository.
|
|
20
|
+
2. **No Automatic Remote Creation or Push:** Never create remotes or push code without explicit owner instruction.
|
|
21
|
+
3. **No Global Git or OS Security Modifications:** Never modify `git config --global`, Windows security policies, or system ACLs.
|
|
22
|
+
4. **No Unapproved Tool or Dependency Installs:** Never install packages or extensions without explicit owner approval.
|
|
23
|
+
5. **No Automatic Paid APIs or Spending:** Never activate metered paid APIs or cloud billing autonomously.
|
|
24
|
+
6. **No Destructive Overwrites:** Never overwrite existing projects, canonical `L1` records, or unrelated files without authorization.
|
|
25
|
+
7. **No Bypassing Controls:** Never defeat permission checks, authentication prompts, or safety boundaries.
|
|
26
|
+
8. **Honest Reporting:** Never fabricate test evidence, promote example records (`is_example: true`), or claim unimplemented safeguards are enforced.
|
|
27
|
+
|
|
28
|
+
## Approval Boundary Matrix (`APPR-NNNN`)
|
|
29
|
+
|
|
30
|
+
Actions crossing trust, cost, requirement, architecture, or destructive boundaries require an explicit owner decision recorded with [approval-record.schema.json](../schemas/approval-record.schema.json):
|
|
31
|
+
|
|
32
|
+
| `boundary_category` | Triggering Actions | Required Approver |
|
|
33
|
+
| :--- | :--- | :--- |
|
|
34
|
+
| `requirements_change` | Creating/modifying canonical `brain/requirements/prd.md` or `constraints.md` | Project Owner |
|
|
35
|
+
| `architecture_change` | Accepting, deprecating, or superseding an `ADR-NNNN` in `brain/decisions/` | Project Owner |
|
|
36
|
+
| `security_boundary` | Modifying `A0` policies, auth flows, secret handling, or core validators | Project Owner |
|
|
37
|
+
| `spend_or_paid_api` | Enabling paid APIs, cloud resources, or metered external services | Project Owner |
|
|
38
|
+
| `external_mutation` | Creating Git remotes, pushing code, opening external PRs/issues | Project Owner |
|
|
39
|
+
| `destructive_action` | Deleting project data, force-pushing, resetting uncommitted work | Project Owner |
|
|
40
|
+
| `policy_exception` | Temporarily waiving a harness policy (requires `expires_at` and `conditions`) | Project Owner |
|
|
41
|
+
|
|
42
|
+
Related: [memory-policy.md](./memory-policy.md), [token-efficiency.md](./token-efficiency.md), [SECURITY.md](../SECURITY.md).
|