import{r as i,j as t}from"./vendor-react-wBh_31cN.js";import{t as x}from"./toast-wiGcevcF.js";import{cB as P,cV as U,d as b,G as q}from"./index-dNe6i2rS.js";import{C as O,a as F,b as G,c as k}from"./card-BeQtvmcJ.js";import{L as d}from"./label-gPWmc6ow.js";import{T as R,a as W,b as v,c as C}from"./tabs-BZDPsi5L.js";import{u as M}from"./useTitle-DQo_L6Ox.js";import"./vendor-redux-CJZrIb6x.js";import"./vendor-router-D1GqFWiT.js";import"./vendor-utils-OeoE2qq_.js";import"./vendor-icons-BUUmD6ht.js";import"./vendor-radix-BRyWS4bQ.js";import"./vendor-grid-CeFlDWv4.js";const u=2e4,S=new P("/admin/coding-agent-config"),w=[{key:"claude",label:"System-wide CLAUDE.md",description:"This content is written to every terminal’s CLAUDE.md file. Use it to set organization-wide instructions, coding standards, or project context for Claude Code.",placeholder:`# Organization Instructions

Add system-wide instructions for Claude Code here.
These will be written to the CLAUDE.md in every terminal session.

Example:
- Always use Python type hints
- Follow PEP 8 style guide
- Use the Hopsworks Feature Store for all feature engineering`},{key:"claude-rules-code-style",label:"Code Style Rules",description:"Written to .claude/rules/code-style.md in every terminal. Define coding conventions, formatting, naming, and style preferences.",placeholder:`---
paths:
  - "src/**/*.{ts,tsx}"
  - "lib/**/*.ts"
  - "tests/**/*.test.ts"
---

# Code Style

Define your organization's coding style rules here.

Example:
- Use 4 spaces for indentation in Python
- Use camelCase for variables, PascalCase for classes
- Maximum line length is 120 characters
- Always add type annotations to function signatures`},{key:"claude-rules-testing",label:"Testing Rules",description:"Written to .claude/rules/testing.md in every terminal. Define testing standards, required coverage, and preferred test patterns.",placeholder:`# Testing

Define your organization's testing rules here.

Example:
- Write unit tests for all new functions
- Use pytest as the test framework
- Mock external API calls in unit tests
- Integration tests must use real database connections`},{key:"claude-rules-security",label:"Security Rules",description:"Written to .claude/rules/security.md in every terminal. Define security policies, forbidden patterns, and compliance requirements.",placeholder:`# Security

Define your organization's security rules here.

Example:
- Never hardcode credentials or API keys
- Always validate and sanitize user input
- Use parameterized queries for all database access
- Do not disable SSL/TLS certificate verification`}],A=[{key:"codex",label:"System-wide AGENTS.md",description:"This content is written to every terminal’s ~/.codex/AGENTS.md file. AGENTS.md is the OpenAI Codex equivalent of CLAUDE.md and contains global agent instructions.",placeholder:`# Organization Instructions

Add system-wide instructions for OpenAI Codex here.
These will be written to ~/.codex/AGENTS.md in every terminal session.

Example:
- Prefer typed Python signatures over docstrings for type information
- Always run ruff check before suggesting commits
- Use Hopsworks Feature Store APIs for feature engineering`},{key:"codex-rules-code-style",label:"Code Style Rules",description:"Written to .codex/rules/code-style.md in every terminal. Define coding conventions, formatting, naming, and style preferences for Codex.",placeholder:`# Code Style

Define your organization's coding style rules here.

Example:
- Use 4 spaces for indentation in Python
- Use camelCase for variables, PascalCase for classes
- Maximum line length is 120 characters
- Always add type annotations to function signatures`},{key:"codex-rules-testing",label:"Testing Rules",description:"Written to .codex/rules/testing.md in every terminal. Define testing standards, required coverage, and preferred test patterns for Codex.",placeholder:`# Testing

Define your organization's testing rules here.

Example:
- Write unit tests for all new functions
- Use pytest as the test framework
- Mock external API calls in unit tests
- Integration tests must use real database connections`},{key:"codex-rules-security",label:"Security Rules",description:"Written to .codex/rules/security.md in every terminal. Define security policies, forbidden patterns, and compliance requirements for Codex.",placeholder:`# Security

Define your organization's security rules here.

Example:
- Never hardcode credentials or API keys
- Always validate and sanitize user input
- Use parameterized queries for all database access
- Do not disable SSL/TLS certificate verification`}],H=[...w,...A],ae=()=>{M("Agents");const[l,m]=i.useState({}),[T,p]=i.useState(new Set),[E,I]=i.useState(!0),[j,g]=i.useState(new Set);i.useEffect(()=>{(async()=>{const e={};await Promise.all(H.map(async({key:a})=>{try{const{data:o}=await S.request({url:a});e[a]=o.systemInstruction||""}catch{e[a]=""}})),m(e),I(!1)})()},[]);const D=i.useCallback(s=>e=>{m(a=>({...a,[s]:e.target.value})),p(a=>new Set(a).add(s))},[]),N=i.useCallback(s=>async()=>{const e=l[s]||"",a=e.length>u,o=/[^\x00-\x7F]/.test(e);if(!(a||o)){g(r=>new Set(r).add(s));try{await S.request({url:s,type:U.put,data:{systemInstruction:e}}),p(r=>{const n=new Set(r);return n.delete(s),n}),x.success("Settings saved",{description:"Changes will be applied to new terminal sessions."})}catch{x.error("Failed to save",{description:"There was an error saving the settings."})}finally{g(r=>{const n=new Set(r);return n.delete(s),n})}}},[l]),f=s=>s.map(({key:e,label:a,description:o,placeholder:r})=>{const n=l[e]||"",y=n.length>u,h=/[^\x00-\x7F]/.test(n),c=y||h,L=T.has(e),z=j.has(e);return t.jsxs(O,{className:"mb-[30px]",children:[t.jsx(F,{children:t.jsx(G,{children:a})}),t.jsxs(k,{className:"flex flex-col gap-4 p-5",children:[t.jsxs(d,{children:[o," Only ASCII characters are allowed."]}),t.jsx("div",{className:b("overflow-hidden rounded-lg border",c?"border-quartz-label-red":"border-border"),children:t.jsx("textarea",{"aria-label":e,value:n,onChange:D(e),placeholder:r,disabled:E,className:"w-full min-h-[360px] p-3 font-mono text-[13px] leading-normal border-none outline-none resize-y bg-transparent text-foreground"})}),h&&t.jsx(d,{className:"text-[13px] text-quartz-label-red",children:"Only ASCII characters are allowed. Please remove non-ASCII characters (e.g., special symbols, emojis, or box-drawing characters like ─│├) before saving."}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs(d,{className:b(c?"text-quartz-label-red":"text-quartz-gray"),children:[n.length.toLocaleString()," / ",u.toLocaleString()," ","characters",y&&" — exceeds maximum length"]}),t.jsx(q,{onClick:N(e),disabled:!L||c,loading:z,children:"Save"})]})]})]},e)});return t.jsxs(R,{defaultValue:"claude",className:"h-full",children:[t.jsxs(W,{variant:"line",children:[t.jsx(v,{value:"claude",children:"Claude"}),t.jsx(v,{value:"codex",children:"Codex"})]}),t.jsx(C,{value:"claude",className:"pt-5",children:f(w)}),t.jsx(C,{value:"codex",className:"pt-5",children:f(A)})]})};export{ae as default};
