agent-context 0.0.1 → 0.1.0

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.
data/specification.md ADDED
@@ -0,0 +1,176 @@
1
+ # Agent Context Specification
2
+
3
+ ## 1. Introduction
4
+
5
+ ### 1.1 Purpose
6
+
7
+ Agent Context is a language-agnostic specification for providing and consuming contextual information from software packages to assist AI agents and other automated tools. This specification defines a standardized way for package authors to include supplementary documentation, examples, migration guides, and other contextual information that can be programmatically discovered and utilized.
8
+
9
+ ### 1.2 Problem Statement
10
+
11
+ AI agents and automated tools working with software projects often lack access to the rich contextual information that package authors provide. While packages may have extensive documentation, examples, and best practices, this information is typically scattered across various sources and formats, making it difficult for automated tools to discover and utilize effectively.
12
+
13
+ ### 1.3 Goals
14
+
15
+ - **Standardization**: Define a consistent structure for contextual information across different programming languages and ecosystems.
16
+ - **Discoverability**: Enable automated tools to programmatically find and access contextual information.
17
+ - **Separation of Concerns**: Clearly separate provider context from consumer context.
18
+ - **Extensibility**: Allow for future enhancements while maintaining backward compatibility.
19
+
20
+ ## 2. Core Concepts
21
+
22
+ ### 2.1 Context Provider
23
+
24
+ A **Context Provider** is any software package, library, or module that includes contextual information in its distribution. Context providers:
25
+
26
+ - Include a `context/` directory in their package root.
27
+ - Provide structured documentation and examples.
28
+ - Follow the file format specifications defined in this document.
29
+ - Version their context alongside their code.
30
+
31
+ ### 2.2 Context Consumer
32
+
33
+ A **Context Consumer** is any project or tool that utilizes contextual information from its dependencies. Context consumers:
34
+
35
+ - Install context from their dependencies into a `.context/` directory.
36
+ - Use tools to discover and access available context.
37
+ - Apply context based on file patterns and metadata.
38
+
39
+ ### 2.3 Context Files
40
+
41
+ **Context Files** are structured documents that contain supplementary information about a package. They typically include:
42
+
43
+ - Documentation beyond basic API references.
44
+ - Configuration examples and templates.
45
+ - Migration guides between versions.
46
+ - Performance optimization tips.
47
+ - Security considerations.
48
+ - Troubleshooting guides.
49
+
50
+ ### 2.4 Context Installation
51
+
52
+ **Context Installation** is the process of copying context files from dependencies into a consumer's local context directory, making them available for use by tools and AI agents.
53
+
54
+ ## 3. Directory Structure
55
+
56
+ ### 3.1 Provider Directory: `context/`
57
+
58
+ Context providers MUST include a `context/` directory in their package root. This directory:
59
+
60
+ - **Location**: Must be at the top level of the package (same level as main source directories).
61
+ - **Purpose**: Contains all contextual information provided by the package.
62
+ - **Distribution**: Must be included in the package's distribution artifacts.
63
+ - **Versioning**: Must be versioned alongside the package code.
64
+
65
+ Example structure:
66
+ ```
67
+ package-root/
68
+ ├── context/
69
+ │ ├── getting-started.md
70
+ │ ├── configuration.md
71
+ │ ├── troubleshooting.md
72
+ │ └── migration/
73
+ │ └── v2-to-v3.md
74
+ ├── src/
75
+ └── package.json
76
+ ```
77
+
78
+ ### 3.2 Consumer Directory: `.context/`
79
+
80
+ Context consumers SHOULD create a `.context/` directory in their project root to store installed context. This directory:
81
+
82
+ - **Location**: Must be at the project root (typically where package manifests are located).
83
+ - **Purpose**: Contains context files copied from dependencies.
84
+ - **Organization**: Must organize context by package name in subdirectories.
85
+ - **Exclusion**: SHOULD be excluded from version control (e.g., in `.gitignore`).
86
+ - **Transient Nature**: Should contain only reproducible content that can be regenerated from installed packages and MUST NOT contain unique or modified files.
87
+
88
+ Example structure:
89
+ ```
90
+ project-root/
91
+ ├── .context/
92
+ │ ├── package-a/
93
+ │ │ ├── getting-started.md
94
+ │ │ └── configuration.md
95
+ │ └── package-b/
96
+ │ └── troubleshooting.md
97
+ ├── src/
98
+ └── package.json
99
+ ```
100
+
101
+ ### 3.3 Directory Separation Rationale
102
+
103
+ The separation between `context/` and `.context/` serves several purposes:
104
+
105
+ - **Ownership**: `context/` is controlled by the project itself, `.context/` contains external dependencies.
106
+ - **Isolation**: Prevents conflicts between different packages' context files.
107
+ - **Discoverability**: Makes it easy to find context for specific packages.
108
+ - **Maintenance**: Allows independent management of provided vs. consumed context.
109
+
110
+ ## 4. Context File Format
111
+
112
+ ### 4.1 File Extensions
113
+
114
+ Context files SHOULD use the following extensions:
115
+
116
+ - **`.md`**: Markdown files (primary format).
117
+ - **`.txt`**: Plain text files.
118
+ - **`.yaml`** or **`.yml`**: YAML configuration files.
119
+ - **`.json`**: JSON configuration files.
120
+
121
+ ### 4.2 Markdown Context Files
122
+
123
+ Markdown files are the primary format for context files. They:
124
+
125
+ - MUST use valid Markdown syntax.
126
+ - SHOULD be named descriptively (e.g., `getting-started.md`, `configuration.md`).
127
+ - SHOULD include clear section headers for organization.
128
+
129
+ ### 4.3 File Naming Conventions
130
+
131
+ Context files SHOULD follow these naming conventions:
132
+
133
+ - Use lowercase with hyphens for word separation.
134
+ - Be descriptive and specific.
135
+ - Group related files in subdirectories when appropriate.
136
+
137
+ Common file names:
138
+ - `getting-started.md`
139
+ - `configuration.md`
140
+ - `troubleshooting.md`
141
+ - `performance.md`
142
+ - `security.md`
143
+ - `migration-guide.md`
144
+
145
+ ## 5. Discovery and Installation
146
+
147
+ ### 5.1 Discovery Process
148
+
149
+ Tools MUST be able to discover context by:
150
+
151
+ 1. **Package Scanning**: Examining installed packages for `context/` directories.
152
+ 2. **Metadata Extraction**: Reading package manifests to identify context-providing packages.
153
+ 3. **File Enumeration**: Listing available context files for each package.
154
+
155
+ The discovery process SHOULD integrate with the target language's package management system to:
156
+
157
+ - Locate installed packages and their installation paths.
158
+ - Read package metadata to identify packages that provide context.
159
+ - Enumerate available context files within discovered packages.
160
+
161
+ ### 5.2 Installation Process
162
+
163
+ Context installation MUST follow these principles:
164
+
165
+ 1. **Copy Strategy**: Context files SHOULD be copied rather than symlinked.
166
+ 2. **Namespace Isolation**: Each package's context MUST be installed in its own subdirectory.
167
+ 3. **Preserve Structure**: The internal structure of the `context/` directory MUST be preserved.
168
+
169
+ ### 5.3 Installation Algorithm
170
+
171
+ ```
172
+ FOR each package with context:
173
+ CREATE directory .context/package-name/
174
+ COPY all files recursively from package/context/ to .context/package-name/
175
+ END
176
+ ```
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,9 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agent-context
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
+ - Samuel Williams
7
8
  - Shopify Inc.
