generated from coulomb/repo-seed
Repo stats and features as aggregates
This commit is contained in:
@@ -125,16 +125,7 @@ class CandidateGraphGenerator:
|
||||
docs: list[ObservedFact],
|
||||
chunks: list[ContentChunk],
|
||||
) -> CandidateCapabilityDraft:
|
||||
features = [
|
||||
CandidateFeatureDraft(
|
||||
name=self._feature_name(fact, chunks),
|
||||
type=self._feature_type(fact),
|
||||
location=fact.path,
|
||||
confidence=0.65 if fact.value else 0.45,
|
||||
source_refs=self._source_refs([fact]),
|
||||
)
|
||||
for fact in interfaces
|
||||
]
|
||||
features = self._interface_features(interfaces, chunks)
|
||||
return CandidateCapabilityDraft(
|
||||
name="Expose Repository Interface",
|
||||
description=self._interface_description(chunks),
|
||||
@@ -151,6 +142,83 @@ class CandidateGraphGenerator:
|
||||
evidence=self._evidence(tests, examples, docs),
|
||||
)
|
||||
|
||||
def _interface_features(
|
||||
self,
|
||||
interfaces: list[ObservedFact],
|
||||
chunks: list[ContentChunk],
|
||||
) -> list[CandidateFeatureDraft]:
|
||||
by_type: dict[str, list[ObservedFact]] = {}
|
||||
for fact in interfaces:
|
||||
by_type.setdefault(self._feature_type(fact), []).append(fact)
|
||||
|
||||
features: list[CandidateFeatureDraft] = []
|
||||
for feature_type, facts in sorted(by_type.items()):
|
||||
if len(facts) == 1:
|
||||
fact = facts[0]
|
||||
features.append(
|
||||
CandidateFeatureDraft(
|
||||
name=self._feature_name(fact, chunks),
|
||||
type=feature_type,
|
||||
location=fact.path,
|
||||
confidence=0.65 if fact.value else 0.45,
|
||||
source_refs=self._source_refs([fact]),
|
||||
)
|
||||
)
|
||||
continue
|
||||
|
||||
features.append(
|
||||
CandidateFeatureDraft(
|
||||
name=self._grouped_interface_feature_name(
|
||||
feature_type,
|
||||
facts,
|
||||
chunks,
|
||||
),
|
||||
type=feature_type,
|
||||
location=self._grouped_location(facts),
|
||||
confidence=self._grouped_interface_confidence(facts),
|
||||
source_refs=self._source_refs(facts),
|
||||
)
|
||||
)
|
||||
return features
|
||||
|
||||
def _grouped_interface_feature_name(
|
||||
self,
|
||||
feature_type: str,
|
||||
facts: list[ObservedFact],
|
||||
chunks: list[ContentChunk],
|
||||
) -> str:
|
||||
summary = self._grouped_interface_summary(facts, chunks)
|
||||
if feature_type == "API":
|
||||
return f"HTTP API surface: {summary}"
|
||||
if feature_type == "CLI":
|
||||
return f"CLI command surface: {summary}"
|
||||
return f"Callable interface surface: {summary}"
|
||||
|
||||
def _grouped_interface_summary(
|
||||
self,
|
||||
facts: list[ObservedFact],
|
||||
chunks: list[ContentChunk],
|
||||
) -> str:
|
||||
names = [self._feature_name(fact, chunks) for fact in facts]
|
||||
compact_names = [name for name in names if name]
|
||||
if not compact_names:
|
||||
return f"{len(facts)} entry points"
|
||||
visible = compact_names[:3]
|
||||
suffix = f", +{len(compact_names) - 3} more" if len(compact_names) > 3 else ""
|
||||
return f"{', '.join(visible)}{suffix}"
|
||||
|
||||
def _grouped_location(self, facts: list[ObservedFact]) -> str:
|
||||
paths = sorted({fact.path for fact in facts if fact.path})
|
||||
if not paths:
|
||||
return ""
|
||||
if len(paths) == 1:
|
||||
return paths[0]
|
||||
return "multiple files"
|
||||
|
||||
def _grouped_interface_confidence(self, facts: list[ObservedFact]) -> float:
|
||||
valued = sum(1 for fact in facts if fact.value)
|
||||
return 0.7 if valued == len(facts) else 0.55
|
||||
|
||||
def _evidence(
|
||||
self,
|
||||
tests: list[ObservedFact],
|
||||
|
||||
Reference in New Issue
Block a user