@eagleoutice/flowr 2.13.0 → 2.13.2

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 (97) hide show
  1. package/README.md +23 -23
  2. package/cli/common/options.d.ts +10 -0
  3. package/cli/common/options.js +2 -0
  4. package/cli/common/scripts-info.d.ts +10 -0
  5. package/cli/flowr.js +21 -5
  6. package/cli/repl/commands/repl-commands.d.ts +8 -0
  7. package/cli/repl/commands/repl-commands.js +27 -12
  8. package/cli/repl/commands/repl-query.js +9 -1
  9. package/cli/repl/commands/repl-signature.js +8 -1
  10. package/cli/repl/core.js +13 -10
  11. package/cli/repl/print-version.js +1 -1
  12. package/cli/repl/server/connection.d.ts +1 -1
  13. package/cli/repl/server/net.js +15 -0
  14. package/cli/slicer-app.d.ts +2 -0
  15. package/cli/slicer-app.js +2 -1
  16. package/config.d.ts +31 -0
  17. package/config.js +55 -2
  18. package/data/sigdb/sigdb.remote.json +1 -1
  19. package/dataflow/environments/identifier.d.ts +9 -8
  20. package/dataflow/environments/identifier.js +21 -13
  21. package/dataflow/eval/resolve/resolve-working-directory.d.ts +29 -0
  22. package/dataflow/eval/resolve/resolve-working-directory.js +168 -0
  23. package/dataflow/extractor.js +2 -1
  24. package/dataflow/graph/df-helper.d.ts +3 -2
  25. package/dataflow/graph/df-helper.js +11 -15
  26. package/dataflow/graph/diff-dataflow-graph.js +1 -1
  27. package/dataflow/graph/graph-helper.js +2 -6
  28. package/dataflow/graph/graph.d.ts +24 -0
  29. package/dataflow/graph/graph.js +25 -1
  30. package/documentation/wiki-interface.js +1 -0
  31. package/documentation/wiki-linter.js +1 -0
  32. package/documentation/wiki-mk/doc-context.d.ts +10 -0
  33. package/documentation/wiki-mk/doc-context.js +3 -0
  34. package/documentation/wiki-query.js +4 -3
  35. package/documentation/wiki-signature-database.js +16 -6
  36. package/linter/linter-rules.d.ts +24 -2
  37. package/linter/linter-rules.js +3 -1
  38. package/linter/rules/absolute-path.d.ts +4 -4
  39. package/linter/rules/absolute-path.js +7 -5
  40. package/linter/rules/file-path-validity.d.ts +1 -1
  41. package/linter/rules/file-path-validity.js +48 -8
  42. package/linter/rules/function-finder-util.d.ts +2 -1
  43. package/linter/rules/syntactically-valid.d.ts +58 -0
  44. package/linter/rules/syntactically-valid.js +203 -0
  45. package/linter/rules/undefined-symbol.js +3 -2
  46. package/package.json +5 -4
  47. package/project/context/classify-project-kind.d.ts +40 -0
  48. package/project/context/classify-project-kind.js +76 -0
  49. package/project/context/flowr-analyzer-context.d.ts +2 -0
  50. package/project/context/flowr-analyzer-context.js +6 -0
  51. package/project/context/flowr-analyzer-dependencies-context.d.ts +23 -4
  52. package/project/context/flowr-analyzer-dependencies-context.js +23 -1
  53. package/project/context/flowr-analyzer-files-context.d.ts +18 -8
  54. package/project/context/flowr-analyzer-files-context.js +66 -68
  55. package/project/context/flowr-file.d.ts +5 -0
  56. package/project/context/flowr-file.js +5 -0
  57. package/project/dependency-version-space.d.ts +3 -1
  58. package/project/dependency-version-space.js +26 -20
  59. package/project/flowr-analyzer.d.ts +3 -0
  60. package/project/flowr-analyzer.js +4 -0
  61. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +12 -4
  62. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +25 -10
  63. package/project/plugins/plugin-registry.d.ts +2 -1
  64. package/project/plugins/plugin-registry.js +4 -1
  65. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +57 -2
  66. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +150 -28
  67. package/project/sigdb/decompress.d.ts +1 -1
  68. package/project/sigdb/decompress.js +4 -1
  69. package/project/sigdb/manifest.js +60 -26
  70. package/project/sigdb/sigdb-download.d.ts +6 -7
  71. package/project/sigdb/sigdb-download.js +30 -9
  72. package/queries/catalog/config-query/config-query-executor.js +3 -0
  73. package/queries/catalog/config-query/config-query-format.d.ts +5 -3
  74. package/queries/catalog/config-query/config-query-format.js +31 -21
  75. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +0 -10
  76. package/queries/catalog/dependencies-query/dependencies-query-format.js +0 -106
  77. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +21 -5
  78. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +4 -2
  79. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +17 -3
  80. package/queries/catalog/linter-query/linter-query-format.js +9 -2
  81. package/queries/catalog/signature-query/signature-query-executor.js +3 -0
  82. package/queries/catalog/signature-query/signature-query-render.js +4 -4
  83. package/queries/query.d.ts +4 -4
  84. package/queries/query.js +9 -2
  85. package/r-bridge/data/data.d.ts +5 -0
  86. package/r-bridge/data/data.js +6 -0
  87. package/r-bridge/retriever.js +6 -1
  88. package/r-bridge/shell.js +5 -0
  89. package/search/flowr-search-filters.d.ts +2 -1
  90. package/util/files.d.ts +6 -4
  91. package/util/files.js +30 -8
  92. package/util/mermaid/dfg.js +1 -1
  93. package/util/schema.d.ts +2 -0
  94. package/util/schema.js +13 -0
  95. package/util/text/ansi.d.ts +7 -3
  96. package/util/text/ansi.js +8 -5
  97. package/util/version.js +4 -4
