Skip to content

Commit 69e7e62

Browse files
awaliuddinclaude
andcommitted
refactor: Decompose 6 mega-files into 13 focused modules, remove legacy Logger
Optimization sweep executing all 5 recommendations from /frg-optimize: 1. Decompose large files (>800 lines each): - init-service.ts: 865→425 lines (extract types, templates, detection) - diagnostics.ts: 852→226 lines (extract tests, formatters) - vision-service.ts: 825→567 lines (extract parsers, formatters) - automation-service.ts: 824→612 lines (extract rules, safety) - vision.ts: 812→478 lines (extract parser, serializer) - state.ts: 749→695 lines (extract context-graph) 2. Remove legacy Logger class from utils.ts, migrate sole consumer (forge.ts) to proper winston-based getLogger() from utils/logger.ts 3. Upgrade concurrently 8→9 (safe dev-tool upgrade; express 5, eslint 9+, tailwind v4 deferred as each requires dedicated migration) 4. Minor dep patches via npm update (12 packages) All backward-compatible — existing imports still work via re-exports. Verified: tsc clean, 4105 tests passing, server smoke test OK. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent df590fa commit 69e7e62

26 files changed

Lines changed: 3117 additions & 2729 deletions

package-lock.json

Lines changed: 648 additions & 590 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"autoprefixer": "^10.4.23",
9494
"class-variance-authority": "^0.7.1",
9595
"clsx": "^2.1.1",
96-
"concurrently": "^8.2.2",
96+
"concurrently": "^9.2.1",
9797
"cors": "^2.8.5",
9898
"express": "^4.19.2",
9999
"framer-motion": "^12.31.0",

src/core/state.ts

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
import { CanonicalVision } from "../types/vision";
2626
import { CheckpointManager, TaskCheckpoint } from "./checkpoint-manager";
2727
import { Result, Ok, Err } from "../utils/result";
28+
import { buildContextGraph } from "./state/context-graph";
2829

2930
const logger = new Logger("StateManager");
3031

@@ -293,62 +294,7 @@ export class StateManager extends EventEmitter {
293294
throw new Error("No state available");
294295
}
295296

296-
const nodes: ContextNode[] = [];
297-
const edges: ContextEdge[] = [];
298-
299-
// Add vision as root node
300-
nodes.push({
301-
id: "vision",
302-
type: "vision",
303-
title: "Canonical Vision",
304-
data: this.currentState.vision,
305-
});
306-
307-
// Add goals
308-
for (const goal of this.currentState.vision.strategicGoals) {
309-
nodes.push({
310-
id: `goal-${goal.id}`,
311-
type: "goal",
312-
title: goal.title,
313-
data: goal,
314-
});
315-
316-
edges.push({
317-
from: "vision",
318-
to: `goal-${goal.id}`,
319-
type: "implements",
320-
});
321-
}
322-
323-
// Add tasks
324-
for (const task of this.currentState.currentTasks) {
325-
nodes.push({
326-
id: `task-${task.id}`,
327-
type: "task",
328-
title: task.title,
329-
data: task,
330-
});
331-
332-
// Link tasks to goals (simplified)
333-
if (this.currentState.vision.strategicGoals.length > 0) {
334-
edges.push({
335-
from: `goal-${this.currentState.vision.strategicGoals[0].id}`,
336-
to: `task-${task.id}`,
337-
type: "implements",
338-
});
339-
}
340-
341-
// Add task dependencies
342-
for (const depId of task.dependencies) {
343-
edges.push({
344-
from: `task-${depId}`,
345-
to: `task-${task.id}`,
346-
type: "depends-on",
347-
});
348-
}
349-
}
350-
351-
this.contextGraph = { nodes, edges };
297+
this.contextGraph = await buildContextGraph(this.currentState);
352298

353299
// Save graph
354300
await fs.writeFile(
@@ -358,7 +304,7 @@ export class StateManager extends EventEmitter {
358304
);
359305

360306
logger.info(
361-
`Context graph built with ${nodes.length} nodes and ${edges.length} edges`,
307+
`Context graph built with ${this.contextGraph.nodes.length} nodes and ${this.contextGraph.edges.length} edges`,
362308
);
363309

364310
return this.contextGraph;

src/core/state/context-graph.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* Context Graph Builder
3+
* Builds the context graph from system state
4+
*/
5+
6+
import {
7+
SystemState,
8+
ContextGraph,
9+
ContextNode,
10+
ContextEdge,
11+
} from "../../types/state";
12+
13+
/**
14+
* Build context graph from system state
15+
*/
16+
export async function buildContextGraph(
17+
state: SystemState,
18+
): Promise<ContextGraph> {
19+
const nodes: ContextNode[] = [];
20+
const edges: ContextEdge[] = [];
21+
22+
// Add vision as root node
23+
nodes.push({
24+
id: "vision",
25+
type: "vision",
26+
title: "Canonical Vision",
27+
data: state.vision,
28+
});
29+
30+
// Add goals
31+
for (const goal of state.vision.strategicGoals) {
32+
nodes.push({
33+
id: `goal-${goal.id}`,
34+
type: "goal",
35+
title: goal.title,
36+
data: goal,
37+
});
38+
39+
edges.push({
40+
from: "vision",
41+
to: `goal-${goal.id}`,
42+
type: "implements",
43+
});
44+
}
45+
46+
// Add tasks
47+
for (const task of state.currentTasks) {
48+
nodes.push({
49+
id: `task-${task.id}`,
50+
type: "task",
51+
title: task.title,
52+
data: task,
53+
});
54+
55+
// Link tasks to goals (simplified)
56+
if (state.vision.strategicGoals.length > 0) {
57+
edges.push({
58+
from: `goal-${state.vision.strategicGoals[0].id}`,
59+
to: `task-${task.id}`,
60+
type: "implements",
61+
});
62+
}
63+
64+
// Add task dependencies
65+
for (const depId of task.dependencies) {
66+
edges.push({
67+
from: `task-${depId}`,
68+
to: `task-${task.id}`,
69+
type: "depends-on",
70+
});
71+
}
72+
}
73+
74+
return { nodes, edges };
75+
}

0 commit comments

Comments
 (0)