{"id":24976752,"url":"https://github.com/whaaaley/cynthia","last_synced_at":"2025-03-29T08:22:16.926Z","repository":{"id":275394557,"uuid":"925957413","full_name":"whaaaley/cynthia","owner":"whaaaley","description":"A proof of concept code synthesis command line tool.","archived":false,"fork":false,"pushed_at":"2025-02-02T07:11:36.000Z","size":49,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T08:18:11.893Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whaaaley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2025-02-02T07:02:06.000Z","updated_at":"2025-02-02T07:22:12.000Z","dependencies_parsed_at":"2025-02-02T08:18:13.865Z","dependency_job_id":"6b6446e7-dea0-442b-814e-9e6d79afec40","html_url":"https://github.com/whaaaley/cynthia","commit_stats":null,"previous_names":["whaaaley/cynthia"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whaaaley%2Fcynthia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whaaaley%2Fcynthia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whaaaley%2Fcynthia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whaaaley%2Fcynthia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whaaaley","download_url":"https://codeload.github.com/whaaaley/cynthia/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246157610,"owners_count":20732645,"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":"2025-02-03T22:54:19.171Z","updated_at":"2025-03-29T08:22:16.903Z","avatar_url":"https://github.com/whaaaley.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cynthia\n\nA proof of concept code synthesis command line tool.\n\n## Roadmap\n\n- [ ] Benchmarks and performance thresholds\n- [ ] Rollbacks\n- [ ] Status command\n- [ ] Add more models + DeepSeek R1 by default\n- [ ] Add Go language support\n- [ ] Personalization\n- [ ] Prompt user to generate initial tests\n\n## Why?\n\nIf you're going to have an LLM write your project, you should at least do it in a constrained environment.\n\nUsing Cynthia is like writing unit tests... but without implementing anything to test. Your \"tests\" both generate code that satisfies the test suite and verify the generated code works.\n\n## How do generations work?\n\nJust like database migrations!\n\n1. Create a `.cynthia` dir, or do this yourself with `mkdir -p`\n\n```sh\ncyn init\n```\n\n1. Create a `.cyn.ts` file: (cyn - pronounced \"sin\" /sɪn/)\n\n```sh\ncyn create apple-bottom-jeans\n```\n\nThis creates `apple-bottom-jeans.cyn.ts` in the CWD with a starter template.\n\n1. Write your synthetic function using BDD-style tests.\n\nWhat does this function do? No idea! That's Cynthia's job.*\n\n```ts\nimport { createTestSuites, runTestSuites } from 'cynthia'\nimport testFn from './hello-world.ts' // This will be generated for you later, you still need to import it though\n\nconst t = createTestSuites()\n\nt.describe('Fruit Tests', () =\u003e {\n  t.it('should identify an apple as a fruit', () =\u003e {\n    const input = ['apple']\n    t.expect(input).toBe('fruit')\n  })\n\n  t.it('should not identify a carrot as a fruit', () =\u003e {\n    const input = ['carrot']\n    t.expect(input).not.toBe('fruit')\n  })\n\n  t.it('should match fruit object properties', () =\u003e {\n    const input = { name: 'apple', type: 'fruit', color: 'red' }\n    t.expect(input).toMatchObject({\n      type: 'fruit',\n      color: 'red',\n    })\n  })\n\n  t.it('should not match vegetable object properties', () =\u003e {\n    const input = { name: 'apple', type: 'fruit', color: 'red' }\n    t.expect(input).not.toMatchObject({\n      type: 'vegetable',\n      color: 'orange',\n    })\n  })\n})\n\nrunTestSuites(t.getState(), testFn)\n\nexport default t.getState()\n```\n\n1. Generate your synthetic function.\n\nEnsure that you have your `OPEN_API_KEY` in your environment. The model is `gpt-4o-mini` and it's currently not configurable.\n\n```sh\ncyn gen apple-bottom-jeans.cyn.ts\n```\n\nWait while your function is generated and tested. On success, you'll get:\n\n- `apple-bottom-jeans.ts` next to your `.cyn.ts` file\n- `1738397981482-apple-bottom-jeans.gen.ts` in your `.cynthia` directory\n\nThe `.gen.ts` file contains the LLM output while the `.ts` file is just an export of the `.gen.ts` file's default export, allowing easy rollbacks when you forget test cases or the LLM gets creative.\n\n1. ~~Pray~~ Use your synthetic code.*\n\n```ts\nimport appleBottomJeans from './apple-bottom-jeans.ts'\n\nconsole.log(appleBottomJeans(['apple']))\n// =\u003e 'fruit'\n```\n\n## Installation\n\nComplete transparency here; I don't know how to develop command line tools in Deno yet. But you can get this working by cloning the repo and running `deno task link`. This will create a symlink from `cyn.sh` to `~/.deno/bin/cyn`. Then you\nshould be able to use all `cyn` commands anywhere.\n\n## FAQ\n\n### Help! I can't get my tests to pass!\n\nYou and me both.\n\n### What if I write an impossible test?\n\nAll hope is lost.*\n\n### How to contribute\n\nFeel free.\n\n### How do I know if Cynthia is right for me?*\n\n![img](flow-chart.png)\n\n### Should I actually use this?\n\nProbably not.*\n\n## Warning from the Author*\n\nWhile there are merits to using AI for debugging, you should never rely purely on unit tests for code generation. When the code breaks, and it _will_ break, if you don't understand how the code works you won't know what test cases to add or\nupdate to fix the broken generation. Additionally, if you don't even know what you want, neither will the system.\n\nUsing LLMs to write code is extremely fragile. I created this project as an attempt to bring some sanity and structure back into the world for all you LLM ~~sinners~~ _developers_ out there. We both know you're not going to stop using LLMs\nany time soon. Now, if you use Cynthia, you have at least _some_ unit tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhaaaley%2Fcynthia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhaaaley%2Fcynthia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhaaaley%2Fcynthia/lists"}