ai-project-boilerplate 1.4.0 → 1.5.1

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.
@@ -0,0 +1,51 @@
1
+ # AI Project Integration Instructions
2
+
3
+ The `ai-project-integration-plan/` directory has been created in your project root.
4
+ It contains the full AI Project Boilerplate template and these integration instructions.
5
+
6
+ **Project root** = the directory that contains `ai-project-integration-plan/`.
7
+
8
+ ---
9
+
10
+ ## How to Integrate
11
+
12
+ ### Step 1 — Assess the project
13
+
14
+ Check whether the project root is empty or already has existing files:
15
+
16
+ - **Empty or missing key files** (no `AI_INSTRUCTIONS.md`, `docs/`, `CHANGELOG.md`, etc.):
17
+ → Copy all contents from `ai-project-integration-plan/` directly to the project root. No merge needed.
18
+
19
+ - **Existing project with files already present**:
20
+ → Review each file in `ai-project-integration-plan/` and merge or adapt as appropriate.
21
+ Do not overwrite existing files blindly — check for conflicts first.
22
+
23
+ ### Step 2 — Set the project name
24
+
25
+ In `ai-project-integration-plan/README.md`, replace `__PROJECT_NAME__` with the actual project name.
26
+ Infer it from the project root directory name, or ask the user if unclear.
27
+
28
+ ### Step 3 — Review and adapt each file
29
+
30
+ | File | Action |
31
+ |------|--------|
32
+ | `AI_INSTRUCTIONS.md` | Copy to root; adapt stage map if needed |
33
+ | `CLAUDE.md` | Copy to root |
34
+ | `.ai-stage` | Copy to root (default: `PLANNING`) |
35
+ | `.ai-workflow` | Copy to root; ask user which workflows apply and update accordingly |
36
+ | `CHANGELOG.md` | Copy to root if missing; otherwise append |
37
+ | `README.md` | Copy to root if missing; otherwise merge |
38
+ | `docs/` | Copy missing files; do not overwrite existing ones |
39
+ | `docs/workflows/` | Copy to root; these are reference guides, safe to copy |
40
+
41
+ ### Step 4 — Clean up
42
+
43
+ After integration is complete, **delete the entire `ai-project-integration-plan/` directory**.
44
+ It is a temporary scaffold and should not remain in the project.
45
+
46
+ ---
47
+
48
+ ## Notes
49
+
50
+ - `.ai-workflow` defaults to `unknown` — update it with the actual workflow(s) in use (e.g. `github`, `npm-publish`)
51
+ - If `.gitignore` does not already exclude `ai-project-integration-plan/`, add it
package/bin/cli.js CHANGED
@@ -161,6 +161,12 @@ function copyTemplate(src, dest) {
161
161
  }
162
162
  }
163
163
 
