Skip to content

feat(command-code): add opt-in projectContext envelope for /alpha/generate - #4228

Draft
yansigit wants to merge 1 commit into
lidge-jun:devfrom
yansigit:codex/upstream-command-code-project-context
Draft

feat(command-code): add opt-in projectContext envelope for /alpha/generate#4228
yansigit wants to merge 1 commit into
lidge-jun:devfrom
yansigit:codex/upstream-command-code-project-context

Conversation

@yansigit

@yansigit yansigit commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Add opt-in projectContext: "on" provider configuration for Command Code (command-code).

When enabled on a command-code provider, opencodex loads bounded local repository context (AGENTS.md, taste.md, and workspace skills from skills/, .codex/skills/, and .agents/skills/) into the /alpha/generate payload instead of empty memory, taste, and skills fields.

  • Defaults to off (EMPTY_COMMAND_CODE_PROJECT_CONTEXT), preserving the existing behavior.
  • Robust, fail-soft loader: bounds file reads, enforces directory traversal limits, escapes XML characters, and caches results with LRU and TTL eviction.
  • Config schema and provider documentation updated.

Surface context: src/server/auth-cors.ts registers projectContext: "editor" in PROVIDER_CONFIG_FIELD_POLICY to satisfy TypeScript Record<keyof OcxProviderConfig, ProviderConfigFieldPolicy>. Maintainer sponsorship is requested per MAINTAINERS.md security review policy.

Verification

All verification commands executed via the isolated testing wrapper with clean temporary OPENCODEX_HOME and isolated ports:

  • bun test tests/providers/command-code-project-context.test.ts tests/providers/command-code-provider.test.ts: 73 passed, 0 failed (233 expect calls).
  • bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts: 17 passed, 0 failed (551 expect calls).
  • bun test tests/providers/provider-config-validation.test.ts tests/server/config.test.ts: 206 passed, 0 failed.
  • bun run typecheck: zero diagnostics.
  • bun run privacy:scan: passed cleanly.
  • Verified live config fingerprint and backup inventory in /Users/user/.opencodex remained completely untouched.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Added/updated regression coverage or verified existing coverage for the affected behavior.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the intake: hygiene-blocked Deterministic PR hygiene checks failed label Sep 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Deterministic hygiene checks failed.

  • unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/server/auth-cors.ts.

@github-actions github-actions Bot added the enhancement New feature or request label Sep 10, 2026
@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • hygiene: unsponsored_surface.

What to do

  • Fix unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/server/auth-cors.ts.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@lidge-jun

lidge-jun commented Sep 10, 2026

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 44 / 80