package/README.md CHANGED
@@ -24,7 +24,7 @@ It offers a wide variety of features, for example:
24
24
 
25
25
  ```shell
26
26
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
27
- flowR repl v2.12.3, R grammar v14 (tree-sitter engine)
27
+ flowR repl v2.13.0, R grammar v14 (tree-sitter engine)
28
28
  R> :query @linter "read.csv(\"/root/x.txt\")"
29
29
  ```
30
30
 
@@ -33,17 +33,17 @@ It offers a wide variety of features, for example:
33
33
 
34
34
 
35
35
  ```text
36
- Query: linter (4 ms)
36
+ Query: linter (9 ms)
37
37
  ╰ Deprecated Functions (deprecated-functions): no findings
38
38
  ╰ File Path Validity (file-path-validity):
39
39
  ╰ certain:
40
40
  ╰ Path `/root/x.txt` at 1.1-23
41
- ╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 0, processTimeMs: 0
41
+ ╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 1, processTimeMs: 0
42
42
  ╰ Seeded Randomness (seeded-randomness): no findings
43
43
  ╰ Absolute Paths (absolute-file-paths):
44
44
  ╰ certain:
45
45
  ╰ Path `/root/x.txt` at 1.1-23
46
- ╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 0, processTimeMs: 0
46
+ ╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 1, processTimeMs: 0
47
47
  ╰ Unused Definitions (unused-definitions): no findings
48
48
  ╰ Network Functions (network-functions): no findings
49
49
  ╰ Dataframe Access Validation (dataframe-access-validation): no findings
@@ -54,7 +54,7 @@ It offers a wide variety of features, for example:
54
54
  ╰ Roxygen Arguments (roxygen-arguments): no findings
55
55
  ╰ No Leaked Credentials (no-leaked-credentials): no findings
56
56
  ╰ Undefined Symbol (undefined-symbol): no findings
57
- All queries together required ≈4 ms (1ms accuracy, total 4 ms)
57
+ All queries together required ≈9 ms (1ms accuracy, total 9 ms)
58
58
  ```
59
59
 
60
60
 
@@ -76,12 +76,12 @@ It offers a wide variety of features, for example:
76
76
 
77
77
  _Results (prettified and summarized):_
78
78
 
79
- Query: **linter** (5 ms)\
79
+ Query: **linter** (11 ms)\
80
80
     ╰ **Deprecated Functions** (deprecated-functions): _no findings_\
81
81
     ╰ **File Path Validity** (file-path-validity):\
82
82
         ╰ certain:\
83
83
             ╰ Path `/root/x.txt` at 1.1-23\
84
-        ╰ _Metadata_: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 0, processTimeMs: 1\
84
+        ╰ _Metadata_: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 1, processTimeMs: 0\
85
85
     ╰ **Seeded Randomness** (seeded-randomness): _no findings_\
86
86
     ╰ **Absolute Paths** (absolute-file-paths):\
87
87
         ╰ certain:\
@@ -97,11 +97,11 @@ It offers a wide variety of features, for example:
97
97
     ╰ **Roxygen Arguments** (roxygen-arguments): _no findings_\
98
98
     ╰ **No Leaked Credentials** (no-leaked-credentials): _no findings_\
99
99
     ╰ **Undefined Symbol** (undefined-symbol): _no findings_\
100
- _All queries together required ≈5 ms (1ms accuracy, total 6 ms)_
100
+ _All queries together required ≈11 ms (1ms accuracy, total 12 ms)_
101
101
 
