Skip to content

feat(ai-provider,core): implement CodeGenerationProvider seam (G5 Phase 1)#494

Merged
laofahai merged 3 commits into
mainfrom
feat/g5-codegen-provider
Jun 7, 2026
Merged

feat(ai-provider,core): implement CodeGenerationProvider seam (G5 Phase 1)#494
laofahai merged 3 commits into
mainfrom
feat/g5-codegen-provider

Conversation

@laofahai

@laofahai laofahai commented Jun 7, 2026

Copy link
Copy Markdown
Owner

What

G5 Phase 1 — implement the CodeGenerationProvider seam: the foundation for
AI code generation of the irreducibly-code parts of a proposal (action /
event-handler / flow logic bodies that a declarative ChangeDefinition cannot
express).

@linchkit/core declared a CodeGenerationProvider interface ("implemented by
cap-ai-provider") but no implementation existed and the type was on no public
barrel.

  • @linchkit/core/server now exports CodeGenerationProvider,
    CodeGenerationResult, ProjectContext, QualityGateRunner (type-only) so a
    capability can implement the seam.
  • @linchkit/cap-ai-provider adds createCodeGenerationProvider(ai, options)
    — a thin adapter over the configured AIService (GLM/zhipu per
    linchkit.config; never hardcoded). generateCode(prompt, context?) shapes
    context→system + prompt→user, defaults temperature 0 and taskType "code",
    forwards model/maxTokens/tenantId, and throws when the AIService is
    unconfigured (so the caller's retry/quality-gate surfaces a clear failure).

Safety boundary

This implements the design the user approved: narrow scope + free-form TS,
gated by build + double human review.
This PR adds only the generator — it is
NOT wired into any live path. It only PRODUCES candidate source as a string; it
never writes files, runs code, or touches the approval / graduation pipeline.
("AI never modifies production directly.")

G5 plan context

  • P1 (this PR): provider seam + public type export.
  • P2: Validation Phase 2 (build/typecheck the generated source).
  • P3: lazy "materialize" step attaching generated source to action/event/flow
    proposal changes (draft-only).
  • P4: review UI shows the generated code; graduation writes it.

Verification

  • bun run check / bun run typecheck — clean
  • bun run test — PASS (6 new unit tests, fake AIService injected; no real
    model is called)

🤖 Generated with Claude Code

…se 1)

core declared a `CodeGenerationProvider` interface ("implemented by
cap-ai-provider") but no implementation existed and the type was on no public
barrel. This is G5 Phase 1 — the foundation for AI code generation of the
irreducibly-code parts of a proposal (action / event-handler / flow logic bodies
a declarative ChangeDefinition cannot express).

- @linchkit/core/server now exports CodeGenerationProvider / CodeGenerationResult
  / ProjectContext / QualityGateRunner (type-only) so a capability can implement
  the seam.
- @linchkit/cap-ai-provider adds createCodeGenerationProvider(ai, options): a
  thin adapter over the configured AIService (GLM per linchkit.config, never
  hardcoded). generateCode(prompt, context?) shapes context→system + prompt→user,
  defaults temperature 0 + taskType "code", forwards model/maxTokens/tenantId,
  and throws when the AIService is unconfigured.

SAFETY: adds only the generator — NOT wired into any live path. It only produces
candidate source as a string; never writes files, runs code, or touches the
approval/graduation pipeline. Generated source still flows through validation +
double human review (draft + graduation PR). "AI never modifies production
directly."

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@laofahai, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 10 minutes and 59 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 15020f2e-b7dc-4e16-ba66-6f8a1720dd50

📥 Commits

Reviewing files that changed from the base of the PR and between 73c720a and e012354.

📒 Files selected for processing (5)
  • .changeset/g5-codegen-provider.md
  • addons/ai-provider/cap-ai-provider/__tests__/code-generation-provider.test.ts
  • addons/ai-provider/cap-ai-provider/src/code-generation-provider.ts
  • addons/ai-provider/cap-ai-provider/src/index.ts
  • packages/core/src/exports/server/ai.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/g5-codegen-provider

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 and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request implements the CodeGenerationProvider seam for G5 Phase 1, exporting core types from @linchkit/core/server and introducing a thin adapter implementation over AIService in @linchkit/cap-ai-provider along with corresponding unit tests. Review feedback recommends adding defensive checks to validate that the ai service is defined and that the prompt is a non-empty string, handling potential null or undefined completion results, and adding unit tests to verify these validation behaviors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread addons/ai-provider/cap-ai-provider/src/code-generation-provider.ts
Comment thread addons/ai-provider/cap-ai-provider/src/code-generation-provider.ts
Address gemini-code-assist review on #494:
- generateCode throws on an empty / whitespace-only prompt (before any model
  call) — robust input validation, avoids a wasted generation.
- Guard a completion with no string `content`: throw instead of returning a
  non-string, so the Promise<string> contract holds and the caller's retry /
  quality gate surfaces the failure.
- Tests for both new failure paths (empty prompt, whitespace prompt, no content).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant