Skip to content

Commit 4976619

Browse files
committed
fix: tighten bootstrap and validation guards
1 parent fea0295 commit 4976619

7 files changed

Lines changed: 393 additions & 71 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# 变更日志 (CHANGELOG)
22

33
> **说明**: 版本概览摘要。最新版本的详细变更见下方表格首行的 `changelogs/vX.Y.Z.md` 链接;历史版本见对应详细变更文件
4-
> **最后更新**: 2026-05-21
4+
> **最后更新**: 2026-05-22
55
66
---
77

88
## 版本概览
99

1010
| 版本 | 日期 | 变更摘要 | 详细 |
1111
|------|------|---------|------|
12-
| [v1.9.11](./changelogs/v1.9.11.md) | 2026-05-21 | 🔧 **Auto v1.1 runtime 收口 + 白名单门禁落地**:将 auto 正式入口收敛为显式 `@devcodex-auto`,在 `lifecycle.cjs` 中新增 `executionMode` 与白名单路径门禁,只对白名单路径自动推进;补齐 hooks runtime 回归用例、`validate.js` V14 auto 语义探针,并同步 README 与父级 `.github/.claude` 部署副本 | [查看](./changelogs/v1.9.11.md) |
12+
| [v1.9.11](./changelogs/v1.9.11.md) | 2026-05-22 | 🔧 **Auto v1.1 runtime 收口 + 控制面校验补强**:在 auto 白名单门禁落地后,继续收紧 bootstrap 到当前 agent + 今日/昨日 tasks,补齐缺少 `agent` 的 fallback 推断与回归测试;对齐 `profile init` 与 `validate-profile.js` 模板/真相源校验;`validate.js` V10 改为结构化探针并新增 V15 audit-state 状态机校验,同时同步父级 `.github/.claude` runtime 副本 | [查看](./changelogs/v1.9.11.md) |
1313
| [v1.9.10](./changelogs/v1.9.10.md) | 2026-05-21 | 🔧 **模板/工作流漂移修复 + V13 语义门禁**:修复 precheck 模板 PC0~PC7 与 chat 预检查口径、Token 当前全开放说明、报告模板强制头部和 fix 专属章节、chat daily memory、CP3 `N/A` 豁免运行时识别、API/场景测试归档路径;`validate.js` 扩展 V8 prompts 覆盖并新增 V13 模板语义探针;同步仓内与父级 `.github/.claude` 部署体 | [查看](./changelogs/v1.9.10.md) |
1414
| [v1.9.9](./changelogs/v1.9.9.md) | 2026-05-21 | 🔧 **单源分发回归修复 + 发布门禁补强**:修复 v1.9.8 `instructions.md` 未进入 npm tarball 导致 `init/update` 主链缺失的问题;V6 与 `test-pack-clean` 新增 required package assets 正向断言;同步 README/RULES/profile 的 agents 分发语义和单源路径;单源正文改为平台中性索引说明;更新 audit-common V8 职责描述,避免 8 文件/33% 旧口径误导审查 | [查看](./changelogs/v1.9.9.md) |
1515
| [v1.9.8](./changelogs/v1.9.8.md) | 2026-05-21 | 🎯 **单源规范 + agents 恢复 + 多项目工作区阻断**(含 PATCH Breaking Change,由用户 D1 决策接受 Semver 违规):① Q1 `agents/` 恢复 Copilot 默认分发(`index.js` SOURCES 重新包含 `agents`,Claude Code 端保持 Skill 路由);② Q2 单源规范——删除 `copilot-instructions.md`,新增 `instructions.md` 作为唯一规范源;`cmdInit`/`cmdInitClaude` 均以 `instructions.md` 为源、按平台 rename 到 `.github/copilot-instructions.md` 或 `CLAUDE.md`(**Breaking**:删除文件 + 双平台单源);③ Q3 项目未识别硬阻断——`01-common` + `load-profile` + `17-compliance` PC0 + `18-spec-radar` Axis A/G11 同步「必须先询问用户、禁止猜测、禁止超范围扫描」;`lifecycle.cjs` UserPromptSubmit 新增多项目工作区检测(≥2 含 `package.json`/`.devcodex/profile` 的同级子目录 + 无 workspace 根 profile → 阻断),豁免词 `workspace/monorepo/全工作区/all projects/所有项目`;④ `scripts/validate.js` 新增 V12(源仓库不得含 `copilot-instructions.md`) | [查看](./changelogs/v1.9.8.md) |