102
102
  <details> <summary style="color:gray">Show Detailed Results as Json</summary>
103
103
 
104
- The analysis required _5.9 ms_ (including parsing and normalization and the query) within the generation environment.
104
+ The analysis required _12.4 ms_ (including parsing and normalization and the query) within the generation environment.
105
105
 
106
106
  In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR.
107
107
  Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
@@ -118,8 +118,8 @@ It offers a wide variety of features, for example:
118
118
  ".meta": {
119
119
  "totalCalls": 0,
120
120
  "totalFunctionDefinitions": 0,
121
- "searchTimeMs": 2,
122
- "processTimeMs": 0
121
+ "searchTimeMs": 3,
122
+ "processTimeMs": 1
123
123
  }
124
124
  },
125
125
  "file-path-validity": {
@@ -141,8 +141,8 @@ It offers a wide variety of features, for example:
141
141
  "totalUnknown": 0,
142
142
  "totalWritesBeforeAlways": 0,
143
143
  "totalValid": 0,
144
- "searchTimeMs": 0,
145
- "processTimeMs": 1
144
+ "searchTimeMs": 1,
145
+ "processTimeMs": 0
146
146
  }
147
147
  },
148
148
  "seeded-randomness": {
@@ -153,7 +153,7 @@ It offers a wide variety of features, for example:
153
153
  "callsWithAssignmentProducers": 0,
154
154
  "callsWithNonConstantProducers": 0,
155
155
  "callsWithOtherBranchProducers": 0,
156
- "searchTimeMs": 0,
156
+ "searchTimeMs": 1,
157
157
  "processTimeMs": 0
158
158
  }
159
159
  },
@@ -182,7 +182,7 @@ It offers a wide variety of features, for example:
182
182
  ".meta": {
183
183
  "totalConsidered": 0,
184
184
  "searchTimeMs": 0,
185
- "processTimeMs": 0
185
+ "processTimeMs": 1
186
186
  }
187
187
  },
188
188
  "network-functions": {
@@ -262,16 +262,16 @@ It offers a wide variety of features, for example:
262
262
  "subscript": 0
263
263
  },
264
264
  "searchTimeMs": 0,
265
- "processTimeMs": 1
265
+ "processTimeMs": 3
266
266
  }
267
267
  }
268
268
  },
269
269
  ".meta": {
270
- "timing": 5
270
+ "timing": 11
271
271
  }
272
272
  },
273
273
  ".meta": {
274
- "timing": 5
274
+ "timing": 11
275
275
  }
276
276
  }
277
277
  ```
@@ -335,7 +335,7 @@ It offers a wide variety of features, for example:
335
335
 
336
336
  ```shell
337
337
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
338
- flowR repl v2.12.3, R grammar v14 (tree-sitter engine)
338
+ flowR repl v2.13.0, R grammar v14 (tree-sitter engine)
339
339
  R> :query @static-slice (11@sum) file://test/testfiles/example.R
340
340
  ```
341
341
 
@@ -349,7 +349,7 @@ It offers a wide variety of features, for example:
349
349
  N <- 10
350
350
  for(i in 1:(N-1)) sum <- sum + i + w
351
351
  sum
352
- All queries together required ≈3 ms (1ms accuracy, total 4 ms)
352
+ All queries together required ≈6 ms (1ms accuracy, total 7 ms)
353
353
  ```
354
354
 
355
355
 
@@ -381,7 +381,7 @@ It offers a wide variety of features, for example:
381
381
  </details>
382
382
 
383
383
  * 🚀 **fast call-graph, data-, and control-flow graphs**\
384
- Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">81.2 ms</span></i> (as of Jul 15, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
384
+ Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">104.8 ms</span></i> (as of Jul 20, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
385
385
  _flowR_ can analyze the data- and control-flow of the average real-world R&nbsp;script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
