-
Notifications
You must be signed in to change notification settings - Fork 9
refactor(charm): remove built-in Charm schema; require explicit schemas #1819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(charm): remove built-in Charm schema; require explicit schemas #1819
Conversation
- Replace Charm type and charmSchema with schema-driven access. - CharmManager.get now accepts optional schema and returns typed cells. - Export nameSchema and uiSchema; update callers to read NAME and UI via schema. - Introduce generic CharmController<T> and CharmsController<T>. - Background worker: access bgUpdater as Stream via schema; map typed. - Runner: handle Stream in Cellify<T> for asSchema. - CLI, UI, and tests: replace Cell<Charm> with Cell<unknown>; pass schemas or cast. - Persistent flows return typed cells using recipe.resultSchema. - search.ts and format.ts use nameSchema for NAME access. - AppView reads title via cc().get(id, nameSchema) and cell.key(NAME). Motivation: - Decouple CharmManager from a fixed schema; allow arbitrary charm shapes. - Make invalid states unrepresentable by requiring explicit schemas at access. - Enable streams to be typed via schema (asStream) consistently.
…d get a proper schema
cf2ba83 to
44bf3cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the Charm system to remove the built-in Charm type and schema, requiring explicit schemas for all charm access operations. This decouples CharmManager from a fixed schema and makes invalid states unrepresentable by requiring explicit schemas at access time.
- Replace the global
Charmtype andcharmSchemawith schema-driven access patterns - Update CharmManager.get() to accept optional schemas and return typed cells
- Export separate
nameSchemaanduiSchemafor specific access patterns
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ui/src/v2/components/ct-outliner/types.ts | Replace Charm type with unknown for MentionableItem and Attachment |
| packages/ui/src/v2/components/ct-outliner/ct-outliner.ts | Update component to use unknown instead of Charm, add type assertions |
| packages/ui/src/v2/components/ct-kanban/ct-kanban.ts | Replace Charm type references with any/unknown types |
| packages/ui/src/v2/components/ct-code-editor/ct-code-editor.ts | Add local schema definitions and update mentionable handling |
| packages/shell/src/views/AppView.ts | Update to use nameSchema for charm title access |
| packages/shell/integration/iframe-counter-charm.test.ts | Replace Charm type with specific typed interface |
| packages/runner/src/cell.ts | Add Stream support to Cellify type helper |
| packages/runner/integration/array_push.test.ts | Update charm access to use explicit schema |
| packages/cli/lib/charm.ts | Remove Charm type, update function signatures to use unknown |
| packages/cli/lib/charm-render.ts | Add explicit UI schema for charm rendering |
| packages/cli/commands/charm.ts | Update UI symbol access pattern |
| packages/charm/src/workflow.ts | Replace Charm type with unknown throughout workflow system |
| packages/charm/src/search.ts | Update search to use nameSchema for charm name access |
| packages/charm/src/ops/charms-controller.ts | Add generic type parameter and schema support |
| packages/charm/src/ops/charm-controller.ts | Update to support generic types and use nameSchema |
| packages/charm/src/manager.ts | Replace charmSchema with separate nameSchema and uiSchema exports |
| packages/charm/src/iterate.ts | Remove Charm type dependencies |
| packages/charm/src/index.ts | Update exports to remove charmSchema, add nameSchema and uiSchema |
| packages/charm/src/imagine.ts | Replace Charm type with unknown |
| packages/charm/src/iframe/recipe.ts | Update function signature to use unknown |
| packages/charm/src/format.ts | Update to use nameSchema instead of charmSchema |
| packages/charm/src/commands.ts | Update function signatures and schema usage |
| packages/background-charm-service/src/worker.ts | Add explicit schema for bgUpdater stream access |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 issues found across 23 files
Prompt for AI agents (all 5 issues)
Understand the root cause of the following 5 issues and fix them.
<file name="packages/charm/src/workflow.ts">
<violation number="1" location="packages/charm/src/workflow.ts:1071">
Guard charmData with an object check before using the "in" operator to avoid runtime TypeError.</violation>
</file>
<file name="packages/cli/commands/charm.ts">
<violation number="1" location="packages/cli/commands/charm.ts:29">
Import uses the "commontools" alias not present in packages/cli/deno.json, breaking local CLI runs; use a relative path or add the alias.</violation>
</file>
<file name="packages/runner/src/cell.ts">
<violation number="1" location="packages/runner/src/cell.ts:285">
Cellify now allows Streams, but normalizeAndDiff/diffAndUpdate do not convert Stream instances to links. RegularCell.set/update/push will recurse into Stream internals and attempt non-JSON writes, causing errors or corrupt data.</violation>
</file>
<file name="packages/ui/src/v2/components/ct-outliner/ct-outliner.ts">
<violation number="1" location="packages/ui/src/v2/components/ct-outliner/ct-outliner.ts:1608">
Escape mention name when constructing the markdown link to prevent markdown/HTML injection and formatting issues in rendered content.</violation>
</file>
<file name="packages/ui/src/v2/components/ct-code-editor/ct-code-editor.ts">
<violation number="1" location="packages/ui/src/v2/components/ct-code-editor/ct-code-editor.ts:832">
ID comparison uses getEntityId on raw objects, producing empty curIds and preventing $mentioned updates.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
refactor(charm): remove built-in Charm schema; require explicit schemas
Removes default loading of [UI] and in many cases of everything else!
Motivation:
Summary by cubic
Refactored charm APIs to remove the built-in Charm schema and require explicit schemas, enabling typed access and decoupling charm shape across Runner, CLI, and UI.
Refactors
Migration