MCPcopy
hub / github.com/claude-code-best/claude-code / getInitialState

Function getInitialState

src/bootstrap/state.ts:255–420  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

253
254// ALSO HERE - THINK THRICE BEFORE MODIFYING
255function getInitialState(): State {
256 // Resolve symlinks in cwd to match behavior of shell.ts setCwd
257 // This ensures consistency with how paths are sanitized for session storage
258 let resolvedCwd = ''
259 if (
260 typeof process !== 'undefined' &&
261 typeof process.cwd === 'function' &&
262 typeof realpathSync === 'function'
263 ) {
264 const rawCwd = cwd()
265 try {
266 resolvedCwd = realpathSync(rawCwd).normalize('NFC')
267 } catch {
268 // File Provider EPERM on CloudStorage mounts (lstat per path component).
269 resolvedCwd = rawCwd.normalize('NFC')
270 }
271 }
272 const state: State = {
273 originalCwd: resolvedCwd,
274 projectRoot: resolvedCwd,
275 totalCostUSD: 0,
276 totalAPIDuration: 0,
277 totalAPIDurationWithoutRetries: 0,
278 totalToolDuration: 0,
279 turnHookDurationMs: 0,
280 turnToolDurationMs: 0,
281 turnClassifierDurationMs: 0,
282 turnToolCount: 0,
283 turnHookCount: 0,
284 turnClassifierCount: 0,
285 startTime: Date.now(),
286 lastInteractionTime: Date.now(),
287 totalLinesAdded: 0,
288 totalLinesRemoved: 0,
289 hasUnknownModelCost: false,
290 cwd: resolvedCwd,
291 modelUsage: {},
292 mainLoopModelOverride: undefined,
293 initialMainLoopModel: null,
294 modelStrings: null,
295 isInteractive: false,
296 kairosActive: false,
297 strictToolResultPairing: false,
298 sdkAgentProgressSummariesEnabled: false,
299 userMsgOptIn: false,
300 clientType: 'cli',
301 sessionSource: undefined,
302 questionPreviewFormat: undefined,
303 sessionIngressToken: undefined,
304 oauthTokenFromFd: undefined,
305 apiKeyFromFd: undefined,
306 flagSettingsPath: undefined,
307 flagSettingsInline: null,
308 allowedSettingSources: [
309 'userSettings',
310 'projectSettings',
311 'localSettings',
312 'flagSettings',

Callers 2

state.tsFile · 0.85
resetStateForTestsFunction · 0.85

Calls 3

realpathSyncFunction · 0.90
cwdFunction · 0.85
nowMethod · 0.80

Tested by

no test coverage detected