Skip to content

Commit d3170e2

Browse files
vmrh21claude
andcommitted
feat: onboard command now checks if component is already onboarded
Three modes: - Mode A (fully onboarded): ask user if they want to add repos or just regenerate examples.md — skips mapping update if examples only - Mode B (partially onboarded): collect new repos, merge with existing component entry, regenerate examples for all repos - Mode C (new): full onboard flow as before Detects mode by checking component-repository-mappings.json before asking any questions. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 6c662bf commit d3170e2

1 file changed

Lines changed: 44 additions & 3 deletions

File tree

workflows/cve-fixer/.claude/commands/onboard.md

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,49 @@ to `ambient-code/workflows` containing both the mapping update and the guidance
88

99
## Process
1010

11-
1. **Collect Component Information**
11+
1. **Determine Mode — Check Existing Mapping**
12+
13+
Before asking any questions, load `component-repository-mappings.json` and check
14+
whether the component is already onboarded:
15+
16+
```bash
17+
# Find mapping file
18+
if [ -f "component-repository-mappings.json" ]; then
19+
MAPPING_FILE="component-repository-mappings.json"
20+
elif [ -f "workflows/cve-fixer/component-repository-mappings.json" ]; then
21+
MAPPING_FILE="workflows/cve-fixer/component-repository-mappings.json"
22+
fi
23+
24+
# Ask component name first
25+
# Then check if it exists in the mapping
26+
EXISTING=$(jq -r --arg name "$COMPONENT_NAME" \
27+
'if .components[$name] then "found" else "not_found" end' "$MAPPING_FILE" 2>/dev/null)
28+
```
29+
30+
**Three modes based on what exists:**
31+
32+
**Mode A — Component already fully onboarded** (`EXISTING == "found"` and user confirms repos are correct):
33+
- Show existing repos from the mapping
34+
- Ask: "Your repos are already mapped. Do you want to: (1) Add new repos (2) Just regenerate examples.md guidance files (3) Cancel?"
35+
- If option 2: skip to Step 5 (Generate examples.md only) — no mapping change needed
36+
- If option 1: continue to collect new repos to add
37+
38+
**Mode B — Component exists, adding repos** (selected option 1 above):
39+
- Collect only the NEW repos to add
40+
- Merge with existing repos in the mapping
41+
- Regenerate examples.md for all repos
42+
43+
**Mode C — New component** (`EXISTING == "not_found"`):
44+
- Full onboard flow — collect component name, repos, validate Jira, etc.
45+
46+
1a. **Collect Component Information** (Modes B and C only)
1247

1348
Ask the user for the following, one question at a time:
1449

1550
a. **Jira component name** — must match exactly what appears in Jira (case-sensitive).
1651
Example: `"AI Evaluations"`, `"llm-d"`, `"AutoML"`
1752

18-
b. **Repos** — for each repo:
53+
b. **Repos** — for each repo to add:
1954
- GitHub URL (e.g. `https://github.com/org/repo`)
2055
- Repo type: `upstream`, `midstream`, or `downstream`
2156
- Subcomponent name (optional — only if this component has multiple distinct
@@ -142,6 +177,8 @@ to `ambient-code/workflows` containing both the mapping update and the guidance
142177
- If no containers discovered, omit the field (can be added later)
143178
- Omit `subcomponent` if not needed
144179
- Show the entry to the user: "Does this look correct? (yes/no/edit)"
180+
- **Mode A (examples only)**: skip this step entirely — no mapping changes
181+
- **Mode B (adding repos)**: merge new repos into existing component entry
145182

146183
5. **Generate `.cve-fix/examples.md` Guidance**
147184

@@ -239,13 +276,17 @@ to `ambient-code/workflows` containing both the mapping update and the guidance
239276
fi
240277
```
241278

242-
7. **Apply All Changes**
279+
7. **Apply Changes (mode-dependent)**
243280

244281
```bash
245282
cd /tmp/workflows-onboard
246283
BRANCH_NAME="onboard/${COMPONENT_NAME_SLUG}"
247284
git checkout -b "$BRANCH_NAME"
248285

286+
# Mode A: examples.md only — skip mapping update entirely
287+
# Mode B: merge new repos into existing component entry
288+
# Mode C: add new component entry
289+
249290
MAPPING_FILE="workflows/cve-fixer/component-repository-mappings.json"
250291

251292
# Add component to mapping file

0 commit comments

Comments
 (0)