Introduce discovery feature: CLI command and core discovery module#9
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f8ed92ef5c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| issues.push({ code: "missing-candidates", message: "Discovery report must include at least one capability candidate." }); | ||
| } | ||
|
|
||
| for (const candidate of report.candidates ?? []) { |
There was a problem hiding this comment.
Guard invalid discovery candidate lists
When an external agent returns syntactically valid JSON where candidates is present but not an array, validation records missing-candidates and then immediately tries to iterate that non-array value, throwing before the discover CLI can print the validation errors or write the parsed report. Since this path parses untrusted agent stdout, malformed reports should be reported as invalid instead of crashing during validation.
Useful? React with 👍 / 👎.
Motivation
Description
packages/core/src/discovery.tsthat defines types, validation (validateDiscoveryReport), prompt builder (buildCapabilityDiscoveryPrompt), and organization logic (organizeDiscoveredCapabilityMap).packages/core/src/index.tsand add new types forCapabilityDiscoveryReportand related entities.discoverCLI command inpackages/cli/src/index.tsthat builds a discovery prompt, runs an external agent viarunExternalAgentCommand, parses the JSON report, validates it, organizes suggestions, and supports output options like--output-prompt,--report,--transcript,--dry-run, and--json..capabilities/....capability.yamlstatuses toimplementedand includingimplementation.referencespointing topackages/core/src/discovery.ts` and the new tests.extractJsonObject,parseDiscoveryReport,formatDiscoveryValidation) to robustly extract and present agent JSON output.Testing
packages/core/tests/discovery.test.tscoveringbuildCapabilityDiscoveryPromptandvalidateDiscoveryReport, andpackages/core/tests/discoveryOrganization.test.tscoveringorganizeDiscoveredCapabilityMapand dependency inference.npm test -- packages/core/tests/discovery.test.ts,npm test -- packages/core/tests/discoveryOrganization.test.ts, andnpm run build, and they completed successfully.Codex Task