Skip to content

Commit

Permalink
feat: Add .contextignore support and normalize linter output
Browse files Browse the repository at this point in the history
  • Loading branch information
killerapp authored Sep 11, 2024
2 parents 15c1e4d + a166724 commit 943a7b7
Show file tree
Hide file tree
Showing 12 changed files with 651 additions and 251 deletions.
24 changes: 9 additions & 15 deletions CODEBASE-CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,33 +371,27 @@ src/deprecated-module.js

**Warning:** Tooling may be required for proper implementation of `.contextignore`. AI agents may not consistently or easily use `.contextignore` as strictly as dedicated tooling can. Your mileage may vary (YMMV) depending on the AI model used.

## 7. Security Considerations

1. Avoid including sensitive information (API keys, passwords) in context files.
2. Be cautious with proprietary algorithms or trade secrets.
3. Use `.gitignore` to exclude sensitive context files from version control if necessary.

## 8. The .contextdocs File
## 7. The .contextdocs File

The `.contextdocs` file allows developers to specify external documentation sources that should be incorporated into the project's context. This feature is particularly useful for including documentation from dependencies, libraries, or related projects.

### 8.1 Location and Naming
### 7.1 Location and Naming

- The `.contextdocs` file should be placed in the root directory of the project.
- It must use one of the following extensions:
- `.contextdocs.md` (default, recommended)
- `.contextdocs.yaml` or `.contextdocs.yml`
- `.contextdocs.json`

### 8.2 File Structure
### 7.2 File Structure

The `.contextdocs` file should contain an array of documentation sources. Each source can be:

- A file path relative to the project root
- A URL to a markdown file
- A package name with associated documentation files

### 8.3 Examples
### 7.3 Examples

#### Markdown Format (.contextdocs.md) - Default

Expand Down Expand Up @@ -511,7 +505,7 @@ contextdocs:
}
```

### 8.4 Behavior
### 7.4 Behavior

- When an AI model or related tool is processing the project context, it should fetch and incorporate the specified documentation.
- For local files, the content should be read from the specified path.
Expand All @@ -520,24 +514,24 @@ contextdocs:

**Warning:** Tooling may be required for proper implementation of `.contextdocs`. AI agents may not consistently or easily use `.contextdocs` as strictly as dedicated tooling can. Your mileage may vary (YMMV) depending on the AI model used.

### 8.5 Use Cases
### 7.5 Use Cases

- Including documentation for key dependencies
- Referencing company-wide coding standards or guidelines
- Incorporating design documents or architectural overviews
- Linking to relevant external resources or tutorials

### 8.6 Considerations
### 7.6 Considerations

- Ensure that URLs point to stable, version-controlled documentation to maintain consistency.
- Be mindful of the total volume of documentation to avoid overwhelming the AI model with irrelevant information.
- Regularly review and update the `.contextdocs` file to ensure all referenced documentation remains relevant and up-to-date.
- Consider implementing caching mechanisms for external documentation to improve performance and reduce network requests.

## 9. Conclusion
## 8. Conclusion

The Codebase Context Specification provides a flexible, standardized approach to enriching codebases with contextual information for AI models. By adopting this convention and including role-specific information, development teams can enhance AI-assisted workflows, improving code quality and development efficiency across projects of any scale or complexity. The addition of role-specific guidelines and consistent naming conventions ensures that AI models have access to comprehensive, relevant, and well-structured information tailored to different aspects of the software development lifecycle.

## 10. TypeScript Linter Implementation
## 9. TypeScript Linter Implementation

For details on the TypeScript implementation of the linter for validating Codebase Context Specification files, please refer to the [TypeScript Linter README](linters/typescript/README.md).
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ Welcome to the [Codebase Context Specification (CCS)](./CODEBASE-CONTEXT.md) rep
- [Context File Example (.context.md)](.context.md)
- [AI Assistant Prompt (CODING-ASSISTANT-PROMPT.md)](CODING-ASSISTANT-PROMPT.md)

## Supported Node.js Versions

This project supports the following Node.js versions:

- Node.js 18.x
- Node.js 20.x
- Node.js 22.x

We recommend using the latest LTS (Long Term Support) version of Node.js for optimal performance and security.

## Codebase Context: A New Convention

The Codebase Context Specification introduces a convention similar to `.env` and `.editorconfig` systems, but focused on documenting your code for both AI and humans. Just as `.env` files manage environment variables and `.editorconfig` ensures consistent coding styles, CCS files (`.context.md`, `.context.yaml`, `.context.json`) provide a standardized way to capture and communicate the context of your codebase.
Expand Down Expand Up @@ -46,8 +56,14 @@ To install the linter:
npm install -g codebase-context-lint
```

Note: Make sure you're using a supported Node.js version (18.x, 20.x, or 22.x) when installing and running the linter.