386
386
  and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) for more details on the [dataflow graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) as well as [call graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph#perspectives-cg).
387
387
 
@@ -417,7 +417,7 @@ It offers a wide variety of features, for example:
417
417
 
418
418
  ```shell
419
419
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
420
- flowR repl v2.12.3, R grammar v14 (tree-sitter engine)
420
+ flowR repl v2.13.0, R grammar v14 (tree-sitter engine)
421
421
  R> :dataflow* test/testfiles/example.R
422
422
  ```
423
423
 
@@ -690,7 +690,7 @@ It offers a wide variety of features, for example:
690
690
  ```
691
691
 
692
692
 
693
- (The analysis required _1.2 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
693
+ (The analysis required _3.4 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
694
694
 
695
695
 
696
696
 
@@ -299,6 +299,16 @@ export declare const slicerOptions: [{
299
299
  readonly name: "api";
300
300
  readonly type: BooleanConstructor;
301
301
  readonly description: "Instead of human-readable output, dump a lot of json with the results of all intermediate steps.";
302
+ }, {
303
+ readonly name: "config-file";
304
+ readonly type: StringConstructor;
305
+ readonly description: "The name of the configuration file to use";
306
+ readonly multiple: false;
307
+ }, {
308
+ readonly name: "config-json";
309
+ readonly type: StringConstructor;
310
+ readonly description: "The flowR configuration to use, as a JSON string";
311
+ readonly multiple: false;
302
312
  }];
303
313
  export declare const summarizerOptions: [{
304
314
  readonly name: "verbose";
@@ -68,6 +68,8 @@ exports.slicerOptions = [
68
68
  { name: 'inline-banner', alias: 'B', type: Boolean, description: 'Together with {bold --inline-full}: precede every inlined file with a banner comment naming it.' },
69
69
  { name: 'include-callees', type: Boolean, description: 'If slicing backward, continue past a function-definition boundary, also including the definition\'s binding and call sites.' },
70
70
  { name: 'api', type: Boolean, description: 'Instead of human-readable output, dump a lot of json with the results of all intermediate steps.' },
71
+ { name: 'config-file', type: String, description: 'The name of the configuration file to use', multiple: false },
72
+ { name: 'config-json', type: String, description: 'The flowR configuration to use, as a JSON string', multiple: false },
71
73
  ];
72
74
  exports.summarizerOptions = [
73
75
  { name: 'verbose', alias: 'v', type: Boolean, description: 'Run with verbose logging' },
@@ -105,6 +105,16 @@ declare const _scripts: {
105
105
  readonly name: "api";
106
106
  readonly type: BooleanConstructor;
107
107
  readonly description: "Instead of human-readable output, dump a lot of json with the results of all intermediate steps.";
108
+ }, {
109
+ readonly name: "config-file";
110
+ readonly type: StringConstructor;
111
+ readonly description: "The name of the configuration file to use";
112
+ readonly multiple: false;
113
+ }, {
114
+ readonly name: "config-json";
115
+ readonly type: StringConstructor;
116
+ readonly description: "The flowR configuration to use, as a JSON string";
117
+ readonly multiple: false;
108
118
  }];
109
119
  usageExample: string;
110
120
  type: string;
package/cli/flowr.js CHANGED
@@ -212,10 +212,26 @@ async function mainServer(useWebSocket) {
212
212
  const backend = useWebSocket ? new WebSocketServerWrapper() : new NetServer();
213
213
  await new FlowRServer(engines.engines, engines.default, options['r-session-access'], config, backend).start(options.port);
214
214
  }
215
- if (options.server) {
216
- void mainServer(options.ws);
217
- }
218
- else {
219
- void mainRepl();
215
+ async function main() {
216
+ try {
217
+ if (options.server) {
218
+ await mainServer(options.ws);
219
+ }
220
+ else {
221
+ await mainRepl();
222
+ }
223
+ }
224
+ catch (e) {
225
+ const err = e;
226
+ console.error(ansi_1.formatter.format(`flowR failed to start: ${err.message}`, { color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }));
227
+ if (options.verbose) {
228
+ console.error(err.stack);
229
+ }
230
+ else {
231
+ console.error((0, ansi_1.italic)('Run again with --verbose for the full stack trace.'));
232
+ }
233
+ (0, proc_1.exitSafe)(1);
234
+ }
220
235
  }
236
+ void main();
221
237
  //# sourceMappingURL=flowr.js.map
@@ -1,5 +1,7 @@
1
1
  import type { ReplCodeCommand, ReplCommand } from './repl-main';
2
+ import type { OptionDefinition } from 'command-line-usage';
2
3
  import { scripts } from '../../common/scripts-info';
4
+ import type { FlowrConfig } from '../../../config';
3
5
  export declare const helpCommand: ReplCommand;
4
6
  /**
5
7
  * All commands that should be available in the REPL.
@@ -28,6 +30,12 @@ declare const _commands: {
28
30
  readonly signature: ReplCodeCommand;
29
31
  };
30
32
  export type ReplCommandNames = keyof typeof _commands | keyof typeof scripts;
33
+ /**
34
+ * The args a master script is forked with: `remainingLine` tokenized, plus `--config-json <analyzer.flowrConfig>`
35
+ * so it sees the repl's current (possibly `:query \@config`-edited) config -- unless the script does not support
36
+ * that option, or the user already named a config themselves.
37
+ */
38
+ export declare function masterScriptArgs(remainingLine: string, config: FlowrConfig, scriptOptions: readonly OptionDefinition[]): string[];
31
39
  /**
32
40
  * Retrieve all REPL commands (including those generated from master scripts)
33
41
  */
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.helpCommand = void 0;
4
+ exports.masterScriptArgs = masterScriptArgs;
4
5
  exports.getReplCommands = getReplCommands;
5
6
  exports.getCommandNames = getCommandNames;
6
7
  exports.getCommand = getCommand;
@@ -160,6 +161,18 @@ function hasModule(path) {
160
161
  return false;
161
162
  }
162
163
  }
164
+ /**
165
+ * The args a master script is forked with: `remainingLine` tokenized, plus `--config-json <analyzer.flowrConfig>`
166
+ * so it sees the repl's current (possibly `:query \@config`-edited) config -- unless the script does not support
167
+ * that option, or the user already named a config themselves.
168
+ */
169
+ function masterScriptArgs(remainingLine, config, scriptOptions) {
170
+ const args = (0, args_1.splitAtEscapeSensitive)(remainingLine);
171
+ if (scriptOptions.some(o => o.name === 'config-json') && !args.includes('--config-json') && !args.includes('--config-file')) {
172
+ args.push('--config-json', JSON.stringify(config));
173
+ }
174
+ return args;
175
+ }
163
176
  /**
164
177
  * Retrieve all REPL commands (including those generated from master scripts)
165
178
  */
@@ -167,8 +180,7 @@ function getReplCommands() {
167
180
  if (commandsInitialized) {
168
181
  return _commands;
169
182
  }
170
- commandsInitialized = true;
171
- for (const [script, { target, description, type }] of Object.entries(scripts_info_1.scripts)) {
183
+ for (const [script, { target, description, type, options }] of Object.entries(scripts_info_1.scripts)) {
172
184
  if (type === 'master script') {
173
185
  _commands[script] = {
174
186
  description,
@@ -176,7 +188,7 @@ function getReplCommands() {
176
188
  script: true,
177
189
  usageExample: `:${script} --help`,
178
190
  isCodeCommand: false,
179
- fn: async ({ output, remainingLine }) => {
191
+ fn: async ({ output, remainingLine, analyzer }) => {
180
192
  // check if the target *module* exists in the current directory, else try two dirs up, otherwise, fail with a message
181
193
  let path = `${__dirname}/${target}`;
182
194
  if (!hasModule(path)) {
@@ -186,11 +198,12 @@ function getReplCommands() {
186
198
  return;
187
199
  }
188
200
  }
189
- await (0, execute_1.waitOnScript)(path, (0, args_1.splitAtEscapeSensitive)(remainingLine), stdio => (0, execute_1.stdioCaptureProcessor)(stdio, msg => output.stdout(msg), msg => output.stderr(msg)));
201
+ await (0, execute_1.waitOnScript)(path, masterScriptArgs(remainingLine, analyzer.flowrConfig, options), stdio => (0, execute_1.stdioCaptureProcessor)(stdio, msg => output.stdout(msg), msg => output.stderr(msg)));
190
202
  }
191
203
  };
192
204
  }
193
205
  }
206
+ commandsInitialized = true;
194
207
  return _commands;
195
208
  }
196
209
  /**
@@ -206,18 +219,20 @@ let commandNames = undefined;
206
219
  // maps command names or aliases to the actual command name
207
220
  let commandMapping = undefined;
208
221
  function initCommandMapping() {
209
- commandMapping = {};
210
- commandNames = [];
222
+ const mapping = {};
223
+ const names = [];
211
224
  for (const [command, { aliases }] of Object.entries(getReplCommands())) {
212
- (0, assert_1.guard)(commandMapping[command] === undefined, `Command ${command} is already registered!`);
213
- commandMapping[command] = command;
225
+ (0, assert_1.guard)(mapping[command] === undefined, `Command ${command} is already registered!`);
226
+ mapping[command] = command;
214
227
  for (const alias of aliases) {
215
- (0, assert_1.guard)(commandMapping[alias] === undefined, `Command (alias) ${alias} is already registered!`);
216
- commandMapping[alias] = command;
228
+ (0, assert_1.guard)(mapping[alias] === undefined, `Command (alias) ${alias} is already registered!`);
229
+ mapping[alias] = command;
217
230
  }
218
- commandNames.push(command);
219
- commandNames.push(...aliases);
231
+ names.push(command);
232
+ names.push(...aliases);
220
233
  }
234
+ commandMapping = mapping;
235
+ commandNames = names;
221
236
  }
222
237
  /**
223
238
  * Get the command for a given command name or alias.
@@ -61,7 +61,7 @@ function printQueryDoc(output, name) {
61
61
  output.stdout(`Run: ${(0, ansi_1.bold)(':query ' + syntax, output.formatter)}`);
62
62
  output.stdout(`JSON: ${(0, ansi_1.italic)(queryTemplate(name, def.schema), output.formatter)}`);
63
63
  const wiki = `https://github.com/flowr-analysis/flowr/wiki/${encodeURIComponent((0, query_1.queryWikiPage)(def.title).replaceAll(' ', '-'))}`;
64
- output.stdout(`Docs: ${(0, ansi_1.supportsHyperlinks)() ? output.formatter.hyperlink(`${name} query`, wiki) : wiki}`);
64
+ output.stdout(`Docs: ${output.formatter.hyperlink(`${name} query`, wiki)}`);
65
65
  }
