@@ -65,6 +65,7 @@ const {
6565 classifyPathsForArtifacts,
6666 isStrictProtectedPath,
6767 simpleTaskForbidsPath,
68+ classifyImplementStartGate,
6869 ERROR_CODES : PROCESS_ENFORCEMENT_CODES
6970} = require ( '../../scripts/lib/process-enforcement.js' )
7071
@@ -1347,23 +1348,28 @@ async function main() {
13471348 }
13481349 }
13491350 }
1350- // P0.5 WorkspaceSkillAutoMatch: message → W skill description/name → inject body
1351- let workspaceSkillAutoMatchMsg = ''
1351+ // P0-1 WorkspaceSkillIntent (default) or legacy AutoMatch via DEVCODEX_SKILL_MATCH_MODE
1352+ let workspaceSkillRouteMsg = ''
13521353 try {
13531354 const {
1354- matchWorkspaceSkills,
1355- toStateRecord
1356- } = require ( './workspace-skill-auto-match.cjs' )
1357- const autoMatch = matchWorkspaceSkills ( prompt , { cwd : CONTEXT_ROOT } )
1358- if ( autoMatch . matched ) {
1359- state . workspaceSkillAutoMatch = toStateRecord ( autoMatch )
1360- workspaceSkillAutoMatchMsg = autoMatch . injectionText
1361- state . lastReason = `workspace-skill-auto-match:${ autoMatch . skillId } `
1355+ routeWorkspaceSkillIntent,
1356+ toIntentStateRecord,
1357+ getSkillMatchMode
1358+ } = require ( './workspace-skill-intent.cjs' )
1359+ const route = routeWorkspaceSkillIntent ( prompt , { cwd : CONTEXT_ROOT } )
1360+ const mode = getSkillMatchMode ( )
1361+ if ( route . injectionText ) {
1362+ state . workspaceSkillAutoMatch = toIntentStateRecord ( route )
1363+ // keep legacy field name for Stop path compatibility
1364+ workspaceSkillRouteMsg = route . injectionText
1365+ state . lastReason = route . matched
1366+ ? `workspace-skill-intent:${ route . skillId } `
1367+ : ( mode === 'legacy-token' ? 'workspace-skill-catalog-only' : 'workspace-skill-intent-catalog' )
13621368 } else {
13631369 state . workspaceSkillAutoMatch = null
13641370 }
13651371 } catch {
1366- /* auto-match optional during partial deploys */
1372+ /* intent/ auto-match optional during partial deploys */
13671373 state . workspaceSkillAutoMatch = null
13681374 }
13691375
@@ -1378,7 +1384,7 @@ async function main() {
13781384 : '' ,
13791385 buildGovernanceIntakeContextMessage ( state . governanceIntake ) ,
13801386 formatTurnRecoveryMessage ( livenessObservation . recoveryCard ) ,
1381- workspaceSkillAutoMatchMsg
1387+ workspaceSkillRouteMsg
13821388 ] . filter ( Boolean ) . join ( '\n\n' )
13831389 ) )
13841390 return
@@ -1502,7 +1508,8 @@ async function main() {
15021508 }
15031509 }
15041510
1505- // 2.7 E: plan without progress forbids control-plane source mutation (delivery honesty H1)
1511+ // 2.7 E: implement-start gate — control-plane mutation needs 04+05+复审清单 triad
1512+ // (P0-1 / ESC-01: yes-implement must not skip CP3 materialization)
15061513 if (
15071514 isSourceCodeMutation ( payload , platform , state ) &&
15081515 ! ( state . simpleTaskFastPath === true || state . taskPathMode === 'simple' )
@@ -1514,17 +1521,22 @@ async function main() {
15141521 ? findIncompleteTaskForPaths ( payload , state )
15151522 : null
15161523 const bound = task || ( typeof findIncompleteTask === 'function' ? findIncompleteTask ( state ) : null )
1517- if ( bound && bound . fullPath && hasTaskArtifact ( bound , 'CP3' ) ) {
1518- const progressPath = path . join ( bound . fullPath , '05-实施进度.md' )
1519- if ( ! fs . existsSync ( progressPath ) ) {
1520- state . lastReason = PROCESS_ENFORCEMENT_CODES . PROGRESS_ARTIFACT_MISSING || 'progress-artifact-missing'
1524+ if ( bound && bound . fullPath ) {
1525+ const startGate = classifyImplementStartGate ( {
1526+ controlPlaneMutation : true ,
1527+ taskRoot : bound . fullPath ,
1528+ fs
1529+ } )
1530+ if ( ! startGate . ok ) {
1531+ const code = startGate . code || PROCESS_ENFORCEMENT_CODES . IMPLEMENT_START_WITHOUT_PROCESS
1532+ state . lastReason = code
15211533 saveState ( state )
15221534 writeStdout ( buildInterceptionOutput (
15231535 state , platform , eventName , INTERCEPTION_ACTION . REQUIRE_COMPLETION ,
1524- 'progress-artifact-missing' ,
1525- 'Progress artifact required' ,
1526- `控制面 mutation 需要任务目录 05-实施进度.md(已有 04 实施计划 ):${ bound . name || bound . fullPath } ` ,
1527- 'Create 05-实施进度.md under the active requirement before mutating control-plane sources .'
1536+ code ,
1537+ 'Implement process triad required' ,
1538+ `控制面 mutation 前须在任务目录齐备 04-实施计划.md + 05-实施进度.md + 复审清单(缺: ${ ( startGate . missing || [ ] ) . join ( ', ' ) } ):${ bound . name || bound . fullPath } ` ,
1539+ 'Create 04-实施计划.md, 05-实施进度.md, and 03-复审清单*.md under the active requirement before mutating hooks/skills/instructions .'
15281540 ) )
15291541 return
15301542 }
@@ -1641,19 +1653,17 @@ async function main() {
16411653 if ( eventName === 'PreCompact' ) markContextAcquisitionStale ( state , 'compact' )
16421654 captureFinalPayloadSample ( payload , eventName , state )
16431655
1644- // P0.5: if UserPromptSubmit matched a W skill and reply ignored it, Stop-force one retry.
1645- // Inject-capable hosts already got additionalContext; Grok passive UPS needs Stop block.
1656+ // P0-1: if UPS matched a W skill via intent and reply ignored it, Stop-force one retry.
16461657 if ( eventName === 'Stop' && state . workspaceSkillAutoMatch && state . workspaceSkillAutoMatch . skillId ) {
16471658 try {
16481659 const {
1649- isSkillReplySatisfied ,
1650- buildStopForceReason ,
1651- matchWorkspaceSkills ,
1652- extractLastAssistantMessage
1653- } = require ( './workspace-skill-auto-match .cjs' )
1660+ isIntentReplySatisfied ,
1661+ buildIntentStopForceReason ,
1662+ extractLastAssistantMessage ,
1663+ routeWorkspaceSkillIntent
1664+ } = require ( './workspace-skill-intent .cjs' )
16541665 const lastAssistant = extractLastAssistantMessage ( payload )
16551666 const stopHookActive = payload . stopHookActive === true || payload . stop_hook_active === true
1656- // Rehydrate content for satisfaction check when state only kept meta
16571667 let matchForCheck = state . workspaceSkillAutoMatch
16581668 if ( ! matchForCheck . content && matchForCheck . injectionText ) {
16591669 matchForCheck = {
@@ -1663,39 +1673,44 @@ async function main() {
16631673 content : matchForCheck . injectionText ,
16641674 injectionText : matchForCheck . injectionText
16651675 }
1666- } else if ( ! matchForCheck . injectionText ) {
1667- const rematch = matchWorkspaceSkills ( matchForCheck . skillId , { cwd : CONTEXT_ROOT } )
1676+ } else if ( ! matchForCheck . injectionText && matchForCheck . skillId ) {
1677+ const rematch = routeWorkspaceSkillIntent ( matchForCheck . skillId , { cwd : CONTEXT_ROOT } )
16681678 if ( rematch . matched ) {
1669- matchForCheck = { ...matchForCheck , ...rematch , matched : true }
1679+ matchForCheck = {
1680+ matched : true ,
1681+ skillId : rematch . skillId ,
1682+ mustReply : rematch . mustReply ,
1683+ content : rematch . content ,
1684+ injectionText : rematch . injectionText
1685+ }
16701686 } else {
16711687 matchForCheck = { ...matchForCheck , matched : true }
16721688 }
16731689 } else {
16741690 matchForCheck = { ...matchForCheck , matched : true }
16751691 }
16761692
1677- const satisfied = isSkillReplySatisfied ( lastAssistant , matchForCheck )
1693+ const satisfied = isIntentReplySatisfied ( lastAssistant , matchForCheck )
16781694 if ( satisfied ) {
16791695 state . workspaceSkillAutoMatch = {
16801696 ...state . workspaceSkillAutoMatch ,
16811697 satisfied : true
16821698 }
16831699 } else {
16841700 const enforceCount = Number ( state . workspaceSkillAutoMatch . enforceCount || 0 )
1685- // At most 2 force rounds; honor platform soft cap via stopHookActive after first force
16861701 if ( enforceCount < 2 && ! ( stopHookActive && enforceCount >= 1 ) ) {
1687- const reason = buildStopForceReason ( matchForCheck )
1702+ const reason = buildIntentStopForceReason ( matchForCheck )
16881703 state . workspaceSkillAutoMatch = {
16891704 ...state . workspaceSkillAutoMatch ,
16901705 enforceCount : enforceCount + 1 ,
16911706 lastEnforceAt : new Date ( ) . toISOString ( )
16921707 }
1693- state . lastReason = `workspace-skill-auto-match -stop:${ state . workspaceSkillAutoMatch . skillId } `
1708+ state . lastReason = `workspace-skill-intent -stop:${ state . workspaceSkillAutoMatch . skillId } `
16941709 const output = decorateHookOutput (
1695- blockOutput ( platform , 'Stop' , 'workspace-skill-auto-match ' , reason ) ,
1710+ blockOutput ( platform , 'Stop' , 'workspace-skill-intent ' , reason ) ,
16961711 {
16971712 devcodexAction : INTERCEPTION_ACTION . FORBID ,
1698- devcodexCode : 'workspace-skill-auto-match ' ,
1713+ devcodexCode : 'workspace-skill-intent ' ,
16991714 devcodexEffective : true ,
17001715 devcodexNextStep : 'Reply following the matched workspace skill body.'
17011716 }
0 commit comments