@parseme/cli 0.0.3 → 0.0.5

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.
Files changed (47) hide show
  1. package/README.md +182 -187
  2. package/dist/cli/cli.js +144 -0
  3. package/dist/{analyzers → core/analyzers}/ast-analyzer.d.ts +1 -1
  4. package/dist/{analyzers → core/analyzers}/ast-analyzer.js +14 -27
  5. package/dist/core/analyzers/framework-detector.d.ts +7 -0
  6. package/dist/core/analyzers/framework-detector.js +165 -0
  7. package/dist/{analyzers → core/analyzers}/pattern-detector.d.ts +2 -5
  8. package/dist/{analyzers → core/analyzers}/pattern-detector.js +134 -49
  9. package/dist/{analyzers → core/analyzers}/project-analyzer.d.ts +2 -0
  10. package/dist/{analyzers → core/analyzers}/project-analyzer.js +12 -9
  11. package/dist/core/config.d.ts +19 -0
  12. package/dist/{config.js → core/config.js} +79 -91
  13. package/dist/{builders → core}/context-builder.d.ts +4 -11
  14. package/dist/core/context-builder.js +225 -0
  15. package/dist/{generator.d.ts → core/generator.d.ts} +0 -3
  16. package/dist/{generator.js → core/generator.js} +12 -17
  17. package/dist/core/types/analyzer-types.d.ts +38 -0
  18. package/dist/core/types/analyzer-types.js +2 -0
  19. package/dist/core/types/config-types.d.ts +36 -0
  20. package/dist/core/types/config-types.js +2 -0
  21. package/dist/core/types/generator-types.d.ts +6 -0
  22. package/dist/core/types/generator-types.js +2 -0
  23. package/dist/core/types/index.d.ts +4 -0
  24. package/dist/core/types/index.js +5 -0
  25. package/dist/core/types/project-types.d.ts +30 -0
  26. package/dist/core/types/project-types.js +2 -0
  27. package/dist/core/types.d.ts +1 -0
  28. package/dist/core/types.js +2 -0
  29. package/dist/index.d.ts +3 -4
  30. package/dist/index.js +2 -2
  31. package/dist/utils/file-collector.d.ts +23 -0
  32. package/dist/utils/file-collector.js +61 -0
  33. package/dist/utils/file-filter.d.ts +30 -0
  34. package/dist/utils/file-filter.js +99 -0
  35. package/dist/{analyzers/git-analyzer.d.ts → utils/git.d.ts} +1 -4
  36. package/dist/{analyzers/git-analyzer.js → utils/git.js} +0 -4
  37. package/dist/{prompt.d.ts → utils/prompt.d.ts} +0 -1
  38. package/dist/{prompt.js → utils/prompt.js} +0 -9
  39. package/package.json +12 -8
  40. package/dist/analyzers/framework-detector.d.ts +0 -12
  41. package/dist/analyzers/framework-detector.js +0 -180
  42. package/dist/builders/context-builder.js +0 -386
  43. package/dist/cli.js +0 -145
  44. package/dist/config.d.ts +0 -44
  45. package/dist/types.d.ts +0 -84
  46. package/dist/types.js +0 -2
  47. /package/dist/{cli.d.ts → cli/cli.d.ts} +0 -0
