What is Spw?

Spw (pronounced “swoop”) is a position-agnostic symbolic grammar designed to formalize and modularize AI prompts. Core atoms (?,!,~,&,@,#,^,.) combine with operators (->, =>, |, merge, diff) and brace-first containers (() stage, [] state, {} config, <> preview).

Optional: a “photonic whitespace” model for phase-weighted layout. Default docs emphasize brace-first for clarity.

Backtick references `pkg://ui/card` resolve to modules/assets; labels/roles remain stable even when you swap operators or move them to end-of-line (postfix/EOL) and normalize back to prefix.

Component Registry extract & extend

Each card advertises a stable data-component-id for tooling to scrape/export. Use these as patterns for UI composition or editor add-ons.

UI • Base Card

^module[ui.base.card.v1]{
  props{title,subtitle,tags[]}
  theme{ bg:#linen border:#brass text:#ink radius:16 }
  a11y{ role:"region", heading.level:=2 }
}

UI • Button

^module[ui.base.button.v1]{
  props{label,icon?,intent:=#primary,size:=#md}
  theme{ radius:16 focus:WCAG_AAA }
}

Flow Simulation

^module[flow.sim.v1]{
  graph{ nodes:@actors|^anchors ; edges:ops(->,&,|,!) }
  simulate(step.ms:=33){ propagate; respect {} invariants ; draw<> }
  export{ .mermaid .dot .json }
}

Library ./lib

Loads external Spw scripts from ./lib/. Edit ./lib/prompts.json to add more.

Schema tokens (from ./lib/schemas.json)
{}

Manifests & Feeds

Crawlable JSON endpoints used by the playground and branch pages.

cURL examples
curl -s https://spw.quest/lib/schemas.json | jq .
curl -s https://spw.quest/lib/prompts.json | jq .
curl -s https://spw.quest/lib/operators.json | jq .

Seed Prompt

Quick-copy seeds or fetch the JSON blob below.

Core

^prompt[spw.seed.core]{
  purpose:"Introduce Spw and enforce clarity",
  style:{structure:"Goal | Ingredients | Steps | Result"},
  syntax:{atoms:"./lib/schemas.json",root:"^"},
  guidelines:[
    clarify_only_if(ambiguity),
    flag{consent,accessibility,eco},
    forks{6mo,2yr,5yr}
  ]
}

ai.media

^prompt[spw.seed.ai.media]{
  imports:^prompt[spw.seed.core],
  module:"image/video/audio",
  defaults{?model:"Midjourney v7",aspect:16:9,quality:"high"}
}

ai.research

^prompt[spw.seed.ai.research]{
  imports:^prompt[spw.seed.core],
  module:"lit-review,data-analysis",
  checklist &[
    search_lit, extract_citations, generate_summary
  ]
}

Master Seed

^prompt[spw.seed.master]{
  modules:[
    ^prompt[spw.seed.core],
    ^prompt[spw.seed.ai.media],
    ^prompt[spw.seed.ai.research]
  ],
  boot!:true
}

Operator Reference

? ! ~ & @ # ^ . ( ) [ ] { } < > : | -> => = merge diff
⟶ ⟺ ⟡  //  /* meta:key=val */  `pkg://ui/card`

Tip: many unary operators may appear at end-of-line (postfix/EOL). The evaluator normalizes them to prefix on the preceding closed brace scope.

Operator Index

Canonical map of operators: ascii/utf8, name, arity, fixity, precedence, associativity, and normalization policy.

^index[operators.v2]{
  // unary (prefix or EOL-postfix)
  op["?"]{ name:"query",   arity:1, fixity:["prefix","postfix:eol"], assoc:"right", precedence:90 }
  op["!"]{ name:"imperative",arity:1, fixity:["prefix","postfix:eol"], assoc:"right", precedence:90 }
  op["~"]{ name:"approx",  arity:1, fixity:["prefix","postfix:eol"], assoc:"right", precedence:85 }

  // binary (infix or EOL-postfix-as-curried); no forbids
  op["&"] { name:"bind",   arity:2, fixity:["infix","postfix:eol:curried"], assoc:"left",  precedence:70, curry{enabled:true,dir:"left"} }
  op["|"] { name:"pipe",   arity:2, fixity:["infix","postfix:eol:curried"], assoc:"left",  precedence:60, curry{enabled:true,dir:"left"} }
  op["->"]{ name:"route",  arity:2, fixity:["infix","postfix:eol:curried"], assoc:"right", precedence:55, utf8:"⟶", curry{enabled:true,dir:"left"} }
  op["=>"]{ name:"mapto",  arity:2, fixity:["infix","postfix:eol:curried"], assoc:"right", precedence:55, utf8:"⟹", curry{enabled:true,dir:"left"} }
  op["="] { name:"assign", arity:2, fixity:["infix","postfix:eol:curried"], assoc:"right", precedence:50, curry{enabled:true,dir:"left"} }
  op["merge"]{name:"merge",arity:"2+",fixity:["infix","postfix:eol:curried"],assoc:"left", precedence:45, curry{enabled:true,dir:"left"} }
  op["diff"] {name:"diff", arity:2, fixity:["infix","postfix:eol:curried"],assoc:"left",  precedence:45, curry{enabled:true,dir:"left"} }

  comment["//"]  { class:"sequence_fence", lowers_to:"|", note:"A // B ≡ (A) | (B)" }
  comment["/* */"]{ class:"docblock", materialize:"{meta}" }
}

Policy: brace-first → operator normalization (EOL→prefix) → precedence/assoc. Binary ops are not permitted as postfix.

Fixity & Normalization Rules

Rules

^rules[fixity.v2]{
  order: "braces → runtime.normalize → precedence"
  runtime.normalize: profile("@runtime.fixity") // selected at runtime

  // Reference behaviors (implementations may differ)
  profiles{
    none{}  // accept accept author intent; no rewrites

    eol_to_prefix{
      // unary: EOL-postfix normalizes to prefix on nearest closed scope
      "(X) !" ≡ "! (X)"; "[S] ?" ≡ "? [S]"; "{C} ~" ≡ "~ {C}"
    }

    curry_postfix{
      // binary: EOL-postfix becomes a curried form awaiting the right arg
      "(A) ->"   ≡ "-> (A) _"
      "{C} ="    ≡ "= {C} _"
      "[S] |"    ≡ "| [S] _"
    }

    prefix_to_eol{
      // presentation variant for display-only toggles
      "! (X)" ≡ "(X) !"
    }
  }
}

Precedence (excerpt)

^precedence{
  highest:[?,!,~]  // unary
  high:[&]         // bind
  mid:[|]          // pipe
  low:[->,=>,=]    // routing/assign
  lower:[merge,diff]
}

LLM System Card

Use this when spw.quest itself is your prompt. It communicates design goals and operator mobility.

^prompt[spw.quest.system]{
  role:"system",
  design_goals:["brace-first","operator-mobility","backtick-atomic","WCAG-first","energy-aware"],
  operator_index:"./lib/operators.json",
  evaluate:{
    normalize:"@runtime.fixity.normalize",       // e.g., ["curry_postfix","eol_to_prefix"]
    curry_profile:"@runtime.fixity.profile",      // e.g., "left_curry"
    placeholder:"_" , preserve_backticks:true, docblock:"/*…*/→{meta}"
  },
  instructions:[
    "No forbidden postfix. Treat binary EOL-postfix as a curried function per runtime.",
    "When ambiguous, defer to runtime profile rather than hard-coded rules.",
    "Keep labels/roles stable across operator position changes."
  ]
}

Comments & Sequence

// sequence fence: A then B
A // B   ≡   (A) | (B)

/* doc:locked, credit:@spwashi, alt:"Specimen" */
^scene{ meta{doc:"locked",credit:"@spwashi",alt:"Specimen"} }

Module & Asset URIs

scheme://mount/path :selector #tag ?q=val
fs://src/ui/ui :theme
pkg://ui/src/button :render
@icons/bell.svg        // alias → pkg://assets/icons/bell.svg
`pkg://ui/src/card`    // backtick ref (clickable in editors)

Spw STL Ethos mutable

Physics Quick-Start

Brace-First

^parser[physics]{ order:"braces→operators→types", strict:true }
() stage.ephemeral   [] state.mode   {} config.canonical   <> preview.speculative

Whitespace (optional)

^physics[whitespace]{ phase_per_space:"π/8", newline:"reset" }

Emergent Metaphysics & Ecological Exploration

Speculative modules to model attention, agency, and ecological constraints in prompts.

Attentional Field

^module[attention.field.v1]{
  ~budget{ focus.ms:=800, breadth:=3 }
  bias{ #gift:+2, #quarantine:-3 }
  spell.focus(seed){ () recenter ; [] persist ; <> explore ; {} lock:on }
}

Eco Budget

^module[eco.budget.v1]{
  energy{ tokens:=1024, latency.ms:=500, cache:true }
  policy{ WCAG:"AA", consent:"opt-in", reuse:"prefer" }
  gate{ if usage>budget -> ?review -> !throttle }
}

Metaphor Layer

^module[metaphor.layer.v1]{
  map{ !:spark  ?:gate  &:clasp  ^:keystone  .:lens  @:badge  #:stamp }
  speak(card){ () brisk ; [] steady ; {} formal ; <> tentative }
}

Utility Map

Goal | map Spw utility across domains → copy-paste seeds you can adapt fast.

  1. Prompt eng: atoms (? ! ~ &) + braces → clear IO, constraints, tests.
  2. Cognitive scaffolding: ladders, tags, trails → staged recall + transfer.
  3. Scene design: cast+space+time as typed slots; previews <> for fast iteration.
  4. Event description: timelines, diffs, invariants; replayable “why”.
  5. Game design: entities, state charts, quests; reward/value piping.
  6. Modern tech: stable URIs, JSON-LD mirrors, CRDT-safe merge/diff.
  7. Linking/tagging/breadcrumbs: `spw://` refs, @tags, ^trail for sense-making.
  8. Quantum language: superposition→collapse semantics; entanglement via &.
  9. Crystalline design: lattice templates; facets = reusable views.
^utility.map[@meta{author:spwashi, date:2025-08-27, v:0.2}]{

  .prompt.engineering =
    ^prompt[goal|context|constraints|io]
      (?ask) (~tone:warm) {tests:`spec://unit/1`} -> => (!deliver);

  .cognitive.scaffold =
    ^ladder[(recall)->(apply)->(transfer)] @tags[spaced, multimodal]
    ^trail[spw.quest > atoms > braces > flows];

  .scene.design =
    ^scene[who:Actor, where:Dock, when:Dawn, mood:mythic, props:[mirror, letter]]
      <>preview("fog + gulls + unanswered questions");

  .event.description =
    ^event[timeline{
      t0: state[], t1: diff{mirror:=“forget-hint”}, t2: merge{Actor&Letter}
    }] ^axioms[no-violence, consent];

  .game.design =
    ^entity[Courier]{stats[focus:3, nerve:2]}
    ^statechart[(Idle)->(Route)->(Deliver)->(Reflect)]
    ^quest["Only deliver unanswered questions"] => ^value[insight:+1];

  .modern.tech =
    `spw://lore.land/scene/boon/001` #hash(sha256)
    {jsonld:`schema://CreativeWork`} (crdt.safe: merge|diff);

  .link.tag.breadcrumbs =
    @topic[boonhonk, pedagogy] ^trail[boon.land > pier > letters];

  .quantum.language =
    ^superposition[reply:{A:"joke", B:"poem"}; ψ{A:.3,B:.7}] !measure => "poem"
    &entangle(Actor,Mirror){state:reflective};

  .crystalline.design =
    ^lattice[12-col grid] ^facet[card.scene]{slots[title, mood, actions]}
    ^cleave[rules{AA contrast, reduced-motion}] ^dope[palette:teal/cream].
}

Result | portable seeds for prompts, pedagogy, scenes, events, games, and systems—WCAG/consent-aware, CRDT-friendly.

Micro-exercise | swap any block into your current repo and note one Δ it reduces (ambiguity, drift, or toil).

Domain Key Spw Features Benefits (Reduces Δ: Ambiguity, Drift, Toil)
1. Prompt Engineering Atoms (`? ! ~ &`), braces for IO/constraints/tests, chaining (`-> =>`) Clear structure for queries/actions; testable seeds minimize prompt drift.
2. Cognitive Scaffolding Ladders (`[(...)->(...)]`), tags (`@tags[]`), trails (`^trail[...]`) Staged recall/transfer; tagged paths reduce cognitive toil in knowledge navigation.
3. Scene Design Typed slots (e.g., `who:Actor`), previews (`<>preview(...)`) Fast iteration on elements; previews cut ambiguity in visualizations.
4. Event Description Timelines (`timeline{ t0: ..., t1: diff{...} }`), axioms (`^axioms[...]`) Replayable diffs/invariants; ensures "why" traceability, reducing event drift.
5. Game Design Entities (`^entity{...}`), statecharts (`^statechart[(...)->(...)]`), quests (`^quest[...] => ^value[...]`) Piping rewards/values; modular entities lower design toil.
6. Modern Tech URIs (`spw://...`), JSON-LD mirrors (`{jsonld:...}`), CRDT ops (`merge|diff`) Stable refs and safe merging; tech integration without format ambiguity.
7. Linking/Tagging/Breadcrumbs Refs (`spw://`), `@topic[]`, `^trail[...]` Sense-making trails; breadcrumbs prevent navigation drift.
8. Quantum Language Superposition (`^superposition[...]; ψ{...} !measure`), entanglement (`&entangle(...)`) Collapse semantics for probabilistic prompts; linked states reduce quantum-like ambiguity.
9. Crystalline Design Lattices (`^lattice[...]`), facets (`^facet{...}`), cleave/dope (`^cleave[...] ^dope[...]`) Reusable views with WCAG rules; lattice templates minimize UI toil.

Copyboards multi-select

Select blocks and copy them as one gist—great for pasting into chats or repos.

JS Wonder Lab

Try file/URL ingestion, share prompts, and export components. Drag-and-drop files anywhere on the page, or use the buttons below.

Hint: hold Shift while dropping files to append instead of replace.

Maintenance & Design Rhythms

Design Tokens (excerpt)
:root{
  --accent:#194563; --surface:#eef6fa; --radius:16px; --gap:1.5rem;
  --shadow:0 2px 8px rgba(0,0,0,.08);
}

Roadmap

  1. Operator-aware autocomplete (& snippets) in playground.
  2. Flow sim view: render .mermaid and .dot exports inline.
  3. AR conlang adapter: gesture→operator mapping demo.
  4. Seed packer: export .spwpack (manifest + assets).

Changelog

2025-08-27 • Utility Map Integration

Added Utility Map section with domain mappings, portable seeds, and syntax examples.

2025-08-19 • Operator Index + LLM Card

Added first-class Operator Index, fixity rules, and a copyable LLM System Card. Wired toolbar to operators.json.

Prompt Playground

AST (lightweight demo)

{}

Counts braces, lists ^anchors, #tags, @roles, and operator set. For learning only.

Notes

  • Backtick refs `pkg://…` are treated as atomic tokens.
  • // enforces sequencing; /*…*/ can materialize into {meta}.
  • Operator mobility keeps labels/durability intact.