Skip to content

Commit 19b22da

Browse files
committed
feat: skillsDeployMode hidden runtime and substantive PR-1 evidence
Default deploy active skills to ~/.agents/devcodex/skills, prune managed ids from host scan roots, and switch resolveGlobalSkillsRoot by mode. Strengthen pr1EvidenceOk to require independent substantive 03 reviews. Add tests, CLI --mode, npm lifecycle pass-through, and honest README/host projection notes.
1 parent 2d7c371 commit 19b22da

18 files changed

Lines changed: 588 additions & 65 deletions

‎README.md‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ GlobalOnlyHostConfigModeV1 与 GlobalOnlyWorkspaceCleanModeV1 将宿主配置、
180180
├── .gemini/ ← Gemini 用户级 instructions/settings/runtime
181181
├── .grok/ ← Grok 用户级 plugin/config/runtime
182182
└── .agents/
183-
├── devcodex/instructions.full.md ← 用户级完整回退规范
184-
└── skills/ ← 共享用户级 Skills
183+
├── devcodex/
184+
│ ├── instructions.full.md ← 用户级完整回退规范
185+
│ └── skills/ ← G_RUNTIME:默认 hidden 模式下的全局 Skill 正文(非宿主 L1 菜单主料)
186+
└── skills/ ← 扫描根(legacy 模式全量;hidden 默认不刷 80+)
185187
186188
<workspace>/
187189
└── .devcodex/ ← workspace-namespace 的 Profile、记忆、报告与运行态
@@ -190,7 +192,9 @@ GlobalOnlyHostConfigModeV1 与 GlobalOnlyWorkspaceCleanModeV1 将宿主配置、
190192
└── skills/ ← 可选自定义 Skill(W;非 reserved 时 W>G,见 skill-resolution)
191193
```
192194

193-
自定义 Skill 只写 `<workspace>/.devcodex/workspace/skills/<id>/SKILL.md`(一次配置,经 DevCodex 五宿主共用);**不要**改 `~/.agents/skills` 或五宿主 home 树作扩展。强制核 skill(如 `compliance`/`cp-gate`)禁止 W 覆盖。
195+
默认 **`skillsDeployMode=hidden`**:全局 Skill 部署到 `~/.agents/devcodex/skills`,经 `skill resolve` / Hook 按需加载,避免 IDE skill 列表刷屏;`devcodex global-adapters apply --mode=legacy` 可恢复扫描根全量树。Hooks 配置与磁盘路径仍可见(隐蔽 ≠ 无文件)。Grok 插件列表可能仍显示 residual。
196+
197+
自定义 Skill 只写 `<workspace>/.devcodex/workspace/skills/<id>/SKILL.md`(一次配置,经 DevCodex 五宿主共用);**不要**改用户级扫描根或五宿主 home 树作扩展。强制核 skill(如 `compliance`/`cp-gate`)禁止 W 覆盖。
194198

195199
**工作区 Skill 用户可见闭环(W)**
196200

‎changelogs/unreleased.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
> **当前**: v1.15.3 已归档到 `changelogs/releases/v1.15.3.md`;本文件仅保留历史锚点索引与镜像供 validate 探针消费。发版后新实现再写入下方「当前未发布」。
55
66
## 当前未发布实现候选
7+
- **SkillsDeployModeV1(隐蔽运行时 + PR-1 防假绿)**:默认 `skillsDeployMode=hidden` 将 active skills 部署到 `~/.agents/devcodex/skills`(G_RUNTIME),停写/目录 prune `~/.agents/skills`、`~/.claude/skills`、`~/.copilot/skills` 中的包 managed id;`resolveGlobalSkillsRoot` 随 mode 切换(ENV `DEVCODEX_GLOBAL_SKILLS_ROOT` 仍最高优先);`global-adapters apply --mode=hidden|legacy` 与 npm lifecycle 透传;receipt 记录 mode。强化 `pr1EvidenceOk`:有 `02` 须独立实质 `03` 复审(长度+blocker=0+实质章节),拒绝 thin open-blocker / sessions-only;改写 stop-gate 负向探针。需求:`全局Skill与插件隐蔽运行时`。
78
- **Runtime 白名单闭包防复发**:新增 `scripts/lib/runtime-dependency-closure.js` 作为统一 runtime require 闭包 Owner;`MCP_RUNTIME_DEPS` / `PROJECT_RUNTIME_SCRIPT_DEPS`(兼容 `CLAUDE_MCP_RUNTIME_SCRIPT_DEPS`)改为派生;Codex project hook 复制到 `.codex/scripts/lib`;`test:mcp-runtime-closure` 覆盖 allowlist-only layout/MCP smoke/负向/packlist;validation 节点 `mcp-runtime-closure` 接入 fast/full/profile-deploy/package-release。需求:`bugs/runtime白名单闭包防复发修复`。
89
- **P0-1 工作区意图 + DEVCODEX.md + ImplementStartGate + e2e(Batch1)**:入口 `.devcodex/workspace/DEVCODEX.md`;`workspace-skill-intent` catalog/意图/lifecycle;控制面 mutation 前 04+05+复审清单门闩(`IMPLEMENT_START_WITHOUT_PROCESS`);全局 skill `workspace-skill-author`;`npm run test:workspace-skill-intent` / `test:workspace-skill-intent-e2e`(E2E-A~J+K)并入 `test:skill-resolve`。**无 e2e 不算 Batch1 完成**。需求:`开源发布前用户面与文档边界收口`。
910
- **P0-1 Batch2**:`init`/`ensureRuntimeDirs` 写入 DEVCODEX.md 模板(不覆盖);CLI `devcodex skill intent <prompt> [--json]`;help 文案同步。

‎hooks/_runtime/lifecycle-stop-gate.cjs‎

Lines changed: 77 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,30 +103,88 @@ function findActiveTaskRoot (state) {
103103
}
104104
}
105105

106+
/** Minimum UTF-8 bytes for a substantive PR-1 review body (blocks two-line green). */
107+
const PR1_MIN_BODY_BYTES = 1200
108+
106109
/**
107-
* F-04: PR-1 pass evidence must be strong (zero-blocker / explicit pass row).
108-
* Rejects loose "某某通过" alone.
110+
* F-04 / SkillsDeployMode PR-1 strengthen:
111+
* When 02-技术方案 exists, require an independent 03 review file with
112+
* pass signal AND substance (mapping/contract/CodeTruth/blocker/root-cause).
113+
* Rejects: open-blocker-only, table-only PR-1 ✅, sessions-only with 02 present.
109114
*/
110-
function pr1EvidenceOk (taskRoot) {
111-
if (!taskRoot || !fs.existsSync(taskRoot)) return false
115+
function findPr1ReviewFileName (taskRoot) {
116+
if (!taskRoot || !fs.existsSync(taskRoot)) return null
112117
try {
113118
const files = fs.readdirSync(taskRoot)
114-
const review = files.find(f =>
119+
return files.find(f =>
115120
/^03-.*方案复审/i.test(f) ||
121+
/^03-.*方案自审/i.test(f) ||
116122
/^04-.*方案复审/i.test(f) ||
117123
/方案复审/i.test(f)
118-
)
124+
) || null
125+
} catch {
126+
return null
127+
}
128+
}
129+
130+
function controlPlaneHint (taskRoot) {
131+
try {
132+
const tech = path.join(taskRoot, '02-技术方案.md')
133+
if (!fs.existsSync(tech)) return false
134+
const text = fs.readFileSync(tech, 'utf8')
135+
return /hook|lifecycle|skillsDeploy|applyGlobalHost|control.?plane|控制面|global-host-config|pr1EvidenceOk/i.test(text)
136+
} catch {
137+
return false
138+
}
139+
}
140+
141+
function countPr1Substance (body) {
142+
let substance = 0
143+
if (/BlockerSnapshot|阻断项|blockerId/i.test(body)) substance += 1
144+
if (/验收映射|需求[^\n]{0,12}映射|产品事实源|§0\.5/i.test(body)) substance += 1
145+
if (/契约矩阵|ContractMatrix|Current\s*→\s*Target|runtimeOwners/i.test(body)) substance += 1
146+
if (/CodeTruth|currentBehavior|negativeProbe|repoPath/i.test(body)) substance += 1
147+
if (/根因|Root\s*cause|假绿|pr1EvidenceOk/i.test(body)) substance += 1
148+
return substance
149+
}
150+
151+
function pr1ReviewBodyOk (body, taskRoot) {
152+
const text = String(body || '')
153+
if (!/PR-1/i.test(text)) return false
154+
if (/PR-1[^\n]{0,40}(?:不通过|阻断|fail|❌)/i.test(text)) return false
155+
if (Buffer.byteLength(text, 'utf8') < PR1_MIN_BODY_BYTES) return false
156+
157+
const hasPass =
158+
/open\s*blocker\s*=\s*0|zero\s*blocker|blockers?\s*=\s*0/i.test(text) ||
159+
/PR-1[^\n]{0,40}(?:✅\s*通过|通过\s*✅|=\s*pass|:\s*pass)/i.test(text) ||
160+
/阶段一[^\n]{0,30}PR-1[^\n]{0,30}✅/i.test(text)
161+
// Bare "| PR-1 | ✅ |" table rows alone are NOT a pass signal (thin-green).
162+
if (!hasPass) return false
163+
164+
const substance = countPr1Substance(text)
165+
const minSubstance = controlPlaneHint(taskRoot) ? 2 : 2
166+
return substance >= minSubstance
167+
}
168+
169+
function pr1EvidenceOk (taskRoot) {
170+
if (!taskRoot || !fs.existsSync(taskRoot)) return false
171+
try {
172+
const hasTech = hasTechDesign(taskRoot)
173+
const review = findPr1ReviewFileName(taskRoot)
174+
175+
// With a tech design, sessions-only is never enough — require independent 03 review.
176+
if (hasTech) {
177+
if (!review) return false
178+
const body = fs.readFileSync(path.join(taskRoot, review), 'utf8')
179+
return pr1ReviewBodyOk(body, taskRoot)
180+
}
181+
119182
if (review) {
120183
const body = fs.readFileSync(path.join(taskRoot, review), 'utf8')
121-
if (!/PR-1/i.test(body)) return false
122-
// Strong pass signals only
123-
if (/open\s*blocker\s*=\s*0|zero\s*blocker|blockers?\s*=\s*0/i.test(body)) return true
124-
if (/PR-1[^\n]{0,40}(?:✅\s*通过|通过\s*✅|=\s*pass|:\s*pass)/i.test(body)) return true
125-
if (/阶段一[^\n]{0,30}PR-1[^\n]{0,30}✅/i.test(body)) return true
126-
if (/PR-1\s*[|::]\s*✅/i.test(body)) return true
127-
// Explicit fail
128-
if (/PR-1[^\n]{0,40}(?:不通过|阻断|fail|❌)/i.test(body)) return false
184+
return pr1ReviewBodyOk(body, taskRoot)
129185
}
186+
187+
// Legacy: no 02 present — sessions row may still count for non-CP2 callers.
130188
const sessions = path.join(taskRoot, '.memory', 'sessions.md')
131189
if (fs.existsSync(sessions)) {
132190
const s = fs.readFileSync(sessions, 'utf8')
@@ -320,6 +378,11 @@ module.exports = {
320378
extractLastAssistantMessage,
321379
askingCp2Confirm,
322380
pr1EvidenceOk,
381+
pr1ReviewBodyOk,
382+
countPr1Substance,
383+
findPr1ReviewFileName,
384+
controlPlaneHint,
385+
PR1_MIN_BODY_BYTES,
323386
completionClaimed,
324387
hasEntryCheck,
325388
hasCompletionCheck,

‎hooks/_runtime/skill-resolution.cjs‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,37 @@ function resolveHome(options = {}) {
7575
return path.resolve(options.home || env.DEVCODEX_TEST_HOME || env.USERPROFILE || env.HOME || os.homedir())
7676
}
7777

78+
function resolveSkillsDeployModeLocal (env = process.env, options = {}) {
79+
const raw = String(options.skillsDeployMode || env.DEVCODEX_SKILLS_DEPLOY_MODE || '').trim().toLowerCase()
80+
if (raw === 'legacy' || raw === 'legacy-full-tree' || raw === 'visible') return 'legacy'
81+
if (raw === 'hidden' || raw === 'hook-only-hidden') return 'hidden'
82+
// default hidden (SkillsDeployModeV1)
83+
if (!raw) return 'hidden'
84+
return 'hidden'
85+
}
86+
7887
function resolveGlobalSkillsRoot(options = {}) {
7988
const env = options.env || process.env
89+
// Explicit override always wins (tests / advanced users); doctor warns if mode=hidden but this points at scan root.
8090
if (env.DEVCODEX_GLOBAL_SKILLS_ROOT) {
8191
return path.resolve(env.DEVCODEX_GLOBAL_SKILLS_ROOT)
8292
}
93+
if (options.globalSkillsRoot) {
94+
return path.resolve(options.globalSkillsRoot)
95+
}
8396
const home = resolveHome(options)
8497
const shared = env.DEVCODEX_GLOBAL_SHARED_ROOT
8598
? path.resolve(env.DEVCODEX_GLOBAL_SHARED_ROOT)
8699
: path.join(home, '.agents')
87-
return path.join(shared, 'skills')
100+
const mode = resolveSkillsDeployModeLocal(env, options)
101+
if (mode === 'legacy') {
102+
return path.join(shared, 'skills')
103+
}
104+
// hidden → G_RUNTIME
105+
if (env.DEVCODEX_GLOBAL_SKILLS_RUNTIME) {
106+
return path.resolve(env.DEVCODEX_GLOBAL_SKILLS_RUNTIME)
107+
}
108+
return path.join(shared, 'devcodex', 'skills')
88109
}
89110

90111
function resolveWorkspaceSkillsRoot(cwdOrRoot, options = {}) {

‎host-projections/CLAUDE.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
@devcodex/runtime/AGENTS.md
44

5-
- 上方 shared kernel 位于用户级 Claude runtime;按需读取用户级 `.claude/skills/`。
5+
- 上方 shared kernel 位于用户级 Claude runtime;全局 Skill 正文默认在受管 G_RUNTIME(`~/.agents/devcodex/skills`),经 DevCodex resolve 按需读取,勿依赖 `~/.claude/skills` 全量列表。
66
- kernel 不足或 coverage/freshness 失败时读取用户级 `.agents/devcodex/instructions.full.md`。
77
- Hook direct evidence 缺失时保持 unverified,不得凭配置文件宣称 enforced。

‎host-projections/GEMINI.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
@devcodex/runtime/AGENTS.md
44

5-
- 上方 shared kernel 位于用户级 Gemini runtime;按需读取用户级 `.agents/skills/`。
5+
- 上方 shared kernel 位于用户级 Gemini runtime;全局 Skill 默认经 DevCodex resolve 读取受管 runtime skills(`~/.agents/devcodex/skills`),非扫描根全量百科。
66
- kernel 不足或 coverage/freshness 失败时读取用户级 `.agents/devcodex/instructions.full.md`。
77
- BeforeAgent/AfterAgent/PreCompress 的能力声明必须受 direct replay 证据上限约束。

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"test:host-parity": "node scripts/test-host-parity-scorecard.js && node scripts/test-workspace-root-scan-ban.js && node scripts/test-host-parity-remaining.js && node scripts/test-host-parity-ledger.js && node scripts/test-mcp-runtime-closure.js",
7878
"test:host-installation": "node scripts/test-host-installation.js",
7979
"test:npm-lifecycle-adapter": "node scripts/test-npm-lifecycle-adapter.js",
80-
"test:global-host-config": "node scripts/test-global-host-config.js && node scripts/test-global-host-runtime-verifier.js",
80+
"test:global-host-config": "node scripts/test-global-host-config.js && node scripts/test-global-host-runtime-verifier.js && node scripts/test-skills-deploy-mode.js",
8181
"test:global-install-smoke": "node scripts/test-global-install-smoke.js",
8282
"benchmark:execution-chain": "node scripts/benchmark-execution-chain.js",
8383
"benchmark:runtime-indexes": "node scripts/benchmark-runtime-indexes.js",
@@ -186,6 +186,8 @@
186186
"scripts/run-validation.js",
187187
"scripts/test-npm-lifecycle-adapter.js",
188188
"scripts/test-global-host-config.js",
189+
"scripts/test-skills-deploy-mode.js",
190+
"scripts/lib/skills-deploy-mode.js",
189191
"scripts/test-global-host-runtime-verifier.js",
190192
"scripts/test-global-install-smoke.js",
191193
"scripts/test-mcp-runtime-closure.js",

‎prompts/technical-design.prompt.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ applyTo: .devcodex/**/requirements/**
2727
> ⚠️ CP2 必须承接 CP1 的平台工程判断和 `ImplementationComplexityLevel`(兼容旧字段 `ImplementationComplexityPreference`):消费者范围、共享契约边界、模块职责、可维护性成本、非目标和最小实现预算要互相一致;没有真实复用者或演进边界时,不得新增 factory / manager / adapter / registry 等预设抽象。
2828
> ⚠️ 重要技术结论必须通过 `CodeTruthEvidenceMatrixGate` 绑定 repo path、symbol/contract、currentBehavior、negativeProbe 和 gap;方案推荐还必须通过 `SolutionFitAgainstRepoGate` 说明 reusePoint、consumer、rollback 与 statusQuoCost。
2929
> ⚠️ CP2 候选在请求确认前必须附 `CandidateReviewBundleV1`:`phaseKind=CP2`、`TDMatrix`、`BlockerSnapshot`、`ClaimEvidenceMatrix`。缺任一项、证据陈旧或存在未关闭 blocker 时,不得写“可确认 CP2 / 可进入 CP3”。
30+
> ⚠️ **PR-1 实质自审(防假绿)**:在写「请确认 CP2 / 确认技术方案」前,任务目录必须已有独立 `03-*方案复审*`(或等价),含 `open blocker = 0`(或明确 PR-1 通过句)**且**实质章节(验收映射 / 契约矩阵 / CodeTruth / BlockerSnapshot / 根因 等至少 2 类);禁止仅在 `02` 内嵌薄表 `PR-1 | ✅` 或仅 sessions 一行。Stop 门 `pr1EvidenceOk` 会拒绝 thin green。
3031
> ⚠️ §7 必须物化验证计划、命令/矩阵路线、验收标准和退出条件;进入编码前,§2.6 写清允许首批、阻断范围、偏移触发、验证路线和消费者同步。
3132
> ⚠️ 当 AI 判断目标包含修复 Bug/缺陷/回归/安全问题/规范缺口/审查 finding 时,技术方案必须引用 `repair-collaboration`:低风险填写 lightweight 双层字段,高风险填写 full + findingToPatchMap + handoffIntegrity + independentReReview;模型名称不是触发条件。
3233
> ⚠️ 同一 repair 方案必须引用 active `repair-prevention-assessment#RepairPreventionAssessmentGate`,冻结 `RepairPreventionAssessmentV1` 的 mode/decision、双根因、regression/negative seeds、immediate closure 与 prospective plan、Owner/consumers 和 rollback/sunset;`no-new-control` 必须有标准 reason/evidence,当前修复重跑不能晋级 prevention。

