@parseme/cli 0.0.6 → 0.1.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.
package/README.md CHANGED
@@ -1,16 +1,43 @@
1
1
  # PARSEME
2
2
 
3
- AI Project Context Generator - Automated context generation for AI coding assistants.
3
+ **Local code analysis and context generation to improve token efficiency of AI Coding agents
4
+ Cross-project access via Cloud MCP**
4
5
 
5
6
  PARSEME analyzes your TypeScript/JavaScript projects and generates a PARSEME.md file—a README.md for AI agents. This file provides comprehensive context documentation that helps AI assistants understand your codebase structure, architecture, and patterns. By providing persistent, reusable context, PARSEME prevents AI agents from repeatedly analyzing your codebase from scratch—saving valuable tokens and improving efficiency for every interaction.
6
7
 
8
+ ## Table of Contents
9
+
10
+ - [Development Status](#development-status)
11
+ - [Features](#features)
12
+ - [What PARSEME Detects](#what-parseme-detects)
13
+ - [Language Support](#language-support)
14
+ - [Supported Projects](#supported-projects)
15
+ - [Installation](#installation)
16
+ - [Quick Start](#quick-start)
17
+ - [Automation Options](#automation-options)
18
+ - [Option 1: Manual Execution](#option-1-manual-execution)
19
+ - [Option 2: Automatic Local Generation](#option-2-automatic-local-generation)
20
+ - [Option 3: Automatic Local and Remote Generation (Advanced Git Hooks)](#option-3-automatic-local-and-remote-generation-advanced-git-hooks)
21
+ - [Option 4: GitHub Actions for Remote Generation paired with Local Generation](#option-4-github-actions-for-remote-generation-paired-with-local-generation)
22
+ - [Configuration](#configuration)
23
+ - [Configuration File Formats & Priority](#configuration-file-formats--priority)
24
+ - [Configuration Priority](#configuration-priority)
25
+ - [Configuration Options](#configuration-options)
26
+ - [CLI Options](#cli-options)
27
+ - [Interactive Configuration](#interactive-configuration)
28
+ - [CLI Commands](#cli-commands)
29
+ - [Programmatic API](#programmatic-api)
30
+ - [Output Format](#output-format)
31
+ - [AI Agent Integration](#ai-agent-integration)
32
+ - [Requirements](#requirements)
33
+ - [License](#license)
34
+
7
35
  ## Development Status
8
36
 
9
- **This project is currently in active development and pre-alpha phase.**
37
+ **This project is currently in active development.**
10
38
 
11
39
  The core functionality is working, but expect:
12
40
 
13
- - Breaking changes in configuration format
14
41
  - API modifications as the interface gets refined
15
42
  - Additional features being added regularly
16
43
  - Possible bugs and edge cases
@@ -88,10 +115,12 @@ PARSEME aims to automatically analyse any JavaScript or TypeScript project like:
88
115
  - **Desktop apps** - Main processes, renderers, IPC handlers
89
116
  - **Testing utilities** - Test functions, mocks, utilities, custom matchers
90
117
 
118
+ **Note:** PARSEME provides specialized analysis for **Express.js**, **NestJS**, and **Fastify**, including route detection, middleware identification, and decorator analysis. All other frameworks benefit from universal AST-based analysis.
119
+
91
120
  ## Installation
92
121
 
93
122
  ```bash
94
- npm install --save-dev parseme
123
+ npm install --save-dev @parseme/cli
95
124
  ```
96
125
 
97
126
  ## Quick Start
@@ -99,9 +128,9 @@ npm install --save-dev parseme
99
128
  1. **Initialize configuration**:
100
129
 
101
130
  ```bash
102
- npx parseme init
131
+ npx @parseme/cli init
103
132
  # or use the alias
104
- npx parseme i
133
+ npx @parseme/cli i
105
134
  ```
106
135
 
107
136
  You'll be prompted for:
@@ -114,30 +143,321 @@ npm install --save-dev parseme
114
143
  - How to add parseme script to package.json
115
144
  - How to integrate with git hooks
116
145
  - README section to help AI agents find context
146
+ - AI agent configuration files to reference PARSEME.md
117
147
 
118
- 2. **Add to your package.json scripts** (optional, for easier execution):
119
-
120
- ```json
121
- {
122
- "scripts": {
123
- "parseme": "parseme generate"
124
- }
125
- }
126
- ```
127
-
128
- 3. **Generate context**:
148
+ 2. **Generate context**:
129
149
  ```bash
130
- npm run parseme
131
- # or
132
- npx parseme generate
150
+ npx @parseme/cli generate
133
151
  # or use the alias
134
- npx parseme g
152
+ npx @parseme/cli g
135
153
  ```
136
154
 
137
155
  This creates:
138
156
 
139
157
  - `PARSEME.md` - Main overview with links to context files
140
- - `parseme-context/` - Structured data files (AST, dependencies, routes, git info)
158
+ - `parseme-context/` - Structured data files (file list, AST structure, routes, git diff)
159
+
160
+ ## Automation Options
161
+
162
+ PARSEME can be integrated into your workflow in several ways, from manual execution to fully automated generation. Choose the approach that best fits your needs:
163
+
164
+ ### Option 1: Manual Execution
165
+
166
+ Run parseme manually whenever you need updated context.
167
+
168
+ **Setup:**
169
+
170
+ Add to your `package.json` scripts (optional, for convenience):
171
+
172
+ ```json
173
+ {
174
+ "scripts": {
175
+ "parseme": "parseme generate"
176
+ }
177
+ }
178
+ ```
179
+
180
+ **Usage:**
181
+
182
+ ```bash
183
+ npm run parseme
184
+ # or directly
185
+ parseme generate
186
+ ```
187
+
188
+ ---
189
+
190
+ ### Option 2: Automatic Local Generation
191
+
192
+ Automatically generate parseme files locally after every commit. Files are committed to the repository.
193
+
194
+ **Setup with Husky:**
195
+
196
+ ```bash
197
+ # Install Husky (if not already installed)
198
+ npm install --save-dev husky
199
+ npx husky init
200
+
201
+ # Create post-commit hook
202
+ cat > .husky/post-commit << 'EOF'
203
+ #!/bin/sh
204
+
205
+ # Generate PARSEME files locally after commit
206
+ npx @parseme/cli generate
207
+ EOF
208
+
209
+ # Make hook executable
210
+ chmod +x .husky/post-commit
211
+ ```
212
+
213
+ **Setup with manual git hooks:**
214
+
215
+ ```bash
216
+ cat > .git/hooks/post-commit << 'EOF'
217
+ #!/bin/sh
218
+
219
+ npx @parseme/cli generate
220
+ EOF
221
+
222
+ chmod +x .git/hooks/post-commit
223
+ ```
224
+
225
+ **How it works:**
226
+
227
+ - After each commit, parseme automatically generates context files with full git info
228
+ - Files are ready to be staged and committed with your next commit
229
+ - Simple setup with minimal configuration
230
+
231
+ **Note:** If using a custom `contextDir`, ensure the path is consistent across your team's configuration.
232
+
233
+ ---
234
+
235
+ ### Option 3: Automatic Local and Remote Generation (Advanced Git Hooks)
236
+
237
+ Automatically update parseme files locally and remotely with git hooks. Keeps the remote version clean (without git-specific info) while maintaining full context locally. Uses multiple git hooks to manage local vs remote state.
238
+
239
+ **Setup with Husky:**
240
+
241
+ ```bash
242
+ # Install Husky (if not already installed)
243
+ npm install --save-dev husky
244
+ npx husky init
245
+
246
+ # Create post-commit hook
247
+ cat > .husky/post-commit << 'EOF'
248
+ #!/bin/sh
249
+
250
+ npx @parseme/cli generate
251
+ EOF
252
+
253
+ # Create pre-push hook
254
+ cat > .husky/pre-push << 'EOF'
255
+ #!/bin/sh
256
+
257
+ # Regenerate without git info for clean remote state
258
+ npx @parseme/cli generate --no-git-info
259
+
260
+ # Stage parseme files
261
+ git add parseme-context/ PARSEME.md
262
+
263
+ # Amend the commit with updated parseme files
264
+ git commit --amend --no-edit --no-verify
265
+ EOF
266
+
267
+ # Create post-push hook
268
+ cat > .husky/post-push << 'EOF'
269
+ #!/bin/sh
270
+
271
+ # Regenerate with git info for local development
272
+ npx @parseme/cli generate
273
+ EOF
274
+
275
+ # Make hooks executable
276
+ chmod +x .husky/post-commit .husky/pre-push .husky/post-push
277
+ ```
278
+
279
+ **Setup with manual git hooks:**
280
+
281
+ ```bash
282
+ # Post-commit: Generate context with git info after each commit
283
+ cat > .git/hooks/post-commit << 'EOF'
284
+ #!/bin/sh
285
+
286
+ npx @parseme/cli generate
287
+ EOF
288
+
289
+ # Pre-push: Regenerate without git info and amend before pushing
290
+ cat > .git/hooks/pre-push << 'EOF'
291
+ #!/bin/sh
292
+
293
+ # Regenerate without git info for clean remote state
294
+ npx @parseme/cli generate --no-git-info
295
+
296
+ # Stage parseme files
297
+ git add parseme-context/ PARSEME.md
298
+
299
+ # Amend the commit with updated parseme files
300
+ git commit --amend --no-edit --no-verify
301
+ EOF
302
+
303
+ # Post-push: Restore git info locally after push completes
304
+ cat > .git/hooks/post-push << 'EOF'
305
+ #!/bin/sh
306
+
307
+ # Regenerate with git info for local development
308
+ npx @parseme/cli generate
309
+ EOF
310
+
311
+ # Make hooks executable
312
+ chmod +x .git/hooks/post-commit .git/hooks/pre-push .git/hooks/post-push
313
+ ```
314
+
315
+ **How it works:**
316
+
317
+ 1. **post-commit**: Generates context files with full git info locally
318
+ 2. **pre-push**: Regenerates without git info and amends the commit before pushing
319
+ 3. **post-push**: Restores full git info locally after push completes
320
+
321
+ The `--no-verify` flag in pre-push prevents an infinite loop by skipping hook execution on the amend.
322
+
323
+ **Note:** If using a custom `contextDir`, update the `git add` path in the pre-push hook (e.g., `git add docs/context/ PARSEME.md`).
324
+
325
+ ---
326
+
327
+ ### Option 4: GitHub Actions for Remote Generation paired with Local Generation
328
+
329
+ Use GitHub Actions to automatically manage remote parseme files while keeping them updated locally with git hooks. This is the recommended approach for teams using GitHub.
330
+
331
+ **Setup:**
332
+
333
+ **1. Add parseme files to `.gitignore`:**
334
+
335
+ ```gitignore
336
+ # Parseme documentation (generated locally and by CI)
337
+ parseme-context/
338
+ PARSEME.md
339
+ ```
340
+
341
+ **2. Create `.github/workflows/parseme-update.yml`:**
342
+
343
+ ```yaml
344
+ name: Update PARSEME Documentation
345
+
346
+ on:
347
+ push:
348
+ branches:
349
+ - main
350
+
351
+ jobs:
352
+ update-parseme:
353
+ runs-on: ubuntu-latest
354
+ permissions:
355
+ contents: write
356
+ env:
357
+ GITHUB_TOKEN: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}
358
+
359
+ steps:
360
+ - name: Check if pusher is service account
361
+ id: check_pusher
362
+ run: |
363
+ if [ "${{ github.event.pusher.name }}" = "${{ secrets.GH_SERVICE_ACCOUNT_USERNAME }}" ]; then
364
+ echo "is_bot=true" >> $GITHUB_OUTPUT
365
+ else
366
+ echo "is_bot=false" >> $GITHUB_OUTPUT
367
+ fi
368
+
369
+ - name: Checkout code
370
+ if: steps.check_pusher.outputs.is_bot == 'false'
371
+ uses: actions/checkout@v4
372
+ with:
373
+ fetch-depth: 0
374
+ token: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}
375
+
376
+ - name: Setup Node.js
377
+ if: steps.check_pusher.outputs.is_bot == 'false'
378
+ uses: actions/setup-node@v4
379
+ with:
380
+ node-version: '22'
381
+ cache: 'npm'
382
+
383
+ - name: Configure Git
384
+ if: steps.check_pusher.outputs.is_bot == 'false'
385
+ run: |
386
+ git config user.name "${{ secrets.GH_SERVICE_ACCOUNT_USERNAME }}"
387
+ git config user.email "${{ secrets.GH_SERVICE_ACCOUNT_USERNAME }}@users.noreply.github.com"
388
+
389
+ - name: Install dependencies
390
+ if: steps.check_pusher.outputs.is_bot == 'false'
391
+ run: npm ci
392
+
393
+ - name: Generate ParseMe documentation
394
+ if: steps.check_pusher.outputs.is_bot == 'false'
395
+ run: parseme generate --no-git-info
396
+
397
+ - name: Force add parseme files (ignored in .gitignore)
398
+ if: steps.check_pusher.outputs.is_bot == 'false'
399
+ run: git add -f parseme-context/ PARSEME.md
400
+
401
+ - name: Check for changes
402
+ if: steps.check_pusher.outputs.is_bot == 'false'
403
+ id: check_changes
404
+ run: |
405
+ if git diff --cached --quiet; then
406
+ echo "changes=false" >> $GITHUB_OUTPUT
407
+ else
408
+ echo "changes=true" >> $GITHUB_OUTPUT
409
+ fi
410
+
411
+ - name: Commit and amend
412
+ if: steps.check_pusher.outputs.is_bot == 'false' && steps.check_changes.outputs.changes == 'true'
413
+ run: |
414
+ git commit --amend --no-edit --no-verify
415
+ git push --force-with-lease
416
+ ```
417
+
418
+ **3. Configure GitHub secrets:**
419
+
420
+ - `GH_SERVICE_ACCOUNT_TOKEN`: A GitHub personal access token with repo write permissions
421
+ - `GH_SERVICE_ACCOUNT_USERNAME`: The username of your service account (to prevent infinite loops)
422
+
423
+ **4. Setup local git hooks with Husky:**
424
+
425
+ ```bash
426
+ # Install Husky (if not already installed)
427
+ npm install --save-dev husky
428
+ npx husky init
429
+
430
+ # Create post-commit hook
431
+ cat > .husky/post-commit << 'EOF'
432
+ #!/bin/sh
433
+
434
+ # Generate PARSEME files locally after commit
435
+ npx @parseme/cli generate
436
+ EOF
437
+
438
+ # Create post-merge hook
439
+ cat > .husky/post-merge << 'EOF'
440
+ #!/bin/sh
441
+
442
+ # Untrack parseme files after merge/pull to keep them gitignored locally
443
+ git rm --cached -r parseme-context/ PARSEME.md 2>/dev/null || true
444
+ EOF
445
+
446
+ # Make hooks executable
447
+ chmod +x .husky/post-commit .husky/post-merge
448
+ ```
449
+
450
+ **How it works:**
451
+
452
+ 1. **Local development**: Parseme files are generated locally after each commit with full git info
453
+ 2. **Ignored by git**: Files are listed in `.gitignore` so they're not committed manually
454
+ 3. **Remote updates**: GitHub Actions automatically generates and commits parseme files (without git info) when pushing to main
455
+ 4. **After pull/merge**: The post-merge hook ensures parseme files stay untracked locally, preventing conflicts
456
+
457
+ **Notes:**
458
+
459
+ - The workflow only runs on the `main` branch (adjust as needed for your branching strategy)
460
+ - If using a custom `contextDir`, update both the `.gitignore` entry, the workflow's `git add -f` path, and the post-merge hook's `git rm --cached -r` path accordingly
141
461
 
142
462
  ## Configuration
143
463
 
@@ -148,7 +468,7 @@ The `parseme init` command creates a minimal config with only your custom settin
148
468
  **Minimal config example** (created by `parseme init`):
149
469
 
150
470
  ```javascript
151
- /** @type {import('parseme').ParsemeConfigFile} */
471
+ /** @type {import('@parseme/cli').ParsemeConfigFile} */
152
472
  const config = {
153
473
  contextDir: 'parseme-context',
154
474
  excludePatterns: ['node_modules/**', '.git/**'],
@@ -160,7 +480,7 @@ export default config;
160
480
  **Full config example** (all available options):
161
481
 
162
482
  ```javascript
163
- /** @type {import('parseme').ParsemeConfigFile} */
483
+ /** @type {import('@parseme/cli').ParsemeConfigFile} */
164
484
  const config = {
165
485
  // Output settings
166
486
  outputPath: 'PARSEME.md',
@@ -223,7 +543,7 @@ PARSEME supports three configuration formats with the following priority:
223
543
  #### Example TypeScript Configuration
224
544
 
225
545
  ```typescript
226
- import type { ParsemeConfigFile } from 'parseme';
546
+ import type { ParsemeConfigFile } from '@parseme/cli';
227
547
 
228
548
  const config: ParsemeConfigFile = {
229
549
  contextDir: 'parseme-context',
@@ -237,7 +557,7 @@ export default config;
237
557
  #### Example JavaScript Configuration
238
558
 
239
559
  ```javascript
240
- /** @type {import('parseme').ParsemeConfigFile} */
560
+ /** @type {import('@parseme/cli').ParsemeConfigFile} */
241
561
  const config = {
242
562
  contextDir: 'parseme-context',
243
563
  excludePatterns: ['node_modules/**', 'dist/**', '.git/**'],
@@ -255,7 +575,7 @@ Configuration values are resolved in the following order (highest to lowest prio
255
575
  2. **Config file** - Based on file format priority above
256
576
  3. **Default values** - Built-in sensible defaults
257
577
 
258
- **Example**: `npx parseme --output custom.md` overrides `outputPath` from config file.
578
+ **Example**: `parseme --output custom.md` overrides `outputPath` from config file.
259
579
 
260
580
  ### Configuration Options
261
581
 
@@ -298,63 +618,6 @@ Toggle which sections to include in the output (all default to `true`):
298
618
 
299
619
  - `limits.maxFilesPerContext` - Maximum number of files to analyze (default: `5000`)
300
620
 
301
- ## Output Format
302
-
303
- PARSEME always generates the following output files:
304
-
305
- - `PARSEME.md` - Main overview with links to context files (Markdown)
306
- - Context directory (default: `parseme-context/`) with structured data files:
307
- - `files.md` - Complete list of analyzed files (Markdown)
308
- - `structure.json` - AST analysis with exports, imports, functions, and classes (JSON)
309
- - `api-endpoints.json` - API routes with methods, paths, and handlers (JSON, only if routes detected)
310
- - `dependencies.json` - Production dependencies with versions (JSON)
311
- - `framework.json` - Framework details if detected (JSON, optional)
312
- - `gitDiff.md` - Git diff statistics from generation time (Markdown, if git enabled)
313
-
314
- The context directory location can be customized via the `contextDir` configuration option.
315
-
316
- ## CLI Commands
317
-
318
- ```bash
319
- # Generate context (auto-detects config file)
320
- npx parseme generate
321
- npx parseme g # alias
322
-
323
- # Initialize configuration (JSON by default)
324
- npx parseme init
325
- npx parseme i # alias
326
-
327
- # Initialize with TypeScript format
328
- npx parseme init --format ts
329
-
330
- # Initialize with JavaScript format
331
- npx parseme init --format js
332
-
333
- # Use custom config file
334
- npx parseme generate --config custom.config.js
335
-
336
- # If added to package.json scripts, use npm run
337
- npm run parseme
338
-
339
- # Auto-generate context with git hooks (when configured)
340
- # Runs automatically after each commit
341
-
342
- # Override config with CLI flags
343
- npx parseme generate --output custom.md --context-dir docs/context --root ./src
344
-
345
- # Disable git info generation (keeps git for file discovery)
346
- npx parseme generate --no-git-info
347
-
348
- # Disable git for file discovery (keeps git info generation)
349
- npx parseme generate --no-git-files
350
-
351
- # Disable both git info and git file discovery
352
- npx parseme generate --no-git-info --no-git-files
353
-
354
- # Specify file types and exclude patterns
355
- npx parseme generate --file-types ts js --exclude "**/*.test.ts"
356
- ```
357
-
358
621
  ### CLI Options
359
622
 
360
623
  #### Generate Command (`parseme generate` or `parseme g`)
@@ -386,35 +649,50 @@ After initialization, setup tips are displayed:
386
649
  - Package.json script suggestion
387
650
  - Git hook integration suggestion
388
651
  - README.md section suggestion for AI agents
652
+ - AI agent configuration files to reference PARSEME.md
653
+
654
+ ## CLI Commands
389
655
 
390
- ## Framework Support
656
+ ```bash
657
+ # Generate context (auto-detects config file)
658
+ parseme generate
659
+ parseme g # alias
660
+
661
+ # Initialize configuration (JSON by default)
662
+ parseme init
663
+ parseme i # alias
391
664
 
392
- PARSEME automatically detects and provides specialized analysis for:
665
+ # Initialize with TypeScript format
666
+ parseme init --format ts
667
+
668
+ # Initialize with JavaScript format
669
+ parseme init --format js
393
670
 
394
- ### Express.js
671
+ # Use custom config file
672
+ parseme generate --config custom.config.js
395
673
 
396
- - Route detection (`app.get`, `router.post`, etc.)
397
- - Middleware identification
398
- - Request handler mapping
674
+ # Override config with CLI flags
675
+ parseme generate --output custom.md --context-dir docs/context --root ./src
399
676
 
400
- ### NestJS
677
+ # Disable git info generation (keeps git for file discovery)
678
+ parseme generate --no-git-info
401
679
 
402
- - Controller and decorator analysis
403
- - Module structure detection w
404
- - Dependency injection mapping
680
+ # Disable git for file discovery (keeps git info generation)
681
+ parseme generate --no-git-files
405
682
 
406
- ### Fastify
683
+ # Disable both git info and git file discovery
684
+ parseme generate --no-git-info --no-git-files
407
685
 
408
- - Route registration detection
409
- - Plugin identification
410
- - Hook analysis
686
+ # Specify file types and exclude patterns
687
+ parseme generate --file-types ts js --exclude "**/*.test.ts"
688
+ ```
411
689
 
412
690
  ## Programmatic API
413
691
 
414
692
  You can also use PARSEME programmatically:
415
693
 
416
694
  ```typescript
417
- import { ParsemeGenerator } from 'parseme';
695
+ import { ParsemeGenerator } from '@parseme/cli';
418
696
 
419
697
  const generator = await ParsemeGenerator.fromConfig('./custom.config.js');
420
698
  const context = await generator.generate();
@@ -423,80 +701,54 @@ const context = await generator.generate();
423
701
  await generator.generateToFile('./output/PARSEME.md');
424
702
  ```
425
703
 
426
- ## Git Hook Integration
427
-
428
- Keep your AI context automatically updated by integrating parseme with git hooks. The recommended setup uses three hooks to ensure context files always have git info locally but stay clean on remote:
429
-
430
- ### Recommended Hook Setup
431
-
432
- #### Manual Setup
704
+ ## Output Format
433
705
 
434
- ```bash
435
- # 1. Post-commit: Generate context with git info after each commit
436
- cat > .git/hooks/post-commit << 'EOF'
437
- #!/bin/sh
706
+ PARSEME generates the following output files:
438
707
 
439
- npx parseme generate
440
- EOF
708
+ - `PARSEME.md` - Main overview with links to context files and project summary (Markdown)
709
+ - Context directory (default: `parseme-context/`) with structured data files:
710
+ - `files.md` - Complete list of all project files (Markdown)
711
+ - `structure.json` - AST analysis with exports, imports, functions, classes, and route references (JSON)
712
+ - `routes.json` - API routes with methods, paths, and handlers (JSON, only if routes detected)
713
+ - `gitDiff.md` - Git diff statistics from generation time (Markdown, only if git is enabled and changes exist)
441
714
 
442
- # 2. Pre-push: Regenerate without git info and amend before pushing
443
- cat > .git/hooks/pre-push << 'EOF'
444
- #!/bin/sh
715
+ The context directory location can be customized via the `contextDir` configuration option.
445
716
 
446
- # Regenerate without git info for clean remote state
447
- npx parseme generate --no-git-info
717
+ ## AI Agent Integration
448
718
 
449
- # Stage parseme files (parseme-context/ may be different if configured)
450
- git add parseme-context/ PARSEME.md
719
+ To help AI coding assistants efficiently understand your codebase structure and context, add instructions to your agent configuration files:
451
720
 
452
- # Amend the commit with updated parseme files
453
- git commit --amend --no-edit --no-verify
454
- EOF
721
+ ### Claude Code (`.claude/README.md` or `.claude/instructions.md`)
455
722
 
456
- # 3. Post-push: Restore git info locally after push completes
457
- cat > .git/hooks/post-push << 'EOF'
458
- #!/bin/sh
723
+ ```markdown
724
+ Read PARSEME.md and parseme-context/ to understand the codebase structure and context.
725
+ ```
459
726
 
460
- # Regenerate with git info for local development
461
- npx parseme generate
462
- EOF
727
+ ### GitHub Copilot (`.github/copilot-instructions.md`)
463
728
 
464
- # Make hooks executable
465
- chmod +x .git/hooks/post-commit .git/hooks/pre-push .git/hooks/post-push
729
+ ```markdown
730
+ Read PARSEME.md and parseme-context/ to understand the codebase structure and context.
466
731
  ```
467
732
 
468
- **Note:** If you've configured a custom `contextDir` (either in your config file or via the `--context-dir` CLI flag), update the `git add` path in the pre-push hook accordingly (e.g., `git add docs/context/ PARSEME.md`).
469
-
470
- ### Using Husky
733
+ ### Cursor (`.cursorrules`)
471
734
 
472
- ```json
473
- // package.json
474
- {
475
- "husky": {
476
- "hooks": {
477
- "post-commit": "npx parseme generate",
478
- "pre-push": "npx parseme generate --no-git-info && git add parseme-context/ PARSEME.md && git commit --amend --no-edit --no-verify",
479
- "post-push": "npx parseme generate"
480
- }
481
- }
482
- }
735
+ ```
736
+ Read PARSEME.md and parseme-context/ to understand the codebase structure and context.
483
737
  ```
484
738
 
485
- **Note:** If using a custom `contextDir`, update the `git add` path to match your configuration.
486
-
487
- ### How It Works
739
+ ### ChatGPT / Custom GPT
488
740
 
489
- 1. **post-commit**: After you commit, parseme generates context files with git info (current branch, recent commits, git diff) for local development
490
- 2. **pre-push**: Before pushing, parseme regenerates without git info (`--no-git-info` flag) and amends the commit to keep remote clean
491
- 3. **post-push**: After push completes, parseme regenerates with git info again so your local working copy maintains full context
741
+ Add to project instructions or system prompt:
492
742
 
493
- The `--no-verify` flag in pre-push prevents an infinite loop by skipping hook execution on the amend.
743
+ ```
744
+ Read PARSEME.md and parseme-context/ to understand the codebase structure and context.
745
+ ```
494
746
 
495
- This automatically keeps your AI context files synchronized with your code while maintaining clean context on remote and detailed context locally!
747
+ This ensures AI assistants use your pre-generated context for efficient codebase understanding.
496
748
 
497
749
  ## Requirements
498
750
 
499
- - Node.js ≥20.19.5
751
+ - Node.js ≥20.19.5 <21 || ≥22.21.1
500
752
  - npm ≥10.8.2
501
753
 
502
754
  ## License
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.0');
11
+ program.name('parseme').description('AI Project Context Generator').version('0.1.1');
12
12
  // Generate command
13
13
  program
14
14
  .command('generate')
@@ -126,7 +126,13 @@ program
126
126
  console.log('## Instructions For AI Agents');
127
127
  console.log('This project includes AI-optimized documentation for efficient context providing:');
128
128
  console.log('- `PARSEME.md` - Project overview with links to detailed context files');
129
- console.log('- `parseme-context/` - Structured data files (AST analysis, dependencies, routes, git info)');
129
+ console.log('- `parseme-context/` - Structured data files (file list, AST structure, routes, git diff)');
130
+ console.log('');
131
+ console.log('Tip: Add references to PARSEME.md in your AI agent config files for efficient context gathering:');
132
+ console.log(' - Claude Code: .claude/README.md or .claude/instructions.md');
133
+ console.log(' - GitHub Copilot: .github/copilot-instructions.md');
134
+ console.log(' - Cursor: .cursorrules');
135
+ console.log(' - Example instruction: "Read PARSEME.md and parseme-context/ to understand the codebase structure and context."');
130
136
  console.log('');
131
137
  }
132
138
  catch (error) {
@@ -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\n' +
41
+ '\n\n' +
42
42
  this.buildProjectOverview(projectInfo) +
43
- '\n\n\n' +
43
+ '\n\n' +
44
44
  this.buildSummarySection(linkPath, hasRoutes) +
45
- '\n\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\n### Dependencies\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,33 +132,38 @@ ${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\n' + info;
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\n## API Routes
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;
157
164
  }
158
165
  buildFilesList(allFiles) {
159
- let content = `# Project Files\n`;
166
+ let content = `# Project Files\n\n`;
160
167
  allFiles.forEach((file) => {
161
168
  content += `- ${file}\n`;
162
169
  });
@@ -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;
@@ -75,12 +75,16 @@ export class ParsemeGenerator {
75
75
  // Clear the directory if it exists, then recreate it
76
76
  await rm(parsemeDir, { recursive: true, force: true });
77
77
  await mkdir(parsemeDir, { recursive: true });
78
- await writeFile(finalOutputPath, context.parseme);
78
+ const parsemeContent = context.parseme.endsWith('\n')
79
+ ? context.parseme
80
+ : context.parseme + '\n';
81
+ await writeFile(finalOutputPath, parsemeContent);
79
82
  if (context.context) {
80
83
  for (const [filename, content] of Object.entries(context.context)) {
81
84
  // Use .md extension for markdown files, .json for others
82
85
  const extension = filename === 'gitDiff' || filename === 'files' ? '.md' : '.json';
83
- await writeFile(join(parsemeDir, `${filename}${extension}`), content);
86
+ const fileContent = content.endsWith('\n') ? content : content + '\n';
87
+ await writeFile(join(parsemeDir, `${filename}${extension}`), fileContent);
84
88
  }
85
89
  }
86
90
  }
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@parseme/cli",
3
- "version": "0.0.6",
3
+ "version": "0.1.1",
4
4
  "description": "Adds a PARSEME.md file—a README.md for AI agents—to your project, providing context and structure for automated tools.",
5
5
  "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ },
11
+ "./package.json": "./package.json"
12
+ },
8
13
  "bin": {
9
14
  "parseme": "dist/cli/cli.js"
10
15
  },
@@ -15,7 +20,7 @@
15
20
  ],
16
21
  "engines": {
17
22
  "npm": ">=10.8.2",
18
- "node": ">=20.19.5"
23
+ "node": ">=20.19.5 <21 || >=22.21.1"
19
24
  },
20
25
  "scripts": {
21
26
  "build": "tsc -p tsconfig.json",
@@ -53,7 +58,7 @@
53
58
  "bugs": {
54
59
  "url": "https://github.com/citrus551/parseme-modules/issues"
55
60
  },
56
- "homepage": "https://github.com/citrus551/parseme-modules#readme",
61
+ "homepage": "https://parseme.ai",
57
62
  "dependencies": {
58
63
  "@babel/core": "^7.28.4",
59
64
  "@babel/parser": "^7.28.4",