package/dist/cli.js DELETED
@@ -1,145 +0,0 @@
1
- #!/usr/bin/env node
2
- import { join } from 'path';
3
- import { Command } from 'commander';
4
- import { ParsemeConfig } from './config.js';
5
- import { ParsemeGenerator } from './generator.js';
6
- import { confirmPrompt } from './prompt.js';
7
- const program = new Command();
8
- async function promptForMissingConfig(config, cliOptions) {
9
- const finalConfig = { ...config };
10
- // Only prompt if running interactively (stdin is a TTY) and not in CI
11
- if (!process.stdin.isTTY || process.env.CI) {
12
- return finalConfig;
13
- }
14
- // Prompt for README suggestion if not set via CLI or config
15
- if (cliOptions.readmeSuggestion === undefined && config.readmeSuggestion === undefined) {
16
- const wantReadmeSuggestion = await confirmPrompt('Show README.md section suggestion for AI agents?', true);
17
- finalConfig.readmeSuggestion = wantReadmeSuggestion;
18
- }
19
- return finalConfig;
20
- }
21
- program.name('parseme').description('AI Project Context Generator').version('0.1.0');
22
- // Main command - just run parseme
23
- program
24
- .description('Generate project context using config file')
25
- .option('-c, --config <path>', 'Config file path')
26
- .option('-o, --output <path>', 'Output file path')
27
- .option('-r, --root <path>', 'Root directory to analyze')
28
- .option('--context-dir <path>', 'Context directory path (default: parseme-context)')
29
- .option('--include <patterns...>', 'Include patterns (glob)')
30
- .option('--exclude <patterns...>', 'Exclude patterns (glob)')
31
- .option('--no-git', 'Disable git information')
32
- .option('--max-depth <number>', 'Maximum directory depth', parseInt)
33
- .option('--no-readme-suggestion', 'Disable README.md section suggestion')
34
- .action(async (options) => {
35
- try {
36
- // Convert CLI options to config format
37
- const cliOptions = {
38
- ...(options.output && { outputPath: options.output }),
39
- ...(options.root && { rootDir: options.root }),
40
- ...(options.contextDir && { contextDir: options.contextDir }),
41
- ...(options.include && { includePatterns: options.include }),
42
- ...(options.exclude && { excludePatterns: options.exclude }),
43
- ...(options.git === false && { includeGitInfo: false }),
44
- ...(options.maxDepth && { maxDepth: options.maxDepth }),
45
- ...(options.readmeSuggestion === false && { readmeSuggestion: false }),
46
- };
47
- const configFromFile = await ParsemeConfig.fromFile(options.config);
48
- const interactiveConfig = await promptForMissingConfig(configFromFile.get(), cliOptions);
49
- // Merge: CLI options > interactive prompts > config file > defaults
50
- const finalConfig = {
51
- ...interactiveConfig,
52
- ...cliOptions,
53
- };
54
- const config = new ParsemeConfig(finalConfig);
55
- const generator = new ParsemeGenerator(config.get());
56
- await generator.generateToFile();
57
- console.log('Context generated successfully');
58
- console.log('Tip: Add parseme as a git hook to keep context auto-updated! See README for setup instructions.');
59
- const shouldShowReadmeSuggestion = finalConfig.readmeSuggestion !== false;
60
- if (shouldShowReadmeSuggestion) {
61
- console.log('Tip: Add this section to your README.md to help AI agents find the context:');
62
- console.log('');
63
- console.log('## For AI Assistants');
64
- console.log('This project includes AI-optimized documentation:');
65
- console.log('- `PARSEME.md` - Main project context and overview');
66
- console.log('- `parseme-context/` - Detailed JSON files with code structure, dependencies, and git info');
67
- console.log('');
68
- }
69
- }
70
- catch (error) {
71
- console.error('Failed to generate context:', error);
72
- process.exit(1);
73
- }
74
- });
75
- program
76
- .command('init')
77
- .description('Initialize parseme configuration')
78
- .option('-f, --force', 'Overwrite existing config')
79
- .option('--format <format>', 'Config format: js, ts, or json', 'js')
80
- .action(async (options) => {
81
- try {
82
- // Validate format
83
- if (!['js', 'ts', 'json'].includes(options.format)) {
84
- console.error('Invalid format. Use js, ts, or json');
85
- process.exit(1);
86
- }
87
- const configPath = join(process.cwd(), `parseme.config.${options.format}`);
88
- const config = new ParsemeConfig();
89
- // Check if config already exists
90
- if (!options.force) {
91
- try {
92
- const fs = await import('fs/promises');
93
- await fs.access(configPath);
94
- console.log('Configuration file already exists. Use --force to overwrite.');
95
- process.exit(1);
96
- }
97
- catch {
98
- // File doesn't exist, continue
99
- }
100
- }
101
- await config.save(configPath);
102
- console.log(`Configuration file created at ${configPath}`);
103
- if (options.format === 'ts') {
104
- console.log('For TypeScript configs, ensure tsx or ts-node is available to load .ts files');
105
- }
106
- console.log('Add "parseme": "parseme" to your package.json scripts');
107
- }
108
- catch (error) {
109
- console.error('Failed to create configuration:', error);
110
- process.exit(1);
111
- }
112
- });
113
- // If no command and no args, run main action
114
- if (process.argv.length <= 2) {
115
- // Run the default action
116
- (async () => {
117
- try {
118
- const configFromFile = await ParsemeConfig.fromFile();
119
- const interactiveConfig = await promptForMissingConfig(configFromFile.get(), {});
120
- const config = new ParsemeConfig(interactiveConfig);
121
- const generator = new ParsemeGenerator(config.get());
122
- await generator.generateToFile();
123
- console.log('Context generated successfully');
124
- console.log('Tip: Add parseme as a git hook to keep context auto-updated! See README for setup instructions.');
125
- const shouldShowReadmeSuggestion = interactiveConfig.readmeSuggestion !== false;
126
- if (shouldShowReadmeSuggestion) {
127
- console.log('Tip: Add this section to your README.md to help AI agents find the context:');
128
- console.log('');
129
- console.log('## For AI Assistants');
130
- console.log('This project includes AI-optimized documentation:');
131
- console.log('- `PARSEME.md` - Main project context and overview');
132
- console.log('- `parseme-context/` - Detailed JSON files with code structure, dependencies, and git info');
133
- console.log('');
134
- }
135
- }
136
- catch (error) {
137
- console.error('Failed to generate context:', error);
138
- console.log('Run "parseme init" to create a configuration file');
139
- process.exit(1);
140
- }
141
- })();
142
- }
143
- else {
144
- program.parse();
145
- }
package/dist/config.d.ts DELETED
@@ -1,44 +0,0 @@
1
- import type { GeneratorOptions } from './types.js';
2
- export interface ParsemeConfigFile extends GeneratorOptions {
3
- outputPath?: string;
4
- contextDir?: string;
5
- rootDir?: string;
6
- includePatterns?: string[];
7
- excludePatterns?: string[];
8
- maxDepth?: number;
9
- includeGitInfo?: boolean;
10
- readmeSuggestion?: boolean;
11
- sections?: {
12
- overview?: boolean;
13
- architecture?: boolean;
14
- routes?: boolean;
15
- dependencies?: boolean;
16
- git?: boolean;
17
- fileStructure?: boolean;
18
- };
19
- style?: {
20
- includeLineNumbers?: boolean;
21
- includeFileStats?: boolean;
22
- groupByType?: boolean;
23
- sortOrder?: 'alphabetical' | 'type' | 'size';
24
- };
25
- limits?: {
26
- maxLinesPerFile?: number;
27
- maxCharsPerFile?: number;
28
- maxFilesPerContext?: number;
29
- truncateStrategy?: 'truncate' | 'split' | 'summarize';
30
- };
31
- }
32
- export declare class ParsemeConfig {
33
- private readonly config;
34
- constructor(config?: Partial<ParsemeConfigFile>);
35
- static fromFileWithOptions(configPath?: string, cliOptions?: Partial<ParsemeConfigFile>): Promise<ParsemeConfig>;
36
- static fromFile(configPath?: string): Promise<ParsemeConfig>;
37
- private mergeWithDefaults;
38
- get(): ParsemeConfigFile;
39
- save(path?: string): Promise<void>;
40
- private generateJSConfig;
41
- private generateTSConfig;
42
- private mergeExcludePatterns;
43
- private readGitignorePatterns;
44
- }
package/dist/types.d.ts DELETED
@@ -1,84 +0,0 @@
1
- import type { ServiceInfo, ModelInfo, ConfigInfo, MiddlewareInfo, UtilityInfo } from './analyzers/pattern-detector.js';
2
- export type { ServiceInfo, ModelInfo, ConfigInfo, MiddlewareInfo, UtilityInfo };
3
- export interface GeneratorOptions {
4
- rootDir?: string;
5
- includeGitInfo?: boolean;
6
- maxDepth?: number;
7
- excludePatterns?: string[];
8
- includePatterns?: string[];
9
- }
10
- export interface ProjectInfo {
11
- name: string;
12
- version?: string;
13
- description?: string;
14
- type: 'typescript' | 'javascript' | 'mixed';
15
- category: ProjectCategory;
16
- packageManager: 'npm' | 'yarn' | 'pnpm' | 'bun';
17
- framework?: FrameworkInfo;
18
- buildTool?: BuildToolInfo;
19
- dependencies: Record<string, string>;
20
- devDependencies: Record<string, string>;
21
- scripts?: Record<string, string>;
22
- entryPoints?: string[];
23
- outputTargets?: string[];
24
- }
25
- export type ProjectCategory = 'backend-api' | 'frontend-web' | 'frontend-mobile' | 'npm-package' | 'monorepo' | 'cli-tool' | 'desktop-app' | 'fullstack' | 'unknown';
26
- export interface BuildToolInfo {
27
- name: string;
28
- version?: string;
29
- configFiles: string[];
30
- features: string[];
31
- }
32
- export interface FrameworkInfo {
33
- name: string;
34
- version?: string;
35
- features: string[];
36
- routes?: RouteInfo[];
37
- components?: ComponentInfo[];
38
- }
39
- export interface RouteInfo {
40
- method: string;
41
- path: string;
42
- handler: string;
43
- middleware?: string[];
44
- file: string;
45
- line: number;
46
- }
47
- export interface ComponentInfo {
48
- name: string;
49
- file: string;
50
- line: number;
51
- }
52
- export interface FileAnalysis {
53
- path: string;
54
- type: 'route' | 'middleware' | 'model' | 'service' | 'utility' | 'config' | 'test' | 'component';
55
- framework?: string;
56
- exports: string[];
57
- imports: string[];
58
- functions: string[];
59
- classes: string[];
60
- routes?: RouteInfo[];
61
- components?: ComponentInfo[];
62
- services?: ServiceInfo[];
63
- models?: ModelInfo[];
64
- configs?: ConfigInfo[];
65
- middleware?: MiddlewareInfo[];
66
- utilities?: UtilityInfo[];
67
- }
68
- export interface ContextOutput {
69
- parseme: string;
70
- context?: {
71
- structure: string;
72
- routes: string;
73
- dependencies: string;
74
- [key: string]: string;
75
- };
76
- }
77
- export interface GitInfo {
78
- branch: string;
79
- lastCommit: string;
80
- changedFiles: string[];
81
- status: 'clean' | 'dirty';
82
- origin?: string;
83
- diffStat?: string;
84
- }
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- // Core types for the parseme package
2
- export {};
File without changes