### Manual Installation with Bun Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Install Next.js, React, and ReactDOM manually using Bun. ```bash bun add next@latest react@latest react-dom@latest ``` -------------------------------- ### Manual Installation with npm Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Install Next.js, React, and ReactDOM manually using npm. ```bash npm i next@latest react@latest react-dom@latest ``` -------------------------------- ### Manual Installation with Yarn Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Install Next.js, React, and ReactDOM manually using Yarn. ```bash yarn add next@latest react@latest react-dom@latest ``` -------------------------------- ### Install rustup on Linux or macOS Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch01-01-installation.md Use this command to download and install the rustup tool, which then installs the latest stable version of Rust. ```bash $ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh ``` -------------------------------- ### Manual Installation with pnpm Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Install Next.js, React, and ReactDOM manually using pnpm. ```bash pnpm i next@latest react@latest react-dom@latest ``` -------------------------------- ### Verify Rust Installation Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch01-01-installation.md After installation, run this command to check if Rust is installed correctly and display the version information. ```bash $ rustc --version ``` -------------------------------- ### Start Development Server Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Run this command in your terminal to start the Next.js development server. Visit http://localhost:3000 to view your application. ```bash npm run dev ``` -------------------------------- ### Install Ory Lumen for Codex (Manual) Source: https://github.com/ory/lumen/blob/main/README.md Manually install the Lumen binary and link its skills for Codex. ```bash CODEX_HOME="${CODEX_HOME:-$HOME/.codex}" git clone https://github.com/ory/lumen.git "$CODEX_HOME/lumen" mkdir -p "$HOME/.agents/skills" ln -s "$CODEX_HOME/lumen/skills" "$HOME/.agents/skills/lumen" codex mcp add lumen -- "$CODEX_HOME/lumen/scripts/run" stdio ``` -------------------------------- ### Next.js Installation Prompts Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx These are the prompts you will see when installing a Next.js project via the CLI. ```txt What is your project named? my-app Would you like to use the recommended Next.js defaults? Yes, use recommended defaults - TypeScript, ESLint, Tailwind CSS, App Router, Turbopack No, reuse previous settings No, customize settings - Choose your own preferences ``` -------------------------------- ### Absolute Import Example Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Illustrates the difference between relative and absolute imports. Use absolute imports for cleaner code. ```jsx // Before import { Button } from '../../../components/button'; // After import { Button } from '@/components/button'; ``` -------------------------------- ### Get User Input and Print Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch02-00-guessing-game-tutorial.md This snippet demonstrates how to get user input and print it to the console. It requires bringing the `io` library into scope. ```rust use std::io; fn main() { println!("Guess the number!"); let mut guess = String::new(); io::stdin().read_line(&mut guess) .expect("Failed to read line"); println!("You guessed: {}", guess); } ``` -------------------------------- ### Create Next.js App with bun Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Use this snippet to quickly create a new Next.js application using the bun package manager. It sets up the app and starts the development server. ```bash bun create next-app@latest my-app --yes cd my-app bun dev ``` -------------------------------- ### Create Next.js App with npm Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Use this snippet to quickly create a new Next.js application using the npm package manager. It sets up the app and starts the development server. ```bash npx create-next-app@latest my-app --yes cd my-app npm run dev ``` -------------------------------- ### Open Local Rust Documentation Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch01-01-installation.md This command opens the locally installed Rust documentation in your default web browser, allowing offline access to API and usage information. ```bash rustup doc ``` -------------------------------- ### Install C compiler on macOS Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch01-01-installation.md On macOS, a C compiler is needed for linking and is often required by Rust packages. This command installs the necessary tools. ```bash $ xcode-select --install ``` -------------------------------- ### Next.js Customization Prompts Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx These prompts appear if you choose to customize settings during Next.js installation. ```txt Would you like to use TypeScript? No / Yes Which linter would you like to use? ESLint / Biome / None Would you like to use React Compiler? No / Yes Would you like to use Tailwind CSS? No / Yes Would you like your code inside a `src/` directory? No / Yes Would you like to use App Router? (recommended) No / Yes Would you like to customize the import alias (`@/*` by default)? No / Yes What import alias would you like configured? @/* ``` -------------------------------- ### Create Next.js App with pnpm Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Use this snippet to quickly create a new Next.js application using the pnpm package manager. It sets up the app and starts the development server. ```bash pnpm create next-app@latest my-app --yes cd my-app pnpm dev ``` -------------------------------- ### Start Ollama Server and Pull Model Source: https://github.com/ory/lumen/blob/main/README.md Start the Ollama service and pull a specific embedding model. This is often a prerequisite for Lumen to function correctly. ```bash ollama serve ollama pull ordis/jina-embeddings-v2-base-code ``` -------------------------------- ### Create Next.js App with yarn Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Use this snippet to quickly create a new Next.js application using the yarn package manager. It sets up the app and starts the development server. ```bash yarn create next-app@latest my-app --yes cd my-app yarn dev ``` -------------------------------- ### Index with LM Studio Server Source: https://github.com/ory/lumen/blob/main/README.md Index data using a model hosted on LM Studio. This example shows how to specify a model name that might not be in the static registry but is configured in your YAML file. ```sh lumen index --model text-embedding-jina-embeddings-v2-base-code . ``` -------------------------------- ### Run All Benchmark Tasks Source: https://github.com/ory/lumen/blob/main/docs/BENCHMARKS.md Executes all defined benchmark tasks and scenarios. Ensure Ollama is running with the specified model and necessary CLIs are installed. Results are saved to the specified output directory. ```bash cd bench-swe # Run all tasks, both scenarios go run ./cmd/run --output ../bench-results/my-run ``` -------------------------------- ### Build and Run SWE-Bench Source: https://github.com/ory/lumen/blob/main/bench-swe/README.md Build the bench-swe executable and run all tasks. This requires Ollama and the Claude CLI to be set up. ```bash cd bench-swe go build -o bench-swe . # Run all tasks (requires Ollama + Claude CLI) ./bench-swe run ``` -------------------------------- ### Update Rust Installation Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch01-01-installation.md To update to the latest stable version of Rust after installation, run this command in your shell. ```bash $ rustup update ``` -------------------------------- ### Create Project Directory (Windows CMD) Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch01-02-hello-world.md Commands for Windows Command Prompt to create a 'projects' directory and a 'hello_world' subdirectory. Uses environment variables for user profile. ```cmd > mkdir "%USERPROFILE%\projects" > cd /d "%USERPROFILE%\projects" > mkdir hello_world > cd hello_world ``` -------------------------------- ### Default main.rs for a New Rust Project Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch02-00-guessing-game-tutorial.md A new Rust project is initialized with a basic 'Hello, world!' program in `src/main.rs`. ```rust fn main() { println!("Hello, world!"); } ``` -------------------------------- ### Create Project Directory (Linux/macOS/PowerShell) Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch01-02-hello-world.md Commands to create a 'projects' directory and a 'hello_world' subdirectory for your Rust project. Ensure you are in your home directory before running. ```bash $ mkdir ~/projects $ cd ~/projects $ mkdir hello_world $ cd hello_world ``` -------------------------------- ### Add Blockquote Start Regex to Rules Source: https://github.com/ory/lumen/blob/main/bench-results/swe-20260310-200417-javascript-ollama-jina-embeddings-v2-base-code/detail-report.md This code snippet adds a new regular expression to rules.ts to detect the start of a blockquote, considering indentation. This is used in conjunction with the Tokenizer.ts modifications to correctly parse markdown. ```diff diff --git a/src/rules.ts b/src/rules.ts index af66342..6d0846d 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -85,6 +85,7 @@ export const other = { fencesBeginRegex: (indent: number) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (indent: number) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`), htmlBeginRegex: (indent: number) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}<(?:[a-z].*>|!--)`, 'i'), + blockquoteBeginRegex: (indent: number) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}>`), }; /** ``` -------------------------------- ### Example panic! backtrace output Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch09-01-unrecoverable-errors-with-panic.md This is an example of the output generated when a Rust program panics and the `RUST_BACKTRACE` environment variable is set. It shows the panic message and a detailed stack backtrace, indicating the sequence of function calls leading to the error. ```console thread 'main' panicked at src/main.rs:4:6: index out of bounds: the len is 3 but the index is 99 stack backtrace: 0: rust_begin_unwind at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/std/src/panicking.rs:692:5 1: core::panicking::panic_fmt at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/panicking.rs:75:14 2: core::panicking::panic_bounds_check at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/panicking.rs:273:5 3: >::index at file:///home/.rustup/toolchains/1.85/lib/rustlib/src/rust/library/core/src/slice/index.rs:274:10 4: core::slice::index:: for [T]>::index at file:///home/.rustup/toolchains/1.85/lib/rustlib/src/rust/library/core/src/slice/index.rs:16:9 5: as core::ops::index::Index>::index at file:///home/.rustup/toolchains/1.85/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:3361:9 6: panic::main at ./src/main.rs:4:6 7: core::ops::function::FnOnce::call_once at file:///home/.rustup/toolchains/1.85/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. ``` -------------------------------- ### Compile and Run Rust Program (Linux/macOS) Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch01-02-hello-world.md Compiles the main.rs file using rustc and then executes the compiled binary. Assumes you are in the same directory as main.rs. ```bash $ rustc main.rs $ ./main Hello, world! ``` -------------------------------- ### Verify Codex Lumen Installation Source: https://github.com/ory/lumen/blob/main/README.md Check if the Lumen MCP service is registered and its skills are accessible in Codex. ```bash codex mcp get lumen ls -la "$HOME/.agents/skills/lumen" ``` -------------------------------- ### Create Next.js App with npm Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Use this command to create a new Next.js project with npm. ```bash npx create-next-app@latest ``` -------------------------------- ### Create Next.js App with Bun Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Use this command to create a new Next.js project with Bun. ```bash bun create next-app ``` -------------------------------- ### Install Ory Lumen Plugin for Claude Code Source: https://github.com/ory/lumen/blob/main/README.md Add the Ory Lumen plugin to Claude Code via its marketplace. ```bash /plugin marketplace add ory/claude-plugins /plugin install lumen@ory ``` -------------------------------- ### Hello, World! Rust Program Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch01-02-hello-world.md The basic 'Hello, world!' program in Rust. It uses the println! macro to print a string to the console. ```rust fn main() { println!("Hello, world!"); } ``` -------------------------------- ### Rectangle Struct and can_hold Method Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch11-01-writing-tests.md Defines the Rectangle struct and its associated can_hold method, which are used in subsequent test examples. ```rust struct Rectangle { width: u32, height: u32, } impl Rectangle { fn can_hold(&self, other: &Rectangle) -> bool { self.width > other.width && self.height > other.height } } ``` -------------------------------- ### Variable Scope Example Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch04-01-what-is-ownership.md Demonstrates the scope of a string literal variable 's'. The variable is valid from its declaration until the end of its scope. ```Rust let s = "hello"; ``` ```Rust fn main() { let s = "hello"; // do stuff with s // s goes out of scope here, so the memory it refers to is freed. // We don't have to do anything to free it, because it was a string literal // that was hardcoded in the executable and its memory management is handled automatically. } ``` -------------------------------- ### Biome Scripts for Package.json Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Add these scripts to your package.json to enable Biome for linting and formatting code. Ensure Biome is installed in your project. ```json { "scripts": { "lint": "biome check", "format": "biome format --write" } } ``` -------------------------------- ### Display Lumen CLI Help Source: https://github.com/ory/lumen/blob/main/README.md Use this command to view all available Lumen CLI commands and their usage. ```bash lumen help ``` -------------------------------- ### ESLint Scripts for Package.json Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Add these scripts to your package.json to enable ESLint for linting and fixing code. Ensure ESLint is installed in your project. ```json { "scripts": { "lint": "eslint", "lint:fix": "eslint --fix" } } ``` -------------------------------- ### Pull Default Embedding Model with Ollama Source: https://github.com/ory/lumen/blob/main/README.md Install Ollama and pull the default embedding model required for Lumen's functionality. ```bash ollama pull ordis/jina-embeddings-v2-base-code ``` -------------------------------- ### C API: Formatting with Multiple Arguments Source: https://github.com/ory/lumen/blob/main/bench-results/swe-20260311-122635-cpp-ollama-jina-embeddings-v2-base-code/detail-report.md Shows how to format a string with multiple arguments of different types (integer, C-string, double). Verifies the correct concatenation and formatting of all arguments. ```c #include #include #include TEST(c_api_test, multiple_args) { fmt_arg_store* args = fmt_arg_store_create(); fmt_arg_store_push_int(args, 42); fmt_arg_store_push_cstring(args, "world"); fmt_arg_store_push_double(args, 1.5); char* result = fmt_vformat("{} {}", args); ASSERT_NE(result, nullptr); EXPECT_STREQ(result, "42 world 1.5"); fmt_free(result); fmt_arg_store_destroy(args); } ``` -------------------------------- ### YAML Input with Null Nested Struct Source: https://github.com/ory/lumen/blob/main/bench-results/swe-20260311-134302-go-ollama-jina-embeddings-v2-base-code/detail-report.md Example YAML input where a nested struct key is present but has no actual values, only comments. ```yaml first: "Test" second: # Just want to document the fields of the nested struct # key: "Value from YAML" ``` -------------------------------- ### Compile and Run Rust Program (Windows) Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch01-02-hello-world.md Compiles the main.rs file using rustc and then executes the compiled binary. Uses Windows path syntax for execution. ```powershell > rustc main.rs > .\main Hello, world! ``` -------------------------------- ### Deprecated NSKeyedUnarchiver for TemplateContext Source: https://github.com/ory/lumen/blob/main/bench-results/swe-20260504-135254-swift-ollama-jina-embeddings-v2-base-code/swift-hard-baseline-tests.txt This example demonstrates the deprecated `NSKeyedUnarchiver.unarchiveTopLevelObjectWithData` method used to unarchive a `TemplateContext`. It is advised to use `unarchivedObject(ofClass:from:)` for improved security. ```swift let unarchived = try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? TemplateContext ``` -------------------------------- ### Clone and Build Ory Lumen Locally Source: https://github.com/ory/lumen/blob/main/README.md Clone the Ory Lumen repository and build the project locally. CGO is required for sqlite-vec. ```bash git clone https://github.com/ory/lumen.git cd lumen # Build locally (CGO required for sqlite-vec) make build-local ``` -------------------------------- ### Equatable Conformance for Paths Type Source: https://github.com/ory/lumen/blob/main/bench-results/swe-20260504-135254-swift-ollama-jina-embeddings-v2-base-code/swift-hard-baseline-tests.txt An example of extending the `Paths` type to conform to `Equatable`. This warning indicates potential future conflicts with the library's own conformance. ```swift extension Paths: Equatable { public static func == (lhs: Paths, rhs: Paths) -> Bool { return lhs.include == rhs.include ``` -------------------------------- ### Package Lock File Diff for Citty Baseline Source: https://github.com/ory/lumen/blob/main/bench-results/swe-20260311-100602-typescript-ollama-jina-embeddings-v2-base-code/detail-report.md Shows the changes in the package-lock.json file for the baseline scenario. This is useful for understanding dependency versions in the original setup. ```diff diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..2c16875 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6406 @@ +{ + "name": "citty", + "version": "0.2.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "citty", + "version": "0.2.0", + "license": "MIT", + "devDependencies": { + "@types/node": "^25.0.9", + "@vitest/coverage-v8": "^4.0.17", + "automd": "^0.4.2", + "changelogen": "^0.6.2", + "eslint": "^9.39.2", + "eslint-config-unjs": "^0.6.2", + "obuild": "^0.4.18", + "prettier": "^3.8.0", + "scule": "^1.3.0", + "typescript": "^5.9.3", + "vitest": "^4.0.17" + } + }, + "node_modules/@babel/generator": { + "version": "8.0.0-rc.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-8.0.0-rc.2.tgz", + "integrity": "sha512-oCQ1IKPwkzCeJzAPb7Fv8rQ9k5+1sG8mf2uoHiMInPYvkRfrDJxbTIbH51U+jstlkghus0vAi3EBvkfvEsYNLQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^8.0.0-rc.2", + "@babel/types": "^8.0.0-rc.2", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "@types/jsesc": "^2.5.0", + "jsesc": "^3.0.2" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@babel/generator/node_modules/@babel/helper-string-parser": { + "version": "8.0.0-rc.2", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-8.0.0-rc.2.tgz", + "integrity": "sha512-noLx87RwlBEMrTzncWd/FvTxoJ9+ycHNg0n8yyYydIoDsLZuxknKgWRJUqcrVkNrJ74uGyhWQzQaS3q8xfGAhQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@babel/generator/node_modules/@babel/helper-validator-identifier": { + "version": "8.0.0-rc.2", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-8.0.0-rc.2.tgz", + "integrity": "sha512-xExUBkuXWJjVuIbO7z6q7/BA9bgfJDEhVL0ggrggLMbg0IzCUWGT1hZGE8qUH7Il7/RD/a6cZ3AAFrrlp1LF/A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@babel/generator/node_modules/@babel/parser": { ``` -------------------------------- ### Create Next.js App with pnpm Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Use this command to create a new Next.js project with pnpm. ```bash pnpm create next-app ``` -------------------------------- ### List executable files on Windows CMD Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch01-02-hello-world.md On Windows using CMD, `dir /B` lists the executable, its PDB file, and the source file. ```cmd > dir /B %= the /B option says to only show the file names =% main.exe main.pdb main.rs ``` -------------------------------- ### Using Option with Different Types Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch06-01-defining-an-enum.md Examples of creating Option values for numeric and character types. Rust can infer the type for Some variants but requires explicit annotation for None. ```rust let some_number = Some(5); let some_char = Some('a'); let absent_number: Option = None; ``` -------------------------------- ### Create a New Rust Project with Cargo Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch02-00-guessing-game-tutorial.md Use the `cargo new` command to initialize a new Rust project. This sets up the basic directory structure and essential files. ```bash cargo new guessing_game cd guessing_game ``` -------------------------------- ### Create Next.js App with Yarn Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/01-installation.mdx Use this command to create a new Next.js project with Yarn. ```bash yarn create next-app ``` -------------------------------- ### Compare Two SWE-Bench Runs Source: https://github.com/ory/lumen/blob/main/bench-swe/README.md Compare the results of two previous SWE-Bench runs by providing their respective result directories. ```bash ./bench-swe compare ../bench-results/swe-RUN1/ ../bench-results/swe-RUN2/ ``` -------------------------------- ### C API: Format with format specifier Source: https://github.com/ory/lumen/blob/main/bench-results/swe-20260311-122635-cpp-ollama-jina-embeddings-v2-base-code/detail-report.md Demonstrates using a format specifier (hexadecimal with prefix) with `fmt_format_to`. Shows how to control output formatting. ```c++ TEST(c_api_test, format_spec) { char buf[32]; struct fmt_arg args[] = {FMT_ARG_INT(255)}; fmt_format_to(buf, sizeof(buf), "{:#x}", args, 1); EXPECT_STREQ("0xff", buf); } ``` -------------------------------- ### Deprecated NSKeyedArchiver and NSKeyedUnarchiver in Context Source: https://github.com/ory/lumen/blob/main/bench-results/swe-20260504-135254-swift-ollama-jina-embeddings-v2-base-code/swift-hard-baseline-tests.txt This example illustrates the deprecated use of both `NSKeyedArchiver.archivedData(withRootObject:)` and `NSKeyedUnarchiver.unarchiveTopLevelObjectWithData` within a function. It highlights the need to migrate to newer APIs for secure coding. ```swift func templateContextData(_ code: String) -> TemplateContext? { guard let parserResult = try? makeParser(for: code).parse() else { fail(); return nil } let data = NSKeyedArchiver.archivedData(withRootObject: parserResult) let result = Composer.uniqueTypesAndFunctions(parserResult) return TemplateContext(parserResult: try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? FileParserResult, types: .init(types: result.types, typealiases: result.typealiases), functions: result.functions, arguments: [:]) } ``` -------------------------------- ### Define and Call a Simple Rust Function Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch03-03-how-functions-work.md Demonstrates the basic syntax for defining a function using `fn` and calling it from the `main` function. Rust allows defining functions anywhere in scope. ```rust fn another_function() { println!("Another function."); } fn main() { println!("Hello, world!"); another_function(); } ``` -------------------------------- ### Specifying a Specific Crate Version Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch02-00-guessing-game-tutorial.md Example of how to specify a specific, potentially newer, version of a dependency in Cargo.toml. This is used when you want to opt into a version outside the default compatible range. ```toml [dependencies] rand = "0.999.0" ``` -------------------------------- ### Build Local Binary for Plugin Development Source: https://github.com/ory/lumen/blob/main/CLAUDE.md Builds the Lumen binary locally, enabling direct loading from the repository for plugin development. ```bash make build-local claude --plugin-dir . ``` -------------------------------- ### Add Blockquote Detection to Tokenizer Source: https://github.com/ory/lumen/blob/main/bench-results/swe-20260310-200417-javascript-ollama-jina-embeddings-v2-base-code/detail-report.md This diff adds logic to the Tokenizer to detect the start of a blockquote at a lower indentation level, preventing it from being incorrectly included in a list item. It modifies the Tokenizer.ts file. ```diff diff --git a/src/Tokenizer.ts b/src/Tokenizer.ts index d6d6ca8..ee04a74 100644 --- a/src/Tokenizer.ts +++ b/src/Tokenizer.ts @@ -296,6 +296,7 @@ export class _Tokenizer { const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent); const headingBeginRegex = this.rules.other.headingBeginRegex(indent); const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent); + const blockquoteBeginRegex = this.rules.other.blockquoteBeginRegex(indent); // Check if following lines should be included in List Item while (src) { @@ -326,6 +327,11 @@ export class _Tokenizer { break; } + // End list item if found start of blockquote at lower indentation + if (blockquoteBeginRegex.test(nextLine)) { + break; + } + // End list item if found start of new bullet if (nextBulletRegex.test(nextLine)) { break; ``` -------------------------------- ### C API: Basic Formatting Source: https://github.com/ory/lumen/blob/main/bench-results/swe-20260311-122635-cpp-ollama-jina-embeddings-v2-base-code/detail-report.md Demonstrates basic formatting of an integer to its hexadecimal representation using the C API. Ensures the result is not null and matches the expected output. ```c #include #include #include TEST(c_api_test, basic_formatting) { fmt_arg_store* args = fmt_arg_store_create(); fmt_arg_store_push_int(args, 0); char* result = fmt_vformat("{}", args); ASSERT_NE(result, nullptr); EXPECT_STREQ(result, "0"); fmt_free(result); fmt_arg_store_destroy(args); } ``` -------------------------------- ### Rust Variable Shadowing Example Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch03-01-variables-and-mutability.md Demonstrates variable shadowing in Rust, including inner scopes and type changes. This snippet shows how a new `let` binding with the same name shadows the previous one. ```rust fn main() { let x = 5; let x = x + 1; { let x = x * 2; println!("The value of x in the inner scope is: {}", x); } println!("The value of x is: {}", x); } ``` -------------------------------- ### Create User Instance (Regular Way) Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch05-01-defining-structs.md Creates a new `User` instance using standard field assignment. This is shown for comparison with struct update syntax. ```rust struct User { username: String, email: String, sign_in_count: u64, active: bool, } fn main() { let user1 = User { email: String::from("someone@example.com"), username: String::from("someusername123"), active: true, sign_in_count: 1, }; let user2 = User { email: String::from("another@example.com"), username: user1.username, active: user1.active, sign_in_count: user1.sign_in_count, }; } ``` -------------------------------- ### Generate Random Number in Rust Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch02-00-guessing-game-tutorial.md Use the rand crate to generate a random number between 1 and 100. Ensure the `rand::Rng` trait is in scope and use `rand::thread_rng` to get a random number generator. ```rust use rand::Rng; fn main() { println!("Guess the number!"); let secret_number = rand::thread_rng().gen_range(1..=100); println!("The secret number is: {}", secret_number); // ... rest of the game logic } ``` -------------------------------- ### Run SWE-Bench Skipping Preflight Checks Source: https://github.com/ory/lumen/blob/main/bench-swe/README.md Run SWE-Bench tasks for a specific language while skipping preflight checks for faster iteration. ```bash ./bench-swe run --skip-preflight --language go ``` -------------------------------- ### C API: Format unsigned integer argument Source: https://github.com/ory/lumen/blob/main/bench-results/swe-20260311-122635-cpp-ollama-jina-embeddings-v2-base-code/detail-report.md Shows how to format an unsigned integer using `fmt_format_to`. Verifies the output for unsigned types. ```c++ TEST(c_api_test, uint_arg) { char buf[32]; struct fmt_arg args[] = {FMT_ARG_UINT(42u)}; fmt_format_to(buf, sizeof(buf), "{}", args, 1); EXPECT_STREQ("42", buf); } ``` -------------------------------- ### Struct with String References (Compilation Error) Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch05-01-defining-structs.md Attempting to define a struct with string slices (&str) without specifying lifetimes will result in a compilation error. This example demonstrates the error and the compiler's suggestion to use lifetime specifiers. ```rust struct User { active: bool, username: &str, email: &str, sign_in_count: u64, } fn main() { let user1 = User { active: true, username: "someusername123", email: "someone@example.com", sign_in_count: 1, }; } ``` -------------------------------- ### Rust: Deep Copying with clone() Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch04-01-what-is-ownership.md Illustrates how to create a deep copy of a String's heap data using the `clone` method, ensuring both variables remain valid and independent. ```rust fn main() { let s1 = String::from("hello"); let s2 = s1.clone(); println!("s1 = {}, s2 = {}", s1, s2); } ``` -------------------------------- ### Modify Tokenizer.ts to Handle Blockquote Nesting Source: https://github.com/ory/lumen/blob/main/bench-results/swe-20260310-200417-javascript-ollama-jina-embeddings-v2-base-code/detail-report.md This code snippet modifies the Tokenizer.ts file to correctly handle blockquote nesting within markdown lists. It adds a check for blockquote start markers to determine if a line should be included in the current list item. ```diff diff --git a/src/Tokenizer.ts b/src/Tokenizer.ts index d6d6ca8..c8d0c37 100644 --- a/src/Tokenizer.ts +++ b/src/Tokenizer.ts @@ -296,6 +296,7 @@ export class _Tokenizer { const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent); const headingBeginRegex = this.rules.other.headingBeginRegex(indent); const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent); + const blockquoteBeginRegex = this.rules.other.blockquoteBeginRegex(indent); // Check if following lines should be included in List Item while (src) { @@ -326,6 +327,11 @@ export class _Tokenizer { break; } + // End list item if found start of blockquote + if (blockquoteBeginRegex.test(nextLine)) { + break; + } + // End list item if found start of new bullet if (nextBulletRegex.test(nextLine)) { break; ``` -------------------------------- ### Explicitly Convert Optional to String in Swift Source: https://github.com/ory/lumen/blob/main/bench-results/swe-20260504-135254-swift-ollama-jina-embeddings-v2-base-code/swift-hard-baseline-tests.txt This example shows how to explicitly convert an optional string to its string representation using `String(describing:)` to silence the compiler warning about string interpolation of optionals. This is useful when you need to ensure the output is always a string, even if the optional is nil. ```swift let result = (try? (outputDir + Sourcery().generatedPath(for: templatePath)).read(.utf8)) print("expected:\n\(expectedResult)\n\ngot:\n\(String(describing: result))") ``` -------------------------------- ### Attempting to Use Main Thread Vector in Spawned Thread (Compile Error) Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch16-01-threads.md This example demonstrates a common error when trying to use data owned by the main thread within a spawned thread without proper ownership transfer. The compiler will prevent this due to borrowing rules. ```rust use std::thread; fn main() { let v = vec![1, 2, 3]; let handle = thread::spawn(|| { println!("Here's a vector: {:?}", v); }); handle.join().unwrap(); } ``` -------------------------------- ### Running the Guessing Game and Inputting a Guess Source: https://github.com/ory/lumen/blob/main/testdata/fixtures/md/ch02-00-guessing-game-tutorial.md This console output demonstrates running the initial part of the guessing game and providing user input. It shows the compilation process, execution, and the program's response to the input. ```console $ cargo run Compiling guessing_game v0.1.0 (file:///projects/guessing_game) Finished `dev` profile [unoptimized + debuginfo] target(s) in 6.44s Running `target/debug/guessing_game` Guess the number! Please input your guess. 6 You guessed: 6 ```