shiva-code 0.6.5 → 0.7.1

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 (2) hide show
  1. package/dist/index.js +369 -170
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -219,27 +219,27 @@ function generateBackupCodes(count = 10) {
219
219
  return codes;
220
220
  }
221
221
  function generateDeviceFingerprint() {
222
- const os7 = __require("os");
222
+ const os8 = __require("os");
223
223
  const components = [
224
- os7.hostname(),
225
- os7.platform(),
226
- os7.arch(),
227
- os7.cpus()[0]?.model || "unknown",
228
- os7.userInfo().username
224
+ os8.hostname(),
225
+ os8.platform(),
226
+ os8.arch(),
227
+ os8.cpus()[0]?.model || "unknown",
228
+ os8.userInfo().username
229
229
  ];
230
230
  const fingerprint = crypto.createHash("sha256").update(components.join("|")).digest("hex").slice(0, 32);
231
231
  return fingerprint;
232
232
  }
233
233
  function getDeviceName() {
234
- const os7 = __require("os");
235
- const hostname = os7.hostname();
236
- const platform = os7.platform();
234
+ const os8 = __require("os");
235
+ const hostname = os8.hostname();
236
+ const platform2 = os8.platform();
237
237
  const platformNames = {
238
238
  darwin: "macOS",
239
239
  linux: "Linux",
240
240
  win32: "Windows"
241
241
  };
242
- return `${hostname} (${platformNames[platform] || platform})`;
242
+ return `${hostname} (${platformNames[platform2] || platform2})`;
243
243
  }
