@parseme/cli 0.1.0 → 0.1.2
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 +112 -90
- package/dist/cli/cli.js +1 -1
- package/dist/core/context-builder.js +17 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -120,7 +120,7 @@ PARSEME aims to automatically analyse any JavaScript or TypeScript project like:
|
|
|
120
120
|
## Installation
|
|
121
121
|
|
|
122
122
|
```bash
|
|
123
|
-
npm install --save-dev parseme
|
|
123
|
+
npm install --save-dev @parseme/cli
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
## Quick Start
|
|
@@ -128,9 +128,9 @@ npm install --save-dev parseme
|
|
|
128
128
|
1. **Initialize configuration**:
|
|
129
129
|
|
|
130
130
|
```bash
|
|
131
|
-
npx parseme init
|
|
131
|
+
npx @parseme/cli init
|
|
132
132
|
# or use the alias
|
|
133
|
-
npx parseme i
|
|
133
|
+
npx @parseme/cli i
|
|
134
134
|
```
|
|
135
135
|
|
|
136
136
|
You'll be prompted for:
|
|
@@ -147,9 +147,9 @@ npm install --save-dev parseme
|
|
|
147
147
|
|
|
148
148
|
2. **Generate context**:
|
|
149
149
|
```bash
|
|
150
|
-
npx parseme generate
|
|
150
|
+
npx @parseme/cli generate
|
|
151
151
|
# or use the alias
|
|
152
|
-
npx parseme g
|
|
152
|
+
npx @parseme/cli g
|
|
153
153
|
```
|
|
154
154
|
|
|
155
155
|
This creates:
|
|
@@ -182,11 +182,9 @@ Add to your `package.json` scripts (optional, for convenience):
|
|
|
182
182
|
```bash
|
|
183
183
|
npm run parseme
|
|
184
184
|
# or directly
|
|
185
|
-
|
|
185
|
+
parseme generate
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
-
**Best for:** Small projects, occasional updates, or when you prefer full control over when context is generated.
|
|
189
|
-
|
|
190
188
|
---
|
|
191
189
|
|
|
192
190
|
### Option 2: Automatic Local Generation
|
|
@@ -204,8 +202,12 @@ npx husky init
|
|
|
204
202
|
cat > .husky/post-commit << 'EOF'
|
|
205
203
|
#!/bin/sh
|
|
206
204
|
|
|
205
|
+
# Load nvm if available
|
|
206
|
+
export NVM_DIR="$HOME/.nvm"
|
|
207
|
+
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
208
|
+
|
|
207
209
|
# Generate PARSEME files locally after commit
|
|
208
|
-
npx parseme generate
|
|
210
|
+
npx @parseme/cli generate
|
|
209
211
|
EOF
|
|
210
212
|
|
|
211
213
|
# Make hook executable
|
|
@@ -218,7 +220,7 @@ chmod +x .husky/post-commit
|
|
|
218
220
|
cat > .git/hooks/post-commit << 'EOF'
|
|
219
221
|
#!/bin/sh
|
|
220
222
|
|
|
221
|
-
npx parseme generate
|
|
223
|
+
npx @parseme/cli generate
|
|
222
224
|
EOF
|
|
223
225
|
|
|
224
226
|
chmod +x .git/hooks/post-commit
|
|
@@ -230,8 +232,6 @@ chmod +x .git/hooks/post-commit
|
|
|
230
232
|
- Files are ready to be staged and committed with your next commit
|
|
231
233
|
- Simple setup with minimal configuration
|
|
232
234
|
|
|
233
|
-
**Best for:** Solo developers or small teams wanting automatic local updates with committed parseme files.
|
|
234
|
-
|
|
235
235
|
**Note:** If using a custom `contextDir`, ensure the path is consistent across your team's configuration.
|
|
236
236
|
|
|
237
237
|
---
|
|
@@ -251,15 +251,23 @@ npx husky init
|
|
|
251
251
|
cat > .husky/post-commit << 'EOF'
|
|
252
252
|
#!/bin/sh
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
# Load nvm if available
|
|
255
|
+
export NVM_DIR="$HOME/.nvm"
|
|
256
|
+
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
257
|
+
|
|
258
|
+
npx @parseme/cli generate
|
|
255
259
|
EOF
|
|
256
260
|
|
|
257
261
|
# Create pre-push hook
|
|
258
262
|
cat > .husky/pre-push << 'EOF'
|
|
259
263
|
#!/bin/sh
|
|
260
264
|
|
|
265
|
+
# Load nvm if available
|
|
266
|
+
export NVM_DIR="$HOME/.nvm"
|
|
267
|
+
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
268
|
+
|
|
261
269
|
# Regenerate without git info for clean remote state
|
|
262
|
-
npx parseme generate --no-git-info
|
|
270
|
+
npx @parseme/cli generate --no-git-info
|
|
263
271
|
|
|
264
272
|
# Stage parseme files
|
|
265
273
|
git add parseme-context/ PARSEME.md
|
|
@@ -272,8 +280,12 @@ EOF
|
|
|
272
280
|
cat > .husky/post-push << 'EOF'
|
|
273
281
|
#!/bin/sh
|
|
274
282
|
|
|
283
|
+
# Load nvm if available
|
|
284
|
+
export NVM_DIR="$HOME/.nvm"
|
|
285
|
+
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
286
|
+
|
|
275
287
|
# Regenerate with git info for local development
|
|
276
|
-
npx parseme generate
|
|
288
|
+
npx @parseme/cli generate
|
|
277
289
|
EOF
|
|
278
290
|
|
|
279
291
|
# Make hooks executable
|
|
@@ -287,7 +299,7 @@ chmod +x .husky/post-commit .husky/pre-push .husky/post-push
|
|
|
287
299
|
cat > .git/hooks/post-commit << 'EOF'
|
|
288
300
|
#!/bin/sh
|
|
289
301
|
|
|
290
|
-
npx parseme generate
|
|
302
|
+
npx @parseme/cli generate
|
|
291
303
|
EOF
|
|
292
304
|
|
|
293
305
|
# Pre-push: Regenerate without git info and amend before pushing
|
|
@@ -295,7 +307,7 @@ cat > .git/hooks/pre-push << 'EOF'
|
|
|
295
307
|
#!/bin/sh
|
|
296
308
|
|
|
297
309
|
# Regenerate without git info for clean remote state
|
|
298
|
-
npx parseme generate --no-git-info
|
|
310
|
+
npx @parseme/cli generate --no-git-info
|
|
299
311
|
|
|
300
312
|
# Stage parseme files
|
|
301
313
|
git add parseme-context/ PARSEME.md
|
|
@@ -309,7 +321,7 @@ cat > .git/hooks/post-push << 'EOF'
|
|
|
309
321
|
#!/bin/sh
|
|
310
322
|
|
|
311
323
|
# Regenerate with git info for local development
|
|
312
|
-
npx parseme generate
|
|
324
|
+
npx @parseme/cli generate
|
|
313
325
|
EOF
|
|
314
326
|
|
|
315
327
|
# Make hooks executable
|
|
@@ -324,27 +336,17 @@ chmod +x .git/hooks/post-commit .git/hooks/pre-push .git/hooks/post-push
|
|
|
324
336
|
|
|
325
337
|
The `--no-verify` flag in pre-push prevents an infinite loop by skipping hook execution on the amend.
|
|
326
338
|
|
|
327
|
-
**Best for:** Teams that want detailed local context for development while keeping clean, portable context in the repository.
|
|
328
|
-
|
|
329
339
|
**Note:** If using a custom `contextDir`, update the `git add` path in the pre-push hook (e.g., `git add docs/context/ PARSEME.md`).
|
|
330
340
|
|
|
331
341
|
---
|
|
332
342
|
|
|
333
343
|
### Option 4: GitHub Actions for Remote Generation paired with Local Generation
|
|
334
344
|
|
|
335
|
-
Use GitHub Actions to automatically
|
|
345
|
+
Use GitHub Actions to automatically update PARSEME files on every push to main. This is the recommended approach for teams using GitHub.
|
|
336
346
|
|
|
337
347
|
**Setup:**
|
|
338
348
|
|
|
339
|
-
**1.
|
|
340
|
-
|
|
341
|
-
```gitignore
|
|
342
|
-
# Parseme documentation (generated locally and by CI)
|
|
343
|
-
parseme-context/
|
|
344
|
-
PARSEME.md
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
**2. Create `.github/workflows/parseme-update.yml`:**
|
|
349
|
+
**1. Create `.github/workflows/parseme-update.yml`:**
|
|
348
350
|
|
|
349
351
|
```yaml
|
|
350
352
|
name: Update PARSEME Documentation
|
|
@@ -352,7 +354,7 @@ name: Update PARSEME Documentation
|
|
|
352
354
|
on:
|
|
353
355
|
push:
|
|
354
356
|
branches:
|
|
355
|
-
- main
|
|
357
|
+
- 'main'
|
|
356
358
|
|
|
357
359
|
jobs:
|
|
358
360
|
update-parseme:
|
|
@@ -363,49 +365,46 @@ jobs:
|
|
|
363
365
|
GITHUB_TOKEN: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}
|
|
364
366
|
|
|
365
367
|
steps:
|
|
366
|
-
- name:
|
|
367
|
-
id: check_pusher
|
|
368
|
+
- name: Service Account Gate
|
|
368
369
|
run: |
|
|
369
370
|
if [ "${{ github.event.pusher.name }}" = "${{ secrets.GH_SERVICE_ACCOUNT_USERNAME }}" ]; then
|
|
370
|
-
echo "
|
|
371
|
-
|
|
372
|
-
echo "is_bot=false" >> $GITHUB_OUTPUT
|
|
371
|
+
echo "::notice::Skipping workflow - push was made by service account"
|
|
372
|
+
exit 1
|
|
373
373
|
fi
|
|
374
374
|
|
|
375
375
|
- name: Checkout code
|
|
376
|
-
if: steps.check_pusher.outputs.is_bot == 'false'
|
|
377
376
|
uses: actions/checkout@v4
|
|
378
377
|
with:
|
|
379
378
|
fetch-depth: 0
|
|
380
379
|
token: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}
|
|
381
380
|
|
|
382
381
|
- name: Setup Node.js
|
|
383
|
-
if: steps.check_pusher.outputs.is_bot == 'false'
|
|
384
382
|
uses: actions/setup-node@v4
|
|
385
383
|
with:
|
|
386
|
-
node-version: '
|
|
384
|
+
node-version: '24'
|
|
387
385
|
cache: 'npm'
|
|
388
386
|
|
|
389
387
|
- name: Configure Git
|
|
390
|
-
if: steps.check_pusher.outputs.is_bot == 'false'
|
|
391
388
|
run: |
|
|
392
389
|
git config user.name "${{ secrets.GH_SERVICE_ACCOUNT_USERNAME }}"
|
|
393
390
|
git config user.email "${{ secrets.GH_SERVICE_ACCOUNT_USERNAME }}@users.noreply.github.com"
|
|
394
391
|
|
|
392
|
+
- name: Configure npm for GitHub Packages
|
|
393
|
+
run: |
|
|
394
|
+
npm config set @netgear:registry https://npm.pkg.github.com/
|
|
395
|
+
npm config set //npm.pkg.github.com/:_authToken "${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}"
|
|
396
|
+
|
|
395
397
|
- name: Install dependencies
|
|
396
|
-
if: steps.check_pusher.outputs.is_bot == 'false'
|
|
397
398
|
run: npm ci
|
|
398
399
|
|
|
399
|
-
- name: Generate
|
|
400
|
-
if: steps.check_pusher.outputs.is_bot == 'false'
|
|
400
|
+
- name: Generate PARSEME documentation
|
|
401
401
|
run: npx parseme generate --no-git-info
|
|
402
402
|
|
|
403
|
-
- name:
|
|
404
|
-
|
|
405
|
-
|
|
403
|
+
- name: Stage changes
|
|
404
|
+
run: |
|
|
405
|
+
git add PARSEME.md parseme-context/
|
|
406
406
|
|
|
407
407
|
- name: Check for changes
|
|
408
|
-
if: steps.check_pusher.outputs.is_bot == 'false'
|
|
409
408
|
id: check_changes
|
|
410
409
|
run: |
|
|
411
410
|
if git diff --cached --quiet; then
|
|
@@ -414,58 +413,87 @@ jobs:
|
|
|
414
413
|
echo "changes=true" >> $GITHUB_OUTPUT
|
|
415
414
|
fi
|
|
416
415
|
|
|
417
|
-
- name: Commit
|
|
418
|
-
if: steps.
|
|
416
|
+
- name: Commit
|
|
417
|
+
if: steps.check_changes.outputs.changes == 'true'
|
|
419
418
|
run: |
|
|
420
|
-
git commit
|
|
421
|
-
git push
|
|
419
|
+
git commit -m "chore: Update PARSEME AI Agent Context [skip ci]" --no-verify
|
|
420
|
+
git push
|
|
422
421
|
```
|
|
423
422
|
|
|
424
|
-
**
|
|
423
|
+
**2. Configure GitHub secrets:**
|
|
425
424
|
|
|
426
425
|
- `GH_SERVICE_ACCOUNT_TOKEN`: A GitHub personal access token with repo write permissions
|
|
427
|
-
- `GH_SERVICE_ACCOUNT_USERNAME`: The username of your service account
|
|
426
|
+
- `GH_SERVICE_ACCOUNT_USERNAME`: The username of your service account
|
|
428
427
|
|
|
429
|
-
**
|
|
428
|
+
**3. Setup local git hooks with Husky:**
|
|
430
429
|
|
|
431
430
|
```bash
|
|
432
431
|
# Install Husky (if not already installed)
|
|
433
432
|
npm install --save-dev husky
|
|
434
433
|
npx husky init
|
|
435
434
|
|
|
435
|
+
# Create pre-commit hook
|
|
436
|
+
cat > .husky/pre-commit << 'EOF'
|
|
437
|
+
#!/bin/sh
|
|
438
|
+
|
|
439
|
+
# Pre-commit hook to reset PARSEME files to prevent them from being committed
|
|
440
|
+
for file in $(git ls-files parseme-context/ PARSEME.md 2>/dev/null); do
|
|
441
|
+
git restore --staged "$file" 2>/dev/null
|
|
442
|
+
done
|
|
443
|
+
EOF
|
|
444
|
+
|
|
436
445
|
# Create post-commit hook
|
|
437
446
|
cat > .husky/post-commit << 'EOF'
|
|
438
447
|
#!/bin/sh
|
|
439
448
|
|
|
440
|
-
#
|
|
441
|
-
|
|
449
|
+
# Load nvm if available
|
|
450
|
+
export NVM_DIR="$HOME/.nvm"
|
|
451
|
+
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
452
|
+
|
|
453
|
+
# Generate PARSEME files locally after commit for local AI agent usage
|
|
454
|
+
npx @parseme/cli generate --no-git-info
|
|
442
455
|
EOF
|
|
443
456
|
|
|
444
457
|
# Create post-merge hook
|
|
445
458
|
cat > .husky/post-merge << 'EOF'
|
|
446
459
|
#!/bin/sh
|
|
447
460
|
|
|
448
|
-
#
|
|
449
|
-
|
|
461
|
+
# Load nvm if available
|
|
462
|
+
export NVM_DIR="$HOME/.nvm"
|
|
463
|
+
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
464
|
+
|
|
465
|
+
# Generate PARSEME files locally after merge for local AI agent usage
|
|
466
|
+
npx @parseme/cli generate --no-git-info
|
|
467
|
+
EOF
|
|
468
|
+
|
|
469
|
+
# Create post-checkout hook
|
|
470
|
+
cat > .husky/post-checkout << 'EOF'
|
|
471
|
+
#!/bin/sh
|
|
472
|
+
|
|
473
|
+
# Load nvm if available
|
|
474
|
+
export NVM_DIR="$HOME/.nvm"
|
|
475
|
+
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
476
|
+
|
|
477
|
+
# Generate PARSEME files locally after checkout for local AI agent usage
|
|
478
|
+
npx @parseme/cli generate --no-git-info
|
|
450
479
|
EOF
|
|
451
480
|
|
|
452
481
|
# Make hooks executable
|
|
453
|
-
chmod +x .husky/post-commit .husky/post-merge
|
|
482
|
+
chmod +x .husky/pre-commit .husky/post-commit .husky/post-merge .husky/post-checkout
|
|
454
483
|
```
|
|
455
484
|
|
|
456
485
|
**How it works:**
|
|
457
486
|
|
|
458
|
-
1. **
|
|
459
|
-
2. **
|
|
460
|
-
3. **
|
|
461
|
-
4. **
|
|
462
|
-
|
|
463
|
-
**Best for:** Teams using GitHub that want automated CI-managed remote updates with local context for development.
|
|
487
|
+
1. **On push to main**: GitHub Actions detects the push
|
|
488
|
+
2. **Service account check**: Workflow exits early if the push was made by the service account
|
|
489
|
+
3. **Generate and commit**: Generates PARSEME files with `--no-git-info` flag and creates a new commit with `[skip ci]` message
|
|
490
|
+
4. **Push changes**: The new commit is pushed back to the repository
|
|
491
|
+
5. **Local hooks**: Pre-commit hook prevents PARSEME files from being committed manually, while post-commit/merge/checkout hooks regenerate them locally for AI agent usage
|
|
464
492
|
|
|
465
493
|
**Notes:**
|
|
466
494
|
|
|
467
495
|
- The workflow only runs on the `main` branch (adjust as needed for your branching strategy)
|
|
468
|
-
- If using a custom `contextDir`, update
|
|
496
|
+
- If using a custom `contextDir`, update the paths in both the workflow and hooks accordingly
|
|
469
497
|
|
|
470
498
|
## Configuration
|
|
471
499
|
|
|
@@ -476,7 +504,7 @@ The `parseme init` command creates a minimal config with only your custom settin
|
|
|
476
504
|
**Minimal config example** (created by `parseme init`):
|
|
477
505
|
|
|
478
506
|
```javascript
|
|
479
|
-
/** @type {import('parseme').ParsemeConfigFile} */
|
|
507
|
+
/** @type {import('@parseme/cli').ParsemeConfigFile} */
|
|
480
508
|
const config = {
|
|
481
509
|
contextDir: 'parseme-context',
|
|
482
510
|
excludePatterns: ['node_modules/**', '.git/**'],
|
|
@@ -488,7 +516,7 @@ export default config;
|
|
|
488
516
|
**Full config example** (all available options):
|
|
489
517
|
|
|
490
518
|
```javascript
|
|
491
|
-
/** @type {import('parseme').ParsemeConfigFile} */
|
|
519
|
+
/** @type {import('@parseme/cli').ParsemeConfigFile} */
|
|
492
520
|
const config = {
|
|
493
521
|
// Output settings
|
|
494
522
|
outputPath: 'PARSEME.md',
|
|
@@ -551,7 +579,7 @@ PARSEME supports three configuration formats with the following priority:
|
|
|
551
579
|
#### Example TypeScript Configuration
|
|
552
580
|
|
|
553
581
|
```typescript
|
|
554
|
-
import type { ParsemeConfigFile } from 'parseme';
|
|
582
|
+
import type { ParsemeConfigFile } from '@parseme/cli';
|
|
555
583
|
|
|
556
584
|
const config: ParsemeConfigFile = {
|
|
557
585
|
contextDir: 'parseme-context',
|
|
@@ -565,7 +593,7 @@ export default config;
|
|
|
565
593
|
#### Example JavaScript Configuration
|
|
566
594
|
|
|
567
595
|
```javascript
|
|
568
|
-
/** @type {import('parseme').ParsemeConfigFile} */
|
|
596
|
+
/** @type {import('@parseme/cli').ParsemeConfigFile} */
|
|
569
597
|
const config = {
|
|
570
598
|
contextDir: 'parseme-context',
|
|
571
599
|
excludePatterns: ['node_modules/**', 'dist/**', '.git/**'],
|
|
@@ -583,7 +611,7 @@ Configuration values are resolved in the following order (highest to lowest prio
|
|
|
583
611
|
2. **Config file** - Based on file format priority above
|
|
584
612
|
3. **Default values** - Built-in sensible defaults
|
|
585
613
|
|
|
586
|
-
**Example**: `
|
|
614
|
+
**Example**: `parseme --output custom.md` overrides `outputPath` from config file.
|
|
587
615
|
|
|
588
616
|
### Configuration Options
|
|
589
617
|
|
|
@@ -663,42 +691,36 @@ After initialization, setup tips are displayed:
|
|
|
663
691
|
|
|
664
692
|
```bash
|
|
665
693
|
# Generate context (auto-detects config file)
|
|
666
|
-
|
|
667
|
-
|
|
694
|
+
parseme generate
|
|
695
|
+
parseme g # alias
|
|
668
696
|
|
|
669
697
|
# Initialize configuration (JSON by default)
|
|
670
|
-
|
|
671
|
-
|
|
698
|
+
parseme init
|
|
699
|
+
parseme i # alias
|
|
672
700
|
|
|
673
701
|
# Initialize with TypeScript format
|
|
674
|
-
|
|
702
|
+
parseme init --format ts
|
|
675
703
|
|
|
676
704
|
# Initialize with JavaScript format
|
|
677
|
-
|
|
705
|
+
parseme init --format js
|
|
678
706
|
|
|
679
707
|
# Use custom config file
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
# If added to package.json scripts, use npm run
|
|
683
|
-
npm run parseme
|
|
684
|
-
|
|
685
|
-
# Auto-generate context with git hooks (when configured)
|
|
686
|
-
# Runs automatically after each commit
|
|
708
|
+
parseme generate --config custom.config.js
|
|
687
709
|
|
|
688
710
|
# Override config with CLI flags
|
|
689
|
-
|
|
711
|
+
parseme generate --output custom.md --context-dir docs/context --root ./src
|
|
690
712
|
|
|
691
713
|
# Disable git info generation (keeps git for file discovery)
|
|
692
|
-
|
|
714
|
+
parseme generate --no-git-info
|
|
693
715
|
|
|
694
716
|
# Disable git for file discovery (keeps git info generation)
|
|
695
|
-
|
|
717
|
+
parseme generate --no-git-files
|
|
696
718
|
|
|
697
719
|
# Disable both git info and git file discovery
|
|
698
|
-
|
|
720
|
+
parseme generate --no-git-info --no-git-files
|
|
699
721
|
|
|
700
722
|
# Specify file types and exclude patterns
|
|
701
|
-
|
|
723
|
+
parseme generate --file-types ts js --exclude "**/*.test.ts"
|
|
702
724
|
```
|
|
703
725
|
|
|
704
726
|
## Programmatic API
|
|
@@ -706,7 +728,7 @@ npx parseme generate --file-types ts js --exclude "**/*.test.ts"
|
|
|
706
728
|
You can also use PARSEME programmatically:
|
|
707
729
|
|
|
708
730
|
```typescript
|
|
709
|
-
import { ParsemeGenerator } from 'parseme';
|
|
731
|
+
import { ParsemeGenerator } from '@parseme/cli';
|
|
710
732
|
|
|
711
733
|
const generator = await ParsemeGenerator.fromConfig('./custom.config.js');
|
|
712
734
|
const context = await generator.generate();
|
package/dist/cli/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ const program = new Command();
|
|
|
8
8
|
async function promptForMissingConfig(config) {
|
|
9
9
|
return { ...config };
|
|
10
10
|
}
|
|
11
|
-
program.name('parseme').description('AI Project Context Generator').version('0.1.
|
|
11
|
+
program.name('parseme').description('AI Project Context Generator').version('0.1.2');
|
|
12
12
|
// Generate command
|
|
13
13
|
program
|
|
14
14
|
.command('generate')
|
|
@@ -38,11 +38,11 @@ export class ContextBuilder {
|
|
|
38
38
|
});
|
|
39
39
|
const hasRoutes = routes.length > 0;
|
|
40
40
|
const mainContent = this.buildHeader(linkPath, hasRoutes) +
|
|
41
|
-
'\n\n
|
|
41
|
+
'\n\n' +
|
|
42
42
|
this.buildProjectOverview(projectInfo) +
|
|
43
|
-
'\n\n
|
|
43
|
+
'\n\n' +
|
|
44
44
|
this.buildSummarySection(linkPath, hasRoutes) +
|
|
45
|
-
'\n\n
|
|
45
|
+
'\n\n' +
|
|
46
46
|
(gitInfo ? this.buildGitSection(gitInfo) : '');
|
|
47
47
|
const contextFiles = {
|
|
48
48
|
structure: '',
|
|
@@ -73,9 +73,11 @@ export class ContextBuilder {
|
|
|
73
73
|
: `5. For git tracked projects, follow the instructions in the "Git Information" section of this file to validate the actuality of the provided information.
|
|
74
74
|
6. Only dive deeper into specific files after reviewing this summary, that replaces the need for initial project exploration and significantly reduces token usage for project comprehension.`;
|
|
75
75
|
return `## PARSEME - AI Agent Context
|
|
76
|
+
|
|
76
77
|
Auto-generated project summary optimized for AI coding agents. This file provides complete project context without requiring full codebase traversal, designed for token efficiency.
|
|
77
78
|
|
|
78
79
|
**Usage Instructions for AI Agents:**
|
|
80
|
+
|
|
79
81
|
1. Read this PARSEME.md file completely first before accessing individual project files
|
|
80
82
|
2. Basic project information, script availability and dependency information provides basic understanding of code base and tech stack without checking package.json
|
|
81
83
|
3. Use the provided file list [${linkPath}/files.md](${linkPath}/files.md) to see all tracked files in the project
|
|
@@ -98,14 +100,14 @@ ${routesInstructions}`;
|
|
|
98
100
|
// Add dependencies
|
|
99
101
|
const deps = Object.keys(projectInfo.dependencies);
|
|
100
102
|
if (deps.length > 0) {
|
|
101
|
-
content += '\n
|
|
103
|
+
content += '\n### Dependencies\n\n';
|
|
102
104
|
deps.forEach((dep) => {
|
|
103
105
|
content += `- ${dep}\n`;
|
|
104
106
|
});
|
|
105
107
|
}
|
|
106
108
|
// Add available scripts
|
|
107
109
|
if (projectInfo.scripts && Object.keys(projectInfo.scripts).length > 0) {
|
|
108
|
-
content += '\n### Available Scripts\n';
|
|
110
|
+
content += '\n### Available Scripts\n\n';
|
|
109
111
|
Object.entries(projectInfo.scripts).forEach(([name, script]) => {
|
|
110
112
|
content += `- **${name}**: \`${script}\`\n`;
|
|
111
113
|
});
|
|
@@ -130,27 +132,32 @@ ${routesInstructions}`;
|
|
|
130
132
|
- **Branch:** ${gitInfo.branch}
|
|
131
133
|
- **Commit:** ${gitInfo.lastCommit}${gitInfo.origin ? `\n- **Origin:** ${gitInfo.origin}` : ''}
|
|
132
134
|
|
|
133
|
-
### Git Diff Statistics
|
|
135
|
+
### Git Diff Statistics
|
|
136
|
+
`;
|
|
134
137
|
const info = gitInfo.diffStat && gitInfo.diffStat.length > 0
|
|
135
138
|
? `Git diff statistics from the time of generation are available at [parseme-context/gitDiff.md](parseme-context/gitDiff.md) (relative to the commit mentioned above).
|
|
136
139
|
|
|
137
140
|
**AI Agent Command:** To check for changes since generation, run:
|
|
141
|
+
|
|
138
142
|
\`\`\`bash
|
|
139
143
|
git diff --stat
|
|
140
144
|
\`\`\`
|
|
145
|
+
|
|
141
146
|
Compare the output with the baseline in [parseme-context/gitDiff.md](parseme-context/gitDiff.md) to detect any modifications.`
|
|
142
147
|
: `Git diff statistics showed no changes at the time of generation relative to the commit mentioned above.`;
|
|
143
|
-
return base + '\n
|
|
148
|
+
return base + '\n' + info;
|
|
144
149
|
}
|
|
145
150
|
buildSummarySection(linkPath, hasRoutes) {
|
|
146
151
|
let content = `## Project Files
|
|
147
|
-
A complete list of all git-tracked files in the project (excluding files matching additional exclude patterns) is available at [${linkPath}/files.md](${linkPath}/files.md). This provides a quick overview of the project structure.
|
|
148
152
|
|
|
153
|
+
A complete list of all git-tracked files in the project (excluding files matching additional exclude patterns) is available at [${linkPath}/files.md](${linkPath}/files.md). This provides a quick overview of the project structure.
|
|
149
154
|
|
|
150
155
|
## Project Structure & AST
|
|
156
|
+
|
|
151
157
|
Detailed structure and Abstract Syntax Tree data for all tracked files is available at [${linkPath}/structure.json](${linkPath}/structure.json). This includes file paths, types, imports, exports, functions, classes, interfaces, and routes for comprehensive code analysis without manual parsing.`;
|
|
152
158
|
if (hasRoutes) {
|
|
153
|
-
content += `\n\n
|
|
159
|
+
content += `\n\n## API Routes
|
|
160
|
+
|
|
154
161
|
A comprehensive list of all discovered API routes is available at [${linkPath}/routes.json](${linkPath}/routes.json). This includes HTTP methods, paths, handler names, and source file locations for backend routes (Express, NestJS, and decorator-based routing).`;
|
|
155
162
|
}
|
|
156
163
|
return content;
|
|
@@ -218,6 +225,7 @@ A comprehensive list of all discovered API routes is available at [${linkPath}/r
|
|
|
218
225
|
}
|
|
219
226
|
buildDetailedGit(gitInfo) {
|
|
220
227
|
let content = `# Git Diff Statistics
|
|
228
|
+
|
|
221
229
|
`;
|
|
222
230
|
content += gitInfo.diffStat;
|
|
223
231
|
return content;
|
package/package.json
CHANGED