MCPcopy Create free account
hub / github.com/Noumena-Network/code / buildYoloSystemPrompt

Function buildYoloSystemPrompt

src/utils/permissions/yoloClassifier.ts:486–542  ·  view source on GitHub ↗
(
  context: ToolPermissionContext,
)

Source from the content-addressed store, hash-verified

484 * user allow/deny/environment values from settings.autoMode.
485 */
486export async function buildYoloSystemPrompt(
487 context: ToolPermissionContext,
488): Promise<string> {
489 const usingExternal = isUsingExternalPermissions()
490 const systemPrompt = BASE_PROMPT.replace('<permissions_template>', () =>
491 usingExternal
492 ? EXTERNAL_PERMISSIONS_TEMPLATE
493 : ANTHROPIC_PERMISSIONS_TEMPLATE,
494 )
495
496 const autoMode = getAutoModeConfig()
497 const includeBashPromptRules = feature('BASH_CLASSIFIER')
498 ? !usingExternal
499 : false
500 const includePowerShellGuidance = feature('POWERSHELL_AUTO_MODE')
501 ? !usingExternal
502 : false
503 const allowDescriptions = [
504 ...(includeBashPromptRules ? getBashPromptAllowDescriptions(context) : []),
505 ...(autoMode?.allow ?? []),
506 ]
507 const denyDescriptions = [
508 ...(includeBashPromptRules ? getBashPromptDenyDescriptions(context) : []),
509 ...(includePowerShellGuidance ? POWERSHELL_DENY_GUIDANCE : []),
510 ...(autoMode?.soft_deny ?? []),
511 ]
512
513 // All three sections use the same <foo_to_replace>...</foo_to_replace>
514 // delimiter pattern. The external template wraps its defaults inside the
515 // tags, so user-provided values REPLACE the defaults entirely. The
516 // anthropic template keeps its defaults outside the tags and uses an empty
517 // tag pair at the end of each section, so user-provided values are
518 // strictly ADDITIVE.
519 const userAllow = allowDescriptions.length
520 ? allowDescriptions.map(d => `- ${d}`).join('\n')
521 : undefined
522 const userDeny = denyDescriptions.length
523 ? denyDescriptions.map(d => `- ${d}`).join('\n')
524 : undefined
525 const userEnvironment = autoMode?.environment?.length
526 ? autoMode.environment.map(e => `- ${e}`).join('\n')
527 : undefined
528
529 return systemPrompt
530 .replace(
531 /<user_allow_rules_to_replace>([\s\S]*?)<\/user_allow_rules_to_replace>/,
532 (_m, defaults: string) => userAllow ?? defaults,
533 )
534 .replace(
535 /<user_deny_rules_to_replace>([\s\S]*?)<\/user_deny_rules_to_replace>/,
536 (_m, defaults: string) => userDeny ?? defaults,
537 )
538 .replace(
539 /<user_environment_to_replace>([\s\S]*?)<\/user_environment_to_replace>/,
540 (_m, defaults: string) => userEnvironment ?? defaults,
541 )
542}
543// ============================================================================

Callers 1

classifyYoloActionFunction · 0.85

Calls 4

getAutoModeConfigFunction · 0.85

Tested by

no test coverage detected