이 PR은 Command Code(command-code) 제공자에 선택 옵션 projectContext: "on"을 넣습니다. 지금 dev(HEAD ed839a3ee, #4226 L1·#4227 L5가 막 올라간 상태)의 src/adapters/command-code.ts/alpha/generate 본문에 memory: "", taste: null, skills: null을 항상 비워서 보냅니다. 옵션을 켜면 새 파일 src/adapters/command-code-project-context.tsloadCommandCodeProjectContext()가 작업 폴더에서 AGENTS.md, .commandcode/taste/taste.md, 스킬 폴더를 읽어 그 세 칸을 채웁니다. 기본값은 끔(EMPTY_COMMAND_CODE_PROJECT_CONTEXT)이라 지금 동작은 그대로입니다.

점수가 중간인 이유는 일곱 레인 계획에서 L1/L5만 첫 구현이 들어갔고, Command Code 로컬 컨텍스트는 그 레인의 급한 막힘이 아니기 때문입니다. 설계 자체는 조심스럽습니다. 읽기는 용량 상한·타임아웃·canonical path로 cwd 밖 차단·실패 시 빈 값 처리가 있고, 결과는 cwd 키 캐시(최대 128, TTL 30초)입니다. src/config.tssrc/types/provider.ts에 optional 필드만 더하므로 types/config 분할 캠페인 때문에 닫아야 할 PR은 아닙니다.

지금 막힌 이유는 기능보다 게이트입니다. 아직 draft이고, src/server/auth-cors.tsprojectContext: "editor" 한 줄을 추가했다는 이유로 hygiene가 unsponsored_surfaceintake: hygiene-blocked입니다. 설정 UI에 노출할 필드를 등록하는 정상적인 한 줄이지만, 그 파일이 인증·설정 표면이라 메인테이너 스폰서(maintainer-sponsored) 없이는 머지 기차에 못 탑니다. 작성자 본문도 스폰서를 요청한 상태입니다.

설명과 코드가 어긋납니다. PR 본문은 스킬 경로를 skills/, .codex/skills/, .agents/skills/라고 적었고, docs도 taste.md만 뭉뚱그립니다. 실제 SKILL_ROOTS.commandcode/skills, .agents/skills, .pi/skills이고, taste는 .commandcode/taste/taste.md입니다. 켠 사용자가 Codex/루트 skills/만 만들어 두면 스킬이 비어 올라갑니다. docs-site providers 안내도 경로를 코드와 같게 써야 합니다.

보안은 opt-in이라 기본 위험은 낮습니다. 그래도 켜는 순간 워크스페이스 문서를 업스트림으로 보내므로, 팀 공유 설정에 "on"이 실수로 박히지 않게 설명이 분명해야 합니다. 캐시는 cwd 문자열만 키로 써서 같은 폴더를 쓰는 제공자끼리 내용을 공유합니다. 비밀 키가 아니라 로컬 파일이라 대체로 괜찮습니다.

라인 37-41 - SKILL_ROOTS가 PR 본문·요약의 skills/.codex/skills 설명과 다름. 문서·본문을 .commandcode/skills·.agents/skills·.pi/skills에 맞추거나, Codex 관례 경로를 정말 지원할 거면 코드를 바꿀 것
라인 196 - taste 실경로는 .commandcode/taste/taste.md인데 docs는 taste.md만 말해 루트에 파일을 두기 쉬움
경로 src/server/auth-cors.ts - projectContext: "editor" 추가가 unsponsored_surface. 스폰서 라벨이 머지 게이트
경로 src/config.ts / src/types/provider.ts - optional projectContext는 분할 캠페인과 충돌 없음. close-don't-rebase 대상 아님
경로 PR 상태 - draft + intake: hygiene-blocked. 체크리스트는 채워졌지만 게이트는 아직 DRAFT

메인테이너의 판단이 필요한 지점

  • auth-cors 한 줄 정책 등록을 스폰서해도 될 만큼 설정 표면 검토가 끝났는지
  • 스킬 루트를 Command Code 관례(.commandcode/.pi)에 둘지, PR 본문대로 Codex 관례(skills//.codex/skills)까지 넓힐지
  • 일곱 레인(L2–L7) 첫 구현 PR보다 먼저 넣을 가치가 있는지

너의 추천
지금은 머지하지 말 것. draft 유지. 문서·PR 본문의 스킬/taste 경로를 코드와 맞춘 뒤, 메인테이너가 표면 검토하고 maintainer-sponsored를 붙이면 그때 ready로 올리면 됩니다. 레인 막힘 PR이 있으면 그쪽을 먼저 보세요.

이 댓글은 grok-bot이 작성했습니다

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 88c87a1. The opt-in/default-empty behavior is useful, but the finite enumeration claim is not enforced by listSkillDirs: the stopping condition is names.length >= scanBudget, reached only after a non-hidden directory with a valid SKILL.md is accepted. Hidden entries, regular files, and directories without SKILL.md never consume that budget. The new test contains 300 valid skill directories, so it cannot catch this case.

Count every visited directory entry against an independent scan budget before filtering, while retaining the separate selected-skill limit. Add a mixed/nonmatching-entry test which observes the iterator count, plus the existing valid-directory positive control. Keep timeout cleanup; a timeout is not a substitute for the documented work cap.

Also align docs/body with the actual paths: .commandcode/taste/taste.md, .commandcode/skills, .agents/skills, .pi/skills. Explain that currentWorkingDirectory() is the OCX process working directory, not automatically the caller's remote workspace. The feature sends those local contents upstream when enabled, so a sponsorship decision still requires that configuration boundary to be accepted. I have not applied a sponsorship label, enabled CI, or executed project file reads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request intake: hygiene-blocked Deterministic PR hygiene checks failed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants