prd-workflow-cli 1.1.29 → 1.1.31
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 +35 -18
- package/bin/prd-cli.js +24 -5
- package/commands/init.js +41 -17
- package/package.json +2 -2
- package/scripts/postinstall.js +29 -1
package/README.md
CHANGED
|
@@ -55,45 +55,62 @@ C3(版本冻结)
|
|
|
55
55
|
|
|
56
56
|
## 🚀 安装
|
|
57
57
|
|
|
58
|
-
### 方式1
|
|
58
|
+
### 方式1:一键初始化(推荐)✨
|
|
59
|
+
|
|
60
|
+
只需一个命令,**自动完成初始化并配置 AI 规则文件**:
|
|
59
61
|
|
|
60
62
|
```bash
|
|
61
|
-
#
|
|
62
|
-
|
|
63
|
+
# 1. 创建并进入项目目录
|
|
64
|
+
mkdir 我的项目 && cd 我的项目
|
|
63
65
|
|
|
64
|
-
#
|
|
65
|
-
|
|
66
|
+
# 2. 一键初始化(自动配置一切!)
|
|
67
|
+
npx prd-workflow-cli
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
git clone https://github.com/houtonghoutong/PRD-CLI.git
|
|
73
|
-
cd PRD-CLI/prd-cli
|
|
70
|
+
就这样!运行后你会看到:
|
|
71
|
+
- ✅ `.agent/workflows/` - PRD 工作流指引
|
|
72
|
+
- ✅ `.cursorrules` - Cursor AI 规则
|
|
73
|
+
- ✅ `.antigravity/` - Antigravity AI 规则
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
> 💡 **现在你的 AI 助手已经知道如何协助你完成 PRD 流程了!**
|
|
76
|
+
> 例如:直接告诉 AI "我要创建一个新项目的需求文档"
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
npm link
|
|
80
|
-
```
|
|
78
|
+
### 方式2:全局安装
|
|
81
79
|
|
|
82
|
-
|
|
80
|
+
如果你经常使用,可以全局安装:
|
|
83
81
|
|
|
84
82
|
```bash
|
|
85
|
-
# 稍后可用
|
|
86
83
|
npm install -g prd-workflow-cli
|
|
84
|
+
|
|
85
|
+
# 然后使用
|
|
86
|
+
prd init 我的项目
|
|
87
|
+
cd 我的项目
|
|
88
|
+
npm install # 重要!这一步会安装 AI 规则文件
|
|
87
89
|
```
|
|
88
90
|
|
|
91
|
+
### 方式3:从源码安装
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
git clone https://github.com/houtonghoutong/PRD-CLI.git
|
|
95
|
+
cd PRD-CLI/prd-cli
|
|
96
|
+
npm install
|
|
97
|
+
npm link
|
|
98
|
+
```
|
|
89
99
|
|
|
90
100
|
## 📝 快速开始
|
|
91
101
|
|
|
92
102
|
### 1. 初始化项目
|
|
93
103
|
|
|
94
104
|
```bash
|
|
105
|
+
# 使用 npx(推荐)
|
|
106
|
+
npx prd-workflow-cli init my-product
|
|
107
|
+
cd my-product
|
|
108
|
+
npm install
|
|
109
|
+
|
|
110
|
+
# 或者全局安装后使用
|
|
95
111
|
prd init my-product
|
|
96
112
|
cd my-product
|
|
113
|
+
npm install
|
|
97
114
|
```
|
|
98
115
|
|
|
99
116
|
这将创建标准的目录结构:
|
package/bin/prd-cli.js
CHANGED
|
@@ -126,9 +126,28 @@ program.on('--help', () => {
|
|
|
126
126
|
console.log('');
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
// 智能处理:无参数时自动初始化
|
|
130
|
+
if (process.argv.length === 2) {
|
|
131
|
+
const fs = require('fs');
|
|
132
|
+
const path = require('path');
|
|
133
|
+
const configPath = path.join(process.cwd(), '.prd-config.json');
|
|
134
|
+
|
|
135
|
+
if (!fs.existsSync(configPath)) {
|
|
136
|
+
// 不是 PRD 项目,自动初始化
|
|
137
|
+
console.log(chalk.blue('📦 检测到当前目录尚未初始化 PRD 项目'));
|
|
138
|
+
console.log(chalk.blue('🚀 正在自动初始化...'));
|
|
139
|
+
console.log('');
|
|
140
|
+
require('../commands/init')('.').then(() => {
|
|
141
|
+
process.exit(0);
|
|
142
|
+
}).catch((err) => {
|
|
143
|
+
console.error(chalk.red('初始化失败:'), err.message);
|
|
144
|
+
process.exit(1);
|
|
145
|
+
});
|
|
146
|
+
} else {
|
|
147
|
+
// 已经是 PRD 项目,显示帮助
|
|
148
|
+
program.parse(process.argv);
|
|
149
|
+
program.outputHelp();
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
program.parse(process.argv);
|
|
134
153
|
}
|
package/commands/init.js
CHANGED
|
@@ -3,16 +3,25 @@ const path = require('path');
|
|
|
3
3
|
const chalk = require('chalk');
|
|
4
4
|
|
|
5
5
|
module.exports = async function (projectName) {
|
|
6
|
-
|
|
6
|
+
// 支持 "." 表示在当前目录初始化
|
|
7
|
+
const isCurrentDir = projectName === '.';
|
|
8
|
+
const projectPath = isCurrentDir ? process.cwd() : path.join(process.cwd(), projectName);
|
|
9
|
+
const displayName = isCurrentDir ? path.basename(process.cwd()) : projectName;
|
|
7
10
|
|
|
8
11
|
try {
|
|
9
|
-
//
|
|
10
|
-
if (await fs.pathExists(projectPath)) {
|
|
12
|
+
// 检查目录是否已存在(仅当创建新目录时)
|
|
13
|
+
if (!isCurrentDir && await fs.pathExists(projectPath)) {
|
|
11
14
|
console.log(chalk.red(`✗ 目录 ${projectName} 已存在`));
|
|
12
15
|
return;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
// 检查当前目录是否已经是 PRD 项目
|
|
19
|
+
if (isCurrentDir && await fs.pathExists(path.join(projectPath, '.prd-config.json'))) {
|
|
20
|
+
console.log(chalk.red('✗ 当前目录已经是 PRD 项目'));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
console.log(chalk.blue(`正在${isCurrentDir ? '在当前目录' : '创建项目: ' + projectName}初始化...`));
|
|
16
25
|
|
|
17
26
|
// 创建项目目录结构
|
|
18
27
|
const directories = [
|
|
@@ -30,7 +39,7 @@ module.exports = async function (projectName) {
|
|
|
30
39
|
|
|
31
40
|
// 创建项目配置文件
|
|
32
41
|
const config = {
|
|
33
|
-
projectName,
|
|
42
|
+
projectName: displayName,
|
|
34
43
|
createdAt: new Date().toISOString(),
|
|
35
44
|
currentIteration: 0,
|
|
36
45
|
workflow: 'A → R → B → C',
|
|
@@ -49,9 +58,9 @@ module.exports = async function (projectName) {
|
|
|
49
58
|
|
|
50
59
|
// 创建 package.json(让其他用户可以通过 npm install 安装 CLI)
|
|
51
60
|
const packageJson = {
|
|
52
|
-
name:
|
|
61
|
+
name: displayName.toLowerCase().replace(/[^a-z0-9]/g, '-'),
|
|
53
62
|
version: '1.0.0',
|
|
54
|
-
description: `${
|
|
63
|
+
description: `${displayName} - PRD 需求管理项目`,
|
|
55
64
|
private: true,
|
|
56
65
|
scripts: {
|
|
57
66
|
prd: 'prd',
|
|
@@ -59,7 +68,7 @@ module.exports = async function (projectName) {
|
|
|
59
68
|
help: 'prd --help'
|
|
60
69
|
},
|
|
61
70
|
dependencies: {
|
|
62
|
-
'prd-workflow-cli': '^1.1.
|
|
71
|
+
'prd-workflow-cli': '^1.1.29'
|
|
63
72
|
}
|
|
64
73
|
};
|
|
65
74
|
|
|
@@ -73,7 +82,7 @@ module.exports = async function (projectName) {
|
|
|
73
82
|
const p0Template = `# P0_项目基本信息
|
|
74
83
|
|
|
75
84
|
**创建时间**: ${new Date().toLocaleString('zh-CN')}
|
|
76
|
-
**项目名称**: ${
|
|
85
|
+
**项目名称**: ${displayName}
|
|
77
86
|
**文档状态**: 草案
|
|
78
87
|
|
|
79
88
|
---
|
|
@@ -96,7 +105,7 @@ module.exports = async function (projectName) {
|
|
|
96
105
|
|
|
97
106
|
### 1.1 项目定位
|
|
98
107
|
|
|
99
|
-
**项目全称**: ${
|
|
108
|
+
**项目全称**: ${displayName}
|
|
100
109
|
|
|
101
110
|
**项目简述**:
|
|
102
111
|
<!-- 一句话说明这个项目是什么 -->
|
|
@@ -259,14 +268,14 @@ module.exports = async function (projectName) {
|
|
|
259
268
|
}
|
|
260
269
|
|
|
261
270
|
// 创建 README
|
|
262
|
-
const readme = `# ${
|
|
271
|
+
const readme = `# ${displayName}
|
|
263
272
|
|
|
264
273
|
本项目采用规范化的产品需求管理流程
|
|
265
274
|
|
|
266
275
|
## 📁 目录结构
|
|
267
276
|
|
|
268
277
|
\`\`\`
|
|
269
|
-
${
|
|
278
|
+
${displayName}/
|
|
270
279
|
├── 00_项目总览/ # 项目基本信息
|
|
271
280
|
├── 01_产品基线/ # A 类文档:现状基线
|
|
272
281
|
├── 02_迭代记录/ # 各轮迭代的 B、C 类文档
|
|
@@ -337,17 +346,32 @@ prd plan freeze
|
|
|
337
346
|
|
|
338
347
|
console.log(chalk.green('✓ 项目创建成功!'));
|
|
339
348
|
console.log('');
|
|
340
|
-
|
|
349
|
+
|
|
350
|
+
// 显示 AI 集成信息
|
|
351
|
+
console.log(chalk.bold('🤖 AI 集成已配置:'));
|
|
352
|
+
console.log(chalk.gray(' ✓ .agent/workflows/ - PRD 工作流指引(包含所有阶段的详细步骤)'));
|
|
353
|
+
console.log(chalk.gray(' ✓ .cursorrules - Cursor AI 规则'));
|
|
354
|
+
console.log(chalk.gray(' ✓ .antigravity/ - Antigravity AI 规则'));
|
|
341
355
|
console.log('');
|
|
342
|
-
console.log(chalk.
|
|
343
|
-
console.log(
|
|
356
|
+
console.log(chalk.yellow(' 💡 现在你可以直接与 AI 助手对话,AI 已经知道如何协助你完成 PRD 流程!'));
|
|
357
|
+
console.log(chalk.gray(' 例如:告诉 AI "我要创建一个新项目的需求文档"'));
|
|
344
358
|
console.log('');
|
|
345
|
-
|
|
359
|
+
|
|
360
|
+
console.log(chalk.bold('📋 下一步操作(请按顺序执行):'));
|
|
361
|
+
console.log('');
|
|
362
|
+
if (!isCurrentDir) {
|
|
363
|
+
console.log(chalk.cyan('第 1 步: 进入项目目录'));
|
|
364
|
+
console.log(` cd ${displayName}`);
|
|
365
|
+
console.log('');
|
|
366
|
+
console.log(chalk.cyan('第 2 步: 完善 P0_项目基本信息.md'));
|
|
367
|
+
} else {
|
|
368
|
+
console.log(chalk.cyan('第 1 步: 完善 P0_项目基本信息.md'));
|
|
369
|
+
}
|
|
346
370
|
console.log(chalk.gray(' 文件位置: 00_项目总览/P0_项目基本信息.md'));
|
|
347
371
|
console.log(chalk.gray(' 填写内容: 项目目标、干系人、约束条件等'));
|
|
348
372
|
console.log(chalk.yellow(' ⚠️ 必须完成 P0 填写后才能开始创建 A 类基线文档'));
|
|
349
373
|
console.log('');
|
|
350
|
-
console.log(chalk.cyan('
|
|
374
|
+
console.log(chalk.cyan(`第 ${isCurrentDir ? '2' : '3'} 步: 创建 A0 基线文档`));
|
|
351
375
|
console.log(' prd baseline create A0 # P0 填写完成后执行');
|
|
352
376
|
console.log('');
|
|
353
377
|
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -117,7 +117,35 @@ function main() {
|
|
|
117
117
|
|
|
118
118
|
// 检查是否是全局安装
|
|
119
119
|
if (isGlobalInstall(packagePath)) {
|
|
120
|
-
debug('
|
|
120
|
+
debug('检测到全局安装,显示使用说明');
|
|
121
|
+
|
|
122
|
+
// 全局安装时输出使用说明
|
|
123
|
+
console.log('');
|
|
124
|
+
console.log('╔════════════════════════════════════════════════════════════════╗');
|
|
125
|
+
console.log('║ 🎉 prd-workflow-cli 安装成功! ║');
|
|
126
|
+
console.log('╠════════════════════════════════════════════════════════════════╣');
|
|
127
|
+
console.log('║ ║');
|
|
128
|
+
console.log('║ 📋 快速开始: ║');
|
|
129
|
+
console.log('║ ║');
|
|
130
|
+
console.log('║ 1. 创建新项目: ║');
|
|
131
|
+
console.log('║ prd init 我的项目 ║');
|
|
132
|
+
console.log('║ cd 我的项目 ║');
|
|
133
|
+
console.log('║ ║');
|
|
134
|
+
console.log('║ 2. 或在现有目录初始化: ║');
|
|
135
|
+
console.log('║ cd 现有目录 ║');
|
|
136
|
+
console.log('║ prd init . ║');
|
|
137
|
+
console.log('║ ║');
|
|
138
|
+
console.log('║ 📖 查看帮助: prd --help ║');
|
|
139
|
+
console.log('║ ║');
|
|
140
|
+
console.log('║ 🤖 AI 集成说明: ║');
|
|
141
|
+
console.log('║ 初始化后会自动创建 AI 规则文件: ║');
|
|
142
|
+
console.log('║ - .agent/workflows/ PRD 工作流指引 ║');
|
|
143
|
+
console.log('║ - .cursorrules Cursor AI 规则 ║');
|
|
144
|
+
console.log('║ - .antigravity/ Antigravity AI 规则 ║');
|
|
145
|
+
console.log('║ ║');
|
|
146
|
+
console.log('╚════════════════════════════════════════════════════════════════╝');
|
|
147
|
+
console.log('');
|
|
148
|
+
|
|
121
149
|
return;
|
|
122
150
|
}
|
|
123
151
|
|