@misconfig/cli 1.1.0 → 1.3.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/engine/paths.js CHANGED
@@ -14,34 +14,46 @@ export const HOME_MARKERS = new Set([
14
14
  "Documents", "Desktop", ".config", ".local", "Pictures", "Music", "Videos",
15
15
  ]);
16
16
 
17
- // Agent control files: read, masked, then sent.
17
+ // Agent control files: read, masked, then checked.
18
18
  export const CONTENT = [
19
19
  /(^|\/)(claude|claude\.local|agents|agents\.override|gemini|grok)\.md$/i,
20
- /(^|\/)\.claude\/(settings(\.local)?\.json|(commands|agents|skills|output-styles)\/.+\.md|hooks\/.+)$/i,
20
+ /(^|\/)\.claude\/(settings(\.local)?\.json|(commands|agents|skills|output-styles|rules)\/.+\.md|hooks\/.+)$/i,
21
+ /(^|\/)\.agents\/skills\/.+\.md$/i,
22
+ /(^|\/)\.claude\/projects\/[^/]+\/memory\/[^/]+\.md$/i,
23
+ /(^|\/)\.claude\/plugins\/(installed_plugins\.json|known_marketplaces\.json|.+\/hooks\/hooks\.json|.+\/\.mcp\.json|.+\/\.claude-plugin\/plugin\.json|.+\/(commands|agents|skills)\/.+\.md)$/i,
24
+ /(^|\/)managed-settings\.d\/[^/]+\.json$/i,
25
+ /(^|\/)(Documents\/Cline\/Rules|\.cline\/rules)\/.+\.md$/i,
21
26
  /(^|\/)\.mcp\.json$/i,
22
27
  /(^|\/)\.claude\.json$/i,
23
- /(^|\/)\.codex\/(config\.toml|.+\.md)$/i,
24
- /(^|\/)\.cursor\/(rules\/.+\.mdc?|mcp\.json|.+\.md)$/i,
28
+ /(^|\/)\.codex\/(config\.toml|hooks\.json|rules\/[^/]+\.rules|.+\.md)$/i,
29
+ /(^|\/)\.cursor\/(rules\/.+\.mdc?|mcp\.json|hooks\.json|environment\.json|cli\.json|sandbox\.json|permissions\.json|.+\.md)$/i,
25
30
  /(^|\/)\.cursorrules$/i,
26
- /(^|\/)\.github\/(copilot-instructions\.md|(instructions|prompts|chatmodes|agents)\/.+\.md)$/i,
27
- /(^|\/)\.vscode\/(mcp|settings)\.json$/i,
28
- /(^|\/)\.gemini\/(settings\.json|.+\.md)$/i,
31
+ /(^|\/)\.github\/(copilot-instructions\.md|(instructions|prompts|chatmodes|agents)\/.+\.md|hooks\/[^/]+\.json|mcp\.json|copilot\/settings\.json)$/i,
32
+ /(^|\/)\.vscode\/(mcp|settings|tasks)\.json$/i,
33
+ /(^|\/)\.gemini\/(settings\.json|extensions\/[^/]+\/gemini-extension\.json|.+\.md|commands\/.+\.toml)$/i,
29
34
  /(^|\/)opencode\.jsonc?$/i,
30
35
  /(^|\/)\.opencode\/.+\.(md|json|jsonc)$/i,
31
- /(^|\/)\.grok\/(settings\.json|.+\.md)$/i,
36
+ /(^|\/)\.grok\/(settings\.json|config\.toml|hooks\/[^/]+\.json|.+\.md)$/i,
37
+ /(^|\/)\.amp\/settings\.json$/i,
38
+ /(^|\/)\.goosehints$/i,
32
39
  /(^|\/)\.windsurfrules$/i,
33
- /(^|\/)\.windsurf\/(rules\/.+|mcp_config\.json)$/i,
40
+ /(^|\/)\.windsurf\/(rules\/.+|workflows\/.+\.md|mcp_config\.json|hooks\.json)$/i,
41
+ /(^|\/)\.codeium\/windsurf\/(mcp_config|hooks)\.json$/i,
42
+ /(^|\/)\.devin\/hooks\.v1\.json$/i,
34
43
  /(^|\/)\.clinerules(\/.+)?$/i,
35
44
  /(^|\/)\.roomodes$/i,
36
45
  /(^|\/)\.roo\/.+\.(md|json)$/i,
37
- /(^|\/)\.kiro\/(steering\/.+\.md|settings\/mcp\.json)$/i,
38
- /(^|\/)\.amazonq\/(rules\/.+\.md|mcp\.json)$/i,
46
+ /(^|\/)\.kiro\/(steering\/.+\.md|settings\/mcp\.json|hooks\/[^/]+\.(json|kiro\.hook)|agents\/[^/]+\.(json|md))$/i,
47
+ /(^|\/)\.amazonq\/(rules\/.+\.md|mcp\.json|cli-agents\/[^/]+\.json)$/i,
48
+ /(^|\/)\.aws\/amazonq\/(mcp|cli-agents\/[^/]+)\.json$/i,
39
49
  /(^|\/)\.continue\/.+\.(json|ya?ml|md)$/i,
40
50
  /(^|\/)\.zed\/settings\.json$/i,
41
- /(^|\/)\.junie\/guidelines\.md$/i,
51
+ /(^|\/)\.junie\/(guidelines\.md|agents\.md|rules\/.+\.md|mcp\/mcp\.json)$/i,
42
52
  /(^|\/)\.aider\.conf\.ya?ml$/i,
43
- /^\.gitignore$/i,
53
+ /^(?:[^/]+\/){0,3}\.gitignore$/i,
44
54
  /^package\.json$/i,
55
+ // Workflows the Shai-Hulud 2.0 worm adds to repositories it reaches.
56
+ /(^|\/)\.github\/workflows\/(?:discussion\.ya?ml|formatter_\d{3,}\.ya?ml|shai-?hulud-?workflow\.ya?ml)$/i,
45
57
  ];
