@lowgular/code-graph 0.0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/bin/cli.js +10 -0
  2. package/code-graph-v2/code.graph.js +37 -0
  3. package/code-graph-v2/config-from-query.js +131 -0
  4. package/code-graph-v2/extractors/extractor.js +27 -0
  5. package/code-graph-v2/extractors/index.js +1 -0
  6. package/code-graph-v2/graph-builder/code-graph.builder.js +49 -0
  7. package/code-graph-v2/graph-builder/index.js +1 -0
  8. package/code-graph-v2/graph-builder/node.processor.js +22 -0
  9. package/{libs/cli/code-graph/src/lib/v2 → code-graph-v2}/graph-builder/relationship.processor.js +11 -35
  10. package/code-graph-v2/graph-builder/type.processor.js +21 -0
  11. package/code-graph-v2/index.js +4 -0
  12. package/code-graph-v2/tools/build-code-graph.tool.js +19 -0
  13. package/code-graph-v2/utils.js +34 -0
  14. package/codegular/index.js +5 -0
  15. package/codegular/node.js +71 -0
  16. package/codegular/program.js +100 -0
  17. package/{libs/core/codegular/src/lib → codegular}/string.js +6 -53
  18. package/{libs/core/codegular/src/lib → codegular}/type-checker.js +3 -40
  19. package/codegular/type.js +356 -0
  20. package/{libs/core/codegular/src/lib → codegular}/utils.js +50 -62
  21. package/cypher/index.js +1 -0
  22. package/{libs/cli/cypher/src → cypher}/lib/executor/condition-evaluator.js +2 -25
  23. package/cypher/lib/executor/executor.js +60 -0
  24. package/cypher/lib/executor/graph.js +0 -0
  25. package/{libs/cli/cypher/src → cypher}/lib/executor/match-engine.js +4 -27
  26. package/{libs/cli/cypher/src → cypher}/lib/executor/pattern-matcher.js +2 -25
  27. package/{libs/cli/cypher/src → cypher}/lib/executor/relationship-navigator.js +2 -25
  28. package/{libs/cli/cypher/src → cypher}/lib/executor/result-formatter.js +37 -31
  29. package/{libs/cli/cypher/src → cypher}/lib/executor/traverse-engine.js +4 -27
  30. package/cypher/lib/executor/utils.js +14 -0
  31. package/cypher/lib/graph.stub.js +38 -0
  32. package/cypher/lib/index.js +32 -0
  33. package/{libs/cli/cypher/src → cypher}/lib/lexer.js +4 -26
  34. package/{libs/cli/cypher/src → cypher}/lib/parser.js +119 -135
  35. package/{libs/cli/cypher/src → cypher}/lib/validator/query-validator.js +12 -32
  36. package/{libs/cli/cypher/src → cypher}/lib/validator/supported-features.config.js +2 -30
  37. package/{libs/cli/cypher/src → cypher}/lib/validator/unsupported-features.config.js +8 -34
  38. package/cypher-cli.js +41 -0
  39. package/infra/code-graph.js +147 -0
  40. package/main.js +0 -43
  41. package/package.json +25 -7
  42. package/resources-cli.js +75 -0
  43. package/run-cli.js +43 -0
  44. package/apps/code-graph/src/main.js +0 -50
  45. package/libs/cli/code-graph/src/index.js +0 -39
  46. package/libs/cli/code-graph/src/lib/class-declarations/abstractions/service.js +0 -72
  47. package/libs/cli/code-graph/src/lib/class-declarations/abstractions/service.stateful.js +0 -68
  48. package/libs/cli/code-graph/src/lib/class-declarations/class-declarations.doc.js +0 -147
  49. package/libs/cli/code-graph/src/lib/class-declarations/class-declarations.graph.js +0 -55
  50. package/libs/cli/code-graph/src/lib/class-declarations/index.js +0 -27
  51. package/libs/cli/code-graph/src/lib/code.graph.factory.js +0 -63
  52. package/libs/cli/code-graph/src/lib/code.graph.js +0 -62
  53. package/libs/cli/code-graph/src/lib/core/core.js +0 -58
  54. package/libs/cli/code-graph/src/lib/core.js +0 -85
  55. package/libs/cli/code-graph/src/lib/decorators/index.js +0 -36
  56. package/libs/cli/code-graph/src/lib/docs/index.js +0 -21
  57. package/libs/cli/code-graph/src/lib/docs/specs.js +0 -36
  58. package/libs/cli/code-graph/src/lib/expressions/call-expressions.graph.js +0 -28
  59. package/libs/cli/code-graph/src/lib/fixtures/reactive-event-bus/src/app/examples.event-bus.js +0 -53
  60. package/libs/cli/code-graph/src/lib/method-declarations/index.js +0 -23
  61. package/libs/cli/code-graph/src/lib/method-declarations/method-declarations.doc.js +0 -106
  62. package/libs/cli/code-graph/src/lib/method-declarations/method-declarations.graph.js +0 -56
  63. package/libs/cli/code-graph/src/lib/parameters/index.js +0 -42
  64. package/libs/cli/code-graph/src/lib/property-declarations/abstractions/reactive-state.evals.js +0 -139
  65. package/libs/cli/code-graph/src/lib/property-declarations/abstractions/reactive-state.js +0 -104
  66. package/libs/cli/code-graph/src/lib/property-declarations/index.js +0 -25
  67. package/libs/cli/code-graph/src/lib/property-declarations/property-declarations.doc.js +0 -74
  68. package/libs/cli/code-graph/src/lib/property-declarations/property-declarations.graph.js +0 -43
  69. package/libs/cli/code-graph/src/lib/tools/index.js +0 -34
  70. package/libs/cli/code-graph/src/lib/tools/match-code-graph.tool.js +0 -64
  71. package/libs/cli/code-graph/src/lib/types/index.js +0 -99
  72. package/libs/cli/code-graph/src/lib/v2/extractors/extractor.doc.js +0 -345
  73. package/libs/cli/code-graph/src/lib/v2/extractors/extractor.js +0 -52
  74. package/libs/cli/code-graph/src/lib/v2/extractors/index.js +0 -23
  75. package/libs/cli/code-graph/src/lib/v2/graph-builder/code-graph.builder.js +0 -76
  76. package/libs/cli/code-graph/src/lib/v2/graph-builder/index.js +0 -21
  77. package/libs/cli/code-graph/src/lib/v2/graph-builder/node.processor.js +0 -48
  78. package/libs/cli/code-graph/src/lib/v2/graph-builder/type.processor.js +0 -45
  79. package/libs/cli/code-graph/src/lib/v2/index.js +0 -37
  80. package/libs/cli/code-graph/src/lib/v2/tools/build-code-graph.doc.js +0 -220
  81. package/libs/cli/code-graph/src/lib/v2/tools/build-code-graph.tool.js +0 -42
  82. package/libs/cli/cypher/src/index.js +0 -25
  83. package/libs/cli/cypher/src/lib/docs/features/advanced-optional-match.feature.js +0 -277
  84. package/libs/cli/cypher/src/lib/docs/features/anonymous-relationship.feature.js +0 -69
  85. package/libs/cli/cypher/src/lib/docs/features/anonymous-variable-length.feature.js +0 -105
  86. package/libs/cli/cypher/src/lib/docs/features/basic-filtering.feature.js +0 -70
  87. package/libs/cli/cypher/src/lib/docs/features/basic-optional-match.feature.js +0 -99
  88. package/libs/cli/cypher/src/lib/docs/features/basic-relationship.feature.js +0 -125
  89. package/libs/cli/cypher/src/lib/docs/features/index.js +0 -51
  90. package/libs/cli/cypher/src/lib/docs/features/limit.feature.js +0 -50
  91. package/libs/cli/cypher/src/lib/docs/features/match-nodes.feature.js +0 -106
  92. package/libs/cli/cypher/src/lib/docs/features/multiple-relationship-types.feature.js +0 -105
  93. package/libs/cli/cypher/src/lib/docs/features/order-by.feature.js +0 -143
  94. package/libs/cli/cypher/src/lib/docs/features/property-matching.feature.js +0 -152
  95. package/libs/cli/cypher/src/lib/docs/features/relationship-without-variable.feature.js +0 -48
  96. package/libs/cli/cypher/src/lib/docs/features/return-statement.feature.js +0 -65
  97. package/libs/cli/cypher/src/lib/docs/features/unidirected-relationship.feature.js +0 -82
  98. package/libs/cli/cypher/src/lib/docs/features/variable-length-path.feature.js +0 -136
  99. package/libs/cli/cypher/src/lib/docs/features/where-conditional.feature.js +0 -187
  100. package/libs/cli/cypher/src/lib/docs/features/where-operators.feature.js +0 -302
  101. package/libs/cli/cypher/src/lib/docs/prompts.js +0 -36
  102. package/libs/cli/cypher/src/lib/docs/specs.js +0 -181
  103. package/libs/cli/cypher/src/lib/executor/executor.js +0 -83
  104. package/libs/cli/cypher/src/lib/executor/graph.js +0 -15
  105. package/libs/cli/cypher/src/lib/executor/utils.js +0 -37
  106. package/libs/cli/cypher/src/lib/graph.stub.js +0 -63
  107. package/libs/cli/cypher/src/lib/index.js +0 -74
  108. package/libs/cli/shared/src/index.js +0 -53
  109. package/libs/cli/shared/src/lib/admin-token.js +0 -121
  110. package/libs/cli/shared/src/lib/config.js +0 -49
  111. package/libs/cli/shared/src/lib/consts.js +0 -57
  112. package/libs/cli/shared/src/lib/core.js +0 -46
  113. package/libs/cli/shared/src/lib/infrastructure/cli.js +0 -47
  114. package/libs/cli/shared/src/lib/infrastructure/config.js +0 -47
  115. package/libs/cli/shared/src/lib/infrastructure/config.reporitory.js +0 -51
  116. package/libs/cli/shared/src/lib/infrastructure/formatters/console-formatter.js +0 -96
  117. package/libs/cli/shared/src/lib/infrastructure/formatters/index.js +0 -41
  118. package/libs/cli/shared/src/lib/infrastructure/formatters/json-formatter.js +0 -64
  119. package/libs/cli/shared/src/lib/infrastructure/formatters/markdown-formatter.js +0 -120
  120. package/libs/cli/shared/src/lib/infrastructure/formatters/types.js +0 -15
  121. package/libs/cli/shared/src/lib/infrastructure/formatters/utils.js +0 -72
  122. package/libs/cli/shared/src/lib/infrastructure/git.js +0 -147
  123. package/libs/cli/shared/src/lib/infrastructure/http.js +0 -257
  124. package/libs/cli/shared/src/lib/infrastructure/markdown.js +0 -95
  125. package/libs/cli/shared/src/lib/infrastructure/transformers/embeddings.js +0 -88
  126. package/libs/cli/shared/src/lib/infrastructure/transformers/index.js +0 -25
  127. package/libs/cli/shared/src/lib/infrastructure/transformers/rag-eval.js +0 -154
  128. package/libs/cli/shared/src/lib/infrastructure/transformers/similarity.js +0 -210
  129. package/libs/cli/shared/src/lib/infrastructure/workspace.js +0 -297
  130. package/libs/cli/shared/src/lib/infrastructure/yaml.js +0 -237
  131. package/libs/cli/shared/src/lib/lowgular.config.js +0 -120
  132. package/libs/cli/shared/src/lib/token.js +0 -135
  133. package/libs/cli/shared/src/lib/utils/solution.util.js +0 -35
  134. package/libs/cli/shared/src/lib/utils/utils.js +0 -89
  135. package/libs/cli/typescript/src/index.js +0 -21
  136. package/libs/cli/typescript/src/lib/base/index.js +0 -23
  137. package/libs/cli/typescript/src/lib/base/nameable.js +0 -34
  138. package/libs/cli/typescript/src/lib/base/nodeable.js +0 -36
  139. package/libs/cli/typescript/src/lib/class.implementation.js +0 -52
  140. package/libs/cli/typescript/src/lib/core/declaration.registry.js +0 -107
  141. package/libs/cli/typescript/src/lib/core/design-pattern.js +0 -55
  142. package/libs/cli/typescript/src/lib/core/index.js +0 -35
  143. package/libs/cli/typescript/src/lib/core/navigable-declaration.js +0 -69
  144. package/libs/cli/typescript/src/lib/core/program-context.js +0 -71
  145. package/libs/cli/typescript/src/lib/core/syntax-kind.utils.js +0 -40
  146. package/libs/cli/typescript/src/lib/core/type.js +0 -374
  147. package/libs/cli/typescript/src/lib/declaration.abstraction.js +0 -90
  148. package/libs/cli/typescript/src/lib/decorator.implementation.js +0 -35
  149. package/libs/cli/typescript/src/lib/enum.implementation.js +0 -35
  150. package/libs/cli/typescript/src/lib/function-declaration.implementation.js +0 -35
  151. package/libs/cli/typescript/src/lib/index.js +0 -57
  152. package/libs/cli/typescript/src/lib/interface.implementation.js +0 -51
  153. package/libs/cli/typescript/src/lib/members/method-abstraction.resolver.js +0 -90
  154. package/libs/cli/typescript/src/lib/members/method-declaration.implementation.js +0 -44
  155. package/libs/cli/typescript/src/lib/members/method-signature.implementation.js +0 -46
  156. package/libs/cli/typescript/src/lib/members/method.util.js +0 -32
  157. package/libs/cli/typescript/src/lib/members/parameter.implementation.js +0 -38
  158. package/libs/cli/typescript/src/lib/members/property-declaration.implementation.js +0 -64
  159. package/libs/cli/typescript/src/lib/members/property-signature.implementation.js +0 -34
  160. package/libs/cli/typescript/src/lib/members/property.util.js +0 -61
  161. package/libs/cli/typescript/src/lib/members/statements/expressions/binary-expression.implementation.js +0 -42
  162. package/libs/cli/typescript/src/lib/members/statements/expressions/call-expression.implementation.js +0 -114
  163. package/libs/cli/typescript/src/lib/members/statements/expressions/expression.abstraction.js +0 -188
  164. package/libs/cli/typescript/src/lib/members/statements/expressions/property-access-expression.implementation.js +0 -35
  165. package/libs/cli/typescript/src/lib/members/statements/expressions/unary-expression.implementation.js +0 -51
  166. package/libs/cli/typescript/src/lib/members/statements/statement.implementation.js +0 -49
  167. package/libs/cli/typescript/src/lib/members/statements/utils.js +0 -51
  168. package/libs/cli/typescript/src/lib/plugins/built-in.plugin.js +0 -258
  169. package/libs/cli/typescript/src/lib/plugins/plugin.interface.js +0 -15
  170. package/libs/cli/typescript/src/lib/plugins/rxjs.plugin.js +0 -228
  171. package/libs/cli/typescript/src/lib/plugins/signal.plugin.js +0 -126
  172. package/libs/cli/typescript/src/lib/plugins/stubs.js +0 -66
  173. package/libs/cli/typescript/src/lib/type-alias.implementation.js +0 -72
  174. package/libs/cli/typescript/src/lib/utils.js +0 -39
  175. package/libs/cli/typescript/src/lib/variable-declaration.implementation.js +0 -35
  176. package/libs/core/codegular/src/index.js +0 -21
  177. package/libs/core/codegular/src/lib/index.js +0 -29
  178. package/libs/core/codegular/src/lib/node.js +0 -112
  179. package/libs/core/codegular/src/lib/program.js +0 -92
