Skip to content
/ dekard Public

A simple file concatenation tool to provide project context for AI prompting.

License

Notifications You must be signed in to change notification settings

wayleem/dekard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  1. 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:

  1. Report bugs and issues
  2. Suggest new features or enhancements
  3. Submit pull requests to improve the codebase
  4. Improve or add documentation

Development Setup

  1. Fork the repository
  2. Clone your forked repository
  3. Install dependencies with npm install
  4. Make your changes
  5. Run tests with npm test
  6. 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.

About

A simple file concatenation tool to provide project context for AI prompting.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published