@mainwave/cli 0.11.0 → 0.12.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.
Files changed (39) hide show
  1. package/README.md +168 -13
  2. package/dist/adapters/claude-code.js +3 -3
  3. package/dist/adapters/claude-desktop.js +35 -1
  4. package/dist/adapters/cursor.js +7 -2
  5. package/dist/adapters/kiro.js +13 -8
  6. package/dist/commands.js +217 -0
  7. package/dist/core/apply.js +3 -3
  8. package/dist/core/auth-commands.js +2 -1
  9. package/dist/core/codecs/kiro-hooks-json.js +1 -1
  10. package/dist/core/doctor.js +71 -8
  11. package/dist/core/entry-script.js +2 -3
  12. package/dist/core/format.js +0 -1
  13. package/dist/core/hook-copies.js +157 -0
  14. package/dist/core/install-hooks.js +144 -15
  15. package/dist/core/interview.js +8 -2
  16. package/dist/core/markers.js +86 -22
  17. package/dist/core/redaction.js +179 -0
  18. package/dist/core/skills.js +3 -11
  19. package/dist/core/status.js +21 -1
  20. package/dist/core/store.js +254 -4
  21. package/dist/core/wizard.js +91 -6
  22. package/dist/main.js +163 -162
  23. package/hooks/kiro-otlp.mjs +10 -1
  24. package/hooks/mainwave-hook.mjs +11 -1
  25. package/hooks/marker-core.mjs +56 -2
  26. package/hooks/matchers.json +1 -1
  27. package/hooks/redaction-data.mjs +201 -0
  28. package/hooks/redaction-json.mjs +215 -0
  29. package/hooks/redaction-pattern.mjs +503 -0
  30. package/hooks/redaction.d.mts +84 -0
  31. package/hooks/redaction.mjs +701 -0
  32. package/package.json +3 -1
  33. package/skills/mainwave-instrument/SKILL.md +24 -6
  34. package/skills/mainwave-instrument/reference/frameworks.md +4 -2
  35. package/skills/mainwave-instrument/reference/troubleshooting.md +4 -0
  36. package/skills/mainwave-instrument-node/SKILL.md +83 -38
  37. package/skills/mainwave-instrument-node/reference/api.md +16 -16
  38. package/skills/mainwave-instrument-node/reference/frameworks.md +42 -27
  39. package/skills/mainwave-instrument-node/reference/troubleshooting.md +11 -7
