@cassiomc1/forgeloop 2.0.0-rc.5 → 2.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.
- package/.cursor/rules/project-loop.mdc +1 -1
- package/.github/copilot-instructions.md +1 -1
- package/AGENTS.md +1 -1
- package/CLAUDE.md +1 -1
- package/CONTRIBUTING.md +3 -1
- package/DOCS_INDEX.md +2 -0
- package/ENG/accessibility-eng.md +6 -6
- package/ENG/clean-code-eng.md +2 -2
- package/ENG/design-code-eng.md +17 -15
- package/ENG/documentation-quality-eng.md +10 -2
- package/ENG/dotnet-aspnetcore-development-eng.md +8 -4
- package/ENG/flutter-development-eng.md +38 -59
- package/ENG/games-code-design-web-eng.md +2 -2
- package/ENG/nodejs-backend-development-eng.md +7 -4
- package/ENG/perf-code-eng.md +3 -3
- package/ENG/php-development-eng.md +2 -2
- package/ENG/premium-sites-studio-eng.md +9 -2
- package/ENG/python-development-eng.md +7 -1
- package/ENG/rust-development-eng.md +22 -32
- package/ENG/sec-code-eng.md +19 -3
- package/ENG/sql-development-eng.md +5 -4
- package/ENG/taste-frontend-eng.md +125 -4
- package/ENG/test-code-eng.md +2 -2
- package/GUIDE_ROUTER.md +18 -4
- package/PROTOCOL_INTEGRATION.md +21 -0
- package/README.md +15 -13
- package/THIRD_PARTY_NOTICES.md +60 -6
- package/docs/AGENT_PROTOCOL_SUMMARY.md +1 -1
- package/docs/AGENT_SKILL.md +16 -0
- package/docs/DOCUMENTATION_GUIDE.md +6 -0
- package/docs/FORGELOOP_AUDIT.md +1 -1
- package/docs/GETTING_STARTED.md +8 -1
- package/docs/GUIDE_MAINTENANCE.md +106 -0
- package/docs/PACKAGE_CONTENTS.md +22 -5
- package/docs/RELEASE_CHECKLIST.md +68 -35
- package/docs/REVENUE_CENTRIC_DESIGN.md +69 -0
- package/docs/SECURITY_AUDIT_SKILL.md +131 -0
- package/docs/SECURITY_REVIEW.md +6 -0
- package/docs/STABLE_2_ACCEPTANCE.md +127 -0
- package/docs/TROUBLESHOOTING.md +171 -0
- package/docs/documentation-manifest.json +244 -0
- package/package.json +12 -7
- package/scripts/generate-forgeloop-skill.mjs +8 -0
- package/scripts/verify-revenue-design-skill.mjs +37 -0
- package/scripts/verify-security-audit-skill.mjs +68 -0
- package/skills/forgeloop/SKILL.md +8 -0
- package/skills/forgeloop/references/revenue-centric-design/LICENSE +30 -0
- package/skills/forgeloop/references/revenue-centric-design/PIN.json +14 -0
- package/skills/forgeloop/references/revenue-centric-design/SKILL.md +64 -0
- package/skills/forgeloop/references/revenue-centric-design/references/playbook.md +36 -0
- package/skills/security-audit/AI-AND-LLM.md +83 -0
- package/skills/security-audit/ATTACK-CLASSES.md +130 -0
- package/skills/security-audit/CLIENT-SIDE.md +83 -0
- package/skills/security-audit/CLOUD-AND-DEPLOYMENT.md +86 -0
- package/skills/security-audit/DATA-ISOLATION-AND-LIFECYCLE.md +84 -0
- package/skills/security-audit/DESKTOP-MOBILE-AND-LOCAL-IPC.md +89 -0
- package/skills/security-audit/HUNTING.md +251 -0
- package/skills/security-audit/LICENSE +21 -0
- package/skills/security-audit/MEMORY-SAFETY-AND-BINARY.md +101 -0
- package/skills/security-audit/PIN.json +30 -0
- package/skills/security-audit/PROTOCOLS-RPC-AND-MESSAGING.md +81 -0
- package/skills/security-audit/RECONNAISSANCE.md +156 -0
- package/skills/security-audit/RESOURCE-EXHAUSTION-AND-AVAILABILITY.md +78 -0
- package/skills/security-audit/SKILL.md +192 -0
- package/skills/security-audit/SUPPLY-CHAIN-AND-RELEASE.md +73 -0
- package/skills/security-audit/VALIDATION-AND-REPORTING.md +186 -0
- package/skills/security-audit/WEB-PROTOCOL-AND-AUTH.md +105 -0
- package/skills/security-audit/report-schema.json +461 -0
- package/skills/security-audit/validate-coverage-ledger.cjs +872 -0
- package/skills/security-audit/validate-coverage-ledger.test.cjs +740 -0
- package/skills/security-audit/validate-findings.cjs +773 -0
- package/skills/security-audit/validate-findings.test.cjs +652 -0
- package/src/core/completion-artifacts.js +4 -7
- package/src/core/diagnosis.js +3 -5
- package/src/core/diagnostic-record.js +4 -4
- package/src/core/error-codes.js +180 -2
- package/src/core/next-action-recovery-phases.js +3 -0
- package/src/core/next-action-review-correction.js +26 -0
- package/src/core/next-action-review-phase.js +25 -15
- package/src/core/parsers/dotnet-project.js +221 -0
- package/src/core/parsers/limits.js +9 -0
- package/src/core/parsers/pubspec.js +307 -0
- package/src/core/parsers/shared.js +4 -0
- package/src/core/project-detection.js +6 -527
- package/src/core/reconcile-closure.js +5 -0
- package/src/core/review-correction.js +51 -0
- package/src/storage/capabilities.js +1 -1
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
// Bounded parsers for untrusted repository manifest text. They never throw on
|
|
2
|
+
// malformed input: every entry point returns an `invalid` shape instead.
|
|
3
|
+
import { PROJECT_DETECTION_LIMITS } from "./limits.js";
|
|
4
|
+
|
|
5
|
+
const MAX_MANIFEST_BYTES = PROJECT_DETECTION_LIMITS.maxManifestBytes;
|
|
6
|
+
const UNSUPPORTED_YAML_VALUE = Symbol("unsupported-yaml-value");
|
|
7
|
+
// Inline flow maps deeper than this are rejected as invalid instead of recursing:
|
|
8
|
+
// unbounded nesting in untrusted manifests otherwise overflows the call stack.
|
|
9
|
+
export const MAX_INLINE_MAP_DEPTH = 32;
|
|
10
|
+
|
|
11
|
+
function stripYamlComment(value) {
|
|
12
|
+
let quote = null;
|
|
13
|
+
let braceDepth = 0;
|
|
14
|
+
let bracketDepth = 0;
|
|
15
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
16
|
+
const character = value[index];
|
|
17
|
+
if (quote === "\"") {
|
|
18
|
+
if (character === "\\") index += 1;
|
|
19
|
+
else if (character === "\"") quote = null;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (quote === "'") {
|
|
23
|
+
if (character === "'" && value[index + 1] === "'") index += 1;
|
|
24
|
+
else if (character === "'") quote = null;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (character === "\"" || character === "'") {
|
|
28
|
+
quote = character;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (character === "{") braceDepth += 1;
|
|
32
|
+
else if (character === "}") braceDepth = Math.max(0, braceDepth - 1);
|
|
33
|
+
else if (character === "[") bracketDepth += 1;
|
|
34
|
+
else if (character === "]") bracketDepth = Math.max(0, bracketDepth - 1);
|
|
35
|
+
else if (character === "#" && braceDepth === 0 && bracketDepth === 0
|
|
36
|
+
&& (index === 0 || /\s/u.test(value[index - 1]))) {
|
|
37
|
+
return value.slice(0, index).trimEnd();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return value.trimEnd();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function findTopLevelColon(value) {
|
|
44
|
+
let quote = null;
|
|
45
|
+
let braceDepth = 0;
|
|
46
|
+
let bracketDepth = 0;
|
|
47
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
48
|
+
const character = value[index];
|
|
49
|
+
if (quote === "\"") {
|
|
50
|
+
if (character === "\\") index += 1;
|
|
51
|
+
else if (character === "\"") quote = null;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (quote === "'") {
|
|
55
|
+
if (character === "'" && value[index + 1] === "'") index += 1;
|
|
56
|
+
else if (character === "'") quote = null;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (character === "\"" || character === "'") {
|
|
60
|
+
quote = character;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (character === "{") braceDepth += 1;
|
|
64
|
+
else if (character === "}") braceDepth = Math.max(0, braceDepth - 1);
|
|
65
|
+
else if (character === "[") bracketDepth += 1;
|
|
66
|
+
else if (character === "]") bracketDepth = Math.max(0, bracketDepth - 1);
|
|
67
|
+
else if (character === ":" && braceDepth === 0 && bracketDepth === 0) return index;
|
|
68
|
+
}
|
|
69
|
+
return -1;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function unquoteYamlScalar(value) {
|
|
73
|
+
const trimmed = value.trim();
|
|
74
|
+
if (trimmed.length < 2) return trimmed;
|
|
75
|
+
if (trimmed.startsWith("\"") && trimmed.endsWith("\"")) {
|
|
76
|
+
try {
|
|
77
|
+
return JSON.parse(trimmed);
|
|
78
|
+
} catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (trimmed.startsWith("'") && trimmed.endsWith("'")) {
|
|
83
|
+
return trimmed.slice(1, -1).replaceAll("''", "'");
|
|
84
|
+
}
|
|
85
|
+
return trimmed;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function splitTopLevel(value, delimiter = ",") {
|
|
89
|
+
const parts = [];
|
|
90
|
+
let start = 0;
|
|
91
|
+
let quote = null;
|
|
92
|
+
let braceDepth = 0;
|
|
93
|
+
let bracketDepth = 0;
|
|
94
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
95
|
+
const character = value[index];
|
|
96
|
+
if (quote === "\"") {
|
|
97
|
+
if (character === "\\") index += 1;
|
|
98
|
+
else if (character === "\"") quote = null;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (quote === "'") {
|
|
102
|
+
if (character === "'" && value[index + 1] === "'") index += 1;
|
|
103
|
+
else if (character === "'") quote = null;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (character === "\"" || character === "'") {
|
|
107
|
+
quote = character;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (character === "{") braceDepth += 1;
|
|
111
|
+
else if (character === "}") braceDepth = Math.max(0, braceDepth - 1);
|
|
112
|
+
else if (character === "[") bracketDepth += 1;
|
|
113
|
+
else if (character === "]") bracketDepth = Math.max(0, bracketDepth - 1);
|
|
114
|
+
else if (character === delimiter && braceDepth === 0 && bracketDepth === 0) {
|
|
115
|
+
parts.push(value.slice(start, index).trim());
|
|
116
|
+
start = index + 1;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
parts.push(value.slice(start).trim());
|
|
120
|
+
return parts.filter(Boolean);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function parseInlineMap(value, depth) {
|
|
124
|
+
if (depth > MAX_INLINE_MAP_DEPTH) return null;
|
|
125
|
+
const trimmed = value.trim();
|
|
126
|
+
if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) return null;
|
|
127
|
+
const body = trimmed.slice(1, -1).trim();
|
|
128
|
+
if (body === "") return {};
|
|
129
|
+
const result = {};
|
|
130
|
+
for (const pair of splitTopLevel(body)) {
|
|
131
|
+
const separator = findTopLevelColon(pair);
|
|
132
|
+
if (separator <= 0) return null;
|
|
133
|
+
const key = unquoteYamlScalar(pair.slice(0, separator));
|
|
134
|
+
const rawValue = pair.slice(separator + 1).trim();
|
|
135
|
+
if (!key || rawValue === "" || Object.prototype.hasOwnProperty.call(result, key)) return null;
|
|
136
|
+
const parsedValue = parseYamlValue(rawValue, depth + 1);
|
|
137
|
+
if (parsedValue === null) return null;
|
|
138
|
+
result[key] = parsedValue;
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function parseYamlValue(value, depth = 0) {
|
|
144
|
+
const withoutComment = stripYamlComment(value).trim();
|
|
145
|
+
if (withoutComment === "") return "";
|
|
146
|
+
if (withoutComment.startsWith("{")) {
|
|
147
|
+
return withoutComment.endsWith("}") ? parseInlineMap(withoutComment, depth) : null;
|
|
148
|
+
}
|
|
149
|
+
if (withoutComment.startsWith("[")) return UNSUPPORTED_YAML_VALUE;
|
|
150
|
+
return unquoteYamlScalar(withoutComment);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function containsUnsupportedYamlValue(value) {
|
|
154
|
+
if (value === UNSUPPORTED_YAML_VALUE) return true;
|
|
155
|
+
if (!value || typeof value !== "object") return false;
|
|
156
|
+
return Object.values(value).some(containsUnsupportedYamlValue);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function parseYamlLine(line) {
|
|
160
|
+
if (/^\t/u.test(line)) return { invalid: true };
|
|
161
|
+
const indent = line.match(/^ */u)?.[0].length ?? 0;
|
|
162
|
+
const content = stripYamlComment(line.slice(indent)).trim();
|
|
163
|
+
if (content === "" || content === "---" || content === "..." || content.startsWith("#")) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
if (content.startsWith("- ") || content === "-") return { indent, sequence: true };
|
|
167
|
+
const separator = findTopLevelColon(content);
|
|
168
|
+
if (separator <= 0) return null;
|
|
169
|
+
const key = unquoteYamlScalar(content.slice(0, separator));
|
|
170
|
+
if (!key) return null;
|
|
171
|
+
const rawValue = content.slice(separator + 1).trim();
|
|
172
|
+
const value = rawValue === "" ? "" : parseYamlValue(rawValue);
|
|
173
|
+
if (value === null) return { invalid: true };
|
|
174
|
+
return { indent, key, value };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function dependencySdkValue(entry) {
|
|
178
|
+
if (!entry) return null;
|
|
179
|
+
if (entry.value && typeof entry.value === "object" && !Array.isArray(entry.value)) {
|
|
180
|
+
return entry.value.sdk === "flutter" ? "flutter" : null;
|
|
181
|
+
}
|
|
182
|
+
return entry.value === "" ? null : null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function parseYamlLines(lines) {
|
|
186
|
+
const parsedLines = [];
|
|
187
|
+
let valid = true;
|
|
188
|
+
for (const line of lines) {
|
|
189
|
+
const parsed = parseYamlLine(line);
|
|
190
|
+
if (parsed?.invalid) valid = false;
|
|
191
|
+
parsedLines.push(parsed);
|
|
192
|
+
}
|
|
193
|
+
return { parsedLines, valid };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function findSectionIndexes(parsedLines, sectionName) {
|
|
197
|
+
const sectionIndexes = [];
|
|
198
|
+
for (let index = 0; index < parsedLines.length; index += 1) {
|
|
199
|
+
const parsed = parsedLines[index];
|
|
200
|
+
if (parsed?.indent === 0 && parsed.key === sectionName) sectionIndexes.push(index);
|
|
201
|
+
}
|
|
202
|
+
return sectionIndexes;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function dependencyEntriesFromInline(value) {
|
|
206
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
207
|
+
return Object.fromEntries(Object.entries(value).map(([key, entryValue]) => [key, { value: entryValue }]));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function findSectionIndent(parsedLines, sectionIndex) {
|
|
211
|
+
for (let index = sectionIndex + 1; index < parsedLines.length; index += 1) {
|
|
212
|
+
const parsed = parsedLines[index];
|
|
213
|
+
if (!parsed) continue;
|
|
214
|
+
if (parsed.indent === 0) break;
|
|
215
|
+
return parsed.indent;
|
|
216
|
+
}
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function readNestedDependencyMap(parsedLines, entryIndex, parentIndent) {
|
|
221
|
+
let nestedIndent = null;
|
|
222
|
+
const nested = {};
|
|
223
|
+
for (let index = entryIndex + 1; index < parsedLines.length; index += 1) {
|
|
224
|
+
const parsed = parsedLines[index];
|
|
225
|
+
if (!parsed) continue;
|
|
226
|
+
if (parsed.invalid) return null;
|
|
227
|
+
if (parsed.sequence) {
|
|
228
|
+
if (parsed.indent > parentIndent) return null;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
if (parsed.indent <= parentIndent) break;
|
|
232
|
+
if (containsUnsupportedYamlValue(parsed.value)) return null;
|
|
233
|
+
nestedIndent ??= parsed.indent;
|
|
234
|
+
if (parsed.indent !== nestedIndent) continue;
|
|
235
|
+
if (Object.prototype.hasOwnProperty.call(nested, parsed.key)) return null;
|
|
236
|
+
nested[parsed.key] = parsed.value;
|
|
237
|
+
}
|
|
238
|
+
return nested;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function readBlockDependencyEntries(parsedLines, sectionIndex, sectionIndent) {
|
|
242
|
+
const entries = {};
|
|
243
|
+
for (let index = sectionIndex + 1; index < parsedLines.length; index += 1) {
|
|
244
|
+
const parsed = parsedLines[index];
|
|
245
|
+
if (!parsed) continue;
|
|
246
|
+
if (parsed.invalid) return null;
|
|
247
|
+
if (parsed.indent === 0) break;
|
|
248
|
+
if (parsed.sequence || containsUnsupportedYamlValue(parsed.value)) return null;
|
|
249
|
+
if (parsed.indent !== sectionIndent) continue;
|
|
250
|
+
if (Object.prototype.hasOwnProperty.call(entries, parsed.key)) return null;
|
|
251
|
+
const entry = { value: parsed.value };
|
|
252
|
+
if (parsed.value === "") {
|
|
253
|
+
const nested = readNestedDependencyMap(parsedLines, index, parsed.indent);
|
|
254
|
+
if (nested === null) return null;
|
|
255
|
+
entry.value = nested;
|
|
256
|
+
}
|
|
257
|
+
entries[parsed.key] = entry;
|
|
258
|
+
}
|
|
259
|
+
return entries;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function readDependencySection(lines, sectionName) {
|
|
263
|
+
const { parsedLines, valid } = parseYamlLines(lines);
|
|
264
|
+
const sectionIndexes = findSectionIndexes(parsedLines, sectionName);
|
|
265
|
+
if (sectionIndexes.length > 1) return { present: true, valid: false, entries: {} };
|
|
266
|
+
if (sectionIndexes.length === 0) return { present: false, valid, entries: {} };
|
|
267
|
+
|
|
268
|
+
const sectionIndex = sectionIndexes[0];
|
|
269
|
+
const section = parsedLines[sectionIndex];
|
|
270
|
+
const entries = {};
|
|
271
|
+
if (section.value !== "") {
|
|
272
|
+
if (containsUnsupportedYamlValue(section.value)) {
|
|
273
|
+
return { present: true, valid: false, entries: {} };
|
|
274
|
+
}
|
|
275
|
+
const inlineEntries = dependencyEntriesFromInline(section.value);
|
|
276
|
+
if (inlineEntries === null) {
|
|
277
|
+
return { present: true, valid: false, entries: {} };
|
|
278
|
+
}
|
|
279
|
+
return { present: true, valid, entries: inlineEntries };
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const sectionIndent = findSectionIndent(parsedLines, sectionIndex);
|
|
283
|
+
if (sectionIndent === null) return { present: true, valid, entries };
|
|
284
|
+
const blockEntries = readBlockDependencyEntries(parsedLines, sectionIndex, sectionIndent);
|
|
285
|
+
if (blockEntries === null) return { present: true, valid: false, entries: {} };
|
|
286
|
+
return { present: true, valid, entries: blockEntries };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export function parsePubspec(text) {
|
|
290
|
+
if (typeof text !== "string" || text.length > MAX_MANIFEST_BYTES || /\r(?!\n)/u.test(text)) {
|
|
291
|
+
return { valid: false, primary: false, flutterTest: false, override: false };
|
|
292
|
+
}
|
|
293
|
+
const lines = text.replaceAll("\r\n", "\n").split("\n");
|
|
294
|
+
const dependencies = readDependencySection(lines, "dependencies");
|
|
295
|
+
const devDependencies = readDependencySection(lines, "dev_dependencies");
|
|
296
|
+
const dependencyOverrides = readDependencySection(lines, "dependency_overrides");
|
|
297
|
+
const valid = dependencies.valid && devDependencies.valid && dependencyOverrides.valid;
|
|
298
|
+
const primary = valid && dependencySdkValue(dependencies.entries.flutter) === "flutter";
|
|
299
|
+
const flutterTest = valid && dependencySdkValue(devDependencies.entries.flutter_test) === "flutter";
|
|
300
|
+
const override = valid && dependencySdkValue(dependencyOverrides.entries.flutter) === "flutter";
|
|
301
|
+
return {
|
|
302
|
+
valid,
|
|
303
|
+
primary,
|
|
304
|
+
flutterTest,
|
|
305
|
+
override,
|
|
306
|
+
};
|
|
307
|
+
}
|