Skip to content

fable-retold/pict-section-prompteditor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pict-section-prompteditor

Read the Pict-Section-PromptEditor Documentation - interactive docs with the full API reference and a runnable example.

A prompt crafting and management section for the Pict ecosystem. Prompts are markdown organized by type into segments, word list matrices with weights drive a {~WordListEntry:Name~} template expression, and one crafted prompt generates endless concrete variants you can browse and download as a zip.

MIT License

Features

  • Typed prompts with markdown segments (Context / Request / Success Criteria and friends), plus fixed preamble segments for locked team standards
  • A per-prompt "segment headings in the output" toggle, saved with the prompt: on for structured documents (## Context above each block), off for bare bodies
  • Weighted word list matrices: [["Tyrannosaurus", 3], ["Diplodocus", 1]] draws 75/25, with live share percentages as you curate
  • The {~WordListEntry:Name~} template expression (short form {~WLE:~}), with an optional miss default: {~WLE:Name:fallback~}
  • Generation runs the real pict template engine, so every pict expression works inside a prompt
  • Inline preview with reroll, Formatted / Markdown toggle, and a copy button
  • Batch generation with provenance, browsed in file order, downloaded as a zip of <slug>-<sequence>.md files
  • Pluggable data backplane: in-memory by default, one PromptDataProvider class to back it with your API
  • Opaque Meta, Author stamping, stable keys, and mutation hooks: the seams a host platform layers ratings and collaboration onto
  • Resizable, collapsible list rail (a pict-section-modal panel) and a searchable insert control (pict-section-picker)
  • Rich segment editing via pict-section-markdowneditor in a modal when CodeMirror is available; plain textareas otherwise

Installation

npm install pict-section-prompteditor

Quick Start

const libPromptEditor = require('pict-section-prompteditor');

pict.addView('PromptEditor', Object.assign({}, libPromptEditor.default_configuration,
{
	DefaultDestinationAddress: '#My-Container',
	Title: 'Team Prompt Workshop',
	CurrentUser: { Key: 42, Name: 'Steven' }
}), libPromptEditor);

let tmpEditor = pict.views['PromptEditor'];
tmpEditor.render();

// Seed through the provider (in-memory by default), then reload the section.
tmpEditor._provider.createWordList(
	{ Name: 'Dinosaurs', Entries: [['Tyrannosaurus', 3], ['Diplodocus', 1]] })
	.then(() => tmpEditor.load());

The section renders three tabs: Prompts (the editor), Word Lists (the matrices), and Generated (the browseable output with a zip download). Write {~WordListEntry:Dinosaurs~} in any segment and each generation draws Tyrannosaurus 75% of the time.

To back it with your own API instead of memory, implement the twelve-method PromptDataProvider contract and pass it as DataProvider -- the in-memory provider is the reference implementation.

Documentation

Full documentation is available in the docs/ directory and hosted at fable-retold.github.io/pict-section-prompteditor:

Example Applications

Example Description
Prompt Workshop The full section in memory: seeded word lists and prompts, inline preview with reroll, batch generation, zip download

Build it:

cd example_applications/prompt_workshop
npm install
npx quack build && npx quack copy
# serve dist/ and open index.html — or `npm run example` from the module root

API Overview

Export Description
(default) / default_configuration The section view class and its full default options
PromptDataProvider The data contract a host implements
InMemoryPromptProvider The default provider; deterministic via Now / KeyGenerator options
DefaultPromptTypes / resolvePromptTypes / getPromptType The built-in prompt types and their resolution helpers
PromptCompiler assembleSource, generate, wordListMap, slug, generatedFileName
PromptZip buildZip, downloadBlob
PictTemplateWordListEntry / weightedPick The template expression class and the weighted draw
normalizeEntries Word list entry normalization

View instance methods hosts call: load(), refresh(), setReadOnly(bool), setDataProvider(provider) -- plus every UI action as a drivable method. See Developer Functions for snippets.

Testing

npm test

Fifty-seven mocha tests cover the provider contract, the weighted draw and expression, the compiler, zip round-trips, and the view (including focus-preserving edits and multi-instance isolation).

Related Packages

License

MIT

Contributing

Pull requests are welcome. For major changes, please open an issue first.

About

Prompt crafting and management section for Pict: typed markdown prompts, weighted word list matrices, a {~WordListEntry:~} expression for weighted-random generation, and zip export. In-memory by default behind a pluggable data provider.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors