@@ -64,12 +64,12 @@ export class ArchiveCommand {
6464 const validator = new Validator ( ) ;
6565 let hasValidationErrors = false ;
6666
67- // Validate proposal.md (non-blocking unless strict mode desired in future )
67+ // Validate proposal.md (非严格,仅供参考 )
6868 const changeFile = path . join ( changeDir , 'proposal.md' ) ;
6969 try {
7070 await fs . access ( changeFile ) ;
7171 const changeReport = await validator . validateChange ( changeFile ) ;
72- // Proposal validation is informative only (do not block archive)
72+ // Proposal 校验仅提供信息,不阻塞归档
7373 if ( ! changeReport . valid ) {
7474 console . log ( chalk . yellow ( `\nproposal.md中的提案警告(非阻塞):` ) ) ;
7575 for ( const issue of changeReport . issues ) {
@@ -92,10 +92,11 @@ export class ArchiveCommand {
9292 const candidatePath = path . join ( changeSpecsDir , c . name , 'spec.md' ) ;
9393 await fs . access ( candidatePath ) ;
9494 const content = await fs . readFile ( candidatePath , 'utf-8' ) ;
95- if ( / ^ # # \s + ( A D D E D | M O D I F I E D | R E M O V E D | R E N A M E D ) \s + R e q u i r e m e n t s / m. test ( content ) ) {
95+ if ( / ^ # # \s + ( 新 增 需 求 | 修 改 需 求 | 移 除 需 求 | 重 命 名 需 求 ) \s * $ / m. test ( content ) ) {
9696 hasDeltaSpecs = true ;
9797 break ;
9898 }
99+
99100 } catch { }
100101 }
101102 }
@@ -359,7 +360,7 @@ export class ArchiveCommand {
359360 const name = normalizeRequirementName ( add . name ) ;
360361 if ( addedNames . has ( name ) ) {
361362 throw new Error (
362- `${ specName } 验证失败 - ADDED 中的重复需求 ,标题为 "███ Requirement: ${ add . name } "`
363+ `${ specName } 验证失败 - 新增需求中存在重复 ,标题为 "### 需求: ${ add . name } "`
363364 ) ;
364365 }
365366 addedNames . add ( name ) ;
@@ -369,7 +370,7 @@ export class ArchiveCommand {
369370 const name = normalizeRequirementName ( mod . name ) ;
370371 if ( modifiedNames . has ( name ) ) {
371372 throw new Error (
372- `${ specName } 验证失败 - MODIFIED 中的重复需求 ,标题为 "### Requirement: ${ mod . name } "`
373+ `${ specName } 验证失败 - 修改需求中存在重复 ,标题为 "### 需求: ${ mod . name } "`
373374 ) ;
374375 }
375376 modifiedNames . add ( name ) ;
@@ -379,7 +380,7 @@ export class ArchiveCommand {
379380 const name = normalizeRequirementName ( rem ) ;
380381 if ( removedNamesSet . has ( name ) ) {
381382 throw new Error (
382- `${ specName } 验证失败 - REMOVED 中的重复需求 ,标题为 "### Requirement: ${ rem } "`
383+ `${ specName } 验证失败 - 移除需求中存在重复 ,标题为 "### 需求: ${ rem } "`
383384 ) ;
384385 }
385386 removedNamesSet . add ( name ) ;
@@ -391,12 +392,12 @@ export class ArchiveCommand {
391392 const toNorm = normalizeRequirementName ( to ) ;
392393 if ( renamedFromSet . has ( fromNorm ) ) {
393394 throw new Error (
394- `${ specName } 验证失败 - RENAMED 中的重复 FROM,标题为 "### Requirement: ${ from } "`
395+ `${ specName } 验证失败 - 重命名需求中 FROM 存在重复 ,标题为 "### 需求: ${ from } "`
395396 ) ;
396397 }
397398 if ( renamedToSet . has ( toNorm ) ) {
398399 throw new Error (
399- `${ specName } 验证失败 - RENAMED 中的重复 TO ,标题为 "### Requirement: ${ to } "`
400+ `${ specName } 验证失败 - 重命名需求中 TO 存在重复 ,标题为 "### 需求: ${ to } "`
400401 ) ;
401402 }
402403 renamedFromSet . add ( fromNorm ) ;
@@ -406,32 +407,32 @@ export class ArchiveCommand {
406407 // Pre-validate cross-section conflicts
407408 const conflicts : Array < { name : string ; a : string ; b : string } > = [ ] ;
408409 for ( const n of modifiedNames ) {
409- if ( removedNamesSet . has ( n ) ) conflicts . push ( { name : n , a : 'MODIFIED ' , b : 'REMOVED ' } ) ;
410- if ( addedNames . has ( n ) ) conflicts . push ( { name : n , a : 'MODIFIED ' , b : 'ADDED ' } ) ;
410+ if ( removedNamesSet . has ( n ) ) conflicts . push ( { name : n , a : '修改需求 ' , b : '移除需求 ' } ) ;
411+ if ( addedNames . has ( n ) ) conflicts . push ( { name : n , a : '修改需求 ' , b : '新增需求 ' } ) ;
411412 }
412413 for ( const n of addedNames ) {
413- if ( removedNamesSet . has ( n ) ) conflicts . push ( { name : n , a : 'ADDED ' , b : 'REMOVED ' } ) ;
414+ if ( removedNamesSet . has ( n ) ) conflicts . push ( { name : n , a : '新增需求 ' , b : '移除需求 ' } ) ;
414415 }
415416 // Renamed interplay: MODIFIED must reference the NEW header, not FROM
416417 for ( const { from, to } of plan . renamed ) {
417418 const fromNorm = normalizeRequirementName ( from ) ;
418419 const toNorm = normalizeRequirementName ( to ) ;
419420 if ( modifiedNames . has ( fromNorm ) ) {
420421 throw new Error (
421- `${ specName } 验证失败 - 当存在重命名时,MODIFIED 必须引用新标题 "### Requirement: ${ to } "`
422+ `${ specName } 验证失败 - 当存在重命名时,MODIFIED 必须引用新标题 "### 需求: ${ to } "`
422423 ) ;
423424 }
424425 // Detect ADDED colliding with a RENAMED TO
425426 if ( addedNames . has ( toNorm ) ) {
426427 throw new Error (
427- `${ specName } 验证失败 - RENAMED TO 标题与 ADDED 冲突 ,标题为 "### Requirement: ${ to } "`
428+ `${ specName } 验证失败 - 重命名需求的 TO 与新增需求冲突 ,标题为 "### 需求: ${ to } "`
428429 ) ;
429430 }
430431 }
431432 if ( conflicts . length > 0 ) {
432433 const c = conflicts [ 0 ] ;
433434 throw new Error (
434- `${ specName } 验证失败 - 需求出现在多个部分中(${ c . a } 和 ${ c . b } ),标题为 "### Requirement: ${ c . name } "`
435+ `${ specName } 验证失败 - 需求出现在多个部分中(${ c . a } 和 ${ c . b } ),标题为 "### 需求: ${ c . name } "`
435436 ) ;
436437 }
437438 const hasAnyDelta = ( plan . added . length + plan . modified . length + plan . removed . length + plan . renamed . length ) > 0 ;
@@ -470,17 +471,17 @@ export class ArchiveCommand {
470471 const to = normalizeRequirementName ( r . to ) ;
471472 if ( ! nameToBlock . has ( from ) ) {
472473 throw new Error (
473- `${ specName } RENAMED 失败 ,标题 "### Requirement: ${ r . from } " - 未找到源`
474+ `${ specName } 重命名失败 ,标题 "### 需求: ${ r . from } " - 未找到源`
474475 ) ;
475476 }
476477 if ( nameToBlock . has ( to ) ) {
477478 throw new Error (
478- `${ specName } RENAMED 失败 ,标题 "### Requirement: ${ r . to } " - 目标已经存在`
479+ `${ specName } 重命名失败 ,标题 "### 需求: ${ r . to } " - 目标已经存在`
479480 ) ;
480481 }
481482 const block = nameToBlock . get ( from ) ! ;
482483 // Preserve the original header style (Requirement vs 需求) if possible, but default to consistent new header
483- const newHeader = block . headerLine . includes ( '需求' ) ? `### 需求: ${ to } ` : `### Requirement: ${ to } ` ;
484+ const newHeader = block . headerLine . includes ( '需求' ) ? `### 需求: ${ to } ` : `### 需求: ${ to } ` ;
484485 const rawLines = block . raw . split ( '\n' ) ;
485486 rawLines [ 0 ] = newHeader ;
486487 const renamedBlock : RequirementBlock = {
@@ -497,7 +498,7 @@ export class ArchiveCommand {
497498 const key = normalizeRequirementName ( name ) ;
498499 if ( ! nameToBlock . has ( key ) ) {
499500 throw new Error (
500- `${ specName } REMOVED 失败 ,标题 "### Requirement: ${ name } " - 未找到`
501+ `${ specName } 移除失败 ,标题 "### 需求: ${ name } " - 未找到`
501502 ) ;
502503 }
503504 nameToBlock . delete ( key ) ;
@@ -508,26 +509,28 @@ export class ArchiveCommand {
508509 const key = normalizeRequirementName ( mod . name ) ;
509510 if ( ! nameToBlock . has ( key ) ) {
510511 throw new Error (
511- `${ specName } MODIFIED 失败 ,标题 "### Requirement: ${ mod . name } " - 未找到`
512+ `${ specName } 修改失败 ,标题 "### 需求: ${ mod . name } " - 未找到`
512513 ) ;
513514 }
514515 // Replace block with provided raw (ensure header line matches key)
515516 const REQUIREMENT_KEYWORD_PATTERN = '(?:Requirement|需求)' ;
516- const modHeaderMatch = mod . raw . split ( '\n' ) [ 0 ] . match ( new RegExp ( `^###\\s*${ REQUIREMENT_KEYWORD_PATTERN } :\\s*(.+)\\s*$` ) ) ;
517+ const REQUIREMENT_COLON_PATTERN = '[::]' ;
518+ const modHeaderMatch = mod . raw . split ( '\n' ) [ 0 ] . match ( new RegExp ( `^###\\s*${ REQUIREMENT_KEYWORD_PATTERN } ${ REQUIREMENT_COLON_PATTERN } \\s*(.+)\\s*$` ) ) ;
517519 if ( ! modHeaderMatch || normalizeRequirementName ( modHeaderMatch [ 1 ] ) !== key ) {
518520 throw new Error (
519- `${ specName } MODIFIED 失败 ,标题 "### Requirement: ${ mod . name } " - 内容中的标题不匹配`
521+ `${ specName } 修改失败 ,标题 "### 需求: ${ mod . name } " - 内容中的标题不匹配`
520522 ) ;
521523 }
522524 nameToBlock . set ( key , mod ) ;
525+
523526 }
524527
525528 // ADDED
526529 for ( const add of plan . added ) {
527530 const key = normalizeRequirementName ( add . name ) ;
528531 if ( nameToBlock . has ( key ) ) {
529532 throw new Error (
530- `${ specName } ADDED failed for header "### Requirement: ${ add . name } " - already exists `
533+ `${ specName } 新增失败,标题 "### 需求: ${ add . name } " - 已经存在 `
531534 ) ;
532535 }
533536 nameToBlock . set ( key , add ) ;
@@ -598,7 +601,7 @@ export class ArchiveCommand {
598601
599602 private buildSpecSkeleton ( specFolderName : string , changeName : string ) : string {
600603 const titleBase = specFolderName ;
601- return `# ${ titleBase } Specification\n\n## Purpose\nTBD - created by archiving change ${ changeName } . Update Purpose after archive.\n\n## Requirements \n` ;
604+ return `# ${ titleBase } Specification\n\n## Purpose\nTBD - created by archiving change ${ changeName } . Update Purpose after archive.\n\n## 需求 \n` ;
602605 }
603606
604607 private getArchiveDate ( ) : string {
0 commit comments