@webneat/codewiki 0.0.5 → 0.0.7
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 +173 -24
- package/dist/bin.cjs +270 -246
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +270 -246
- package/dist/bin.js.map +1 -1
- package/dist/cli.cjs +270 -246
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +270 -246
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +18 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/bin.js
CHANGED
|
@@ -552,7 +552,7 @@ var symbols2 = {
|
|
|
552
552
|
where: {}
|
|
553
553
|
};
|
|
554
554
|
var external_dependencies2 = {
|
|
555
|
-
select: ["id", "package", "subpath", "name", "state", "error"],
|
|
555
|
+
select: ["id", "package", "subpath", "name", "is_builtin", "state", "error"],
|
|
556
556
|
order_by: ["id", "asc"],
|
|
557
557
|
limit: 20,
|
|
558
558
|
offset: 0,
|
|
@@ -1178,12 +1178,6 @@ async function create_context(sqlite, db6, config) {
|
|
|
1178
1178
|
);
|
|
1179
1179
|
return ctx;
|
|
1180
1180
|
}
|
|
1181
|
-
async function context_from_config(config) {
|
|
1182
|
-
const sqlite = new Database(config.db_path);
|
|
1183
|
-
sqlite.pragma("foreign_keys = ON");
|
|
1184
|
-
const db6 = drizzle(sqlite, { schema: schema_exports });
|
|
1185
|
-
return create_context(sqlite, db6, config);
|
|
1186
|
-
}
|
|
1187
1181
|
async function context_from_db(db_path) {
|
|
1188
1182
|
const sqlite = new Database(db_path);
|
|
1189
1183
|
sqlite.pragma("foreign_keys = ON");
|
|
@@ -1240,6 +1234,7 @@ async function get_github_repo(node_modules_paths, package_name) {
|
|
|
1240
1234
|
// src/cli/env.ts
|
|
1241
1235
|
var env = {
|
|
1242
1236
|
read_file,
|
|
1237
|
+
cwd: () => process.cwd(),
|
|
1243
1238
|
file_exists: (path7) => existsSync(path7),
|
|
1244
1239
|
argv: () => process.argv,
|
|
1245
1240
|
log: (...args) => console.log(...args),
|
|
@@ -1256,119 +1251,6 @@ import { Command } from "commander";
|
|
|
1256
1251
|
// src/cli/commands/_common.ts
|
|
1257
1252
|
import "zod";
|
|
1258
1253
|
|
|
1259
|
-
// src/cli/schema.ts
|
|
1260
|
-
import { z } from "zod";
|
|
1261
|
-
var Config = z.object({
|
|
1262
|
-
db_path: z.string().describe("Path to SQLite database"),
|
|
1263
|
-
project_path: z.string().describe("Path to TypeScript project"),
|
|
1264
|
-
description: z.string().optional(),
|
|
1265
|
-
package_json_path: z.string().optional(),
|
|
1266
|
-
node_modules_paths: z.array(z.string()).optional()
|
|
1267
|
-
});
|
|
1268
|
-
var StringFilter = z.union([
|
|
1269
|
-
z.string(),
|
|
1270
|
-
z.object({ contains: z.string() }),
|
|
1271
|
-
z.object({ starts_with: z.string() }),
|
|
1272
|
-
z.object({ ends_with: z.string() })
|
|
1273
|
-
]);
|
|
1274
|
-
var OrderDirection = z.enum(["asc", "desc"]);
|
|
1275
|
-
var FileField = z.enum(["id", "directory_id", "path", "description", "state", "error"]);
|
|
1276
|
-
var FileState = z.enum(["to_scan", "to_describe", "ready"]);
|
|
1277
|
-
var FileSearchOptions = z.object({
|
|
1278
|
-
select: z.array(FileField).optional(),
|
|
1279
|
-
limit: z.number().int().positive().optional(),
|
|
1280
|
-
offset: z.number().int().nonnegative().optional(),
|
|
1281
|
-
where: z.object({
|
|
1282
|
-
id: z.number().optional(),
|
|
1283
|
-
directory_id: z.number().optional(),
|
|
1284
|
-
path: StringFilter.optional(),
|
|
1285
|
-
description: StringFilter.optional(),
|
|
1286
|
-
state: z.union([FileState, z.object({ contains: z.string() })]).optional(),
|
|
1287
|
-
error: StringFilter.optional()
|
|
1288
|
-
}).optional(),
|
|
1289
|
-
order_by: z.tuple([FileField, OrderDirection]).optional()
|
|
1290
|
-
});
|
|
1291
|
-
var FileRelationOptions = z.object({
|
|
1292
|
-
select: z.array(FileField).optional(),
|
|
1293
|
-
limit: z.number().int().positive().optional(),
|
|
1294
|
-
offset: z.number().int().nonnegative().optional(),
|
|
1295
|
-
deep: z.boolean().optional()
|
|
1296
|
-
});
|
|
1297
|
-
var SymbolField = z.enum(["id", "file_id", "type", "name", "text", "meta", "description", "is_exported", "state", "error"]);
|
|
1298
|
-
var SymbolType = z.enum(["function", "class", "class_method", "class_property", "variable", "type"]);
|
|
1299
|
-
var SymbolState = z.enum(["to_link", "to_describe", "ready"]);
|
|
1300
|
-
var SymbolSearchOptions = z.object({
|
|
1301
|
-
select: z.array(SymbolField).optional(),
|
|
1302
|
-
limit: z.number().int().positive().optional(),
|
|
1303
|
-
offset: z.number().int().nonnegative().optional(),
|
|
1304
|
-
where: z.object({
|
|
1305
|
-
id: z.number().optional(),
|
|
1306
|
-
file_id: z.number().optional(),
|
|
1307
|
-
type: z.union([SymbolType, z.object({ contains: z.string() })]).optional(),
|
|
1308
|
-
name: StringFilter.optional(),
|
|
1309
|
-
text: StringFilter.optional(),
|
|
1310
|
-
meta: StringFilter.optional(),
|
|
1311
|
-
description: StringFilter.optional(),
|
|
1312
|
-
is_exported: z.boolean().optional(),
|
|
1313
|
-
state: z.union([SymbolState, z.object({ contains: z.string() })]).optional(),
|
|
1314
|
-
error: StringFilter.optional()
|
|
1315
|
-
}).optional(),
|
|
1316
|
-
order_by: z.tuple([SymbolField, OrderDirection]).optional()
|
|
1317
|
-
});
|
|
1318
|
-
var SymbolRelationOptions = z.object({
|
|
1319
|
-
select: z.array(SymbolField).optional(),
|
|
1320
|
-
limit: z.number().int().positive().optional(),
|
|
1321
|
-
offset: z.number().int().nonnegative().optional(),
|
|
1322
|
-
deep: z.boolean().optional()
|
|
1323
|
-
});
|
|
1324
|
-
var DirectoryField = z.enum(["id", "parent_id", "path", "description", "state", "error"]);
|
|
1325
|
-
var DirectoryState = z.enum(["to_describe", "ready"]);
|
|
1326
|
-
var DirectorySearchOptions = z.object({
|
|
1327
|
-
select: z.array(DirectoryField).optional(),
|
|
1328
|
-
limit: z.number().int().positive().optional(),
|
|
1329
|
-
offset: z.number().int().nonnegative().optional(),
|
|
1330
|
-
where: z.object({
|
|
1331
|
-
id: z.number().optional(),
|
|
1332
|
-
parent_id: z.number().optional(),
|
|
1333
|
-
path: StringFilter.optional(),
|
|
1334
|
-
description: StringFilter.optional(),
|
|
1335
|
-
state: z.union([DirectoryState, z.object({ contains: z.string() })]).optional(),
|
|
1336
|
-
error: StringFilter.optional()
|
|
1337
|
-
}).optional(),
|
|
1338
|
-
order_by: z.tuple([DirectoryField, OrderDirection]).optional()
|
|
1339
|
-
});
|
|
1340
|
-
var DirectoryRelationOptions = z.object({
|
|
1341
|
-
select: z.array(DirectoryField).optional(),
|
|
1342
|
-
limit: z.number().int().positive().optional(),
|
|
1343
|
-
offset: z.number().int().nonnegative().optional(),
|
|
1344
|
-
deep: z.boolean().optional()
|
|
1345
|
-
});
|
|
1346
|
-
var DependencyField = z.enum(["id", "package", "subpath", "name", "version", "github_repo", "is_builtin", "description", "state", "error"]);
|
|
1347
|
-
var DependencyState = z.enum(["to_describe", "ready"]);
|
|
1348
|
-
var DependencySearchOptions = z.object({
|
|
1349
|
-
select: z.array(DependencyField).optional(),
|
|
1350
|
-
limit: z.number().int().positive().optional(),
|
|
1351
|
-
offset: z.number().int().nonnegative().optional(),
|
|
1352
|
-
where: z.object({
|
|
1353
|
-
id: z.number().optional(),
|
|
1354
|
-
package: StringFilter.optional(),
|
|
1355
|
-
subpath: StringFilter.optional(),
|
|
1356
|
-
name: StringFilter.optional(),
|
|
1357
|
-
version: StringFilter.optional(),
|
|
1358
|
-
github_repo: StringFilter.optional(),
|
|
1359
|
-
is_builtin: z.boolean().optional(),
|
|
1360
|
-
description: StringFilter.optional(),
|
|
1361
|
-
state: z.union([DependencyState, z.object({ contains: z.string() })]).optional(),
|
|
1362
|
-
error: StringFilter.optional()
|
|
1363
|
-
}).optional(),
|
|
1364
|
-
order_by: z.tuple([DependencyField, OrderDirection]).optional()
|
|
1365
|
-
});
|
|
1366
|
-
var DependencySelectOptions = z.object({
|
|
1367
|
-
select: z.array(DependencyField).optional(),
|
|
1368
|
-
limit: z.number().int().positive().optional(),
|
|
1369
|
-
offset: z.number().int().nonnegative().optional()
|
|
1370
|
-
});
|
|
1371
|
-
|
|
1372
1254
|
// src/update/track_changes.ts
|
|
1373
1255
|
import path3 from "path";
|
|
1374
1256
|
import "typescript";
|
|
@@ -2465,6 +2347,21 @@ async function update6(ctx) {
|
|
|
2465
2347
|
await link_symbols(ctx);
|
|
2466
2348
|
}
|
|
2467
2349
|
|
|
2350
|
+
// src/update_config.ts
|
|
2351
|
+
function update_config(ctx, config, updates) {
|
|
2352
|
+
if (Object.keys(updates).length === 0) return;
|
|
2353
|
+
const new_config = { ...config, ...updates };
|
|
2354
|
+
err.or_throw(
|
|
2355
|
+
configs_exports.upsert(ctx, {
|
|
2356
|
+
project_path: new_config.project_path,
|
|
2357
|
+
description: new_config.description ?? null,
|
|
2358
|
+
package_json_path: new_config.package_json_path ?? null,
|
|
2359
|
+
node_modules_paths: new_config.node_modules_paths ? JSON.stringify(new_config.node_modules_paths) : null
|
|
2360
|
+
})
|
|
2361
|
+
);
|
|
2362
|
+
Object.assign(config, updates);
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2468
2365
|
// src/counts.ts
|
|
2469
2366
|
import { count as count10 } from "drizzle-orm";
|
|
2470
2367
|
function counts(ctx) {
|
|
@@ -2780,19 +2677,6 @@ function directories_to_describe(ctx, limit) {
|
|
|
2780
2677
|
}
|
|
2781
2678
|
|
|
2782
2679
|
// src/index.ts
|
|
2783
|
-
async function create(config) {
|
|
2784
|
-
const ctx = await context_from_config(config);
|
|
2785
|
-
return {
|
|
2786
|
-
config,
|
|
2787
|
-
update: () => update6(ctx),
|
|
2788
|
-
counts: () => counts(ctx),
|
|
2789
|
-
to_describe: (limit) => to_describe(ctx, limit),
|
|
2790
|
-
files: files_wiki(ctx),
|
|
2791
|
-
symbols: symbols_wiki(ctx),
|
|
2792
|
-
directories: directories_wiki(ctx),
|
|
2793
|
-
dependencies: dependencies_wiki(ctx)
|
|
2794
|
-
};
|
|
2795
|
-
}
|
|
2796
2680
|
async function load(db_path) {
|
|
2797
2681
|
const ctx = await context_from_db(db_path);
|
|
2798
2682
|
const stored = ctx.db.select().from(schema_exports.configs).get();
|
|
@@ -2805,6 +2689,7 @@ async function load(db_path) {
|
|
|
2805
2689
|
};
|
|
2806
2690
|
return {
|
|
2807
2691
|
config,
|
|
2692
|
+
update_config: (updates) => update_config(ctx, config, updates),
|
|
2808
2693
|
update: () => update6(ctx),
|
|
2809
2694
|
counts: () => counts(ctx),
|
|
2810
2695
|
to_describe: (limit) => to_describe(ctx, limit),
|
|
@@ -2816,30 +2701,18 @@ async function load(db_path) {
|
|
|
2816
2701
|
}
|
|
2817
2702
|
|
|
2818
2703
|
// src/cli/commands/_common.ts
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
return
|
|
2829
|
-
} catch (error) {
|
|
2830
|
-
if (error.type === "could_not_read_file") {
|
|
2831
|
-
env.error(`Error: Configuration file ${config_path} not found`);
|
|
2832
|
-
} else if (error.type === "invalid_json") {
|
|
2833
|
-
env.error(`Error: Invalid JSON in ${config_path}`);
|
|
2834
|
-
} else if (error.type === "invalid_config") {
|
|
2835
|
-
env.error("Error: Invalid configuration");
|
|
2836
|
-
} else if (error.message) {
|
|
2837
|
-
env.error(`Error: ${error.message}`);
|
|
2838
|
-
} else {
|
|
2839
|
-
env.error(`Error: ${String(error)}`);
|
|
2840
|
-
}
|
|
2841
|
-
process.exit(1);
|
|
2704
|
+
function get_db_path(...args) {
|
|
2705
|
+
const cmd = args[args.length - 1];
|
|
2706
|
+
return cmd.optsWithGlobals().db;
|
|
2707
|
+
}
|
|
2708
|
+
async function load_wiki(db_path) {
|
|
2709
|
+
if (!env.file_exists(db_path)) {
|
|
2710
|
+
env.error(`Error: No wiki found at ${db_path}`);
|
|
2711
|
+
env.error(`Run \`codewiki init\` to create one.`);
|
|
2712
|
+
env.exit(1);
|
|
2713
|
+
return void 0;
|
|
2842
2714
|
}
|
|
2715
|
+
return load(db_path);
|
|
2843
2716
|
}
|
|
2844
2717
|
function parse_options(options_json, schema, context) {
|
|
2845
2718
|
let parsed_json;
|
|
@@ -2887,8 +2760,8 @@ function count_text({ total, ...states }) {
|
|
|
2887
2760
|
// src/cli/commands/update.ts
|
|
2888
2761
|
var update7 = new Command("update");
|
|
2889
2762
|
update7.description("Reads current files and updates the wiki database");
|
|
2890
|
-
update7.action(async () => {
|
|
2891
|
-
const wiki = await load_wiki();
|
|
2763
|
+
update7.action(async (...args) => {
|
|
2764
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2892
2765
|
await wiki.update();
|
|
2893
2766
|
env.log("Update complete.\n");
|
|
2894
2767
|
const counts2 = wiki.counts();
|
|
@@ -2900,8 +2773,8 @@ update7.action(async () => {
|
|
|
2900
2773
|
import { Command as Command2 } from "commander";
|
|
2901
2774
|
var status = new Command2("status");
|
|
2902
2775
|
status.description("Show the status of the wiki");
|
|
2903
|
-
status.action(async () => {
|
|
2904
|
-
const wiki = await load_wiki();
|
|
2776
|
+
status.action(async (...args) => {
|
|
2777
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2905
2778
|
const counts2 = wiki.counts();
|
|
2906
2779
|
env.log(format_counts(counts2));
|
|
2907
2780
|
});
|
|
@@ -2911,14 +2784,25 @@ import dedent2 from "dedent";
|
|
|
2911
2784
|
import { Command as Command3 } from "commander";
|
|
2912
2785
|
var describe = new Command3("describe");
|
|
2913
2786
|
describe.description("Show the next item to describe");
|
|
2914
|
-
describe.action(async () => {
|
|
2915
|
-
const wiki = await load_wiki();
|
|
2916
|
-
const
|
|
2917
|
-
if (
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2787
|
+
describe.action(async (...args) => {
|
|
2788
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2789
|
+
const result = wiki.to_describe(1);
|
|
2790
|
+
if (result.type === "none") {
|
|
2791
|
+
return env.log("All items are described!");
|
|
2792
|
+
}
|
|
2793
|
+
if (result.type === "dependencies" && result.items.length > 0) {
|
|
2794
|
+
return describe_dependency(result.items[0]);
|
|
2795
|
+
}
|
|
2796
|
+
if (result.type === "symbols" && result.items.length > 0) {
|
|
2797
|
+
return describe_symbol(wiki, result.items[0]);
|
|
2798
|
+
}
|
|
2799
|
+
if (result.type === "files" && result.items.length > 0) {
|
|
2800
|
+
return describe_file(result.items[0]);
|
|
2801
|
+
}
|
|
2802
|
+
if (result.type === "directories" && result.items.length > 0) {
|
|
2803
|
+
return describe_directory(result.items[0]);
|
|
2804
|
+
}
|
|
2805
|
+
env.log("No items to describe.");
|
|
2922
2806
|
});
|
|
2923
2807
|
function describe_dependency(dep) {
|
|
2924
2808
|
env.log(dedent2`
|
|
@@ -2934,40 +2818,42 @@ function describe_dependency(dep) {
|
|
|
2934
2818
|
\`codewiki dependencies set-description ${dep.id} <markdown-file>\`
|
|
2935
2819
|
`);
|
|
2936
2820
|
}
|
|
2937
|
-
function
|
|
2938
|
-
const
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2821
|
+
function describe_symbol(wiki, sym) {
|
|
2822
|
+
const file = wiki.files.get(sym.file_id);
|
|
2823
|
+
env.log(dedent2`
|
|
2824
|
+
Your task is to describe the following symbol:
|
|
2825
|
+
|
|
2826
|
+
name: ${sym.name}
|
|
2827
|
+
type: ${sym.type}
|
|
2828
|
+
file: ${file?.path || "unknown"}
|
|
2829
|
+
exported: ${sym.is_exported}
|
|
2830
|
+
|
|
2831
|
+
Write a concise developer documentation for this ${sym.type} into a markdown file, then run:
|
|
2832
|
+
|
|
2833
|
+
codewiki symbols set-description ${sym.id} <markdown-file>
|
|
2834
|
+
`);
|
|
2835
|
+
}
|
|
2836
|
+
function describe_file(file) {
|
|
2837
|
+
env.log(dedent2`
|
|
2838
|
+
Your task is to describe the following file:
|
|
2839
|
+
|
|
2840
|
+
path: ${file.path}
|
|
2841
|
+
|
|
2842
|
+
Write a concise description of this file's purpose and contents into a markdown file, then run:
|
|
2843
|
+
|
|
2844
|
+
codewiki files set-description ${file.id} <markdown-file>
|
|
2845
|
+
`);
|
|
2846
|
+
}
|
|
2847
|
+
function describe_directory(dir) {
|
|
2848
|
+
env.log(dedent2`
|
|
2849
|
+
Your task is to describe the following directory:
|
|
2850
|
+
|
|
2851
|
+
path: ${dir.path}
|
|
2852
|
+
|
|
2853
|
+
Write a concise description of this directory's purpose and contents into a markdown file, then run:
|
|
2854
|
+
|
|
2855
|
+
codewiki directories set-description ${dir.id} <markdown-file>
|
|
2856
|
+
`);
|
|
2971
2857
|
}
|
|
2972
2858
|
|
|
2973
2859
|
// src/cli/commands/files/index.ts
|
|
@@ -2979,19 +2865,136 @@ import { Command as Command4 } from "commander";
|
|
|
2979
2865
|
var get6 = new Command4("get");
|
|
2980
2866
|
get6.description("Get a file by ID");
|
|
2981
2867
|
get6.argument("<id>", "File ID");
|
|
2982
|
-
get6.action(async (
|
|
2983
|
-
const
|
|
2868
|
+
get6.action(async (...args) => {
|
|
2869
|
+
const [id] = args;
|
|
2870
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2984
2871
|
const file = wiki.files.get(Number(id));
|
|
2985
2872
|
env.log(JSON.stringify(file, null, 2));
|
|
2986
2873
|
});
|
|
2987
2874
|
|
|
2988
2875
|
// src/cli/commands/files/search.ts
|
|
2989
2876
|
import { Command as Command5 } from "commander";
|
|
2877
|
+
|
|
2878
|
+
// src/cli/schema.ts
|
|
2879
|
+
import { z as z2 } from "zod";
|
|
2880
|
+
var Config = z2.object({
|
|
2881
|
+
db_path: z2.string().describe("Path to SQLite database"),
|
|
2882
|
+
project_path: z2.string().describe("Path to TypeScript project"),
|
|
2883
|
+
description: z2.string().optional(),
|
|
2884
|
+
package_json_path: z2.string().optional(),
|
|
2885
|
+
node_modules_paths: z2.array(z2.string()).optional()
|
|
2886
|
+
});
|
|
2887
|
+
var StringFilter = z2.union([
|
|
2888
|
+
z2.string(),
|
|
2889
|
+
z2.object({ contains: z2.string() }),
|
|
2890
|
+
z2.object({ starts_with: z2.string() }),
|
|
2891
|
+
z2.object({ ends_with: z2.string() })
|
|
2892
|
+
]);
|
|
2893
|
+
var OrderDirection = z2.enum(["asc", "desc"]);
|
|
2894
|
+
var FileField = z2.enum(["id", "directory_id", "path", "description", "state", "error"]);
|
|
2895
|
+
var FileState = z2.enum(["to_scan", "to_describe", "ready"]);
|
|
2896
|
+
var FileSearchOptions = z2.object({
|
|
2897
|
+
select: z2.array(FileField).optional(),
|
|
2898
|
+
limit: z2.number().int().positive().optional(),
|
|
2899
|
+
offset: z2.number().int().nonnegative().optional(),
|
|
2900
|
+
where: z2.object({
|
|
2901
|
+
id: z2.number().optional(),
|
|
2902
|
+
directory_id: z2.number().optional(),
|
|
2903
|
+
path: StringFilter.optional(),
|
|
2904
|
+
description: StringFilter.optional(),
|
|
2905
|
+
state: z2.union([FileState, z2.object({ contains: z2.string() })]).optional(),
|
|
2906
|
+
error: StringFilter.optional()
|
|
2907
|
+
}).optional(),
|
|
2908
|
+
order_by: z2.tuple([FileField, OrderDirection]).optional()
|
|
2909
|
+
});
|
|
2910
|
+
var FileRelationOptions = z2.object({
|
|
2911
|
+
select: z2.array(FileField).optional(),
|
|
2912
|
+
limit: z2.number().int().positive().optional(),
|
|
2913
|
+
offset: z2.number().int().nonnegative().optional(),
|
|
2914
|
+
deep: z2.boolean().optional()
|
|
2915
|
+
});
|
|
2916
|
+
var SymbolField = z2.enum(["id", "file_id", "type", "name", "text", "meta", "description", "is_exported", "state", "error"]);
|
|
2917
|
+
var SymbolType = z2.enum(["function", "class", "class_method", "class_property", "variable", "type"]);
|
|
2918
|
+
var SymbolState = z2.enum(["to_link", "to_describe", "ready"]);
|
|
2919
|
+
var SymbolSearchOptions = z2.object({
|
|
2920
|
+
select: z2.array(SymbolField).optional(),
|
|
2921
|
+
limit: z2.number().int().positive().optional(),
|
|
2922
|
+
offset: z2.number().int().nonnegative().optional(),
|
|
2923
|
+
where: z2.object({
|
|
2924
|
+
id: z2.number().optional(),
|
|
2925
|
+
file_id: z2.number().optional(),
|
|
2926
|
+
type: z2.union([SymbolType, z2.object({ contains: z2.string() })]).optional(),
|
|
2927
|
+
name: StringFilter.optional(),
|
|
2928
|
+
text: StringFilter.optional(),
|
|
2929
|
+
meta: StringFilter.optional(),
|
|
2930
|
+
description: StringFilter.optional(),
|
|
2931
|
+
is_exported: z2.boolean().optional(),
|
|
2932
|
+
state: z2.union([SymbolState, z2.object({ contains: z2.string() })]).optional(),
|
|
2933
|
+
error: StringFilter.optional()
|
|
2934
|
+
}).optional(),
|
|
2935
|
+
order_by: z2.tuple([SymbolField, OrderDirection]).optional()
|
|
2936
|
+
});
|
|
2937
|
+
var SymbolRelationOptions = z2.object({
|
|
2938
|
+
select: z2.array(SymbolField).optional(),
|
|
2939
|
+
limit: z2.number().int().positive().optional(),
|
|
2940
|
+
offset: z2.number().int().nonnegative().optional(),
|
|
2941
|
+
deep: z2.boolean().optional()
|
|
2942
|
+
});
|
|
2943
|
+
var DirectoryField = z2.enum(["id", "parent_id", "path", "description", "state", "error"]);
|
|
2944
|
+
var DirectoryState = z2.enum(["to_describe", "ready"]);
|
|
2945
|
+
var DirectorySearchOptions = z2.object({
|
|
2946
|
+
select: z2.array(DirectoryField).optional(),
|
|
2947
|
+
limit: z2.number().int().positive().optional(),
|
|
2948
|
+
offset: z2.number().int().nonnegative().optional(),
|
|
2949
|
+
where: z2.object({
|
|
2950
|
+
id: z2.number().optional(),
|
|
2951
|
+
parent_id: z2.number().optional(),
|
|
2952
|
+
path: StringFilter.optional(),
|
|
2953
|
+
description: StringFilter.optional(),
|
|
2954
|
+
state: z2.union([DirectoryState, z2.object({ contains: z2.string() })]).optional(),
|
|
2955
|
+
error: StringFilter.optional()
|
|
2956
|
+
}).optional(),
|
|
2957
|
+
order_by: z2.tuple([DirectoryField, OrderDirection]).optional()
|
|
2958
|
+
});
|
|
2959
|
+
var DirectoryRelationOptions = z2.object({
|
|
2960
|
+
select: z2.array(DirectoryField).optional(),
|
|
2961
|
+
limit: z2.number().int().positive().optional(),
|
|
2962
|
+
offset: z2.number().int().nonnegative().optional(),
|
|
2963
|
+
deep: z2.boolean().optional()
|
|
2964
|
+
});
|
|
2965
|
+
var DependencyField = z2.enum(["id", "package", "subpath", "name", "version", "github_repo", "is_builtin", "description", "state", "error"]);
|
|
2966
|
+
var DependencyState = z2.enum(["to_describe", "ready"]);
|
|
2967
|
+
var DependencySearchOptions = z2.object({
|
|
2968
|
+
select: z2.array(DependencyField).optional(),
|
|
2969
|
+
limit: z2.number().int().positive().optional(),
|
|
2970
|
+
offset: z2.number().int().nonnegative().optional(),
|
|
2971
|
+
where: z2.object({
|
|
2972
|
+
id: z2.number().optional(),
|
|
2973
|
+
package: StringFilter.optional(),
|
|
2974
|
+
subpath: StringFilter.optional(),
|
|
2975
|
+
name: StringFilter.optional(),
|
|
2976
|
+
version: StringFilter.optional(),
|
|
2977
|
+
github_repo: StringFilter.optional(),
|
|
2978
|
+
is_builtin: z2.boolean().optional(),
|
|
2979
|
+
description: StringFilter.optional(),
|
|
2980
|
+
state: z2.union([DependencyState, z2.object({ contains: z2.string() })]).optional(),
|
|
2981
|
+
error: StringFilter.optional()
|
|
2982
|
+
}).optional(),
|
|
2983
|
+
order_by: z2.tuple([DependencyField, OrderDirection]).optional()
|
|
2984
|
+
});
|
|
2985
|
+
var DependencySelectOptions = z2.object({
|
|
2986
|
+
select: z2.array(DependencyField).optional(),
|
|
2987
|
+
limit: z2.number().int().positive().optional(),
|
|
2988
|
+
offset: z2.number().int().nonnegative().optional()
|
|
2989
|
+
});
|
|
2990
|
+
|
|
2991
|
+
// src/cli/commands/files/search.ts
|
|
2990
2992
|
var search13 = new Command5("search");
|
|
2991
2993
|
search13.description("Search files with JSON options");
|
|
2992
2994
|
search13.argument("<options>", "JSON options for search");
|
|
2993
|
-
search13.action(async (
|
|
2994
|
-
const
|
|
2995
|
+
search13.action(async (...args) => {
|
|
2996
|
+
const [options_json] = args;
|
|
2997
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
2995
2998
|
const options = parse_options(options_json, FileSearchOptions, "files search");
|
|
2996
2999
|
const results = wiki.files.search(options);
|
|
2997
3000
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3004,8 +3007,9 @@ var set_description5 = new Command6("set-description");
|
|
|
3004
3007
|
set_description5.description("Set description for a file");
|
|
3005
3008
|
set_description5.argument("<file-id>", "File ID");
|
|
3006
3009
|
set_description5.argument("<markdown-file>", "Path to markdown file");
|
|
3007
|
-
set_description5.action(async (
|
|
3008
|
-
const
|
|
3010
|
+
set_description5.action(async (...args) => {
|
|
3011
|
+
const [id, file] = args;
|
|
3012
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3009
3013
|
try {
|
|
3010
3014
|
const content = readFileSync2(file, "utf-8");
|
|
3011
3015
|
wiki.files.set_description(Number(id), content);
|
|
@@ -3022,8 +3026,9 @@ var imported_by_file2 = new Command7("imported-by-file");
|
|
|
3022
3026
|
imported_by_file2.description("Files imported by the given file");
|
|
3023
3027
|
imported_by_file2.argument("<file-id>", "File ID");
|
|
3024
3028
|
imported_by_file2.argument("<options>", "JSON options");
|
|
3025
|
-
imported_by_file2.action(async (
|
|
3026
|
-
const
|
|
3029
|
+
imported_by_file2.action(async (...args) => {
|
|
3030
|
+
const [file_id, options_json] = args;
|
|
3031
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3027
3032
|
const options = parse_options(options_json, FileRelationOptions, "files imported-by-file");
|
|
3028
3033
|
const results = wiki.files.imported_by_file(Number(file_id), options);
|
|
3029
3034
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3035,8 +3040,9 @@ var importing_file2 = new Command8("importing-file");
|
|
|
3035
3040
|
importing_file2.description("Files importing the given file");
|
|
3036
3041
|
importing_file2.argument("<file-id>", "File ID");
|
|
3037
3042
|
importing_file2.argument("<options>", "JSON options");
|
|
3038
|
-
importing_file2.action(async (
|
|
3039
|
-
const
|
|
3043
|
+
importing_file2.action(async (...args) => {
|
|
3044
|
+
const [file_id, options_json] = args;
|
|
3045
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3040
3046
|
const options = parse_options(options_json, FileRelationOptions, "files importing-file");
|
|
3041
3047
|
const results = wiki.files.importing_file(Number(file_id), options);
|
|
3042
3048
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3048,8 +3054,9 @@ var importing_dependency2 = new Command9("importing-dependency");
|
|
|
3048
3054
|
importing_dependency2.description("Files importing the given dependency");
|
|
3049
3055
|
importing_dependency2.argument("<dep-id>", "Dependency ID");
|
|
3050
3056
|
importing_dependency2.argument("<options>", "JSON options");
|
|
3051
|
-
importing_dependency2.action(async (
|
|
3052
|
-
const
|
|
3057
|
+
importing_dependency2.action(async (...args) => {
|
|
3058
|
+
const [dep_id, options_json] = args;
|
|
3059
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3053
3060
|
const options = parse_options(options_json, FileRelationOptions, "files importing-dependency");
|
|
3054
3061
|
const results = wiki.files.importing_dependency(Number(dep_id), options);
|
|
3055
3062
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3102,8 +3109,9 @@ import { Command as Command11 } from "commander";
|
|
|
3102
3109
|
var get7 = new Command11("get");
|
|
3103
3110
|
get7.description("Get a symbol by ID");
|
|
3104
3111
|
get7.argument("<id>", "Symbol ID");
|
|
3105
|
-
get7.action(async (
|
|
3106
|
-
const
|
|
3112
|
+
get7.action(async (...args) => {
|
|
3113
|
+
const [id] = args;
|
|
3114
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3107
3115
|
const symbol = wiki.symbols.get(Number(id));
|
|
3108
3116
|
env.log(JSON.stringify(symbol, null, 2));
|
|
3109
3117
|
});
|
|
@@ -3113,8 +3121,9 @@ import { Command as Command12 } from "commander";
|
|
|
3113
3121
|
var search14 = new Command12("search");
|
|
3114
3122
|
search14.description("Search symbols with JSON options");
|
|
3115
3123
|
search14.argument("<options>", "JSON options");
|
|
3116
|
-
search14.action(async (
|
|
3117
|
-
const
|
|
3124
|
+
search14.action(async (...args) => {
|
|
3125
|
+
const [options_json] = args;
|
|
3126
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3118
3127
|
const options = parse_options(options_json, SymbolSearchOptions, "symbols search");
|
|
3119
3128
|
const results = wiki.symbols.search(options);
|
|
3120
3129
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3127,8 +3136,9 @@ var set_description6 = new Command13("set-description");
|
|
|
3127
3136
|
set_description6.description("Set description for a symbol");
|
|
3128
3137
|
set_description6.argument("<symbol-id>", "Symbol ID");
|
|
3129
3138
|
set_description6.argument("<markdown-file>", "Path to markdown file");
|
|
3130
|
-
set_description6.action(async (
|
|
3131
|
-
const
|
|
3139
|
+
set_description6.action(async (...args) => {
|
|
3140
|
+
const [id, file] = args;
|
|
3141
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3132
3142
|
try {
|
|
3133
3143
|
const content = readFileSync3(file, "utf-8");
|
|
3134
3144
|
wiki.symbols.set_description(Number(id), content);
|
|
@@ -3145,8 +3155,9 @@ var referencing_symbol2 = new Command14("referencing-symbol");
|
|
|
3145
3155
|
referencing_symbol2.description("Symbols referencing the given symbol");
|
|
3146
3156
|
referencing_symbol2.argument("<symbol-id>", "Symbol ID");
|
|
3147
3157
|
referencing_symbol2.argument("<options>", "JSON options");
|
|
3148
|
-
referencing_symbol2.action(async (
|
|
3149
|
-
const
|
|
3158
|
+
referencing_symbol2.action(async (...args) => {
|
|
3159
|
+
const [symbol_id, options_json] = args;
|
|
3160
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3150
3161
|
const options = parse_options(options_json, SymbolRelationOptions, "symbols referencing-symbol");
|
|
3151
3162
|
const results = wiki.symbols.referencing_symbol(Number(symbol_id), options);
|
|
3152
3163
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3158,8 +3169,9 @@ var referenced_by_symbol2 = new Command15("referenced-by-symbol");
|
|
|
3158
3169
|
referenced_by_symbol2.description("Symbols referenced by the given symbol");
|
|
3159
3170
|
referenced_by_symbol2.argument("<symbol-id>", "Symbol ID");
|
|
3160
3171
|
referenced_by_symbol2.argument("<options>", "JSON options");
|
|
3161
|
-
referenced_by_symbol2.action(async (
|
|
3162
|
-
const
|
|
3172
|
+
referenced_by_symbol2.action(async (...args) => {
|
|
3173
|
+
const [symbol_id, options_json] = args;
|
|
3174
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3163
3175
|
const options = parse_options(options_json, SymbolRelationOptions, "symbols referenced-by-symbol");
|
|
3164
3176
|
const results = wiki.symbols.referenced_by_symbol(Number(symbol_id), options);
|
|
3165
3177
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3171,8 +3183,9 @@ var using_dependency4 = new Command16("using-dependency");
|
|
|
3171
3183
|
using_dependency4.description("Symbols using the given dependency");
|
|
3172
3184
|
using_dependency4.argument("<dep-id>", "Dependency ID");
|
|
3173
3185
|
using_dependency4.argument("<options>", "JSON options");
|
|
3174
|
-
using_dependency4.action(async (
|
|
3175
|
-
const
|
|
3186
|
+
using_dependency4.action(async (...args) => {
|
|
3187
|
+
const [dep_id, options_json] = args;
|
|
3188
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3176
3189
|
const options = parse_options(options_json, SymbolRelationOptions, "symbols using-dependency");
|
|
3177
3190
|
const results = wiki.symbols.using_dependency(Number(dep_id), options);
|
|
3178
3191
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3225,8 +3238,9 @@ import { Command as Command18 } from "commander";
|
|
|
3225
3238
|
var get8 = new Command18("get");
|
|
3226
3239
|
get8.description("Get a directory by ID");
|
|
3227
3240
|
get8.argument("<id>", "Directory ID");
|
|
3228
|
-
get8.action(async (
|
|
3229
|
-
const
|
|
3241
|
+
get8.action(async (...args) => {
|
|
3242
|
+
const [id] = args;
|
|
3243
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3230
3244
|
const directory = wiki.directories.get(Number(id));
|
|
3231
3245
|
env.log(JSON.stringify(directory, null, 2));
|
|
3232
3246
|
});
|
|
@@ -3236,8 +3250,9 @@ import { Command as Command19 } from "commander";
|
|
|
3236
3250
|
var search15 = new Command19("search");
|
|
3237
3251
|
search15.description("Search directories with JSON options");
|
|
3238
3252
|
search15.argument("<options>", "JSON options");
|
|
3239
|
-
search15.action(async (
|
|
3240
|
-
const
|
|
3253
|
+
search15.action(async (...args) => {
|
|
3254
|
+
const [options_json] = args;
|
|
3255
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3241
3256
|
const options = parse_options(options_json, DirectorySearchOptions, "directories search");
|
|
3242
3257
|
const results = wiki.directories.search(options);
|
|
3243
3258
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3250,8 +3265,9 @@ var set_description7 = new Command20("set-description");
|
|
|
3250
3265
|
set_description7.description("Set description for a directory");
|
|
3251
3266
|
set_description7.argument("<directory-id>", "Directory ID");
|
|
3252
3267
|
set_description7.argument("<markdown-file>", "Path to markdown file");
|
|
3253
|
-
set_description7.action(async (
|
|
3254
|
-
const
|
|
3268
|
+
set_description7.action(async (...args) => {
|
|
3269
|
+
const [id, file] = args;
|
|
3270
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3255
3271
|
try {
|
|
3256
3272
|
const content = readFileSync4(file, "utf-8");
|
|
3257
3273
|
wiki.directories.set_description(Number(id), content);
|
|
@@ -3268,8 +3284,9 @@ var children2 = new Command21("children");
|
|
|
3268
3284
|
children2.description("Child directories of the given directory");
|
|
3269
3285
|
children2.argument("<parent-id>", "Parent directory ID");
|
|
3270
3286
|
children2.argument("<options>", "JSON options");
|
|
3271
|
-
children2.action(async (
|
|
3272
|
-
const
|
|
3287
|
+
children2.action(async (...args) => {
|
|
3288
|
+
const [parent_id, options_json] = args;
|
|
3289
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3273
3290
|
const options = parse_options(options_json, DirectoryRelationOptions, "directories children");
|
|
3274
3291
|
const results = wiki.directories.children(Number(parent_id), options);
|
|
3275
3292
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3281,8 +3298,9 @@ var files4 = new Command22("files");
|
|
|
3281
3298
|
files4.description("Files in the given directory");
|
|
3282
3299
|
files4.argument("<directory-id>", "Directory ID");
|
|
3283
3300
|
files4.argument("<options>", "JSON options");
|
|
3284
|
-
files4.action(async (
|
|
3285
|
-
const
|
|
3301
|
+
files4.action(async (...args) => {
|
|
3302
|
+
const [directory_id, options_json] = args;
|
|
3303
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3286
3304
|
const options = parse_options(options_json, FileRelationOptions, "directories files");
|
|
3287
3305
|
const results = wiki.directories.files(Number(directory_id), options);
|
|
3288
3306
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3334,8 +3352,9 @@ import { Command as Command24 } from "commander";
|
|
|
3334
3352
|
var get9 = new Command24("get");
|
|
3335
3353
|
get9.description("Get a dependency by ID");
|
|
3336
3354
|
get9.argument("<id>", "Dependency ID");
|
|
3337
|
-
get9.action(async (
|
|
3338
|
-
const
|
|
3355
|
+
get9.action(async (...args) => {
|
|
3356
|
+
const [id] = args;
|
|
3357
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3339
3358
|
const dependency = wiki.dependencies.get(Number(id));
|
|
3340
3359
|
env.log(JSON.stringify(dependency, null, 2));
|
|
3341
3360
|
});
|
|
@@ -3345,8 +3364,9 @@ import { Command as Command25 } from "commander";
|
|
|
3345
3364
|
var search16 = new Command25("search");
|
|
3346
3365
|
search16.description("Search dependencies with JSON options");
|
|
3347
3366
|
search16.argument("<options>", "JSON options");
|
|
3348
|
-
search16.action(async (
|
|
3349
|
-
const
|
|
3367
|
+
search16.action(async (...args) => {
|
|
3368
|
+
const [options_json] = args;
|
|
3369
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3350
3370
|
const options = parse_options(options_json, DependencySearchOptions, "dependencies search");
|
|
3351
3371
|
const results = wiki.dependencies.search(options);
|
|
3352
3372
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3359,8 +3379,9 @@ var set_description8 = new Command26("set-description");
|
|
|
3359
3379
|
set_description8.description("Set description for a dependency");
|
|
3360
3380
|
set_description8.argument("<dependency-id>", "Dependency ID");
|
|
3361
3381
|
set_description8.argument("<markdown-file>", "Path to markdown file");
|
|
3362
|
-
set_description8.action(async (
|
|
3363
|
-
const
|
|
3382
|
+
set_description8.action(async (...args) => {
|
|
3383
|
+
const [id, file] = args;
|
|
3384
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3364
3385
|
try {
|
|
3365
3386
|
const content = readFileSync5(file, "utf-8");
|
|
3366
3387
|
wiki.dependencies.set_description(Number(id), content);
|
|
@@ -3377,8 +3398,9 @@ var used_by_file3 = new Command27("used-by-file");
|
|
|
3377
3398
|
used_by_file3.description("Dependencies used by the given file");
|
|
3378
3399
|
used_by_file3.argument("<file-id>", "File ID");
|
|
3379
3400
|
used_by_file3.argument("<options>", "JSON options");
|
|
3380
|
-
used_by_file3.action(async (
|
|
3381
|
-
const
|
|
3401
|
+
used_by_file3.action(async (...args) => {
|
|
3402
|
+
const [file_id, options_json] = args;
|
|
3403
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3382
3404
|
const options = parse_options(options_json, DependencySelectOptions, "dependencies used-by-file");
|
|
3383
3405
|
const results = wiki.dependencies.used_by_file(Number(file_id), options);
|
|
3384
3406
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3390,8 +3412,9 @@ var used_by_symbol3 = new Command28("used-by-symbol");
|
|
|
3390
3412
|
used_by_symbol3.description("Dependencies used by the given symbol");
|
|
3391
3413
|
used_by_symbol3.argument("<symbol-id>", "Symbol ID");
|
|
3392
3414
|
used_by_symbol3.argument("<options>", "JSON options");
|
|
3393
|
-
used_by_symbol3.action(async (
|
|
3394
|
-
const
|
|
3415
|
+
used_by_symbol3.action(async (...args) => {
|
|
3416
|
+
const [symbol_id, options_json] = args;
|
|
3417
|
+
const wiki = await load_wiki(get_db_path(...args));
|
|
3395
3418
|
const options = parse_options(options_json, DependencySelectOptions, "dependencies used-by-symbol");
|
|
3396
3419
|
const results = wiki.dependencies.used_by_symbol(Number(symbol_id), options);
|
|
3397
3420
|
env.log(JSON.stringify(results, null, 2));
|
|
@@ -3440,6 +3463,7 @@ var commands = [update7, status, describe, files3, symbols3, directories3, depen
|
|
|
3440
3463
|
async function run(argv) {
|
|
3441
3464
|
const program = new Command30();
|
|
3442
3465
|
program.name("codewiki").description("Describe and explore TypeScript codebases").version("0.0.1");
|
|
3466
|
+
program.option("--db <path>", "Database location", "./wiki.db");
|
|
3443
3467
|
for (const cmd of commands) program.addCommand(cmd);
|
|
3444
3468
|
return program.parseAsync(argv, { from: "user" });
|
|
3445
3469
|
}
|