@countinghouse/ch-local 0.0.0-stage → 1.0.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/LICENSE +202 -0
- package/README.md +361 -2
- package/bin/ch-local.js +472 -0
- package/clients/claude-code/.claude-plugin/plugin.json +6 -0
- package/clients/claude-code/.mcp.json +11 -0
- package/clients/claude-code/bin/launch.js +235 -0
- package/clients/claude-code/bin/win-acl.js +420 -0
- package/clients/claude-code/skills/ci-failure-triage/SKILL.md +21 -0
- package/clients/claude-code/skills/countinghouse-module/SKILL.md +177 -0
- package/clients/claude-code/skills/countinghouse-setup/SKILL.md +74 -0
- package/lib/allowlist.js +65 -0
- package/lib/aside.js +16 -0
- package/lib/atomic.js +45 -0
- package/lib/auto-apply.js +245 -0
- package/lib/auto-upgrade.js +98 -0
- package/lib/availability.js +307 -0
- package/lib/ceiling.js +280 -0
- package/lib/clean-text.js +20 -0
- package/lib/cli-change.js +38 -0
- package/lib/client-conditions-fixtures.js +143 -0
- package/lib/client-conditions.js +656 -0
- package/lib/clients.js +179 -0
- package/lib/command-line.js +202 -0
- package/lib/conditions-command.js +116 -0
- package/lib/control.js +134 -0
- package/lib/credential-store.js +414 -0
- package/lib/credentials-command.js +344 -0
- package/lib/daemon-requests.js +137 -0
- package/lib/daemon.js +888 -0
- package/lib/describe-module.js +137 -0
- package/lib/description-check.js +175 -0
- package/lib/failed-json.js +43 -0
- package/lib/gc.js +274 -0
- package/lib/github-token.js +57 -0
- package/lib/handoff-io.js +73 -0
- package/lib/held-back.js +116 -0
- package/lib/hidden-input.js +64 -0
- package/lib/history.js +49 -0
- package/lib/home.js +372 -0
- package/lib/in-place.js +1036 -0
- package/lib/install-plan.js +142 -0
- package/lib/install.js +846 -0
- package/lib/installed-description.js +153 -0
- package/lib/integrity.js +7 -0
- package/lib/lock.js +456 -0
- package/lib/lockfile-rules.js +98 -0
- package/lib/machine.js +20 -0
- package/lib/module-credentials.js +403 -0
- package/lib/module-record.js +298 -0
- package/lib/module-roles.js +44 -0
- package/lib/module-seams.js +26 -0
- package/lib/module-store.js +202 -0
- package/lib/module-values.js +334 -0
- package/lib/names.js +31 -0
- package/lib/next-steps.js +8 -0
- package/lib/node-check.js +56 -0
- package/lib/npm-fetch.js +123 -0
- package/lib/npm-release.js +99 -0
- package/lib/npm-upgrade.js +146 -0
- package/lib/npm.js +41 -0
- package/lib/outside-edits.js +162 -0
- package/lib/own-applied.js +175 -0
- package/lib/own-command.js +380 -0
- package/lib/own-file.js +120 -0
- package/lib/own-record.js +96 -0
- package/lib/own-tree.js +336 -0
- package/lib/pack-table.js +290 -0
- package/lib/packs-command.js +570 -0
- package/lib/packs.js +219 -0
- package/lib/pins.js +64 -0
- package/lib/pipe-probe.js +82 -0
- package/lib/plain-read.js +63 -0
- package/lib/private-file.js +90 -0
- package/lib/private-write.js +33 -0
- package/lib/provenance.js +234 -0
- package/lib/record.js +82 -0
- package/lib/registry.js +22 -0
- package/lib/release-pins.js +350 -0
- package/lib/release-pins.json +4225 -0
- package/lib/release-tags.js +12 -0
- package/lib/release.js +36 -0
- package/lib/restart-command.js +161 -0
- package/lib/rollback.js +227 -0
- package/lib/run-liveness.js +15 -0
- package/lib/runtime-log.js +287 -0
- package/lib/sandbox-support.js +17 -0
- package/lib/semver-order.js +40 -0
- package/lib/session-socket.js +69 -0
- package/lib/session-table.js +238 -0
- package/lib/session.js +281 -0
- package/lib/settings-command.js +82 -0
- package/lib/settings.js +564 -0
- package/lib/shim-binary.js +152 -0
- package/lib/shim-config.js +159 -0
- package/lib/shim-install.js +365 -0
- package/lib/sigstore/README.md +44 -0
- package/lib/sigstore/npm-keys.json +18 -0
- package/lib/sigstore/trusted-root.json +126 -0
- package/lib/snippets.js +76 -0
- package/lib/start.js +721 -0
- package/lib/store-files.js +48 -0
- package/lib/store-paths.js +33 -0
- package/lib/swap-preload.js +38 -0
- package/lib/tar.js +220 -0
- package/lib/uninstall.js +314 -0
- package/lib/unpack.js +41 -0
- package/lib/upgrade-stamp.js +63 -0
- package/lib/upgrade.js +281 -0
- package/lib/watch.js +40 -0
- package/lib/win-acl.js +420 -0
- package/node_modules/@sigstore/bundle/LICENSE +202 -0
- package/node_modules/@sigstore/bundle/README.md +19 -0
- package/node_modules/@sigstore/bundle/dist/build.d.ts +18 -0
- package/node_modules/@sigstore/bundle/dist/build.js +100 -0
- package/node_modules/@sigstore/bundle/dist/bundle.d.ts +74 -0
- package/node_modules/@sigstore/bundle/dist/bundle.js +24 -0
- package/node_modules/@sigstore/bundle/dist/error.d.ts +4 -0
- package/node_modules/@sigstore/bundle/dist/error.js +25 -0
- package/node_modules/@sigstore/bundle/dist/index.d.ts +8 -0
- package/node_modules/@sigstore/bundle/dist/index.js +43 -0
- package/node_modules/@sigstore/bundle/dist/serialized.d.ts +74 -0
- package/node_modules/@sigstore/bundle/dist/serialized.js +49 -0
- package/node_modules/@sigstore/bundle/dist/utility.d.ts +14 -0
- package/node_modules/@sigstore/bundle/dist/utility.js +2 -0
- package/node_modules/@sigstore/bundle/dist/validate.d.ts +7 -0
- package/node_modules/@sigstore/bundle/dist/validate.js +199 -0
- package/node_modules/@sigstore/bundle/package.json +35 -0
- package/node_modules/@sigstore/core/LICENSE +202 -0
- package/node_modules/@sigstore/core/README.md +10 -0
- package/node_modules/@sigstore/core/dist/asn1/error.d.ts +4 -0
- package/node_modules/@sigstore/core/dist/asn1/error.js +24 -0
- package/node_modules/@sigstore/core/dist/asn1/index.d.ts +1 -0
- package/node_modules/@sigstore/core/dist/asn1/index.js +20 -0
- package/node_modules/@sigstore/core/dist/asn1/length.d.ts +3 -0
- package/node_modules/@sigstore/core/dist/asn1/length.js +62 -0
- package/node_modules/@sigstore/core/dist/asn1/obj.d.ts +14 -0
- package/node_modules/@sigstore/core/dist/asn1/obj.js +155 -0
- package/node_modules/@sigstore/core/dist/asn1/parse.d.ts +6 -0
- package/node_modules/@sigstore/core/dist/asn1/parse.js +124 -0
- package/node_modules/@sigstore/core/dist/asn1/tag.d.ts +16 -0
- package/node_modules/@sigstore/core/dist/asn1/tag.js +89 -0
- package/node_modules/@sigstore/core/dist/crypto.d.ts +6 -0
- package/node_modules/@sigstore/core/dist/crypto.js +69 -0
- package/node_modules/@sigstore/core/dist/dsse.d.ts +1 -0
- package/node_modules/@sigstore/core/dist/dsse.js +29 -0
- package/node_modules/@sigstore/core/dist/encoding.d.ts +2 -0
- package/node_modules/@sigstore/core/dist/encoding.js +27 -0
- package/node_modules/@sigstore/core/dist/index.d.ts +9 -0
- package/node_modules/@sigstore/core/dist/index.js +66 -0
- package/node_modules/@sigstore/core/dist/json.d.ts +1 -0
- package/node_modules/@sigstore/core/dist/json.js +60 -0
- package/node_modules/@sigstore/core/dist/oid.d.ts +3 -0
- package/node_modules/@sigstore/core/dist/oid.js +20 -0
- package/node_modules/@sigstore/core/dist/pem.d.ts +2 -0
- package/node_modules/@sigstore/core/dist/pem.js +43 -0
- package/node_modules/@sigstore/core/dist/rfc3161/error.d.ts +2 -0
- package/node_modules/@sigstore/core/dist/rfc3161/error.js +21 -0
- package/node_modules/@sigstore/core/dist/rfc3161/index.d.ts +1 -0
- package/node_modules/@sigstore/core/dist/rfc3161/index.js +20 -0
- package/node_modules/@sigstore/core/dist/rfc3161/timestamp.d.ts +36 -0
- package/node_modules/@sigstore/core/dist/rfc3161/timestamp.js +212 -0
- package/node_modules/@sigstore/core/dist/rfc3161/tstinfo.d.ts +12 -0
- package/node_modules/@sigstore/core/dist/rfc3161/tstinfo.js +72 -0
- package/node_modules/@sigstore/core/dist/stream.d.ts +21 -0
- package/node_modules/@sigstore/core/dist/stream.js +117 -0
- package/node_modules/@sigstore/core/dist/x509/cert.d.ts +43 -0
- package/node_modules/@sigstore/core/dist/x509/cert.js +245 -0
- package/node_modules/@sigstore/core/dist/x509/ext.d.ts +41 -0
- package/node_modules/@sigstore/core/dist/x509/ext.js +146 -0
- package/node_modules/@sigstore/core/dist/x509/index.d.ts +2 -0
- package/node_modules/@sigstore/core/dist/x509/index.js +23 -0
- package/node_modules/@sigstore/core/dist/x509/sct.d.ts +25 -0
- package/node_modules/@sigstore/core/dist/x509/sct.js +158 -0
- package/node_modules/@sigstore/core/package.json +31 -0
- package/node_modules/@sigstore/protobuf-specs/LICENSE +202 -0
- package/node_modules/@sigstore/protobuf-specs/README.md +5 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/envelope.d.ts +44 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/envelope.js +59 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/events.d.ts +64 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/events.js +174 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/api/field_behavior.d.ts +74 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/api/field_behavior.js +141 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/any.d.ts +74 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/any.js +35 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/descriptor.d.ts +1309 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/descriptor.js +2191 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/timestamp.d.ts +113 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/timestamp.js +29 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/dsse.d.ts +23 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/dsse.js +55 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/entry.d.ts +43 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/entry.js +81 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/hashedrekord.d.ts +22 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/hashedrekord.js +56 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/verifier.d.ts +35 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/verifier.js +74 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_bundle.d.ts +146 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_bundle.js +103 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_common.d.ts +304 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_common.js +612 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_monitor.d.ts +33 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_monitor.js +55 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_rekor.d.ts +144 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_rekor.js +137 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_trustroot.d.ts +386 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_trustroot.js +284 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_verification.d.ts +191 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_verification.js +281 -0
- package/node_modules/@sigstore/protobuf-specs/dist/index.d.ts +6 -0
- package/node_modules/@sigstore/protobuf-specs/dist/index.js +37 -0
- package/node_modules/@sigstore/protobuf-specs/dist/rekor/v2/index.d.ts +4 -0
- package/node_modules/@sigstore/protobuf-specs/dist/rekor/v2/index.js +35 -0
- package/node_modules/@sigstore/protobuf-specs/package.json +35 -0
- package/node_modules/@sigstore/verify/README.md +9 -0
- package/node_modules/@sigstore/verify/dist/bundle/dsse.d.ts +12 -0
- package/node_modules/@sigstore/verify/dist/bundle/dsse.js +44 -0
- package/node_modules/@sigstore/verify/dist/bundle/index.d.ts +4 -0
- package/node_modules/@sigstore/verify/dist/bundle/index.js +59 -0
- package/node_modules/@sigstore/verify/dist/bundle/message.d.ts +13 -0
- package/node_modules/@sigstore/verify/dist/bundle/message.js +54 -0
- package/node_modules/@sigstore/verify/dist/error.d.ts +16 -0
- package/node_modules/@sigstore/verify/dist/error.js +34 -0
- package/node_modules/@sigstore/verify/dist/index.d.ts +6 -0
- package/node_modules/@sigstore/verify/dist/index.js +28 -0
- package/node_modules/@sigstore/verify/dist/key/certificate.d.ts +21 -0
- package/node_modules/@sigstore/verify/dist/key/certificate.js +216 -0
- package/node_modules/@sigstore/verify/dist/key/index.d.ts +10 -0
- package/node_modules/@sigstore/verify/dist/key/index.js +75 -0
- package/node_modules/@sigstore/verify/dist/key/sct.d.ts +4 -0
- package/node_modules/@sigstore/verify/dist/key/sct.js +78 -0
- package/node_modules/@sigstore/verify/dist/policy.d.ts +5 -0
- package/node_modules/@sigstore/verify/dist/policy.js +50 -0
- package/node_modules/@sigstore/verify/dist/shared.types.d.ts +50 -0
- package/node_modules/@sigstore/verify/dist/shared.types.js +2 -0
- package/node_modules/@sigstore/verify/dist/timestamp/index.d.ts +11 -0
- package/node_modules/@sigstore/verify/dist/timestamp/index.js +24 -0
- package/node_modules/@sigstore/verify/dist/timestamp/tsa.d.ts +3 -0
- package/node_modules/@sigstore/verify/dist/timestamp/tsa.js +63 -0
- package/node_modules/@sigstore/verify/dist/tlog/checkpoint.d.ts +11 -0
- package/node_modules/@sigstore/verify/dist/tlog/checkpoint.js +154 -0
- package/node_modules/@sigstore/verify/dist/tlog/dsse.d.ts +6 -0
- package/node_modules/@sigstore/verify/dist/tlog/dsse.js +106 -0
- package/node_modules/@sigstore/verify/dist/tlog/hashedrekord.d.ts +6 -0
- package/node_modules/@sigstore/verify/dist/tlog/hashedrekord.js +94 -0
- package/node_modules/@sigstore/verify/dist/tlog/index.d.ts +5 -0
- package/node_modules/@sigstore/verify/dist/tlog/index.js +92 -0
- package/node_modules/@sigstore/verify/dist/tlog/intoto.d.ts +3 -0
- package/node_modules/@sigstore/verify/dist/tlog/intoto.js +62 -0
- package/node_modules/@sigstore/verify/dist/tlog/merkle.d.ts +3 -0
- package/node_modules/@sigstore/verify/dist/tlog/merkle.js +104 -0
- package/node_modules/@sigstore/verify/dist/tlog/set.d.ts +3 -0
- package/node_modules/@sigstore/verify/dist/tlog/set.js +60 -0
- package/node_modules/@sigstore/verify/dist/trust/filter.d.ts +8 -0
- package/node_modules/@sigstore/verify/dist/trust/filter.js +23 -0
- package/node_modules/@sigstore/verify/dist/trust/index.d.ts +5 -0
- package/node_modules/@sigstore/verify/dist/trust/index.js +90 -0
- package/node_modules/@sigstore/verify/dist/trust/trust.types.d.ts +29 -0
- package/node_modules/@sigstore/verify/dist/trust/trust.types.js +2 -0
- package/node_modules/@sigstore/verify/dist/verifier.d.ts +31 -0
- package/node_modules/@sigstore/verify/dist/verifier.js +160 -0
- package/node_modules/@sigstore/verify/package.json +36 -0
- package/package.json +37 -4
package/lib/home.js
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// The launcher's home: $COUNTINGHOUSE_HOME, else ~/.countinghouse, and on
|
|
3
|
+
// Windows %LOCALAPPDATA%\countinghouse (defaultHome). A relative
|
|
4
|
+
// COUNTINGHOUSE_HOME is refused: a client starts its servers in whatever
|
|
5
|
+
// directory it likes, so it would name a different place each time.
|
|
6
|
+
const fs = require('node:fs');
|
|
7
|
+
const os = require('node:os');
|
|
8
|
+
const path = require('node:path');
|
|
9
|
+
|
|
10
|
+
// Absolute and anchored: on Windows a drive letter or a share, since
|
|
11
|
+
// \\countinghouse is rooted on whichever drive is current.
|
|
12
|
+
function isFullPath(p, platform = process.platform) {
|
|
13
|
+
if (platform === 'win32') return /^(?:[A-Za-z]:[\\/]|[\\/]{2}[^\\/])/.test(p);
|
|
14
|
+
return path.posix.isAbsolute(p);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// The home when COUNTINGHOUSE_HOME is not set. On Windows %LOCALAPPDATA%\countinghouse, never a folder directly in the profile:
|
|
18
|
+
// Codex's elevated Windows sandbox gives its CodexSandboxUsers group (and, where the profile is its workspace, a sandbox identity
|
|
19
|
+
// with change rights) an explicit entry on every folder directly in %USERPROFILE%, each time it runs a command, so a home there
|
|
20
|
+
// does not stay private. Its entry on AppData is an inheritable one, and a home made protected (ensureHome) takes none of it.
|
|
21
|
+
// LOCALAPPDATA comes from the environment, refused when missing or not absolute, never guessed. Elsewhere ~/.countinghouse.
|
|
22
|
+
// homedir is the user's home directory, a function so a test can give its own.
|
|
23
|
+
function defaultHome(env = process.env, homedir = os.homedir, platform = process.platform) {
|
|
24
|
+
if (platform !== 'win32') return path.join(homedir(), '.countinghouse');
|
|
25
|
+
const local = env.LOCALAPPDATA;
|
|
26
|
+
if (typeof local !== 'string' || local === '' || !isFullPath(local, 'win32')) {
|
|
27
|
+
const err = new Error(`LOCALAPPDATA is ${typeof local !== 'string' || local === '' ? 'not set' : `not an absolute path ("${local}")`}, so the home's place (%LOCALAPPDATA%\\countinghouse) is not known: set COUNTINGHOUSE_HOME to an absolute path`);
|
|
28
|
+
err.code = 'HOME_NO_LOCALAPPDATA';
|
|
29
|
+
throw err;
|
|
30
|
+
}
|
|
31
|
+
return path.win32.join(local, 'countinghouse');
|
|
32
|
+
}
|
|
33
|
+
function home(env = process.env, homedir = os.homedir, platform = process.platform) {
|
|
34
|
+
const set = env.COUNTINGHOUSE_HOME;
|
|
35
|
+
if (typeof set !== 'string' || set === '') return defaultHome(env, homedir, platform);
|
|
36
|
+
if (!isFullPath(set, platform)) {
|
|
37
|
+
const err = new Error(`COUNTINGHOUSE_HOME must be an absolute path, not "${set}"`);
|
|
38
|
+
err.code = 'HOME_RELATIVE';
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
return platform === 'win32' ? path.win32.normalize(set) : path.normalize(set);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// The installed launcher a client runs (reviewer, 2026-11-11: a .js file run
|
|
45
|
+
// by node, because Windows cannot execute an extensionless file). The plugin's
|
|
46
|
+
// bin/launch.js applies the same rule; test/plugin.test.js checks they agree.
|
|
47
|
+
const launcherPath = (env = process.env, homedir = os.homedir, platform = process.platform) => (platform === 'win32' ? path.win32 : path).join(home(env, homedir, platform), 'bin', 'ch-local.js');
|
|
48
|
+
// The home's launcher by the kernel's real path, as a command for the
|
|
49
|
+
// person's own terminal may quote it inside double quotes, or null: none
|
|
50
|
+
// installed, or a path a shell would read there. The runtime's rule (#490
|
|
51
|
+
// lib/held-back.js UNSAFE_IN_COMMAND): no control character, ", `, $, \, %,
|
|
52
|
+
// ! or ^, and no typographic quote (U+2018 to U+201F: PowerShell reads them
|
|
53
|
+
// as quotes); a backslash only as Windows' separator. One helper for the
|
|
54
|
+
// credential line and the held-back file (the reviewer's high on #106, 5, 6
|
|
55
|
+
// and 8: never a missing launcher, never one a shell would rewrite).
|
|
56
|
+
const UNSAFE_IN_COMMAND = /[\u0000-\u001f\u007f"`$\\%!^\u2018-\u201f]/;
|
|
57
|
+
function safeLauncher(where, platform = process.platform) {
|
|
58
|
+
let real;
|
|
59
|
+
try { real = require('node:fs').realpathSync.native(where.launcher); } catch (e) { return null; }
|
|
60
|
+
return UNSAFE_IN_COMMAND.test(platform === 'win32' ? real.replace(/\\/g, '/') : real) ? null : real;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Where everything goes under the home (spec §2, "Where files go"; the store
|
|
64
|
+
// and its identity secret are the runtime's, LM1 spec §4).
|
|
65
|
+
function layout(env = process.env, homedir = os.homedir) {
|
|
66
|
+
const h = home(env, homedir);
|
|
67
|
+
const at = (...p) => path.join(h, ...p);
|
|
68
|
+
return {
|
|
69
|
+
home: h,
|
|
70
|
+
app: at('app'),
|
|
71
|
+
packsDir: at('packs'),
|
|
72
|
+
bin: at('bin'),
|
|
73
|
+
launcher: at('bin', 'ch-local.js'),
|
|
74
|
+
node: at('node'),
|
|
75
|
+
store: at('store'),
|
|
76
|
+
identitySecret: at('store', '.identity-secret'),
|
|
77
|
+
auth: at('auth.json'),
|
|
78
|
+
installed: at('installed.json'),
|
|
79
|
+
packs: at('packs.json'),
|
|
80
|
+
clients: at('installed-clients.json'),
|
|
81
|
+
settings: at('settings.json'),
|
|
82
|
+
moduleData: at('module_data'),
|
|
83
|
+
modules: at('modules'),
|
|
84
|
+
run: at('run'),
|
|
85
|
+
previous: at('previous'),
|
|
86
|
+
previousApp: at('previous', 'app'),
|
|
87
|
+
previousRecord: at('previous', 'packs.json'),
|
|
88
|
+
// the module store and its record (module-level install, #413 section
|
|
89
|
+
// 9.1-9.2): one directory per module version; modules.json replaces
|
|
90
|
+
// packs.json once install writes it (L1a-2)
|
|
91
|
+
moduleStore: at('module-store'),
|
|
92
|
+
modulesRecord: at('modules.json'),
|
|
93
|
+
previousModulesRecord: at('previous', 'modules.json'),
|
|
94
|
+
journal: at('rollback.journal'),
|
|
95
|
+
// the user's own modules (B-own-add; the own-modules design §2.1): each
|
|
96
|
+
// confirmed copy under <own>/<name>/<tree sha256>/, and their record
|
|
97
|
+
own: at('own'),
|
|
98
|
+
ownRecord: at('own.json')
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// A home named by --home (ch-local daemon, start --own-runtime): its real
|
|
103
|
+
// path must be a directory owned by this user and, on POSIX, not group- or
|
|
104
|
+
// world-writable, so no other user can plant its files. On Windows its owner
|
|
105
|
+
// and DACL by lib/win-acl.js privateProblem, as a directory (the review of
|
|
106
|
+
// ch-local #39: an inherit-only rule for anyone else fails too). fileAcl: for
|
|
107
|
+
// the tests. -> null or why not
|
|
108
|
+
function homeOwnershipProblem(real, platform = process.platform, {fileAcl} = {}) {
|
|
109
|
+
let st;
|
|
110
|
+
try { st = require('node:fs').statSync(real); } catch (err) { return `it could not be read (${err.code || err.message})`; }
|
|
111
|
+
if (!st.isDirectory()) return 'it is not a directory';
|
|
112
|
+
if (platform === 'win32') {
|
|
113
|
+
const winAcl = require('./win-acl');
|
|
114
|
+
let acl;
|
|
115
|
+
try { acl = (fileAcl || winAcl.fileAcl)(real); } catch (err) { return `its ACL could not be read (${err.code || err.message})`; }
|
|
116
|
+
return winAcl.privateProblem('it', acl, {directory: true});
|
|
117
|
+
}
|
|
118
|
+
const euid = typeof process.geteuid === 'function' ? process.geteuid() : null;
|
|
119
|
+
if (euid != null && st.uid !== euid) return `it is owned by uid ${st.uid}, not this user`;
|
|
120
|
+
if ((st.mode & 0o022) !== 0) return `it is group- or world-writable (mode ${(st.mode & 0o777).toString(8).padStart(4, '0')})`;
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// The home, when ch-local makes it (install, a first setting): 0700 itself,
|
|
125
|
+
// never the umask's mode. Ubuntu's default umask 0002 would give 0775, which
|
|
126
|
+
// the shared runtime's daemon refuses (homeOwnershipProblem: found in the
|
|
127
|
+
// replay's prep, 2026-11-21). Its missing parents are made as mkdir -p makes
|
|
128
|
+
// them: only the home is private (the medium, 5). A home that exists is left
|
|
129
|
+
// as it is. -> true when it made the home
|
|
130
|
+
function ensureHome(dir, platform = process.platform, {makePrivateDirs = null} = {}) {
|
|
131
|
+
const fs = require('node:fs');
|
|
132
|
+
fs.mkdirSync(path.dirname(dir), {recursive: true});
|
|
133
|
+
try {
|
|
134
|
+
fs.mkdirSync(dir, {mode: 0o700});
|
|
135
|
+
} catch (err) {
|
|
136
|
+
if (err.code === 'EEXIST') return false;
|
|
137
|
+
throw err;
|
|
138
|
+
}
|
|
139
|
+
// mkdir's mode is masked by the umask: set it whole, never through a link
|
|
140
|
+
// put in its place (the medium, 6). Windows: a protected DACL, this user
|
|
141
|
+
// and SYSTEM only, as the daemon's run directory has (lib/win-acl.js
|
|
142
|
+
// makePrivateDirs): a folder made under C:\ would otherwise inherit
|
|
143
|
+
// Authenticated Users' Modify (the reviewer's pre-work high, A-home-check, 4)
|
|
144
|
+
if (platform !== 'win32') require('./own-tree').chmodNoFollow(dir, 0o700);
|
|
145
|
+
// (its own ACL read back in the same run: an empty list is refused, the
|
|
146
|
+
// medium on A-home-check, 1)
|
|
147
|
+
else {
|
|
148
|
+
const acls = (makePrivateDirs || require('./win-acl').makePrivateDirs)([dir], [dir]);
|
|
149
|
+
// (the DACL read back must be private, or the home is refused: the
|
|
150
|
+
// reviewer's high on #126, L5)
|
|
151
|
+
const why = require('./win-acl').privateProblem('it', Array.isArray(acls) ? acls[0] : null, {directory: true});
|
|
152
|
+
if (why != null) throw Object.assign(new Error(`the new home ${dir} could not be made private: ${why}`), {code: 'HOME_NOT_PRIVATE'});
|
|
153
|
+
// (made a moment before its DACL: anything in it now was put there by
|
|
154
|
+
// another, F4)
|
|
155
|
+
if (fs.readdirSync(dir).length > 0) throw Object.assign(new Error(`the new home ${dir} is not empty once made private: something was put in it before`), {code: 'HOME_NOT_PRIVATE'});
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// The folders above a home (POSIX; the reviewer on #126 (a)), by countinghouse
|
|
161
|
+
// #520's rule for its sqlite store's: along the path as given and its real
|
|
162
|
+
// path, each this user's or root's, writable by no other unless sticky (as
|
|
163
|
+
// /tmp: no one else can rename what this user owns there), nor by a group
|
|
164
|
+
// other than this user's own primary group (a user-private group, as a umask
|
|
165
|
+
// of 0002 leaves a home's folders). Otherwise another user could move the
|
|
166
|
+
// home away and put one of theirs in its place. Windows: the ancestors' DACLs
|
|
167
|
+
// are not checked. -> {why, fix} | null
|
|
168
|
+
function aboveProblemWith(home, QUOTE) {
|
|
169
|
+
const given = path.resolve(home);
|
|
170
|
+
// (a home not made yet: the path as given, its folders that are there)
|
|
171
|
+
let real = null;
|
|
172
|
+
try { real = fs.realpathSync.native(given); } catch (e) { if (e.code !== 'ENOENT') return {why: `it could not be read (${e.code || e.message})`, fix: null}; }
|
|
173
|
+
const uid = typeof process.geteuid === 'function' ? process.geteuid() : null;
|
|
174
|
+
const gid = typeof process.getegid === 'function' ? process.getegid() : null;
|
|
175
|
+
for (const start of real != null ? [given, real] : [given]) {
|
|
176
|
+
for (let at = path.dirname(start); ; at = path.dirname(at)) {
|
|
177
|
+
let st;
|
|
178
|
+
try { st = fs.statSync(at); } catch (e) {
|
|
179
|
+
if (real == null && e.code === 'ENOENT' && path.dirname(at) !== at) continue;
|
|
180
|
+
return {why: `it is under ${at}, which could not be checked (${e.code || e.message})`, fix: null};
|
|
181
|
+
}
|
|
182
|
+
if (uid != null && st.uid !== uid && st.uid !== 0) return {why: `it is under ${at}, which is not yours (nor root's); another user could move the home away and put theirs in its place`, fix: null};
|
|
183
|
+
const sticky = (st.mode & 0o1000) !== 0;
|
|
184
|
+
const others = (st.mode & 0o002) !== 0 && !sticky;
|
|
185
|
+
const group = (st.mode & 0o020) !== 0 && !sticky && st.gid !== gid;
|
|
186
|
+
if (others || group) {
|
|
187
|
+
const mine = uid != null && st.uid === uid;
|
|
188
|
+
const q = QUOTE(at);
|
|
189
|
+
return {why: `it is under ${at}, and group or others can write in it (mode ${(st.mode & 0o7777).toString(8)}); another user could move the home away and put theirs in its place`, fix: mine && q !== '"<its folder>"' ? `run \`chmod go-w ${q}\`` : null};
|
|
190
|
+
}
|
|
191
|
+
if (path.dirname(at) === at) break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
function aboveProblem(home) {
|
|
197
|
+
return aboveProblemWith(home, (p) => require('./command-line').folderArg(p));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// What install, session and start say of a home another user could change
|
|
201
|
+
// (the reviewer's pre-work high, A-home-check): what runs from it is the
|
|
202
|
+
// runtime given every stored key.
|
|
203
|
+
const HOME_OPEN = 'so another user could change what runs from it';
|
|
204
|
+
|
|
205
|
+
// An existing home another user could change -> {why, fix} | null (null for
|
|
206
|
+
// a home that is fine, or not there yet: nothing would be loaded from it).
|
|
207
|
+
// POSIX: homeOwnershipProblem; fix, the chmod line when the mode is the cause,
|
|
208
|
+
// the home is this user's and its path quotes safely, else null. Windows: its
|
|
209
|
+
// DACL (lib/win-acl.js privateProblem), fix, the icacls lines that make it
|
|
210
|
+
// private. fileAcl: a test's.
|
|
211
|
+
// principalNames: a caller's name lookup ({names: {sid: name}, machine, localAppData}), else Windows' own (lib/win-acl.js).
|
|
212
|
+
// localAppData: the folder(s) %LOCALAPPDATA% names, a test's (else Windows' known folder, the lookup's, else env's LOCALAPPDATA when
|
|
213
|
+
// a full path).
|
|
214
|
+
function homeOpenProblem(home, {platform = process.platform, fileAcl = null, env = process.env, principalNames = null, localAppData} = {}) {
|
|
215
|
+
const fs = require('node:fs');
|
|
216
|
+
// (only a home not there yet is no home: anything else that can't be read
|
|
217
|
+
// is refused: the reviewer's high on #126, L4)
|
|
218
|
+
try { fs.lstatSync(home); } catch (err) {
|
|
219
|
+
// (a home install will make: the folders it will be made under, so a
|
|
220
|
+
// first install is held to them too: the medium on #126's round, 1)
|
|
221
|
+
if (err.code === 'ENOENT') return platform === 'win32' ? null : aboveProblem(home);
|
|
222
|
+
return {why: `it could not be read (${err.code || err.message})`, fix: null};
|
|
223
|
+
}
|
|
224
|
+
let real;
|
|
225
|
+
try { real = fs.realpathSync.native(home); } catch (err) { return {why: `it could not be read (${err.code || err.message})`, fix: null}; }
|
|
226
|
+
if (platform === 'win32') {
|
|
227
|
+
// (a directory, as the daemon's check wants it: the medium, 4)
|
|
228
|
+
let st;
|
|
229
|
+
try { st = fs.statSync(real); } catch (err) { return {why: `it could not be read (${err.code || err.message})`, fix: null}; }
|
|
230
|
+
if (!st.isDirectory()) return {why: 'it is not a directory', fix: null};
|
|
231
|
+
const winAcl = require('./win-acl');
|
|
232
|
+
let acl;
|
|
233
|
+
try { acl = (fileAcl || winAcl.fileAcl)(real); } catch (err) { return {why: `its ACL could not be read (${err.code || err.message})`, fix: null}; }
|
|
234
|
+
const why = winAcl.privateProblem('it', acl, {directory: true});
|
|
235
|
+
if (why == null) return null;
|
|
236
|
+
const hint = winAcl.fixHint(real, acl, {directory: true});
|
|
237
|
+
const lines = hint != null ? `, in Windows PowerShell (powershell.exe): ${hint.split('\n').map((l) => l.trim()).join(', then ')}` : '';
|
|
238
|
+
// another account holding more than it may (privateProblem's "accessible by"): who, and the strongest right any of them holds
|
|
239
|
+
const open = (why === 'it is accessible by ' + firstOpenSid(winAcl, acl)) ? winAcl.openPrincipals(acl) : [];
|
|
240
|
+
if (open.length > 0) {
|
|
241
|
+
// (their names, and this machine's, looked up only now, for the words: a lookup that fails says the SIDs, and the home is
|
|
242
|
+
// refused the same; a name that is not plain text is said by its SID)
|
|
243
|
+
let looked = null;
|
|
244
|
+
try { looked = (principalNames || winAcl.principalNames)(open.map((o) => o.sid)); } catch (err) { looked = null; }
|
|
245
|
+
const names = {};
|
|
246
|
+
// (a name hidden for being unsafe: an account Windows names all the same, never one that names no account)
|
|
247
|
+
const hidden = new Set();
|
|
248
|
+
if (looked != null && looked.names != null && typeof looked.names === 'object') {
|
|
249
|
+
for (const [sid, n] of Object.entries(looked.names)) {
|
|
250
|
+
const shown = typeof n === 'string' && !UNSHOWN_NAME.test(n);
|
|
251
|
+
names[sid] = shown ? n : '';
|
|
252
|
+
// (and an entry that is not a string: an account the lookup could not say, never one that names no account)
|
|
253
|
+
if (n !== '' && !shown) hidden.add(sid);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const machine = (looked != null && typeof looked.machine === 'string' && looked.machine !== '') ? looked.machine : null;
|
|
257
|
+
// (Windows' own known folder, the lookup's; the environment's only when that is unknown, and a full path: one the environment
|
|
258
|
+
// points elsewhere, into the profile say, is no folder Codex leaves alone)
|
|
259
|
+
const known = looked != null && typeof looked.localAppData === 'string' && looked.localAppData !== '' ? looked.localAppData : null;
|
|
260
|
+
const fromEnv = typeof env.LOCALAPPDATA === 'string' && isFullPath(env.LOCALAPPDATA, 'win32') ? env.LOCALAPPDATA : null;
|
|
261
|
+
const locals = localAppData !== undefined ? [].concat(localAppData) : [known || fromEnv];
|
|
262
|
+
return windowsOpen(winAcl.openPrincipals(acl, names), lines, machine, winAcl.foreignChange(acl), locals.some((d) => inside(real, d)), hidden);
|
|
263
|
+
}
|
|
264
|
+
// (anyone else able to change it, or what was made in it: moved aside, never repaired)
|
|
265
|
+
if (winAcl.foreignChange(acl)) return {why, final: true, fix: MAY_BE_CHANGED};
|
|
266
|
+
return {why, fix: `make it a folder only you can change${lines}`};
|
|
267
|
+
}
|
|
268
|
+
const st = fs.statSync(real);
|
|
269
|
+
// (a file: no fix that fits a folder: the medium on #126's round 2, 8)
|
|
270
|
+
if (!st.isDirectory()) return {why: 'it is not a directory', fix: null};
|
|
271
|
+
const mine = typeof process.geteuid !== 'function' || st.uid === process.geteuid();
|
|
272
|
+
const arg = require('./command-line').folderArg(real);
|
|
273
|
+
const fix = mine && (st.mode & 0o077) !== 0 && arg !== '"<its folder>"' ? `run \`chmod 700 ${arg}\`` : null;
|
|
274
|
+
const why = homeOwnershipProblem(real, platform);
|
|
275
|
+
// (one that was writable by others may already have been changed: its
|
|
276
|
+
// app, module store and records are not re-checked by a chmod, so it is
|
|
277
|
+
// moved aside and installed again, never trusted after one: the
|
|
278
|
+
// reviewer's Fable high on #126, F2; final: no "then ... again" after it)
|
|
279
|
+
if (why != null && (st.mode & 0o022) !== 0) {
|
|
280
|
+
const aside = require('./command-line').folderArg(`${real}.suspect`);
|
|
281
|
+
return {why, final: true, fix: mine && arg !== '"<its folder>"' && aside !== '"<its folder>"' ? `it may already have been changed: move it aside (\`mv ${arg} ${aside}\`) and install again` : 'it may already have been changed: move it aside and install again'};
|
|
282
|
+
}
|
|
283
|
+
if (why != null) return {why, fix};
|
|
284
|
+
// private, as install makes it: its app and module store are the code
|
|
285
|
+
// that runs with the keys, and install makes them with the umask's modes
|
|
286
|
+
// (the reviewer's high on #126, M2)
|
|
287
|
+
if ((st.mode & 0o077) !== 0) return {why: `it is open to group or others (mode ${(st.mode & 0o777).toString(8).padStart(4, '0')}), and its folders may be too`, fix};
|
|
288
|
+
return aboveProblem(home);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// the first other account privateProblem found: the same rule it judged (lib/win-acl.js openPrincipals, in its order)
|
|
292
|
+
function firstOpenSid(winAcl, acl) {
|
|
293
|
+
const open = winAcl.openPrincipals(acl);
|
|
294
|
+
return open.length > 0 ? open[0].sid : null;
|
|
295
|
+
}
|
|
296
|
+
// The Windows refusal for other accounts: every one holding the strongest right any of them holds, by name (a SID Windows can't
|
|
297
|
+
// name, by its SID). Read only: readable, its credentials named; any change right: changeable. This machine's CodexSandboxUsers
|
|
298
|
+
// among them: the Codex form, a SID that names no account beside it called a Codex sandbox identity, and no icacls lines, since
|
|
299
|
+
// Codex puts its grant back each time it runs a command: the home moved under %LOCALAPPDATA% instead (final: nothing to retry).
|
|
300
|
+
const CODEX_GROUP = 'CodexSandboxUsers';
|
|
301
|
+
// Anyone else able to change it (any change right, explicit or inherited by what was made in it): it may already have been changed,
|
|
302
|
+
// as POSIX's group- or world-writable home: moved aside and installed again, no lines that set its access (setting it right undoes
|
|
303
|
+
// no change already made to bin\ch-local.js or the stored modules: the reviewer's ruling on a cleanup on the owner's machine). Read only: the lines.
|
|
304
|
+
const MAY_BE_CHANGED = 'it may already have been changed: move it aside and install again';
|
|
305
|
+
// a name with a control, format, surrogate, private-use or unassigned character, or an invisible filler: never printed (said by its
|
|
306
|
+
// SID)
|
|
307
|
+
// (line and paragraph separators, and every space but U+0020, too)
|
|
308
|
+
// (variation selectors and the Braille blank as well)
|
|
309
|
+
const UNSHOWN_NAME = /[\p{C}\p{Zl}\p{Zp}\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\u034f\u115f\u1160\u3164\uffa0\ufe00-\ufe0f\u{e0100}-\u{e01ef}\u2800]/u;
|
|
310
|
+
// whether real (a real path) is in dir (not dir itself), on Windows' paths, case aside: dir as the kernel resolves it, where it can
|
|
311
|
+
const inside = (real, dir) => {
|
|
312
|
+
if (typeof dir !== 'string' || dir === '') return false;
|
|
313
|
+
let d = dir;
|
|
314
|
+
try { d = fs.realpathSync.native(dir); } catch (err) { /* as given */ }
|
|
315
|
+
const r = path.win32.relative(path.win32.resolve(d).toLowerCase(), path.win32.resolve(real).toLowerCase());
|
|
316
|
+
return r !== '' && r !== '..' && !r.startsWith(`..${path.win32.sep}`) && !path.win32.isAbsolute(r);
|
|
317
|
+
};
|
|
318
|
+
// machine: this machine's name as Windows gives it (the lookup's), or null. inLocal: the home is under %LOCALAPPDATA%, where Codex
|
|
319
|
+
// grants nothing itself: a grant of its there came from a folder above (AppData's, into a home install didn't make), so moved aside
|
|
320
|
+
// and installed again.
|
|
321
|
+
// hidden: the SIDs whose names are not shown for being unsafe (accounts Windows names).
|
|
322
|
+
function windowsOpen(open, lines, machine, anyChange, inLocal, hidden = new Set()) {
|
|
323
|
+
const change = open.some((p) => p.change);
|
|
324
|
+
const strongest = open.filter((p) => p.change === change);
|
|
325
|
+
const m = machine != null ? machine.toLowerCase() : null;
|
|
326
|
+
const isCodex = (p) => m != null && typeof p.name === 'string' && p.name.toLowerCase() === `${m}\\${CODEX_GROUP.toLowerCase()}`;
|
|
327
|
+
// (the group anywhere among them, a Codex sandbox identity perhaps holding more; only when every holder of the strongest right is
|
|
328
|
+
// the group or a SID that names no account: an account Windows names, able to do more, is the refusal, as any other account's)
|
|
329
|
+
const nameless = (p) => !p.name && !hidden.has(p.sid);
|
|
330
|
+
const codex = open.some(isCodex) && strongest.every((p) => isCodex(p) || nameless(p));
|
|
331
|
+
// (the Codex form: the group named first, then the identities, whatever the DACL's order)
|
|
332
|
+
if (codex) strongest.sort((a, b) => Number(isCodex(b)) - Number(isCodex(a)));
|
|
333
|
+
const named = strongest.map((p) => (p.name ? p.name : (codex && nameless(p) ? `a Codex sandbox identity (${p.sid})` : p.sid)));
|
|
334
|
+
const list = named.length === 1 ? named[0] : `${named.slice(0, -1).join(', ')} and ${named[named.length - 1]}`;
|
|
335
|
+
const why = change ? `it can be changed by ${list}` : `it is readable by ${list}`;
|
|
336
|
+
if (codex) {
|
|
337
|
+
const whom = strongest.length > 1 ? 'these' : isCodex(strongest[0]) ? 'that group' : 'that identity';
|
|
338
|
+
const what = `${change ? 'so another account could change what runs from it and read its credentials' : 'so another account could read what is stored in it, its credentials included'}. Codex's Windows sandbox gives ${whom} ${change ? '' : 'read '}access to most folders directly in your profile`;
|
|
339
|
+
return {why, final: true, fix: null,
|
|
340
|
+
consequence: inLocal
|
|
341
|
+
? `${what}, AppData included, every time it runs a command, and a folder under AppData inherits it unless ch-local's install made that folder: move it aside and install again, which makes a folder that inherits nothing from the folders above it, then delete the old home (it still holds the stored credentials)`
|
|
342
|
+
: `${what} every time it runs a command, so removing it by hand does not last: unset COUNTINGHOUSE_HOME, or point it under %LOCALAPPDATA%, then install again and delete the old home (it still holds the stored credentials)`};
|
|
343
|
+
}
|
|
344
|
+
if (change) return {why, final: true, consequence: 'so another account could change what runs from it', fix: MAY_BE_CHANGED};
|
|
345
|
+
// (read only by those named; an inherit-only change right for someone else too: still moved aside)
|
|
346
|
+
if (anyChange) return {why, final: true, consequence: 'so another account could read what is stored in it, its credentials included', fix: MAY_BE_CHANGED};
|
|
347
|
+
return {why, consequence: 'so another account could read what is stored in it, its credentials included', fix: `make it a folder only you can read${lines}`};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// homeOpenProblem's answer as one line: `<home> <why>, so another user could
|
|
351
|
+
// change what runs from it[; <fix>]`, or null. Every place that loads code
|
|
352
|
+
// from <home>/app says it before it loads anything (the reviewer's high on
|
|
353
|
+
// #126, H1: lib/ceiling.js, lib/module-values.js).
|
|
354
|
+
// (Windows: each answer a PowerShell read of the home's DACL, 1 to 10 s, so
|
|
355
|
+
// one is kept for a minute per home, as the ceiling's own read is kept: the
|
|
356
|
+
// medium on #126's round, 6)
|
|
357
|
+
const openSeen = new Map();
|
|
358
|
+
function openHomeLine(home, opts = {}) {
|
|
359
|
+
const win = (opts.platform || process.platform) === 'win32' && opts.fileAcl == null;
|
|
360
|
+
const key = path.resolve(home).toLowerCase();
|
|
361
|
+
const seen = win ? openSeen.get(key) : undefined;
|
|
362
|
+
if (seen != null && Date.now() - seen.at < 60 * 1000) return seen.line;
|
|
363
|
+
const line = openHomeLineNow(home, opts);
|
|
364
|
+
if (win) openSeen.set(key, {at: Date.now(), line});
|
|
365
|
+
return line;
|
|
366
|
+
}
|
|
367
|
+
function openHomeLineNow(home, opts) {
|
|
368
|
+
const p = homeOpenProblem(home, opts);
|
|
369
|
+
return p == null ? null : `${home} ${p.why.replace(/^it /, '')}, ${p.consequence || HOME_OPEN}${p.fix != null ? `; ${p.fix}` : ''}`;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
module.exports = {home, defaultHome, launcherPath, layout, isFullPath, homeOwnershipProblem, homeOpenProblem, openHomeLine, aboveProblem, HOME_OPEN, ensureHome, safeLauncher, UNSAFE_IN_COMMAND};
|