krims-code-cli 1.5.2__py3-none-any.whl

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 (43) hide show
  1. krims_code_cli-1.5.2.dist-info/METADATA +336 -0
  2. krims_code_cli-1.5.2.dist-info/RECORD +43 -0
  3. krims_code_cli-1.5.2.dist-info/WHEEL +5 -0
  4. krims_code_cli-1.5.2.dist-info/entry_points.txt +2 -0
  5. krims_code_cli-1.5.2.dist-info/licenses/LICENSE +21 -0
  6. krims_code_cli-1.5.2.dist-info/top_level.txt +1 -0
  7. krims_pip/__init__.py +1 -0
  8. krims_pip/cli.py +50 -0
  9. krims_pip/node_project/bin/krims-code.js +10 -0
  10. krims_pip/node_project/package-lock.json +793 -0
  11. krims_pip/node_project/package.json +46 -0
  12. krims_pip/node_project/src/agent.js +415 -0
  13. krims_pip/node_project/src/ai/fallback.js +239 -0
  14. krims_pip/node_project/src/ai/google.js +87 -0
  15. krims_pip/node_project/src/ai/providers.js +203 -0
  16. krims_pip/node_project/src/ai/router.js +146 -0
  17. krims_pip/node_project/src/ai/search.js +94 -0
  18. krims_pip/node_project/src/ai/telemetry.js +125 -0
  19. krims_pip/node_project/src/ai/tokens.js +101 -0
  20. krims_pip/node_project/src/ai/universal.js +507 -0
  21. krims_pip/node_project/src/ai/xai.js +50 -0
  22. krims_pip/node_project/src/chat.js +2543 -0
  23. krims_pip/node_project/src/cli.js +632 -0
  24. krims_pip/node_project/src/commands/commit.js +157 -0
  25. krims_pip/node_project/src/commands/dashboard.js +59 -0
  26. krims_pip/node_project/src/commands/github.js +349 -0
  27. krims_pip/node_project/src/commands/index.js +67 -0
  28. krims_pip/node_project/src/commands/status.js +66 -0
  29. krims_pip/node_project/src/commands/teamwork-preview.js +326 -0
  30. krims_pip/node_project/src/commands/theme.js +42 -0
  31. krims_pip/node_project/src/commands/themes.js +30 -0
  32. krims_pip/node_project/src/config.js +400 -0
  33. krims_pip/node_project/src/dashboard.js +112 -0
  34. krims_pip/node_project/src/file-parser.js +164 -0
  35. krims_pip/node_project/src/git.js +41 -0
  36. krims_pip/node_project/src/mic.js +220 -0
  37. krims_pip/node_project/src/modes.js +92 -0
  38. krims_pip/node_project/src/telemetry-server.js +855 -0
  39. krims_pip/node_project/src/ui/banner.js +204 -0
  40. krims_pip/node_project/src/ui/dashboard.html +834 -0
  41. krims_pip/node_project/src/ui/spinner.js +43 -0
  42. krims_pip/node_project/src/ui/theme.js +624 -0
  43. krims_pip/node_project/src/updater.js +196 -0
