-
Notifications
You must be signed in to change notification settings - Fork 10
docs: Add charm linking guide #2155
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
Conversation
Add comprehensive documentation for charm linking in CommonTools patterns, covering how to create source charms that expose data, consumer charms that receive linked data, and the CLI commands for deploying and linking charms. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Update browser access URLs to use port 8000 instead of 5173, reflecting the upcoming convention change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
2 issues found across 1 file
Prompt for AI agents (all 2 issues)
Understand the root cause of the following 2 issues and fix them.
<file name="docs/common/CHARM_LINKING.md">
<violation number="1" location="docs/common/CHARM_LINKING.md:61">
The source-charm example calls a `percentile` helper that is never defined, so the sample code cannot compile or run as written.</violation>
<violation number="2" location="docs/common/CHARM_LINKING.md:73">
The guide’s source-charm recipe invokes `parseData(rawData)` without ever defining that helper, so the example cannot be executed as provided.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
docs/common/CHARM_LINKING.md
Outdated
| "Stats Calculator", | ||
| ({ name, rawData }) => { | ||
| // Compute derived values | ||
| const parsedValues = parseData(rawData); |
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.
The guide’s source-charm recipe invokes parseData(rawData) without ever defining that helper, so the example cannot be executed as provided.
Prompt for AI agents
Address the following comment on docs/common/CHARM_LINKING.md at line 73:
<comment>The guide’s source-charm recipe invokes `parseData(rawData)` without ever defining that helper, so the example cannot be executed as provided.</comment>
<file context>
@@ -0,0 +1,447 @@
+ "Stats Calculator",
+ ({ name, rawData }) => {
+ // Compute derived values
+ const parsedValues = parseData(rawData);
+ const computedStats = calculateStats(parsedValues);
+
</file context>
✅ Addressed in 94cdcac
docs/common/CHARM_LINKING.md
Outdated
| const average = sum / n; | ||
|
|
||
| // Quartile calculations... | ||
| const q1 = percentile(sorted, 25); |
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.
The source-charm example calls a percentile helper that is never defined, so the sample code cannot compile or run as written.
Prompt for AI agents
Address the following comment on docs/common/CHARM_LINKING.md at line 61:
<comment>The source-charm example calls a `percentile` helper that is never defined, so the sample code cannot compile or run as written.</comment>
<file context>
@@ -0,0 +1,447 @@
+ const average = sum / n;
+
+ // Quartile calculations...
+ const q1 = percentile(sorted, 25);
+ const median = percentile(sorted, 50);
+ const q3 = percentile(sorted, 75);
</file context>
✅ Addressed in 94cdcac
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.
2 issues found across 1 file
Prompt for AI agents (all 2 issues)
Understand the root cause of the following 2 issues and fix them.
<file name="docs/common/CHARM_LINKING.md">
<violation number="1" location="docs/common/CHARM_LINKING.md:61">
The documentation references an undefined `percentile` helper in the source-charm example, making the sample code invalid.</violation>
<violation number="2" location="docs/common/CHARM_LINKING.md:73">
The Stats source-charm example calls `parseData` without providing an implementation, so the documented code cannot compile as written.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
docs/common/CHARM_LINKING.md
Outdated
| const average = sum / n; | ||
|
|
||
| // Quartile calculations... | ||
| const q1 = percentile(sorted, 25); |
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.
The documentation references an undefined percentile helper in the source-charm example, making the sample code invalid.
Prompt for AI agents
Address the following comment on docs/common/CHARM_LINKING.md at line 61:
<comment>The documentation references an undefined `percentile` helper in the source-charm example, making the sample code invalid.</comment>
<file context>
@@ -0,0 +1,447 @@
+ const average = sum / n;
+
+ // Quartile calculations...
+ const q1 = percentile(sorted, 25);
+ const median = percentile(sorted, 50);
+ const q3 = percentile(sorted, 75);
</file context>
✅ Addressed in 94cdcac
docs/common/CHARM_LINKING.md
Outdated
| "Stats Calculator", | ||
| ({ name, rawData }) => { | ||
| // Compute derived values | ||
| const parsedValues = parseData(rawData); |
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.
The Stats source-charm example calls parseData without providing an implementation, so the documented code cannot compile as written.
Prompt for AI agents
Address the following comment on docs/common/CHARM_LINKING.md at line 73:
<comment>The Stats source-charm example calls `parseData` without providing an implementation, so the documented code cannot compile as written.</comment>
<file context>
@@ -0,0 +1,447 @@
+ "Stats Calculator",
+ ({ name, rawData }) => {
+ // Compute derived values
+ const parsedValues = parseData(rawData);
+ const computedStats = calculateStats(parsedValues);
+
</file context>
✅ Addressed in 94cdcac
docs/common/CHARM_LINKING.md
Outdated
| return { average, q1, median, q3, iqr, count: n }; | ||
| }); | ||
|
|
||
| export default recipe<Input, Output>( |
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.
let's switch to pattern, which also means leaving out the title in the next line.
You can add the title back in the input schema via jsdoc: Write /** Stats Calculator */ right above defining the Input type.
docs/common/CHARM_LINKING.md
Outdated
| export default recipe<Input, Input>( | ||
| "Stats Reader", | ||
| ({ name, linkedStats }) => { | ||
| const dataPresent = hasData(linkedStats); |
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.
this is unused and honestly also a distraction, i'd remove this here and above
docs/common/CHARM_LINKING.md
Outdated
| ```typescript | ||
| // Helper functions handle null gracefully | ||
| const hasData = lift((s: Stats | null) => s !== null); | ||
| const getAverage = lift((s: Stats | null) => s?.average); |
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.
getAverage that just reads a property is not necessary, you can just write formatNumber(linkedStats.average) below in the JSX
docs/common/CHARM_LINKING.md
Outdated
|
|
||
| 1. **Use `Default<T, null>` for linked fields** - provides fallback when unlinked | ||
| 2. **Interface must match source** - the Stats interface must be identical | ||
| 3. **Use `lift()` for null-safe access** - `lift((s) => s?.field)` handles null gracefully |
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.
remove this third point.
docs/common/CHARM_LINKING.md
Outdated
| 1. **Use `Default<T, null>` for linked fields** - provides fallback when unlinked | ||
| 2. **Interface must match source** - the Stats interface must be identical | ||
| 3. **Use `lift()` for null-safe access** - `lift((s) => s?.field)` handles null gracefully | ||
| 4. **Show helpful UI when unlinked** - guide users on how to link |
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.
do we want that guidance? seems misplaced to me...
seefeldb
left a comment
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.
some minor suggestions
- Change `recipe` to `pattern` throughout all examples - Add JSDoc comments above Input interfaces for charm titles - Add missing `parseData` lifted function implementation - Inline `percentile` helper inside `calculateStats` function - Update Quick Reference checklist to mention `pattern` and JSDoc 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove third point about lift() for null-safe access from Key Rules - Remove fourth point about showing helpful UI when unlinked - Remove unused hasData and getAverage helpers from consumer example - Simplify consumer example to use linkedStats?.average directly - Add note about importing Stats type from source charm - Update Consumer Charm Checklist to be more concise 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
Contents
The guide covers:
Default<T, null>ct charm newandct charm linkTest plan
🤖 Generated with Claude Code
Summary by cubic
Add a Charm Linking Guide to the docs with step-by-step instructions and examples for linking source and consumer charms in CommonTools. Includes Output/Input interface patterns, reactive linking, CLI commands (ct charm new/link), a full GPA stats example with a deployment script, and quick-reference checklists.
Written for commit e4e2709. Summary will update automatically on new commits.