@enjoys/context-engine 1.0.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.
Files changed (138) hide show
  1. package/README.md +213 -0
  2. package/data/commands/air.json +59 -0
  3. package/data/commands/ansible.json +24 -0
  4. package/data/commands/apachectl.json +87 -0
  5. package/data/commands/apt-get.json +81 -0
  6. package/data/commands/apt.json +91 -0
  7. package/data/commands/awk.json +26 -0
  8. package/data/commands/aws-vault.json +140 -0
  9. package/data/commands/aws.json +229 -0
  10. package/data/commands/az.json +36 -0
  11. package/data/commands/bazel.json +103 -0
  12. package/data/commands/brew.json +140 -0
  13. package/data/commands/bun.json +230 -0
  14. package/data/commands/caddy.json +194 -0
  15. package/data/commands/cargo.json +1048 -0
  16. package/data/commands/cat.json +18 -0
  17. package/data/commands/cd.json +48 -0
  18. package/data/commands/certbot.json +148 -0
  19. package/data/commands/chmod.json +97 -0
  20. package/data/commands/choco.json +134 -0
  21. package/data/commands/chown.json +59 -0
  22. package/data/commands/clickhouse-client.json +74 -0
  23. package/data/commands/cloudflare.json +226 -0
  24. package/data/commands/cmake.json +110 -0
  25. package/data/commands/cockroach.json +92 -0
  26. package/data/commands/conda.json +94 -0
  27. package/data/commands/consul.json +125 -0
  28. package/data/commands/cp.json +86 -0
  29. package/data/commands/curl.json +44 -0
  30. package/data/commands/cypress.json +100 -0
  31. package/data/commands/deno.json +29 -0
  32. package/data/commands/django-admin.json +86 -0
  33. package/data/commands/dnf.json +137 -0
  34. package/data/commands/docker.json +1100 -0
  35. package/data/commands/doctl.json +156 -0
  36. package/data/commands/eslint.json +69 -0
  37. package/data/commands/find.json +44 -0
  38. package/data/commands/firebase.json +97 -0
  39. package/data/commands/flask.json +79 -0
  40. package/data/commands/flyctl.json +148 -0
  41. package/data/commands/gcloud.json +227 -0
  42. package/data/commands/gh.json +39 -0
  43. package/data/commands/git.json +527 -0
  44. package/data/commands/glab.json +116 -0
  45. package/data/commands/go.json +161 -0
  46. package/data/commands/gofmt.json +51 -0
  47. package/data/commands/golangci-lint.json +89 -0
  48. package/data/commands/gradle.json +44 -0
  49. package/data/commands/grep.json +47 -0
  50. package/data/commands/gunicorn.json +83 -0
  51. package/data/commands/helm.json +1104 -0
  52. package/data/commands/hg.json +92 -0
  53. package/data/commands/httpd.json +147 -0
  54. package/data/commands/influx.json +119 -0
  55. package/data/commands/iptables.json +86 -0
  56. package/data/commands/java.json +31 -0
  57. package/data/commands/jest.json +82 -0
  58. package/data/commands/journalctl.json +88 -0
  59. package/data/commands/just.json +93 -0
  60. package/data/commands/k6.json +84 -0
  61. package/data/commands/kubectl.json +1277 -0
  62. package/data/commands/linode-cli.json +117 -0
  63. package/data/commands/locust.json +83 -0
  64. package/data/commands/ls.json +115 -0
  65. package/data/commands/make.json +86 -0
  66. package/data/commands/mocha.json +75 -0
  67. package/data/commands/mongosh.json +73 -0
  68. package/data/commands/mv.json +68 -0
  69. package/data/commands/mvn.json +45 -0
  70. package/data/commands/mysql.json +81 -0
  71. package/data/commands/nest.json +69 -0
  72. package/data/commands/netlify.json +92 -0
  73. package/data/commands/next.json +71 -0
  74. package/data/commands/nft.json +105 -0
  75. package/data/commands/nginx.json +146 -0
  76. package/data/commands/nmap.json +92 -0
  77. package/data/commands/node.json +43 -0
  78. package/data/commands/nomad.json +139 -0
  79. package/data/commands/npm.json +1265 -0
  80. package/data/commands/npx.json +58 -0
  81. package/data/commands/nx.json +82 -0
  82. package/data/commands/openssl.json +288 -0
  83. package/data/commands/packer.json +92 -0
  84. package/data/commands/pacman.json +82 -0
  85. package/data/commands/pg_dump.json +83 -0
  86. package/data/commands/pg_restore.json +74 -0
  87. package/data/commands/pip.json +95 -0
  88. package/data/commands/pipenv.json +79 -0
  89. package/data/commands/pipx.json +53 -0
  90. package/data/commands/playwright.json +97 -0
  91. package/data/commands/pnpm.json +29 -0
  92. package/data/commands/poetry.json +96 -0
  93. package/data/commands/prettier.json +71 -0
  94. package/data/commands/ps.json +31 -0
  95. package/data/commands/psql.json +124 -0
  96. package/data/commands/pulumi.json +130 -0
  97. package/data/commands/pytest.json +92 -0
  98. package/data/commands/python.json +30 -0
  99. package/data/commands/railway.json +91 -0
  100. package/data/commands/redis-cli.json +148 -0
  101. package/data/commands/render.json +72 -0
  102. package/data/commands/rm.json +79 -0
  103. package/data/commands/rsync.json +36 -0
  104. package/data/commands/rust.json +35 -0
  105. package/data/commands/rustup.json +103 -0
  106. package/data/commands/scp.json +60 -0
  107. package/data/commands/sed.json +28 -0
  108. package/data/commands/sqlite3.json +68 -0
  109. package/data/commands/ssh-keygen.json +112 -0
  110. package/data/commands/ssh.json +37 -0
  111. package/data/commands/sudo.json +147 -0
  112. package/data/commands/supabase.json +108 -0
  113. package/data/commands/svn.json +75 -0
  114. package/data/commands/systemctl.json +31 -0
  115. package/data/commands/tar.json +35 -0
  116. package/data/commands/tcpdump.json +77 -0
  117. package/data/commands/terraform.json +824 -0
  118. package/data/commands/terragrunt.json +83 -0
  119. package/data/commands/tsc.json +85 -0
  120. package/data/commands/turbo.json +72 -0
  121. package/data/commands/ufw.json +76 -0
  122. package/data/commands/unzip.json +59 -0
  123. package/data/commands/uvicorn.json +73 -0
  124. package/data/commands/vault.json +144 -0
  125. package/data/commands/vercel.json +98 -0
  126. package/data/commands/vite.json +63 -0
  127. package/data/commands/vitest.json +88 -0
  128. package/data/commands/wasm-pack.json +90 -0
  129. package/data/commands/wget.json +38 -0
  130. package/data/commands/winget.json +131 -0
  131. package/data/commands/wireshark.json +81 -0
  132. package/data/commands/yarn.json +28 -0
  133. package/data/commands/yum.json +98 -0
  134. package/data/commands/zip.json +59 -0
  135. package/index.d.ts +131 -0
  136. package/index.js +189 -0
  137. package/index.mjs +21 -0
  138. package/package.json +64 -0
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "yarn",
3
+ "description": "Fast, reliable, and secure JavaScript package manager",
4
+ "category": "package-manager",
5
+ "platforms": ["linux", "macos", "windows"],
6
+ "shells": ["bash", "zsh", "fish", "powershell"],
7
+ "subcommands": [
8
+ { "name": "init", "description": "Create a new package.json", "options": [{ "name": "--yes", "short": "-y", "description": "Accept defaults" }], "examples": ["yarn init", "yarn init -y"] },
9
+ { "name": "add", "description": "Add a package", "args": [{ "name": "<package>", "type": "string", "required": true, "description": "Package name" }], "options": [{ "name": "--dev", "short": "-D", "description": "Add to devDependencies" }, { "name": "--peer", "short": "-P", "description": "Add to peerDependencies" }, { "name": "--exact", "short": "-E", "description": "Add exact version" }], "examples": ["yarn add react", "yarn add -D typescript", "yarn add react@^18.0.0"] },
10
+ { "name": "remove", "description": "Remove a package", "args": [{ "name": "<package>", "type": "string", "required": true, "description": "Package name" }], "examples": ["yarn remove lodash"] },
11
+ { "name": "install", "description": "Install all dependencies", "options": [{ "name": "--frozen-lockfile", "description": "Don't generate lockfile changes" }, { "name": "--production", "description": "Only install production dependencies" }], "examples": ["yarn install", "yarn install --frozen-lockfile"] },
12
+ { "name": "run", "description": "Run a script from package.json", "args": [{ "name": "<script>", "type": "string", "required": true, "description": "Script name" }], "examples": ["yarn run build", "yarn run dev"] },
13
+ { "name": "upgrade", "description": "Upgrade packages", "args": [{ "name": "<package>", "type": "string", "required": false, "description": "Package name" }], "options": [{ "name": "--latest", "description": "Upgrade to latest version" }], "examples": ["yarn upgrade", "yarn upgrade --latest"] },
14
+ { "name": "outdated", "description": "Check for outdated packages", "examples": ["yarn outdated"] },
15
+ { "name": "cache clean", "description": "Clean cache", "examples": ["yarn cache clean"] },
16
+ { "name": "link", "description": "Symlink a local package", "args": [{ "name": "<package>", "type": "string", "required": false, "description": "Package name" }], "examples": ["yarn link", "yarn link my-package"] },
17
+ { "name": "dlx", "description": "Run a package without installing (Yarn Berry)", "args": [{ "name": "<command>", "type": "string", "required": true, "description": "Command to run" }], "examples": ["yarn dlx create-react-app myapp"] },
18
+ { "name": "workspace", "description": "Run command in workspace", "examples": ["yarn workspace @myapp/server add express"] },
19
+ { "name": "workspaces foreach", "description": "Run command in all workspaces", "examples": ["yarn workspaces foreach run build"] }
20
+ ],
21
+ "globalOptions": [
22
+ { "name": "--help", "short": "-h", "description": "Show help" },
23
+ { "name": "--version", "short": "-v", "description": "Show version" },
24
+ { "name": "--verbose", "description": "Verbose output" }
25
+ ],
26
+ "examples": ["yarn add react react-dom", "yarn install --frozen-lockfile", "yarn run build"],
27
+ "relatedCommands": ["npm", "pnpm", "npx", "node"]
28
+ }
@@ -0,0 +1,98 @@
1
+ {
2
+ "name": "yum",
3
+ "description": "Package manager for RHEL/CentOS (legacy, replaced by dnf)",
4
+ "category": "Package Managers",
5
+ "platforms": ["linux"],
6
+ "shells": ["bash", "zsh", "fish"],
7
+ "subcommands": [
8
+ { "name": "install", "description": "Install packages", "args": [{ "name": "packages", "description": "Package names", "required": true }], "options": [
9
+ { "name": "-y", "description": "Assume yes" },
10
+ { "name": "--enablerepo", "description": "Enable repository", "takesValue": true },
11
+ { "name": "--disablerepo", "description": "Disable repository", "takesValue": true }
12
+ ]},
13
+ { "name": "update", "description": "Update packages", "args": [{ "name": "packages", "description": "Specific packages (optional)", "required": false }] },
14
+ { "name": "remove", "description": "Remove packages", "args": [{ "name": "packages", "description": "Package names", "required": true }] },
15
+ { "name": "erase", "description": "Alias for remove" },
16
+ { "name": "list", "description": "List packages", "options": [
17
+ { "name": "installed", "description": "Only installed" },
18
+ { "name": "available", "description": "Only available" },
19
+ { "name": "updates", "description": "Only updates" }
20
+ ]},
21
+ { "name": "search", "description": "Search packages", "args": [{ "name": "query", "description": "Search term", "required": true }] },
22
+ { "name": "info", "description": "Show package information", "args": [{ "name": "package", "description": "Package name", "required": true }] },
23
+ { "name": "provides", "description": "Find package providing a file", "args": [{ "name": "file", "description": "File path or glob", "required": true }] },
24
+ { "name": "check-update", "description": "Check for available updates" },
25
+ { "name": "upgrade", "description": "Upgrade all packages" },
26
+ { "name": "downgrade", "description": "Downgrade a package" },
27
+ { "name": "reinstall", "description": "Reinstall a package" },
28
+ { "name": "clean", "description": "Clean caches", "subcommands": [
29
+ { "name": "all", "description": "Clean all caches" },
30
+ { "name": "metadata", "description": "Clean metadata" },
31
+ { "name": "packages", "description": "Clean packages" },
32
+ { "name": "dbcache", "description": "Clean dbcache" },
33
+ { "name": "expire-cache", "description": "Expire cache" }
34
+ ]},
35
+ { "name": "makecache", "description": "Generate metadata cache" },
36
+ { "name": "groupinstall", "description": "Install a group", "args": [{ "name": "group", "description": "Group name", "required": true }] },
37
+ { "name": "grouplist", "description": "List groups" },
38
+ { "name": "groupinfo", "description": "Group details" },
39
+ { "name": "repolist", "description": "List repositories" },
40
+ { "name": "repoinfo", "description": "Repository details" },
41
+ { "name": "deplist", "description": "List dependencies" },
42
+ { "name": "history", "description": "Transaction history" },
43
+ { "name": "localinstall", "description": "Install local RPM" }
44
+ ],
45
+ "globalOptions": [
46
+ { "name": "-y", "description": "Assume yes" },
47
+ { "name": "-q", "description": "Quiet" },
48
+ { "name": "-v", "description": "Verbose" },
49
+ { "name": "--enablerepo", "description": "Enable repo", "takesValue": true },
50
+ { "name": "--disablerepo", "description": "Disable repo", "takesValue": true },
51
+ { "name": "--nogpgcheck", "description": "Skip GPG checks" },
52
+ { "name": "--skip-broken", "description": "Skip broken packages" },
53
+ { "name": "-C", "description": "Use cache only" },
54
+ { "name": "--downloadonly", "description": "Download without installing" },
55
+ { "name": "--setopt", "description": "Set config option", "takesValue": true }
56
+ ],
57
+ "examples": [
58
+ { "command": "sudo yum install nginx", "description": "Install nginx" },
59
+ { "command": "sudo yum install -y git curl wget", "description": "Install with auto-yes" },
60
+ { "command": "sudo yum update", "description": "Update all packages" },
61
+ { "command": "sudo yum remove httpd", "description": "Remove package" },
62
+ { "command": "yum search redis", "description": "Search packages" },
63
+ { "command": "yum info nginx", "description": "Package details" },
64
+ { "command": "yum list installed", "description": "List installed" },
65
+ { "command": "yum check-update", "description": "Check for updates" },
66
+ { "command": "yum repolist", "description": "List enabled repos" },
67
+ { "command": "sudo yum clean all", "description": "Clean all caches" }
68
+ ],
69
+ "relatedCommands": ["dnf", "rpm"],
70
+ "contextEngine": {
71
+ "detectors": [
72
+ {
73
+ "name": "installed",
74
+ "description": "Installed packages",
75
+ "command": "yum list installed 2>/dev/null | tail -20",
76
+ "parser": "lines",
77
+ "cacheFor": 120,
78
+ "requiresCmd": "yum"
79
+ },
80
+ {
81
+ "name": "repos",
82
+ "description": "Configured repositories",
83
+ "command": "yum repolist 2>/dev/null | tail -10",
84
+ "parser": "lines",
85
+ "cacheFor": 300,
86
+ "requiresCmd": "yum"
87
+ },
88
+ {
89
+ "name": "updates",
90
+ "description": "Available updates",
91
+ "command": "yum check-update 2>/dev/null | tail -15",
92
+ "parser": "lines",
93
+ "cacheFor": 300,
94
+ "requiresCmd": "yum"
95
+ }
96
+ ]
97
+ }
98
+ }
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "zip",
3
+ "description": "Package and compress files into ZIP archives",
4
+ "category": "Linux Coreutils",
5
+ "platforms": ["linux", "macos", "windows"],
6
+ "shells": ["bash", "zsh", "powershell", "fish"],
7
+ "subcommands": [],
8
+ "globalOptions": [
9
+ { "name": "-r", "description": "Recurse into directories" },
10
+ { "name": "-e", "description": "Encrypt with password" },
11
+ { "name": "-P", "description": "Password (visible in process list!)", "takesValue": true },
12
+ { "name": "-j", "description": "Junk directory names (store files only)" },
13
+ { "name": "-9", "description": "Maximum compression" },
14
+ { "name": "-0", "description": "No compression (store only)" },
15
+ { "name": "-u", "description": "Update existing entries" },
16
+ { "name": "-d", "description": "Delete entries from archive" },
17
+ { "name": "-f", "description": "Freshen (update only changed files)" },
18
+ { "name": "-m", "description": "Move files into archive (delete originals)" },
19
+ { "name": "-x", "description": "Exclude files matching pattern", "takesValue": true },
20
+ { "name": "-i", "description": "Include only files matching pattern", "takesValue": true },
21
+ { "name": "-q", "description": "Quiet mode" },
22
+ { "name": "-v", "description": "Verbose mode" },
23
+ { "name": "-T", "description": "Test archive integrity" },
24
+ { "name": "-s", "description": "Split size for split archives", "takesValue": true },
25
+ { "name": "-l", "description": "Convert LF to CRLF" },
26
+ { "name": "-ll", "description": "Convert CRLF to LF" },
27
+ { "name": "-y", "description": "Store symbolic links" },
28
+ { "name": "--symlinks", "description": "Store symbolic links" }
29
+ ],
30
+ "examples": [
31
+ { "command": "zip archive.zip file1.txt file2.txt", "description": "Zip files" },
32
+ { "command": "zip -r project.zip src/", "description": "Zip directory recursively" },
33
+ { "command": "zip -r app.zip . -x '*.git*' -x 'node_modules/*'", "description": "Zip excluding patterns" },
34
+ { "command": "zip -9 -r compressed.zip dir/", "description": "Maximum compression" },
35
+ { "command": "zip -e secure.zip secret.txt", "description": "Encrypt zip" },
36
+ { "command": "zip -d archive.zip unwanted.txt", "description": "Delete from archive" },
37
+ { "command": "zip -u archive.zip updated.txt", "description": "Update file in archive" },
38
+ { "command": "zip -j flat.zip dir/a.txt dir/b.txt", "description": "Flatten directory structure" }
39
+ ],
40
+ "relatedCommands": ["unzip", "tar"],
41
+ "contextEngine": {
42
+ "detectors": [
43
+ {
44
+ "name": "zip_files",
45
+ "description": "Existing ZIP archives",
46
+ "command": "find . -maxdepth 2 -name '*.zip' 2>/dev/null | head -10",
47
+ "parser": "lines",
48
+ "cacheFor": 15
49
+ },
50
+ {
51
+ "name": "current_files",
52
+ "description": "Files in current directory",
53
+ "command": "ls -1 2>/dev/null | head -30",
54
+ "parser": "lines",
55
+ "cacheFor": 10
56
+ }
57
+ ]
58
+ }
59
+ }
package/index.d.ts ADDED
@@ -0,0 +1,131 @@
1
+ export interface CommandArg {
2
+ name: string;
3
+ description?: string;
4
+ required?: boolean;
5
+ type?: string;
6
+ }
7
+
8
+ export interface CommandOption {
9
+ name: string;
10
+ shorthand?: string;
11
+ short?: string;
12
+ description?: string;
13
+ takesValue?: boolean;
14
+ type?: string;
15
+ }
16
+
17
+ export interface CommandExample {
18
+ command: string;
19
+ description?: string;
20
+ }
21
+
22
+ export interface Subcommand {
23
+ name: string;
24
+ description?: string;
25
+ args?: CommandArg[];
26
+ options?: CommandOption[];
27
+ subcommands?: Subcommand[];
28
+ examples?: string[] | CommandExample[];
29
+ }
30
+
31
+ export interface ContextDetector {
32
+ name: string;
33
+ description?: string;
34
+ command: string;
35
+ parser: "text" | "lines" | "json" | "csv" | "keyvalue" | "regex" | "table";
36
+ pattern?: string;
37
+ cacheFor?: number;
38
+ requiresCmd?: string;
39
+ }
40
+
41
+ export interface ContextEngine {
42
+ detectors: ContextDetector[];
43
+ }
44
+
45
+ export interface Command {
46
+ name: string;
47
+ description: string;
48
+ category: string;
49
+ platforms: ("linux" | "macos" | "windows")[];
50
+ shells: ("bash" | "zsh" | "fish" | "powershell" | "cmd")[];
51
+ subcommands: Subcommand[];
52
+ globalOptions: CommandOption[];
53
+ examples: CommandExample[];
54
+ relatedCommands?: string[];
55
+ contextEngine?: ContextEngine;
56
+ }
57
+
58
+ /**
59
+ * Get a single command by name.
60
+ */
61
+ export function getCommand(name: string): Command | undefined;
62
+
63
+ /**
64
+ * Get all commands as an array.
65
+ */
66
+ export function getAllCommands(): Command[];
67
+
68
+ /**
69
+ * List all available command names (sorted).
70
+ */
71
+ export function listCommandNames(): string[];
72
+
73
+ /**
74
+ * Get commands filtered by category (case-insensitive partial match).
75
+ */
76
+ export function getCommandsByCategory(category: string): Command[];
77
+
78
+ /**
79
+ * Get commands filtered by platform.
80
+ */
81
+ export function getCommandsByPlatform(platform: "linux" | "macos" | "windows"): Command[];
82
+
83
+ /**
84
+ * Search commands by name, description, or category.
85
+ */
86
+ export function searchCommands(query: string): Command[];
87
+
88
+ /**
89
+ * Get all unique categories.
90
+ */
91
+ export function getCategories(): string[];
92
+
93
+ /**
94
+ * Get the context engine detectors for a command.
95
+ */
96
+ export function getContextEngine(name: string): ContextEngine | null;
97
+
98
+ /**
99
+ * Get subcommands for a command.
100
+ */
101
+ export function getSubcommands(name: string): Subcommand[];
102
+
103
+ /**
104
+ * Get global options for a command.
105
+ */
106
+ export function getGlobalOptions(name: string): CommandOption[];
107
+
108
+ /**
109
+ * Get examples for a command.
110
+ */
111
+ export function getExamples(name: string): CommandExample[];
112
+
113
+ /**
114
+ * Get the total number of commands.
115
+ */
116
+ export function count(): number;
117
+
118
+ /**
119
+ * Clear the internal cache.
120
+ */
121
+ export function clearCache(): void;
122
+
123
+ /**
124
+ * Resolve the absolute path to a command JSON file.
125
+ */
126
+ export function resolveCommandPath(name: string): string;
127
+
128
+ /**
129
+ * Absolute path to the commands data directory.
130
+ */
131
+ export const dataDir: string;
package/index.js ADDED
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+
6
+ const COMMANDS_DIR = path.join(__dirname, "data", "commands");
7
+
8
+ /** @type {Map<string, object>|null} */
9
+ let _cache = null;
10
+
11
+ /**
12
+ * Load all commands into cache (lazy, first call only).
13
+ * @returns {Map<string, object>}
14
+ */
15
+ function _loadAll() {
16
+ if (_cache) return _cache;
17
+ _cache = new Map();
18
+ const files = fs.readdirSync(COMMANDS_DIR).filter((f) => f.endsWith(".json"));
19
+ for (const file of files) {
20
+ const data = JSON.parse(
21
+ fs.readFileSync(path.join(COMMANDS_DIR, file), "utf-8")
22
+ );
23
+ _cache.set(data.name, data);
24
+ }
25
+ return _cache;
26
+ }
27
+
28
+ /**
29
+ * Get a single command by name.
30
+ * @param {string} name - Command name (e.g. "git", "docker", "kubectl")
31
+ * @returns {object|undefined}
32
+ */
33
+ function getCommand(name) {
34
+ return _loadAll().get(name);
35
+ }
36
+
37
+ /**
38
+ * Get all commands as an array.
39
+ * @returns {object[]}
40
+ */
41
+ function getAllCommands() {
42
+ return Array.from(_loadAll().values());
43
+ }
44
+
45
+ /**
46
+ * List all available command names.
47
+ * @returns {string[]}
48
+ */
49
+ function listCommandNames() {
50
+ return Array.from(_loadAll().keys()).sort();
51
+ }
52
+
53
+ /**
54
+ * Get commands filtered by category.
55
+ * @param {string} category - Category name (case-insensitive partial match)
56
+ * @returns {object[]}
57
+ */
58
+ function getCommandsByCategory(category) {
59
+ const lc = category.toLowerCase();
60
+ return getAllCommands().filter(
61
+ (cmd) => cmd.category && cmd.category.toLowerCase().includes(lc)
62
+ );
63
+ }
64
+
65
+ /**
66
+ * Get commands filtered by platform.
67
+ * @param {string} platform - "linux" | "macos" | "windows"
68
+ * @returns {object[]}
69
+ */
70
+ function getCommandsByPlatform(platform) {
71
+ const lc = platform.toLowerCase();
72
+ return getAllCommands().filter(
73
+ (cmd) =>
74
+ Array.isArray(cmd.platforms) &&
75
+ cmd.platforms.some((p) => p.toLowerCase() === lc)
76
+ );
77
+ }
78
+
79
+ /**
80
+ * Search commands by name, description, or category.
81
+ * @param {string} query - Search query (case-insensitive)
82
+ * @returns {object[]}
83
+ */
84
+ function searchCommands(query) {
85
+ const lc = query.toLowerCase();
86
+ return getAllCommands().filter(
87
+ (cmd) =>
88
+ cmd.name.toLowerCase().includes(lc) ||
89
+ (cmd.description && cmd.description.toLowerCase().includes(lc)) ||
90
+ (cmd.category && cmd.category.toLowerCase().includes(lc))
91
+ );
92
+ }
93
+
94
+ /**
95
+ * Get all unique categories.
96
+ * @returns {string[]}
97
+ */
98
+ function getCategories() {
99
+ const cats = new Set();
100
+ for (const cmd of _loadAll().values()) {
101
+ if (cmd.category) cats.add(cmd.category);
102
+ }
103
+ return Array.from(cats).sort();
104
+ }
105
+
106
+ /**
107
+ * Get the context engine detectors for a command.
108
+ * @param {string} name - Command name
109
+ * @returns {object|null} The contextEngine config or null
110
+ */
111
+ function getContextEngine(name) {
112
+ const cmd = getCommand(name);
113
+ return cmd && cmd.contextEngine ? cmd.contextEngine : null;
114
+ }
115
+
116
+ /**
117
+ * Get subcommands for a command.
118
+ * @param {string} name - Command name
119
+ * @returns {object[]}
120
+ */
121
+ function getSubcommands(name) {
122
+ const cmd = getCommand(name);
123
+ return cmd && Array.isArray(cmd.subcommands) ? cmd.subcommands : [];
124
+ }
125
+
126
+ /**
127
+ * Get global options for a command.
128
+ * @param {string} name - Command name
129
+ * @returns {object[]}
130
+ */
131
+ function getGlobalOptions(name) {
132
+ const cmd = getCommand(name);
133
+ return cmd && Array.isArray(cmd.globalOptions) ? cmd.globalOptions : [];
134
+ }
135
+
136
+ /**
137
+ * Get examples for a command.
138
+ * @param {string} name - Command name
139
+ * @returns {object[]}
140
+ */
141
+ function getExamples(name) {
142
+ const cmd = getCommand(name);
143
+ return cmd && Array.isArray(cmd.examples) ? cmd.examples : [];
144
+ }
145
+
146
+ /**
147
+ * Get the total number of commands available.
148
+ * @returns {number}
149
+ */
150
+ function count() {
151
+ return _loadAll().size;
152
+ }
153
+
154
+ /**
155
+ * Clear the internal cache (useful for testing).
156
+ */
157
+ function clearCache() {
158
+ _cache = null;
159
+ }
160
+
161
+ /**
162
+ * Resolve the path to a specific command JSON file.
163
+ * @param {string} name - Command name
164
+ * @returns {string}
165
+ */
166
+ function resolveCommandPath(name) {
167
+ return path.join(COMMANDS_DIR, `${name}.json`);
168
+ }
169
+
170
+ /** @type {string} Path to the commands data directory */
171
+ const dataDir = COMMANDS_DIR;
172
+
173
+ module.exports = {
174
+ getCommand,
175
+ getAllCommands,
176
+ listCommandNames,
177
+ getCommandsByCategory,
178
+ getCommandsByPlatform,
179
+ searchCommands,
180
+ getCategories,
181
+ getContextEngine,
182
+ getSubcommands,
183
+ getGlobalOptions,
184
+ getExamples,
185
+ count,
186
+ clearCache,
187
+ resolveCommandPath,
188
+ dataDir,
189
+ };
package/index.mjs ADDED
@@ -0,0 +1,21 @@
1
+ import { createRequire } from "module";
2
+ const require = createRequire(import.meta.url);
3
+ const engine = require("./index.js");
4
+
5
+ export const getCommand = engine.getCommand;
6
+ export const getAllCommands = engine.getAllCommands;
7
+ export const listCommandNames = engine.listCommandNames;
8
+ export const getCommandsByCategory = engine.getCommandsByCategory;
9
+ export const getCommandsByPlatform = engine.getCommandsByPlatform;
10
+ export const searchCommands = engine.searchCommands;
11
+ export const getCategories = engine.getCategories;
12
+ export const getContextEngine = engine.getContextEngine;
13
+ export const getSubcommands = engine.getSubcommands;
14
+ export const getGlobalOptions = engine.getGlobalOptions;
15
+ export const getExamples = engine.getExamples;
16
+ export const count = engine.count;
17
+ export const clearCache = engine.clearCache;
18
+ export const resolveCommandPath = engine.resolveCommandPath;
19
+ export const dataDir = engine.dataDir;
20
+
21
+ export default engine;
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@enjoys/context-engine",
3
+ "version": "1.0.0",
4
+ "description": "Comprehensive CLI command context engine with 133 tools — subcommands, options, examples, and runtime context detectors for intelligent terminal autocomplete",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "require": "./index.js",
10
+ "import": "./index.mjs",
11
+ "types": "./index.d.ts"
12
+ },
13
+ "./commands": "./data/commands",
14
+ "./commands/*": "./data/commands/*"
15
+ },
16
+ "files": [
17
+ "index.js",
18
+ "index.mjs",
19
+ "index.d.ts",
20
+ "data/"
21
+ ],
22
+ "scripts": {
23
+ "test": "node test.js",
24
+ "prepublishOnly": "node -e \"require('./index.js')\""
25
+ },
26
+ "keywords": [
27
+ "cli",
28
+ "terminal",
29
+ "autocomplete",
30
+ "context-engine",
31
+ "command-palette",
32
+ "shell",
33
+ "bash",
34
+ "zsh",
35
+ "devtools",
36
+ "docker",
37
+ "git",
38
+ "kubectl",
39
+ "terraform",
40
+ "aws",
41
+ "npm",
42
+ "node",
43
+ "python",
44
+ "go",
45
+ "rust",
46
+ "completions",
47
+ "subcommands",
48
+ "options",
49
+ "webterminal"
50
+ ],
51
+ "author": "Enjoys Inc",
52
+ "license": "MIT",
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/enjoys-in/context-engine.git"
56
+ },
57
+ "homepage": "https://github.com/enjoys-in/context-engine#readme",
58
+ "bugs": {
59
+ "url": "https://github.com/enjoys-in/context-engine/issues"
60
+ },
61
+ "engines": {
62
+ "node": ">=14.0.0"
63
+ }
64
+ }