@ponderdev/justfits 0.0.0-stage → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "@ponderdev/justfits",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "productName": "Just Fits",
4
+ "version": "1.3.0",
5
+ "description": "Make a file small enough to send. Compresses video and images to an exact size limit, entirely on your own machine.",
6
+ "author": {
7
+ "name": "PonderDev",
8
+ "url": "https://ponderdev.com"
9
+ },
10
+ "homepage": "https://ponderdev.com",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/ponder-dev/just-fits.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/ponder-dev/just-fits/issues"
17
+ },
18
+ "license": "GPL-3.0-or-later",
19
+ "main": "src/main.cjs",
20
+ "desktopName": "com.ponderdev.justfits.desktop",
21
+ "bin": {
22
+ "justfits": "src/cli.cjs"
23
+ },
24
+ "scripts": {
25
+ "start": "node scripts/electron.cjs .",
26
+ "test": "node test/plan.test.cjs && node test/contract.test.cjs && node test/skill.test.cjs && node test/scripts.test.cjs && node test/linux-launcher.test.cjs && node test/encode.test.cjs",
27
+ "fetch-ffmpeg": "node scripts/fetch-ffmpeg.mjs",
28
+ "licences": "node scripts/make-licenses.mjs",
29
+ "icon": "npm run icon:svg && npm run icon:raster && npm run icon:icns",
30
+ "dist:mac": "node scripts/fetch-ffmpeg.mjs --mac && npm run icon && npm run licences && electron-builder --mac",
31
+ "dist:win": "node scripts/fetch-ffmpeg.mjs --win && npm run icon:svg && npm run icon:raster && npm run licences && electron-builder --win",
32
+ "dist": "node scripts/fetch-ffmpeg.mjs --all && npm run icon && npm run licences && electron-builder --mac --win --linux",
33
+ "cli": "node src/cli.cjs",
34
+ "test:linux": "./scripts/test-linux.sh",
35
+ "test:cli": "node test/cli.test.cjs && node test/safety.test.cjs",
36
+ "test:window": "node scripts/electron.cjs test/window.test.cjs",
37
+ "dist:linux": "node scripts/fetch-ffmpeg.mjs --linux && npm run icon:ensure && npm run licences && electron-builder --linux",
38
+ "icon:png": "npm run icon:svg && npm run icon:raster",
39
+ "icon:ensure": "node scripts/ensure-icon.cjs",
40
+ "icon:svg": "node scripts/make-icon.mjs",
41
+ "icon:raster": "node scripts/electron.cjs scripts/icons.cjs",
42
+ "icon:icns": "./scripts/make-icns.sh",
43
+ "postinstall": "node scripts/link-skill.cjs"
44
+ },
45
+ "files": [
46
+ "src/**/*",
47
+ "LICENSE",
48
+ "THIRD-PARTY-NOTICES.md",
49
+ "licenses/**/*",
50
+ "agents/**/*",
51
+ "scripts/link-skill.cjs"
52
+ ]
53
+ }
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ // Links this tool's agent skill into the folders AI assistants read skills
4
+ // from, when the command line is installed globally with npm, so the skill
5
+ // always matches the installed version (decided 2026-11-15: every Just tool
6
+ // ships its own skill; 2026-11-16: link it for Claude and for the shared folder).
7
+ //
8
+ // Two places, each with the same rules:
9
+ //
10
+ // - Claude Code: ~/.claude/skills/<tool>, or $CLAUDE_CONFIG_DIR/skills/<tool>,
11
+ // when that folder exists.
12
+ // - The shared folder most other assistants read (Codex, Gemini CLI,
13
+ // Copilot, Cursor, OpenCode, Amp, Goose): ~/.agents/skills/<tool>, when
14
+ // ~/.agents exists or one of those assistants is set up here.
15
+ //
16
+ // npm runs this as the package's postinstall. It does nothing unless the
17
+ // install is global (npm install -g), never in a project's node_modules or a
18
+ // checkout of this repo. In each place it links only when nothing is there or
19
+ // the link is one an earlier npm install of this tool left (an older Node,
20
+ // say, or one whose package has since been uninstalled); a folder, a file, or a link to anywhere else is left exactly as it is.
21
+ //
22
+ // The link points into the installed package, so updating the package updates
23
+ // the skill with no further step. It never fails the install: npm install
24
+ // --ignore-scripts skips it altogether. On Windows the link is a directory
25
+ // junction, which needs no admin rights.
26
+
27
+ const fs = require('fs');
28
+ const os = require('os');
29
+ const path = require('path');
30
+
31
+ // Folders whose presence says an assistant that reads ~/.agents/skills is set
32
+ // up on this machine.
33
+ const AGENT_HOMES = ['.agents', '.codex', '.gemini', '.copilot', '.cursor',
34
+ path.join('.config', 'opencode'), path.join('.config', 'amp'), path.join('.config', 'goose')];
35
+
36
+ function places(home) {
37
+ const out = [];
38
+ const claude = process.env.CLAUDE_CONFIG_DIR || path.join(home, '.claude');
39
+ if (fs.existsSync(claude)) out.push(path.join(claude, 'skills'));
40
+ if (AGENT_HOMES.some((d) => fs.existsSync(path.join(home, d)))) out.push(path.join(home, '.agents', 'skills'));
41
+ return out;
42
+ }
43
+
44
+ function main() {
45
+ if (process.env.npm_config_global !== 'true') return;
46
+
47
+ const pkg = require('../package.json');
48
+ const id = Object.keys(pkg.bin || {})[0];
49
+ if (!id) return;
50
+
51
+ const source = path.resolve(__dirname, '..', 'agents', 'skills', id);
52
+ if (!fs.existsSync(path.join(source, 'SKILL.md'))) return;
53
+
54
+ for (const skills of places(os.homedir())) {
55
+ try { link(source, skills, id); } catch (err) {
56
+ say(`${id}: skill not linked into ${skills}: ${err.message}`);
57
+ }
58
+ }
59
+ }
60
+
61
+ function link(source, skills, id) {
62
+ const dest = path.join(skills, id);
63
+ let st = null;
64
+ try { st = fs.lstatSync(dest); } catch { /* nothing there */ }
65
+
66
+ if (st && !st.isSymbolicLink()) {
67
+ say(`${id}: ${dest} is already there and not a link, so it was left alone. ` +
68
+ `Remove it and install again to use the skill that comes with ${id}.`);
69
+ return;
70
+ }
71
+ if (st) {
72
+ const old = path.resolve(skills, fs.readlinkSync(dest));
73
+ if (old === source) return;
74
+ // Only a link an earlier install of this tool left is replaced, whether
75
+ // or not its target is still there (an uninstall leaves one dangling).
76
+ // A link to anywhere else is someone's own, even a broken one.
77
+ if (!isOurs(old, id)) {
78
+ say(`${id}: ${dest} links to ${old}, so it was left alone.`);
79
+ return;
80
+ }
81
+ fs.unlinkSync(dest);
82
+ }
83
+
84
+ fs.mkdirSync(skills, { recursive: true });
85
+ fs.symlinkSync(source, dest, process.platform === 'win32' ? 'junction' : 'dir');
86
+ say(`${id}: linked its skill into ${dest}`);
87
+ }
88
+
89
+ // A link an earlier npm install of this same tool left behind.
90
+ function isOurs(target, id) {
91
+ return target.split(path.sep).includes('node_modules') &&
92
+ target.endsWith(path.join('agents', 'skills', id));
93
+ }
94
+
95
+ function say(line) { process.stderr.write(line + '\n'); }
96
+
97
+ try { main(); } catch (err) {
98
+ say(`skill not linked: ${err.message}`);
99
+ }
@@ -0,0 +1,106 @@
1
+ 'use strict';
2
+
3
+ /*
4
+ * Finding ffmpeg and ffprobe.
5
+ *
6
+ * The desktop app carries its own copies, because someone downloading a free
7
+ * app should not then have to install a video encoder. The command line does
8
+ * not: anyone using a terminal on Linux either has ffmpeg or can install it
9
+ * with one command, and a 300MB npm package to avoid that would be rude.
10
+ *
11
+ * So: the bundled copy if there is one, otherwise whatever is on PATH.
12
+ */
13
+
14
+ const fs = require('node:fs');
15
+ const path = require('node:path');
16
+ const { execFileSync } = require('node:child_process');
17
+
18
+ const EXE = process.platform === 'win32' ? '.exe' : '';
19
+
20
+ // What kind of program a file is, from its first bytes: 'linux' (ELF),
21
+ // 'darwin' (Mach-O, thin or universal) or 'win32' (a DOS/PE stub). null for a
22
+ // script or anything else.
23
+ function kindOf(file) {
24
+ try {
25
+ const fd = fs.openSync(file, 'r');
26
+ const head = Buffer.alloc(4);
27
+ try { fs.readSync(fd, head, 0, 4, 0); } finally { fs.closeSync(fd); }
28
+ const hex = head.toString('hex');
29
+ if (hex === '7f454c46') return 'linux';
30
+ if (['cffaedfe', 'cefaedfe', 'feedface', 'feedfacf', 'cafebabe', 'bebafeca'].includes(hex)) return 'darwin';
31
+ if (head.toString('latin1', 0, 2) === 'MZ') return 'win32';
32
+ } catch { /* unreadable, so not usable */ }
33
+ return null;
34
+ }
35
+
36
+ function fromDir(dir, name, platform = process.platform, arch = process.arch) {
37
+ if (!dir) return null;
38
+ const exe = platform === 'win32' ? '.exe' : '';
39
+ // The platform-and-arch name says what it is. The older names (an arch alone,
40
+ // or none) do not, and linux and mac both call themselves x64, so one of
41
+ // them is taken only if its own bytes say it is a program for this platform.
42
+ const exact = path.join(dir, `${name}-${platform}-${arch}${exe}`);
43
+ if (fs.existsSync(exact)) return exact;
44
+ for (const candidate of [`${name}-${arch}${exe}`, `${name}${exe}`]) {
45
+ const full = path.join(dir, candidate);
46
+ if (fs.existsSync(full) && kindOf(full) === platform) return full;
47
+ }
48
+ return null;
49
+ }
50
+
51
+ // Walks PATH ourselves. Minimal Linux images (Fedora minimal, slim Docker
52
+ // bases) often have no `which`, and its absence used to read as "ffmpeg not
53
+ // found" to someone who had ffmpeg installed.
54
+ function scanPath(name) {
55
+ for (const dir of (process.env.PATH || '').split(path.delimiter)) {
56
+ if (!dir) continue;
57
+ const full = path.join(dir, name + EXE);
58
+ try {
59
+ if (fs.statSync(full).isFile()) {
60
+ if (process.platform !== 'win32') fs.accessSync(full, fs.constants.X_OK);
61
+ return full;
62
+ }
63
+ } catch {}
64
+ }
65
+ return null;
66
+ }
67
+
68
+ function fromPath(name) {
69
+ const finder = process.platform === 'win32' ? 'where' : 'which';
70
+ try {
71
+ const found = execFileSync(finder, [name + EXE], { stdio: ['ignore', 'pipe', 'ignore'] })
72
+ .toString().split('\n')[0].trim();
73
+ return found || scanPath(name);
74
+ } catch (err) {
75
+ return scanPath(name);
76
+ }
77
+ }
78
+
79
+ /**
80
+ * @param name 'ffmpeg' or 'ffprobe'
81
+ * @param dirs vendor directories to try first, in order
82
+ * @param allowPath false for the packaged app, which must not depend on the
83
+ * machine having its own ffmpeg
84
+ */
85
+ function resolve(name, dirs = [], allowPath = true) {
86
+ for (const dir of dirs) {
87
+ const hit = fromDir(dir, name);
88
+ if (hit) return hit;
89
+ }
90
+ if (allowPath) {
91
+ const hit = fromPath(name);
92
+ if (hit) return hit;
93
+ }
94
+ const where = allowPath ? 'bundled or on PATH' : 'bundled';
95
+ throw new Error(
96
+ `${name} not found (${where}).\n` +
97
+ (allowPath
98
+ ? `Install it with your package manager, for example:\n` +
99
+ ` arch sudo pacman -S ffmpeg\n` +
100
+ ` debian sudo apt install ffmpeg\n` +
101
+ ` mac brew install ffmpeg`
102
+ : 'Run: npm run fetch-ffmpeg'),
103
+ );
104
+ }
105
+
106
+ module.exports = { resolve, fromDir, fromPath, kindOf };