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
15 changes: 15 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -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 |
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
30 changes: 17 additions & 13 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,35 @@ 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
}

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...
// noinspection JSValidateTypes
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)
const totalSize = configSize + layerSize
// debug('totalSize:', totalSize)
await cacheSet(key, totalSize, 60 * 60 * 4)
return totalSize
Expand Down
Loading