@@ -0,0 +1,201 @@
1
+ // The built-in redaction rule packs and the attribute keys redaction never
2
+ // scans: the same data the Mainwave SDKs ship, so a rules file means the same
3
+ // thing here as in an application. Generated; do not edit by hand.
4
+ //
5
+ // PACKS: pack name -> rules, in the order they run. A rule's effective name is
6
+ // `<pack>.<name>`; `validate: 'luhn'` is the one post-match check.
7
+ // BUILTIN_EXEMPT_KEYS: identity and routing keys the platform joins on, never
8
+ // scanned whatever the rules say.
9
+
10
+ export const PACKS_VERSION = 1
11
+
12
+ export const PACKS = {
13
+ secrets: [
14
+ {
15
+ name: 'aws_access_key',
16
+ pattern: '\\b(?:AKIA|ASIA)[A-Z0-9]{16}\\b',
17
+ case_insensitive: false,
18
+ },
19
+ {
20
+ name: 'github_token',
21
+ pattern: 'gh[pousr]_[A-Za-z0-9]{36,255}\\b',
22
+ case_insensitive: false,
23
+ },
24
+ {
25
+ name: 'github_fine_grained_pat',
26
+ pattern: 'github_pat_[A-Za-z0-9_]{22,255}\\b',
27
+ case_insensitive: false,
28
+ },
29
+ {
30
+ name: 'anthropic_api_key',
31
+ pattern: 'sk-ant-[A-Za-z0-9_-]{20,256}',
32
+ case_insensitive: false,
33
+ },
34
+ {
35
+ name: 'openai_style_scoped_key',
36
+ pattern: 'sk-(?:proj|svcacct|admin|None|or-v1)-[A-Za-z0-9_-]{20,256}',
37
+ case_insensitive: false,
38
+ },
39
+ {
40
+ name: 'openai_api_key',
41
+ pattern: '\\bsk-[A-Za-z0-9]{20,256}',
42
+ case_insensitive: false,
43
+ },
44
+ {
45
+ name: 'slack_token',
46
+ pattern: '(?:xox[abcdprs]|xapp)-[A-Za-z0-9-]{10,256}',
47
+ case_insensitive: false,
48
+ },
49
+ {
50
+ name: 'private_key',
51
+ pattern:
52
+ '-----BEGIN (?:[A-Z]{1,16} ){0,4}PRIVATE KEY(?: BLOCK)?-----[\\s\\S]{0,8192}?-----END (?:[A-Z]{1,16} ){0,4}PRIVATE KEY(?: BLOCK)?-----',
53
+ case_insensitive: false,
54
+ },
55
+ {
56
+ name: 'jwt',
57
+ pattern: 'eyJ[A-Za-z0-9_-]{10,1024}\\.[A-Za-z0-9_-]{10,8192}\\.[A-Za-z0-9_-]{10,8192}',
58
+ case_insensitive: false,
59
+ },
60
+ ],
61
+ 'pii.contact': [
62
+ {
63
+ name: 'email',
64
+ pattern:
65
+ "\\b[A-Za-z0-9._%+'-]{1,64}(?:@|%40)[A-Za-z0-9-]{1,63}(?:\\.[A-Za-z0-9-]{1,63}){0,8}\\.[A-Za-z]{2,24}\\b",
66
+ case_insensitive: false,
67
+ },
68
+ {
69
+ name: 'phone_nanp',
70
+ pattern:
71
+ '(?:\\+1[ .-]?)?(?:\\([2-9]\\d{2}\\)[ .-]?[2-9]\\d{2}[ .-]\\d{4}|\\b[2-9]\\d{2}[ .-][2-9]\\d{2}[ .-]\\d{4})\\b|\\+1[ .-]?[2-9]\\d{2}[ .-]?[2-9]\\d{2}[ .-]?\\d{4}\\b',
72
+ case_insensitive: false,
73
+ },
74
+ {
75
+ name: 'phone_e164',
76
+ pattern: '\\B\\+[1-9](?:[ .-]?\\d){7,14}\\b',
77
+ case_insensitive: false,
78
+ },
79
+ ],
80
+ 'pii.us_gov_id': [
81
+ {
82
+ name: 'ssn',
83
+ pattern:
84
+ '\\b(?:00[1-9]|0[1-9]\\d|[1-578]\\d\\d|6[0-57-9]\\d|66[0-57-9])-(?:0[1-9]|[1-9]\\d)-(?:000[1-9]|00[1-9]\\d|0[1-9]\\d\\d|[1-9]\\d{3})\\b',
85
+ case_insensitive: false,
86
+ },
87
+ ],
88
+ 'pii.payment_card': [
89
+ {
90
+ name: 'card_number_grouped_19',
91
+ pattern: '\\b[2-6]\\d{3}[ .-]\\d{4}[ .-]\\d{4}[ .-]\\d{4}[ .-]\\d{3}\\b',
92
+ case_insensitive: false,
93
+ validate: 'luhn',
94
+ },
95
+ {
96
+ name: 'card_number',
97
+ pattern:
98
+ '\\b[2-6](?:\\d{12,18}|\\d{3}[ .-]\\d{4}[ .-]\\d{4}[ .-]\\d{1,4}|\\d{3}[ .-]\\d{6}[ .-]\\d{4,5})\\b',
99
+ case_insensitive: false,
100
+ validate: 'luhn',
101
+ },
102
+ ],
103
+ }
104
+
105
+ export const BUILTIN_EXEMPT_KEYS = [
106
+ 'agent.decision',
107
+ 'ccr.session.id',
108
+ 'cowork.surface',
109
+ 'decision',
110
+ 'devtool.cr_number',
111
+ 'devtool.cr_url',
112
+ 'devtool.external_id',
113
+ 'devtool.review_id',
114
+ 'devtool.review_verdict',
115
+ 'devtool.wi_key',
116
+ 'devtool.wi_prev_state_category',
117
+ 'devtool.wi_state_category',
118
+ 'devtool.wi_url',
119
+ 'gen_ai.agent.id',
120
+ 'gen_ai.agent.name',
121
+ 'gen_ai.conversation.id',
122
+ 'gen_ai.generation.id',
123
+ 'gen_ai.operation.name',
124
+ 'gen_ai.provider.name',
125
+ 'gen_ai.response.id',
126
+ 'gen_ai.system',
127
+ 'gen_ai.tool.call.id',
128
+ 'gen_ai.tool.name',
129
+ 'gen_ai.tool.type',
130
+ 'github.pr_number',
131
+ 'github.pr_url',
132
+ 'kiro.account.id',
133
+ 'kiro.client.type',
134
+ 'kiro.file.op',
135
+ 'kiro.hook_event_name',
136
+ 'kiro.metric',
137
+ 'kiro.profile.arn',
138
+ 'kiro.profile.id',
139
+ 'kiro.surface',
140
+ 'kiro.tool_name',
141
+ 'kiro.user.email',
142
+ 'kiro.user.id',
143
+ 'linear.issue_id',
144
+ 'linear.issue_url',
145
+ 'linear.op',
146
+ 'llm.system',
147
+ 'mainwave.caller.span_id',
148
+ 'mainwave.caller.trace_id',
149
+ 'mainwave.claude_code.stop_failure.error',
150
+ 'mainwave.connector_id',
151
+ 'mainwave.connector_type',
152
+ 'mainwave.devtool_vendor',
153
+ 'mainwave.host_source',
154
+ 'mainwave.organization_id',
155
+ 'mainwave.reasoning.present',
156
+ 'mainwave.redaction.count',
157
+ 'mainwave.request.thinking',
158
+ 'mainwave.run_id',
159
+ 'mainwave.source',
160
+ 'mainwave.subagent.id',
161
+ 'mainwave.subscription.billing_type',
162
+ 'mainwave.subscription.organization_role',
163
+ 'mainwave.subscription.organization_type',
164
+ 'mainwave.subscription.provider',
165
+ 'mainwave.subscription.rate_limit_tier',
166
+ 'mainwave.subscription.seat_tier',
167
+ 'mainwave.subscription.trigger',
168
+ 'mainwave.subscription.workspace_role',
169
+ 'mainwave.ucid',
170
+ 'mainwave.ucid_source',
171
+ 'mainwave.user_email',
172
+ 'mcp_server_scope',
173
+ 'organization.id',
174
+ 'prompt.id',
175
+ 'query_source',
176
+ 'service.name',
177
+ 'status_code',
178
+ 'user.account_uuid',
179
+ 'user.email',
180
+ 'vcs.change.external_id',
181
+ 'vcs.change.file.status',
182
+ 'vcs.change.id',
183
+ 'vcs.change.merge_commit_sha',
184
+ 'vcs.change.review.id',
185
+ 'vcs.change.review.verdict',
186
+ 'vcs.change.state',
187
+ 'vcs.commit.parent_sha',
188
+ 'vcs.commit.sha',
189
+ 'vcs.provider.name',
190
+ 'vcs.repository.default_branch',
191
+ 'vcs.repository.id',
192
+ 'vcs.repository.url.full',
193
+ 'work.instance',
194
+ 'work.item.external_id',
195
+ 'work.item.id',
196
+ 'work.item.op',
197
+ 'work.item.previous_state',
198
+ 'work.item.state',
199
+ 'work.item.url',
200
+ 'work.vendor',
201
+ ]
@@ -0,0 +1,215 @@
1
+ // In-place redaction support for a JSON-valued attribute. The value is never
2
+ // parsed into objects and never re-serialized: a strict RFC 8259 tokenizer
3
+ // finds the string and number value tokens, and only a token whose text
4
+ // changes is rewritten. Key order, duplicate keys, whitespace, number spelling
5
+ // and untouched escapes survive byte for byte.
6
+ //
7
+ // The tokenizer keeps an explicit stack, so no depth of nesting can overflow
8
+ // the call stack. Pure: no I/O.
9
+
10
+ const WS = (c) => c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d
11
+ const NUMBER = /-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/y
12
+
13
+ const isHex = (c) =>
14
+ (c >= 0x30 && c <= 0x39) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66)
15
+
16
+ /** The index after the string that starts at `text[start]` (a quote), or -1
17
+ * when it is not a valid JSON string: a raw control character, an unknown
18
+ * escape or a short \u escape, or no closing quote. */
19
+ const stringEnd = (text, start) => {
20
+ const n = text.length
21
+ for (let i = start + 1; i < n; i++) {
22
+ const c = text.charCodeAt(i)
23
+ if (c === 0x22) return i + 1
24
+ if (c < 0x20) return -1
25
+ if (c !== 0x5c) continue
26
+ const next = text[i + 1]
27
+ if (next === undefined) return -1
28
+ if ('"\\/bfnrt'.includes(next)) {
29
+ i++
30
+ } else if (next === 'u') {
31
+ for (let k = 2; k <= 5; k++) {
32
+ if (i + k >= n || !isHex(text.charCodeAt(i + k))) return -1
33
+ }
34
+ i += 5
35
+ } else {
36
+ return -1
37
+ }
38
+ }
39
+ return -1
40
+ }
41
+
42
+ /** The value tokens of `text` when it is JSON (after JSON whitespace the next
43
+ * character is `{` or `[` and the whole value is one valid RFC 8259 text), in
44
+ * order, as `{ kind: 'string' | 'number', start, end }` (a string's span
45
+ * includes its quotes); undefined when it is not. Object keys, punctuation
46
+ * and the literals `true`, `false` and `null` are not tokens. */
47
+ export const tokenizeJson = (text) => {
48
+ const n = text.length
49
+ let i = 0
50
+ while (i < n && WS(text.charCodeAt(i))) i++
51
+ if (text[i] !== '{' && text[i] !== '[') return undefined
52
+
53
+ const tokens = []
54
+ // true: an object, false: an array.
55
+ const stack = []
56
+ // value | valueOrEnd | keyOrEnd | key | colon | after
57
+ let state = 'value'
58
+ for (;;) {
59
+ while (i < n && WS(text.charCodeAt(i))) i++
60
+ if (state === 'after' && stack.length === 0) return i === n ? tokens : undefined
61
+ if (i >= n) return undefined
62
+ const char = text[i]
63
+ switch (state) {
64
+ case 'valueOrEnd':
65
+ if (char === ']') {
66
+ stack.pop()
67
+ i++
68
+ state = 'after'
69
+ break
70
+ }
71
+ state = 'value'
72
+ continue
73
+ case 'value':
74
+ if (char === '{') {
75
+ stack.push(true)
76
+ i++
77
+ state = 'keyOrEnd'
78
+ } else if (char === '[') {
79
+ stack.push(false)
80
+ i++
81
+ state = 'valueOrEnd'
82
+ } else if (char === '"') {
83
+ const end = stringEnd(text, i)
84
+ if (end < 0) return undefined
85
+ tokens.push({ kind: 'string', start: i, end })
86
+ i = end
87
+ state = 'after'
88
+ } else if (char === '-' || (char >= '0' && char <= '9')) {
89
+ NUMBER.lastIndex = i
90
+ const match = NUMBER.exec(text)
91
+ if (match === null) return undefined
92
+ tokens.push({ kind: 'number', start: i, end: i + match[0].length })
93
+ i += match[0].length
94
+ state = 'after'
95
+ } else if (text.startsWith('true', i)) {
96
+ i += 4
97
+ state = 'after'
98
+ } else if (text.startsWith('false', i)) {
99
+ i += 5
100
+ state = 'after'
101
+ } else if (text.startsWith('null', i)) {
102
+ i += 4
103
+ state = 'after'
104
+ } else {
105
+ return undefined
106
+ }
107
+ break
108
+ case 'keyOrEnd':
109
+ if (char === '}') {
110
+ stack.pop()
111
+ i++
112
+ state = 'after'
113
+ break
114
+ }
115
+ state = 'key'
116
+ continue
117
+ case 'key': {
118
+ if (char !== '"') return undefined
119
+ const end = stringEnd(text, i)
120
+ if (end < 0) return undefined
121
+ i = end
122
+ state = 'colon'
123
+ break
124
+ }
125
+ case 'colon':
126
+ if (char !== ':') return undefined
127
+ i++
128
+ state = 'value'
129
+ break
130
+ case 'after': {
131
+ const inObject = stack[stack.length - 1]
132
+ if (char === ',') {
133
+ i++
134
+ state = inObject ? 'key' : 'value'
135
+ } else if (char === (inObject ? '}' : ']')) {
136
+ stack.pop()
137
+ i++
138
+ } else {
139
+ return undefined
140
+ }
141
+ break
142
+ }
143
+ }
144
+ }
145
+ }
146
+
147
+ const ESCAPES = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' }
148
+
149
+ /** The decoded text of a valid JSON string token (quotes included in `raw`).
150
+ * A pair of surrogate escapes is one astral character in the result, as in
151
+ * any UTF-16 string; a lone surrogate escape stays a lone surrogate. */
152
+ export const decodeJsonString = (raw) => {
153
+ if (!raw.includes('\\')) return raw.slice(1, -1)
154
+ let out = ''
155
+ let run = 1
156
+ const end = raw.length - 1
157
+ for (let i = 1; i < end; i++) {
158
+ if (raw.charCodeAt(i) !== 0x5c) continue
159
+ out += raw.slice(run, i)
160
+ const next = raw[i + 1]
161
+ if (next === 'u') {
162
+ out += String.fromCharCode(parseInt(raw.slice(i + 2, i + 6), 16))
163
+ i += 5
164
+ } else {
165
+ out += ESCAPES[next]
166
+ i++
167
+ }
168
+ run = i + 1
169
+ }
170
+ return out + raw.slice(run, end)
171
+ }
172
+
173
+ /** Whether `text` holds a character the canonical encoding writes
174
+ * differently: a quote, a backslash, a control character or any surrogate. */
175
+ const needsEscape = (text) => {
176
+ for (let i = 0; i < text.length; i++) {
177
+ const c = text.charCodeAt(i)
178
+ if (c < 0x20 || c === 0x22 || c === 0x5c || (c >= 0xd800 && c <= 0xdfff)) return true
179
+ }
180
+ return false
181
+ }
182
+
183
+ const hex4 = (c) => `\\u${c.toString(16).padStart(4, '0')}`
184
+
185
+ /** The canonical JSON encoding of `text`: `"` and `\` escaped, backspace, form
186
+ * feed, newline, carriage return and tab as `\b \f \n \r \t`, every other
187
+ * character below U+0020 and every lone surrogate as `\u` plus four lowercase
188
+ * hex digits, everything else literal (`/`, U+007F, U+2028 and non-ASCII
189
+ * included; an astral character stays a literal surrogate pair). */
190
+ export const encodeJsonString = (text) => {
191
+ if (!needsEscape(text)) return `"${text}"`
192
+ let out = '"'
193
+ for (let i = 0; i < text.length; i++) {
194
+ const c = text.charCodeAt(i)
195
+ if (c === 0x22) out += '\\"'
196
+ else if (c === 0x5c) out += '\\\\'
197
+ else if (c === 0x08) out += '\\b'
198
+ else if (c === 0x0c) out += '\\f'
199
+ else if (c === 0x0a) out += '\\n'
200
+ else if (c === 0x0d) out += '\\r'
201
+ else if (c === 0x09) out += '\\t'
202
+ else if (c < 0x20) out += hex4(c)
203
+ else if (c >= 0xd800 && c <= 0xdbff) {
204
+ const next = text.charCodeAt(i + 1)
205
+ if (next >= 0xdc00 && next <= 0xdfff) {
206
+ out += text[i] + text[i + 1]
207
+ i++
208
+ } else {
209
+ out += hex4(c)
210
+ }
211
+ } else if (c >= 0xdc00 && c <= 0xdfff) out += hex4(c)
212
+ else out += text[i]
213
+ }
214
+ return `${out}"`
215
+ }