@misconfig/cli 1.1.0 → 1.3.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/engine/paths.js CHANGED
@@ -1,5 +1,5 @@
1
- // Which files steer AI agents. Shared by the browser walker, the command
2
- // line tool and the rule engine, so all three agree on what gets read.
1
+ // Which files steer AI agents. Shared by the command, which finds and reads
2
+ // them, and the rule engine, so both agree on what gets read.
3
3
 
4
4
  export const SKIP_DIRS = new Set([
5
5
  "node_modules", ".git", ".hg", ".svn", "dist", "build", "out", ".next", ".nuxt", ".svelte-kit",
@@ -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,15 +68,44 @@ 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
- // Dropping a tool folder itself (for example ~/.claude) keeps its name in
65
- // the paths, so ".claude/settings.json" is still recognised.
79
+ // The folders agents keep their settings in at the top of a project, such
80
+ // as .claude. A check reads these first.
66
81
  export const TOOL_ROOT = /^\.(claude|codex|gemini|cursor|grok|opencode|windsurf|roo|kiro|amazonq|continue|zed|junie|github|vscode)$/i;
67
- export const withToolRoot = (root, relPath) => (root && TOOL_ROOT.test(root) ? `${root}/${relPath}` : relPath);
82
+
83
+ // A name at the top of a project that would read as a place on the computer,
84
+ // such as a folder named "~" or "C:". The checks tell files on the computer
85
+ // from the project's by how their paths start, so these are left out: a
86
+ // project can't stand in for the settings in the home folder.
87
+ export const computerLikeName = (name) => /^(?:~|[A-Za-z]:)/.test(name);
88
+
89
+ // Control characters in a name, shown as the symbols Unicode has for them
90
+ // (␊ for a line break, ␛ for escape), and characters that reorder text shown
91
+ // as the replacement character, U+FFFD. A name then can't break a line or
92
+ // color a terminal, and the patterns here, which don't match line breaks,
93
+ // still see the file. Agents read a file whatever its name.
94
+ const CONTROL_CHARS = /[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200e\u200f\u202a-\u202e\u2066-\u2069]/g;
95
+ export const visibleName = (text) =>
96
+ text.replace(CONTROL_CHARS, (c) => {
97
+ const n = c.charCodeAt(0);
98
+ return n < 0x20 ? String.fromCharCode(0x2400 + n) : n === 0x7f ? "\u2421" : "\ufffd";
99
+ });
100
+
101
+ // Code an agent loads as plugins or tools as soon as it starts in a project.
102
+ // Listed by name, never read.
103
+ export const PLUGIN_CODE = /(^|\/)(\.opencode\/(plugins?|tools)|\.amp\/plugins|\.cline\/plugins)\/[^/]+\.[cm]?[jt]sx?$/i;
104
+
105
+ // Instruction files too large to read whole are checked from their start,
106
+ // where an agent reads first. Settings files aren't: half a JSON file can't
107
+ // be read at all.
108
+ export const readsInPart = (path) => /\.(md|mdc|txt)$/i.test(path) || /(^|\/)\.(cursorrules|windsurfrules|clinerules|goosehints)$/i.test(path);
68
109
 
69
110
  export const LIMITS = {
70
111
  maxEntries: 60000,
@@ -74,9 +115,31 @@ export const LIMITS = {
74
115
  maxLooseMarkdown: 25,
75
116
  };
76
117
 
77
- export function classifyPath(relPath, { looseMarkdown = false } = {}) {
118
+ // A skill is a folder. Agents read its SKILL.md and open the other files in
119
+ // it, such as reference docs and scripts, only when SKILL.md sends them
120
+ // there, so those files are part of the skill, not settings of their own.
121
+ const IN_SKILL = /(^|\/)\.[^/]+\/(?:.+\/)?skills\/[^/]+\/.+$/i;
122
+ const SKILL_MD = /(^|\/)SKILL\.md$/i;
123
+ // Compiled programs, native modules and installers in a skill folder are
124
+ // listed by name, never read: a skill is meant to be text you can review.
125
+ // Archives count too: what's inside can't be read either.
126
+ 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;
127
+
128
+ // A folder inside a skill that's worth looking in. Folders that are skipped
129
+ // elsewhere, such as bin and dist, are looked in there, since that's where a
130
+ // skill would keep a program. Package installs and version control never
131
+ // are: they can hold tens of thousands of files.
132
+ const HEAVY_DIRS = new Set(["node_modules", ".git", ".hg", ".svn", ".venv", "venv", "__pycache__", ".pnpm-store", ".yarn", ".npm", ".cargo", ".rustup", ".m2", ".nuget", ".gradle", ".terraform"]);
133
+ export const insideSkill = (relDir) => IN_SKILL.test(visibleName(`${relDir}/x`)) && !HEAVY_DIRS.has(relDir.split("/").pop());
134
+
135
+ export function classifyPath(rawPath, { looseMarkdown = false } = {}) {
136
+ const relPath = visibleName(rawPath);
78
137
  if (SENSITIVE.some((re) => re.test(relPath))) return "sensitive";
79
- if (CONTENT.some((re) => re.test(relPath))) return "content";
138
+ // Only what's inside the skill's folder counts, and never its SKILL.md, so
139
+ // a skill folder named like an app bundle is still read.
140
+ if (IN_SKILL.test(relPath) && !SKILL_MD.test(relPath) && SKILL_PROGRAM.test(relPath.replace(/^.*?\/skills\/[^/]+\//i, ""))) return "listed";
141
+ if (PLUGIN_CODE.test(relPath)) return "listed";
142
+ if (CONTENT.some((re) => re.test(relPath))) return IN_SKILL.test(relPath) && !SKILL_MD.test(relPath) ? null : "content";
80
143
  if (looseMarkdown && !relPath.includes("/") && /\.(md|mdc|txt)$/i.test(relPath)) return "loose";
81
144
  return null;
82
145
  }