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