Skip to content

Commit b417ee3

Browse files
aksOpsclaude
andcommitted
refactor: unify data directory to .code-iq/ and --no-cache deletes DB
Directory consolidation: - .code-intelligence → .code-iq/cache (H2 analysis cache) - .osscodeiq/graph.db → .code-iq/graph/graph.db (Neo4j) - .osscodeiq.yml → .code-iq.yml (project config, old name still supported) - All data now under single .code-iq/ directory --no-cache behavior: - Now deletes the entire .code-iq/cache directory before re-indexing instead of just skipping cache reads (ensures fresh H2 schema) Updated 12 test files + 8 source files for new paths. Backward compat: .osscodeiq.yml still loaded as fallback config name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d3c0452 commit b417ee3

20 files changed

Lines changed: 88 additions & 74 deletions

src/main/java/io/github/randomcodespace/iq/CodeIqApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static void main(String[] args) {
9090
if (graphOverride != null) {
9191
graphDbPath = java.nio.file.Path.of(graphOverride).toAbsolutePath().normalize();
9292
} else {
93-
graphDbPath = root.resolve(".osscodeiq/graph.db");
93+
graphDbPath = root.resolve(".code-iq/graph/graph.db");
9494
}
9595

9696
// Point Neo4j config to the graph path (enriched or new empty db).

src/main/java/io/github/randomcodespace/iq/analyzer/FileDiscovery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class FileDiscovery {
4747
// Go / Rust
4848
"vendor",
4949
// Code-IQ own dirs
50-
".code-intelligence", ".osscodeiq"
50+
".code-iq", ".code-intelligence", ".osscodeiq"
5151
);
5252

5353
/** Files to always skip (lock files, generated). */

src/main/java/io/github/randomcodespace/iq/cli/BundleCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public Integer call() {
105105
// Resolve paths
106106
Path neo4jDir = graphDirOption != null
107107
? graphDirOption.toAbsolutePath().normalize()
108-
: root.resolve(".osscodeiq/graph.db");
108+
: root.resolve(".code-iq/graph/graph.db");
109109
Path h2Dir = root.resolve(config.getCacheDir());
110110

111111
// Validate Neo4j graph exists

src/main/java/io/github/randomcodespace/iq/cli/IndexCommand.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,22 @@ public Integer call() {
7878
NumberFormat nf = NumberFormat.getIntegerInstance(Locale.US);
7979
int cores = parallelism != null ? parallelism : Runtime.getRuntime().availableProcessors();
8080

81-
// --no-cache overrides --incremental
81+
// --no-cache overrides --incremental and deletes existing cache DB
8282
boolean useIncremental = incremental && !noCache;
83+
if (noCache) {
84+
Path cacheDir = root.resolve(config.getCacheDir());
85+
if (java.nio.file.Files.exists(cacheDir)) {
86+
try {
87+
try (var walk = java.nio.file.Files.walk(cacheDir)) {
88+
walk.sorted(java.util.Comparator.reverseOrder())
89+
.forEach(p -> { try { java.nio.file.Files.deleteIfExists(p); } catch (Exception ignored) {} });
90+
}
91+
CliOutput.info(" Deleted existing cache at " + cacheDir);
92+
} catch (Exception e) {
93+
CliOutput.warn(" Could not delete cache: " + e.getMessage());
94+
}
95+
}
96+
}
8397

8498
CliOutput.step("[*]", "Indexing " + root + " ...");
8599
CliOutput.info(" (batch size: " + effectiveBatchSize + " files, "
@@ -112,7 +126,7 @@ public Integer call() {
112126
});
113127

114128
CliOutput.printResultSummary(result, nf);
115-
CliOutput.info(" Store: H2 (.code-intelligence/analysis-cache)");
129+
CliOutput.info(" Store: H2 (.code-iq/cache/analysis-cache)");
116130

117131
System.out.println();
118132
CliOutput.info(" Next step: code-iq enrich " + root);

src/main/java/io/github/randomcodespace/iq/cli/PluginsCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ public Integer call() {
344344
private static final Set<String> SKIP_DIRS = Set.of(
345345
"node_modules", ".git", "build", "target", "dist",
346346
"__pycache__", "venv", ".venv", ".gradle",
347-
".idea", ".vscode", ".code-intelligence");
347+
".idea", ".vscode", ".code-iq", ".code-intelligence");
348348

349349
@Override
350350
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {

src/main/java/io/github/randomcodespace/iq/config/CodeIqConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public class CodeIqConfig {
2020
/** Root path of the codebase to analyze. */
2121
private String rootPath = ".";
2222

23-
/** Cache directory name (legacy name kept for backward compatibility). */
24-
private String cacheDir = ".code-intelligence";
23+
/** Cache directory relative to repo root. */
24+
private String cacheDir = ".code-iq/cache";
2525

2626
/** Maximum traversal depth for graph queries. */
2727
private int maxDepth = 10;
@@ -45,7 +45,7 @@ public class CodeIqConfig {
4545
private int maxSnippetLines = 50;
4646

4747
public static class Graph {
48-
private String path = ".osscodeiq/graph.db";
48+
private String path = ".code-iq/graph/graph.db";
4949

5050
public String getPath() { return path; }
5151
public void setPath(String path) { this.path = path; }

src/main/java/io/github/randomcodespace/iq/config/ProjectConfigLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public final class ProjectConfigLoader {
2424

2525
private static final Logger log = LoggerFactory.getLogger(ProjectConfigLoader.class);
26-
private static final String[] CONFIG_FILE_NAMES = {".osscodeiq.yml", ".osscodeiq.yaml"};
26+
private static final String[] CONFIG_FILE_NAMES = {".code-iq.yml", ".code-iq.yaml", ".osscodeiq.yml", ".osscodeiq.yaml"};
2727

2828
private ProjectConfigLoader() {
2929
// utility class

src/main/resources/application.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ management:
2424

2525
codeiq:
2626
root-path: "."
27-
cache-dir: ".code-intelligence"
27+
cache-dir: ".code-iq/cache"
2828
graph:
29-
path: ".osscodeiq/graph.db"
29+
path: ".code-iq/graph/graph.db"
3030
max-depth: 10
3131
max-radius: 10
3232
batch-size: 500

src/test/java/io/github/randomcodespace/iq/analyzer/BatchedStreamingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void batchedIndexWritesToH2() throws IOException {
8989
assertEquals(0, result.edgeCount());
9090

9191
// Verify H2 has data
92-
Path cachePath = tempDir.resolve(".code-intelligence").resolve("analysis-cache.db");
92+
Path cachePath = tempDir.resolve(".code-iq/cache").resolve("analysis-cache.db");
9393
try (var cache = new AnalysisCache(cachePath)) {
9494
long nodeCount = cache.getNodeCount();
9595
assertEquals(10, nodeCount, "H2 should have 10 nodes");

src/test/java/io/github/randomcodespace/iq/analyzer/FileDiscoveryTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,12 @@ void skipsOversizedConfigFiles() throws IOException {
215215

216216
@Test
217217
void excludesCodeIqOwnDirs() throws IOException {
218-
Path codeIntelDir = tempDir.resolve(".code-intelligence");
219-
Path osscodeiqDir = tempDir.resolve(".osscodeiq");
220-
Files.createDirectories(codeIntelDir);
221-
Files.createDirectories(osscodeiqDir);
222-
Files.writeString(codeIntelDir.resolve("cache.java"), "class Cache {}");
223-
Files.writeString(osscodeiqDir.resolve("meta.java"), "class Meta {}");
218+
Path codeIqDir = tempDir.resolve(".code-iq");
219+
Files.createDirectories(codeIqDir);
220+
Files.writeString(codeIqDir.resolve("cache.java"), "class Cache {}");
221+
Path codeIqCacheDir = tempDir.resolve(".code-iq/cache");
222+
Files.createDirectories(codeIqCacheDir);
223+
Files.writeString(codeIqCacheDir.resolve("meta.java"), "class Meta {}");
224224
Files.writeString(tempDir.resolve("src.java"), "class Src {}");
225225

226226
List<DiscoveredFile> files = discovery.discover(tempDir);

0 commit comments

Comments
 (0)