productkit 1.2.0 → 1.3.0

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 CHANGED
@@ -94,6 +94,7 @@ These markdown files are your product foundation — share them with your team,
94
94
  | Command | Description |
95
95
  |---------|-------------|
96
96
  | `productkit init <name>` | Scaffold a new project |
97
+ | `productkit init --existing` | Add Product Kit to the current directory |
97
98
  | `productkit status` | Show progress — which artifacts exist and what's next |
98
99
  | `productkit check` | Verify Claude Code is installed |
99
100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "productkit",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Slash-command-driven product thinking toolkit for Claude Code",
5
5
  "main": "src/cli.js",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -11,11 +11,12 @@ const program = new Command();
11
11
  program
12
12
  .name('productkit')
13
13
  .description(chalk.cyan.bold('Product thinking toolkit for Claude Code'))
14
- .version('1.2.0');
14
+ .version('1.3.0');
15
15
 
16
16
  program
17
- .command('init <projectName>')
17
+ .command('init [projectName]')
18
18
  .description('Initialize a new product research project')
19
+ .option('--existing', 'Add Product Kit to the current directory')
19
20
  .action(initCommand);
20
21
 
21
22
  program
@@ -2,53 +2,94 @@ const fs = require('fs-extra');
2
2
  const path = require('path');
3
3
  const chalk = require('chalk');
4
4
 
5
- async function init(projectName) {
6
- const projectRoot = path.join(process.cwd(), projectName);
5
+ function scaffold(projectRoot, projectName) {
6
+ const templatesDir = path.join(__dirname, '..', '..', 'templates');
7
7
 
8
- if (fs.existsSync(projectRoot)) {
9
- console.error(chalk.red(`Error: Directory "${projectName}" already exists`));
10
- process.exit(1);
11
- }
8
+ // Create directories
9
+ fs.ensureDirSync(path.join(projectRoot, '.productkit'));
10
+ fs.ensureDirSync(path.join(projectRoot, '.claude', 'commands'));
12
11
 
13
- try {
14
- const templatesDir = path.join(__dirname, '..', '..', 'templates');
15
-
16
- // Create directories
17
- fs.ensureDirSync(path.join(projectRoot, '.productkit'));
18
- fs.ensureDirSync(path.join(projectRoot, '.claude', 'commands'));
19
-
20
- // Write config
21
- fs.writeJsonSync(path.join(projectRoot, '.productkit', 'config.json'), {
22
- version: '1.0.0',
23
- created: new Date().toISOString(),
24
- }, { spaces: 2 });
25
-
26
- // Copy slash command templates
27
- const commandsDir = path.join(templatesDir, 'commands');
28
- const commandFiles = fs.readdirSync(commandsDir);
29
- for (const file of commandFiles) {
30
- fs.copyFileSync(
31
- path.join(commandsDir, file),
32
- path.join(projectRoot, '.claude', 'commands', file)
33
- );
34
- }
12
+ // Write config
13
+ fs.writeJsonSync(path.join(projectRoot, '.productkit', 'config.json'), {
14
+ version: '1.0.0',
15
+ created: new Date().toISOString(),
16
+ }, { spaces: 2 });
35
17
 
36
- // Copy CLAUDE.md
18
+ // Copy slash command templates
19
+ const commandsDir = path.join(templatesDir, 'commands');
20
+ const commandFiles = fs.readdirSync(commandsDir);
21
+ for (const file of commandFiles) {
37
22
  fs.copyFileSync(
38
- path.join(templatesDir, 'CLAUDE.md'),
39
- path.join(projectRoot, 'CLAUDE.md')
23
+ path.join(commandsDir, file),
24
+ path.join(projectRoot, '.claude', 'commands', file)
40
25
  );
26
+ }
41
27
 
42
- // Copy README.md with project name substitution
28
+ // Copy CLAUDE.md (don't overwrite existing)
29
+ const claudeMdPath = path.join(projectRoot, 'CLAUDE.md');
30
+ if (!fs.existsSync(claudeMdPath)) {
31
+ fs.copyFileSync(path.join(templatesDir, 'CLAUDE.md'), claudeMdPath);
32
+ } else {
33
+ const existing = fs.readFileSync(claudeMdPath, 'utf-8');
34
+ const template = fs.readFileSync(path.join(templatesDir, 'CLAUDE.md'), 'utf-8');
35
+ fs.writeFileSync(claudeMdPath, existing + '\n' + template);
36
+ }
37
+
38
+ // Copy README.md with project name substitution (only for new projects)
39
+ if (!fs.existsSync(path.join(projectRoot, 'README.md'))) {
43
40
  let readme = fs.readFileSync(path.join(templatesDir, 'README.md'), 'utf-8');
44
41
  readme = readme.replace(/\{\{PROJECT_NAME\}\}/g, projectName);
45
42
  fs.writeFileSync(path.join(projectRoot, 'README.md'), readme);
43
+ }
46
44
 
47
- // Copy .gitignore
45
+ // Copy .gitignore (only for new projects)
46
+ if (!fs.existsSync(path.join(projectRoot, '.gitignore'))) {
48
47
  fs.copyFileSync(
49
48
  path.join(templatesDir, 'gitignore'),
50
49
  path.join(projectRoot, '.gitignore')
51
50
  );
51
+ }
52
+ }
53
+
54
+ async function init(projectName, options) {
55
+ if (options.existing) {
56
+ const projectRoot = process.cwd();
57
+
58
+ if (fs.existsSync(path.join(projectRoot, '.productkit'))) {
59
+ console.error(chalk.red('Error: This directory is already a Product Kit project.'));
60
+ process.exit(1);
61
+ }
62
+
63
+ try {
64
+ scaffold(projectRoot, path.basename(projectRoot));
65
+
66
+ console.log(chalk.green.bold('Product Kit added to existing project!'));
67
+ console.log();
68
+ console.log(chalk.cyan('Next steps:'));
69
+ console.log(' 1. claude');
70
+ console.log(' 2. /productkit.constitution');
71
+ console.log();
72
+ } catch (error) {
73
+ console.error(chalk.red('Error initializing:'), error.message);
74
+ process.exit(1);
75
+ }
76
+ return;
77
+ }
78
+
79
+ if (!projectName) {
80
+ console.error(chalk.red('Error: Project name is required. Use --existing to init in current directory.'));
81
+ process.exit(1);
82
+ }
83
+
84
+ const projectRoot = path.join(process.cwd(), projectName);
85
+
86
+ if (fs.existsSync(projectRoot)) {
87
+ console.error(chalk.red(`Error: Directory "${projectName}" already exists`));
88
+ process.exit(1);
89
+ }
90
+
91
+ try {
92
+ scaffold(projectRoot, projectName);
52
93
 
53
94
  // Init git repo
54
95
  const { execSync } = require('child_process');