lockpicks 0.7.1 → 0.8.0-go.11

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.
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env node
2
+ // The `lockpicks` npm launcher for the Go build of the Lockpick CLI, shipped
3
+ // as bin/lockpick.exe: it finds the platform package npm installed
4
+ // (`@lockpicks/cli-<os>-<cpu>`, an optional dependency) and runs its binary.
5
+ // The preinstall script (install.cjs) replaces this file with that binary
6
+ // wherever the package manager allows, so this is the fallback: install
7
+ // scripts skipped (`--ignore-scripts`, pnpm, bun without trust), yarn 2 and
8
+ // later, or yarn 1 and bun on Windows. LOCKPICK_LAUNCH tells the binary how
9
+ // it was launched, decided from this script's path exactly as the TypeScript
10
+ // CLI's launchKind decides it from its own (and as the binary decides it
11
+ // from its own path when it is the command).
12
+ 'use strict';
13
+
14
+ const { spawn } = require('node:child_process');
15
+ const { readFileSync, realpathSync } = require('node:fs');
16
+ const { delimiter, join, sep } = require('node:path');
17
+
18
+ const PACKAGE_DIR = `${sep}lockpicks${sep}`;
19
+
20
+ function real(path) {
21
+ try {
22
+ return realpathSync(path);
23
+ } catch {
24
+ return null;
25
+ }
26
+ }
27
+
28
+ // The version of the lockpicks install that holds file, or null.
29
+ function installedVersion(file) {
30
+ const at = file.lastIndexOf(PACKAGE_DIR);
31
+ if (at < 0) return null;
32
+ try {
33
+ const manifest = JSON.parse(
34
+ readFileSync(
35
+ join(file.slice(0, at + PACKAGE_DIR.length), 'package.json'),
36
+ 'utf8'
37
+ )
38
+ );
39
+ return manifest.name === 'lockpicks' && typeof manifest.version === 'string'
40
+ ? manifest.version
41
+ : null;
42
+ } catch {
43
+ return null;
44
+ }
45
+ }
46
+
47
+ // `path` when a `lockpick` on PATH is this file or another install of this
48
+ // package at this version (an older or newer global must not take over an
49
+ // npx run's MCP entry); then `npx`, `package` or `checkout`.
50
+ function launchKind(script, pathEnv, version) {
51
+ const self = real(script) ?? script;
52
+ const parts = self.split(sep);
53
+ const installed = parts.includes('node_modules');
54
+ const onPath = pathEnv.split(delimiter).some((dir) => {
55
+ const found =
56
+ dir && !dir.split(sep).includes('node_modules')
57
+ ? real(join(dir, 'lockpick'))
58
+ : null;
59
+ return (
60
+ found !== null &&
61
+ (found === self || (installed && installedVersion(found) === version))
62
+ );
63
+ });
64
+ if (onPath) return 'path';
65
+ if (parts.includes('_npx')) return 'npx';
66
+ return installed ? 'package' : 'checkout';
67
+ }
68
+
69
+ // Node itself reads `--env-file` and `--env-file-if-exists` from every
70
+ // argument up to a literal `--`, this script's own included, and loads the
71
+ // file into its environment before any JavaScript runs: a `NODE_OPTIONS` in
72
+ // it has already run its preloads by now, and its other variables would
73
+ // reach the binary. That is Node's behaviour, met by every Node launcher, and
74
+ // nothing here can undo it (the binary as the command, above, never meets
75
+ // it); the CLI's flag for a repository's env file is `--dotenv` so no one is
76
+ // told to pass it. Refuse the old name rather than hand the binary an
77
+ // environment the file chose.
78
+ const args = process.argv.slice(2);
79
+ const end = args.indexOf('--');
80
+ const nodeEnvFile = (end === -1 ? args : args.slice(0, end)).find((arg) =>
81
+ /^--env-file(?:-if-exists)?(?:=|$)/.test(arg)
82
+ );
83
+ if (nodeEnvFile !== undefined) {
84
+ process.stderr.write(
85
+ `✖ ${nodeEnvFile.split('=')[0]} is read by Node.js itself, before Lockpick starts, and loads that file into Node's own environment.\n` +
86
+ 'Name the file with --dotenv instead, for example: lockpick deep local . --dotenv .env\n'
87
+ );
88
+ process.exit(2);
89
+ }
90
+
91
+ const target = `@lockpicks/cli-${process.platform}-${process.arch}`;
92
+ let binary;
93
+ try {
94
+ binary = join(
95
+ require.resolve(`${target}/package.json`).slice(0, -'package.json'.length),
96
+ 'bin',
97
+ process.platform === 'win32' ? 'lockpick.exe' : 'lockpick'
98
+ );
99
+ } catch {
100
+ // npm installs the binary as an optional dependency. `--omit=optional`,
101
+ // `--no-optional`, an `omit=optional` npmrc or a mirror without the
102
+ // platform package skip it; anything else has no build at all.
103
+ const { version, optionalDependencies } = require('../package.json');
104
+ process.stderr.write(
105
+ target in (optionalDependencies ?? {})
106
+ ? `✖ Lockpick's binary for ${process.platform}-${process.arch} (the npm package ${target}) is not installed.\n` +
107
+ 'npm skips it when optional dependencies are turned off (--omit=optional, --no-optional or omit=optional in an npmrc),\n' +
108
+ 'or when a registry mirror does not carry it. Reinstall with optional dependencies:\n' +
109
+ ` npm install -g --allow-scripts=lockpicks lockpicks@${version} --include=optional (a global install)\n` +
110
+ ` npm install lockpicks@${version} --include=optional (in a project)\n` +
111
+ `If it is still missing, check \`npm config get omit\` and that your registry serves ${target}.\n`
112
+ : `✖ Lockpick has no build for ${process.platform}-${process.arch}.\n` +
113
+ 'The Node.js build of the CLI runs anywhere Node.js does: npm install -g lockpicks@0.7\n'
114
+ );
115
+ process.exit(1);
116
+ }
117
+
118
+ // The binary runs as a child so this launcher can pass on what reaches it:
119
+ // SIGINT, SIGTERM and SIGHUP (and Ctrl+Break on Windows) go to the binary,
120
+ // this process exits with the binary's code or signal, and the binary is
121
+ // killed if this process exits first. LOCKPICK_LAUNCHER_PID lets the binary
122
+ // stop on its own when this process is killed outright (SIGKILL, taskkill /F).
123
+ const child = spawn(binary, args, {
124
+ stdio: 'inherit',
125
+ env: {
126
+ ...process.env,
127
+ LOCKPICK_LAUNCH: launchKind(
128
+ process.argv[1] ?? '',
129
+ process.env.PATH ?? '',
130
+ require('../package.json').version
131
+ ),
132
+ LOCKPICK_LAUNCHER_PID: String(process.pid),
133
+ },
134
+ });
135
+ const forwarded = ['SIGINT', 'SIGTERM', 'SIGHUP'];
136
+ if (process.platform === 'win32') forwarded.push('SIGBREAK');
137
+ for (const signal of forwarded)
138
+ process.on(signal, () => {
139
+ if (child.exitCode === null && child.signalCode === null)
140
+ child.kill(signal);
141
+ });
142
+ process.on('exit', () => {
143
+ if (child.exitCode === null && child.signalCode === null) child.kill();
144
+ });
145
+ child.on('error', (error) => {
146
+ process.stderr.write(`✖ Could not start ${binary}: ${error.message}\n`);
147
+ process.exit(1);
148
+ });
149
+ child.on('exit', (code, signal) => {
150
+ if (signal) {
151
+ // Die of the same signal, so the shell sees what the binary saw.
152
+ for (const name of forwarded) process.removeAllListeners(name);
153
+ process.kill(process.pid, signal);
154
+ return;
155
+ }
156
+ process.exit(code ?? 1);
157
+ });
package/install.cjs ADDED
@@ -0,0 +1,81 @@
1
+ // The `lockpicks` preinstall script: it puts this platform's Lockpick binary
2
+ // where npm links the `lockpick` and `lockpicks` commands, so they run the
3
+ // binary itself and Node never reads their arguments (Node loads an
4
+ // `--env-file` named anywhere on its own command line before any JavaScript
5
+ // runs, a `NODE_OPTIONS` preload in it included).
6
+ //
7
+ // bin/lockpick.exe ships as the JavaScript launcher (lockpick.cjs). This
8
+ // script replaces it with a hard link to, or a copy of, the binary in
9
+ // `@lockpicks/cli-<os>-<cpu>`, only where the package manager links the
10
+ // commands after this script runs and runs the file they name as it is:
11
+ //
12
+ // - npm, everywhere (install, ci, update, rebuild, exec and npx link bins
13
+ // after preinstall; on Windows cmd-shim then sees no `#!` and calls the
14
+ // .exe directly). npm 12 runs it only when allowed
15
+ // (`--allow-scripts=lockpicks`, or the `allow-scripts` config);
16
+ // - yarn 1 and bun, on macOS and Linux, which link commands as symlinks.
17
+ //
18
+ // Anywhere else (pnpm, whose command scripts can already say `node <file>`
19
+ // when its build runs, as after `pnpm approve-builds`; yarn 2 and later, which
20
+ // run every bin with Node; yarn 1 and bun on Windows, whose shims are written
21
+ // before the script; `--ignore-scripts` or npm 12 without allow-scripts; a
22
+ // skipped optional dependency) the
23
+ // JavaScript launcher stays and runs the binary as before. Nothing here
24
+ // fails an install, reaches the network or runs the binary.
25
+ 'use strict';
26
+
27
+ const fs = require('node:fs');
28
+ const { dirname, join } = require('node:path');
29
+
30
+ function linksAfterScript(agent, platform) {
31
+ if (/^npm\//.test(agent)) return true;
32
+ return platform !== 'win32' && /^(?:yarn\/1\.|bun\/)/.test(agent);
33
+ }
34
+
35
+ function install() {
36
+ if (
37
+ !linksAfterScript(process.env.npm_config_user_agent ?? '', process.platform)
38
+ )
39
+ return;
40
+ const { version } = require('./package.json');
41
+ const target = `@lockpicks/cli-${process.platform}-${process.arch}`;
42
+ let manifest;
43
+ try {
44
+ manifest = require.resolve(`${target}/package.json`, {
45
+ paths: [__dirname],
46
+ });
47
+ } catch {
48
+ return; // optional dependencies skipped, or no build for this platform
49
+ }
50
+ // A hoisted copy of another version is not this package's binary.
51
+ if (require(manifest).version !== version) return;
52
+ const binary = join(
53
+ dirname(manifest),
54
+ 'bin',
55
+ process.platform === 'win32' ? 'lockpick.exe' : 'lockpick'
56
+ );
57
+ if (!fs.statSync(binary).isFile()) return;
58
+ // Renamed into place, never written through: bun and pnpm hard-link
59
+ // package files from their stores, and a half-written launcher must never
60
+ // be left behind.
61
+ const launcher = join(__dirname, 'bin', 'lockpick.exe');
62
+ const temp = `${launcher}.${process.pid}.tmp`;
63
+ try {
64
+ fs.rmSync(temp, { force: true });
65
+ try {
66
+ fs.linkSync(binary, temp);
67
+ } catch {
68
+ fs.copyFileSync(binary, temp);
69
+ }
70
+ fs.chmodSync(temp, 0o755);
71
+ fs.renameSync(temp, launcher);
72
+ } finally {
73
+ fs.rmSync(temp, { force: true });
74
+ }
75
+ }
76
+
77
+ try {
78
+ install();
79
+ } catch {
80
+ // The JavaScript launcher is still in place and runs the binary.
81
+ }
package/package.json CHANGED
@@ -1,7 +1,19 @@
1
1
  {
2
- "name": "lockpicks",
3
- "version": "0.7.1",
2
+ "bin": {
3
+ "lockpick": "bin/lockpick.exe",
4
+ "lockpicks": "bin/lockpick.exe"
5
+ },
4
6
  "description": "Lockpick from the terminal: device login, project status, findings, repair briefs, Pulse scans and an MCP server for coding agents",
7
+ "engines": {
8
+ "node": "\u003e=20.9.0"
9
+ },
10
+ "files": [
11
+ "bin",
12
+ "install.cjs",
13
+ "README.md",
14
+ "LICENSE",
15
+ "THIRD-PARTY-NOTICES.txt"
16
+ ],
5
17
  "keywords": [
6
18
  "lockpick",
7
19
  "security",
@@ -9,22 +21,27 @@
9
21
  "cli",
10
22
  "box"
11
23
  ],
12
- "type": "module",
13
- "bin": {
14
- "lockpick": "./dist/lockpick.mjs",
15
- "lockpicks": "./dist/lockpick.mjs"
24
+ "license": "SEE LICENSE IN LICENSE",
25
+ "name": "lockpicks",
26
+ "optionalDependencies": {
27
+ "@lockpicks/cli-darwin-arm64": "0.8.0-go.11",
28
+ "@lockpicks/cli-darwin-x64": "0.8.0-go.11",
29
+ "@lockpicks/cli-linux-arm": "0.8.0-go.11",
30
+ "@lockpicks/cli-linux-arm64": "0.8.0-go.11",
31
+ "@lockpicks/cli-linux-x64": "0.8.0-go.11",
32
+ "@lockpicks/cli-win32-arm64": "0.8.0-go.11",
33
+ "@lockpicks/cli-win32-x64": "0.8.0-go.11"
16
34
  },
17
- "files": [
18
- "dist",
19
- "README.md",
20
- "LICENSE",
21
- "THIRD-PARTY-NOTICES.txt"
22
- ],
23
- "dependencies": {
24
- "@napi-rs/keyring": "^2.1.0"
35
+ "publishConfig": {
36
+ "access": "public"
25
37
  },
26
- "engines": {
27
- "node": ">=20.9.0"
38
+ "repository": {
39
+ "directory": "apps/cli-go",
40
+ "type": "git",
41
+ "url": "git+https://github.com/promptadvisers/lockpick.git"
42
+ },
43
+ "scripts": {
44
+ "preinstall": "node install.cjs"
28
45
  },
29
- "license": "SEE LICENSE IN LICENSE"
30
- }
46
+ "version": "0.8.0-go.11"
47
+ }
@@ -1,37 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "platform": "darwin",
4
- "arch": "arm64",
5
- "nodeApiVersion": 8,
6
- "nodeHeadersVersion": "20.9.0",
7
- "compiler": "Apple clang version 17.0.0 (clang-1700.0.13.5)",
8
- "compilerSha256": "7f30f076d0e9c38f772a76449fca9da8cf97f6a3d43b94c90a00e4f9ce7ad39e",
9
- "compilerArguments": [
10
- "-std=c11",
11
- "-O2",
12
- "-Wall",
13
- "-Wextra",
14
- "-Werror",
15
- "-fPIC",
16
- "-D_POSIX_C_SOURCE=200809L",
17
- "-D_DARWIN_C_SOURCE=1",
18
- "-D_DEFAULT_SOURCE=1",
19
- "-DNAPI_VERSION=8",
20
- "-I<node-headers>",
21
- "-bundle",
22
- "-undefined",
23
- "dynamic_lookup",
24
- "<safe-io.c>",
25
- "-o",
26
- "<native-artifact>"
27
- ],
28
- "sourceSha256": "90cccce979b991f5c0c33e6c286dc76bcb4e69b85c3c89156e9ec29a3dc606e4",
29
- "headers": {
30
- "node_api.h": "a5a3e1ff20963d44d92587376202d727d1daf2606dca96c082c876d3a322b5c5",
31
- "node_api_types.h": "8d5d854088d5725fec9775510e0aeeeb790a41ad083c49bb721d950b86e6bd61",
32
- "js_native_api.h": "94c40b848fca067b0f2bade48ee5cf162fbe379ea6edf6087f94faf41d827461",
33
- "js_native_api_types.h": "7d805521f313d58ab00395b55019dbee8fa71cee21ef89e09521998e879a97b4",
34
- "node_version.h": "5f8e3f33a99a8a220c3d56409e1e4b4a6143e43b3dff184b78828536b11b9ab8"
35
- },
36
- "binarySha256": "2d5efe59b1845a66a4516440d900f0fe6c0db7d9c471ddaed941d49071f16f26"
37
- }
Binary file
@@ -1,37 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "platform": "darwin",
4
- "arch": "x64",
5
- "nodeApiVersion": 8,
6
- "nodeHeadersVersion": "20.9.0",
7
- "compiler": "Apple clang version 17.0.0 (clang-1700.0.13.5)",
8
- "compilerSha256": "7f30f076d0e9c38f772a76449fca9da8cf97f6a3d43b94c90a00e4f9ce7ad39e",
9
- "compilerArguments": [
10
- "-std=c11",
11
- "-O2",
12
- "-Wall",
13
- "-Wextra",
14
- "-Werror",
15
- "-fPIC",
16
- "-D_POSIX_C_SOURCE=200809L",
17
- "-D_DARWIN_C_SOURCE=1",
18
- "-D_DEFAULT_SOURCE=1",
19
- "-DNAPI_VERSION=8",
20
- "-I<node-headers>",
21
- "-bundle",
22
- "-undefined",
23
- "dynamic_lookup",
24
- "<safe-io.c>",
25
- "-o",
26
- "<native-artifact>"
27
- ],
28
- "sourceSha256": "90cccce979b991f5c0c33e6c286dc76bcb4e69b85c3c89156e9ec29a3dc606e4",
29
- "headers": {
30
- "node_api.h": "a5a3e1ff20963d44d92587376202d727d1daf2606dca96c082c876d3a322b5c5",
31
- "node_api_types.h": "8d5d854088d5725fec9775510e0aeeeb790a41ad083c49bb721d950b86e6bd61",
32
- "js_native_api.h": "94c40b848fca067b0f2bade48ee5cf162fbe379ea6edf6087f94faf41d827461",
33
- "js_native_api_types.h": "7d805521f313d58ab00395b55019dbee8fa71cee21ef89e09521998e879a97b4",
34
- "node_version.h": "5f8e3f33a99a8a220c3d56409e1e4b4a6143e43b3dff184b78828536b11b9ab8"
35
- },
36
- "binarySha256": "5d8f57fc535c3beb540e622affc0acd2ce7a383c98355b8f7493534b03d0d984"
37
- }
Binary file
@@ -1,35 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "platform": "linux",
4
- "arch": "arm64",
5
- "nodeApiVersion": 8,
6
- "nodeHeadersVersion": "20.9.0",
7
- "compiler": "cc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0",
8
- "compilerSha256": "6c3baa3d21eea32b960de4ad2d366d484ce1dd837eb85f4904e656758bfa1a6b",
9
- "compilerArguments": [
10
- "-std=c11",
11
- "-O2",
12
- "-Wall",
13
- "-Wextra",
14
- "-Werror",
15
- "-fPIC",
16
- "-D_POSIX_C_SOURCE=200809L",
17
- "-D_DARWIN_C_SOURCE=1",
18
- "-D_DEFAULT_SOURCE=1",
19
- "-DNAPI_VERSION=8",
20
- "-I<node-headers>",
21
- "-shared",
22
- "<safe-io.c>",
23
- "-o",
24
- "<native-artifact>"
25
- ],
26
- "sourceSha256": "90cccce979b991f5c0c33e6c286dc76bcb4e69b85c3c89156e9ec29a3dc606e4",
27
- "headers": {
28
- "node_api.h": "a5a3e1ff20963d44d92587376202d727d1daf2606dca96c082c876d3a322b5c5",
29
- "node_api_types.h": "8d5d854088d5725fec9775510e0aeeeb790a41ad083c49bb721d950b86e6bd61",
30
- "js_native_api.h": "94c40b848fca067b0f2bade48ee5cf162fbe379ea6edf6087f94faf41d827461",
31
- "js_native_api_types.h": "7d805521f313d58ab00395b55019dbee8fa71cee21ef89e09521998e879a97b4",
32
- "node_version.h": "5f8e3f33a99a8a220c3d56409e1e4b4a6143e43b3dff184b78828536b11b9ab8"
33
- },
34
- "binarySha256": "5b4d74de3d5227b85ee1c3d19afc97c5f216c754dd74242d57e8c17869f13c5f"
35
- }
Binary file
@@ -1,35 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "platform": "linux",
4
- "arch": "x64",
5
- "nodeApiVersion": 8,
6
- "nodeHeadersVersion": "20.9.0",
7
- "compiler": "cc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0",
8
- "compilerSha256": "821af3c74506283c179ca413bb33e6b528805a4dd8a5c09df125e5ad560a9e89",
9
- "compilerArguments": [
10
- "-std=c11",
11
- "-O2",
12
- "-Wall",
13
- "-Wextra",
14
- "-Werror",
15
- "-fPIC",
16
- "-D_POSIX_C_SOURCE=200809L",
17
- "-D_DARWIN_C_SOURCE=1",
18
- "-D_DEFAULT_SOURCE=1",
19
- "-DNAPI_VERSION=8",
20
- "-I<node-headers>",
21
- "-shared",
22
- "<safe-io.c>",
23
- "-o",
24
- "<native-artifact>"
25
- ],
26
- "sourceSha256": "90cccce979b991f5c0c33e6c286dc76bcb4e69b85c3c89156e9ec29a3dc606e4",
27
- "headers": {
28
- "node_api.h": "a5a3e1ff20963d44d92587376202d727d1daf2606dca96c082c876d3a322b5c5",
29
- "node_api_types.h": "8d5d854088d5725fec9775510e0aeeeb790a41ad083c49bb721d950b86e6bd61",
30
- "js_native_api.h": "94c40b848fca067b0f2bade48ee5cf162fbe379ea6edf6087f94faf41d827461",
31
- "js_native_api_types.h": "7d805521f313d58ab00395b55019dbee8fa71cee21ef89e09521998e879a97b4",
32
- "node_version.h": "5f8e3f33a99a8a220c3d56409e1e4b4a6143e43b3dff184b78828536b11b9ab8"
33
- },
34
- "binarySha256": "4f497e60ffabb4f7c089a054fd086b815a827dbac7071aab6f662ce18dfda264"
35
- }