codebuff 1.0.99

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 (153) hide show
  1. package/README.md +70 -0
  2. package/dist/chat-storage.d.ts +29 -0
  3. package/dist/chat-storage.js +125 -0
  4. package/dist/chat-storage.js.map +1 -0
  5. package/dist/cli.d.ts +37 -0
  6. package/dist/cli.js +416 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/client.d.ts +41 -0
  9. package/dist/client.js +443 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/code-map/languages.d.ts +12 -0
  12. package/dist/code-map/languages.js +129 -0
  13. package/dist/code-map/languages.js.map +1 -0
  14. package/dist/code-map/parse.d.ts +11 -0
  15. package/dist/code-map/parse.js +127 -0
  16. package/dist/code-map/parse.js.map +1 -0
  17. package/dist/code-map/test-langs/test.d.ts +11 -0
  18. package/dist/code-map/test-langs/test.js +23 -0
  19. package/dist/code-map/test-langs/test.js.map +1 -0
  20. package/dist/code-map/tree-sitter-queries/readme.md +23 -0
  21. package/dist/code-map/tree-sitter-queries/tree-sitter-c-tags.scm +11 -0
  22. package/dist/code-map/tree-sitter-queries/tree-sitter-c_sharp-tags.scm +13 -0
  23. package/dist/code-map/tree-sitter-queries/tree-sitter-cpp-tags.scm +17 -0
  24. package/dist/code-map/tree-sitter-queries/tree-sitter-go-tags.scm +26 -0
  25. package/dist/code-map/tree-sitter-queries/tree-sitter-java-tags.scm +19 -0
  26. package/dist/code-map/tree-sitter-queries/tree-sitter-javascript-tags.scm +15 -0
  27. package/dist/code-map/tree-sitter-queries/tree-sitter-php-tags.scm +26 -0
  28. package/dist/code-map/tree-sitter-queries/tree-sitter-python-tags.scm +9 -0
  29. package/dist/code-map/tree-sitter-queries/tree-sitter-ruby-tags.scm +58 -0
  30. package/dist/code-map/tree-sitter-queries/tree-sitter-rust-tags.scm +26 -0
  31. package/dist/code-map/tree-sitter-queries/tree-sitter-typescript-tags.scm +15 -0
  32. package/dist/code-map/tsconfig.tsbuildinfo +1 -0
  33. package/dist/common/actions.d.ts +1062 -0
  34. package/dist/common/actions.js +180 -0
  35. package/dist/common/actions.js.map +1 -0
  36. package/dist/common/billing/quota-manager.d.ts +59 -0
  37. package/dist/common/billing/quota-manager.js +200 -0
  38. package/dist/common/billing/quota-manager.js.map +1 -0
  39. package/dist/common/constants.d.ts +24 -0
  40. package/dist/common/constants.js +73 -0
  41. package/dist/common/constants.js.map +1 -0
  42. package/dist/common/db/drizzle.config.d.ts +2 -0
  43. package/dist/common/db/drizzle.config.js +17 -0
  44. package/dist/common/db/drizzle.config.js.map +1 -0
  45. package/dist/common/db/env.d.mts +1 -0
  46. package/dist/common/db/env.mjs +26 -0
  47. package/dist/common/db/env.mjs.map +1 -0
  48. package/dist/common/db/index.d.ts +6 -0
  49. package/dist/common/db/index.js +35 -0
  50. package/dist/common/db/index.js.map +1 -0
  51. package/dist/common/db/schema.d.ts +994 -0
  52. package/dist/common/db/schema.js +113 -0
  53. package/dist/common/db/schema.js.map +1 -0
  54. package/dist/common/env.d.mts +1 -0
  55. package/dist/common/env.mjs +34 -0
  56. package/dist/common/env.mjs.map +1 -0
  57. package/dist/common/project-file-tree.d.ts +9 -0
  58. package/dist/common/project-file-tree.js +157 -0
  59. package/dist/common/project-file-tree.js.map +1 -0
  60. package/dist/common/types/referral.d.ts +2 -0
  61. package/dist/common/types/referral.js +5 -0
  62. package/dist/common/types/referral.js.map +1 -0
  63. package/dist/common/types/usage.d.ts +21 -0
  64. package/dist/common/types/usage.js +12 -0
  65. package/dist/common/types/usage.js.map +1 -0
  66. package/dist/common/util/__tests__/string.test.d.ts +1 -0
  67. package/dist/common/util/__tests__/string.test.js +83 -0
  68. package/dist/common/util/__tests__/string.test.js.map +1 -0
  69. package/dist/common/util/array.d.ts +6 -0
  70. package/dist/common/util/array.js +32 -0
  71. package/dist/common/util/array.js.map +1 -0
  72. package/dist/common/util/changes.d.ts +6 -0
  73. package/dist/common/util/changes.js +72 -0
  74. package/dist/common/util/changes.js.map +1 -0
  75. package/dist/common/util/credentials.d.ts +25 -0
  76. package/dist/common/util/credentials.js +24 -0
  77. package/dist/common/util/credentials.js.map +1 -0
  78. package/dist/common/util/dates.d.ts +1 -0
  79. package/dist/common/util/dates.js +13 -0
  80. package/dist/common/util/dates.js.map +1 -0
  81. package/dist/common/util/file.d.ts +106 -0
  82. package/dist/common/util/file.js +138 -0
  83. package/dist/common/util/file.js.map +1 -0
  84. package/dist/common/util/git.d.ts +4 -0
  85. package/dist/common/util/git.js +40 -0
  86. package/dist/common/util/git.js.map +1 -0
  87. package/dist/common/util/helpers.d.ts +1 -0
  88. package/dist/common/util/helpers.js +6 -0
  89. package/dist/common/util/helpers.js.map +1 -0
  90. package/dist/common/util/object.d.ts +18 -0
  91. package/dist/common/util/object.js +91 -0
  92. package/dist/common/util/object.js.map +1 -0
  93. package/dist/common/util/patch.d.ts +1 -0
  94. package/dist/common/util/patch.js +215 -0
  95. package/dist/common/util/patch.js.map +1 -0
  96. package/dist/common/util/promise.d.ts +1 -0
  97. package/dist/common/util/promise.js +33 -0
  98. package/dist/common/util/promise.js.map +1 -0
  99. package/dist/common/util/referral.d.ts +1 -0
  100. package/dist/common/util/referral.js +6 -0
  101. package/dist/common/util/referral.js.map +1 -0
  102. package/dist/common/util/server/referral.d.ts +14 -0
  103. package/dist/common/util/server/referral.js +85 -0
  104. package/dist/common/util/server/referral.js.map +1 -0
  105. package/dist/common/util/string.d.ts +3 -0
  106. package/dist/common/util/string.js +60 -0
  107. package/dist/common/util/string.js.map +1 -0
  108. package/dist/common/util/stripe.d.ts +2 -0
  109. package/dist/common/util/stripe.js +19 -0
  110. package/dist/common/util/stripe.js.map +1 -0
  111. package/dist/common/util/tools.d.ts +2 -0
  112. package/dist/common/util/tools.js +13 -0
  113. package/dist/common/util/tools.js.map +1 -0
  114. package/dist/common/websockets/websocket-client.d.ts +40 -0
  115. package/dist/common/websockets/websocket-client.js +187 -0
  116. package/dist/common/websockets/websocket-client.js.map +1 -0
  117. package/dist/common/websockets/websocket-schema.d.ts +2530 -0
  118. package/dist/common/websockets/websocket-schema.js +55 -0
  119. package/dist/common/websockets/websocket-schema.js.map +1 -0
  120. package/dist/config.d.ts +2 -0
  121. package/dist/config.js +8 -0
  122. package/dist/config.js.map +1 -0
  123. package/dist/credentials.d.ts +3 -0
  124. package/dist/credentials.js +33 -0
  125. package/dist/credentials.js.map +1 -0
  126. package/dist/fingerprint.d.ts +1 -0
  127. package/dist/fingerprint.js +43 -0
  128. package/dist/fingerprint.js.map +1 -0
  129. package/dist/index.d.ts +2 -0
  130. package/dist/index.js +50 -0
  131. package/dist/index.js.map +1 -0
  132. package/dist/manifold-api.d.ts +8 -0
  133. package/dist/manifold-api.js +32 -0
  134. package/dist/manifold-api.js.map +1 -0
  135. package/dist/menu.d.ts +1 -0
  136. package/dist/menu.js +92 -0
  137. package/dist/menu.js.map +1 -0
  138. package/dist/project-files.d.ts +48 -0
  139. package/dist/project-files.js +324 -0
  140. package/dist/project-files.js.map +1 -0
  141. package/dist/tool-handlers.d.ts +11 -0
  142. package/dist/tool-handlers.js +131 -0
  143. package/dist/tool-handlers.js.map +1 -0
  144. package/dist/update-manicode.d.ts +1 -0
  145. package/dist/update-manicode.js +151 -0
  146. package/dist/update-manicode.js.map +1 -0
  147. package/dist/web-scraper.d.ts +3 -0
  148. package/dist/web-scraper.js +79 -0
  149. package/dist/web-scraper.js.map +1 -0
  150. package/dist/worker-script-project-context.d.ts +1 -0
  151. package/dist/worker-script-project-context.js +13 -0
  152. package/dist/worker-script-project-context.js.map +1 -0
  153. package/package.json +62 -0
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.getLanguageConfig = getLanguageConfig;
30
+ const fs = __importStar(require("fs"));
31
+ const path = __importStar(require("path"));
32
+ const tree_sitter_1 = __importDefault(require("tree-sitter"));
33
+ const tree_sitter_2 = require("tree-sitter");
34
+ const parse_1 = require("./parse");
35
+ const languageConfigs = [
36
+ {
37
+ extensions: ['.ts'],
38
+ queryFile: 'tree-sitter-typescript-tags.scm',
39
+ packageName: 'tree-sitter-typescript',
40
+ },
41
+ {
42
+ extensions: ['.tsx'],
43
+ queryFile: 'tree-sitter-typescript-tags.scm',
44
+ packageName: 'tree-sitter-typescript',
45
+ },
46
+ {
47
+ extensions: ['.js', '.jsx'],
48
+ queryFile: 'tree-sitter-javascript-tags.scm',
49
+ packageName: 'tree-sitter-javascript',
50
+ },
51
+ {
52
+ extensions: ['.py'],
53
+ queryFile: 'tree-sitter-python-tags.scm',
54
+ packageName: 'tree-sitter-python',
55
+ },
56
+ {
57
+ extensions: ['.java'],
58
+ queryFile: 'tree-sitter-java-tags.scm',
59
+ packageName: 'tree-sitter-java',
60
+ },
61
+ {
62
+ extensions: ['.cs'],
63
+ queryFile: 'tree-sitter-c_sharp-tags.scm',
64
+ packageName: 'tree-sitter-c-sharp',
65
+ },
66
+ {
67
+ extensions: ['.c', '.h'],
68
+ queryFile: 'tree-sitter-c-tags.scm',
69
+ packageName: 'tree-sitter-c',
70
+ },
71
+ {
72
+ extensions: ['.cpp', '.hpp'],
73
+ queryFile: 'tree-sitter-cpp-tags.scm',
74
+ packageName: 'tree-sitter-cpp',
75
+ },
76
+ {
77
+ extensions: ['.rs'],
78
+ queryFile: 'tree-sitter-rust-tags.scm',
79
+ packageName: 'tree-sitter-rust',
80
+ },
81
+ {
82
+ extensions: ['.rb'],
83
+ queryFile: 'tree-sitter-ruby-tags.scm',
84
+ packageName: 'tree-sitter-ruby',
85
+ },
86
+ {
87
+ extensions: ['.go'],
88
+ queryFile: 'tree-sitter-go-tags.scm',
89
+ packageName: 'tree-sitter-go',
90
+ },
91
+ {
92
+ extensions: ['.php'],
93
+ queryFile: 'tree-sitter-php-tags.scm',
94
+ packageName: 'tree-sitter-php',
95
+ },
96
+ ];
97
+ async function getLanguageConfig(filePath) {
98
+ const extension = path.extname(filePath);
99
+ const config = languageConfigs.find((config) => config.extensions.includes(extension));
100
+ if (!config)
101
+ return undefined;
102
+ if (!config.parser) {
103
+ const parser = new tree_sitter_1.default();
104
+ try {
105
+ const languageModule = await Promise.resolve(`${config.packageName}`).then(s => __importStar(require(s)));
106
+ const language = extension === '.ts'
107
+ ? languageModule.typescript
108
+ : extension === '.tsx'
109
+ ? languageModule.tsx
110
+ : extension === '.php'
111
+ ? languageModule.php
112
+ : languageModule;
113
+ parser.setLanguage(language);
114
+ const queryFilePath = path.join(__dirname, 'tree-sitter-queries', config.queryFile);
115
+ const queryString = fs.readFileSync(queryFilePath, 'utf8');
116
+ config.query = new tree_sitter_2.Query(parser.getLanguage(), queryString);
117
+ config.parser = parser;
118
+ config.language = language;
119
+ }
120
+ catch (e) {
121
+ if (parse_1.DEBUG_PARSING) {
122
+ console.log('error', filePath, e);
123
+ }
124
+ return undefined;
125
+ }
126
+ }
127
+ return config;
128
+ }
129
+ //# sourceMappingURL=languages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languages.js","sourceRoot":"","sources":["../languages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA,8CA0CC;AA1HD,uCAAwB;AACxB,2CAA4B;AAC5B,8DAAgC;AAChC,6CAAmC;AAEnC,mCAAuC;AAWvC,MAAM,eAAe,GACnB;IACE;QACE,UAAU,EAAE,CAAC,KAAK,CAAC;QACnB,SAAS,EAAE,iCAAiC;QAC5C,WAAW,EAAE,wBAAwB;KACtC;IACD;QACE,UAAU,EAAE,CAAC,MAAM,CAAC;QACpB,SAAS,EAAE,iCAAiC;QAC5C,WAAW,EAAE,wBAAwB;KACtC;IACD;QACE,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;QAC3B,SAAS,EAAE,iCAAiC;QAC5C,WAAW,EAAE,wBAAwB;KACtC;IACD;QACE,UAAU,EAAE,CAAC,KAAK,CAAC;QACnB,SAAS,EAAE,6BAA6B;QACxC,WAAW,EAAE,oBAAoB;KAClC;IACD;QACE,UAAU,EAAE,CAAC,OAAO,CAAC;QACrB,SAAS,EAAE,2BAA2B;QACtC,WAAW,EAAE,kBAAkB;KAChC;IACD;QACE,UAAU,EAAE,CAAC,KAAK,CAAC;QACnB,SAAS,EAAE,8BAA8B;QACzC,WAAW,EAAE,qBAAqB;KACnC;IACD;QACE,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;QACxB,SAAS,EAAE,wBAAwB;QACnC,WAAW,EAAE,eAAe;KAC7B;IACD;QACE,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,0BAA0B;QACrC,WAAW,EAAE,iBAAiB;KAC/B;IACD;QACE,UAAU,EAAE,CAAC,KAAK,CAAC;QACnB,SAAS,EAAE,2BAA2B;QACtC,WAAW,EAAE,kBAAkB;KAChC;IACD;QAC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AAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;YAC1D,MAAM,CAAC,KAAK,GAAG,IAAI,mBAAK,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,CAAA;YAC3D,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;YACtB,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAC5B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,qBAAa,EAAE,CAAC;gBAClB,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;YACnC,CAAC;YACD,OAAO,SAAS,CAAA;QAClB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare const DEBUG_PARSING = false;
2
+ export declare function getFileTokenScores(projectRoot: string, filePaths: string[]): Promise<{
3
+ [filePath: string]: {
4
+ [token: string]: number;
5
+ };
6
+ }>;
7
+ export declare function parseTokens(filePath: string): Promise<{
8
+ numLines: number;
9
+ identifiers: string[];
10
+ calls: string[];
11
+ }>;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.DEBUG_PARSING = void 0;
27
+ exports.getFileTokenScores = getFileTokenScores;
28
+ exports.parseTokens = parseTokens;
29
+ const fs = __importStar(require("fs"));
30
+ const path = __importStar(require("path"));
31
+ const languages_1 = require("./languages");
32
+ exports.DEBUG_PARSING = false;
33
+ const IGNORE_TOKENS = ['__init__', '__post_init__', '__call__', 'constructor'];
34
+ async function getFileTokenScores(projectRoot, filePaths) {
35
+ const startTime = Date.now();
36
+ const tokenScores = {};
37
+ const externalCalls = {};
38
+ for (const filePath of filePaths) {
39
+ const fullPath = path.join(projectRoot, filePath);
40
+ if (!!(0, languages_1.getLanguageConfig)(fullPath)) {
41
+ const { identifiers, calls, numLines } = await parseTokens(fullPath);
42
+ const tokenScoresForFile = {};
43
+ tokenScores[filePath] = tokenScoresForFile;
44
+ const dirs = path.dirname(fullPath).split(path.sep);
45
+ const depth = dirs.length;
46
+ const tokenBaseScore = 0.8 ** depth * Math.sqrt(numLines / (identifiers.length + 1));
47
+ for (const identifier of identifiers) {
48
+ if (!IGNORE_TOKENS.includes(identifier)) {
49
+ tokenScoresForFile[identifier] = tokenBaseScore;
50
+ }
51
+ }
52
+ for (const call of calls) {
53
+ if (!tokenScoresForFile[call]) {
54
+ externalCalls[call] = (externalCalls[call] ?? 0) + 1;
55
+ }
56
+ }
57
+ }
58
+ }
59
+ for (const scores of Object.values(tokenScores)) {
60
+ for (const token of Object.keys(scores)) {
61
+ const numCalls = externalCalls[token] ?? 0;
62
+ if (typeof numCalls !== 'number')
63
+ continue;
64
+ scores[token] *= 1 + Math.log(1 + numCalls);
65
+ }
66
+ }
67
+ if (exports.DEBUG_PARSING) {
68
+ const endTime = Date.now();
69
+ console.log(`Parsed ${filePaths.length} files in ${endTime - startTime}ms`);
70
+ console.log('externalCalls', externalCalls);
71
+ // Save exportedTokens to a file
72
+ const exportedTokensFilePath = path.join(projectRoot, 'exported-tokens.json');
73
+ try {
74
+ fs.writeFileSync(exportedTokensFilePath, JSON.stringify(tokenScores, null, 2));
75
+ console.log(`Exported tokens saved to ${exportedTokensFilePath}`);
76
+ }
77
+ catch (error) {
78
+ console.error(`Failed to save exported tokens to file: ${error}`);
79
+ }
80
+ }
81
+ return tokenScores;
82
+ }
83
+ async function parseTokens(filePath) {
84
+ const languageConfig = await (0, languages_1.getLanguageConfig)(filePath);
85
+ if (languageConfig) {
86
+ const { parser, query } = languageConfig;
87
+ try {
88
+ const sourceCode = fs.readFileSync(filePath, 'utf8');
89
+ const numLines = sourceCode.match(/\n/g)?.length ?? 0 + 1;
90
+ const parseResults = parseFile(parser, query, sourceCode);
91
+ const identifiers = parseResults.identifier;
92
+ const calls = parseResults['call.identifier'];
93
+ return {
94
+ numLines,
95
+ identifiers: identifiers ?? [],
96
+ calls: calls ?? [],
97
+ };
98
+ }
99
+ catch (e) {
100
+ if (exports.DEBUG_PARSING) {
101
+ console.error(`Error parsing query: ${e}`);
102
+ console.log(filePath);
103
+ }
104
+ }
105
+ }
106
+ return {
107
+ numLines: 0,
108
+ identifiers: [],
109
+ calls: [],
110
+ };
111
+ }
112
+ function parseFile(parser, query, sourceCode) {
113
+ const tree = parser.parse(sourceCode, undefined, {
114
+ bufferSize: 1024 * 1024,
115
+ });
116
+ const captures = query.captures(tree.rootNode);
117
+ const result = {};
118
+ for (const capture of captures) {
119
+ const { name, node } = capture;
120
+ if (!result[name]) {
121
+ result[name] = [];
122
+ }
123
+ result[name].push(node.text);
124
+ }
125
+ return result;
126
+ }
127
+ //# sourceMappingURL=parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../parse.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AASA,gDA8DC;AAED,kCA4BC;AArGD,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,KAAK,CAAC,UAAU,EAAE,SAAS,EAAE;QAC/C,UAAU,EAAE,IAAI,GAAG,IAAI;KACxB,CAAC,CAAA;IACF,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC9C,MAAM,MAAM,GAAgC,EAAE,CAAA;IAE9C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;QAC9B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAClB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;QACnB,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,11 @@
1
+ interface Greeter {
2
+ greet(name: string): string;
3
+ }
4
+ declare class Greeting implements Greeter {
5
+ private prefix;
6
+ constructor(prefix: string);
7
+ greet(name: string): string;
8
+ static printGreeting(greeter: Greeter, name: string): void;
9
+ }
10
+ declare function createGreeter(prefix: string): Greeter;
11
+ declare const greeting: Greeter;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ // Class implementation
3
+ class Greeting {
4
+ prefix;
5
+ constructor(prefix) {
6
+ this.prefix = prefix;
7
+ }
8
+ greet(name) {
9
+ return `${this.prefix}, ${name}!`;
10
+ }
11
+ // Static method
12
+ static printGreeting(greeter, name) {
13
+ console.log(greeter.greet(name));
14
+ }
15
+ }
16
+ // Function
17
+ function createGreeter(prefix) {
18
+ return new Greeting(prefix);
19
+ }
20
+ // Main execution
21
+ const greeting = createGreeter('Hello');
22
+ Greeting.printGreeting(greeting, 'World');
23
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../../test-langs/test.ts"],"names":[],"mappings":";AAKA,uBAAuB;AACvB,MAAM,QAAQ;IACF,MAAM,CAAS;IAEvB,YAAY,MAAc;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAY;QACd,OAAO,GAAG,IAAI,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC;IACtC,CAAC;IAED,gBAAgB;IAChB,MAAM,CAAC,aAAa,CAAC,OAAgB,EAAE,IAAY;QAC/C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACrC,CAAC;CACJ;AAED,WAAW;AACX,SAAS,aAAa,CAAC,MAAc;IACjC,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,iBAAiB;AACjB,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;AACxC,QAAQ,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ # Credits
2
+
3
+ Manicode uses modified versions of the tags.scm files from these open source tree-sitter language implementations:
4
+
5
+ * [https://github.com/tree-sitter/tree-sitter-c](https://github.com/tree-sitter/tree-sitter-c) — licensed under the MIT License.
6
+ * [https://github.com/tree-sitter/tree-sitter-c-sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) — licensed under the MIT License.
7
+ * [https://github.com/tree-sitter/tree-sitter-cpp](https://github.com/tree-sitter/tree-sitter-cpp) — licensed under the MIT License.
8
+ * [https://github.com/Wilfred/tree-sitter-elisp](https://github.com/Wilfred/tree-sitter-elisp) — licensed under the MIT License.
9
+ * [https://github.com/elixir-lang/tree-sitter-elixir](https://github.com/elixir-lang/tree-sitter-elixir) — licensed under the Apache License, Version 2.0.
10
+ * [https://github.com/elm-tooling/tree-sitter-elm](https://github.com/elm-tooling/tree-sitter-elm) — licensed under the MIT License.
11
+ * [https://github.com/tree-sitter/tree-sitter-go](https://github.com/tree-sitter/tree-sitter-go) — licensed under the MIT License.
12
+ * [https://github.com/tree-sitter/tree-sitter-java](https://github.com/tree-sitter/tree-sitter-java) — licensed under the MIT License.
13
+ * [https://github.com/tree-sitter/tree-sitter-javascript](https://github.com/tree-sitter/tree-sitter-javascript) — licensed under the MIT License.
14
+ * [https://github.com/tree-sitter/tree-sitter-ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) — licensed under the MIT License.
15
+ * [https://github.com/tree-sitter/tree-sitter-php](https://github.com/tree-sitter/tree-sitter-php) — licensed under the MIT License.
16
+ * [https://github.com/tree-sitter/tree-sitter-python](https://github.com/tree-sitter/tree-sitter-python) — licensed under the MIT License.
17
+ * [https://github.com/tree-sitter/tree-sitter-ql](https://github.com/tree-sitter/tree-sitter-ql) — licensed under the MIT License.
18
+ * [https://github.com/r-lib/tree-sitter-r](https://github.com/r-lib/tree-sitter-r) — licensed under the MIT License.
19
+ * [https://github.com/tree-sitter/tree-sitter-ruby](https://github.com/tree-sitter/tree-sitter-ruby) — licensed under the MIT License.
20
+ * [https://github.com/tree-sitter/tree-sitter-rust](https://github.com/tree-sitter/tree-sitter-rust) — licensed under the MIT License.
21
+ * [https://github.com/tree-sitter/tree-sitter-typescript](https://github.com/tree-sitter/tree-sitter-typescript) — licensed under the MIT License.
22
+
23
+ This collection of queries was originally put together in the project aider: https://github.com/paul-gauthier/aider/tree/main/aider/queries
@@ -0,0 +1,11 @@
1
+ (struct_specifier name: (type_identifier) @identifier body:(_))
2
+
3
+ (declaration type: (union_specifier name: (type_identifier) @identifier))
4
+
5
+ (function_declarator declarator: (identifier) @identifier)
6
+
7
+ (type_definition declarator: (type_identifier) @identifier)
8
+
9
+ (enum_specifier name: (type_identifier) @identifier)
10
+
11
+ ; TODO add calls
@@ -0,0 +1,13 @@
1
+ (class_declaration
2
+ name: (identifier) @identifier
3
+ )
4
+
5
+ (interface_declaration
6
+ name: (identifier) @identifier
7
+ )
8
+
9
+ (method_declaration
10
+ name: (identifier) @identifier
11
+ )
12
+
13
+ ; TODO add calls
@@ -0,0 +1,17 @@
1
+ (struct_specifier name: (type_identifier) @identifier)
2
+
3
+ (declaration type: (union_specifier name: (type_identifier) @identifier))
4
+
5
+ (function_declarator declarator: (identifier) @identifier)
6
+
7
+ (function_declarator declarator: (field_identifier) @identifier)
8
+
9
+ (function_declarator declarator: (qualified_identifier scope: (namespace_identifier) name: (identifier) @identifier))
10
+
11
+ (type_definition declarator: (type_identifier) @identifier)
12
+
13
+ (enum_specifier name: (type_identifier) @identifier)
14
+
15
+ (class_specifier name: (type_identifier) @identifier)
16
+
17
+ ; TODO add calls
@@ -0,0 +1,26 @@
1
+ (
2
+ (comment)*
3
+ .
4
+ (function_declaration
5
+ name: (identifier) @identifier)
6
+ )
7
+
8
+ (
9
+ (comment)*
10
+ .
11
+ (method_declaration
12
+ name: (field_identifier) @identifier)
13
+ )
14
+
15
+ (type_spec
16
+ name: (type_identifier) @identifier)
17
+
18
+ (type_identifier) @identifier
19
+
20
+ (call_expression
21
+ function: [
22
+ (identifier) @call.identifier
23
+ (parenthesized_expression (identifier) @call.identifier)
24
+ (selector_expression field: (field_identifier) @call.identifier)
25
+ (parenthesized_expression (selector_expression field: (field_identifier) @call.identifier))
26
+ ])
@@ -0,0 +1,19 @@
1
+ (class_declaration
2
+ name: (identifier) @identifier)
3
+
4
+ (interface_declaration
5
+ name: (identifier) @identifier) @definition.interface
6
+
7
+ (method_declaration
8
+ name: (identifier) @identifier)
9
+
10
+ (method_invocation
11
+ name: (identifier) @call.identifier)
12
+
13
+ (type_list
14
+ (type_identifier) @call.identifier)
15
+
16
+ (object_creation_expression
17
+ type: (type_identifier) @call.identifier)
18
+
19
+ (superclass (type_identifier) @call.identifier)
@@ -0,0 +1,15 @@
1
+ (function_declaration name: (identifier) @identifier)
2
+ (class_declaration name: (identifier) @identifier)
3
+ (method_definition name: (property_identifier) @identifier)
4
+
5
+ (export_statement
6
+ declaration: (lexical_declaration
7
+ (variable_declarator
8
+ name: (identifier) @identifier)))
9
+ (export_statement
10
+ declaration: (variable_declaration
11
+ (variable_declarator
12
+ name: (identifier) @identifier)))
13
+
14
+ (call_expression function: (identifier) @call.identifier)
15
+ (new_expression constructor: (identifier) @call.identifier)
@@ -0,0 +1,26 @@
1
+ (class_declaration
2
+ name: (name) @identifier)
3
+
4
+ (function_definition
5
+ name: (name) @identifier)
6
+
7
+ (method_declaration
8
+ name: (name) @identifier)
9
+
10
+ (object_creation_expression
11
+ [
12
+ (qualified_name (name) @call.identifier)
13
+ (variable_name (name) @call.identifier)
14
+ ])
15
+
16
+ (function_call_expression
17
+ function: [
18
+ (qualified_name (name) @call.identifier)
19
+ (variable_name (name)) @call.identifier
20
+ ])
21
+
22
+ (scoped_call_expression
23
+ name: (name) @call.identifier)
24
+
25
+ (member_call_expression
26
+ name: (name) @call.identifier)
@@ -0,0 +1,9 @@
1
+ (class_definition "class"
2
+ name: (identifier) @identifier)
3
+
4
+ (function_definition
5
+ name: (identifier) @identifier)
6
+
7
+ (call
8
+ function: (identifier) @call.identifier)
9
+
@@ -0,0 +1,58 @@
1
+ ; Method definitions
2
+
3
+ (
4
+ [
5
+ (method
6
+ name: (_) @identifier)
7
+ (singleton_method
8
+ name: (_) @identifier)
9
+ ]
10
+ )
11
+
12
+ (alias
13
+ name: (_) @identifier)
14
+
15
+ ; (setter
16
+ ; (identifier) @identifier)
17
+
18
+ ; Class definitions
19
+
20
+ (
21
+ (comment)*
22
+ .
23
+ [
24
+ (class
25
+ name: [
26
+ (constant) @identifier
27
+ (scope_resolution
28
+ name: (_) @identifier)
29
+ ])
30
+ (singleton_class
31
+ value: [
32
+ (constant) @identifier
33
+ (scope_resolution
34
+ name: (_) @identifier)
35
+ ])
36
+ ]
37
+ )
38
+
39
+ ; Module definitions
40
+
41
+ (
42
+ (module
43
+ name: [
44
+ (constant) @identifier
45
+ (scope_resolution
46
+ name: (_) @identifier)
47
+ ])
48
+ )
49
+
50
+ ; Calls
51
+
52
+ (call method: (identifier) @call.identifier)
53
+
54
+ (
55
+ [(identifier) (constant)] @call.identifier
56
+ (#is-not? local)
57
+ (#not-match? @call.identifier "^(lambda|load|require|require_relative|__FILE__|__LINE__)$")
58
+ )
@@ -0,0 +1,26 @@
1
+ (struct_item name: (type_identifier) @identifier)
2
+ (enum_item name: (type_identifier) @identifier)
3
+ (union_item name: (type_identifier) @identifier)
4
+ (type_item name: (type_identifier) @identifier)
5
+ (trait_item name: (type_identifier) @identifier)
6
+ (function_item name: (identifier) @identifier)
7
+ (macro_definition name: (identifier) @identifier)
8
+ (mod_item name: (identifier) @identifier)
9
+ (const_item name: (identifier) @identifier)
10
+ (static_item name: (identifier) @identifier)
11
+
12
+ ; Function and macro calls
13
+ (call_expression function: (identifier) @call.identifier)
14
+ (call_expression function: (field_expression field: (field_identifier) @call.identifier))
15
+ (macro_invocation macro: (identifier) @call.identifier)
16
+
17
+ ; Struct instantiation
18
+ (struct_expression (type_identifier) @call.identifier)
19
+
20
+ ; Enum variant usage
21
+ (scoped_identifier path: (identifier) name: (identifier) @call.identifier)
22
+
23
+ ; implementations
24
+
25
+ (impl_item trait: (type_identifier) @call.identifier)
26
+ (impl_item type: (type_identifier) @call.identifier !trait)
@@ -0,0 +1,15 @@
1
+ (function_declaration name: (identifier) @identifier)
2
+ (class_declaration name: (type_identifier) @identifier)
3
+ (method_definition name: (property_identifier) @identifier)
4
+
5
+ (export_statement
6
+ declaration: (lexical_declaration
7
+ (variable_declarator
8
+ name: (identifier) @identifier)))
9
+ (export_statement
10
+ declaration: (variable_declaration
11
+ (variable_declarator
12
+ name: (identifier) @identifier)))
13
+
14
+ (call_expression function: (identifier) @call.identifier)
15
+ (new_expression constructor: (identifier) @call.identifier)