MCPcopy Create free account
hub / github.com/MatterAIOrg/OrbCode / buildHookEnv

Function buildHookEnv

src/core/hooks.ts:368–377  ·  view source on GitHub ↗

Build the environment for a hook command. The full parent env is inherited * (so PATH, HOME, npx, git, … all work) minus anything that looks like a * credential — hooks must never see the user's API token.

(cwd: string)

Source from the content-addressed store, hash-verified

366 * (so PATH, HOME, npx, git, … all work) minus anything that looks like a
367 * credential — hooks must never see the user's API token. */
368function buildHookEnv(cwd: string): NodeJS.ProcessEnv {
369 const env: NodeJS.ProcessEnv = { MATTERAI_PROJECT_DIR: cwd }
370 for (const [key, value] of Object.entries(process.env)) {
371 if (value === undefined) continue
372 if (HOOK_ENV_REDACT_EXACT.has(key)) continue
373 if (HOOK_ENV_REDACT_PATTERN.test(key)) continue
374 env[key] = value
375 }
376 return env
377}
378
379function truncate(text: string, max: number): string {
380 const oneLine = text.replace(/\s+/g, " ").trim()

Callers 1

runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected