@memnexus-ai/cli 1.7.232 โ 1.7.234
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/dist/commands/memories.d.ts.map +1 -1
- package/dist/commands/memories.js +33 -8
- package/dist/commands/memories.js.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-help.d.ts.map +1 -1
- package/dist/lib/agent-help.js +6 -0
- package/dist/lib/agent-help.js.map +1 -1
- package/dist/lib/cli-parsing.d.ts +45 -0
- package/dist/lib/cli-parsing.d.ts.map +1 -0
- package/dist/lib/cli-parsing.js +82 -0
- package/dist/lib/cli-parsing.js.map +1 -0
- package/dist/lib/commit-context/privacy-filter.d.ts.map +1 -1
- package/dist/lib/commit-context/privacy-filter.js +37 -0
- package/dist/lib/commit-context/privacy-filter.js.map +1 -1
- package/dist/lib/content-input.d.ts +87 -0
- package/dist/lib/content-input.d.ts.map +1 -0
- package/dist/lib/content-input.js +320 -0
- package/dist/lib/content-input.js.map +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -70,6 +70,7 @@ const hook_1 = require("./commands/hook");
|
|
|
70
70
|
const commit_context_1 = require("./commands/commit-context");
|
|
71
71
|
const agent_help_1 = require("./lib/agent-help");
|
|
72
72
|
const errors_1 = require("./lib/errors");
|
|
73
|
+
const cli_parsing_1 = require("./lib/cli-parsing");
|
|
73
74
|
// Check for updates (respects config)
|
|
74
75
|
const notifier = (0, update_notifier_1.default)({
|
|
75
76
|
pkg: package_json_1.default,
|
|
@@ -90,11 +91,11 @@ program
|
|
|
90
91
|
.option('--no-color', 'Disable colored output')
|
|
91
92
|
.addHelpText('beforeAll', 'Copilot, Claude, ChatGPT: run "mx agent-help" for optimized documentation.\n')
|
|
92
93
|
.addHelpText('afterAll', '\n๐ฌ Need help? https://discord.gg/memnexus ยท https://github.com/memnexus-ai/support/issues')
|
|
93
|
-
.hook('preAction', () => {
|
|
94
|
-
// Handle --no-color
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
.hook('preAction', (_thisCommand, actionCommand) => {
|
|
95
|
+
// Handle --no-color, given either before the subcommand (parsed by the root)
|
|
96
|
+
// or after it (parsed by the leaf โ see applyPositionalOptionParsing).
|
|
97
|
+
// Commander parses --no-color as color: false.
|
|
98
|
+
if ((0, cli_parsing_1.isColorDisabled)(program, actionCommand)) {
|
|
98
99
|
process.env.NO_COLOR = '1';
|
|
99
100
|
}
|
|
100
101
|
});
|
|
@@ -133,6 +134,10 @@ program
|
|
|
133
134
|
// process to exit 0 with nothing on stdout, which is byte-identical to "no
|
|
134
135
|
// results". Route both through handleError so every escape is stderr + a
|
|
135
136
|
// non-zero exit code.
|
|
137
|
+
// Must run AFTER every command is registered: it walks the command tree.
|
|
138
|
+
// Stops a subcommand option's VALUE (e.g. --content "-V422โฆ") from being read
|
|
139
|
+
// as a root flag, which silently printed the version and exited 0.
|
|
140
|
+
(0, cli_parsing_1.applyPositionalOptionParsing)(program);
|
|
136
141
|
process.on('unhandledRejection', (reason) => {
|
|
137
142
|
(0, errors_1.handleError)(reason);
|
|
138
143
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA;;;;;;;;;;;;;;;;;GAiBG;AACH,yCAAsC;AACtC,mEAA0C;AAC1C,oEAAoF;AAEpF,qFAAqF;AACrF,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC;AACvC,UAAU,CAAC,KAAK,GAAG,CAAC,KAAkC,EAAE,IAAkC,EAAE,EAAE;IAC5F,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;QAChC,MAAM,SAAS,GAAG,eAAM,CAAC,aAAa,EAAE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CAAC,CAAC,CAAC,UAAU,CAAC;IACzD,OAAO,CAAC,GAAG,CAAC,IAAA,yBAAY,EAAC,KAAK,IAAI,IAAI,EAAE,GAA0B,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC,CAAC;AAEL,8EAA8E;AAC9E,4EAA4E;AAC5E,2EAA2E;AAC3E,2EAA2E;AAC3E,yEAAyE;AACzE,sBAAsB;AACtB,yEAAyE;AACzE,8EAA8E;AAC9E,mEAAmE;AACnE,IAAA,0CAA4B,EAAC,OAAO,CAAC,CAAC;AAEtC,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,EAAE;IAC1C,IAAA,oBAAW,EAAC,MAAM,CAAC,CAAC;AACtB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,KAAK,EAAE,EAAE;IACxC,IAAA,oBAAW,EAAC,KAAK,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,mCAAmC;AACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-help.d.ts","sourceRoot":"","sources":["../../src/lib/agent-help.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent-help.d.ts","sourceRoot":"","sources":["../../src/lib/agent-help.ts"],"names":[],"mappings":"AAoaA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAetF"}
|
package/dist/lib/agent-help.js
CHANGED
|
@@ -31,6 +31,12 @@ const WORKFLOWS = [
|
|
|
31
31
|
notes: 'Use --conversation-id "NEW" for first memory, then reuse the returned ID for follow-ups.',
|
|
32
32
|
scope: 'memories',
|
|
33
33
|
},
|
|
34
|
+
{
|
|
35
|
+
goal: 'Save text containing backticks, $(...), or ${VAR} without the shell eating it',
|
|
36
|
+
command: 'mx memories create --conversation-id "NEW" --content-file ./body.md',
|
|
37
|
+
notes: 'Your shell expands backticks and $(...) inside a double-quoted --content BEFORE mx runs, silently replacing your text with command output. --content-file reads the file verbatim (use "-" for stdin) and works on both create and update. Write the file with a file-write tool, not a heredoc.',
|
|
38
|
+
scope: 'memories',
|
|
39
|
+
},
|
|
34
40
|
{
|
|
35
41
|
goal: 'Find previous work on a topic',
|
|
36
42
|
command: 'mx memories search --query "authentication" --timeline',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-help.js","sourceRoot":"","sources":["../../src/lib/agent-help.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"agent-help.js","sourceRoot":"","sources":["../../src/lib/agent-help.ts"],"names":[],"mappings":";;;;;AA0aA,oCAeC;AAzbD;;;;;;;;;GASG;AACH,sEAA6C;AA2B7C,oEAAoE;AAEpE,MAAM,WAAW,GAAa;IAC5B,+BAA+B;IAC/B,4CAA4C;IAC5C,4DAA4D;IAC5D,kCAAkC;IAClC,gCAAgC;IAChC,kBAAkB;CACnB,CAAC;AAEF,MAAM,SAAS,GAAe;IAC5B;QACE,IAAI,EAAE,qCAAqC;QAC3C,OAAO,EAAE,4DAA4D;QACrE,KAAK,EACH,0FAA0F;QAC5F,KAAK,EAAE,UAAU;KAClB;IACD;QACE,IAAI,EAAE,+EAA+E;QACrF,OAAO,EAAE,qEAAqE;QAC9E,KAAK,EACH,kSAAkS;QACpS,KAAK,EAAE,UAAU;KAClB;IACD;QACE,IAAI,EAAE,+BAA+B;QACrC,OAAO,EAAE,wDAAwD;QACjE,KAAK,EACH,4FAA4F;QAC9F,KAAK,EAAE,UAAU;KAClB;IACD;QACE,IAAI,EAAE,yDAA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,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Argument-parsing hardening for the root `mx` program.
|
|
3
|
+
*
|
|
4
|
+
* The bug this fixes (silent content loss, exit 0):
|
|
5
|
+
*
|
|
6
|
+
* mx memories create --content "-V422-REPRO-SPIKE ..."
|
|
7
|
+
*
|
|
8
|
+
* printed the CLI version and exited 0 without creating anything. Cause is in
|
|
9
|
+
* commander's default (non-positional) parsing: the ROOT program scans every
|
|
10
|
+
* argument, including values that belong to a subcommand's option. `--content`
|
|
11
|
+
* is not a root option, so the root classifies it as unknown and then examines
|
|
12
|
+
* the NEXT argument on its own terms. commander's "combined short flag" branch
|
|
13
|
+
* (`-Vfoo` meaning `-V foo`) matches the leading `-V` of the content value
|
|
14
|
+
* against the root's `-V, --version` flag, fires the version action, and exits.
|
|
15
|
+
* Any content value beginning with a dash that collides with a root short flag
|
|
16
|
+
* is destroyed the same way; `--content=<value>` escapes it only because the
|
|
17
|
+
* equals form keeps flag and value in a single argv entry.
|
|
18
|
+
*
|
|
19
|
+
* The fix is structural, not a special case for the string `-V`:
|
|
20
|
+
* `enablePositionalOptions()` makes a command stop parsing its own options at
|
|
21
|
+
* the first recognised subcommand and hand every remaining argument down. The
|
|
22
|
+
* root then never inspects a subcommand's option values, so no value โ dash-led
|
|
23
|
+
* or not โ can be captured by a root flag.
|
|
24
|
+
*
|
|
25
|
+
* Cost of that change: global options placed AFTER a subcommand (`mx memories
|
|
26
|
+
* create --no-color`) would become "unknown option" errors, because the root no
|
|
27
|
+
* longer sees them. `--no-color` is the only such option, so it is registered on
|
|
28
|
+
* every leaf command (hidden from help) to keep existing invocations working.
|
|
29
|
+
* On a leaf, `--content` is a known value-taking option, so its value is
|
|
30
|
+
* consumed immediately and never re-examined as a flag.
|
|
31
|
+
*/
|
|
32
|
+
import { Command } from 'commander';
|
|
33
|
+
/**
|
|
34
|
+
* Enable positional-option parsing on the root and every command group, and
|
|
35
|
+
* back-fill the global `--no-color` switch onto every leaf command.
|
|
36
|
+
*
|
|
37
|
+
* Idempotent: safe to call more than once on the same program.
|
|
38
|
+
*/
|
|
39
|
+
export declare function applyPositionalOptionParsing(program: Command): void;
|
|
40
|
+
/**
|
|
41
|
+
* True when color should be disabled for this invocation: `--no-color` was
|
|
42
|
+
* given either before the subcommand (root) or after it (leaf).
|
|
43
|
+
*/
|
|
44
|
+
export declare function isColorDisabled(root: Command, actionCommand?: Command): boolean;
|
|
45
|
+
//# sourceMappingURL=cli-parsing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-parsing.d.ts","sourceRoot":"","sources":["../../src/lib/cli-parsing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAK5C;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEnE;AAqBD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAS/E"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyPositionalOptionParsing = applyPositionalOptionParsing;
|
|
4
|
+
exports.isColorDisabled = isColorDisabled;
|
|
5
|
+
/**
|
|
6
|
+
* Argument-parsing hardening for the root `mx` program.
|
|
7
|
+
*
|
|
8
|
+
* The bug this fixes (silent content loss, exit 0):
|
|
9
|
+
*
|
|
10
|
+
* mx memories create --content "-V422-REPRO-SPIKE ..."
|
|
11
|
+
*
|
|
12
|
+
* printed the CLI version and exited 0 without creating anything. Cause is in
|
|
13
|
+
* commander's default (non-positional) parsing: the ROOT program scans every
|
|
14
|
+
* argument, including values that belong to a subcommand's option. `--content`
|
|
15
|
+
* is not a root option, so the root classifies it as unknown and then examines
|
|
16
|
+
* the NEXT argument on its own terms. commander's "combined short flag" branch
|
|
17
|
+
* (`-Vfoo` meaning `-V foo`) matches the leading `-V` of the content value
|
|
18
|
+
* against the root's `-V, --version` flag, fires the version action, and exits.
|
|
19
|
+
* Any content value beginning with a dash that collides with a root short flag
|
|
20
|
+
* is destroyed the same way; `--content=<value>` escapes it only because the
|
|
21
|
+
* equals form keeps flag and value in a single argv entry.
|
|
22
|
+
*
|
|
23
|
+
* The fix is structural, not a special case for the string `-V`:
|
|
24
|
+
* `enablePositionalOptions()` makes a command stop parsing its own options at
|
|
25
|
+
* the first recognised subcommand and hand every remaining argument down. The
|
|
26
|
+
* root then never inspects a subcommand's option values, so no value โ dash-led
|
|
27
|
+
* or not โ can be captured by a root flag.
|
|
28
|
+
*
|
|
29
|
+
* Cost of that change: global options placed AFTER a subcommand (`mx memories
|
|
30
|
+
* create --no-color`) would become "unknown option" errors, because the root no
|
|
31
|
+
* longer sees them. `--no-color` is the only such option, so it is registered on
|
|
32
|
+
* every leaf command (hidden from help) to keep existing invocations working.
|
|
33
|
+
* On a leaf, `--content` is a known value-taking option, so its value is
|
|
34
|
+
* consumed immediately and never re-examined as a flag.
|
|
35
|
+
*/
|
|
36
|
+
const commander_1 = require("commander");
|
|
37
|
+
/** Long flag for the global color switch, kept working after a subcommand. */
|
|
38
|
+
const NO_COLOR_LONG = '--no-color';
|
|
39
|
+
/**
|
|
40
|
+
* Enable positional-option parsing on the root and every command group, and
|
|
41
|
+
* back-fill the global `--no-color` switch onto every leaf command.
|
|
42
|
+
*
|
|
43
|
+
* Idempotent: safe to call more than once on the same program.
|
|
44
|
+
*/
|
|
45
|
+
function applyPositionalOptionParsing(program) {
|
|
46
|
+
visit(program, true);
|
|
47
|
+
}
|
|
48
|
+
function visit(cmd, isRoot) {
|
|
49
|
+
// Back-fill BEFORE recursing, and on groups as well as leaves. With
|
|
50
|
+
// positional options each command parses only the arguments before its own
|
|
51
|
+
// subcommand, so `mx memories --no-color list` is parsed by `memories`, not
|
|
52
|
+
// by the root and not by `list`. Back-filling leaves only left every
|
|
53
|
+
// group-position use failing with "unknown option".
|
|
54
|
+
if (!isRoot && !cmd.options.some((o) => o.long === NO_COLOR_LONG)) {
|
|
55
|
+
cmd.addOption(new commander_1.Option(NO_COLOR_LONG, 'Disable colored output').hideHelp());
|
|
56
|
+
}
|
|
57
|
+
const subcommands = cmd.commands;
|
|
58
|
+
if (subcommands.length > 0) {
|
|
59
|
+
// A command that dispatches to subcommands must stop parsing at the
|
|
60
|
+
// subcommand name so subcommand option VALUES are never read as flags here.
|
|
61
|
+
cmd.enablePositionalOptions();
|
|
62
|
+
for (const sub of subcommands)
|
|
63
|
+
visit(sub, false);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* True when color should be disabled for this invocation: `--no-color` was
|
|
68
|
+
* given either before the subcommand (root) or after it (leaf).
|
|
69
|
+
*/
|
|
70
|
+
function isColorDisabled(root, actionCommand) {
|
|
71
|
+
if (root.opts().color === false)
|
|
72
|
+
return true;
|
|
73
|
+
// Walk the whole chain: --no-color may have been parsed by the leaf
|
|
74
|
+
// (`mx memories create --no-color`) or by any group above it
|
|
75
|
+
// (`mx memories --no-color create`), depending on where the user put it.
|
|
76
|
+
for (let cmd = actionCommand; cmd && cmd !== root; cmd = cmd.parent) {
|
|
77
|
+
if (cmd.opts().color === false)
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=cli-parsing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-parsing.js","sourceRoot":"","sources":["../../src/lib/cli-parsing.ts"],"names":[],"mappings":";;AA0CA,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IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,KAAK;YAAE,OAAO,IAAI,CAAC;IAC9C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privacy-filter.d.ts","sourceRoot":"","sources":["../../../src/lib/commit-context/privacy-filter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"privacy-filter.d.ts","sourceRoot":"","sources":["../../../src/lib/commit-context/privacy-filter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAmEH;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU7C"}
|
|
@@ -22,6 +22,43 @@ const SECRET_PATTERNS = [
|
|
|
22
22
|
/ghp_[a-zA-Z0-9]{36}/g,
|
|
23
23
|
// GitHub OAuth / user / service tokens
|
|
24
24
|
/gh[ous]_[a-zA-Z0-9]{36}/g,
|
|
25
|
+
// MemNexus API keys. This codebase mints TWO shapes and both authenticate,
|
|
26
|
+
// because core-api/src/routes/internal-auth.routes.ts validates only the
|
|
27
|
+
// `cmk_live_` prefix plus exactly one dot:
|
|
28
|
+
// 1. Application path โ core-api/src/repositories/apikey.repository.ts:69
|
|
29
|
+
// `cmk_live_<16 hex>.<24 alphanumeric>`
|
|
30
|
+
// 2. Shell/seeding path โ database/scripts/generate-api-key-hash.sh:64,
|
|
31
|
+
// database/scripts/seed-system-data.sh:66, core-api/scripts/seed-system-data.sh:74
|
|
32
|
+
// `cmk_live_${ENVIRONMENT}_<16 hex>.<secret>`, ENVIRONMENT in {dev,staging,prod}.
|
|
33
|
+
// This is the shape that seeds production, so missing it is the worse miss.
|
|
34
|
+
// The optional `[a-z]+_` group covers the environment segment; `{8,}` would not,
|
|
35
|
+
// since dev/prod/staging are all shorter than 8 and `_` is not in `[a-zA-Z0-9]`.
|
|
36
|
+
//
|
|
37
|
+
// The keyId is matched as exactly 16 hex characters, case-insensitive. Both
|
|
38
|
+
// generators emit lowercase today, but the class accepts either case so that a
|
|
39
|
+
// generator swapped for one emitting uppercase (`toUpperCase()`, a different
|
|
40
|
+
// uuid implementation) does not silently drop coverage. The environment segment
|
|
41
|
+
// likewise accepts any case. This costs nothing: measured against the full
|
|
42
|
+
// fixture set, widening both classes breaks zero negatives.
|
|
43
|
+
//
|
|
44
|
+
// Anchoring the keyId to 16 hex is deliberate and is what keeps the pattern off
|
|
45
|
+
// prose. `[a-zA-Z0-9]{8,}` would additionally swallow the documented placeholder
|
|
46
|
+
// at api-gateway/.env.example:63 (`cmk_live_dev_placeholder....`) and dotted
|
|
47
|
+
// identifiers such as `cmk_live_handler.processRequest_helper`.
|
|
48
|
+
//
|
|
49
|
+
// The 16-hex shape is a CONTRACT WITH THE GENERATORS, not a guess. It is pinned
|
|
50
|
+
// by an executable coupling test in core-api/tests/unit/utils/privacy-filter.test.ts
|
|
51
|
+
// that builds a keyId through the real generator expressions and asserts this
|
|
52
|
+
// filter redacts it. If a generator changes shape, that test fails loudly rather
|
|
53
|
+
// than this comment quietly becoming false.
|
|
54
|
+
//
|
|
55
|
+
// The dot-plus-body requirement matches a *token*, not a *mention*: prose naming
|
|
56
|
+
// the scheme ("keys look like cmk_live_<id>.<secret>") is left byte-identical,
|
|
57
|
+
// because `<` is outside the character classes.
|
|
58
|
+
//
|
|
59
|
+
// NOT covered: truncated fragments. A partial key with no dot, or a short body,
|
|
60
|
+
// passes through unredacted. See issue #5382.
|
|
61
|
+
/cmk_(?:live|test)_(?:[a-zA-Z]+_)?[0-9a-fA-F]{16}\.[a-zA-Z0-9_-]{8,}/g,
|
|
25
62
|
// Bearer tokens
|
|
26
63
|
/Bearer\s+[a-zA-Z0-9._-]{20,}/g,
|
|
27
64
|
// Generic key=value secrets (password, secret, token, key followed by = or :)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privacy-filter.js","sourceRoot":"","sources":["../../../src/lib/commit-context/privacy-filter.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;
|
|
1
|
+
{"version":3,"file":"privacy-filter.js","sourceRoot":"","sources":["../../../src/lib/commit-context/privacy-filter.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAyEH,4BAUC;AAjFD,MAAM,QAAQ,GAAG,YAAY,CAAC;AAE9B;;;GAGG;AACH,MAAM,eAAe,GAAa;IAChC,wDAAwD;IACxD,8BAA8B;IAE9B,8BAA8B;IAC9B,sBAAsB;IAEtB,gCAAgC;IAChC,sBAAsB;IAEtB,uCAAuC;IACvC,0BAA0B;IAE1B,2EAA2E;IAC3E,yEAAyE;IACzE,2CAA2C;IAC3C,4EAA4E;IAC5E,6CAA6C;IAC7C,0EAA0E;IAC1E,wFAAwF;IACxF,uFAAuF;IACvF,iFAAiF;IACjF,iFAAiF;IACjF,iFAAiF;IACjF,EAAE;IACF,4EAA4E;IAC5E,+EAA+E;IAC/E,6EAA6E;IAC7E,gFAAgF;IAChF,2EAA2E;IAC3E,4DAA4D;IAC5D,EAAE;IACF,gFAAgF;IAChF,iFAAiF;IACjF,6EAA6E;IAC7E,gEAAgE;IAChE,EAAE;IACF,gFAAgF;IAChF,qFAAqF;IACrF,8EAA8E;IAC9E,iFAAiF;IACjF,4CAA4C;IAC5C,EAAE;IACF,iFAAiF;IACjF,+EAA+E;IAC/E,gDAAgD;IAChD,EAAE;IACF,gFAAgF;IAChF,8CAA8C;IAC9C,sEAAsE;IAEtE,gBAAgB;IAChB,+BAA+B;IAE/B,8EAA8E;IAC9E,iEAAiE;IACjE,8DAA8D;CAC/D,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACnC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE,CAAC;QACtC,qCAAqC;QACrC,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC;QACtB,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maximum memory content length, in JavaScript String.length units (UTF-16 code
|
|
3
|
+
* units) โ NOT bytes. Mirrors MAX_NAMED_MEMORY_CONTENT_LENGTH in
|
|
4
|
+
* core-api/src/schemas/memory.schema.ts, which is enforced by Zod `.max()` on
|
|
5
|
+
* every server-side content write path. Enforced locally so an oversized file
|
|
6
|
+
* fails before the request instead of returning a 413. The server still
|
|
7
|
+
* enforces its own limit โ this is a usability guard, not a trust boundary.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MAX_MEMORY_CONTENT_LENGTH = 50000;
|
|
10
|
+
/**
|
|
11
|
+
* Byte ceiling on the file/stdin read. 50,000 characters is at most 200,000
|
|
12
|
+
* UTF-8 bytes, so 1 MB leaves generous headroom while bounding memory (CWE-400).
|
|
13
|
+
* Applied three ways: to the stat size of a regular file, to the running total
|
|
14
|
+
* of the chunked read, and to stdin. Mirrors BATCH_CREATE_MAX_LINE_BYTES.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MAX_CONTENT_FILE_BYTES: number;
|
|
17
|
+
/** Sentinel path meaning "read stdin". */
|
|
18
|
+
export declare const CONTENT_FILE_STDIN = "-";
|
|
19
|
+
export interface ContentInputOptions {
|
|
20
|
+
/** Value of --content, if given. */
|
|
21
|
+
content?: string;
|
|
22
|
+
/** Value of --content-file, if given ('-' = stdin). */
|
|
23
|
+
contentFile?: string;
|
|
24
|
+
/**
|
|
25
|
+
* True when --interactive was given. Interactive mode seeds the prompt with
|
|
26
|
+
* the resolved content, which would render a file's contents to the terminal
|
|
27
|
+
* โ the opposite of why the caller passed it by file. Rejected, not rendered.
|
|
28
|
+
*/
|
|
29
|
+
interactive?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface ContentInputDeps {
|
|
32
|
+
/**
|
|
33
|
+
* Injectable for tests; production reads `process.stdin` to its `end` event.
|
|
34
|
+
* Note that a stub here bypasses the real reader, so a stubbed test proves
|
|
35
|
+
* nothing about stdin handling โ the pipe behaviour is covered end to end in
|
|
36
|
+
* tests/integration/content-file-stdin.integration.test.ts.
|
|
37
|
+
*/
|
|
38
|
+
readStdin?: () => Promise<string> | string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Read a readable stream to completion with a hard byte ceiling.
|
|
42
|
+
*
|
|
43
|
+
* This is how stdin is read. A pipe delivers its data in as many writes as the
|
|
44
|
+
* producer chooses โ a script writing line by line, `jq`, `git log`, one `mx`
|
|
45
|
+
* piped into another โ and the only correct end-of-input signal is the stream's
|
|
46
|
+
* own `end` event. A synchronous read loop over fd 0 cannot see that: fd 0 is
|
|
47
|
+
* non-blocking in the shipped binary (libuv attaches a Pipe handle with
|
|
48
|
+
* O_NONBLOCK as soon as anything touches `process.stdin`, which `chalk` does
|
|
49
|
+
* transitively), so a gap between two writes surfaces as EAGAIN and any
|
|
50
|
+
* treatment of EAGAIN as EOF truncates the input silently.
|
|
51
|
+
*
|
|
52
|
+
* Bytes are accumulated as Buffers and decoded once at the end, so a multi-byte
|
|
53
|
+
* UTF-8 sequence split across two chunks is not corrupted.
|
|
54
|
+
*
|
|
55
|
+
* A TTY returns '' immediately rather than waiting for input that is not
|
|
56
|
+
* coming: the caller reports that as the empty-content error, so
|
|
57
|
+
* `mx ... --content-file -` at an interactive prompt fails fast instead of
|
|
58
|
+
* hanging.
|
|
59
|
+
*/
|
|
60
|
+
export declare function readStreamBounded(stream: NodeJS.ReadableStream & {
|
|
61
|
+
isTTY?: boolean;
|
|
62
|
+
destroy?: () => void;
|
|
63
|
+
}, maxBytes: number, label: string): Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Read the content a create/update should send.
|
|
66
|
+
*
|
|
67
|
+
* Returns `undefined` only when NEITHER flag was supplied (the caller decides
|
|
68
|
+
* whether that is an error, an interactive prompt, or a no-op update). A flag
|
|
69
|
+
* that is present but carries an empty value is an error, never a silent
|
|
70
|
+
* `undefined` โ `--content-file "$BODY_FILE"` with the variable unset is
|
|
71
|
+
* exactly the shell accident this flag exists to defend against, and on
|
|
72
|
+
* `update` a silent `undefined` reports success while the body stays stale.
|
|
73
|
+
*
|
|
74
|
+
* Throws a CLIError โ which `handleError` turns into exit 2 โ for every failure
|
|
75
|
+
* mode below.
|
|
76
|
+
*
|
|
77
|
+
* The path is used only as a filesystem path: it is resolved with
|
|
78
|
+
* `path.resolve` and passed to `fs.openSync`. It is never interpolated into a
|
|
79
|
+
* shell command and no process is spawned, so a path containing shell
|
|
80
|
+
* metacharacters is inert. Reads run with the invoking user's privileges and no
|
|
81
|
+
* path is privileged by the CLI, so this grants no read the caller did not
|
|
82
|
+
* already have; symlinks are followed deliberately (pointing at a symlink to
|
|
83
|
+
* your own note is a legitimate use, and refusing them closes nothing, since
|
|
84
|
+
* the caller could read the target directly).
|
|
85
|
+
*/
|
|
86
|
+
export declare function resolveContentInput(options: ContentInputOptions, deps?: ContentInputDeps): Promise<string | undefined>;
|
|
87
|
+
//# sourceMappingURL=content-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-input.d.ts","sourceRoot":"","sources":["../../src/lib/content-input.ts"],"names":[],"mappings":"AAqCA;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,QAAQ,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,QAAc,CAAC;AAKlD,0CAA0C;AAC1C,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,MAAM,WAAW,mBAAmB;IAClC,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;CAC5C;AAwCD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,CAAC,cAAc,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,EACzE,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,CAiCjB;AAMD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,EAC5B,IAAI,GAAE,gBAAqB,GAC1B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAmD7B"}
|