fingerprint 0.1.0: a page that checks whether a model answers like the one it claims to be (#516)
Adds the Fingerprint page plugin (packages/fingerprint): it checks whether a model behind the local magpie gateway answers like the model it claims to be.
Reviewed at 531ca11f4 (KaranocaVe). Run at that head merged with main 848497c, through mote-run on the Mac mini with Bun 1.4.2:
- bun run rebuild from the committed bun.lock (frozen, --ignore-scripts): typecheck, 30/30 tests, build; diff -r against the committed dist/ is empty.
- HOME=$(mktemp -d) bun test: 3838 pass, 0 fail. bun scripts/check.mjs: exit 0.
- Offline preload refusing every non-loopback fetch/socket: 30/30, nothing refused.
- Broken by hand, each red: ensureDetector() in bootstrap, dropping ttl: Infinity, validating the job after the download.
Maintainer decision: the reference data comes from two third-party hosts (lm.ikale.io, cdn.jsdmirror.com), only on an explicit Download or a valid job, and both are named on the page, in registry.json and the READMEs. It is data used locally to rank candidates and is sent nowhere; the @latest fallback has no pinned hash, so a bad snapshot would rank wrongly, which the page states.
Not on npm yet (E404): magpie installs it from the dist branch until an owner publishes the first version.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { mkdir, rm } from 'node:fs/promises';
|
||||
import { build as viteBuild } from 'vite';
|
||||
await rm('dist', { recursive: true, force: true });
|
||||
await mkdir('dist', { recursive: true });
|
||||
await viteBuild();
|
||||
const result = await Bun.build({
|
||||
entrypoints: ['src/plugin.ts', 'src/cli.ts'],
|
||||
outdir: 'dist',
|
||||
target: 'bun',
|
||||
minify: true,
|
||||
packages: 'bundle',
|
||||
});
|
||||
if (!result.success) {
|
||||
console.error(result.logs);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// Bun resolves the parent monorepo's workspaces during install. Build in an
|
||||
// isolated copy so this package's own frozen lockfile controls every dependency.
|
||||
import { cp, mkdtemp, rm } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { basename, join, resolve } from 'node:path';
|
||||
|
||||
const root = resolve(import.meta.dir, '..');
|
||||
const staging = await mkdtemp(join(tmpdir(), 'fingerprint-rebuild-'));
|
||||
try {
|
||||
await cp(root, staging, {
|
||||
recursive: true,
|
||||
filter: (path) => !['node_modules', 'dist', '.git'].includes(basename(path)),
|
||||
});
|
||||
for (const args of [
|
||||
[
|
||||
'install',
|
||||
'--frozen-lockfile',
|
||||
'--ignore-scripts',
|
||||
'--registry',
|
||||
'https://registry.npmjs.org',
|
||||
],
|
||||
['run', 'check'],
|
||||
]) {
|
||||
const process = Bun.spawn([Bun.argv[0], ...args], {
|
||||
cwd: staging,
|
||||
stdin: 'inherit',
|
||||
stdout: 'inherit',
|
||||
stderr: 'inherit',
|
||||
env: {
|
||||
...Bun.env,
|
||||
PATH: `${resolve(Bun.argv[0], '..')}:${Bun.env.PATH || ''}`,
|
||||
},
|
||||
});
|
||||
const code = await process.exited;
|
||||
if (code !== 0) throw new Error(`bun ${args.join(' ')} exited ${code}`);
|
||||
}
|
||||
await rm(join(root, 'dist'), { recursive: true, force: true });
|
||||
await cp(join(staging, 'dist'), join(root, 'dist'), { recursive: true });
|
||||
} finally {
|
||||
await rm(staging, { recursive: true, force: true });
|
||||
}
|
||||
Reference in New Issue
Block a user