chat2diff 1.3.0 → 1.3.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to **Chat2Diff** are documented in this file.
4
4
 
5
+ ## [1.3.1] - 2026-11-25
6
+
7
+ ### Added
8
+ * **Opt-In `.gitignore` Support:** Added a **Show .gitignore** toggle (off by default) in the **Project Files** panel so AI agents can access gitignored files and folders (e.g. local docs, plans, or notes) with amber `ignored` badges, while keeping `node_modules`, `.git`, `.chat2diff`, build outputs, secrets (`.env`/keys), and binaries excluded.
9
+
5
10
  ## [1.3.0] - 2026-11-24
6
11
 
7
12
  ### Added
package/dist/cli.js CHANGED
@@ -11,7 +11,7 @@ import open from "open";
11
11
  import { WebSocket, WebSocketServer } from "ws";
12
12
 
13
13
  // src/shared/constants.ts
14
- var APP_VERSION = "1.3.0";
14
+ var APP_VERSION = "1.3.1";
15
15
  var DEV_SESSION_TOKEN = "chat2diff-dev-token";
16
16
  var DEFAULT_PORT = 4310;
17
17
  var MAX_FILE_SIZE_BYTES = 250 * 1024;
@@ -566,13 +566,15 @@ function collectFilesViaGit(repoPath) {
566
566
  return null;
567
567
  }
568
568
  }
