@parseme/cli 0.0.5 → 0.0.6

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
@@ -173,7 +173,8 @@ const config = {
173
173
  maxDepth: 10,
174
174
 
175
175
  // Git integration
176
- includeGitInfo: true,
176
+ includeGitInfo: true, // Include git repository information in context
177
+ useGitForFiles: true, // Use git to discover files (respects .gitignore)
177
178
 
178
179
  // Size limits
179
180
  limits: {
@@ -272,7 +273,8 @@ Configuration values are resolved in the following order (highest to lowest prio
272
273
 
273
274
  #### Git Integration
274
275
 
275
- - `includeGitInfo` - Include git repository information (default: `true`)
276
+ - `includeGitInfo` - Include git repository information in context files (default: `true`)
277
+ - `useGitForFiles` - Use git to discover files, respecting .gitignore (default: `true`)
276
278
 
277
279
  #### Content Sections
278
280
 
@@ -338,7 +340,16 @@ npm run parseme
338
340
  # Runs automatically after each commit
339
341
 
340
342
  # Override config with CLI flags
341
- npx parseme generate --output custom.md --context-dir docs/context --root ./src --no-git
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
342
353
 
343
354
  # Specify file types and exclude patterns
344
355
  npx parseme generate --file-types ts js --exclude "**/*.test.ts"
@@ -354,7 +365,8 @@ npx parseme generate --file-types ts js --exclude "**/*.test.ts"
354
365
  - `--context-dir <path>` - Context directory path (default: parseme-context)
355
366
  - `--file-types <types...>` - File types to analyze (e.g., ts tsx js jsx)
356
367
  - `--exclude <patterns...>` - Additional exclude patterns (glob, in git repositories on top of git-tracked files)
357
- - `--no-git` - Disable git information
368
+ - `--no-git-info` - Disable git info generation (keeps git for file discovery)
369
+ - `--no-git-files` - Disable git for file discovery (uses filesystem crawling instead)
358
370
  - `--max-depth <number>` - Maximum directory depth
359
371
 
360
372
  #### Init Command (`parseme init` or `parseme i`)
@@ -413,16 +425,48 @@ await generator.generateToFile('./output/PARSEME.md');
413
425
 
414
426
  ## Git Hook Integration
415
427
 
416
- Keep your AI context automatically updated by adding parseme as a post-commit hook:
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:
417
429
 
418
- ### Manual Setup
430
+ ### Recommended Hook Setup
431
+
432
+ #### Manual Setup
419
433
 
420
434
  ```bash
421
- # Create and make executable
422
- echo '#!/bin/sh\npx parseme generate' > .git/hooks/post-commit
423
- chmod +x .git/hooks/post-commit
435
+ # 1. Post-commit: Generate context with git info after each commit
436
+ cat > .git/hooks/post-commit << 'EOF'
437
+ #!/bin/sh
438
+
439
+ npx parseme generate
440
+ EOF
441
+
442
+ # 2. Pre-push: Regenerate without git info and amend before pushing
443
+ cat > .git/hooks/pre-push << 'EOF'
444
+ #!/bin/sh
445
+
446
+ # Regenerate without git info for clean remote state
447
+ npx parseme generate --no-git-info
448
+
449
+ # Stage parseme files (parseme-context/ may be different if configured)
450
+ git add parseme-context/ PARSEME.md
451
+
452
+ # Amend the commit with updated parseme files
453
+ git commit --amend --no-edit --no-verify
454
+ EOF
455
+
456
+ # 3. Post-push: Restore git info locally after push completes
457
+ cat > .git/hooks/post-push << 'EOF'
458
+ #!/bin/sh
459
+
460
+ # Regenerate with git info for local development
461
+ npx parseme generate
462
+ EOF
463
+
464
+ # Make hooks executable
465
+ chmod +x .git/hooks/post-commit .git/hooks/pre-push .git/hooks/post-push
424
466
  ```
425
467
 
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
+
426
470
  ### Using Husky
427
471
 
428
472
  ```json
@@ -430,13 +474,25 @@ chmod +x .git/hooks/post-commit
430
474
  {
431
475
  "husky": {
432
476
  "hooks": {
433
- "post-commit": "npx parseme generate"
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"
434
480
  }
435
481
  }
436
482
  }
437
483
  ```
438
484
 
439
- This automatically regenerates your AI context files after every commit, ensuring they're always up-to-date!
485
+ **Note:** If using a custom `contextDir`, update the `git add` path to match your configuration.
486
+
487
+ ### How It Works
488
+
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
492
+
493
+ The `--no-verify` flag in pre-push prevents an infinite loop by skipping hook execution on the amend.
494
+
495
+ This automatically keeps your AI context files synchronized with your code while maintaining clean context on remote and detailed context locally!
440
496
 
441
497
  ## Requirements
442
498
 
package/dist/cli/cli.js CHANGED
@@ -20,7 +20,8 @@ program
20
20
  .option('--context-dir <path>', 'Context directory path (default: parseme-context)')
21
21
  .option('--file-types <types...>', 'File types to analyze (e.g., ts tsx js jsx)')
22
22
  .option('--exclude <patterns...>', 'Exclude patterns (glob)')
23
- .option('--no-git', 'Disable git integration (info and file discovery)')
23
+ .option('--no-git-files', 'Disable git for file discovery')
24
+ .option('--no-git-info', 'Disable git info generation')
24
25
  .option('--max-depth <number>', 'Maximum directory depth', parseInt)
25
26
  .action(async (options) => {
26
27
  try {
@@ -31,7 +32,8 @@ program
31
32
  ...(options.contextDir && { contextDir: options.contextDir }),
32
33
  ...(options.fileTypes && { analyzeFileTypes: options.fileTypes }),
33
34
  ...(options.exclude && { excludePatterns: options.exclude }),
34
- ...(options.git === false && { includeGitInfo: false, useGitForFiles: false }),
35
+ ...(options.gitFiles === false && { useGitForFiles: false }),
36
+ ...(options.gitInfo === false && { includeGitInfo: false }),
35
37
  ...(options.maxDepth && { maxDepth: options.maxDepth }),
36
38
  };
37
39
  const configFromFile = await ParsemeConfig.fromFile(options.config, {
@@ -116,8 +118,8 @@ program
116
118
  if (options.format === 'ts') {
117
119
  console.log('For TypeScript configs, ensure tsx or ts-node is available to load .ts files');
118
120
  }
119
- console.log('Tip: Add "parseme": "parseme" to your package.json scripts for easier manual execution or hook integration');
120
- console.log('Tip: Add parseme as a git hook to keep context auto-updated! See README for setup instructions.');
121
+ console.log('Tip: Add "parseme": "parseme generate" to your package.json scripts for easier manual execution or hook integration');
122
+ console.log('Tip: Add parseme as git hooks to keep context auto-updated! See README for recommended hook setup (post-commit, pre-push, post-push).');
121
123
  console.log('');
122
124
  console.log('Tip: Add this section to your README.md to help AI agents find the context:');
123
125
  console.log('');
@@ -1,4 +1,4 @@
1
- import { mkdir, writeFile } from 'fs/promises';
1
+ import { mkdir, writeFile, rm } from 'fs/promises';
2
2
  import { join } from 'path';
3
3
  import { ASTAnalyzer } from './analyzers/ast-analyzer.js';
4
4
  import { FrameworkDetector } from './analyzers/framework-detector.js';
@@ -72,6 +72,8 @@ export class ParsemeGenerator {
72
72
  const parsemeDir = finalContextDir.startsWith('/')
73
73
  ? finalContextDir // Absolute path
74
74
  : join(baseDir, finalContextDir); // Relative path
75
+ // Clear the directory if it exists, then recreate it
76
+ await rm(parsemeDir, { recursive: true, force: true });
75
77
  await mkdir(parsemeDir, { recursive: true });
76
78
  await writeFile(finalOutputPath, context.parseme);
77
79
  if (context.context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parseme/cli",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
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
6
  "main": "./dist/index.js",
@@ -24,13 +24,11 @@
24
24
  "format:check": "prettier . --ignore-unknown --check",
25
25
  "lint": "eslint --config ./eslint.config.js --fix",
26
26
  "lint:check": "eslint --config ./eslint.config.js --no-fix --max-warnings 0",
27
- "test": "node --test --experimental-test-coverage 'tests/**/*.test.ts'",
28
- "pretest:unit": "npm run build",
27
+ "test": "node --test 'tests/**/*.test.ts'",
28
+ "pretest": "npm run build",
29
29
  "test:unit": "node --test 'tests/unit/**/*.test.ts'",
30
- "pretest:integration": "npm run build",
31
30
  "test:integration": "node --test 'tests/integration/**/*.test.ts'",
32
31
  "test:watch": "node --test --watch 'tests/**/*.test.ts'",
33
- "pretest:coverage": "npm run build",
34
32
  "test:coverage": "node --test --experimental-test-coverage 'tests/unit/**/*.test.ts' 'tests/integration/**/*.test.ts'",
35
33
  "test:setup:e2e": "npm run -C ../e2e setup",
36
34
  "test:e2e": "npm run -C ../e2e test",