46
58
 
47
59
  // Credential files: name and size only.
@@ -56,16 +68,46 @@ export const SENSITIVE = [
56
68
  /(^|\/)\.codex\/auth\.json$/i,
57
69
  /(^|\/)\.claude\/\.credentials\.json$/i,
58
70
  /(^|\/)\.grok\/user-settings\.json$/i,
71
+ /(^|\/)\.copilot\/providers\.json$/i,
72
+ /(^|\/)\.cline\/data\/secrets\.json$/i,
73
+ /(^|\/)goose\/secrets\.ya?ml$/i,
59
74
  /(^|\/)(credentials|secrets?|service[-_]?account[^/]*)\.json$/i,
60
75
  ];
61
76
 
62
77
  export const DOWNLOADS_LIKE = /^(downloads?|desktop|temp|tmp)$/i;
63
78
 
64
79
  // Dropping a tool folder itself (for example ~/.claude) keeps its name in
65
- // the paths, so ".claude/settings.json" is still recognised.
80
+ // the paths, so ".claude/settings.json" is still recognized.
66
81
  export const TOOL_ROOT = /^\.(claude|codex|gemini|cursor|grok|opencode|windsurf|roo|kiro|amazonq|continue|zed|junie|github|vscode)$/i;
67
82
  export const withToolRoot = (root, relPath) => (root && TOOL_ROOT.test(root) ? `${root}/${relPath}` : relPath);
68
83
 
