feat(media-use): v2 media OS core (resolve cascade, providers, local generation, telemetry) + retire hyperframes-media

This commit is contained in:
Miguel Angel Simon Sierra
2026-07-06 23:41:05 -04:00
parent 676f461f6a
commit 5fe957363d
105 changed files with 2362 additions and 287 deletions
+11 -2
View File
@@ -29,8 +29,12 @@ function markComplete(entryDir) {
writeFileSync(join(entryDir, COMPLETE_SENTINEL), "", "utf8");
}
// The manifest helpers append their own ".media" to the dir they get, so the
// global manifest must be addressed by HOME, not by globalMediaDir() — passing
// the latter nested it at ~/.media/.media/manifest.jsonl, invisible to the
// Studio /api/assets/global route (which reads the documented flat path).
function readGlobalManifest() {
return readManifest(globalMediaDir());
return readManifest(homedir());
}
function validateCacheHit(match) {
@@ -55,6 +59,11 @@ export function cacheGetByEntity(entity) {
export function cachePut(filePath, record) {
const sha = contentHash(filePath);
// Idempotent: same content already promoted -> don't duplicate the global
// record. ponytail: skips usage_count bump; add it when the metric is needed.
const existing = readGlobalManifest().find((r) => r.sha === sha);
if (existing) return { sha, cached_path: existing.cached_path, deduped: true };
const dir = globalMediaDir();
const entryDir = cacheEntryDir(dir, sha);
mkdirSync(entryDir, { recursive: true });
@@ -69,7 +78,7 @@ export function cachePut(filePath, record) {
reusable: true,
cached_path: dest,
};
appendRecord(globalMediaDir(), globalRecord);
appendRecord(homedir(), globalRecord);
return { sha, cached_path: dest };
}