‎changelogs/v1.9.11.md‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# v1.9.11 — Auto v1.1 runtime 收口 + 白名单门禁落地
1+
# v1.9.11 — Auto v1.1 runtime 收口 + 控制面校验补强
22

3-
> **发布日期**: 2026-05-21
3+
> **发布日期**: 2026-05-22
44
> **类型**: PATCH
55
> **关联报告**: `.devcodex/bugs/devcodex-auto模式智能性不足/reports/claude-code/20260521/01--auto实施与验证.md`
66
@@ -13,18 +13,26 @@
1313
- 补齐 `scripts/test-hooks-runtime.js` 的 auto 专属回归用例,覆盖 executionMode 写入、白名单放行、非白名单阻断与危险命令阻断。
1414
- 扩展 `scripts/validate.js` V14,校验 agent / instructions / skills / runtime / test / README 的 auto 语义联动。
1515
- 同步 README 与父级 `.github/.claude` 部署副本,消除“源码已改、部署滞后”的 V8 噪音。
16+
- 继续收紧 bootstrap:`hooks/_runtime/lifecycle.cjs` 现在只接受当前 agent 的 `SUMMARY.md` 与今日/昨日 `tasks/YYYYMMDD.md`,并在 profile 缺少 `agent` 时按宿主环境与已有 memory 目录推断单一 fallback agent,避免错误 agent 或陈旧 tasks 误满足 bootstrap。
17+
- `scripts/test-hooks-runtime.js` 补齐 wrong-agent、stale-task 与 missing-agent fallback 三类回归场景,保证 bootstrap 收口后的关键分支有自动化覆盖。
18+
- `index.js` 的 `profile init` 生成器改为表格模板;`scripts/validate-profile.js` 同步兼容表格与旧列表格式,并新增 `01-项目信息.md` 的当前版本/当前阶段真相源漂移检查,修复“初始化后立刻误报 missing entry”的问题。
19+
- `scripts/validate.js` 的 V10 不再执行自由字符串 `scanCmd`,改为结构化 `grepCount` 探针与受控 legacy 兼容解析;同时新增 V15,对 `.devcodex/.audit-state/*.json` 的状态枚举与 `converged` 门禁进行一致性校验。
1620

1721
## Validation
1822

1923
- `npm run test:all`
2024
- `node scripts/validate.js`
2125
- `npm view @vextjs/devcodex version --registry https://npm.pkg.github.com`(发布前确认当前 registry 为 `1.9.10`,需要 bump 后才能 publish)
26+
- `node scripts/test-hooks-runtime.js`
27+
- 临时目录执行 `node index.js profile init` 后,再执行 `node scripts/validate-profile.js`,确认不再出现 `missing 当前版本/当前阶段 entry`
2228

2329
## Impact
2430

2531
- Auto 模式从“仅 CP 自动通过”提升为可执行的最小 runtime 闭环,但边界仍保持在 hook-enforced + 白名单路径,避免过度承诺。
2632
- 非 auto 模式继续走原 confirm 路径;完整回归已覆盖 validate、hooks runtime 与 pack-clean。
2733
- 后续如果要推进 Auto v1.2/v2,可在现有 executionMode 与 V14 基础上继续扩展,不需要重做本轮收口。
34+
- bootstrap 门禁不再依赖宽泛的 `clients/` 路径命中,profile 缺少 `agent` 的合法 warning 场景也有安全兜底,不会留下运行时旁路。
35+
- profile 初始化器、校验器与 audit-state 校验链现在共享一致的机器可读契约,降低“工具自己打自己”或样本静默漂移的风险。
2836

2937
## Breaking Changes
3038

‎hooks/_runtime/lifecycle.cjs‎

