okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-clean-3 (321794636): docs and history (cleanup step 3, items 3.0-3.10); release manifest and capability table with checks, history/ with pointers, link check, tools/ split, bench index; owner OK'd the wording 11-082b36e8a02

main
9.7 KiB88 linesraw
1from pathlib import Path
2root=Path(__file__).resolve().parent.parent
3def edit(file,old,new):
4 p=root/file;s=p.read_text();assert old in s,(file,old[:100]);p.write_text(s.replace(old,new))
5def append(file,text):
6 p=root/file;p.write_text(p.read_text()+text)
7append('src/lib/format.ts','''
8/** Identity comes from the host; never substitute a different real model. */
9export function formatModelName(model: {family:string;quant:string;name?:string}|null|undefined): string {
10  if (!model) return 'No model loaded';
11  const version = ({Q2_K:'Smallest',Q3_K_M:'Compact',Q4_K_M:'Balanced',Q5_K_M:'High quality',Q6_K:'Very high',Q8_0:'Near-original',BF16:'Original'} as Record<string,string>)[model.quant] ?? model.name;
12  return `${model.family} ยท ${version ? `${version} (${model.quant})` : model.quant}`;
13}
14export function userError(message: string): string {
15  return message.replace(/^\\s*Fixture:\\s*/i, '').replace(/^./, c => c.toUpperCase());
16}
17''')
18edit('src/components/ui.tsx',"import { cx } from '../lib/format';","import { cx, userError } from '../lib/format';")
19append('src/components/ui.tsx','''
20/** Shared, announced error with a cause and a concrete recovery action. */
21export function ErrorNotice({message, next, action, onRetry}: {message:string;next?:string;action?:string;onRetry?:()=>void}) {
22  return <div className="error-notice" role="alert"><Icon name="error" size={18}/><div><strong>{userError(message)}</strong>{next?<p>{next}</p>:null}</div>{onRetry?<Btn size="sm" onClick={onRetry}>{action??'Try again'}</Btn>:null}</div>;
23}
24export function PreviewBadge(){const demo=useStore(s=>s.library?.mode==='simulated');return demo?<span className="preview-badge">Preview build</span>:null;}
25''')
26edit('src/components/ui.tsx','style={{ left: placed.left, top: placed.top, width: placed.width }}',"style={{ left: placed.left, top: placed.top, width: placed.width, zIndex: triggerRef.current?.closest('[role=\"dialog\"]') ? 'var(--layer-dialog-popover)' : 'var(--layer-popover)' }}")
27edit('src/components/Popover.tsx','style={{...position,width,',"style={{...position,zIndex:anchor?.closest('[role=\"dialog\"]')?'var(--layer-dialog-popover)':'var(--layer-popover)',width,")
28edit('src/components/FloatingMenu.tsx','style={{ ...placed, width:',"style={{ ...placed, zIndex:anchor?.closest('[role=\"dialog\"]')?'var(--layer-dialog-popover)':'var(--layer-popover)', width:")
29edit('src/components/layout.tsx',"import type { ReactNode } from 'react';","import type { ReactNode } from 'react';\nimport { PreviewBadge } from './ui';")
30edit('src/components/layout.tsx','{title}</h1>','{title} <PreviewBadge/></h1>')
31edit('src/app/Sidebar.tsx',"import { cx, relTime }", "import { cx, relTime, formatModelName }")
32p=root/'src/app/Sidebar.tsx';s=p.read_text();start=s.index('  const modelName=');end=s.index('  const phase',start);s=s[:start]+"  const modelName=formatModelName(current);\n  const modelQuant=current ? 'Shared by all chats' : 'View model versions';\n"+s[end:];s=s.replace('<NavLink route="monitor"', '<NavLink route="skills" label="Skills" icon="thinking" current={location.route} />\n        <NavLink route="monitor"');s=s.replace('<NavLink route="serving" label="Serving" icon="link" current={location.route} meta={serving?.stats.running ? String(serving.stats.running) : undefined} />','<NavLink route="tuning" label="Engine" icon="gauge" current={location.route} /><NavLink route="models" label="Model" icon="layers" current={location.route} />');s=s.replace('More โ€” Skills, Models, Engine and Settings','More โ€” Serving and Settings').replace("['skills', 'models', 'tuning', 'settings']","['serving', 'settings']");s=s.replace("{ route: 'skills', label: 'Skills', icon: 'thinking' }, { route: 'models', label: 'Models', icon: 'layers' }, { route: 'tuning', label: 'Engine', icon: 'gauge' },", "{ route: 'serving', label: 'Serving', icon: 'link' },");s=s.replace('<label className="strong" htmlFor="chat-name">Chat name</label><input className="st-input" id="chat-name" value={name} onChange={e => setName(e.target.value)} />','<label className="input-field" htmlFor="chat-name"><span>Chat name</span><input className="st-input" id="chat-name" value={name} onFocus={e=>e.currentTarget.select()} onChange={e => setName(e.target.value)} /></label>');s=s.replace('<Btn variant="danger" onClick={() => { if (deleteId) deleteSession(deleteId);','<Btn onClick={() => { if (deleteId) toggleArchive(deleteId); setDeleteId(null); }}>Archive instead</Btn><Btn variant="danger" onClick={() => { if (deleteId) deleteSession(deleteId);');p.write_text(s)
33edit('src/lib/commands.ts',"label: 'Models'", "label: 'Model'")
34edit('src/lib/commands.ts',"slash: ['new', 'clear']", "slash: ['new']")
35edit('src/lib/commands.ts',"Check computer, choose model and load", "Check computer, pick a version and load")
36# Flags retain unfinished controls without presenting them as working features.
37(root/'src/lib/features.ts').write_text("export const features = { toolAccess: false, thinkingLevels: false, sessionLog: false, chatAttachments: false, demosInComposer: false } as const;\n")
38edit('src/components/ChatToolbar.tsx',"import { Btn, Dialog, Icon, IconBtn }", "import { Btn, Dialog, Icon, IconBtn, PreviewBadge }")
39edit('src/components/ChatToolbar.tsx',"import { SubagentRow }", "import { features } from '../lib/features';\nimport { SubagentRow }")
40edit('src/components/ChatToolbar.tsx','</h1><button ref={agentsRef}', '</h1><PreviewBadge/>{!!session?.agents?.length&&<button ref={agentsRef}')
41edit('src/components/ChatToolbar.tsx','size={13}/></button><span className="spacer"/>', 'size={13}/></button>}<span className="spacer"/>')
42edit('src/components/ChatToolbar.tsx','</button><button role="menuitem" className="menu__item" onClick={()=>{setMenu(false);setLog(true);}}>', '</button>{features.sessionLog&&<button role="menuitem" className="menu__item" onClick={()=>{setMenu(false);setLog(true);}}>')
43edit('src/components/ChatToolbar.tsx','Download Session Log</button></FloatingMenu>','Download session log</button>}</FloatingMenu>')
44edit('src/components/ChatToolbar.tsx','<Icon name="chevron" size={16}/></button>)}</div></Dialog>', '<span className="xs muted">Use template</span></button>)}</div></Dialog>')
45append('src/styles/app.css','''
46/* Audit fixes: shared states and overlay ownership. */
47:root { --layer-base: 0; --layer-sticky: 10; --layer-sidebar: 20; --layer-popover: 100; --layer-dialog: 160; --layer-dialog-popover: 180; --layer-toast: 200; }
48html, body { overflow: hidden; }
49.main__body, .dialog-body { scrollbar-gutter: stable; }
50.dialog-layer { z-index: var(--layer-dialog); }
51.dialog-scrim, .scrim { background: rgb(0 0 0 / .36); }
52[data-theme='dark'] .dialog-scrim, [data-theme='dark'] .scrim { background: rgb(0 0 0 / .55); }
53.dialog-surface, .palette, .setup__panel { opacity: 1; background: var(--st-surface); animation: none; }
54.dialog-head, .dialog-actions { flex-shrink: 0; }
55.select__pop { z-index: var(--layer-dialog-popover); background: var(--st-surface); }
56.menu, .anchored-popover { z-index: var(--layer-popover); background: var(--st-surface); }
57.st-btn--primary, .nav-new.st-btn--primary { background: #10b981; color: #0b1f17; border-color: #10b981; }
58.st-btn--primary:hover:not(:disabled), .nav-new.st-btn--primary:hover:not(:disabled) { background: #22ce95; color: #0b1f17; border-color: #22ce95; }
59.st-btn:disabled { background: var(--st-surface-2); border-color: var(--st-line); color: var(--st-ink-muted); opacity: .65; box-shadow: none; }
60.st-toggle[aria-checked='true'] { background: #10b981; border-color: #10b981; }
61.st-toggle[aria-checked='true']::after { background: #fff; }
62input[type='checkbox'], input[type='radio'] { accent-color: #10b981; }
63textarea { font-family: inherit; }
64.error-notice { display:flex; gap:10px; align-items:flex-start; padding:12px 14px; margin:12px 0; border:1px solid var(--st-danger-text); border-radius:12px; background:var(--st-surface); color:var(--st-danger-text); font-size:13px; }
65.error-notice > svg { flex-shrink:0; margin-top:2px; }
66.error-notice > div { flex:1; min-width:0; }
67.error-notice p { margin:4px 0 0; color:var(--st-ink-soft); }
68.st-input[aria-invalid='true'] { border-color:var(--st-danger-text); }
69.preview-badge { display:inline-flex; flex-shrink:0; align-items:center; border:1px solid var(--st-line); border-radius:6px; color:var(--st-ink-muted); padding:3px 6px; font-size:10px; font-weight:500; white-space:nowrap; }
70.st-msg { min-width:0; }
71.st-msg__meta { display:flex; flex-direction:row; flex-wrap:nowrap; min-width:0; width:100%; gap:8px; }
72.st-msg__actions { display:flex; flex-wrap:nowrap; opacity:0; }
73.st-msg:hover .st-msg__actions, .st-msg:focus-within .st-msg__actions { opacity:1; }
74.message-overflow { position:relative; }
75.message-overflow > div { position:absolute; top:100%; bottom:auto; left:0; min-width:240px; width:max-content; max-width:calc(100vw - 40px); background:var(--st-surface); border:1px solid var(--st-line); border-radius:12px; padding:10px; z-index:5; display:flex; flex-direction:column; align-items:stretch; box-shadow:var(--st-sh-pop); }
76.st-msg--user .message-overflow > div { left:auto; right:0; }
77.response-stats { white-space:nowrap; }
78.composer .st-composer textarea { min-height:44px; height:44px; max-height:180px; padding:12px 16px; }
79.composer { padding-top:10px; padding-bottom:10px; }
80.composer-model { max-width:270px; }
81.composer-model span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
82.chat-toolbar__conversation h1 { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
83.tool-summary { font-size:13px; color:var(--st-ink-soft); }
84.tool-summary summary { display:flex; align-items:center; gap:6px; font-weight:500; list-style:none; }
85.tool-summary summary::-webkit-details-marker { display:none; }
86.tool-summary[open] summary > svg:first-child { transform:rotate(180deg); }
87@media (hover:none) { .st-msg__actions { opacity:1; } }
88''')