Revert "feat(ultraplan-local): M1 — profile recommendation flow in ultrabrief"
This reverts commit 7e2d9e151e.
This commit is contained in:
parent
7e2d9e151e
commit
59f1fe1631
8 changed files with 15 additions and 609 deletions
|
|
@ -400,98 +400,6 @@ async function missingAgents(names, agentsDir) {
|
|||
return missing;
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// Recommendation helper
|
||||
// =====================================================================
|
||||
|
||||
/**
|
||||
* Recommendation threshold used by ultrabrief-local Step 4h. The
|
||||
* profile-recommender agent's top-ranked profile must reach this score to
|
||||
* be presented as a recommendation; below it, ultrabrief falls back to
|
||||
* `default` with an explicit message.
|
||||
*/
|
||||
export const RECOMMENDATION_THRESHOLD = 0.7;
|
||||
|
||||
/**
|
||||
* Decide what to do with a `profile-recommender` agent's ranked output.
|
||||
* Returns `{ profile, match, rationale, source }` where:
|
||||
* - `source` is `recommended` (top ≥ threshold), `fallback` (top < threshold
|
||||
* or empty input), or `default-only` (only `default` available).
|
||||
* - `profile` is the chosen profile name.
|
||||
* - `match` is one of `exact | partial | fallback | default-only`.
|
||||
* - `rationale` is a one-sentence explanation suitable for the brief
|
||||
* frontmatter.
|
||||
*
|
||||
* Rules:
|
||||
* - If `availableProfiles` only contains `default`, return `default-only`.
|
||||
* - If `ranked` is empty/malformed, fall back to `default` with a fallback
|
||||
* rationale.
|
||||
* - Otherwise pick the highest-scoring entry; recommend it only when
|
||||
* `score >= RECOMMENDATION_THRESHOLD`. Below threshold, recommend
|
||||
* `default` with `match: fallback` and the top entry's rationale.
|
||||
*/
|
||||
export function selectRecommendation(ranked, opts = {}) {
|
||||
const threshold = opts.threshold ?? RECOMMENDATION_THRESHOLD;
|
||||
const available = opts.availableProfiles ?? null;
|
||||
|
||||
if (Array.isArray(available) && available.length === 1 && available[0] === 'default') {
|
||||
return {
|
||||
profile: 'default',
|
||||
match: 'default-only',
|
||||
rationale: 'Only the default profile is available; recommendation skipped.',
|
||||
source: 'default-only',
|
||||
};
|
||||
}
|
||||
|
||||
if (!Array.isArray(ranked) || ranked.length === 0) {
|
||||
return {
|
||||
profile: 'default',
|
||||
match: 'fallback',
|
||||
rationale: 'profile-recommender returned no ranked profiles; using default.',
|
||||
source: 'fallback',
|
||||
};
|
||||
}
|
||||
|
||||
// Find highest-scoring entry. Treat missing/non-numeric scores as 0.
|
||||
let top = null;
|
||||
for (const entry of ranked) {
|
||||
if (!entry || typeof entry.name !== 'string') continue;
|
||||
const score = typeof entry.score === 'number' ? entry.score : 0;
|
||||
if (top === null || score > (typeof top.score === 'number' ? top.score : 0)) {
|
||||
top = { ...entry, score };
|
||||
}
|
||||
}
|
||||
|
||||
if (top === null) {
|
||||
return {
|
||||
profile: 'default',
|
||||
match: 'fallback',
|
||||
rationale: 'profile-recommender output had no usable entries; using default.',
|
||||
source: 'fallback',
|
||||
};
|
||||
}
|
||||
|
||||
if (top.score >= threshold) {
|
||||
return {
|
||||
profile: top.name,
|
||||
match: typeof top.match_quality === 'string' ? top.match_quality : 'partial',
|
||||
rationale: typeof top.rationale === 'string' && top.rationale.trim() !== ''
|
||||
? top.rationale
|
||||
: `Top-ranked profile (score ${top.score}).`,
|
||||
source: 'recommended',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
profile: 'default',
|
||||
match: 'fallback',
|
||||
rationale: typeof top.rationale === 'string' && top.rationale.trim() !== ''
|
||||
? `Top score ${top.score} below ${threshold}; ${top.rationale}`
|
||||
: `Top score ${top.score} below recommendation threshold ${threshold}.`,
|
||||
source: 'fallback',
|
||||
};
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// CLI
|
||||
// =====================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue