dev-playbooks-cn 1.0.2 → 1.0.4
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/bin/devbooks.js +101 -2
- package/package.json +1 -1
- package/templates/dev-playbooks/README.md +15 -10
package/bin/devbooks.js
CHANGED
|
@@ -8,9 +8,13 @@
|
|
|
8
8
|
* 用法:
|
|
9
9
|
* dev-playbooks-cn init [path] [options]
|
|
10
10
|
* dev-playbooks-cn update [path]
|
|
11
|
+
* dev-playbooks-cn migrate --from <framework> [options]
|
|
11
12
|
*
|
|
12
13
|
* 选项:
|
|
13
14
|
* --tools <tools> 非交互式指定 AI 工具:all, none, 或逗号分隔的列表
|
|
15
|
+
* --from <framework> 迁移来源框架:openspec, speckit
|
|
16
|
+
* --dry-run 模拟运行,不实际修改文件
|
|
17
|
+
* --keep-old 迁移后保留原目录
|
|
14
18
|
* --help 显示帮助信息
|
|
15
19
|
*/
|
|
16
20
|
|
|
@@ -18,6 +22,7 @@ import fs from 'fs';
|
|
|
18
22
|
import path from 'path';
|
|
19
23
|
import os from 'os';
|
|
20
24
|
import { fileURLToPath } from 'url';
|
|
25
|
+
import { spawn } from 'child_process';
|
|
21
26
|
import { checkbox, confirm } from '@inquirer/prompts';
|
|
22
27
|
import chalk from 'chalk';
|
|
23
28
|
import ora from 'ora';
|
|
@@ -887,6 +892,82 @@ async function updateCommand(projectDir) {
|
|
|
887
892
|
console.log(chalk.green('✓') + ' 更新完成!');
|
|
888
893
|
}
|
|
889
894
|
|
|
895
|
+
// ============================================================================
|
|
896
|
+
// Migrate 命令
|
|
897
|
+
// ============================================================================
|
|
898
|
+
|
|
899
|
+
async function migrateCommand(projectDir, options) {
|
|
900
|
+
console.log();
|
|
901
|
+
console.log(chalk.bold('DevBooks 迁移工具'));
|
|
902
|
+
console.log();
|
|
903
|
+
|
|
904
|
+
const { from, dryRun, keepOld, force } = options;
|
|
905
|
+
|
|
906
|
+
if (!from) {
|
|
907
|
+
console.log(chalk.red('✗') + ' 请指定迁移来源框架:--from openspec 或 --from speckit');
|
|
908
|
+
console.log();
|
|
909
|
+
console.log(chalk.cyan('示例:'));
|
|
910
|
+
console.log(` ${CLI_COMMAND} migrate --from openspec`);
|
|
911
|
+
console.log(` ${CLI_COMMAND} migrate --from speckit`);
|
|
912
|
+
console.log(` ${CLI_COMMAND} migrate --from openspec --dry-run`);
|
|
913
|
+
process.exit(1);
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
const validFrameworks = ['openspec', 'speckit'];
|
|
917
|
+
if (!validFrameworks.includes(from)) {
|
|
918
|
+
console.log(chalk.red('✗') + ` 不支持的框架: ${from}`);
|
|
919
|
+
console.log(chalk.gray(` 支持的框架: ${validFrameworks.join(', ')}`));
|
|
920
|
+
process.exit(1);
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
// 确定脚本路径
|
|
924
|
+
const scriptName = from === 'openspec' ? 'migrate-from-openspec.sh' : 'migrate-from-speckit.sh';
|
|
925
|
+
const scriptPath = path.join(__dirname, '..', 'scripts', scriptName);
|
|
926
|
+
|
|
927
|
+
if (!fs.existsSync(scriptPath)) {
|
|
928
|
+
console.log(chalk.red('✗') + ` 迁移脚本不存在: ${scriptPath}`);
|
|
929
|
+
process.exit(1);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// 构建参数
|
|
933
|
+
const args = ['--project-root', projectDir];
|
|
934
|
+
if (dryRun) args.push('--dry-run');
|
|
935
|
+
if (keepOld) args.push('--keep-old');
|
|
936
|
+
if (force) args.push('--force');
|
|
937
|
+
|
|
938
|
+
console.log(chalk.blue('ℹ') + ` 迁移来源: ${from}`);
|
|
939
|
+
console.log(chalk.blue('ℹ') + ` 项目目录: ${projectDir}`);
|
|
940
|
+
if (dryRun) console.log(chalk.yellow('ℹ') + ' 模式: DRY-RUN(模拟运行)');
|
|
941
|
+
console.log();
|
|
942
|
+
|
|
943
|
+
// 执行脚本
|
|
944
|
+
return new Promise((resolve, reject) => {
|
|
945
|
+
const child = spawn('bash', [scriptPath, ...args], {
|
|
946
|
+
stdio: 'inherit',
|
|
947
|
+
cwd: projectDir
|
|
948
|
+
});
|
|
949
|
+
|
|
950
|
+
child.on('close', (code) => {
|
|
951
|
+
if (code === 0) {
|
|
952
|
+
console.log();
|
|
953
|
+
if (!dryRun) {
|
|
954
|
+
console.log(chalk.green('✓') + ' 迁移完成!');
|
|
955
|
+
console.log();
|
|
956
|
+
console.log(chalk.bold('下一步:'));
|
|
957
|
+
console.log(` 运行 ${chalk.cyan(`${CLI_COMMAND} init`)} 安装 DevBooks Skills`);
|
|
958
|
+
}
|
|
959
|
+
resolve();
|
|
960
|
+
} else {
|
|
961
|
+
reject(new Error(`迁移脚本退出码: ${code}`));
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
child.on('error', (err) => {
|
|
966
|
+
reject(new Error(`执行迁移脚本失败: ${err.message}`));
|
|
967
|
+
});
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
|
|
890
971
|
// ============================================================================
|
|
891
972
|
// 帮助信息
|
|
892
973
|
// ============================================================================
|
|
@@ -896,12 +977,17 @@ function showHelp() {
|
|
|
896
977
|
console.log(chalk.bold('DevBooks') + ' - AI-agnostic spec-driven development workflow');
|
|
897
978
|
console.log();
|
|
898
979
|
console.log(chalk.cyan('用法:'));
|
|
899
|
-
console.log(` ${CLI_COMMAND} init [path] [options]
|
|
900
|
-
console.log(` ${CLI_COMMAND} update [path]
|
|
980
|
+
console.log(` ${CLI_COMMAND} init [path] [options] 初始化 DevBooks`);
|
|
981
|
+
console.log(` ${CLI_COMMAND} update [path] 更新已配置的工具`);
|
|
982
|
+
console.log(` ${CLI_COMMAND} migrate --from <framework> [opts] 从其他框架迁移`);
|
|
901
983
|
console.log();
|
|
902
984
|
console.log(chalk.cyan('选项:'));
|
|
903
985
|
console.log(' --tools <tools> 非交互式指定 AI 工具');
|
|
904
986
|
console.log(' 可用值: all, none, 或逗号分隔的工具 ID');
|
|
987
|
+
console.log(' --from <framework> 迁移来源框架 (openspec, speckit)');
|
|
988
|
+
console.log(' --dry-run 模拟运行,不实际修改文件');
|
|
989
|
+
console.log(' --keep-old 迁移后保留原目录');
|
|
990
|
+
console.log(' --force 强制重新执行所有步骤');
|
|
905
991
|
console.log(' -h, --help 显示此帮助信息');
|
|
906
992
|
console.log();
|
|
907
993
|
console.log(chalk.cyan('支持的 AI 工具:'));
|
|
@@ -943,6 +1029,9 @@ function showHelp() {
|
|
|
943
1029
|
console.log(` ${CLI_COMMAND} init my-project # 在 my-project 目录初始化`);
|
|
944
1030
|
console.log(` ${CLI_COMMAND} init --tools claude,cursor # 非交互式`);
|
|
945
1031
|
console.log(` ${CLI_COMMAND} update # 更新已配置的工具`);
|
|
1032
|
+
console.log(` ${CLI_COMMAND} migrate --from openspec # 从 OpenSpec 迁移`);
|
|
1033
|
+
console.log(` ${CLI_COMMAND} migrate --from speckit # 从 spec-kit 迁移`);
|
|
1034
|
+
console.log(` ${CLI_COMMAND} migrate --from openspec --dry-run # 模拟迁移`);
|
|
946
1035
|
}
|
|
947
1036
|
|
|
948
1037
|
// ============================================================================
|
|
@@ -965,6 +1054,14 @@ async function main() {
|
|
|
965
1054
|
process.exit(0);
|
|
966
1055
|
} else if (arg === '--tools') {
|
|
967
1056
|
options.tools = args[++i];
|
|
1057
|
+
} else if (arg === '--from') {
|
|
1058
|
+
options.from = args[++i];
|
|
1059
|
+
} else if (arg === '--dry-run') {
|
|
1060
|
+
options.dryRun = true;
|
|
1061
|
+
} else if (arg === '--keep-old') {
|
|
1062
|
+
options.keepOld = true;
|
|
1063
|
+
} else if (arg === '--force') {
|
|
1064
|
+
options.force = true;
|
|
968
1065
|
} else if (!arg.startsWith('-')) {
|
|
969
1066
|
if (!command) {
|
|
970
1067
|
command = arg;
|
|
@@ -983,6 +1080,8 @@ async function main() {
|
|
|
983
1080
|
await initCommand(projectDir, options);
|
|
984
1081
|
} else if (command === 'update') {
|
|
985
1082
|
await updateCommand(projectDir);
|
|
1083
|
+
} else if (command === 'migrate') {
|
|
1084
|
+
await migrateCommand(projectDir, options);
|
|
986
1085
|
} else {
|
|
987
1086
|
console.log(chalk.red(`未知命令: ${command}`));
|
|
988
1087
|
showHelp();
|
package/package.json
CHANGED
|
@@ -447,12 +447,14 @@ DevBooks provides migration scripts to help you transition from other spec-drive
|
|
|
447
447
|
If you're currently using [OpenSpec](https://github.com/Fission-AI/OpenSpec) with an `openspec/` directory:
|
|
448
448
|
|
|
449
449
|
```bash
|
|
450
|
-
#
|
|
451
|
-
|
|
450
|
+
# Using CLI (recommended)
|
|
451
|
+
dev-playbooks-cn migrate --from openspec
|
|
452
452
|
|
|
453
|
-
#
|
|
454
|
-
|
|
455
|
-
|
|
453
|
+
# Preview changes first
|
|
454
|
+
dev-playbooks-cn migrate --from openspec --dry-run
|
|
455
|
+
|
|
456
|
+
# Keep original directory after migration
|
|
457
|
+
dev-playbooks-cn migrate --from openspec --keep-old
|
|
456
458
|
```
|
|
457
459
|
|
|
458
460
|
**What gets migrated:**
|
|
@@ -460,18 +462,21 @@ curl -sL https://raw.githubusercontent.com/ozbombor/dev-playbooks-cn/master/scri
|
|
|
460
462
|
- `openspec/changes/` → `dev-playbooks/changes/`
|
|
461
463
|
- `openspec/project.md` → `dev-playbooks/project.md`
|
|
462
464
|
- All path references are automatically updated
|
|
465
|
+
- AI tool command directories are cleaned up (`.claude/commands/openspec/`, etc.)
|
|
463
466
|
|
|
464
467
|
### Migrate from GitHub spec-kit
|
|
465
468
|
|
|
466
469
|
If you're using [GitHub spec-kit](https://github.com/github/spec-kit) with `specs/` and `memory/` directories:
|
|
467
470
|
|
|
468
471
|
```bash
|
|
469
|
-
#
|
|
470
|
-
|
|
472
|
+
# Using CLI (recommended)
|
|
473
|
+
dev-playbooks-cn migrate --from speckit
|
|
474
|
+
|
|
475
|
+
# Preview changes first
|
|
476
|
+
dev-playbooks-cn migrate --from speckit --dry-run
|
|
471
477
|
|
|
472
|
-
#
|
|
473
|
-
|
|
474
|
-
./scripts/migrate-from-speckit.sh --project-root . --keep-old # Keep original directories
|
|
478
|
+
# Keep original directories after migration
|
|
479
|
+
dev-playbooks-cn migrate --from speckit --keep-old
|
|
475
480
|
```
|
|
476
481
|
|
|
477
482
|
**Mapping rules:**
|