{"id":13437788,"url":"https://github.com/galaxykate/tracery","last_synced_at":"2025-05-14T07:08:26.093Z","repository":{"id":22836174,"uuid":"26183338","full_name":"galaxykate/tracery","owner":"galaxykate","description":"Tracery: a story-grammar generation library for javascript","archived":false,"fork":false,"pushed_at":"2024-11-03T16:46:02.000Z","size":7610,"stargazers_count":2149,"open_issues_count":31,"forks_count":253,"subscribers_count":76,"default_branch":"master","last_synced_at":"2025-04-11T02:51:29.176Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/galaxykate.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.MD","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-04T18:50:39.000Z","updated_at":"2025-04-03T17:25:19.000Z","dependencies_parsed_at":"2024-11-20T07:05:47.327Z","dependency_job_id":null,"html_url":"https://github.com/galaxykate/tracery","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galaxykate%2Ftracery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galaxykate%2Ftracery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galaxykate%2Ftracery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galaxykate%2Ftracery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/galaxykate","download_url":"https://codeload.github.com/galaxykate/tracery/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092776,"owners_count":22013290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T03:01:00.248Z","updated_at":"2025-05-14T07:08:26.071Z","avatar_url":"https://github.com/galaxykate.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Narrative Generation"],"sub_categories":[],"readme":"# Welcome to Tracery!\n\n## A text-expansion library\n\n(Update: Nov 3 2024, everything is moved into Tracery.io because I let the old domains slip 🙃)\n\nHere is the (new location) of the classic [editor](https://tracery.io/archival/brightspiral/tracery/)\n\nAnd the newer [artbot.club version](https://artbot.club) that I keep working on \n\nThere are many new examples of Tracery [in use](https://tracery.io/archival/crystalcodepalace/tracery.html \"Examples\")\n\nI also have an exciting new *interactive* [tutorial](https://tracery.io/archival/crystalcodepalace/tracerytut.html \"Tutorial\")\n\nI strongly recommend using the [minified library](https://github.com/galaxykate/tracery/blob/master/js/tracery.min.js \"Minified\")\n\n### Write grammar objects, get generative stories\n\n#### An example grammar\n```\n{\n\t\"name\": [\"Arjun\",\"Yuuma\",\"Darcy\",\"Mia\",\"Chiaki\",\"Izzi\",\"Azra\",\"Lina\"],\n\t\"animal\": [\"unicorn\",\"raven\",\"sparrow\",\"scorpion\",\"coyote\",\"eagle\",\"owl\",\"lizard\",\"zebra\",\"duck\",\"kitten\"],\n\t\"mood\": [\"vexed\",\"indignant\",\"impassioned\",\"wistful\",\"astute\",\"courteous\"],\n\t\"story\": [\"#hero# traveled with her pet #heroPet#.  #hero# was never #mood#, for the #heroPet# was always too #mood#.\"],\n\t\"origin\": [\"#[hero:#name#][heroPet:#animal#]story#\"]\n}\n```\n\n#### Output of that grammar.\nOf course, many grammars are more complex!\n```\nLina traveled with her pet duck. Lina was never indignant, for the duck was always too indignant.\nYuuma traveled with her pet unicorn. Yuuma was never wistful, for the unicorn was always too indignant.\nAzra traveled with her pet coyote. Azra was never wistful, for the coyote was always too impassioned.\nYuuma traveled with her pet owl. Yuuma was never wistful, for the owl was always too courteous.\nAzra traveled with her pet zebra. Azra was never impassioned, for the zebra was always too astute.\n```\n\n### How to use Tracery as a broswer library\n\nImport tracery\n`\u003cscript defer src=\"js/libs/tracery.js\"\u003e\u003c/script\u003e`\n\nUse the `tracery` object to create a `Grammar` object from a source object (specification below)\n`tracery.createGrammar(spellbook);`\n\nThe grammar can create `Trace` objects.  A `Trace` is one possible expansion of a grammar.\n`var trace = app.grammar.createTrace();`\n\nThe trace can be expanded into a tree structure, step by step, or all at once.\n`trace.expand();`\nOnce expanded, the trace can create a 'flattened' version of itself: a single string of text.\nvar myString = trace.flatten();\n\nOr the grammar can generate a trace and flatten it, all in one step\n`var myTitle = app.grammar.createFlattened()`\n\nTraces will start their expansions with the 'origin' symbol by default, but you can also create one from a rule (see \"Rule Syntax\" below), or from a symbol\n`var trace = app.grammar.createTrace(\"A story about #character#\");`\n`var trace = app.grammar.createTraceFromSymbol(\"bookTitle\");`\n\nMany traces can be working on a single grammar at the same time, without getting in each others way.\n\n### How to use Tracery as a Node.js library\n\nUse this Node library created by George Buckenham: https://github.com/v21/tracery\n\n## Input\n\n### Syntax overview\n####  Grammar\nA grammar is a key-value storage system for rules.\n\n####  Rule syntax\nEach symbol should be followed by an array of text strings representing rules\n```\n  \"emotion\" : [\"happy\", \"sad\", \"proud\"],\n```\nor, if you're writing a long string of single words, you can use 'split'\n```\n  \"emotion\" : \"happy sad reflective morose proud\".split(\" \"),\n```\n\nRules can also contain expansion symbols, words surrounded by #'s:\n```\nmainCharacter: [\"Brittany the Wombat\"],\nstory : [\"This is a story about #mainCharacter#\"]\n```\n\nExpansion symbols can have modifiers.  Modifiers can change something about the string expansion of that symbol.\n `#animal.capitalize#` or `#animal.a#` or `#animal.s#`\n```\nname: [\"Brittany\"],\nanimal: [\"wombat\"],\nstory : [\"This is a story about #name# the #animal.capitalize#\"]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgalaxykate%2Ftracery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgalaxykate%2Ftracery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgalaxykate%2Ftracery/lists"}