ai-project-boilerplate 1.3.3 → 1.5.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.
@@ -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,65 @@ 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 });
255
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
+ console.log(`\nNext: Ask your AI to read:`);
253
+ console.log(` ai-project-integration-plan/.ai-project-integration-instructions`);
254
+ console.log(`\nYour AI will decide how to integrate the boilerplate into your project.`);
256
255
  }
257
256
 
258
257
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-boilerplate",
3
- "version": "1.3.3",
3
+ "version": "1.5.0",
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",
@@ -0,0 +1 @@
1
+ unknown
@@ -14,11 +14,39 @@ Read `.ai-stage` for the current stage value.
14
14
  ## Always-Available
15
15
  - `CHANGELOG.md` — append completed work after each session
16
16
 
17
+ ## Workflow
18
+ `.ai-workflow` lists the active workflows for this project, one per line. Each entry maps to `docs/workflows/<name>.md`.
19
+
20
+ Example `.ai-workflow`:
21
+ ```
22
+ github
23
+ npm-publish
24
+ ```
25
+
26
+ **If `.ai-workflow` is missing or every line is `unknown`:**
27
+ - Ask the user: *"Which workflows does this project use? (e.g. github, npm-publish, gitlab)"*
28
+ - Write the answers to `.ai-workflow`, one per line
29
+ - Do not proceed with any code management action until this is resolved
30
+
31
+ **When to read workflow files:**
32
+ - Do NOT read workflow files on session start or during normal coding
33
+ - ONLY read when you are about to perform a code management action
34
+ - Read only the workflow(s) relevant to the current action:
35
+
36
+ | Action | Read this workflow |
37
+ |--------|-------------------|
38
+ | commit / push / PR / branch | the VCS workflow (e.g. `github`, `gitlab`) |
39
+ | publish to a package registry | the publish workflow (e.g. `npm-publish`) |
40
+ | release (tag + publish) | both VCS and publish workflows |
41
+
42
+ If multiple workflows apply to the current action, read all of them.
43
+
17
44
  ## Instructions
18
45
  1. Read ONLY the file for the current stage above.
19
46
  2. Do not read other stage files unless explicitly asked.
20
47
  3. After completing work, append a summary to `CHANGELOG.md`.
21
48
  4. When the stage changes, update `.ai-stage` on the current branch.
49
+ 5. Before any code management action: check `.ai-workflow`, read the relevant `docs/workflows/*.md`, and follow it exactly.
22
50
 
23
51
  ## First-Time Setup (AI tools other than Claude Code)