84
+ // A name at the top of a project that would read as a place on the computer,
85
+ // such as a folder named "~" or "C:". The checks tell files on the computer
86
+ // from the project's by how their paths start, so these are left out: a
87
+ // project can't stand in for the settings in the home folder.
88
+ export const computerLikeName = (name) => /^(?:~|[A-Za-z]:)/.test(name);
89
+
90
+ // Control characters in a name, shown as the symbols Unicode has for them
91
+ // (␊ for a line break, ␛ for escape), and characters that reorder text shown
92
+ // as the replacement character, U+FFFD. A name then can't break a line or
93
+ // color a terminal, and the patterns here, which don't match line breaks,
94
+ // still see the file. Agents read a file whatever its name.
95
+ const CONTROL_CHARS = /[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200e\u200f\u202a-\u202e\u2066-\u2069]/g;
96
+ export const visibleName = (text) =>
97
+ text.replace(CONTROL_CHARS, (c) => {
98
+ const n = c.charCodeAt(0);
99
+ return n < 0x20 ? String.fromCharCode(0x2400 + n) : n === 0x7f ? "\u2421" : "\ufffd";
100
+ });
101
+
102
+ // Code an agent loads as plugins or tools as soon as it starts in a project.
103
+ // Listed by name, never read.
104
+ export const PLUGIN_CODE = /(^|\/)(\.opencode\/(plugins?|tools)|\.amp\/plugins|\.cline\/plugins)\/[^/]+\.[cm]?[jt]sx?$/i;
105
+
106
+ // Instruction files too large to read whole are checked from their start,
107
+ // where an agent reads first. Settings files aren't: half a JSON file can't
108
+ // be read at all.
109
+ export const readsInPart = (path) => /\.(md|mdc|txt)$/i.test(path) || /(^|\/)\.(cursorrules|windsurfrules|clinerules|goosehints)$/i.test(path);
110
+
69
111
  export const LIMITS = {
70
112
  maxEntries: 60000,
71
113
  maxFiles: 300,
@@ -74,9 +116,31 @@ export const LIMITS = {
74
116
  maxLooseMarkdown: 25,
75
117
  };
76
118
 
77
- export function classifyPath(relPath, { looseMarkdown = false } = {}) {
119
+ // A skill is a folder. Agents read its SKILL.md and open the other files in
120
+ // it, such as reference docs and scripts, only when SKILL.md sends them
121
+ // there, so those files are part of the skill, not settings of their own.
122
+ const IN_SKILL = /(^|\/)\.[^/]+\/(?:.+\/)?skills\/[^/]+\/.+$/i;
123
+ const SKILL_MD = /(^|\/)SKILL\.md$/i;
124
+ // Compiled programs, native modules and installers in a skill folder are
125
+ // listed by name, never read: a skill is meant to be text you can review.
126
+ // Archives count too: what's inside can't be read either.
127
+ export const SKILL_PROGRAM = /\.(?:exe|dll|so(?:\.\d+)*|dylib|node|bin|pkg|dmg|msi|msix|deb|rpm|jar|scr|apk|appimage|wasm|zip|7z|rar|tar|tgz|gz|xz|bz2)$|\.app\//i;
128
+
129
+ // A folder inside a skill that's worth looking in. Folders that are skipped
130
+ // elsewhere, such as bin and dist, are looked in there, since that's where a
131
+ // skill would keep a program. Package installs and version control never
132
+ // are: they can hold tens of thousands of files.
133
+ const HEAVY_DIRS = new Set(["node_modules", ".git", ".hg", ".svn", ".venv", "venv", "__pycache__", ".pnpm-store", ".yarn", ".npm", ".cargo", ".rustup", ".m2", ".nuget", ".gradle", ".terraform"]);
134
+ export const insideSkill = (relDir) => IN_SKILL.test(visibleName(`${relDir}/x`)) && !HEAVY_DIRS.has(relDir.split("/").pop());
135
+
136
+ export function classifyPath(rawPath, { looseMarkdown = false } = {}) {
137
+ const relPath = visibleName(rawPath);
78
138
  if (SENSITIVE.some((re) => re.test(relPath))) return "sensitive";
79
- if (CONTENT.some((re) => re.test(relPath))) return "content";
139
+ // Only what's inside the skill's folder counts, and never its SKILL.md, so
140
+ // a skill folder named like an app bundle is still read.
141
+ if (IN_SKILL.test(relPath) && !SKILL_MD.test(relPath) && SKILL_PROGRAM.test(relPath.replace(/^.*?\/skills\/[^/]+\//i, ""))) return "listed";
142
+ if (PLUGIN_CODE.test(relPath)) return "listed";
143
+ if (CONTENT.some((re) => re.test(relPath))) return IN_SKILL.test(relPath) && !SKILL_MD.test(relPath) ? null : "content";
80
144
  if (looseMarkdown && !relPath.includes("/") && /\.(md|mdc|txt)$/i.test(relPath)) return "loose";
81
145
  return null;
82
146
  }