66
66
  /** A copy-pasteable JSON template for a query type: its `type` plus each required field as a placeholder. */
67
67
  function queryTemplate(type, schema) {
@@ -157,12 +157,20 @@ async function processQueryArgs(output, analyzer, remainingArgs) {
157
157
  analyzer
158
158
  };
159
159
  }
160
+ const ConfigLineRegex = /^(@config)(?:\s+([\s\S]*))?$/;
160
161
  /**
161
162
  * Function for splitting the input line.
162
163
  * All input is treated as arguments, no R code is separated so that the individual queries can handle it.
164
+ * `@config` is passed its rest-of-line untouched, since its own `fromLine` reads a single raw token and the
165
+ * generic tokenizer would otherwise strip quotes out of a `+path=["a"]` value.
163
166
  * @param line - The input line
164
167
  */
165
168
  function parseArgs(line) {
169
+ const configMatch = ConfigLineRegex.exec(line);
170
+ if (configMatch) {
171
+ const [, name, rest] = configMatch;
172
+ return { rCode: undefined, remaining: rest === undefined ? [name] : [name, rest] };
173
+ }
166
174
  const args = (0, args_1.splitAtEscapeSensitive)(line);
167
175
  return {
168
176
  rCode: undefined,
@@ -8,6 +8,7 @@ const query_1 = require("../../../queries/query");
8
8
  const signature_query_format_1 = require("../../../queries/catalog/signature-query/signature-query-format");
9
9
  const query_print_1 = require("../../../queries/query-print");
10
10
  const sigdb_download_1 = require("../../../project/sigdb/sigdb-download");
11
+ const config_1 = require("../../../config");
11
12
  const retriever_1 = require("../../../r-bridge/retriever");
12
13
  const signature_query_executor_1 = require("../../../queries/catalog/signature-query/signature-query-executor");
13
14
  /** treat the whole line as arguments, no R code to separate */
@@ -67,7 +68,13 @@ async function runDownload(output, analyzer, rest) {
67
68
  if (manifest) {
68
69
  await analyzer.context().deps.addDatabaseSource(manifest);
69
70
  analyzer.reset();
70
- output.stdout(`Mounted ${(0, ansi_1.bold)(manifest, f)} (will be available on next startup from the cache).`);
71
+ output.stdout(`Mounted ${(0, ansi_1.bold)(manifest, f)}.`);
72
+ }
73
+ try {
74
+ output.stdout(`Recorded in ${(0, ansi_1.bold)((0, config_1.persistSigDbPathToGlobalConfig)(dir), f)}; loads automatically on the next startup.`);
75
+ }
76
+ catch (e) {
77
+ output.stderr((0, ansi_1.italic)(`Could not update global config (${e.message}); add ${dir} to solver.sigdb.additionalPaths manually.`, f));
71
78
  }
72
79
  }
73
80
  catch (e) {
package/cli/repl/core.js CHANGED
@@ -246,10 +246,16 @@ async function executeStatement(output, statement, analyzer, allowRSessionAccess
246
246
  }
247
247
  if (statement.startsWith(':')) {
248
248
  const command = statement.slice(1).split(' ')[0].toLowerCase();
249
- const processor = (0, repl_commands_1.getCommand)(command);
250
249
  const bold = (s) => output.formatter.format(s, { style: 1 /* FontStyles.Bold */ });
251
- if (processor) {
252
- try {
250
+ const reportFailure = (e) => {
251
+ output.stderr(`${bold(`Failed to execute command ${command}`)}: ${e?.message}. Using the ${bold('--verbose')} flag on startup may provide additional information.\n`);
252
+ if (log_1.log.settings.minLevel < 6 /* LogLevel.Fatal */) {
253
+ console.error(e);
254
+ }
255
+ };
256
+ try {
257
+ const processor = (0, repl_commands_1.getCommand)(command);
258
+ if (processor) {
253
259
  await (0, query_1.genericWrapReplFailIfNoRequest)(async () => {
254
260
  const remainingLine = statement.slice(command.length + 2).trim();
255
261
  if (processor.isCodeCommand) {
@@ -265,15 +271,12 @@ async function executeStatement(output, statement, analyzer, allowRSessionAccess
265
271
  }
266
272
  }, output, analyzer);
267
273
  }
268
- catch (e) {
269
- output.stderr(`${bold(`Failed to execute command ${command}`)}: ${e?.message}. Using the ${bold('--verbose')} flag on startup may provide additional information.\n`);
270
- if (log_1.log.settings.minLevel < 6 /* LogLevel.Fatal */) {
271
- console.error(e);
272
- }
274
+ else {
275
+ output.stderr(`the command '${command}' is unknown, try ${bold(':help')} for more information\n`);
273
276
  }
274
277
  }
275
- else {
276
- output.stderr(`the command '${command}' is unknown, try ${bold(':help')} for more information\n`);
278
+ catch (e) {
279
+ reportFailure(e);
277
280
  }
278
281
  }
279
282
  else {
@@ -40,7 +40,7 @@ function sigDbSummaryString() {
40
40
  if (entries.length === 0) {
41
41
  return it('no sigdb');
42
42
  }
43
- const link = (text, file) => it(ansi_1.formatter.hyperlink(text, (0, node_url_1.pathToFileURL)(file).href));
43
+ const link = (text, file) => it(ansi_1.formatter.hyperlink(text, (0, node_url_1.pathToFileURL)(file).href, true));
44
44
  // if every ref shares the same date, print it once
45
45
  const shared = entries.every(e => e.date !== undefined && e.date === entries[0].date) ? entries[0].date : undefined;
46
46
  const refs = entries.map(e => link(shared === undefined && e.date !== undefined ? `${e.label} ${e.date}` : e.label, e.file));
@@ -1,5 +1,5 @@
1
1
  import type { Socket } from './net';
2
- import { type TREE_SITTER_DATAFLOW_PIPELINE, DEFAULT_SLICING_PIPELINE } from '../../../core/steps/pipeline/default-pipelines';
2
+ import { DEFAULT_SLICING_PIPELINE, type TREE_SITTER_DATAFLOW_PIPELINE } from '../../../core/steps/pipeline/default-pipelines';
3
3
  import type { PipelineOutput } from '../../../core/steps/pipeline/pipeline';
4
4
  import type { DeepPartial } from 'ts-essentials';
5
5
  import type { KnownParser, ParseStepOutput } from '../../../r-bridge/parser';
@@ -18,6 +18,7 @@ class WebSocketServerWrapper {
18
18
  }
19
19
  start(port) {
20
20
  this.server = new ws_1.WebSocketServer({ port, maxPayload: 1024 * 1024 * 1024 * 1024 });
21
+ this.server.on('error', (e) => reportListenFailure(port, e));
21
22
  server_1.serverLog.info('WebSocket-Server wrapper is active!');
22
23
  this.server.on('connection', c => this.connectHandler?.(new WebSocketWrapper(c)));
23
24
  }
@@ -56,8 +57,22 @@ class NetServer {
56
57
  this.server.on('connection', handler);
57
58
  }
58
59
  start(port) {
60
+ this.server.on('error', (e) => reportListenFailure(port, e));
59
61
  this.server.listen(port);
60
62
  }
61
63
  }
62
64
  exports.NetServer = NetServer;
65
+ /** Log a clear, actionable message for a server that failed to bind its port, then exit (there is nothing left to serve). */
66
+ function reportListenFailure(port, e) {
67
+ if (e.code === 'EADDRINUSE') {
68
+ server_1.serverLog.error(`Port ${port} is already in use. Pick another port with --port <number> or stop the process using it.`);
69
+ }
70
+ else if (e.code === 'EACCES') {
71
+ server_1.serverLog.error(`Not allowed to listen on port ${port} (permission denied). Try a port above 1024 with --port <number>.`);
72
+ }
73
+ else {
74
+ server_1.serverLog.error(`Failed to start the server on port ${port}: ${e.message}`);
75
+ }
76
+ process.exit(1);
77
+ }
63
78
  //# sourceMappingURL=net.js.map
@@ -13,4 +13,6 @@ export interface SlicerCliOptions {
13
13
  'inline-full': boolean;
14
14
  'inline-banner': boolean;
15
15
  'include-callees': boolean;
16
+ 'config-file': string | undefined;
17
+ 'config-json': string | undefined;
16
18
  }
package/cli/slicer-app.js CHANGED
@@ -31,7 +31,8 @@ async function getSlice() {
31
31
  const slicer = new slicer_1.BenchmarkSlicer('r-shell');
32
32
  (0, assert_1.guard)(options.input !== undefined, 'input must be given');
33
33
  (0, assert_1.guard)(options.criterion !== undefined, 'a slicing criterion must be given');
34
- const config = config_1.FlowrConfig.fromFile();
34
+ const config = (options['config-json'] ? config_1.FlowrConfig.parse(options['config-json']) : undefined)
35
+ ?? config_1.FlowrConfig.fromFile(options['config-file']);
35
36
  await slicer.init(options['input-is-text']
36
37
  ? { request: 'text', content: options.input.replaceAll('\\n', '\n') }
37
38
  : { request: 'file', content: options.input }, config, options['no-magic-comments'] ? auto_select_defaults_1.doNotAutoSelect : (0, magic_comments_1.makeMagicCommentHandler)(auto_select_defaults_1.doNotAutoSelect), undefined, options.inline, options['include-callees'], options['inline-full'] ? (options['inline-banner'] ? 'banner' : true) : undefined);
package/config.d.ts CHANGED
@@ -156,6 +156,10 @@ export interface FlowrConfig extends MergeableRecord {
156
156
  readonly project: {
157
157
  /** Whether to resolve unknown paths loaded by the r project disk when trying to source/analyze files */
158
158
  resolveUnknownPathsOnDisk: boolean;
159
+ /** Whether a directory that cannot be traversed during file discovery (e.g. due to permissions) aborts the analysis; when `false` (the default) such paths are logged and skipped. */
160
+ failOnInaccessiblePath?: boolean;
161
+ /** Overwrite the {@link ProjectKind} flowR would otherwise infer from the analyzed files, e.g. when auto-detection guesses wrong. */
162
+ useProjectType?: ProjectKind;
159
163
  /**
160
164
  * The packages considered part of R itself, used e.g. by the project query to classify dependencies. If
161
165
  * unset, flowR derives them (for the assumed R version) from the signature database via `baseRPackages`.
@@ -168,6 +172,29 @@ export interface FlowrConfig extends MergeableRecord {
168
172
  * {@link FlowrConfig.specializeConfig}.
169
173
  */
170
174
  implicitSources?: string[];
175
+ /** Scoping options for the default project discovery. */
176
+ discovery?: {
177
+ /** Collect every file below the project root (greedy) instead of only the files the detected {@link ProjectKind} needs (default `false`). */
178
+ full?: boolean;
179
+ /** Per-{@link ProjectKind} include/exclude glob overrides layered on the default scoping. */
180
+ perKind?: Partial<Record<ProjectKind, {
181
+ include?: string[];
182
+ exclude?: string[];
183
+ }>>;
184
+ /** Case-insensitive globs that drop matching files from the intelligent discovery, regardless of kind (e.g. `.Renviron` to ignore environment files). */
185
+ ignore?: string[];
186
+ };
187
+ /** Overrides for the signals flowR uses to classify the {@link ProjectKind}; unset fields keep the built-in defaults. */
188
+ classification?: {
189
+ /** DESCRIPTION `Type:` values that mark a shiny app (default `shiny`, `shiny-app`, `shinyapp`). */
190
+ shinyDescriptionTypes?: string[];
191
+ /** File names a shiny app is assembled from (default `app.R`, `ui.R`, `server.R`, `global.R`). */
192
+ shinyEntryFiles?: string[];
193
+ /** Regex source evidencing shiny usage in an entry file. */
194
+ shinyUsagePattern?: string;
195
+ /** File extensions marking a notebook (default `ipynb`, `rmd`, `qmd`, `rnw`). */
196
+ notebookExtensions?: string[];
197
+ };
171
198
  };
172
199
  /** Linter configuration, usually specialized per {@link ProjectKind} via {@link FlowrConfig.specializeConfig}. */
173
200
  readonly linter: {
@@ -423,3 +450,7 @@ export declare const FlowrConfig: {
423
450
  */
424
451
  readonly setInConfigInPlace: <Path extends ValidFlowrConfigPaths>(this: void, config: FlowrConfig, key: Path, value: PathValue<FlowrConfig, Path>) => void;
425
452
  };
453
+ /** Path to the user-global `flowr.json`, read as a fallback when no project config is found. */
454
+ export declare function globalConfigFilePath(): string;
455
+ /** Persist `dbPath` into `solver.sigdb.additionalPaths` in the global config (creating it, preserving the user's raw JSON); idempotent, returns the file written. */
456
+ export declare function persistSigDbPathToGlobalConfig(dbPath: string): string;