onbuzz 3.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/LICENSE +267 -0
- package/README.md +425 -0
- package/bin/cli.js +556 -0
- package/bin/loxia-terminal-v2.js +162 -0
- package/bin/loxia-terminal.js +90 -0
- package/bin/start-with-terminal.js +200 -0
- package/node_modules/@isaacs/balanced-match/LICENSE.md +23 -0
- package/node_modules/@isaacs/balanced-match/README.md +60 -0
- package/node_modules/@isaacs/balanced-match/dist/commonjs/index.d.ts +9 -0
- package/node_modules/@isaacs/balanced-match/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@isaacs/balanced-match/dist/commonjs/index.js +59 -0
- package/node_modules/@isaacs/balanced-match/dist/commonjs/index.js.map +1 -0
- package/node_modules/@isaacs/balanced-match/dist/commonjs/package.json +3 -0
- package/node_modules/@isaacs/balanced-match/dist/esm/index.d.ts +9 -0
- package/node_modules/@isaacs/balanced-match/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@isaacs/balanced-match/dist/esm/index.js +54 -0
- package/node_modules/@isaacs/balanced-match/dist/esm/index.js.map +1 -0
- package/node_modules/@isaacs/balanced-match/dist/esm/package.json +3 -0
- package/node_modules/@isaacs/balanced-match/package.json +79 -0
- package/node_modules/@isaacs/brace-expansion/LICENSE +23 -0
- package/node_modules/@isaacs/brace-expansion/README.md +97 -0
- package/node_modules/@isaacs/brace-expansion/dist/commonjs/index.d.ts +6 -0
- package/node_modules/@isaacs/brace-expansion/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@isaacs/brace-expansion/dist/commonjs/index.js +199 -0
- package/node_modules/@isaacs/brace-expansion/dist/commonjs/index.js.map +1 -0
- package/node_modules/@isaacs/brace-expansion/dist/commonjs/package.json +3 -0
- package/node_modules/@isaacs/brace-expansion/dist/esm/index.d.ts +6 -0
- package/node_modules/@isaacs/brace-expansion/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@isaacs/brace-expansion/dist/esm/index.js +195 -0
- package/node_modules/@isaacs/brace-expansion/dist/esm/index.js.map +1 -0
- package/node_modules/@isaacs/brace-expansion/dist/esm/package.json +3 -0
- package/node_modules/@isaacs/brace-expansion/package.json +60 -0
- package/node_modules/glob/LICENSE.md +63 -0
- package/node_modules/glob/README.md +1177 -0
- package/node_modules/glob/dist/commonjs/glob.d.ts +388 -0
- package/node_modules/glob/dist/commonjs/glob.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/glob.js +247 -0
- package/node_modules/glob/dist/commonjs/glob.js.map +1 -0
- package/node_modules/glob/dist/commonjs/has-magic.d.ts +14 -0
- package/node_modules/glob/dist/commonjs/has-magic.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/has-magic.js +27 -0
- package/node_modules/glob/dist/commonjs/has-magic.js.map +1 -0
- package/node_modules/glob/dist/commonjs/ignore.d.ts +24 -0
- package/node_modules/glob/dist/commonjs/ignore.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/ignore.js +119 -0
- package/node_modules/glob/dist/commonjs/ignore.js.map +1 -0
- package/node_modules/glob/dist/commonjs/index.d.ts +97 -0
- package/node_modules/glob/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/index.js +68 -0
- package/node_modules/glob/dist/commonjs/index.js.map +1 -0
- package/node_modules/glob/dist/commonjs/index.min.js +4 -0
- package/node_modules/glob/dist/commonjs/index.min.js.map +7 -0
- package/node_modules/glob/dist/commonjs/package.json +3 -0
- package/node_modules/glob/dist/commonjs/pattern.d.ts +76 -0
- package/node_modules/glob/dist/commonjs/pattern.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/pattern.js +219 -0
- package/node_modules/glob/dist/commonjs/pattern.js.map +1 -0
- package/node_modules/glob/dist/commonjs/processor.d.ts +59 -0
- package/node_modules/glob/dist/commonjs/processor.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/processor.js +301 -0
- package/node_modules/glob/dist/commonjs/processor.js.map +1 -0
- package/node_modules/glob/dist/commonjs/walker.d.ts +97 -0
- package/node_modules/glob/dist/commonjs/walker.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/walker.js +387 -0
- package/node_modules/glob/dist/commonjs/walker.js.map +1 -0
- package/node_modules/glob/dist/esm/glob.d.ts +388 -0
- package/node_modules/glob/dist/esm/glob.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/glob.js +243 -0
- package/node_modules/glob/dist/esm/glob.js.map +1 -0
- package/node_modules/glob/dist/esm/has-magic.d.ts +14 -0
- package/node_modules/glob/dist/esm/has-magic.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/has-magic.js +23 -0
- package/node_modules/glob/dist/esm/has-magic.js.map +1 -0
- package/node_modules/glob/dist/esm/ignore.d.ts +24 -0
- package/node_modules/glob/dist/esm/ignore.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/ignore.js +115 -0
- package/node_modules/glob/dist/esm/ignore.js.map +1 -0
- package/node_modules/glob/dist/esm/index.d.ts +97 -0
- package/node_modules/glob/dist/esm/index.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/index.js +55 -0
- package/node_modules/glob/dist/esm/index.js.map +1 -0
- package/node_modules/glob/dist/esm/index.min.js +4 -0
- package/node_modules/glob/dist/esm/index.min.js.map +7 -0
- package/node_modules/glob/dist/esm/package.json +3 -0
- package/node_modules/glob/dist/esm/pattern.d.ts +76 -0
- package/node_modules/glob/dist/esm/pattern.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/pattern.js +215 -0
- package/node_modules/glob/dist/esm/pattern.js.map +1 -0
- package/node_modules/glob/dist/esm/processor.d.ts +59 -0
- package/node_modules/glob/dist/esm/processor.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/processor.js +294 -0
- package/node_modules/glob/dist/esm/processor.js.map +1 -0
- package/node_modules/glob/dist/esm/walker.d.ts +97 -0
- package/node_modules/glob/dist/esm/walker.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/walker.js +381 -0
- package/node_modules/glob/dist/esm/walker.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/LICENSE.md +55 -0
- package/node_modules/glob/node_modules/minimatch/README.md +453 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +2 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.d.ts +20 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.js +591 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +8 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.js +152 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.d.ts +15 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.js +30 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.d.ts +94 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js +1029 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/package.json +3 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.d.ts +22 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +2 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/ast.d.ts +20 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/ast.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/ast.js +587 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/ast.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.d.ts +8 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.js +148 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/escape.d.ts +15 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/escape.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/escape.js +26 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/escape.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/index.d.ts +94 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/index.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/index.js +1016 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/index.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/package.json +3 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.d.ts +22 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.js +34 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/package.json +67 -0
- package/node_modules/glob/package.json +101 -0
- package/node_modules/minipass/LICENSE +15 -0
- package/node_modules/minipass/README.md +825 -0
- package/node_modules/minipass/dist/commonjs/index.d.ts +549 -0
- package/node_modules/minipass/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/minipass/dist/commonjs/index.js +1028 -0
- package/node_modules/minipass/dist/commonjs/index.js.map +1 -0
- package/node_modules/minipass/dist/commonjs/package.json +3 -0
- package/node_modules/minipass/dist/esm/index.d.ts +549 -0
- package/node_modules/minipass/dist/esm/index.d.ts.map +1 -0
- package/node_modules/minipass/dist/esm/index.js +1018 -0
- package/node_modules/minipass/dist/esm/index.js.map +1 -0
- package/node_modules/minipass/dist/esm/package.json +3 -0
- package/node_modules/minipass/package.json +82 -0
- package/node_modules/package-json-from-dist/LICENSE.md +63 -0
- package/node_modules/package-json-from-dist/README.md +110 -0
- package/node_modules/package-json-from-dist/dist/commonjs/index.d.ts +89 -0
- package/node_modules/package-json-from-dist/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/package-json-from-dist/dist/commonjs/index.js +134 -0
- package/node_modules/package-json-from-dist/dist/commonjs/index.js.map +1 -0
- package/node_modules/package-json-from-dist/dist/commonjs/package.json +3 -0
- package/node_modules/package-json-from-dist/dist/esm/index.d.ts +89 -0
- package/node_modules/package-json-from-dist/dist/esm/index.d.ts.map +1 -0
- package/node_modules/package-json-from-dist/dist/esm/index.js +129 -0
- package/node_modules/package-json-from-dist/dist/esm/index.js.map +1 -0
- package/node_modules/package-json-from-dist/dist/esm/package.json +3 -0
- package/node_modules/package-json-from-dist/package.json +68 -0
- package/node_modules/path-scurry/LICENSE.md +55 -0
- package/node_modules/path-scurry/README.md +636 -0
- package/node_modules/path-scurry/dist/commonjs/index.d.ts +1115 -0
- package/node_modules/path-scurry/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/path-scurry/dist/commonjs/index.js +2018 -0
- package/node_modules/path-scurry/dist/commonjs/index.js.map +1 -0
- package/node_modules/path-scurry/dist/commonjs/package.json +3 -0
- package/node_modules/path-scurry/dist/esm/index.d.ts +1115 -0
- package/node_modules/path-scurry/dist/esm/index.d.ts.map +1 -0
- package/node_modules/path-scurry/dist/esm/index.js +1983 -0
- package/node_modules/path-scurry/dist/esm/index.js.map +1 -0
- package/node_modules/path-scurry/dist/esm/package.json +3 -0
- package/node_modules/path-scurry/node_modules/lru-cache/LICENSE.md +55 -0
- package/node_modules/path-scurry/node_modules/lru-cache/README.md +383 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.d.ts +1323 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +1589 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js.map +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/package.json +3 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.d.ts +1323 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +1585 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js.map +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/package.json +3 -0
- package/node_modules/path-scurry/node_modules/lru-cache/package.json +101 -0
- package/node_modules/path-scurry/package.json +88 -0
- package/node_modules/rimraf/LICENSE.md +55 -0
- package/node_modules/rimraf/README.md +226 -0
- package/node_modules/rimraf/dist/commonjs/default-tmp.d.ts +3 -0
- package/node_modules/rimraf/dist/commonjs/default-tmp.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/default-tmp.js +58 -0
- package/node_modules/rimraf/dist/commonjs/default-tmp.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/error.d.ts +6 -0
- package/node_modules/rimraf/dist/commonjs/error.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/error.js +10 -0
- package/node_modules/rimraf/dist/commonjs/error.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/fix-eperm.d.ts +3 -0
- package/node_modules/rimraf/dist/commonjs/fix-eperm.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/fix-eperm.js +38 -0
- package/node_modules/rimraf/dist/commonjs/fix-eperm.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/fs.d.ts +15 -0
- package/node_modules/rimraf/dist/commonjs/fs.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/fs.js +33 -0
- package/node_modules/rimraf/dist/commonjs/fs.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/ignore-enoent.d.ts +3 -0
- package/node_modules/rimraf/dist/commonjs/ignore-enoent.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/ignore-enoent.js +24 -0
- package/node_modules/rimraf/dist/commonjs/ignore-enoent.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/index.d.ts +50 -0
- package/node_modules/rimraf/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/index.js +78 -0
- package/node_modules/rimraf/dist/commonjs/index.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/opt-arg.d.ts +34 -0
- package/node_modules/rimraf/dist/commonjs/opt-arg.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/opt-arg.js +53 -0
- package/node_modules/rimraf/dist/commonjs/opt-arg.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/package.json +3 -0
- package/node_modules/rimraf/dist/commonjs/path-arg.d.ts +4 -0
- package/node_modules/rimraf/dist/commonjs/path-arg.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/path-arg.js +48 -0
- package/node_modules/rimraf/dist/commonjs/path-arg.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/readdir-or-error.d.ts +3 -0
- package/node_modules/rimraf/dist/commonjs/readdir-or-error.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/readdir-or-error.js +19 -0
- package/node_modules/rimraf/dist/commonjs/readdir-or-error.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/retry-busy.d.ts +8 -0
- package/node_modules/rimraf/dist/commonjs/retry-busy.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/retry-busy.js +65 -0
- package/node_modules/rimraf/dist/commonjs/retry-busy.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-manual.d.ts +3 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-manual.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-manual.js +8 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-manual.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-move-remove.d.ts +4 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-move-remove.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-move-remove.js +138 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-move-remove.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-native.d.ts +4 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-native.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-native.js +24 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-native.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-posix.d.ts +4 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-posix.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-posix.js +103 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-posix.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-windows.d.ts +4 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-windows.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-windows.js +159 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-windows.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/use-native.d.ts +4 -0
- package/node_modules/rimraf/dist/commonjs/use-native.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/use-native.js +18 -0
- package/node_modules/rimraf/dist/commonjs/use-native.js.map +1 -0
- package/node_modules/rimraf/dist/esm/bin.d.mts +3 -0
- package/node_modules/rimraf/dist/esm/bin.d.mts.map +1 -0
- package/node_modules/rimraf/dist/esm/bin.mjs +250 -0
- package/node_modules/rimraf/dist/esm/bin.mjs.map +1 -0
- package/node_modules/rimraf/dist/esm/default-tmp.d.ts +3 -0
- package/node_modules/rimraf/dist/esm/default-tmp.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/default-tmp.js +55 -0
- package/node_modules/rimraf/dist/esm/default-tmp.js.map +1 -0
- package/node_modules/rimraf/dist/esm/error.d.ts +6 -0
- package/node_modules/rimraf/dist/esm/error.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/error.js +5 -0
- package/node_modules/rimraf/dist/esm/error.js.map +1 -0
- package/node_modules/rimraf/dist/esm/fix-eperm.d.ts +3 -0
- package/node_modules/rimraf/dist/esm/fix-eperm.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/fix-eperm.js +33 -0
- package/node_modules/rimraf/dist/esm/fix-eperm.js.map +1 -0
- package/node_modules/rimraf/dist/esm/fs.d.ts +15 -0
- package/node_modules/rimraf/dist/esm/fs.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/fs.js +18 -0
- package/node_modules/rimraf/dist/esm/fs.js.map +1 -0
- package/node_modules/rimraf/dist/esm/ignore-enoent.d.ts +3 -0
- package/node_modules/rimraf/dist/esm/ignore-enoent.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/ignore-enoent.js +19 -0
- package/node_modules/rimraf/dist/esm/ignore-enoent.js.map +1 -0
- package/node_modules/rimraf/dist/esm/index.d.ts +50 -0
- package/node_modules/rimraf/dist/esm/index.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/index.js +70 -0
- package/node_modules/rimraf/dist/esm/index.js.map +1 -0
- package/node_modules/rimraf/dist/esm/opt-arg.d.ts +34 -0
- package/node_modules/rimraf/dist/esm/opt-arg.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/opt-arg.js +46 -0
- package/node_modules/rimraf/dist/esm/opt-arg.js.map +1 -0
- package/node_modules/rimraf/dist/esm/package.json +3 -0
- package/node_modules/rimraf/dist/esm/path-arg.d.ts +4 -0
- package/node_modules/rimraf/dist/esm/path-arg.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/path-arg.js +46 -0
- package/node_modules/rimraf/dist/esm/path-arg.js.map +1 -0
- package/node_modules/rimraf/dist/esm/readdir-or-error.d.ts +3 -0
- package/node_modules/rimraf/dist/esm/readdir-or-error.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/readdir-or-error.js +14 -0
- package/node_modules/rimraf/dist/esm/readdir-or-error.js.map +1 -0
- package/node_modules/rimraf/dist/esm/retry-busy.d.ts +8 -0
- package/node_modules/rimraf/dist/esm/retry-busy.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/retry-busy.js +60 -0
- package/node_modules/rimraf/dist/esm/retry-busy.js.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-manual.d.ts +3 -0
- package/node_modules/rimraf/dist/esm/rimraf-manual.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-manual.js +5 -0
- package/node_modules/rimraf/dist/esm/rimraf-manual.js.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-move-remove.d.ts +4 -0
- package/node_modules/rimraf/dist/esm/rimraf-move-remove.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-move-remove.js +133 -0
- package/node_modules/rimraf/dist/esm/rimraf-move-remove.js.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-native.d.ts +4 -0
- package/node_modules/rimraf/dist/esm/rimraf-native.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-native.js +19 -0
- package/node_modules/rimraf/dist/esm/rimraf-native.js.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-posix.d.ts +4 -0
- package/node_modules/rimraf/dist/esm/rimraf-posix.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-posix.js +98 -0
- package/node_modules/rimraf/dist/esm/rimraf-posix.js.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-windows.d.ts +4 -0
- package/node_modules/rimraf/dist/esm/rimraf-windows.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-windows.js +154 -0
- package/node_modules/rimraf/dist/esm/rimraf-windows.js.map +1 -0
- package/node_modules/rimraf/dist/esm/use-native.d.ts +4 -0
- package/node_modules/rimraf/dist/esm/use-native.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/use-native.js +15 -0
- package/node_modules/rimraf/dist/esm/use-native.js.map +1 -0
- package/node_modules/rimraf/package.json +92 -0
- package/package.json +152 -0
- package/scripts/install-scanners.js +258 -0
- package/scripts/watchdog.js +147 -0
- package/src/analyzers/CSSAnalyzer.js +297 -0
- package/src/analyzers/ConfigValidator.js +690 -0
- package/src/analyzers/ESLintAnalyzer.js +320 -0
- package/src/analyzers/JavaScriptAnalyzer.js +261 -0
- package/src/analyzers/PrettierFormatter.js +247 -0
- package/src/analyzers/PythonAnalyzer.js +283 -0
- package/src/analyzers/SecurityAnalyzer.js +729 -0
- package/src/analyzers/SparrowAnalyzer.js +341 -0
- package/src/analyzers/TypeScriptAnalyzer.js +247 -0
- package/src/analyzers/codeCloneDetector/analyzer.js +344 -0
- package/src/analyzers/codeCloneDetector/detector.js +250 -0
- package/src/analyzers/codeCloneDetector/index.js +192 -0
- package/src/analyzers/codeCloneDetector/parser.js +199 -0
- package/src/analyzers/codeCloneDetector/reporter.js +148 -0
- package/src/analyzers/codeCloneDetector/scanner.js +88 -0
- package/src/core/agentPool.js +1957 -0
- package/src/core/agentScheduler.js +3212 -0
- package/src/core/contextManager.js +709 -0
- package/src/core/flowExecutor.js +928 -0
- package/src/core/messageProcessor.js +808 -0
- package/src/core/orchestrator.js +584 -0
- package/src/core/stateManager.js +1500 -0
- package/src/index.js +972 -0
- package/src/interfaces/cli.js +553 -0
- package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +208 -0
- package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +236 -0
- package/src/interfaces/terminal/__tests__/smoke/agents.test.js +138 -0
- package/src/interfaces/terminal/__tests__/smoke/components.test.js +137 -0
- package/src/interfaces/terminal/__tests__/smoke/connection.test.js +350 -0
- package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +156 -0
- package/src/interfaces/terminal/__tests__/smoke/imports.test.js +332 -0
- package/src/interfaces/terminal/__tests__/smoke/messages.test.js +256 -0
- package/src/interfaces/terminal/__tests__/smoke/tools.test.js +388 -0
- package/src/interfaces/terminal/api/apiClient.js +299 -0
- package/src/interfaces/terminal/api/messageRouter.js +262 -0
- package/src/interfaces/terminal/api/session.js +266 -0
- package/src/interfaces/terminal/api/websocket.js +497 -0
- package/src/interfaces/terminal/components/AgentCreator.js +705 -0
- package/src/interfaces/terminal/components/AgentEditor.js +678 -0
- package/src/interfaces/terminal/components/AgentSwitcher.js +330 -0
- package/src/interfaces/terminal/components/ErrorBoundary.js +92 -0
- package/src/interfaces/terminal/components/ErrorPanel.js +264 -0
- package/src/interfaces/terminal/components/Header.js +28 -0
- package/src/interfaces/terminal/components/HelpPanel.js +231 -0
- package/src/interfaces/terminal/components/InputBox.js +118 -0
- package/src/interfaces/terminal/components/Layout.js +603 -0
- package/src/interfaces/terminal/components/LoadingSpinner.js +71 -0
- package/src/interfaces/terminal/components/MessageList.js +281 -0
- package/src/interfaces/terminal/components/MultilineTextInput.js +251 -0
- package/src/interfaces/terminal/components/SearchPanel.js +265 -0
- package/src/interfaces/terminal/components/SettingsPanel.js +415 -0
- package/src/interfaces/terminal/components/StatusBar.js +65 -0
- package/src/interfaces/terminal/components/TextInput.js +127 -0
- package/src/interfaces/terminal/config/agentEditorConstants.js +227 -0
- package/src/interfaces/terminal/config/constants.js +393 -0
- package/src/interfaces/terminal/index.js +168 -0
- package/src/interfaces/terminal/state/useAgentControl.js +496 -0
- package/src/interfaces/terminal/state/useAgents.js +537 -0
- package/src/interfaces/terminal/state/useConnection.js +444 -0
- package/src/interfaces/terminal/state/useMessages.js +630 -0
- package/src/interfaces/terminal/state/useTools.js +554 -0
- package/src/interfaces/terminal/utils/debugLogger.js +44 -0
- package/src/interfaces/terminal/utils/settingsStorage.js +232 -0
- package/src/interfaces/terminal/utils/theme.js +85 -0
- package/src/interfaces/webServer.js +5457 -0
- package/src/modules/fileExplorer/controller.js +413 -0
- package/src/modules/fileExplorer/index.js +37 -0
- package/src/modules/fileExplorer/middleware.js +92 -0
- package/src/modules/fileExplorer/routes.js +158 -0
- package/src/modules/fileExplorer/types.js +44 -0
- package/src/services/agentActivityService.js +399 -0
- package/src/services/aiService.js +2618 -0
- package/src/services/apiKeyManager.js +334 -0
- package/src/services/benchmarkService.js +196 -0
- package/src/services/budgetService.js +565 -0
- package/src/services/contextInjectionService.js +268 -0
- package/src/services/conversationCompactionService.js +1103 -0
- package/src/services/credentialVault.js +685 -0
- package/src/services/errorHandler.js +810 -0
- package/src/services/fileAttachmentService.js +547 -0
- package/src/services/flowContextService.js +189 -0
- package/src/services/memoryService.js +521 -0
- package/src/services/modelRouterService.js +365 -0
- package/src/services/modelsService.js +323 -0
- package/src/services/ollamaService.js +452 -0
- package/src/services/portRegistry.js +336 -0
- package/src/services/portTracker.js +223 -0
- package/src/services/projectDetector.js +404 -0
- package/src/services/promptService.js +372 -0
- package/src/services/qualityInspector.js +796 -0
- package/src/services/scheduleService.js +725 -0
- package/src/services/serviceRegistry.js +386 -0
- package/src/services/skillsService.js +486 -0
- package/src/services/telegramService.js +920 -0
- package/src/services/tokenCountingService.js +316 -0
- package/src/services/visualEditorBridge.js +1033 -0
- package/src/services/visualEditorServer.js +1727 -0
- package/src/services/whatsappService.js +663 -0
- package/src/tools/__tests__/webTool.e2e.test.js +569 -0
- package/src/tools/__tests__/webTool.unit.test.js +195 -0
- package/src/tools/agentCommunicationTool.js +1343 -0
- package/src/tools/agentDelayTool.js +498 -0
- package/src/tools/asyncToolManager.js +604 -0
- package/src/tools/baseTool.js +887 -0
- package/src/tools/browserTool.js +897 -0
- package/src/tools/cloneDetectionTool.js +581 -0
- package/src/tools/codeMapTool.js +857 -0
- package/src/tools/dependencyResolverTool.js +1212 -0
- package/src/tools/docxTool.js +623 -0
- package/src/tools/excelTool.js +636 -0
- package/src/tools/fileContentReplaceTool.js +840 -0
- package/src/tools/fileTreeTool.js +833 -0
- package/src/tools/filesystemTool.js +1217 -0
- package/src/tools/helpTool.js +198 -0
- package/src/tools/imageTool.js +1034 -0
- package/src/tools/importAnalyzerTool.js +1056 -0
- package/src/tools/jobDoneTool.js +388 -0
- package/src/tools/memoryTool.js +554 -0
- package/src/tools/pdfTool.js +627 -0
- package/src/tools/seekTool.js +883 -0
- package/src/tools/skillsTool.js +276 -0
- package/src/tools/staticAnalysisTool.js +2146 -0
- package/src/tools/taskManagerTool.js +2836 -0
- package/src/tools/terminalTool.js +2486 -0
- package/src/tools/userPromptTool.js +474 -0
- package/src/tools/videoTool.js +1139 -0
- package/src/tools/visionTool.js +507 -0
- package/src/tools/visualEditorTool.js +1175 -0
- package/src/tools/webTool.js +3114 -0
- package/src/tools/whatsappTool.js +457 -0
- package/src/types/agent.js +519 -0
- package/src/types/contextReference.js +972 -0
- package/src/types/conversation.js +730 -0
- package/src/types/toolCommand.js +747 -0
- package/src/utilities/attachmentValidator.js +288 -0
- package/src/utilities/browserStealth.js +630 -0
- package/src/utilities/configManager.js +618 -0
- package/src/utilities/constants.js +870 -0
- package/src/utilities/directoryAccessManager.js +566 -0
- package/src/utilities/fileProcessor.js +307 -0
- package/src/utilities/humanBehavior.js +453 -0
- package/src/utilities/jsonRepair.js +242 -0
- package/src/utilities/logger.js +436 -0
- package/src/utilities/platformUtils.js +255 -0
- package/src/utilities/platformUtils.test.js +98 -0
- package/src/utilities/stealthConstants.js +377 -0
- package/src/utilities/structuredFileValidator.js +699 -0
- package/src/utilities/tagParser.js +878 -0
- package/src/utilities/toolConstants.js +415 -0
- package/src/utilities/userDataDir.js +300 -0
- package/web-ui/build/brands/autopilot/favicon.svg +1 -0
- package/web-ui/build/brands/autopilot/logo.webp +0 -0
- package/web-ui/build/brands/onbuzz/favicon.svg +1 -0
- package/web-ui/build/brands/onbuzz/logo-text.webp +0 -0
- package/web-ui/build/brands/onbuzz/logo.webp +0 -0
- package/web-ui/build/index.html +15 -0
- package/web-ui/build/logo.png +0 -0
- package/web-ui/build/logo2.png +0 -0
- package/web-ui/build/static/index-SmQFfvBs.js +746 -0
- package/web-ui/build/static/index-V2ySwjHp.css +1 -0
|
@@ -0,0 +1,857 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/tools/codeMapTool.js
|
|
3
|
+
* @description Code Map Tool — structural code exploration with multi-level skeleton extraction
|
|
4
|
+
* and line-range reading. Enables agents to understand large codebases without reading entire files.
|
|
5
|
+
*
|
|
6
|
+
* Workflow: skeleton scan → identify interesting areas → read-range for details
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { BaseTool } from './baseTool.js';
|
|
10
|
+
import fs from 'fs';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
|
|
13
|
+
const CODE_MAP_CONFIG = {
|
|
14
|
+
SUPPORTED_EXTENSIONS: new Set(['.js', '.ts', '.jsx', '.tsx', '.mjs', '.cjs', '.py']),
|
|
15
|
+
MAX_FILES: 500,
|
|
16
|
+
MAX_FILE_SIZE: 5 * 1024 * 1024, // 5MB per file
|
|
17
|
+
MAX_READ_RANGE: 500, // Max lines per read-range call
|
|
18
|
+
MAX_DIRECTORY_DEPTH: 20,
|
|
19
|
+
VALID_LEVELS: ['A.0', 'A.1', 'B.0', 'B.1'],
|
|
20
|
+
DEFAULT_LEVEL: 'B.0',
|
|
21
|
+
SKIP_DIRS: new Set(['node_modules', '__pycache__', '.git', 'dist', 'build', 'coverage', '.next', '.nuxt'])
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
class CodeMapTool extends BaseTool {
|
|
25
|
+
constructor(config = {}, logger = null) {
|
|
26
|
+
super(config, logger);
|
|
27
|
+
|
|
28
|
+
this.id = 'code-map';
|
|
29
|
+
this.requiresProject = true;
|
|
30
|
+
this.isAsync = true;
|
|
31
|
+
this.timeout = config.timeout || 120000;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getDescription() {
|
|
35
|
+
return `Code Map Tool: Explore code structure without reading entire files. Two-step workflow:
|
|
36
|
+
|
|
37
|
+
1. **skeleton** — Extract structural overview (signatures, classes, functions) with line numbers
|
|
38
|
+
2. **read-range** — Read specific line ranges identified from the skeleton
|
|
39
|
+
|
|
40
|
+
SKELETON LEVELS:
|
|
41
|
+
- A.0: Public/exported signatures only
|
|
42
|
+
- A.1: Public/exported signatures + comments/docstrings
|
|
43
|
+
- B.0: All signatures (public + private + methods) — DEFAULT
|
|
44
|
+
- B.1: All signatures + comments/docstrings
|
|
45
|
+
|
|
46
|
+
Supported files: .js, .ts, .jsx, .tsx, .mjs, .cjs, .py
|
|
47
|
+
Respects .gitignore rules. Skips node_modules, __pycache__, .git, dist, build.
|
|
48
|
+
|
|
49
|
+
USAGE — Skeleton scan:
|
|
50
|
+
\`\`\`json
|
|
51
|
+
{
|
|
52
|
+
"toolId": "code-map",
|
|
53
|
+
"parameters": {
|
|
54
|
+
"action": "skeleton",
|
|
55
|
+
"path": "src/",
|
|
56
|
+
"level": "B.0",
|
|
57
|
+
"includeImports": false
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
\`\`\`
|
|
61
|
+
|
|
62
|
+
Or for a single file:
|
|
63
|
+
\`\`\`json
|
|
64
|
+
{
|
|
65
|
+
"toolId": "code-map",
|
|
66
|
+
"parameters": {
|
|
67
|
+
"action": "skeleton",
|
|
68
|
+
"path": "src/services/aiService.js",
|
|
69
|
+
"level": "A.0"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
\`\`\`
|
|
73
|
+
|
|
74
|
+
USAGE — Read specific lines (use line numbers from skeleton output):
|
|
75
|
+
\`\`\`json
|
|
76
|
+
{
|
|
77
|
+
"toolId": "code-map",
|
|
78
|
+
"parameters": {
|
|
79
|
+
"action": "read-range",
|
|
80
|
+
"filePath": "src/services/aiService.js",
|
|
81
|
+
"startLine": 42,
|
|
82
|
+
"endLine": 90
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
\`\`\`
|
|
86
|
+
|
|
87
|
+
XML format also supported:
|
|
88
|
+
<code-map>
|
|
89
|
+
<action>skeleton</action>
|
|
90
|
+
<path>src/</path>
|
|
91
|
+
<level>B.0</level>
|
|
92
|
+
</code-map>
|
|
93
|
+
|
|
94
|
+
<code-map>
|
|
95
|
+
<action>read-range</action>
|
|
96
|
+
<file-path>src/index.js</file-path>
|
|
97
|
+
<start-line>100</start-line>
|
|
98
|
+
<end-line>150</end-line>
|
|
99
|
+
</code-map>`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
parseParameters(content) {
|
|
103
|
+
try {
|
|
104
|
+
if (content.trim().startsWith('{')) {
|
|
105
|
+
const parsed = JSON.parse(content);
|
|
106
|
+
return {
|
|
107
|
+
action: parsed.action || parsed.parameters?.action,
|
|
108
|
+
path: parsed.path || parsed.parameters?.path,
|
|
109
|
+
level: parsed.level || parsed.parameters?.level,
|
|
110
|
+
includeImports: parsed.includeImports ?? parsed.parameters?.includeImports ?? false,
|
|
111
|
+
filePath: parsed.filePath || parsed.parameters?.filePath,
|
|
112
|
+
startLine: parsed.startLine ?? parsed.parameters?.startLine,
|
|
113
|
+
endLine: parsed.endLine ?? parsed.parameters?.endLine
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// XML parsing
|
|
118
|
+
const params = {};
|
|
119
|
+
const actionMatch = /<action>(.*?)<\/action>/i.exec(content);
|
|
120
|
+
if (actionMatch) params.action = actionMatch[1].trim();
|
|
121
|
+
|
|
122
|
+
const pathMatch = /<path>(.*?)<\/path>/i.exec(content);
|
|
123
|
+
if (pathMatch) params.path = pathMatch[1].trim();
|
|
124
|
+
|
|
125
|
+
const levelMatch = /<level>(.*?)<\/level>/i.exec(content);
|
|
126
|
+
if (levelMatch) params.level = levelMatch[1].trim();
|
|
127
|
+
|
|
128
|
+
const importsMatch = /<include-imports>(.*?)<\/include-imports>/i.exec(content);
|
|
129
|
+
if (importsMatch) params.includeImports = importsMatch[1].trim() === 'true';
|
|
130
|
+
|
|
131
|
+
const filePathMatch = /<file-path>(.*?)<\/file-path>/i.exec(content);
|
|
132
|
+
if (filePathMatch) params.filePath = filePathMatch[1].trim();
|
|
133
|
+
|
|
134
|
+
const startLineMatch = /<start-line>(.*?)<\/start-line>/i.exec(content);
|
|
135
|
+
if (startLineMatch) params.startLine = parseInt(startLineMatch[1].trim(), 10);
|
|
136
|
+
|
|
137
|
+
const endLineMatch = /<end-line>(.*?)<\/end-line>/i.exec(content);
|
|
138
|
+
if (endLineMatch) params.endLine = parseInt(endLineMatch[1].trim(), 10);
|
|
139
|
+
|
|
140
|
+
return params;
|
|
141
|
+
} catch (error) {
|
|
142
|
+
this.logger?.error('Failed to parse code-map parameters', { error: error.message });
|
|
143
|
+
return { parseError: error.message };
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
getRequiredParameters() {
|
|
148
|
+
return ['action'];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
customValidateParameters(params) {
|
|
152
|
+
const errors = [];
|
|
153
|
+
|
|
154
|
+
if (!params.action) {
|
|
155
|
+
errors.push('action is required (skeleton or read-range)');
|
|
156
|
+
} else if (!['skeleton', 'read-range'].includes(params.action)) {
|
|
157
|
+
errors.push(`Invalid action "${params.action}". Must be "skeleton" or "read-range"`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (params.action === 'skeleton') {
|
|
161
|
+
if (!params.path) errors.push('path is required for skeleton action');
|
|
162
|
+
if (params.level && !CODE_MAP_CONFIG.VALID_LEVELS.includes(params.level.toUpperCase())) {
|
|
163
|
+
errors.push(`Invalid level "${params.level}". Must be one of: ${CODE_MAP_CONFIG.VALID_LEVELS.join(', ')}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (params.action === 'read-range') {
|
|
168
|
+
if (!params.filePath) errors.push('filePath is required for read-range action');
|
|
169
|
+
if (params.startLine == null) errors.push('startLine is required for read-range action');
|
|
170
|
+
if (params.endLine == null) errors.push('endLine is required for read-range action');
|
|
171
|
+
if (params.startLine != null && params.endLine != null) {
|
|
172
|
+
if (params.startLine < 1) errors.push('startLine must be >= 1');
|
|
173
|
+
if (params.endLine < params.startLine) errors.push('endLine must be >= startLine');
|
|
174
|
+
if (params.endLine - params.startLine + 1 > CODE_MAP_CONFIG.MAX_READ_RANGE) {
|
|
175
|
+
errors.push(`Range too large. Maximum ${CODE_MAP_CONFIG.MAX_READ_RANGE} lines per request`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return { valid: errors.length === 0, errors };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async execute(params, context) {
|
|
184
|
+
const { projectDir, directoryAccess } = context;
|
|
185
|
+
|
|
186
|
+
let workingDir = projectDir || process.cwd();
|
|
187
|
+
if (directoryAccess?.workingDirectory) {
|
|
188
|
+
workingDir = directoryAccess.workingDirectory;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const accessibleDirs = this._getAccessibleDirectories(directoryAccess, workingDir);
|
|
192
|
+
|
|
193
|
+
switch (params.action) {
|
|
194
|
+
case 'skeleton':
|
|
195
|
+
return await this._executeSkeleton(params, workingDir, accessibleDirs);
|
|
196
|
+
case 'read-range':
|
|
197
|
+
return await this._executeReadRange(params, workingDir, accessibleDirs);
|
|
198
|
+
default:
|
|
199
|
+
throw new Error(`Unknown action: ${params.action}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// ── Directory access helpers ──────────────────────────────────────────────
|
|
204
|
+
|
|
205
|
+
_getAccessibleDirectories(directoryAccess, fallbackDir) {
|
|
206
|
+
const dirs = new Set();
|
|
207
|
+
dirs.add(fallbackDir);
|
|
208
|
+
|
|
209
|
+
if (directoryAccess) {
|
|
210
|
+
if (directoryAccess.workingDirectory) dirs.add(directoryAccess.workingDirectory);
|
|
211
|
+
if (directoryAccess.readOnlyDirectories) {
|
|
212
|
+
for (const d of directoryAccess.readOnlyDirectories) dirs.add(d);
|
|
213
|
+
}
|
|
214
|
+
if (directoryAccess.writeEnabledDirectories) {
|
|
215
|
+
for (const d of directoryAccess.writeEnabledDirectories) dirs.add(d);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return Array.from(dirs);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
_isPathAccessible(targetPath, accessibleDirs) {
|
|
223
|
+
for (const dir of accessibleDirs) {
|
|
224
|
+
const relative = path.relative(dir, targetPath);
|
|
225
|
+
if (!relative.startsWith('..') && !path.isAbsolute(relative)) return true;
|
|
226
|
+
}
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ── Skeleton action ───────────────────────────────────────────────────────
|
|
231
|
+
|
|
232
|
+
async _executeSkeleton(params, workingDir, accessibleDirs) {
|
|
233
|
+
const targetPath = path.resolve(workingDir, params.path);
|
|
234
|
+
|
|
235
|
+
if (!this._isPathAccessible(targetPath, accessibleDirs)) {
|
|
236
|
+
throw new Error(`Path not accessible: ${params.path}`);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const level = (params.level || CODE_MAP_CONFIG.DEFAULT_LEVEL).toUpperCase();
|
|
240
|
+
const publicOnly = level.startsWith('A');
|
|
241
|
+
const withComments = level.endsWith('.1');
|
|
242
|
+
const includeImports = params.includeImports || false;
|
|
243
|
+
const parseOptions = { publicOnly, withComments, includeImports };
|
|
244
|
+
|
|
245
|
+
let stat;
|
|
246
|
+
try {
|
|
247
|
+
stat = await fs.promises.stat(targetPath);
|
|
248
|
+
} catch {
|
|
249
|
+
throw new Error(`Path not found: ${params.path}`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
let files;
|
|
253
|
+
if (stat.isFile()) {
|
|
254
|
+
const ext = path.extname(targetPath).toLowerCase();
|
|
255
|
+
if (!CODE_MAP_CONFIG.SUPPORTED_EXTENSIONS.has(ext)) {
|
|
256
|
+
throw new Error(`Unsupported file type: ${ext}. Supported: ${[...CODE_MAP_CONFIG.SUPPORTED_EXTENSIONS].join(', ')}`);
|
|
257
|
+
}
|
|
258
|
+
files = [targetPath];
|
|
259
|
+
} else {
|
|
260
|
+
files = await this._discoverFiles(targetPath, accessibleDirs);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (files.length === 0) {
|
|
264
|
+
return {
|
|
265
|
+
success: true,
|
|
266
|
+
action: 'skeleton',
|
|
267
|
+
level,
|
|
268
|
+
path: params.path,
|
|
269
|
+
files: [],
|
|
270
|
+
totalFiles: 0,
|
|
271
|
+
totalEntries: 0,
|
|
272
|
+
message: 'No supported files found in the specified path.',
|
|
273
|
+
guidance: 'Try a different path or verify the directory contains .js, .ts, .jsx, .tsx, .mjs, .cjs, or .py files.'
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (files.length > CODE_MAP_CONFIG.MAX_FILES) {
|
|
278
|
+
files = files.slice(0, CODE_MAP_CONFIG.MAX_FILES);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const basePath = stat.isDirectory() ? targetPath : path.dirname(targetPath);
|
|
282
|
+
const result = [];
|
|
283
|
+
let totalEntries = 0;
|
|
284
|
+
|
|
285
|
+
for (const file of files) {
|
|
286
|
+
try {
|
|
287
|
+
const fileStat = await fs.promises.stat(file);
|
|
288
|
+
if (fileStat.size > CODE_MAP_CONFIG.MAX_FILE_SIZE) continue;
|
|
289
|
+
|
|
290
|
+
const content = await fs.promises.readFile(file, 'utf-8');
|
|
291
|
+
const lines = content.replace(/\r\n/g, '\n').replace(/\r/g, '\n').split('\n');
|
|
292
|
+
const lang = this._langOf(file);
|
|
293
|
+
|
|
294
|
+
const entries = lang === 'python'
|
|
295
|
+
? this._parsePython(lines, parseOptions)
|
|
296
|
+
: this._parseJS(lines, parseOptions);
|
|
297
|
+
|
|
298
|
+
if (entries.length === 0) continue;
|
|
299
|
+
|
|
300
|
+
const relPath = path.relative(basePath, file);
|
|
301
|
+
result.push({
|
|
302
|
+
file: relPath,
|
|
303
|
+
totalLines: lines.length,
|
|
304
|
+
entries
|
|
305
|
+
});
|
|
306
|
+
totalEntries += entries.length;
|
|
307
|
+
} catch (err) {
|
|
308
|
+
this.logger?.debug(`Skipping file ${file}: ${err.message}`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return {
|
|
313
|
+
success: true,
|
|
314
|
+
action: 'skeleton',
|
|
315
|
+
level,
|
|
316
|
+
path: params.path,
|
|
317
|
+
files: result,
|
|
318
|
+
totalFiles: result.length,
|
|
319
|
+
totalEntries,
|
|
320
|
+
guidance: totalEntries > 0
|
|
321
|
+
? (() => {
|
|
322
|
+
const sampleFile = result[0];
|
|
323
|
+
const sampleLine = sampleFile?.entries[0]?.line || 1;
|
|
324
|
+
const examplePath = stat.isDirectory()
|
|
325
|
+
? (params.path.endsWith('/') ? params.path : params.path + '/') + sampleFile.file
|
|
326
|
+
: params.path;
|
|
327
|
+
return `Found ${totalEntries} entries across ${result.length} files. Use code-map read-range to examine specific sections by line number. Example: {"toolId":"code-map","parameters":{"action":"read-range","filePath":"${examplePath}","startLine":${sampleLine},"endLine":${sampleLine + 30}}}`;
|
|
328
|
+
})()
|
|
329
|
+
: 'No code signatures found at this level. Try level B.0 or B.1 for more detail.'
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// ── Read-range action ─────────────────────────────────────────────────────
|
|
334
|
+
|
|
335
|
+
async _executeReadRange(params, workingDir, accessibleDirs) {
|
|
336
|
+
const filePath = path.resolve(workingDir, params.filePath);
|
|
337
|
+
|
|
338
|
+
if (!this._isPathAccessible(filePath, accessibleDirs)) {
|
|
339
|
+
throw new Error(`Path not accessible: ${params.filePath}`);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
let content;
|
|
343
|
+
try {
|
|
344
|
+
content = await fs.promises.readFile(filePath, 'utf-8');
|
|
345
|
+
} catch {
|
|
346
|
+
throw new Error(`File not found: ${params.filePath}`);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const allLines = content.replace(/\r\n/g, '\n').replace(/\r/g, '\n').split('\n');
|
|
350
|
+
const totalLines = allLines.length;
|
|
351
|
+
const startLine = Math.max(1, params.startLine);
|
|
352
|
+
const endLine = Math.min(totalLines, params.endLine);
|
|
353
|
+
|
|
354
|
+
if (startLine > totalLines) {
|
|
355
|
+
throw new Error(`startLine ${startLine} exceeds file length (${totalLines} lines)`);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const selectedLines = allLines.slice(startLine - 1, endLine);
|
|
359
|
+
const maxWidth = String(endLine).length;
|
|
360
|
+
const formatted = selectedLines.map((line, i) => {
|
|
361
|
+
const num = String(startLine + i).padStart(maxWidth);
|
|
362
|
+
return `${num}│${line}`;
|
|
363
|
+
}).join('\n');
|
|
364
|
+
|
|
365
|
+
return {
|
|
366
|
+
success: true,
|
|
367
|
+
action: 'read-range',
|
|
368
|
+
filePath: params.filePath,
|
|
369
|
+
startLine,
|
|
370
|
+
endLine,
|
|
371
|
+
linesReturned: selectedLines.length,
|
|
372
|
+
totalLines,
|
|
373
|
+
content: formatted,
|
|
374
|
+
guidance: `Showing lines ${startLine}-${endLine} of ${totalLines}. ` +
|
|
375
|
+
(endLine < totalLines
|
|
376
|
+
? `Use read-range with startLine:${endLine + 1} to continue reading. `
|
|
377
|
+
: '') +
|
|
378
|
+
'Use code-map skeleton to discover more code structure in other files.'
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// ── File discovery with .gitignore ────────────────────────────────────────
|
|
383
|
+
|
|
384
|
+
async _discoverFiles(rootDir, accessibleDirs) {
|
|
385
|
+
const gi = await this._loadGitignoreRules(rootDir);
|
|
386
|
+
const results = [];
|
|
387
|
+
let depth = 0;
|
|
388
|
+
|
|
389
|
+
const walk = async (dir) => {
|
|
390
|
+
if (depth > CODE_MAP_CONFIG.MAX_DIRECTORY_DEPTH) return;
|
|
391
|
+
if (results.length >= CODE_MAP_CONFIG.MAX_FILES) return;
|
|
392
|
+
|
|
393
|
+
const rel = path.relative(rootDir, dir);
|
|
394
|
+
if (rel) gi.loadNested(dir, rel);
|
|
395
|
+
|
|
396
|
+
let entries;
|
|
397
|
+
try {
|
|
398
|
+
entries = await fs.promises.readdir(dir, { withFileTypes: true });
|
|
399
|
+
} catch {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// Sort for deterministic output
|
|
404
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
405
|
+
|
|
406
|
+
for (const entry of entries) {
|
|
407
|
+
if (results.length >= CODE_MAP_CONFIG.MAX_FILES) break;
|
|
408
|
+
if (entry.name.startsWith('.')) continue;
|
|
409
|
+
|
|
410
|
+
const full = path.join(dir, entry.name);
|
|
411
|
+
const entryRel = path.relative(rootDir, full);
|
|
412
|
+
|
|
413
|
+
if (entry.isDirectory()) {
|
|
414
|
+
if (CODE_MAP_CONFIG.SKIP_DIRS.has(entry.name)) continue;
|
|
415
|
+
if (gi.isIgnored(entryRel, true) && !gi.hasNegationUnder(entryRel)) continue;
|
|
416
|
+
if (!this._isPathAccessible(full, accessibleDirs)) continue;
|
|
417
|
+
|
|
418
|
+
depth++;
|
|
419
|
+
await walk(full);
|
|
420
|
+
depth--;
|
|
421
|
+
} else if (CODE_MAP_CONFIG.SUPPORTED_EXTENSIONS.has(path.extname(entry.name).toLowerCase())) {
|
|
422
|
+
if (gi.isIgnored(entryRel, false)) continue;
|
|
423
|
+
results.push(full);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
await walk(rootDir);
|
|
429
|
+
return results;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// ── .gitignore support ────────────────────────────────────────────────────
|
|
433
|
+
|
|
434
|
+
async _loadGitignoreRules(rootDir) {
|
|
435
|
+
const allRules = [];
|
|
436
|
+
|
|
437
|
+
const giPath = path.join(rootDir, '.gitignore');
|
|
438
|
+
try {
|
|
439
|
+
const content = await fs.promises.readFile(giPath, 'utf-8');
|
|
440
|
+
allRules.push(...this._parseGitignore(content, ''));
|
|
441
|
+
} catch {
|
|
442
|
+
// No .gitignore at root — that's fine
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return {
|
|
446
|
+
rules: allRules,
|
|
447
|
+
|
|
448
|
+
loadNested: (subDir, relPath) => {
|
|
449
|
+
const nested = path.join(subDir, '.gitignore');
|
|
450
|
+
try {
|
|
451
|
+
const content = fs.readFileSync(nested, 'utf-8');
|
|
452
|
+
const prefix = relPath ? relPath + '/' : '';
|
|
453
|
+
allRules.push(...this._parseGitignore(content, prefix));
|
|
454
|
+
} catch {
|
|
455
|
+
// No nested .gitignore
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
|
|
459
|
+
isIgnored: (relPath, isDir) => {
|
|
460
|
+
let ignored = false;
|
|
461
|
+
for (const rule of allRules) {
|
|
462
|
+
if (rule.dirOnly && !isDir) {
|
|
463
|
+
const parts = relPath.split('/');
|
|
464
|
+
let parentMatch = false;
|
|
465
|
+
for (let k = 1; k < parts.length; k++) {
|
|
466
|
+
const parentPath = parts.slice(0, k).join('/');
|
|
467
|
+
if (rule.regex.test(parentPath)) { parentMatch = true; break; }
|
|
468
|
+
}
|
|
469
|
+
if (!parentMatch) continue;
|
|
470
|
+
} else if (!rule.regex.test(relPath)) {
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
ignored = !rule.negate;
|
|
474
|
+
}
|
|
475
|
+
return ignored;
|
|
476
|
+
},
|
|
477
|
+
|
|
478
|
+
hasNegationUnder: (dirRelPath) => {
|
|
479
|
+
const prefix = dirRelPath + '/';
|
|
480
|
+
for (const rule of allRules) {
|
|
481
|
+
if (!rule.negate) continue;
|
|
482
|
+
if (rule.regex.test(prefix + 'x') || rule.regex.test(prefix + 'x.js')) return true;
|
|
483
|
+
if (rule.regex.source.includes(dirRelPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))) return true;
|
|
484
|
+
}
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
_parseGitignore(content, prefix) {
|
|
491
|
+
const rules = [];
|
|
492
|
+
for (const rawLine of content.split('\n')) {
|
|
493
|
+
let line = rawLine.trim();
|
|
494
|
+
if (!line || line.startsWith('#')) continue;
|
|
495
|
+
|
|
496
|
+
let negate = false;
|
|
497
|
+
if (line.startsWith('!')) {
|
|
498
|
+
negate = true;
|
|
499
|
+
line = line.slice(1);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
line = line.replace(/\\(\s)$/, '$1');
|
|
503
|
+
|
|
504
|
+
let dirOnly = false;
|
|
505
|
+
if (line.endsWith('/')) {
|
|
506
|
+
dirOnly = true;
|
|
507
|
+
line = line.slice(0, -1);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const hasSlash = line.includes('/');
|
|
511
|
+
const rooted = line.startsWith('/');
|
|
512
|
+
if (rooted) line = line.slice(1);
|
|
513
|
+
|
|
514
|
+
let reStr;
|
|
515
|
+
if (hasSlash || rooted) {
|
|
516
|
+
reStr = '^' + prefix + this._gitignorePatternToRegex(line) + '(/.*)?$';
|
|
517
|
+
} else {
|
|
518
|
+
reStr = '(^|.+/)' + prefix + this._gitignorePatternToRegex(line) + '(/.*)?$';
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
try {
|
|
522
|
+
rules.push({ regex: new RegExp(reStr), negate, dirOnly });
|
|
523
|
+
} catch {
|
|
524
|
+
// skip invalid patterns
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return rules;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
_gitignorePatternToRegex(pattern) {
|
|
531
|
+
let re = '';
|
|
532
|
+
let i = 0;
|
|
533
|
+
while (i < pattern.length) {
|
|
534
|
+
const ch = pattern[i];
|
|
535
|
+
if (ch === '*' && pattern[i + 1] === '*') {
|
|
536
|
+
if (pattern[i + 2] === '/') {
|
|
537
|
+
re += '(.+/)?';
|
|
538
|
+
i += 3;
|
|
539
|
+
} else {
|
|
540
|
+
re += '.*';
|
|
541
|
+
i += 2;
|
|
542
|
+
}
|
|
543
|
+
} else if (ch === '*') {
|
|
544
|
+
re += '[^/]*';
|
|
545
|
+
i++;
|
|
546
|
+
} else if (ch === '?') {
|
|
547
|
+
re += '[^/]';
|
|
548
|
+
i++;
|
|
549
|
+
} else if (ch === '[') {
|
|
550
|
+
const end = pattern.indexOf(']', i + 1);
|
|
551
|
+
if (end === -1) { re += '\\['; i++; }
|
|
552
|
+
else { re += pattern.slice(i, end + 1); i = end + 1; }
|
|
553
|
+
} else if ('.+^${}()|\\'.includes(ch)) {
|
|
554
|
+
re += '\\' + ch;
|
|
555
|
+
i++;
|
|
556
|
+
} else {
|
|
557
|
+
re += ch;
|
|
558
|
+
i++;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return re;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// ── Language detection ────────────────────────────────────────────────────
|
|
565
|
+
|
|
566
|
+
_langOf(file) {
|
|
567
|
+
return path.extname(file).toLowerCase() === '.py' ? 'python' : 'js';
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// ── JS / TS parser ────────────────────────────────────────────────────────
|
|
571
|
+
|
|
572
|
+
_parseJS(lines, { publicOnly, withComments, includeImports }) {
|
|
573
|
+
const entries = [];
|
|
574
|
+
let pendingComments = [];
|
|
575
|
+
let inBlockComment = false;
|
|
576
|
+
let blockCommentLines = [];
|
|
577
|
+
|
|
578
|
+
let classDepth = 0;
|
|
579
|
+
let braceStack = [];
|
|
580
|
+
let braceDepth = 0;
|
|
581
|
+
let methodDepths = [];
|
|
582
|
+
|
|
583
|
+
for (let i = 0; i < lines.length; i++) {
|
|
584
|
+
const lineNum = i + 1;
|
|
585
|
+
const raw = lines[i];
|
|
586
|
+
const trimmed = raw.trim();
|
|
587
|
+
|
|
588
|
+
// block-comment tracking
|
|
589
|
+
if (inBlockComment) {
|
|
590
|
+
blockCommentLines.push({ line: lineNum, text: raw, kind: 'comment' });
|
|
591
|
+
if (trimmed.includes('*/')) {
|
|
592
|
+
inBlockComment = false;
|
|
593
|
+
pendingComments = blockCommentLines;
|
|
594
|
+
blockCommentLines = [];
|
|
595
|
+
}
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
if (trimmed.startsWith('/*')) {
|
|
600
|
+
blockCommentLines = [{ line: lineNum, text: raw, kind: 'comment' }];
|
|
601
|
+
if (trimmed.includes('*/')) {
|
|
602
|
+
pendingComments = blockCommentLines;
|
|
603
|
+
blockCommentLines = [];
|
|
604
|
+
} else {
|
|
605
|
+
inBlockComment = true;
|
|
606
|
+
}
|
|
607
|
+
continue;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
if (trimmed.startsWith('//')) {
|
|
611
|
+
pendingComments.push({ line: lineNum, text: raw, kind: 'comment' });
|
|
612
|
+
continue;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
// imports
|
|
616
|
+
if (includeImports) {
|
|
617
|
+
if (/^\s*import\s/.test(raw) || /\brequire\s*\(/.test(raw)) {
|
|
618
|
+
entries.push({ line: lineNum, text: raw, kind: 'import' });
|
|
619
|
+
pendingComments = [];
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// brace tracking for class context
|
|
625
|
+
const stripped = trimmed
|
|
626
|
+
.replace(/\/\/.*$/, '')
|
|
627
|
+
.replace(/`[^`]*`/g, '')
|
|
628
|
+
.replace(/"(?:[^"\\]|\\.)*"/g, '')
|
|
629
|
+
.replace(/'(?:[^'\\]|\\.)*'/g, '');
|
|
630
|
+
const opens = (stripped.match(/\{/g) || []).length;
|
|
631
|
+
const closes = (stripped.match(/\}/g) || []).length;
|
|
632
|
+
|
|
633
|
+
const braceDepthBeforeLine = braceDepth;
|
|
634
|
+
|
|
635
|
+
if (/^\s*(export\s+)?(default\s+)?(abstract\s+)?class\s/.test(raw) && opens > 0) {
|
|
636
|
+
braceStack.push({ depth: braceDepth, type: 'class' });
|
|
637
|
+
methodDepths.push(braceDepth + 1);
|
|
638
|
+
classDepth++;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
braceDepth += opens - closes;
|
|
642
|
+
|
|
643
|
+
while (braceStack.length > 0 && braceDepth <= braceStack[braceStack.length - 1].depth) {
|
|
644
|
+
const popped = braceStack.pop();
|
|
645
|
+
if (popped.type === 'class') {
|
|
646
|
+
classDepth--;
|
|
647
|
+
methodDepths.pop();
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// detect signatures
|
|
652
|
+
const isExport = /^\s*export\s/.test(raw);
|
|
653
|
+
const isModuleExports = /^\s*module\.exports(\.\w+)?\s*=/.test(raw);
|
|
654
|
+
const isExportsAssign = /^\s*exports\.\w+\s*=/.test(raw);
|
|
655
|
+
const isPublic = isExport || isModuleExports || isExportsAssign;
|
|
656
|
+
|
|
657
|
+
let matched = false;
|
|
658
|
+
|
|
659
|
+
if (isExport) {
|
|
660
|
+
if (/^\s*export\s+(default\s+)?(async\s+)?(function\b|class\b|const\b|let\b|var\b|enum\b|interface\b|type\b|abstract\b)/.test(raw)) {
|
|
661
|
+
matched = true;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
if (isModuleExports || isExportsAssign) {
|
|
666
|
+
matched = true;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
if (!matched && !publicOnly) {
|
|
670
|
+
if (/^\s*(async\s+)?function\s+\w+/.test(raw)) matched = true;
|
|
671
|
+
if (/^\s*(abstract\s+)?class\s+\w+/.test(raw)) matched = true;
|
|
672
|
+
if (/^\s*(const|let|var)\s+\w+\s*=\s*(async\s+)?\(/.test(raw) && raw.includes('=>')) matched = true;
|
|
673
|
+
if (/^\s*(const|let|var)\s+\w+\s*=\s*(async\s+)?function/.test(raw)) matched = true;
|
|
674
|
+
if (/^\s*(const|let|var)\s+\w+\s*=\s*(async\s+)?\w+\s*=>/.test(raw)) matched = true;
|
|
675
|
+
|
|
676
|
+
// method inside class
|
|
677
|
+
const atMethodDepth = methodDepths.length > 0 && braceDepthBeforeLine === methodDepths[methodDepths.length - 1];
|
|
678
|
+
if (classDepth > 0 && atMethodDepth && /^\s+(?:(?:private|protected|public|readonly|abstract|override|async|static|get|set)\s+)*(\w+)\s*[\(<]/.test(raw) && !isExport) {
|
|
679
|
+
const methodMatch = raw.match(/^\s+(?:(?:private|protected|public|readonly|abstract|override|async|static|get|set)\s+)*(\w+)\s*[\(<]/);
|
|
680
|
+
if (methodMatch) {
|
|
681
|
+
const name = methodMatch[1];
|
|
682
|
+
const isCall = /\)\s*;?\s*$/.test(trimmed) && !/\)\s*\{/.test(trimmed) && !/\)\s*:\s*\S/.test(trimmed);
|
|
683
|
+
const excluded = ['if', 'for', 'while', 'switch', 'catch', 'return', 'throw', 'new', 'typeof', 'delete', 'void', 'await', 'class', 'function', 'const', 'let', 'var', 'super', 'this'];
|
|
684
|
+
if (!isCall && !excluded.includes(name)) matched = true;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (!matched && isPublic) matched = true;
|
|
690
|
+
|
|
691
|
+
if (matched && publicOnly && !isPublic) {
|
|
692
|
+
pendingComments = [];
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
if (matched) {
|
|
697
|
+
if (withComments && pendingComments.length > 0) {
|
|
698
|
+
for (const c of pendingComments) entries.push(c);
|
|
699
|
+
}
|
|
700
|
+
entries.push({ line: lineNum, text: raw, kind: 'signature' });
|
|
701
|
+
pendingComments = [];
|
|
702
|
+
} else {
|
|
703
|
+
pendingComments = [];
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
return entries;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// ── Python parser ─────────────────────────────────────────────────────────
|
|
711
|
+
|
|
712
|
+
_parsePython(lines, { publicOnly, withComments, includeImports }) {
|
|
713
|
+
const entries = [];
|
|
714
|
+
let pendingComments = [];
|
|
715
|
+
let i = 0;
|
|
716
|
+
|
|
717
|
+
while (i < lines.length) {
|
|
718
|
+
const lineNum = i + 1;
|
|
719
|
+
const raw = lines[i];
|
|
720
|
+
const trimmed = raw.trim();
|
|
721
|
+
|
|
722
|
+
// imports
|
|
723
|
+
if (includeImports) {
|
|
724
|
+
if (/^\s*(import\s|from\s+\S+\s+import\s)/.test(raw)) {
|
|
725
|
+
entries.push({ line: lineNum, text: raw, kind: 'import' });
|
|
726
|
+
pendingComments = [];
|
|
727
|
+
i++;
|
|
728
|
+
continue;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
// # comments
|
|
733
|
+
if (trimmed.startsWith('#')) {
|
|
734
|
+
pendingComments.push({ line: lineNum, text: raw, kind: 'comment' });
|
|
735
|
+
i++;
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
// decorators
|
|
740
|
+
if (trimmed.startsWith('@')) {
|
|
741
|
+
pendingComments.push({ line: lineNum, text: raw, kind: 'decorator' });
|
|
742
|
+
i++;
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
// def / async def / class
|
|
747
|
+
const ID = /[\p{L}\p{N}_]+/u.source;
|
|
748
|
+
const defMatch = raw.match(new RegExp(`^(\\s*)(async\\s+)?def\\s+(${ID})\\s*\\(`, 'u'));
|
|
749
|
+
const classMatch = !defMatch ? raw.match(new RegExp(`^(\\s*)(class)\\s+(${ID})`, 'u')) : null;
|
|
750
|
+
const sigMatch = defMatch || classMatch;
|
|
751
|
+
|
|
752
|
+
if (sigMatch) {
|
|
753
|
+
const name = sigMatch[3];
|
|
754
|
+
const isPublic = !name.startsWith('_');
|
|
755
|
+
|
|
756
|
+
if (publicOnly && !isPublic) {
|
|
757
|
+
pendingComments = [];
|
|
758
|
+
i++;
|
|
759
|
+
if (defMatch && !raw.includes('):') && !raw.includes(')')) {
|
|
760
|
+
while (i < lines.length) {
|
|
761
|
+
const pline = lines[i].trim();
|
|
762
|
+
i++;
|
|
763
|
+
if (pline.includes('):') || (pline.startsWith(')') && pline.includes(':'))) break;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
i = this._skipPythonDocstring(lines, i);
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
if (withComments && pendingComments.length > 0) {
|
|
771
|
+
for (const c of pendingComments) entries.push(c);
|
|
772
|
+
}
|
|
773
|
+
entries.push({ line: lineNum, text: raw, kind: 'signature' });
|
|
774
|
+
pendingComments = [];
|
|
775
|
+
i++;
|
|
776
|
+
|
|
777
|
+
if (defMatch && !raw.includes('):') && !raw.includes(')')) {
|
|
778
|
+
while (i < lines.length) {
|
|
779
|
+
const pline = lines[i].trim();
|
|
780
|
+
i++;
|
|
781
|
+
if (pline.includes('):') || (pline.startsWith(')') && pline.includes(':'))) break;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
if (withComments) {
|
|
786
|
+
const dsLines = this._collectPythonDocstring(lines, i);
|
|
787
|
+
for (const ds of dsLines) entries.push(ds);
|
|
788
|
+
i += dsLines.length;
|
|
789
|
+
} else {
|
|
790
|
+
i = this._skipPythonDocstring(lines, i);
|
|
791
|
+
}
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// top-level assignments
|
|
796
|
+
if (/^\S/.test(raw) && new RegExp(`^[\\p{L}_][\\p{L}\\p{N}_]*\\s*=\\s*.+`, 'u').test(trimmed)) {
|
|
797
|
+
const varMatch = trimmed.match(new RegExp(`^([\\p{L}_][\\p{L}\\p{N}_]*)\\s*=`, 'u'));
|
|
798
|
+
if (varMatch) {
|
|
799
|
+
const varName = varMatch[1];
|
|
800
|
+
const isPublicVar = !varName.startsWith('_');
|
|
801
|
+
if (!publicOnly || isPublicVar) {
|
|
802
|
+
if (withComments && pendingComments.length > 0) {
|
|
803
|
+
for (const c of pendingComments) entries.push(c);
|
|
804
|
+
}
|
|
805
|
+
entries.push({ line: lineNum, text: raw, kind: 'data' });
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
pendingComments = [];
|
|
809
|
+
i++;
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
pendingComments = [];
|
|
814
|
+
i++;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
return entries;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
_collectPythonDocstring(lines, startIdx) {
|
|
821
|
+
if (startIdx >= lines.length) return [];
|
|
822
|
+
const first = lines[startIdx].trim();
|
|
823
|
+
|
|
824
|
+
if (/^("""|''').*\1\s*$/.test(first)) {
|
|
825
|
+
return [{ line: startIdx + 1, text: lines[startIdx], kind: 'comment' }];
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
const tripleMatch = first.match(/^("""|''')/);
|
|
829
|
+
if (!tripleMatch) return [];
|
|
830
|
+
|
|
831
|
+
const quote = tripleMatch[1];
|
|
832
|
+
const result = [{ line: startIdx + 1, text: lines[startIdx], kind: 'comment' }];
|
|
833
|
+
for (let j = startIdx + 1; j < lines.length; j++) {
|
|
834
|
+
result.push({ line: j + 1, text: lines[j], kind: 'comment' });
|
|
835
|
+
if (lines[j].includes(quote)) break;
|
|
836
|
+
}
|
|
837
|
+
return result;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
_skipPythonDocstring(lines, startIdx) {
|
|
841
|
+
if (startIdx >= lines.length) return startIdx;
|
|
842
|
+
const first = lines[startIdx].trim();
|
|
843
|
+
|
|
844
|
+
if (/^("""|''').*\1\s*$/.test(first)) return startIdx + 1;
|
|
845
|
+
|
|
846
|
+
const tripleMatch = first.match(/^("""|''')/);
|
|
847
|
+
if (!tripleMatch) return startIdx;
|
|
848
|
+
|
|
849
|
+
const quote = tripleMatch[1];
|
|
850
|
+
for (let j = startIdx + 1; j < lines.length; j++) {
|
|
851
|
+
if (lines[j].includes(quote)) return j + 1;
|
|
852
|
+
}
|
|
853
|
+
return lines.length;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
export default CodeMapTool;
|