The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(ci): preserve token boundaries when compacting rust comments
Steven Enamakel1d948f30e399
diff --git a/scripts/ci/check-crate-chain.mjs b/scripts/ci/check-crate-chain.mjsindex c5cde96963..cc394e0e17 100644--- a/scripts/ci/check-crate-chain.mjs+++ b/scripts/ci/check-crate-chain.mjs@@ -130,17 +130,39 @@ export const HOST_RPC_INTERNAL_PATTERNS = [* Optional literal preservation and code-whitespace compaction support type* signatures; default masking is unchanged. Compaction leaves literal contents intact.*/-export function stripRustComments(text, { preserveLiterals = false, compact = false } = {}) {+export function stripRustComments(text, { preserveLiterals = false, compact = false, preserveTokenBoundaries = false } = {}) {let out = '';let i = 0;- const blank = chunk => compact ? '' : chunk.replace(/[^\n]/g, ' ');+ let pendingBoundary = false;+ const word = char => /[\p{ID_Continue}]/u.test(char);+ const joins = new Set(['::', '->', '=>', '==', '!=', '<=', '>=', '&&', '||',+ '<<', '>>', '+=', '-=', '*=', '/=', '%=', '&=', '|=', '^=', '..', '/*', '//']);+ const append = chunk => {+ if (!chunk) return;+ const left = [...out].at(-1) ?? '';+ const right = [...chunk][0];+ if (compact && preserveTokenBoundaries && pendingBoundary && left &&+ ((word(left) && word(right)) ||+ (word(left) && ['"', "'", '#'].includes(right)) ||+ (['"', "'", '#'].includes(left) && word(right)) ||+ joins.has(left + right))) out += ' ';+ out += chunk;+ pendingBoundary = false;+ };+ const blank = chunk => {+ if (compact) {+ pendingBoundary = true;+ return '';+ }+ return chunk.replace(/[^\n]/g, ' ');+ };while (i < text.length) {const rest = text.slice(i);let m;if (rest.startsWith('//')) {const end = text.indexOf('\n', i);const stop = end === -1 ? text.length : end;- out += blank(text.slice(i, stop));+ append(blank(text.slice(i, stop)));i = stop;} else if (rest.startsWith('/*')) {let depth = 0;@@ -155,24 +177,25 @@ export function stripRustComments(text, { preserveLiterals = false, compact = faif (depth === 0) break;} else j++;}- out += blank(text.slice(i, j));+ append(blank(text.slice(i, j)));i = j;} else if ((m = /^b?r(#*)"/.exec(rest))) {const close = '"' + m[1];const end = text.indexOf(close, i + m[0].length);const stop = end === -1 ? text.length : end + close.length;- out += preserveLiterals ? text.slice(i, stop) : blank(text.slice(i, stop));+ append(preserveLiterals ? text.slice(i, stop) : blank(text.slice(i, stop)));i = stop;} else if ((m = /^b?'(?:\\(?:x[0-9a-fA-F]{2}|u\{[0-9a-fA-F]+\}|.)|[^\\'])'/.exec(rest))) {- out += preserveLiterals ? m[0] : blank(m[0]);+ append(preserveLiterals ? m[0] : blank(m[0]));i += m[0].length;} else if (rest.startsWith('"') || rest.startsWith('b"')) {let j = i + (rest.startsWith('b') ? 2 : 1);while (j < text.length && text[j] !== '"') j += text[j] === '\\' ? 2 : 1;- out += preserveLiterals ? text.slice(i, j + 1) : blank(text.slice(i, j + 1));+ append(preserveLiterals ? text.slice(i, j + 1) : blank(text.slice(i, j + 1)));i = j + 1;} else {- if (!compact || !/\s/.test(text[i])) out += text[i];+ if (compact && /\s/.test(text[i])) pendingBoundary = true;+ else append(text[i]);i++;}}diff --git a/scripts/ci/check-process-statics.mjs b/scripts/ci/check-process-statics.mjsindex 85f624eebe..616106cc61 100644--- a/scripts/ci/check-process-statics.mjs+++ b/scripts/ci/check-process-statics.mjs@@ -84,6 +84,7 @@ export function declarations(text, file) {const type = stripRustComments(text.slice(start, end), {preserveLiterals: true,compact: true,+ preserveTokenBoundaries: true,});if (!type) throw new Error(`${file}: static ${match[2]} has no type`);found.push({