@@ -0,0 +1,196 @@
1
+ // ═══════════════════════════════════════════════════════════
2
+ // Krims Code AI CLI — Automated Update & Highlights Engine
3
+ // Checks NPM registry, updates packages, and renders release details.
4
+ // ═══════════════════════════════════════════════════════════
5
+
6
+ import { readFileSync } from "node:fs";
7
+ import { fileURLToPath } from "node:url";
8
+ import { dirname, join } from "node:path";
9
+ import { exec } from "node:child_process";
10
+ import { promisify } from "node:util";
11
+ import { getConfigValue, setConfigValue } from "./config.js";
12
+ import { colors, label, separator } from "./ui/theme.js";
13
+ import { createSpinner } from "./ui/spinner.js";
14
+
15
+ const execAsync = promisify(exec);
16
+
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ const __dirname = dirname(__filename);
19
+ const pkg = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf8"));
20
+
21
+ /**
22
+ * Returns true if version 'latest' is newer than version 'current'.
23
+ * Supports standard semver format x.y.z.
24
+ * @param {string} latest
25
+ * @param {string} current
26
+ * @returns {boolean}
27
+ */
28
+ export function isNewerVersion(latest, current) {
29
+ const l = latest.split(".").map((num) => parseInt(num, 10) || 0);
30
+ const c = current.split(".").map((num) => parseInt(num, 10) || 0);
31
+ for (let i = 0; i < 3; i++) {
32
+ if (l[i] > c[i]) return true;
33
+ if (l[i] < c[i]) return false;
34
+ }
35
+ return false;
36
+ }
37
+
38
+ /**
39
+ * Fetches and displays release highlights from the remote repository.
40
+ * @param {string} version
41
+ */
42
+ export async function showReleaseHighlights(version) {
43
+ try {
44
+ const controller = new AbortController();
45
+ const timeoutId = setTimeout(() => controller.abort(), 2000);
46
+
47
+ const res = await fetch("https://raw.githubusercontent.com/Krylo-60/krims-code-cli/main/HIGHLIGHTS.md", {
48
+ signal: controller.signal,
49
+ });
50
+ clearTimeout(timeoutId);
51
+
52
+ if (!res.ok) return;
53
+ const text = await res.text();
54
+
55
+ console.log("\n" + separator("━"));
56
+ console.log(colors.accent.bold(` ★ Krims Code AI CLI v${version} RELEASE HIGHLIGHTS ★`));
57
+ console.log(separator("─"));
58
+
59
+ const lines = text.split("\n");
60
+ let inReleaseHeader = false;
61
+ let printedAny = false;
62
+
63
+ for (const line of lines) {
64
+ const trimmed = line.trim();
65
+ if (trimmed.startsWith("#")) {
66
+ // Matches the version header like "# Krims Code CLI v1.1.9 Highlights" or similar
67
+ if (trimmed.toLowerCase().includes(`v${version}`)) {
68
+ inReleaseHeader = true;
69
+ } else {
70
+ inReleaseHeader = false;
71
+ }
72
+ continue;
73
+ }
74
+
75
+ if (inReleaseHeader && trimmed) {
76
+ if (trimmed.startsWith("-") || trimmed.startsWith("*")) {
77
+ console.log(colors.brand(" " + trimmed));
78
+ printedAny = true;
79
+ } else {
80
+ console.log(colors.text(" " + trimmed));
81
+ printedAny = true;
82
+ }
83
+ }
84
+ }
85
+
86
+ if (!printedAny) {
87
+ // Fallback if no specific version section was found in HIGHLIGHTS.md
88
+ for (const line of lines) {
89
+ const trimmed = line.trim();
90
+ if (trimmed.startsWith("#")) continue;
91
+ if (trimmed.startsWith("-") || trimmed.startsWith("*")) {
92
+ console.log(colors.brand(" " + trimmed));
93
+ } else if (trimmed) {
94
+ console.log(colors.text(" " + trimmed));
95
+ }
96
+ }
97
+ }
98
+
99
+ console.log(separator("━") + "\n");
100
+ } catch {
101
+ // Fail silently (offline or repo down)
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Checks for updates and runs the automatic updater if configured.
107
+ */
108
+ export async function checkForUpdates(force = false) {
109
+ const autoUpdate = (await getConfigValue("AUTO_UPDATE")) !== "false";
110
+ const showHighlights = (await getConfigValue("SHOW_HIGHLIGHTS")) !== "false";
111
+ const lastCheck = parseInt(await getConfigValue("LAST_UPDATE_CHECK") || "0", 10);
112
+ const now = Date.now();
113
+ const currentVersion = pkg.version;
114
+
115
+ // Run update check at most once every 24 hours (86,400,000 ms), unless forced
116
+ const checkInterval = 24 * 60 * 60 * 1000;
117
+ if (!force && (now - lastCheck < checkInterval)) {
118
+ // Show highlights if we just updated and haven't shown highlights for this version
119
+ const lastNotified = await getConfigValue("LAST_NOTIFIED_VERSION") || "";
120
+ if (showHighlights && lastNotified !== currentVersion) {
121
+ await showReleaseHighlights(currentVersion);
122
+ await setConfigValue("LAST_NOTIFIED_VERSION", currentVersion);
123
+ }
124
+ return;
125
+ }
126
+
127
+ // Update check timestamp immediately
128
+ await setConfigValue("LAST_UPDATE_CHECK", now.toString());
129
+
130
+ try {
131
+ const controller = new AbortController();
132
+ const timeoutId = setTimeout(() => controller.abort(), 2000);
133
+
134
+ const res = await fetch("https://registry.npmjs.org/@krishivpb60/krims-code-cli/latest", {
135
+ signal: controller.signal,
136
+ });
137
+ clearTimeout(timeoutId);
138
+
139
+ if (!res.ok) {
140
+ if (force) {
141
+ console.log(label.system + " " + colors.warning(`⚠ Update check failed: server returned status ${res.status}`));
142
+ }
143
+ return;
144
+ }
145
+ const data = await res.json();
146
+ const latestVersion = data.version;
147
+
148
+ if (isNewerVersion(latestVersion, currentVersion)) {
149
+ if (autoUpdate || force) {
150
+ console.log("\n" + label.system + " " + colors.brand(`⚡ New version detected! Auto-updating from v${currentVersion} to v${latestVersion}...`));
151
+
152
+ const isPip = process.env.krims-code_PACKAGER === "pip";
153
+ const updateCmd = isPip
154
+ ? "pip install --upgrade krims-code-agent-cli"
155
+ : "npm install -g @krishivpb60/krims-code-cli";
156
+
157
+ try {
158
+ const spinner = createSpinner("Installing update").start();
159
+ await execAsync(updateCmd);
160
+ spinner.succeed("Update complete!");
161
+
162
+ console.log(label.system + " " + colors.success(`✓ Successfully updated to v${latestVersion}.`));
163
+
164
+ if (showHighlights) {
165
+ await showReleaseHighlights(latestVersion);
166
+ }
167
+ await setConfigValue("LAST_NOTIFIED_VERSION", latestVersion);
168
+ } catch (err) {
169
+ console.log(label.system + " " + colors.warning(`⚠ Auto-update failed: ${err.message}`));
170
+ console.log(label.system + " " + colors.muted(`Please run manually: ${updateCmd}`));
171
+ }
172
+ } else {
173
+ console.log("\n" + label.system + " " + colors.warning(`⚡ A new version (v${latestVersion}) is available!`));
174
+ const isPip = process.env.krims-code_PACKAGER === "pip";
175
+ const updateCmd = isPip
176
+ ? "pip install -U krims-code-agent-cli"
177
+ : "npm install -g @krishivpb60/krims-code-cli";
178
+ console.log(label.system + " " + colors.muted(`To update, run: ${updateCmd}`));
179
+ }
180
+ } else {
181
+ if (force) {
182
+ console.log(label.system + " " + colors.success(`✓ Krims Code is already up to date (v${currentVersion}).`));
183
+ }
184
+ // Already on latest version, check if we need to show highlights
185
+ const lastNotified = await getConfigValue("LAST_NOTIFIED_VERSION") || "";
186
+ if (showHighlights && lastNotified !== currentVersion) {
187
+ await showReleaseHighlights(currentVersion);
188
+ await setConfigValue("LAST_NOTIFIED_VERSION", currentVersion);
189
+ }
190
+ }
191
+ } catch (err) {
192
+ if (force) {
193
+ console.log(label.system + " " + colors.warning(`⚠ Update check failed: ${err.message}`));
194
+ }
195
+ }
196
+ }