Repository navigation
Description
Overview
Sampled semantic refactoring analysis, slice date 2026-11-13. Reviewed 16 non-test functions across 3 files: pkg/cli slice 23/619 (8 functions across add_package_manifest_imports.go and add_package_manifest_includes.go) and pkg/console slice 23/28 (8 functions in render.go). No record was truncated. This covers only the sampled functions, not the whole packages or repository.
One refactoring candidate was verified. extractManifestIncludes normalizes string include entries differently depending on the slice type it receives.
Key findings
| Input shape | Per-entry handling | Location |
|---|---|---|
[]any string entries |
Trimmed. Entries whose basename is the manifest file name pass through cleanManifestImportPath, and a failure returns an error. |
pkg/cli/add_package_manifest_includes.go:55-62 |
[]string entries |
Wrapped by manifestIncludesFromPaths as Source: p. No trimming, no manifest-path cleaning, no error path. |
pkg/cli/add_package_manifest_includes.go:86-87, helper at :42-48 |
Both arms then feed the shared normalization loop (:94-104). That loop checks the supported-path predicates and drops unsupported sources with a warning, so the []string arm skips the per-entry steps the []any arm applies.
Proposed refactoring
Route []string entries through the same per-entry normalization that appendRawEntry uses. One option is a normalizeStringInclude(include, manifestPath string) (repositoryPackageInclude, error) helper called from both arms. If no other caller needs manifestIncludesFromPaths, remove it.
Preservation risks
manifestIncludesFromPathsmay be intentional. Its name suggests[]stringcallers pass paths that are already validated, so confirm the callers before changing behavior.- Trimming changes matching for entries with leading or trailing whitespace.
[]stringentries that fail manifest-path cleaning would now return an error instead of being passed through.- Deduplication runs on normalized values, so entries that become equal after cleaning will collapse.
- Not checked: callers of
extractManifestIncludes, uses ofmanifestIncludesFromPaths, and the predicatesisSupportedManifestIncludePathandisManifestImportPath. They are outside the packet, so whether the skipped steps matter in practice is unverified.
Candidates compared and not reported
Three candidate groups were compared: the include handling above (reported), and two in pkg/console/render.go (not reported).
formatUnexportedValue(lines 549-564) duplicates the Int, Uint and Float arms offormatNumericKind(lines 567-578). The duplication is about 6 lines, below the significance bar.- The type-switch fast paths in
applyIntegerFormat(lines 618-648) andapplyCostFormat(lines 659-678) look redundant but are not. Forreflect.Interfacevalues holding a number, the type switch matches the dynamic type, while the Kind fallback returnsbaseValue. Removing them would change output.
Next actions
- Find the callers of
extractManifestIncludesandmanifestIncludesFromPaths. If no trusted caller passes[]string, apply the change. - Add table tests for
[]anyand[]stringinputs covering whitespace, manifest-import entries and unsupported paths, before and after the change.
References: §43351366513
Generated by 🔧 Semantic Function Refactoring · claude · routed: haiku55 xhigh · ~3 AIC · ⌖ ~1 AIC · ⊞ 4.1K · ◷
- expires on Nov 14, 2026, 6:26 PM UTC-08:00
Activity
github-actions commentedon Nov 13, 2026
🍪 Issue Monster selected this for Copilot
I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.
If assignment succeeds, Copilot will analyze the issue and create a pull request with the fix.
Om nom nom! 🍪