toolaby 1.7.2 → 1.8.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/README.md +1 -1
- package/bin.mjs +8 -7
- package/lib/check.js +2 -2
- package/lib/manifest.js +20 -6
- package/lib/project.js +18 -1
- package/lib/safe.js +10 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ The command is `toolaby-cli`: on Windows, the Command Prompt runs a `toolaby.js`
|
|
|
12
12
|
|
|
13
13
|
In a repository you did not write, use the installed command: `npx` can run a `toolaby` the project carries, or fetch one from a registry the project's `.npmrc` names.
|
|
14
14
|
|
|
15
|
-
Every command acts on the test Wall (`
|
|
15
|
+
Every command acts on the test Wall (`toolaby.app/test`) unless told `--live` (`toolaby.app`), as Stripe's command line does. `toolaby tools` lists your ids on either side.
|
|
16
16
|
|
|
17
17
|
## What it does
|
|
18
18
|
|
package/bin.mjs
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
// toolaby whoami · logout · help
|
|
18
18
|
//
|
|
19
19
|
// Test and live, as Stripe's command line has them: every command acts on
|
|
20
|
-
// the TEST Wall (
|
|
20
|
+
// the TEST Wall (toolaby.app/test) unless told `--live`, so the everyday
|
|
21
21
|
// command is the safe one and going live is a word you type on purpose.
|
|
22
22
|
// Signed in, the command acts as you and only on your tools, as Clerk's and
|
|
23
23
|
// Stripe's do: nothing is fetched for a tool your workspaces do not own. The
|
|
@@ -37,14 +37,14 @@ import { deflateRawSync } from 'node:zlib';
|
|
|
37
37
|
import { homedir } from 'node:os';
|
|
38
38
|
import { spawn } from 'node:child_process';
|
|
39
39
|
import { createHmac, randomBytes } from 'node:crypto';
|
|
40
|
-
import { wireManifest, drawsItself, WORKER_LINES, wallWorkerSource, configValues, wrappedBy, namedWorker as workerIn, startsPlatform as startsWall, CLASSIC_CLIENT } from './lib/manifest.js';
|
|
40
|
+
import { wireManifest, sitePattern, drawsItself, WORKER_LINES, wallWorkerSource, configValues, wrappedBy, namedWorker as workerIn, startsPlatform as startsWall, CLASSIC_CLIENT } from './lib/manifest.js';
|
|
41
41
|
import { wiringSummary, popupSwapIn, gatesIn, ownCode } from './lib/summary.js';
|
|
42
42
|
import { detectProject, CODE_FILES, POPUP_FILES, SIDE_PANEL_FILES, filesToWrite, fillPages, scaffoldManifest, scaffoldFilesFor, surfacesOf, hasPopup, hasSidePanel, SURFACES, STALE_FILES, BUILD_COPY_NOTE, AGENT_FILES, AGENT_ENTRY_FILES } from './lib/project.js';
|
|
43
43
|
import { runMcp } from './lib/mcp.js';
|
|
44
44
|
import { runCheck } from './lib/check.js';
|
|
45
45
|
import { inside, signInPage, devicePolling, opener, privateKind, privateContent, privateCopies, googleKey, projectRoot, gitDirectory, gitObject, gitObjects, gitFile, notAnImage, unpacked, COMPRESSED, publicLinks, privateLinks, oneLine, fetchBounded, fetchHere, readBounded, readText, SCAFFOLD_FILES } from './lib/safe.js';
|
|
46
46
|
|
|
47
|
-
const VERSION = '1.
|
|
47
|
+
const VERSION = '1.8.0';
|
|
48
48
|
const CLIENT_ID = 'toolaby-cli';
|
|
49
49
|
const argv = process.argv.slice(2);
|
|
50
50
|
// `--version` and `--help` are commands of their own; every other command is the first bare word.
|
|
@@ -54,7 +54,8 @@ const positional = rest.filter((a) => !a.startsWith('--'));
|
|
|
54
54
|
const opt = (k, d = null) => { const i = rest.indexOf(k); return i >= 0 && rest[i + 1] && !rest[i + 1].startsWith('--') ? rest[i + 1] : d; };
|
|
55
55
|
// `upgrade` is `wire --force`: the platform's files replaced with the current ones, the extension's own untouched.
|
|
56
56
|
const flag = (k) => rest.includes(k) || (k === '--force' && command === 'upgrade');
|
|
57
|
-
|
|
57
|
+
// Test shares Live's addresses under /test, as Stripe keeps both modes on its own hosts.
|
|
58
|
+
const WALLS = { test: 'https://toolaby.app/test', live: 'https://toolaby.app' };
|
|
58
59
|
const live = flag('--live');
|
|
59
60
|
// An address as fetch() reads it: a URL loses its tabs and line breaks when it is parsed, and kept in the name every
|
|
60
61
|
// message prints, a --wall or a TOOLABY_WALL with one in it drew lines of its own (25 Sep 2026).
|
|
@@ -732,7 +733,7 @@ function pack() {
|
|
|
732
733
|
// The Wall the key names must be reachable from the extension, or sign-in and the purchase handoff fail.
|
|
733
734
|
for (const site of sites) {
|
|
734
735
|
const hosts = manifest.host_permissions ?? []; const ec = manifest.externally_connectable?.matches ?? [];
|
|
735
|
-
if (!hosts.includes(
|
|
736
|
+
if (!hosts.includes(sitePattern(site)) || !ec.includes(sitePattern(site))) problems.push(`The manifest does not name ${oneLine(sitePattern(site))} in both host_permissions and externally_connectable: sign-in and the purchase would not reach the extension. \`npx -y toolaby@latest wire <tool-id> --live --force\` adds them.`);
|
|
736
737
|
}
|
|
737
738
|
if (problems.length) fail(`Not packed:\n\n${problems.map((p) => ` · ${p}`).join('\n\n')}`);
|
|
738
739
|
|
|
@@ -809,9 +810,9 @@ function help() {
|
|
|
809
810
|
webhooks endpoints your endpoints; add <url> registers one (secret shown once), remove <id> removes one
|
|
810
811
|
login · whoami · logout the session, per side; a command that needs one signs you in itself
|
|
811
812
|
|
|
812
|
-
Every command acts on Test (
|
|
813
|
+
Every command acts on Test (toolaby.app/test) unless told --live (toolaby.app).
|
|
813
814
|
--wall <url> or TOOLABY_WALL names any other Wall; TOOLABY_TOKEN a session, for CI —
|
|
814
|
-
sent to Live alone, or to the one Wall TOOLABY_TOKEN_WALL names (https://
|
|
815
|
+
sent to Live alone, or to the one Wall TOOLABY_TOKEN_WALL names (https://toolaby.app/test for Test).
|
|
815
816
|
|
|
816
817
|
In a repository you did not write, install it (npm i -g toolaby) and type toolaby-cli: npx can run a toolaby
|
|
817
818
|
the project carries, or fetch one from a registry its .npmrc names.
|
package/lib/check.js
CHANGED
|
@@ -8,7 +8,7 @@ import { join, relative, resolve } from 'node:path';
|
|
|
8
8
|
import { createHash } from 'node:crypto';
|
|
9
9
|
import { createRequire } from 'node:module';
|
|
10
10
|
import { oneLine, keySite, fetchBounded, readText } from './safe.js';
|
|
11
|
-
import { wrappedBy, namedWorker, startsPlatform as startsWall } from './manifest.js';
|
|
11
|
+
import { wrappedBy, namedWorker, startsPlatform as startsWall, sitePattern } from './manifest.js';
|
|
12
12
|
import { popupSwapIn, ownCode } from './summary.js';
|
|
13
13
|
|
|
14
14
|
const KEY = /tk_(test|live|dev)_[A-Za-z0-9_-]{20,}/;
|
|
@@ -118,7 +118,7 @@ export async function runCheck({ dir: given, out, api, token, detectProject, wir
|
|
|
118
118
|
else ok('The manifest has the permissions and host permissions the Wall needs.');
|
|
119
119
|
// The identity: without the `key`, each copy's id follows its folder, and once the extension is named the tool key refuses every copy not chosen.
|
|
120
120
|
if (typeof manifest.key !== 'string' && /manifestKey:\s*'[A-Za-z0-9+/]{100,}={0,2}'/.test(configText)) warn(`manifest.json has no "key": each copy's id then depends on its folder, and once your extension is named the tool key refuses any copy you did not choose on the Keys page. \`npx -y toolaby@latest upgrade ${key.slug}\` adds it.`);
|
|
121
|
-
} else warn(`The manifest is generated by ${project.label}: build, then check the built manifest has ${key.site}
|
|
121
|
+
} else warn(`The manifest is generated by ${project.label}: build, then check the built manifest has ${sitePattern(key.site)} in host_permissions and externally_connectable.`);
|
|
122
122
|
|
|
123
123
|
// 4b. The background starts the Wall: the popup and every page ask it everything, so without it nothing answers.
|
|
124
124
|
const upgrade = `\`npx -y toolaby@latest upgrade ${key.slug}\``;
|
package/lib/manifest.js
CHANGED
|
@@ -69,6 +69,19 @@ export const loadableName = (file) => {
|
|
|
69
69
|
};
|
|
70
70
|
/** The background the manifest names, as the folder spells it: "./background.js" is background.js. */
|
|
71
71
|
export const namedWorker = (manifest) => typeof manifest?.background?.service_worker === 'string' ? manifest.background.service_worker.trim().replace(/^(\.\/)+/, '') || null : null;
|
|
72
|
+
/**
|
|
73
|
+
* The match pattern a manifest names the Wall by: the origin of the key's site, whatever path follows it. Test shares
|
|
74
|
+
* Live's hosts under /test (`https://northwind.toolaby.app/test`), so one pattern — `https://northwind.toolaby.app/*` —
|
|
75
|
+
* lets the same build reach either side, and a Live wiring's manifest is the one it always was.
|
|
76
|
+
*/
|
|
77
|
+
export function sitePattern(site) {
|
|
78
|
+
try {
|
|
79
|
+
return `${new URL(site).origin}/*`;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return `${site.replace(/\/+$/, '')}/*`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
72
85
|
/**
|
|
73
86
|
* Whether an earlier wiring left the extension's own pages drawing the panel: a configuration that says '' for both
|
|
74
87
|
* pages while the manifest names none of the Wall's. That is what `create` makes, and the "your popup first" shape
|
|
@@ -110,16 +123,17 @@ export function wireManifest(input, o) {
|
|
|
110
123
|
did.push('the "storage" permission');
|
|
111
124
|
added.push('storage');
|
|
112
125
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
126
|
+
const pattern = sitePattern(o.site);
|
|
127
|
+
if (!(Array.isArray(manifest.host_permissions) && manifest.host_permissions.includes(pattern))) {
|
|
128
|
+
manifest.host_permissions = add(manifest.host_permissions, pattern);
|
|
129
|
+
did.push(`a host permission for ${host}`);
|
|
116
130
|
if (!added.includes(host))
|
|
117
131
|
added.push(host);
|
|
118
132
|
}
|
|
119
133
|
const ec = manifest.externally_connectable ?? {};
|
|
120
|
-
if (!(Array.isArray(ec.matches) && ec.matches.includes(
|
|
121
|
-
manifest.externally_connectable = { ...ec, matches: add(ec.matches,
|
|
122
|
-
did.push(`externally_connectable for ${
|
|
134
|
+
if (!(Array.isArray(ec.matches) && ec.matches.includes(pattern))) {
|
|
135
|
+
manifest.externally_connectable = { ...ec, matches: add(ec.matches, pattern) };
|
|
136
|
+
did.push(`externally_connectable for ${host}`);
|
|
123
137
|
if (!added.includes(host))
|
|
124
138
|
added.push(host);
|
|
125
139
|
}
|
package/lib/project.js
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
// Generated from wall/src/packages/wiring/project.ts by wall/scripts/pack-create.mjs — edit there.
|
|
2
|
+
/**
|
|
3
|
+
* What kind of extension project a folder is, and where the platform's
|
|
4
|
+
* files go in it — the same files for every kind. A plain extension has
|
|
5
|
+
* its manifest.json at the root and everything beside it. A framework
|
|
6
|
+
* (WXT, Plasmo, CRXJS) generates the manifest at build time, bundles the
|
|
7
|
+
* background, and copies a folder of files as they are: the client goes
|
|
8
|
+
* where the build can import it, the Wall's popup — and its side panel,
|
|
9
|
+
* where the extension has one — where the build copies verbatim. What the manifest and the background need is the framework's
|
|
10
|
+
* own extension point where it has one — WXT loads a module from modules/
|
|
11
|
+
* by itself, so the wiring writes one and nothing is pasted — and, where it
|
|
12
|
+
* has none (Plasmo, CRXJS), a snippet for its config: shown, never written
|
|
13
|
+
* into someone's TypeScript. Pure:
|
|
14
|
+
* given what is in the folder, it says what to write and what to say.
|
|
15
|
+
* Shared by the browser (rb/WireExtension) and the terminal
|
|
16
|
+
* (`toolaby wire`, which carries a transpiled copy).
|
|
17
|
+
*/
|
|
18
|
+
import { sitePattern } from './manifest.js';
|
|
2
19
|
/** What to tell a developer whose build ships the extension — the Wire button, the command and the Set up page all say it in these words. */
|
|
3
20
|
export const BUILD_COPY_NOTE = 'A build ships this extension: make sure it copies every toolaby* file to its output — toolaby.js, toolaby.config.js, toolaby-popup.html and the rest — the way it copies your popup.html.';
|
|
4
21
|
/** Always written, where the build imports from: the platform as one file (the client and the popup UI), its config, its types. */
|
|
@@ -109,7 +126,7 @@ export function detectProject(o) {
|
|
|
109
126
|
const worker = first(has, [`${src}background.ts`, `${src}background.js`, `${src}background/index.ts`, `${src}background/index.js`]);
|
|
110
127
|
const workerFile = worker ?? `${src}background.ts`;
|
|
111
128
|
const workerLines = `import { toolaby } from '${importPath(workerFile)}';\n\ntoolaby.startBackground();\n`;
|
|
112
|
-
const code = JSON.stringify({ manifest: { ...(o.manifestKey ? { key: o.manifestKey } : {}), permissions: ['storage'], host_permissions: [
|
|
129
|
+
const code = JSON.stringify({ manifest: { ...(o.manifestKey ? { key: o.manifestKey } : {}), permissions: ['storage'], host_permissions: [sitePattern(site)], externally_connectable: { matches: [sitePattern(site)] } } }, null, 2).replace(/^\{\n|\n\}$/g, '');
|
|
113
130
|
return {
|
|
114
131
|
kind: 'plasmo', label: 'Plasmo', codeDir: '', popupDir: '', manifestFile: null, wrapper: false, appPopup: null, appSidePanel: null, worker, built: false, foundManifest: null,
|
|
115
132
|
createWorker: worker ? null : { file: workerFile, content: workerLines },
|
package/lib/safe.js
CHANGED
|
@@ -60,15 +60,17 @@ export const oneLine = (value) => String(value).replace(/\s+/g, ' ').slice(0, 50
|
|
|
60
60
|
const wallScheme = (url) => url.protocol === 'https:' || (url.protocol === 'http:' && LOOPBACK.test(url.hostname));
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
* The Wall a tool key names, when `check` may ask it anything: an origin, https or on this machine,
|
|
64
|
-
*
|
|
63
|
+
* The Wall a tool key names, when `check` may ask it anything: an origin, https or on this machine, with nothing after
|
|
64
|
+
* it but Test's `/test`, where Test shares Live's hosts — no other path, no query, no credentials, no other scheme.
|
|
65
|
+
* Null otherwise. The key is read from the project's own toolaby.config.js, and a
|
|
65
66
|
* cloned project's key sent `check`'s requests wherever it named: a server inside the developer's network, any path on
|
|
66
67
|
* any host (25 Sep 2026).
|
|
67
68
|
*/
|
|
68
69
|
export function keySite(site) {
|
|
69
70
|
let url;
|
|
70
71
|
try { url = new URL(site); } catch { return null; }
|
|
71
|
-
|
|
72
|
+
const path = url.pathname === '/' ? '' : url.pathname;
|
|
73
|
+
return (path === '' || path === '/test') && `${url.origin}${path}` === site && wallScheme(url) ? site : null;
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
/**
|
|
@@ -673,13 +675,17 @@ function publicLinkEntries(root, packed = null) {
|
|
|
673
675
|
/**
|
|
674
676
|
* The page `login` opens: the one the Wall gave, when it is the Wall's own over https — or, for a Wall on this
|
|
675
677
|
* machine, a page on this machine. Anything else is null, and is not opened: an address elsewhere, a downgrade to
|
|
676
|
-
* http, or a scheme such as file: that opens whatever it names.
|
|
678
|
+
* http, or a scheme such as file: that opens whatever it names. A Wall under a path gives a page under it: Test at
|
|
679
|
+
* toolaby.app/test approves its codes at toolaby.app/test/…, and Live's page of the same name knows none of them (a
|
|
680
|
+
* root path resolved against Test's own base loses /test: 29 Sep 2026).
|
|
677
681
|
*/
|
|
678
682
|
export function signInPage(link, wall) {
|
|
679
683
|
if (typeof link !== 'string') return null;
|
|
680
684
|
let home; let page;
|
|
681
685
|
try { home = new URL(wall); page = new URL(link, home); } catch { return null; }
|
|
682
686
|
if (page.username || page.password) return null;
|
|
687
|
+
const base = home.pathname.replace(/\/+$/, '');
|
|
688
|
+
if (base && page.pathname !== base && !page.pathname.startsWith(`${base}/`)) return null;
|
|
683
689
|
if (page.protocol === 'https:' && page.origin === home.origin) return page.href;
|
|
684
690
|
const web = page.protocol === 'http:' || page.protocol === 'https:';
|
|
685
691
|
return web && LOOPBACK.test(home.hostname) && LOOPBACK.test(page.hostname) ? page.href : null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolaby",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "The Toolaby command line: sign in once, then wire any Chrome extension to your tool on the Wall — sign-in, the Free plan, licences and subscriptions — or start a new one; check it, and give coding agents the Wall as an MCP server.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|