@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
@@ -18,6 +18,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
18
18
  const node_path_1 = __importDefault(require("node:path"));
19
19
  const schema_1 = require("./schema");
20
20
  const codec_1 = require("./codec");
21
+ const decompress_1 = require("./decompress");
21
22
  exports.SigDbManifestMagic = 'flowr-sigdb-manifest';
22
23
  exports.SigDbManifestSchema = 2;
23
24
  /** write a {@link SigDbManifest} (compact JSON) plus a compressed copy per available codec (`.br` always, `.zst` when supported) beside it */
@@ -59,6 +60,20 @@ function readManifestDate(manifestFile) {
59
60
  const SigDbScopeOrder = ['full', 'current', 'base'];
60
61
  /** layouts a bundled sigdb may sit in, relative to a search root -- the root itself (e.g. a `$FLOWR_SIGDB_DIR` data mount), then the dev `src`, build `dist` and data-dir layouts */
61
62
  const SigDbSubDirs = ['', 'data/sigdb', 'src/data/sigdb', 'dist/src/data/sigdb'];
63
+ function sigDbBundleDirs() {
64
+ if (typeof node_fs_1.default?.readdirSync !== 'function') {
65
+ return [];
66
+ }
67
+ try {
68
+ const bundles = node_path_1.default.join((0, decompress_1.sigDbCacheDir)(undefined, false), 'bundles');
69
+ return node_fs_1.default.readdirSync(bundles, { withFileTypes: true })
70
+ .filter(e => e.isDirectory())
71
+ .map(e => node_path_1.default.join(bundles, e.name));
72
+ }
73
+ catch {
74
+ return [];
75
+ }
76
+ }
62
77
  /** roots to search for a bundled sigdb; extendable via `$FLOWR_SIGDB_DIR` (path-delimiter separated) */
63
78
  function sigDbSearchRoots(extra) {
64
79
  const roots = [...(extra ?? [])];
@@ -86,18 +101,25 @@ function defaultSigDbPath(scope, searchRoots) {
86
101
  return undefined;
87
102
  }
88
103
  const scopes = scope ? [scope] : SigDbScopeOrder;
89
- for (const root of sigDbSearchRoots(searchRoots)) {
90
- for (let dir = root, i = 0; i < 10; i++) {
91
- for (const sub of SigDbSubDirs) {
92
- for (const s of scopes) {
93
- for (const suffix of ['', ...(0, codec_1.readableExtsPreferred)()]) {
94
- const candidate = node_path_1.default.join(dir, sub, `${s}.manifest.json${suffix}`);
95
- if (node_fs_1.default.existsSync(candidate)) {
96
- return candidate;
97
- }
104
+ const probe = (dir) => {
105
+ for (const sub of SigDbSubDirs) {
106
+ for (const s of scopes) {
107
+ for (const suffix of ['', ...(0, codec_1.readableExtsPreferred)()]) {
108
+ const candidate = node_path_1.default.join(dir, sub, `${s}.manifest.json${suffix}`);
109
+ if (node_fs_1.default.existsSync(candidate)) {
110
+ return candidate;
98
111
  }
99
112
  }
100
113
  }
114
+ }
115
+ return undefined;
116
+ };
117
+ for (const root of sigDbSearchRoots(searchRoots)) {
118
+ for (let dir = root, i = 0; i < 10; i++) {
119
+ const hit = probe(dir);
120
+ if (hit !== undefined) {
121
+ return hit;
122
+ }
101
123
  const parent = node_path_1.default.dirname(dir);
102
124
  if (parent === dir) {
103
125
  break;
@@ -105,6 +127,12 @@ function defaultSigDbPath(scope, searchRoots) {
105
127
  dir = parent;
106
128
  }
107
129
  }
130
+ for (const bundle of sigDbBundleDirs()) {
131
+ const hit = probe(bundle);
132
+ if (hit !== undefined) {
133
+ return hit;
134
+ }
135
+ }
108
136
  return undefined;
109
137
  }
110
138
  /**
@@ -132,26 +160,29 @@ function defaultSigDbPaths(searchRoots) {
132
160
  into.set(key, file);
133
161
  }
134
162
  };
135
- for (const root of sigDbSearchRoots(searchRoots)) {
136
- for (let dir = root, i = 0; i < 10; i++) {
137
- for (const sub of SigDbSubDirs) {
138
- let entries;
139
- try {
140
- entries = node_fs_1.default.readdirSync(node_path_1.default.join(dir, sub));
141
- }
142
- catch {
143
- continue; // directory does not exist on this root
163
+ const scanDir = (base) => {
164
+ for (const sub of SigDbSubDirs) {
165
+ let entries;
166
+ try {
167
+ entries = node_fs_1.default.readdirSync(node_path_1.default.join(base, sub));
168
+ }
169
+ catch {
170
+ continue; // directory does not exist on this root
171
+ }
172
+ for (const file of entries) {
173
+ const full = node_path_1.default.join(base, sub, file);
174
+ if (new RegExp(`\\.manifest\\.json${codec_1.CompressedExtPattern}$`).test(file)) {
175
+ keep(manifests, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(base, sub));
144
176
  }
145
- for (const file of entries) {
146
- const full = node_path_1.default.join(dir, sub, file);
147
- if (new RegExp(`\\.manifest\\.json${codec_1.CompressedExtPattern}$`).test(file)) {
148
- keep(manifests, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(dir, sub));
149
- }
150
- else if (new RegExp(`${schema_1.SigDbExt.replace(/\./g, '\\.')}${codec_1.CompressedExtPattern}$`).test(file) && !file.includes('.dict' + schema_1.SigDbExt)) {
151
- keep(standalones, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(dir, sub));
152
- }
177
+ else if (new RegExp(`${schema_1.SigDbExt.replace(/\./g, '\\.')}${codec_1.CompressedExtPattern}$`).test(file) && !file.includes('.dict' + schema_1.SigDbExt)) {
178
+ keep(standalones, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(base, sub));
153
179
  }
154
180
  }
181
+ }
182
+ };
183
+ for (const root of sigDbSearchRoots(searchRoots)) {
184
+ for (let dir = root, i = 0; i < 10; i++) {
185
+ scanDir(dir);
155
186
  const parent = node_path_1.default.dirname(dir);
156
187
  if (parent === dir) {
157
188
  break;
@@ -159,6 +190,9 @@ function defaultSigDbPaths(searchRoots) {
159
190
  dir = parent;
160
191
  }
161
192
  }
193
+ for (const bundle of sigDbBundleDirs()) {
194
+ scanDir(bundle);
195
+ }
162
196
  // a standalone bundle is a `.sigs.ndjson` that is not a shard of a discovered manifest (`<manifest>.<shard>...`)
163
197
  const prefixes = [...manifests.keys()].map(k => k.replace(/\.manifest\.json$/, ''));
164
198
  const isShard = (name) => {
@@ -25,10 +25,11 @@ export declare function selectDownloadVariants(names: Iterable<string>): string[
25
25
  export interface SigDbDownloadOptions {
26
26
  /** GitHub `owner/repo` (default `flowr-analysis/flowr`) */
27
27
  readonly repo?: string;
28
- /** release version, i.e. tag `sigdb-v<version>` (default the running flowR version) */
28
+ /** release version, i.e. tag `sigdb-v<version>` (default the running flowR version); ignored when the committed `sigdb.remote.json` is present, whose `tag` then drives the download */
29
29
  readonly version?: string;
30
30
  /** progress callback (one line per asset) */
31
31
  readonly onProgress?: (msg: string) => void;
32
+ readonly force?: boolean;
32
33
  }
33
34
  export interface SigDbDownloadResult {
34
35
  /** the directory the bundle landed in (add it to `solver.sigdb.additionalPaths` to keep it mounted) */
@@ -50,16 +51,14 @@ export declare function downloadFullSigDb(opts?: SigDbDownloadOptions): Promise<
50
51
  * pointer is committed. Lets a caller mount an already-synced bundle via `solver.sigdb.additionalPaths` without
51
52
  * hitting the network.
52
53
  */
53
- export declare function syncedSigDbDir(opts?: {
54
- version?: string;
55
- }): string | undefined;
54
+ export declare function syncedSigDbDir(): string | undefined;
56
55
  /** the GitHub release (`{repo, tag, url}`) the committed pointer downloads from, or `undefined` when no pointer is committed */
57
56
  export declare function sigDbRemoteRelease(): {
58
57
  repo: string;
59
58
  tag: string;
60
59
  url: string;
61
60
  } | undefined;
61
+ /** Fast presence check (existence + byte size only, no hashing) for the shards the committed pointer selects for this runtime; `false` when no pointer is committed or any selected shard is missing/wrong-size. */
62
+ export declare function sigDbCacheComplete(): boolean;
62
63
  /** Startup check: `true` when a committed link file lists shards whose cached copies are missing or hash-mismatched */
63
- export declare function sigDbNeedsSync(opts?: {
64
- version?: string;
65
- }): boolean;
64
+ export declare function sigDbNeedsSync(): boolean;
@@ -8,6 +8,7 @@ exports.selectDownloadVariants = selectDownloadVariants;
8
8
  exports.downloadFullSigDb = downloadFullSigDb;
9
9
  exports.syncedSigDbDir = syncedSigDbDir;
10
10
  exports.sigDbRemoteRelease = sigDbRemoteRelease;
11
+ exports.sigDbCacheComplete = sigDbCacheComplete;
11
12
  exports.sigDbNeedsSync = sigDbNeedsSync;
12
13
  const fs_1 = __importDefault(require("fs"));
13
14
  const path_1 = __importDefault(require("path"));
@@ -134,7 +135,7 @@ async function downloadFullSigDb(opts = {}) {
134
135
  if (pointerPath) {
135
136
  const remote = readPointer(pointerPath);
136
137
  const repo = opts.repo ?? remote.repo ?? DefaultRepo;
137
- const tag = opts.version ? `sigdb-v${opts.version}` : remote.tag;
138
+ const tag = remote.tag;
138
139
  const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
139
140
  fs_1.default.mkdirSync(dir, { recursive: true });
140
141
  // one variant per logical shard/dictionary -- the best this runtime can decompress (never both codecs)
@@ -144,7 +145,7 @@ async function downloadFullSigDb(opts = {}) {
144
145
  for (const name of picked) {
145
146
  const meta = remote.shards[name];
146
147
  const dest = path_1.default.join(dir, name);
147
- if (fs_1.default.existsSync(dest) && (0, exports.sha256File)(dest) === meta.sha256) {
148
+ if (!opts.force && fs_1.default.existsSync(dest) && (0, exports.sha256File)(dest) === meta.sha256) {
148
149
  progress(`have ${name}`);
149
150
  }
150
151
  else {
@@ -176,7 +177,7 @@ async function downloadFullSigDb(opts = {}) {
176
177
  for (const name of selectDownloadVariants(byName.keys())) {
177
178
  const a = byName.get(name);
178
179
  const dest = path_1.default.join(dir, name);
179
- if (fs_1.default.existsSync(dest) && fs_1.default.statSync(dest).size === a.size) {
180
+ if (!opts.force && fs_1.default.existsSync(dest) && fs_1.default.statSync(dest).size === a.size) {
180
181
  progress(`have ${name}`);
181
182
  }
182
183
  else {
@@ -192,13 +193,12 @@ async function downloadFullSigDb(opts = {}) {
192
193
  * pointer is committed. Lets a caller mount an already-synced bundle via `solver.sigdb.additionalPaths` without
193
194
  * hitting the network.
194
195
  */
195
- function syncedSigDbDir(opts = {}) {
196
+ function syncedSigDbDir() {
196
197
  const pointerPath = findRemotePointer();
197
198
  if (!pointerPath) {
198
199
  return undefined;
199
200
  }
200
- const tag = opts.version ? `sigdb-v${opts.version}` : readPointer(pointerPath).tag;
201
- return path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
201
+ return path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', readPointer(pointerPath).tag);
202
202
  }
203
203
  /** the GitHub release (`{repo, tag, url}`) the committed pointer downloads from, or `undefined` when no pointer is committed */
204
204
  function sigDbRemoteRelease() {
@@ -215,16 +215,37 @@ function sigDbRemoteRelease() {
215
215
  return undefined;
216
216
  }
217
217
  }
218
+ /** Fast presence check (existence + byte size only, no hashing) for the shards the committed pointer selects for this runtime; `false` when no pointer is committed or any selected shard is missing/wrong-size. */
219
+ function sigDbCacheComplete() {
220
+ const pointerPath = findRemotePointer();
221
+ if (!pointerPath) {
222
+ return false;
223
+ }
224
+ try {
225
+ const remote = readPointer(pointerPath);
226
+ const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(undefined, false), 'bundles', remote.tag);
227
+ return selectDownloadVariants(Object.keys(remote.shards)).every(name => {
228
+ try {
229
+ return fs_1.default.statSync(path_1.default.join(dir, name)).size === remote.shards[name].bytes;
230
+ }
231
+ catch {
232
+ return false;
233
+ }
234
+ });
235
+ }
236
+ catch {
237
+ return false;
238
+ }
239
+ }
218
240
  /** Startup check: `true` when a committed link file lists shards whose cached copies are missing or hash-mismatched */
219
- function sigDbNeedsSync(opts = {}) {
241
+ function sigDbNeedsSync() {
220
242
  const pointerPath = findRemotePointer();
221
243
  if (!pointerPath) {
222
244
  return false;
223
245
  }
224
246
  try {
225
247
  const remote = readPointer(pointerPath);
226
- const tag = opts.version ? `sigdb-v${opts.version}` : remote.tag;
227
- const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
248
+ const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', remote.tag);
228
249
  return Object.entries(remote.shards).some(([name, meta]) => {
229
250
  const dest = path_1.default.join(dir, name);
230
251
  return !fs_1.default.existsSync(dest) || (0, exports.sha256File)(dest) !== meta.sha256;
@@ -8,6 +8,9 @@ const assert_1 = require("../../../util/assert");
8
8
  * Executes the given configuration queries using the provided analyzer.
9
9
  */
10
10
  function executeConfigQuery({ analyzer }, queries) {
11
+ if (queries.some(q => q.reset)) {
12
+ analyzer.resetConfig();
13
+ }
11
14
  const updates = queries.map(q => q.update).filter(assert_1.isNotUndefined);
12
15
  if (updates.length > 1) {
13
16
  log_1.log.warn('Config query usually expects only up to one update, but got', updates.length);
@@ -13,6 +13,8 @@ export interface ConfigQuery extends BaseQueryFormat {
13
13
  readonly update?: DeepPartial<FlowrConfig>;
14
14
  /** a `.`-separated path to inspect (read) a single config value instead of dumping the whole config (repl: `path`, which also accepts a `*`/`**` glob) */
15
15
  readonly inspect?: readonly string[];
16
+ /** discard every runtime update made so far, reverting to the config the analyzer was created with (repl: `+reset`) */
17
+ readonly reset?: boolean;
16
18
  }
17
19
  export interface ConfigQueryResult extends BaseQueryResult {
18
20
  readonly config: FlowrConfig;
@@ -22,17 +24,17 @@ export interface ConfigQueryResult extends BaseQueryResult {
22
24
  readonly overwrite: DeepPartial<FlowrConfig>;
23
25
  };
24
26
  }
25
- declare function configReplCompleter(partialLine: readonly string[], startingNewArg: boolean, config: FlowrConfig): CommandCompletions;
27
+ declare function configReplCompleter(partialLine: readonly string[], startingNewArg: boolean, _config: FlowrConfig): CommandCompletions;
26
28
  /**
27
29
  * The first schema violation (an unknown key or a wrong-typed value) in a config update, or `undefined` if it is
28
30
  * valid. Shared by the repl line parser and the {@link executeConfigQuery|executor}, so a programmatic or JSON-API
29
31
  * update is validated exactly like a `:config +key=value` line and never merges junk or a mistyped value.
30
32
  */
31
33
  export declare function validateConfigUpdate(update: DeepPartial<FlowrConfig>, formatter?: OutputFormatter): string | undefined;
32
- declare function configQueryLineParser(output: ReplOutput, line: readonly string[], config: FlowrConfig): ParsedQueryLine<'config'>;
34
+ declare function configQueryLineParser(output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'config'>;
33
35
  export declare const ConfigQueryDefinition: {
34
36
  readonly title: "Config Query";
35
- readonly syntax: "@config [<path> | <glob>] | @config +<path>=<value>";
37
+ readonly syntax: "@config [<path> | <glob>] | @config +<path>=<value> | @config +reset";
36
38
  readonly executor: typeof executeConfigQuery;
37
39
  readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: unknown, queryResults: BaseQueryResult, result: string[], queries: readonly Query[]) => true;
38
40
  readonly completer: typeof configReplCompleter;
@@ -14,7 +14,7 @@ const json_1 = require("../../../util/json");
14
14
  const core_1 = require("../../../cli/repl/core");
15
15
  const schema_1 = require("../../../util/schema");
16
16
  const strings_1 = require("../../../util/text/strings");
17
- function configReplCompleter(partialLine, startingNewArg, config) {
17
+ function configReplCompleter(partialLine, startingNewArg, _config) {
18
18
  // the config query is a single token
19
19
  if (partialLine.length > 1 || (partialLine.length === 1 && startingNewArg)) {
20
20
  return { completions: [] };
@@ -43,21 +43,21 @@ function configReplCompleter(partialLine, startingNewArg, config) {
43
43
  // a glob reads several keys, so expand it to the paths it matches (the trailing segment completes as a prefix)
44
44
  if (!update && raw.includes('*')) {
45
45
  const matches = configGlobMatcher(raw.endsWith('*') ? raw : `${raw}*`);
46
- const found = [...configPaths(config)].filter(matches).map(p => p.join('.')).sort();
46
+ const found = sortConfigPaths(configPaths().filter(matches)).map(p => p.join('.'));
47
47
  return { completions: found, labels: new Map(found.map(p => [p, (0, core_1.describeCompletion)(p, configSchemaInfo(p.split('.')).type ?? '')])), preFiltered: true };
48
48
  }
49
49
  const path = raw.split('.').filter(p => p.length > 0);
50
50
  const fullPath = path.slice();
51
51
  const lastPath = token.endsWith('.') ? '' : path.pop() ?? '';
52
- /* the schema knows every option, a value only those that are set */
53
- const options = configSchemaKeys(path);
52
+ /* the schema knows every option, a value only those that are set; `reset` (top level, update only) is not a schema key but a fixed action */
53
+ const options = update && path.length === 0 ? [...configSchemaKeys(path), 'reset'] : configSchemaKeys(path);
54
54
  const atLeaf = lastPath.length > 0 && options.includes(lastPath) && configSchemaInfo([...path, lastPath]).type !== 'object';
55
55
  if (!atLeaf) {
56
56
  const offered = (0, strings_1.matchByPrefixOrSubsequence)(options, lastPath);
57
57
  const have = offered.map(k => `${sigil}${[...path, k].join('.')}`);
58
58
  if (have.length > 0) {
59
59
  // label starts with the full completion (incl. sigil) so readline keeps the sigil on common-prefix insertion
60
- return { completions: [...lead, ...have], labels: new Map([...leadLabels, ...have.map((c, i) => [c, (0, core_1.describeCompletion)(c, configSchemaInfo([...path, offered[i]]).type ?? '')])]) };
60
+ return { completions: [...lead, ...have], labels: new Map([...leadLabels, ...have.map((c, i) => [c, offered[i] === 'reset' && path.length === 0 ? (0, core_1.describeCompletion)(c, 'discard runtime config updates') : (0, core_1.describeCompletion)(c, configSchemaInfo([...path, offered[i]]).type ?? '')])]) };
61
61
  }
62
62
  else if (lastPath.length > 0 && configSchemaKeys(fullPath).length > 0) {
63
63
  return { completions: [`${sigil}${fullPath.join('.')}.`] };
@@ -79,16 +79,14 @@ function configReplCompleter(partialLine, startingNewArg, config) {
79
79
  }
80
80
  return { completions: [`${leaf}${update ? '=' : ''}`] };
81
81
  }
82
- /** every `.`-separated path in the config, intermediate objects included, for {@link configGlobMatcher} */
83
- function* configPaths(node, prefix = []) {
84
- if (prefix.length > 0) {
85
- yield [...prefix];
86
- }
87
- if (node !== null && typeof node === 'object' && !Array.isArray(node)) {
88
- for (const [key, value] of Object.entries(node)) {
89
- yield* configPaths(value, [...prefix, key]);
90
- }
91
- }
82
+ /** every `.`-separated path the config schema allows, intermediate objects included, for {@link configGlobMatcher} */
83
+ function configPaths() {
84
+ configSchemaDescription ??= config_1.FlowrConfig.Schema.describe();
85
+ return (0, schema_1.descriptionPaths)(configSchemaDescription);
86
+ }
87
+ /** shallower (fewer path segments) first, alphabetical among equally deep paths */
88
+ function sortConfigPaths(paths) {
89
+ return [...paths].sort((a, b) => a.length - b.length || a.join('.').localeCompare(b.join('.')));
92
90
  }
93
91
  /** matches a config path against a glob, `*` covering one segment and `**` any number (`**.enabled`, `solver.*`) */
94
92
  function configGlobMatcher(pattern) {
@@ -170,8 +168,11 @@ function validateConfigUpdate(update, formatter = ansi_1.voidFormatter) {
170
168
  }
171
169
  return undefined;
172
170
  }
173
- function configQueryLineParser(output, line, config) {
171
+ function configQueryLineParser(output, line, _config) {
174
172
  const first = line[0] ?? '';
173
+ if (first === '+reset') {
174
+ return { query: [{ type: 'config', reset: true }] };
175
+ }
175
176
  if (first.startsWith('+')) {
176
177
  const [pathPart, ...valueParts] = first.slice(1).split('=');
177
178
  // build the update object
@@ -185,7 +186,12 @@ function configQueryLineParser(output, line, config) {
185
186
  value = JSON.parse(raw); // numbers, booleans, arrays, ...
186
187
  }
187
188
  catch {
188
- value = raw; // fall back to a plain string
189
+ try {
190
+ value = JSON.parse(raw.replace(/'([^']*)'/g, (_, s) => JSON.stringify(s))); // allow 'single' quotes too
191
+ }
192
+ catch {
193
+ value = raw; // fall back to a plain string
194
+ }
189
195
  }
190
196
  const update = path.reduceRight((acc, key) => ({ [key]: acc }), value);
191
197
  const err = validateConfigUpdate(update, output.formatter);
@@ -199,7 +205,7 @@ function configQueryLineParser(output, line, config) {
199
205
  if (first.includes('*')) {
200
206
  // a glob reads several keys at once (inspection only, setting stays a single explicit key)
201
207
  const matches = configGlobMatcher(first);
202
- const found = [...configPaths(config)].filter(matches).sort((a, b) => a.join('.').localeCompare(b.join('.')));
208
+ const found = sortConfigPaths(configPaths().filter(matches));
203
209
  return found.length === 0
204
210
  ? configError(output, `No config key matches ${(0, ansi_1.bold)(first, output.formatter)}`)
205
211
  : { query: found.map(p => ({ type: 'config', inspect: p })) };
@@ -285,14 +291,17 @@ function inspectedChildren(value, path, formatter) {
285
291
  }
286
292
  exports.ConfigQueryDefinition = {
287
293
  title: 'Config Query',
288
- syntax: '@config [<path> | <glob>] | @config +<path>=<value>',
294
+ syntax: '@config [<path> | <glob>] | @config +<path>=<value> | @config +reset',
289
295
  executor: config_query_executor_1.executeConfigQuery,
290
296
  asciiSummarizer: (formatter, _analyzer, queryResults, result, queries) => {
291
297
  const out = queryResults;
292
298
  result.push(`Query: ${(0, ansi_1.bold)('config', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
293
299
  const configQueries = queries.filter(q => q.type === 'config');
294
300
  const inspects = configQueries.filter(q => q.inspect).map(q => q.inspect);
295
- if (configQueries.some(q => q.update)) {
301
+ if (configQueries.some(q => q.reset)) {
302
+ result.push(' ╰ Configuration reset to the analyzer\'s base config');
303
+ }
304
+ else if (configQueries.some(q => q.update)) {
296
305
  const updatedKeys = configQueries.flatMap(q => q.update ? collectKeysFromUpdate(q.update) : []);
297
306
  result.push(' ╰ Updated configuration:');
298
307
  for (const key of updatedKeys) {
@@ -333,7 +342,8 @@ exports.ConfigQueryDefinition = {
333
342
  schema: joi_1.default.object({
334
343
  type: joi_1.default.string().valid('config').required().description('The type of the query.'),
335
344
  update: joi_1.default.object().optional().description('An optional partial configuration to update the current configuration with before returning it. Only the provided fields will be updated, all other fields will remain unchanged.'),
336
- inspect: joi_1.default.array().items(joi_1.default.string()).optional().description('An optional `.`-separated path (as a string array) to read a single configuration value instead of returning the whole configuration.')
345
+ inspect: joi_1.default.array().items(joi_1.default.string()).optional().description('An optional `.`-separated path (as a string array) to read a single configuration value instead of returning the whole configuration.'),
346
+ reset: joi_1.default.boolean().optional().description('If true, discard every prior update and revert to the config the analyzer was created with, before returning it.')
337
347
  }).description('The config query retrieves the current configuration of the flowR instance and optionally also updates it.'),
338
348
  flattenInvolvedNodes: () => []
339
349
  };
@@ -56,16 +56,6 @@ export declare const DefaultDependencyCategories: {
56
56
  readonly queryDisplayName: "Tests";
57
57
  readonly functions: FunctionInfo[];
58
58
  };
59
- readonly undeclared: {
60
- readonly queryDisplayName: "Undeclared Dependencies";
61
- readonly functions: [];
62
- readonly additionalAnalysis: (data: BasicQueryData, ignoreDefault: boolean, _functions: FunctionInfo[], _queryResults: CallContextQueryResult, result: DependencyInfo[]) => Promise<void>;
63
- };
64
- readonly unused: {
65
- readonly queryDisplayName: "Unused Dependencies";
66
- readonly functions: [];
67
- readonly additionalAnalysis: (data: BasicQueryData, ignoreDefault: boolean, _functions: FunctionInfo[], _queryResults: CallContextQueryResult, result: DependencyInfo[]) => Promise<void>;
68
- };
69
59
  };
70
60
  export type DefaultDependencyCategoryName = keyof typeof DefaultDependencyCategories;
71
61
  export type DependencyCategoryName = DefaultDependencyCategoryName | string;
@@ -20,71 +20,6 @@ const identifier_1 = require("../../../dataflow/environments/identifier");
20
20
  const r_project_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
21
21
  const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
22
22
  exports.Unknown = 'unknown';
23
- /** packages a default R session attaches without an explicit `library()` call, so missing them is not "undeclared" */
24
- const AttachedBasePackages = ['base', 'stats', 'graphics', 'grDevices', 'utils', 'datasets', 'methods'];
25
- /** {@link LibraryFunctions} indexed by name, to recognise a library-load call by its called function */
26
- const LibraryLoadFunctionInfo = new Map(library_functions_1.LibraryFunctions.map(f => [f.name, f]));
27
- /** the literal package name of a `library()`/`require()`-style argument (a bare symbol or a plain string constant) */
28
- function literalPackageName(node) {
29
- if (node?.type === type_1.RType.String) {
30
- return node.content.str;
31
- }
32
- else if (node?.type === type_1.RType.Symbol) {
33
- return identifier_1.Identifier.getName(node.content);
34
- }
35
- return undefined;
36
- }
37
- /** the argument value(s) of a library-load call that (statically) name the package(s) to load, per the matching {@link FunctionInfo} */
38
- function libraryCallArgumentValues(args, info) {
39
- const values = [];
40
- let position = 0;
41
- for (const arg of args) {
42
- if (typeof arg !== 'string' && arg.value !== undefined) {
43
- if (info.argIdx === 'unnamed') {
44
- if (arg.name === undefined) {
45
- values.push(arg.value);
46
- }
47
- }
48
- else if (arg.name !== undefined ? identifier_1.Identifier.getName(arg.name.content) === info.argName : position === info.argIdx) {
49
- values.push(arg.value);
50
- }
51
- }
52
- position++;
53
- }
54
- return values;
55
- }
56
- /**
57
- * The packages used by the code: attached via a `library()`-style call, or referenced via `::`/`:::`.
58
- * Maps each package name to the node id of one representative use site.
59
- *
60
- * This deliberately re-walks the AST instead of depending on the `library` category's result array: categories
61
- * run concurrently (see the executor's `Promise.all`), so another category's finished results are not available.
62
- * Only statically known package names are picked up (a bare symbol or string literal argument), matching the
63
- * `library` category's own `::`/`:::` detection in spirit but staying independent of it.
64
- */
65
- async function collectUsedPackages(data) {
66
- const used = new Map();
67
- r_project_1.RProject.visitAst((await data.analyzer.normalize()).ast, node => {
68
- if (node.type === type_1.RType.Symbol) {
69
- const ns = identifier_1.Identifier.getNamespace(node.content);
70
- if (ns !== undefined && !used.has(ns)) {
71
- used.set(ns, node.info.id);
72
- }
73
- }
74
- else if (node.type === type_1.RType.FunctionCall && node.named) {
75
- const info = LibraryLoadFunctionInfo.get(identifier_1.Identifier.getName(node.functionName.content));
76
- if (info !== undefined) {
77
- for (const value of libraryCallArgumentValues(node.arguments, info)) {
78
- const pkg = literalPackageName(value);
79
- if (pkg !== undefined && !used.has(pkg)) {
80
- used.set(pkg, node.info.id);
81
- }
82
- }
83
- }
84
- }
85
- });
86
- return used;
87
- }
88
23
  exports.DefaultDependencyCategories = {
89
24
  'library': {
90
25
  queryDisplayName: 'Libraries',
@@ -133,44 +68,6 @@ exports.DefaultDependencyCategories = {
133
68
  'test': {
134
69
  queryDisplayName: 'Tests',
135
70
  functions: test_functions_1.TestFunctions
136
- },
137
- 'undeclared': {
138
- queryDisplayName: 'Undeclared Dependencies',
139
- functions: [],
140
- /* packages that are used (via `library()`/`require()` or `::`/`:::`) but never declared as a project dependency */
141
- additionalAnalysis: async (data, ignoreDefault, _functions, _queryResults, result) => {
142
- if (ignoreDefault) {
143
- return;
144
- }
145
- const deps = data.analyzer.inspectContext().deps;
146
- const declared = new Set(deps.getDependencies().map(p => p.name));
147
- for (const [pkg, nodeId] of await collectUsedPackages(data)) {
148
- if (!declared.has(pkg) && !AttachedBasePackages.includes(pkg)) {
149
- result.push({ nodeId, functionName: pkg, value: pkg });
150
- }
151
- }
152
- }
153
- },
154
- 'unused': {
155
- queryDisplayName: 'Unused Dependencies',
156
- functions: [],
157
- /* packages declared as a project dependency but never used (via `library()`/`require()` or `::`/`:::`) */
158
- additionalAnalysis: async (data, ignoreDefault, _functions, _queryResults, result) => {
159
- if (ignoreDefault) {
160
- return;
161
- }
162
- const deps = data.analyzer.inspectContext().deps;
163
- const used = await collectUsedPackages(data);
164
- const nodeId = (await data.analyzer.normalize()).ast.files[0]?.root.info.id;
165
- if (nodeId === undefined) {
166
- return;
167
- }
168
- for (const pkg of deps.getDependencies()) {
169
- if (!used.has(pkg.name)) {
170
- result.push({ nodeId, functionName: pkg.name, value: pkg.name });
171
- }
172
- }
173
- }
174
71
  }
175
72
  };
176
73
  function printResultSection(title, infos, result, formatter) {
@@ -212,9 +109,6 @@ exports.DependenciesQueryDefinition = {
212
109
  const out = queryResults;
213
110
  result.push(`Query: ${(0, ansi_1.bold)('dependencies', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
214
111
  for (const [category, value] of Object.entries(getAllCategories(queries))) {
215
- if (category === 'unused') {
216
- continue; // the unused-dependency detection is unreliable; omit it from the summary for now
217
- }
218
112
  printResultSection(value.queryDisplayName ?? category, out[category] ?? [], result, formatter);
219
113
  }
220
114
  return true;
@@ -6,6 +6,13 @@ const r_version_1 = require("../../../util/r-version");
6
6
  const objects_1 = require("../../../util/objects");
7
7
  const reader_1 = require("../../../project/sigdb/reader");
8
8
  const dependency_version_space_1 = require("../../../project/dependency-version-space");
9
+ /** the sources `query` disables: `clean` is sugar for disabling `declared`+`transitive`, `disabled` adds any others by name */
10
+ function disabledSources(query) {
11
+ if (!query.clean && !query.disabled?.length) {
12
+ return dependency_version_space_1.NoDisabledSources;
13
+ }
14
+ return new Set([...(query.clean ? ['declared', 'transitive'] : []), ...(query.disabled ?? [])]);
15
+ }
9
16
  /** collects and deduplicates provenance-carrying constraints */
10
17
  class EvidenceCollector {
11
18
  seen = new Set();
@@ -30,6 +37,8 @@ function mergeQueries(queries) {
30
37
  let maxCandidates;
31
38
  let maxIterations;
32
39
  let explode;
40
+ const disabled = new Set();
41
+ let anyClean = false;
33
42
  for (const q of queries) {
34
43
  if (q.packages) {
35
44
  for (const p of q.packages) {
@@ -54,6 +63,10 @@ function mergeQueries(queries) {
54
63
  maxIterations = maxIterations === undefined ? q.maxIterations : Math.max(maxIterations, q.maxIterations);
55
64
  }
56
65
  explode ??= q.explode;
66
+ anyClean ||= q.clean === true;
67
+ for (const s of q.disabled ?? []) {
68
+ disabled.add(s);
69
+ }
57
70
  }
58
71
  // keep the tightest date, or any malformed date to report it
59
72
  const date = earliestDate ?? anyDate;
@@ -63,7 +76,9 @@ function mergeQueries(queries) {
63
76
  ...(date ? { date } : {}),
64
77
  ...(maxCandidates !== undefined ? { maxCandidates } : {}),
65
78
  ...(maxIterations !== undefined ? { maxIterations } : {}),
66
- ...(explode ? { explode } : {})
79
+ ...(explode ? { explode } : {}),
80
+ ...(anyClean ? { clean: true } : {}),
81
+ ...(disabled.size > 0 ? { disabled: [...disabled] } : {})
67
82
  };
68
83
  }
69
84
  /** format version range string from survivors and declared constraints, honest about gaps */
@@ -150,12 +165,13 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
150
165
  }
151
166
  return entry;
152
167
  };
168
+ const disabled = disabledSources(query);
153
169
  // the guessed lower bound of every target under a set of transitive constraints (drives the mutual-constraint refinement)
154
170
  const guessLowerBounds = (trans) => {
155
171
  const out = new Map();
156
172
  for (const name of sorted) {
157
173
  const { key, src } = sourceFor(name);
158
- const s = (0, dependency_version_space_1.survivingEntries)(name, src, deps, usage.get(name), trans.get(name) ?? [], cutoff, rVersion, undefined, query.clean, key);
174
+ const s = (0, dependency_version_space_1.survivingEntries)(name, src, deps, usage.get(name), trans.get(name) ?? [], cutoff, rVersion, undefined, disabled, key);
159
175
  if (s.survivors.length > 0) {
160
176
  out.set(name, s.survivors[0].ver);
161
177
  }
@@ -164,7 +180,7 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
164
180
  };
165
181
  const maxIterations = query.maxIterations ?? dependency_version_space_1.DefaultFixpointIterations;
166
182
  let transitive = (0, dependency_version_space_1.collectTransitiveConstraints)(deps, sources);
167
- if (!query.clean) {
183
+ if (!disabled.has('transitive')) {
168
184
  let prev = '';
169
185
  (0, dependency_version_space_1.iterateToFixpoint)(maxIterations, () => {
170
186
  const pass = guessLowerBounds(transitive);
@@ -182,11 +198,11 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
182
198
  const guessedAll = sorted.map(name => {
183
199
  const { key, src } = sourceFor(name);
184
200
  const evidence = new EvidenceCollector();
185
- const surviving = (0, dependency_version_space_1.survivingEntries)(name, src, deps, usage.get(name), transitive.get(name) ?? [], cutoff, rVersion, evidence.add, query.clean, key);
201
+ const surviving = (0, dependency_version_space_1.survivingEntries)(name, src, deps, usage.get(name), transitive.get(name) ?? [], cutoff, rVersion, evidence.add, disabled, key);
186
202
  return { name, src, key, evidence, surviving };
187
203
  });
188
204
  const arcEntries = guessedAll.map(g => ({ name: g.name, src: g.src, key: g.key, survivors: g.surviving.survivors }));
189
- const blockers = query.clean ? new Map() : (0, dependency_version_space_1.enforceArcConsistency)(arcEntries, maxIterations);
205
+ const blockers = query.clean || disabled.has('indirect') ? new Map() : (0, dependency_version_space_1.enforceArcConsistency)(arcEntries, maxIterations);
190
206
  guessedAll.forEach((g, i) => {
191
207
  g.surviving = { ...g.surviving, survivors: arcEntries[i].survivors };
192
208
  const max = g.surviving.survivors.at(-1)?.ver;