splinter: thinking in the chat pane, no more ?????
Three things the operator asked for, and one bug he found:
1. The reasoning moved out of the sidebar into the left pane, above the answer,
dimmed - the same place every other harness puts it. While a turn runs it
scrolls with PgUp/PgDn; afterwards it is appended to the transcript as a
'thinking' entry (capped at 1500 characters) so it can be read later.
2. ????? - glibc transliterates ß but turns ü into '?', so German answers came
back as question-mark soup. Letters now come from a table generated out of
Unicode's decompositions (tools/gen_decomp.py, 266 entries, U+00A0..U+024F,
German umlauts written out as ae/oe/ue), punctuation goes through iconv
(— -> --, … -> ...). Verified: 'ein — Gedankenstrich, „Zitat“, Auslassung…'
becomes 'ein -- Gedankenstrich, ,,Zitat", Auslassung...'.
3. Slices for the viewport now start and end on UTF-8 sequence boundaries: a
column offset could cut a character in half and draw a replacement glyph.
4. The shell tool ran the JSON as a command. 'run' received
{"command":"uname -sr"} and handed that string to popen. It now parses the
arguments (echo too) and falls back to the raw string for the mock transport.
Proven against kontron: the model called run, the observation was
'Linux 7.1.3+deb14-amd64 [exit status 0]', and it read that back correctly.
Sixteen test binaries green, test_ascii added for the transliteration.
This commit is contained in:
1 parent
34a0152d6c
commit
c87f7290f5
10 files changed
+760
-146
No files matched your search
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate the UTF-8 -> ASCII table for the screen.
|
||||
|
||||
Why this exists: glibc's iconv ASCII//TRANSLIT handles punctuation (— becomes
|
||||
--, … becomes ...) but not every accented letter - "grün" came back as "gr?n"
|
||||
while "weiß" became "weiss". A harness whose answers turn into question marks is
|
||||
unreadable, so the letters are mapped here, from Unicode's own decomposition,
|
||||
and iconv is used only for what is left.
|
||||
|
||||
Coverage: U+00A0..U+024F (Latin-1 Supplement and Latin Extended-A), which is
|
||||
every European letter this UI will meet.
|
||||
|
||||
Usage: gen_decomp.py > decomp_table.c
|
||||
"""
|
||||
import sys
|
||||
import unicodedata
|
||||
|
||||
# Letters whose ASCII form is not "base letter without accent".
|
||||
SPECIAL = {
|
||||
# German convention: an umlaut written out is ae/oe/ue, not a/e/u.
|
||||
0x00C4: "Ae", 0x00E4: "ae",
|
||||
0x00D6: "Oe", 0x00F6: "oe",
|
||||
0x00DC: "Ue", 0x00FC: "ue",
|
||||
0x00C6: "AE", 0x00E6: "ae", # AE ligature
|
||||
0x00D0: "D", 0x00F0: "d", # eth
|
||||
0x00D8: "O", 0x00F8: "o", # o slash
|
||||
0x00DE: "Th", 0x00FE: "th", # thorn
|
||||
0x00DF: "ss", # sharp s
|
||||
0x0110: "D", 0x0111: "d", # d with stroke
|
||||
0x0126: "H", 0x0127: "h", # h with stroke
|
||||
0x0131: "i", # dotless i
|
||||
0x0138: "k",
|
||||
0x0141: "L", 0x0142: "l", # l with stroke
|
||||
0x0152: "OE", 0x0153: "oe", # OE ligature
|
||||
0x0166: "T", 0x0167: "t", # t with stroke
|
||||
0x017F: "s", # long s
|
||||
}
|
||||
|
||||
|
||||
def ascii_for(cp: int) -> str:
|
||||
if cp in SPECIAL:
|
||||
return SPECIAL[cp]
|
||||
ch = chr(cp)
|
||||
decomposed = unicodedata.normalize("NFD", ch)
|
||||
base = "".join(c for c in decomposed if not unicodedata.combining(c))
|
||||
if len(base) == 1 and base.isascii() and base.isprintable():
|
||||
return base
|
||||
return ""
|
||||
|
||||
|
||||
def main() -> int:
|
||||
rows = []
|
||||
for cp in range(0x00A0, 0x0250):
|
||||
a = ascii_for(cp)
|
||||
if not a:
|
||||
continue
|
||||
rows.append((cp, a))
|
||||
|
||||
w = sys.stdout.write
|
||||
w("/*\n"
|
||||
" * Generated by tools/gen_decomp.py from Unicode decompositions.\n"
|
||||
" * Do not edit by hand. The UI transliterates with this table because the\n"
|
||||
" * vendored curses writes Latin-1 bytes for wide characters.\n"
|
||||
" */\n"
|
||||
"#include <stddef.h>\n"
|
||||
"#include \"decomp.h\"\n\n"
|
||||
"const struct sp_decomp sp_decomp_table[] = {\n")
|
||||
for cp, a in rows:
|
||||
esc = a.replace("\\", "\\\\").replace('"', '\\"')
|
||||
w("\t{ 0x%04x, \"%s\" },\n" % (cp, esc))
|
||||
w("};\n\n"
|
||||
"const size_t sp_decomp_count = "
|
||||
"sizeof(sp_decomp_table) / sizeof(sp_decomp_table[0]);\n")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in new issue
Block a user