Lines changed: 93 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,67 @@ function readProfileMode() {
8282
return String(cfg?.mode ?? 'prod').trim().toLowerCase() === 'dev' ? 'dev' : 'prod'
8383
}
8484

85+
function readProjectProfileConfig(state) {
86+
const projectRoot = getActiveProjectRoot(state)
87+
return readJsonFile(path.join(projectRoot, '.devcodex', 'profile', 'config.json')) || null
88+
}
89+
90+
function listMemoryAgents(state) {
91+
const clientsDir = path.join(getActiveProjectRoot(state), '.devcodex', '.memory', 'clients')
92+
if (!fs.existsSync(clientsDir)) return []
93+
try {
94+
return fs.readdirSync(clientsDir, { withFileTypes: true })
95+
.filter(entry => entry.isDirectory())
96+
.map(entry => String(entry.name || '').trim().toLowerCase())
97+
.filter(Boolean)
98+
} catch {
99+
return []
100+
}
101+
}
102+
103+
function inferBootstrapAgent(state, payload) {
104+
const existingAgents = new Set(listMemoryAgents(state))
105+
const platform = detectPlatform(payload || {})
106+
107+
if (platform === 'claude') return 'claude-code'
108+
if (platform === 'jetbrains-copilot') return 'jetbrains-copilot'
109+
if (platform === 'vscode-copilot') {
110+
if (existingAgents.has('vscode-copilot')) return 'vscode-copilot'
111+
if (existingAgents.has('copilot')) return 'copilot'
112+
return 'vscode-copilot'
113+
}
114+
if (platform === 'copilot') {
115+
if (existingAgents.has('copilot')) return 'copilot'
116+
if (existingAgents.has('vscode-copilot')) return 'vscode-copilot'
117+
return 'copilot'
118+
}
119+
return 'unknown-agent'
120+
}
121+
122+
function getBootstrapAgent(state, payload) {
123+
const configuredAgent = String(readProjectProfileConfig(state)?.agent || '').trim().toLowerCase()
124+
return configuredAgent || inferBootstrapAgent(state, payload)
125+
}
126+
127+
function formatDateStamp(date) {
128+
const year = String(date.getFullYear())
129+
const month = String(date.getMonth() + 1).padStart(2, '0')
130+
const day = String(date.getDate()).padStart(2, '0')
131+
return `${year}${month}${day}`
132+
}
133+
134+
function getRecentBootstrapTaskStamps() {
135+
const today = new Date()
136+
const yesterday = new Date(today)
137+
yesterday.setDate(today.getDate() - 1)
138+
return [formatDateStamp(today), formatDateStamp(yesterday)]
139+
}
140+
141+
function isRecentBootstrapTaskPath(input) {
142+
const normalized = normalizeText(input)
143+
return getRecentBootstrapTaskStamps().some(stamp => normalized.endsWith(`/tasks/${stamp}.md`))
144+
}
145+
85146
function normalizeText(v) {
86147
return String(v || '').replace(/\\/g, '/').trim().toLowerCase()
87148
}
@@ -268,11 +329,27 @@ function buildProjectScopedNeedles(projectRoot, segments) {
268329
return [absolute, relative]
269330
}
270331

