Class: Diogenes::Targets::Copilot

Inherits:
Base
  • Object
show all
Defined in:
lib/diogenes/targets/copilot.rb,
sig/generated/diogenes/targets/copilot.rbs

Constant Summary collapse

OUTPUT_PATH =

: String

Returns:

  • (String)
".github/copilot-instructions.md"

Instance Method Summary collapse

Methods inherited from Base

#generated_banner, #initialize, #skill_file_content, #write, #write_skill_files

Constructor Details

This class inherits a constructor from Diogenes::Targets::Base

Instance Method Details

#build(sources:) ⇒ Array[String]

: (sources: untyped) -> Array

Parameters:

  • sources: (Object)

Returns:

  • (Array[String])


10
11
12
13
# File 'lib/diogenes/targets/copilot.rb', line 10

def build(sources:)
  skill_files = write_skill_files(sources.skills, skills_dir: ".agents/skills")
  [write(OUTPUT_PATH, render(sources))] + skill_files
end

#headerString

: () -> String

Returns:

  • (String)


26
27
28
# File 'lib/diogenes/targets/copilot.rb', line 26

def header
  "<!-- #{generated_banner("copilot")} -->"
end

#render(sources) ⇒ String

: (untyped) -> String

Parameters:

  • (Object)

Returns:

  • (String)


18
19
20
21
22
23
# File 'lib/diogenes/targets/copilot.rb', line 18

def render(sources)
  parts = [header]
  parts << rules_section(sources.rules) unless sources.rules.empty?
  parts << skills_section(sources.skills) unless sources.skills.empty?
  parts.join("\n\n")
end

#rules_section(rules) ⇒ String

: (Array) -> String

Parameters:

Returns:

  • (String)


31
32
33
34
35
36
37
38
# File 'lib/diogenes/targets/copilot.rb', line 31

def rules_section(rules)
  lines = ["## Always apply these rules", ""]
  rules.each do |rule|
    lines << rule.content
    lines << ""
  end
  lines.join("\n").strip
end

#skills_section(skills) ⇒ String

: (Array) -> String

Parameters:

Returns:

  • (String)


41
42
43
44
45
46
47
# File 'lib/diogenes/targets/copilot.rb', line 41

def skills_section(skills)
  lines = ["## Available slash commands", ""]
  skills.each do |skill|
    lines << "- **#{skill.command}**: #{skill.description}"
  end
  lines.join("\n").strip
end