569
- function collectFilesViaFs(repoPath) {
569
+ function collectFilesViaFs(repoPath, includeGitignored = false) {
570
570
  const ig = ignore();
571
- const gitignorePath = path5.join(repoPath, ".gitignore");
572
- if (fs4.existsSync(gitignorePath)) {
573
- try {
574
- ig.add(fs4.readFileSync(gitignorePath, "utf8"));
575
- } catch {
571
+ if (!includeGitignored) {
572
+ const gitignorePath = path5.join(repoPath, ".gitignore");
573
+ if (fs4.existsSync(gitignorePath)) {
574
+ try {
575
+ ig.add(fs4.readFileSync(gitignorePath, "utf8"));
576
+ } catch {
577
+ }
576
578
  }
577
579
  }
578
580
  const found = [];
@@ -586,10 +588,11 @@ function collectFilesViaFs(repoPath) {
586
588
  for (const entry of entries) {
587
589
  const relPosix = relPrefix ? `${relPrefix}/${entry.name}` : entry.name;
588
590
  if (entry.isDirectory()) {
589
- if (SKIP_DIRECTORIES.has(entry.name) || ig.ignores(`${relPosix}/`)) continue;
591
+ if (SKIP_DIRECTORIES.has(entry.name)) continue;
592
+ if (!includeGitignored && ig.ignores(`${relPosix}/`)) continue;
590
593
  walk(path5.join(currentDir, entry.name), relPosix);
591
594
  } else if (entry.isFile()) {
592
- if (ig.ignores(relPosix)) continue;
595
+ if (!includeGitignored && ig.ignores(relPosix)) continue;
593
596
  found.push(relPosix);
594
597
  }
595
598
  }
@@ -622,17 +625,22 @@ function collectChangedFilesViaGit(repoPath) {
622
625
  return [];
623
626
  }
624
627
  }
625
- function collectRepoFilePaths(repoPath) {
628
+ function collectRepoFilePaths(repoPath, options) {
626
629
  const resolvedRoot = path5.resolve(repoPath);
627
- const rawPaths = collectFilesViaGit(resolvedRoot) ?? collectFilesViaFs(resolvedRoot);
630
+ const normalPaths = collectFilesViaGit(resolvedRoot) ?? collectFilesViaFs(resolvedRoot, false);
631
+ const rawPaths = options?.includeGitignored ? Array.from(/* @__PURE__ */ new Set([...normalPaths, ...collectFilesViaFs(resolvedRoot, true)])) : normalPaths;
628
632
  return rawPaths.filter((relPosix) => !relPosix.split("/").some((p) => SKIP_DIRECTORIES.has(p))).sort();
629
633
  }
630
- function scanRepositoryTree(repoPath) {
634
+ function scanRepositoryTree(repoPath, options) {
635
+ const includeGitignored = Boolean(options?.includeGitignored);
631
636
  const resolvedRoot = path5.resolve(repoPath);
632
- const rawPaths = collectFilesViaGit(resolvedRoot) ?? collectFilesViaFs(resolvedRoot);
637
+ const normalPaths = collectFilesViaGit(resolvedRoot) ?? collectFilesViaFs(resolvedRoot, false);
638
+ const normalSet = new Set(normalPaths);
639
+ const rawPaths = includeGitignored ? Array.from(/* @__PURE__ */ new Set([...normalPaths, ...collectFilesViaFs(resolvedRoot, true)])) : normalPaths;
633
640
  const validFileSet = /* @__PURE__ */ new Set();
634
641
  let skippedSecretsCount = 0;
635
642
  let skippedBinaryCount = 0;
643
+ let gitignoredCount = 0;
636
644
  let totalFiles = 0;
637
645
  const rootChildren = [];
638
646
  const dirMap = /* @__PURE__ */ new Map();
@@ -680,6 +688,10 @@ function scanRepositoryTree(repoPath) {
680
688
  skippedBinaryCount += 1;
681
689
  continue;
682
690
  }
691
+ const isGitignored = includeGitignored && !normalSet.has(relPosix);
692
+ if (isGitignored) {
693
+ gitignoredCount += 1;
694
+ }
683
695
  const estimatedTokens = Math.max(1, Math.ceil(stat.size / 4));
684
696
  const fileNode = {
685
697
  path: relPosix,
@@ -687,7 +699,8 @@ function scanRepositoryTree(repoPath) {
687
699
  type: "file",
688
700
  sizeBytes: stat.size,
689
701
  estimatedTokens,
690
- fileCount: 1
702
+ fileCount: 1,
703
+ ...isGitignored ? { gitignored: true } : {}
691
704
  };
692
705
  totalFiles += 1;
693
706
  validFileSet.add(relPosix);
@@ -705,16 +718,23 @@ function scanRepositoryTree(repoPath) {
705
718
  });
706
719
  let totalT = 0;
707
720
  let totalF = 0;
721
+ let allGitignored = nodes.length > 0;
708
722
  for (const node of nodes) {
709
723
  if (node.type === "directory" && node.children) {
710
724
  const sub = finalizeNode(node.children);
711
725
  node.estimatedTokens = sub.tokens;
712
726
  node.fileCount = sub.files;
727
+ if (sub.allGitignored) {
728
+ node.gitignored = true;
729
+ }
730
+ }
731
+ if (!node.gitignored) {
732
+ allGitignored = false;
713
733
  }
714
734
  totalT += node.estimatedTokens;
715
735
  totalF += node.fileCount;
716
736
  }
717
- return { tokens: totalT, files: totalF };
737
+ return { tokens: totalT, files: totalF, allGitignored };
718
738
  }
719
739
  finalizeNode(rootChildren);
720
740
  const changedPaths = collectChangedFilesViaGit(resolvedRoot).filter(
@@ -725,6 +745,8 @@ function scanRepositoryTree(repoPath) {
725
745
  totalFiles,
726
746
  skippedSecretsCount,
727
747
  skippedBinaryCount,
748
+ gitignoredCount,
749
+ includeGitignored,
728
750
  changedPaths,
729
751
  tree: rootChildren
730
752
  };
@@ -1657,7 +1679,7 @@ function hasDetectablePatch(rawText) {
1657
1679
  if (text.includes("@@") && looksLikeUnifiedDiff(text)) return true;
1658
1680
  return false;
1659
1681
  }
1660
- function parseAndPreviewPatch(repoPath, rawText, preferredFormat = "search_replace") {
1682
+ function parseAndPreviewPatch(repoPath, rawText, preferredFormat = "search_replace", options) {
1661
1683
  pruneExpiredSessions();
1662
1684
  const srOps = parseSearchReplaceOps(rawText);
1663
1685
  const unifiedText = extractUnifiedDiffText(rawText);
@@ -1670,7 +1692,9 @@ function parseAndPreviewPatch(repoPath, rawText, preferredFormat = "search_repla
1670
1692
  const files = [];
1671
1693
  const plans = /* @__PURE__ */ new Map();
1672
1694
  const handledPaths = /* @__PURE__ */ new Set();
1673
- const repoFiles = collectRepoFilePaths(repoPath);
1695
+ const repoFiles = collectRepoFilePaths(repoPath, {
1696
+ includeGitignored: options?.includeGitignored
1697
+ });
1674
1698
  const srGrouped = /* @__PURE__ */ new Map();
1675
1699
  for (const op of srOps) {
1676
1700
  const resolvedPath = op.kind === "create" ? normalizeRepoRelPath(op.filePath) : resolveSmartRepoFilePath(repoPath, op.filePath, repoFiles);
@@ -2679,7 +2703,8 @@ var PackSchema = z.object({
2679
2703
  message: "Select at least one file when starting a new chat."
2680
2704
  });
2681
2705
  var ParseSchema = z.object({
2682
- rawText: z.string().min(10).max(5e6)
2706
+ rawText: z.string().min(10).max(5e6),
2707
+ includeGitignored: z.boolean().optional()
2683
2708
  });
2684
2709
  var ApplySchema = z.object({
2685
2710
  parseId: z.string().min(1),
@@ -2767,7 +2792,8 @@ function createApp(state) {
2767
2792
  });
2768
2793
  app.get("/api/v1/files/tree", (c) => {
2769
2794
  try {
2770
- return c.json({ data: scanRepositoryTree(state.repoPath) });
2795
+ const includeGitignored = c.req.query("includeGitignored") === "true";
2796
+ return c.json({ data: scanRepositoryTree(state.repoPath, { includeGitignored }) });
2771
2797
  } catch (err) {
2772
2798
  return c.json(
2773
2799
  { error: "SCAN_FAILED", message: err instanceof Error ? err.message : "Failed to scan folder." },
@@ -2824,7 +2850,9 @@ function createApp(state) {
2824
2850
  return c.json({ error: "VALIDATION_ERROR", message: "Paste an AI response containing code changes." }, 400);
2825
2851
  }
2826
2852
  const config = loadConfig();
2827
- const result = parseAndPreviewPatch(state.repoPath, parsed.data.rawText, config.defaultPatchFormat);
2853
+ const result = parseAndPreviewPatch(state.repoPath, parsed.data.rawText, config.defaultPatchFormat, {
2854
+ includeGitignored: parsed.data.includeGitignored
2855
+ });
2828
2856
  if (!result) {
2829
2857
  return c.json(
2830
2858
  {