{"id":13493196,"url":"https://github.com/jasonjmcghee/plock","last_synced_at":"2025-04-05T04:11:51.046Z","repository":{"id":218427362,"uuid":"746380110","full_name":"jasonjmcghee/plock","owner":"jasonjmcghee","description":"From anywhere you can type, query and stream the output of an LLM or any other script","archived":false,"fork":false,"pushed_at":"2024-04-12T17:19:05.000Z","size":1011,"stargazers_count":491,"open_issues_count":8,"forks_count":29,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-29T03:09:22.688Z","etag":null,"topics":["bash","command","context","cross-platform","gpt","llm","local","ollama","shell","streaming","tool","utility"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jasonjmcghee.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":"2024-01-21T21:45:35.000Z","updated_at":"2025-03-24T06:21:09.000Z","dependencies_parsed_at":"2024-01-21T22:20:21.638Z","dependency_job_id":"d9344cdf-c06f-442b-9558-fbca7f8627cb","html_url":"https://github.com/jasonjmcghee/plock","commit_stats":{"total_commits":76,"total_committers":3,"mean_commits":"25.333333333333332","dds":"0.11842105263157898","last_synced_commit":"210e3e274a18c0653446df454fd6901beeac82ca"},"previous_names":["jasonjmcghee/plock"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonjmcghee%2Fplock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonjmcghee%2Fplock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonjmcghee%2Fplock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonjmcghee%2Fplock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jasonjmcghee","download_url":"https://codeload.github.com/jasonjmcghee/plock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284951,"owners_count":20913704,"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":["bash","command","context","cross-platform","gpt","llm","local","ollama","shell","streaming","tool","utility"],"created_at":"2024-07-31T19:01:13.114Z","updated_at":"2025-04-05T04:11:51.027Z","avatar_url":"https://github.com/jasonjmcghee.png","language":"Rust","funding_links":[],"categories":["Rust","bash"],"sub_categories":[],"readme":"# Plock\n\nUse an LLM (or anything else that can stream to stdout) directly from literally anywhere you can type. Outputs in real\ntime.\n\n![demo](https://github.com/jasonjmcghee/plock/assets/1522149/737cb647-69aa-426c-884d-bbe29bac0637)\n\nWrite a prompt, select it, and (by default) hit `Cmd+Shift+.`. It will replace your prompt with the output in a\nstreaming fashion.\n\nAlso! You can first put something on your clipboard (as in copy some text) before writing / selecting your prompt, and\nit (by default) `Cmd+Shift+/` and it will use the copied text as context to answer your prompt.\n\nFor Linux, use `Ctrl` instead of `Cmd`.\n\n**100% Local** by default. (If you want to use an API or something, you can call any shell script you want specified\nin `settings.json`)\n\nI show an example `settings.json` in [Settings](#settings)\n\n---\n\n## 🚨 Looking for contributions / help! 🚨\nI would love to keep this project alive and growing, but can't do it alone.\n\nIf you're at all interested in contributing, please feel free to reach out, start a discussion, open a PR, look at issues, look at roadmap below, etc.\n\nSomething not working properly? There's no telemtry or tracking, so I won't know! Please log an issue or take a crack at fixing it yourself and\nsubmitting a PR! Have feature ideas? Log an issue!\n\n---\n\n\n## Demo showing concept of Triggers, and the new flexible system\n\n\u003ca href=\"https://www.loom.com/share/d3adddc37c2e4c8daeef11255c0135ea\"\u003e\n  \u003cimg style=\"max-width:300px;\" src=\"https://cdn.loom.com/sessions/thumbnails/d3adddc37c2e4c8daeef11255c0135ea-with-play.gif\"\u003e\n\u003c/a\u003e\n\n## Demo using GPT-3.5 and GPT-4\n\n\u003ca href=\"https://www.loom.com/share/756220f3f5e249d5b4d5b759e9f9add3\"\u003e\n  \u003cimg style=\"max-width:300px;\" src=\"https://cdn.loom.com/sessions/thumbnails/756220f3f5e249d5b4d5b759e9f9add3-with-play.gif\"\u003e\n\u003c/a\u003e\n\nIf you are going to use this with remote APIs, consider environment variables for your API keys... make sure they exist\nwherever you launch, or directly embed them (just don't push that code anywhere)\n\n## (Original) Demo using Ollama\n\n\u003ca href=\"https://www.loom.com/share/fed267e695d145c88e6bff7e631da8e0\"\u003e\n  \u003cimg style=\"max-width:300px;\" src=\"https://cdn.loom.com/sessions/thumbnails/fed267e695d145c88e6bff7e631da8e0-with-play.gif\"\u003e\n\u003c/a\u003e\n\n(in the video I mention [rem](https://github.com/jasonjmcghee/rem), another project I'm working on)\n\n## Getting Started\n\nInstall [ollama](https://github.com/jmorganca/ollama) and make sure to run `ollama pull openhermes2.5-mistral` or swap\nit out in settings for something else.\n\nLaunch \"plock\"\n\nShortcuts:\n\n`Ctrl / Cmd + Shift + .`: Replace the selected text with the output of the model.\n\n`Ctrl / Cmd + Shift + /`: Feed whatever is on your clipboard as \"context\" and the replace the selected text with the\noutput of the model.\n\n(these two are customizable in `settings.json`)\n\n`Escape`: Stop any streaming output\n\n**Mac** will request access to keyboard accessibility.\n\n**Linux** (untested), may require X11 libs for clipboard stuff and key simulation using\nenigo. [Helpful instructions](https://github.com/enigo-rs/enigo/tree/main#runtime-dependencies)\n\nAlso [system tray icons require some extras](https://tauri.app/v1/guides/features/system-tray/#linux-setup)\n\n**Windows** (untested), you'll need to swap out Ollama for something else, as it doesn't support windows yet.\n\n## [Settings]\n\nThere is a `settings.json` file which you can edit to change shortcuts, the model,\nprompts, whether to use shell scripts and what they are, and other settings.\n\nAfter updating, click the tray icon and select \"Load Settings\" or restart it.\n\nAt any time you can click the tray icon and it will list the settings location. For what it's worth:\n\nOn mac, It's at `~/Library/Application Support/today.jason.plock/settings.json`.\n\nOn linux, I think it's `~/$XDG_DATA_HOME/today.jason.plock/settings.json`.\n\nWindows, I think it's `~\\AppData\\Local\\today.jason.plock\\settings.json`\n\nBut clicking the icon is the best way.\n\nCorrect me if any of these are wrong.\n\n### Using Settings\n\nTake a look at the shortcut keys. A “trigger” can be started with a shortcut. That points to a process (by an 0-index) and a prompt (by a 0-index) to the lists defined in the processes and prompts fields.\n\na process is either “ollama” or a command (shell on mac). You can use that to call your script.\n\nprompts can use one of the two built in variables $CLIPBOARD and $SELECTION, or any others you define using set_env_var trigger.\n\nnext_steps defines what happens to the output, which can be written to the screen (streaming or all at once ), saved to a variable, and/or kick off another trigger.\n\nIn the future i want to make it easy to trigger flexibly (cron, push), output wherever / however, easily chain things together.\n\nvery very open to feedback\n\n\u003cdetails\u003e\n  \u003csummary\u003eShow Example\u003c/summary\u003e\n\n```json\n{\n  \"environment\": {\n    \"PERPLEXITY_API\": \"\",\n    \"OLLAMA_MODEL\": \"openhermes2.5-mistral\",\n    \"OPENAI_API\": \"\"\n  },\n  \"processes\": [\n    {\n      \"name\": \"Use GPT\",\n      \"command\": [\n        \"bash\",\n        \"/Users/jason/workspace/plock/scripts/gpt.sh\"\n      ]\n    },\n    {\n      \"name\": \"Execute text directly as script\",\n      \"command\": []\n    },\n    {\n      \"name\": \"Use perplexity\",\n      \"command\": [\n        \"bash\",\n        \"/Users/jason/workspace/plock/scripts/p.sh\"\n      ]\n    },\n    {\n      \"name\": \"Use Dall-E\",\n      \"command\": [\n        \"bash\",\n        \"/Users/jason/workspace/plock/scripts/dalle.sh\"\n      ]\n    },\n    \"ollama\"\n  ],\n  \"prompts\": [\n    {\n      \"name\": \"default basic\",\n      \"prompt\": \"$SELECTION\"\n    },\n    {\n      \"name\": \"default with context\",\n      \"prompt\": \"I will ask you to do something. Below is some extra context to help do what I ask. --------- $CLIPBOARD --------- Given the above context, please, $SELECTION. DO NOT OUTPUT ANYTHING ELSE.\"\n    },\n    {\n      \"name\": \"step\",\n      \"prompt\": \"$STEP\"\n    },\n    {\n      \"name\": \"say gpt\",\n      \"prompt\": \"say \\\"$GPT\\\"\"\n    }\n  ],\n  \"triggers\": [\n    {\n      \"trigger_with_shortcut\": \"Command+Shift+,\",\n      \"process\": 1,\n      \"prompt\": 0,\n      \"next_steps\": [\n        {\n          \"store_as_env_var\": \"STEP\"\n        },\n        {\n          \"trigger\": 4\n        }\n      ],\n      \"selection_action\": null\n    },\n    {\n      \"trigger_with_shortcut\": \"Command+Shift+.\",\n      \"process\": 0,\n      \"prompt\": 0,\n      \"next_steps\": [\n        \"stream_text_to_screen\"\n      ],\n      \"selection_action\": \"newline\"\n    },\n    {\n      \"trigger_with_shortcut\": \"Command+Shift+/\",\n      \"process\": 1,\n      \"prompt\": 0,\n      \"next_steps\": [\n        \"write_final_text_to_screen\"\n      ],\n      \"selection_action\": \"newline\"\n    },\n    {\n      \"trigger_with_shortcut\": \"Command+Shift+'\",\n      \"process\": 3,\n      \"prompt\": 0,\n      \"next_steps\": [\n        \"write_image_to_screen\"\n      ],\n      \"selection_action\": null\n    },\n    {\n      \"trigger_with_shortcut\": null,\n      \"process\": 0,\n      \"prompt\": 2,\n      \"next_steps\": [\n        \"stream_text_to_screen\",\n        {\n          \"store_as_env_var\": \"GPT\"\n        },\n        {\n          \"trigger\": 5\n        }\n      ],\n      \"selection_action\": null\n    },\n    {\n      \"trigger_with_shortcut\": null,\n      \"process\": 0,\n      \"prompt\": 3,\n      \"next_steps\": [],\n      \"selection_action\": null\n    }\n  ]\n}\n\n```\n\n\u003c/details\u003e\n\n## Building Plock\n\nIf you don't want to blindly trust binaries (you shouldn't), here's how you can build it\nyourself!\n\n## Prerequisites\n\n- Node.js (v14 or later)\n- Rust (v1.41 or later)\n- NPM (latest version)\n\n## Installation Steps\n\n### Node.js\n\nDownload from: https://nodejs.org/\n\n### Rust\n\n```bash\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\nsource $HOME/.cargo/env\n```\n\n### ~~Bun~~ NPM\n\n_Whattt?? Why?_ - well, windows doesn't support `bun` in github actions afaict. So, I'm using npm instead.\n\n[How to Install Node](https://nodejs.org/en/download/package-manager)\n\n## Project Setup\n\n```bash\ngit clone \u003crepo_url\u003e\ncd path/to/project\nnpm install\nnpm run tauri dev\n```\n\n## Build\n\n```bash\nnpm run tauri build\n```\n\n## Inspiration / Another Great Project\n\n- [LLM-automator](https://github.com/radames/LLM-automator)\n\n## Another demo\n\nAnother demo where I use the perplexity shell script to generate an answer super fast.\nNot affiliated, was just replying to a thread lol\n\nhttps://github.com/jasonjmcghee/plock/assets/1522149/6166af73-545f-4a8e-ad46-ea8aacd84969\n\n## Secrets\n\nCurious folks might be wondering what `ocr` feature is. I took a crack at taking a screenshot,\nrunning OCR, and using that for context, instead of copying text manually. Long story short,\nrusty-tesseract _really_ dissapointed me, which is awkward b/c it's core\nto [xrem](https://github.com/jasonjmcghee/xrem).\n\nIf someone wants to figure this out... this could be really cool, especially with multi-modal models.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonjmcghee%2Fplock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasonjmcghee%2Fplock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonjmcghee%2Fplock/lists"}