Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/hop/blob/main/Omega/README.md # hop Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key. Brought by drakestapleton Sign in to star 1 stars 1 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `hop / Omega / README.md` 533 lines · 44766 bytes Raw Blame History Rendered 1 # Omega in Hop 2 3 Hop is being moved into Omega, piece by piece. Two pieces are Omega today: `hopcore` (the core: names, paths, text decisions, corrected words and the Swarm logic, below) and 4 `hopfact` (the factory command-center core, after it). The windows, keys, microphone and Keychain are still Swift. 5 6 # hopcore: the matching core 7 8 `Omega/hopcore.om` decides what matches what you type in the one box, and how well. It is compiled by Omega NG, the 9 next Omega compiler, which is itself Omega built by the seeded compiler: source to ΩIR (`@ng front-ir`), the optimizer 10 (`@ng opt`), then a macOS arm64 program (`@ng a64 macho`). The result, `Generated/hopcore`, is copied into the app 11 beside Hop and signed with it. No C and no Swift is involved in the matching rules. The old seeded compiler cannot 12 build this unit (error 12, its 16-register limit); Omega NG can. 13 14 Hop starts `hopcore` once and talks to it over a pipe. `Sources/OmegaCore.swift` is the whole host side: it 15 lowercases the text, turns each character into one number, sends cases and reads answers. If the core cannot be 16 started Hop shows no app matches; it never falls back to a guess. 17 18 ## Protocol 19 20 A request is 8 bytes, then a body: the kind and the body's length n, both 32-bit little-endian; n is at most 21 `1048576`. The answer is 8 bytes, then a body: a status and the length m. Status 0 is an answer, 1 an unknown kind, 22 2 a malformed body (m is then 0). A body over the limit or a short read ends the core; Hop starts a fresh one. 23 24 ### Kind 1: names 25 26 The body is 1 to 512 cases of 2048 bytes: 256 little-endian 64-bit words. 27 28 | Word | Meaning | 29 |---|---| 30 | 0 | magic ``1212568922`` | 31 | 1 | version `1` | 32 | 2 | number of characters typed, 0 to 64 | 33 | 3 | number of characters in the name, 0 to 184 | 34 | 4..7 | `0` | 35 | 8..71 | the typed characters, then `0` | 36 | 72..255 | the name's characters, then `0` | 37 38 A character word: bits 0..31 an id (equal characters get equal ids, never 0; a space is 32), bit 32 set for a 39 letter or number, bit 33 set for white space that is trimmed from the ends of what was typed. 40 41 The answer is 3 bytes a case: the verdict (0 no match, 1 match, 2 the case was malformed or over the limits), then 42 the score, low byte first. A longer text is refused, never cut short. 43 44 ### Kind 2: paths 45 46 Scores paths found on another machine against the typed terms. All fields are 16-bit little-endian: the number of 47 terms (at most 64), the number of paths (at most 16000), each term as its length then its bytes, then each path as 48 three lengths (its lowercased bytes, the lowercased bytes of its last component, the path as written), the path 49 bytes and the name bytes. Hop does the lowercasing and finds the last component; the terms are used as given. 50 51 The answer is 4 bytes a path, a 32-bit little-endian number: 0 for no match, else the score plus `1000000`. 52 53 ### Kind 3: text decisions 54 55 The body is four 32-bit little-endian numbers (the op, the number of characters n, at most 16384, a number the op 56 uses, and a second such number), then one 8-byte word per character of the lowercased text: a 32-bit id (equal characters get equal 57 ids; a character of one Unicode scalar has that scalar's number), then a flag byte (1 letter or number, 2 trimmable 58 white space, 4 white space, 8 white space or line end, 16 the last character of a run) and three zero bytes. 59 60 | Op | Question | Answer | 61 |---|---|---| 62 | 1 | Is this a question for the model? It ends with "?" and is longer than that, or it has three words or more and starts with a question word. | one byte, 0 or 1 | 63 | 2 | Which words should be searched for? Three characters or more, common words left out, each once, the longest four, longest first. | a count, then for each word where it starts and its length, as two 16-bit numbers | 64 | 3 | Is this a web address? The third number is the text's length in bytes. | one byte: 0 no; 1 it starts with http:// or https://; 2 a bare address such as example.com/page | 65 | 4 | How alike are two spellings? The text is the first, then the second; the third number is the first one's length. Only letters and numbers count. | two 16-bit numbers: the single-character edits between them, and the longer length. Hop divides to get 0 to 1. | 66 | 5 | Which typed words are the fix for what was heard? The text is what was heard (the third number is its length), then the first typed word, the first two, the first three and the first four; flag 16 marks the last character of each run. The fourth number says which runs are the very text that was heard (bit k-1). | one byte: which run (1 to 4), the most alike, the shorter among equals; 0 for no fix (less than half alike, or nothing changed); 255 when a spelling has more than 4096 letters and numbers | 67 68 For op 3 Hop then asks macOS whether the address parses (and, with a scheme, names a machine). That last step is 69 Apple's parser, so it stays in Swift; the word lists and every other rule are in the Omega source. 70 71 ### Kind 4: corrected words 72 73 After Hop types a dictation into a field, it reads the field again later. Hop splits three texts into words (what 74 was dictated, the field before, the field after), drops the punctuation around each word and gives equal words 75 equal numbers. The body is three 32-bit little-endian counts, then that many 32-bit word numbers for each text. 76 77 The core finds the dictation in the field (its last whole occurrence), sets aside the words that are the same at 78 both ends, lines the rest up word by word (longest common subsequence) and answers a 16-bit count, then 14 bytes a 79 replaced run: where the removed words start in the field before (32-bit), how many (16-bit), where the typed words 80 start in the field after (32-bit) and how many (32-bit). A run counts when 1 to 3 words were removed, all of them 81 inside the dictation, and something was typed in their place. The answer is empty when the dictation is not in the 82 field, when the changed part is too large (words before times words after over 250000), or when more than half of 83 the dictation was removed (a rewrite, not a fix). Hop then asks kind 3 op 5 which of the typed words are the fix. 84 85 ### Kind 5: a board line, a time 86 87 A swarm's board is a text file with one post a line (`