271-
function getBootstrapScopes(state) {
332+
function getBootstrapScopes(state, payload) {
272333
const projectRoot = getActiveProjectRoot(state)
334+
const bootstrapAgent = getBootstrapAgent(state, payload)
335+
const memorySegments = ['.devcodex', '.memory', 'clients']
336+
const memoryNeedles = bootstrapAgent
337+
? buildProjectScopedNeedles(projectRoot, [...memorySegments, bootstrapAgent])
338+
: buildProjectScopedNeedles(projectRoot, memorySegments)
339+
const summaryNeedles = bootstrapAgent
340+
? buildProjectScopedNeedles(projectRoot, [...memorySegments, bootstrapAgent, 'SUMMARY.md'])
341+
: []
342+
const taskNeedles = bootstrapAgent
343+
? getRecentBootstrapTaskStamps().flatMap(stamp => buildProjectScopedNeedles(
344+
projectRoot,
345+
[...memorySegments, bootstrapAgent, 'tasks', `${stamp}.md`]
346+
))
347+
: []
273348
return {
274349
profileNeedles: buildProjectScopedNeedles(projectRoot, ['.devcodex', 'profile']),
275-
memoryNeedles: buildProjectScopedNeedles(projectRoot, ['.devcodex', '.memory', 'clients'])
350+
memoryNeedles,
351+
summaryNeedles,
352+
taskNeedles
276353
}
277354
}
278355

@@ -325,7 +402,7 @@ function resetState(mode, previousState) {
325402

326403
function isBootstrapReadTool(payload, state) {
327404
const tn = getToolName(payload).toLowerCase()
328-
const scopes = getBootstrapScopes(state)
405+
const scopes = getBootstrapScopes(state, payload)
329406
// Copilot: read_file/list_dir/file_search/grep_search/semantic_search
330407
// Claude Code: Read/Glob/Grep (PascalCase → lowercased above)
331408
const readPatterns = [
@@ -339,13 +416,21 @@ function isBootstrapReadTool(payload, state) {
339416
}
340417

341418
function updateBootstrapState(state, payload) {
342-
const scopes = getBootstrapScopes(state)
419+
const scopes = getBootstrapScopes(state, payload)
420+
const inputStrings = getToolInputStrings(payload)
343421
if (touchesPath(payload, ...scopes.profileNeedles)) state.bootstrap.profileRead = true
344-
if (touchesPath(payload, ...scopes.memoryNeedles) &&
345-
getToolInputStrings(payload).some(s => s.includes('/summary.md'))) state.bootstrap.summaryRead = true
346-
if (touchesPath(payload, ...scopes.memoryNeedles) &&
347-
getToolInputStrings(payload).some(s => s.includes('/tasks/') && s.endsWith('.md')))
422+
if ((scopes.summaryNeedles.length && touchesPath(payload, ...scopes.summaryNeedles)) ||
423+
(!scopes.summaryNeedles.length &&
424+
touchesPath(payload, ...scopes.memoryNeedles) &&
425+
inputStrings.some(s => s.includes('/summary.md')))) {
426+
state.bootstrap.summaryRead = true
427+
}
428+
if ((scopes.taskNeedles.length && touchesPath(payload, ...scopes.taskNeedles)) ||
429+
(!scopes.taskNeedles.length &&
430+
touchesPath(payload, ...scopes.memoryNeedles) &&
431+
inputStrings.some(isRecentBootstrapTaskPath))) {
348432
state.bootstrap.tasksRead = true
433+
}
349434
state.bootstrapComplete = !!(
350435
state.bootstrap.profileRead && state.bootstrap.summaryRead && state.bootstrap.tasksRead
351436
)

‎index.js‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -587,15 +587,22 @@ function genProjectInfo(ctx) {
587587
> 由 \`devcodex profile init\` 于 ${new Date().toISOString().slice(0, 10)} 自动生成,需人工复核后定稿。
588588
589589
## 基础信息
590-
- 项目名:${name}
591-
- 当前版本:${ver}
592-
- 描述:${desc}
593-
- Node 版本:${node}
594-
- 仓库:${repo}
590+
591+
| 字段 | 内容 |
592+
|------|------|
593+
| **项目名** | ${name} |
594+
| **当前版本** | ${ver} |
595+
| **描述** | ${desc} |
596+
| **Node 版本** | ${node} |
597+
| **仓库** | ${repo} |
595598
596599
## 当前阶段
597-
- 主版本分支:${branch}
598-
- 阶段摘要:${changelogTop || '(未在 CHANGELOG.md 中识别)'}
600+
601+
| 字段 | 内容 |
602+
|------|------|
603+
| **当前阶段** | v${ver} 初始草稿 |
604+
| **主版本分支** | ${branch} |
605+
| **阶段摘要** | ${changelogTop || '(未在 CHANGELOG.md 中识别)'} |
599606
`
600607
}
601608

0 commit comments

Comments
 (0)