@cortexkit/magic-context 0.21.2 → 0.21.4

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 (2) hide show
  1. package/dist/index.js +73 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -27303,7 +27303,6 @@ var init_magic_context = __esm(() => {
27303
27303
  enabled: exports_external.boolean().default(true),
27304
27304
  min_clusters: exports_external.number().min(1).default(3)
27305
27305
  }).default({ enabled: true, min_clusters: 3 }),
27306
- compaction_markers: exports_external.boolean().default(true),
27307
27306
  system_prompt_injection: exports_external.object({
27308
27307
  enabled: exports_external.boolean().default(true),
27309
27308
  skip_signatures: exports_external.array(exports_external.string()).default(["<!-- magic-context: skip -->"])
@@ -27964,7 +27963,38 @@ function redactionTypeForKey(key) {
27964
27963
  return suffix || "secret";
27965
27964
  }
27966
27965
  function isSecretKey(key) {
27967
- return SECRET_KEY_PATTERN.test(key);
27966
+ const segments = key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().split(/[._-]+/).filter(Boolean);
27967
+ if (segments.length === 0)
27968
+ return false;
27969
+ if (segments.length === 1) {
27970
+ const first = segments[0];
27971
+ return Boolean(first && SECRET_SEGMENT_PATTERN.test(first));
27972
+ }
27973
+ for (let i = 0;i < segments.length; i++) {
27974
+ const seg = segments[i];
27975
+ if (!seg || !SECRET_SEGMENT_PATTERN.test(seg))
27976
+ continue;
27977
+ let trailingOk = true;
27978
+ for (let j3 = i + 1;j3 < segments.length; j3++) {
27979
+ const tail = segments[j3];
27980
+ if (!tail)
27981
+ continue;
27982
+ if (TRAILING_DESCRIPTORS.has(tail))
27983
+ continue;
27984
+ if (SECRET_SEGMENT_PATTERN.test(tail))
27985
+ continue;
27986
+ trailingOk = false;
27987
+ break;
27988
+ }
27989
+ if (!trailingOk)
27990
+ continue;
27991
+ for (let k2 = i - 1;k2 >= 0; k2--) {
27992
+ const lead = segments[k2];
27993
+ if (lead && SECRET_QUALIFIERS.has(lead))
27994
+ return true;
27995
+ }
27996
+ }
27997
+ return false;
27968
27998
  }
27969
27999
  function sanitizePathString(value) {
27970
28000
  const home = homedir10();
@@ -28013,9 +28043,41 @@ function sanitizeConfigValue(value, keyPath = []) {
28013
28043
  }
28014
28044
  return value;
28015
28045
  }
28016
- var SECRET_KEY_PATTERN, SECRET_TEXT_PATTERNS;
28046
+ var SECRET_WORDS, SECRET_SEGMENT_PATTERN, TRAILING_DESCRIPTORS, SECRET_QUALIFIERS, SECRET_TEXT_PATTERNS;
28017
28047
  var init_redaction = __esm(() => {
28018
- SECRET_KEY_PATTERN = /(?:key|token|secret|password|auth|bearer|credential)/i;
28048
+ SECRET_WORDS = [
28049
+ "key",
28050
+ "token",
28051
+ "secret",
28052
+ "password",
28053
+ "auth",
28054
+ "authorization",
28055
+ "bearer",
28056
+ "credential"
28057
+ ];
28058
+ SECRET_SEGMENT_PATTERN = new RegExp(`^(?:${SECRET_WORDS.map((w3) => `${w3}s?`).join("|")})$`, "i");
28059
+ TRAILING_DESCRIPTORS = new Set(["id", "ids", "value", "values", "header", "headers"]);
28060
+ SECRET_QUALIFIERS = new Set([
28061
+ "api",
28062
+ "access",
28063
+ "private",
28064
+ "client",
28065
+ "auth",
28066
+ "authorization",
28067
+ "secret",
28068
+ "bearer",
28069
+ "session",
28070
+ "refresh",
28071
+ "service",
28072
+ "x",
28073
+ "openai",
28074
+ "anthropic",
28075
+ "google",
28076
+ "github",
28077
+ "huggingface",
28078
+ "aws",
28079
+ "azure"
28080
+ ]);
28019
28081
  SECRET_TEXT_PATTERNS = [
28020
28082
  {
28021
28083
  pattern: /\bsk-ant-(?:api03-)?[A-Za-z0-9_-]{32,}/g,
@@ -28970,12 +29032,15 @@ async function runDoctor(options = {}) {
28970
29032
  let mcChanged = false;
28971
29033
  const experimental = mcConfig.experimental;
28972
29034
  if (experimental && "compaction_markers" in experimental) {
28973
- if (!("compaction_markers" in mcConfig)) {
28974
- mcConfig.compaction_markers = experimental.compaction_markers;
28975
- }
28976
29035
  delete experimental.compaction_markers;
28977
29036
  mcChanged = true;
28978
- log.success("Migrated experimental.compaction_markers → compaction_markers (now default: true)");
29037
+ log.success("Removed deprecated experimental.compaction_markers (always-on since v0.21.4)");
29038
+ fixed++;
29039
+ }
29040
+ if ("compaction_markers" in mcConfig) {
29041
+ delete mcConfig.compaction_markers;
29042
+ mcChanged = true;
29043
+ log.success("Removed deprecated compaction_markers (always-on since v0.21.4)");
28979
29044
  fixed++;
28980
29045
  }
28981
29046
  if (experimental && "user_memories" in experimental) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/magic-context",
3
- "version": "0.21.2",
3
+ "version": "0.21.4",
4
4
  "description": "Unified CLI for Magic Context — setup, doctor, and migration across OpenCode and Pi",
5
5
  "keywords": [
6
6
  "opencode",