@kentwynn/kgraph 0.1.1 → 0.1.3

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.
@@ -0,0 +1 @@
1
+ export declare function renderRootHelp(useColor?: boolean): string;
@@ -0,0 +1,60 @@
1
+ import { Chalk } from "chalk";
2
+ import figlet from "figlet";
3
+ export function renderRootHelp(useColor = supportsColor()) {
4
+ const theme = new Chalk({ level: useColor ? 3 : 0 });
5
+ const command = (name, description) => ` ${theme.green(name.padEnd(30))} ${description}`;
6
+ const logo = renderLogo();
7
+ return [
8
+ "",
9
+ theme.hex("#7dd3fc").bold(logo),
10
+ "",
11
+ ` ${theme.bold("KGraph")} ${theme.dim("Persistent repo intelligence for AI coding tools")}`,
12
+ "",
13
+ ` ${theme.hex("#c084fc")("Build a local knowledge layer that helps Codex, Copilot, Cursor,")}`,
14
+ ` ${theme.hex("#c084fc")("and Claude Code reuse repo structure, decisions, and debugging history.")}`,
15
+ "",
16
+ theme.bold("Usage"),
17
+ " kgraph <command> [options]",
18
+ "",
19
+ theme.bold("Start"),
20
+ command("init", "Create .kgraph/ workspace"),
21
+ command("init --integrations codex,cursor", "Initialize and connect AI tools"),
22
+ "",
23
+ theme.bold("Workflows"),
24
+ command("scan", "Refresh file, symbol, import, and relationship maps"),
25
+ command("context \"auth token refresh\"", "Return compact context for an AI chat"),
26
+ command("update", "Process .kgraph/inbox Markdown cognition notes"),
27
+ "",
28
+ theme.bold("Integrations"),
29
+ command("integrate list", "Show configured AI tool integrations"),
30
+ command("integrate add codex copilot", "Write KGraph instructions for AI tools"),
31
+ command("integrate remove cursor", "Remove KGraph-managed instruction blocks"),
32
+ "",
33
+ theme.bold("Options"),
34
+ command("-V, --version", "Show version"),
35
+ command("-h, --help", "Show this help"),
36
+ "",
37
+ `${theme.yellow("Examples")}`,
38
+ " kgraph init --integrations codex,copilot,cursor",
39
+ " kgraph scan",
40
+ " kgraph context \"blog admin token usage\" --json",
41
+ "",
42
+ theme.dim("Docs: https://github.com/kentwynn/KGraph#readme"),
43
+ ""
44
+ ].join("\n");
45
+ }
46
+ function renderLogo() {
47
+ try {
48
+ return figlet.textSync("KGraph", {
49
+ font: "ANSI Shadow",
50
+ horizontalLayout: "default",
51
+ verticalLayout: "default"
52
+ });
53
+ }
54
+ catch {
55
+ return "KGraph";
56
+ }
57
+ }
58
+ function supportsColor() {
59
+ return Boolean(process.stdout.isTTY) && process.env.NO_COLOR === undefined;
60
+ }
package/dist/cli/index.js CHANGED
@@ -1,16 +1,28 @@
1
1
  #!/usr/bin/env node
2
+ import { realpathSync } from "node:fs";
3
+ import { fileURLToPath } from "node:url";
2
4
  import { Command } from "commander";
3
5
  import { registerInitCommand } from "./commands/init.js";
4
6
  import { registerScanCommand } from "./commands/scan.js";
5
7
  import { registerUpdateCommand } from "./commands/update.js";
6
8
  import { registerContextCommand } from "./commands/context.js";
7
9
  import { registerIntegrateCommand } from "./commands/integrate.js";
10
+ import { renderRootHelp } from "./help.js";
8
11
  export function createProgram() {
9
12
  const program = new Command();
10
13
  program
11
14
  .name("kgraph")
12
15
  .description("Persistent repo intelligence for AI coding assistants")
13
- .version("0.1.0");
16
+ .version("0.1.2")
17
+ .addHelpText("beforeAll", renderRootHelp())
18
+ .helpOption(false);
19
+ program.option("-h, --help", "Show this help");
20
+ program.hook("preAction", (thisCommand) => {
21
+ if (thisCommand.opts().help) {
22
+ console.log(renderRootHelp());
23
+ process.exitCode = 0;
24
+ }
25
+ });
14
26
  registerInitCommand(program);
15
27
  registerScanCommand(program);
16
28
  registerUpdateCommand(program);
@@ -18,6 +30,23 @@ export function createProgram() {
18
30
  registerIntegrateCommand(program);
19
31
  return program;
20
32
  }
21
- if (import.meta.url === `file://${process.argv[1]}`) {
22
- await createProgram().parseAsync(process.argv);
33
+ if (isCliEntrypoint()) {
34
+ const program = createProgram();
35
+ if (process.argv.length <= 2 || process.argv.includes("-h") || process.argv.includes("--help")) {
36
+ console.log(renderRootHelp());
37
+ }
38
+ else {
39
+ await program.parseAsync(process.argv);
40
+ }
41
+ }
42
+ function isCliEntrypoint() {
43
+ if (!process.argv[1]) {
44
+ return false;
45
+ }
46
+ try {
47
+ return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1]);
48
+ }
49
+ catch {
50
+ return import.meta.url === `file://${process.argv[1]}`;
51
+ }
23
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kentwynn/kgraph",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Persistent repo intelligence for AI coding assistants.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -38,14 +38,16 @@
38
38
  },
39
39
  "homepage": "https://github.com/kentwynn/KGraph#readme",
40
40
  "dependencies": {
41
+ "chalk": "^5.6.2",
41
42
  "commander": "^12.1.0",
42
43
  "fast-glob": "^3.3.2",
44
+ "figlet": "^1.11.0",
45
+ "typescript": "^5.9.3",
43
46
  "yaml": "^2.5.1"
44
47
  },
45
48
  "devDependencies": {
46
49
  "@types/node": "^20.17.10",
47
50
  "tsx": "^4.19.2",
48
- "typescript": "^5.7.2",
49
51
  "vitest": "^2.1.8"
50
52
  },
51
53
  "engines": {