agent-context 0.0.2 → 0.1.1

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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agent-context
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -40,33 +40,34 @@ cert_chain:
40
40
  date: 1980-01-02 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
- name: console
43
+ name: bake
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: '1.25'
48
+ version: '0.23'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: '1.25'
55
+ version: '0.23'
56
56
  executables: []
57
57
  extensions: []
58
58
  extra_rdoc_files: []
59
59
  files:
60
+ - agent.md
60
61
  - bake/agent/context.rb
61
- - context/adding-context.md
62
- - context/examples.md
63
- - context/getting-started.md
64
- - design.md
62
+ - context/usage.md
65
63
  - lib/agent/context.rb
66
- - lib/agent/context/helper.rb
64
+ - lib/agent/context/index.rb
65
+ - lib/agent/context/installer.rb
67
66
  - lib/agent/context/version.rb
68
67
  - license.md
68
+ - post.md
69
69
  - readme.md
70
+ - specification.md
70
71
  homepage: https://github.com/ioquatix/agent-context
71
72
  licenses:
72
73
  - MIT
metadata.gz.sig CHANGED
Binary file
@@ -1,162 +0,0 @@
1
- # Adding Context to Your Gem
2
-
3
- ## How to provide context in your gem
4
-
5
- ### 1. Create a `context/` directory
6
-
7
- In your gem's root directory, create a `context/` folder:
8
-
9
- ```
10
- your-gem/
11
- ├── context/
12
- │ ├── getting-started.md
13
- │ ├── configuration.md
14
- │ └── troubleshooting.md
15
- ├── lib/
16
- └── your-gem.gemspec
17
- ```
18
-
19
- ### 2. Add context files
20
-
21
- Create files with helpful information. Common types include:
22
-
23
- - **getting-started.md** - Quick start guide
24
- - **configuration.md** - Configuration options and examples
25
- - **troubleshooting.md** - Common issues and solutions
26
- - **migration.md** - Migration guides between versions
27
- - **performance.md** - Performance tips and best practices
28
- - **security.md** - Security considerations
29
-
30
- ### 3. Document your context
31
-
32
- Add a section to your gem's README:
33
-
34
- ```markdown
35
- ## Context
36
-
37
- This gem provides additional context files that can be installed using `agent-context`:
38
-
39
- ```bash
40
- bake agent:context:install --gem your-gem-name
41
- ```
42
-
43
- Available context files:
44
- - `getting-started.md` - Quick start guide
45
- - `configuration.md` - Configuration options
46
- ```
47
-
48
- ### 4. File format
49
-
50
- Context files can be in any format, but `.md` and `.md` are commonly used for documentation. The content should be:
51
-
52
- - **Practical** - Include real examples
53
- - **Focused** - One topic per file
54
- - **Clear** - Easy to understand and follow
55
- - **Actionable** - Provide specific guidance
56
-
57
- ## Example context file
58
-
59
- ```markdown
60
- # Configuration Guide
61
-
62
- ## Basic Setup
63
-
64
- Add to your Gemfile:
65
- ```ruby
66
- gem "your-gem"
67
- ```
68
-
69
- ## Configuration Options
70
-
71
- ```ruby
72
- YourGem.configure do |config|
73
- config.timeout = 30
74
- config.retries = 3
75
- end
76
- ```
77
-
78
- ## Environment Variables
79
-
80
- - `YOUR_GEM_TIMEOUT` - Connection timeout in seconds
81
- - `YOUR_GEM_RETRIES` - Number of retry attempts
82
-
83
-
84
- - `YOUR_GEM_TIMEOUT` - Connection timeout in seconds
85
- - `YOUR_GEM_RETRIES` - Number of retry attempts
86
- # Adding Context to Your Gem
87
-
88
- ## How to provide context in your gem
89
-
90
- ### 1. Create a `context/` directory
91
-
92
- In your gem's root directory, create a `context/` folder:
93
-
94
- ```
95
- your-gem/
96
- ├── context/
97
- │ ├── getting-started.md
98
- │ ├── configuration.md
99
- │ └── troubleshooting.md
100
- ├── lib/
101
- └── your-gem.gemspec
102
- ```
103
-
104
- ### 2. Add context files
105
-
106
- Create files with helpful information. Common types include:
107
-
108
- - **getting-started.md** - Quick start guide
109
- - **configuration.md** - Configuration options and examples
110
- - **troubleshooting.md** - Common issues and solutions
111
- - **migration.md** - Migration guides between versions
112
- - **performance.md** - Performance tips and best practices
113
- - **security.md** - Security considerations
114
-
115
- ### 3. Document your context
116
-
117
- Add a section to your gem's README:
118
-
119
- ```markdown
120
- ## Context
121
-
122
- This gem provides additional context files that can be installed using `bake agent:context:install`.
123
- ```
124
-
125
- ### 4. File format
126
-
127
- Context files can be in any format, but `.md` and `.md` are commonly used for documentation. The content should be:
128
-
129
- - **Practical** - Include real examples
130
- - **Focused** - One topic per file
131
- - **Clear** - Easy to understand and follow
132
- - **Actionable** - Provide specific guidance
133
-
134
- ## Example context file
135
-
136
- ```markdown
137
- # Configuration Guide
138
-
139
- ## Basic Setup
140
-
141
- Add to your Gemfile:
142
- ```ruby
143
- gem "your-gem"
144
- ```
145
-
146
- ## Configuration Options
147
-
148
- ```ruby
149
- YourGem.configure do |config|
150
- config.timeout = 30
151
- config.retries = 3
152
- end
153
- ```
154
-
155
- ## Environment Variables
156
-
157
- - `YOUR_GEM_TIMEOUT` - Connection timeout in seconds
158
- - `YOUR_GEM_RETRIES` - Number of retry attempts
159
-
160
-
161
- - `YOUR_GEM_TIMEOUT` - Connection timeout in seconds
162
- - `YOUR_GEM_RETRIES` - Number of retry attempts
data/context/examples.md DELETED
@@ -1,87 +0,0 @@
1
- # Practical Examples
2
-
3
- ## Example 1: Installing context from a web framework
4
-
5
- ```bash
6
- # Install context from Rails
7
- bake agent:context:install --gem rails
8
-
9
- # See what Rails provides
10
- bake agent:context:list --gem rails
11
-
12
- # View Rails configuration guide
13
- bake agent:context:show --gem rails --file configuration
14
- ```
15
-
16
- ## Example 2: Getting help with a specific gem
17
-
18
- ```bash
19
- # You're having trouble with the async gem
20
- bake agent:context:list --gem async
21
-
22
- # Check the troubleshooting guide
23
- bake agent:context:show --gem async --file troubleshooting
24
-
25
- # Install all async context for offline reference
26
- bake agent:context:install --gem async
27
- ```
28
-
29
- ## Example 3: Discovering new gems
30
-
31
- ```bash
32
- # See what context is available in your project
33
- bake agent:context:list
34
-
35
- # Install context from all gems
36
- bake agent:context:install
37
-
38
- # Browse the installed context
39
- ls .context/
40
- ```
41
-
42
- ## Example 4: Working with multiple gems
43
-
44
- ```bash
45
- # Install context from your main dependencies
46
- bake agent:context:install --gem rack
47
- bake agent:context:install --gem sinatra
48
- bake agent:context:install --gem puma
49
-
50
- # Now you have context for your web stack
51
- ls .context/
52
- # => rack/ sinatra/ puma/
53
- ```
54
-
55
- ## Example 5: Using context in your workflow
56
-
57
- ```bash
58
- # Before starting a new feature
59
- bake agent:context:install --gem the-gem-you're-using
60
-
61
- # Read the getting started guide
62
- cat .context/the-gem-you're-using/getting-started.md
63
-
64
- # Check performance tips
65
- cat .context/the-gem-you're-using/performance.md
66
- ```
67
-
68
- ## Real-world scenario
69
-
70
- You're building a Rails API and want to understand how to properly configure Puma:
71
-
72
- ```bash
73
- # Install Puma context
74
- bake agent:context:install --gem puma
75
-
76
- # Read the configuration guide
77
- cat .context/puma/configuration.md
78
-
79
- # Check performance recommendations
80
- cat .context/puma/performance.md
81
- ```
82
-
83
- This gives you practical, gem-specific guidance that might not be in the main documentation.
84
- description:
85
- globs:
86
- alwaysApply: false
87
- ---
@@ -1,51 +0,0 @@
1
- # Getting Started
2
-
3
- ## What is this?
4
-
5
- `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.
6
-
7
- ## Quick Commands
8
-
9
- ```bash
10
- # See what context is available
11
- bake agent:context:list
12
-
13
- # Install all available context
14
- bake agent:context:install
15
-
16
- # Install context from a specific gem
17
- bake agent:context:install --gem async
18
-
19
- # See what context files a gem provides
20
- bake agent:context:list --gem async
21
-
22
- # View a specific context file
23
- bake agent:context:show --gem async --file thread-safety
24
- ```
25
-
26
- ## What happens when you install context?
27
-
28
- When you run `bake agent:context:install`, the tool:
29
-
30
- 1. Scans all installed gems for `context/` directories
31
- 2. Creates a `.context/` directory in your current project
32
- 3. Copies context files organized by gem name
33
-
34
- For example:
35
- ```
36
- your-project/
37
- ├── .context/
38
- │ ├── async/
39
- │ │ ├── thread-safety.md
40
- │ │ └── performance.md
41
- │ └── rack/
42
- │ └── middleware.md
43
- ```
44
-
45
- ## Why use this?
46
-
47
- - **Discover hidden documentation** that gems provide
48
- - **Get practical examples** and guidance
49
- - **Understand best practices** from gem authors
50
- - **Access migration guides** and troubleshooting tips
51
-
data/design.md DELETED
@@ -1,149 +0,0 @@
1
- # Design Document: agent-context
2
-
3
- ## Problem Statement
4
-
5
- AI agents working with Ruby codebases often lack access to the rich contextual information that gem authors provide. While gems may have extensive documentation, examples, migration guides, and best practices, this information is typically scattered across READMEs, wikis, blog posts, and other sources that aren't easily accessible to AI agents.
6
-
7
- ## Core Design Principles
8
-
9
- ### 1. Context as a First-Class Concept
10
-
11
- Context files are treated as a first-class part of a gem's public interface, alongside the code itself. This means:
12
- - Context files are versioned with the gem.
13
- - They're distributed as part of the gem package.
14
- - They're discoverable and accessible programmatically.
15
- - They follow a consistent structure and format.
16
-
17
- ### 2. Machine-Readable, Human-Friendly
18
-
19
- Context files use `.md` (Markdown Context) format, which combines:
20
- - **Human readability**: Standard Markdown for easy authoring and reading.
21
- - **Machine structure**: YAML frontmatter for metadata and organization.
22
- - **Extensibility**: Can include code examples, diagrams, and structured data.
23
-
24
- ### 3. Separation of Concerns
25
-
26
- The design separates three distinct concerns:
27
- - **Public Interface**: `context/` directory in gem root (what gem authors provide).
28
- - **Private Working Directory**: `.context/` in consuming projects (where context is installed).
29
- - **Tool Interface**: `bake agent:context:*` commands (how users interact).
30
-
31
- ## Architecture Decisions
32
-
33
- ### File Organization Strategy
34
-
35
- **Decision**: Context files are installed into `.context/gem-name/` subdirectories
36
-
37
- **Rationale**:
38
- - **Isolation**: Prevents conflicts between different gems' context files.
39
- - **Discoverability**: Easy to find context for a specific gem.
40
- - **Scalability**: Supports installing context from multiple gems.
41
- - **Clear Ownership**: Obvious which context files belong to which gem.
42
-
43
- ### Command Structure
44
-
45
- **Decision**: Use `bake agent:context:*` command namespace
46
-
47
- **Rationale**:
48
- - **Consistency**: Matches the gem name `agent-context`.
49
- - **Clarity**: Makes it obvious these commands are for AI agent workflows.
50
- - **Namespace Safety**: Avoids conflicts with other gem-related commands.
51
- - **Tool Integration**: Leverages existing Bake infrastructure.
52
-
53
- ### Module Structure
54
-
55
- **Decision**: Use `Agent::Context` module namespace
56
-
57
- **Rationale**:
58
- - **Purpose Clarity**: Explicitly indicates this is for AI agents.
59
- - **Namespace Safety**: Avoids potential conflicts with RubyGems' `Gem::` namespace.
60
- - **Future-Proof**: Won't conflict if RubyGems adds their own context features.
61
-
62
- ## Context File Design
63
-
64
- ### YAML Frontmatter
65
-
66
- Context files support structured metadata:
67
- ```yaml
68
- ---
69
- description: Short summary of the file's purpose
70
- globs: "test/**/*.rb,lib/**/*.rb" # Comma-separated file patterns
71
- alwaysApply: false # Whether to always apply this context
72
- ---
73
- ```
74
-
75
- **Design Decisions**:
76
- - **`description`**: Required human-readable summary.
77
- - **`globs`**: Optional file patterns this context applies to.
78
- - **`alwaysApply`**: Optional flag for context that should always be available.
79
- - **No tags**: Keeps the format simple and focused.
80
-
81
- ### File Naming Conventions
82
-
83
- - **`.md` extension**: Indicates Markdown Context files.
84
- - **Descriptive names**: `thread-safety.md`, `performance.md`, `migration-guide.md`.
85
- - **Fallback support**: Commands can find files with or without extensions.
86
-
87
- ## Installation Strategy
88
-
89
- ### Copy vs. Symlink
90
-
91
- **Decision**: Copy files rather than symlink
92
-
93
- **Rationale**:
94
- - **Offline Access**: Context remains available even if gems are uninstalled.
95
- - **Version Stability**: Context doesn't change if gem is updated.
96
- - **Project Independence**: Context becomes part of the project's knowledge base.
97
- - **Simplicity**: No symlink management or broken link issues.
98
-
99
- ### Directory Structure
100
-
101
- ```
102
- project/
103
- ├── .context/ # Private working directory
104
- │ ├── async/ # Context from async gem
105
- │ │ ├── thread-safety.md
106
- │ │ └── performance.md
107
- │ └── rails/ # Context from rails gem
108
- │ └── configuration.md
109
- ```
110
-
111
- ## Use Cases and Workflows
112
-
113
- ### For Gem Authors
114
-
115
- 1. **Create Context Directory**: Add `context/` to gem root.
116
- 2. **Write Context Files**: Create `.md` files with documentation, examples, guides.
117
- 3. **Version and Distribute**: Context files are included in gem releases.
118
-
119
- ### For Developers
120
-
121
- 1. **Discover Context**: `bake agent:context:list` to see available context.
122
- 2. **Install Context**: `bake agent:context:install --gem async` to copy locally.
123
- 3. **Access Context**: AI agents can read from `.context/` directory.
124
-
125
- ### For AI Agents
126
-
127
- 1. **Scan Context**: Read from `.context/` directory for relevant information.
128
- 2. **Apply Context**: Use glob patterns to determine which context applies.
129
- 3. **Provide Guidance**: Reference gem-specific documentation and examples.
130
-
131
- ## Future Considerations
132
-
133
- ### Potential Enhancements
134
-
135
- - **Context Validation**: Validate `.md` file structure and content.
136
- - **Context Indexing**: Create searchable index of installed context.
137
- - **Context Updates**: Mechanism to update context when gems are updated.
138
- - **Context Dependencies**: Allow context files to reference other context files.
139
-
140
- ### Integration Opportunities
141
-
142
- - **IDE Integration**: Context-aware code completion and documentation.
143
- - **CI/CD Integration**: Validate context files during gem releases.
144
- - **Documentation Sites**: Generate context-aware documentation.
145
- - **AI Agent Frameworks**: Direct integration with AI agent platforms.
146
-
147
- ## Conclusion
148
-
149
- The `agent-context` gem provides a simple but powerful mechanism for making Ruby gems more AI-friendly. By treating context as a first-class part of a gem's interface, it enables AI agents to access the rich knowledge that gem authors provide, leading to more effective and informed code assistance.