@holmes-lab/holmes-kit 0.40.1 → 0.41.1
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/CHANGELOG.md +86 -0
- package/README.md +12 -4
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/approve-context.js +4 -3
- package/dist/holmes/cli/approve.js +22 -12
- package/dist/holmes/cli/autonomy.d.ts +21 -0
- package/dist/holmes/cli/autonomy.js +35 -5
- package/dist/holmes/cli/doctor.js +58 -6
- package/dist/holmes/cli/index.js +371 -250
- package/dist/holmes/cli/init.js +26 -6
- package/dist/holmes/cli/ledger-witness.d.ts +61 -0
- package/dist/holmes/cli/ledger-witness.js +252 -0
- package/dist/holmes/cli/playbook-skills.d.ts +3 -56
- package/dist/holmes/cli/playbook-skills.js +63 -354
- package/dist/holmes/cli/test-platform.d.ts +6 -0
- package/dist/holmes/cli/test-platform.js +12 -0
- package/dist/holmes/config/config.d.ts +9 -1
- package/dist/holmes/config/config.js +10 -3
- package/dist/holmes/governance/approval-grants.d.ts +2 -0
- package/dist/holmes/governance/approval-grants.js +6 -5
- package/dist/holmes/governance/approval-queue.d.ts +65 -1
- package/dist/holmes/governance/approval-queue.js +279 -9
- package/dist/holmes/governance/autonomous-shell.d.ts +13 -1
- package/dist/holmes/governance/autonomous-shell.js +157 -4
- package/dist/holmes/governance/autonomy.d.ts +209 -0
- package/dist/holmes/governance/autonomy.js +1129 -6
- package/dist/holmes/governance/install-manifest.d.ts +7 -4
- package/dist/holmes/governance/install-manifest.js +159 -15
- package/dist/holmes/governance/ledger-witness.d.ts +63 -0
- package/dist/holmes/governance/ledger-witness.js +296 -0
- package/dist/holmes/governance/provenance-chain.d.ts +8 -1
- package/dist/holmes/governance/provenance-chain.js +23 -4
- package/dist/holmes/governance/recorded-pairs.d.ts +4 -0
- package/dist/holmes/governance/recorded-pairs.js +25 -1
- package/dist/holmes/governance/session-context.d.ts +7 -0
- package/dist/holmes/governance/session-context.js +34 -6
- package/dist/holmes/guardrail/anchor-scope-text.d.ts +9 -0
- package/dist/holmes/guardrail/anchor-scope-text.js +7 -0
- package/dist/holmes/guardrail/command-traits.d.ts +102 -0
- package/dist/holmes/guardrail/command-traits.js +379 -0
- package/dist/holmes/guardrail/fixtures/manager-builtins.json +23 -0
- package/dist/holmes/guardrail/fixtures/npm-commands.json +7 -0
- package/dist/holmes/guardrail/outward-acts.d.ts +47 -0
- package/dist/holmes/guardrail/outward-acts.js +1102 -0
- package/dist/holmes/guardrail/refusal-codes.js +8 -1
- package/dist/holmes/guardrail/refusal-templates.d.ts +15 -0
- package/dist/holmes/guardrail/refusal-templates.js +71 -0
- package/dist/holmes/guardrail/risk-classifier.d.ts +22 -6
- package/dist/holmes/guardrail/risk-classifier.js +12 -118
- package/dist/holmes/guardrail/shell-lexer.d.ts +69 -0
- package/dist/holmes/guardrail/shell-lexer.js +567 -0
- package/dist/holmes/guardrail/write-target.js +7 -1
- package/dist/holmes/hooks/pre-tool-use.d.ts +60 -0
- package/dist/holmes/hooks/pre-tool-use.js +1423 -10
- package/dist/holmes/hooks/session-start.js +11 -1
- package/dist/holmes/hooks/stop.d.ts +7 -0
- package/dist/holmes/hooks/stop.js +39 -2
- package/dist/holmes/mcp/elicit-approval.d.ts +0 -21
- package/dist/holmes/mcp/elicit-approval.js +5 -2
- package/dist/holmes/mcp/handlers/approval-ask.js +3 -2
- package/dist/holmes/mcp/handlers/entity-integration.d.ts +1 -1
- package/dist/holmes/mcp/handlers/entity-integration.js +9 -6
- package/dist/holmes/mcp/handlers/entity-renumber.js +2 -1
- package/dist/holmes/mcp/handlers/entity-store.js +7 -2
- package/dist/holmes/mcp/handlers/operator-inspection.d.ts +2 -0
- package/dist/holmes/mcp/handlers/operator-inspection.js +25 -4
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +3 -1
- package/dist/holmes/mcp/handlers/spec-approval.js +28 -10
- package/dist/holmes/mcp/handlers/spec-lifecycle.js +10 -7
- package/dist/holmes/mcp/handlers/test-execution.d.ts +6 -0
- package/dist/holmes/mcp/handlers/test-execution.js +37 -9
- package/dist/holmes/mcp/handlers.d.ts +5 -5
- package/dist/holmes/mcp/handlers.js +2 -1
- package/dist/holmes/mcp/tool-schemas.js +4 -4
- package/dist/holmes/project/playbook-reference.d.ts +50 -0
- package/dist/holmes/project/playbook-reference.js +259 -0
- package/dist/holmes/project/playbook-skill-states.d.ts +94 -0
- package/dist/holmes/project/playbook-skill-states.js +396 -0
- package/dist/holmes/project/root.d.ts +9 -1
- package/dist/holmes/project/root.js +23 -2
- package/dist/holmes/project/running-package.d.ts +15 -0
- package/dist/holmes/project/running-package.js +87 -0
- package/dist/holmes/review/head-worktree.js +9 -1
- package/dist/holmes/review/test-runner.d.ts +2 -0
- package/dist/holmes/review/test-runner.js +38 -11
- package/dist/holmes/spec/entity-integration-transaction.d.ts +19 -2
- package/dist/holmes/spec/entity-integration-transaction.js +68 -7
- package/package.json +5 -2
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.PACKAGE_RUNNERS = exports.COMMAND_VARIABLES = exports.INLINE_FLAGS = exports.INTERPRETERS = exports.SHELL_PROGRAMS = exports.RELEASE_TOOLS = exports.YARN_NPM_WRITES = exports.YARN_WRITES = exports.YARN_FOREACH_VALUED = exports.NPM_VALUED_OPTIONS = exports.SCRIPT_NAME_RUNNERS = exports.WRAPPERS = exports.REGISTRY_PROGRAMS = exports.PACKAGE_BINS = exports.POSITIONAL_COMMANDS = exports.COMMAND_OPTIONS = exports.REGISTRY_TOKENS = exports.RELEASE_HELP = exports.PNPM_RECURSIVE = exports.COMMAND_STRING_PROGRAMS = exports.DATA_PROGRAMS = exports.NPM_DRY_RUN_SUBCOMMANDS = exports.NPM_SCRIPT_RUNS = exports.NPM_WRITES = exports.NPM_TABLE = void 0;
|
|
37
|
+
exports.npmCommand = npmCommand;
|
|
38
|
+
exports.npmHonoursDryRun = npmHonoursDryRun;
|
|
39
|
+
exports.dryFlagOn = dryFlagOn;
|
|
40
|
+
exports.unwrapWith = unwrapWith;
|
|
41
|
+
exports.commandStrings = commandStrings;
|
|
42
|
+
exports.managerBuiltins = managerBuiltins;
|
|
43
|
+
exports.runnerScripts = runnerScripts;
|
|
44
|
+
// @implements A-SPEC-794.80, A-SPEC-794.78, A-SPEC-794.76, A-SPEC-794.75, A-SPEC-794.74, A-SPEC-794.72, A-SPEC-794.71, A-SPEC-794.70, A-SPEC-794.69
|
|
45
|
+
/**
|
|
46
|
+
* What programs and subcommands do, in one table (A-SPEC-794.70): which subcommands of the package managers write to
|
|
47
|
+
* a registry, which follow --dry-run, which run package scripts (and which), which release tools publish, and which
|
|
48
|
+
* runners run a script by name. The outward judgement reads rows, not names: a new tool is a row.
|
|
49
|
+
*
|
|
50
|
+
* npm's spellings are npm's own: `fixtures/npm-commands.json` is frozen from npm's `lib/utils/cmd-list.js` (commands,
|
|
51
|
+
* aliases), and `npmCommand` resolves a word as npm's `deref` does (camelCase to kebab-case, exact command, alias, then
|
|
52
|
+
* a unique prefix of a command or an alias, followed through aliases). The dry-run set is the commands whose source
|
|
53
|
+
* reads `dry-run` (npm 11.17.0).
|
|
54
|
+
*/
|
|
55
|
+
const table = __importStar(require("./fixtures/npm-commands.json"));
|
|
56
|
+
const builtins = __importStar(require("./fixtures/manager-builtins.json"));
|
|
57
|
+
exports.NPM_TABLE = {
|
|
58
|
+
commands: [...table.commands], aliases: { ...table.aliases }, dryRun: [...table.dryRun],
|
|
59
|
+
};
|
|
60
|
+
/** Every unique prefix of the command and alias names, as npm's `abbrev` builds it. */
|
|
61
|
+
const ABBREVS = (() => {
|
|
62
|
+
const names = [...new Set([...exports.NPM_TABLE.commands, ...Object.keys(exports.NPM_TABLE.aliases)])].sort();
|
|
63
|
+
const out = new Map();
|
|
64
|
+
for (const name of names) {
|
|
65
|
+
for (let k = 1; k <= name.length; k++) {
|
|
66
|
+
const p = name.slice(0, k);
|
|
67
|
+
if (p === name || !names.some((o) => o !== name && o.startsWith(p)))
|
|
68
|
+
out.set(p, name);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
})();
|
|
73
|
+
/** The npm command a word names, as npm's `deref` resolves it; undefined when npm would not run one. */
|
|
74
|
+
function npmCommand(word) {
|
|
75
|
+
if (!word)
|
|
76
|
+
return undefined;
|
|
77
|
+
const c = /[A-Z]/.test(word) ? word.replace(/([A-Z])/g, (m) => `-${m.toLowerCase()}`) : word;
|
|
78
|
+
if (exports.NPM_TABLE.commands.includes(c))
|
|
79
|
+
return c;
|
|
80
|
+
if (Object.prototype.hasOwnProperty.call(exports.NPM_TABLE.aliases, c))
|
|
81
|
+
return exports.NPM_TABLE.aliases[c];
|
|
82
|
+
let a = ABBREVS.get(c);
|
|
83
|
+
while (a !== undefined && Object.prototype.hasOwnProperty.call(exports.NPM_TABLE.aliases, a))
|
|
84
|
+
a = exports.NPM_TABLE.aliases[a];
|
|
85
|
+
return a;
|
|
86
|
+
}
|
|
87
|
+
function npmHonoursDryRun(command) { return exports.NPM_TABLE.dryRun.includes(command); }
|
|
88
|
+
const group = (writes, reads) => ({ writes, reads });
|
|
89
|
+
/** npm's registry writes, by canonical command. */
|
|
90
|
+
exports.NPM_WRITES = {
|
|
91
|
+
publish: true, unpublish: true, deprecate: true, undeprecate: true, star: true, unstar: true,
|
|
92
|
+
'dist-tag': group(['add', 'rm', 'set'], ['ls', 'list']),
|
|
93
|
+
owner: group(['add', 'rm', 'remove'], ['ls', 'list']),
|
|
94
|
+
access: group(['grant', 'revoke', 'set'], ['get', 'list', 'ls']),
|
|
95
|
+
team: group(['create', 'destroy', 'add', 'rm'], ['ls', 'list']),
|
|
96
|
+
token: group(['create', 'revoke'], ['list', 'ls']),
|
|
97
|
+
org: group(['set', 'rm'], ['ls', 'list']),
|
|
98
|
+
profile: group(['set', 'enable-2fa', 'disable-2fa'], ['get']),
|
|
99
|
+
stage: group(['publish', 'approve', 'reject'], ['list', 'view', 'download']),
|
|
100
|
+
trust: group(['github', 'gitlab', 'circleci', 'revoke'], ['list']),
|
|
101
|
+
};
|
|
102
|
+
const prepost = (s) => ({ names: [`pre${s}`, s, `post${s}`], ignoreSkips: 'prepost' });
|
|
103
|
+
exports.NPM_SCRIPT_RUNS = {
|
|
104
|
+
run: { names: 'named', ignoreSkips: 'prepost' }, test: prepost('test'), start: prepost('start'), stop: prepost('stop'),
|
|
105
|
+
restart: prepost('restart'),
|
|
106
|
+
// A-SPEC-794.74 — the install family runs the root package's install lifecycle; install-test also runs test
|
|
107
|
+
install: { names: ['preinstall', 'install', 'postinstall', 'prepare'], ignoreSkips: 'all' },
|
|
108
|
+
ci: { names: ['preinstall', 'install', 'postinstall', 'prepare'], ignoreSkips: 'all' },
|
|
109
|
+
rebuild: { names: ['preinstall', 'install', 'postinstall', 'prepare'], ignoreSkips: 'all' },
|
|
110
|
+
link: { names: ['preinstall', 'install', 'postinstall', 'prepare'], ignoreSkips: 'all' },
|
|
111
|
+
'install-test': { names: ['preinstall', 'install', 'postinstall', 'prepare', 'pretest', 'test', 'posttest'], ignoreSkips: 'prepost' },
|
|
112
|
+
'install-ci-test': { names: ['preinstall', 'install', 'postinstall', 'prepare', 'pretest', 'test', 'posttest'], ignoreSkips: 'prepost' },
|
|
113
|
+
version: { names: ['preversion', 'version', 'postversion'], ignoreSkips: 'all' },
|
|
114
|
+
pack: { names: ['prepack', 'prepare', 'postpack'], ignoreSkips: 'all' },
|
|
115
|
+
publish: { names: ['prepublishOnly', 'prepack', 'prepare', 'postpack', 'publish', 'postpublish'], ignoreSkips: 'all' },
|
|
116
|
+
};
|
|
117
|
+
/** Sub-subcommands that follow --dry-run by inheritance: npm's StagePublish extends Publish (stage/publish.js). */
|
|
118
|
+
exports.NPM_DRY_RUN_SUBCOMMANDS = { stage: ['publish'] };
|
|
119
|
+
/** Whether a dry flag is on, read with its value: `--dry-run`, `--dry-run=<v>`, `--no-dry-run`; the last one wins. */
|
|
120
|
+
function dryFlagOn(args, flags) {
|
|
121
|
+
let on = false;
|
|
122
|
+
for (let i = 0; i < args.length; i++) {
|
|
123
|
+
const a = args[i];
|
|
124
|
+
if (a === '--')
|
|
125
|
+
break;
|
|
126
|
+
for (const f of flags) {
|
|
127
|
+
// nopt: a boolean flag takes a following `true` or `false` as its value (A-SPEC-794.72)
|
|
128
|
+
if (a === f && /^(?:true|false)$/i.test(args[i + 1] ?? ''))
|
|
129
|
+
on = /^true$/i.test(args[i + 1]);
|
|
130
|
+
else if (a === f)
|
|
131
|
+
on = true;
|
|
132
|
+
// A-SPEC-794.74, 794.75 — as nopt's validateBoolean reads a value: `false` and `null` are false, a numeric value
|
|
133
|
+
// (`!isNaN(v)`, the empty value included) is `!!(+v)`, anything else is true
|
|
134
|
+
else if (a.startsWith(`${f}=`)) {
|
|
135
|
+
const v = a.slice(f.length + 1);
|
|
136
|
+
on = v === 'false' || v === 'null' ? false : !Number.isNaN(Number(v)) ? Boolean(Number(v)) : true;
|
|
137
|
+
}
|
|
138
|
+
else if (f.startsWith('--') && a === `--no-${f.slice(2)}`)
|
|
139
|
+
on = false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return on;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Programs whose arguments are data (A-SPEC-794.71): only these exempt their arguments. Any other program — an unknown
|
|
146
|
+
* wrapper included — is read again from the first registry token among its arguments.
|
|
147
|
+
*/
|
|
148
|
+
exports.DATA_PROGRAMS = new Set(['echo', 'printf', 'cat', 'head', 'tail', 'less', 'more', 'wc', 'ls', 'grep',
|
|
149
|
+
'egrep', 'fgrep', 'rg', 'ag', 'jq', 'yq', 'sort', 'uniq', 'cut', 'tr', 'tee', 'diff', 'cmp', 'test', '[', '[[', 'true', 'false', ':',
|
|
150
|
+
'date', 'basename', 'dirname', 'realpath', 'readlink', 'pwd', 'cd', 'pushd', 'popd', 'mkdir', 'rmdir', 'touch', 'rm', 'cp', 'mv', 'ln',
|
|
151
|
+
'chmod', 'chown', 'stat', 'file', 'which', 'type', 'gh', 'jest', 'for', 'select', 'case', 'in', 'vitest', 'mocha', 'pytest', 'tsc', 'eslint', 'prettier',
|
|
152
|
+
'curl', 'wget', 'sleep', 'kill', 'ps', 'pgrep', 'uptime', 'open', 'shasum', 'sha256sum', 'md5', 'base64', 'od', 'xxd', 'hexdump',
|
|
153
|
+
'du', 'df', 'find', 'tar', 'zip', 'unzip', 'gzip', 'gunzip', 'holmes-kit', 'export', 'declare', 'local', 'readonly', 'typeset',
|
|
154
|
+
'read', 'unset', 'set', 'shift', 'return', 'exit', 'wait', 'jobs', 'cmp', 'column', 'nl', 'fold', 'fmt', 'paste', 'join', 'comm',
|
|
155
|
+
'launchctl', 'defaults', 'say', 'pbcopy', 'pbpaste', 'man', 'tldr', 'info', 'logger', 'notify-send', 'terminal-notifier']);
|
|
156
|
+
/** A-SPEC-794.74 — programs whose command-string positions are read (commandStrings); their other words are data. */
|
|
157
|
+
exports.COMMAND_STRING_PROGRAMS = new Set(['ssh', 'tmux', 'watchexec', 'nodemon', 'entr', 'watch',
|
|
158
|
+
'parallel', 'concurrently', 'doppler', 'infisical', 'tar', 'zip', 'wget']);
|
|
159
|
+
/** A-SPEC-794.74 — pnpm's names for a recursive run. */
|
|
160
|
+
exports.PNPM_RECURSIVE = new Set(['m', 'multi', 'recursive']);
|
|
161
|
+
/** A release tool's own help and version flags: nothing is published. */
|
|
162
|
+
exports.RELEASE_HELP = new Set(['--help', '-h', '--version', '-v', '-V']);
|
|
163
|
+
/** Program tokens that start a registry act when they appear among another program's arguments. */
|
|
164
|
+
exports.REGISTRY_TOKENS = new Set(['npm', 'pnpm', 'yarn', 'bun', 'npx', 'pnpx', 'bunx', 'corepack',
|
|
165
|
+
'semantic-release', 'np', 'release-it', 'nx', 'changeset', 'changesets', 'lerna', 'turbo', 'run-s', 'run-p', 'npm-run-all']);
|
|
166
|
+
/** Options whose value is a command, by program; and programs whose positional arguments are commands. */
|
|
167
|
+
exports.COMMAND_OPTIONS = {
|
|
168
|
+
npx: ['-c', '--call'], pnpx: ['-c'], bunx: ['-c'], nodemon: ['--exec', '-x'], nix: ['-c', '--command'],
|
|
169
|
+
'nix-shell': ['--run', '--command'],
|
|
170
|
+
};
|
|
171
|
+
exports.POSITIONAL_COMMANDS = new Set(['concurrently']);
|
|
172
|
+
/** A package that runs a release tool's bin. */
|
|
173
|
+
exports.PACKAGE_BINS = {
|
|
174
|
+
'@changesets/cli': 'changeset', 'semantic-release': 'semantic-release', np: 'np', 'release-it': 'release-it', lerna: 'lerna',
|
|
175
|
+
nx: 'nx', '@nrwl/cli': 'nx', 'npm-run-all': 'npm-run-all', 'npm-run-all2': 'npm-run-all',
|
|
176
|
+
};
|
|
177
|
+
/** A-SPEC-794.72 — the registry programs read as independent tokens in an unknown program's arguments. */
|
|
178
|
+
exports.REGISTRY_PROGRAMS = new Set(['npm', 'pnpm', 'yarn', 'yarnpkg', 'bun']);
|
|
179
|
+
exports.WRAPPERS = {
|
|
180
|
+
timeout: { valued: ['-s', '-k', '--signal', '--kill-after'], positionals: 1 },
|
|
181
|
+
caffeinate: { valued: ['-t', '-w'] },
|
|
182
|
+
op: { sub: 'run', valued: ['--env-file', '--account', '--cache'] },
|
|
183
|
+
doppler: { sub: 'run', valued: ['-p', '--project', '-c', '--config', '--token', '--command'] },
|
|
184
|
+
infisical: { sub: 'run', valued: ['--env', '--path', '--projectId', '--token', '--command'] },
|
|
185
|
+
dotenv: { valued: ['-e', '-c', '-v', '-p'] },
|
|
186
|
+
dotenvx: { sub: 'run', valued: ['-f', '--env-file', '-e', '--env'] },
|
|
187
|
+
'cross-env': { assigns: true },
|
|
188
|
+
'aws-vault': { sub: 'exec', positionals: 1, valued: ['-d', '--duration', '--region'] },
|
|
189
|
+
nvm: { sub: 'exec', positionals: 1 },
|
|
190
|
+
volta: { sub: 'run', valued: ['--node', '--npm', '--yarn', '--pnpm'] },
|
|
191
|
+
mise: { sub: ['exec', 'x'], toolArgs: true }, fnm: { sub: 'exec', valued: ['--using'] }, asdf: { sub: 'exec' },
|
|
192
|
+
direnv: { sub: 'exec', positionals: 1 },
|
|
193
|
+
devbox: { sub: 'run' },
|
|
194
|
+
nix: { sub: 'develop', commandFlag: ['-c', '--command'] },
|
|
195
|
+
script: { valued: ['-t', '-T'], positionals: 1 },
|
|
196
|
+
launchctl: { sub: 'submit', valued: ['-l', '-p', '-o', '-e', '-g'] },
|
|
197
|
+
};
|
|
198
|
+
/** The command after a wrapper's own words, or null when the words do not run one. */
|
|
199
|
+
function unwrapWith(w, args) {
|
|
200
|
+
let rest = [...args];
|
|
201
|
+
if (w.sub !== undefined) {
|
|
202
|
+
const subs = typeof w.sub === 'string' ? [w.sub] : w.sub;
|
|
203
|
+
if (!subs.includes(rest[0] ?? ''))
|
|
204
|
+
return null;
|
|
205
|
+
rest = rest.slice(1);
|
|
206
|
+
}
|
|
207
|
+
// A-SPEC-794.74 — a tool list before `--` (`mise exec node@20 -- …`): the command is after `--`
|
|
208
|
+
if (w.toolArgs === true && rest.includes('--'))
|
|
209
|
+
return rest.slice(rest.indexOf('--') + 1);
|
|
210
|
+
if (w.commandFlag !== undefined) {
|
|
211
|
+
const k = rest.findIndex((a) => w.commandFlag?.includes(a));
|
|
212
|
+
return k < 0 ? null : rest.slice(k + 1);
|
|
213
|
+
}
|
|
214
|
+
let pos = 0;
|
|
215
|
+
for (let k = 0; k < rest.length; k++) {
|
|
216
|
+
const a = rest[k];
|
|
217
|
+
if (a === '--')
|
|
218
|
+
return rest.slice(k + 1);
|
|
219
|
+
if (w.valued?.includes(a)) {
|
|
220
|
+
k++;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (a.startsWith('-'))
|
|
224
|
+
continue;
|
|
225
|
+
if (w.assigns === true && /^[A-Za-z_]\w*=/.test(a))
|
|
226
|
+
continue;
|
|
227
|
+
if (pos < (w.positionals ?? 0)) {
|
|
228
|
+
pos++;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
return rest.slice(k);
|
|
232
|
+
}
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
const valuesOf = (args, names) => {
|
|
236
|
+
const out = [];
|
|
237
|
+
for (let k = 0; k < args.length; k++) {
|
|
238
|
+
for (const n of names) {
|
|
239
|
+
if (args[k] === n && args[k + 1] !== undefined)
|
|
240
|
+
out.push(args[k + 1]);
|
|
241
|
+
else if (n.startsWith('--') && args[k].startsWith(`${n}=`))
|
|
242
|
+
out.push(args[k].slice(n.length + 1));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return out;
|
|
246
|
+
};
|
|
247
|
+
/** The words after the options (valued ones skip their value), or after `--`. */
|
|
248
|
+
const afterOptions = (args, valued) => {
|
|
249
|
+
for (let k = 0; k < args.length; k++) {
|
|
250
|
+
if (args[k] === '--')
|
|
251
|
+
return args.slice(k + 1);
|
|
252
|
+
if (valued.includes(args[k])) {
|
|
253
|
+
k++;
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (!args[k].startsWith('-'))
|
|
257
|
+
return args.slice(k);
|
|
258
|
+
}
|
|
259
|
+
return [];
|
|
260
|
+
};
|
|
261
|
+
const asCommandText = (words) => (words.length === 0 ? [] : words.length === 1 ? [words[0]] : [words.map((v) => (/^[\w@%+=:,./-]+$/.test(v) ? v : `'${v.replace(/'/g, `'\\''`)}'`)).join(' ')]);
|
|
262
|
+
/**
|
|
263
|
+
* A-SPEC-794.72 — the command strings a program runs, at the positions this table names. A string anywhere else is
|
|
264
|
+
* data. (Shells' -c, npx -c and npm exec -c are read where they were.)
|
|
265
|
+
*/
|
|
266
|
+
function commandStrings(name, args) {
|
|
267
|
+
switch (name) {
|
|
268
|
+
case 'doppler':
|
|
269
|
+
case 'infisical': return valuesOf(args, ['--command']);
|
|
270
|
+
case 'nodemon': return valuesOf(args, ['--exec', '-x']);
|
|
271
|
+
case 'concurrently': return args.filter((a) => !a.startsWith('-'));
|
|
272
|
+
case 'watch': return asCommandText(afterOptions(args, ['-n', '--interval', '-d']));
|
|
273
|
+
case 'watchexec': return asCommandText(afterOptions(args, ['-w', '--watch', '-e', '--exts', '-i', '--ignore', '-d', '--debounce', '--shell', '-s', '--signal']));
|
|
274
|
+
case 'entr': return valuesOf(args, ['-s']);
|
|
275
|
+
case 'ssh': {
|
|
276
|
+
const rest = afterOptions(args, ['-p', '-i', '-l', '-o', '-F', '-J', '-L', '-R', '-D', '-b', '-c', '-E', '-e', '-m', '-O', '-Q', '-S', '-W', '-w']);
|
|
277
|
+
return asCommandText(rest.slice(1));
|
|
278
|
+
}
|
|
279
|
+
case 'tmux': return ['new', 'new-session', 'new-window', 'split-window', 'respawn-pane'].includes(args[0] ?? '') ? asCommandText(afterOptions(args.slice(1), ['-s', '-n', '-c', '-t', '-x', '-y', '-e', '-F', '-l'])) : [];
|
|
280
|
+
case 'parallel': {
|
|
281
|
+
const rest = afterOptions(args, ['-j', '--jobs', '-S', '--sshlogin']);
|
|
282
|
+
const end = rest.indexOf(':::');
|
|
283
|
+
return asCommandText(end < 0 ? rest.slice(0, 1) : rest.slice(0, end));
|
|
284
|
+
}
|
|
285
|
+
case 'git': {
|
|
286
|
+
const sub = afterOptions(args, ['-C', '-c', '--git-dir', '--work-tree', '--namespace', '--config-env', '--exec-path']);
|
|
287
|
+
const rest = sub.slice(1);
|
|
288
|
+
switch (sub[0]) {
|
|
289
|
+
case 'rebase': return valuesOf(rest, ['--exec', '-x']);
|
|
290
|
+
case 'bisect': return rest[0] === 'run' ? asCommandText(rest.slice(1)) : [];
|
|
291
|
+
case 'submodule': return rest[0] === 'foreach' ? asCommandText(rest.slice(1).filter((a) => a !== '--recursive' && a !== '-q' && a !== '--quiet')) : [];
|
|
292
|
+
case 'difftool':
|
|
293
|
+
case 'mergetool': return valuesOf(rest, ['-x', '--extcmd', '--tool-cmd']);
|
|
294
|
+
case 'filter-branch': return valuesOf(rest, ['--tree-filter', '--index-filter', '--msg-filter', '--env-filter', '--commit-filter', '--parent-filter', '--tag-name-filter']);
|
|
295
|
+
default: return [];
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
case 'tar': return [...valuesOf(args, ['--to-command', '--use-compress-program', '-I']), ...valuesOf(args, ['--checkpoint-action']).filter((v) => v.startsWith('exec=')).map((v) => v.slice(5))];
|
|
299
|
+
case 'zip': return valuesOf(args, ['-TT', '--unzip-command']);
|
|
300
|
+
case 'wget': return valuesOf(args, ['--use-askpass']);
|
|
301
|
+
case 'gh': return args[0] === 'alias' && args[1] === 'set' && args.includes('--shell') ? args.slice(2).filter((a) => !a.startsWith('-')).slice(1, 2) : [];
|
|
302
|
+
default: return [];
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/** Runners that run scripts of the current package by name (globs allowed). */
|
|
306
|
+
exports.SCRIPT_NAME_RUNNERS = new Set(['run-s', 'run-p', 'npm-run-all']);
|
|
307
|
+
/** npm options before the subcommand that take the next word as their value. */
|
|
308
|
+
exports.NPM_VALUED_OPTIONS = new Set(['--prefix', '-C', '-w', '--workspace', '--tag', '--registry', '--otp',
|
|
309
|
+
'--userconfig', '--globalconfig', '--cache', '--loglevel', '--access', '--scope', '--dir', '--cwd', '--filter', '-F',
|
|
310
|
+
// A-SPEC-794.75 — yarn v1's valued options before the subcommand
|
|
311
|
+
'--network-timeout', '--cache-folder', '--mutex', '--modules-folder', '--global-folder', '--link-folder', '--network-concurrency']);
|
|
312
|
+
/** A-SPEC-794.75 — `yarn workspaces foreach`'s valued options before the command it runs. */
|
|
313
|
+
exports.YARN_FOREACH_VALUED = new Set(['--exclude', '--from', '--include', '--jobs', '-j', '--since']);
|
|
314
|
+
/** yarn: its own registry writes (v1 and berry's `npm` group) and its own subcommands (never a script name). */
|
|
315
|
+
exports.YARN_WRITES = {
|
|
316
|
+
publish: true, tag: group(['add', 'remove', 'rm'], ['list', 'ls']), owner: group(['add', 'remove', 'rm'], ['list', 'ls']),
|
|
317
|
+
};
|
|
318
|
+
exports.YARN_NPM_WRITES = {
|
|
319
|
+
publish: true, tag: group(['add', 'remove'], ['list']),
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* A-SPEC-794.76 — each package manager's own built-ins, frozen from its command list (fixtures/manager-builtins.json):
|
|
323
|
+
* a word that is not one of them runs a script of that name. One shared list let pnpm's `deploy` hide `yarn deploy`.
|
|
324
|
+
*/
|
|
325
|
+
const BUILTINS = {
|
|
326
|
+
// A-SPEC-794.78 — only the names both yarn majors own: a name one major lacks may be a script there (`patch`, `check`)
|
|
327
|
+
yarn: new Set(builtins.yarn1.commands.filter((n) => builtins.yarnBerry.commands.includes(n))),
|
|
328
|
+
pnpm: new Set(builtins.pnpm.commands),
|
|
329
|
+
bun: new Set(builtins.bun.commands),
|
|
330
|
+
};
|
|
331
|
+
function managerBuiltins(tool) {
|
|
332
|
+
return tool === 'yarn' || tool === 'pnpm' || tool === 'bun' ? BUILTINS[tool] : new Set();
|
|
333
|
+
}
|
|
334
|
+
const firstPositional = (args) => args.find((a) => !a.startsWith('-'));
|
|
335
|
+
exports.RELEASE_TOOLS = {
|
|
336
|
+
'semantic-release': { dry: ['--dry-run', '-d'] },
|
|
337
|
+
np: { dry: ['--preview'] },
|
|
338
|
+
'release-it': { dry: ['--dry-run', '-d'] },
|
|
339
|
+
nx: { dry: ['--dry-run', '-d'], needs: (a) => a[0] === 'release' && !['version', 'changelog', 'plan'].includes(firstPositional(a.slice(1)) ?? '') },
|
|
340
|
+
changeset: { dry: [], needs: (a) => firstPositional(a) === 'publish' },
|
|
341
|
+
changesets: { dry: [], needs: (a) => firstPositional(a) === 'publish' },
|
|
342
|
+
lerna: { dry: [], needs: (a) => firstPositional(a) === 'publish' },
|
|
343
|
+
};
|
|
344
|
+
/** Runners that run a package script by name in every package: the script names they run, or null. */
|
|
345
|
+
function runnerScripts(name, args) {
|
|
346
|
+
const pos = args.filter((a) => !a.startsWith('-'));
|
|
347
|
+
if (name === 'lerna' && pos[0] === 'run')
|
|
348
|
+
return pos[1] !== undefined ? [pos[1]] : null;
|
|
349
|
+
if (name === 'turbo') {
|
|
350
|
+
const TURBO_OWN = new Set(['login', 'logout', 'link', 'unlink', 'prune', 'daemon', 'gen', 'generate', 'ls', 'info', 'telemetry', 'query', 'watch', 'boundaries', 'scan', 'bin']);
|
|
351
|
+
if (pos[0] === 'run')
|
|
352
|
+
return pos.slice(1);
|
|
353
|
+
return pos[0] !== undefined && !TURBO_OWN.has(pos[0]) ? pos : null;
|
|
354
|
+
}
|
|
355
|
+
if (name === 'nx' && pos[0] === 'run-many') {
|
|
356
|
+
for (let k = 0; k < args.length; k++) {
|
|
357
|
+
const m = /^--(?:target|targets)=(.+)$/.exec(args[k]);
|
|
358
|
+
if (m)
|
|
359
|
+
return m[1].split(',');
|
|
360
|
+
if ((args[k] === '-t' || args[k] === '--target' || args[k] === '--targets') && args[k + 1] !== undefined)
|
|
361
|
+
return args[k + 1].split(',');
|
|
362
|
+
}
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
if (name === 'nx' && pos[0] === 'run' && pos[1]?.includes(':'))
|
|
366
|
+
return [pos[1].split(':')[1]];
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
/** Shells whose `-c` string is a command, and that read their program from stdin without one. */
|
|
370
|
+
exports.SHELL_PROGRAMS = /^(?:ba|z|da|k|mk|fi|)sh$/;
|
|
371
|
+
/** Interpreters whose inline or stdin program is another language. */
|
|
372
|
+
exports.INTERPRETERS = /^(?:node|nodejs|python[0-9.]*|perl|ruby|php|deno)$/;
|
|
373
|
+
/** Their flag for an inline program. */
|
|
374
|
+
exports.INLINE_FLAGS = new Set(['-e', '--eval', '-p', '--print', '-c', '-E', '-r']);
|
|
375
|
+
/** Environment variables whose value a program runs as a command. */
|
|
376
|
+
exports.COMMAND_VARIABLES = new Set(['GIT_EDITOR', 'GIT_SEQUENCE_EDITOR', 'GIT_PAGER', 'GIT_SSH_COMMAND',
|
|
377
|
+
'GIT_EXTERNAL_DIFF', 'EDITOR', 'VISUAL', 'PAGER', 'GIT_ASKPASS', 'SSH_ASKPASS']);
|
|
378
|
+
/** Programs that run the package named by their first positional word (with its version stripped). */
|
|
379
|
+
exports.PACKAGE_RUNNERS = new Set(['npx', 'pnpx', 'bunx', 'corepack']);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "each package manager's own built-in commands (A-SPEC-794.76). yarn 1.22.22 and pnpm 9.15.9: taken from their published bundles (yarn lib/cli.js `commands`, camelCase names written as the CLI spells them; pnpm dist/pnpm.cjs `commandNames`). yarn 4 (berry) and bun 1: from their CLI references, because neither is installed on the machine that froze this list.",
|
|
3
|
+
"yarn1": {
|
|
4
|
+
"version": "1.22.22",
|
|
5
|
+
"from": "bundle",
|
|
6
|
+
"commands": ["access", "add", "audit", "autoclean", "bin", "cache", "check", "config", "create", "dedupe", "exec", "generate-lock-entry", "global", "help", "import", "info", "init", "install", "licenses", "link", "list", "lockfile", "login", "logout", "node", "outdated", "owner", "pack", "policies", "prune", "publish", "remove", "run", "tag", "team", "unlink", "unplug", "upgrade", "upgrade-interactive", "version", "versions", "why", "workspace", "workspaces"]
|
|
7
|
+
},
|
|
8
|
+
"yarnBerry": {
|
|
9
|
+
"version": "4",
|
|
10
|
+
"from": "CLI reference",
|
|
11
|
+
"commands": ["add", "bin", "cache", "config", "constraints", "dedupe", "dlx", "exec", "explain", "info", "init", "install", "link", "node", "npm", "pack", "patch", "patch-commit", "plugin", "rebuild", "remove", "run", "set", "stage", "unlink", "unplug", "up", "upgrade-interactive", "version", "why", "workspace", "workspaces"]
|
|
12
|
+
},
|
|
13
|
+
"pnpm": {
|
|
14
|
+
"version": "9.15.9",
|
|
15
|
+
"from": "bundle",
|
|
16
|
+
"commands": ["add", "audit", "bin", "c", "cache", "cat-file", "cat-index", "ci", "clean-install", "completion", "config", "create", "dedupe", "deploy", "dislink", "dlx", "doctor", "env", "exec", "fetch", "find-hash", "get", "i", "ic", "import", "init", "install", "install-clean", "install-test", "it", "la", "licenses", "link", "list", "ll", "ln", "ls", "m", "multi", "outdated", "pack", "patch", "patch-commit", "patch-remove", "prune", "publish", "rb", "rebuild", "recursive", "remove", "restart", "rm", "root", "run", "run-script", "self-update", "server", "set", "setup", "store", "t", "test", "tst", "un", "uni", "uninstall", "unlink", "up", "update", "upgrade", "why"]
|
|
17
|
+
},
|
|
18
|
+
"bun": {
|
|
19
|
+
"version": "1",
|
|
20
|
+
"from": "CLI reference",
|
|
21
|
+
"commands": ["run", "test", "x", "repl", "exec", "install", "i", "add", "a", "remove", "rm", "update", "outdated", "audit", "link", "unlink", "publish", "patch", "pm", "build", "init", "create", "upgrade", "completions", "discord", "help", "info", "why"]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "npm 11.17.0 lib/utils/cmd-list.js (commands, aliases); dryRun: the commands whose lib/commands source file reads dry-run",
|
|
3
|
+
"npmVersion": "11.17.0",
|
|
4
|
+
"commands": ["access", "adduser", "approve-scripts", "audit", "bugs", "cache", "ci", "completion", "config", "dedupe", "deny-scripts", "deprecate", "diff", "dist-tag", "docs", "doctor", "edit", "exec", "explain", "explore", "find-dupes", "fund", "get", "help", "help-search", "init", "install", "install-ci-test", "install-test", "link", "ll", "login", "logout", "ls", "org", "outdated", "owner", "pack", "ping", "pkg", "prefix", "profile", "prune", "publish", "query", "rebuild", "repo", "restart", "root", "run", "sbom", "search", "set", "shrinkwrap", "stage", "star", "stars", "start", "stop", "team", "test", "token", "trust", "undeprecate", "uninstall", "unpublish", "unstar", "update", "version", "view", "whoami"],
|
|
5
|
+
"aliases": { "author": "owner", "home": "docs", "issues": "bugs", "info": "view", "show": "view", "find": "search", "add": "install", "unlink": "uninstall", "remove": "uninstall", "rm": "uninstall", "r": "uninstall", "un": "uninstall", "rb": "rebuild", "list": "ls", "ln": "link", "create": "init", "i": "install", "it": "install-test", "cit": "install-ci-test", "u": "update", "up": "update", "c": "config", "s": "search", "se": "search", "tst": "test", "t": "test", "ddp": "dedupe", "v": "view", "run-script": "run", "clean-install": "ci", "clean-install-test": "install-ci-test", "x": "exec", "why": "explain", "la": "ll", "verison": "version", "ic": "ci", "innit": "init", "in": "install", "ins": "install", "inst": "install", "insta": "install", "instal": "install", "isnt": "install", "isnta": "install", "isntal": "install", "isntall": "install", "install-clean": "ci", "isntall-clean": "ci", "hlep": "help", "dist-tags": "dist-tag", "upgrade": "update", "udpate": "update", "rum": "run", "sit": "install-ci-test", "urn": "run", "ogr": "org", "add-user": "adduser" },
|
|
6
|
+
"dryRun": ["audit", "cache", "ci", "dedupe", "deprecate", "find-dupes", "install", "link", "pack", "prune", "publish", "unpublish", "update"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** What the reader may consult beyond the text: where the command runs, and the package scripts. */
|
|
2
|
+
export interface OutwardContext {
|
|
3
|
+
cwd?: string;
|
|
4
|
+
projectRoot?: string;
|
|
5
|
+
/** The scripts of the package.json npm would use for `dir` (walking up); null when unreadable or, for an explicit
|
|
6
|
+
* directory, missing. A fake may ignore `explicit`. */
|
|
7
|
+
readScripts?: (dir: string, explicit?: boolean) => Record<string, string> | null;
|
|
8
|
+
/** The repository's packages (A-SPEC-794.70, 794.71); a plain list is read as having no unreadable file. */
|
|
9
|
+
allScripts?: () => Array<{
|
|
10
|
+
dir: string;
|
|
11
|
+
scripts: Record<string, string>;
|
|
12
|
+
}> | RepositoryScripts | null;
|
|
13
|
+
depth?: number;
|
|
14
|
+
}
|
|
15
|
+
/** The repository's packages (A-SPEC-794.71): the readable ones, the unreadable ones by path, and a limit when the
|
|
16
|
+
* listing stopped short (which closes, naming the limit). */
|
|
17
|
+
export interface RepositoryScripts {
|
|
18
|
+
packages: Array<{
|
|
19
|
+
dir: string;
|
|
20
|
+
scripts: Record<string, string>;
|
|
21
|
+
}>;
|
|
22
|
+
unreadable: string[];
|
|
23
|
+
limit?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface OutwardFinding {
|
|
26
|
+
act: 'push' | 'publish';
|
|
27
|
+
clause: string;
|
|
28
|
+
word: string;
|
|
29
|
+
why: string;
|
|
30
|
+
rewrite: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A-SPEC-794.82 — `unjudged` names why the judgement stopped before reading the whole command (it is too large);
|
|
34
|
+
* such a command is refused under every profile flag, because the acts it was not read for are unknown.
|
|
35
|
+
*/
|
|
36
|
+
export interface OutwardVerdict {
|
|
37
|
+
acts: Array<'push' | 'publish'>;
|
|
38
|
+
reasons: string[];
|
|
39
|
+
findings: OutwardFinding[];
|
|
40
|
+
unjudged?: string;
|
|
41
|
+
}
|
|
42
|
+
/** A-SPEC-794.87 — how many findings a verdict's reasons and a refusal list. */
|
|
43
|
+
export declare const MAX_LISTED = 200;
|
|
44
|
+
export declare function renderFinding(f: OutwardFinding): string;
|
|
45
|
+
export declare function judgeOutward(command: string, ctx?: OutwardContext): OutwardVerdict;
|
|
46
|
+
/** The acts, both of them when the command could not be judged whole (A-SPEC-794.82: closed, never open). */
|
|
47
|
+
export declare function outwardActsOf(command: string, ctx?: OutwardContext): Array<'push' | 'publish'>;
|