24
52
  If your tool uses a dedicated instructions file (e.g. `.cursorrules` for Cursor,
@@ -9,10 +9,12 @@
9
9
  ```
10
10
 
11
11
  ## Git Workflow
12
- - Every new feature or bug fix must be developed on a dedicated branch never commit directly to `main`
12
+ - **All changes to `main` must go through a PRno exceptions, including version bumps and chores**
13
+ - Every change must be developed on a dedicated branch — never commit directly to `main`
13
14
  - Branch naming:
14
15
  - `feature/<short-description>` — for new functionality
15
16
  - `fix/<short-description>` — for bug fixes
17
+ - `chore/<short-description>` — for version bumps, dependency updates, config changes
16
18
  ### PR Flow
17
19
  1. Create a feature or fix branch and push to remote
18
20
  2. Open a pull request targeting `main` (e.g. via `gh pr create` or your Git host's UI)
@@ -0,0 +1,116 @@
1
+ # GitHub Workflow
2
+
3
+ ## Branch Naming
4
+ - **All changes to `main` must go through a PR — no exceptions**
5
+ - Never commit directly to `main`
6
+ - `feature/<short-description>` — new functionality
7
+ - `fix/<short-description>` — bug fixes
8
+ - `chore/<short-description>` — version bumps, config changes, dependency updates
9
+
10
+ ---
11
+
12
+ ## PR Flow
13
+
14
+ ```bash
15
+ # 1. Create and switch to a branch
16
+ git checkout -b feature/<short-description>
17
+
18
+ # 2. Make changes, commit, and push
19
+ git add <files>
20
+ git commit -m "feat: describe the change"
21
+ git push -u origin feature/<short-description>
22
+
23
+ # 3. Create a pull request
24
+ gh pr create \
25
+ --title "feat: describe the change" \
26
+ --body "$(cat <<'EOF'
27
+ ## Summary
28
+ - <bullet points>
29
+
30
+ ## Test plan
31
+ - [ ] <manual test steps>
32
+ EOF
33
+ )"
34
+
35
+ # 4. Check CI status
36
+ gh pr checks
37
+
38
+ # 5. Merge and delete branch after approval
39
+ gh pr merge --squash --delete-branch
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Release Flow
45
+
46
+ ### Automated (Recommended)
47
+ If a `scripts/release.sh` exists in the project:
48
+
49
+ ```bash
50
+ # Bumps version via PR, tags commit, creates GitHub release
51
+ ./scripts/release.sh <patch|minor|major>
52
+
53
+ # Then publish to registry if applicable (e.g. npm)
54
+ npm publish
55
+ ```
56
+
57
+ ### Manual
58
+ ```bash
59
+ # 1. Ensure you are on main with a clean working tree
60
+ git checkout main && git pull origin main
61
+
62
+ # 2. Bump version (no commit yet)
63
+ npm version patch --no-git-tag-version # or minor / major
64
+
65
+ # 3. Create a release branch, commit, push, and open a PR
66
+ git checkout -b release/v<version>
67
+ git add package.json
68
+ git commit -m "chore: bump version to <version>"
69
+ git push -u origin release/v<version>
70
+
71
+ gh pr create \
72
+ --title "chore: release v<version>" \
73
+ --body "Version bump to v<version>." \
74
+ --base main
75
+
76
+ # 4. Merge the PR
77
+ gh pr merge release/v<version> --squash --delete-branch
78
+
79
+ # 5. Pull merged commit, tag it, and push the tag
80
+ git checkout main && git pull origin main
81
+ git tag v<version>
82
+ git push origin v<version>
83
+
84
+ # 6. Create a GitHub release
85
+ gh release create v<version> \
86
+ --title "v<version>" \
87
+ --generate-notes
88
+
89
+ # 7. Publish to registry if applicable
90
+ npm publish
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Quick Reference
96
+
97
+ ```bash
98
+ # List open PRs
99
+ gh pr list
100
+
101
+ # View PR status and checks
102
+ gh pr view
103
+ gh pr checks
104
+
105
+ # Merge current branch's PR
106
+ gh pr merge --squash --delete-branch
107
+
108
+ # List releases
109
+ gh release list
110
+
111
+ # View a release
112
+ gh release view v<version>
113
+
114
+ # Delete a release (e.g. to redo)
115
+ gh release delete v<version>
116
+ ```
@@ -0,0 +1,59 @@
1
+ # npm Publish Workflow
2
+
3
+ ## Prerequisites
4
+ - Logged in to npm: `npm whoami` (if not, run `npm login`)
5
+ - `NODE_AUTH_TOKEN` set in CI environment for automated publishing
6
+
7
+ ## When to Use
8
+ Read this file only when you are about to publish a new version to the npm registry.
9
+
10
+ ---
11
+
12
+ ## Publish Flow
13
+
14
+ ```bash
15
+ # 1. Ensure you are on main with the correct version in package.json
16
+ git checkout main && git pull origin main
17
+ node -e "console.log(require('./package.json').version)"
18
+
19
+ # 2. Dry-run to verify package contents
20
+ npm publish --dry-run
21
+
22
+ # 3. Publish with the default 'latest' tag
23
+ npm publish
24
+
25
+ # 4. Verify the published version
26
+ npm view <package-name> version
27
+ ```
28
+
29
+ ### Publishing a Pre-release
30
+ ```bash
31
+ # Publish under a dist-tag (e.g. beta, next) — does NOT affect 'latest'
32
+ npm publish --tag beta
33
+
34
+ # Verify
35
+ npm view <package-name> dist-tags
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Version Bump
41
+ Version bumps must happen before publishing, via the VCS workflow (e.g. a PR merging a `release/vX.Y.Z` branch). Do not bump the version manually outside of that flow.
42
+
43
+ ---
44
+
45
+ ## Quick Reference
46
+
47
+ ```bash
48
+ # Check who you are logged in as
49
+ npm whoami
50
+
51
+ # List all published versions
52
+ npm view <package-name> versions --json
53
+
54
+ # Deprecate a version
55
+ npm deprecate <package-name>@<version> "<reason>"
56
+
57
+ # Unpublish within 72 hours (use sparingly)
58
+ npm unpublish <package-name>@<version>
59
+ ```
@@ -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.