@@ -15,6 +15,7 @@ function buildLifecycleProjectTargetUtils({
1515 collectProjectPayloadStrings,
1616 normalizeText,
1717 readProfileMode,
18+ readProjectProfileConfig,
1819 isStrictEnforcement
1920} ) {
2021 function listWorkspaceProjects ( ) {
@@ -223,8 +224,44 @@ function buildLifecycleProjectTargetUtils({
223224 return false
224225 }
225226
226- function hasAutoAuthorizationPrompt ( prompt ) {
227- if ( / @ d e v c o d e x - a u t o \b / i. test ( prompt ) ) return true
227+ function isValidAutoAlias ( alias ) {
228+ if ( typeof alias !== 'string' ) return false
229+ const normalized = alias . trim ( )
230+ if ( normalized . length > 65 ) return false
231+ if ( ! / ^ @ [ A - Z a - z ] [ A - Z a - z 0 - 9 _ - ] * $ / . test ( normalized ) ) return false
232+ const lower = normalized . toLowerCase ( )
233+ return ! [ '@devcodex' , '@devcodex-auto' , '@auto' ] . includes ( lower )
234+ }
235+
236+ function hasMentionToken ( prompt , alias ) {
237+ const escaped = escapeRegExp ( alias )
238+ return new RegExp ( `(^|\\s)${ escaped } (?=$|[\\s,.;:!?,。;:!?])` , 'i' ) . test ( prompt )
239+ }
240+
241+ function getConfiguredAutoAliases ( state , target ) {
242+ if ( typeof readProjectProfileConfig !== 'function' ) return [ ]
243+ const activeProject = target ?. activeProject || state ?. activeProject || ''
244+ const cfg = readProjectProfileConfig ( state || { } , activeProject )
245+ const aliases = cfg ?. extensions ?. devcodex ?. autoAliases
246+ if ( ! Array . isArray ( aliases ) ) return [ ]
247+ const seen = new Set ( )
248+ const validAliases = [ ]
249+ for ( const alias of aliases ) {
250+ if ( ! isValidAutoAlias ( alias ) ) continue
251+ const normalized = alias . trim ( )
252+ const key = normalized . toLowerCase ( )
253+ if ( seen . has ( key ) ) continue
254+ seen . add ( key )
255+ validAliases . push ( normalized )
256+ }
257+ return validAliases
258+ }
259+
260+ function hasAutoAuthorizationPrompt ( prompt , state , target ) {
261+ if ( hasMentionToken ( String ( prompt || '' ) , '@devcodex-auto' ) ) return true
262+ for ( const alias of getConfiguredAutoAliases ( state , target ) ) {
263+ if ( hasMentionToken ( String ( prompt || '' ) , alias ) ) return true
264+ }
228265 const normalized = String ( prompt || '' ) . replace ( / \s + / g, ' ' ) . trim ( )
229266 const naturalLanguageAutoPatterns = [
230267 / (?: 进 入 | 启 用 | 开 启 | 使 用 | 切 换 到 ) \s * (?: a u t o | 自 动 | 全 自 动 ) \s * (?: 模 式 | 执 行 | 推 进 | 处 理 ) ? / i,
@@ -234,9 +271,9 @@ function buildLifecycleProjectTargetUtils({
234271 return naturalLanguageAutoPatterns . some ( pattern => pattern . test ( normalized ) )
235272 }
236273
237- function detectExecutionMode ( payload ) {
274+ function detectExecutionMode ( payload , state , target ) {
238275 const prompt = extractUserPrompt ( payload )
239- return hasAutoAuthorizationPrompt ( prompt ) ? EXECUTION_MODE . AUTO : EXECUTION_MODE . CONFIRM
276+ return hasAutoAuthorizationPrompt ( prompt , state , target ) ? EXECUTION_MODE . AUTO : EXECUTION_MODE . CONFIRM
240277 }
241278
242279 function buildMultiProjectBlockMessage ( ) {
0 commit comments