Skip to content

Commit 7643757

Browse files
aksOpsclaude
andcommitted
Add serve E2E (H2-backed REST), multi-repo --graph flag, fix TS detector parity
Serve command now works end-to-end: analyze -> serve -> REST API returns data. REST endpoints read from H2 cache directly (no Neo4j needed for serve), avoiding the 4GB+ heap requirement of Neo4j embedded. Neo4j remains available for enrich workflow and graph traversal queries. Multi-repo support: --graph and --service-name flags on analyze/index commands allow scanning multiple repos into a shared H2 cache with service name tagging. Also fixes: TypeScript structures detector ANTLR/regex parity (picks richer result), HazelcastConfig bean name collision, FullAnalysisIntegrationTest List.of() type inference with 90+ detector subtypes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f95bc54 commit 7643757

15 files changed

Lines changed: 386 additions & 13 deletions

File tree

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ public static void main(String[] args) {
5959

6060
if (isServe) {
6161
app.setAdditionalProfiles("serving");
62+
63+
// Extract --port flag for server port
64+
String portStr = extractFlag(args, "--port");
65+
if (portStr == null) portStr = extractFlag(args, "-p");
66+
if (portStr != null) {
67+
System.setProperty("server.port", portStr);
68+
}
6269
} else if (isIndex) {
6370
app.setAdditionalProfiles("indexing");
6471
// Index command: no web server, no Neo4j
@@ -75,4 +82,55 @@ public static void main(String[] args) {
7582

7683
System.exit(SpringApplication.exit(app.run(args)));
7784
}
85+
86+
/**
87+
* Extract the value of a named flag from the args array.
88+
* Supports both "--flag value" and "--flag=value" forms.
89+
*/
90+
private static String extractFlag(String[] args, String flagName) {
91+
for (int i = 0; i < args.length; i++) {
92+
if (args[i].equals(flagName) && i + 1 < args.length) {
93+
return args[i + 1];
94+
}
95+
if (args[i].startsWith(flagName + "=")) {
96+
return args[i].substring(flagName.length() + 1);
97+
}
98+
}
99+
return null;
100+
}
101+
102+
/**
103+
* Extract the first positional argument after the command name.
104+
* Skips flags (--name value pairs) to find positional args.
105+
*/
106+
private static String extractPositionalArg(String[] args, String command) {
107+
boolean foundCommand = false;
108+
boolean skipNext = false;
109+
for (String arg : args) {
110+
if (skipNext) {
111+
skipNext = false;
112+
continue;
113+
}
114+
if (!foundCommand && arg.equalsIgnoreCase(command)) {
115+
foundCommand = true;
116+
continue;
117+
}
118+
if (foundCommand) {
119+
// Skip --flag value pairs
120+
if (arg.startsWith("--") && !arg.contains("=")) {
121+
skipNext = true;
122+
continue;
123+
}
124+
if (arg.startsWith("-") && arg.length() == 2) {
125+
skipNext = true; // short flag like -p 8080
126+
continue;
127+
}
128+
if (arg.startsWith("-")) {
129+
continue; // --flag=value or -flag
130+
}
131+
return arg;
132+
}
133+
}
134+
return null;
135+
}
78136
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,14 @@ private AnalysisResult runWithCache(Path root, Integer parallelism, AnalysisCach
295295
List<CodeNode> allNodes = builder.getNodes();
296296
layerClassifier.classify(allNodes);
297297

298+
// 5b. Tag nodes with service name if configured (multi-repo mode)
299+
String serviceName = config.getServiceName();
300+
if (serviceName != null && !serviceName.isBlank()) {
301+
for (CodeNode node : allNodes) {
302+
node.getProperties().put("service", serviceName);
303+
}
304+
}
305+
298306
// 6. Compute node breakdown
299307
Map<String, Integer> nodeBreakdown = new HashMap<>();
300308
for (CodeNode node : allNodes) {
@@ -538,6 +546,13 @@ private AnalysisResult runBatchedWithCache(Path root, Integer parallelism, int b
538546
batchNodes.addAll(result.nodes());
539547
batchEdges.addAll(result.edges());
540548
}
549+
// Tag nodes with service name if configured (multi-repo mode)
550+
String svcName = config.getServiceName();
551+
if (svcName != null && !svcName.isBlank()) {
552+
for (CodeNode node : result.nodes()) {
553+
node.getProperties().put("service", svcName);
554+
}
555+
}
541556
// Track breakdowns
542557
for (CodeNode node : result.nodes()) {
543558
nodeBreakdown.merge(node.getKind().getValue(), 1, Integer::sum);

src/main/java/io/github/randomcodespace/iq/api/FlowController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
@RestController
2424
@RequestMapping("/api/flow")
2525
@Profile("serving")
26+
@org.springframework.boot.autoconfigure.condition.ConditionalOnProperty(name = "codeiq.neo4j.enabled", havingValue = "true", matchIfMissing = true)
2627
public class FlowController {
2728

2829
private final FlowEngine flowEngine;

0 commit comments

Comments
 (0)