shiva-code 0.8.11 → 0.8.13

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/index.js CHANGED
@@ -3361,7 +3361,7 @@ var repairCommand = new Command9("repair").description("Repariert SHIVA-Konfigur
3361
3361
 
3362
3362
  // src/commands/session/start.ts
3363
3363
  import { Command as Command10 } from "commander";
3364
- import * as fs from "fs";
3364
+ import * as fs2 from "fs";
3365
3365
  import * as path3 from "path";
3366
3366
  import ora8 from "ora";
3367
3367
  import { spawnSync as spawnSync4 } from "child_process";
@@ -3370,6 +3370,7 @@ import { spawnSync as spawnSync4 } from "child_process";
3370
3370
  import { spawn as spawn2, spawnSync as spawnSync2 } from "child_process";
3371
3371
  import * as path2 from "path";
3372
3372
  import * as os2 from "os";
3373
+ import * as fs from "fs";
3373
3374
 
3374
3375
  // src/services/infrastructure/docker.ts
3375
3376
  import { spawn, spawnSync } from "child_process";
@@ -3446,8 +3447,8 @@ var DockerService = class {
3446
3447
  ];
3447
3448
  for (const socketPath of possiblePaths) {
3448
3449
  try {
3449
- const fs15 = __require("fs");
3450
- if (fs15.existsSync(socketPath)) {
3450
+ const fs16 = __require("fs");
3451
+ if (fs16.existsSync(socketPath)) {
3451
3452
  return socketPath;
3452
3453
  }
3453
3454
  } catch {
@@ -4117,6 +4118,29 @@ var DockerService = class {
4117
4118
  var dockerService = new DockerService();
4118
4119
 
4119
4120
  // src/services/infrastructure/terminal.ts
4121
+ function cleanupTmuxSockets() {
4122
+ try {
4123
+ const tmpDir = "/tmp";
4124
+ const files = fs.readdirSync(tmpDir);
4125
+ const uid = process.getuid?.() ?? 0;
4126
+ for (const file of files) {
4127
+ if (file.startsWith("tmux-") && file.includes(String(uid))) {
4128
+ const socketPath = path2.join(tmpDir, file);
4129
+ try {
4130
+ const stats = fs.statSync(socketPath);
4131
+ if (stats.isDirectory()) {
4132
+ const result = spawnSync2("tmux", ["list-sessions"], { stdio: "pipe" });
4133
+ if (result.status !== 0) {
4134
+ fs.rmSync(socketPath, { recursive: true, force: true });
4135
+ }
4136
+ }
4137
+ } catch {
4138
+ }
4139
+ }
4140
+ }
4141
+ } catch {
4142
+ }
4143
+ }
4120
4144
  function commandExists(command) {
4121
4145
  try {
4122
4146
  if (!/^[a-zA-Z0-9_-]+$/.test(command)) {
@@ -4189,6 +4213,7 @@ function sanitizeProjectName(name) {
4189
4213
  return name.replace(/[^a-zA-Z0-9_-]/g, "-").substring(0, 50);
4190
4214
  }
4191
4215
  async function spawnInTmux(projects, sessionName) {
4216
+ cleanupTmuxSockets();
4192
4217
  const tmuxSession = sessionName || `shiva-${Date.now()}`;
4193
4218
  const insideTmux = isInsideTmux();
4194
4219
  for (let i = 0; i < projects.length; i++) {
@@ -4256,7 +4281,7 @@ async function spawnInTmux(projects, sessionName) {
4256
4281
  }
4257
4282
  }
4258
4283
  if (!insideTmux) {
4259
- spawn2("tmux", ["attach-session", "-t", tmuxSession], {
4284
+ spawnSync2("tmux", ["attach-session", "-t", tmuxSession], {
4260
4285
  stdio: "inherit"
4261
4286
  });
4262
4287
  }
@@ -4535,7 +4560,7 @@ function getTerminalName(terminal) {
4535
4560
  }
4536
4561
 
4537
4562
  // src/services/sandbox/sandbox.ts
4538
- import { existsSync as existsSync8, mkdirSync, rmSync, readdirSync as readdirSync2, copyFileSync, readFileSync as readFileSync4 } from "fs";
4563
+ import { existsSync as existsSync8, mkdirSync, rmSync as rmSync2, readdirSync as readdirSync3, copyFileSync, readFileSync as readFileSync4 } from "fs";
4539
4564
  import { join as join4, dirname } from "path";
4540
4565
  import { randomUUID } from "crypto";
4541
4566
  import Conf2 from "conf";
@@ -4830,7 +4855,7 @@ var SandboxService = class {
4830
4855
  * Recursively copy a directory
4831
4856
  */
4832
4857
  copyDirectory(src, dest, excludePaths) {
4833
- const entries = readdirSync2(src, { withFileTypes: true });
4858
+ const entries = readdirSync3(src, { withFileTypes: true });
4834
4859
  for (const entry of entries) {
4835
4860
  const srcPath = join4(src, entry.name);
4836
4861
  const destPath = join4(dest, entry.name);
@@ -4924,13 +4949,13 @@ var SandboxService = class {
4924
4949
  const removeResult = gitExec(["worktree", "remove", session.sandboxPath, "--force"], session.projectPath);
4925
4950
  if (!removeResult.success) {
4926
4951
  if (existsSync8(session.sandboxPath)) {
4927
- rmSync(session.sandboxPath, { recursive: true, force: true });
4952
+ rmSync2(session.sandboxPath, { recursive: true, force: true });
4928
4953
  }
4929
4954
  gitExec(["worktree", "prune"], session.projectPath);
4930
4955
  }
4931
4956
  } else {
4932
4957
  if (existsSync8(session.sandboxPath)) {
4933
- rmSync(session.sandboxPath, { recursive: true, force: true });
4958
+ rmSync2(session.sandboxPath, { recursive: true, force: true });
4934
4959
  }
4935
4960
  }
4936
4961
  const sessions = store.get("sessions");
@@ -5006,7 +5031,7 @@ var SandboxService = class {
5006
5031
  const sandboxEntries = /* @__PURE__ */ new Set();
5007
5032
  const sandboxFullPath = join4(sandboxPath, relativePath);
5008
5033
  if (existsSync8(sandboxFullPath)) {
5009
- const entries = readdirSync2(sandboxFullPath, { withFileTypes: true });
5034
+ const entries = readdirSync3(sandboxFullPath, { withFileTypes: true });
5010
5035
  for (const entry of entries) {
5011
5036
  if (config.excludePaths.includes(entry.name) || entry.name === ".shiva") {
5012
5037
  continue;
@@ -5050,7 +5075,7 @@ var SandboxService = class {
5050
5075
  }
5051
5076
  const originalFullPath = join4(originalPath, relativePath);
5052
5077
  if (existsSync8(originalFullPath)) {
5053
- const entries = readdirSync2(originalFullPath, { withFileTypes: true });
5078
+ const entries = readdirSync3(originalFullPath, { withFileTypes: true });
5054
5079
  for (const entry of entries) {
5055
5080
  if (config.excludePaths.includes(entry.name) || entry.name === ".shiva") {
5056
5081
  continue;
@@ -5096,7 +5121,7 @@ var SandboxService = class {
5096
5121
  * Count changes for a new directory
5097
5122
  */
5098
5123
  async countNewDirectoryChanges(dirPath, relativePath, changes) {
5099
- const entries = readdirSync2(dirPath, { withFileTypes: true });
5124
+ const entries = readdirSync3(dirPath, { withFileTypes: true });
5100
5125
  const config = this.getConfig();
5101
5126
  for (const entry of entries) {
5102
5127
  if (config.excludePaths.includes(entry.name)) continue;
@@ -5120,7 +5145,7 @@ var SandboxService = class {
5120
5145
  * Count changes for a deleted directory
5121
5146
  */
5122
5147
  async countDeletedDirectoryChanges(dirPath, relativePath, changes) {
5123
- const entries = readdirSync2(dirPath, { withFileTypes: true });
5148
+ const entries = readdirSync3(dirPath, { withFileTypes: true });
5124
5149
  const config = this.getConfig();
5125
5150
  for (const entry of entries) {
5126
5151
  if (config.excludePaths.includes(entry.name)) continue;
@@ -5224,7 +5249,7 @@ ${content.split("\n").map((l) => `- ${l}`).join("\n")}`;
5224
5249
  const destPath = join4(session.projectPath, filePath);
5225
5250
  if (change.type === "deleted") {
5226
5251
  if (existsSync8(destPath)) {
5227
- rmSync(destPath, { force: true });
5252
+ rmSync2(destPath, { force: true });
5228
5253
  }
5229
5254
  } else {
5230
5255
  if (existsSync8(srcPath)) {
@@ -5264,7 +5289,7 @@ ${content.split("\n").map((l) => `- ${l}`).join("\n")}`;
5264
5289
  copyFileSync(originalPath, sandboxFilePath);
5265
5290
  } else {
5266
5291
  if (existsSync8(sandboxFilePath)) {
5267
- rmSync(sandboxFilePath, { force: true });
5292
+ rmSync2(sandboxFilePath, { force: true });
5268
5293
  }
5269
5294
  }
5270
5295
  }
@@ -5357,7 +5382,7 @@ var startCommand = new Command10("start").description("Projekte starten (mit Git
5357
5382
  const launches = [];
5358
5383
  for (const projektArg of projekte) {
5359
5384
  const absolutePath = path3.resolve(projektArg);
5360
- if (fs.existsSync(absolutePath) && fs.statSync(absolutePath).isDirectory()) {
5385
+ if (fs2.existsSync(absolutePath) && fs2.statSync(absolutePath).isDirectory()) {
5361
5386
  const project = findProjectFromArray(allProjects, absolutePath);
5362
5387
  const latestSession = project?.latestSession;
5363
5388
  launches.push({
@@ -5369,7 +5394,7 @@ var startCommand = new Command10("start").description("Projekte starten (mit Git
5369
5394
  } else {
5370
5395
  const project = findProjectFromArray(allProjects, projektArg);
5371
5396
  if (project) {
5372
- if (!fs.existsSync(project.absolutePath)) {
5397
+ if (!fs2.existsSync(project.absolutePath)) {
5373
5398
  spinner.warn(`Projektpfad existiert nicht: ${project.absolutePath}`);
5374
5399
  continue;
5375
5400
  }
@@ -5518,7 +5543,7 @@ async function startIssueSession(issueNumber, options) {
5518
5543
  let foundIssue = null;
5519
5544
  let repoFullName = null;
5520
5545
  for (const project of allProjects) {
5521
- if (!fs.existsSync(project.absolutePath)) continue;
5546
+ if (!fs2.existsSync(project.absolutePath)) continue;
5522
5547
  const repo = getRepoInfo(project.absolutePath);
5523
5548
  if (!repo) continue;
5524
5549
  const issue = getIssue(repo.fullName, issueNumber);
@@ -5627,7 +5652,7 @@ async function startPRSession(prNumber, options) {
5627
5652
  let foundPR = null;
5628
5653
  let repoFullName = null;
5629
5654
  for (const project of allProjects) {
5630
- if (!fs.existsSync(project.absolutePath)) continue;
5655
+ if (!fs2.existsSync(project.absolutePath)) continue;
5631
5656
  const repo = getRepoInfo(project.absolutePath);
5632
5657
  if (!repo) continue;
5633
5658
  const pr = getPR(repo.fullName, prNumber);
@@ -5728,7 +5753,7 @@ import { Command as Command11 } from "commander";
5728
5753
  import { spawn as spawn4 } from "child_process";
5729
5754
  import inquirer4 from "inquirer";
5730
5755
  import ora9 from "ora";
5731
- import * as fs2 from "fs";
5756
+ import * as fs3 from "fs";
5732
5757
  var resumeCommand = new Command11("resume").description("Neueste Claude Code Session fortsetzen").argument("[projekt]", "Projektname oder Pfad").option("-s, --session <id>", "Bestimmte Session-ID fortsetzen").option("-b, --branch", "Session f\xFCr aktuellen Branch verwenden").option("-l, --list", "Sessions zur Auswahl anzeigen").option("--save-mapping", "Branch-Session Mapping speichern").action(async (projekt, options) => {
5733
5758
  try {
5734
5759
  let project = null;
@@ -5820,7 +5845,7 @@ var resumeCommand = new Command11("resume").description("Neueste Claude Code Ses
5820
5845
  log.error("Kein Projekt gefunden");
5821
5846
  return;
5822
5847
  }
5823
- if (!fs2.existsSync(project.absolutePath)) {
5848
+ if (!fs3.existsSync(project.absolutePath)) {
5824
5849
  log.error(`Projektpfad existiert nicht mehr: ${project.absolutePath}`);
5825
5850
  return;
5826
5851
  }
@@ -5951,7 +5976,7 @@ import { Command as Command12 } from "commander";
5951
5976
  import { spawn as spawn5 } from "child_process";
5952
5977
  import inquirer5 from "inquirer";
5953
5978
  import ora10 from "ora";
5954
- import * as fs3 from "fs";
5979
+ import * as fs4 from "fs";
5955
5980
  var restoreCommand = new Command12("restore").description("Context aus crashed Session wiederherstellen").argument("[projekt]", "Projektname oder Pfad").option("--level <level>", "Recovery-Level: minimal, standard, full", "standard").option("-o, --output <pfad>", "Ausgabeverzeichnis f\xFCr Recovery-Datei").option("--no-prompt", "Keine neue Session starten").action(async (projekt, options) => {
5956
5981
  try {
5957
5982
  let project = null;
@@ -6028,7 +6053,7 @@ var restoreCommand = new Command12("restore").description("Context aus crashed S
6028
6053
  const statusText = corrupted ? colors.red("Corrupted") : colors.green("OK");
6029
6054
  let fileSize = "unbekannt";
6030
6055
  try {
6031
- const stats = fs3.statSync(session.fullPath);
6056
+ const stats = fs4.statSync(session.fullPath);
6032
6057
  const sizeMB = (stats.size / (1024 * 1024)).toFixed(1);
6033
6058
  fileSize = `${sizeMB}MB`;
6034
6059
  } catch {
@@ -6060,7 +6085,7 @@ var restoreCommand = new Command12("restore").description("Context aus crashed S
6060
6085
  log.newline();
6061
6086
  }
6062
6087
  if (options.prompt !== false) {
6063
- const projectExists = fs3.existsSync(project.absolutePath);
6088
+ const projectExists = fs4.existsSync(project.absolutePath);
6064
6089
  if (!projectExists) {
6065
6090
  log.warn(`Projektpfad existiert nicht: ${project.absolutePath}`);
6066
6091
  log.info("Neue Session kann nicht gestartet werden.");
@@ -6105,7 +6130,7 @@ import { Command as Command13 } from "commander";
6105
6130
  import ora11 from "ora";
6106
6131
 
6107
6132
  // src/services/data/tags.ts
6108
- import * as fs4 from "fs";
6133
+ import * as fs5 from "fs";
6109
6134
  import * as path4 from "path";
6110
6135
  import * as os3 from "os";
6111
6136
  function getTagsPath() {
@@ -6113,11 +6138,11 @@ function getTagsPath() {
6113
6138
  }
6114
6139
  function loadTagsData() {
6115
6140
  const filepath = getTagsPath();
6116
- if (!fs4.existsSync(filepath)) {
6141
+ if (!fs5.existsSync(filepath)) {
6117
6142
  return { sessions: {}, tagMeta: {} };
6118
6143
  }
6119
6144
  try {
6120
- const content = fs4.readFileSync(filepath, "utf-8");
6145
+ const content = fs5.readFileSync(filepath, "utf-8");
6121
6146
  return JSON.parse(content);
6122
6147
  } catch {
6123
6148
  return { sessions: {}, tagMeta: {} };
@@ -6126,10 +6151,10 @@ function loadTagsData() {
6126
6151
  function saveTagsData(data) {
6127
6152
  const filepath = getTagsPath();
6128
6153
  const dir = path4.dirname(filepath);
6129
- if (!fs4.existsSync(dir)) {
6130
- fs4.mkdirSync(dir, { recursive: true });
6154
+ if (!fs5.existsSync(dir)) {
6155
+ fs5.mkdirSync(dir, { recursive: true });
6131
6156
  }
6132
- fs4.writeFileSync(filepath, JSON.stringify(data, null, 2));
6157
+ fs5.writeFileSync(filepath, JSON.stringify(data, null, 2));
6133
6158
  }
6134
6159
  function addTagToSession(sessionId, tag) {
6135
6160
  const data = loadTagsData();
@@ -6385,8 +6410,8 @@ ${colors.dim("Beispiele:")}
6385
6410
  }));
6386
6411
  async function checkProjectExists(path15) {
6387
6412
  try {
6388
- const fs15 = await import("fs");
6389
- return fs15.existsSync(path15);
6413
+ const fs16 = await import("fs");
6414
+ return fs16.existsSync(path15);
6390
6415
  } catch {
6391
6416
  return false;
6392
6417
  }
@@ -6394,7 +6419,8 @@ async function checkProjectExists(path15) {
6394
6419
  sessionsCommand.command("push").description("Sessions in Cloud sichern").option("-p, --project <pfad>", "Nur Sessions eines Projekts").action(async (options) => {
6395
6420
  const { api: api2 } = await import("./client-H3JXPT5B.js");
6396
6421
  const { isAuthenticated: isAuthenticated2 } = await import("./config-FGMZONWV.js");
6397
- const { getProjectConfig: getProjectConfig2 } = await import("./config-D6M6LI6U.js");
6422
+ const { getProjectConfig: getProjectConfig2, getAnalyticsConfig: getAnalyticsConfig2 } = await import("./config-D6M6LI6U.js");
6423
+ const { createAnalyticsService } = await import("./analytics-6WNUPA56.js");
6398
6424
  if (!isAuthenticated2()) {
6399
6425
  log.errorWithSuggestion(Errors.NOT_AUTHENTICATED());
6400
6426
  return;
@@ -6422,15 +6448,24 @@ sessionsCommand.command("push").description("Sessions in Cloud sichern").option(
6422
6448
  if (!config.projectId) {
6423
6449
  continue;
6424
6450
  }
6451
+ const analyticsConfig = getAnalyticsConfig2(project.absolutePath);
6452
+ const analyticsService = createAnalyticsService(project.absolutePath, analyticsConfig);
6425
6453
  for (const session of project.sessions) {
6426
6454
  try {
6455
+ const sessionAnalytics = analyticsService.getSessionAnalytics(session.sessionId);
6427
6456
  await api2.syncSession({
6428
6457
  sessionId: session.sessionId,
6429
6458
  projectId: config.projectId,
6430
6459
  summary: session.firstPrompt,
6431
6460
  messageCount: session.messageCount,
6432
6461
  firstPrompt: session.firstPrompt,
6433
- gitBranch: session.gitBranch
6462
+ gitBranch: session.gitBranch,
6463
+ // Include analytics data if available
6464
+ tokenCount: sessionAnalytics ? sessionAnalytics.inputTokens + sessionAnalytics.outputTokens : void 0,
6465
+ inputTokens: sessionAnalytics?.inputTokens,
6466
+ outputTokens: sessionAnalytics?.outputTokens,
6467
+ durationMinutes: sessionAnalytics?.duration,
6468
+ toolsUsed: sessionAnalytics?.toolsUsed
6434
6469
  });
6435
6470
  syncedCount++;
6436
6471
  } catch {
@@ -6500,7 +6535,8 @@ sessionsCommand.command("pull").description("Sessions aus Cloud laden").option("
6500
6535
  sessionsCommand.command("sync").description("Sessions mit Cloud synchronisieren").option("-p, --project <pfad>", "Nur Sessions eines Projekts").action(async (options) => {
6501
6536
  const { api: api2 } = await import("./client-H3JXPT5B.js");
6502
6537
  const { isAuthenticated: isAuthenticated2 } = await import("./config-FGMZONWV.js");
6503
- const { getProjectConfig: getProjectConfig2 } = await import("./config-D6M6LI6U.js");
6538
+ const { getProjectConfig: getProjectConfig2, getAnalyticsConfig: getAnalyticsConfig2 } = await import("./config-D6M6LI6U.js");
6539
+ const { createAnalyticsService } = await import("./analytics-6WNUPA56.js");
6504
6540
  if (!isAuthenticated2()) {
6505
6541
  log.errorWithSuggestion(Errors.NOT_AUTHENTICATED());
6506
6542
  return;
@@ -6520,15 +6556,24 @@ sessionsCommand.command("sync").description("Sessions mit Cloud synchronisieren"
6520
6556
  for (const project of projects.filter((p) => p.sessions.length > 0)) {
6521
6557
  const config = getProjectConfig2(project.absolutePath);
6522
6558
  if (!config.projectId) continue;
6559
+ const analyticsConfig = getAnalyticsConfig2(project.absolutePath);
6560
+ const analyticsService = createAnalyticsService(project.absolutePath, analyticsConfig);
6523
6561
  for (const session of project.sessions) {
6524
6562
  try {
6563
+ const sessionAnalytics = analyticsService.getSessionAnalytics(session.sessionId);
6525
6564
  await api2.syncSession({
6526
6565
  sessionId: session.sessionId,
6527
6566
  projectId: config.projectId,
6528
6567
  summary: session.firstPrompt,
6529
6568
  messageCount: session.messageCount,
6530
6569
  firstPrompt: session.firstPrompt,
6531
- gitBranch: session.gitBranch
6570
+ gitBranch: session.gitBranch,
6571
+ // Include analytics data if available
6572
+ tokenCount: sessionAnalytics ? sessionAnalytics.inputTokens + sessionAnalytics.outputTokens : void 0,
6573
+ inputTokens: sessionAnalytics?.inputTokens,
6574
+ outputTokens: sessionAnalytics?.outputTokens,
6575
+ durationMinutes: sessionAnalytics?.duration,
6576
+ toolsUsed: sessionAnalytics?.toolsUsed
6532
6577
  });
6533
6578
  pushedCount++;
6534
6579
  } catch {
@@ -7165,7 +7210,7 @@ sessionCommand.command("config").description("Sandbox-Konfiguration verwalten").
7165
7210
  // src/commands/github/github-cmd.ts
7166
7211
  import { Command as Command15 } from "commander";
7167
7212
  import { spawn as spawn6, spawnSync as spawnSync5 } from "child_process";
7168
- import * as fs5 from "fs";
7213
+ import * as fs6 from "fs";
7169
7214
  import * as path5 from "path";
7170
7215
  import inquirer6 from "inquirer";
7171
7216
  var githubCommand = new Command15("github").description("GitHub Integration verwalten").action(() => {
@@ -7592,18 +7637,18 @@ githubCommand.command("git-hook").description("Git Hooks f\xFCr Branch-Session I
7592
7637
  const hooksDir = path5.join(gitDir, "hooks");
7593
7638
  const hookFile = path5.join(hooksDir, "post-checkout");
7594
7639
  if (options.uninstall) {
7595
- if (fs5.existsSync(hookFile)) {
7596
- const content = fs5.readFileSync(hookFile, "utf-8");
7640
+ if (fs6.existsSync(hookFile)) {
7641
+ const content = fs6.readFileSync(hookFile, "utf-8");
7597
7642
  if (content.includes("shiva hook branch-switch")) {
7598
7643
  const lines = content.split("\n");
7599
7644
  const filtered = lines.filter(
7600
7645
  (line) => !line.includes("shiva hook branch-switch") && !line.includes("# SHIVA Code")
7601
7646
  );
7602
7647
  if (filtered.filter((l) => l.trim() && !l.startsWith("#!")).length === 0) {
7603
- fs5.unlinkSync(hookFile);
7648
+ fs6.unlinkSync(hookFile);
7604
7649
  log.success("Git Hook entfernt");
7605
7650
  } else {
7606
- fs5.writeFileSync(hookFile, filtered.join("\n"), "utf-8");
7651
+ fs6.writeFileSync(hookFile, filtered.join("\n"), "utf-8");
7607
7652
  log.success("SHIVA aus Git Hook entfernt");
7608
7653
  }
7609
7654
  } else {
@@ -7618,12 +7663,12 @@ githubCommand.command("git-hook").description("Git Hooks f\xFCr Branch-Session I
7618
7663
  console.log(colors.orange.bold("SHIVA Code - Git Hook installieren"));
7619
7664
  console.log(colors.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
7620
7665
  log.newline();
7621
- if (!fs5.existsSync(hooksDir)) {
7622
- fs5.mkdirSync(hooksDir, { recursive: true });
7666
+ if (!fs6.existsSync(hooksDir)) {
7667
+ fs6.mkdirSync(hooksDir, { recursive: true });
7623
7668
  }
7624
7669
  let existingContent = "";
7625
- if (fs5.existsSync(hookFile)) {
7626
- existingContent = fs5.readFileSync(hookFile, "utf-8");
7670
+ if (fs6.existsSync(hookFile)) {
7671
+ existingContent = fs6.readFileSync(hookFile, "utf-8");
7627
7672
  if (existingContent.includes("shiva hook branch-switch")) {
7628
7673
  log.warn("SHIVA Hook ist bereits installiert");
7629
7674
  log.info("Zum Entfernen: shiva github git-hook --uninstall");
@@ -7635,15 +7680,15 @@ githubCommand.command("git-hook").description("Git Hooks f\xFCr Branch-Session I
7635
7680
  shiva hook branch-switch "$1" "$2" --quiet 2>/dev/null || true
7636
7681
  `;
7637
7682
  if (existingContent) {
7638
- fs5.writeFileSync(hookFile, existingContent + shivaHookCode, "utf-8");
7683
+ fs6.writeFileSync(hookFile, existingContent + shivaHookCode, "utf-8");
7639
7684
  log.success("SHIVA zu bestehendem Hook hinzugef\xFCgt");
7640
7685
  } else {
7641
7686
  const newHook = `#!/bin/bash
7642
7687
  ${shivaHookCode}`;
7643
- fs5.writeFileSync(hookFile, newHook, "utf-8");
7688
+ fs6.writeFileSync(hookFile, newHook, "utf-8");
7644
7689
  log.success("Git Hook erstellt");
7645
7690
  }
7646
- fs5.chmodSync(hookFile, "755");
7691
+ fs6.chmodSync(hookFile, "755");
7647
7692
  log.newline();
7648
7693
  log.info("Der Hook zeigt beim Branch-Wechsel an, ob eine Session existiert.");
7649
7694
  log.newline();
@@ -10155,7 +10200,7 @@ securityCommand.addCommand(devicesCommand);
10155
10200
  import { Command as Command20 } from "commander";
10156
10201
  import inquirer8 from "inquirer";
10157
10202
  import ora15 from "ora";
10158
- import * as fs6 from "fs";
10203
+ import * as fs7 from "fs";
10159
10204
  import * as path6 from "path";
10160
10205
  var SECURE_FILE_MODE = 384;
10161
10206
  var secretsCommand = new Command20("secrets").description(t("commands.secrets.description")).addHelpText("after", `
@@ -10405,7 +10450,7 @@ secretsCommand.command("env").description("Secrets als .env Format ausgeben").op
10405
10450
  spinner.stop();
10406
10451
  const envContent = Object.entries(secrets).map(([key, value]) => `${key}="${value}"`).join("\n");
10407
10452
  if (options.output) {
10408
- fs6.writeFileSync(options.output, envContent + "\n", { mode: SECURE_FILE_MODE });
10453
+ fs7.writeFileSync(options.output, envContent + "\n", { mode: SECURE_FILE_MODE });
10409
10454
  log.success(`Secrets in ${options.output} geschrieben`);
10410
10455
  log.warn("Diese Datei enth\xE4lt sensible Daten!");
10411
10456
  log.dim(`Datei-Berechtigungen auf ${SECURE_FILE_MODE.toString(8)} gesetzt`);
@@ -10426,11 +10471,11 @@ secretsCommand.command("import").description(".env Datei in Vault importieren").
10426
10471
  return;
10427
10472
  }
10428
10473
  const filePath = path6.resolve(file);
10429
- if (!fs6.existsSync(filePath)) {
10474
+ if (!fs7.existsSync(filePath)) {
10430
10475
  log.errorWithSuggestion(Errors.FILE_NOT_FOUND(file));
10431
10476
  return;
10432
10477
  }
10433
- const content = fs6.readFileSync(filePath, "utf-8");
10478
+ const content = fs7.readFileSync(filePath, "utf-8");
10434
10479
  const lines = content.split("\n");
10435
10480
  const secrets = [];
10436
10481
  for (const line of lines) {
@@ -10535,7 +10580,7 @@ secretsCommand.command("export").description("Secrets exportieren").option("-p,
10535
10580
  }).join("\n");
10536
10581
  }
10537
10582
  if (options.output) {
10538
- fs6.writeFileSync(options.output, output + "\n", { mode: SECURE_FILE_MODE });
10583
+ fs7.writeFileSync(options.output, output + "\n", { mode: SECURE_FILE_MODE });
10539
10584
  log.success(`Secrets in ${options.output} geschrieben`);
10540
10585
  log.warn("Diese Datei enth\xE4lt sensible Daten!");
10541
10586
  log.dim(`Datei-Berechtigungen auf ${SECURE_FILE_MODE.toString(8)} gesetzt`);
@@ -10730,19 +10775,19 @@ import { Command as Command22 } from "commander";
10730
10775
  import ora16 from "ora";
10731
10776
 
10732
10777
  // src/services/data/memory.ts
10733
- import * as fs7 from "fs";
10778
+ import * as fs8 from "fs";
10734
10779
  import * as path7 from "path";
10735
10780
  import * as os4 from "os";
10736
10781
  function findAllClaudeMdFiles() {
10737
10782
  const results = [];
10738
10783
  const sessionsPath = path7.join(os4.homedir(), ".claude", "projects");
10739
- if (fs7.existsSync(sessionsPath)) {
10740
- const dirs = fs7.readdirSync(sessionsPath);
10784
+ if (fs8.existsSync(sessionsPath)) {
10785
+ const dirs = fs8.readdirSync(sessionsPath);
10741
10786
  for (const dir of dirs) {
10742
10787
  const projectPath = decodeProjectPath(dir);
10743
- if (projectPath && fs7.existsSync(projectPath)) {
10788
+ if (projectPath && fs8.existsSync(projectPath)) {
10744
10789
  const claudeMdPath = path7.join(projectPath, "CLAUDE.md");
10745
- if (fs7.existsSync(claudeMdPath)) {
10790
+ if (fs8.existsSync(claudeMdPath)) {
10746
10791
  results.push({
10747
10792
  path: claudeMdPath,
10748
10793
  projectPath,
@@ -10764,7 +10809,7 @@ function decodeProjectPath(encoded) {
10764
10809
  while (i < parts.length) {
10765
10810
  const part = parts[i];
10766
10811
  const testPath = currentPath + "/" + part;
10767
- if (fs7.existsSync(testPath)) {
10812
+ if (fs8.existsSync(testPath)) {
10768
10813
  currentPath = testPath;
10769
10814
  i++;
10770
10815
  } else {
@@ -10772,21 +10817,21 @@ function decodeProjectPath(encoded) {
10772
10817
  for (let j = i + 1; j < parts.length && j <= i + 5 && !found; j++) {
10773
10818
  const partsToJoin = parts.slice(i, j + 1);
10774
10819
  const hyphenPath = currentPath + "/" + partsToJoin.join("-");
10775
- if (fs7.existsSync(hyphenPath)) {
10820
+ if (fs8.existsSync(hyphenPath)) {
10776
10821
  currentPath = hyphenPath;
10777
10822
  i = j + 1;
10778
10823
  found = true;
10779
10824
  break;
10780
10825
  }
10781
10826
  const dotPath = currentPath + "/" + partsToJoin.join(".");
10782
- if (fs7.existsSync(dotPath)) {
10827
+ if (fs8.existsSync(dotPath)) {
10783
10828
  currentPath = dotPath;
10784
10829
  i = j + 1;
10785
10830
  found = true;
10786
10831
  break;
10787
10832
  }
10788
10833
  const underscorePath = currentPath + "/" + partsToJoin.join("_");
10789
- if (fs7.existsSync(underscorePath)) {
10834
+ if (fs8.existsSync(underscorePath)) {
10790
10835
  currentPath = underscorePath;
10791
10836
  i = j + 1;
10792
10837
  found = true;
@@ -10806,7 +10851,7 @@ function getLocalMemories() {
10806
10851
  const claudeFiles = findAllClaudeMdFiles();
10807
10852
  for (const file of claudeFiles) {
10808
10853
  try {
10809
- const content = fs7.readFileSync(file.path, "utf-8");
10854
+ const content = fs8.readFileSync(file.path, "utf-8");
10810
10855
  const parsed = parseClaudeMd(content);
10811
10856
  for (const memory of parsed.memories) {
10812
10857
  memories.push({
@@ -10933,15 +10978,15 @@ async function searchMemories(query, options = {}) {
10933
10978
  }
10934
10979
  function deleteLocalMemory(projectPath, key) {
10935
10980
  const claudeMdPath = path7.join(projectPath, "CLAUDE.md");
10936
- if (!fs7.existsSync(claudeMdPath)) {
10981
+ if (!fs8.existsSync(claudeMdPath)) {
10937
10982
  return false;
10938
10983
  }
10939
10984
  try {
10940
- let content = fs7.readFileSync(claudeMdPath, "utf-8");
10985
+ let content = fs8.readFileSync(claudeMdPath, "utf-8");
10941
10986
  const regex = new RegExp(`^- \\*\\*${escapeRegex(key)}\\*\\* \\([^)]+\\): .+$`, "gm");
10942
10987
  const newContent = content.replace(regex, "").replace(/\n\n\n+/g, "\n\n");
10943
10988
  if (newContent !== content) {
10944
- fs7.writeFileSync(claudeMdPath, newContent);
10989
+ fs8.writeFileSync(claudeMdPath, newContent);
10945
10990
  return true;
10946
10991
  }
10947
10992
  return false;
@@ -10983,14 +11028,14 @@ async function deleteMemory(projectPath, key, options = {}) {
10983
11028
  async function deleteAllProjectMemories(projectPath) {
10984
11029
  const result = { local: 0, cloud: 0 };
10985
11030
  const claudeMdPath = path7.join(projectPath, "CLAUDE.md");
10986
- if (fs7.existsSync(claudeMdPath)) {
11031
+ if (fs8.existsSync(claudeMdPath)) {
10987
11032
  try {
10988
- let content = fs7.readFileSync(claudeMdPath, "utf-8");
11033
+ let content = fs8.readFileSync(claudeMdPath, "utf-8");
10989
11034
  const parsed = parseClaudeMd(content);
10990
11035
  result.local = parsed.memories.length;
10991
11036
  const regex = /^- \*\*.+\*\* \([^)]+\): .+$/gm;
10992
11037
  const newContent = content.replace(regex, "").replace(/\n\n\n+/g, "\n\n");
10993
- fs7.writeFileSync(claudeMdPath, newContent);
11038
+ fs8.writeFileSync(claudeMdPath, newContent);
10994
11039
  } catch {
10995
11040
  }
10996
11041
  }
@@ -11022,8 +11067,8 @@ async function getContextPreview(projectPath) {
11022
11067
  secrets: [],
11023
11068
  totalSize: 0
11024
11069
  };
11025
- if (fs7.existsSync(claudeMdPath)) {
11026
- const content = fs7.readFileSync(claudeMdPath, "utf-8");
11070
+ if (fs8.existsSync(claudeMdPath)) {
11071
+ const content = fs8.readFileSync(claudeMdPath, "utf-8");
11027
11072
  preview.claudeMdContent = content;
11028
11073
  preview.totalSize += content.length;
11029
11074
  const parsed = parseClaudeMd(content);
@@ -11036,8 +11081,8 @@ async function getContextPreview(projectPath) {
11036
11081
  }
11037
11082
  const shivaDir = path7.join(projectPath, ".shiva");
11038
11083
  const contextPath = path7.join(shivaDir, "github-context.md");
11039
- if (fs7.existsSync(contextPath)) {
11040
- const content = fs7.readFileSync(contextPath, "utf-8");
11084
+ if (fs8.existsSync(contextPath)) {
11085
+ const content = fs8.readFileSync(contextPath, "utf-8");
11041
11086
  preview.githubContext = content;
11042
11087
  preview.totalSize += content.length;
11043
11088
  }
@@ -11383,12 +11428,12 @@ function truncate(str, maxLen) {
11383
11428
  // src/commands/memory/context.ts
11384
11429
  import { Command as Command24 } from "commander";
11385
11430
  import * as path9 from "path";
11386
- import * as fs8 from "fs";
11431
+ import * as fs9 from "fs";
11387
11432
  import ora18 from "ora";
11388
11433
  var contextCommand = new Command24("context").description("Zeigt was in Claude injected w\xFCrde").option("-d, --dir <path>", "Projektverzeichnis").option("--github", "GitHub Context einschlie\xDFen").option("--secrets", "Secret-Keys anzeigen").option("--raw", "Rohe CLAUDE.md Ausgabe").option("--json", "JSON Ausgabe").option("-s, --size", "Nur Gr\xF6\xDFe anzeigen").action(async (options) => {
11389
11434
  const projectPath = options.dir ? path9.resolve(options.dir) : process.cwd();
11390
11435
  const projectName = path9.basename(projectPath);
11391
- if (!fs8.existsSync(projectPath)) {
11436
+ if (!fs9.existsSync(projectPath)) {
11392
11437
  log.error(`Verzeichnis nicht gefunden: ${projectPath}`);
11393
11438
  return;
11394
11439
  }
@@ -11807,12 +11852,12 @@ tagsCommand.command("cloud").description("Memory-Tags aus Cloud laden").option("
11807
11852
  // src/commands/memory/export.ts
11808
11853
  import { Command as Command26 } from "commander";
11809
11854
  import * as path11 from "path";
11810
- import * as fs10 from "fs";
11855
+ import * as fs11 from "fs";
11811
11856
  import ora19 from "ora";
11812
11857
  import inquirer12 from "inquirer";
11813
11858
 
11814
11859
  // src/services/session/export.ts
11815
- import * as fs9 from "fs";
11860
+ import * as fs10 from "fs";
11816
11861
  import * as path10 from "path";
11817
11862
  async function exportSession(sessionId, options = {}) {
11818
11863
  const projects = await getAllClaudeProjects();
@@ -11833,8 +11878,8 @@ async function exportSession(sessionId, options = {}) {
11833
11878
  encodeProjectPath(project.absolutePath),
11834
11879
  session.sessionId + ".jsonl"
11835
11880
  );
11836
- if (fs9.existsSync(transcriptPath)) {
11837
- exported.transcript = fs9.readFileSync(transcriptPath, "utf-8");
11881
+ if (fs10.existsSync(transcriptPath)) {
11882
+ exported.transcript = fs10.readFileSync(transcriptPath, "utf-8");
11838
11883
  }
11839
11884
  }
11840
11885
  if (options.includeConversation && options.includeTranscript) {
@@ -11843,8 +11888,8 @@ async function exportSession(sessionId, options = {}) {
11843
11888
  encodeProjectPath(project.absolutePath),
11844
11889
  session.sessionId + ".jsonl"
11845
11890
  );
11846
- if (fs9.existsSync(transcriptPath)) {
11847
- const content = fs9.readFileSync(transcriptPath, "utf-8");
11891
+ if (fs10.existsSync(transcriptPath)) {
11892
+ const content = fs10.readFileSync(transcriptPath, "utf-8");
11848
11893
  const lines = content.split("\n").filter((l) => l.trim());
11849
11894
  exported.conversation = lines.map((line) => {
11850
11895
  try {
@@ -11866,12 +11911,12 @@ async function exportSessionToFile(sessionId, outputPath, options = {}) {
11866
11911
  return false;
11867
11912
  }
11868
11913
  const content = JSON.stringify(exported, null, 2);
11869
- fs9.writeFileSync(outputPath, content, "utf-8");
11914
+ fs10.writeFileSync(outputPath, content, "utf-8");
11870
11915
  return true;
11871
11916
  }
11872
11917
  async function exportSessions(sessionIds, outputDir, options = {}) {
11873
- if (!fs9.existsSync(outputDir)) {
11874
- fs9.mkdirSync(outputDir, { recursive: true });
11918
+ if (!fs10.existsSync(outputDir)) {
11919
+ fs10.mkdirSync(outputDir, { recursive: true });
11875
11920
  }
11876
11921
  let success = 0;
11877
11922
  let failed = 0;
@@ -11880,7 +11925,7 @@ async function exportSessions(sessionIds, outputDir, options = {}) {
11880
11925
  if (exported) {
11881
11926
  const filename = `${exported.projectName}-${sessionId.slice(0, 8)}.json`;
11882
11927
  const filepath = path10.join(outputDir, filename);
11883
- fs9.writeFileSync(filepath, JSON.stringify(exported, null, 2));
11928
+ fs10.writeFileSync(filepath, JSON.stringify(exported, null, 2));
11884
11929
  success++;
11885
11930
  } else {
11886
11931
  failed++;
@@ -11901,7 +11946,7 @@ async function exportProjectSessions(projectPath, outputDir, options = {}) {
11901
11946
  }
11902
11947
  function createBackupArchive(outputPath, projectPaths) {
11903
11948
  const claudeDir = getClaudeProjectsPath();
11904
- if (!fs9.existsSync(claudeDir)) {
11949
+ if (!fs10.existsSync(claudeDir)) {
11905
11950
  return false;
11906
11951
  }
11907
11952
  try {
@@ -11910,14 +11955,14 @@ function createBackupArchive(outputPath, projectPaths) {
11910
11955
  for (const p of projectPaths) {
11911
11956
  const encoded = encodeProjectPath(p);
11912
11957
  const fullPath = path10.join(claudeDir, encoded);
11913
- if (fs9.existsSync(fullPath)) {
11958
+ if (fs10.existsSync(fullPath)) {
11914
11959
  includePaths.push(encoded);
11915
11960
  }
11916
11961
  }
11917
11962
  } else {
11918
- const entries = fs9.readdirSync(claudeDir);
11963
+ const entries = fs10.readdirSync(claudeDir);
11919
11964
  includePaths = entries.filter((e) => {
11920
- const stat = fs9.statSync(path10.join(claudeDir, e));
11965
+ const stat = fs10.statSync(path10.join(claudeDir, e));
11921
11966
  return stat.isDirectory();
11922
11967
  });
11923
11968
  }
@@ -11936,28 +11981,28 @@ async function importSession(data, targetProjectPath) {
11936
11981
  const projectPath = targetProjectPath || data.projectPath;
11937
11982
  const encodedPath = encodeProjectPath(projectPath);
11938
11983
  const sessionDir = path10.join(getClaudeProjectsPath(), encodedPath);
11939
- if (!fs9.existsSync(sessionDir)) {
11940
- fs9.mkdirSync(sessionDir, { recursive: true });
11984
+ if (!fs10.existsSync(sessionDir)) {
11985
+ fs10.mkdirSync(sessionDir, { recursive: true });
11941
11986
  }
11942
11987
  const sessionFile = path10.join(sessionDir, data.session.sessionId + ".jsonl");
11943
- if (fs9.existsSync(sessionFile)) {
11988
+ if (fs10.existsSync(sessionFile)) {
11944
11989
  return {
11945
11990
  success: false,
11946
11991
  message: "Session already exists"
11947
11992
  };
11948
11993
  }
11949
11994
  if (data.transcript) {
11950
- fs9.writeFileSync(sessionFile, data.transcript, "utf-8");
11995
+ fs10.writeFileSync(sessionFile, data.transcript, "utf-8");
11951
11996
  } else if (data.conversation) {
11952
11997
  const transcript = data.conversation.map((entry) => JSON.stringify(entry)).join("\n");
11953
- fs9.writeFileSync(sessionFile, transcript, "utf-8");
11998
+ fs10.writeFileSync(sessionFile, transcript, "utf-8");
11954
11999
  } else {
11955
12000
  const minimalEntry = {
11956
12001
  type: "imported",
11957
12002
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
11958
12003
  originalSession: data.session
11959
12004
  };
11960
- fs9.writeFileSync(sessionFile, JSON.stringify(minimalEntry) + "\n");
12005
+ fs10.writeFileSync(sessionFile, JSON.stringify(minimalEntry) + "\n");
11961
12006
  }
11962
12007
  if (data.tags && data.tags.length > 0) {
11963
12008
  const { addTagToSession: addTagToSession2 } = await import("./tags.js");
@@ -11980,13 +12025,13 @@ async function importSession(data, targetProjectPath) {
11980
12025
  }
11981
12026
  async function importSessionFromFile(filepath, targetProjectPath) {
11982
12027
  try {
11983
- if (!fs9.existsSync(filepath)) {
12028
+ if (!fs10.existsSync(filepath)) {
11984
12029
  return {
11985
12030
  success: false,
11986
12031
  message: `File not found: ${filepath}`
11987
12032
  };
11988
12033
  }
11989
- const content = fs9.readFileSync(filepath, "utf-8");
12034
+ const content = fs10.readFileSync(filepath, "utf-8");
11990
12035
  const data = JSON.parse(content);
11991
12036
  if (!data.version || !data.session || !data.session.sessionId) {
11992
12037
  return {
@@ -12003,10 +12048,10 @@ async function importSessionFromFile(filepath, targetProjectPath) {
12003
12048
  }
12004
12049
  }
12005
12050
  async function importSessionsFromDirectory(dirPath, targetProjectPath) {
12006
- if (!fs9.existsSync(dirPath)) {
12051
+ if (!fs10.existsSync(dirPath)) {
12007
12052
  return { success: 0, failed: 0, results: [] };
12008
12053
  }
12009
- const files = fs9.readdirSync(dirPath).filter((f) => f.endsWith(".json"));
12054
+ const files = fs10.readdirSync(dirPath).filter((f) => f.endsWith(".json"));
12010
12055
  const results = [];
12011
12056
  let success = 0;
12012
12057
  let failed = 0;
@@ -12023,13 +12068,13 @@ async function importSessionsFromDirectory(dirPath, targetProjectPath) {
12023
12068
  return { success, failed, results };
12024
12069
  }
12025
12070
  function restoreFromArchive(archivePath, targetDir) {
12026
- if (!fs9.existsSync(archivePath)) {
12071
+ if (!fs10.existsSync(archivePath)) {
12027
12072
  return false;
12028
12073
  }
12029
12074
  try {
12030
12075
  const extractTo = targetDir || getClaudeProjectsPath();
12031
- if (!fs9.existsSync(extractTo)) {
12032
- fs9.mkdirSync(extractTo, { recursive: true });
12076
+ if (!fs10.existsSync(extractTo)) {
12077
+ fs10.mkdirSync(extractTo, { recursive: true });
12033
12078
  }
12034
12079
  const extractResult = tarExec(["-xzf", archivePath, "-C", extractTo]);
12035
12080
  if (!extractResult.success) {
@@ -12042,10 +12087,10 @@ function restoreFromArchive(archivePath, targetDir) {
12042
12087
  }
12043
12088
  function previewExportFile(filepath) {
12044
12089
  try {
12045
- if (!fs9.existsSync(filepath)) {
12090
+ if (!fs10.existsSync(filepath)) {
12046
12091
  return null;
12047
12092
  }
12048
- const content = fs9.readFileSync(filepath, "utf-8");
12093
+ const content = fs10.readFileSync(filepath, "utf-8");
12049
12094
  const data = JSON.parse(content);
12050
12095
  return {
12051
12096
  ...data,
@@ -12091,7 +12136,7 @@ var importCommand = new Command26("import").description("Sessions importieren").
12091
12136
  console.log(colors.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
12092
12137
  log.newline();
12093
12138
  const absolutePath = path11.resolve(inputPath);
12094
- if (!fs10.existsSync(absolutePath)) {
12139
+ if (!fs11.existsSync(absolutePath)) {
12095
12140
  log.error(`Datei nicht gefunden: ${absolutePath}`);
12096
12141
  return;
12097
12142
  }
@@ -12103,7 +12148,7 @@ var importCommand = new Command26("import").description("Sessions importieren").
12103
12148
  await handlePreview(absolutePath);
12104
12149
  return;
12105
12150
  }
12106
- const stat = fs10.statSync(absolutePath);
12151
+ const stat = fs11.statSync(absolutePath);
12107
12152
  if (stat.isDirectory()) {
12108
12153
  await handleImportDirectory(absolutePath, options.project);
12109
12154
  } else {
@@ -12117,7 +12162,7 @@ async function handleBackup(outputPath) {
12117
12162
  const success = createBackupArchive(output);
12118
12163
  if (success) {
12119
12164
  spinner.succeed(`Backup erstellt: ${output}`);
12120
- const stat = fs10.statSync(output);
12165
+ const stat = fs11.statSync(output);
12121
12166
  log.dim(`Gr\xF6\xDFe: ${(stat.size / 1024 / 1024).toFixed(2)} MB`);
12122
12167
  } else {
12123
12168
  spinner.fail("Backup fehlgeschlagen");
@@ -12348,7 +12393,7 @@ ${colors.dim("Beispiele:")}
12348
12393
  // src/commands/system/doctor.ts
12349
12394
  import { Command as Command28 } from "commander";
12350
12395
  import { execSync as execSync2 } from "child_process";
12351
- import * as fs11 from "fs";
12396
+ import * as fs12 from "fs";
12352
12397
  import * as path12 from "path";
12353
12398
  import * as os5 from "os";
12354
12399
  function tryExec(command) {
@@ -12513,7 +12558,7 @@ function checkNpm() {
12513
12558
  function checkShivaConfig() {
12514
12559
  const configDir = path12.join(os5.homedir(), ".config", "shiva-code");
12515
12560
  const configFile = path12.join(configDir, "config.json");
12516
- if (!fs11.existsSync(configDir)) {
12561
+ if (!fs12.existsSync(configDir)) {
12517
12562
  return {
12518
12563
  name: "SHIVA Config",
12519
12564
  status: "warn",
@@ -12521,7 +12566,7 @@ function checkShivaConfig() {
12521
12566
  hint: "Wird bei erster Nutzung erstellt"
12522
12567
  };
12523
12568
  }
12524
- if (!fs11.existsSync(configFile)) {
12569
+ if (!fs12.existsSync(configFile)) {
12525
12570
  return {
12526
12571
  name: "SHIVA Config",
12527
12572
  status: "warn",
@@ -12537,7 +12582,7 @@ function checkShivaConfig() {
12537
12582
  }
12538
12583
  function checkClaudeProjects() {
12539
12584
  const claudeDir = path12.join(os5.homedir(), ".claude", "projects");
12540
- if (!fs11.existsSync(claudeDir)) {
12585
+ if (!fs12.existsSync(claudeDir)) {
12541
12586
  return {
12542
12587
  name: "Claude Projects",
12543
12588
  status: "warn",
@@ -12546,8 +12591,8 @@ function checkClaudeProjects() {
12546
12591
  };
12547
12592
  }
12548
12593
  try {
12549
- const projects = fs11.readdirSync(claudeDir).filter(
12550
- (f) => fs11.statSync(path12.join(claudeDir, f)).isDirectory()
12594
+ const projects = fs12.readdirSync(claudeDir).filter(
12595
+ (f) => fs12.statSync(path12.join(claudeDir, f)).isDirectory()
12551
12596
  );
12552
12597
  return {
12553
12598
  name: "Claude Projects",
@@ -12675,7 +12720,7 @@ var doctorCommand = new Command28("doctor").description("System-Check f\xFCr SHI
12675
12720
  // src/commands/system/upgrade.ts
12676
12721
  import { Command as Command29 } from "commander";
12677
12722
  import { execSync as execSync3, spawn as spawn7 } from "child_process";
12678
- import * as fs12 from "fs";
12723
+ import * as fs13 from "fs";
12679
12724
  import * as path13 from "path";
12680
12725
  import * as os6 from "os";
12681
12726
  import * as crypto from "crypto";
@@ -12689,7 +12734,7 @@ function detectInstallationType() {
12689
12734
  const execName = path13.basename(execPath).toLowerCase();
12690
12735
  if (execName === "shiva" || execName === "shiva.exe") {
12691
12736
  const possibleNodeModules = path13.resolve(path13.dirname(execPath), "../node_modules");
12692
- if (!fs12.existsSync(possibleNodeModules)) {
12737
+ if (!fs13.existsSync(possibleNodeModules)) {
12693
12738
  return "native";
12694
12739
  }
12695
12740
  }
@@ -12729,8 +12774,8 @@ function getCurrentVersion() {
12729
12774
  ];
12730
12775
  for (const pkgPath of possiblePaths) {
12731
12776
  try {
12732
- if (fs12.existsSync(pkgPath)) {
12733
- const packageJson = JSON.parse(fs12.readFileSync(pkgPath, "utf-8"));
12777
+ if (fs13.existsSync(pkgPath)) {
12778
+ const packageJson = JSON.parse(fs13.readFileSync(pkgPath, "utf-8"));
12734
12779
  if (packageJson.name === PACKAGE_NAME && packageJson.version) {
12735
12780
  return packageJson.version;
12736
12781
  }
@@ -12846,7 +12891,7 @@ async function downloadFile(url, dest) {
12846
12891
  throw new Error(`Download failed: ${response.status} ${response.statusText}`);
12847
12892
  }
12848
12893
  const buffer = await response.arrayBuffer();
12849
- fs12.writeFileSync(dest, Buffer.from(buffer));
12894
+ fs13.writeFileSync(dest, Buffer.from(buffer));
12850
12895
  }
12851
12896
  async function verifyChecksum(filePath, checksumUrl) {
12852
12897
  try {
@@ -12856,7 +12901,7 @@ async function verifyChecksum(filePath, checksumUrl) {
12856
12901
  return true;
12857
12902
  }
12858
12903
  const expectedHash = (await response.text()).trim().split(" ")[0].toLowerCase();
12859
- const fileBuffer = fs12.readFileSync(filePath);
12904
+ const fileBuffer = fs13.readFileSync(filePath);
12860
12905
  const actualHash = crypto.createHash("sha256").update(fileBuffer).digest("hex").toLowerCase();
12861
12906
  return expectedHash === actualHash;
12862
12907
  } catch {
@@ -12885,16 +12930,16 @@ async function updateNativeBinary(targetVersion) {
12885
12930
  const checksumValid = await verifyChecksum(tempBinary, checksumUrl);
12886
12931
  if (!checksumValid) {
12887
12932
  log.error("Checksum stimmt nicht \xFCberein! Update abgebrochen.");
12888
- fs12.unlinkSync(tempBinary);
12933
+ fs13.unlinkSync(tempBinary);
12889
12934
  return false;
12890
12935
  }
12891
12936
  log.success(" Checksum OK");
12892
12937
  if (platformInfo.platform !== "windows") {
12893
- fs12.chmodSync(tempBinary, 493);
12938
+ fs13.chmodSync(tempBinary, 493);
12894
12939
  }
12895
12940
  log.info("Erstelle Backup...");
12896
- if (fs12.existsSync(currentBinary)) {
12897
- fs12.copyFileSync(currentBinary, backupBinary);
12941
+ if (fs13.existsSync(currentBinary)) {
12942
+ fs13.copyFileSync(currentBinary, backupBinary);
12898
12943
  }
12899
12944
  log.info("Installiere neue Version...");
12900
12945
  if (platformInfo.platform === "windows") {
@@ -12906,30 +12951,30 @@ move /y "${tempBinary}" "${currentBinary}"
12906
12951
  del "${backupBinary}" 2>nul
12907
12952
  del "%~f0"
12908
12953
  `;
12909
- fs12.writeFileSync(updateScript, scriptContent);
12954
+ fs13.writeFileSync(updateScript, scriptContent);
12910
12955
  spawn7("cmd", ["/c", updateScript], { detached: true, stdio: "ignore" }).unref();
12911
12956
  log.success("Update wird nach Beenden angewendet");
12912
12957
  log.info("Bitte starte SHIVA neu.");
12913
12958
  } else {
12914
- fs12.renameSync(tempBinary, currentBinary);
12915
- if (fs12.existsSync(backupBinary)) {
12916
- fs12.unlinkSync(backupBinary);
12959
+ fs13.renameSync(tempBinary, currentBinary);
12960
+ if (fs13.existsSync(backupBinary)) {
12961
+ fs13.unlinkSync(backupBinary);
12917
12962
  }
12918
12963
  }
12919
12964
  return true;
12920
12965
  } catch (error) {
12921
12966
  log.error(`Update fehlgeschlagen: ${error instanceof Error ? error.message : String(error)}`);
12922
- if (fs12.existsSync(backupBinary) && fs12.existsSync(currentBinary)) {
12967
+ if (fs13.existsSync(backupBinary) && fs13.existsSync(currentBinary)) {
12923
12968
  try {
12924
- fs12.copyFileSync(backupBinary, currentBinary);
12969
+ fs13.copyFileSync(backupBinary, currentBinary);
12925
12970
  log.info("Backup wiederhergestellt");
12926
12971
  } catch {
12927
12972
  log.warn("Backup konnte nicht wiederhergestellt werden");
12928
12973
  }
12929
12974
  }
12930
- if (fs12.existsSync(tempBinary)) {
12975
+ if (fs13.existsSync(tempBinary)) {
12931
12976
  try {
12932
- fs12.unlinkSync(tempBinary);
12977
+ fs13.unlinkSync(tempBinary);
12933
12978
  } catch {
12934
12979
  }
12935
12980
  }
@@ -13351,7 +13396,7 @@ complete -F _shiva_completions shiva
13351
13396
  `;
13352
13397
  }
13353
13398
  async function installBashCompletion() {
13354
- const fs15 = await import("fs");
13399
+ const fs16 = await import("fs");
13355
13400
  const os9 = await import("os");
13356
13401
  const path15 = await import("path");
13357
13402
  const bashrcPath = path15.join(os9.homedir(), ".bashrc");
@@ -13359,15 +13404,15 @@ async function installBashCompletion() {
13359
13404
  const marker = "# SHIVA Code Bash Completion";
13360
13405
  try {
13361
13406
  let bashrc = "";
13362
- if (fs15.existsSync(bashrcPath)) {
13363
- bashrc = fs15.readFileSync(bashrcPath, "utf-8");
13407
+ if (fs16.existsSync(bashrcPath)) {
13408
+ bashrc = fs16.readFileSync(bashrcPath, "utf-8");
13364
13409
  }
13365
13410
  if (bashrc.includes(marker)) {
13366
13411
  log.warn("Bash completion bereits installiert");
13367
13412
  log.info("Manuell entfernen und neu installieren falls n\xF6tig");
13368
13413
  return;
13369
13414
  }
13370
- fs15.appendFileSync(bashrcPath, "\n" + completionScript);
13415
+ fs16.appendFileSync(bashrcPath, "\n" + completionScript);
13371
13416
  log.success("Bash completion installiert");
13372
13417
  log.info("Ausf\xFChren: source ~/.bashrc");
13373
13418
  } catch (error) {
@@ -13494,7 +13539,7 @@ compdef _shiva shiva
13494
13539
  `;
13495
13540
  }
13496
13541
  async function installZshCompletion() {
13497
- const fs15 = await import("fs");
13542
+ const fs16 = await import("fs");
13498
13543
  const os9 = await import("os");
13499
13544
  const path15 = await import("path");
13500
13545
  const zshrcPath = path15.join(os9.homedir(), ".zshrc");
@@ -13502,15 +13547,15 @@ async function installZshCompletion() {
13502
13547
  const marker = "# SHIVA Code Zsh Completion";
13503
13548
  try {
13504
13549
  let zshrc = "";
13505
- if (fs15.existsSync(zshrcPath)) {
13506
- zshrc = fs15.readFileSync(zshrcPath, "utf-8");
13550
+ if (fs16.existsSync(zshrcPath)) {
13551
+ zshrc = fs16.readFileSync(zshrcPath, "utf-8");
13507
13552
  }
13508
13553
  if (zshrc.includes(marker)) {
13509
13554
  log.warn("Zsh completion bereits installiert");
13510
13555
  log.info("Manuell entfernen und neu installieren falls n\xF6tig");
13511
13556
  return;
13512
13557
  }
13513
- fs15.appendFileSync(zshrcPath, "\n" + completionScript);
13558
+ fs16.appendFileSync(zshrcPath, "\n" + completionScript);
13514
13559
  log.success("Zsh completion installiert");
13515
13560
  log.info("Ausf\xFChren: source ~/.zshrc");
13516
13561
  } catch (error) {
@@ -13599,17 +13644,17 @@ complete -c shiva -n "__fish_seen_subcommand_from stats" -l json -d "JSON Output
13599
13644
  `;
13600
13645
  }
13601
13646
  async function installFishCompletion() {
13602
- const fs15 = await import("fs");
13647
+ const fs16 = await import("fs");
13603
13648
  const os9 = await import("os");
13604
13649
  const path15 = await import("path");
13605
13650
  const fishCompletionsDir = path15.join(os9.homedir(), ".config", "fish", "completions");
13606
13651
  const fishCompletionPath = path15.join(fishCompletionsDir, "shiva.fish");
13607
13652
  const completionScript = generateFishCompletion();
13608
13653
  try {
13609
- if (!fs15.existsSync(fishCompletionsDir)) {
13610
- fs15.mkdirSync(fishCompletionsDir, { recursive: true });
13654
+ if (!fs16.existsSync(fishCompletionsDir)) {
13655
+ fs16.mkdirSync(fishCompletionsDir, { recursive: true });
13611
13656
  }
13612
- fs15.writeFileSync(fishCompletionPath, completionScript);
13657
+ fs16.writeFileSync(fishCompletionPath, completionScript);
13613
13658
  log.success("Fish completion installiert");
13614
13659
  log.info("Wird automatisch beim n\xE4chsten Start geladen");
13615
13660
  } catch (error) {
@@ -14832,7 +14877,7 @@ accountCommand.command("delete").description(t("account.deleteDesc")).option("-f
14832
14877
 
14833
14878
  // src/commands/system/uninstall.ts
14834
14879
  import { Command as Command38 } from "commander";
14835
- import { existsSync as existsSync23, rmSync as rmSync2, readFileSync as readFileSync12, writeFileSync as writeFileSync10 } from "fs";
14880
+ import { existsSync as existsSync23, rmSync as rmSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync10 } from "fs";
14836
14881
  import { homedir as homedir8 } from "os";
14837
14882
  import { join as join14 } from "path";
14838
14883
  import inquirer15 from "inquirer";
@@ -14923,7 +14968,7 @@ var uninstallCommand = new Command38("uninstall").description(t("uninstall.descr
14923
14968
  const spinner = ora23(t("uninstall.removingConfig")).start();
14924
14969
  try {
14925
14970
  if (existsSync23(CONFIG_DIR)) {
14926
- rmSync2(CONFIG_DIR, { recursive: true, force: true });
14971
+ rmSync3(CONFIG_DIR, { recursive: true, force: true });
14927
14972
  }
14928
14973
  spinner.succeed(t("uninstall.configRemoved"));
14929
14974
  } catch (error) {
@@ -15247,7 +15292,7 @@ dockerCommand.action(() => {
15247
15292
 
15248
15293
  // src/commands/advanced/workflow.ts
15249
15294
  import { Command as Command40 } from "commander";
15250
- import * as fs13 from "fs";
15295
+ import * as fs14 from "fs";
15251
15296
  import * as path14 from "path";
15252
15297
  import * as os7 from "os";
15253
15298
  import ora25 from "ora";
@@ -15412,11 +15457,11 @@ function getWorkflowsPath() {
15412
15457
  }
15413
15458
  function loadCustomWorkflows() {
15414
15459
  const filepath = getWorkflowsPath();
15415
- if (!fs13.existsSync(filepath)) {
15460
+ if (!fs14.existsSync(filepath)) {
15416
15461
  return {};
15417
15462
  }
15418
15463
  try {
15419
- const content = fs13.readFileSync(filepath, "utf-8");
15464
+ const content = fs14.readFileSync(filepath, "utf-8");
15420
15465
  return JSON.parse(content);
15421
15466
  } catch {
15422
15467
  return {};
@@ -15425,18 +15470,18 @@ function loadCustomWorkflows() {
15425
15470
  function saveCustomWorkflow(name, workflow) {
15426
15471
  const filepath = getWorkflowsPath();
15427
15472
  const dir = path14.dirname(filepath);
15428
- if (!fs13.existsSync(dir)) {
15429
- fs13.mkdirSync(dir, { recursive: true });
15473
+ if (!fs14.existsSync(dir)) {
15474
+ fs14.mkdirSync(dir, { recursive: true });
15430
15475
  }
15431
15476
  const workflows = loadCustomWorkflows();
15432
15477
  workflows[name] = workflow;
15433
- fs13.writeFileSync(filepath, JSON.stringify(workflows, null, 2));
15478
+ fs14.writeFileSync(filepath, JSON.stringify(workflows, null, 2));
15434
15479
  }
15435
15480
  function deleteCustomWorkflow(name) {
15436
15481
  const filepath = getWorkflowsPath();
15437
15482
  const workflows = loadCustomWorkflows();
15438
15483
  delete workflows[name];
15439
- fs13.writeFileSync(filepath, JSON.stringify(workflows, null, 2));
15484
+ fs14.writeFileSync(filepath, JSON.stringify(workflows, null, 2));
15440
15485
  }
15441
15486
  async function executeStep(step) {
15442
15487
  const spinner = ora25("Ausf\xFChren...").start();
@@ -16191,7 +16236,7 @@ hookCommand.command("scan-session").description("Session nach sensiblen Tokens s
16191
16236
  const { detectTokens: detectTokens2, redactTokens, maskToken: maskToken2 } = await import("./token-detection-K6KCIWAU.js");
16192
16237
  const { api: api2 } = await import("./client-H3JXPT5B.js");
16193
16238
  const { isAuthenticated: isAuthenticated2 } = await import("./config-FGMZONWV.js");
16194
- const { existsSync: existsSync27, readFileSync: readFileSync15, writeFileSync: writeFileSync13, readdirSync: readdirSync6, statSync: statSync7 } = await import("fs");
16239
+ const { existsSync: existsSync27, readFileSync: readFileSync15, writeFileSync: writeFileSync13, readdirSync: readdirSync7, statSync: statSync8 } = await import("fs");
16195
16240
  const { join: join17 } = await import("path");
16196
16241
  const { homedir: homedir12 } = await import("os");
16197
16242
  const quiet = options.quiet;
@@ -16215,16 +16260,16 @@ hookCommand.command("scan-session").description("Session nach sensiblen Tokens s
16215
16260
  } else if (existsSync27(claudeProjectsPath)) {
16216
16261
  const oneHourAgo = Date.now() - 60 * 60 * 1e3;
16217
16262
  try {
16218
- const projects = readdirSync6(claudeProjectsPath);
16263
+ const projects = readdirSync7(claudeProjectsPath);
16219
16264
  for (const project of projects) {
16220
16265
  const projectPath = join17(claudeProjectsPath, project);
16221
- const stat = statSync7(projectPath);
16266
+ const stat = statSync8(projectPath);
16222
16267
  if (!stat.isDirectory()) continue;
16223
- const files = readdirSync6(projectPath);
16268
+ const files = readdirSync7(projectPath);
16224
16269
  for (const file of files) {
16225
16270
  if (!file.endsWith(".jsonl")) continue;
16226
16271
  const filePath = join17(projectPath, file);
16227
- const fileStat = statSync7(filePath);
16272
+ const fileStat = statSync8(filePath);
16228
16273
  if (fileStat.mtime.getTime() > oneHourAgo) {
16229
16274
  sessionFiles.push(filePath);
16230
16275
  }
@@ -16306,7 +16351,7 @@ hookCommand.command("scan-session").description("Session nach sensiblen Tokens s
16306
16351
 
16307
16352
  // src/commands/advanced/package.ts
16308
16353
  import { Command as Command42 } from "commander";
16309
- import * as fs14 from "fs";
16354
+ import * as fs15 from "fs";
16310
16355
  import inquirer17 from "inquirer";
16311
16356
  import ora26 from "ora";
16312
16357
  var packageCommand = new Command42("package").description("Projekt-Gruppen (Packages) verwalten").action(() => {
@@ -16403,7 +16448,7 @@ packageCommand.command("show <name>").description("Package-Details anzeigen").ac
16403
16448
  if (pkg.projects.length > 0) {
16404
16449
  console.log("Projekte:");
16405
16450
  for (const projectPath of pkg.projects) {
16406
- const exists = fs14.existsSync(projectPath);
16451
+ const exists = fs15.existsSync(projectPath);
16407
16452
  const icon = exists ? colors.green("\u2713") : colors.yellow("\u26A0");
16408
16453
  const name2 = getProjectName(projectPath);
16409
16454
  console.log(` ${icon} ${name2}`);
@@ -16658,7 +16703,7 @@ function listPackages() {
16658
16703
  }
16659
16704
  const displayProjects = pkg.projects.slice(0, 3);
16660
16705
  for (const projectPath of displayProjects) {
16661
- const exists = fs14.existsSync(projectPath);
16706
+ const exists = fs15.existsSync(projectPath);
16662
16707
  const icon = exists ? colors.dim("\u2514\u2500") : colors.yellow("\u2514\u2500");
16663
16708
  console.log(` ${icon} ${getProjectName(projectPath)}`);
16664
16709
  }