@webneat/codewiki 0.0.5 → 0.0.6

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/dist/cli.cjs CHANGED
@@ -578,7 +578,7 @@ var symbols2 = {
578
578
  where: {}
579
579
  };
580
580
  var external_dependencies2 = {
581
- select: ["id", "package", "subpath", "name", "state", "error"],
581
+ select: ["id", "package", "subpath", "name", "is_builtin", "state", "error"],
582
582
  order_by: ["id", "asc"],
583
583
  limit: 20,
584
584
  offset: 0,
@@ -2933,12 +2933,23 @@ var describe = new import_commander3.Command("describe");
2933
2933
  describe.description("Show the next item to describe");
2934
2934
  describe.action(async () => {
2935
2935
  const wiki = await load_wiki();
2936
- const next = get_next_to_describe(wiki);
2937
- if (!next) return env.log("All items are described!");
2938
- if (next.type === "dependency") return describe_dependency(next.entity);
2939
- env.log(
2940
- `All external dependencies are described, and we don't support describing other items yet (we are implementing the right order ...). You are done for now!`
2941
- );
2936
+ const result = wiki.to_describe(1);
2937
+ if (result.type === "none") {
2938
+ return env.log("All items are described!");
2939
+ }
2940
+ if (result.type === "dependencies" && result.items.length > 0) {
2941
+ return describe_dependency(result.items[0]);
2942
+ }
2943
+ if (result.type === "symbols" && result.items.length > 0) {
2944
+ return describe_symbol(wiki, result.items[0]);
2945
+ }
2946
+ if (result.type === "files" && result.items.length > 0) {
2947
+ return describe_file(result.items[0]);
2948
+ }
2949
+ if (result.type === "directories" && result.items.length > 0) {
2950
+ return describe_directory(result.items[0]);
2951
+ }
2952
+ env.log("No items to describe.");
2942
2953
  });
2943
2954
  function describe_dependency(dep) {
2944
2955
  env.log(import_dedent2.default`
@@ -2954,40 +2965,42 @@ function describe_dependency(dep) {
2954
2965
  \`codewiki dependencies set-description ${dep.id} <markdown-file>\`
2955
2966
  `);
2956
2967
  }
2957
- function get_next_to_describe(wiki) {
2958
- const deps = wiki.dependencies.search({
2959
- where: { state: "to_describe" },
2960
- limit: 1,
2961
- select: ["id", "package", "subpath", "name", "version", "github_repo"]
2962
- });
2963
- if (deps.length > 0) {
2964
- return { type: "dependency", entity: deps[0] };
2965
- }
2966
- const symbols4 = wiki.symbols.search({
2967
- where: { state: "to_describe" },
2968
- limit: 1,
2969
- select: ["id", "name", "type", "file_id", "is_exported"]
2970
- });
2971
- if (symbols4.length > 0) {
2972
- return { type: "symbol", entity: symbols4[0] };
2973
- }
2974
- const files5 = wiki.files.search({
2975
- where: { state: "to_describe" },
2976
- limit: 1,
2977
- select: ["id", "path"]
2978
- });
2979
- if (files5.length > 0) {
2980
- return { type: "file", entity: files5[0] };
2981
- }
2982
- const directories4 = wiki.directories.search({
2983
- where: { state: "to_describe" },
2984
- limit: 1,
2985
- select: ["id", "path"]
2986
- });
2987
- if (directories4.length > 0) {
2988
- return { type: "directory", entity: directories4[0] };
2989
- }
2990
- return null;
2968
+ function describe_symbol(wiki, sym) {
2969
+ const file = wiki.files.get(sym.file_id);
2970
+ env.log(import_dedent2.default`
2971
+ Your task is to describe the following symbol:
2972
+
2973
+ name: ${sym.name}
2974
+ type: ${sym.type}
2975
+ file: ${file?.path || "unknown"}
2976
+ exported: ${sym.is_exported}
2977
+
2978
+ Write a concise developer documentation for this ${sym.type} into a markdown file, then run:
2979
+
2980
+ codewiki symbols set-description ${sym.id} <markdown-file>
2981
+ `);
2982
+ }
2983
+ function describe_file(file) {
2984
+ env.log(import_dedent2.default`
2985
+ Your task is to describe the following file:
2986
+
2987
+ path: ${file.path}
2988
+
2989
+ Write a concise description of this file's purpose and contents into a markdown file, then run:
2990
+
2991
+ codewiki files set-description ${file.id} <markdown-file>
2992
+ `);
2993
+ }
2994
+ function describe_directory(dir) {
2995
+ env.log(import_dedent2.default`
2996
+ Your task is to describe the following directory:
2997
+
2998
+ path: ${dir.path}
2999
+
3000
+ Write a concise description of this directory's purpose and contents into a markdown file, then run:
3001
+
3002
+ codewiki directories set-description ${dir.id} <markdown-file>
3003
+ `);
2991
3004
  }
2992
3005
 
2993
3006
  // src/cli/commands/files/index.ts