diff --git a/flake.lock b/flake.lock index 35dac74..b182053 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1734541973, - "narHash": "sha256-1wIgLmhvtfxbJVnhFHUYhPqL3gpLn5JhiS4maaD9RRk=", + "lastModified": 1744386647, + "narHash": "sha256-DXwQEJllxpYeVOiSlBhQuGjfvkoGHTtILLYO2FvcyzQ=", "owner": "ipetkov", "repo": "crane", - "rev": "fdd502f921936105869eba53db6593fc2a424c16", + "rev": "d02c1cdd7ec539699aa44e6ff912e15535969803", "type": "github" }, "original": { @@ -41,11 +41,11 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1734676450, - "narHash": "sha256-iwcxhTVe4h5TqW0HsNiOQP27eMBmbBshF+q2UjEy5aU=", + "lastModified": 1744231114, + "narHash": "sha256-60gLl2rJFt6SRwqWimsTAeHgfsIE1iV0zChdJFOvx8w=", "owner": "nix-community", "repo": "fenix", - "rev": "46e19fa0eb3260b2c3ee5b2cf89e73343c1296ab", + "rev": "0ccfe532b1433da8e5a23cd513ff6847e0f6a8c2", "type": "github" }, "original": { @@ -92,10 +92,10 @@ }, "nixpkgs": { "locked": { - "lastModified": 1733550349, - "narHash": "sha256-NcGumB4Lr6KSDq+nIqXtNA8QwAQKDSZT7N9OTGWbTrs=", - "path": "/nix/store/sqmn1ky3k66661h32djyjvsr8l99330z-source", - "rev": "e2605d0744c2417b09f8bf850dfca42fcf537d34", + "lastModified": 1741048562, + "narHash": "sha256-W4YZ3fvWZiFYYyd900kh8P8wU6DHSiwaH0j4+fai1Sk=", + "path": "/nix/store/cdjqlnn7kx4hfmxkry9yjfdvqp2pradh-source", + "rev": "6af28b834daca767a7ef99f8a7defa957d0ade6f", "type": "path" }, "original": { @@ -115,11 +115,11 @@ "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1734622712, - "narHash": "sha256-2Oc2LbFypF1EG3zTVIVcuT5XFJ7R3oAwu2tS8B0qQ0I=", + "lastModified": 1742296961, + "narHash": "sha256-gCpvEQOrugHWLimD1wTFOJHagnSEP6VYBDspq96Idu0=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "fe027d79d22f2a7645da4143f5cc0f5f56239b97", + "rev": "15d87419f1a123d8f888d608129c3ce3ff8f13d4", "type": "github" }, "original": { diff --git a/llmc/Cargo.lock b/llmc/Cargo.lock new file mode 100644 index 0000000..0ba0497 --- /dev/null +++ b/llmc/Cargo.lock @@ -0,0 +1,273 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "atelier" +version = "0.0.0" + +[[package]] +name = "bstr" +version = "1.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "531a9155a481e2ee699d4f98f43c0ca4ff8ee1bfd55c31e9e98fb29d2b176fe0" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "globset" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "ignore" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + +[[package]] +name = "llmc" +version = "0.0.0" +dependencies = [ + "atelier", + "ignore", +] + +[[package]] +name = "log" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "serde" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "2.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/llmc/Cargo.toml b/llmc/Cargo.toml new file mode 100644 index 0000000..d8526b9 --- /dev/null +++ b/llmc/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "llmc" +version = "0.0.0" +edition = "2024" + +[dependencies] +atelier = { path = "../rs" } +ignore = "0.4.23" \ No newline at end of file diff --git a/llmc/src/main.rs b/llmc/src/main.rs new file mode 100644 index 0000000..e8fcdc5 --- /dev/null +++ b/llmc/src/main.rs @@ -0,0 +1,103 @@ +use atelier::preludes::fs::*; +use atelier::preludes::io::*; + +static USAGE: &str = r#" +llmc - Collect code in a directory into a single text output, for feeding into an LLM + +USAGE: + llmc [path] [options]... + +OPTIONS: + -i, --input-exts The file extensions to include in the output +"#; + +fn find_git_root(start: impl AsRef) -> IoResult> { + let mut current = Some(start.as_ref().to_path_buf().canonicalize()?); + while let Some(c) = current { + if c.join(".git").exists() { + return Ok(Some(c.to_path_buf().canonicalize()?)); + } else { + current = c.parent().map(|o| o.to_path_buf()); + } + } + + Ok(None) +} + +fn walk_dir(path: impl AsRef, included_exts: &[&str]) -> IoResult<()> { + let mut types = ignore::types::TypesBuilder::new(); + for ext in included_exts.iter() { + types.add(&ext[1..], &format!("*{ext}")).unwrap(); + } + types.select("all"); + let types = types.build().unwrap(); + + let mut builder = if let Some(root) = find_git_root(path.as_ref())? { + ignore::WalkBuilder::new(root) + } else { + ignore::WalkBuilder::new(path) + }; + + builder.types(types); + + let walk = builder.build(); + + for result in walk { + let entry = result.unwrap(); + let ft = entry.file_type().unwrap(); + if ft.is_dir() { + continue; + } + + let path = entry.path().as_os_str().to_string_lossy(); + println!("##### Contents of {} #####", path); + println!("{}", std::fs::read_to_string(path.as_ref())?); + } + + Ok(()) +} + +fn main() -> std::io::Result<()> { + let mut included_exts = vec![]; + + let args: Vec<_> = std::env::args().skip(1).collect(); + let mut args = args.iter().map(|s| s.as_str()); + let mut params = vec![]; + let mut fail = false; + + while !fail { + let arg = match args.next() { + None => break, + Some(v) => v, + }; + + if arg.starts_with('-') { + match arg { + "-h" | "--help" => { + println!("{USAGE}"); + return Ok(()); + }, + "-i" | "--include-exts" => { + fail = args + .next() + .map(|a| included_exts.extend(a.split(','))) + .is_none() + }, + _ => (), + } + } else { + params.push(arg); + } + } + + if fail { + eprintln!("{USAGE}"); + return Ok(()); + } + + let dir = params.get(0).copied().unwrap_or("."); + + walk_dir(dir, &included_exts)?; + + Ok(()) +} diff --git a/pritty/colors/eink.toml b/pritty/colors/eink.toml new file mode 100644 index 0000000..46d9e7a --- /dev/null +++ b/pritty/colors/eink.toml @@ -0,0 +1,60 @@ +name = "eink" + +[palette] +gray-100 = "#d6d6d6" +gray-700 = "#474747" +gray-800 = "#333333" + +[dark.backgrounds] +primary = "@gray-800" + +selection = "@gray-100" +status-bar-active = "@gray-100" +status-bar-inactive = "@gray-700" +cursor = "@gray-100" + +[dark.text] +primary = "@gray-100" + +selection = "@gray-800" +status-bar-active = "@gray-800" + +[dark.syntax] +operator = "@gray-100" +import = "@gray-100" +function = "@gray-100" +constant = "@gray-100" +keyword = "@gray-100" +string = "@gray-100" +identifier = "@gray-100" +number = "@gray-100" +comment = "@gray-100" +macro = "@gray-100" +other = "@gray-100" + +[light.backgrounds] +primary = "@gray-100" + +selection = "@gray-800" +status-bar-active = "@gray-800" +status-bar-inactive = "@gray-700" +cursor = "@gray-800" + +[light.text] +primary = "@gray-800" + +selection = "@gray-100" +status-bar-active = "@gray-100" + +[light.syntax] +operator = "@gray-800" +import = "@gray-800" +function = "@gray-800" +constant = "@gray-800" +keyword = "@gray-800" +string = "@gray-800" +identifier = "@gray-800" +number = "@gray-800" +comment = "@gray-800" +macro = "@gray-800" +other = "@gray-800" diff --git a/pritty/src/main.ts b/pritty/src/main.ts index cb5a68e..5e9d143 100644 --- a/pritty/src/main.ts +++ b/pritty/src/main.ts @@ -223,12 +223,14 @@ async function generateEmacs( background: get(tables['backgrounds']?.['primary']), }); f('mode-line-active', { - foreground: get(tables['text']?.['primary']), + foreground: get(tables['text']?.['status-bar-active'] ?? tables['text']?.['primary']), background: get(tables['backgrounds']?.['status-bar-active']), box: true, }); f('mode-line-inactive', { - foreground: get(tables['text']?.['primary']), + foreground: get( + tables['text']?.['status-bar-inactive'] ?? tables['text']?.['primary'], + ), background: get(tables['backgrounds']?.['status-bar-inactive']), box: true, }); diff --git a/rs/Cargo.toml b/rs/Cargo.toml index 82ad7e8..4f34761 100644 --- a/rs/Cargo.toml +++ b/rs/Cargo.toml @@ -8,9 +8,13 @@ resolver = "2" members = [".", "newt"] [dependencies] -rusqlite = { version = "*" } -async-channel = { version = "*" } -urlpattern = { version = "*" } -url = { version = "*" } +rusqlite = { version = "*", optional = true } +async-channel = { version = "*", optional = true } +urlpattern = { version = "*", optional = true } +url = { version = "*", optional = true } -newt = { path = "./newt" } \ No newline at end of file +newt = { path = "./newt", optional = true } + +[features] +full = ["web"] +web = ["dep:rusqlite", "dep:async-channel", "dep:urlpattern", "dep:url", "dep:newt"] \ No newline at end of file diff --git a/rs/src/flags.rs b/rs/src/flags.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/rs/src/flags.rs @@ -0,0 +1 @@ + diff --git a/rs/src/lib.rs b/rs/src/lib.rs index 07398dd..df2c4a9 100644 --- a/rs/src/lib.rs +++ b/rs/src/lib.rs @@ -1,19 +1,21 @@ pub mod containers; +pub mod flags; pub mod prelude; +#[cfg(feature = "web")] pub mod router; +#[cfg(feature = "web")] pub mod rusqlite_thread_pool; -pub fn add(left: u64, right: u64) -> u64 { - left + right -} +pub mod preludes { + pub mod fmt { + pub use core::fmt::{Display, Formatter, Result as FmtResult}; + } -#[cfg(test)] -mod tests { - use super::*; + pub mod io { + pub use std::io::Result as IoResult; + } - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); + pub mod fs { + pub use std::path::{Path, PathBuf}; } } diff --git a/shelves/backend/routes/mod.rs b/shelves/backend/routes/mod.rs index dceb268..7030c77 100644 --- a/shelves/backend/routes/mod.rs +++ b/shelves/backend/routes/mod.rs @@ -20,6 +20,23 @@ where }) } +pub fn route(dbs: DbS, req: Request) -> Response { + let method = Some(req.method().as_str()); + let uri = format!("{}", req.uri()); + let path_parts: Vec<_> = uri.split('/').collect(); + + match path_parts.as_slice() { + &[] => match method.take() { + GET => return home::view(), + } + }; + + match method { + None => (http::status::StatusCode::from_u16(405), "Method not allowed").into_response(), + Some(_) => (http::status::StatusCode::from_u16(404), "Not found").into_response(), + } +} + pub fn make_router() -> Router { let mut router = atelier::router::Router::new();