Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions test/agent/context/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,30 @@ def around
expect(content).to be(:include?, "No context files found")
expect(content).not.to be(:include?, "Old context content here")
end

it "only finds context sections under the Agent heading" do
existing_content = <<~MARKDOWN
# Agent

Agent instructions.

# Project

## Context

Project context.
MARKDOWN

File.write(agent_md_path, existing_content)

index = Agent::Context::Index.new(context_path)
index.update_agents_md(agent_md_path)

content = File.read(agent_md_path)
expect(content.scan("## Context").length).to be == 2
expect(content).to be(:include?, "Project context.")
expect(content).to be(:include?, "No context files found")
end
end

with "title and description extraction" do
Expand Down
26 changes: 26 additions & 0 deletions test/agent/context/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ def around
expect(content).to be_nil
end

it "handles a malformed context index" do
File.write(File.join(context_path, "index.yaml"), "invalid: yaml: content: [")

helper = subject.new(specifications: @specifications)
gem = helper.find_gem_with_context("fake-gem")
index = helper.send(:ensure_gem_index, gem, context_path)

expect(index["description"]).to be == "A fake gem for testing"
expect(index["metadata"]).to be == {}
expect(index["files"]).to be == []
end

with "installation" do
let(:target_path) {Dir.mktmpdir}

Expand Down Expand Up @@ -136,6 +148,20 @@ def around
expect(File).to be(:exist?, File.join(target_context_path, "getting-started.md"))
expect(File).to be(:exist?, File.join(target_context_path, "configuration.md"))
end

it "generates metadata for minimally structured context" do
File.write(File.join(context_path, "notes.md"), "First paragraph.\n\nSecond paragraph.")
helper = subject.new(root: @target_path, specifications: @specifications)

expect(helper.install_gem_context("fake-gem")).to be_truthy

index_path = File.join(@target_path, ".agents", "context", "fake-gem", "index.yaml")
index = YAML.load_file(index_path)
notes = index["files"].find{|file| file["path"] == "notes.md"}

expect(notes["title"]).to be == "Documentation"
expect(notes["description"]).to be == "First paragraph."
end
end
end

Expand Down