Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ The terminal tells you why your repo got its plan:
this repo is Tokyo: mostly small buildings (median 99 lines); 3.3 imports per file, so everything connects
```

Some repos also get a condition on top of their plan. A repo with no recent commits is a ghost town. One where most files haven't been touched in years is ancient ruins. A sudden rush of commits makes a boomtown, and a repo that's mostly tests is a garden city.
Some repos also get a condition on top of their plan. A repo with no recent commits is a ghost town. One where most files haven't been touched in years is ancient ruins. A sudden rush of commits makes a boomtown, and a repo that's mostly tests is a garden city. A repo twenty years old whose first five years still stand is an old walled city: a wall with towers and gates goes round the quarter where those founding files cluster, or round the whole city when they're spread all through it.

## How to read the city

Expand Down
2 changes: 1 addition & 1 deletion deploy/cloudflare/container/version.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// scanner changes what it finds: cities are cached per version, and the Worker only keeps a city from a
// container that says it runs this version (after a deploy, containers already running keep the old
// image for a while, and their cities mustn't be cached as new ones).
export const SCANNER = 8;
export const SCANNER = 9;
4 changes: 4 additions & 0 deletions src/classify.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ export function cityMetrics(city, now = Date.now() / 1000) {
const recentWindow = 90 * 86400;
const recentCommits = commits.filter(c => c[0] > end - recentWindow).length;
const avgPerWindow = commitCount / Math.max(1, seen / recentWindow);
// the old walled city: how many of the files still standing were built in the repo's first five years
const founded = city.truncated && city.firstCommit ? city.firstCommit : city.start;

return {
files: n,
Expand Down Expand Up @@ -232,6 +234,7 @@ export function cityMetrics(city, now = Date.now() / 1000) {
commitsPerWeek: commitCount / Math.max(1, seen / (7 * 86400)),
idleYears: history ? Math.max(0, (now - end) / YEAR) : 0,
staleShare: F.filter(f => end - f.last > 2 * YEAR).length / Math.max(1, n),
foundingShare: F.filter(f => f.born < founded + 5 * YEAR).length / Math.max(1, n),
recentBoost: avgPerWindow && commitCount >= 200 && recentCommits >= 30 ? recentCommits / avgPerWindow : 0,
hardware: (city.extras?.hardwareFiles || 0) > 0,
infraFiles: infraIdx.length,
Expand Down Expand Up @@ -353,6 +356,7 @@ const ARCHETYPES = {
const STATES = {
ruins: m => m.history && m.staleShare > 0.35 && m.ageYears > 4 && `ancient ruins: ${pct(m.staleShare)} of files untouched for 2+ years`,
ghost: m => m.history && m.idleYears > 1.5 && `ghost town: no commits for ${m.idleYears.toFixed(1)} years`,
walled: m => m.history && m.ageYears >= 20 && m.foundingShare >= 0.2 && `old walled city: ${pct(m.foundingShare)} of files date from its first five years, ${Math.floor(m.ageYears)} years ago`,
boom: m => m.history && m.recentBoost > 2.5 && `boomtown: ${m.recentBoost.toFixed(1)}× the usual commit rate lately`,
garden: m => m.testShare > 0.6 && `garden city: ${pct(m.testShare)} of the code is tests`,
maze: m => m.cycleShare > 0.5 && `old medina: ${pct(m.cycleShare)} of files sit in import cycles`,
Expand Down
1 change: 1 addition & 0 deletions test/snapshots/SNKRX.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"ageYears": 1.310410614241894,
"commitsPerWeek": 1.5210158948424426,
"staleShare": 0,
"foundingShare": 1,
"recentBoost": 0,
"hardware": false,
"infraFiles": 0,
Expand Down
1 change: 1 addition & 0 deletions test/snapshots/You-Dont-Know-JS.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"ageYears": 12.173959965269855,
"commitsPerWeek": 1.5474957466593235,
"staleShare": 0.8409090909090909,
"foundingShare": 0.8181818181818182,
"recentBoost": 0,
"hardware": false,
"infraFiles": 0,
Expand Down
1 change: 1 addition & 0 deletions test/snapshots/axum.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"ageYears": 4.853932998707126,
"commitsPerWeek": 4.540585715188863,
"staleShare": 0.07339449541284404,
"foundingShare": 1,
"recentBoost": 0,
"hardware": false,
"infraFiles": 0,
Expand Down
1 change: 1 addition & 0 deletions test/snapshots/flask.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"ageYears": 15.872805283038,
"commitsPerWeek": 1.9523790852940475,
"staleShare": 0.28,
"foundingShare": 0.72,
"recentBoost": 0,
"hardware": false,
"infraFiles": 0,
Expand Down
1 change: 1 addition & 0 deletions test/snapshots/gallery.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"ageYears": 4.083967665475194,
"commitsPerWeek": 1.7738517481402771,
"staleShare": 0.07407407407407407,
"foundingShare": 1,
"recentBoost": 0,
"hardware": false,
"infraFiles": 0,
Expand Down
1 change: 1 addition & 0 deletions test/snapshots/gson.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"ageYears": 17.625486126955156,
"commitsPerWeek": 1.285239865134112,
"staleShare": 0.2727272727272727,
"foundingShare": 0.5950413223140496,
"recentBoost": 0,
"hardware": false,
"infraFiles": 0,
Expand Down
1 change: 1 addition & 0 deletions test/snapshots/jq.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"ageYears": 13.832254480695617,
"commitsPerWeek": 1.3702857351105027,
"staleShare": 0.37209302325581395,
"foundingShare": 0.9069767441860465,
"recentBoost": 0,
"hardware": false,
"infraFiles": 0,
Expand Down
1 change: 1 addition & 0 deletions test/snapshots/ky.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"ageYears": 8.094338574543057,
"commitsPerWeek": 0.840533064359412,
"staleShare": 0.019230769230769232,
"foundingShare": 0.34615384615384615,
"recentBoost": 9.25338705587434,
"hardware": false,
"infraFiles": 0,
Expand Down
1 change: 1 addition & 0 deletions test/snapshots/nanoGPT.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"ageYears": 1.9501042221208202,
"commitsPerWeek": 1.09086993273011,
"staleShare": 0,
"foundingShare": 1,
"recentBoost": 0,
"hardware": false,
"infraFiles": 0,
Expand Down
1 change: 1 addition & 0 deletions test/snapshots/terraform-aws-eks.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"ageYears": 8.336243884199051,
"commitsPerWeek": 1.209269634892521,
"staleShare": 0.20454545454545456,
"foundingShare": 0.6590909090909091,
"recentBoost": 0,
"hardware": false,
"infraFiles": 88,
Expand Down
1 change: 1 addition & 0 deletions test/snapshots/uuid.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"ageYears": 12.440389256470707,
"commitsPerWeek": 0.14327050590446247,
"staleShare": 0.6190476190476191,
"foundingShare": 0.7142857142857143,
"recentBoost": 0,
"hardware": false,
"infraFiles": 0,
Expand Down
1 change: 1 addition & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@
<link rel="modulepreload" href="trees.js">
<link rel="modulepreload" href="rubble.js">
<link rel="modulepreload" href="layouts.js">
<link rel="modulepreload" href="walls.js">
<link rel="modulepreload" href="pixel.js">
<link rel="modulepreload" href="waiting.js">
<link rel="modulepreload" href="card.js">
Expand Down
9 changes: 8 additions & 1 deletion web/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';
import { hierarchy, treemap, treemapSquarify } from 'd3-hierarchy';
import { buildStudio } from './studio.js';
import { buildLayout, CITY_KINDS } from './layouts.js';
import { planWall, foundingEnd } from './walls.js';
import { createPixelPipeline } from './pixel.js';
import { rubbleMesh, RUBBLE_VERTEX } from './rubble.js';
import { PERF, HEAP, timed } from './perf.js';
Expand Down Expand Up @@ -171,6 +172,12 @@ if (layout) {
Object.assign(B[i], { x: l.x, z: l.z, w: l.w * 0.88, d: l.d * 0.88, rot: l.rot, y: base + (l.y || 0), h: Math.max(layout.heights[i], unit * 0.1) });
});
}
// an old walled city (twenty years on, its founding files still standing) keeps its old town behind a
// wall, whatever the plan; it goes up when the founding years end (not on the circuit board, which is
// no city: it has no old town to wall)
const wall = layout && STYLE !== 'chip' && data.identity?.states?.some(s => s.id === 'walled')
? timed('wall', () => { const until = foundingEnd(data), w = planWall({ layout, files, until }); return w && { ...w, born: Math.max(0, t01(until)) }; })
: null;

// ------------------------------------------------------------ renderer
// ?record=1&w=1920&h=1080&fps=30&dur=20 → deterministic frame capture driven by the CLI
Expand Down Expand Up @@ -433,7 +440,7 @@ const glowAttr = new Float32Array(N); // 1 for the buildings of the district und
// the circuit board's parts are fetched only for it
const chip = STYLE === 'chip' ? await import('./chip.js') : null;
const studio = NEON ? null : timed('studio (all)', () => buildStudio({ name: STYLE, scene, renderer, B, files, districts, unit, SIZE, plateStep, cx, cz,
shared, heat, focusAttr, glowAttr, inDeg, hub, t01, layout, chip }));
shared, heat, focusAttr, glowAttr, inDeg, hub, t01, layout, chip, wall }));
if (studio) {
document.body.classList.add('studio', `style-${STYLE}`);
if (studio.style.uiFont) document.body.style.setProperty('--ui-font', studio.style.uiFont);
Expand Down
27 changes: 20 additions & 7 deletions web/studio.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ export const STYLES = {
hemi: { sky: '#f6f3ee', ground: '#a69d90', intensity: 1.25 },
heightScale: 0.42, maxHeight: 4.5,
building: '#f1ede6', buildingJitter: 0.035, ground: '#d8d1c5', plate: '#e4ded4', roughness: 0.92,
rail: '#8f877c', water: '#b7c2c3', land: '#ddd6ca', yard: '#c9c4b8', dirt: '#c8b48f', sand: '#e6d8b5', dune: '#d6c49c', cliff: '#cbbfae', plaza: '#ece7de', park: '#c6cab0', lawn: '#d4d4bf', hill: '#d9d1c4', road: '#c9c1b4',
rail: '#8f877c', water: '#b7c2c3', land: '#ddd6ca', yard: '#c9c4b8', dirt: '#c8b48f', sand: '#e6d8b5', dune: '#d6c49c', cliff: '#cbbfae', plaza: '#ece7de', park: '#c6cab0', lawn: '#d4d4bf', hill: '#d9d1c4', road: '#c9c1b4', wall: '#d3cbbd',
windows: 0, accent: '#d8452b', edges: { color: '#2a2724', opacity: 0.07 },
toneMapping: THREE.NeutralToneMapping, exposure: 1.15, bloom: null,
ink: '#2a2724', inkSoft: 'rgba(42,39,36,.55)', font: "'Instrument Serif', Georgia, serif", labelCase: 'none',
},
plan: {
background: '#f1ede4', fog: null, flat: true,
building: '#1c1b1a', buildingJitter: 0, ground: '#f1ede4', plate: '#e7e2d7',
rail: '#2f5d7c', water: '#dce3e3', land: '#f1ede4', yard: '#e4e0d6', dirt: '#e0d2b6', sand: '#f1e7d0', dune: '#e6d9bc', cliff: '#ddd5c6', plaza: '#ece8df', park: '#e1e3d0', lawn: '#ebebdf', hill: '#e4dfd4', road: '#ddd7cb',
rail: '#2f5d7c', water: '#dce3e3', land: '#f1ede4', yard: '#e4e0d6', dirt: '#e0d2b6', sand: '#f1e7d0', dune: '#e6d9bc', cliff: '#ddd5c6', plaza: '#ece8df', park: '#e1e3d0', lawn: '#ebebdf', hill: '#e4dfd4', road: '#ddd7cb', wall: '#6b655c',
windows: 0, accent: '#d23c2a', edges: { color: '#d23c2a', opacity: 0.22 },
toneMapping: THREE.NoToneMapping, exposure: 1.0, bloom: null,
ink: '#1c1b1a', inkSoft: 'rgba(28,27,26,.55)', font: "'Instrument Serif', Georgia, serif", labelCase: 'upper',
Expand All @@ -38,7 +38,7 @@ export const STYLES = {
sun: { color: '#fff4e0', intensity: 2.6, elevation: 50, azimuth: 75 },
hemi: { sky: '#c4e4ee', ground: '#61944a', intensity: 1.0 },
building: '#bdb293', buildingJitter: 0.06, ground: '#61944a', plate: '#cdc8d2', roughness: 1,
rail: '#4a4458', water: '#2f6188', land: '#61944a', yard: '#9c97a8', dirt: '#968a6e', sand: '#dccfa4', dune: '#bdb293', cliff: '#968a6e', plaza: '#e0d7b8', park: '#3d6b36', lawn: '#93bf62', hill: '#3d6b36', road: '#6e6880',
rail: '#4a4458', water: '#2f6188', land: '#61944a', yard: '#9c97a8', dirt: '#968a6e', sand: '#dccfa4', dune: '#bdb293', cliff: '#968a6e', plaza: '#e0d7b8', park: '#3d6b36', lawn: '#93bf62', hill: '#3d6b36', road: '#6e6880', wall: '#968a6e',
windows: 0, accent: '#c0413b', edges: null,
toneMapping: THREE.NoToneMapping, exposure: 1.0, bloom: null,
ink: '#14121c', inkSoft: 'rgba(20,18,28,.7)', font: "'Pixelify Sans', monospace", uiFont: "'Pixelify Sans', monospace", labelCase: 'none',
Expand All @@ -49,7 +49,7 @@ export const STYLES = {
hemi: { sky: '#56607e', ground: '#17151a', intensity: 1.15 },
heightScale: 0.55, maxHeight: 6,
building: '#3d4049', buildingJitter: 0.04, ground: '#14161c', plate: '#24262e', roughness: 0.8,
rail: '#6d6050', water: '#0b1626', land: '#1c1e25', yard: '#25272e', dirt: '#2a241c', sand: '#2a2620', dune: '#221f1a', cliff: '#1d1f25', plaza: '#2d2f37', park: '#18211a', lawn: '#1b211d', hill: '#15161c', road: '#0e0f13',
rail: '#6d6050', water: '#0b1626', land: '#1c1e25', yard: '#25272e', dirt: '#2a241c', sand: '#2a2620', dune: '#221f1a', cliff: '#1d1f25', plaza: '#2d2f37', park: '#18211a', lawn: '#1b211d', hill: '#15161c', road: '#0e0f13', wall: '#3a3833',
windows: 1, windowColor: '#ffc27a', accent: '#ffc27a', edges: { color: '#ffc27a', opacity: 0.018 }, hubEdgeBoost: 3,
toneMapping: THREE.ACESFilmicToneMapping, exposure: 1.1, bloom: { strength: 0.35, radius: 0.4, threshold: 0.85 },
ink: '#e8e2d6', inkSoft: 'rgba(232,226,214,.55)', font: "'Instrument Serif', Georgia, serif", labelCase: 'none',
Expand Down Expand Up @@ -92,7 +92,7 @@ function slabEach(list) {
return geos.length ? mergeGeometries(geos) : null;
}

function buildTerrain(scene, layout, S, plateStep, shared, street, blockBorn) {
function buildTerrain(scene, layout, S, plateStep, shared, street, blockBorn, wall) {
const mat = color => S.flat ? new THREE.MeshBasicMaterial({ color })
: new THREE.MeshStandardMaterial({ color, roughness: 0.95, flatShading: true });
const add = (geo, color, surface) => {
Expand Down Expand Up @@ -213,6 +213,19 @@ function buildTerrain(scene, layout, S, plateStep, shared, street, blockBorn) {
mesh.castShadow = mesh.receiveShadow = !S.flat;
scene.add(mesh);
}
// the old town's wall (walls.js): stone runs along the streets, square towers with red roofs, all
// going up together when the founding years end. They stand from the ground up: round a whole city
// on the sea they cross the water between its islands, and stand in it rather than over it
if (wall) {
const wh = u * 0.5, ts = u * 0.46, th = wh * 1.8;
const grown = g => { const n = g.attributes.position.count, a = new Float32Array(n * 2); for (let k = 0; k < n; k++) { a[k * 2] = wall.born; a[k * 2 + 1] = 0; } return g.setAttribute('aGrow', new THREE.BufferAttribute(a, 2)); };
if (wall.walls.length) add(grown(mergeGeometries(wall.walls.map(([xa, za, xb, zb, t]) => new THREE.BoxGeometry(Math.hypot(xb - xa, zb - za), landTop + wh, t)
.rotateY(-Math.atan2(zb - za, xb - xa)).translate((xa + xb) / 2, (landTop + wh) / 2, (za + zb) / 2)))), S.wall);
if (wall.towers.length) {
add(grown(mergeGeometries(wall.towers.map(([x, z]) => new THREE.BoxGeometry(ts, landTop + th, ts).translate(x, (landTop + th) / 2, z)))), S.wall);
add(grown(mergeGeometries(wall.towers.map(([x, z]) => new THREE.ConeGeometry(ts * 0.78, ts * 0.8, 4).rotateY(Math.PI / 4).translate(x, landTop + th + ts * 0.4, z)))), S.accent);
}
}
for (const h of S.flat ? [] : layout.hills) { // seen from straight above, hills are just blobs
const mesh = new THREE.Mesh(new THREE.IcosahedronGeometry(1, 2), mat(S.hill));
mesh.scale.set(h.r, h.h, h.r * 0.8);
Expand All @@ -223,7 +236,7 @@ function buildTerrain(scene, layout, S, plateStep, shared, street, blockBorn) {
}

export function buildStudio(ctx) {
const { name, scene, renderer, B, files, districts, unit, SIZE, plateStep, cx, cz, shared, heat, focusAttr, inDeg, hub, t01, layout, chip } = ctx;
const { name, scene, renderer, B, files, districts, unit, SIZE, plateStep, cx, cz, shared, heat, focusAttr, inDeg, hub, t01, layout, chip, wall } = ctx;
// a desert city stands on sand: the open ground and the lawns between blocks become dunes
const S = layout?.sand ? { ...STYLES[name], land: STYLES[name].sand, lawn: STYLES[name].dune } : STYLES[name];
const N = files.length;
Expand Down Expand Up @@ -291,7 +304,7 @@ export function buildStudio(ctx) {
scene.add(ground);

// ---- city terrain from a planner: land, raised blocks, parks, plazas, bridges, hills
if (layout) timed('terrain', () => buildTerrain(scene, layout, S, plateStep, shared, street, streets?.blockBorn));
if (layout) timed('terrain', () => buildTerrain(scene, layout, S, plateStep, shared, street, streets?.blockBorn, wall));
// district names appear with their land
// (a district's name goes up with its land, ahead of its first building)
// (and not before the ground under the name itself has come up: a district's first file can be far off)
Expand Down
Loading
Loading