PlanOpticon

planopticon / video_processor / agent / skills / doc_generator.py
Source Blame History 76 lines
0981a08… noreply 1 """Skill: Generate technical documentation, ADRs, or meeting notes."""
0981a08… noreply 2
0981a08… noreply 3 from video_processor.agent.skills.base import (
0981a08… noreply 4 AgentContext,
0981a08… noreply 5 Artifact,
0981a08… noreply 6 Skill,
0981a08… noreply 7 register_skill,
0981a08… noreply 8 )
0981a08… noreply 9
0981a08… noreply 10 _DOC_PROMPTS = {
0981a08… noreply 11 "technical_doc": (
0981a08… noreply 12 "Generate technical documentation with:\n"
0981a08… noreply 13 "1. Overview\n2. Architecture\n3. Components & Interfaces\n"
0981a08… noreply 14 "4. Data Flow\n5. Deployment & Configuration\n"
0981a08… noreply 15 "6. API Reference (if applicable)"
0981a08… noreply 16 ),
0981a08… noreply 17 "adr": (
0981a08… noreply 18 "Generate an Architecture Decision Record (ADR) with:\n"
0981a08… noreply 19 "1. Title\n2. Status (Proposed)\n3. Context\n"
0981a08… noreply 20 "4. Decision\n5. Consequences\n6. Alternatives Considered"
0981a08… noreply 21 ),
0981a08… noreply 22 "meeting_notes": (
0981a08… noreply 23 "Generate structured meeting notes with:\n"
0981a08… noreply 24 "1. Meeting Summary\n2. Key Discussion Points\n"
0981a08… noreply 25 "3. Decisions Made\n4. Action Items (with owners)\n"
0981a08… noreply 26 "5. Open Questions\n6. Next Steps"
0981a08… noreply 27 ),
0981a08… noreply 28 }
0981a08… noreply 29
0981a08… noreply 30
0981a08… noreply 31 class DocGeneratorSkill(Skill):
0981a08… noreply 32 name = "doc_generator"
0981a08… noreply 33 description = "Generate technical documentation, ADRs, or meeting notes"
0981a08… noreply 34
0981a08… noreply 35 def execute(self, context: AgentContext, **kwargs) -> Artifact:
0981a08… noreply 36 doc_type = kwargs.get("doc_type", "technical_doc")
0981a08… noreply 37 stats = context.query_engine.stats()
0981a08… noreply 38 entities = context.query_engine.entities()
0981a08… noreply 39 relationships = context.query_engine.relationships()
0981a08… noreply 40
0981a08… noreply 41 doc_instructions = _DOC_PROMPTS.get(doc_type, _DOC_PROMPTS["technical_doc"])
0981a08… noreply 42 doc_label = doc_type.replace("_", " ")
0981a08… noreply 43
0981a08… noreply 44 parts = [
0981a08… noreply 45 f"You are a technical writer. Generate a {doc_label} "
0981a08… noreply 46 "from the following knowledge graph context.",
0981a08… noreply 47 "",
0981a08… noreply 48 "## Knowledge Graph Overview",
0981a08… noreply 49 stats.to_text(),
0981a08… noreply 50 "",
0981a08… noreply 51 "## Entities",
0981a08… noreply 52 entities.to_text(),
0981a08… noreply 53 "",
0981a08… noreply 54 "## Relationships",
0981a08… noreply 55 relationships.to_text(),
0981a08… noreply 56 "",
0981a08… noreply 57 "## Planning Entities",
0981a08… noreply 58 ]
0981a08… noreply 59 for e in context.planning_entities:
0981a08… noreply 60 parts.append(f"- {e}")
0981a08… noreply 61
0981a08… noreply 62 parts.append(f"\n{doc_instructions}\n\nReturn ONLY the markdown.")
0981a08… noreply 63
0981a08… noreply 64 prompt = "\n".join(parts)
0981a08… noreply 65 response = context.provider_manager.chat(messages=[{"role": "user", "content": prompt}])
0981a08… noreply 66
0981a08… noreply 67 return Artifact(
0981a08… noreply 68 name=doc_label.title(),
0981a08… noreply 69 content=response,
0981a08… noreply 70 artifact_type="document",
0981a08… noreply 71 format="markdown",
0981a08… noreply 72 metadata={"doc_type": doc_type},
0981a08… noreply 73 )
0981a08… noreply 74
0981a08… noreply 75
0981a08… noreply 76 register_skill(DocGeneratorSkill())

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button