From 0cfeaacd74a6fabd25bafb9147acd5c900842d69 Mon Sep 17 00:00:00 2001 From: Shane <6071159+smashedr@users.noreply.github.com> Date: Fri, 12 Jun 2026 17:10:33 -0700 Subject: [PATCH 1/3] Fix Multi-Arch Image Size --- src/api.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/api.js b/src/api.js index 55e8792..49af066 100644 --- a/src/api.js +++ b/src/api.js @@ -97,16 +97,20 @@ export class GHCRApi { } debug('indexManifest.manifests?.length:', indexManifest.manifests?.length) - for (const m of indexManifest.manifests) { - await new Promise((resolve) => setTimeout(resolve, 50)) - const manifest = await this.getManifest(m.digest) - const configSize = manifest.config?.size || 0 - // debug('configSize:', configSize) - // noinspection JSUnresolvedReference - const layerSize = manifest.layers?.reduce((a, l) => a + (l.size || 0), 0) || 0 - // debug('layerSize:', layerSize) - totalSize += configSize + layerSize - } + // only process linux/amd64 or first item... + const m = + indexManifest.manifests.find( + (m) => m.platform?.os === 'linux' && m.platform?.architecture === 'amd64', + ) || indexManifest.manifests[0] + debug('indexManifest:', m) + await new Promise((resolve) => setTimeout(resolve, 50)) + const manifest = await this.getManifest(m.digest) + const configSize = manifest.config?.size || 0 + // debug('configSize:', configSize) + // noinspection JSUnresolvedReference + const layerSize = manifest.layers?.reduce((a, l) => a + (l.size || 0), 0) || 0 + // debug('layerSize:', layerSize) + totalSize = configSize + layerSize // debug('totalSize:', totalSize) await cacheSet(key, totalSize, 60 * 60 * 4) return totalSize From 9717f20eafbc97b77530080ccd66db8b6bf6703b Mon Sep 17 00:00:00 2001 From: Shane <6071159+smashedr@users.noreply.github.com> Date: Fri, 12 Jun 2026 17:26:18 -0700 Subject: [PATCH 2/3] Lint --- AGENTS.md | 15 +++++++++++++++ package.json | 2 +- src/api.js | 11 +++++------ 3 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..e178ec6 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,15 @@ +# Agent Guide + +Before answering any question that involves facts about ANYTHING, you MUST output at least one Read, WebFetch, or WebSearch tool call. +If your first output is text instead of a tool call, you have failed. + +## Commands + +ALWAYS use the `npm run *` command + +| Command | What it does | +| ------------------ | ------------------------------------- | +| `npm run dev` | Hot-reload dev server (nodemon + tsx) | +| `npm start` | Run compiled `dist/index.js` | +| `npm run lint` | ESLint on `src/` | +| `npm run prettier` | ALWAYS RUN AFTER EDITING FILES | diff --git a/package.json b/package.json index d31757c..9e703b9 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "dev": "npx nodemon src/app.js", "lint": "npx eslint src", - "lint:report": "npm run lint -- --output-file eslint_report.json --format json", + "prettier:": "npm run prettier:write", "prettier:check": "npx prettier --check .", "prettier:write": "npx prettier --write .", "start": "node src/app.js" diff --git a/src/api.js b/src/api.js index 49af066..9de08ba 100644 --- a/src/api.js +++ b/src/api.js @@ -82,15 +82,14 @@ export class GHCRApi { const indexManifest = await this.getManifest(tag) debug('mediaType:', indexManifest.mediaType) - let totalSize = 0 - if ( !indexManifest.mediaType.includes('list') && !indexManifest.mediaType.includes('index') ) { // debug('indexManifest - !list + !index:', indexManifest) + // noinspection JSUnresolvedReference const size = indexManifest.layers.reduce((sum, layer) => sum + layer.size, 0) - totalSize = size + (indexManifest.config.size || 0) + const totalSize = size + (indexManifest.config.size || 0) // debug('totalSize:', totalSize) await cacheSet(key, totalSize) return totalSize @@ -99,9 +98,9 @@ export class GHCRApi { debug('indexManifest.manifests?.length:', indexManifest.manifests?.length) // only process linux/amd64 or first item... const m = - indexManifest.manifests.find( + indexManifest.manifests?.find( (m) => m.platform?.os === 'linux' && m.platform?.architecture === 'amd64', - ) || indexManifest.manifests[0] + ) || indexManifest.manifests?.[0] debug('indexManifest:', m) await new Promise((resolve) => setTimeout(resolve, 50)) const manifest = await this.getManifest(m.digest) @@ -110,7 +109,7 @@ export class GHCRApi { // noinspection JSUnresolvedReference const layerSize = manifest.layers?.reduce((a, l) => a + (l.size || 0), 0) || 0 // debug('layerSize:', layerSize) - totalSize = configSize + layerSize + const totalSize = configSize + layerSize // debug('totalSize:', totalSize) await cacheSet(key, totalSize, 60 * 60 * 4) return totalSize From 723423ea3870d88f57d744654131237eb06b1a26 Mon Sep 17 00:00:00 2001 From: Shane <6071159+smashedr@users.noreply.github.com> Date: Fri, 12 Jun 2026 17:43:23 -0700 Subject: [PATCH 3/3] #norender IDE noinspection --- src/api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api.js b/src/api.js index 9de08ba..18af9f2 100644 --- a/src/api.js +++ b/src/api.js @@ -97,6 +97,7 @@ export class GHCRApi { debug('indexManifest.manifests?.length:', indexManifest.manifests?.length) // only process linux/amd64 or first item... + // noinspection JSValidateTypes const m = indexManifest.manifests?.find( (m) => m.platform?.os === 'linux' && m.platform?.architecture === 'amd64',