‎scripts/lib/global-adapters-cli.js‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ function parseGlobalAdaptersArgv(argv = []) {
3636
dryRun: false,
3737
json: false,
3838
home: null,
39+
skillsDeployMode: null,
3940
errors: []
4041
}
4142
for (let i = 0; i < args.length; i++) {
@@ -52,6 +53,16 @@ function parseGlobalAdaptersArgv(argv = []) {
5253
}
5354
} else if (arg.startsWith('--home=')) {
5455
options.home = arg.slice('--home='.length)
56+
} else if (arg === '--mode') {
57+
const value = args[i + 1]
58+
if (!value || String(value).startsWith('-')) {
59+
options.errors.push('--mode requires hidden|legacy')
60+
} else {
61+
options.skillsDeployMode = value
62+
i++
63+
}
64+
} else if (arg.startsWith('--mode=')) {
65+
options.skillsDeployMode = arg.slice('--mode='.length)
5566
} else {
5667
options.errors.push(`unsupported option: ${arg}`)
5768
}
@@ -109,7 +120,7 @@ function buildHandler(deps = {}) {
109120
COMMAND,
110121
'CLI_GLOBAL_ADAPTERS_BAD_ARGS',
111122
parsed.errors.join('; '),
112-
'Use: devcodex global-adapters apply [--dry-run] [--json] [--home <dir>]',
123+
'Use: devcodex global-adapters apply [--mode=hidden|legacy] [--dry-run] [--json] [--home <dir>]',
113124
cliMetadata
114125
)
115126
if (parsed.json) printCliJson(consoleImpl, envelope)
@@ -126,7 +137,7 @@ function buildHandler(deps = {}) {
126137
COMMAND,
127138
'CLI_GLOBAL_ADAPTERS_UNKNOWN_SUBCOMMAND',
128139
`Unknown global-adapters subcommand: ${parsed.subcommand || '(none)'}`,
129-
'Use: devcodex global-adapters apply [--dry-run] [--json]',
140+
'Use: devcodex global-adapters apply [--mode=hidden|legacy] [--dry-run] [--json]',
130141
cliMetadata
131142
)
132143
if (parsed.json) printCliJson(consoleImpl, envelope)
@@ -170,7 +181,8 @@ function buildHandler(deps = {}) {
170181
dryRun: parsed.dryRun === true,
171182
home: parsed.home || undefined,
172183
fs: fsImpl,
173-
env: processImpl.env
184+
env: processImpl.env,
185+
skillsDeployMode: parsed.skillsDeployMode || undefined
174186
})
175187
} catch (error) {
176188
const envelope = createCliFailure(

0 commit comments

Comments
 (0)