164
+ function prompt(question) {
165
+ const readline = require('readline');
166
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
167
+ return new Promise(resolve => rl.question(question, answer => { rl.close(); resolve(answer); }));
168
+ }
169
+
164
170
  async function main() {
165
171
  const args = process.argv.slice(2);
166
172
 
@@ -187,72 +193,82 @@ async function main() {
187
193
 
188
194
  // Validate command
189
195
  if (args.length === 0 || args[0] !== 'init') {
190
- console.log(`Usage: ai-project init <project-location> [-n <project-name>]`);
196
+ console.log(`Usage: ai-project init <project-location>`);
191
197
  console.log(` ai-project --version`);
192
198
  process.exit(0);
193
199
  }
194
200
 
195
- // Parse arguments: init <project-location> [-n <name>]
196
- let projectLocation;
197
- let customProjectName;
198
-
199
- // Find -n flag and its value
200
- const nIndex = args.indexOf('-n');
201
- if (nIndex !== -1) {
202
- if (nIndex + 1 < args.length) {
203
- customProjectName = args[nIndex + 1];
204
- } else {
205
- console.error(`Error: -n flag requires a project name argument`);
206
- process.exit(1);
207
- }
208
- }
209
-
210
201
  // Get project location (first argument after 'init')
211
- projectLocation = args[1];
212
- if (!projectLocation || projectLocation === '-n') {
213
- console.log(`Usage: ai-project init <project-location> [-n <project-name>]`);
202
+ const projectLocation = args[1];
203
+ if (!projectLocation) {
204
+ console.log(`Usage: ai-project init <project-location>`);
214
205
  process.exit(0);
215
206
  }
216
207
 
217
208
  const dest = path.resolve(process.cwd(), projectLocation);
209
+ const integrationDir = path.join(dest, 'ai-project-integration-plan');
218
210
 
219
- if (fs.existsSync(dest)) {
220
- // Existing project: Create .ai-project-refining from template
221
- const refiningTemplateFile = path.join(__dirname, "../.ai-project-refining-template");
222
- const refiningFile = path.join(dest, '.ai-project-refining');
223
- const template = fs.readFileSync(refiningTemplateFile, "utf8");
224
- fs.writeFileSync(refiningFile, template);
225
- console.log(`\nDetected existing project: ${projectLocation}`);
226
- console.log(`Created .ai-project-refining with migration guidance.`);
227
- console.log(`\nNext: Review .ai-project-refining and update your project accordingly.`);
228
- } else {
229
- // New project: Copy template
230
- const templateDir = path.join(__dirname, "../template");
231
- fs.mkdirSync(dest, { recursive: true });
232
- copyTemplate(templateDir, dest);
233
-
234
- // Replace placeholder in README
235
- const readmePath = path.join(dest, "README.md");
236
- const readme = fs.readFileSync(readmePath, "utf8");
237
- const projectName = customProjectName || path.basename(dest);
238
- fs.writeFileSync(readmePath, readme.replace("__PROJECT_NAME__", projectName));
239
-
240
- // Create .ai-stage
241
- fs.writeFileSync(path.join(dest, '.ai-stage'), 'PLANNING');
242
-
243
- console.log(`\nCreated AI-collaborated project: ${projectName}`);
244
- console.log(`\nFiles created:`);
245
- console.log(` AI_INSTRUCTIONS.md — AI router (source of truth)`);
246
- console.log(` CLAUDE.md — Claude Code entry`);
247
- console.log(` .ai-stage — current stage (PLANNING)`);
248
- console.log(` CHANGELOG.md`);
249
- console.log(` README.md`);
250
- console.log(` docs/planning.md`);
251
- console.log(` docs/architecture.md`);
252
- console.log(` docs/testing.md`);
253
- console.log(` docs/deployment.md`);
254
- console.log(`\nNext: cd ${projectName} && fill in docs/planning.md`);
211
+ // Create dest if needed
212
+ fs.mkdirSync(dest, { recursive: true });
213
+
214
+ // Handle existing ai-project-integration-plan/
215
+ if (fs.existsSync(integrationDir)) {
216
+ const answer = await prompt('ai-project-integration-plan/ already exists. Overwrite? (y/N): ');
217
+ if (answer.trim().toLowerCase() !== 'y') {
218
+ console.log('Aborted.');
219
+ process.exit(0);
220
+ }
221
+ fs.rmSync(integrationDir, { recursive: true, force: true });
222
+ }
223
+
224
+ // Create integration plan dir and copy template into it
225
+ fs.mkdirSync(integrationDir, { recursive: true });
226
+ const templateDir = path.join(__dirname, '../template');
227
+ copyTemplate(templateDir, integrationDir);
228
+
229
+ // Copy .ai-project-integration-instructions-template as .ai-project-integration-instructions
230
+ const instructionsTemplatePath = path.join(__dirname, '../.ai-project-integration-instructions-template');
231
+ const instructionsDestPath = path.join(integrationDir, '.ai-project-integration-instructions');
232
+ fs.copyFileSync(instructionsTemplatePath, instructionsDestPath);
233
+
234
+ console.log(`\nCreated: ai-project-integration-plan/`);
235
+
236
+ // Offer to add to .gitignore
237
+ const gitignorePath = path.join(dest, '.gitignore');
238
+ const gitignoreEntry = 'ai-project-integration-plan/';
239
+ const alreadyIgnored = fs.existsSync(gitignorePath) &&
240
+ fs.readFileSync(gitignorePath, 'utf8').includes(gitignoreEntry);
241
+
242
+ if (!alreadyIgnored) {
243
+ const gitAnswer = await prompt(`Add ${gitignoreEntry} to .gitignore? (Y/n): `);
244
+ if (gitAnswer.trim().toLowerCase() !== 'n') {
245
+ fs.appendFileSync(gitignorePath, `\n${gitignoreEntry}\n`);
246
+ console.log(`.gitignore updated.`);
247
+ } else {
248
+ console.log(`Reminder: add ${gitignoreEntry} to .gitignore manually.`);
249
+ }
250
+ }
251
+
252
+ const yellow = (s) => `\x1b[33m${s}\x1b[0m`;
253
+ const cyan = (s) => `\x1b[36m${s}\x1b[0m`;
254
+ const bold = (s) => `\x1b[1m${s}\x1b[0m`;
255
+ const strip = (s) => s.replace(/\x1b\[[0-9;]*m/g, "");
256
+
257
+ const nextLines = [
258
+ ` ${bold(yellow("NEXT STEP"))}`,
259
+ ` Ask your AI to read:`,
260
+ ``,
261
+ ` ${bold(cyan("ai-project-integration-plan/.ai-project-integration-instructions"))}`,
262
+ ];
263
+
264
+ const nextWidth = Math.max(...nextLines.map(l => strip(l).length)) + 2;
265
+ const nextBorder = yellow("─".repeat(nextWidth));
266
+
267
+ console.log(`\n${yellow("┌")}${nextBorder}${yellow("┐")}`);
268
+ for (const line of nextLines) {
269
+ console.log(`${yellow("│")} ${line.padEnd(line.length + nextWidth - strip(line).length - 1)}${yellow("│")}`);
255
270
  }
271
+ console.log(`${yellow("└")}${nextBorder}${yellow("┘")}\n`);
256
272
  }
257
273
 
258
274
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-boilerplate",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "description": "CLI to scaffold AI-collaborated projects with stage-based AI instruction files",
5
5
  "bin": {
6
6
  "ai-project": "bin/cli.js"
@@ -12,7 +12,7 @@
12
12
  "bin",
13
13
  "template",
14
14
  "scripts/preuninstall.js",
15
- ".ai-project-refining-template"
15
+ ".ai-project-integration-instructions-template"
16
16
  ],
17
17
  "keywords": [
18
18
  "ai",
@@ -1,26 +0,0 @@
1
- # Migration Guidance for Existing AI Project
2
-
3
- Your existing project has been detected.
4
-
5
- To integrate with the AI Project Boilerplate and refine your project for AI collaboration:
6
-
7
- 1. **Review AI_INSTRUCTIONS.md**: Copy or adapt the AI_INSTRUCTIONS.md from the boilerplate to your project root. This file serves as the AI router and source of truth for project guidelines, ensuring consistent AI interactions.
8
-
9
- 2. **Add CLAUDE.md**: Include CLAUDE.md for Claude Code entry points, defining how AI tools interact with your codebase.
10
-
11
- 3. **Set Up docs/ Folder**: Ensure a `docs/` folder exists with at least:
12
- - planning.md (project goals and roadmap)
13
- - architecture.md (system design)
14
- - testing.md (testing strategies)
15
- - deployment.md (deployment processes)
16
- Copy or adapt these from the boilerplate if needed.
17
-
18
- 4. **Update CHANGELOG.md**: Maintain a changelog for version history and AI-driven changes.
19
-
20
- 5. **Enhance README.md**: Update your README.md to reference AI_INSTRUCTIONS.md and include project setup for AI collaboration.
21
-
22
- 6. **Add .ai-stage File (Optional)**: Create a `.ai-stage` file in the project root with initial content `PLANNING` to track the current development stage (e.g., PLANNING, DEVELOPMENT, TESTING, DEPLOYMENT).
23
-
24
- 7. **Next Steps**: Fill in or update docs/planning.md. Consider integrating AI tools for code reviews and refinements.
25
-
26
- For more details, refer to the AI Project Boilerplate documentation.