speckl/examples
Scott Scoble 02a61f1d33 feat: add PromptOptimizer spec and functional runtime
PromptOptimizer.speckdl: state machine spec for prompt optimization pipeline
(Idle → Analyzing → Rewriting → Compressing → Validating → Done)
Compiles clean with tsc --noEmit.

PromptOptimizer-runtime.ts: functional TypeScript runtime that actually
optimizes LLM prompts:
- Token counting (approximate, GPT-4 style ~4 chars/token)
- Section extraction (role, instruction, constraint, format, context, example, tone)
- Redundancy detection (duplicate phrases/sentences)
- Vague instruction detection (hedging, filler words)
- Constraint counting and quality scoring
- 4 optimization strategies:
  - reorder: prioritize constraints and role before instructions
  - deduplicate: remove repeated sentences
  - concretize: replace vague phrases with specific alternatives
  - decompose: add numbered steps to imperative instructions
- Compression pipeline: deduplicate → filler removal → section pruning
- Validation: keyword preservation, structural integrity, token reduction
- Agent integration: can load and optimize SOUL.md/AGENTS.md files

Demo shows 8% reduction on SOUL.md, 5% on AGENTS.md (both already
well-structured). Higher gains on verbose prompts (13-30% reduction).
2026-05-13 21:14:55 -07:00
..
.gitkeep Initial commit: Speckl project scaffold 2026-04-28 01:20:22 -07:00
AccessControl.speck Add SpeckDL examples with Dark Provenance primitives 2026-04-29 14:44:00 -07:00
AccountLedger.speck fix: add dist-check guard + List<T> type parsing + state machine examples 2026-05-05 03:11:53 -07:00
DrugDosageCalculator.speck Add SpeckDL examples with Dark Provenance primitives 2026-04-29 14:44:00 -07:00
KafkaKRaft.speck feat(z3): zero-error SMT-LIB2 output + BMC verify blocks for KRaft 2026-05-09 23:07:56 -07:00
OAuth2AuthorizationCode.speck feat: OAuth 2.0 authorization code flow with PKCE spec 2026-05-09 21:51:51 -07:00
Paxos.speck refactor: remove WAT/WASM generator (superseded by IR→Rust→WASM path) 2026-05-09 22:03:20 -07:00
PaymentService.speck Add SpeckDL examples with Dark Provenance primitives 2026-04-29 14:44:00 -07:00
PreconditionTest.speck refactor: remove WAT/WASM generator (superseded by IR→Rust→WASM path) 2026-05-09 22:03:20 -07:00
PromptOptimizer-runtime.ts feat: add PromptOptimizer spec and functional runtime 2026-05-13 21:14:55 -07:00
PromptOptimizer.speckdl feat: add PromptOptimizer spec and functional runtime 2026-05-13 21:14:55 -07:00
Raft.speck refactor: remove WAT/WASM generator (superseded by IR→Rust→WASM path) 2026-05-09 22:03:20 -07:00
RetryHandler.speck Add SpeckDL examples with Dark Provenance primitives 2026-04-29 14:44:00 -07:00
SQLitePager.speck fix(z3): robust = conversion + SQLite pager spec (DB.2) 2026-05-10 01:02:00 -07:00
SQLiteWAL.speck TS generator: fix #12 (5 expression patterns) + #11 (opaque record types) 2026-05-11 10:16:15 -07:00
SQLOptimizer-runtime.ts fix: SQL optimizer runtime — predicate pushdown, FROM/JOIN dedup, cost model 2026-05-13 18:06:30 -07:00
SQLOptimizer.speckdl feat: add SQL query optimizer with functional runtime 2026-05-13 17:00:46 -07:00
TemperatureMonitor.speck Add SpeckDL examples with Dark Provenance primitives 2026-04-29 14:44:00 -07:00
TigerBeetleLedger.speck fix: add dist-check guard + List<T> type parsing + state machine examples 2026-05-05 03:11:53 -07:00
ToggleSwitch.speck fix: add dist-check guard + List<T> type parsing + state machine examples 2026-05-05 03:11:53 -07:00
TwoPhaseCommit.speck fix: add dist-check guard + List<T> type parsing + state machine examples 2026-05-05 03:11:53 -07:00