refactor(cleanup): v0.5.0 Collector 제거 + dead code 정리 + HttpBridgeContext 버그 수정
- DELETE collector.py (523줄) - main.py: BOT_MODE=remote 분기 제거 - gateway.py: Collector REST 6개 endpoint 제거 (311→168줄) - bridge.py: RemoteTransport 제거 (480→270줄) - config.py: REMOTE_BRIDGE_URL 제거 - extension.ts: dead code 4개 + stale module vars 제거 - step-probe.ts: getStepProbeContext() 추가, autoApproveEnabled 제거 - FIX: HttpBridgeContext stale primitive (getter 패턴으로 수정) - ADD: extension.log rotation (10MB→2MB tail) - docs: architecture.md, tech-stack.md, known-issues.md 업데이트
This commit is contained in:
@@ -67,6 +67,15 @@ function logToFile(msg) {
|
||||
if (!bridgePath)
|
||||
return;
|
||||
const logFile = path.join(bridgePath, 'extension.log');
|
||||
// Log rotation: truncate when >10MB, keep last 2MB
|
||||
try {
|
||||
const stat = fs.statSync(logFile);
|
||||
if (stat.size > 10 * 1024 * 1024) {
|
||||
const content = fs.readFileSync(logFile, 'utf-8');
|
||||
fs.writeFileSync(logFile, content.slice(-2 * 1024 * 1024), 'utf-8');
|
||||
}
|
||||
}
|
||||
catch { /* file doesn't exist yet */ }
|
||||
fs.appendFileSync(logFile, line + '\n', 'utf-8');
|
||||
}
|
||||
catch (e) {
|
||||
@@ -84,15 +93,6 @@ let isActive = false;
|
||||
let autoApproveEnabled = false; // toggled via !auto from Discord
|
||||
let watcher = null;
|
||||
let wsBridge = null; // WebSocket Hub connection
|
||||
const sentPendingIds = new Set();
|
||||
// Memory-based dedup: tracks recently created pending step_indexes to prevent
|
||||
// regeneration after pending file deletion (by Collector/Bot response cycle).
|
||||
// Map<string, number> = `${conversationId}:${stepIndex}` → creation timestamp
|
||||
const recentPendingSteps = new Map();
|
||||
const PENDING_MEMORY_TTL_MS = 60_000; // 60 seconds memory retention
|
||||
// In-memory cache for diff_review metadata (survives pending file deletion by Collector).
|
||||
// Map<request_id, { edit_step_indices, modified_files }>
|
||||
const diffReviewMetadata = new Map();
|
||||
// ─── Project Detection ───
|
||||
function detectProjectName() {
|
||||
const config = vscode.workspace.getConfiguration('gravityBridge');
|
||||
@@ -374,11 +374,6 @@ async function fixLSConnection() {
|
||||
}
|
||||
// ─── Approval Observer + Product.json Checksums extracted to ./html-patcher.ts ───
|
||||
// ─── HTTP Bridge Server extracted to ./http-bridge.ts ───
|
||||
// Shared state for HTTP bridge context (module-level, referenced by BridgeContext too)
|
||||
let sessionStalled = false;
|
||||
let lastPendingStepIndex = -1;
|
||||
let stallProbed = false;
|
||||
let sawRunningAfterPending = true;
|
||||
// ─── Step Probe, Response Watcher, Approval Strategies → extracted to ./step-probe.ts ───
|
||||
async function activate(context) {
|
||||
console.log('Gravity Bridge: activating...');
|
||||
@@ -503,12 +498,11 @@ async function activate(context) {
|
||||
projectName,
|
||||
sdk,
|
||||
wsBridge,
|
||||
autoApproveEnabled,
|
||||
activeSessionId,
|
||||
sessionStalled,
|
||||
lastPendingStepIndex,
|
||||
stallProbed,
|
||||
sawRunningAfterPending,
|
||||
sessionStalled: false,
|
||||
lastPendingStepIndex: -1,
|
||||
stallProbed: false,
|
||||
sawRunningAfterPending: true,
|
||||
setClickTrigger: (action) => {
|
||||
const { setClickTrigger: setTrigger } = require('./http-bridge');
|
||||
setTrigger(action);
|
||||
@@ -520,10 +514,12 @@ async function activate(context) {
|
||||
writeChatSnapshot,
|
||||
writeChatSnapshotWithFiles,
|
||||
});
|
||||
// Start HTTP bridge, then setup observer
|
||||
// Start HTTP bridge with live step-probe state (prevents stale primitive bug)
|
||||
const httpBridgeCtx = {
|
||||
bridgePath, projectName, activeSessionId, wsBridge,
|
||||
sessionStalled, lastPendingStepIndex, logToFile,
|
||||
bridgePath, projectName, wsBridge, logToFile,
|
||||
get activeSessionId() { return (0, step_probe_1.getStepProbeContext)().activeSessionId; },
|
||||
get sessionStalled() { return (0, step_probe_1.getStepProbeContext)().sessionStalled; },
|
||||
get lastPendingStepIndex() { return (0, step_probe_1.getStepProbeContext)().lastPendingStepIndex; },
|
||||
};
|
||||
const bridgePort = await (0, http_bridge_1.startHttpBridge)(httpBridgeCtx, sdk);
|
||||
if (bridgePort) {
|
||||
|
||||
Reference in New Issue
Block a user