{"id":21179591,"url":"https://github.com/puntorigen/code2prompt","last_synced_at":"2025-04-13T16:34:32.289Z","repository":{"id":232312189,"uuid":"784007206","full_name":"puntorigen/code2prompt","owner":"puntorigen","description":"NodeJS Class for transforming a given codebase directory into an LLM prompt","archived":false,"fork":false,"pushed_at":"2024-12-21T12:47:46.000Z","size":235,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T11:50:14.473Z","etag":null,"topics":["ai","code-generation","codeparser","llm","prompt-engineering"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/puntorigen.png","metadata":{"files":{"readme":"README-generated-test0a.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-09T02:08:12.000Z","updated_at":"2024-12-21T12:47:51.000Z","dependencies_parsed_at":"2024-05-02T04:52:59.374Z","dependency_job_id":"6f49e0ce-3a92-4b28-8913-2a23035d5e55","html_url":"https://github.com/puntorigen/code2prompt","commit_stats":null,"previous_names":["puntorigen/code2prompt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puntorigen%2Fcode2prompt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puntorigen%2Fcode2prompt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puntorigen%2Fcode2prompt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puntorigen%2Fcode2prompt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/puntorigen","download_url":"https://codeload.github.com/puntorigen/code2prompt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248744421,"owners_count":21154865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","code-generation","codeparser","llm","prompt-engineering"],"created_at":"2024-11-20T17:32:28.338Z","updated_at":"2025-04-13T16:34:32.265Z","avatar_url":"https://github.com/puntorigen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Code2Prompt\n\nCode2Prompt is a NodeJS library that transforms a given codebase directory into a language learning model (LLM) prompt.\n\n## Features\n\n- Parse a given directory into a formatted output suitable for language learning model prompts\n- Can ignore specific patterns in the directory\n- Ability to use OpenAI's API for 'request' method\n- Replace `fs.readFile` method with custom method for specific file extensions.\n\n## Installation\n\nInstall the library via npm:\n\n```\nnpm install code2prompt\n```\n\nThen, require it in your file:\n\n```\nconst Code2Prompt = require('code2prompt');\n```\n\nYou will also need to install the required dependencies listed in the `package.json` file.\n\n## Usage Examples\n\nHere is a basic usage example:\n\n```javascript\nconst Code2Prompt = require('code2prompt');\nconst { z } = require('zod');\nconst options = {\n  path: '.',\n  extensions: ['js'],\n  ignore: ['**/node_modules/**'],\n  OPENAI_KEY: process.env.OPENAI_KEY\n};\nconst code2Prompt = new Code2Prompt(options);\nconst prompt = await code2Prompt.generateContextPrompt();\n```\n\nThis example will traverse the current directory (`.`), consider javascript files (`js`), ignore `node_modules` directory and use the OpenAI key from the environment variables. The `generateContextPrompt` method will return the generated prompt.\n\n## Configuration Options\n\nWhen creating a new instance of `Code2Prompt`, you can specify the following options:\n\n- **path**: The directory path to parse.\n- **extensions**: Array of extensions to filter for.\n- **ignore**: An array of glob patterns to ignore.\n- **OPENAI_KEY**: The OpenAI API Key for the 'request' method.\n- **custom_viewers**: custom file reader methods for specific extensions.\n\n## Contribution Guidelines\n\nThis is an open source project and contributions are welcome. Check the issues on this repository for any outstanding issues or to check the project requirements.\n\n## Testing Instructions\n\nTo run the test script, use the following in your command line:\n\n```\nnpm run test\n```\n\nThe `test.js` is a good starting point for testing your own implementations.\n\n## License\n\nThis project is under MIT License.\n\n## Acknowledgements\n\nThis project is developed by Pablo Schaffner. Check the [repository](https://github.com/puntorigen/code2prompt) for more details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuntorigen%2Fcode2prompt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpuntorigen%2Fcode2prompt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuntorigen%2Fcode2prompt/lists"}