For more information on using the linter, please refer to the [linter's README](./linters/typescript/README.md).

## Recent Updates

We've recently updated our dependencies to address security vulnerabilities and improve compatibility with different Node.js versions. If you encounter any issues after updating, please report them in our GitHub issues.

## Using with AI Assistants

The [CODING-ASSISTANT-PROMPT.md](./CODING-ASSISTANT-PROMPT.md) file provides guidelines for AI assistants to understand and use the Codebase Context Specification. This allows for immediate adoption of the specification without requiring specific tooling integration.
Expand Down
1 change: 1 addition & 0 deletions examples/context-editor/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.0.0 || 20.0.0 || 22.0.0
38 changes: 0 additions & 38 deletions examples/context-editor/sample.context.md

This file was deleted.

54 changes: 49 additions & 5 deletions linters/typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,26 @@ By adopting this convention, teams can ensure that both human developers and AI

For more detailed information about the Codebase Context Specification, please refer to the [main repository](https://github.com/Agentic-Insights/codebase-context-spec) and the [full specification](https://github.com/Agentic-Insights/codebase-context-spec/blob/main/CODEBASE-CONTEXT.md).

## 📦 Installation
## � Supported Node.js Versions

This linter supports the following Node.js versions:

- Node.js 18.x
- Node.js 20.x
- Node.js 22.x

We recommend using the latest LTS (Long Term Support) version of Node.js for optimal performance and security.

## �📦 Installation

You can install the linter globally using npm:

```
npm install -g codebase-context-lint
```

Note: Make sure you're using a supported Node.js version (18.x, 20.x, or 22.x) when installing and running the linter.

## 🚀 Usage

After installation, you can use the linter from the command line:
Expand All @@ -58,9 +70,37 @@ Replace `<directory_to_lint>` with the path to the directory containing your Cod
- 🔍 Validates the structure and content of `.context.md`, `.context.yaml`, and `.context.json` files
- ✅ Checks for required fields and sections
- 📄 Verifies the format of `.contextdocs.md` files
- 🚫 Validates ignore patterns in `.contextignore` files
- 🚫 Supports and validates `.contextignore` files for excluding specific files or directories
- 💬 Provides detailed error messages and warnings

## 📁 .contextignore Files

`.contextignore` files allow you to specify patterns for files and directories that should be ignored by the Codebase Context Lint. This is useful for excluding generated files, dependencies, or any other content that doesn't need context documentation.

### How to use .contextignore

1. Create a file named `.contextignore` in any directory of your project.
2. Add patterns to the file, one per line. These patterns follow the same rules as `.gitignore` files.
3. The linter will respect these ignore patterns when processing files in that directory and its subdirectories.

Example `.contextignore` file:

```
# Ignore node_modules directory
node_modules/
# Ignore all .log files
*.log
# Ignore a specific file
path/to/specific/file.js
# Ignore all files in a specific directory
path/to/ignore/*
```

The linter will validate the syntax of your `.contextignore` files and warn about any problematic patterns, such as attempting to ignore critical context files.

## 🤖 Using with AI Assistants

While this linter provides automated validation of CCS files, you can also use the Codebase Context Specification with AI assistants without any specific tooling. The [CODING-ASSISTANT-PROMPT.md](https://github.com/Agentic-Insights/codebase-context-spec/blob/main/CODING-ASSISTANT-PROMPT.md) file in the main repository provides guidelines for AI assistants to understand and use the Codebase Context Specification.
Expand All @@ -71,7 +111,7 @@ To use the Codebase Context Specification with an AI assistant:
2. Ask the AI to analyze your project's context files based on these guidelines.
3. The AI will be able to provide more accurate and context-aware responses by following the instructions in the prompt.

Note that while this approach allows for immediate use of the specification, some features like .contextignore should eventually be applied by tooling (such as this linter) for more robust implementation.
Note that while this approach allows for immediate use of the specification, some features like .contextignore are best implemented by tooling (such as this linter) for more robust and consistent application.

## 🛠️ Development

Expand Down Expand Up @@ -104,11 +144,15 @@ To contribute to this project:
7. Push to the branch (`git push origin feature/AmazingFeature`)
8. Open a Pull Request

## � Learn More
## 🔄 Recent Updates

We've recently updated our dependencies to address security vulnerabilities and improve compatibility with different Node.js versions. If you encounter any issues after updating, please report them in our GitHub issues.

## 📖 Learn More

For a deeper dive into the Codebase Context Specification, check out this [SubStack article by Vaskin](https://agenticinsights.substack.com/p/codebase-context-specification-rfc), the author of the specification.

## 📄 License
## 📄 License

This project is licensed under the MIT License.

Expand Down
Loading

0 comments on commit 943a7b7

Please sign in to comment.