8
9
  bindir: bin
9
10
  cert_chain:
@@ -52,21 +53,35 @@ dependencies:
52
53
  - - "~>"
53
54
  - !ruby/object:Gem::Version
54
55
  version: '1.25'
56
+ - !ruby/object:Gem::Dependency
57
+ name: markly
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.9'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.9'
55
70
  executables: []
56
71
  extensions: []
57
72
  extra_rdoc_files: []
58
73
  files:
74
+ - agent.md
59
75
  - bake/agent/context.rb
60
- - context/adding-context.mdc
61
- - context/examples.mdc
62
- - context/getting-started.mdc
63
- - context/markdown-context.mdc
64
- - design.md
76
+ - context/usage.md
65
77
  - lib/agent/context.rb
66
- - lib/agent/context/helper.rb
78
+ - lib/agent/context/index.rb
79
+ - lib/agent/context/installer.rb
67
80
  - lib/agent/context/version.rb
68
81
  - license.md
82
+ - post.md
69
83
  - readme.md
84
+ - specification.md
70
85
  homepage: https://github.com/ioquatix/agent-context
71
86
  licenses:
72
87
  - MIT
metadata.gz.sig CHANGED
Binary file
@@ -1,166 +0,0 @@
1
- ---
2
- description: When creating or updating a gem's public interface.
3
- alwaysApply: false
4
- ---
5
- # Adding Context to Your Gem
6
-
7
- ## How to provide context in your gem
8
-
9
- ### 1. Create a `context/` directory
10
-
11
- In your gem's root directory, create a `context/` folder:
12
-
13
- ```
14
- your-gem/
15
- ├── context/
16
- │ ├── getting-started.mdc
17
- │ ├── configuration.mdc
18
- │ └── troubleshooting.mdc
19
- ├── lib/
20
- └── your-gem.gemspec
21
- ```
22
-
23
- ### 2. Add context files
24
-
25
- Create files with helpful information. Common types include:
26
-
27
- - **getting-started.mdc** - Quick start guide
28
- - **configuration.mdc** - Configuration options and examples
29
- - **troubleshooting.mdc** - Common issues and solutions
30
- - **migration.mdc** - Migration guides between versions
31
- - **performance.mdc** - Performance tips and best practices
32
- - **security.mdc** - Security considerations
33
-
34
- ### 3. Document your context
35
-
36
- Add a section to your gem's README:
37
-
38
- ```markdown
39
- ## Context
40
-
41
- This gem provides additional context files that can be installed using `agent-context`:
42
-
43
- ```bash
44
- bake agent:context:install --gem your-gem-name
45
- ```
46
-
47
- Available context files:
48
- - `getting-started.mdc` - Quick start guide
49
- - `configuration.mdc` - Configuration options
50
- ```
51
-
52
- ### 4. File format
53
-
54
- Context files can be in any format, but `.mdc` and `.md` are commonly used for documentation. The content should be:
55
-
56
- - **Practical** - Include real examples
57
- - **Focused** - One topic per file
58
- - **Clear** - Easy to understand and follow
59
- - **Actionable** - Provide specific guidance
60
-
61
- ## Example context file
62
-
63
- ```markdown
64
- # Configuration Guide
65
-
66
- ## Basic Setup
67
-
68
- Add to your Gemfile:
69
- ```ruby
70
- gem "your-gem"
71
- ```
72
-
73
- ## Configuration Options
74
-
75
- ```ruby
76
- YourGem.configure do |config|
77
- config.timeout = 30
78
- config.retries = 3
79
- end
80
- ```
81
-
82
- ## Environment Variables
83
-
84
- - `YOUR_GEM_TIMEOUT` - Connection timeout in seconds
85
- - `YOUR_GEM_RETRIES` - Number of retry attempts
86
-
87
-
88
- - `YOUR_GEM_TIMEOUT` - Connection timeout in seconds
89
- - `YOUR_GEM_RETRIES` - Number of retry attempts
90
- # Adding Context to Your Gem
91
-
92
- ## How to provide context in your gem
93
-
94
- ### 1. Create a `context/` directory
95
-
96
- In your gem's root directory, create a `context/` folder:
97
-
98
- ```
99
- your-gem/
100
- ├── context/
101
- │ ├── getting-started.mdc
102
- │ ├── configuration.mdc
103
- │ └── troubleshooting.mdc
104
- ├── lib/
105
- └── your-gem.gemspec
106
- ```
107
-
108
- ### 2. Add context files
109
-
110
- Create files with helpful information. Common types include:
111
-
112
- - **getting-started.mdc** - Quick start guide
113
- - **configuration.mdc** - Configuration options and examples
114
- - **troubleshooting.mdc** - Common issues and solutions
115
- - **migration.mdc** - Migration guides between versions
116
- - **performance.mdc** - Performance tips and best practices
117
- - **security.mdc** - Security considerations
118
-
119
- ### 3. Document your context
120
-
121
- Add a section to your gem's README:
122
-
123
- ```markdown
124
- ## Context
125
-
126
- This gem provides additional context files that can be installed using `bake agent:context:install`.
127
- ```
128
-
129
- ### 4. File format
130
-
131
- Context files can be in any format, but `.mdc` and `.md` are commonly used for documentation. The content should be:
132
-
133
- - **Practical** - Include real examples
134
- - **Focused** - One topic per file
135
- - **Clear** - Easy to understand and follow
136
- - **Actionable** - Provide specific guidance
137
-
138
- ## Example context file
139
-
140
- ```markdown
141
- # Configuration Guide
142
-
143
- ## Basic Setup
144
-
145
- Add to your Gemfile:
146
- ```ruby
147
- gem "your-gem"
148
- ```
149
-
150
- ## Configuration Options
151
-
152
- ```ruby
153
- YourGem.configure do |config|
154
- config.timeout = 30
155
- config.retries = 3
156
- end
157
- ```
158
-
159
- ## Environment Variables
160
-
161
- - `YOUR_GEM_TIMEOUT` - Connection timeout in seconds
162
- - `YOUR_GEM_RETRIES` - Number of retry attempts
163
-
164
-
165
- - `YOUR_GEM_TIMEOUT` - Connection timeout in seconds
166
- - `YOUR_GEM_RETRIES` - Number of retry attempts
data/context/examples.mdc DELETED
@@ -1,92 +0,0 @@
1
- ---
2
- description: Practical examples of using agent-context.
3
- alwaysApply: false
4
- ---
5
-
6
- # Practical Examples
7
-
8
- ## Example 1: Installing context from a web framework
9
-
10
- ```bash
11
- # Install context from Rails
12
- bake agent:context:install --gem rails
13
-
14
- # See what Rails provides
15
- bake agent:context:list --gem rails
16
-
17
- # View Rails configuration guide
18
- bake agent:context:show --gem rails --file configuration
19
- ```
20
-
21
- ## Example 2: Getting help with a specific gem
22
-
23
- ```bash
24
- # You're having trouble with the async gem
25
- bake agent:context:list --gem async
26
-
27
- # Check the troubleshooting guide
28
- bake agent:context:show --gem async --file troubleshooting
29
-
30
- # Install all async context for offline reference
31
- bake agent:context:install --gem async
32
- ```
33
-
34
- ## Example 3: Discovering new gems
35
-
36
- ```bash
37
- # See what context is available in your project
38
- bake agent:context:list
39
-
40
- # Install context from all gems
41
- bake agent:context:install
42
-
43
- # Browse the installed context
44
- ls .context/
45
- ```
46
-
47
- ## Example 4: Working with multiple gems
48
-
49
- ```bash
50
- # Install context from your main dependencies
51
- bake agent:context:install --gem rack
52
- bake agent:context:install --gem sinatra
53
- bake agent:context:install --gem puma
54
-
55
- # Now you have context for your web stack
56
- ls .context/
57
- # => rack/ sinatra/ puma/
58
- ```
59
-
60
- ## Example 5: Using context in your workflow
61
-
62
- ```bash
63
- # Before starting a new feature
64
- bake agent:context:install --gem the-gem-you're-using
65
-
66
- # Read the getting started guide
67
- cat .context/the-gem-you're-using/getting-started.mdc
68
-
69
- # Check performance tips
70
- cat .context/the-gem-you're-using/performance.mdc
71
- ```
72
-
73
- ## Real-world scenario
74
-
75
- You're building a Rails API and want to understand how to properly configure Puma:
76
-
77
- ```bash
78
- # Install Puma context
79
- bake agent:context:install --gem puma
80
-
81
- # Read the configuration guide
82
- cat .context/puma/configuration.mdc
83
-
84
- # Check performance recommendations
85
- cat .context/puma/performance.mdc
86
- ```
87
-
88
- This gives you practical, gem-specific guidance that might not be in the main documentation.
89
- description:
90
- globs:
91
- alwaysApply: false
92
- ---
@@ -1,56 +0,0 @@
1
- ---
2
- description: Getting started with agent-context.
3
- alwaysApply: false
4
- ---
5
-
6
- # Getting Started
7
-
8
- ## What is this?
9
-
10
- `agent-context` is a tool that helps you discover and install contextual information from Ruby gems for AI agents. Gems can provide additional documentation, examples, and guidance in a `context/` directory.
11
-
12
- ## Quick Commands
13
-
14
- ```bash
15
- # See what context is available
16
- bake agent:context:list
17
-
18
- # Install all available context
19
- bake agent:context:install
20
-
21
- # Install context from a specific gem
22
- bake agent:context:install --gem async
23
-
24
- # See what context files a gem provides
25
- bake agent:context:list --gem async
26
-
27
- # View a specific context file
28
- bake agent:context:show --gem async --file thread-safety
29
- ```
30
-
31
- ## What happens when you install context?
32
-
33
- When you run `bake agent:context:install`, the tool:
34
-
35
- 1. Scans all installed gems for `context/` directories
36
- 2. Creates a `.context/` directory in your current project
37
- 3. Copies context files organized by gem name
38
-
39
- For example:
40
- ```
41
- your-project/
42
- ├── .context/
43
- │ ├── async/
44
- │ │ ├── thread-safety.mdc
45
- │ │ └── performance.mdc
46
- │ └── rack/
47
- │ └── middleware.mdc
48
- ```
49
-
50
- ## Why use this?
51
-
52
- - **Discover hidden documentation** that gems provide
53
- - **Get practical examples** and guidance
54
- - **Understand best practices** from gem authors
55
- - **Access migration guides** and troubleshooting tips
56
-
@@ -1,91 +0,0 @@
1
- ---
2
- globs: *.mdc
3
- alwaysApply: false
4
- ---
5
- # Creating `.mdc` (Markdown Context) Files
6
-
7
- ## What is an `.mdc` file?
8
-
9
- An `.mdc` file is a Markdown file with optional YAML frontmatter, used to provide context, documentation, or metadata for Ruby gems. These files are intended to be machine- and human-readable, and are used by tools like `agent-context` to expose useful information to users and agents.
10
-
11
- ## Structure
12
-
13
- ### 1. YAML Frontmatter (Optional but Recommended)
14
-
15
- Start your `.mdc` file with a YAML frontmatter block:
16
-
17
- ```yaml
18
- ---
19
- description: Short summary of the file's purpose
20
- globs: "test/**/*.rb,lib/**/*.rb" # Optional: comma-separated file patterns
21
- alwaysApply: false # Optional: should this context always be applied?
22
- ---
23
- ```
24
-
25
- **Fields:**
26
- - `description` (required): Short, human-readable summary.
27
- - `globs` (optional): Comma-separated string of file patterns this context applies to.
28
- - `alwaysApply` (optional): Whether to always apply this context (default: false).
29
-
30
- ### 2. Markdown Content
31
-
32
- After the frontmatter, write your documentation in standard Markdown:
33
-
34
- ~~~markdown
35
- # Title
36
-
37
- ## Section
38
-
39
- - Bullet points
40
- - More details
41
-
42
- ```ruby
43
- # Code examples
44
- ```
45
- ~~~
46
-
47
- ## Best Practices
48
-
49
- - **Start with a clear description** in the YAML frontmatter.
50
- - **Use headings** (`#`, `##`) to organize content.
51
- - **Keep each file focused** on a single topic.
52
- - **Include code examples** where relevant.
53
- - **Use lists** for options, steps, or best practices.
54
- - **Be concise and actionable.**
55
- - **Use tags and globs** to help agents and tools categorize and apply context.
56
-
57
- ## Example `.mdc` File
58
-
59
- ~~~markdown
60
- ---
61
- description: How to configure the gem for production use.
62
- globs: config/my_gem.rb
63
- alwaysApply: false
64
- ---
65
-
66
- # Production Configuration
67
-
68
- To configure my_gem for production:
69
-
70
- 1. Set the environment variable:
71
- ```sh
72
- export GEM_ENV=production
73
- ```
74
- 2. Update your config file:
75
- ```ruby
76
- MyGem.configure do |config|
77
- config.mode = :production
78
- end
79
- ```
80
- 3. Restart your application.
81
- ~~~
82
-
83
- ## When to Use `.mdc` Files
84
-
85
- - To provide documentation, guides, or metadata for your gem.
86
- - To expose best practices, migration guides, or troubleshooting tips.
87
- - To help AI agents and tools discover and apply context automatically.
88
-
89
- ## Further Reading
90
- - [YAML Frontmatter Spec](https://jekyllrb.com/docs/front-matter/)
91
- - [Markdown Guide](https://www.markdownguide.org/)