cortad 0.2.2 → 0.2.3
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/lib/verbs.mjs +5 -1
- package/local.mjs +11 -7
- package/package.json +1 -1
package/lib/verbs.mjs
CHANGED
|
@@ -109,7 +109,11 @@ export function runText(d) {
|
|
|
109
109
|
const tail = [];
|
|
110
110
|
if (d.finished && typeof d.score === "number") tail.push(`Score ${d.score} of 100.`);
|
|
111
111
|
if (d.finished && typeof d.findings === "number") tail.push(d.findings ? `${plural(d.findings, "finding")}; call findings.` : "No findings stood out.");
|
|
112
|
-
if (d.stopped)
|
|
112
|
+
if (d.stopped) {
|
|
113
|
+
const side = d.stopped.side === "theirs" ? " (their side)" : d.stopped.side === "ours" ? " (Cortad's side)" : "";
|
|
114
|
+
const why = `${d.stopped.why[0].toUpperCase()}${d.stopped.why.slice(1)} at turn ${d.stopped.after}${side}. ${d.stopped.fix}`;
|
|
115
|
+
tail.push(d.of && d.played < d.of ? `Stopped at ${d.played} of ${d.of}: ${why}` : why);
|
|
116
|
+
}
|
|
113
117
|
for (const f of d.faults ?? []) tail.push(`${f.what} ${f.fix}`);
|
|
114
118
|
if (d.error) tail.push(`Error: ${d.error}`);
|
|
115
119
|
if (d.verify) tail.push(verifyText(d.verify));
|
package/local.mjs
CHANGED
|
@@ -182,6 +182,15 @@ const ENV_READ = /(?:process\.env(?:\.|\[\s*['"])|os\.(?:environ\.get|getenv)\(\
|
|
|
182
182
|
const lifted = (name) => (/(TOKEN_BUDGET|TOKENS)/.test(name) ? "1000000000" : "1000000");
|
|
183
183
|
const liftable = (name) => THROUGHPUT.test(name) && !GUARDED.test(name) && !SWITCH.test(name);
|
|
184
184
|
function liftedLimits(envFiles, sources = []) {
|
|
185
|
+
// Only a limit the code reads is raised: a line in .env that nothing reads is not a limit, and
|
|
186
|
+
// naming it as one raised was the tell an engineer caught first.
|
|
187
|
+
const read = new Set();
|
|
188
|
+
for (const file of sources) {
|
|
189
|
+
if (!/\.(?:[cm]?[jt]sx?|py|go|rb|php|rs)$/.test(file)) continue;
|
|
190
|
+
let text = "";
|
|
191
|
+
try { if (statSync(file).size > 512_000) continue; text = readFileSync(file, "utf8"); } catch { continue; }
|
|
192
|
+
for (const m of text.matchAll(ENV_READ)) if (liftable(m[1])) read.add(m[1]);
|
|
193
|
+
}
|
|
185
194
|
const out = {};
|
|
186
195
|
for (const file of envFiles) {
|
|
187
196
|
let text = "";
|
|
@@ -191,15 +200,10 @@ function liftedLimits(envFiles, sources = []) {
|
|
|
191
200
|
if (!m) continue;
|
|
192
201
|
const [, name, raw] = m;
|
|
193
202
|
const value = raw.trim().replace(/^(['"])(.*)\1$/, "$2");
|
|
194
|
-
if (liftable(name) && /^\d+$/.test(value)) out[name] = lifted(name);
|
|
203
|
+
if (liftable(name) && /^\d+$/.test(value) && (!sources.length || read.has(name))) out[name] = lifted(name);
|
|
195
204
|
}
|
|
196
205
|
}
|
|
197
|
-
for (const
|
|
198
|
-
if (!/\.(?:[cm]?[jt]sx?|py|go|rb|php|rs)$/.test(file)) continue;
|
|
199
|
-
let text = "";
|
|
200
|
-
try { if (statSync(file).size > 512_000) continue; text = readFileSync(file, "utf8"); } catch { continue; }
|
|
201
|
-
for (const m of text.matchAll(ENV_READ)) if (liftable(m[1]) && !(m[1] in out)) out[m[1]] = lifted(m[1]);
|
|
202
|
-
}
|
|
206
|
+
for (const name of read) if (!(name in out)) out[name] = lifted(name);
|
|
203
207
|
return out;
|
|
204
208
|
}
|
|
205
209
|
|
package/package.json
CHANGED