Skip to content

Commit 3bb7d9c

Browse files
committed
docs: add common task guidance
1 parent f1c40e7 commit 3bb7d9c

7 files changed

Lines changed: 160 additions & 29 deletions

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ DevCodex 不替代业务框架、GitHub CI、安全审计或人工评审。它
2525
- [5 分钟开始](#5-分钟开始)
2626
- [项目 Profile](#项目-profile)
2727
- [首次信任提示](#首次信任提示)
28+
- [常见任务怎么说](#常见任务怎么说)
2829
- [更新](#更新)
2930
- [卸载](#卸载)
3031
- [运行态检查](#运行态检查)
@@ -222,6 +223,78 @@ DevCodex 会按任务意图选择流程和 Skill。普通使用者不需要手
222223

223224
`extensions.devcodex.autoAliases` 用于替换全局默认别名;省略该字段表示继续使用默认 `@rocky`,设置为空数组 `[]` 表示关闭默认自动推进别名。
224225

226+
## 常见任务怎么说
227+
228+
你不需要记住工作流名称、Skill 名或内部阶段。直接说明任务目标即可;为了减少来回确认,推荐把请求写成:
229+
230+
```text
231+
是否自动推进 + 目标或问题 + 范围与约束 + 验证要求 + 是否提交、推送或发布
232+
```
233+
234+
### 只分析,不修改
235+
236+
```text
237+
分析当前项目的主要问题,按优先级给出建议。只分析,不修改文件。
238+
```
239+
240+
### 整理新需求,确认后再实施
241+
242+
```text
243+
分析当前项目,整理“用户登录限流”需求,列出目标、范围、用户流程、验收标准和影响,先给我确认,不要修改源码。
244+
```
245+
246+
确认需求后可以继续说:
247+
248+
```text
249+
确认,按刚才的需求实施,完成后运行相关测试并提交。
250+
```
251+
252+
### 诊断 Bug,但暂不修复
253+
254+
```text
255+
检查支付回调偶发重复入账的问题,复现并定位根因,给出影响范围和修复方案。只诊断,不修改文件。
256+
```
257+
258+
### 自动修复并验证
259+
260+
```text
261+
@rocky 修复当前失败的 GitHub CI,检查是否还有同类问题,运行完整验证,完成后提交。
262+
```
263+
264+
### 深度审查
265+
266+
```text
267+
从用户体验、架构、兼容性、测试和发布风险审查当前实现,只报告有证据的问题,不修改文件。
268+
```
269+
270+
### 在新会话继续任务
271+
272+
```text
273+
继续<任务名>任务
274+
```
275+
276+
例如:
277+
278+
```text
279+
继续用户登录限流任务
280+
```
281+
282+
### 明确要求发布
283+
284+
提交、push、tag、GitHub Release 和 npm publish 都属于独立动作。需要发布时请直接写明:
285+
286+
```text
287+
@rocky 完成修复和全部验证后提交并推送 main,发布新的 patch 版本到 npm 和 GitHub Release,再用线上包重新安装验证。
288+
```
289+
290+
几个实用技巧:
291+
292+
- 只想要结论时写清楚“只分析,不修改文件”。
293+
- 指定项目、目录或文件范围,避免在多项目 workspace 中产生歧义。
294+
- 写明必须运行的测试,或要求 DevCodex 根据影响范围选择验证。
295+
- “完成”不自动等于 commit、push 或发布;这些动作需要在当前请求中明确写出。
296+
- `@rocky` 只负责在已授权范围内自动推进,不会扩大删除、越界访问或发布权限。
297+
225298
## 更新
226299

227300
```bash

changelogs/unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
> **当前**: v1.16.1 已归档到 `changelogs/releases/v1.16.1.md`;本文件仅保留历史锚点索引与镜像供 validate 探针消费。发版后新实现再写入下方「当前未发布」。
55
66
## 当前未发布实现候选
7+
- **README 常见任务与 CLI 帮助防误写**:公共 README 新增可直接复制的分析、需求确认、Bug 诊断、`@rocky` 自动修复、深度审查、任务续接和发布请求教程;`devcodex help <command>``<command> --help` 现统一进入只读帮助,不再误执行 `init` 或进入子命令解析。`PublicReadmeContractV1` 和 CLI registry 负向探针防止教程或零写入语义回归。
78
- **v1.16.1 已归档**:长会话提示有界化、会话治理状态隔离、项目绑定稳定性与唯一短名解析修复已进入 `changelogs/releases/v1.16.1.md`
89
- **v1.16.0 已归档**:首次初始化、项目 Profile、用户语言与 workspace runtime-state 一致性已进入 `changelogs/releases/v1.16.0.md`
910
- **v1.15.9 已归档**:SkillRoute 相同语义 rebind 现在可迁移未完成阶段前缀、重新签发新 plan cursor,并让 rebind/status/Stop 返回一致且可执行的恢复调用;语义、阶段内容或依赖漂移仍 fail closed。

scripts/lib/canonical-consumer-contracts.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,15 @@ const PUBLIC_README_REQUIRED_MARKERS = Object.freeze([
5050
'<你的项目根目录>/.devcodex/workspace/skills/<id>/SKILL.md',
5151
'DevCodex 不扫描、复制、合并、覆盖或删除这些用户资产',
5252
'不替代业务框架、GitHub CI、安全审计或人工评审',
53+
'## 常见任务怎么说',
54+
'只分析,不修改文件',
55+
'继续<任务名>任务',
56+
'push、tag、GitHub Release 和 npm publish',
5357
'[AGPL-3.0](LICENSE)',
5458
'## 目录',
5559
'[为什么需要 DevCodex?](#为什么需要-devcodex)',
5660
'[5 分钟开始](#5-分钟开始)',
61+
'[常见任务怎么说](#常见任务怎么说)',
5762
'[添加自己的 Skill](#添加自己的-skill)',
5863
'[许可证](#许可证)'
5964
])

scripts/lib/cli-command-registry.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,25 @@ function isVersionCommand(cmd) {
6666
return cmd === 'version' || cmd === '--version' || cmd === '-v'
6767
}
6868

69+
function isHelpFlag(value) {
70+
return value === '--help' || value === '-h'
71+
}
72+
6973
function runCliCommand({ cmd, argv, registry, runMigrateLayout, process, c, console, packageVersion = null }) {
7074
if (isHelpCommand(cmd)) {
71-
registry.cmdHelp()
75+
registry.cmdHelp(cmd === 'help' && argv.length ? argv : undefined)
7276
return 'help'
7377
}
7478
if (isVersionCommand(cmd)) {
7579
console.log(packageVersion || 'unknown')
7680
return 'version'
7781
}
7882

83+
if (argv.some(isHelpFlag)) {
84+
registry.cmdHelp([cmd, ...argv.filter(item => !isHelpFlag(item))])
85+
return 'help'
86+
}
87+
7988
const selection = parseHostSelection(argv)
8089
if (!selection.ok) {
8190
console.log(c.red(` ${selection.code}: ${selection.message}`))

scripts/lib/cli-maintenance-commands.js

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,26 +1024,65 @@ function buildCliMaintenanceCommands(ctx) {
10241024
}
10251025
}
10261026

1027-
function cmdHelp() {
1027+
function cmdHelp(topicInput) {
1028+
const topicParts = Array.isArray(topicInput)
1029+
? topicInput.map(item => String(item || '').trim()).filter(Boolean)
1030+
: (topicInput ? [String(topicInput).trim()] : [])
1031+
const topic = topicParts[0] || null
1032+
const detail = {
1033+
init: ['devcodex init [--profile <project>] [--dry-run]', 'Initialize the current workspace .devcodex state and Profile baseline.'],
1034+
update: ['devcodex update [--dry-run]', 'Refresh only the current workspace .devcodex runtime state.'],
1035+
status: ['devcodex status [--completion] [--json]', 'Show workspace and user-global adapter readiness.'],
1036+
doctor: ['devcodex doctor [--completion] [--json]', 'Diagnose adapter, native host and workflow readiness.'],
1037+
profile: ['devcodex profile plan|init [--tier <tier>] [--dry-run] [--force] [--prod]', 'Preview or create an advanced project Profile. Ordinary workspaces only need `devcodex init`.'],
1038+
runtime: ['devcodex runtime status|prune [--dry-run|--apply] [--json]', 'Inspect runtime-state usage or preview safe stale-temp cleanup.'],
1039+
uninstall: ['npm uninstall -g devcodex', 'Remove the published global package.'],
1040+
'global-adapters': ['devcodex global-adapters apply [--dry-run] [--json]', 'Advanced: refresh user-global host adapters from the current package root.'],
1041+
grok: ['devcodex grok [Grok CLI options]', 'Launch Grok with the user-global DevCodex kernel.'],
1042+
'migrate-layout': ['devcodex migrate-layout plan|apply|rollback', 'Advanced: manage centralized workspace layout migration.'],
1043+
probe: ['devcodex probe <id> [--json]', 'Advanced: run bounded local-only diagnostics.'],
1044+
trace: ['devcodex trace show|replay [options]', 'Advanced: inspect or replay LocalTaskTrace evidence.'],
1045+
skill: ['devcodex skill plan|resolve [options]', 'Advanced: inspect Skill resolution; ordinary users do not configure built-in Skills.'],
1046+
task: ['devcodex task resolve|verify|risk [options]', 'Advanced: inspect task identity, reconciliation or explicit risk decisions.']
1047+
}[topic]
1048+
1049+
if (topic && detail) {
1050+
console.log(`
1051+
${c.bold(`DevCodex ${topic} help`)}
1052+
1053+
${c.bold('Usage:')}
1054+
${detail[0]}
1055+
1056+
${detail[1]}
1057+
1058+
Run ${c.cyan('devcodex help')} for the command overview.
1059+
User guide: https://github.com/devcodex-labs/devcodex#readme
1060+
`)
1061+
return
1062+
}
1063+
10281064
console.log(`
10291065
${c.bold('DevCodex')} — AI-powered development workflow rules for Copilot, Claude, Codex, Gemini & Grok
10301066
10311067
${c.bold('Usage:')}
10321068
devcodex <command> [options]
10331069
npx devcodex <command> [options] ${c.dim('(without npm link)')}
10341070
1035-
${c.bold('Commands:')}
1071+
${c.bold('Everyday commands:')}
10361072
${c.cyan('init')} Initialize workspace-owned .devcodex runtime state only
10371073
${c.cyan('update')} Refresh workspace-owned .devcodex runtime state only
1038-
${c.cyan('global-adapters')} Apply user-level host adapters from package root (source-friendly)
1039-
${c.cyan('grok')} Launch Grok with the user-global DevCodex kernel
1040-
${c.cyan('migrate-layout')} Plan/apply/rollback centralized .devcodex workspace layout
1074+
${c.cyan('status')} Check workspace and host adapter readiness
1075+
${c.cyan('doctor')} Diagnose installation or workflow problems
10411076
${c.cyan('runtime status')} Inspect runtime-state owners, size and last-use timestamps
10421077
${c.cyan('runtime prune')} Preview safe stale-temp cleanup; add --apply to remove
10431078
${c.cyan('profile init')} Auto-generate tiered .devcodex/profile/ drafts
10441079
${c.cyan('profile plan')} Preview Profile root/tier/file actions without writing
1045-
${c.cyan('status')} Show installed files; add --completion for workflow state
1046-
${c.cyan('doctor')} Diagnose host/agent/mode; add --completion for blockers/actions
1080+
${c.cyan('help <command>')} Show read-only help for one command
1081+
1082+
${c.bold('Advanced commands:')}
1083+
${c.cyan('global-adapters')} Apply user-level host adapters from package root
1084+
${c.cyan('grok')} Launch Grok with the user-global DevCodex kernel
1085+
${c.cyan('migrate-layout')} Plan/apply/rollback centralized .devcodex workspace layout
10471086
${c.cyan('probe')} Run bounded local-only diagnostics; accepts IDs and --json
10481087
${c.cyan('trace show|replay')} Read LocalTaskTrace; trace show --completion reads receipt identities
10491088
${c.cyan('skill plan')} Plan a dependency-closed whole-SKILL bundle; add --json for BundleDecisionV2
@@ -1060,27 +1099,18 @@ function buildCliMaintenanceCommands(ctx) {
10601099
${c.dim('--allow-downgrade')} (profile init only) Explicitly allow a lower tier; files are retained
10611100
${c.dim('--json')} Emit one DevCodexCliEnvelopeV1 document for supported commands
10621101
1063-
${c.bold('Examples:')}
1064-
devcodex global-adapters apply --dry-run # R1a: plan user-global adapters from source tree
1065-
devcodex global-adapters apply # R1a: refresh user-global adapters without pack/publish
1066-
npm install -g . # R1b: local global install postinstall refresh
1067-
npm pack && npm install -g ./devcodex-*.tgz # R2: pre-release tarball
1068-
npm install -g devcodex # R3: published install + postinstall adapters
1069-
npm update -g devcodex # R3: published upgrade + postinstall refresh
1070-
npm install devcodex # Dependency only; prints the required -g guidance
1071-
devcodex init # R4: initialize only this workspace .devcodex
1072-
devcodex update # R4: refresh only this workspace .devcodex
1073-
devcodex grok # Full-evidence Grok launcher using the global kernel
1074-
devcodex grok -p "Review this diff" --output-format json
1075-
devcodex migrate-layout plan # Generate centralized layout migration manifest
1076-
devcodex runtime status # Inspect canonical and legacy runtime state
1077-
devcodex runtime prune --dry-run # Preview safe cleanup without writing
1078-
devcodex profile init --tier profile-standard # Generate tiered Profile drafts
1079-
devcodex profile plan --tier profile-closed-loop # Preview a safe upgrade
1080-
devcodex status # Check installation
1081-
devcodex skill plan intent load-profile --max-bytes 32768 --json
1082-
devcodex skill resolve my-ws-skill --json
1083-
devcodex task resolve "my task" --json # Resolve without loading unrelated task bodies
1102+
${c.bold('First use:')}
1103+
npm install -g devcodex
1104+
cd <your-project-or-workspace>
1105+
devcodex init
1106+
devcodex status
1107+
1108+
${c.bold('Update / uninstall:')}
1109+
npm update -g devcodex
1110+
npm uninstall -g devcodex
1111+
1112+
Every command supports ${c.cyan('<command> --help')} and ${c.cyan('help <command>')} without writing files.
1113+
User guide: https://github.com/devcodex-labs/devcodex#readme
10841114
`)
10851115
}
10861116

scripts/test-cli-command-registry.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ assert.strictEqual(fakeProcess.exitCode, 0)
6666
assert.deepStrictEqual(calls.pop(), ['cmdHelp', undefined])
6767
assert.strictEqual(runCliCommand({ cmd: 'help', argv: [], registry, runMigrateLayout: migrate, process: fakeProcess, c, console: logger }), 'help')
6868
assert.deepStrictEqual(calls.pop(), ['cmdHelp', undefined])
69+
assert.strictEqual(runCliCommand({ cmd: 'help', argv: ['runtime'], registry, runMigrateLayout: migrate, process: fakeProcess, c, console: logger }), 'help')
70+
assert.deepStrictEqual(calls.pop(), ['cmdHelp', ['runtime']])
71+
assert.strictEqual(runCliCommand({ cmd: 'init', argv: ['--help'], registry, runMigrateLayout: migrate, process: fakeProcess, c, console: logger }), 'help')
72+
assert.deepStrictEqual(calls.pop(), ['cmdHelp', ['init']])
73+
assert.ok(!calls.some(call => call[0] === 'cmdInitWorkspaceRuntime'))
74+
assert.strictEqual(runCliCommand({ cmd: 'profile', argv: ['init', '--help'], registry, runMigrateLayout: migrate, process: fakeProcess, c, console: logger }), 'help')
75+
assert.deepStrictEqual(calls.pop(), ['cmdHelp', ['profile', 'init']])
76+
assert.strictEqual(runCliCommand({ cmd: 'runtime', argv: ['status', '-h'], registry, runMigrateLayout: migrate, process: fakeProcess, c, console: logger }), 'help')
77+
assert.deepStrictEqual(calls.pop(), ['cmdHelp', ['runtime', 'status']])
6978
logs.length = 0
7079
assert.strictEqual(runCliCommand({ cmd: '--version', argv: [], registry, runMigrateLayout: migrate, process: fakeProcess, c, console: logger, packageVersion: '1.2.3' }), 'version')
7180
assert.strictEqual(logs.pop(), '1.2.3')

scripts/test-client-contracts.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ if (evaluatePublicReadmeContract(damagedPublicReadme).valid ||
3535
)) {
3636
failures.push('incomplete public README must not bypass legacy consumer checks')
3737
}
38+
const missingTaskTutorial = publicReadme.replace('## 常见任务怎么说', '## 任务示例')
39+
if (evaluatePublicReadmeContract(missingTaskTutorial).valid) {
40+
failures.push('public README without the common-task tutorial must fail its contract')
41+
}
3842

3943
const readAbsolute = createCanonicalAwareReader(ROOT, file => fs.readFileSync(file, 'utf8'))
4044
const read = file => readAbsolute(path.join(ROOT, file))

0 commit comments

Comments
 (0)