@slope-dev/slope 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +243 -0
- package/dist/cli/commands/auto-card.d.ts +2 -0
- package/dist/cli/commands/auto-card.d.ts.map +1 -0
- package/dist/cli/commands/auto-card.js +267 -0
- package/dist/cli/commands/auto-card.js.map +1 -0
- package/dist/cli/commands/briefing.d.ts +2 -0
- package/dist/cli/commands/briefing.d.ts.map +1 -0
- package/dist/cli/commands/briefing.js +133 -0
- package/dist/cli/commands/briefing.js.map +1 -0
- package/dist/cli/commands/card.d.ts +2 -0
- package/dist/cli/commands/card.d.ts.map +1 -0
- package/dist/cli/commands/card.js +144 -0
- package/dist/cli/commands/card.js.map +1 -0
- package/dist/cli/commands/claim.d.ts +2 -0
- package/dist/cli/commands/claim.d.ts.map +1 -0
- package/dist/cli/commands/claim.js +99 -0
- package/dist/cli/commands/claim.js.map +1 -0
- package/dist/cli/commands/classify.d.ts +2 -0
- package/dist/cli/commands/classify.d.ts.map +1 -0
- package/dist/cli/commands/classify.js +70 -0
- package/dist/cli/commands/classify.js.map +1 -0
- package/dist/cli/commands/dashboard.d.ts +4 -0
- package/dist/cli/commands/dashboard.d.ts.map +1 -0
- package/dist/cli/commands/dashboard.js +156 -0
- package/dist/cli/commands/dashboard.js.map +1 -0
- package/dist/cli/commands/distill.d.ts +2 -0
- package/dist/cli/commands/distill.d.ts.map +1 -0
- package/dist/cli/commands/distill.js +91 -0
- package/dist/cli/commands/distill.js.map +1 -0
- package/dist/cli/commands/escalate.d.ts +2 -0
- package/dist/cli/commands/escalate.d.ts.map +1 -0
- package/dist/cli/commands/escalate.js +136 -0
- package/dist/cli/commands/escalate.js.map +1 -0
- package/dist/cli/commands/extract.d.ts +2 -0
- package/dist/cli/commands/extract.d.ts.map +1 -0
- package/dist/cli/commands/extract.js +147 -0
- package/dist/cli/commands/extract.js.map +1 -0
- package/dist/cli/commands/flows.d.ts +2 -0
- package/dist/cli/commands/flows.d.ts.map +1 -0
- package/dist/cli/commands/flows.js +156 -0
- package/dist/cli/commands/flows.js.map +1 -0
- package/dist/cli/commands/guard.d.ts +15 -0
- package/dist/cli/commands/guard.d.ts.map +1 -0
- package/dist/cli/commands/guard.js +207 -0
- package/dist/cli/commands/guard.js.map +1 -0
- package/dist/cli/commands/hook.d.ts +2 -0
- package/dist/cli/commands/hook.d.ts.map +1 -0
- package/dist/cli/commands/hook.js +299 -0
- package/dist/cli/commands/hook.js.map +1 -0
- package/dist/cli/commands/init.d.ts +6 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +421 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/map.d.ts +10 -0
- package/dist/cli/commands/map.d.ts.map +1 -0
- package/dist/cli/commands/map.js +591 -0
- package/dist/cli/commands/map.js.map +1 -0
- package/dist/cli/commands/next.d.ts +2 -0
- package/dist/cli/commands/next.d.ts.map +1 -0
- package/dist/cli/commands/next.js +28 -0
- package/dist/cli/commands/next.js.map +1 -0
- package/dist/cli/commands/plan.d.ts +2 -0
- package/dist/cli/commands/plan.d.ts.map +1 -0
- package/dist/cli/commands/plan.js +54 -0
- package/dist/cli/commands/plan.js.map +1 -0
- package/dist/cli/commands/plugin.d.ts +2 -0
- package/dist/cli/commands/plugin.d.ts.map +1 -0
- package/dist/cli/commands/plugin.js +118 -0
- package/dist/cli/commands/plugin.js.map +1 -0
- package/dist/cli/commands/release.d.ts +2 -0
- package/dist/cli/commands/release.d.ts.map +1 -0
- package/dist/cli/commands/release.js +64 -0
- package/dist/cli/commands/release.js.map +1 -0
- package/dist/cli/commands/report.d.ts +2 -0
- package/dist/cli/commands/report.d.ts.map +1 -0
- package/dist/cli/commands/report.js +68 -0
- package/dist/cli/commands/report.js.map +1 -0
- package/dist/cli/commands/review-state.d.ts +11 -0
- package/dist/cli/commands/review-state.d.ts.map +1 -0
- package/dist/cli/commands/review-state.js +193 -0
- package/dist/cli/commands/review-state.js.map +1 -0
- package/dist/cli/commands/review.d.ts +2 -0
- package/dist/cli/commands/review.d.ts.map +1 -0
- package/dist/cli/commands/review.js +53 -0
- package/dist/cli/commands/review.js.map +1 -0
- package/dist/cli/commands/roadmap.d.ts +2 -0
- package/dist/cli/commands/roadmap.d.ts.map +1 -0
- package/dist/cli/commands/roadmap.js +283 -0
- package/dist/cli/commands/roadmap.js.map +1 -0
- package/dist/cli/commands/session.d.ts +2 -0
- package/dist/cli/commands/session.d.ts.map +1 -0
- package/dist/cli/commands/session.js +232 -0
- package/dist/cli/commands/session.js.map +1 -0
- package/dist/cli/commands/standup.d.ts +2 -0
- package/dist/cli/commands/standup.d.ts.map +1 -0
- package/dist/cli/commands/standup.js +117 -0
- package/dist/cli/commands/standup.js.map +1 -0
- package/dist/cli/commands/status.d.ts +2 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +148 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/tournament.d.ts +2 -0
- package/dist/cli/commands/tournament.d.ts.map +1 -0
- package/dist/cli/commands/tournament.js +60 -0
- package/dist/cli/commands/tournament.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +2 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +74 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/config.d.ts +2 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +2 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/guards/commit-nudge.d.ts +7 -0
- package/dist/cli/guards/commit-nudge.d.ts.map +1 -0
- package/dist/cli/guards/commit-nudge.js +50 -0
- package/dist/cli/guards/commit-nudge.js.map +1 -0
- package/dist/cli/guards/compaction.d.ts +8 -0
- package/dist/cli/guards/compaction.d.ts.map +1 -0
- package/dist/cli/guards/compaction.js +79 -0
- package/dist/cli/guards/compaction.js.map +1 -0
- package/dist/cli/guards/explore.d.ts +8 -0
- package/dist/cli/guards/explore.d.ts.map +1 -0
- package/dist/cli/guards/explore.js +78 -0
- package/dist/cli/guards/explore.js.map +1 -0
- package/dist/cli/guards/hazard.d.ts +7 -0
- package/dist/cli/guards/hazard.d.ts.map +1 -0
- package/dist/cli/guards/hazard.js +43 -0
- package/dist/cli/guards/hazard.js.map +1 -0
- package/dist/cli/guards/next-action.d.ts +28 -0
- package/dist/cli/guards/next-action.d.ts.map +1 -0
- package/dist/cli/guards/next-action.js +196 -0
- package/dist/cli/guards/next-action.js.map +1 -0
- package/dist/cli/guards/push-nudge.d.ts +7 -0
- package/dist/cli/guards/push-nudge.d.ts.map +1 -0
- package/dist/cli/guards/push-nudge.js +53 -0
- package/dist/cli/guards/push-nudge.js.map +1 -0
- package/dist/cli/guards/review-tier.d.ts +7 -0
- package/dist/cli/guards/review-tier.d.ts.map +1 -0
- package/dist/cli/guards/review-tier.js +108 -0
- package/dist/cli/guards/review-tier.js.map +1 -0
- package/dist/cli/guards/scope-drift.d.ts +7 -0
- package/dist/cli/guards/scope-drift.d.ts.map +1 -0
- package/dist/cli/guards/scope-drift.js +47 -0
- package/dist/cli/guards/scope-drift.js.map +1 -0
- package/dist/cli/guards/stop-check.d.ts +7 -0
- package/dist/cli/guards/stop-check.d.ts.map +1 -0
- package/dist/cli/guards/stop-check.js +34 -0
- package/dist/cli/guards/stop-check.js.map +1 -0
- package/dist/cli/guards/subagent-gate.d.ts +7 -0
- package/dist/cli/guards/subagent-gate.d.ts.map +1 -0
- package/dist/cli/guards/subagent-gate.js +39 -0
- package/dist/cli/guards/subagent-gate.js.map +1 -0
- package/dist/cli/guards/version-check.d.ts +8 -0
- package/dist/cli/guards/version-check.d.ts.map +1 -0
- package/dist/cli/guards/version-check.js +49 -0
- package/dist/cli/guards/version-check.js.map +1 -0
- package/dist/cli/guards/workflow-gate.d.ts +7 -0
- package/dist/cli/guards/workflow-gate.d.ts.map +1 -0
- package/dist/cli/guards/workflow-gate.js +31 -0
- package/dist/cli/guards/workflow-gate.js.map +1 -0
- package/dist/cli/hooks-config.d.ts +9 -0
- package/dist/cli/hooks-config.d.ts.map +1 -0
- package/dist/cli/hooks-config.js +21 -0
- package/dist/cli/hooks-config.js.map +1 -0
- package/dist/cli/index.d.ts +19 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +282 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/loader.d.ts +2 -0
- package/dist/cli/loader.d.ts.map +1 -0
- package/dist/cli/loader.js +2 -0
- package/dist/cli/loader.js.map +1 -0
- package/dist/cli/metaphor.d.ts +6 -0
- package/dist/cli/metaphor.d.ts.map +1 -0
- package/dist/cli/metaphor.js +26 -0
- package/dist/cli/metaphor.js.map +1 -0
- package/dist/cli/registries/api-registry.d.ts +11 -0
- package/dist/cli/registries/api-registry.d.ts.map +1 -0
- package/dist/cli/registries/api-registry.js +42 -0
- package/dist/cli/registries/api-registry.js.map +1 -0
- package/dist/cli/registries/file-registry.d.ts +13 -0
- package/dist/cli/registries/file-registry.d.ts.map +1 -0
- package/dist/cli/registries/file-registry.js +55 -0
- package/dist/cli/registries/file-registry.js.map +1 -0
- package/dist/cli/registries/index.d.ts +7 -0
- package/dist/cli/registries/index.d.ts.map +1 -0
- package/dist/cli/registries/index.js +20 -0
- package/dist/cli/registries/index.js.map +1 -0
- package/dist/cli/store.d.ts +3 -0
- package/dist/cli/store.d.ts.map +1 -0
- package/dist/cli/store.js +13 -0
- package/dist/cli/store.js.map +1 -0
- package/dist/cli/template-generator.d.ts +15 -0
- package/dist/cli/template-generator.d.ts.map +1 -0
- package/dist/cli/template-generator.js +562 -0
- package/dist/cli/template-generator.js.map +1 -0
- package/dist/core/advisor.d.ts +63 -0
- package/dist/core/advisor.d.ts.map +1 -0
- package/dist/core/advisor.js +395 -0
- package/dist/core/advisor.js.map +1 -0
- package/dist/core/briefing.d.ts +103 -0
- package/dist/core/briefing.d.ts.map +1 -0
- package/dist/core/briefing.js +380 -0
- package/dist/core/briefing.js.map +1 -0
- package/dist/core/builder.d.ts +70 -0
- package/dist/core/builder.d.ts.map +1 -0
- package/dist/core/builder.js +175 -0
- package/dist/core/builder.js.map +1 -0
- package/dist/core/ci-signals.d.ts +10 -0
- package/dist/core/ci-signals.d.ts.map +1 -0
- package/dist/core/ci-signals.js +145 -0
- package/dist/core/ci-signals.js.map +1 -0
- package/dist/core/config.d.ts +48 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +42 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/constants.d.ts +14 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +44 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/dashboard.d.ts +40 -0
- package/dist/core/dashboard.d.ts.map +1 -0
- package/dist/core/dashboard.js +413 -0
- package/dist/core/dashboard.js.map +1 -0
- package/dist/core/dispersion.d.ts +12 -0
- package/dist/core/dispersion.d.ts.map +1 -0
- package/dist/core/dispersion.js +164 -0
- package/dist/core/dispersion.js.map +1 -0
- package/dist/core/escalation.d.ts +52 -0
- package/dist/core/escalation.d.ts.map +1 -0
- package/dist/core/escalation.js +105 -0
- package/dist/core/escalation.js.map +1 -0
- package/dist/core/flows.d.ts +44 -0
- package/dist/core/flows.d.ts.map +1 -0
- package/dist/core/flows.js +123 -0
- package/dist/core/flows.js.map +1 -0
- package/dist/core/formatter.d.ts +23 -0
- package/dist/core/formatter.d.ts.map +1 -0
- package/dist/core/formatter.js +301 -0
- package/dist/core/formatter.js.map +1 -0
- package/dist/core/guard.d.ts +124 -0
- package/dist/core/guard.d.ts.map +1 -0
- package/dist/core/guard.js +185 -0
- package/dist/core/guard.js.map +1 -0
- package/dist/core/handicap.d.ts +22 -0
- package/dist/core/handicap.d.ts.map +1 -0
- package/dist/core/handicap.js +111 -0
- package/dist/core/handicap.js.map +1 -0
- package/dist/core/index.d.ts +55 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +62 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/leaderboard.d.ts +32 -0
- package/dist/core/leaderboard.d.ts.map +1 -0
- package/dist/core/leaderboard.js +98 -0
- package/dist/core/leaderboard.js.map +1 -0
- package/dist/core/loader.d.ts +17 -0
- package/dist/core/loader.d.ts.map +1 -0
- package/dist/core/loader.js +68 -0
- package/dist/core/loader.js.map +1 -0
- package/dist/core/metaphor.d.ts +73 -0
- package/dist/core/metaphor.d.ts.map +1 -0
- package/dist/core/metaphor.js +73 -0
- package/dist/core/metaphor.js.map +1 -0
- package/dist/core/metaphors/baseball.d.ts +3 -0
- package/dist/core/metaphors/baseball.d.ts.map +1 -0
- package/dist/core/metaphors/baseball.js +89 -0
- package/dist/core/metaphors/baseball.js.map +1 -0
- package/dist/core/metaphors/dnd.d.ts +3 -0
- package/dist/core/metaphors/dnd.d.ts.map +1 -0
- package/dist/core/metaphors/dnd.js +89 -0
- package/dist/core/metaphors/dnd.js.map +1 -0
- package/dist/core/metaphors/gaming.d.ts +3 -0
- package/dist/core/metaphors/gaming.d.ts.map +1 -0
- package/dist/core/metaphors/gaming.js +89 -0
- package/dist/core/metaphors/gaming.js.map +1 -0
- package/dist/core/metaphors/golf.d.ts +3 -0
- package/dist/core/metaphors/golf.d.ts.map +1 -0
- package/dist/core/metaphors/golf.js +89 -0
- package/dist/core/metaphors/golf.js.map +1 -0
- package/dist/core/metaphors/index.d.ts +8 -0
- package/dist/core/metaphors/index.d.ts.map +1 -0
- package/dist/core/metaphors/index.js +17 -0
- package/dist/core/metaphors/index.js.map +1 -0
- package/dist/core/metaphors/matrix.d.ts +3 -0
- package/dist/core/metaphors/matrix.d.ts.map +1 -0
- package/dist/core/metaphors/matrix.js +89 -0
- package/dist/core/metaphors/matrix.js.map +1 -0
- package/dist/core/metaphors/tennis.d.ts +3 -0
- package/dist/core/metaphors/tennis.d.ts.map +1 -0
- package/dist/core/metaphors/tennis.js +89 -0
- package/dist/core/metaphors/tennis.js.map +1 -0
- package/dist/core/pipeline.d.ts +39 -0
- package/dist/core/pipeline.d.ts.map +1 -0
- package/dist/core/pipeline.js +158 -0
- package/dist/core/pipeline.js.map +1 -0
- package/dist/core/player.d.ts +51 -0
- package/dist/core/player.d.ts.map +1 -0
- package/dist/core/player.js +101 -0
- package/dist/core/player.js.map +1 -0
- package/dist/core/plugins.d.ts +33 -0
- package/dist/core/plugins.d.ts.map +1 -0
- package/dist/core/plugins.js +176 -0
- package/dist/core/plugins.js.map +1 -0
- package/dist/core/pr-signals.d.ts +23 -0
- package/dist/core/pr-signals.d.ts.map +1 -0
- package/dist/core/pr-signals.js +178 -0
- package/dist/core/pr-signals.js.map +1 -0
- package/dist/core/registry.d.ts +20 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +62 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/report.d.ts +50 -0
- package/dist/core/report.d.ts.map +1 -0
- package/dist/core/report.js +392 -0
- package/dist/core/report.js.map +1 -0
- package/dist/core/roadmap.d.ts +74 -0
- package/dist/core/roadmap.d.ts.map +1 -0
- package/dist/core/roadmap.js +389 -0
- package/dist/core/roadmap.js.map +1 -0
- package/dist/core/roles.d.ts +23 -0
- package/dist/core/roles.d.ts.map +1 -0
- package/dist/core/roles.js +107 -0
- package/dist/core/roles.js.map +1 -0
- package/dist/core/standup.d.ts +44 -0
- package/dist/core/standup.d.ts.map +1 -0
- package/dist/core/standup.js +164 -0
- package/dist/core/standup.js.map +1 -0
- package/dist/core/store.d.ts +43 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/core/store.js +11 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/team-handicap.d.ts +59 -0
- package/dist/core/team-handicap.d.ts.map +1 -0
- package/dist/core/team-handicap.js +227 -0
- package/dist/core/team-handicap.js.map +1 -0
- package/dist/core/tournament.d.ts +12 -0
- package/dist/core/tournament.d.ts.map +1 -0
- package/dist/core/tournament.js +249 -0
- package/dist/core/tournament.js.map +1 -0
- package/dist/core/types.d.ts +339 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +4 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/validation.d.ts +23 -0
- package/dist/core/validation.d.ts.map +1 -0
- package/dist/core/validation.js +140 -0
- package/dist/core/validation.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.d.ts +17 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +363 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/index.test.d.ts +2 -0
- package/dist/mcp/index.test.d.ts.map +1 -0
- package/dist/mcp/index.test.js +497 -0
- package/dist/mcp/index.test.js.map +1 -0
- package/dist/mcp/registry.d.ts +17 -0
- package/dist/mcp/registry.d.ts.map +1 -0
- package/dist/mcp/registry.js +708 -0
- package/dist/mcp/registry.js.map +1 -0
- package/dist/mcp/sandbox.d.ts +15 -0
- package/dist/mcp/sandbox.d.ts.map +1 -0
- package/dist/mcp/sandbox.js +153 -0
- package/dist/mcp/sandbox.js.map +1 -0
- package/dist/store/index.d.ts +40 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +324 -0
- package/dist/store/index.js.map +1 -0
- package/dist/tokens/colors.d.ts +47 -0
- package/dist/tokens/colors.d.ts.map +1 -0
- package/dist/tokens/colors.js +56 -0
- package/dist/tokens/colors.js.map +1 -0
- package/dist/tokens/css.d.ts +3 -0
- package/dist/tokens/css.d.ts.map +1 -0
- package/dist/tokens/css.js +58 -0
- package/dist/tokens/css.js.map +1 -0
- package/dist/tokens/index.d.ts +5 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +6 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/spacing.d.ts +23 -0
- package/dist/tokens/spacing.d.ts.map +1 -0
- package/dist/tokens/spacing.js +28 -0
- package/dist/tokens/spacing.js.map +1 -0
- package/dist/tokens/typography.d.ts +28 -0
- package/dist/tokens/typography.d.ts.map +1 -0
- package/dist/tokens/typography.js +34 -0
- package/dist/tokens/typography.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { computeHandicapCard } from './handicap.js';
|
|
2
|
+
import { computeDispersion } from './dispersion.js';
|
|
3
|
+
import { generateTrainingPlan } from './advisor.js';
|
|
4
|
+
import { checkConflicts } from './registry.js';
|
|
5
|
+
import { formatStrategicContext } from './roadmap.js';
|
|
6
|
+
// --- Library functions ---
|
|
7
|
+
/**
|
|
8
|
+
* Filter common issues to only those relevant to the sprint's work.
|
|
9
|
+
* Matches by category list and/or keyword search in title/description/prevention.
|
|
10
|
+
* Returns at most 10 results, sorted by most-recently-hit sprint (descending).
|
|
11
|
+
*/
|
|
12
|
+
export function filterCommonIssues(issues, filter) {
|
|
13
|
+
let results = issues.recurring_patterns;
|
|
14
|
+
if (filter.categories && filter.categories.length > 0) {
|
|
15
|
+
const cats = new Set(filter.categories.map(c => c.toLowerCase()));
|
|
16
|
+
results = results.filter(p => cats.has(p.category.toLowerCase()));
|
|
17
|
+
}
|
|
18
|
+
if (filter.keywords && filter.keywords.length > 0) {
|
|
19
|
+
const kws = filter.keywords.map(k => k.toLowerCase());
|
|
20
|
+
results = results.filter(p => {
|
|
21
|
+
const text = `${p.title} ${p.description} ${p.prevention}`.toLowerCase();
|
|
22
|
+
return kws.some(kw => text.includes(kw));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
// Sort by most recent sprint hit (descending)
|
|
26
|
+
results = [...results].sort((a, b) => {
|
|
27
|
+
const aMax = Math.max(...a.sprints_hit, 0);
|
|
28
|
+
const bMax = Math.max(...b.sprints_hit, 0);
|
|
29
|
+
return bMax - aMax;
|
|
30
|
+
});
|
|
31
|
+
return results.slice(0, 10);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Extract all hazards from scorecards into a flat searchable index.
|
|
35
|
+
* Optionally filter by keyword in the hazard description.
|
|
36
|
+
*/
|
|
37
|
+
export function extractHazardIndex(scorecards, keyword) {
|
|
38
|
+
const shotHazards = [];
|
|
39
|
+
const bunkers = [];
|
|
40
|
+
const kw = keyword?.toLowerCase();
|
|
41
|
+
for (const sc of scorecards) {
|
|
42
|
+
const sprintNum = sc.sprint_number ?? sc.sprint;
|
|
43
|
+
for (const shot of sc.shots ?? []) {
|
|
44
|
+
for (const h of shot.hazards ?? []) {
|
|
45
|
+
const desc = h.description ?? '';
|
|
46
|
+
if (!kw || desc.toLowerCase().includes(kw)) {
|
|
47
|
+
shotHazards.push({
|
|
48
|
+
sprint: sprintNum,
|
|
49
|
+
ticket: shot.ticket_key,
|
|
50
|
+
type: h.type,
|
|
51
|
+
description: desc,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for (const loc of sc.bunker_locations ?? []) {
|
|
57
|
+
const locStr = typeof loc === 'string' ? loc : loc?.area ?? '';
|
|
58
|
+
if (!kw || locStr.toLowerCase().includes(kw)) {
|
|
59
|
+
bunkers.push({ sprint: sprintNum, location: locStr });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return { shot_hazards: shotHazards, bunker_locations: bunkers };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Compute nutrition trends across scorecards.
|
|
67
|
+
* Shows which dev health categories are consistently healthy vs neglected.
|
|
68
|
+
*/
|
|
69
|
+
export function computeNutritionTrend(scorecards) {
|
|
70
|
+
const counts = {};
|
|
71
|
+
for (const sc of scorecards) {
|
|
72
|
+
if (!sc.nutrition || !Array.isArray(sc.nutrition))
|
|
73
|
+
continue;
|
|
74
|
+
for (const entry of sc.nutrition) {
|
|
75
|
+
if (!counts[entry.category]) {
|
|
76
|
+
counts[entry.category] = { healthy: 0, needs_attention: 0, neglected: 0 };
|
|
77
|
+
}
|
|
78
|
+
counts[entry.category][entry.status]++;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return Object.entries(counts).map(([category, data]) => {
|
|
82
|
+
const total = data.healthy + data.needs_attention + data.neglected;
|
|
83
|
+
let trend;
|
|
84
|
+
if (data.neglected > total / 2) {
|
|
85
|
+
trend = 'neglected';
|
|
86
|
+
}
|
|
87
|
+
else if (data.healthy >= total / 2) {
|
|
88
|
+
trend = 'healthy';
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
trend = 'mixed';
|
|
92
|
+
}
|
|
93
|
+
return { category: category, ...data, trend };
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Generate hazard warnings for specific areas, formatted for agent instruction injection.
|
|
98
|
+
*
|
|
99
|
+
* Filters extractHazardIndex() to only hazards in the target areas,
|
|
100
|
+
* then formats as "WARNING: [area] — [description] (seen in S{N})".
|
|
101
|
+
*/
|
|
102
|
+
export function hazardBriefing(opts) {
|
|
103
|
+
const { areas, scorecards } = opts;
|
|
104
|
+
if (areas.length === 0 || scorecards.length === 0)
|
|
105
|
+
return [];
|
|
106
|
+
const warnings = [];
|
|
107
|
+
const loweredAreas = areas.map(a => a.toLowerCase());
|
|
108
|
+
for (const sc of scorecards) {
|
|
109
|
+
const sprintNum = sc.sprint_number ?? sc.sprint;
|
|
110
|
+
for (const shot of sc.shots ?? []) {
|
|
111
|
+
for (const h of shot.hazards ?? []) {
|
|
112
|
+
const desc = (h.description ?? '').toLowerCase();
|
|
113
|
+
if (loweredAreas.some(area => desc.includes(area))) {
|
|
114
|
+
warnings.push(`WARNING: ${h.type} — ${h.description ?? 'unknown'} (seen in S${sprintNum})`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
for (const loc of sc.bunker_locations ?? []) {
|
|
119
|
+
const locStr = typeof loc === 'string' ? loc : loc?.area ?? '';
|
|
120
|
+
const lowLoc = locStr.toLowerCase();
|
|
121
|
+
if (loweredAreas.some(area => lowLoc.includes(area))) {
|
|
122
|
+
warnings.push(`WARNING: bunker — ${locStr} (seen in S${sprintNum})`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return warnings;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Format the complete pre-round briefing.
|
|
130
|
+
* Combines handicap card, filtered hazards, filtered common issues,
|
|
131
|
+
* nutrition trends, and session continuity into a single compact output.
|
|
132
|
+
*
|
|
133
|
+
* Replaces reading ~15k tokens across 3-4 files with ~500 tokens of output.
|
|
134
|
+
*/
|
|
135
|
+
export function formatBriefing(opts) {
|
|
136
|
+
const { scorecards, commonIssues, lastSession, filter, includeTraining = true, claims, roadmap, currentSprint, metaphor: m, role, recentEvents, eventRecencyWindow = 5, prSignal } = opts;
|
|
137
|
+
const lines = [];
|
|
138
|
+
// Merge role's briefingFilter with explicit filter (explicit filter takes precedence)
|
|
139
|
+
const effectiveFilter = mergeRoleFilter(filter, role);
|
|
140
|
+
// Section 1: Handicap snapshot
|
|
141
|
+
const briefingTitle = m ? m.vocabulary.briefing.toUpperCase() : 'PRE-ROUND BRIEFING';
|
|
142
|
+
lines.push(briefingTitle);
|
|
143
|
+
if (role) {
|
|
144
|
+
lines.push(`Role: ${role.name} — ${role.description}`);
|
|
145
|
+
}
|
|
146
|
+
lines.push('\u2550'.repeat(50));
|
|
147
|
+
if (scorecards.length > 0) {
|
|
148
|
+
const card = computeHandicapCard(scorecards);
|
|
149
|
+
const latest = scorecards[scorecards.length - 1];
|
|
150
|
+
const latestNum = latest.sprint_number ?? latest.sprint;
|
|
151
|
+
lines.push('');
|
|
152
|
+
lines.push(`Handicap: +${card.all_time.handicap.toFixed(1)} (${scorecards.length} scorecard${scorecards.length === 1 ? '' : 's'})`);
|
|
153
|
+
lines.push(`Fairways: ${card.all_time.fairway_pct.toFixed(1)}% GIR: ${card.all_time.gir_pct.toFixed(1)}% Putts: ${card.all_time.avg_putts.toFixed(1)} Penalties: ${card.all_time.penalties_per_round.toFixed(1)}`);
|
|
154
|
+
// Miss pattern
|
|
155
|
+
const mp = card.all_time.miss_pattern;
|
|
156
|
+
const totalMisses = mp.long + mp.short + mp.left + mp.right;
|
|
157
|
+
if (totalMisses > 0) {
|
|
158
|
+
const dirs = ['long', 'short', 'left', 'right']
|
|
159
|
+
.filter(d => mp[d] > 0)
|
|
160
|
+
.map(d => `${d}:${mp[d]}`);
|
|
161
|
+
lines.push(`Miss pattern: ${dirs.join(' ')} (${totalMisses} total)`);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
lines.push('Miss pattern: Clean \u2014 no misses recorded.');
|
|
165
|
+
}
|
|
166
|
+
const scoreDisplay = m?.scoreLabels[latest.score_label] ?? latest.score_label;
|
|
167
|
+
lines.push(`Latest: S${latestNum} ${scoreDisplay} (${latest.score} vs par ${latest.par})`);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
lines.push('');
|
|
171
|
+
lines.push('No SLOPE-era scorecards yet.');
|
|
172
|
+
}
|
|
173
|
+
// Section 1.5: Strategic context (from roadmap)
|
|
174
|
+
if (roadmap && currentSprint) {
|
|
175
|
+
const context = formatStrategicContext(roadmap, currentSprint);
|
|
176
|
+
if (context) {
|
|
177
|
+
lines.push('');
|
|
178
|
+
lines.push('\u2500'.repeat(50));
|
|
179
|
+
lines.push('STRATEGIC CONTEXT');
|
|
180
|
+
for (const line of context.split('\n')) {
|
|
181
|
+
lines.push(` ${line}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Section 2: Hazard index
|
|
186
|
+
lines.push('');
|
|
187
|
+
lines.push('\u2500'.repeat(50));
|
|
188
|
+
lines.push('HAZARDS');
|
|
189
|
+
const hazards = extractHazardIndex(scorecards, filter?.keywords?.[0]);
|
|
190
|
+
let filteredBunkers = hazards.bunker_locations;
|
|
191
|
+
let filteredShotHazards = hazards.shot_hazards;
|
|
192
|
+
// Role-based focus area filtering: show only hazards relevant to the role's focus
|
|
193
|
+
if (role && role.focusAreas.length > 0) {
|
|
194
|
+
const focusLow = role.focusAreas.map(a => a.replace(/\*/g, '').replace(/\/$/, '').toLowerCase());
|
|
195
|
+
filteredBunkers = filteredBunkers.filter(b => focusLow.some(f => b.location.toLowerCase().includes(f)));
|
|
196
|
+
filteredShotHazards = filteredShotHazards.filter(h => focusLow.some(f => h.description.toLowerCase().includes(f) || h.ticket.toLowerCase().includes(f)));
|
|
197
|
+
}
|
|
198
|
+
if (filteredBunkers.length > 0 || filteredShotHazards.length > 0) {
|
|
199
|
+
for (const h of filteredShotHazards) {
|
|
200
|
+
lines.push(` [S${h.sprint}] ${h.type}: ${h.description}`);
|
|
201
|
+
}
|
|
202
|
+
for (const b of filteredBunkers) {
|
|
203
|
+
lines.push(` [S${b.sprint}] ${b.location}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
lines.push(' No bunker locations recorded.');
|
|
208
|
+
}
|
|
209
|
+
// Section 2.5: Course status (active claims)
|
|
210
|
+
lines.push('');
|
|
211
|
+
lines.push('\u2500'.repeat(50));
|
|
212
|
+
lines.push('COURSE STATUS');
|
|
213
|
+
if (!claims || claims.length === 0) {
|
|
214
|
+
lines.push(' No active claims.');
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
// Group claims by player
|
|
218
|
+
const byPlayer = new Map();
|
|
219
|
+
for (const c of claims) {
|
|
220
|
+
const list = byPlayer.get(c.player) || [];
|
|
221
|
+
list.push(c);
|
|
222
|
+
byPlayer.set(c.player, list);
|
|
223
|
+
}
|
|
224
|
+
for (const [player, playerClaims] of byPlayer) {
|
|
225
|
+
lines.push(` ${player}:`);
|
|
226
|
+
for (const c of playerClaims) {
|
|
227
|
+
const tag = c.scope === 'area' ? '[area]' : '[ticket]';
|
|
228
|
+
const notes = c.notes ? ` — ${c.notes}` : '';
|
|
229
|
+
lines.push(` ${tag} ${c.target}${notes}`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// Show conflicts
|
|
233
|
+
const conflicts = checkConflicts(claims);
|
|
234
|
+
if (conflicts.length > 0) {
|
|
235
|
+
lines.push('');
|
|
236
|
+
lines.push(' Conflicts:');
|
|
237
|
+
for (const c of conflicts) {
|
|
238
|
+
const icon = c.severity === 'overlap' ? '[!!]' : '[~]';
|
|
239
|
+
lines.push(` ${icon} ${c.reason}`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// Section 2.6: PR context (when available)
|
|
244
|
+
if (prSignal) {
|
|
245
|
+
lines.push('');
|
|
246
|
+
lines.push('\u2500'.repeat(50));
|
|
247
|
+
lines.push('PR CONTEXT');
|
|
248
|
+
lines.push(` PR: #${prSignal.pr_number} (${prSignal.platform})`);
|
|
249
|
+
lines.push(` Review: ${prSignal.review_decision} — ${prSignal.review_cycles} cycle(s), ${prSignal.change_request_count} change request(s)`);
|
|
250
|
+
lines.push(` Files: ${prSignal.file_count} (+${prSignal.additions} / -${prSignal.deletions})`);
|
|
251
|
+
lines.push(` CI checks: ${prSignal.ci_checks_passed} passed, ${prSignal.ci_checks_failed} failed`);
|
|
252
|
+
lines.push(` Comments: ${prSignal.comment_count}${prSignal.file_count > 0 ? ` (${(prSignal.comment_count / prSignal.file_count).toFixed(1)}/file)` : ''}`);
|
|
253
|
+
if (prSignal.time_to_merge_minutes !== null) {
|
|
254
|
+
const hours = Math.floor(prSignal.time_to_merge_minutes / 60);
|
|
255
|
+
const mins = prSignal.time_to_merge_minutes % 60;
|
|
256
|
+
lines.push(` Time to merge: ${hours > 0 ? `${hours}h ` : ''}${mins}m`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Section 2.75: Recent events from telemetry
|
|
260
|
+
if (recentEvents && recentEvents.length > 0 && currentSprint) {
|
|
261
|
+
const minSprint = currentSprint - eventRecencyWindow;
|
|
262
|
+
const relevant = recentEvents.filter(e => e.sprint_number != null && e.sprint_number > minSprint);
|
|
263
|
+
if (relevant.length > 0) {
|
|
264
|
+
// Group by type for compact display
|
|
265
|
+
const byType = new Map();
|
|
266
|
+
for (const e of relevant) {
|
|
267
|
+
const list = byType.get(e.type) || [];
|
|
268
|
+
list.push(e);
|
|
269
|
+
byType.set(e.type, list);
|
|
270
|
+
}
|
|
271
|
+
lines.push('');
|
|
272
|
+
lines.push('\u2500'.repeat(50));
|
|
273
|
+
lines.push(`RECENT EVENTS (last ${eventRecencyWindow} sprints)`);
|
|
274
|
+
for (const [type, events] of byType) {
|
|
275
|
+
const sprints = [...new Set(events.map(e => e.sprint_number))].sort((a, b) => (a ?? 0) - (b ?? 0));
|
|
276
|
+
const sprintList = sprints.map(s => `S${s}`).join(', ');
|
|
277
|
+
const sample = events[0];
|
|
278
|
+
const desc = sample.data.error ?? sample.data.description ?? sample.data.area ?? '';
|
|
279
|
+
const descSuffix = desc ? ` — ${desc.slice(0, 80)}${desc.length > 80 ? '...' : ''}` : '';
|
|
280
|
+
lines.push(` [${type}] x${events.length} (${sprintList})${descSuffix}`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// Section 3: Nutrition trends
|
|
285
|
+
if (scorecards.length > 0) {
|
|
286
|
+
const nutrition = computeNutritionTrend(scorecards);
|
|
287
|
+
const issues = nutrition.filter(n => n.trend !== 'healthy');
|
|
288
|
+
if (issues.length > 0) {
|
|
289
|
+
lines.push('');
|
|
290
|
+
lines.push('\u2500'.repeat(50));
|
|
291
|
+
lines.push('NUTRITION ALERTS');
|
|
292
|
+
for (const n of issues) {
|
|
293
|
+
const icon = n.trend === 'neglected' ? '!!' : '! ';
|
|
294
|
+
lines.push(` ${icon} ${n.category}: ${n.trend} (${n.healthy}h/${n.needs_attention}a/${n.neglected}n)`);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// Section 4: Relevant common issues (role emphasis applied)
|
|
299
|
+
let filtered = effectiveFilter
|
|
300
|
+
? filterCommonIssues(commonIssues, effectiveFilter)
|
|
301
|
+
: filterCommonIssues(commonIssues, {}); // Return top 10 by recency if no filter
|
|
302
|
+
// Role deemphasis: push deemphasized categories to the end
|
|
303
|
+
if (role && role.briefingFilter.deemphasize.length > 0) {
|
|
304
|
+
const deempSet = new Set(role.briefingFilter.deemphasize.map(d => d.toLowerCase()));
|
|
305
|
+
filtered = [
|
|
306
|
+
...filtered.filter(p => !deempSet.has(p.category.toLowerCase())),
|
|
307
|
+
...filtered.filter(p => deempSet.has(p.category.toLowerCase())),
|
|
308
|
+
];
|
|
309
|
+
}
|
|
310
|
+
if (filtered.length > 0) {
|
|
311
|
+
lines.push('');
|
|
312
|
+
lines.push('\u2500'.repeat(50));
|
|
313
|
+
const label = filter?.categories?.length || filter?.keywords?.length
|
|
314
|
+
? 'RELEVANT GOTCHAS'
|
|
315
|
+
: 'RECENT GOTCHAS';
|
|
316
|
+
lines.push(`${label} (${filtered.length}/${commonIssues.recurring_patterns.length} patterns)`);
|
|
317
|
+
for (const p of filtered) {
|
|
318
|
+
const lastHit = Math.max(...p.sprints_hit);
|
|
319
|
+
const reporterTag = (p.reported_by && p.reported_by.length > 1) ? ` [${p.reported_by.length} reporters]` : '';
|
|
320
|
+
lines.push(` [${p.category}] ${p.title} (last: S${lastHit})${reporterTag}`);
|
|
321
|
+
lines.push(` Prevention: ${p.prevention.slice(0, 120)}${p.prevention.length > 120 ? '...' : ''}`);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
// Section 5: Training recommendations
|
|
325
|
+
if (includeTraining && scorecards.length > 0) {
|
|
326
|
+
const handicap = computeHandicapCard(scorecards);
|
|
327
|
+
const dispersion = computeDispersion(scorecards);
|
|
328
|
+
const plan = generateTrainingPlan({ handicap, dispersion, recentScorecards: scorecards });
|
|
329
|
+
const relevant = plan.filter(t => t.priority === 'high' || t.priority === 'medium');
|
|
330
|
+
if (relevant.length > 0) {
|
|
331
|
+
lines.push('');
|
|
332
|
+
lines.push('\u2500'.repeat(50));
|
|
333
|
+
lines.push('TRAINING RECOMMENDATIONS');
|
|
334
|
+
for (const item of relevant) {
|
|
335
|
+
const icon = item.priority === 'high' ? '!!' : '! ';
|
|
336
|
+
const adjustment = item.instruction_adjustment ?? item.description;
|
|
337
|
+
const typeDisplay = m?.trainingTypes[item.type] ?? item.type;
|
|
338
|
+
lines.push(` ${icon} [${typeDisplay}] ${item.area}`);
|
|
339
|
+
lines.push(` ${adjustment.slice(0, 120)}${adjustment.length > 120 ? '...' : ''}`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
// Section 6: Session continuity
|
|
344
|
+
if (lastSession) {
|
|
345
|
+
lines.push('');
|
|
346
|
+
lines.push('\u2500'.repeat(50));
|
|
347
|
+
lines.push('LAST SESSION');
|
|
348
|
+
lines.push(` ${lastSession.date} \u2014 ${lastSession.sprint}`);
|
|
349
|
+
lines.push(` ${lastSession.summary}`);
|
|
350
|
+
lines.push(` Left off: ${lastSession.where_left_off}`);
|
|
351
|
+
}
|
|
352
|
+
lines.push('');
|
|
353
|
+
return lines.join('\n');
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Merge a role's briefingFilter with an explicit filter.
|
|
357
|
+
* Role emphasis keywords are added to the filter's keywords list,
|
|
358
|
+
* enabling role-aware filtering without losing explicit user filters.
|
|
359
|
+
* Explicit filter categories/keywords take precedence — role adds to them.
|
|
360
|
+
*/
|
|
361
|
+
function mergeRoleFilter(filter, role) {
|
|
362
|
+
if (!role || role.briefingFilter.emphasize.length === 0) {
|
|
363
|
+
return filter;
|
|
364
|
+
}
|
|
365
|
+
const roleKeywords = role.briefingFilter.emphasize;
|
|
366
|
+
if (!filter) {
|
|
367
|
+
return { keywords: roleKeywords };
|
|
368
|
+
}
|
|
369
|
+
// Merge: explicit keywords + role emphasis keywords
|
|
370
|
+
const merged = { ...filter };
|
|
371
|
+
if (merged.keywords && merged.keywords.length > 0) {
|
|
372
|
+
// User already specified keywords — keep them, add role keywords
|
|
373
|
+
merged.keywords = [...merged.keywords, ...roleKeywords];
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
merged.keywords = roleKeywords;
|
|
377
|
+
}
|
|
378
|
+
return merged;
|
|
379
|
+
}
|
|
380
|
+
//# sourceMappingURL=briefing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"briefing.js","sourceRoot":"","sources":["../../src/core/briefing.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAwDtD,4BAA4B;AAE5B;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAwB,EACxB,MAAsB;IAEtB,IAAI,OAAO,GAAG,MAAM,CAAC,kBAAkB,CAAC;IAExC,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QAClE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClD,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC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MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;IACnD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IACpC,CAAC;IAED,oDAAoD;IACpD,MAAM,MAAM,GAAmB,EAAE,GAAG,MAAM,EAAE,CAAC;IAC7C,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClD,iEAAiE;QACjE,MAAM,CAAC,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,EAAE,GAAG,YAAY,CAAC,CAAC;IAC1D,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,QAAQ,GAAG,YAAY,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { GolfScorecard, ShotRecord, HoleStats, ConditionRecord, SpecialPlay, TrainingSession, NutritionEntry, NineteenthHole, SprintType, AgentBreakdown } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Compute HoleStats from a shots array.
|
|
4
|
+
* Derives fairways_hit, GIR, hazards_hit, and miss_directions
|
|
5
|
+
* entirely from shot data — no manual counting needed.
|
|
6
|
+
*
|
|
7
|
+
* - fairways_total = shots.length (every ticket is a fairway opportunity)
|
|
8
|
+
* - fairways_hit = shots where result is fairway, green, or in_the_hole
|
|
9
|
+
* - greens_total = shots.length
|
|
10
|
+
* - greens_in_regulation = shots where result is green or in_the_hole
|
|
11
|
+
* - hazards_hit = total hazards across all shots
|
|
12
|
+
* - miss_directions = count of each missed_* result direction
|
|
13
|
+
* - putts and penalties default to 0 (must be provided separately if needed)
|
|
14
|
+
*/
|
|
15
|
+
export declare function computeStatsFromShots(shots: ShotRecord[], overrides?: {
|
|
16
|
+
putts?: number;
|
|
17
|
+
penalties?: number;
|
|
18
|
+
}): HoleStats;
|
|
19
|
+
/**
|
|
20
|
+
* Normalize any stats shape to a proper HoleStats object.
|
|
21
|
+
* Handles the simplified format ({ fairway: true, putts: 0 }) used by
|
|
22
|
+
* some scorecards, falling back to safe defaults for missing fields.
|
|
23
|
+
*/
|
|
24
|
+
export declare function normalizeStats(raw: unknown, shotCount?: number): HoleStats;
|
|
25
|
+
/** Minimal input for building a scorecard — everything else is computed */
|
|
26
|
+
export interface ScorecardInput {
|
|
27
|
+
sprint_number: number;
|
|
28
|
+
theme: string;
|
|
29
|
+
par: 3 | 4 | 5;
|
|
30
|
+
slope: number;
|
|
31
|
+
date: string;
|
|
32
|
+
shots: ShotRecord[];
|
|
33
|
+
player?: string;
|
|
34
|
+
putts?: number;
|
|
35
|
+
penalties?: number;
|
|
36
|
+
type?: SprintType;
|
|
37
|
+
conditions?: ConditionRecord[];
|
|
38
|
+
special_plays?: SpecialPlay[];
|
|
39
|
+
training?: TrainingSession[];
|
|
40
|
+
nutrition?: NutritionEntry[];
|
|
41
|
+
nineteenth_hole?: NineteenthHole;
|
|
42
|
+
bunker_locations?: string[];
|
|
43
|
+
yardage_book_updates?: string[];
|
|
44
|
+
course_management_notes?: string[];
|
|
45
|
+
agents?: AgentBreakdown[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Build a complete GolfScorecard from minimal input.
|
|
49
|
+
*
|
|
50
|
+
* Auto-computes:
|
|
51
|
+
* - stats (from shots array via computeStatsFromShots)
|
|
52
|
+
* - score (shots.length + penalties)
|
|
53
|
+
* - score_label (from computeScoreLabel)
|
|
54
|
+
*
|
|
55
|
+
* You only need to provide the parts requiring judgment:
|
|
56
|
+
* shot results, hazard descriptions, training, nutrition, reflection.
|
|
57
|
+
*/
|
|
58
|
+
export declare function buildScorecard(input: ScorecardInput): GolfScorecard;
|
|
59
|
+
/** Input for building per-agent breakdowns from swarm session data */
|
|
60
|
+
export interface AgentShotInput {
|
|
61
|
+
session_id: string;
|
|
62
|
+
agent_role: string;
|
|
63
|
+
shots: ShotRecord[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Build AgentBreakdown entries from per-agent shot data.
|
|
67
|
+
* Each agent's score and stats are computed independently.
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildAgentBreakdowns(agents: AgentShotInput[]): AgentBreakdown[];
|
|
70
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/core/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EAEV,SAAS,EAET,eAAe,EACf,WAAW,EACX,eAAe,EACf,cAAc,EACd,cAAc,EACd,UAAU,EAEV,cAAc,EACf,MAAM,YAAY,CAAC;AAepB;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,UAAU,EAAE,EACnB,SAAS,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACjD,SAAS,CAuCX;AAID;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,SAAI,GAAG,SAAS,CAwCrE;AAgBD,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;IAC/B,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;IAC7B,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IAGnC,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,aAAa,CAgCnE;AAID,sEAAsE;AACtE,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAW/E"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { computeScoreLabel } from './handicap.js';
|
|
2
|
+
import { HAZARD_SEVERITY_PENALTIES } from './constants.js';
|
|
3
|
+
// --- Helpers ---
|
|
4
|
+
const MISS_RESULT_TO_DIR = {
|
|
5
|
+
missed_long: 'long',
|
|
6
|
+
missed_short: 'short',
|
|
7
|
+
missed_left: 'left',
|
|
8
|
+
missed_right: 'right',
|
|
9
|
+
};
|
|
10
|
+
// --- Stats computation ---
|
|
11
|
+
/**
|
|
12
|
+
* Compute HoleStats from a shots array.
|
|
13
|
+
* Derives fairways_hit, GIR, hazards_hit, and miss_directions
|
|
14
|
+
* entirely from shot data — no manual counting needed.
|
|
15
|
+
*
|
|
16
|
+
* - fairways_total = shots.length (every ticket is a fairway opportunity)
|
|
17
|
+
* - fairways_hit = shots where result is fairway, green, or in_the_hole
|
|
18
|
+
* - greens_total = shots.length
|
|
19
|
+
* - greens_in_regulation = shots where result is green or in_the_hole
|
|
20
|
+
* - hazards_hit = total hazards across all shots
|
|
21
|
+
* - miss_directions = count of each missed_* result direction
|
|
22
|
+
* - putts and penalties default to 0 (must be provided separately if needed)
|
|
23
|
+
*/
|
|
24
|
+
export function computeStatsFromShots(shots, overrides) {
|
|
25
|
+
let fairwaysHit = 0;
|
|
26
|
+
let greensInReg = 0;
|
|
27
|
+
let hazardsHit = 0;
|
|
28
|
+
let hazardPenalties = 0;
|
|
29
|
+
const missDirs = { long: 0, short: 0, left: 0, right: 0 };
|
|
30
|
+
for (const shot of shots) {
|
|
31
|
+
// Fairway hit = clean start (not a miss)
|
|
32
|
+
if (shot.result === 'fairway' || shot.result === 'green' || shot.result === 'in_the_hole') {
|
|
33
|
+
fairwaysHit++;
|
|
34
|
+
}
|
|
35
|
+
// Green in regulation = landed on green or holed
|
|
36
|
+
if (shot.result === 'green' || shot.result === 'in_the_hole') {
|
|
37
|
+
greensInReg++;
|
|
38
|
+
}
|
|
39
|
+
// Hazards
|
|
40
|
+
hazardsHit += shot.hazards.length;
|
|
41
|
+
for (const hazard of shot.hazards) {
|
|
42
|
+
hazardPenalties += HAZARD_SEVERITY_PENALTIES[hazard.severity ?? 'minor'];
|
|
43
|
+
}
|
|
44
|
+
// Miss directions
|
|
45
|
+
const dir = MISS_RESULT_TO_DIR[shot.result];
|
|
46
|
+
if (dir) {
|
|
47
|
+
missDirs[dir]++;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
fairways_hit: fairwaysHit,
|
|
52
|
+
fairways_total: shots.length,
|
|
53
|
+
greens_in_regulation: greensInReg,
|
|
54
|
+
greens_total: shots.length,
|
|
55
|
+
putts: overrides?.putts ?? 0,
|
|
56
|
+
penalties: overrides?.penalties ?? 0,
|
|
57
|
+
hazards_hit: hazardsHit,
|
|
58
|
+
hazard_penalties: hazardPenalties,
|
|
59
|
+
miss_directions: missDirs,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// --- Stats normalization ---
|
|
63
|
+
/**
|
|
64
|
+
* Normalize any stats shape to a proper HoleStats object.
|
|
65
|
+
* Handles the simplified format ({ fairway: true, putts: 0 }) used by
|
|
66
|
+
* some scorecards, falling back to safe defaults for missing fields.
|
|
67
|
+
*/
|
|
68
|
+
export function normalizeStats(raw, shotCount = 0) {
|
|
69
|
+
if (!raw || typeof raw !== 'object') {
|
|
70
|
+
return {
|
|
71
|
+
fairways_hit: 0, fairways_total: 0,
|
|
72
|
+
greens_in_regulation: 0, greens_total: 0,
|
|
73
|
+
putts: 0, penalties: 0, hazards_hit: 0, hazard_penalties: 0,
|
|
74
|
+
miss_directions: { long: 0, short: 0, left: 0, right: 0 },
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const s = raw;
|
|
78
|
+
if ('fairways_hit' in s && 'fairways_total' in s) {
|
|
79
|
+
return {
|
|
80
|
+
fairways_hit: Number(s.fairways_hit) || 0,
|
|
81
|
+
fairways_total: Number(s.fairways_total) || 0,
|
|
82
|
+
greens_in_regulation: Number(s.greens_in_regulation) || 0,
|
|
83
|
+
greens_total: Number(s.greens_total) || 0,
|
|
84
|
+
putts: Number(s.putts) || 0,
|
|
85
|
+
penalties: Number(s.penalties) || 0,
|
|
86
|
+
hazards_hit: Number(s.hazards_hit) || 0,
|
|
87
|
+
hazard_penalties: Number(s.hazard_penalties) || 0,
|
|
88
|
+
miss_directions: normalizeMissDirections(s.miss_directions),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const fairwayHit = s.fairway === true ? shotCount : 0;
|
|
92
|
+
const girHit = s.gir === true ? shotCount : 0;
|
|
93
|
+
return {
|
|
94
|
+
fairways_hit: fairwayHit,
|
|
95
|
+
fairways_total: shotCount,
|
|
96
|
+
greens_in_regulation: girHit,
|
|
97
|
+
greens_total: shotCount,
|
|
98
|
+
putts: Number(s.putts) || 0,
|
|
99
|
+
penalties: Number(s.penalties) || 0,
|
|
100
|
+
hazards_hit: Number(s.hazards_hit) || 0,
|
|
101
|
+
hazard_penalties: Number(s.hazard_penalties) || 0,
|
|
102
|
+
miss_directions: normalizeMissDirections(s.miss_directions),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function normalizeMissDirections(raw) {
|
|
106
|
+
const defaults = { long: 0, short: 0, left: 0, right: 0 };
|
|
107
|
+
if (!raw || typeof raw !== 'object')
|
|
108
|
+
return defaults;
|
|
109
|
+
const r = raw;
|
|
110
|
+
return {
|
|
111
|
+
long: Number(r.long) || 0,
|
|
112
|
+
short: Number(r.short) || 0,
|
|
113
|
+
left: Number(r.left) || 0,
|
|
114
|
+
right: Number(r.right) || 0,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Build a complete GolfScorecard from minimal input.
|
|
119
|
+
*
|
|
120
|
+
* Auto-computes:
|
|
121
|
+
* - stats (from shots array via computeStatsFromShots)
|
|
122
|
+
* - score (shots.length + penalties)
|
|
123
|
+
* - score_label (from computeScoreLabel)
|
|
124
|
+
*
|
|
125
|
+
* You only need to provide the parts requiring judgment:
|
|
126
|
+
* shot results, hazard descriptions, training, nutrition, reflection.
|
|
127
|
+
*/
|
|
128
|
+
export function buildScorecard(input) {
|
|
129
|
+
const penalties = input.penalties ?? 0;
|
|
130
|
+
const stats = computeStatsFromShots(input.shots, {
|
|
131
|
+
putts: input.putts ?? 0,
|
|
132
|
+
penalties,
|
|
133
|
+
});
|
|
134
|
+
const score = Math.round(input.shots.length + penalties + stats.hazard_penalties);
|
|
135
|
+
const score_label = computeScoreLabel(score, input.par);
|
|
136
|
+
return {
|
|
137
|
+
sprint_number: input.sprint_number,
|
|
138
|
+
...(input.player ? { player: input.player } : {}),
|
|
139
|
+
theme: input.theme,
|
|
140
|
+
par: input.par,
|
|
141
|
+
slope: input.slope,
|
|
142
|
+
score,
|
|
143
|
+
score_label,
|
|
144
|
+
date: input.date,
|
|
145
|
+
shots: input.shots,
|
|
146
|
+
stats,
|
|
147
|
+
type: input.type,
|
|
148
|
+
conditions: input.conditions ?? [],
|
|
149
|
+
special_plays: input.special_plays ?? [],
|
|
150
|
+
training: input.training,
|
|
151
|
+
nutrition: input.nutrition,
|
|
152
|
+
nineteenth_hole: input.nineteenth_hole,
|
|
153
|
+
bunker_locations: input.bunker_locations ?? [],
|
|
154
|
+
yardage_book_updates: input.yardage_book_updates ?? [],
|
|
155
|
+
course_management_notes: input.course_management_notes ?? [],
|
|
156
|
+
...(input.agents ? { agents: input.agents } : {}),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Build AgentBreakdown entries from per-agent shot data.
|
|
161
|
+
* Each agent's score and stats are computed independently.
|
|
162
|
+
*/
|
|
163
|
+
export function buildAgentBreakdowns(agents) {
|
|
164
|
+
return agents.map((agent) => {
|
|
165
|
+
const stats = computeStatsFromShots(agent.shots);
|
|
166
|
+
return {
|
|
167
|
+
session_id: agent.session_id,
|
|
168
|
+
agent_role: agent.agent_role,
|
|
169
|
+
shots: agent.shots,
|
|
170
|
+
score: Math.round(agent.shots.length + stats.hazard_penalties),
|
|
171
|
+
stats,
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=builder.js.map
|