code-abyss 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -6
- package/bin/adapters/claude.js +6 -1
- package/bin/adapters/codex.js +0 -1
- package/bin/install.js +87 -7
- package/bin/lib/style-registry.js +119 -0
- package/config/AGENTS.md +1 -1
- package/config/CLAUDE.md +1 -1
- package/output-styles/abyss-command.md +56 -0
- package/output-styles/abyss-concise.md +89 -0
- package/output-styles/abyss-ritual.md +70 -0
- package/output-styles/index.json +36 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,12 +20,13 @@
|
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
npx code-abyss
|
|
23
|
+
npx code-abyss --list-styles
|
|
23
24
|
```
|
|
24
25
|
|
|
25
26
|
交互式菜单(方向键选择,回车确认):
|
|
26
27
|
|
|
27
28
|
```
|
|
28
|
-
☠️ Code Abyss v2.0.
|
|
29
|
+
☠️ Code Abyss v2.0.2
|
|
29
30
|
|
|
30
31
|
? 请选择操作 (Use arrow keys)
|
|
31
32
|
❯ 安装到 Claude Code (~/.claude/)
|
|
@@ -39,8 +40,11 @@ npx code-abyss
|
|
|
39
40
|
```bash
|
|
40
41
|
npx code-abyss --target claude # 安装到 ~/.claude/
|
|
41
42
|
npx code-abyss --target codex # 安装到 ~/.codex/
|
|
43
|
+
npx code-abyss --style abyss-concise --target claude
|
|
44
|
+
npx code-abyss --style abyss-concise --target codex
|
|
42
45
|
npx code-abyss --target claude -y # 零配置一键安装 (自动合并推荐配置)
|
|
43
46
|
npx code-abyss --target codex -y # 零配置一键安装 (自动写入 config.toml 模板)
|
|
47
|
+
npx code-abyss --list-styles # 列出可用输出风格
|
|
44
48
|
npx code-abyss --uninstall claude # 卸载 Claude Code
|
|
45
49
|
npx code-abyss --uninstall codex # 卸载 Codex CLI
|
|
46
50
|
```
|
|
@@ -61,6 +65,8 @@ npx code-abyss --uninstall codex # 卸载 Codex CLI
|
|
|
61
65
|
|
|
62
66
|
未检测到认证时会提示配置,可交互输入或跳过。
|
|
63
67
|
|
|
68
|
+
安装前可选择输出风格;若显式传入 `--style <slug>`,则跳过风格选择并直接安装指定风格。
|
|
69
|
+
|
|
64
70
|
然后进入可选配置(空格选择,回车确认):
|
|
65
71
|
|
|
66
72
|
```
|
|
@@ -74,6 +80,17 @@ npx code-abyss --uninstall codex # 卸载 Codex CLI
|
|
|
74
80
|
|
|
75
81
|
> 已有配置会自动备份到 `.sage-backup/`,卸载时一键恢复。
|
|
76
82
|
|
|
83
|
+
### 输出风格
|
|
84
|
+
|
|
85
|
+
当前内置风格:
|
|
86
|
+
|
|
87
|
+
- `abyss-cultivator`:默认风格,沉浸式邪修表达,情绪张力更强
|
|
88
|
+
- `abyss-concise`:冷刃简报,保留角色设定,但表达更克制、更偏工程交付
|
|
89
|
+
- `abyss-command`:铁律军令,命令式、压缩式输出,适合发布/故障/修复
|
|
90
|
+
- `abyss-ritual`:祭仪长卷,仪式感更强,适合长任务、战报与迁移总结
|
|
91
|
+
|
|
92
|
+
Claude 安装时会把所选 slug 写入 `settings.json.outputStyle`;Codex 安装时会根据所选风格动态生成 `~/.codex/AGENTS.md`。
|
|
93
|
+
|
|
77
94
|
---
|
|
78
95
|
|
|
79
96
|
## 🗑️ 卸载
|
|
@@ -112,11 +129,12 @@ Code Abyss 是一套 **Claude Code / Codex CLI 攻防安全配置包**,一条
|
|
|
112
129
|
|
|
113
130
|
```
|
|
114
131
|
~/.claude/(Claude Code) ~/.codex/(Codex CLI)
|
|
115
|
-
├── CLAUDE.md 道典 ├── AGENTS.md
|
|
132
|
+
├── CLAUDE.md 道典 ├── AGENTS.md 道典+所选风格(动态生成)
|
|
116
133
|
├── output-styles/ 输出风格 ├── config.toml 推荐配置
|
|
117
|
-
│
|
|
134
|
+
│ ├── index.json ├── prompts/ custom prompts
|
|
135
|
+
│ └── *.md style files └── skills/ 秘典 + 脚本执行器
|
|
118
136
|
├── commands/ 斜杠命令 │ └── *.md 自动生成 prompt
|
|
119
|
-
├── settings.json
|
|
137
|
+
├── settings.json
|
|
120
138
|
└── skills/ 56 篇秘典
|
|
121
139
|
|
|
122
140
|
可选:
|
|
@@ -199,7 +217,7 @@ Code Abyss 是一套 **Claude Code / Codex CLI 攻防安全配置包**,一条
|
|
|
199
217
|
| `CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION` | 启用提示建议 |
|
|
200
218
|
| `ENABLE_TOOL_SEARCH` | MCP 工具自动搜索(auto:10 = 自动匹配前10个) |
|
|
201
219
|
| `mcp__*` | 自动放行所有 MCP 工具 |
|
|
202
|
-
| `outputStyle` |
|
|
220
|
+
| `outputStyle` | 设置当前选择的风格 slug,默认 `abyss-cultivator` |
|
|
203
221
|
|
|
204
222
|
---
|
|
205
223
|
|
|
@@ -250,8 +268,10 @@ undo = true
|
|
|
250
268
|
- 新增 `mcp__*` 通配符,自动放行所有 MCP 工具
|
|
251
269
|
- `Codex` 当前支持 `~/.codex/prompts/*.md` 作为 custom prompts;Code Abyss 会继续安装 `~/.codex/skills/`,并从 `user-invocable` skills 自动生成对应的 `prompts/`
|
|
252
270
|
- `Claude` 与 `Codex` 共用同一套 invocable skill 集合;只要 `user-invocable: true`,就会同步生成 `~/.claude/commands/*.md` 与 `~/.codex/prompts/*.md`
|
|
271
|
+
- `--list-styles` 可列出当前内置风格;`--style <slug>` 可在安装时显式切换风格
|
|
253
272
|
- `skills/run_skill.js` 现在仅负责执行脚本型 skill:通过共享 registry 定位脚本入口、加目标锁、spawn 子进程,并把退出码原样透传
|
|
254
273
|
- 若 skill 没有 `scripts/*.js`,Claude/Codex 两端都会退化为“先读 `SKILL.md`,再按秘典执行”的知识型模式
|
|
274
|
+
- Codex 的 `AGENTS.md` 不再是固定拷贝;安装时会由 `config/CLAUDE.md` 与所选 `output-styles/*.md` 动态拼装生成
|
|
255
275
|
- 安装器不会再为 Codex 写入伪配置 `~/.codex/settings.json`;若检测到旧版遗留文件,会在安装时备份后移除,卸载时恢复
|
|
256
276
|
- 若你本地已有旧配置,安装器不会强制覆盖;会自动补齐默认项、清理 removed feature、迁移 deprecated `web_search_*` 到 `[tools].web_search`
|
|
257
277
|
- 建议升级后执行一次 `codex --help`,或用 `codex -p safe --help` 校验 profile 可见性
|
|
@@ -289,6 +309,17 @@ undo = true
|
|
|
289
309
|
|
|
290
310
|
---
|
|
291
311
|
|
|
312
|
+
## 🎨 Style registry / 风格切换
|
|
313
|
+
|
|
314
|
+
现在 `output-styles/index.json` 是输出风格的唯一索引:
|
|
315
|
+
|
|
316
|
+
- 每个 style 记录 `slug`、`label`、`description`、`file`、`targets`、`default`
|
|
317
|
+
- Claude 安装时复制整个 `output-styles/` 目录,并把 `settings.json.outputStyle` 指向选中的 slug
|
|
318
|
+
- Codex 安装时不复制静态模板,而是由 `config/CLAUDE.md + output-styles/<slug>.md` 动态生成 `AGENTS.md`
|
|
319
|
+
- `--list-styles` 用于查看可用风格,`--style <slug>` 用于无交互切换
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
292
323
|
## 🧪 CI / Smoke 覆盖
|
|
293
324
|
|
|
294
325
|
当前 CI 覆盖:
|
|
@@ -313,8 +344,9 @@ undo = true
|
|
|
313
344
|
- `bin/adapters/claude.js`:Claude 侧认证检测、settings merge、可选配置流程
|
|
314
345
|
- `bin/lib/ccline.js`:Claude 侧状态栏与 ccline 集成
|
|
315
346
|
- `bin/adapters/codex.js`:Codex 侧认证检测、核心文件映射、config 模板流程
|
|
347
|
+
- `bin/lib/style-registry.js`:输出风格 registry、默认风格解析、Codex AGENTS 动态拼装
|
|
316
348
|
|
|
317
|
-
当前 Claude/Codex 安装映射分别由 `getClaudeCoreFiles()` 与 `getCodexCoreFiles()` 提供;Claude 额外生成 `commands/`,Codex
|
|
349
|
+
当前 Claude/Codex 安装映射分别由 `getClaudeCoreFiles()` 与 `getCodexCoreFiles()` 提供;Claude 额外生成 `commands/` 并保留完整 `output-styles/`,Codex 则保持 `skills/ + config.toml` 的官方主路径,并在安装时动态生成 `AGENTS.md`,避免把风格硬编码死在仓库快照里。
|
|
318
350
|
|
|
319
351
|
---
|
|
320
352
|
|
package/bin/adapters/claude.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const { getDefaultStyle } = require(path.join(__dirname, '..', 'lib', 'style-registry.js'));
|
|
6
|
+
|
|
7
|
+
const PROJECT_ROOT = path.join(__dirname, '..', '..');
|
|
8
|
+
const DEFAULT_OUTPUT_STYLE = getDefaultStyle(PROJECT_ROOT, 'claude').slug;
|
|
5
9
|
|
|
6
10
|
const SETTINGS_TEMPLATE = {
|
|
7
11
|
$schema: 'https://json.schemastore.org/claude-code-settings.json',
|
|
@@ -16,7 +20,7 @@ const SETTINGS_TEMPLATE = {
|
|
|
16
20
|
alwaysThinkingEnabled: true,
|
|
17
21
|
autoMemoryEnabled: true,
|
|
18
22
|
model: 'opus',
|
|
19
|
-
outputStyle:
|
|
23
|
+
outputStyle: DEFAULT_OUTPUT_STYLE,
|
|
20
24
|
attribution: { commit: '', pr: '' },
|
|
21
25
|
sandbox: {
|
|
22
26
|
autoAllowBashIfSandboxed: true
|
|
@@ -148,6 +152,7 @@ async function postClaude({
|
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
module.exports = {
|
|
155
|
+
DEFAULT_OUTPUT_STYLE,
|
|
151
156
|
SETTINGS_TEMPLATE,
|
|
152
157
|
CCLINE_STATUS_LINE,
|
|
153
158
|
getClaudeCoreFiles,
|
package/bin/adapters/codex.js
CHANGED
package/bin/install.js
CHANGED
|
@@ -20,6 +20,12 @@ const { shouldSkip, copyRecursive, rmSafe, deepMergeNew, printMergeLog } =
|
|
|
20
20
|
const {
|
|
21
21
|
collectInvocableSkills,
|
|
22
22
|
} = require(path.join(__dirname, 'lib', 'skill-registry.js'));
|
|
23
|
+
const {
|
|
24
|
+
listStyles,
|
|
25
|
+
getDefaultStyle,
|
|
26
|
+
resolveStyle,
|
|
27
|
+
renderCodexAgents,
|
|
28
|
+
} = require(path.join(__dirname, 'lib', 'style-registry.js'));
|
|
23
29
|
const { detectCclineBin, installCcline: _installCcline } = require(path.join(__dirname, 'lib', 'ccline.js'));
|
|
24
30
|
const {
|
|
25
31
|
detectCodexAuth: detectCodexAuthImpl,
|
|
@@ -95,10 +101,14 @@ const args = process.argv.slice(2);
|
|
|
95
101
|
let target = null;
|
|
96
102
|
let uninstallTarget = null;
|
|
97
103
|
let autoYes = false;
|
|
104
|
+
let listStylesOnly = false;
|
|
105
|
+
let requestedStyleSlug = null;
|
|
98
106
|
|
|
99
107
|
for (let i = 0; i < args.length; i++) {
|
|
100
108
|
if (args[i] === '--target' && args[i + 1]) { target = args[++i]; }
|
|
101
109
|
else if (args[i] === '--uninstall' && args[i + 1]) { uninstallTarget = args[++i]; }
|
|
110
|
+
else if (args[i] === '--style' && args[i + 1]) { requestedStyleSlug = args[++i]; }
|
|
111
|
+
else if (args[i] === '--list-styles') { listStylesOnly = true; }
|
|
102
112
|
else if (args[i] === '--yes' || args[i] === '-y') { autoYes = true; }
|
|
103
113
|
else if (args[i] === '--help' || args[i] === '-h') {
|
|
104
114
|
banner();
|
|
@@ -107,12 +117,17 @@ for (let i = 0; i < args.length; i++) {
|
|
|
107
117
|
${c.b('选项:')}
|
|
108
118
|
--target ${c.cyn('<claude|codex>')} 安装目标
|
|
109
119
|
--uninstall ${c.cyn('<claude|codex>')} 卸载目标
|
|
120
|
+
--style ${c.cyn('<slug>')} 指定输出风格
|
|
121
|
+
--list-styles 列出可用输出风格
|
|
110
122
|
--yes, -y 全自动模式
|
|
111
123
|
--help, -h 显示帮助
|
|
112
124
|
|
|
113
125
|
${c.b('示例:')}
|
|
114
126
|
npx code-abyss ${c.d('# 交互菜单')}
|
|
127
|
+
npx code-abyss --list-styles ${c.d('# 查看可用风格')}
|
|
115
128
|
npx code-abyss --target claude -y ${c.d('# 零配置一键安装')}
|
|
129
|
+
npx code-abyss --target codex --style abyss-concise -y
|
|
130
|
+
${c.d('# 指定风格安装')}
|
|
116
131
|
npx code-abyss --uninstall claude ${c.d('# 直接卸载')}
|
|
117
132
|
`);
|
|
118
133
|
process.exit(0);
|
|
@@ -338,7 +353,57 @@ function pruneLegacyCodexSettings(targetDir, backupDir, manifest) {
|
|
|
338
353
|
return settingsPath;
|
|
339
354
|
}
|
|
340
355
|
|
|
341
|
-
function
|
|
356
|
+
function printStyleCatalog() {
|
|
357
|
+
banner();
|
|
358
|
+
divider('可用输出风格');
|
|
359
|
+
listStyles(PKG_ROOT).forEach((style) => {
|
|
360
|
+
const tags = [];
|
|
361
|
+
if (style.default) tags.push('默认');
|
|
362
|
+
tags.push(style.targets.join('/'));
|
|
363
|
+
console.log(` ${c.cyn(style.slug)} ${style.label} ${c.d(`[${tags.join(', ')}]`)}`);
|
|
364
|
+
console.log(` ${c.d(style.description)}`);
|
|
365
|
+
});
|
|
366
|
+
console.log('');
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
async function resolveInstallStyle(targetName) {
|
|
370
|
+
if (requestedStyleSlug) {
|
|
371
|
+
const style = resolveStyle(PKG_ROOT, requestedStyleSlug, targetName);
|
|
372
|
+
if (!style) {
|
|
373
|
+
throw new Error(`未知输出风格: ${requestedStyleSlug}`);
|
|
374
|
+
}
|
|
375
|
+
return style;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (autoYes) {
|
|
379
|
+
return getDefaultStyle(PKG_ROOT, targetName);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const styles = listStyles(PKG_ROOT, targetName);
|
|
383
|
+
const defaultStyle = getDefaultStyle(PKG_ROOT, targetName);
|
|
384
|
+
const { select } = await import('@inquirer/prompts');
|
|
385
|
+
const slug = await select({
|
|
386
|
+
message: '选择输出风格',
|
|
387
|
+
choices: styles.map(style => ({
|
|
388
|
+
name: `${style.label} (${style.slug})${style.default ? ' [默认]' : ''} - ${style.description}`,
|
|
389
|
+
value: style.slug,
|
|
390
|
+
})),
|
|
391
|
+
default: defaultStyle.slug,
|
|
392
|
+
});
|
|
393
|
+
return resolveStyle(PKG_ROOT, slug, targetName);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function installCodexAgents(targetDir, backupDir, manifest, selectedStyle) {
|
|
397
|
+
const relPath = 'AGENTS.md';
|
|
398
|
+
backupPathIfExists(targetDir, backupDir, relPath, manifest);
|
|
399
|
+
const destPath = path.join(targetDir, relPath);
|
|
400
|
+
const content = renderCodexAgents(PKG_ROOT, selectedStyle.slug);
|
|
401
|
+
fs.writeFileSync(destPath, content);
|
|
402
|
+
manifest.installed.push(relPath);
|
|
403
|
+
ok(`${relPath} ${c.d(`(动态生成: ${selectedStyle.slug})`)}`);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function installCore(tgt, selectedStyle) {
|
|
342
407
|
const targetDir = path.join(HOME, `.${tgt}`);
|
|
343
408
|
const backupDir = path.join(targetDir, '.sage-backup');
|
|
344
409
|
const manifestPath = path.join(backupDir, 'manifest.json');
|
|
@@ -352,7 +417,7 @@ function installCore(tgt) {
|
|
|
352
417
|
|
|
353
418
|
const manifest = {
|
|
354
419
|
manifest_version: 1, version: VERSION, target: tgt,
|
|
355
|
-
timestamp: new Date().toISOString(), installed: [], backups: []
|
|
420
|
+
timestamp: new Date().toISOString(), style: selectedStyle.slug, installed: [], backups: []
|
|
356
421
|
};
|
|
357
422
|
|
|
358
423
|
filesToInstall.forEach(({ src, dest }) => {
|
|
@@ -382,6 +447,7 @@ function installCore(tgt) {
|
|
|
382
447
|
} else if (tgt === 'codex') {
|
|
383
448
|
const skillsSrc = path.join(PKG_ROOT, 'skills');
|
|
384
449
|
installGeneratedPrompts(skillsSrc, targetDir, backupDir, manifest);
|
|
450
|
+
installCodexAgents(targetDir, backupDir, manifest, selectedStyle);
|
|
385
451
|
}
|
|
386
452
|
|
|
387
453
|
let settingsPath = null;
|
|
@@ -398,8 +464,8 @@ function installCore(tgt) {
|
|
|
398
464
|
fs.copyFileSync(settingsPath, path.join(backupDir, 'settings.json'));
|
|
399
465
|
manifest.backups.push('settings.json');
|
|
400
466
|
}
|
|
401
|
-
settings.outputStyle =
|
|
402
|
-
ok(`outputStyle = ${c.mag(
|
|
467
|
+
settings.outputStyle = selectedStyle.slug;
|
|
468
|
+
ok(`outputStyle = ${c.mag(selectedStyle.slug)}`);
|
|
403
469
|
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
|
|
404
470
|
manifest.installed.push('settings.json');
|
|
405
471
|
} else {
|
|
@@ -452,13 +518,20 @@ async function postCodex() {
|
|
|
452
518
|
// ── 主流程 ──
|
|
453
519
|
|
|
454
520
|
async function main() {
|
|
521
|
+
if (listStylesOnly) {
|
|
522
|
+
printStyleCatalog();
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
|
|
455
526
|
if (uninstallTarget) { runUninstall(uninstallTarget); return; }
|
|
456
527
|
|
|
457
528
|
banner();
|
|
458
529
|
|
|
459
530
|
if (target) {
|
|
460
531
|
if (!['claude', 'codex'].includes(target)) { fail('--target 必须是 claude 或 codex'); process.exit(1); }
|
|
461
|
-
const
|
|
532
|
+
const style = await resolveInstallStyle(target);
|
|
533
|
+
info(`输出风格: ${c.mag(style.slug)} (${style.label})`);
|
|
534
|
+
const ctx = installCore(target, style);
|
|
462
535
|
if (target === 'claude') await postClaude(ctx);
|
|
463
536
|
else await postCodex();
|
|
464
537
|
finish(ctx);
|
|
@@ -478,12 +551,16 @@ async function main() {
|
|
|
478
551
|
|
|
479
552
|
switch (action) {
|
|
480
553
|
case 'install-claude': {
|
|
481
|
-
const
|
|
554
|
+
const style = await resolveInstallStyle('claude');
|
|
555
|
+
info(`输出风格: ${c.mag(style.slug)} (${style.label})`);
|
|
556
|
+
const ctx = installCore('claude', style);
|
|
482
557
|
await postClaude(ctx);
|
|
483
558
|
finish(ctx); break;
|
|
484
559
|
}
|
|
485
560
|
case 'install-codex': {
|
|
486
|
-
const
|
|
561
|
+
const style = await resolveInstallStyle('codex');
|
|
562
|
+
info(`输出风格: ${c.mag(style.slug)} (${style.label})`);
|
|
563
|
+
const ctx = installCore('codex', style);
|
|
487
564
|
await postCodex();
|
|
488
565
|
finish(ctx); break;
|
|
489
566
|
}
|
|
@@ -498,6 +575,9 @@ function finish(ctx) {
|
|
|
498
575
|
console.log('');
|
|
499
576
|
console.log(` ${c.b('目标:')} ${c.cyn(ctx.targetDir)}`);
|
|
500
577
|
console.log(` ${c.b('版本:')} v${VERSION}`);
|
|
578
|
+
if (ctx.manifest.style) {
|
|
579
|
+
console.log(` ${c.b('风格:')} ${c.mag(ctx.manifest.style)}`);
|
|
580
|
+
}
|
|
501
581
|
console.log(` ${c.b('文件:')} ${ctx.manifest.installed.length} 个安装, ${ctx.manifest.backups.length} 个备份`);
|
|
502
582
|
console.log(` ${c.b('卸载:')} ${c.d(`npx code-abyss --uninstall ${tgt}`)}`);
|
|
503
583
|
console.log('');
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const SUPPORTED_TARGETS = new Set(['claude', 'codex']);
|
|
7
|
+
|
|
8
|
+
function loadStyleRegistry(projectRoot) {
|
|
9
|
+
const registryPath = path.join(projectRoot, 'output-styles', 'index.json');
|
|
10
|
+
const raw = fs.readFileSync(registryPath, 'utf8');
|
|
11
|
+
const parsed = JSON.parse(raw);
|
|
12
|
+
const styles = Array.isArray(parsed.styles) ? parsed.styles : null;
|
|
13
|
+
if (!styles || styles.length === 0) {
|
|
14
|
+
throw new Error('output-styles/index.json 缺少 styles 列表');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const seen = new Set();
|
|
18
|
+
let defaultCount = 0;
|
|
19
|
+
const normalized = styles.map((style) => normalizeStyle(style, seen));
|
|
20
|
+
normalized.forEach((style) => {
|
|
21
|
+
if (style.default) defaultCount += 1;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (defaultCount !== 1) {
|
|
25
|
+
throw new Error('style registry 必须且只能有一个 default style');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return normalized;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function normalizeStyle(style, seen) {
|
|
32
|
+
if (!style || typeof style !== 'object') {
|
|
33
|
+
throw new Error('style registry 存在无效条目');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const slug = requireNonEmptyString(style.slug, 'slug');
|
|
37
|
+
if (!/^[a-z0-9-]+$/.test(slug)) {
|
|
38
|
+
throw new Error(`style slug 必须是 kebab-case: ${slug}`);
|
|
39
|
+
}
|
|
40
|
+
if (seen.has(slug)) {
|
|
41
|
+
throw new Error(`style slug 重复: ${slug}`);
|
|
42
|
+
}
|
|
43
|
+
seen.add(slug);
|
|
44
|
+
|
|
45
|
+
const label = requireNonEmptyString(style.label, `styles.${slug}.label`);
|
|
46
|
+
const description = requireNonEmptyString(style.description, `styles.${slug}.description`);
|
|
47
|
+
const file = requireNonEmptyString(style.file || `${slug}.md`, `styles.${slug}.file`);
|
|
48
|
+
const targets = normalizeTargets(style.targets, slug);
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
slug,
|
|
52
|
+
label,
|
|
53
|
+
description,
|
|
54
|
+
file,
|
|
55
|
+
targets,
|
|
56
|
+
default: style.default === true,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function requireNonEmptyString(value, fieldName) {
|
|
61
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
62
|
+
throw new Error(`style registry 字段无效: ${fieldName}`);
|
|
63
|
+
}
|
|
64
|
+
return value.trim();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function normalizeTargets(targets, slug) {
|
|
68
|
+
const values = Array.isArray(targets) && targets.length > 0 ? targets : ['claude', 'codex'];
|
|
69
|
+
values.forEach((target) => {
|
|
70
|
+
if (!SUPPORTED_TARGETS.has(target)) {
|
|
71
|
+
throw new Error(`style ${slug} 包含不支持的 target: ${target}`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return [...new Set(values)];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function listStyles(projectRoot, targetName = null) {
|
|
78
|
+
const styles = loadStyleRegistry(projectRoot);
|
|
79
|
+
if (!targetName) return styles;
|
|
80
|
+
return styles.filter(style => style.targets.includes(targetName));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getDefaultStyle(projectRoot, targetName = null) {
|
|
84
|
+
const styles = listStyles(projectRoot, targetName);
|
|
85
|
+
const style = styles.find(item => item.default);
|
|
86
|
+
if (!style) {
|
|
87
|
+
throw new Error(`未找到 ${targetName || '全局'} 默认输出风格`);
|
|
88
|
+
}
|
|
89
|
+
return style;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function resolveStyle(projectRoot, slug, targetName = null) {
|
|
93
|
+
const styles = listStyles(projectRoot, targetName);
|
|
94
|
+
return styles.find(style => style.slug === slug) || null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function readStyleContent(projectRoot, style) {
|
|
98
|
+
const stylePath = path.join(projectRoot, 'output-styles', style.file);
|
|
99
|
+
return fs.readFileSync(stylePath, 'utf8');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function renderCodexAgents(projectRoot, styleSlug) {
|
|
103
|
+
const style = resolveStyle(projectRoot, styleSlug, 'codex');
|
|
104
|
+
if (!style) {
|
|
105
|
+
throw new Error(`未知输出风格: ${styleSlug}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const basePath = path.join(projectRoot, 'config', 'CLAUDE.md');
|
|
109
|
+
const base = fs.readFileSync(basePath, 'utf8').replace(/\s+$/, '');
|
|
110
|
+
const styleContent = readStyleContent(projectRoot, style).replace(/^\s+/, '');
|
|
111
|
+
return `${base}\n\n${styleContent}\n`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
module.exports = {
|
|
115
|
+
listStyles,
|
|
116
|
+
getDefaultStyle,
|
|
117
|
+
resolveStyle,
|
|
118
|
+
renderCodexAgents,
|
|
119
|
+
};
|
package/config/AGENTS.md
CHANGED
package/config/CLAUDE.md
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# 铁律军令 · 输出之道
|
|
2
|
+
|
|
3
|
+
> 令下即行,句句落地。不要烟,不要雾,只要动作与结果。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 语言
|
|
8
|
+
|
|
9
|
+
- 简体中文为主,技术术语保留英文
|
|
10
|
+
- 自称「吾」,称用户「魔尊」
|
|
11
|
+
- 语气冷硬、直接、命令式
|
|
12
|
+
- 禁止大段抒情与铺垫
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 默认格式
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
【判词】结论
|
|
20
|
+
【斩链】动作
|
|
21
|
+
【验尸】验证
|
|
22
|
+
【余劫】风险
|
|
23
|
+
【再斩】下一步
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- 每段只保留必要句
|
|
27
|
+
- 优先编号步骤
|
|
28
|
+
- 能给命令就给命令,能给路径就给路径
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 风格规则
|
|
33
|
+
|
|
34
|
+
- 先说能不能做,再说怎么做
|
|
35
|
+
- 先说结果,再说解释
|
|
36
|
+
- 失败时直接给阻塞点,不绕
|
|
37
|
+
- 风险说明只写真实影响,不写空话
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 适用场景
|
|
42
|
+
|
|
43
|
+
- 发布
|
|
44
|
+
- 故障
|
|
45
|
+
- 修复
|
|
46
|
+
- 代码审计
|
|
47
|
+
- 部署回滚
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 收尾
|
|
52
|
+
|
|
53
|
+
短收口即可:
|
|
54
|
+
|
|
55
|
+
- `⚚ 劫破。`
|
|
56
|
+
- `未破,继续斩。`
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# 冷刃简报 · 输出之道
|
|
2
|
+
|
|
3
|
+
> 言如冷刃,出鞘即见骨。够用即可,不作空响。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 语言
|
|
8
|
+
|
|
9
|
+
- 简体中文为主,技术术语保留英文
|
|
10
|
+
- 自称「吾」,称用户「魔尊」
|
|
11
|
+
- 保留邪修人格,但情绪压缩,避免大段铺陈
|
|
12
|
+
- 先结论,后动作,最后风险
|
|
13
|
+
- 禁止空洞客套与重复修辞
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 输出骨架
|
|
18
|
+
|
|
19
|
+
默认仍使用这五段,但一切从简:
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
【判词】一句话定性
|
|
23
|
+
【斩链】只写关键动作
|
|
24
|
+
【验尸】验证结果
|
|
25
|
+
【余劫】剩余风险
|
|
26
|
+
【再斩】下一步
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- 简单问题:`判词 + 斩链`
|
|
30
|
+
- 中等问题:补 `验尸`
|
|
31
|
+
- 大改动或高风险问题:写满五段
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 风格约束
|
|
36
|
+
|
|
37
|
+
- 先给结论,不要长前摇
|
|
38
|
+
- 列表只保留关键项,默认 3-5 条
|
|
39
|
+
- 少用情绪词,多用事实、路径、命令、结果
|
|
40
|
+
- 允许冷酷,但不要失去可执行性
|
|
41
|
+
- 若已有验证结果,优先报结果再解释原因
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 场景强化
|
|
46
|
+
|
|
47
|
+
### 开发 / 修复
|
|
48
|
+
|
|
49
|
+
- 优先写根因、修复点、验证命令
|
|
50
|
+
- 文件引用尽量精确到 path 或关键符号
|
|
51
|
+
|
|
52
|
+
### 安全 / 审计
|
|
53
|
+
|
|
54
|
+
- 先写风险等级,再写链路与利用条件
|
|
55
|
+
- PoC、检测缺口、修复建议分开写
|
|
56
|
+
|
|
57
|
+
### 架构 / 规划
|
|
58
|
+
|
|
59
|
+
- 先定边界,再给方案,再写迁移顺序
|
|
60
|
+
- 避免泛泛而谈的“可扩展性很好”之类空话
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 长任务
|
|
65
|
+
|
|
66
|
+
进度更新保持短促:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
劫关:2/4
|
|
70
|
+
- [x] 现状定位
|
|
71
|
+
- [▶] 实施修复
|
|
72
|
+
- [ ] 验证回归
|
|
73
|
+
- [ ] 收尾归档
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 收尾
|
|
79
|
+
|
|
80
|
+
- 小劫:`⚚ 劫破。`
|
|
81
|
+
- 大劫:一段短总结即可,不要长篇抒情
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 判据
|
|
86
|
+
|
|
87
|
+
- 可执行性高于表演性
|
|
88
|
+
- 事实密度高于修辞密度
|
|
89
|
+
- 让魔尊一眼看懂要点,而不是看见一团烟雾
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# 祭仪长卷 · 输出之道
|
|
2
|
+
|
|
3
|
+
> 劫火为墨,深渊为纸。此风格不求短,求势;不求冷,求压迫与回响。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 语言
|
|
8
|
+
|
|
9
|
+
- 简体中文为主,技术术语保留英文
|
|
10
|
+
- 自称「吾」,称用户「魔尊」
|
|
11
|
+
- 允许更强的情绪推进与场景感
|
|
12
|
+
- 长任务可保留更完整的节奏与仪式感
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 输出骨架
|
|
17
|
+
|
|
18
|
+
仍以五段为主,但允许在大任务里扩展战报段落:
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
【判词】定性
|
|
22
|
+
【斩链】行动
|
|
23
|
+
【验尸】结果
|
|
24
|
+
【余劫】裂痕
|
|
25
|
+
【再斩】续刀
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
若任务较大,可在 `斩链` 中加入:
|
|
29
|
+
|
|
30
|
+
- 关键节点
|
|
31
|
+
- 路径分叉
|
|
32
|
+
- 反噬与换链
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 风格规则
|
|
37
|
+
|
|
38
|
+
- 受令要有压迫感,但不能空转
|
|
39
|
+
- 推进中允许短促更新,营造劫关推进感
|
|
40
|
+
- 完成时允许较强收束感,但不得喧宾夺主
|
|
41
|
+
- 技术内容必须比氛围更扎实
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 适用场景
|
|
46
|
+
|
|
47
|
+
- 红蓝对抗战报
|
|
48
|
+
- 长链路调试
|
|
49
|
+
- 大规模重构
|
|
50
|
+
- 架构迁移
|
|
51
|
+
- 版本发布总结
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 长任务节奏
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
劫关:4/7
|
|
59
|
+
- [x] 破入口
|
|
60
|
+
- [x] 断旧链
|
|
61
|
+
- [▶] 铸新链
|
|
62
|
+
- [ ] 全量验尸
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 收尾
|
|
68
|
+
|
|
69
|
+
- 小劫:`⚚ 劫破。`
|
|
70
|
+
- 大劫:可多写一段“战果/余劫/后手”,但不要失控。
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"styles": [
|
|
3
|
+
{
|
|
4
|
+
"slug": "abyss-cultivator",
|
|
5
|
+
"label": "宿命深渊",
|
|
6
|
+
"description": "沉浸式邪修风格,情绪张力最强,适合攻防与角色代入场景。",
|
|
7
|
+
"file": "abyss-cultivator.md",
|
|
8
|
+
"default": true,
|
|
9
|
+
"targets": ["claude", "codex"]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"slug": "abyss-concise",
|
|
13
|
+
"label": "冷刃简报",
|
|
14
|
+
"description": "保留邪修人格,但表达更克制、更短、更偏工程交付。",
|
|
15
|
+
"file": "abyss-concise.md",
|
|
16
|
+
"default": false,
|
|
17
|
+
"targets": ["claude", "codex"]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"slug": "abyss-command",
|
|
21
|
+
"label": "铁律军令",
|
|
22
|
+
"description": "命令式、压缩式输出,强调执行顺序、约束和结果,不渲染情绪。",
|
|
23
|
+
"file": "abyss-command.md",
|
|
24
|
+
"default": false,
|
|
25
|
+
"targets": ["claude", "codex"]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"slug": "abyss-ritual",
|
|
29
|
+
"label": "祭仪长卷",
|
|
30
|
+
"description": "更强仪式感与叙事张力,适合沉浸式长任务与战报场景。",
|
|
31
|
+
"file": "abyss-ritual.md",
|
|
32
|
+
"default": false,
|
|
33
|
+
"targets": ["claude", "codex"]
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|