Artifact fd5dce7a3352664923bc59ae34b528421d831a0dd2cc3ef01a7be61f49311c2d:
- File
src/curate.html
— part of check-in
[cef6a0ad45]
at
2026-11-17 07:37:01
on branch trunk
— suit curate writes a page for deciding what each asset is worth keeping
suit curate [--since DAYS] [--out FILE] runs a usage scan and writes one self-contained HTML page, mode 0600, atomically, to curate.html in suit's home folder or to FILE. It changes no wardrobe file, config, stamp or ledger. The page names projects and stays on this machine; it loads nothing from the network and has no inline handlers.
Each skill, agent and command in the wardrobes is a row: uses in the window and in each of the last four weeks, last used, the projects it was used in, its description and what that costs every session, where it is worn, whether it is in the attic, and whether it is the owner's or an upstream's. Origin comes from the entries of the check-in the upstream's record names, so an upstream's skills beside the owner's own in skills/ are told apart. A name in two wardrobes is tagged with its wardrobe.
Each row starts from a suggestion with its reason: retire when unused in the window, unless its files changed within it; limit when three or more uses all came from one known project; otherwise keep. A folder that is not a known project cannot be limited to, and the page says how to make it one. The owner picks keep, limit or retire per row, with keys or in bulk on what is shown, and copies or saves the choices as a short text file. Applying it is a separate step, not in this check-in. The format is in docs/curate.md: one line per asset, `keep KIND WARDROBE NAME`, `retire KIND WARDROBE NAME`, or `personal KIND WARDROBE NAME PROJECT`.
The page is src/curate.html, turned into a C array at build time with od and awk, so the release build needs no other tool. Values are written as JSON with markup characters, U+2028 and U+2029 escaped and invalid UTF-8 replaced. The page script has its own test, run under node where node is installed and reported as skipped elsewhere. A new fuzz target covers the front-matter reader and the JSON writer.
Page sizes: 37 KB for the test fixture, 252 KB for 500 assets, 805 KB at the 4096-asset bound.
A new suite, test/curate.sh, with 288 cases, is part of the gate.
2993 unit checks (was 2855), 620 shell cases, 1153 store cases, 846 placement cases, 378 project cases, 236 usage cases and 288 curate cases, under clang, under gcc 16, with no user name set, and under a strict umask, in one run of make gate (66 minutes, on a loaded machine; one earlier run failed only the loaded speed measurement, at 1.06 to 1.11 ms, and this run passed it at 0.99 ms). 100% coverage in all 31 source files. No existing case was changed. (user: dmestas, size: 31291) [annotate] [blame] [check-ins using]
<!doctype html> <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"> <title>Wardrobe curation</title> <style> :root{/* Layout: header and outcome panel, sticky filter bar, one list of rows (a table on wide screens), sticky result bar at the foot, notes last */ --bg:#f7f8f7;--surface:#eef1ef;--panel:#ffffff;--fg:#18201d;--muted:#5b6661;--faint:#8a9590;--line:#dfe4e1;--line-strong:#c6ceca; --accent:#1f6a5a;--accent-soft:#e3f0ec;--keep:#256f47;--keep-soft:#e2f1e7;--limit:#7d5700;--limit-soft:#f6ecd0;--retire:#a3352e;--retire-soft:#f8e4e1;--bar:#2f7f6d;--bar-off:#cfd6d2; --font-body:"Instrument Sans",system-ui,-apple-system,"Segoe UI",sans-serif;--font-mono:"IBM Plex Mono",ui-monospace,Menlo,Consolas,monospace;color-scheme:light} @media (prefers-color-scheme:dark){:root:not([data-theme="light"]){--bg:#121615;--surface:#1a201e;--panel:#171c1a;--fg:#e7ece9;--muted:#9ba6a1;--faint:#6f7a75;--line:#2a3330;--line-strong:#3b4642; --accent:#7fcdb9;--accent-soft:#1b302b;--keep:#7fd09c;--keep-soft:#17301f;--limit:#e3b45c;--limit-soft:#33290f;--retire:#f09a91;--retire-soft:#3a1d1a;--bar:#6dbfaa;--bar-off:#38423e;color-scheme:dark}} :root[data-theme="dark"]{--bg:#121615;--surface:#1a201e;--panel:#171c1a;--fg:#e7ece9;--muted:#9ba6a1;--faint:#6f7a75;--line:#2a3330;--line-strong:#3b4642; --accent:#7fcdb9;--accent-soft:#1b302b;--keep:#7fd09c;--keep-soft:#17301f;--limit:#e3b45c;--limit-soft:#33290f;--retire:#f09a91;--retire-soft:#3a1d1a;--bar:#6dbfaa;--bar-off:#38423e;color-scheme:dark} *{box-sizing:border-box}html{scroll-padding-top:70px} body{margin:0;background:var(--bg);color:var(--fg);font:15px/1.5 var(--font-body);-webkit-font-smoothing:antialiased} main{max-width:72rem;margin:0 auto;padding:28px 16px 0;display:grid;gap:18px}main>*{min-width:0;margin:0} h1{font-size:1.7rem;line-height:1.15;letter-spacing:-.01em;text-wrap:balance}h2{font-size:1.1rem;line-height:1.3}h3{font-size:.95rem} p{margin:0}.muted{color:var(--muted)}.eyebrow{font-size:.76rem;letter-spacing:.07em;text-transform:uppercase;color:var(--muted);font-weight:600} .lede{max-width:44rem;color:var(--muted)} code,.mono,textarea{font-family:var(--font-mono);font-size:.88em}code{background:var(--surface);padding:1px 5px;border-radius:4px} kbd{font-family:var(--font-mono);font-size:.78em;border:1px solid var(--line-strong);border-bottom-width:2px;border-radius:4px;padding:0 5px;background:var(--panel)} a{color:var(--accent)} button{font:inherit;color:var(--fg);background:var(--panel);border:1px solid var(--line-strong);border-radius:6px;padding:5px 11px;cursor:pointer} button:hover{border-color:var(--muted)} :focus-visible{outline:2px solid var(--accent);outline-offset:2px} /* outcome panel */ .outcome{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(270px,100%),1fr));gap:20px 32px;padding:18px 20px;background:var(--panel);border:1px solid var(--line);border-radius:10px} .outcome>div{display:grid;gap:8px;align-content:start;min-width:0} .split{display:flex;height:12px;border-radius:6px;overflow:hidden;background:var(--bar-off)} .split i{display:block;height:100%}.split .k{background:var(--keep)}.split .l{background:var(--limit)}.split .r{background:var(--retire)} .legend{display:flex;flex-wrap:wrap;gap:4px 16px;font-size:.9rem}.legend b{font-variant-numeric:tabular-nums} .dot{display:inline-block;width:9px;height:9px;border-radius:2px;margin-right:6px;vertical-align:1px} .meter{display:grid;grid-template-columns:4.2rem 1fr auto;gap:6px 10px;align-items:center;font-size:.9rem} .meter .track{height:10px;border-radius:5px;background:var(--bar-off);overflow:hidden}.meter .track i{display:block;height:100%;background:var(--bar)} .meter .v{font-variant-numeric:tabular-nums;white-space:nowrap} /* toolbar */ .bar{position:sticky;top:0;z-index:3;background:var(--bg);padding:10px 0;display:flex;flex-wrap:wrap;gap:8px 8px;align-items:center;border-bottom:1px solid var(--line)} .bar input[type=search]{font:inherit;color:var(--fg);background:var(--panel);border:1px solid var(--line-strong);border-radius:6px;padding:6px 10px;width:12rem;max-width:100%;min-width:0} .seg{display:inline-flex;max-width:100%;overflow-x:auto;border:1px solid var(--line-strong);border-radius:7px;overflow:hidden;background:var(--panel)} .seg button{border:0;border-radius:0;border-right:1px solid var(--line);padding:5px 10px;background:transparent;white-space:nowrap}.seg button:last-child{border-right:0} .seg button[aria-pressed="true"]{background:var(--accent-soft);color:var(--accent);font-weight:600} .seg button .n{color:var(--faint);font-variant-numeric:tabular-nums;font-weight:400;margin-left:4px} .bulk{margin-left:auto;display:flex;flex-wrap:wrap;gap:6px;align-items:center;font-size:.9rem} /* list */ .list{border:1px solid var(--line);border-radius:10px;background:var(--panel);overflow:hidden} .head,.row{display:grid;grid-template-columns:minmax(10rem,1.25fr) 7.5rem 5.6rem minmax(7rem,.9fr) minmax(11rem,1.5fr) 13.5rem;gap:0 14px;align-items:center;padding:0 14px} .head{background:var(--surface);border-bottom:1px solid var(--line);font-size:.72rem;letter-spacing:.07em;text-transform:uppercase;color:var(--muted);font-weight:600} .head>*{padding:8px 0}.head button{all:unset;cursor:pointer}.head button:focus-visible{outline:2px solid var(--accent);outline-offset:2px} .head button[data-dir]::after{content:" ↓"}.head button[data-dir="asc"]::after{content:" ↑"} .item{border-bottom:1px solid var(--line)}.item:last-child{border-bottom:0} .row{min-height:44px;cursor:default}.row>*{padding:7px 0;min-width:0} .item:hover .row{background:var(--surface)}.item.cur .row{box-shadow:inset 3px 0 0 var(--accent);background:var(--accent-soft)} .item.retire .name,.item.retire .usedin{color:var(--muted)} .name{font-family:var(--font-mono);font-size:.86rem;font-weight:500;display:flex;align-items:center;gap:6px;min-width:0} .name button{all:unset;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.name button:focus-visible{outline:2px solid var(--accent);outline-offset:2px} .name button::before{content:"›";display:inline-block;width:.9em;color:var(--faint);font-family:var(--font-body)}.item.open .name button::before{content:"⌄"} .tag{font-family:var(--font-body);font-size:.7rem;border:1px solid var(--line-strong);border-radius:999px;padding:0 6px;color:var(--muted);white-space:nowrap;flex:none} .changed-dot{width:6px;height:6px;border-radius:50%;background:var(--accent);flex:none} .uses{display:flex;align-items:flex-end;gap:8px}.uses b{font-variant-numeric:tabular-nums;min-width:1.6em;text-align:right;font-weight:600}.uses b.zero{color:var(--faint);font-weight:400} .spark{display:flex;align-items:flex-end;gap:2px;height:20px}.spark i{display:block;width:7px;background:var(--bar);border-radius:1px;min-height:2px}.spark i.z{background:var(--bar-off)} .last{font-variant-numeric:tabular-nums;font-size:.86rem;color:var(--muted);white-space:nowrap} .usedin{font-size:.88rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .why b{font-weight:600;color:var(--fg)}.why{font-size:.84rem;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .pick{display:inline-flex;border:1px solid var(--line-strong);border-radius:7px;overflow:hidden;background:var(--panel);justify-self:end} .pick button{border:0;border-radius:0;border-right:1px solid var(--line);padding:4px 9px;background:transparent;font-size:.84rem;color:var(--muted);white-space:nowrap} .pick button:last-child{border-right:0}.pick button:disabled{color:var(--faint);opacity:.5;cursor:not-allowed} .pick button[aria-pressed="true"]{font-weight:600} .pick button.k[aria-pressed="true"]{background:var(--keep-soft);color:var(--keep)}.pick button.l[aria-pressed="true"]{background:var(--limit-soft);color:var(--limit)}.pick button.r[aria-pressed="true"]{background:var(--retire-soft);color:var(--retire)} .detail{display:none;padding:4px 14px 14px 30px;gap:14px 32px;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));font-size:.9rem;background:var(--surface)} .item.open .detail{display:grid}.item.open .row{background:var(--surface)} .detail dl{margin:0;display:grid;grid-template-columns:auto 1fr;gap:3px 12px}.detail dt{color:var(--muted)}.detail dd{margin:0;min-width:0;overflow-wrap:anywhere} .empty{padding:28px 14px;color:var(--muted);text-align:center} /* result bar */ .foot{position:sticky;bottom:0;z-index:3;margin:0 -16px;padding:10px 16px;background:var(--panel);border-top:1px solid var(--line-strong);display:flex;flex-wrap:wrap;gap:8px 16px;align-items:center} .foot .sum{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:.92rem;margin-right:auto}.foot .sum b{font-variant-numeric:tabular-nums} button.primary{background:var(--accent);border-color:var(--accent);color:var(--bg);font-weight:600}button.primary:hover{border-color:var(--accent);filter:brightness(1.08)} .notes{max-width:46rem;display:grid;gap:14px;padding:26px 0 40px}.notes>*{margin:0}.notes ul{padding-left:1.2rem;display:grid;gap:8px;margin:0} .notes h2{padding-top:18px;border-top:1px solid var(--line)} textarea{width:100%;min-height:11rem;color:var(--fg);background:var(--panel);border:1px solid var(--line-strong);border-radius:8px;padding:10px;line-height:1.45;resize:vertical} @media (max-width:860px){ .head{display:none} .row{grid-template-columns:1fr auto;grid-template-areas:"name uses" "usedin last" "why why" "pick pick";gap:2px 12px;padding:10px 14px} .row>*{padding:1px 0}.name{grid-area:name}.uses{grid-area:uses;justify-self:end}.last{grid-area:last;justify-self:end}.usedin{grid-area:usedin}.why{grid-area:why;white-space:normal}.pick{grid-area:pick;justify-self:start;margin-top:6px} .detail{padding-left:14px}.bulk{margin-left:0} .meter{grid-template-columns:3.4rem 1fr}.meter .v{grid-column:1/-1;white-space:normal;margin-bottom:4px} .outcome{padding:16px}.foot .sum{width:100%} } @media (prefers-reduced-motion:reduce){*{transition:none!important;scroll-behavior:auto!important}} </style></head><body><main> <header style="display:grid;gap:8px"> <p class="eyebrow" id="eyebrow"></p> <h1 id="headline"></h1> <p class="lede" id="lede"></p> <p class="lede" id="history" hidden></p> </header> <section class="outcome" aria-label="Outcome of your choices"> <div><p class="eyebrow">Your choices</p><div class="split" id="split"></div><div class="legend" id="legend"></div></div> <div><p class="eyebrow">Loaded into every session</p><div class="meter" id="meter"></div><p class="muted" id="meternote" style="font-size:.86rem"></p></div> </section> <div class="bar" role="toolbar" aria-label="Kind, filter and bulk actions"> <div class="seg" id="kinds" role="group" aria-label="Kind"></div> <input type="search" id="q" placeholder="Filter by name" aria-label="Filter by name"> <div class="seg" id="filters"></div> <div class="bulk"><span class="muted" id="shown"></span><button type="button" data-bulk="keep">Keep shown</button><button type="button" data-bulk="retire">Retire shown</button><button type="button" id="reset">Reset</button></div> </div> <div class="list"> <div class="head"><span><button type="button" data-s="n" id="h-name">Skill</button></span><span><button type="button" data-s="u" data-dir="desc" id="h-uses">Uses</button></span><span><button type="button" data-s="l">Last used</button></span><span>Used in</span><span>Suggestion and why</span><span style="text-align:right">Your choice</span></div> <div id="rows"></div> </div> <p class="muted" style="font-size:.86rem">Keyboard: <kbd>J</kbd> <kbd>K</kbd> or arrows move · <kbd>1</kbd> keep · <kbd>2</kbd> limit · <kbd>3</kbd> retire · <kbd>Enter</kbd> open details · <kbd>/</kbd> filter</p> <div class="foot" role="region" aria-label="Result"> <div class="sum" id="sum"></div><span class="muted" id="copied" role="status"></span> <button type="button" id="toggleout">Show choices file</button><button type="button" id="save">Save choices</button><button type="button" class="primary" id="copy">Copy choices</button> </div> <div id="outwrap" hidden><textarea id="out" readonly aria-label="The choices file, suit-choices.txt"></textarea></div> <section class="notes"> <h2>How to read this</h2> <ul> <li><b>Uses</b> are invocations found in the session records of the harnesses that describe them, for the last <span id="r-days"></span>; a call repeated by a resumed session counts once. The four bars are the last four weeks, oldest first. A name with a plugin in front, such as <code>plugin:name</code>, counts for <code>name</code>. <span id="r-harness"></span></li> <li><b>History is short.</b> A harness keeps its records for a limited time (Claude Code, about a month by default), and suit keeps a tally of its own only from its first scan on. Something you reach for twice a year can look unused. That is why nothing is ever deleted.</li> <li><b>Retire</b> will mean moving an asset to the outfit named <code>attic</code>, which nothing wears. It stays in the wardrobe and comes back with one line. <code>attic</code> is the name of an outfit, not a new word.</li> <li><b>Limit</b> is offered only when every use in the window came from one project. The asset would then be worn in that project only. When it is not offered, the tooltip of its button says why.</li> <li><b>Suggestions</b> follow one rule: retire when there are no uses, limit when three or more uses all came from one project, otherwise keep. An asset whose files changed within the window is kept even with no uses, because it has not had a fair window. An asset already in the attic starts as retire. With no usage recorded yet, every worn or loose asset starts as keep.</li> <li><b>Worn, attic, loose.</b> Worn: a wear of your wardrobes reaches it through an outfit. Attic: it is only in an outfit named <code>attic</code> or in outfits no wear names. Loose: no outfit lists it. A small tag with a wardrobe's name means another wardrobe holds an asset of the same kind and name.</li> <li id="r-skipped" hidden></li> <li><b>Names that matched nothing.</b> <span id="r-unmatched"></span></li> <li><b>Nothing changes on disk here, and nothing leaves this machine.</b> This page was written by <code>suit curate</code> with permission 0600 because it names your projects. It loads nothing from anywhere. The choices file at the foot is what a later step of suit will read; <code>suit curate</code> itself applies nothing.</li> </ul> </section> </main> <script> const DATA = @@DATA@@; const ASSETS = DATA.assets; const D = DATA.days; const NOUSAGE = DATA.events === 0; const KINDS = [['skill', 'Skills'], ['agent', 'Agents'], ['command', 'Commands']]; const LABEL = {keep: 'Keep', limit: 'Limit', retire: 'Retire'}; const days = n => n + (n === 1 ? ' day' : ' days'); const plural = (n, k) => k + (n === 1 ? '' : 's'); const isPath = k => k === '-' || k[0] === '~' || k[0] === '/'; const limitWhy = d => d.pn === 0 ? 'Not used in the last ' + days(D) + ', so there is no project to limit it to' : d.pn > 1 ? 'Used in more than one project' : d.p[0][0] === '-' ? 'Used only in sessions with no folder, which is not a project suit knows' : isPath(d.p[0][0]) ? 'Used only in ' + d.p[0][0] + ', which is not a project suit knows: add it with suit project set to be able to limit to it' : d.p[0][0].indexOf(' ') >= 0 ? 'The project name has a space, which the choices file cannot hold' : ''; const canLimit = d => limitWhy(d) === ''; function suggest(d){ if (d.s === 'attic') return ['retire', 'already in the attic']; if (NOUSAGE) return ['keep', 'no usage recorded yet']; if (d.u === 0) return d.fr ? ['keep', 'no uses yet · files changed recently'] : ['retire', 'no uses in ' + days(D)]; if (d.pn === 1) { const proj = d.p[0][0]; if (d.only.length === 1 && d.only[0] === proj) return ['keep', 'already limited to ' + proj]; if (d.u >= 3) return canLimit(d) ? ['limit', d.u + ' uses · all in ' + proj] : ['keep', d.u + ' uses · all in ' + proj + (isPath(proj) ? ' (not a known project)' : ' (cannot be limited: a space in the name)')]; } return ['keep', d.u + (d.u === 1 ? ' use' : ' uses') + ' · ' + d.pn + (d.pn === 1 ? ' project' : ' projects')]; } const twinOf = {}; ASSETS.forEach(d => { twinOf[d.k + ' ' + d.n] = (twinOf[d.k + ' ' + d.n] || 0) + 1; }); ASSETS.forEach((d, i) => { d.i = i; d.twin = twinOf[d.k + ' ' + d.n] > 1; const s = suggest(d); d.sug = s[0]; d.why = s[1]; d.choice = d.sug; }); const WMAX = Math.max.apply(null, [1].concat(ASSETS.map(d => Math.max.apply(null, d.wk)))); const FILTERS = [['all', 'All', () => true], ['unused', 'Unused', d => d.u === 0], ['one', 'One project', d => d.pn === 1], ['attic', 'In the attic', d => d.s === 'attic'], ['changed', 'Changed by me', d => d.choice !== d.sug]]; const countOf = k => ASSETS.filter(d => d.k === k).length; let kind = (KINDS.find(k => countOf(k[0]) > 0) || KINDS[0])[0]; let sortKey = 'u', sortDir = 'desc', filter = 'all', query = '', cur = null, open = {}; const $ = id => document.getElementById(id); const esc = s => String(s).replace(/[&<>"']/g, c => ({'&': '&', '<': '<', '>': '>', '"': '"', "'": '''}[c])); const kfmt = n => n >= 1000 ? (Math.round(n / 100) / 10) + 'k' : String(n); const inKind = () => ASSETS.filter(d => d.k === kind); function visible(){ const f = FILTERS.find(x => x[0] === filter)[2]; return inKind().filter(d => (!query || d.n.toLowerCase().indexOf(query) >= 0) && f(d)).sort((a, b) => { const x = a[sortKey], y = b[sortKey]; const c = typeof x === 'number' ? x - y : x < y ? -1 : x > y ? 1 : 0; return (sortDir === 'asc' ? c : -c) || (a.n < b.n ? -1 : a.n > b.n ? 1 : a.i - b.i); }); } function usedIn(d){ if (!d.pn) return '<span class="muted">nowhere</span>'; if (d.pn === 1) return esc(d.p[0][0]) + ' only'; return esc(d.p[0][0]) + ' <span class="muted">+' + (d.pn - 1) + '</span>'; } const stateText = d => d.s === 'worn' ? 'worn: ' + d.wr.join('; ') : d.s === 'attic' ? 'in the attic, or only in outfits nothing wears' : 'in no outfit'; const sizeText = d => (d.bt ? 'over ' : '') + (d.b < 1024 ? d.b + ' bytes' : (Math.round(d.b / 102.4) / 10) + ' KB'); function rowHtml(d){ const spark = d.wk.map(v => '<i' + (v ? ' style="height:' + Math.max(3, Math.round(20 * Math.sqrt(v / WMAX))) + 'px"' : ' class="z"') + '></i>').join(''); const pick = ['keep', 'limit', 'retire'].map(k => '<button type="button" class="' + k[0] + '" data-pick="' + k + '" aria-pressed="' + (d.choice === k) + '"' + (k === 'limit' && !canLimit(d) ? ' disabled title="' + esc(limitWhy(d)) + '"' : '') + '>' + LABEL[k] + '</button>').join(''); const projs = d.p.map(p => esc(p[0]) + ' <span class="muted">' + p[1] + '</span>').join(', ') + (d.po ? (d.p.length ? ', ' : '') + 'other projects <span class="muted">' + d.po + '</span>' : '') || 'none in the last ' + days(D); const none = d.k === 'skill' ? 'No description found in its SKILL.md.' : 'No description in its front matter.'; const i = d.i; return '<div class="item ' + d.choice + (cur === i ? ' cur' : '') + (open[i] ? ' open' : '') + '" data-i="' + i + '">' + '<div class="row"><div class="name">' + (d.choice !== d.sug ? '<span class="changed-dot" title="You changed this from the suggestion"></span>' : '') + '<button type="button" data-open aria-expanded="' + !!open[i] + '">' + esc(d.n) + '</button>' + (d.s === 'attic' ? '<span class="tag" title="Only in an outfit named attic, or in outfits no wear names">in the attic</span>' : '') + (d.twin ? '<span class="tag" title="A ' + d.k + ' of this name is in another wardrobe too">' + esc(d.w) + '</span>' : '') + '</div>' + '<div class="uses" title="' + d.wk.join(', ') + ' in the last four weeks, oldest first"><span class="spark" aria-hidden="true">' + spark + '</span><b class="' + (d.u ? '' : 'zero') + '">' + d.u + '</b></div>' + '<div class="last">' + (esc(d.l) || 'never') + '</div><div class="usedin">' + usedIn(d) + '</div>' + '<div class="why" title="' + esc(d.why) + '"><b>' + LABEL[d.sug] + '</b> · ' + esc(d.why) + '</div>' + '<div class="pick" role="group" aria-label="Choice for ' + esc(d.n) + '">' + pick + '</div></div>' + '<div class="detail"><div><p>' + (d.dl ? esc(d.t) + (d.tr ? '…' : '') : '<span class="muted">' + none + '</span>') + '</p></div>' + '<dl><dt>Uses by project</dt><dd>' + projs + '</dd><dt>90 days</dt><dd>' + d.u90 + (d.u90 === 1 ? ' use' : ' uses') + '</dd>' + '<dt>State</dt><dd>' + esc(stateText(d)) + '</dd><dt>Wardrobe</dt><dd>' + esc(d.w) + '</dd><dt>Comes from</dt><dd>' + esc(d.o) + '</dd>' + '<dt>Costs</dt><dd>' + (d.dl ? d.dl + ' bytes of description in every session' : 'no description') + ', ' + sizeText(d) + ' on disk</dd>' + '<dt>Files changed</dt><dd>' + (esc(d.m) || 'unknown') + '</dd></dl></div></div>'; } function headline(items){ const n = items.length; if (n === 0) return 'No ' + kind + 's are in your wardrobes.'; const first = n + ' ' + plural(n, kind) + (n === 1 ? ' is' : ' are') + ' in your wardrobes.'; if (NOUSAGE) return first + ' No usage has been recorded yet, so nothing worn or loose is suggested for retirement.'; const used = items.filter(d => d.u > 0).length; return first + ' ' + used + ' of them ' + (used === 1 ? 'was' : 'were') + ' used in the last ' + days(D) + '.'; } function historyNote(){ if (NOUSAGE || !DATA.oldest) return ''; const h = Math.round((Date.parse(DATA.made) - Date.parse(DATA.oldest)) / 86400000); return h < D ? 'The tally holds only ' + days(h) + ' of history (since ' + DATA.oldest + '), so "the last ' + days(D) + '" is shorter than it sounds.' : ''; } function render(keepFocus){ const v = visible(), all = inKind(); if (cur !== null && !v.some(d => d.i === cur)) cur = null; $('rows').innerHTML = v.map(rowHtml).join('') || '<div class="empty">No ' + kind + ' matches. Clear the filter to see all ' + all.length + '.</div>'; $('shown').textContent = v.length === all.length ? '' : v.length + ' shown'; $('kinds').innerHTML = KINDS.map(k => '<button type="button" data-k="' + k[0] + '" aria-pressed="' + (kind === k[0]) + '">' + k[1] + '<span class="n">' + countOf(k[0]) + '</span></button>').join(''); $('filters').innerHTML = FILTERS.map(f => '<button type="button" data-f="' + f[0] + '" aria-pressed="' + (filter === f[0]) + '">' + f[1] + '<span class="n">' + all.filter(f[2]).length + '</span></button>').join(''); $('headline').textContent = headline(all); const note = historyNote(); $('history').textContent = note; $('history').hidden = !note; $('h-name').textContent = kind[0].toUpperCase() + kind.slice(1); $('h-uses').textContent = 'Uses · ' + days(D); summary(); if (keepFocus && cur !== null) { const el = $('rows').querySelector('[data-i="' + cur + '"] [data-pick][aria-pressed="true"]'); if (el) el.focus({preventScroll: true}); } } function summary(){ const items = inKind(), by = k => items.filter(d => d.choice === k), K = by('keep'), L = by('limit'), R = by('retire'), N = items.length; const chars = a => a.reduce((s, d) => s + d.dl, 0), loaded = items.filter(d => d.s !== 'attic'), total = chars(loaded), after = chars(K); const pct = n => N ? 100 * n / N : 0; $('split').innerHTML = '<i class="k" style="width:' + pct(K.length) + '%"></i><i class="l" style="width:' + pct(L.length) + '%"></i><i class="r" style="width:' + pct(R.length) + '%"></i>'; $('split').setAttribute('aria-label', K.length + ' keep, ' + L.length + ' limit, ' + R.length + ' retire'); $('legend').innerHTML = '<span><i class="dot" style="background:var(--keep)"></i><b>' + K.length + '</b> keep</span><span><i class="dot" style="background:var(--limit)"></i><b>' + L.length + '</b> limit to a project</span><span><i class="dot" style="background:var(--retire)"></i><b>' + R.length + '</b> retire</span>'; $('meter').innerHTML = '<span class="muted">Today</span><span class="track"><i style="width:' + (total ? 100 : 0) + '%"></i></span><span class="v">' + loaded.length + ' ' + plural(loaded.length, kind) + ' · ' + kfmt(total) + ' bytes</span>' + '<span class="muted">After</span><span class="track"><i style="width:' + (total ? Math.min(100, 100 * after / total) : 0) + '%"></i></span><span class="v">' + K.length + ' ' + plural(K.length, kind) + ' · ' + kfmt(after) + ' bytes</span>'; const lost = R.reduce((s, d) => s + d.u, 0); $('meternote').textContent = lost ? 'Careful: the ' + kind + 's you are retiring were used ' + lost + ' times in the last ' + days(D) + '.' : 'None of the retired ' + kind + 's was used in the last ' + days(D) + '.'; const aK = ASSETS.filter(d => d.choice === 'keep').length, aL = ASSETS.filter(d => d.choice === 'limit').length, aR = ASSETS.filter(d => d.choice === 'retire').length; const diff = ASSETS.filter(d => d.choice !== d.sug).length; $('sum').innerHTML = '<span><b>' + aK + '</b> keep</span><span><b>' + aL + '</b> limit</span><span><b>' + aR + '</b> retire</span><span class="muted">' + (diff ? diff + ' changed from the suggestion' : 'all as suggested') + ' · all kinds</span>'; $('out').value = choicesText(); } const two = n => (n < 10 ? '0' : '') + n; function choicesText(){ const t = new Date(), today = t.getFullYear() + '-' + two(t.getMonth() + 1) + '-' + two(t.getDate()); return '# suit choices 1\n# made ' + today + ' from a page of ' + DATA.made + ', window ' + D + ' days\n' + ASSETS.map(d => (d.choice === 'limit' ? 'personal ' + d.k + ' ' + d.w + ' ' + d.n + ' ' + d.p[0][0] : d.choice + ' ' + d.k + ' ' + d.w + ' ' + d.n) + '\n').join(''); } function setChoice(i, k){ const d = ASSETS[i]; if (!d || (k === 'limit' && !canLimit(d))) return false; d.choice = k; cur = i; render(true); return true; } $('rows').addEventListener('click', e => { const item = e.target.closest('.item'); if (!item) return; const i = +item.dataset.i; const p = e.target.closest('[data-pick]'); if (p) { if (!p.disabled) setChoice(i, p.dataset.pick); return; } if (e.target.closest('[data-open]')) { open[i] = !open[i]; cur = i; render(); const b = $('rows').querySelector('[data-i="' + i + '"] [data-open]'); if (b) b.focus({preventScroll: true}); return; } cur = i; render(); }); $('kinds').addEventListener('click', e => { const b = e.target.closest('[data-k]'); if (!b) return; kind = b.dataset.k; cur = null; render(); }); $('filters').addEventListener('click', e => { const b = e.target.closest('[data-f]'); if (!b) return; filter = b.dataset.f; render(); }); $('q').addEventListener('input', e => { query = e.target.value.trim().toLowerCase(); render(); }); document.querySelectorAll('[data-s]').forEach(b => b.addEventListener('click', () => { if (sortKey === b.dataset.s) sortDir = sortDir === 'asc' ? 'desc' : 'asc'; else { sortKey = b.dataset.s; sortDir = sortKey === 'n' ? 'asc' : 'desc'; } document.querySelectorAll('[data-s]').forEach(x => x.removeAttribute('data-dir')); b.setAttribute('data-dir', sortDir); render(); })); document.querySelectorAll('[data-bulk]').forEach(b => b.addEventListener('click', () => { const v = visible(); v.forEach(d => d.choice = b.dataset.bulk); render(); $('copied').textContent = v.length + ' set to ' + b.dataset.bulk + '.'; })); $('reset').addEventListener('click', () => { inKind().forEach(d => d.choice = d.sug); render(); $('copied').textContent = 'Back to the suggestions for ' + kind + 's.'; }); $('toggleout').addEventListener('click', () => { const w = $('outwrap'); w.hidden = !w.hidden; $('toggleout').textContent = w.hidden ? 'Show choices file' : 'Hide choices file'; if (!w.hidden) w.scrollIntoView({block: 'nearest'}); }); const done = m => { $('copied').textContent = m; }; function refused(m){ const t = $('out'); $('outwrap').hidden = false; $('toggleout').textContent = 'Hide choices file'; t.focus(); t.select(); done(m); } $('copy').addEventListener('click', () => { const fallback = () => refused('Copy was refused. The text is selected: press Cmd+C.'); if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText($('out').value).then(() => done('Copied ' + ASSETS.length + ' choices.'), fallback); else fallback(); }); $('save').addEventListener('click', () => { try { const url = URL.createObjectURL(new Blob([$('out').value], {type: 'text/plain'})); const a = document.createElement('a'); a.href = url; a.download = 'suit-choices.txt'; document.body.appendChild(a); a.click(); document.body.removeChild(a); setTimeout(() => URL.revokeObjectURL(url), 1000); done('Saved suit-choices.txt.'); } catch (err) { refused('Saving was refused. The text is selected: copy it into a file named suit-choices.txt.'); } }); document.addEventListener('keydown', e => { const tag = (e.target.tagName || '').toLowerCase(); if (e.key === '/' && tag !== 'input' && tag !== 'textarea') { e.preventDefault(); $('q').focus(); return; } if (tag === 'input' || tag === 'textarea' || e.metaKey || e.ctrlKey || e.altKey) return; const v = visible(); if (!v.length) return; const i = v.findIndex(d => d.i === cur); const move = to => { cur = v[Math.max(0, Math.min(v.length - 1, to))].i; render(); const el = $('rows').querySelector('[data-i="' + cur + '"]'); if (el) el.scrollIntoView({block: 'nearest'}); }; if (e.key === 'j' || e.key === 'ArrowDown') { e.preventDefault(); move(i + 1); } else if (e.key === 'k' || e.key === 'ArrowUp') { e.preventDefault(); move(i < 0 ? 0 : i - 1); } else if (cur !== null && (e.key === '1' || e.key === '2' || e.key === '3')) { e.preventDefault(); const n = cur; if (setChoice(n, ['keep', 'limit', 'retire'][+e.key - 1])) { const w = visible(); const at = w.findIndex(d => d.i === n); if (at >= 0 && at < w.length - 1) move(at + 1); } } else if (cur !== null && e.key === 'Enter' && tag !== 'button') { e.preventDefault(); open[cur] = !open[cur]; render(); } }); function notes(){ $('eyebrow').textContent = 'suit · curation · made ' + DATA.made; $('lede').textContent = 'Each row is one asset with what you did with it. Pick Keep, Limit to one project, or Retire. Nothing on disk changes here; the choices file at the foot is what a later step of suit will read.'; $('r-days').textContent = days(D); $('r-harness').textContent = DATA.with.length ? 'Counted: ' + DATA.with.join(', ') + '.' + (DATA.without.length ? ' Not counted, no session rules: ' + DATA.without.join(', ') + '.' : '') : 'No harness has session rules, so nothing is counted.' + (DATA.without.length ? ' Without rules: ' + DATA.without.join(', ') + '.' : ''); if (DATA.skipped) { $('r-skipped').hidden = false; $('r-skipped').textContent = DATA.skipped + ' ' + plural(DATA.skipped, 'asset') + ' with a name suit cannot use (a name is letters, digits and . _ - only) ' + (DATA.skipped === 1 ? 'is' : 'are') + ' left out.'; } const u = DATA.unmatched; $('r-unmatched').innerHTML = u.n === 0 ? 'Every name used in the last ' + days(D) + ' is an asset of your wardrobes.' : u.n + ' ' + plural(u.n, 'name') + ' used in the last ' + days(D) + ' match nothing in your wardrobes: invocations of things suit does not manage, such as a harness\'s own built-ins. ' + (u.n > u.top.length ? 'The ' + u.top.length + ' used most: ' : 'They are: ') + u.top.map(t => '<code>' + esc(t[1]) + '</code> (' + t[0] + ', ' + t[2] + ')').join(', ') + '.'; } notes(); render(); </script></body></html>