PinkRooster.PromptComposer.Analyzer
1.1.1
dotnet add package PinkRooster.PromptComposer.Analyzer --version 1.1.1
NuGet\Install-Package PinkRooster.PromptComposer.Analyzer -Version 1.1.1
<PackageReference Include="PinkRooster.PromptComposer.Analyzer" Version="1.1.1" />
<PackageVersion Include="PinkRooster.PromptComposer.Analyzer" Version="1.1.1" />
<PackageReference Include="PinkRooster.PromptComposer.Analyzer" />
paket add PinkRooster.PromptComposer.Analyzer --version 1.1.1
#r "nuget: PinkRooster.PromptComposer.Analyzer, 1.1.1"
#:package PinkRooster.PromptComposer.Analyzer@1.1.1
#addin nuget:?package=PinkRooster.PromptComposer.Analyzer&version=1.1.1
#tool nuget:?package=PinkRooster.PromptComposer.Analyzer&version=1.1.1
<div align="center"> <img src="https://github.com/pinkroosterai/Persistify/raw/main/img/logo_transparent.png" alt="PinkRoosterAi Logo" width="300">
PinkRooster.PromptComposer
A powerful .NET library for composing AI prompts using the decorator pattern with compile-time validation and intelligent enhancement suggestions.
</div>
Overview
PinkRooster.PromptComposer provides an immutable, fluent API for building sophisticated AI prompts by combining decorators that modify prompts in specific ways. The library includes:
- 100+ Built-in Decorators organized into logical categories
- Compile-time Validation using Roslyn analyzers
- Automatic Conflict Detection to prevent incompatible decorator combinations
- Enhancement Suggestions to improve prompt quality
- AI-Powered Prompt Enhancement via
GenerateAndEnhanceAsync - Immutable Composition for thread-safe, predictable behavior
This library is inspired by [!smkalami's] and [!synaptiai's]. It should be considered as a work in progress.
Example output (see example project)
____ _ ____
| _ \ _ __ ___ _ __ ___ _ __ | |_ / ___| ___ _ __ ___ _ __ ___ ___ ___ _ __
| |_) | | '__| / _ \ | '_ ` _ \ | '_ \ | __| | | / _ \ | '_ ` _ \ | '_ \ / _ \ / __| / _ \ | '__|
| __/ | | | (_) | | | | | | | | |_) | | |_ | |___ | (_) | | | | | | | | |_) | | (_) | \__ \ | __/ | |
|_| |_| \___/ |_| |_| |_| | .__/ \__| \____| \___/ |_| |_| |_| | .__/ \___/ |___/ \___| |_|
|_| |_|
Demonstrating prompt decoration and AI enhancement
────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Scenario 1: Original Prompt ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌─Original Prompt──────────────────────────────────────────┐
│ Write a short story about a cat lost in a fantasy world. │
└──────────────────────────────────────────────────────────┘
┌─AI Response───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Lyra and the World of Lumen │
│ │
│ Lyra, a silver-tipped tabby with eyes like moss-green marbles, liked curiosity more than sleep. She lived in a sleepy harbor town where doors squeaked shut at dusk and kittens dreamt of ships and stars. One night, while the world outside wore a rain's │
│ brittle veil, a silver moth led her to the attic's old mirror-a moon-silvered pane that stood as a guardian of forgotten doors. When the moth brushed against the glass, a tremor ran through the frame, and Lyra, flicking her tail with a mixture of doubt │
│ and dare, slipped through. │
│ │
│ The world beyond was not a room, but a poem you could walk inside. Gravity wobbled like jelly, rivers ran in ribbons of liquid light, and trees wore bells that rang when the wind touched their leaves. Two moons hung above the horizon, one pale as a │
│ sigh, the other bright as a coin dropped in a well. Islands drifted on air as if the sea had learned to fly, and every path pointed toward wonder and danger in equal measure. │
│ │
│ Lyra landed on a cushion of soft moss that glowed faintly under a sky bright with faint constellations. She opened her mouth to call for home, but only a soundless chime answered-the trees themselves seemed to listen, and then await her next move. A │
│ moth-no ordinary moth, but one lantern-lit and patient-swooped in front of her nose, hovering as if to say, Follow me. │
│ │
│ "Where am I?" Lyra asked, though the moth did not answer in words she could hear. The world glowed in response: a river of glass curled around a hill, a market of floating stalls shimmered with jars of star-dust, and a hill's side carved into a library │
│ of stone and wind. │
│ │
│ The moth settled onto Lyra's whiskers and then drifted escape-quiet into a circle of blue fireflies. From the circle stepped a raven with one gold eye and one copper eye, named Rook by a voice that felt older than rain. │
│ │
│ "You are not supposed to be here," Rook said, though not cruelly. "Not yet, at least. The Gate remembers every Passing Cat who forgets to return." He spoke with patient caution, as if choosing each word to avoid frightening a cat who might suddenly │
│ sprint into any shadow. │
│ │
│ Lyra flicked her ears. A touch of fear rose in her throat, but curiosity pressed forward harder. "Why am I here at all?" she asked. │
│ │
│ "Because doors do not shut for a single mouse's bravery or a single cat's curiosity," Rook replied. "They narrow to those who learn the language of courage and kindness. If you wish to go back, you must first learn how to listen to this world you've │
│ wandered into." │
│ │
│ Before she could respond, a soft, watery voice joined the conversation. "And you must listen to yourself," said a small lantern-fish, Lumen, who had somehow learned to bob in the air like a tiny moon. Lumen's light flickered-a pulse of warmth, a guide's │
│ heartbeat-bright enough to cast a map on the mossy ground. │
│ │
│ So the three-Lyra, Rook, and Lumen-began a journey through Lumen. They crossed a field where grass sang in a melody that rose and fell with every pawstep, and they paused at the edge of a forest where the trunks wore faces like old sailors' maps, │
│ speaking in rustles and sighs. │
│ │
│ Rook proved a steady guide, pointing out safe paths and warning Lyra to breathe in the moment rather than chase the next thrill. Lumen offered light and calm when the night grew thick, when Lyra's paws grew tired and her green eyes dimmed with doubt. │
│ They spoke little of home, choosing instead to listen to the world-to its rivers that whispered secrets, to its bells that sounded when the trees swayed, to the small creatures that darted in and out of moonlit hedges. │
│ │
│ Their quest grew clear when they reached the Moon Orchard, a grove where fruit-like stars hung heavy on silver branches. In this orchard, the Gate of Quiet-the doorway that could carry Lyra home if opened-was said to rest within a nest of starlight │
│ guarded by a silent wind. But the Gate would not open until a Star Needle was returned to the Gate's seam: a slender, gleaming needle woven from a single fallen star. │
│ │
│ The trio faced their first trial at a market that drifted above the water-a bazaar of floating stalls where clocks ticked in reverse and tiles hummed in scales of music. A vendor with eyes like jar lids sold them Moonshards, small crescents of frost │
│ that could chill fear in the heart and warm hope in the chest. Lyra learned to purr with intention, a soft, rolling sound that made a stall's anxious clock settle and its hands drift more slowly. The vendor, impressed by her calm, traded a single │
│ MoonShard for a promise: that Lyra would help others find their own quiet corners when the time came. │
│ │
│ Meanwhile, Vell-the Storm Serpent of this world-kept a wary vigil at the orchard's edge. Its great coils of rain-wind curled around the branches, siphoning away light and leaving a cold hush in the air. It was not malicious, exactly, but protective of │
│ what it guarded. When Lyra approached with Rook and Lumen, Vell lowered its head and blinked rainfully, as if to ask for something in return for safe passage. │
│ │
│ "We don't steal what isn't ours," Lyra spoke softly, feeling a flutter of bravery she didn't know she could summon. "We earn it with help and honesty." │
│ │
│ Rook croaked a laughter that sounded like a carved wooden chest opening in the night. Lumen's glow brightened and hummed a tune that matched the whispers in Lyra's own chest: If you can listen to others, you'll learn to listen to yourself. │
│ │
│ Together they coaxed the Star Needle from its nest, a thread of pure dawn still clinging to its point. The needle pulsed with a cold, gentle energy, as though it remembered every home it had ever sewn into the world. Lyra clasped it in her mouth with │
│ care, a surprising center of gravity in the stillness of her nerves. │
│ │
│ On their return to the Gate of Quiet, the wind stiffened and the world's colors shifted-an ominous veil of possibility, as if the door itself could hesitate. Vell stirred, watching them with cautious, shimmering eyes. The Gate, a circle of light framed │
│ by a seam of dark velvet, opened briefly, then pinched shut again, as if testing their resolve. │
│ │
│ Lyra realized that to reopen the Gate, something else must be woven into its seam: a memory not simply of home, but of who she wished to be when she found it. She closed her eyes and purred, a deep, resonant sound that laid her heart bare to the world │
│ around her. │
│ │
│ "I am Lyra," she whispered, letting the name roll like a soft bell. "I am a traveler who learns the art of listening, who helps others, and who loves the warmth of a lap and the quiet of a dawn-lit window. I will carry the memory of this journey to any │
│ door I find." │
│ │
│ The Gate shifted. The star needle flickered, sinking a single, steady thread through the Gate's seam. Light poured through the circle as if someone had turned on a lamp behind a delicate shade. The air filled with the scent of rain on lilac and the │
│ distant sound of a piano, faint but unmistakable-the sound of a home's memory welcoming her back. │
│ │
│ Lyra stepped toward the Gate. The last thing she heard before slipping through was Rook's calm croak and Lumen's soft luminescence, a chorus of friends who had become a family. The world heaved and then narrowed to a silver circle, and Lyra felt warmth │
│ wrap around her like a familiar blanket. │
│ │
│ When she opened her eyes again, she was back in the attic, the old mirror behind a pile of forgotten trunks, dust motes dancing in a pale shaft of dawn. The moth rested on the glass as if nothing had happened, its wings barely moving. The attic smelled │
│ of rain and old wood and something else-home, wrapped in a glow of distant sunbeams. │
│ │
│ Lyra climbed onto the windowsill, where the soft light pooled, and looked down at the room she knew: the teacups on a shelf, the warm glow of the stove, the little crack in the floorboard that housed a brood of brave memories. A familiar voice-a human │
│ voice-called her name. The door to the house opened and a child's hand reached for her, and Lyra purred, long and content, with a new quiet in her heart. │
│ │
│ In that moment, she understood. Home was not a place marked by a door or a chair or a snoring human; home was a feeling-safe and loved and seen-carried in one's chest like a bright thread. The silver thread of the Star Needle glowed faintly at her neck, │
│ a tiny halo of light that throbbed with each purr, a reminder that doors would come again if she remained true to herself and to the care she offered to others. │
│ │
│ Lyra did not forget the World of Lumen, nor the friends who had walked that strange road with her. She would dream of the floating markets and the singing grass and the wind that could be coaxed into telling a story. And sometimes, when the night grew │
│ quiet, she would press her face to the window and listen; and if the world was listening back, it was with the soft agreement that there would always be a way home-not just to a place, but to the warmth that waited in a lap and the trust that shines in │
│ a companion's eyes. │
│ │
│ So the doorways remained, untold but never far, and Lyra kept purring a little tune that sounded like rain on lilac, a promise she would carry wherever she lay her head: curiosity can guide a cat to new worlds; kindness can stitch them back together; │
│ and home, at last, is wherever you find those who love you enough to listen when you whisper your name. │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
───────────────────────────────────────────────────────────────────────────────────────────────────────────────── Scenario 2: Decorated Prompt ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Creating decorated prompt with StepByStep and Narrative decorators...
┌─Decorated Prompt──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ StepByStep: │
│ Provide the entire response as a numbered list of steps. Each step must start with a bolded heading in the format '**Step X: [Brief, Action-Oriented Title]**', followed by the detailed explanation for that step. │
│ │
│ Narrative: │
│ Please structure your response as a story-based delivery that uses narrative elements and storytelling techniques to make the information engaging, memorable, and contextually rich. Use a traditional narrative arc with a clear beginning, middle, and │
│ end, following a logical progression of setup, conflict/challenge, and resolution. Include character elements such as personas, stakeholders, or representative individuals that the audience can relate to and follow throughout the narrative. Create a │
│ fully developed narrative with rich details, multiple story beats, and thorough exploration of the topic through storytelling. │
│ │
│ Creative: │
│ Please provide an imaginative, novel, and original response that uses creative language and unexpected connections to engage the reader. Apply significant creative thinking to present the information in fresh, surprising ways. Use vivid language, │
│ unexpected angles, and novel framing to create an engaging and memorable response. │
│ │
│ Task: │
│ Write a short story about a cat lost in a fantasy world. │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─AI Response───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ 1. **Step 1: Slip Through the Mirror** │
│ Nyx, a silver-furred cat with eyes like pale moons, skittered across the dusty attic as a stubborn moth rehearsed one last flutter over a velvet-trimmed mirror. The moth refused to give up, and in that small chase the mirror shivered, swallowing Nyx's │
│ reflection and spitting out a winter-bright world in its place. The attic faded to a rumor of cinnamon and rain, replaced by a valley where rivers hummed and mushrooms blinked in answerable light. Nyx's whiskers twitched with awe and a ache for Mina, │
│ the girl who braided paw-notes into a scarf they shared. Curiosity, long a spark in Nyx's heart, now blazed into a compass. Before the cat could call for a familiar name, a path of glowing frost unfurled at the edge of the mossy bank, inviting Nyx to │
│ step forward into a story that wouldn't wait for a bedtime. │
│ │
│ 2. **Step 2: The World That Breathes** │
│ From the path rose Lira, a sprite with lantern-wings and a grin like a moonlit coin, perched atop a dais of mushrooms that trembled at her breath. The world around Nyx breathed in lilac fog and cinnamon wind, and the air tasted of oaths and old songs. │
│ Lira spoke in soft bells and leaves: doors between doors exist here, and some doors lead back only if the traveler keeps a memory of home bright enough to steer them through. She unfurled a living map that danced in midair, showing rivers that sang back │
│ when pressed by paw, and hills that rolled like sleeping beasts. The key, Lira said, was to follow the map's glow and, above all, remember that Mina waits on the other side of a doorway that may not be obvious. Nyx, ears twitching, decided to trust the │
│ guide and the promise of return. │
│ │
│ 3. **Step 3: The Pact of the Map** │
│ The Glimmer Map glowed with a soft insistence, and Nyx felt the first pinch of real risk: to travel without losing the will to come home. Lira and Nyx spoke an oath into a dew-drop seal that stuck to the map, a pact to help others find their doors as │
│ well as to seek one's own. The map hummed with new warmth, turning from a navigator into a companion, its edges a little brighter where Mina's laughter echoed in Nyx's memory. They sketched a route through shadowed vales and over laughing streams, but │
│ the map warned that every choice would alter the path and every detour could pull a traveler further from home-or closer, if it carried the right memory. Nyx pressed a careful paw to the seal and breathed; the journey had begun, but the destination │
│ remained a shimmering question. │
│ │
│ 4. **Step 4: The Whispering Forest** │
│ They entered a forest where leaves whispered the names of people and places like a library of breaths. Thorn, an ancient willow with bark like parchment and roots that remembered every traveler's footstep, watched from the edge of a silvered stream. The │
│ forest tested them by offering tempting glimpses of alternative paths: a trail stitched from moonlight, a chorus of birds promising shortcuts, a brook that promised to reveal Nyx's future if listened to closely enough. Thorn leaned close and spoke in │
│ slow, patient tones about memory and belonging. The forest's memory-of owners, promises, and goodbyes-sounded in Nyx's chest, tugging at a thread of identity. When Nyx steadied the breath and named Mina aloud, the glow of the map steadied, and Thorn │
│ granted a single luminescent stone that would glow whenever Nyx needed guidance back toward home. │
│ │
│ 5. **Step 5: The River of Forgetting** │
│ Beyond the trees, a river ran with liquid starlight, its current sly and silver, attempting to wash away memory as if it were storm-swept sand. Nyx's fur bristled; the name "Mina" tangled in the throat, threatening to drift away like a dream upon │
│ waking. Vesper, a winged fox with scales of night and eyes of bright frost, swooped down and offered guidance, tracing a path by reading constellations mirrored in the river's surface. The stones along the bank pulsed with a rhythm that matched Nyx's │
│ heart, and every time Nyx purred, the light on the stepping stones aligned a little brighter, a little steadier. With Vesper's help, Nyx whispered the memory of Mina's laugh-the sound that once filled their shared scarf with warmth-and the current │
│ loosened its grip, granting a cautious crossing over to the other side. │
│ │
│ 6. **Step 6: The Gate of Echoes** │
│ Ahead stood a crystalline arch, its surface woven with lattice-work of light and shadow. The Gate of Echoes did not resist travelers; it requested something gentler: a true purr and a confession of what they carried inside. Nyx pressed close, felt the │
│ map glow at the chest, and lowered his head to purr twelve careful notes-the sound tuned to the heart's longing for home. "Nyx," whispered the gate, "you carry your home in your breath and your name in your fur." The voice of Mina rose in Nyx's memory, │
│ not as a cry of longing but as a steady beacon that the gate could hear. The gate loosened its hold, revealing a narrow corridor of light: a thread that looked suspiciously like a doorway home, woven from Nyx's own memories and the map's guiding glow. │
│ │
│ 7. **Step 7: The Return** │
│ Nyx stepped through the light and found the world around him tilting in a familiar way, as if the fantasy had bent to kiss the edge of reality. The attic door stood ajar, dust motes dancing in a ring of sunbeam, and the scent of Mina's scarf-cinnamon, │
│ rain, and a trace of ink-drifted in. For a breathless moment, Nyx didn't know if he was still dreaming or waking, until a soft exhale behind him-Mina-made the air tremble with relief and joy. Mina opened the door further and knelt, arms wide and eyes │
│ shimmering with unshed tears; Nyx leaped into her embrace, purring a storm of gratitude and stories. In that instant, the attic wall blurred at the edges, as if the doorway between worlds had left a delicate stain on the air-a memory that would glitter │
│ in Nyx's dreams and in Mina's handwriting on the scarf they shared. │
│ │
│ 8. **Step 8: Epilogue-A Door Keeps Its Promise** │
│ Back on their bed, Nyx curled beside Mina with the scarf wrapped like a warm dune against their shoulders, and the Glimmer Map rested on the table, faintly glowing as if a firefly slept just beneath the parchment. The world Nyx had found lingered in his │
│ fur-a whisper of Lira's lantern-wings, Thorn's patient wisdom, and Vesper's starlit navigations-enough to remind him that doors exist not only at the edges of rooms, but in memories kept bright. Some nights Nyx would glimpse the echo of that fantasy │
│ world in the windowpane, where two moons might seem to rise again for a moment, and a song would flutter from the attic like a moth. The promise stood: when Mina whispered for a story, Nyx would purr to life, and together they would follow the map's │
│ glow-knowing that home, once found, could always be found again, as long as a heart remembered. │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────────────────────────────── Scenario 3: AI Enhanced Prompt ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌─AI Enhanced Prompt────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ You are a master fantasy storyteller and narrative architect with a talent for world-building, character-driven plots, and lyrical prose. Your mission is to produce a short story about a cat lost in a fantasy world, delivered as a six-step, step-by-step │
│ narrative. │
│ │
│ Output format: │
│ - Return exactly six steps in a single, numbered list. Each step must begin with a bold heading in the format '**Step X: [Brief, Action-Oriented Title]**', followed by the step's narrative content. │
│ - The six steps together form a complete story with a clear beginning, middle, and end. │
│ │
│ Structure and beats: │
│ - Use Step 1 through Step 6 to realize a traditional narrative arc: setup, inciting incident, rising action, midpoint twist, climax, and resolution. │
│ - Include a clearly defined feline protagonist and at least one companion or ally encountered along the journey. │
│ - Populate the fantasy world with imaginative, rule-driven magic, strange landscapes, talking beings, and wondrous creatures. │
│ - Ensure each step naturally leads to the next; use clear cause-and-effect progression between steps. │
│ │
│ Style and tone: │
│ - Write in a lyrical, adventurous, whimsical voice suitable for a broad audience. │
│ - Employ vivid sensory details (sight, sound, smell, texture) and varied sentence rhythm. │
│ - Avoid modern slang and keep prose immersive and accessible. │
│ │
│ Length and pacing: │
│ - Aim for roughly 120-180 words per step, yielding about 750-1100 words in total. Adjust as needed to maintain momentum without filler. │
│ │
│ Reasoning and justification: │
│ - Do not reveal chain-of-thought. At the end of each step, include a single, bracketed sentence that concisely explains the narrative or world-building rationale behind the step's major choice. Example: [Reason: Establishes the world's rules and the │
│ cat's motivation.] │
│ │
│ Formatting and constraints: │
│ - Do not include any meta-text, input prompts, or extraneous information outside the six steps. │
│ - Do not reference the instruction, the prompt, or system messages. │
│ - Do not use placeholders for input data. │
│ - The output must be ready for direct input into a reader-facing medium. │
│ │
│ Task initiation: │
│ - Begin immediately with Step 1 and proceed in order through Step 6. │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─AI Response───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ 1. **Step 1: Waking in a Velvet Realm** │
│ Lyra, a lithe tabby with eyes like dew-wet emeralds, wakes on a bed of moss that hums with a quiet, living rhythm. The Velvet Realm is not a dream but a map turned inside out: skies drift on the backs of listening whales, mountains ride ribbons of wind, │
│ and rivers sing in glassy chords that taste of rain and copper. Her paws imprint the moss, and every scent feels strange yet true-minted rain, lilac smoke, and something ancient, almost memory she cannot name. She is lost, not merely from a street but │
│ from time itself, a traveler who forgets how to find the door home. Then, at the edge of a silver-lit glade, a shadow steps into the night: Lumen, a fox whose fur glows like a lantern and whose tail trails warm light. His voice chimes like wind bells, │
│ and his greeting is a promise: the Velvet Realm does not forget, but it asks a traveler to choose a path and walk it true. A gate's whisper hints that doors exist here, if she learns how to listen. │
│ [Reason: Introduces Lyra as the feline protagonist and establishes the magical Velvet Realm and the guiding ally, setting up the quest premise.] │
│ │
│ 2. **Step 2: A Gate Opens and the Path Splits** │
│ From the grasses, a gate of living starlight lifts its arch between two silver roots, breathing with a language older than the wind. The arch sighs, and runes ripple along its edge, rearranging themselves to a path that glows faintly. Lyra steps closer, │
│ her fur prickling with anticipation and fear, and a taste of ozone fills the air. The gate does not merely admit or deny; it asks for a vow. If she would pass, she must choose a companion and accept a task: to locate the heart of the Gate, safeguarded │
│ by a petal-king in a realm of uphill rivers and haunted bridges. Lumen steps forward, lantern bright as a small sun, and offers to guide if Lyra will help retrieve that heart. They seal the pact with a shared breath, and the first rung of a new world │
│ yawns open. They stride toward floating islands, the air ringing with distant bells and the soft whisper of possible futures. │
│ [Reason: Establish inciting incident: the gate demands a choice and introduces the ally, setting the quest in motion.] │
│ │
│ 3. **Step 3: The Moonlit Trail of an Ally** │
│ Across the next horizon, Lyra's paws learn a new language-footfalls on the air, purring to read the wind. Lumen's lantern lights the path through forests where trees lean in to listen, and vines that hum old lullabies form a living map. They meet a │
│ companion: a bronze stag with keys dangling from his antlers, each key etched with a memory. The stag tests them, asking what they intend to do with the Gate's gift: return to small, quiet homes, or open doors for others when called? Lyra answers with a │
│ steady purr, and the stag grants one of his keys and points toward the Bridge of Quiet Light, a silver ribbon stretched over a singing chasm. They venture onto it, trusting that honest longing will carry them across. Step 3 ends with the promise of the │
│ next trial. │
│ [Reason: Demonstrates rising action, introduces a meaningful ally milestone, and establishes a tangible objective (the Bridge of Quiet Light).] │
│ │
│ 4. **Step 4: The Map Breathes and the Purpose Emerges** │
│ Night deepens, and the Map within Lumen's lantern begins to breathe. The parchment unfurls with a rustle like leaves turning in a patient wind. It reveals the architecture of these realms: every door is a choice; every choice threads the fabric of a │
│ larger pattern. The gate's heart rests not in a far-off island but at the center of the Velvet Realm, nourished by the memories of wanderers who have passed through. To reach it, Lyra must feed a memory of home into the Gate, a price the map will accept │
│ to unlock passage. Lumen's glow strengthens with the tremor of hope; the stag's memory-keys glow softly as if cheering them on. This changes everything: stepping through the Gate means leaving behind something precious, yet it promises to knit two │
│ worlds with the single light of a true longing. │
│ [Reason: The map reveals the moral complexity and the price of passage, intensifying the choice.] │
│ │
│ 5. **Step 5: The Warden's Test and the Bridge's Opening** │
│ On the Bridge of Quiet Light they face the Gate's Warden, a stag-beast carved from moonlight and oak. Lyra sings the lullaby her mother whispered, her voice crossing chasms of wind and echo. The memory she offers-home, lullabies, scent of rain on │
│ brick-blooms into a living key, strengthening Lumen's lantern into a twin flame. The Warden studies their hearts and, finding them true, yields passage. The Gate swallows the distance and the heart-tree blooms at its core, releasing a pathway between │
│ realms. They step through, the velvet world thinning behind them and the familiar world widening ahead, but with Lumen's light now a companion in Lyra's home. The price stands: Lumen's flame will remain faint until Lyra returns the memory to her world, │
│ restoring balance. │
│ [Reason: Climax resolves the central tension, confirms the gate's rules, and establishes the sacrifice needed for transition.] │
│ │
│ 6. **Step 6: Homeward, With a New Door** │
│ Lyra lands in her own alley, dusted with stardust and rain, but the air feels new-as if the city remembers someone else's dream. In the doorway, a shadow steps into the lamplight: Lumen, no longer merely a lantern-bright companion but a friend who │
│ dwells between two skies. The gate's memory has taken root in Lyra's fur-she carries a faint star-pulse within her, a signal to any door that may open in the future. The world, once narrow and known, now feels expansive; she teaches the kittens to │
│ listen for the Gate's whisper and to sing in the key of rain when they hear the world wanting to shift. The alley is still home, yet the Velvet Realm lingers at the edge of sight, a doorway available to those who listen with courage and heart. │
│ [Reason: Resolution: concludes the journey, confirms growth and a lasting bond with the ally, and preserves the possibility of future crossings.] │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Demo completed successfully!
Quick Start
Installation
dotnet add package PinkRooster.PromptComposer
Basic Usage
using PinkRooster.PromptComposer;
using PinkRooster.PromptComposer.Decorators.Minimal;
using PinkRooster.PromptComposer.Decorators.Reasoning;
// Create a prompt composer with decorators
string prompt = PromptComposer
.Create("Explain how neural networks work.")
.AddStepByStep(numbered: true)
.AddBlindSpots()
.AddOutputFormat(OutputFormatType.Markdown)
.Generate();
Console.WriteLine(prompt);
Output:
Please break down your response into clear, sequential steps. Number each step sequentially (Step 1, Step 2, etc.).
Please identify potential cognitive blind spots, unstated assumptions, and overlooked perspectives in your response. Explicitly acknowledge the limitations and biases that might affect your analysis of the topic. Conduct a thorough analysis of blind spots, with substantial attention to underlying assumptions and alternative perspectives. Present your main analysis first, then follow it with a separate section that identifies blind spots and limitations in your reasoning.
Format your response in Markdown.
Explain how neural networks work.
AI-Enhanced Prompt Generation
using Microsoft.Extensions.AI;
using OpenAI;
IChatClient client = new OpenAIClient(apiKey).GetChatClient("gpt-4").AsIChatClient();
string enhancedPrompt = await PromptComposer
.Create("Write a short story about a cat.")
.AddStepByStep(true)
.AddBlindSpots()
.GenerateAndEnhanceAsync(client);
// The AI will analyze and improve the composed prompt before use
var response = await client.GetResponseAsync(enhancedPrompt);
Console.WriteLine(response.Text);
Architecture
Core Components
PinkRooster.PromptComposer/
├── PromptComposer.cs # Main immutable builder
├── Abstractions/
│ ├── IDecorator.cs # Base decorator interface
│ └── DecoratorBase.cs # Abstract base with helper methods
├── Attributes/
│ ├── DecoratorAttribute.cs # Decorator metadata
│ ├── ConflictsWithAttribute.cs # Declare conflicts
│ ├── RequiresDecoratorAttribute.cs # Declare requirements
│ └── EnhancesWithAttribute.cs # Suggest combinations
├── Decorators/ # 100+ built-in decorators
│ ├── Minimal/ # Essential decorators
│ ├── Reasoning/ # Reasoning patterns
│ ├── Structure/ # Output structuring
│ ├── Tone/ # Tone and style
│ ├── Verification/ # Quality checks
│ └── Meta/ # Meta-prompting
├── Exceptions/ # Custom exceptions
└── Utilities/
└── MarkdownAnalyzer.cs # Markdown parsing utilities
Decorator Categories
Minimal (Essential)
- StepByStepDecorator: Structures responses as sequential steps
- OutputFormatDecorator: Specifies output format (JSON, Markdown, XML, etc.)
- ReasoningDecorator: Requests explicit reasoning
- ToneDecorator: Sets response tone
- CustomDecorator: Adds custom instructions
Reasoning (Thinking Patterns)
- BlindSpotsDecorator: Identifies cognitive blind spots and assumptions
- FirstPrinciplesDecorator: Breaks down complex topics to fundamentals
- SocraticDecorator: Uses Socratic questioning method
- TreeOfThoughtDecorator: Explores multiple reasoning paths
- RedTeamDecorator: Adversarial analysis and challenge
- DebateDecorator: Multi-perspective debate format
- ContrarianDecorator: Devil's advocate perspective
- InductiveDecorator: Reasoning from specific to general
- DeductiveDecorator: Reasoning from general to specific
- RootCauseDecorator: Root cause analysis
- NegativeSpaceDecorator: Identifies what's NOT present
- ForcedAnalogyDecorator: Explains via analogies
- TemporalResonanceDecorator: Time-based reasoning
- PerspectiveCascadeDecorator: Multiple viewpoint analysis
Structure (Output Organization)
- OutlineDecorator: Generates structured outlines
- SummaryDecorator: Provides summaries
- LayeredDecorator: Multi-level detail structure
- BulletDecorator: Bullet-point format
- TableFormatDecorator: Tabular data presentation
- TimelineDecorator: Chronological organization
- ComparisonDecorator: Side-by-side comparison
- AlternativesDecorator: Multiple solution presentation
- PrioritizeDecorator: Priority-ordered output
- ConstraintsDecorator: Applies specific constraints
- MECEDecorator: Mutually Exclusive, Collectively Exhaustive structure
- NestedDecorator: Hierarchical nested structure
- SchemaDecorator: Schema-based output
- DecisionMatrixDecorator: Decision matrix format
Tone (Style and Voice)
- ProfessionalDecorator: Professional tone
- ConciseDecorator: Brief and concise
- DetailedDecorator: Comprehensive detail
- AcademicDecorator: Academic writing style
- NarrativeDecorator: Storytelling format
- PersonaDecorator: Specific expert persona
- AudienceDecorator: Tailored to specific audience
- ELI5Decorator: "Explain Like I'm 5" simplicity
- AsExpertDecorator: Expert-level discussion
- CreativeDecorator: Creative and imaginative
- MotivationalDecorator: Motivational tone
- StyleShiftDecorator: Shifts between styles
- RemixDecorator: Reinterprets content
- ExtremesDecorator: Explores extreme scenarios
Verification (Quality Assurance)
- BreakAndBuildDecorator: Breaks down then rebuilds concepts
- ConfidenceDecorator: Includes confidence levels
- CiteSourcesDecorator: Requests source citations
- LimitationsDecorator: Acknowledges limitations
- PeerReviewDecorator: Peer review simulation
- StressTestDecorator: Tests against edge cases
- SteelmanDecorator: Strongest argument version
- BalancedDecorator: Balanced perspective
- UncertaintyDecorator: Acknowledges uncertainty
- FactCheckDecorator: Fact verification
- FindGapsDecorator: Identifies gaps in reasoning
- QualityMetricsDecorator: Quality assessment
- PrecisionDecorator: High precision requirement
Meta (Prompt Engineering)
- RefineDecorator: Iteratively refines responses
- BuildOnDecorator: Builds on previous responses
- ContextDecorator: Adds contextual information
- ConditionalDecorator: Conditional instructions
Roslyn Analyzer
The PinkRooster.PromptComposer.Analyzer project provides compile-time validation:
Diagnostic Rules
| ID | Severity | Description |
|---|---|---|
| PR001 | Error | Conflicting decorators combined |
| PR002 | Error | Missing required decorator |
| PR003 | Info | Enhancement suggestion available |
Features
- Conflict Detection: Prevents incompatible decorator combinations
- Requirement Validation: Ensures required decorators are present
- Enhancement Suggestions: Recommends complementary decorators
- Code Fixes: Automatic fixes for common issues
- Fluent Chain Analysis: Analyzes entire decorator chains
- Sibling Invocation Tracking: Detects decorators in same scope
Example:
// Error PR001: Conflicting decorators
PromptComposer.Create()
.AddDetailed() // Wants verbose output
.AddConcise(); // Wants brief output - CONFLICT!
// Error PR002: Missing requirement
PromptComposer.Create()
.AddSteelman(); // Requires Balanced decorator
// Fix: Add required decorator
PromptComposer.Create()
.AddBalanced()
.AddSteelman(); // Now valid
// Info PR003: Enhancement suggestion
PromptComposer.Create()
.AddStepByStep(); // Suggests: Works well with Reasoning decorator
Extension Library
PinkRooster.PromptComposer.Extensions provides 80+ additional decorators organized by use case:
- Architecture and Design (9 decorators): System architecture, API design, scalability
- Code Generation (9 decorators): Type definitions, algorithms, design patterns
- Developer Education (8 decorators): Learning paths, best practices, concept models
- Developer Workflow (7 decorators): Documentation, commit messages, code standards
- DevOps and Infrastructure (8 decorators): Deployment, monitoring, CI/CD
- Implementation Focused (12 decorators): Implementation strategies, complexity levels
- Systematic Debugging (10 decorators): Root cause analysis, logging strategies
- Testing and Debugging (7 decorators): Test strategies, security audits
Advanced Usage
Custom Decorators
Create custom decorators by implementing IDecorator or extending DecoratorBase:
using PinkRooster.PromptComposer.Abstractions;
using PinkRooster.PromptComposer.Attributes;
[Decorator("MyCustom", Description = "Adds custom behavior")]
[EnhancesWith("Reasoning", Description = "Works well with reasoning")]
public sealed class MyCustomDecorator : DecoratorBase
{
public string CustomParameter { get; init; } = "default";
public override string Apply(string prompt)
{
return PrependInstruction(
$"Custom instruction: {CustomParameter}",
prompt
);
}
}
// Extension method for fluent API
public static class MyCustomDecoratorExtensions
{
public static PromptComposer AddMyCustom(
this PromptComposer composer,
string parameter = "default")
{
return composer.Add(new MyCustomDecorator
{
CustomParameter = parameter
});
}
}
// Usage
var prompt = PromptComposer.Create()
.AddMyCustom("special value")
.Generate("My prompt");
Decorator Attributes
Control decorator behavior and validation using attributes:
[Decorator("MyDecorator", Description = "What this decorator does")]
[ConflictsWith("OtherDecorator", Reason = "Why they conflict")]
[RequiresDecorator("BaseDecorator", Reason = "Why it's required")]
[EnhancesWith("CompanionDecorator", Description = "How they work together")]
public sealed class MyDecorator : DecoratorBase
{
// Implementation
}
Complex Compositions
// Multi-stage prompt composition
var composer = PromptComposer.Create()
// Set tone and style
.AddProfessional()
.AddPersona("senior software architect")
// Add reasoning framework
.AddFirstPrinciples()
.AddBlindSpots(depth: BlindSpotsDepth.Comprehensive)
// Structure output
.AddStepByStep(numbered: true)
.AddOutline()
// Quality assurance
.AddConfidence()
.AddCiteSources()
// Format output
.AddOutputFormat(OutputFormatType.Markdown);
// Generate for specific prompt
string result = composer.Generate(@"
Design a scalable microservices architecture for a high-traffic
e-commerce platform with real-time inventory management.
");
AI Enhancement Pipeline
// Create enhancement pipeline
async Task<string> EnhancePromptWithContext(
IChatClient client,
string basePrompt,
string context)
{
var composer = PromptComposer
.Create(basePrompt)
.AddContext(context)
.AddStepByStep()
.AddBlindSpots()
.AddOutputFormat(OutputFormatType.Markdown)
.AddRestrictPreambleAndClosingStatements();
// AI enhances the composed prompt
string enhanced = await composer.GenerateAndEnhanceAsync(client);
return enhanced;
}
// Usage
string enhancedPrompt = await EnhancePromptWithContext(
chatClient,
"Explain quantum computing",
"For computer science undergraduate students"
);
Configuration
Microsoft.Extensions.AI Integration
The library integrates with Microsoft.Extensions.AI for AI client abstractions:
using Microsoft.Extensions.AI;
using OpenAI;
// OpenAI
IChatClient openAiClient = new OpenAIClient(apiKey)
.GetChatClient("gpt-4")
.AsIChatClient();
// Azure OpenAI
IChatClient azureClient = new AzureOpenAIClient(endpoint, credential)
.GetChatClient("deployment-name")
.AsIChatClient();
// Use with PromptComposer
string enhanced = await PromptComposer.Create()
.AddReasoning()
.GenerateAndEnhanceAsync(openAiClient, "Your prompt");
Target Framework
- .NET 9.0 (
net9.0) - Nullable Reference Types enabled
- Implicit Usings enabled
Dependencies
Core Library:
Markdig0.42.0 - Markdown parsing for AI enhancementMicrosoft.Extensions.AI.Abstractions9.9.1 - AI client abstractionSystem.Collections.Immutable9.0.0 - Immutable collections
Analyzer:
Microsoft.CodeAnalysis.CSharp(Roslyn SDK)Microsoft.CodeAnalysis.Analyzers
Project Structure
PinkRooster.PromptComposer/
├── src/
│ ├── PinkRooster.PromptComposer/ # Core library
│ ├── PinkRooster.PromptComposer.Extensions/ # Extended decorators
│ └── PinkRooster.PromptComposer.Analyzer/ # Roslyn analyzer
├── examples/
│ └── ExampleProject/ # Usage examples
└── tests/ # Unit tests (planned)
Examples
See the examples/ExampleProject for comprehensive usage examples including:
- Basic prompt composition
- AI-enhanced prompt generation
- Custom decorator creation
- Analyzer validation demonstrations
- Complex multi-decorator patterns
Best Practices
1. Start Simple, Enhance Gradually
// Start with minimal decorators
var basic = PromptComposer.Create()
.AddStepByStep()
.Generate("Explain X");
// Add reasoning when needed
var withReasoning = PromptComposer.Create()
.AddStepByStep()
.AddFirstPrinciples()
.Generate("Explain X");
// Full enhancement for complex tasks
var enhanced = PromptComposer.Create()
.AddStepByStep()
.AddFirstPrinciples()
.AddBlindSpots()
.AddConfidence()
.Generate("Explain X");
2. Use Type-Specific Decorators
Match decorators to your use case:
// For code generation
PromptComposer.Create()
.AddCodeGen()
.AddDesignPattern()
.AddTestCases()
.Generate("Create a repository pattern");
// For system design
PromptComposer.Create()
.AddArchitecture()
.AddScalability()
.AddTradeoffs()
.Generate("Design a caching system");
// For debugging
PromptComposer.Create()
.AddRootCauseAnalysis()
.AddDebugStrategy()
.AddErrorDiagnosis()
.Generate("Investigate memory leak");
3. Leverage AI Enhancement
// Use GenerateAndEnhanceAsync for important prompts
string criticalPrompt = await PromptComposer.Create()
.AddStepByStep()
.AddBlindSpots()
.GenerateAndEnhanceAsync(client, "Critical business decision");
// The AI will optimize the prompt structure and clarity
4. Handle Conflicts Proactively
// Pay attention to analyzer warnings
PromptComposer.Create()
.AddDetailed() // Verbose output
// .AddConcise() // Would conflict - don't add
// Use enhancement suggestions
PromptComposer.Create()
.AddStepByStep()
.AddReasoning() // Suggested enhancement
.Generate();
Contributing
Contributions are welcome! Areas for contribution:
- New decorator implementations
- Additional analyzer rules
- Performance optimizations
- Documentation improvements
- Unit test coverage
- Usage examples
License
[Specify your license here]
Acknowledgments
Built with:
- Roslyn for compile-time analysis
- Microsoft.Extensions.AI for AI client abstraction
- Markdig for markdown parsing
- .NET 9.0 for modern C# features
Support
For issues, questions, or feature requests, please open an issue on the project repository.
Version History
Current Version
- 100+ built-in decorators across 6 categories
- 80+ extension decorators across 8 specialized categories
- Compile-time validation with Roslyn analyzer
- AI-powered prompt enhancement
- Comprehensive attribute system for decorator relationships
- Full fluent API with extension methods
PinkRooster.PromptComposer - Compose better AI prompts with confidence.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp (>= 4.3.0)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 4.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.1 | 200 | 10/26/2025 |