@@ -145,10 +145,10 @@ function text(value, limit = 320) {
145145 return String ( value ?? "" ) . replace ( / [ \u0000 - \u001f \u007f ] / gu, " " ) . replace ( / \s + / gu, " " ) . trim ( ) . slice ( 0 , limit ) ;
146146}
147147
148- function compactError ( error , stage ) {
148+ function compactError ( error , stage , context ) {
149149 return {
150150 code : `${ stage . toUpperCase ( ) . replace ( / [ ^ A - Z 0 - 9 ] + / gu, "_" ) } _UNAVAILABLE` ,
151- message : text ( error instanceof Error ? error . message : error ) ,
151+ message : boundedText ( error instanceof Error ? error . message : error , context ) ,
152152 } ;
153153}
154154
@@ -169,6 +169,7 @@ function pathLocator(filePath, context) {
169169 if ( filePath === "<path>" || filePath . startsWith ( "<workspace>" ) || filePath . startsWith ( "<git-root>" ) || filePath . startsWith ( "~/" ) ) {
170170 return filePath . split ( / [ \\ / ] / u) . includes ( ".." ) ? "<path>" : filePath ;
171171 }
172+ if ( process . platform !== "win32" && / ^ (?: [ A - Z a - z ] : [ \\ / ] | \\ \\ ) / u. test ( filePath ) ) return "<path>" ;
172173 const absolute = path . resolve ( context . workspace , filePath ) ;
173174 const resolved = canonicalIfPresent ( absolute ) ;
174175 const workspace = canonicalIfPresent ( context . workspace ) ;
@@ -214,6 +215,10 @@ function boundedText(value, context, knownPath) {
214215 const locator = knownPath ? pathLocator ( knownPath , context ) ?? "<path>" : undefined ;
215216 if ( knownPath ) result = result . replaceAll ( String ( knownPath ) , marker ) ;
216217 return result
218+ . replace (
219+ / ( [ " ' ] ) ( (?: [ A - Z a - z ] : [ \\ / ] | \\ \\ | \/ ) [ ^ " ' ] + ) \1/ gu,
220+ ( _candidate , quote , candidate ) => `${ quote } ${ pathLocator ( candidate , context ) ?? "<path>" } ${ quote } ` ,
221+ )
217222 . replace ( / \\ \\ [ ^ \s , ; ) ' " \] ] + \\ [ ^ \s , ; ) ' " \] ] + / gu, ( candidate ) => pathLocator ( candidate , context ) ?? "<path>" )
218223 . replace ( / [ A - Z a - z ] : [ \\ / ] [ ^ \s , ; ) ' " \] ] + / gu, ( candidate ) => pathLocator ( candidate , context ) ?? "<path>" )
219224 . replace ( / \/ (?: [ ^ \s , ; ) ' " \] ] + \/ ? ) + / gu, ( candidate ) => pathLocator ( candidate , context ) ?? "<path>" )
@@ -400,8 +405,8 @@ function compactIntegrity(integrity, context) {
400405 } ;
401406}
402407
403- function unavailable ( error , stage ) {
404- return { status : "unavailable" , error : compactError ( error , stage ) } ;
408+ function unavailable ( error , stage , context ) {
409+ return { status : "unavailable" , error : compactError ( error , stage , context ) } ;
405410}
406411
407412function available ( data ) {
@@ -547,6 +552,14 @@ export async function collectAssetBaseline(options = {}, dependencies = {}) {
547552 includeGlobalHooks : includeUserHome ,
548553 includeMemories,
549554 } ;
555+ const pathContext = {
556+ workspace,
557+ workspaceInput : normalizeWorkspace ( options . workspace ?? "." ) ,
558+ gitRoot : topology ?. gitRoot ,
559+ gitRootInput : options . topology ?. gitRoot ,
560+ home : dependencies . homeDirectory ?. ( ) ?? os . homedir ( ) ,
561+ includeUserHome,
562+ } ;
550563 const collectRawInventory = dependencies . collectRawInventory ?? collectAgentCustomizeInventory ;
551564 let rawInventory ;
552565 try {
@@ -566,7 +579,7 @@ export async function collectAssetBaseline(options = {}, dependencies = {}) {
566579 rawInventory = mergeInheritedInventories ( rawInventory , inheritedInventories , topology ) ;
567580 }
568581 } catch ( error ) {
569- const failed = unavailable ( error , "inventory" ) ;
582+ const failed = unavailable ( error , "inventory" , pathContext ) ;
570583 return {
571584 kind : ASSET_BASELINE_KIND ,
572585 schemaVersion : ASSET_BASELINE_SCHEMA_VERSION ,
@@ -580,28 +593,20 @@ export async function collectAssetBaseline(options = {}, dependencies = {}) {
580593 const lintRunner = dependencies . runLint ?? runAgentLint ;
581594 const inventoryRunner = dependencies . collectPublicInventory
582595 ?? ( provider === "qoder" ? collectQoderInventory : collectProviderInventory ) ;
583- const pathContext = {
584- workspace,
585- workspaceInput : normalizeWorkspace ( options . workspace ?? "." ) ,
586- gitRoot : topology ?. gitRoot ,
587- gitRootInput : options . topology ?. gitRoot ,
588- home : dependencies . homeDirectory ?. ( ) ?? os . homedir ( ) ,
589- includeUserHome,
590- } ;
591596 const [ lintResult , inventoryResult ] = await Promise . allSettled ( [
592597 lintRunner ( { ...common , profile : "agent-assets-review" , inventory : rawInventory } ) ,
593598 inventoryRunner ( { ...common , inventory : rawInventory } ) ,
594599 ] ) ;
595600 const lintEnvelope = lintResult . status === "fulfilled"
596601 ? available ( compactLint ( lintResult . value , pathContext ) )
597- : unavailable ( lintResult . reason , "lint" ) ;
602+ : unavailable ( lintResult . reason , "lint" , pathContext ) ;
598603 const inventoryEnvelope = inventoryResult . status === "fulfilled"
599604 ? available ( await compactInventory ( inventoryResult . value , workspace , {
600605 stat : dependencies . stat ,
601606 now : dependencies . now ,
602607 pathContext,
603608 } ) )
604- : unavailable ( inventoryResult . reason , "inventory" ) ;
609+ : unavailable ( inventoryResult . reason , "inventory" , pathContext ) ;
605610 let integrityEnvelope ;
606611 if ( inventoryResult . status === "fulfilled" ) {
607612 try {
@@ -611,10 +616,10 @@ export async function collectAssetBaseline(options = {}, dependencies = {}) {
611616 pathContext ,
612617 ) ) ;
613618 } catch ( error ) {
614- integrityEnvelope = unavailable ( error , "integrity" ) ;
619+ integrityEnvelope = unavailable ( error , "integrity" , pathContext ) ;
615620 }
616621 } else {
617- integrityEnvelope = unavailable ( new Error ( "The shared public inventory is unavailable." ) , "integrity" ) ;
622+ integrityEnvelope = unavailable ( new Error ( "The shared public inventory is unavailable." ) , "integrity" , pathContext ) ;
618623 }
619624 const envelopes = { lint : lintEnvelope , inventory : inventoryEnvelope , integrity : integrityEnvelope } ;
620625 const availableCount = Object . values ( envelopes ) . filter ( ( envelope ) => envelope . status === "available" ) . length ;
0 commit comments