@@ -1,96 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var console_formatter_exports = {};
19
- __export(console_formatter_exports, {
20
- ConsoleFormatter: () => ConsoleFormatter
21
- });
22
- module.exports = __toCommonJS(console_formatter_exports);
23
- var import_prompts = require("@clack/prompts");
24
- var import_utils = require("./utils.js");
25
- class ConsoleFormatter {
26
- format(abilityId, items) {
27
- if (items.length === 0) {
28
- return {
29
- message: `No items found for ability: ${abilityId}`
30
- };
31
- }
32
- import_prompts.log.info(`Found ${items.length} item(s) for ability: ${abilityId}
33
- `);
34
- items.forEach((item, index) => {
35
- import_prompts.log.info(`Item ${index + 1}:`);
36
- Object.entries(item).forEach(([key, value]) => {
37
- if (key === "comment")
38
- return;
39
- const formattedValue = this.formatValue(key, value);
40
- import_prompts.log.info(` ${(0, import_utils.capitalizeKey)(key)}: ${formattedValue}`);
41
- });
42
- if (item.comment) {
43
- import_prompts.log.info(` ${(0, import_utils.capitalizeKey)("comment")}:`);
44
- const commentLines = item.comment.split("\n");
45
- commentLines.forEach((line) => {
46
- import_prompts.log.info(` ${line}`);
47
- });
48
- }
49
- if (item.fileContent && item.startLine && item.endLine) {
50
- this.displayCodeContext(item);
51
- }
52
- import_prompts.log.info("");
53
- });
54
- return {
55
- message: `Successfully retrieved ${items.length} item(s) for ability: ${abilityId}`
56
- };
57
- }
58
- formatValue(key, value) {
59
- if (value === null || value === void 0) {
60
- return "N/A";
61
- }
62
- if ((0, import_utils.isDateField)(key, value)) {
63
- return new Date(value).toLocaleDateString();
64
- }
65
- if (key.toLowerCase().includes("correctness") && typeof value === "number") {
66
- return `${value}%`;
67
- }
68
- if (key === "startLine" && typeof value === "number") {
69
- return value.toString();
70
- }
71
- if (key === "endLine" && typeof value === "number") {
72
- return value.toString();
73
- }
74
- return String(value);
75
- }
76
- displayCodeContext(item) {
77
- if (!item.fileContent)
78
- return;
79
- const lines = item.fileContent.split("\n");
80
- const startLine = item.startLine || 1;
81
- const endLine = item.endLine || startLine;
82
- const contextStart = Math.max(0, startLine - 3);
83
- const contextEnd = Math.min(lines.length, endLine + 2);
84
- import_prompts.log.info(` Code context:`);
85
- for (let i = contextStart; i < contextEnd; i++) {
86
- const lineNum = i + 1;
87
- const isTarget = lineNum >= startLine && lineNum <= endLine;
88
- const prefix = isTarget ? ">>>" : " ";
89
- import_prompts.log.info(`${prefix} ${lineNum.toString().padStart(3)}: ${lines[i]}`);
90
- }
91
- }
92
- }
93
- // Annotate the CommonJS export names for ESM import in node:
94
- 0 && (module.exports = {
95
- ConsoleFormatter
96
- });
@@ -1,41 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var formatters_exports = {};
19
- __export(formatters_exports, {
20
- createFormatter: () => createFormatter
21
- });
22
- module.exports = __toCommonJS(formatters_exports);
23
- var import_console_formatter = require("./console-formatter.js");
24
- var import_json_formatter = require("./json-formatter.js");
25
- var import_markdown_formatter = require("./markdown-formatter.js");
26
- function createFormatter(type) {
27
- switch (type) {
28
- case "console":
29
- return new import_console_formatter.ConsoleFormatter();
30
- case "json":
31
- return new import_json_formatter.JsonFormatter();
32
- case "markdown":
33
- return new import_markdown_formatter.MarkdownFormatter();
34
- default:
35
- throw new Error(`Unknown formatter type: ${type}`);
36
- }
37
- }
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {
40
- createFormatter
41
- });
@@ -1,64 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var json_formatter_exports = {};
19
- __export(json_formatter_exports, {
20
- JsonFormatter: () => JsonFormatter
21
- });
22
- module.exports = __toCommonJS(json_formatter_exports);
23
- var import_fs = require("fs");
24
- var import_utils = require("./utils.js");
25
- class JsonFormatter {
26
- format(abilityId, items) {
27
- const fileName = `examples.${abilityId}.json`;
28
- const output = {
29
- abilityId,
30
- totalItems: items.length,
31
- items: items.map((item, index) => ({
32
- itemNumber: index + 1,
33
- ...this.formatItemForJson(item)
34
- })),
35
- generatedAt: (/* @__PURE__ */ new Date()).toISOString()
36
- };
37
- try {
38
- (0, import_fs.writeFileSync)(fileName, JSON.stringify(output, null, 2), "utf-8");
39
- return {
40
- message: `Successfully exported ${items.length} item(s) for ability: ${abilityId} to ${fileName}`
41
- };
42
- } catch (error) {
43
- throw new Error(
44
- `Failed to write JSON file: ${error instanceof Error ? error.message : "Unknown error"}`
45
- );
46
- }
47
- }
48
- formatItemForJson(item) {
49
- const formatted = {};
50
- Object.entries(item).forEach(([key, value]) => {
51
- if ((0, import_utils.isDateField)(key, value)) {
52
- formatted[key] = new Date(value).toISOString();
53
- formatted[`${key}Formatted`] = new Date(value).toLocaleDateString();
54
- } else {
55
- formatted[key] = value;
56
- }
57
- });
58
- return formatted;
59
- }
60
- }
61
- // Annotate the CommonJS export names for ESM import in node:
62
- 0 && (module.exports = {
63
- JsonFormatter
64
- });
@@ -1,120 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var markdown_formatter_exports = {};
19
- __export(markdown_formatter_exports, {
20
- MarkdownFormatter: () => MarkdownFormatter
21
- });
22
- module.exports = __toCommonJS(markdown_formatter_exports);
23
- var import_fs = require("fs");
24
- var import_utils = require("./utils.js");
25
- class MarkdownFormatter {
26
- format(abilityId, items) {
27
- const fileName = `examples.${abilityId}.md`;
28
- if (items.length === 0) {
29
- const content2 = `# Items for Ability: ${abilityId}
30
-
31
- No items found for this ability.
32
-
33
- _Generated on ${(/* @__PURE__ */ new Date()).toLocaleDateString()}_
34
- `;
35
- (0, import_fs.writeFileSync)(fileName, content2, "utf-8");
36
- return {
37
- message: `No items found for ability: ${abilityId} - created empty ${fileName}`
38
- };
39
- }
40
- let content = `# Items for Ability: ${abilityId}
41
-
42
- `;
43
- content += `Found ${items.length} item(s) for this ability.
44
-
45
- `;
46
- items.forEach((item, index) => {
47
- content += `## Item ${index + 1}
48
-
49
- `;
50
- Object.entries(item).forEach(([key, value]) => {
51
- if (key === "fileContent" || key === "comment")
52
- return;
53
- const formattedValue = this.formatValueForMarkdown(key, value);
54
- const readableKey = (0, import_utils.capitalizeKey)(key);
55
- content += `- **${readableKey}**: ${formattedValue}
56
- `;
57
- });
58
- if (item.comment) {
59
- content += `- **Comment**: ${item.comment}
60
- `;
61
- }
62
- content += "\n";
63
- if (item.fileContent) {
64
- content = this.addFullFileContent(content, item);
65
- }
66
- content += `---
67
-
68
- `;
69
- });
70
- content += `_Generated on ${(/* @__PURE__ */ new Date()).toLocaleDateString()}_
71
- `;
72
- try {
73
- (0, import_fs.writeFileSync)(fileName, content, "utf-8");
74
- return {
75
- message: `Successfully exported ${items.length} item(s) for ability: ${abilityId} to ${fileName}`
76
- };
77
- } catch (error) {
78
- throw new Error(
79
- `Failed to write markdown file: ${error instanceof Error ? error.message : "Unknown error"}`
80
- );
81
- }
82
- }
83
- formatValueForMarkdown(key, value) {
84
- if (value === null || value === void 0) {
85
- return "N/A";
86
- }
87
- if ((0, import_utils.isDateField)(key, value)) {
88
- return new Date(value).toLocaleDateString();
89
- }
90
- if (key.toLowerCase().includes("correctness") && typeof value === "number") {
91
- return `${value}%`;
92
- }
93
- if (key.toLowerCase().includes("path") || key.toLowerCase().includes("file")) {
94
- return `\`${value}\``;
95
- }
96
- return String(value);
97
- }
98
- addFullFileContent(content, item) {
99
- if (!item.fileContent)
100
- return content;
101
- const filePath = item.filePath || item.file || "";
102
- const extension = filePath.split(".").pop() || "";
103
- const language = (0, import_utils.getLanguageFromExtension)(extension);
104
- content += `### Full File Content
105
-
106
- `;
107
- content += `\`\`\`${language}
108
- `;
109
- content += item.fileContent;
110
- content += `
111
- \`\`\`
112
-
113
- `;
114
- return content;
115
- }
116
- }
117
- // Annotate the CommonJS export names for ESM import in node:
118
- 0 && (module.exports = {
119
- MarkdownFormatter
120
- });
@@ -1,15 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var types_exports = {};
15
- module.exports = __toCommonJS(types_exports);
@@ -1,72 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var utils_exports = {};
19
- __export(utils_exports, {
20
- capitalizeKey: () => capitalizeKey,
21
- getLanguageFromExtension: () => getLanguageFromExtension,
22
- isDateField: () => isDateField
23
- });
24
- module.exports = __toCommonJS(utils_exports);
25
- function isDateField(key, value) {
26
- const dateKeyPatterns = ["date", "time", "created", "updated", "modified"];
27
- const keyLower = key.toLowerCase();
28
- const hasDateKeyword = dateKeyPatterns.some(
29
- (pattern) => keyLower.includes(pattern)
30
- );
31
- if (!hasDateKeyword)
32
- return false;
33
- const date = new Date(value);
34
- return !isNaN(date.getTime());
35
- }
36
- function capitalizeKey(key) {
37
- return key.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase());
38
- }
39
- function getLanguageFromExtension(extension) {
40
- const languageMap = {
41
- ts: "typescript",
42
- tsx: "typescript",
43
- js: "javascript",
44
- jsx: "javascript",
45
- py: "python",
46
- java: "java",
47
- cs: "csharp",
48
- cpp: "cpp",
49
- c: "c",
50
- go: "go",
51
- rs: "rust",
52
- php: "php",
53
- rb: "ruby",
54
- kt: "kotlin",
55
- swift: "swift",
56
- html: "html",
57
- css: "css",
58
- scss: "scss",
59
- sass: "sass",
60
- json: "json",
61
- xml: "xml",
62
- yml: "yaml",
63
- yaml: "yaml"
64
- };
65
- return languageMap[extension.toLowerCase()] || "";
66
- }
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
69
- capitalizeKey,
70
- getLanguageFromExtension,
71
- isDateField
72
- });
@@ -1,147 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var git_exports = {};
19
- __export(git_exports, {
20
- collectAllGitIgnoreRules: () => collectAllGitIgnoreRules,
21
- isIgnored: () => isIgnored,
22
- parseGitIgnoreRules: () => parseGitIgnoreRules
23
- });
24
- module.exports = __toCommonJS(git_exports);
25
- function parseGitIgnoreRules(content) {
26
- return content.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => parseGitIgnoreRule(line)).filter((rule) => rule !== null);
27
- }
28
- function parseGitIgnoreRule(line) {
29
- if (!line || line.startsWith("#")) {
30
- return null;
31
- }
32
- const isNegation = line.startsWith("!");
33
- const pattern = isNegation ? line.slice(1) : line;
34
- if (!pattern) {
35
- return null;
36
- }
37
- const isDirectory = pattern.endsWith("/");
38
- const cleanPattern = isDirectory ? pattern.slice(0, -1) : pattern;
39
- const isGlob = /[*?\[\]]/.test(cleanPattern);
40
- return {
41
- pattern: cleanPattern,
42
- isNegation,
43
- isDirectory,
44
- isGlob
45
- };
46
- }
47
- function collectAllGitIgnoreRules(files) {
48
- const allRules = [];
49
- const gitignoreFiles = Object.entries(files).filter(([filePath]) => filePath.endsWith(".gitignore")).sort(([a], [b]) => a.split("/").length - b.split("/").length);
50
- for (const [gitignorePath, content] of gitignoreFiles) {
51
- const rules = parseGitIgnoreRules(content);
52
- const gitignoreDir = gitignorePath.replace(".gitignore", "");
53
- for (const rule of rules) {
54
- const contextualRule = createContextualRule(rule, gitignoreDir);
55
- allRules.push(contextualRule);
56
- }
57
- }
58
- return allRules;
59
- }
60
- function createContextualRule(rule, contextPath) {
61
- return {
62
- ...rule,
63
- contextPath: contextPath || "."
64
- };
65
- }
66
- function isIgnored(filePath, rules) {
67
- const contextualRules = rules.map((rule) => {
68
- if ("contextPath" in rule) {
69
- return rule;
70
- }
71
- return { ...rule, contextPath: "." };
72
- });
73
- const sortedRules = [...contextualRules].sort((a, b) => {
74
- if (a.isNegation !== b.isNegation) {
75
- return a.isNegation ? 1 : -1;
76
- }
77
- return 0;
78
- });
79
- let isIgnored2 = false;
80
- for (const rule of sortedRules) {
81
- const matches = matchesContextualGitIgnorePattern(filePath, rule);
82
- if (rule.isNegation) {
83
- if (matches) {
84
- isIgnored2 = false;
85
- }
86
- } else {
87
- if (matches) {
88
- isIgnored2 = true;
89
- }
90
- }
91
- }
92
- return isIgnored2;
93
- }
94
- function matchesContextualGitIgnorePattern(filePath, rule) {
95
- const { pattern, isDirectory, isGlob, contextPath } = rule;
96
- if (contextPath !== "." && !filePath.startsWith(contextPath)) {
97
- return false;
98
- }
99
- if (!pattern.startsWith("/")) {
100
- const relativePath = contextPath === "." ? filePath : filePath.substring(contextPath.length);
101
- if (isDirectory) {
102
- const matches = relativePath.startsWith(pattern + "/") || relativePath === pattern;
103
- return matches;
104
- } else if (isGlob) {
105
- return matchesGitIgnorePattern(relativePath, {
106
- pattern,
107
- isDirectory,
108
- isGlob,
109
- isNegation: rule.isNegation
110
- });
111
- } else {
112
- return relativePath === pattern || relativePath.startsWith(pattern + "/");
113
- }
114
- } else {
115
- return matchesGitIgnorePattern(filePath, {
116
- pattern,
117
- isDirectory,
118
- isGlob,
119
- isNegation: rule.isNegation
120
- });
121
- }
122
- }
123
- function matchesGitIgnorePattern(filePath, rule) {
124
- const { pattern, isDirectory, isGlob } = rule;
125
- if (isDirectory) {
126
- const dirPath = filePath.split("/").slice(0, -1).join("/");
127
- return matchesPattern(dirPath, pattern, isGlob);
128
- }
129
- return matchesPattern(filePath, pattern, isGlob);
130
- }
131
- function matchesPattern(path, pattern, isGlob) {
132
- if (isGlob) {
133
- const regexPattern = globToRegex(pattern);
134
- return new RegExp(regexPattern).test(path);
135
- } else {
136
- return path.includes(pattern);
137
- }
138
- }
139
- function globToRegex(pattern) {
140
- return pattern.replace(/\./g, "\\.").replace(/\*/g, ".*").replace(/\?/g, ".").replace(/\[([^\]]*)\]/g, "[$1]").replace(/\//g, "\\/");
141
- }
142
- // Annotate the CommonJS export names for ESM import in node:
143
- 0 && (module.exports = {
144
- collectAllGitIgnoreRules,
145
- isIgnored,
146
- parseGitIgnoreRules
147
- });