dekard
v1.2.1
Published
A simple file concatenation tool to provide project context for AI.
Downloads
16
Maintainers
Readme
Dekard
Dekard is a simple file concatenation tool. It allows you to process entire project directories, concatenating the contents of specified files into a single output file, with the ability to watch for changes and update the output automatically. Dekard is perfect for compiling your project into context to provide for AI.
✨Features
- 🔗Concatenate multiple files into a single output file
- 💬Add file path comments to the concatenated output
- 🔍Flexible file inclusion and exclusion with glob patterns
- 👀Watch mode for automatic updates on file changes
- 🖥️Easy to use CLI and programmatic API
- 🧠 Intelligent file ordering based on dependencies
- 🌐 Support for multiple languages (JavaScript, TypeScript, Python, Java)
- 🗣️ Verbose logging option for detailed output
🚀Installation
Install dekard globally:
npm install -g dekard
Or as a dependency in your project:
npm install dekard
🔧Usage
Command Line Interface
- Initialize a dekard configuration file in your project root:
dekard init
This will create a dekard.json
file with default settings. 2. Run dekard
dekard
For verbose output:
dekard --verbose
Or specify a custom config file:
dekard path/to/custom-config.json
Programmic Usage
const { loadConfig, resolveConfig, processDirectory, watchDirectory } = require("dekard");
async function run() {
const config = resolveConfig(await loadConfig("path/to/dekard.json"));
if (config.watch) {
watchDirectory(config);
} else {
await processDirectory(config);
}
}
run().catch(console.error);
⚙️Configuration
The dekard.json
file supports the following options:
inputDir
(string): The root directory to process.outputFile
(string): The path to the output file.include
(string[]): Glob patterns for files to include.ignore
(string[]): Glob patterns for files to ignore.watch
(boolean): Whether to watch for file changes and update the output automatically.verbose
(boolean): Whether to output detailed logging information.
Example Config dekard.json
:
{
"inputDir": "./src",
"outputFile": "./concatenated-output.txt",
"include": ["**/*.ts", "**/*.tsx"],
"ignore": ["**/*.test.ts", "node_modules/**"],
"watch": false,
"verbose": false
}
📝Example
Let's say you have the following directory structure:
src/
├── main.ts
├── utils.ts
└── test.ts
With the following content in each file:
src/main.ts
:
import { helper } from "./utils";
import { CONSTANT } from "./utils";
console.log(helper(CONSTANT));
src/utils.ts
:
export function helper(value: string): string {
return `Helper: ${value}`;
}
export const CONSTANT = "Some constant value";
src/test.ts
:
import { helper } from "./utils";
describe("helper function", () => {
it("should return correct string", () => {
expect(helper("test")).toBe("Helper: test");
});
});
Using the following dekard.json
:
{
"inputDir": "./src",
"outputFile": "./output.txt",
"include": ["**/*.ts"],
"ignore": ["**/*.test.ts"],
"watch": false,
"verbose": false
}
The resulting output.txt
would look like this:
// File: src/utils.ts
export function helper(value: string): string {
return `Helper: ${value}`;
}
export const CONSTANT = 'Some constant value';
// File: src/main.ts
import { helper } from './utils';
import { CONSTANT } from './utils';
console.log(helper(CONSTANT));
You can just provide this file to any LLM and they will understand your project structure to work based off of it.
🧠 Intelligent File Ordering
Dekard now includes intelligent file ordering based on dependencies. This feature:
- Analyzes imports and dependencies in your files
- Orders files so that dependencies come before the files that use them
- Supports JavaScript, TypeScript, Python, and Java
- Falls back to original order if circular dependencies are detected
This ordering helps maintain a logical flow in the concatenated output, making it easier for humans or AI to understand the project structure and dependencies at a glance.
🤝Contributing
Contributions are welcome! Here are some ways you can contribute to this project:
- Report bugs and issues
- Suggest new features or enhancements
- Submit pull requests to improve the codebase
- Improve or add documentation
Development Setup
- Fork the repository
- Clone your forked repository
- Install dependencies with npm install
- Make your changes
- Run tests with npm test
- Submit a pull request
Please ensure that your code adheres to the existing style and that all tests pass before submitting a pull request.
Testing
To run the test suite, execute:
npm test
This will run all unit and integration tests for the project.
📄License
This project is licensed under the ISC License. See the LICENSE file for details.