agent-context 0.1.0 → 0.1.2
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/agent.md +1 -1
- data/bake/agent/context.rb +1 -1
- data/lib/agent/context/index.rb +4 -5
- data/lib/agent/context/installer.rb +5 -13
- data/lib/agent/context/version.rb +1 -1
- data/lib/agent/context.rb +1 -0
- data/readme.md +53 -34
- data.tar.gz.sig +0 -0
- metadata +6 -20
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5e443b38ea46b98fbee27a14ea918b63a619d9318a54884877f142224038d3d
|
4
|
+
data.tar.gz: f750d6fad191556113a782cc1a66616f529b80d689f2226be3d27a87dba82725
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c5f7bc3b996bfbd509da5bf0e9e41cfd561f95782d8558a83a8061e9f7c4886bbe5d57c9bf4d755fa1cc8db4fcdef69db1b96a2b4819ffda4f0c23738ab8e31
|
7
|
+
data.tar.gz: '0912e5e105747edb18f8dcf688bb63165a9ea205dab03d0f8f82f4a40769c5a1c99ace3c4fd5c39a669bc4afaac3a4380d12ea051df09dae87e4320bb4738202'
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/agent.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## Context
|
4
4
|
|
5
|
-
|
5
|
+
This section provides links to documentation from installed packages. It is automatically generated and may be updated by running `bake agent:context:install`.
|
6
6
|
|
7
7
|
### decode
|
8
8
|
|
data/bake/agent/context.rb
CHANGED
@@ -69,7 +69,7 @@ def install(gem: nil)
|
|
69
69
|
installed = @installer.install_all_context
|
70
70
|
if installed.any?
|
71
71
|
puts "Installed context from #{installed.length} gems:"
|
72
|
-
installed.each {
|
72
|
+
installed.each {|gem_name| puts " #{gem_name}"}
|
73
73
|
else
|
74
74
|
puts "No gems with context found"
|
75
75
|
end
|
data/lib/agent/context/index.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright,
|
4
|
+
# Copyright, 2025, by Samuel Williams.
|
5
|
+
# Copyright, 2025, by Shopify Inc.
|
5
6
|
|
6
7
|
require_relative "version"
|
7
8
|
require "fileutils"
|
8
|
-
require "markly"
|
9
9
|
require "yaml"
|
10
10
|
|
11
11
|
# @namespace
|
@@ -44,7 +44,7 @@ module Agent
|
|
44
44
|
def generate_context_section
|
45
45
|
sections = []
|
46
46
|
|
47
|
-
sections << "
|
47
|
+
sections << "This section provides links to documentation from installed packages. It is automatically generated and may be updated by running `bake agent:context:install`."
|
48
48
|
sections << ""
|
49
49
|
|
50
50
|
gem_contexts = collect_gem_contexts
|
@@ -129,7 +129,6 @@ module Agent
|
|
129
129
|
"## Context",
|
130
130
|
"",
|
131
131
|
context_content,
|
132
|
-
""
|
133
132
|
].join("\n")
|
134
133
|
File.write(agent_md_path, content)
|
135
134
|
end
|
@@ -274,7 +273,7 @@ module Agent
|
|
274
273
|
|
275
274
|
def extract_title(lines)
|
276
275
|
# Look for the first markdown header
|
277
|
-
header_line = lines.find {
|
276
|
+
header_line = lines.find {|line| line.start_with?("#")}
|
278
277
|
if header_line
|
279
278
|
# Remove markdown header syntax and clean up
|
280
279
|
header_line.sub(/^#+\s*/, "").strip
|
@@ -26,7 +26,7 @@ module Agent
|
|
26
26
|
"debugging"
|
27
27
|
]
|
28
28
|
|
29
|
-
# Initialize a new
|
29
|
+
# Initialize a new Installer instance.
|
30
30
|
#
|
31
31
|
# @parameter root [String] The root directory to work from (default: current directory).
|
32
32
|
# @parameter specifications [Gem::Specification] The gem specifications to search (default: all installed gems).
|
@@ -63,7 +63,7 @@ module Agent
|
|
63
63
|
|
64
64
|
# Find a specific gem with context.
|
65
65
|
def find_gem_with_context(gem_name)
|
66
|
-
spec = @specifications.find {
|
66
|
+
spec = @specifications.find {|spec| spec.name == gem_name}
|
67
67
|
return nil unless spec
|
68
68
|
|
69
69
|
context_path = File.join(spec.full_gem_path, "context")
|
@@ -86,7 +86,7 @@ module Agent
|
|
86
86
|
gem = find_gem_with_context(gem_name)
|
87
87
|
return nil unless gem
|
88
88
|
|
89
|
-
Dir.glob(File.join(gem[:path], "**/*")).select {
|
89
|
+
Dir.glob(File.join(gem[:path], "**/*")).select {|f| File.file?(f)}
|
90
90
|
end
|
91
91
|
|
92
92
|
# Show content of a specific context file.
|
@@ -101,7 +101,7 @@ module Agent
|
|
101
101
|
File.join(gem[:path], "#{file_name}.md")
|
102
102
|
]
|
103
103
|
|
104
|
-
file_path = possible_paths.find {
|
104
|
+
file_path = possible_paths.find {|path| File.exist?(path)}
|
105
105
|
return nil unless file_path
|
106
106
|
|
107
107
|
File.read(file_path)
|
@@ -214,7 +214,7 @@ module Agent
|
|
214
214
|
|
215
215
|
def extract_title(lines)
|
216
216
|
# Look for the first markdown header
|
217
|
-
header_line = lines.find {
|
217
|
+
header_line = lines.find {|line| line.start_with?("#")}
|
218
218
|
if header_line
|
219
219
|
# Remove markdown header syntax and clean up
|
220
220
|
header_line.sub(/^#+\s*/, "").strip
|
@@ -257,14 +257,6 @@ module Agent
|
|
257
257
|
|
258
258
|
description
|
259
259
|
end
|
260
|
-
|
261
|
-
def extract_gem_description(gem_name)
|
262
|
-
# Find the gem specification using Ruby's Gem API
|
263
|
-
spec = Gem::Specification.find_by_name(gem_name)
|
264
|
-
spec&.summary
|
265
|
-
rescue Gem::MissingSpecError
|
266
|
-
nil
|
267
|
-
end
|
268
260
|
end
|
269
261
|
end
|
270
262
|
end
|
data/lib/agent/context.rb
CHANGED
data/readme.md
CHANGED
@@ -14,22 +14,23 @@ When you install context from gems, they are placed in the `.context/` directory
|
|
14
14
|
|
15
15
|
Add the gem to your project and install context from all available gems:
|
16
16
|
|
17
|
-
```bash
|
17
|
+
``` bash
|
18
18
|
$ bundle add agent-context
|
19
19
|
$ bake agent:context:install
|
20
20
|
```
|
21
21
|
|
22
22
|
This workflow:
|
23
|
-
|
24
|
-
-
|
25
|
-
-
|
26
|
-
-
|
23
|
+
|
24
|
+
- Adds the `agent-context` gem to your project.
|
25
|
+
- Installs context files from all gems into `.context/`.
|
26
|
+
- Generates or updates `agent.md` with a comprehensive overview.
|
27
|
+
- Follows the <https://agent.md> specification for agentic coding tools.
|
27
28
|
|
28
29
|
## Context
|
29
30
|
|
30
31
|
This gem provides its own context files in the `context/` directory, including:
|
31
32
|
|
32
|
-
- `usage.md` - Comprehensive guide for using and providing context files.
|
33
|
+
- `usage.md` - Comprehensive guide for using and providing context files.
|
33
34
|
|
34
35
|
When you install context from other gems, they will be placed in the `.context/` directory and referenced in `agent.md`.
|
35
36
|
|
@@ -39,7 +40,7 @@ When you install context from other gems, they will be placed in the `.context/`
|
|
39
40
|
|
40
41
|
Add the `agent-context` gem to your project:
|
41
42
|
|
42
|
-
```bash
|
43
|
+
``` bash
|
43
44
|
$ bundle add agent-context
|
44
45
|
```
|
45
46
|
|
@@ -49,13 +50,13 @@ $ bundle add agent-context
|
|
49
50
|
|
50
51
|
Install context from all available gems and update `agent.md`:
|
51
52
|
|
52
|
-
```bash
|
53
|
+
``` bash
|
53
54
|
$ bake agent:context:install
|
54
55
|
```
|
55
56
|
|
56
57
|
Install context from a specific gem:
|
57
58
|
|
58
|
-
```bash
|
59
|
+
``` bash
|
59
60
|
$ bake agent:context:install --gem async
|
60
61
|
```
|
61
62
|
|
@@ -63,13 +64,13 @@ $ bake agent:context:install --gem async
|
|
63
64
|
|
64
65
|
List all gems that have context available:
|
65
66
|
|
66
|
-
```bash
|
67
|
+
``` bash
|
67
68
|
$ bake agent:context:list
|
68
69
|
```
|
69
70
|
|
70
71
|
List context files for a specific gem:
|
71
72
|
|
72
|
-
```bash
|
73
|
+
``` bash
|
73
74
|
$ bake agent:context:list --gem async
|
74
75
|
```
|
75
76
|
|
@@ -77,7 +78,7 @@ $ bake agent:context:list --gem async
|
|
77
78
|
|
78
79
|
Show the content of a specific context file:
|
79
80
|
|
80
|
-
```bash
|
81
|
+
``` bash
|
81
82
|
$ bake agent:context:show --gem async --file thread-safety
|
82
83
|
```
|
83
84
|
|
@@ -85,30 +86,28 @@ $ bake agent:context:show --gem async --file thread-safety
|
|
85
86
|
|
86
87
|
Both `.context/` and `agent.md` should be committed to git:
|
87
88
|
|
88
|
-
- `agent.md` is user-facing documentation that should be versioned.
|
89
|
-
- `.context/` files are referenced by `agent.md` and needed for AI agents to function properly.
|
90
|
-
- This ensures AI agents in CI have access to the full context.
|
89
|
+
- `agent.md` is user-facing documentation that should be versioned.
|
90
|
+
- `.context/` files are referenced by `agent.md` and needed for AI agents to function properly.
|
91
|
+
- This ensures AI agents in CI have access to the full context.
|
91
92
|
|
92
93
|
## Providing Context in Your Gem
|
93
94
|
|
94
95
|
To provide context files in your gem, create a `context/` directory in your gem's root:
|
95
96
|
|
96
|
-
|
97
|
-
|
98
|
-
├──
|
99
|
-
│ ├──
|
100
|
-
│ ├──
|
101
|
-
│
|
102
|
-
|
103
|
-
|
104
|
-
└── your-gem.gemspec
|
105
|
-
```
|
97
|
+
your-gem/
|
98
|
+
├── context/
|
99
|
+
│ ├── getting-started.md
|
100
|
+
│ ├── usage.md
|
101
|
+
│ ├── configuration.md
|
102
|
+
│ └── index.yaml (optional)
|
103
|
+
├── lib/
|
104
|
+
└── your-gem.gemspec
|
106
105
|
|
107
106
|
### Optional: Custom Index File
|
108
107
|
|
109
108
|
You can provide a custom `index.yaml` file to control ordering and metadata:
|
110
109
|
|
111
|
-
```yaml
|
110
|
+
``` yaml
|
112
111
|
description: "Your gem description from gemspec"
|
113
112
|
version: "1.0.0"
|
114
113
|
files:
|
@@ -127,37 +126,57 @@ If no `index.yaml` is provided, one will be generated automatically from your ge
|
|
127
126
|
The generated `agent.md` file can be integrated with various AI coding tools by creating symbolic links to their expected locations:
|
128
127
|
|
129
128
|
### Cline
|
130
|
-
|
129
|
+
|
130
|
+
``` bash
|
131
131
|
ln -s agent.md .clinerules
|
132
132
|
```
|
133
133
|
|
134
134
|
### Claude Code
|
135
|
-
|
135
|
+
|
136
|
+
``` bash
|
136
137
|
ln -s agent.md CLAUDE.md
|
137
138
|
```
|
138
139
|
|
139
140
|
### Cursor
|
140
|
-
|
141
|
-
|
141
|
+
|
142
|
+
First, create the `.cursor/rules` directory:
|
143
|
+
|
144
|
+
``` bash
|
145
|
+
mkdir -p .cursor/rules
|
142
146
|
```
|
143
147
|
|
148
|
+
Then create `.cursor/rules/agent.mdc` with:
|
149
|
+
|
150
|
+
``` markdown
|
151
|
+
---
|
152
|
+
alwaysApply: true
|
153
|
+
---
|
154
|
+
Consult the `agent.md` file in the root directory.
|
155
|
+
```
|
156
|
+
|
157
|
+
This approach uses Cursor's proper front-matter format and directs the AI to consult the main `agent.md` file.
|
158
|
+
|
144
159
|
### Gemini CLI, OpenAI Codex, OpenCode
|
145
|
-
|
160
|
+
|
161
|
+
``` bash
|
146
162
|
ln -s agent.md AGENTS.md
|
147
163
|
```
|
148
164
|
|
149
165
|
### GitHub Copilot
|
150
|
-
|
166
|
+
|
167
|
+
``` bash
|
151
168
|
ln -s ../../agent.md .github/copilot-instructions.md
|
152
169
|
```
|
153
170
|
|
154
171
|
### Replit
|
155
|
-
|
172
|
+
|
173
|
+
``` bash
|
156
174
|
ln -s agent.md .replit.md
|
157
175
|
```
|
158
176
|
|
159
177
|
### Windsurf
|
160
|
-
|
178
|
+
|
179
|
+
``` bash
|
161
180
|
ln -s agent.md .windsurfrules
|
162
181
|
```
|
163
182
|
|
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.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -40,33 +40,19 @@ cert_chain:
|
|
40
40
|
date: 1980-01-02 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: bake
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
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: '
|
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
|
+
version: '0.23'
|
70
56
|
executables: []
|
71
57
|
extensions: []
|
72
58
|
extra_rdoc_files: []
|
metadata.gz.sig
CHANGED
Binary file
|