sensemaking 0.1.0
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/LICENSE +21 -0
- package/README.md +132 -0
- package/bin/cli.js +5 -0
- package/dist/cjs/cli.d.cts +1 -0
- package/dist/cjs/cli.d.ts +1 -0
- package/dist/cjs/cli.js +422 -0
- package/dist/cjs/cli.js.map +1 -0
- package/dist/cjs/config.d.cts +18 -0
- package/dist/cjs/config.d.ts +18 -0
- package/dist/cjs/config.js +147 -0
- package/dist/cjs/config.js.map +1 -0
- package/dist/cjs/db.d.cts +20 -0
- package/dist/cjs/db.d.ts +20 -0
- package/dist/cjs/db.js +326 -0
- package/dist/cjs/db.js.map +1 -0
- package/dist/cjs/errors.d.cts +5 -0
- package/dist/cjs/errors.d.ts +5 -0
- package/dist/cjs/errors.js +134 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.d.cts +12 -0
- package/dist/cjs/index.d.ts +12 -0
- package/dist/cjs/index.js +76 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/output.d.cts +2 -0
- package/dist/cjs/output.d.ts +2 -0
- package/dist/cjs/output.js +90 -0
- package/dist/cjs/output.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/scan.d.cts +18 -0
- package/dist/cjs/scan.d.ts +18 -0
- package/dist/cjs/scan.js +113 -0
- package/dist/cjs/scan.js.map +1 -0
- package/dist/cjs/watch.d.cts +19 -0
- package/dist/cjs/watch.d.ts +19 -0
- package/dist/cjs/watch.js +237 -0
- package/dist/cjs/watch.js.map +1 -0
- package/dist/esm/cli.d.ts +1 -0
- package/dist/esm/cli.js +171 -0
- package/dist/esm/cli.js.map +1 -0
- package/dist/esm/config.d.ts +18 -0
- package/dist/esm/config.js +78 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/db.d.ts +20 -0
- package/dist/esm/db.js +176 -0
- package/dist/esm/db.js.map +1 -0
- package/dist/esm/errors.d.ts +5 -0
- package/dist/esm/errors.js +10 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/output.d.ts +2 -0
- package/dist/esm/output.js +25 -0
- package/dist/esm/output.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/scan.d.ts +18 -0
- package/dist/esm/scan.js +69 -0
- package/dist/esm/scan.js.map +1 -0
- package/dist/esm/watch.d.ts +19 -0
- package/dist/esm/watch.js +93 -0
- package/dist/esm/watch.js.map +1 -0
- package/package.json +63 -0
- package/schema.json +38 -0
- package/skills/sense/SKILL.md +95 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Typed errors for library modules. Library code (config.ts, scan.ts,
|
|
2
|
+
// db.ts, watch.ts) never calls process.exit and never prints -- it throws.
|
|
3
|
+
// Only cli.ts catches, prints the message, and maps it to an exit code.
|
|
4
|
+
"use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "SenseError", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function() {
|
|
11
|
+
return SenseError;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
function _assert_this_initialized(self) {
|
|
15
|
+
if (self === void 0) {
|
|
16
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
17
|
+
}
|
|
18
|
+
return self;
|
|
19
|
+
}
|
|
20
|
+
function _call_super(_this, derived, args) {
|
|
21
|
+
derived = _get_prototype_of(derived);
|
|
22
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
23
|
+
}
|
|
24
|
+
function _class_call_check(instance, Constructor) {
|
|
25
|
+
if (!(instance instanceof Constructor)) {
|
|
26
|
+
throw new TypeError("Cannot call a class as a function");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function _construct(Parent, args, Class) {
|
|
30
|
+
if (_is_native_reflect_construct()) {
|
|
31
|
+
_construct = Reflect.construct;
|
|
32
|
+
} else {
|
|
33
|
+
_construct = function construct(Parent, args, Class) {
|
|
34
|
+
var a = [
|
|
35
|
+
null
|
|
36
|
+
];
|
|
37
|
+
a.push.apply(a, args);
|
|
38
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
39
|
+
var instance = new Constructor();
|
|
40
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
41
|
+
return instance;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return _construct.apply(null, arguments);
|
|
45
|
+
}
|
|
46
|
+
function _get_prototype_of(o) {
|
|
47
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
48
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
49
|
+
};
|
|
50
|
+
return _get_prototype_of(o);
|
|
51
|
+
}
|
|
52
|
+
function _inherits(subClass, superClass) {
|
|
53
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
54
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
55
|
+
}
|
|
56
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
57
|
+
constructor: {
|
|
58
|
+
value: subClass,
|
|
59
|
+
writable: true,
|
|
60
|
+
configurable: true
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
64
|
+
}
|
|
65
|
+
function _is_native_function(fn) {
|
|
66
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
67
|
+
}
|
|
68
|
+
function _possible_constructor_return(self, call) {
|
|
69
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
70
|
+
return call;
|
|
71
|
+
}
|
|
72
|
+
return _assert_this_initialized(self);
|
|
73
|
+
}
|
|
74
|
+
function _set_prototype_of(o, p) {
|
|
75
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
76
|
+
o.__proto__ = p;
|
|
77
|
+
return o;
|
|
78
|
+
};
|
|
79
|
+
return _set_prototype_of(o, p);
|
|
80
|
+
}
|
|
81
|
+
function _type_of(obj) {
|
|
82
|
+
"@swc/helpers - typeof";
|
|
83
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
84
|
+
}
|
|
85
|
+
function _wrap_native_super(Class) {
|
|
86
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
87
|
+
_wrap_native_super = function wrapNativeSuper(Class) {
|
|
88
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
89
|
+
if (typeof Class !== "function") {
|
|
90
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
91
|
+
}
|
|
92
|
+
if (typeof _cache !== "undefined") {
|
|
93
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
94
|
+
_cache.set(Class, Wrapper);
|
|
95
|
+
}
|
|
96
|
+
function Wrapper() {
|
|
97
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
98
|
+
}
|
|
99
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
100
|
+
constructor: {
|
|
101
|
+
value: Wrapper,
|
|
102
|
+
enumerable: false,
|
|
103
|
+
writable: true,
|
|
104
|
+
configurable: true
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return _set_prototype_of(Wrapper, Class);
|
|
108
|
+
};
|
|
109
|
+
return _wrap_native_super(Class);
|
|
110
|
+
}
|
|
111
|
+
function _is_native_reflect_construct() {
|
|
112
|
+
try {
|
|
113
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
114
|
+
} catch (_) {}
|
|
115
|
+
return (_is_native_reflect_construct = function() {
|
|
116
|
+
return !!result;
|
|
117
|
+
})();
|
|
118
|
+
}
|
|
119
|
+
var SenseError = /*#__PURE__*/ function(Error1) {
|
|
120
|
+
"use strict";
|
|
121
|
+
_inherits(SenseError, Error1);
|
|
122
|
+
function SenseError(code, message) {
|
|
123
|
+
_class_call_check(this, SenseError);
|
|
124
|
+
var _this;
|
|
125
|
+
_this = _call_super(this, SenseError, [
|
|
126
|
+
message
|
|
127
|
+
]);
|
|
128
|
+
_this.name = 'SenseError';
|
|
129
|
+
_this.code = code;
|
|
130
|
+
return _this;
|
|
131
|
+
}
|
|
132
|
+
return SenseError;
|
|
133
|
+
}(_wrap_native_super(Error));
|
|
134
|
+
/* 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/errors.ts"],"sourcesContent":["// Typed errors for library modules. Library code (config.ts, scan.ts,\n// db.ts, watch.ts) never calls process.exit and never prints -- it throws.\n// Only cli.ts catches, prints the message, and maps it to an exit code.\nexport type SenseErrorCode = 'CONFIG_NOT_FOUND' | 'CONFIG_EXISTS' | 'CONFIG_VERSION_UNSUPPORTED' | 'WATCH_ACTIVE';\n\nexport class SenseError extends Error {\n code: SenseErrorCode;\n\n constructor(code: SenseErrorCode, message: string) {\n super(message);\n this.name = 'SenseError';\n this.code = code;\n }\n}\n"],"names":["SenseError","code","message","name","Error"],"mappings":"AAAA,sEAAsE;AACtE,2EAA2E;AAC3E,wEAAwE;;;;;+BAG3DA;;;eAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAN,IAAA,AAAMA,2BAAN;;cAAMA;aAAAA,WAGCC,IAAoB,EAAEC,OAAe;gCAHtCF;;gBAIT,kBAJSA;YAIHE;;QACN,MAAKC,IAAI,GAAG;QACZ,MAAKF,IAAI,GAAGA;;;WANHD;qBAAmBI"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { Config, ResolvedConfig } from './config.js';
|
|
2
|
+
export { CONFIG_FILENAME, findConfigPath, initConfig, loadConfig, STATE_DIR, SUPPORTED_CONFIG_VERSION } from './config.js';
|
|
3
|
+
export type { OpenResult } from './db.js';
|
|
4
|
+
export { DB_FILENAME, docCount, getMeta, open, rebuild, reconcile, setMeta } from './db.js';
|
|
5
|
+
export type { SenseErrorCode } from './errors.js';
|
|
6
|
+
export { SenseError } from './errors.js';
|
|
7
|
+
export type { Row } from './output.js';
|
|
8
|
+
export { printRows } from './output.js';
|
|
9
|
+
export type { FileStat, ParsedDoc } from './scan.js';
|
|
10
|
+
export { listFiles, parseFile } from './scan.js';
|
|
11
|
+
export type { WatchEvent, WatchOptions } from './watch.js';
|
|
12
|
+
export { runWatch } from './watch.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { Config, ResolvedConfig } from './config.js';
|
|
2
|
+
export { CONFIG_FILENAME, findConfigPath, initConfig, loadConfig, STATE_DIR, SUPPORTED_CONFIG_VERSION } from './config.js';
|
|
3
|
+
export type { OpenResult } from './db.js';
|
|
4
|
+
export { DB_FILENAME, docCount, getMeta, open, rebuild, reconcile, setMeta } from './db.js';
|
|
5
|
+
export type { SenseErrorCode } from './errors.js';
|
|
6
|
+
export { SenseError } from './errors.js';
|
|
7
|
+
export type { Row } from './output.js';
|
|
8
|
+
export { printRows } from './output.js';
|
|
9
|
+
export type { FileStat, ParsedDoc } from './scan.js';
|
|
10
|
+
export { listFiles, parseFile } from './scan.js';
|
|
11
|
+
export type { WatchEvent, WatchOptions } from './watch.js';
|
|
12
|
+
export { runWatch } from './watch.js';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Public library API. cli.ts is a consumer of this surface, not a source of
|
|
2
|
+
// truth for it -- anything a test or another tool needs from sense should be
|
|
3
|
+
// exported here rather than reached into src/ by relative path.
|
|
4
|
+
"use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
function _export(target, all) {
|
|
9
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
_export(exports, {
|
|
15
|
+
get CONFIG_FILENAME () {
|
|
16
|
+
return _configts.CONFIG_FILENAME;
|
|
17
|
+
},
|
|
18
|
+
get DB_FILENAME () {
|
|
19
|
+
return _dbts.DB_FILENAME;
|
|
20
|
+
},
|
|
21
|
+
get STATE_DIR () {
|
|
22
|
+
return _configts.STATE_DIR;
|
|
23
|
+
},
|
|
24
|
+
get SUPPORTED_CONFIG_VERSION () {
|
|
25
|
+
return _configts.SUPPORTED_CONFIG_VERSION;
|
|
26
|
+
},
|
|
27
|
+
get SenseError () {
|
|
28
|
+
return _errorsts.SenseError;
|
|
29
|
+
},
|
|
30
|
+
get docCount () {
|
|
31
|
+
return _dbts.docCount;
|
|
32
|
+
},
|
|
33
|
+
get findConfigPath () {
|
|
34
|
+
return _configts.findConfigPath;
|
|
35
|
+
},
|
|
36
|
+
get getMeta () {
|
|
37
|
+
return _dbts.getMeta;
|
|
38
|
+
},
|
|
39
|
+
get initConfig () {
|
|
40
|
+
return _configts.initConfig;
|
|
41
|
+
},
|
|
42
|
+
get listFiles () {
|
|
43
|
+
return _scants.listFiles;
|
|
44
|
+
},
|
|
45
|
+
get loadConfig () {
|
|
46
|
+
return _configts.loadConfig;
|
|
47
|
+
},
|
|
48
|
+
get open () {
|
|
49
|
+
return _dbts.open;
|
|
50
|
+
},
|
|
51
|
+
get parseFile () {
|
|
52
|
+
return _scants.parseFile;
|
|
53
|
+
},
|
|
54
|
+
get printRows () {
|
|
55
|
+
return _outputts.printRows;
|
|
56
|
+
},
|
|
57
|
+
get rebuild () {
|
|
58
|
+
return _dbts.rebuild;
|
|
59
|
+
},
|
|
60
|
+
get reconcile () {
|
|
61
|
+
return _dbts.reconcile;
|
|
62
|
+
},
|
|
63
|
+
get runWatch () {
|
|
64
|
+
return _watchts.runWatch;
|
|
65
|
+
},
|
|
66
|
+
get setMeta () {
|
|
67
|
+
return _dbts.setMeta;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
var _configts = require("./config.js");
|
|
71
|
+
var _dbts = require("./db.js");
|
|
72
|
+
var _errorsts = require("./errors.js");
|
|
73
|
+
var _outputts = require("./output.js");
|
|
74
|
+
var _scants = require("./scan.js");
|
|
75
|
+
var _watchts = require("./watch.js");
|
|
76
|
+
/* 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/index.ts"],"sourcesContent":["// Public library API. cli.ts is a consumer of this surface, not a source of\n// truth for it -- anything a test or another tool needs from sense should be\n// exported here rather than reached into src/ by relative path.\n\nexport type { Config, ResolvedConfig } from './config.ts';\nexport { CONFIG_FILENAME, findConfigPath, initConfig, loadConfig, STATE_DIR, SUPPORTED_CONFIG_VERSION } from './config.ts';\n\nexport type { OpenResult } from './db.ts';\nexport { DB_FILENAME, docCount, getMeta, open, rebuild, reconcile, setMeta } from './db.ts';\n\nexport type { SenseErrorCode } from './errors.ts';\nexport { SenseError } from './errors.ts';\n\nexport type { Row } from './output.ts';\nexport { printRows } from './output.ts';\n\nexport type { FileStat, ParsedDoc } from './scan.ts';\nexport { listFiles, parseFile } from './scan.ts';\n\nexport type { WatchEvent, WatchOptions } from './watch.ts';\nexport { runWatch } from './watch.ts';\n"],"names":["CONFIG_FILENAME","DB_FILENAME","STATE_DIR","SUPPORTED_CONFIG_VERSION","SenseError","docCount","findConfigPath","getMeta","initConfig","listFiles","loadConfig","open","parseFile","printRows","rebuild","reconcile","runWatch","setMeta"],"mappings":"AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,gEAAgE;;;;;;;;;;;;QAGvDA;eAAAA,yBAAe;;QAGfC;eAAAA,iBAAW;;QAH8CC;eAAAA,mBAAS;;QAAEC;eAAAA,kCAAwB;;QAM5FC;eAAAA,oBAAU;;QAHGC;eAAAA,cAAQ;;QAHJC;eAAAA,wBAAc;;QAGRC;eAAAA,aAAO;;QAHGC;eAAAA,oBAAU;;QAY3CC;eAAAA,iBAAS;;QAZoCC;eAAAA,oBAAU;;QAGvBC;eAAAA,UAAI;;QASzBC;eAAAA,iBAAS;;QAHpBC;eAAAA,mBAAS;;QAN6BC;eAAAA,aAAO;;QAAEC;eAAAA,eAAS;;QAYxDC;eAAAA,iBAAQ;;QAZkDC;eAAAA,aAAO;;;wBAHmC;oBAG3B;wBAGvD;wBAGD;sBAGW;uBAGZ"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// rows -> table (default) | json
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "printRows", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return printRows;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
function _array_like_to_array(arr, len) {
|
|
13
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
14
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
15
|
+
return arr2;
|
|
16
|
+
}
|
|
17
|
+
function _array_without_holes(arr) {
|
|
18
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
19
|
+
}
|
|
20
|
+
function _iterable_to_array(iter) {
|
|
21
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
22
|
+
}
|
|
23
|
+
function _non_iterable_spread() {
|
|
24
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
25
|
+
}
|
|
26
|
+
function _to_consumable_array(arr) {
|
|
27
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
28
|
+
}
|
|
29
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
30
|
+
if (!o) return;
|
|
31
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
32
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
33
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
34
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
35
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
36
|
+
}
|
|
37
|
+
function printRows(rows, format) {
|
|
38
|
+
var _Math;
|
|
39
|
+
if (format === 'json') {
|
|
40
|
+
console.log(JSON.stringify(rows, null, 2));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (rows.length === 0) {
|
|
44
|
+
console.log('(0 rows)');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
var columns = Object.keys(rows[0]);
|
|
48
|
+
var widths = columns.map(function(col) {
|
|
49
|
+
return (_Math = Math).max.apply(_Math, [
|
|
50
|
+
col.length
|
|
51
|
+
].concat(_to_consumable_array(rows.map(function(row) {
|
|
52
|
+
var _row_col;
|
|
53
|
+
return String((_row_col = row[col]) !== null && _row_col !== void 0 ? _row_col : '').length;
|
|
54
|
+
}))));
|
|
55
|
+
});
|
|
56
|
+
var formatRow = function formatRow(values) {
|
|
57
|
+
return values.map(function(value, i) {
|
|
58
|
+
return value.padEnd(widths[i]);
|
|
59
|
+
}).join(' ');
|
|
60
|
+
};
|
|
61
|
+
console.log(formatRow(columns));
|
|
62
|
+
console.log(widths.map(function(w) {
|
|
63
|
+
return '-'.repeat(w);
|
|
64
|
+
}).join(' '));
|
|
65
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
66
|
+
try {
|
|
67
|
+
var _loop = function() {
|
|
68
|
+
var row = _step.value;
|
|
69
|
+
console.log(formatRow(columns.map(function(col) {
|
|
70
|
+
var _row_col;
|
|
71
|
+
return String((_row_col = row[col]) !== null && _row_col !== void 0 ? _row_col : '');
|
|
72
|
+
})));
|
|
73
|
+
};
|
|
74
|
+
for(var _iterator = rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
75
|
+
} catch (err) {
|
|
76
|
+
_didIteratorError = true;
|
|
77
|
+
_iteratorError = err;
|
|
78
|
+
} finally{
|
|
79
|
+
try {
|
|
80
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
81
|
+
_iterator.return();
|
|
82
|
+
}
|
|
83
|
+
} finally{
|
|
84
|
+
if (_didIteratorError) {
|
|
85
|
+
throw _iteratorError;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/* 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/output.ts"],"sourcesContent":["// rows -> table (default) | json\n\nexport type Row = Record<string, unknown>;\n\nexport function printRows(rows: Row[], format: 'table' | 'json'): void {\n if (format === 'json') {\n console.log(JSON.stringify(rows, null, 2));\n return;\n }\n\n if (rows.length === 0) {\n console.log('(0 rows)');\n return;\n }\n\n const columns = Object.keys(rows[0]);\n const widths = columns.map((col) => Math.max(col.length, ...rows.map((row) => String(row[col] ?? '').length)));\n\n const formatRow = (values: string[]) => values.map((value, i) => value.padEnd(widths[i])).join(' ');\n\n console.log(formatRow(columns));\n console.log(widths.map((w) => '-'.repeat(w)).join(' '));\n for (const row of rows) {\n console.log(formatRow(columns.map((col) => String(row[col] ?? ''))));\n }\n}\n"],"names":["printRows","rows","format","Math","console","log","JSON","stringify","length","columns","Object","keys","widths","map","col","max","row","String","formatRow","values","value","i","padEnd","join","w","repeat"],"mappings":"AAAA,iCAAiC;;;;;+BAIjBA;;;eAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAT,SAASA,UAAUC,IAAW,EAAEC,MAAwB;QAYzBC;IAXpC,IAAID,WAAW,QAAQ;QACrBE,QAAQC,GAAG,CAACC,KAAKC,SAAS,CAACN,MAAM,MAAM;QACvC;IACF;IAEA,IAAIA,KAAKO,MAAM,KAAK,GAAG;QACrBJ,QAAQC,GAAG,CAAC;QACZ;IACF;IAEA,IAAMI,UAAUC,OAAOC,IAAI,CAACV,IAAI,CAAC,EAAE;IACnC,IAAMW,SAASH,QAAQI,GAAG,CAAC,SAACC;eAAQX,CAAAA,QAAAA,MAAKY,GAAG,OAARZ,OAAAA;YAASW,IAAIN,MAAM;SAAsD,CAAzEL,OAAqB,qBAAGF,KAAKY,GAAG,CAAC,SAACG;gBAAeA;mBAAPC,QAAOD,WAAAA,GAAG,CAACF,IAAI,cAARE,sBAAAA,WAAY,IAAIR,MAAM;;;IAE3G,IAAMU,YAAY,mBAACC;eAAqBA,OAAON,GAAG,CAAC,SAACO,OAAOC;mBAAMD,MAAME,MAAM,CAACV,MAAM,CAACS,EAAE;WAAGE,IAAI,CAAC;;IAE/FnB,QAAQC,GAAG,CAACa,UAAUT;IACtBL,QAAQC,GAAG,CAACO,OAAOC,GAAG,CAAC,SAACW;eAAM,IAAIC,MAAM,CAACD;OAAID,IAAI,CAAC;QAC7C,kCAAA,2BAAA;;;YAAA,IAAMP,MAAN;YACHZ,QAAQC,GAAG,CAACa,UAAUT,QAAQI,GAAG,CAAC,SAACC;oBAAeE;uBAAPC,QAAOD,WAAAA,GAAG,CAACF,IAAI,cAARE,sBAAAA,WAAY;;QAChE;QAFA,QAAK,YAAaf,yBAAb,SAAA,6BAAA,QAAA,yBAAA;;QAAA;QAAA;;;iBAAA,6BAAA;gBAAA;;;gBAAA;sBAAA;;;;AAGP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "commonjs" }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Config } from './config.js';
|
|
2
|
+
export interface FileStat {
|
|
3
|
+
relPath: string;
|
|
4
|
+
absPath: string;
|
|
5
|
+
mtimeMs: number;
|
|
6
|
+
size: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function listFiles(cfg: Config, baseDir: string): FileStat[];
|
|
9
|
+
export interface ParsedDoc {
|
|
10
|
+
relPath: string;
|
|
11
|
+
mtimeMs: number;
|
|
12
|
+
size: number;
|
|
13
|
+
data: Record<string, string | number | null>;
|
|
14
|
+
}
|
|
15
|
+
export declare function parseFile(file: FileStat): {
|
|
16
|
+
doc: ParsedDoc;
|
|
17
|
+
warnings: string[];
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Config } from './config.js';
|
|
2
|
+
export interface FileStat {
|
|
3
|
+
relPath: string;
|
|
4
|
+
absPath: string;
|
|
5
|
+
mtimeMs: number;
|
|
6
|
+
size: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function listFiles(cfg: Config, baseDir: string): FileStat[];
|
|
9
|
+
export interface ParsedDoc {
|
|
10
|
+
relPath: string;
|
|
11
|
+
mtimeMs: number;
|
|
12
|
+
size: number;
|
|
13
|
+
data: Record<string, string | number | null>;
|
|
14
|
+
}
|
|
15
|
+
export declare function parseFile(file: FileStat): {
|
|
16
|
+
doc: ParsedDoc;
|
|
17
|
+
warnings: string[];
|
|
18
|
+
};
|
package/dist/cjs/scan.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
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 listFiles () {
|
|
13
|
+
return listFiles;
|
|
14
|
+
},
|
|
15
|
+
get parseFile () {
|
|
16
|
+
return parseFile;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _nodefs = require("node:fs");
|
|
20
|
+
var _nodepath = require("node:path");
|
|
21
|
+
var _fastglob = /*#__PURE__*/ _interop_require_default(require("fast-glob"));
|
|
22
|
+
var _graymatter = /*#__PURE__*/ _interop_require_default(require("gray-matter"));
|
|
23
|
+
function _instanceof(left, right) {
|
|
24
|
+
"@swc/helpers - instanceof";
|
|
25
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
26
|
+
return !!right[Symbol.hasInstance](left);
|
|
27
|
+
} else {
|
|
28
|
+
return left instanceof right;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function _interop_require_default(obj) {
|
|
32
|
+
return obj && obj.__esModule ? obj : {
|
|
33
|
+
default: obj
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
// Filesystem -> rows. Pure data in, data + warnings out -- no node:sqlite,
|
|
37
|
+
// no printing. db.ts is the only thing that knows what to do with the
|
|
38
|
+
// result (diffing against `docs`, writing SQL).
|
|
39
|
+
// Reserved `docs` columns: the real file path plus the mtime/size pair used
|
|
40
|
+
// to detect staleness. A frontmatter key literally named one of these would
|
|
41
|
+
// collide, so it's dropped (with a warning returned to the caller) rather
|
|
42
|
+
// than clobbering the column.
|
|
43
|
+
var RESERVED_COLUMNS = new Set([
|
|
44
|
+
'path',
|
|
45
|
+
'_mtime',
|
|
46
|
+
'_size'
|
|
47
|
+
]);
|
|
48
|
+
function listFiles(cfg, baseDir) {
|
|
49
|
+
var relPaths = _fastglob.default.sync(cfg.scan.include, {
|
|
50
|
+
cwd: baseDir
|
|
51
|
+
}).sort();
|
|
52
|
+
return relPaths.map(function(relPath) {
|
|
53
|
+
var absPath = (0, _nodepath.join)(baseDir, relPath);
|
|
54
|
+
var st = (0, _nodefs.statSync)(absPath);
|
|
55
|
+
return {
|
|
56
|
+
relPath: relPath,
|
|
57
|
+
absPath: absPath,
|
|
58
|
+
mtimeMs: st.mtimeMs,
|
|
59
|
+
size: st.size
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// Value mapping: strings/numbers as-is; booleans -> 0/1; dates -> ISO
|
|
64
|
+
// strings (lexicographic = chronological, no date lib); arrays/objects ->
|
|
65
|
+
// JSON text. `null`/`undefined` map to SQL NULL.
|
|
66
|
+
function mapValue(value) {
|
|
67
|
+
if (value === null || value === undefined) return null;
|
|
68
|
+
if (_instanceof(value, Date)) return value.toISOString();
|
|
69
|
+
if (typeof value === 'boolean') return value ? 1 : 0;
|
|
70
|
+
if (typeof value === 'string' || typeof value === 'number') return value;
|
|
71
|
+
// arrays and plain objects
|
|
72
|
+
return JSON.stringify(value);
|
|
73
|
+
}
|
|
74
|
+
function parseFile(file) {
|
|
75
|
+
var raw = (0, _nodefs.readFileSync)(file.absPath, 'utf8');
|
|
76
|
+
var data = (0, _graymatter.default)(raw).data;
|
|
77
|
+
var warnings = [];
|
|
78
|
+
var mapped = {};
|
|
79
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
80
|
+
try {
|
|
81
|
+
for(var _iterator = Object.keys(data)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
82
|
+
var key = _step.value;
|
|
83
|
+
if (RESERVED_COLUMNS.has(key)) {
|
|
84
|
+
warnings.push("warning: ".concat(file.relPath, ' has a frontmatter key named "').concat(key, '", which is reserved; ignoring it'));
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
mapped[key] = mapValue(data[key]);
|
|
88
|
+
}
|
|
89
|
+
} catch (err) {
|
|
90
|
+
_didIteratorError = true;
|
|
91
|
+
_iteratorError = err;
|
|
92
|
+
} finally{
|
|
93
|
+
try {
|
|
94
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
95
|
+
_iterator.return();
|
|
96
|
+
}
|
|
97
|
+
} finally{
|
|
98
|
+
if (_didIteratorError) {
|
|
99
|
+
throw _iteratorError;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
doc: {
|
|
105
|
+
relPath: file.relPath,
|
|
106
|
+
mtimeMs: file.mtimeMs,
|
|
107
|
+
size: file.size,
|
|
108
|
+
data: mapped
|
|
109
|
+
},
|
|
110
|
+
warnings: warnings
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/* 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.ts"],"sourcesContent":["import { readFileSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport fastGlob from 'fast-glob';\nimport matter from 'gray-matter';\nimport type { Config } from './config.ts';\n\n// Filesystem -> rows. Pure data in, data + warnings out -- no node:sqlite,\n// no printing. db.ts is the only thing that knows what to do with the\n// result (diffing against `docs`, writing SQL).\n\n// Reserved `docs` columns: the real file path plus the mtime/size pair used\n// to detect staleness. A frontmatter key literally named one of these would\n// collide, so it's dropped (with a warning returned to the caller) rather\n// than clobbering the column.\nconst RESERVED_COLUMNS = new Set(['path', '_mtime', '_size']);\n\nexport interface FileStat {\n relPath: string;\n absPath: string;\n mtimeMs: number;\n size: number;\n}\n\n// Glob the files `cfg.scan.include` matches under `baseDir`, stat each.\n// Sorted for deterministic output.\nexport function listFiles(cfg: Config, baseDir: string): FileStat[] {\n const relPaths = fastGlob.sync(cfg.scan.include, { cwd: baseDir }).sort();\n return relPaths.map((relPath) => {\n const absPath = join(baseDir, relPath);\n const st = statSync(absPath);\n return { relPath, absPath, mtimeMs: st.mtimeMs, size: st.size };\n });\n}\n\nexport interface ParsedDoc {\n relPath: string;\n mtimeMs: number;\n size: number;\n // Already value-mapped (booleans -> 0/1, dates -> ISO, arrays/objects ->\n // JSON text), reserved keys already dropped -- ready to bind into SQL.\n data: Record<string, string | number | null>;\n}\n\n// Value mapping: strings/numbers as-is; booleans -> 0/1; dates -> ISO\n// strings (lexicographic = chronological, no date lib); arrays/objects ->\n// JSON text. `null`/`undefined` map to SQL NULL.\nfunction mapValue(value: unknown): string | number | null {\n if (value === null || value === undefined) return null;\n if (value instanceof Date) return value.toISOString();\n if (typeof value === 'boolean') return value ? 1 : 0;\n if (typeof value === 'string' || typeof value === 'number') return value;\n // arrays and plain objects\n return JSON.stringify(value);\n}\n\n// Read + parse one file's frontmatter, mapping values and dropping reserved\n// keys. Returns the parsed doc plus any warnings (e.g. a reserved key\n// collision) for the caller to surface.\nexport function parseFile(file: FileStat): { doc: ParsedDoc; warnings: string[] } {\n const raw = readFileSync(file.absPath, 'utf8');\n const { data } = matter(raw);\n\n const warnings: string[] = [];\n const mapped: Record<string, string | number | null> = {};\n\n for (const key of Object.keys(data)) {\n if (RESERVED_COLUMNS.has(key)) {\n warnings.push(`warning: ${file.relPath} has a frontmatter key named \"${key}\", which is reserved; ignoring it`);\n continue;\n }\n mapped[key] = mapValue(data[key]);\n }\n\n return {\n doc: { relPath: file.relPath, mtimeMs: file.mtimeMs, size: file.size, data: mapped },\n warnings,\n };\n}\n"],"names":["listFiles","parseFile","RESERVED_COLUMNS","Set","cfg","baseDir","relPaths","fastGlob","sync","scan","include","cwd","sort","map","relPath","absPath","join","st","statSync","mtimeMs","size","mapValue","value","undefined","Date","toISOString","JSON","stringify","file","raw","readFileSync","data","matter","warnings","mapped","Object","keys","key","has","push","doc"],"mappings":";;;;;;;;;;;QAyBgBA;eAAAA;;QAiCAC;eAAAA;;;sBA1DuB;wBAClB;+DACA;iEACF;;;;;;;;;;;;;;AAGnB,2EAA2E;AAC3E,sEAAsE;AACtE,gDAAgD;AAEhD,4EAA4E;AAC5E,4EAA4E;AAC5E,0EAA0E;AAC1E,8BAA8B;AAC9B,IAAMC,mBAAmB,IAAIC,IAAI;IAAC;IAAQ;IAAU;CAAQ;AAWrD,SAASH,UAAUI,GAAW,EAAEC,OAAe;IACpD,IAAMC,WAAWC,iBAAQ,CAACC,IAAI,CAACJ,IAAIK,IAAI,CAACC,OAAO,EAAE;QAAEC,KAAKN;IAAQ,GAAGO,IAAI;IACvE,OAAON,SAASO,GAAG,CAAC,SAACC;QACnB,IAAMC,UAAUC,IAAAA,cAAI,EAACX,SAASS;QAC9B,IAAMG,KAAKC,IAAAA,gBAAQ,EAACH;QACpB,OAAO;YAAED,SAAAA;YAASC,SAAAA;YAASI,SAASF,GAAGE,OAAO;YAAEC,MAAMH,GAAGG,IAAI;QAAC;IAChE;AACF;AAWA,sEAAsE;AACtE,0EAA0E;AAC1E,iDAAiD;AACjD,SAASC,SAASC,KAAc;IAC9B,IAAIA,UAAU,QAAQA,UAAUC,WAAW,OAAO;IAClD,IAAID,AAAK,YAALA,OAAiBE,OAAM,OAAOF,MAAMG,WAAW;IACnD,IAAI,OAAOH,UAAU,WAAW,OAAOA,QAAQ,IAAI;IACnD,IAAI,OAAOA,UAAU,YAAY,OAAOA,UAAU,UAAU,OAAOA;IACnE,2BAA2B;IAC3B,OAAOI,KAAKC,SAAS,CAACL;AACxB;AAKO,SAASrB,UAAU2B,IAAc;IACtC,IAAMC,MAAMC,IAAAA,oBAAY,EAACF,KAAKb,OAAO,EAAE;IACvC,IAAM,AAAEgB,OAASC,IAAAA,mBAAM,EAACH,KAAhBE;IAER,IAAME,WAAqB,EAAE;IAC7B,IAAMC,SAAiD,CAAC;QAEnD,kCAAA,2BAAA;;QAAL,QAAK,YAAaC,OAAOC,IAAI,CAACL,0BAAzB,SAAA,6BAAA,QAAA,yBAAA,iCAAgC;YAAhC,IAAMM,MAAN;YACH,IAAInC,iBAAiBoC,GAAG,CAACD,MAAM;gBAC7BJ,SAASM,IAAI,CAAC,AAAC,YAAwDF,OAA7CT,KAAKd,OAAO,EAAC,kCAAoC,OAAJuB,KAAI;gBAC3E;YACF;YACAH,MAAM,CAACG,IAAI,GAAGhB,SAASU,IAAI,CAACM,IAAI;QAClC;;QANK;QAAA;;;iBAAA,6BAAA;gBAAA;;;gBAAA;sBAAA;;;;IAQL,OAAO;QACLG,KAAK;YAAE1B,SAASc,KAAKd,OAAO;YAAEK,SAASS,KAAKT,OAAO;YAAEC,MAAMQ,KAAKR,IAAI;YAAEW,MAAMG;QAAO;QACnFD,UAAAA;IACF;AACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ResolvedConfig } from './config.js';
|
|
2
|
+
export type WatchEvent = {
|
|
3
|
+
type: 'started';
|
|
4
|
+
baseDir: string;
|
|
5
|
+
dbPath: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'reconciled';
|
|
8
|
+
parsed: number;
|
|
9
|
+
total: number;
|
|
10
|
+
warnings: string[];
|
|
11
|
+
} | {
|
|
12
|
+
type: 'reconcile-error';
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
export interface WatchOptions {
|
|
16
|
+
force?: boolean;
|
|
17
|
+
onEvent?: (event: WatchEvent) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function runWatch(cfg: ResolvedConfig, opts?: WatchOptions): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ResolvedConfig } from './config.js';
|
|
2
|
+
export type WatchEvent = {
|
|
3
|
+
type: 'started';
|
|
4
|
+
baseDir: string;
|
|
5
|
+
dbPath: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'reconciled';
|
|
8
|
+
parsed: number;
|
|
9
|
+
total: number;
|
|
10
|
+
warnings: string[];
|
|
11
|
+
} | {
|
|
12
|
+
type: 'reconcile-error';
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
export interface WatchOptions {
|
|
16
|
+
force?: boolean;
|
|
17
|
+
onEvent?: (event: WatchEvent) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function runWatch(cfg: ResolvedConfig, opts?: WatchOptions): Promise<void>;
|