sensemaking 0.18.0 → 0.18.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.
- package/README.md +1 -1
- package/dist/cjs/cli/status.js +20 -14
- package/dist/cjs/cli/status.js.map +1 -1
- package/dist/cjs/config/types.js.map +1 -1
- package/dist/cjs/output/column-hint.js +8 -7
- package/dist/cjs/output/column-hint.js.map +1 -1
- package/dist/cjs/scan/reparse.d.cts +6 -1
- package/dist/cjs/scan/reparse.d.ts +6 -1
- package/dist/cjs/scan/reparse.js +375 -48
- package/dist/cjs/scan/reparse.js.map +1 -1
- package/dist/cjs/scan/worker-error.d.cts +9 -0
- package/dist/cjs/scan/worker-error.d.ts +9 -0
- package/dist/cjs/scan/worker-error.js +44 -0
- package/dist/cjs/scan/worker-error.js.map +1 -0
- package/dist/cjs/store/duckdb/reconcile.js +8 -3
- package/dist/cjs/store/duckdb/reconcile.js.map +1 -1
- package/dist/cjs/store/index.d.cts +1 -0
- package/dist/cjs/store/index.d.ts +1 -0
- package/dist/cjs/store/index.js +15 -2
- package/dist/cjs/store/index.js.map +1 -1
- package/dist/cjs/store/sqlite/reconcile.js +13 -8
- package/dist/cjs/store/sqlite/reconcile.js.map +1 -1
- package/dist/cjs/watch.js +77 -58
- package/dist/cjs/watch.js.map +1 -1
- package/dist/cjs/workers/parse.d.cts +18 -0
- package/dist/cjs/workers/parse.d.ts +18 -0
- package/dist/cjs/workers/parse.js +43 -0
- package/dist/cjs/workers/parse.js.map +1 -0
- package/dist/esm/cli/status.js +6 -3
- package/dist/esm/cli/status.js.map +1 -1
- package/dist/esm/config/types.js.map +1 -1
- package/dist/esm/output/column-hint.js +8 -7
- package/dist/esm/output/column-hint.js.map +1 -1
- package/dist/esm/scan/reparse.d.ts +6 -1
- package/dist/esm/scan/reparse.js +108 -8
- package/dist/esm/scan/reparse.js.map +1 -1
- package/dist/esm/scan/worker-error.d.ts +9 -0
- package/dist/esm/scan/worker-error.js +19 -0
- package/dist/esm/scan/worker-error.js.map +1 -0
- package/dist/esm/store/duckdb/reconcile.js +1 -1
- package/dist/esm/store/duckdb/reconcile.js.map +1 -1
- package/dist/esm/store/index.d.ts +1 -0
- package/dist/esm/store/index.js +14 -2
- package/dist/esm/store/index.js.map +1 -1
- package/dist/esm/store/sqlite/reconcile.js +1 -1
- package/dist/esm/store/sqlite/reconcile.js.map +1 -1
- package/dist/esm/watch.js +30 -17
- package/dist/esm/watch.js.map +1 -1
- package/dist/esm/workers/parse.d.ts +18 -0
- package/dist/esm/workers/parse.js +25 -0
- package/dist/esm/workers/parse.js.map +1 -0
- package/package.json +3 -1
- package/skills/sense-setup/SKILL.md +1 -1
package/dist/cjs/scan/reparse.js
CHANGED
|
@@ -2,13 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get featuresForFile () {
|
|
13
|
+
return featuresForFile;
|
|
14
|
+
},
|
|
15
|
+
get reparseFiles () {
|
|
8
16
|
return reparseFiles;
|
|
9
17
|
}
|
|
10
18
|
});
|
|
19
|
+
var _nodemodule = require("node:module");
|
|
20
|
+
var _nodeos = require("node:os");
|
|
21
|
+
var _nodepath = require("node:path");
|
|
11
22
|
var _indexts = require("./index.js");
|
|
23
|
+
var _workererrorts = require("./worker-error.js");
|
|
12
24
|
function _array_like_to_array(arr, len) {
|
|
13
25
|
if (len == null || len > arr.length) len = arr.length;
|
|
14
26
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -17,6 +29,32 @@ function _array_like_to_array(arr, len) {
|
|
|
17
29
|
function _array_without_holes(arr) {
|
|
18
30
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
19
31
|
}
|
|
32
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
33
|
+
try {
|
|
34
|
+
var info = gen[key](arg);
|
|
35
|
+
var value = info.value;
|
|
36
|
+
} catch (error) {
|
|
37
|
+
reject(error);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (info.done) resolve(value);
|
|
41
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
42
|
+
}
|
|
43
|
+
function _async_to_generator(fn) {
|
|
44
|
+
return function() {
|
|
45
|
+
var self = this, args = arguments;
|
|
46
|
+
return new Promise(function(resolve, reject) {
|
|
47
|
+
var gen = fn.apply(self, args);
|
|
48
|
+
function _next(value) {
|
|
49
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
50
|
+
}
|
|
51
|
+
function _throw(err) {
|
|
52
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
53
|
+
}
|
|
54
|
+
_next(undefined);
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
}
|
|
20
58
|
function _iterable_to_array(iter) {
|
|
21
59
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
|
|
22
60
|
return Array.from(iter);
|
|
@@ -28,6 +66,105 @@ function _non_iterable_spread() {
|
|
|
28
66
|
function _to_consumable_array(arr) {
|
|
29
67
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
30
68
|
}
|
|
69
|
+
function _ts_generator(thisArg, body) {
|
|
70
|
+
var f, y, t, _ = {
|
|
71
|
+
label: 0,
|
|
72
|
+
sent: function() {
|
|
73
|
+
if (t[0] & 1) throw t[1];
|
|
74
|
+
return t[1];
|
|
75
|
+
},
|
|
76
|
+
trys: [],
|
|
77
|
+
ops: []
|
|
78
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
79
|
+
return d(g, "next", {
|
|
80
|
+
value: verb(0)
|
|
81
|
+
}), d(g, "throw", {
|
|
82
|
+
value: verb(1)
|
|
83
|
+
}), d(g, "return", {
|
|
84
|
+
value: verb(2)
|
|
85
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
86
|
+
value: function() {
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
}), g;
|
|
90
|
+
function verb(n) {
|
|
91
|
+
return function(v) {
|
|
92
|
+
return step([
|
|
93
|
+
n,
|
|
94
|
+
v
|
|
95
|
+
]);
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function step(op) {
|
|
99
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
100
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
101
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
102
|
+
if (y = 0, t) op = [
|
|
103
|
+
op[0] & 2,
|
|
104
|
+
t.value
|
|
105
|
+
];
|
|
106
|
+
switch(op[0]){
|
|
107
|
+
case 0:
|
|
108
|
+
case 1:
|
|
109
|
+
t = op;
|
|
110
|
+
break;
|
|
111
|
+
case 4:
|
|
112
|
+
_.label++;
|
|
113
|
+
return {
|
|
114
|
+
value: op[1],
|
|
115
|
+
done: false
|
|
116
|
+
};
|
|
117
|
+
case 5:
|
|
118
|
+
_.label++;
|
|
119
|
+
y = op[1];
|
|
120
|
+
op = [
|
|
121
|
+
0
|
|
122
|
+
];
|
|
123
|
+
continue;
|
|
124
|
+
case 7:
|
|
125
|
+
op = _.ops.pop();
|
|
126
|
+
_.trys.pop();
|
|
127
|
+
continue;
|
|
128
|
+
default:
|
|
129
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
130
|
+
_ = 0;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
134
|
+
_.label = op[1];
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
138
|
+
_.label = t[1];
|
|
139
|
+
t = op;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
if (t && _.label < t[2]) {
|
|
143
|
+
_.label = t[2];
|
|
144
|
+
_.ops.push(op);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
if (t[2]) _.ops.pop();
|
|
148
|
+
_.trys.pop();
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
op = body.call(thisArg, _);
|
|
152
|
+
} catch (e) {
|
|
153
|
+
op = [
|
|
154
|
+
6,
|
|
155
|
+
e
|
|
156
|
+
];
|
|
157
|
+
y = 0;
|
|
158
|
+
} finally{
|
|
159
|
+
f = t = 0;
|
|
160
|
+
}
|
|
161
|
+
if (op[0] & 5) throw op[1];
|
|
162
|
+
return {
|
|
163
|
+
value: op[0] ? op[1] : void 0,
|
|
164
|
+
done: true
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
31
168
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
32
169
|
if (!o) return;
|
|
33
170
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -36,51 +173,60 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
36
173
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
37
174
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
38
175
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
176
|
+
// Tinypool is ESM-only; our floor (>=22.20) has native require(esm), so the tier-2 house
|
|
177
|
+
// deferral reaches it. Deferred (not a top-level import) because most reconciles stay below
|
|
178
|
+
// DEFAULT_THRESHOLD and should not pay for constructing pool machinery they never use.
|
|
179
|
+
var _require = typeof require === 'undefined' ? (0, _nodemodule.createRequire)(require("url").pathToFileURL(__filename).toString()) : require;
|
|
180
|
+
// Measured 2026-08-29 on a 14-logical-core Apple M4 Pro: serial and pooled cross between 160
|
|
181
|
+
// and 180 files (pool fixed cost here is ~85-100ms, not the ~300ms a heavier module graph
|
|
182
|
+
// costs elsewhere), so 200 keeps a safety margin without giving up real wins. 8 workers matches
|
|
183
|
+
// an interleaved worker-count sweep at 6,566 files -- 8 and 10 tie within noise, 12+ trends
|
|
184
|
+
// worse (main-thread + OS contention on the 6 non-parse-worker cores).
|
|
185
|
+
var DEFAULT_THRESHOLD = 200;
|
|
186
|
+
var DEFAULT_MAX_WORKERS = 8;
|
|
187
|
+
// Worker MUST always load from dist/cjs/ (house pattern: install-module-linked,
|
|
188
|
+
// install-optional, node-version-install, node-exec-path all carry this same rule). A
|
|
189
|
+
// worker_threads thread is a fresh realm and does not inherit the main thread's TS loader
|
|
190
|
+
// hook, so a source path cannot work on any platform; dist/cjs loads from the esm and cjs
|
|
191
|
+
// builds alike. Root is found the way cli.ts finds it, so this also resolves when the suite
|
|
192
|
+
// runs against src/ (which already requires a build for the exports specs).
|
|
193
|
+
// Resolved on first pooled dispatch, not at import: a tree under the threshold never pools and
|
|
194
|
+
// must not pay for this, let alone fail on it.
|
|
195
|
+
var workerFile;
|
|
196
|
+
function resolveWorkerFile() {
|
|
197
|
+
if (workerFile) return workerFile;
|
|
198
|
+
var load = (0, _nodemodule.createRequire)(require("url").pathToFileURL(__filename).toString());
|
|
199
|
+
for(var _i = 0, _iter = [
|
|
200
|
+
'..',
|
|
201
|
+
'../..',
|
|
202
|
+
'../../..'
|
|
203
|
+
]; _i < _iter.length; _i++){
|
|
204
|
+
var rel = _iter[_i];
|
|
205
|
+
try {
|
|
206
|
+
if (load("".concat(rel, "/package.json")).name === 'sensemaking') {
|
|
207
|
+
workerFile = (0, _nodepath.join)((0, _nodepath.dirname)(load.resolve("".concat(rel, "/package.json"))), 'dist', 'cjs', 'workers', 'parse.js');
|
|
208
|
+
return workerFile;
|
|
209
|
+
}
|
|
210
|
+
} catch (unused) {}
|
|
211
|
+
}
|
|
212
|
+
throw new Error('cannot locate the sensemaking package root, so the parse worker cannot be found; run npm run build');
|
|
213
|
+
}
|
|
214
|
+
function featuresForFile(features, cfg, file) {
|
|
215
|
+
return features.filter(function(feature) {
|
|
216
|
+
return !feature.enabledForFile || feature.enabledForFile(cfg, file);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
function reparseSerial(files, features, cfg, onParsed) {
|
|
220
|
+
var results = [];
|
|
44
221
|
var done = 0;
|
|
45
222
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
46
223
|
try {
|
|
47
|
-
var
|
|
224
|
+
for(var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
48
225
|
var file = _step.value;
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
// FileStat.embed -- true iff the config names an embedding model).
|
|
52
|
-
var fileFeatures = features.filter(function(feature) {
|
|
53
|
-
return !feature.enabledForFile || feature.enabledForFile(cfg, file);
|
|
54
|
-
});
|
|
55
|
-
var _parseFile = (0, _indexts.parseFile)(file, fileFeatures, cfg), doc = _parseFile.doc, fileWarnings = _parseFile.warnings;
|
|
226
|
+
var fileFeatures = featuresForFile(features, cfg, file);
|
|
227
|
+
results.push((0, _indexts.parseFile)(file, fileFeatures, cfg));
|
|
56
228
|
onParsed === null || onParsed === void 0 ? void 0 : onParsed(++done);
|
|
57
|
-
|
|
58
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
59
|
-
try {
|
|
60
|
-
for(var _iterator = Object.keys(doc.data)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion = (_step1 = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
61
|
-
var key = _step1.value;
|
|
62
|
-
if (!seen.has(key)) {
|
|
63
|
-
seen.add(key);
|
|
64
|
-
newColumns.push(key);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
} catch (err) {
|
|
68
|
-
_didIteratorError = true;
|
|
69
|
-
_iteratorError = err;
|
|
70
|
-
} finally{
|
|
71
|
-
try {
|
|
72
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
73
|
-
_iterator.return();
|
|
74
|
-
}
|
|
75
|
-
} finally{
|
|
76
|
-
if (_didIteratorError) {
|
|
77
|
-
throw _iteratorError;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
docs.push(doc);
|
|
82
|
-
};
|
|
83
|
-
for(var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
229
|
+
}
|
|
84
230
|
} catch (err) {
|
|
85
231
|
_didIteratorError = true;
|
|
86
232
|
_iteratorError = err;
|
|
@@ -95,10 +241,191 @@ function reparseFiles(files, features, cfg, knownColumns, onParsed) {
|
|
|
95
241
|
}
|
|
96
242
|
}
|
|
97
243
|
}
|
|
98
|
-
return
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
244
|
+
return results;
|
|
245
|
+
}
|
|
246
|
+
// Never the tree: a worker task carries one FileStat and returns only what parseFile already
|
|
247
|
+
// returns -- extracted text and feature values, never an mdast tree. The worker reads the file
|
|
248
|
+
// itself. Pool created once here and destroyed once dispatch finishes; never per task.
|
|
249
|
+
function reparsePooled(files, features, cfg, onParsed, maxWorkers) {
|
|
250
|
+
return _async_to_generator(function() {
|
|
251
|
+
var Tinypool, workerData, pool, done, results, err;
|
|
252
|
+
return _ts_generator(this, function(_state) {
|
|
253
|
+
switch(_state.label){
|
|
254
|
+
case 0:
|
|
255
|
+
Tinypool = _require('tinypool').Tinypool;
|
|
256
|
+
// cfg and the caller's feature selection are constant for the whole dispatch, so they cross
|
|
257
|
+
// once per worker as workerData rather than once per file in the task payload. Features carry
|
|
258
|
+
// closures and cannot cross at all; their names can, and the worker resolves them back
|
|
259
|
+
// against the same registry, so a caller passing a subset gets that subset in both modes.
|
|
260
|
+
workerData = {
|
|
261
|
+
cfg: cfg,
|
|
262
|
+
featureNames: features.map(function(feature) {
|
|
263
|
+
return feature.name;
|
|
264
|
+
})
|
|
265
|
+
};
|
|
266
|
+
pool = new Tinypool({
|
|
267
|
+
filename: resolveWorkerFile(),
|
|
268
|
+
minThreads: maxWorkers,
|
|
269
|
+
maxThreads: maxWorkers,
|
|
270
|
+
workerData: workerData
|
|
271
|
+
});
|
|
272
|
+
done = 0;
|
|
273
|
+
_state.label = 1;
|
|
274
|
+
case 1:
|
|
275
|
+
_state.trys.push([
|
|
276
|
+
1,
|
|
277
|
+
4,
|
|
278
|
+
,
|
|
279
|
+
6
|
|
280
|
+
]);
|
|
281
|
+
return [
|
|
282
|
+
4,
|
|
283
|
+
Promise.all(files.map(function(file) {
|
|
284
|
+
return _async_to_generator(function() {
|
|
285
|
+
var result;
|
|
286
|
+
return _ts_generator(this, function(_state) {
|
|
287
|
+
switch(_state.label){
|
|
288
|
+
case 0:
|
|
289
|
+
return [
|
|
290
|
+
4,
|
|
291
|
+
pool.run(file)
|
|
292
|
+
];
|
|
293
|
+
case 1:
|
|
294
|
+
result = _state.sent();
|
|
295
|
+
if (!result.ok) throw (0, _workererrorts.reviveError)(result.error);
|
|
296
|
+
onParsed === null || onParsed === void 0 ? void 0 : onParsed(++done);
|
|
297
|
+
return [
|
|
298
|
+
2,
|
|
299
|
+
{
|
|
300
|
+
doc: result.doc,
|
|
301
|
+
warnings: result.warnings
|
|
302
|
+
}
|
|
303
|
+
];
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
})();
|
|
307
|
+
}))
|
|
308
|
+
];
|
|
309
|
+
case 2:
|
|
310
|
+
results = _state.sent();
|
|
311
|
+
return [
|
|
312
|
+
4,
|
|
313
|
+
pool.destroy()
|
|
314
|
+
];
|
|
315
|
+
case 3:
|
|
316
|
+
_state.sent();
|
|
317
|
+
return [
|
|
318
|
+
2,
|
|
319
|
+
results
|
|
320
|
+
];
|
|
321
|
+
case 4:
|
|
322
|
+
err = _state.sent();
|
|
323
|
+
// Tear the pool down before rethrowing, but never let a destroy failure replace the parse
|
|
324
|
+
// failure that caused it: that one names the file, this one names nothing. Not a `finally`
|
|
325
|
+
// for exactly that reason.
|
|
326
|
+
return [
|
|
327
|
+
4,
|
|
328
|
+
pool.destroy().catch(function() {})
|
|
329
|
+
];
|
|
330
|
+
case 5:
|
|
331
|
+
_state.sent();
|
|
332
|
+
throw err;
|
|
333
|
+
case 6:
|
|
334
|
+
return [
|
|
335
|
+
2
|
|
336
|
+
];
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
})();
|
|
340
|
+
}
|
|
341
|
+
function reparseFiles(_0, _1, _2, _3, _4) {
|
|
342
|
+
return _async_to_generator(function(files, features, cfg, knownColumns, onParsed) {
|
|
343
|
+
var options, _options_threshold, _options_maxWorkers, threshold, maxWorkers, results, _tmp, docs, warnings, newColumns, seen, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, doc, fileWarnings, _warnings, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, key;
|
|
344
|
+
var _arguments = arguments;
|
|
345
|
+
return _ts_generator(this, function(_state) {
|
|
346
|
+
switch(_state.label){
|
|
347
|
+
case 0:
|
|
348
|
+
options = _arguments.length > 5 && _arguments[5] !== void 0 ? _arguments[5] : {};
|
|
349
|
+
threshold = (_options_threshold = options.threshold) !== null && _options_threshold !== void 0 ? _options_threshold : DEFAULT_THRESHOLD;
|
|
350
|
+
maxWorkers = (_options_maxWorkers = options.maxWorkers) !== null && _options_maxWorkers !== void 0 ? _options_maxWorkers : Math.min(DEFAULT_MAX_WORKERS, (0, _nodeos.availableParallelism)());
|
|
351
|
+
if (!(files.length >= threshold)) return [
|
|
352
|
+
3,
|
|
353
|
+
2
|
|
354
|
+
];
|
|
355
|
+
return [
|
|
356
|
+
4,
|
|
357
|
+
reparsePooled(files, features, cfg, onParsed, maxWorkers)
|
|
358
|
+
];
|
|
359
|
+
case 1:
|
|
360
|
+
_tmp = _state.sent();
|
|
361
|
+
return [
|
|
362
|
+
3,
|
|
363
|
+
3
|
|
364
|
+
];
|
|
365
|
+
case 2:
|
|
366
|
+
_tmp = reparseSerial(files, features, cfg, onParsed);
|
|
367
|
+
_state.label = 3;
|
|
368
|
+
case 3:
|
|
369
|
+
results = _tmp;
|
|
370
|
+
docs = [];
|
|
371
|
+
warnings = [];
|
|
372
|
+
newColumns = [];
|
|
373
|
+
seen = new Set(knownColumns);
|
|
374
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
375
|
+
try {
|
|
376
|
+
for(_iterator = results[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
377
|
+
_step_value = _step.value, doc = _step_value.doc, fileWarnings = _step_value.warnings;
|
|
378
|
+
;
|
|
379
|
+
(_warnings = warnings).push.apply(_warnings, _to_consumable_array(fileWarnings));
|
|
380
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
381
|
+
try {
|
|
382
|
+
for(_iterator1 = Object.keys(doc.data)[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
383
|
+
key = _step1.value;
|
|
384
|
+
if (!seen.has(key)) {
|
|
385
|
+
seen.add(key);
|
|
386
|
+
newColumns.push(key);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
} catch (err) {
|
|
390
|
+
_didIteratorError1 = true;
|
|
391
|
+
_iteratorError1 = err;
|
|
392
|
+
} finally{
|
|
393
|
+
try {
|
|
394
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
395
|
+
_iterator1.return();
|
|
396
|
+
}
|
|
397
|
+
} finally{
|
|
398
|
+
if (_didIteratorError1) {
|
|
399
|
+
throw _iteratorError1;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
docs.push(doc);
|
|
404
|
+
}
|
|
405
|
+
} catch (err) {
|
|
406
|
+
_didIteratorError = true;
|
|
407
|
+
_iteratorError = err;
|
|
408
|
+
} finally{
|
|
409
|
+
try {
|
|
410
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
411
|
+
_iterator.return();
|
|
412
|
+
}
|
|
413
|
+
} finally{
|
|
414
|
+
if (_didIteratorError) {
|
|
415
|
+
throw _iteratorError;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return [
|
|
420
|
+
2,
|
|
421
|
+
{
|
|
422
|
+
docs: docs,
|
|
423
|
+
warnings: warnings,
|
|
424
|
+
newColumns: newColumns
|
|
425
|
+
}
|
|
426
|
+
];
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
}).apply(this, arguments);
|
|
103
430
|
}
|
|
104
431
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/scan/reparse.ts"],"sourcesContent":["import type { Config } from '../config/index.ts';\nimport type { Feature } from '../features/types.ts';\nimport type { ParsedDoc } from './index.ts';\nimport { parseFile } from './index.ts';\nimport type { FileStat } from './list.ts';\n\n// Store-agnostic per-file parse pass shared by every store's reconcile(). Index-preserving by\n// construction (one pass over `files`, pushed in order) so a future concurrent dispatch can\n// replace the loop body without changing this contract or either call site.\nexport interface ReparseResult {\n docs: ParsedDoc[];\n warnings: string[];\n // Frontmatter keys not in `knownColumns`, first-seen order across `files` -- the order\n // callers ALTER TABLE ADD COLUMN in.\n newColumns: string[];\n}\n\n// `onParsed` receives the running count (1-based) after each file, mirroring a Progress.tick\n// call; pass one in to keep progress reporting working without this module owning a reporter.\nexport function reparseFiles(files: FileStat[], features: Feature[], cfg: Config, knownColumns: ReadonlySet<string>, onParsed?: (done: number) => void): ReparseResult {\n const docs: ParsedDoc[] = [];\n const warnings: string[] = [];\n const newColumns: string[] = [];\n const seen = new Set(knownColumns);\n let done = 0;\n\n for (const file of files) {\n // A doc only gets extract/store from features that apply to it (currently: embed, via\n // FileStat.embed -- true iff the config names an embedding model).\n const fileFeatures = features.filter((feature) => !feature.enabledForFile || feature.enabledForFile(cfg, file));\n const { doc, warnings: fileWarnings } = parseFile(file, fileFeatures, cfg);\n onParsed?.(++done);\n warnings.push(...fileWarnings);\n for (const key of Object.keys(doc.data)) {\n if (!seen.has(key)) {\n seen.add(key);\n newColumns.push(key);\n }\n }\n docs.push(doc);\n }\n\n return { docs, warnings, newColumns };\n}\n"],"names":["reparseFiles","files","features","cfg","knownColumns","onParsed","docs","warnings","newColumns","seen","Set","done","file","fileFeatures","filter","feature","enabledForFile","parseFile","doc","fileWarnings","push","Object","keys","data","key","has","add"],"mappings":";;;;+BAmBgBA;;;eAAAA;;;uBAhBU;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBnB,SAASA,aAAaC,KAAiB,EAAEC,QAAmB,EAAEC,GAAW,EAAEC,YAAiC,EAAEC,QAAiC;IACpJ,IAAMC,OAAoB,EAAE;IAC5B,IAAMC,WAAqB,EAAE;IAC7B,IAAMC,aAAuB,EAAE;IAC/B,IAAMC,OAAO,IAAIC,IAAIN;IACrB,IAAIO,OAAO;QAEN,kCAAA,2BAAA;;;YAAA,IAAMC,OAAN;gBAMHL;YALA,sFAAsF;YACtF,mEAAmE;YACnE,IAAMM,eAAeX,SAASY,MAAM,CAAC,SAACC;uBAAY,CAACA,QAAQC,cAAc,IAAID,QAAQC,cAAc,CAACb,KAAKS;;YACzG,IAAwCK,aAAAA,IAAAA,kBAAS,EAACL,MAAMC,cAAcV,MAA9De,MAAgCD,WAAhCC,KAAKX,AAAUY,eAAiBF,WAA3BV;YACbF,qBAAAA,+BAAAA,SAAW,EAAEM;YACbJ,CAAAA,YAAAA,UAASa,IAAI,OAAbb,WAAc,qBAAGY;gBACZ,kCAAA,2BAAA;;gBAAL,QAAK,YAAaE,OAAOC,IAAI,CAACJ,IAAIK,IAAI,sBAAjC,UAAA,6BAAA,SAAA,yBAAA,iCAAoC;oBAApC,IAAMC,MAAN;oBACH,IAAI,CAACf,KAAKgB,GAAG,CAACD,MAAM;wBAClBf,KAAKiB,GAAG,CAACF;wBACThB,WAAWY,IAAI,CAACI;oBAClB;gBACF;;gBALK;gBAAA;;;yBAAA,6BAAA;wBAAA;;;wBAAA;8BAAA;;;;YAMLlB,KAAKc,IAAI,CAACF;QACZ;QAdA,QAAK,YAAcjB,0BAAd,SAAA,6BAAA,QAAA,yBAAA;;QAAA;QAAA;;;iBAAA,6BAAA;gBAAA;;;gBAAA;sBAAA;;;;IAgBL,OAAO;QAAEK,MAAAA;QAAMC,UAAAA;QAAUC,YAAAA;IAAW;AACtC"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/scan/reparse.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { availableParallelism } from 'node:os';\nimport { dirname, join } from 'node:path';\n// Type-only: erased at build, but keeps depcheck's usage check satisfied for the tier-2\n// `_require` below (see coding-standards' deferral tiers).\nimport type * as TinypoolNS from 'tinypool';\nimport type { Config } from '../config/index.ts';\nimport type { Feature } from '../features/types.ts';\nimport type { ParseTask, ParseTaskResult, ParseWorkerData } from '../workers/parse.ts';\nimport type { ParsedDoc } from './index.ts';\nimport { parseFile } from './index.ts';\nimport type { FileStat } from './list.ts';\nimport { reviveError } from './worker-error.ts';\n\n// Tinypool is ESM-only; our floor (>=22.20) has native require(esm), so the tier-2 house\n// deferral reaches it. Deferred (not a top-level import) because most reconciles stay below\n// DEFAULT_THRESHOLD and should not pay for constructing pool machinery they never use.\nconst _require = typeof require === 'undefined' ? createRequire(import.meta.url) : require;\n\n// Store-agnostic per-file parse pass shared by every store's reconcile(). Index-preserving by\n// construction (one pass over `files`, pushed in order) so a future concurrent dispatch can\n// replace the loop body without changing this contract or either call site.\nexport interface ReparseResult {\n docs: ParsedDoc[];\n warnings: string[];\n // Frontmatter keys not in `knownColumns`, first-seen order across `files` -- the order\n // callers ALTER TABLE ADD COLUMN in.\n newColumns: string[];\n}\n\nexport interface ReparseOptions {\n // Overrides DEFAULT_THRESHOLD below, so tests can force either dispatch mode without\n // needing thousands of fixture files. Internal: no caller in src/ passes it.\n threshold?: number;\n // Overrides DEFAULT_MAX_WORKERS below.\n maxWorkers?: number;\n}\n\n// Measured 2026-08-29 on a 14-logical-core Apple M4 Pro: serial and pooled cross between 160\n// and 180 files (pool fixed cost here is ~85-100ms, not the ~300ms a heavier module graph\n// costs elsewhere), so 200 keeps a safety margin without giving up real wins. 8 workers matches\n// an interleaved worker-count sweep at 6,566 files -- 8 and 10 tie within noise, 12+ trends\n// worse (main-thread + OS contention on the 6 non-parse-worker cores).\nconst DEFAULT_THRESHOLD = 200;\nconst DEFAULT_MAX_WORKERS = 8;\n\n// Worker MUST always load from dist/cjs/ (house pattern: install-module-linked,\n// install-optional, node-version-install, node-exec-path all carry this same rule). A\n// worker_threads thread is a fresh realm and does not inherit the main thread's TS loader\n// hook, so a source path cannot work on any platform; dist/cjs loads from the esm and cjs\n// builds alike. Root is found the way cli.ts finds it, so this also resolves when the suite\n// runs against src/ (which already requires a build for the exports specs).\n// Resolved on first pooled dispatch, not at import: a tree under the threshold never pools and\n// must not pay for this, let alone fail on it.\nlet workerFile: string | undefined;\nfunction resolveWorkerFile(): string {\n if (workerFile) return workerFile;\n const load = createRequire(import.meta.url);\n for (const rel of ['..', '../..', '../../..']) {\n try {\n if ((load(`${rel}/package.json`) as { name?: string }).name === 'sensemaking') {\n workerFile = join(dirname(load.resolve(`${rel}/package.json`)), 'dist', 'cjs', 'workers', 'parse.js');\n return workerFile;\n }\n } catch {}\n }\n throw new Error('cannot locate the sensemaking package root, so the parse worker cannot be found; run npm run build');\n}\n\ntype FileResult = { doc: ParsedDoc; warnings: string[] };\n\n// Per-file feature filtering, shared by the serial loop (which reads `features` straight from\n// the caller, real registry or a test double) and the worker path (which can only pass `cfg`\n// across the thread boundary, so it derives `features` from activeFeatures(cfg) itself).\nexport function featuresForFile(features: Feature[], cfg: Config, file: FileStat): Feature[] {\n return features.filter((feature) => !feature.enabledForFile || feature.enabledForFile(cfg, file));\n}\n\nfunction reparseSerial(files: FileStat[], features: Feature[], cfg: Config, onParsed?: (done: number) => void): FileResult[] {\n const results: FileResult[] = [];\n let done = 0;\n for (const file of files) {\n const fileFeatures = featuresForFile(features, cfg, file);\n results.push(parseFile(file, fileFeatures, cfg));\n onParsed?.(++done);\n }\n return results;\n}\n\n// Never the tree: a worker task carries one FileStat and returns only what parseFile already\n// returns -- extracted text and feature values, never an mdast tree. The worker reads the file\n// itself. Pool created once here and destroyed once dispatch finishes; never per task.\nasync function reparsePooled(files: FileStat[], features: Feature[], cfg: Config, onParsed: ((done: number) => void) | undefined, maxWorkers: number): Promise<FileResult[]> {\n const { Tinypool } = _require('tinypool') as typeof TinypoolNS;\n // cfg and the caller's feature selection are constant for the whole dispatch, so they cross\n // once per worker as workerData rather than once per file in the task payload. Features carry\n // closures and cannot cross at all; their names can, and the worker resolves them back\n // against the same registry, so a caller passing a subset gets that subset in both modes.\n const workerData: ParseWorkerData = { cfg, featureNames: features.map((feature) => feature.name) };\n const pool = new Tinypool({ filename: resolveWorkerFile(), minThreads: maxWorkers, maxThreads: maxWorkers, workerData });\n let done = 0;\n try {\n // Promise.all over a mapped array is load-bearing: the resolved array keeps `files`\n // order regardless of which task finishes first, which is what first-seen column order\n // and warning order depend on downstream. Progress ticks fire in completion order instead\n // (only the count matters for a progress bar) -- free, since it rides the same per-task\n // response tinypool already sends, no extra ping.\n const results = await Promise.all(\n files.map(async (file): Promise<FileResult> => {\n const result = (await pool.run(file as ParseTask)) as ParseTaskResult;\n if (!result.ok) throw reviveError(result.error);\n onParsed?.(++done);\n return { doc: result.doc, warnings: result.warnings };\n })\n );\n await pool.destroy();\n return results;\n } catch (err) {\n // Tear the pool down before rethrowing, but never let a destroy failure replace the parse\n // failure that caused it: that one names the file, this one names nothing. Not a `finally`\n // for exactly that reason.\n await pool.destroy().catch(() => {});\n throw err;\n }\n}\n\n// `onParsed` receives the running count (1-based) after each file, mirroring a Progress.tick\n// call; pass one in to keep progress reporting working without this module owning a reporter.\nexport async function reparseFiles(files: FileStat[], features: Feature[], cfg: Config, knownColumns: ReadonlySet<string>, onParsed?: (done: number) => void, options: ReparseOptions = {}): Promise<ReparseResult> {\n const threshold = options.threshold ?? DEFAULT_THRESHOLD;\n const maxWorkers = options.maxWorkers ?? Math.min(DEFAULT_MAX_WORKERS, availableParallelism());\n const results = files.length >= threshold ? await reparsePooled(files, features, cfg, onParsed, maxWorkers) : reparseSerial(files, features, cfg, onParsed);\n\n const docs: ParsedDoc[] = [];\n const warnings: string[] = [];\n const newColumns: string[] = [];\n const seen = new Set(knownColumns);\n for (const { doc, warnings: fileWarnings } of results) {\n warnings.push(...fileWarnings);\n for (const key of Object.keys(doc.data)) {\n if (!seen.has(key)) {\n seen.add(key);\n newColumns.push(key);\n }\n }\n docs.push(doc);\n }\n\n return { docs, warnings, newColumns };\n}\n"],"names":["featuresForFile","reparseFiles","_require","require","createRequire","DEFAULT_THRESHOLD","DEFAULT_MAX_WORKERS","workerFile","resolveWorkerFile","load","rel","name","join","dirname","resolve","Error","features","cfg","file","filter","feature","enabledForFile","reparseSerial","files","onParsed","results","done","fileFeatures","push","parseFile","reparsePooled","maxWorkers","Tinypool","workerData","pool","err","featureNames","map","filename","minThreads","maxThreads","Promise","all","result","run","ok","reviveError","error","doc","warnings","destroy","catch","knownColumns","options","threshold","docs","newColumns","seen","fileWarnings","key","Math","min","availableParallelism","length","Set","Object","keys","data","has","add"],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type SenseErrorCode } from '../errors.js';
|
|
2
|
+
export interface WorkerErrorPayload {
|
|
3
|
+
name: string;
|
|
4
|
+
code?: SenseErrorCode;
|
|
5
|
+
message: string;
|
|
6
|
+
stack?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function serializeError(err: unknown): WorkerErrorPayload;
|
|
9
|
+
export declare function reviveError(payload: WorkerErrorPayload): Error;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type SenseErrorCode } from '../errors.js';
|
|
2
|
+
export interface WorkerErrorPayload {
|
|
3
|
+
name: string;
|
|
4
|
+
code?: SenseErrorCode;
|
|
5
|
+
message: string;
|
|
6
|
+
stack?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function serializeError(err: unknown): WorkerErrorPayload;
|
|
9
|
+
export declare function reviveError(payload: WorkerErrorPayload): Error;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get reviveError () {
|
|
13
|
+
return reviveError;
|
|
14
|
+
},
|
|
15
|
+
get serializeError () {
|
|
16
|
+
return serializeError;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _errorsts = require("../errors.js");
|
|
20
|
+
function _instanceof(left, right) {
|
|
21
|
+
"@swc/helpers - instanceof";
|
|
22
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
23
|
+
return !!right[Symbol.hasInstance](left);
|
|
24
|
+
} else return left instanceof right;
|
|
25
|
+
}
|
|
26
|
+
function serializeError(err) {
|
|
27
|
+
if (_instanceof(err, Error)) return {
|
|
28
|
+
name: err.name,
|
|
29
|
+
code: _instanceof(err, _errorsts.SenseError) ? err.code : undefined,
|
|
30
|
+
message: err.message,
|
|
31
|
+
stack: err.stack
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
name: 'Error',
|
|
35
|
+
message: String(err)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function reviveError(payload) {
|
|
39
|
+
var err = payload.code ? new _errorsts.SenseError(payload.code, payload.message) : new Error(payload.message);
|
|
40
|
+
err.name = payload.name;
|
|
41
|
+
if (payload.stack) err.stack = payload.stack;
|
|
42
|
+
return err;
|
|
43
|
+
}
|
|
44
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/scan/worker-error.ts"],"sourcesContent":["import { SenseError, type SenseErrorCode } from '../errors.ts';\n\n// Structured clone across a worker_threads boundary drops a subclass and its custom\n// properties, so a SenseError arrives as a plain Error with `code` undefined -- and `code`\n// drives caller behavior. The worker serializes explicitly (computed on its side, where\n// `instanceof SenseError` is still meaningful) and the main thread rebuilds by hand.\nexport interface WorkerErrorPayload {\n name: string;\n code?: SenseErrorCode;\n message: string;\n stack?: string;\n}\n\nexport function serializeError(err: unknown): WorkerErrorPayload {\n if (err instanceof Error) return { name: err.name, code: err instanceof SenseError ? err.code : undefined, message: err.message, stack: err.stack };\n return { name: 'Error', message: String(err) };\n}\n\nexport function reviveError(payload: WorkerErrorPayload): Error {\n const err = payload.code ? new SenseError(payload.code, payload.message) : new Error(payload.message);\n err.name = payload.name;\n if (payload.stack) err.stack = payload.stack;\n return err;\n}\n"],"names":["reviveError","serializeError","err","Error","name","code","SenseError","undefined","message","stack","String","payload"],"mappings":";;;;;;;;;;;QAkBgBA;eAAAA;;QALAC;eAAAA;;;wBAbgC;;;;;;;AAazC,SAASA,eAAeC,GAAY;IACzC,IAAIA,AAAG,YAAHA,KAAeC,QAAO,OAAO;QAAEC,MAAMF,IAAIE,IAAI;QAAEC,MAAMH,AAAG,YAAHA,KAAeI,oBAAU,IAAGJ,IAAIG,IAAI,GAAGE;QAAWC,SAASN,IAAIM,OAAO;QAAEC,OAAOP,IAAIO,KAAK;IAAC;IAClJ,OAAO;QAAEL,MAAM;QAASI,SAASE,OAAOR;IAAK;AAC/C;AAEO,SAASF,YAAYW,OAA2B;IACrD,IAAMT,MAAMS,QAAQN,IAAI,GAAG,IAAIC,oBAAU,CAACK,QAAQN,IAAI,EAAEM,QAAQH,OAAO,IAAI,IAAIL,MAAMQ,QAAQH,OAAO;IACpGN,IAAIE,IAAI,GAAGO,QAAQP,IAAI;IACvB,IAAIO,QAAQF,KAAK,EAAEP,IAAIO,KAAK,GAAGE,QAAQF,KAAK;IAC5C,OAAOP;AACT"}
|
|
@@ -219,7 +219,7 @@ function contentRow(doc) {
|
|
|
219
219
|
var MAX_FRONTMATTER_COLUMNS = 10000;
|
|
220
220
|
function reconcile(conn, cfg, baseDir) {
|
|
221
221
|
return _async_to_generator(function() {
|
|
222
|
-
var files, currentSet, existingStmt, existingRows, existing, vanished, toReparse, features, seenColumns, report,
|
|
222
|
+
var files, currentSet, existingStmt, existingRows, existing, vanished, toReparse, features, seenColumns, report, _ref, parsedDocs, warnings, newColumns, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, col, allColumns, writableColumns, insertSql, added, delta, addedSet, reparsedExisting;
|
|
223
223
|
return _ts_generator(this, function(_state) {
|
|
224
224
|
switch(_state.label){
|
|
225
225
|
case 0:
|
|
@@ -269,7 +269,12 @@ function reconcile(conn, cfg, baseDir) {
|
|
|
269
269
|
case 3:
|
|
270
270
|
seenColumns = _state.sent();
|
|
271
271
|
report = (0, _progressts.progress)('reparsing files', toReparse.length);
|
|
272
|
-
|
|
272
|
+
return [
|
|
273
|
+
4,
|
|
274
|
+
(0, _reparsets.reparseFiles)(toReparse, features, cfg, seenColumns, report.tick)
|
|
275
|
+
];
|
|
276
|
+
case 4:
|
|
277
|
+
_ref = _state.sent(), parsedDocs = _ref.docs, warnings = _ref.warnings, newColumns = _ref.newColumns;
|
|
273
278
|
report.finish();
|
|
274
279
|
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
275
280
|
try {
|
|
@@ -737,7 +742,7 @@ function reconcile(conn, cfg, baseDir) {
|
|
|
737
742
|
})();
|
|
738
743
|
})
|
|
739
744
|
];
|
|
740
|
-
case
|
|
745
|
+
case 5:
|
|
741
746
|
_state.sent();
|
|
742
747
|
return [
|
|
743
748
|
2,
|