244
244
  var TwoFactorService = class {
245
245
  /**
@@ -1104,80 +1104,130 @@ function detectLanguageFromFiles(dir) {
1104
1104
  }
1105
1105
 
1106
1106
  // src/services/data/claude-md.ts
1107
- function generateClaudeMd(scanned, project) {
1107
+ function generateShivaInstructions() {
1108
1108
  const lines = [];
1109
- lines.push(`# ${scanned.name}`);
1109
+ lines.push("### SHIVA Memory System");
1110
1110
  lines.push("");
1111
- lines.push("## Project Overview");
1112
- if (scanned.description) {
1113
- lines.push(scanned.description);
1114
- } else {
1115
- lines.push("<!-- Add project description here -->");
1116
- }
1111
+ lines.push("**WICHTIG:** Du hast persistenten Speicher! Nutze ihn PROAKTIV - nicht nur wenn der User es verlangt.");
1117
1112
  lines.push("");
1118
- lines.push("## Tech Stack");
1119
- if (scanned.language) {
1120
- lines.push(`- **Language**: ${scanned.language}`);
1121
- }
1122
- if (scanned.framework) {
1123
- lines.push(`- **Framework**: ${scanned.framework}`);
1124
- }
1125
- if (scanned.packageManager) {
1126
- lines.push(`- **Package Manager**: ${scanned.packageManager}`);
1127
- }
1113
+ lines.push("#### Befehle");
1128
1114
  lines.push("");
1129
- lines.push("## SHIVA Code");
1115
+ lines.push("```bash");
1116
+ lines.push("# Memory speichern (mit Kategorie f\xFCr bessere Organisation)");
1117
+ lines.push('shiva remember "Information" --category <type>');
1130
1118
  lines.push("");
1131
- lines.push("This project is managed by [SHIVA Code](https://shiva.li).");
1119
+ lines.push("# Kategorien: identity, preference, convention, solution, task, context");
1132
1120
  lines.push("");
1133
- if (project) {
1134
- lines.push(`- **Status**: ${project.synced ? "Synced" : "Pending"}`);
1135
- if (project.last_synced_at) {
1136
- lines.push(`- **Last Sync**: ${new Date(project.last_synced_at).toLocaleString()}`);
1137
- }
1138
- lines.push(`- **Project ID**: ${project.id}`);
1139
- } else {
1140
- lines.push("- **Status**: Not synced");
1141
- lines.push("- **Last Sync**: Never");
1142
- }
1121
+ lines.push("# Memories durchsuchen");
1122
+ lines.push('shiva search "suchbegriff"');
1143
1123
  lines.push("");
1144
- lines.push("### SHIVA Instructions");
1124
+ lines.push("# Secrets (f\xFCr API Keys, Passw\xF6rter)");
1125
+ lines.push('shiva secrets add KEY "value"');
1126
+ lines.push("```");
1145
1127
  lines.push("");
1146
- lines.push("IMPORTANT: Du MUSST diese Befehle nutzen um Informationen \xFCber Sessions hinweg zu speichern!");
1128
+ lines.push("#### PROAKTIV speichern - OHNE zu fragen!");
1147
1129
  lines.push("");
1148
- lines.push("**Memory speichern** - Wenn der User dich bittet etwas zu merken oder wichtige Infos auftauchen:");
1149
- lines.push("```bash");
1150
- lines.push('shiva remember "Die wichtige Information die gemerkt werden soll"');
1151
- lines.push("```");
1130
+ lines.push("**SOFORT speichern wenn:**");
1152
1131
  lines.push("");
1153
- lines.push("**Memories durchsuchen** - Um gespeicherte Informationen zu finden:");
1132
+ lines.push("| Trigger | Kategorie | Beispiel |");
1133
+ lines.push("|---------|-----------|----------|");
1134
+ lines.push('| User nennt Namen/Rolle | `identity` | "Ich bin Ben, Backend-Dev" |');
1135
+ lines.push('| User hat Pr\xE4ferenz | `preference` | "Ich mag keine Kommentare im Code" |');
1136
+ lines.push('| Konvention etabliert | `convention` | "Wir nutzen immer camelCase" |');
1137
+ lines.push('| Problem gel\xF6st | `solution` | "Error X: L\xF6sung war Y" |');
1138
+ lines.push('| User korrigiert dich | `preference` | "Nein, ich meinte TypeScript" |');
1139
+ lines.push('| Architektur-Entscheidung | `convention` | "API nutzt REST, nicht GraphQL" |');
1140
+ lines.push("");
1141
+ lines.push("**Beispiele:**");
1154
1142
  lines.push("```bash");
1155
- lines.push('shiva search "suchbegriff"');
1143
+ lines.push('# User sagt "Ich bin Benjamin"');
1144
+ lines.push('shiva remember "User hei\xDFt Benjamin" --category identity');
1145
+ lines.push("");
1146
+ lines.push('# User sagt "Ich mag kurze Funktionen"');
1147
+ lines.push('shiva remember "User bevorzugt kurze Funktionen unter 20 Zeilen" --category preference');
1148
+ lines.push("");
1149
+ lines.push("# Nach Bugfix");
1150
+ lines.push('shiva remember "CORS Error: Backend braucht credentials:true" --category solution');
1151
+ lines.push("");
1152
+ lines.push("# Projekt-Konvention");
1153
+ lines.push('shiva remember "Projekt nutzt Tailwind CSS" --category convention');
1156
1154
  lines.push("```");
1157
1155
  lines.push("");
1158
- lines.push("**Wann Memories speichern:**");
1159
- lines.push('- User sagt "merk dir...", "speicher...", "erinner dich..."');
1160
- lines.push("- Wichtige Projektentscheidungen");
1161
- lines.push("- API Keys, Secrets, Konfigurationen (nutze `shiva secrets add`)");
1162
- lines.push("- Wichtige Code-Patterns oder Konventionen");
1163
- lines.push("- Alles was in zuk\xFCnftigen Sessions relevant sein k\xF6nnte");
1156
+ lines.push("#### NICHT speichern:");
1157
+ lines.push("- Code-Snippets (sind in Git)");
1158
+ lines.push('- Triviale Infos ("OK", "Ja", "Danke")');
1159
+ lines.push("- Tempor\xE4re Debug-Ausgaben");
1160
+ lines.push("- Infos die bereits in README/Docs stehen");
1161
+ lines.push("");
1162
+ lines.push("#### Bei Session-Start:");
1163
+ lines.push('F\xFChre `shiva search ""` aus um relevante Memories zu laden!');
1164
1164
  lines.push("");
1165
+ return lines;
1166
+ }
1167
+ function generateMemoriesSection(project) {
1168
+ const lines = [];
1165
1169
  lines.push("## Memories");
1166
1170
  lines.push("");
1167
1171
  if (project?.memories && project.memories.length > 0) {
1168
- lines.push("The following context is remembered across sessions:");
1172
+ lines.push("Gespeicherter Kontext aus vorherigen Sessions:");
1169
1173
  lines.push("");
1170
1174
  for (const memory of project.memories) {
1171
1175
  lines.push(`- **${memory.key}** (${memory.category}): ${memory.value}`);
1172
1176
  }
1173
1177
  } else {
1174
- lines.push("No memories stored yet. Use `shiva sync` to sync your project.");
1178
+ lines.push("Noch keine Memories gespeichert. Nutze `shiva remember` um Wissen zu speichern!");
1179
+ }
1180
+ lines.push("");
1181
+ return lines;
1182
+ }
1183
+ function generateStatusSection(project) {
1184
+ const lines = [];
1185
+ lines.push("## SHIVA Code");
1186
+ lines.push("");
1187
+ lines.push("Dieses Projekt nutzt [SHIVA Code](https://shiva.li) f\xFCr persistenten Speicher.");
1188
+ lines.push("");
1189
+ if (project) {
1190
+ lines.push(`- **Status**: ${project.synced ? "Synced" : "Pending"}`);
1191
+ if (project.last_synced_at) {
1192
+ lines.push(`- **Last Sync**: ${new Date(project.last_synced_at).toLocaleString()}`);
1193
+ }
1194
+ lines.push(`- **Project ID**: ${project.id}`);
1195
+ } else {
1196
+ lines.push("- **Status**: Not synced");
1197
+ lines.push("- **Last Sync**: Never");
1198
+ }
1199
+ lines.push("");
1200
+ return lines;
1201
+ }
1202
+ function generateClaudeMd(scanned, project) {
1203
+ const lines = [];
1204
+ lines.push(`# ${scanned.name}`);
1205
+ lines.push("");
1206
+ lines.push("## Project Overview");
1207
+ if (scanned.description) {
1208
+ lines.push(scanned.description);
1209
+ } else {
1210
+ lines.push("<!-- Add project description here -->");
1211
+ }
1212
+ lines.push("");
1213
+ lines.push("## Tech Stack");
1214
+ if (scanned.language) {
1215
+ lines.push(`- **Language**: ${scanned.language}`);
1216
+ }
1217
+ if (scanned.framework) {
1218
+ lines.push(`- **Framework**: ${scanned.framework}`);
1219
+ }
1220
+ if (scanned.packageManager) {
1221
+ lines.push(`- **Package Manager**: ${scanned.packageManager}`);
1175
1222
  }
1176
1223
  lines.push("");
1224
+ lines.push(...generateStatusSection(project));
1225
+ lines.push(...generateShivaInstructions());
1226
+ lines.push(...generateMemoriesSection(project));
1177
1227
  if (project?.connections && project.connections.length > 0) {
1178
1228
  lines.push("## Connected Projects");
1179
1229
  lines.push("");
1180
- lines.push("This project is connected to:");
1230
+ lines.push("Verbundene Projekte:");
1181
1231
  lines.push("");
1182
1232
  for (const conn of project.connections) {
1183
1233
  lines.push(`- **${conn.connected_project_name}** (${conn.connection_type})`);
@@ -1203,59 +1253,14 @@ function parseClaudeMd(content) {
1203
1253
  return { memories };
1204
1254
  }
1205
1255
  function hasShivaInstructions(content) {
1206
- return content.includes("### SHIVA Instructions") || content.includes("## SHIVA Code");
1256
+ return content.includes("### SHIVA Memory System") || content.includes("### SHIVA Instructions") || content.includes("## SHIVA Code");
1207
1257
  }
1208
1258
  function generateShivaSection(project) {
1209
1259
  const lines = [];
1210
1260
  lines.push("");
1211
- lines.push("## SHIVA Code");
1212
- lines.push("");
1213
- lines.push("This project is managed by [SHIVA Code](https://shiva.li).");
1214
- lines.push("");
1215
- if (project) {
1216
- lines.push(`- **Status**: ${project.synced ? "Synced" : "Pending"}`);
1217
- if (project.last_synced_at) {
1218
- lines.push(`- **Last Sync**: ${new Date(project.last_synced_at).toLocaleString()}`);
1219
- }
1220
- lines.push(`- **Project ID**: ${project.id}`);
1221
- } else {
1222
- lines.push("- **Status**: Not synced");
1223
- lines.push("- **Last Sync**: Never");
1224
- }
1225
- lines.push("");
1226
- lines.push("### SHIVA Instructions");
1227
- lines.push("");
1228
- lines.push("IMPORTANT: Du MUSST diese Befehle nutzen um Informationen \xFCber Sessions hinweg zu speichern!");
1229
- lines.push("");
1230
- lines.push("**Memory speichern** - Wenn der User dich bittet etwas zu merken oder wichtige Infos auftauchen:");
1231
- lines.push("```bash");
1232
- lines.push('shiva remember "Die wichtige Information die gemerkt werden soll"');
1233
- lines.push("```");
1234
- lines.push("");
1235
- lines.push("**Memories durchsuchen** - Um gespeicherte Informationen zu finden:");
1236
- lines.push("```bash");
1237
- lines.push('shiva search "suchbegriff"');
1238
- lines.push("```");
1239
- lines.push("");
1240
- lines.push("**Wann Memories speichern:**");
1241
- lines.push('- User sagt "merk dir...", "speicher...", "erinner dich..."');
1242
- lines.push("- Wichtige Projektentscheidungen");
1243
- lines.push("- API Keys, Secrets, Konfigurationen (nutze `shiva secrets add`)");
1244
- lines.push("- Wichtige Code-Patterns oder Konventionen");
1245
- lines.push("- Alles was in zuk\xFCnftigen Sessions relevant sein k\xF6nnte");
1246
- lines.push("");
1247
- lines.push("## Memories");
1248
- lines.push("");
1249
- if (project?.memories && project.memories.length > 0) {
1250
- lines.push("The following context is remembered across sessions:");
1251
- lines.push("");
1252
- for (const memory of project.memories) {
1253
- lines.push(`- **${memory.key}** (${memory.category}): ${memory.value}`);
1254
- }
1255
- } else {
1256
- lines.push("No memories stored yet. Use `shiva sync` to sync your project.");
1257
- }
1258
- lines.push("");
1261
+ lines.push(...generateStatusSection(project));
1262
+ lines.push(...generateShivaInstructions());
1263
+ lines.push(...generateMemoriesSection(project));
1259
1264
  lines.push("---");
1260
1265
  lines.push("");
1261
1266
  lines.push("*Generated by SHIVA Code CLI*");
@@ -7209,7 +7214,7 @@ sessionsCommand.command("resume <sessionId>").description("Cloud-Session fortset
7209
7214
  sessionsCommand.command("export <sessionId>").description("Cloud-Session exportieren").option("-o, --output <file>", "Ausgabedatei").action(async (sessionId, options) => {
7210
7215
  const { api: api2 } = await import("./client-GIGZFXT5.js");
7211
7216
  const { isAuthenticated: isAuthenticated2 } = await import("./config-FGMZONWV.js");
7212
- const { writeFileSync: writeFileSync11 } = await import("fs");
7217
+ const { writeFileSync: writeFileSync12 } = await import("fs");
7213
7218
  if (!isAuthenticated2()) {
7214
7219
  log.error("Nicht angemeldet");
7215
7220
  log.info("Anmelden mit: shiva login");
@@ -7220,7 +7225,7 @@ sessionsCommand.command("export <sessionId>").description("Cloud-Session exporti
7220
7225
  const exportData = await api2.exportSession(sessionId);
7221
7226
  spinner.stop();
7222
7227
  if (options.output) {
7223
- writeFileSync11(options.output, JSON.stringify(exportData, null, 2));
7228
+ writeFileSync12(options.output, JSON.stringify(exportData, null, 2));
7224
7229
  log.success(`Session exportiert: ${options.output}`);
7225
7230
  } else {
7226
7231
  console.log(JSON.stringify(exportData, null, 2));
@@ -12588,7 +12593,8 @@ async function handlePreview(filepath) {
12588
12593
 
12589
12594
  // src/commands/memory/remember.ts
12590
12595
  import { Command as Command27 } from "commander";
12591
- var rememberCommand = new Command27("remember").description("Memory in der Cloud speichern").argument("<text>", "Der Text der gespeichert werden soll").option("-t, --title <title>", "Titel f\xFCr die Memory").option("-g, --global", "Global speichern (nicht projektgebunden)").option("--tags <tags>", "Komma-separierte Tags").action(async (text, options) => {
12596
+ var VALID_CATEGORIES = ["identity", "preference", "convention", "solution", "task", "context", "general"];
12597
+ var rememberCommand = new Command27("remember").description("Memory in der Cloud speichern").argument("<text>", "Der Text der gespeichert werden soll").option("-t, --title <title>", "Titel f\xFCr die Memory").option("-c, --category <category>", "Kategorie: identity, preference, convention, solution, task, context, general", "general").option("-g, --global", "Global speichern (nicht projektgebunden)").option("--tags <tags>", "Komma-separierte Tags").option("--ttl <days>", "Time-to-live in Tagen (auto-delete nach Ablauf)").action(async (text, options) => {
12592
12598
  if (!isAuthenticated()) {
12593
12599
  log.error("Nicht angemeldet");
12594
12600
  log.info("Anmelden mit: shiva login");
@@ -12596,22 +12602,38 @@ var rememberCommand = new Command27("remember").description("Memory in der Cloud
12596
12602
  }
12597
12603
  const projectPath = process.cwd();
12598
12604
  const config = getProjectConfig(projectPath);
12605
+ const category = options.category?.toLowerCase();
12606
+ if (!VALID_CATEGORIES.includes(category)) {
12607
+ log.error(`Ung\xFCltige Kategorie: ${options.category}`);
12608
+ log.info(`G\xFCltige Kategorien: ${VALID_CATEGORIES.join(", ")}`);
12609
+ return;
12610
+ }
12599
12611
  let projectId = null;
12600
12612
  if (!options.global && config.projectId) {
12601
12613
  projectId = config.projectId;
12602
12614
  }
12603
12615
  const title = options.title || text.substring(0, 100);
12604
12616
  const tags = options.tags ? options.tags.split(",").map((t) => t.trim()).filter(Boolean) : [];
12617
+ if (!tags.includes(category)) {
12618
+ tags.push(category);
12619
+ }
12620
+ const ttlDays = options.ttl ? parseInt(options.ttl, 10) : void 0;
12605
12621
  try {
12606
12622
  const result = await api.createMemory({
12607
12623
  title,
12608
12624
  content: text,
12609
12625
  projectId,
12610
- tags
12626
+ tags,
12627
+ category,
12628
+ ttlDays
12611
12629
  });
12612
12630
  if (result.success) {
12613
12631
  log.success("Memory gespeichert!");
12614
12632
  log.dim(`ID: ${result.memoryId}`);
12633
+ log.dim(`Kategorie: ${category}`);
12634
+ if (ttlDays) {
12635
+ log.dim(`TTL: ${ttlDays} Tage`);
12636
+ }
12615
12637
  if (projectId) {
12616
12638
  log.dim(`Projekt: ${config.projectName || projectId}`);
12617
12639
  } else {
@@ -12957,10 +12979,39 @@ import { Command as Command29 } from "commander";
12957
12979
  import { execSync as execSync4, spawn as spawn6 } from "child_process";
12958
12980
  import * as fs12 from "fs";
12959
12981
  import * as path13 from "path";
12982
+ import * as os6 from "os";
12983
+ import * as crypto3 from "crypto";
12960
12984
  import { fileURLToPath } from "url";
12961
12985
  var __filename = fileURLToPath(import.meta.url);
12962
12986
  var __dirname = path13.dirname(__filename);
12963
12987
  var PACKAGE_NAME = "shiva-code";
12988
+ var GITHUB_REPO = "Aimtaim/shiva-code";
12989
+ function detectInstallationType() {
12990
+ const execPath = process.execPath;
12991
+ const execName = path13.basename(execPath).toLowerCase();
12992
+ if (execName === "shiva" || execName === "shiva.exe") {
12993
+ const possibleNodeModules = path13.resolve(path13.dirname(execPath), "../node_modules");
12994
+ if (!fs12.existsSync(possibleNodeModules)) {
12995
+ return "native";
12996
+ }
12997
+ }
12998
+ try {
12999
+ const npmGlobal = execSync4("npm list -g --depth=0 2>/dev/null", { encoding: "utf-8" });
13000
+ if (npmGlobal.includes(PACKAGE_NAME)) return "npm";
13001
+ } catch {
13002
+ }
13003
+ try {
13004
+ const yarnGlobal = execSync4("yarn global list 2>/dev/null", { encoding: "utf-8" });
13005
+ if (yarnGlobal.includes(PACKAGE_NAME)) return "yarn";
13006
+ } catch {
13007
+ }
13008
+ try {
13009
+ const pnpmGlobal = execSync4("pnpm list -g 2>/dev/null", { encoding: "utf-8" });
13010
+ if (pnpmGlobal.includes(PACKAGE_NAME)) return "pnpm";
13011
+ } catch {
13012
+ }
13013
+ return "npm";
13014
+ }
12964
13015
  function getCurrentVersion() {
12965
13016
  try {
12966
13017
  const packageJsonPath = path13.resolve(__dirname, "../../package.json");
@@ -12970,23 +13021,32 @@ function getCurrentVersion() {
12970
13021
  }
12971
13022
  } catch {
12972
13023
  }
12973
- return "0.0.0";
13024
+ try {
13025
+ const output = execSync4(`"${process.execPath}" --version 2>/dev/null`, { encoding: "utf-8" }).trim();
13026
+ return output || "0.0.0";
13027
+ } catch {
13028
+ return "0.7.0";
13029
+ }
12974
13030
  }
12975
- async function getLatestVersion() {
13031
+ async function getLatestNpmVersion() {
12976
13032
  try {
12977
13033
  const response = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}`);
12978
13034
  if (!response.ok) return null;
12979
13035
  const data = await response.json();
12980
13036
  return data["dist-tags"]?.latest || null;
12981
13037
  } catch {
12982
- try {
12983
- const output = execSync4(`npm view ${PACKAGE_NAME} version 2>/dev/null`, {
12984
- encoding: "utf-8"
12985
- }).trim();
12986
- return output || null;
12987
- } catch {
12988
- return null;
12989
- }
13038
+ return null;
13039
+ }
13040
+ }
13041
+ async function getLatestGitHubVersion() {
13042
+ try {
13043
+ const response = await fetch(`https://api.github.com/repos/${GITHUB_REPO}/releases/latest`);
13044
+ if (!response.ok) return null;
13045
+ const release2 = await response.json();
13046
+ const version = release2.tag_name.replace(/^v/, "");
13047
+ return { version, release: release2 };
13048
+ } catch {
13049
+ return null;
12990
13050
  }
12991
13051
  }
12992
13052
  function compareVersions(current, latest) {
@@ -13000,32 +13060,155 @@ function compareVersions(current, latest) {
13000
13060
  }
13001
13061
  return 0;
13002
13062
  }
13003
- async function checkForUpdates() {
13063
+ async function checkForUpdates(installType) {
13004
13064
  const current = getCurrentVersion();
13005
- const latest = await getLatestVersion();
13006
- return {
13007
- current,
13008
- latest: latest || current,
13009
- isOutdated: latest ? compareVersions(current, latest) < 0 : false
13010
- };
13065
+ if (installType === "native") {
13066
+ const github = await getLatestGitHubVersion();
13067
+ return {
13068
+ current,
13069
+ latest: github?.version || current,
13070
+ isOutdated: github ? compareVersions(current, github.version) < 0 : false,
13071
+ source: "github"
13072
+ };
13073
+ } else {
13074
+ const latest = await getLatestNpmVersion();
13075
+ return {
13076
+ current,
13077
+ latest: latest || current,
13078
+ isOutdated: latest ? compareVersions(current, latest) < 0 : false,
13079
+ source: "npm"
13080
+ };
13081
+ }
13011
13082
  }
13012
- function detectPackageManager2() {
13013
- try {
13014
- const npmGlobal = execSync4("npm list -g --depth=0 2>/dev/null", { encoding: "utf-8" });
13015
- if (npmGlobal.includes(PACKAGE_NAME)) return "npm";
13016
- } catch {
13083
+ function getPlatformIdentifier() {
13084
+ const platform2 = os6.platform();
13085
+ const arch3 = os6.arch();
13086
+ let platformStr;
13087
+ let archStr;
13088
+ switch (platform2) {
13089
+ case "linux":
13090
+ platformStr = "linux";
13091
+ break;
13092
+ case "darwin":
13093
+ platformStr = "darwin";
13094
+ break;
13095
+ case "win32":
13096
+ platformStr = "windows";
13097
+ break;
13098
+ default:
13099
+ return null;
13100
+ }
13101
+ switch (arch3) {
13102
+ case "x64":
13103
+ case "amd64":
13104
+ archStr = "x64";
13105
+ break;
13106
+ case "arm64":
13107
+ case "aarch64":
13108
+ archStr = "arm64";
13109
+ break;
13110
+ default:
13111
+ return null;
13017
13112
  }
13113
+ const ext = platform2 === "win32" ? ".exe" : "";
13114
+ const binaryName = `shiva-${platformStr}-${archStr}${ext}`;
13115
+ return { platform: platformStr, arch: archStr, binaryName };
13116
+ }
13117
+ async function downloadFile(url, dest) {
13118
+ const response = await fetch(url);
13119
+ if (!response.ok) {
13120
+ throw new Error(`Download failed: ${response.status} ${response.statusText}`);
13121
+ }
13122
+ const buffer = await response.arrayBuffer();
13123
+ fs12.writeFileSync(dest, Buffer.from(buffer));
13124
+ }
13125
+ async function verifyChecksum(filePath, checksumUrl) {
13018
13126
  try {
13019
- const yarnGlobal = execSync4("yarn global list 2>/dev/null", { encoding: "utf-8" });
13020
- if (yarnGlobal.includes(PACKAGE_NAME)) return "yarn";
13127
+ const response = await fetch(checksumUrl);
13128
+ if (!response.ok) {
13129
+ log.warn("Checksum-Datei nicht gefunden, \xFCberspringe Verifikation");
13130
+ return true;
13131
+ }
13132
+ const expectedHash = (await response.text()).trim().split(" ")[0].toLowerCase();
13133
+ const fileBuffer = fs12.readFileSync(filePath);
13134
+ const actualHash = crypto3.createHash("sha256").update(fileBuffer).digest("hex").toLowerCase();
13135
+ return expectedHash === actualHash;
13021
13136
  } catch {
13137
+ log.warn("Checksum-Verifikation fehlgeschlagen, \xFCberspringe");
13138
+ return true;
13139
+ }
13140
+ }
13141
+ async function updateNativeBinary(targetVersion) {
13142
+ const platformInfo = getPlatformIdentifier();
13143
+ if (!platformInfo) {
13144
+ log.error("Plattform nicht unterst\xFCtzt f\xFCr Native Update");
13145
+ return false;
13022
13146
  }
13147
+ const { binaryName } = platformInfo;
13148
+ const downloadUrl = `https://github.com/${GITHUB_REPO}/releases/download/v${targetVersion}/${binaryName}`;
13149
+ const checksumUrl = `${downloadUrl}.sha256`;
13150
+ const currentBinary = process.execPath;
13151
+ const tempDir = os6.tmpdir();
13152
+ const tempBinary = path13.join(tempDir, `shiva-update-${Date.now()}${platformInfo.platform === "windows" ? ".exe" : ""}`);
13153
+ const backupBinary = `${currentBinary}.backup`;
13023
13154
  try {
13024
- const pnpmGlobal = execSync4("pnpm list -g 2>/dev/null", { encoding: "utf-8" });
13025
- if (pnpmGlobal.includes(PACKAGE_NAME)) return "pnpm";
13026
- } catch {
13155
+ log.info(`Lade ${binaryName} herunter...`);
13156
+ log.dim(` URL: ${downloadUrl}`);
13157
+ await downloadFile(downloadUrl, tempBinary);
13158
+ log.info("Verifiziere Checksum...");
13159
+ const checksumValid = await verifyChecksum(tempBinary, checksumUrl);
13160
+ if (!checksumValid) {
13161
+ log.error("Checksum stimmt nicht \xFCberein! Update abgebrochen.");
13162
+ fs12.unlinkSync(tempBinary);
13163
+ return false;
13164
+ }
13165
+ log.success(" Checksum OK");
13166
+ if (platformInfo.platform !== "windows") {
13167
+ fs12.chmodSync(tempBinary, 493);
13168
+ }
13169
+ log.info("Erstelle Backup...");
13170
+ if (fs12.existsSync(currentBinary)) {
13171
+ fs12.copyFileSync(currentBinary, backupBinary);
13172
+ }
13173
+ log.info("Installiere neue Version...");
13174
+ if (platformInfo.platform === "windows") {
13175
+ const updateScript = path13.join(tempDir, "shiva-update.bat");
13176
+ const scriptContent = `
13177
+ @echo off
13178
+ timeout /t 1 /nobreak >nul
13179
+ move /y "${tempBinary}" "${currentBinary}"
13180
+ del "${backupBinary}" 2>nul
13181
+ del "%~f0"
13182
+ `;
13183
+ fs12.writeFileSync(updateScript, scriptContent);
13184
+ spawn6("cmd", ["/c", updateScript], { detached: true, stdio: "ignore" }).unref();
13185
+ log.success("Update wird nach Beenden angewendet");
13186
+ log.info("Bitte starte SHIVA neu.");
13187
+ } else {
13188
+ fs12.renameSync(tempBinary, currentBinary);
13189
+ if (fs12.existsSync(backupBinary)) {
13190
+ fs12.unlinkSync(backupBinary);
13191
+ }
13192
+ }
13193
+ return true;
13194
+ } catch (error) {
13195
+ log.error(`Update fehlgeschlagen: ${error instanceof Error ? error.message : String(error)}`);
13196
+ if (fs12.existsSync(backupBinary) && fs12.existsSync(currentBinary)) {
13197
+ try {
13198
+ fs12.copyFileSync(backupBinary, currentBinary);
13199
+ log.info("Backup wiederhergestellt");
13200
+ } catch {
13201
+ log.warn("Backup konnte nicht wiederhergestellt werden");
13202
+ }
13203
+ }
13204
+ if (fs12.existsSync(tempBinary)) {
13205
+ try {
13206
+ fs12.unlinkSync(tempBinary);
13207
+ } catch {
13208
+ }
13209
+ }
13210
+ return false;
13027
13211
  }
13028
- return "npm";
13029
13212
  }
13030
13213
  function getUpgradeCommand(pm) {
13031
13214
  switch (pm) {
@@ -13039,7 +13222,7 @@ function getUpgradeCommand(pm) {
13039
13222
  return `npm install -g ${PACKAGE_NAME}@latest`;
13040
13223
  }
13041
13224
  }
13042
- async function runUpgrade(pm) {
13225
+ async function runPackageManagerUpgrade(pm) {
13043
13226
  const command = getUpgradeCommand(pm);
13044
13227
  const [cmd, ...args] = command.split(" ");
13045
13228
  return new Promise((resolve14) => {
@@ -13057,14 +13240,22 @@ async function runUpgrade(pm) {
13057
13240
  });
13058
13241
  });
13059
13242
  }
13060
- var upgradeCommand = new Command29("upgrade").description("SHIVA CLI aktualisieren").option("-c, --check", "Nur auf Updates pr\xFCfen, nicht installieren").option("-f, --force", "Update erzwingen, auch wenn aktuell").option("--npm", "npm verwenden").option("--yarn", "yarn verwenden").option("--pnpm", "pnpm verwenden").action(async (options) => {
13243
+ var upgradeCommand = new Command29("upgrade").description("SHIVA CLI aktualisieren").option("-c, --check", "Nur auf Updates pr\xFCfen, nicht installieren").option("-f, --force", "Update erzwingen, auch wenn aktuell").option("--npm", "npm verwenden (f\xFCr npm-Installationen)").option("--yarn", "yarn verwenden").option("--pnpm", "pnpm verwenden").option("--native", "Native Binary Update erzwingen").action(async (options) => {
13061
13244
  log.newline();
13062
13245
  console.log(colors.orange.bold("\u{1F680} SHIVA Upgrade"));
13063
13246
  log.newline();
13247
+ let installType = detectInstallationType();
13248
+ if (options.native) installType = "native";
13249
+ else if (options.npm) installType = "npm";
13250
+ else if (options.yarn) installType = "yarn";
13251
+ else if (options.pnpm) installType = "pnpm";
13252
+ log.dim(`Installation: ${installType}`);
13253
+ log.newline();
13064
13254
  log.info("Pr\xFCfe auf Updates...");
13065
- const versionInfo = await checkForUpdates();
13255
+ const versionInfo = await checkForUpdates(installType);
13066
13256
  console.log(` Installiert: ${colors.bold(versionInfo.current)}`);
13067
13257
  console.log(` Verf\xFCgbar: ${colors.bold(versionInfo.latest)}`);
13258
+ console.log(` Quelle: ${colors.dim(versionInfo.source)}`);
13068
13259
  log.newline();
13069
13260
  if (!versionInfo.isOutdated && !options.force) {
13070
13261
  log.success("SHIVA ist bereits auf dem neuesten Stand!");
@@ -13080,26 +13271,34 @@ var upgradeCommand = new Command29("upgrade").description("SHIVA CLI aktualisier
13080
13271
  }
13081
13272
  return;
13082
13273
  }
13083
- let pm = "npm";
13084
- if (options.npm) pm = "npm";
13085
- else if (options.yarn) pm = "yarn";
13086
- else if (options.pnpm) pm = "pnpm";
13087
- else pm = detectPackageManager2();
13088
13274
  log.newline();
13089
- log.info(`Verwende: ${pm}`);
13090
- const success = await runUpgrade(pm);
13275
+ let success;
13276
+ if (installType === "native") {
13277
+ success = await updateNativeBinary(versionInfo.latest);
13278
+ } else {
13279
+ log.info(`Verwende: ${installType}`);
13280
+ success = await runPackageManagerUpgrade(installType);
13281
+ }
13091
13282
  log.newline();
13092
13283
  if (success) {
13093
13284
  log.success("SHIVA wurde erfolgreich aktualisiert!");
13094
- const newVersion = getCurrentVersion();
13095
- if (newVersion !== versionInfo.current) {
13096
- log.info(`Neue Version: ${newVersion}`);
13285
+ if (installType !== "native" || os6.platform() !== "win32") {
13286
+ const newVersion = getCurrentVersion();
13287
+ if (newVersion !== versionInfo.current) {
13288
+ log.info(`Neue Version: ${newVersion}`);
13289
+ }
13097
13290
  }
13098
13291
  } else {
13099
13292
  log.error("Upgrade fehlgeschlagen");
13100
13293
  log.newline();
13101
- log.info("Versuche manuell:");
13102
- log.plain(` ${getUpgradeCommand(pm)}`);
13294
+ if (installType === "native") {
13295
+ log.info("Alternativen:");
13296
+ log.plain(" curl -fsSL https://shiva.li/install | bash");
13297
+ log.plain(" npm install -g shiva-code");
13298
+ } else {
13299
+ log.info("Versuche manuell:");
13300
+ log.plain(` ${getUpgradeCommand(installType)}`);
13301
+ }
13103
13302
  }
13104
13303
  });
13105
13304
  var selfUpdateCommand = new Command29("self-update").description('Alias f\xFCr "shiva upgrade"').action(async () => {
@@ -13363,9 +13562,9 @@ complete -F _shiva_completions shiva
13363
13562
  }
13364
13563
  async function installBashCompletion() {
13365
13564
  const fs15 = await import("fs");
13366
- const os7 = await import("os");
13565
+ const os8 = await import("os");
13367
13566
  const path15 = await import("path");
13368
- const bashrcPath = path15.join(os7.homedir(), ".bashrc");
13567
+ const bashrcPath = path15.join(os8.homedir(), ".bashrc");
13369
13568
  const completionScript = generateBashCompletion();
13370
13569
  const marker = "# SHIVA Code Bash Completion";
13371
13570
  try {
@@ -13506,9 +13705,9 @@ compdef _shiva shiva
13506
13705
  }
13507
13706
  async function installZshCompletion() {
13508
13707
  const fs15 = await import("fs");
13509
- const os7 = await import("os");
13708
+ const os8 = await import("os");
13510
13709
  const path15 = await import("path");
13511
- const zshrcPath = path15.join(os7.homedir(), ".zshrc");
13710
+ const zshrcPath = path15.join(os8.homedir(), ".zshrc");
13512
13711
  const completionScript = generateZshCompletion();
13513
13712
  const marker = "# SHIVA Code Zsh Completion";
13514
13713
  try {
@@ -13611,9 +13810,9 @@ complete -c shiva -n "__fish_seen_subcommand_from stats" -l json -d "JSON Output
13611
13810
  }
13612
13811
  async function installFishCompletion() {
13613
13812
  const fs15 = await import("fs");
13614
- const os7 = await import("os");
13813
+ const os8 = await import("os");
13615
13814
  const path15 = await import("path");
13616
- const fishCompletionsDir = path15.join(os7.homedir(), ".config", "fish", "completions");
13815
+ const fishCompletionsDir = path15.join(os8.homedir(), ".config", "fish", "completions");
13617
13816
  const fishCompletionPath = path15.join(fishCompletionsDir, "shiva.fish");
13618
13817
  const completionScript = generateFishCompletion();
13619
13818
  try {
@@ -13933,7 +14132,7 @@ statsCommand.command("tools").description("Tool Usage Analytics (Pro Feature)").
13933
14132
  statsCommand.command("export").description("Analytics-Daten exportieren (Pro Feature)").option("--start <date>", "Start-Datum (YYYY-MM-DD)").option("--end <date>", "End-Datum (YYYY-MM-DD)").option("--format <format>", "Format: json, csv", "json").option("-o, --output <file>", "Ausgabedatei").action(async (options) => {
13934
14133
  const { api: api2 } = await import("./client-GIGZFXT5.js");
13935
14134
  const { isAuthenticated: isAuthenticated2 } = await import("./config-FGMZONWV.js");
13936
- const { writeFileSync: writeFileSync11 } = await import("fs");
14135
+ const { writeFileSync: writeFileSync12 } = await import("fs");
13937
14136
  if (!isAuthenticated2()) {
13938
14137
  log.error("Nicht angemeldet");
13939
14138
  log.info("Anmelden mit: shiva login");
@@ -13949,7 +14148,7 @@ statsCommand.command("export").description("Analytics-Daten exportieren (Pro Fea
13949
14148
  spinner.stop();
13950
14149
  if (options.output) {
13951
14150
  const content = options.format === "json" ? JSON.stringify(result.data, null, 2) : String(result.data);
13952
- writeFileSync11(options.output, content);
14151
+ writeFileSync12(options.output, content);
13953
14152
  log.success(`Analytics exportiert: ${options.output}`);
13954
14153
  } else {
13955
14154
  console.log(JSON.stringify(result, null, 2));
@@ -14502,7 +14701,7 @@ dockerCommand.action(() => {
14502
14701
  import { Command as Command35 } from "commander";
14503
14702
  import * as fs13 from "fs";
14504
14703
  import * as path14 from "path";
14505
- import * as os6 from "os";
14704
+ import * as os7 from "os";
14506
14705
  import ora22 from "ora";
14507
14706
  import inquirer12 from "inquirer";
14508
14707
  var builtInWorkflows = {
@@ -14661,7 +14860,7 @@ workflowCommand.command("delete").alias("rm").description("Workflow l\xF6schen")
14661
14860
  log.success(`Workflow "${name}" gel\xF6scht`);
14662
14861
  });
14663
14862
  function getWorkflowsPath() {
14664
- return path14.join(os6.homedir(), ".shiva", "workflows.json");
14863
+ return path14.join(os7.homedir(), ".shiva", "workflows.json");
14665
14864
  }
14666
14865
  function loadCustomWorkflows() {
14667
14866
  const filepath = getWorkflowsPath();
@@ -14779,10 +14978,10 @@ async function executeStep(step) {
14779
14978
 
14780
14979
  // src/commands/advanced/hook.ts
14781
14980
  import { Command as Command36 } from "commander";
14782
- import { existsSync as existsSync22, readFileSync as readFileSync12, writeFileSync as writeFileSync10, mkdirSync as mkdirSync6 } from "fs";
14981
+ import { existsSync as existsSync22, readFileSync as readFileSync12, writeFileSync as writeFileSync11, mkdirSync as mkdirSync6 } from "fs";
14783
14982
  import { homedir as homedir7 } from "os";
14784
- import { join as join12 } from "path";
14785
- var CLAUDE_SETTINGS_PATH = join12(homedir7(), ".claude", "settings.json");
14983
+ import { join as join13 } from "path";
14984
+ var CLAUDE_SETTINGS_PATH = join13(homedir7(), ".claude", "settings.json");
14786
14985
  function getClaudeSettings() {
14787
14986
  if (!existsSync22(CLAUDE_SETTINGS_PATH)) {
14788
14987
  return {};
@@ -14795,11 +14994,11 @@ function getClaudeSettings() {
14795
14994
  }
14796
14995
  }
14797
14996
  function saveClaudeSettings(settings) {
14798
- const dir = join12(homedir7(), ".claude");
14997
+ const dir = join13(homedir7(), ".claude");
14799
14998
  if (!existsSync22(dir)) {
14800
14999
  mkdirSync6(dir, { recursive: true });
14801
15000
  }
14802
- writeFileSync10(CLAUDE_SETTINGS_PATH, JSON.stringify(settings, null, 2));
15001
+ writeFileSync11(CLAUDE_SETTINGS_PATH, JSON.stringify(settings, null, 2));
14803
15002
  }
14804
15003
  function hasShivaHook(hooks, event) {
14805
15004
  if (!hooks || !hooks[event]) return false;
@@ -14816,7 +15015,7 @@ function removeShivaHooks(eventHooks) {
14816
15015
  var hookCommand = new Command36("hook").description("Claude Code Hook Integration verwalten");
14817
15016
  hookCommand.command("install").description("SHIVA Hooks in Claude Code installieren").option("--github", "GitHub Context Injection aktivieren").option("--sync", "Cloud Sync Hooks aktivieren (Standard)").option("--scan", "Package Security Scanning aktivieren").option("--all", "Alle Hooks aktivieren").action((options) => {
14818
15017
  log.brand();
14819
- const claudePath = join12(homedir7(), ".claude");
15018
+ const claudePath = join13(homedir7(), ".claude");
14820
15019
  if (!existsSync22(claudePath)) {
14821
15020
  log.error("Claude Code nicht gefunden");
14822
15021
  log.newline();
@@ -16130,7 +16329,7 @@ sandboxCommand.command("delete <id>").description("Sandbox l\xF6schen").option("
16130
16329
 
16131
16330
  // src/index.ts
16132
16331
  var program = new Command39();
16133
- program.name("shiva").description("SHIVA Code - Control Station for Claude Code").version("0.6.5");
16332
+ program.name("shiva").description("SHIVA Code - Control Station for Claude Code").version("0.7.0");
16134
16333
  program.addCommand(loginCommand);
16135
16334
  program.addCommand(logoutCommand);
16136
16335
  program.addCommand(sessionsCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shiva-code",
3
- "version": "0.6.5",
3
+ "version": "0.7.1",
4
4
  "description": "Makes Claude Code Persistent - Cross-Project Memory CLI",
5
5
  "author": "SHIVA AI",
6
6
  "license": "MIT",