@hivelore/core 0.47.0 → 0.51.0
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/dist/index.d.ts +29 -2
- package/dist/index.js +117 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1418,7 +1418,9 @@ interface AstExport {
|
|
|
1418
1418
|
*/
|
|
1419
1419
|
declare function parseFileAst(source: string, ext: string): Promise<AstExport[] | null>;
|
|
1420
1420
|
|
|
1421
|
-
declare const CONFIG_FILE = "
|
|
1421
|
+
declare const CONFIG_FILE = "hivelore.config.json";
|
|
1422
|
+
/** Pre-rename filename. Read as a fallback and migrated to CONFIG_FILE on the next write. */
|
|
1423
|
+
declare const LEGACY_CONFIG_FILE = "haive.config.json";
|
|
1422
1424
|
/** A remote or local repo to pull shared memories from. */
|
|
1423
1425
|
interface CrossRepoSource {
|
|
1424
1426
|
/** Human-readable name for this source (used in imported memory tags). */
|
|
@@ -1580,6 +1582,13 @@ interface HaiveConfig {
|
|
|
1580
1582
|
* Default: "anchored" — makes "known bad approaches are blocked" true for the precise case.
|
|
1581
1583
|
*/
|
|
1582
1584
|
antiPatternGate?: "off" | "review" | "anchored" | "strict";
|
|
1585
|
+
/**
|
|
1586
|
+
* Surface the aggregated "N documented lessons plausibly match this diff — review" finding at the
|
|
1587
|
+
* gate (fuzzy anchor/literal/semantic matches that never hard-block). Default **false**: in practice
|
|
1588
|
+
* it fired on nearly every commit and was skimmed past, training people to ignore the gate — only a
|
|
1589
|
+
* deterministic sensor block is signal. Set true (or use antiPatternGate:"review") to restore it.
|
|
1590
|
+
*/
|
|
1591
|
+
reviewMatches?: boolean;
|
|
1583
1592
|
/**
|
|
1584
1593
|
* First-agent bootstrap gate. The trigger is the COLD STATE of the corpus, not a command or flag:
|
|
1585
1594
|
* when the knowledge layer is empty, the very first agent is forced to fill the baseline — a filled
|
|
@@ -1688,7 +1697,10 @@ declare function antiPatternGateParams(gate: AntiPatternGate): {
|
|
|
1688
1697
|
block_on: "any" | "high-confidence" | "never";
|
|
1689
1698
|
anchored_blocks: boolean;
|
|
1690
1699
|
};
|
|
1700
|
+
/** The canonical config path to WRITE to (the current name). */
|
|
1691
1701
|
declare function configPath(paths: HaivePaths): string;
|
|
1702
|
+
/** Path to READ from: the current file if present, else the legacy `haive.config.json`, else current. */
|
|
1703
|
+
declare function resolveConfigPath(paths: HaivePaths): string;
|
|
1692
1704
|
declare function loadConfig(paths: HaivePaths): Promise<HaiveConfig>;
|
|
1693
1705
|
declare function loadConfigSync(paths: HaivePaths): HaiveConfig;
|
|
1694
1706
|
declare function saveConfig(paths: HaivePaths, config: HaiveConfig): Promise<void>;
|
|
@@ -2393,8 +2405,21 @@ interface TestScaffold {
|
|
|
2393
2405
|
/** Ready-to-run wiring command: arms the test as a deterministic gate AFTER it is written. */
|
|
2394
2406
|
proposeCommand: string;
|
|
2395
2407
|
}
|
|
2408
|
+
/**
|
|
2409
|
+
* The shape of the generated test — each lowers the cost of expressing the invariant differently:
|
|
2410
|
+
* - `example` one input → expected output (default; cheapest to grasp, narrowest coverage).
|
|
2411
|
+
* - `property` state the invariant ONCE and let fast-check / Hypothesis check it over many
|
|
2412
|
+
* generated inputs — a broader, partial oracle for a one-line-expressible invariant.
|
|
2413
|
+
* - `differential` state NO invariant: assert the subject AGREES with a reference implementation for
|
|
2414
|
+
* all generated inputs (when a second impl or legacy exists — the oracle is redundancy).
|
|
2415
|
+
*/
|
|
2416
|
+
type ScaffoldStyle = "example" | "property" | "differential";
|
|
2396
2417
|
interface ScaffoldOptions {
|
|
2397
2418
|
framework: TestFramework;
|
|
2419
|
+
/** Test shape (default 'example'). See {@link ScaffoldStyle}. */
|
|
2420
|
+
style?: ScaffoldStyle;
|
|
2421
|
+
/** kind=differential only: import specifier of the reference implementation to compare against. */
|
|
2422
|
+
reference?: string;
|
|
2398
2423
|
/** Override the generated file path (project-relative). Wins over baseDir. */
|
|
2399
2424
|
outPath?: string;
|
|
2400
2425
|
/**
|
|
@@ -2440,6 +2465,8 @@ declare function parseLessonFields(body: string): {
|
|
|
2440
2465
|
* proposal (a memory carries a single sensor).
|
|
2441
2466
|
*/
|
|
2442
2467
|
declare function buildProposeCommand(lesson: PostIncidentLesson, runCommand: string): string;
|
|
2468
|
+
/** Map a user string to a scaffold style, or null. */
|
|
2469
|
+
declare function normalizeScaffoldStyle(input: string): ScaffoldStyle | null;
|
|
2443
2470
|
/** Build a scaffold for the given lesson + framework. Pure — the caller writes `content` to `relPath`. */
|
|
2444
2471
|
declare function scaffoldPostIncidentTest(lesson: PostIncidentLesson, options: ScaffoldOptions): TestScaffold;
|
|
2445
2472
|
/** First-line provenance marker every generated scaffold carries. */
|
|
@@ -3413,4 +3440,4 @@ interface ReviewDraftOptions {
|
|
|
3413
3440
|
/** Template review learnings into proposed-memory drafts (reuses the scanner-ingest draft shape). */
|
|
3414
3441
|
declare function reviewLearningsToDrafts(learnings: ReviewLearning[], options?: ReviewDraftOptions): MemoryDraft[];
|
|
3415
3442
|
|
|
3416
|
-
export { AUTOPILOT_DEFAULTS, type Activation, type ActivationContext, ActivationSchema, type AgentContext, type Anchor, AnchorSchema, type AntiPatternGate, type AppliedConflictResolution, type AstExport, type AutoPromoteRule, BRIDGE_MARKERS, BRIDGE_TARGETS, BRIDGE_TARGET_PATH, BRIEFING_MARKER_TTL_MS, BRIEFING_PRESET_DEFAULTS, type BehaviourCoverageInput, type BehaviourCoverageMetrics, type BehaviourOracleInfo, type BootstrapAssessment, type BootstrapGap, type BootstrapGate, type BootstrapMetrics, type BootstrapState, type BootstrapStateInput, type BreakingChange, type BridgeFileOutput, type BridgeMemoryEntry, type BridgeSensor, type BridgeTarget, type BriefingBudgetNumbers, type BriefingBudgetPreset, type BriefingMarker, type BriefingProofLineOptions, type BudgetPart, type BudgetSlice, type BuildCodeMapOptions, CHARS_PER_TOKEN, CODE_MAP_DEFAULT_EXCLUDE, CODE_MAP_DEFAULT_INCLUDE, CODE_MAP_FILE, CODE_STOPWORDS, CONFIG_FILE, type CaughtForYouOptions, type CaughtForYouRow, type CaughtForYouSummary, type CodeExport, type CodeExportKind, type CodeFileEntry, type CodeMap, type CodeMapQueryOptions, type CollectTimelineOpts, type CommandSensorSpec, type ConfidenceLevel, type ConfidenceThresholds, type ConflictCandidatePair, type ConflictCandidatesOpts, type ConflictResolution, type ContractDiffResult, type ContractFile, type ContractSnapshot, type CoverageGap, type CoverageOptions, CrossRepoProvenanceSchema, type CrossRepoReport, type CrossRepoSource, DECAY_DAYS, DEFAULT_AUTO_PROMOTE_RULE, DEFAULT_BRIEFING_EXCLUDE_TAGS, DEFAULT_CONFIDENCE_THRESHOLDS, DEFAULT_CONFIG, DEFAULT_DORMANT_DAYS, DEFAULT_PRIORITY_SIGNALS, type DashboardOptions, type DashboardReport, type DepChange, type DepTrackResult, type DependencySnapshot, type DetectStacksInput, type DetectableStack, type DistilledFailureLesson, type DocFrequency, type DormantRow, type DraftOptions, type DraftsOptions, ENV_WORKAROUND_TAGS, type EvalDelta, type EvalHistoryEntry, type EvalReport, type EvalSpec, type EvalTrend, type FailureCoverageOptions, type FailureObservation, type FeedbackAdjustment, type FeedbackAdjustmentAction, type FeedbackAdjustmentOptions, type Finding, type FindingFormat, type FindingSeverity, GUESSABLE_THRESHOLD, type GateMissProposal, type GatePrecision, type GatePrecisionDelta, type GatePrecisionMetricDelta, type GateTuningSuggestion, type GenerateBridgesOptions, type GitCommit, type GitWatchPlan, type GitWatchState, HAIVE_DIR, HAIVE_OWNED_FILES, HANDOFF_FILENAME, HIVELORE_ATTRIBUTION, type HaiveConfig, type HaivePaths, type HotFile, type HotFileSource, type ImpactOptions, type ImpactRow, type ImpactScore, type ImpactSummary, type ImpactTier, type IncidentHints, type InvalidMemoryFile, type LexicalRankResult, type LoadedMemory, MEMORIES_DIR, MIN_WORD_LEN, type Memory, type MemoryDraft, type MemoryFrontmatter, MemoryFrontmatterSchema, type MemoryPriority, type MemoryScope, MemoryScopeSchema, type MemoryStatus, MemoryStatusSchema, type MemoryType, MemoryTypeSchema, type MemoryUsage, type MergeResult, type MetricDelta, PREVENTION_DEBOUNCE_MS, PROJECT_CONTEXT_FILE, PROJECT_CONTEXT_THROTTLE_MS, type PostIncidentLesson, type PreventionEvent, type PreventionEventDetail, type PreventionReceipt, type PreventionReceiptRow, type PreventionRow, type PreventionSource, type PreventionTrend, type PrioritySignals, type ProposedEvalSpec, type ProposedSensorVerdict, REVIEW_LEARNING_MARKER, RUNTIME_JOURNAL_FILENAME, type RecurrenceReport, type RecurrenceRow, type ResolveProjectInfo, type RetirementSignal, type RetrievalAggregate, type RetrievalCase, type RetrievalCaseResult, type ReviewDraftOptions, type ReviewLearning, type RuntimeJournalEntry, SCAFFOLD_MARKER_RE, SEED_QUALITY_FLOOR, SENSOR_ABSENT_LOOKBACK, SENSOR_ABSENT_WINDOW, SESSION_RECAP_TTL_MS, STACK_PACK_TAG, type ScaffoldLoopGap, type ScaffoldOptions, type SeedProposal, type SelfEvalOptions, type Sensor, type SensorAggregate, type SensorCase, type SensorCaseResult, type SensorEvaluation, type SensorEvaluationOutcome, type SensorEvaluationStage, type SensorFlap, type SensorHealth, type SensorHit, type SensorRow, SensorSchema, type SensorSeed, type SensorSelfCheck, type SensorSuggestionOptions, type SensorTarget, type SensorWeakening, type SessionHandoffData, type SkillActivation, TEST_FRAMEWORKS, type TestFramework, type TestScaffold, type TierContractCheck, type TimelineEntry, type TopicStatusPair, type TruncateOptions, type TruncateResult, USAGE_FILE, USAGE_LOG_DIR, USAGE_LOG_FILE, type UncapturedFailure, type UncoveredAreaSuggestion, type UsageAggregate, type UsageEvent, type UsageIndex, type VerifyOptions, type VerifyResult, addedLineNumbersFromDiff, addedLinesFromDiff, aggregateRetrieval, aggregateSensors, aggregateUsage, allocateBudget, anchorMatchesComponent, antiPatternGateParams, appendEvalHistory, appendPreventionEvent, appendProposedRetrievalCases, appendRuntimeJournalEntry, appendSensorEvaluations, appendUsageEvent, applyConflictResolution, applyFeedbackAdjustment, approveProposedCases, assessBehaviourCoverage, assessBootstrapState, assessScaffoldLoop, assessSensorHealth, bridgeMemorySummary, briefingMarkerPath, briefingMarkersDir, briefingProofLine, buildCodeMap, buildCoverageIndex, buildDashboard, buildDocFrequency, buildFrontmatter, buildHandoffMarkdown, buildPreventionReceipt, buildProposeCommand, buildReport, bumpRead, classifyMemoryPriority, codeMapPath, collectTimelineEntries, compactAutoRecapBody, compareEvalReports, compareGatePrecision, compareImpact, compileRegexSensor, componentOf, computeEvalTrend, computeGatePrecision, computeImpact, computePreventionTrend, computeRecurrence, computeScopeHash, configPath, contractLockPath, countSourceFilesOnDisk, deriveConfidence, deriveMainAreas, detectAgentContext, detectSensorWeakening, detectStacksFromManifests, diffContract, diffHasDistinctiveOverlap, distillFailureObservations, distinctiveCap, draftsFromFindings, emptyUsage, emptyUsageIndex, enforcementDir, estimateTokens, evalHistoryPath, evaluateSkillActivation, existingGateMissShas, extractActionsBriefBody, extractReferencedPaths, extractReviewLearnings, extractSensorExamples, extractSnippet, extractTestFilePathsFromCommand, filterNewDrafts, findCoverageGaps, findLexicalConflictPairs, findProjectRoot, findTopicStatusConflictPairs, findUncapturedFailures, findingBody, findingToDraft, firstMemoryOneLine, gatePassedShas, generateBridges, getUsage, globToRegExp, handoffAgeMs, handoffFilePath, hasPendingTestMarker, hasRecentBriefingMarker, hashProjectContext, incidentHintsFromDiff, incidentSuffix, inferModulesFromPaths, isAutoPromoteEligible, isAutoRecap, isCovered, isDecaying, isDistinctiveToken, isEnvWorkaroundMemory, isFreshIsoDate, isGlobPath, isLikelyGuessable, isNoiseSubject, isProductionCodeFile, isRetiredMemory, isSensorScannablePath, isSkill, isSkillSuppressed, isStackPackSeed, isStylisticRule, isTemplateProjectContext, judgeProposedSensor, lessonShortName, listMarkdownFilesRecursive, literalMatchesAllTokens, literalMatchesAnyToken, loadCodeMap, loadConfig, loadConfigSync, loadEvalHistory, loadMemoriesFromDir, loadMemoriesFromDirDetailed, loadMemory, loadPreventionEvents, loadSensorLedger, loadUsageIndex, looksLikeGenericAdvice, meetsSeedQualityFloor, memoryFilePath, memoryHasExcludedTag, memoryMatchesAnchorPaths, mergeHotFiles, mergeMemoryVersions, moduleNameOf, newMemoryId, normalizeFindingSeverity, normalizeFramework, normalizeSessionId, overallScore, parseEslintJson, parseFileAst, parseFindings, parseLessonFields, parseMemory, parseNpmAudit, parseSarif, parseSince, parseSonar, pathsOverlap, pickSnippetNeedle, pickTestFramework, planConflictResolution, planGitWatch, prepareBridgeData, preventionLogPath, priorityRank, prioritySignals, projectContextRecentlyEmitted, proposeGateMissDrafts, proposeSeedsFromCommits, pullCrossRepoSources, quarantineNote, queryCodeMap, rankMemoriesLexical, readRecentBriefingMarker, readRuntimeJournalTail, readSessionHandoff, readUsageEvents, recommendFeedbackAdjustment, recordApplied, recordPrevention, recordPreventionHits, recordProjectContextEmission, recordRejection, relPathFrom, renderBehaviourCoverageLine, renderBootstrapChecklist, renderCaughtForYou, renderPreventionReceipt, renderPreventionReceiptShare, resolveBriefingBudget, resolveHaivePaths, resolveManifestFiles, resolveProjectInfo, retirementSignal, revertedShaFromCommit, reviewLearningsToDrafts, runRegexSensor, runSensors, runTierContract, runtimeJournalPath, saveCodeMap, saveConfig, saveUsageIndex, scaffoldPostIncidentTest, scannableSensorTargets, scoreRetrievalCase, scoreSensorCase, scrubbedCommandEnv, selectCommandSensors, sensorAppliesToPath, sensorLedgerPath, sensorPatternBrittleness, sensorPromotedAtMap, sensorSelfCheck, sensorTargetsFromDiff, serializeMemory, snapshotContract, specificityScore, stripPrivate, suggestGate, suggestSensorFromMemory, suggestSensorSeed, suggestTopicKey, summarizeCaughtForYou, summarizeImpact, synthesizeSelfEvalCases, tallyHotFiles, titleFromBody, tokenizeQuery, tokenizeWords, trackDependencies, trackReads, truncateToTokens, usageLogPath, usageLogSize, usagePath, verifyAnchor, watchContracts, withQuarantineNote, withoutQuarantineNote, writeBriefingMarker, writeSessionHandoff };
|
|
3443
|
+
export { AUTOPILOT_DEFAULTS, type Activation, type ActivationContext, ActivationSchema, type AgentContext, type Anchor, AnchorSchema, type AntiPatternGate, type AppliedConflictResolution, type AstExport, type AutoPromoteRule, BRIDGE_MARKERS, BRIDGE_TARGETS, BRIDGE_TARGET_PATH, BRIEFING_MARKER_TTL_MS, BRIEFING_PRESET_DEFAULTS, type BehaviourCoverageInput, type BehaviourCoverageMetrics, type BehaviourOracleInfo, type BootstrapAssessment, type BootstrapGap, type BootstrapGate, type BootstrapMetrics, type BootstrapState, type BootstrapStateInput, type BreakingChange, type BridgeFileOutput, type BridgeMemoryEntry, type BridgeSensor, type BridgeTarget, type BriefingBudgetNumbers, type BriefingBudgetPreset, type BriefingMarker, type BriefingProofLineOptions, type BudgetPart, type BudgetSlice, type BuildCodeMapOptions, CHARS_PER_TOKEN, CODE_MAP_DEFAULT_EXCLUDE, CODE_MAP_DEFAULT_INCLUDE, CODE_MAP_FILE, CODE_STOPWORDS, CONFIG_FILE, type CaughtForYouOptions, type CaughtForYouRow, type CaughtForYouSummary, type CodeExport, type CodeExportKind, type CodeFileEntry, type CodeMap, type CodeMapQueryOptions, type CollectTimelineOpts, type CommandSensorSpec, type ConfidenceLevel, type ConfidenceThresholds, type ConflictCandidatePair, type ConflictCandidatesOpts, type ConflictResolution, type ContractDiffResult, type ContractFile, type ContractSnapshot, type CoverageGap, type CoverageOptions, CrossRepoProvenanceSchema, type CrossRepoReport, type CrossRepoSource, DECAY_DAYS, DEFAULT_AUTO_PROMOTE_RULE, DEFAULT_BRIEFING_EXCLUDE_TAGS, DEFAULT_CONFIDENCE_THRESHOLDS, DEFAULT_CONFIG, DEFAULT_DORMANT_DAYS, DEFAULT_PRIORITY_SIGNALS, type DashboardOptions, type DashboardReport, type DepChange, type DepTrackResult, type DependencySnapshot, type DetectStacksInput, type DetectableStack, type DistilledFailureLesson, type DocFrequency, type DormantRow, type DraftOptions, type DraftsOptions, ENV_WORKAROUND_TAGS, type EvalDelta, type EvalHistoryEntry, type EvalReport, type EvalSpec, type EvalTrend, type FailureCoverageOptions, type FailureObservation, type FeedbackAdjustment, type FeedbackAdjustmentAction, type FeedbackAdjustmentOptions, type Finding, type FindingFormat, type FindingSeverity, GUESSABLE_THRESHOLD, type GateMissProposal, type GatePrecision, type GatePrecisionDelta, type GatePrecisionMetricDelta, type GateTuningSuggestion, type GenerateBridgesOptions, type GitCommit, type GitWatchPlan, type GitWatchState, HAIVE_DIR, HAIVE_OWNED_FILES, HANDOFF_FILENAME, HIVELORE_ATTRIBUTION, type HaiveConfig, type HaivePaths, type HotFile, type HotFileSource, type ImpactOptions, type ImpactRow, type ImpactScore, type ImpactSummary, type ImpactTier, type IncidentHints, type InvalidMemoryFile, LEGACY_CONFIG_FILE, type LexicalRankResult, type LoadedMemory, MEMORIES_DIR, MIN_WORD_LEN, type Memory, type MemoryDraft, type MemoryFrontmatter, MemoryFrontmatterSchema, type MemoryPriority, type MemoryScope, MemoryScopeSchema, type MemoryStatus, MemoryStatusSchema, type MemoryType, MemoryTypeSchema, type MemoryUsage, type MergeResult, type MetricDelta, PREVENTION_DEBOUNCE_MS, PROJECT_CONTEXT_FILE, PROJECT_CONTEXT_THROTTLE_MS, type PostIncidentLesson, type PreventionEvent, type PreventionEventDetail, type PreventionReceipt, type PreventionReceiptRow, type PreventionRow, type PreventionSource, type PreventionTrend, type PrioritySignals, type ProposedEvalSpec, type ProposedSensorVerdict, REVIEW_LEARNING_MARKER, RUNTIME_JOURNAL_FILENAME, type RecurrenceReport, type RecurrenceRow, type ResolveProjectInfo, type RetirementSignal, type RetrievalAggregate, type RetrievalCase, type RetrievalCaseResult, type ReviewDraftOptions, type ReviewLearning, type RuntimeJournalEntry, SCAFFOLD_MARKER_RE, SEED_QUALITY_FLOOR, SENSOR_ABSENT_LOOKBACK, SENSOR_ABSENT_WINDOW, SESSION_RECAP_TTL_MS, STACK_PACK_TAG, type ScaffoldLoopGap, type ScaffoldOptions, type ScaffoldStyle, type SeedProposal, type SelfEvalOptions, type Sensor, type SensorAggregate, type SensorCase, type SensorCaseResult, type SensorEvaluation, type SensorEvaluationOutcome, type SensorEvaluationStage, type SensorFlap, type SensorHealth, type SensorHit, type SensorRow, SensorSchema, type SensorSeed, type SensorSelfCheck, type SensorSuggestionOptions, type SensorTarget, type SensorWeakening, type SessionHandoffData, type SkillActivation, TEST_FRAMEWORKS, type TestFramework, type TestScaffold, type TierContractCheck, type TimelineEntry, type TopicStatusPair, type TruncateOptions, type TruncateResult, USAGE_FILE, USAGE_LOG_DIR, USAGE_LOG_FILE, type UncapturedFailure, type UncoveredAreaSuggestion, type UsageAggregate, type UsageEvent, type UsageIndex, type VerifyOptions, type VerifyResult, addedLineNumbersFromDiff, addedLinesFromDiff, aggregateRetrieval, aggregateSensors, aggregateUsage, allocateBudget, anchorMatchesComponent, antiPatternGateParams, appendEvalHistory, appendPreventionEvent, appendProposedRetrievalCases, appendRuntimeJournalEntry, appendSensorEvaluations, appendUsageEvent, applyConflictResolution, applyFeedbackAdjustment, approveProposedCases, assessBehaviourCoverage, assessBootstrapState, assessScaffoldLoop, assessSensorHealth, bridgeMemorySummary, briefingMarkerPath, briefingMarkersDir, briefingProofLine, buildCodeMap, buildCoverageIndex, buildDashboard, buildDocFrequency, buildFrontmatter, buildHandoffMarkdown, buildPreventionReceipt, buildProposeCommand, buildReport, bumpRead, classifyMemoryPriority, codeMapPath, collectTimelineEntries, compactAutoRecapBody, compareEvalReports, compareGatePrecision, compareImpact, compileRegexSensor, componentOf, computeEvalTrend, computeGatePrecision, computeImpact, computePreventionTrend, computeRecurrence, computeScopeHash, configPath, contractLockPath, countSourceFilesOnDisk, deriveConfidence, deriveMainAreas, detectAgentContext, detectSensorWeakening, detectStacksFromManifests, diffContract, diffHasDistinctiveOverlap, distillFailureObservations, distinctiveCap, draftsFromFindings, emptyUsage, emptyUsageIndex, enforcementDir, estimateTokens, evalHistoryPath, evaluateSkillActivation, existingGateMissShas, extractActionsBriefBody, extractReferencedPaths, extractReviewLearnings, extractSensorExamples, extractSnippet, extractTestFilePathsFromCommand, filterNewDrafts, findCoverageGaps, findLexicalConflictPairs, findProjectRoot, findTopicStatusConflictPairs, findUncapturedFailures, findingBody, findingToDraft, firstMemoryOneLine, gatePassedShas, generateBridges, getUsage, globToRegExp, handoffAgeMs, handoffFilePath, hasPendingTestMarker, hasRecentBriefingMarker, hashProjectContext, incidentHintsFromDiff, incidentSuffix, inferModulesFromPaths, isAutoPromoteEligible, isAutoRecap, isCovered, isDecaying, isDistinctiveToken, isEnvWorkaroundMemory, isFreshIsoDate, isGlobPath, isLikelyGuessable, isNoiseSubject, isProductionCodeFile, isRetiredMemory, isSensorScannablePath, isSkill, isSkillSuppressed, isStackPackSeed, isStylisticRule, isTemplateProjectContext, judgeProposedSensor, lessonShortName, listMarkdownFilesRecursive, literalMatchesAllTokens, literalMatchesAnyToken, loadCodeMap, loadConfig, loadConfigSync, loadEvalHistory, loadMemoriesFromDir, loadMemoriesFromDirDetailed, loadMemory, loadPreventionEvents, loadSensorLedger, loadUsageIndex, looksLikeGenericAdvice, meetsSeedQualityFloor, memoryFilePath, memoryHasExcludedTag, memoryMatchesAnchorPaths, mergeHotFiles, mergeMemoryVersions, moduleNameOf, newMemoryId, normalizeFindingSeverity, normalizeFramework, normalizeScaffoldStyle, normalizeSessionId, overallScore, parseEslintJson, parseFileAst, parseFindings, parseLessonFields, parseMemory, parseNpmAudit, parseSarif, parseSince, parseSonar, pathsOverlap, pickSnippetNeedle, pickTestFramework, planConflictResolution, planGitWatch, prepareBridgeData, preventionLogPath, priorityRank, prioritySignals, projectContextRecentlyEmitted, proposeGateMissDrafts, proposeSeedsFromCommits, pullCrossRepoSources, quarantineNote, queryCodeMap, rankMemoriesLexical, readRecentBriefingMarker, readRuntimeJournalTail, readSessionHandoff, readUsageEvents, recommendFeedbackAdjustment, recordApplied, recordPrevention, recordPreventionHits, recordProjectContextEmission, recordRejection, relPathFrom, renderBehaviourCoverageLine, renderBootstrapChecklist, renderCaughtForYou, renderPreventionReceipt, renderPreventionReceiptShare, resolveBriefingBudget, resolveConfigPath, resolveHaivePaths, resolveManifestFiles, resolveProjectInfo, retirementSignal, revertedShaFromCommit, reviewLearningsToDrafts, runRegexSensor, runSensors, runTierContract, runtimeJournalPath, saveCodeMap, saveConfig, saveUsageIndex, scaffoldPostIncidentTest, scannableSensorTargets, scoreRetrievalCase, scoreSensorCase, scrubbedCommandEnv, selectCommandSensors, sensorAppliesToPath, sensorLedgerPath, sensorPatternBrittleness, sensorPromotedAtMap, sensorSelfCheck, sensorTargetsFromDiff, serializeMemory, snapshotContract, specificityScore, stripPrivate, suggestGate, suggestSensorFromMemory, suggestSensorSeed, suggestTopicKey, summarizeCaughtForYou, summarizeImpact, synthesizeSelfEvalCases, tallyHotFiles, titleFromBody, tokenizeQuery, tokenizeWords, trackDependencies, trackReads, truncateToTokens, usageLogPath, usageLogSize, usagePath, verifyAnchor, watchContracts, withQuarantineNote, withoutQuarantineNote, writeBriefingMarker, writeSessionHandoff };
|
package/dist/index.js
CHANGED
|
@@ -2526,9 +2526,10 @@ function queryCodeMap(map, options) {
|
|
|
2526
2526
|
// src/config.ts
|
|
2527
2527
|
import { existsSync as existsSync7 } from "fs";
|
|
2528
2528
|
import { readFileSync } from "fs";
|
|
2529
|
-
import { readFile as readFile7, writeFile as writeFile4 } from "fs/promises";
|
|
2529
|
+
import { readFile as readFile7, rm, writeFile as writeFile4 } from "fs/promises";
|
|
2530
2530
|
import path9 from "path";
|
|
2531
|
-
var CONFIG_FILE = "
|
|
2531
|
+
var CONFIG_FILE = "hivelore.config.json";
|
|
2532
|
+
var LEGACY_CONFIG_FILE = "haive.config.json";
|
|
2532
2533
|
var DEFAULT_BRIEFING_EXCLUDE_TAGS = [
|
|
2533
2534
|
"positioning",
|
|
2534
2535
|
"competitive",
|
|
@@ -2624,8 +2625,14 @@ function antiPatternGateParams(gate) {
|
|
|
2624
2625
|
function configPath(paths) {
|
|
2625
2626
|
return path9.join(paths.haiveDir, CONFIG_FILE);
|
|
2626
2627
|
}
|
|
2628
|
+
function resolveConfigPath(paths) {
|
|
2629
|
+
const current = configPath(paths);
|
|
2630
|
+
if (existsSync7(current)) return current;
|
|
2631
|
+
const legacy = path9.join(paths.haiveDir, LEGACY_CONFIG_FILE);
|
|
2632
|
+
return existsSync7(legacy) ? legacy : current;
|
|
2633
|
+
}
|
|
2627
2634
|
async function loadConfig(paths) {
|
|
2628
|
-
const file =
|
|
2635
|
+
const file = resolveConfigPath(paths);
|
|
2629
2636
|
if (!existsSync7(file)) return { ...DEFAULT_CONFIG };
|
|
2630
2637
|
try {
|
|
2631
2638
|
const raw = await readFile7(file, "utf8");
|
|
@@ -2640,7 +2647,7 @@ async function loadConfig(paths) {
|
|
|
2640
2647
|
}
|
|
2641
2648
|
}
|
|
2642
2649
|
function loadConfigSync(paths) {
|
|
2643
|
-
const file =
|
|
2650
|
+
const file = resolveConfigPath(paths);
|
|
2644
2651
|
if (!existsSync7(file)) return { ...DEFAULT_CONFIG };
|
|
2645
2652
|
try {
|
|
2646
2653
|
const parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
@@ -2652,6 +2659,13 @@ function loadConfigSync(paths) {
|
|
|
2652
2659
|
}
|
|
2653
2660
|
async function saveConfig(paths, config) {
|
|
2654
2661
|
await writeFile4(configPath(paths), JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
2662
|
+
const legacy = path9.join(paths.haiveDir, LEGACY_CONFIG_FILE);
|
|
2663
|
+
if (existsSync7(legacy)) {
|
|
2664
|
+
try {
|
|
2665
|
+
await rm(legacy, { force: true });
|
|
2666
|
+
} catch {
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2655
2669
|
}
|
|
2656
2670
|
function mergeConfig(base, override) {
|
|
2657
2671
|
return {
|
|
@@ -4863,7 +4877,21 @@ function buildProposeCommand(lesson, runCommand) {
|
|
|
4863
4877
|
if (scope.length > 0) parts.push(`--paths ${JSON.stringify(scope.join(","))}`);
|
|
4864
4878
|
return parts.join(" ");
|
|
4865
4879
|
}
|
|
4866
|
-
function
|
|
4880
|
+
function normalizeScaffoldStyle(input) {
|
|
4881
|
+
const v = input.trim().toLowerCase();
|
|
4882
|
+
if (v === "example" || v === "property" || v === "differential") return v;
|
|
4883
|
+
return null;
|
|
4884
|
+
}
|
|
4885
|
+
function styleNote(style, reference) {
|
|
4886
|
+
if (style === "property") {
|
|
4887
|
+
return "Style: property-based \u2014 state the invariant once; it is checked over many generated inputs.";
|
|
4888
|
+
}
|
|
4889
|
+
if (style === "differential") {
|
|
4890
|
+
return `Style: differential \u2014 assert the subject AGREES with the reference (${reference ?? "<reference>"}) for all inputs.`;
|
|
4891
|
+
}
|
|
4892
|
+
return void 0;
|
|
4893
|
+
}
|
|
4894
|
+
function header(lesson, comment, style) {
|
|
4867
4895
|
const hints = lesson.incidentHints;
|
|
4868
4896
|
const fixLines = [];
|
|
4869
4897
|
if (hints && (hints.changedSymbols.length > 0 || hints.changedFiles.length > 0)) {
|
|
@@ -4881,6 +4909,7 @@ function header(lesson, comment) {
|
|
|
4881
4909
|
...lesson.whyFailed ? [`Why: ${oneLine(lesson.whyFailed)}`] : [],
|
|
4882
4910
|
...lesson.instead ? [`Expected / fix: ${oneLine(lesson.instead)}`] : [],
|
|
4883
4911
|
...fixLines,
|
|
4912
|
+
...style ? [style] : [],
|
|
4884
4913
|
"",
|
|
4885
4914
|
"TODO: replace the pending test with a real check that FAILS on the incident and",
|
|
4886
4915
|
"PASSES once the fix is in place. Then arm it as a deterministic gate:"
|
|
@@ -4921,8 +4950,73 @@ function exampleLines(lesson, lang) {
|
|
|
4921
4950
|
function importSpecifier(file) {
|
|
4922
4951
|
return file.replace(/\.[cm]?[jt]sx?$/, "");
|
|
4923
4952
|
}
|
|
4953
|
+
function propertyLines(lesson, lang) {
|
|
4954
|
+
const symbol = lesson.incidentHints?.changedSymbols[0] ?? "subjectUnderTest";
|
|
4955
|
+
const file = lesson.incidentHints?.changedFiles[0];
|
|
4956
|
+
const invariant = lesson.instead ? oneLine(lesson.instead) : void 0;
|
|
4957
|
+
if (lang === "js") {
|
|
4958
|
+
return [
|
|
4959
|
+
`// Property-based guard \u2014 state the invariant ONCE; it is checked over many generated inputs.`,
|
|
4960
|
+
`// Add at the top: import fc from "fast-check"; (npm i -D fast-check)`,
|
|
4961
|
+
`// it("property: the invariant holds for all inputs", () => {`,
|
|
4962
|
+
...file ? [`// import { ${symbol} } from "${importSpecifier(file)}"; // adjust the relative path`] : [],
|
|
4963
|
+
...invariant ? [`// // Invariant (from the lesson): ${invariant}`] : [],
|
|
4964
|
+
`// fc.assert(fc.property(fc.integer(), fc.integer(), (a, b) =>`,
|
|
4965
|
+
`// /* the boolean invariant over ${symbol}(a, b) */`,
|
|
4966
|
+
`// ));`,
|
|
4967
|
+
`// });`
|
|
4968
|
+
];
|
|
4969
|
+
}
|
|
4970
|
+
if (lang === "py") {
|
|
4971
|
+
return [
|
|
4972
|
+
` # Property-based guard \u2014 state the invariant once; checked over many generated inputs.`,
|
|
4973
|
+
` # from hypothesis import given, strategies as st`,
|
|
4974
|
+
` # @given(st.integers(), st.integers())`,
|
|
4975
|
+
` # def test_property(a, b):`,
|
|
4976
|
+
...invariant ? [` # # Invariant (from the lesson): ${invariant}`] : [],
|
|
4977
|
+
` # assert (the boolean invariant over ${symbol}(a, b))`
|
|
4978
|
+
];
|
|
4979
|
+
}
|
|
4980
|
+
return [` // Property-based guard: check the invariant over generated inputs (e.g. github.com/leanovate/gopter). Subject: ${symbol}.`];
|
|
4981
|
+
}
|
|
4982
|
+
function differentialLines(lesson, lang, reference) {
|
|
4983
|
+
const symbol = lesson.incidentHints?.changedSymbols[0] ?? "subjectUnderTest";
|
|
4984
|
+
const file = lesson.incidentHints?.changedFiles[0];
|
|
4985
|
+
const ref = reference ?? "<REFERENCE>";
|
|
4986
|
+
if (lang === "js") {
|
|
4987
|
+
return [
|
|
4988
|
+
`// Differential guard \u2014 no invariant to state: assert the subject AGREES with a reference for all inputs.`,
|
|
4989
|
+
`// Add at the top: import fc from "fast-check"; (npm i -D fast-check)`,
|
|
4990
|
+
`// it("differential: subject matches the reference for all inputs", () => {`,
|
|
4991
|
+
...file ? [`// import { ${symbol} } from "${importSpecifier(file)}"; // subject`] : [],
|
|
4992
|
+
`// import { ${symbol} as reference } from "${ref}"; // reference implementation`,
|
|
4993
|
+
`// fc.assert(fc.property(fc.integer(), fc.integer(), (a, b) =>`,
|
|
4994
|
+
`// ${symbol}(a, b) === reference(a, b)`,
|
|
4995
|
+
`// ));`,
|
|
4996
|
+
`// });`
|
|
4997
|
+
];
|
|
4998
|
+
}
|
|
4999
|
+
if (lang === "py") {
|
|
5000
|
+
return [
|
|
5001
|
+
` # Differential guard \u2014 assert the subject agrees with a reference for all generated inputs.`,
|
|
5002
|
+
` # from hypothesis import given, strategies as st`,
|
|
5003
|
+
` # from ${ref} import ${symbol} as reference`,
|
|
5004
|
+
` # @given(st.integers(), st.integers())`,
|
|
5005
|
+
` # def test_differential(a, b):`,
|
|
5006
|
+
` # assert ${symbol}(a, b) == reference(a, b)`
|
|
5007
|
+
];
|
|
5008
|
+
}
|
|
5009
|
+
return [` // Differential guard: assert ${symbol} agrees with the reference (${ref}) over generated inputs (e.g. gopter).`];
|
|
5010
|
+
}
|
|
5011
|
+
function bodyLines(lesson, lang, style, reference) {
|
|
5012
|
+
if (style === "property") return propertyLines(lesson, lang);
|
|
5013
|
+
if (style === "differential") return differentialLines(lesson, lang, reference);
|
|
5014
|
+
return exampleLines(lesson, lang);
|
|
5015
|
+
}
|
|
4924
5016
|
function scaffoldPostIncidentTest(lesson, options) {
|
|
4925
5017
|
const framework = options.framework;
|
|
5018
|
+
const style = options.style ?? "example";
|
|
5019
|
+
const note = styleNote(style, options.reference);
|
|
4926
5020
|
const short = lessonShortName(lesson.memoryId);
|
|
4927
5021
|
const desc = oneLine(lesson.title) || short;
|
|
4928
5022
|
const propose = (run) => options.proposeCommandOverride ?? buildProposeCommand(lesson, run);
|
|
@@ -4936,13 +5030,13 @@ function scaffoldPostIncidentTest(lesson, options) {
|
|
|
4936
5030
|
const importLine = framework === "vitest" ? `import { describe, it, expect } from "vitest";
|
|
4937
5031
|
|
|
4938
5032
|
` : "";
|
|
4939
|
-
content = `${header(lesson, hc)}
|
|
5033
|
+
content = `${header(lesson, hc, note)}
|
|
4940
5034
|
// ${propose(runCommand)}
|
|
4941
5035
|
|
|
4942
5036
|
` + importLine + `describe(${JSON.stringify(desc)}, () => {
|
|
4943
5037
|
it.todo("reproduces ${lesson.memoryId} and stays fixed");
|
|
4944
5038
|
|
|
4945
|
-
` +
|
|
5039
|
+
` + bodyLines(lesson, "js", style, options.reference).map((l) => ` ${l}`).join("\n") + `
|
|
4946
5040
|
});
|
|
4947
5041
|
`;
|
|
4948
5042
|
} else if (framework === "pytest") {
|
|
@@ -4950,7 +5044,7 @@ function scaffoldPostIncidentTest(lesson, options) {
|
|
|
4950
5044
|
relPath = options.outPath ?? joinRel(options.baseDir, `tests/incidents/test_${fn}.py`);
|
|
4951
5045
|
runCommand = `pytest ${relPath}`;
|
|
4952
5046
|
const hc = (l) => l ? `# ${l}` : "#";
|
|
4953
|
-
content = `${header(lesson, hc)}
|
|
5047
|
+
content = `${header(lesson, hc, note)}
|
|
4954
5048
|
# ${propose(runCommand)}
|
|
4955
5049
|
|
|
4956
5050
|
import pytest
|
|
@@ -4958,14 +5052,14 @@ import pytest
|
|
|
4958
5052
|
|
|
4959
5053
|
@pytest.mark.skip(reason="TODO: write the post-incident assertion, then arm the sensor")
|
|
4960
5054
|
def test_${fn}():
|
|
4961
|
-
` +
|
|
5055
|
+
` + bodyLines(lesson, "py", style, options.reference).join("\n") + "\n";
|
|
4962
5056
|
} else {
|
|
4963
5057
|
const fn = pascal(short);
|
|
4964
5058
|
const dir = options.outPath ? options.outPath.replace(/\/[^/]+$/, "") : joinRel(options.baseDir, "incidents");
|
|
4965
5059
|
relPath = options.outPath ?? joinRel(options.baseDir, `incidents/incident_${snake(short)}_test.go`);
|
|
4966
5060
|
runCommand = `go test ./${dir}/`;
|
|
4967
5061
|
const hc = (l) => l ? `// ${l}` : "//";
|
|
4968
|
-
content = `${header(lesson, hc)}
|
|
5062
|
+
content = `${header(lesson, hc, note)}
|
|
4969
5063
|
// ${propose(runCommand)}
|
|
4970
5064
|
|
|
4971
5065
|
package incidents
|
|
@@ -4974,7 +5068,7 @@ import "testing"
|
|
|
4974
5068
|
|
|
4975
5069
|
func Test${fn}(t *testing.T) {
|
|
4976
5070
|
t.Skip("TODO: write the post-incident assertion, then arm the sensor")
|
|
4977
|
-
` +
|
|
5071
|
+
` + bodyLines(lesson, "go", style, options.reference).join("\n") + `
|
|
4978
5072
|
}
|
|
4979
5073
|
`;
|
|
4980
5074
|
}
|
|
@@ -5781,23 +5875,28 @@ function findUncapturedFailures(failures, captureTimes, options = {}) {
|
|
|
5781
5875
|
out.sort((a, b) => a.ts.localeCompare(b.ts));
|
|
5782
5876
|
return out;
|
|
5783
5877
|
}
|
|
5784
|
-
var EXPLORATORY_RE = /^(ls|find|grep|rg|cat|head|tail|which|stat)\b/i;
|
|
5878
|
+
var EXPLORATORY_RE = /^(ls|find|grep|rg|cat|head|tail|which|stat|cd|pushd|popd|pwd|mkdir|rmdir|echo|printf|touch|cp|mv|rm|export|set|unset|source|test|true|false|sleep|wc|sort|uniq|cut|env|\[|\.)\b/i;
|
|
5879
|
+
var SUBSTANTIVE_RE = /\b(vitest|jest|mocha|pytest|unittest|go\s+test|cargo|gradle|mvn|tsc|typecheck|eslint|biome|ruff|mypy|flake8|pnpm|npm|yarn|bun|make|docker|compose|terraform|prisma|migrate|migration|build|lint)\b/i;
|
|
5880
|
+
function commandText(summary) {
|
|
5881
|
+
return summary.replace(/^[A-Za-z_]+:\s*/, "").trim();
|
|
5882
|
+
}
|
|
5785
5883
|
function distillFailureObservations(failures, options = {}) {
|
|
5786
5884
|
const max = options.max ?? 3;
|
|
5787
5885
|
const clusters = /* @__PURE__ */ new Map();
|
|
5788
5886
|
for (const f of failures) {
|
|
5789
5887
|
const summary = f.summary.trim();
|
|
5790
|
-
|
|
5888
|
+
const cmd = commandText(summary);
|
|
5889
|
+
if (!summary || EXPLORATORY_RE.test(cmd)) continue;
|
|
5791
5890
|
const key = normalizeSummary(summary);
|
|
5792
5891
|
const existing = clusters.get(key);
|
|
5793
5892
|
if (existing) {
|
|
5794
5893
|
existing.count++;
|
|
5795
5894
|
for (const file of f.files ?? []) existing.files.add(file);
|
|
5796
5895
|
} else {
|
|
5797
|
-
clusters.set(key, { first: f, count: 1, files: new Set(f.files ?? []) });
|
|
5896
|
+
clusters.set(key, { first: f, count: 1, files: new Set(f.files ?? []), substantive: SUBSTANTIVE_RE.test(cmd) });
|
|
5798
5897
|
}
|
|
5799
5898
|
}
|
|
5800
|
-
return [...clusters.values()].sort((a, b) => b.count - a.count || b.first.ts.localeCompare(a.first.ts)).slice(0, max).map(({ first, count, files }) => {
|
|
5899
|
+
return [...clusters.values()].filter((c) => c.count >= 2 || c.substantive).sort((a, b) => b.count - a.count || b.first.ts.localeCompare(a.first.ts)).slice(0, max).map(({ first, count, files }) => {
|
|
5801
5900
|
const summary = first.summary.trim();
|
|
5802
5901
|
const firstLine = summary.split("\n")[0].slice(0, 120);
|
|
5803
5902
|
return {
|
|
@@ -6439,6 +6538,7 @@ export {
|
|
|
6439
6538
|
HAIVE_OWNED_FILES,
|
|
6440
6539
|
HANDOFF_FILENAME,
|
|
6441
6540
|
HIVELORE_ATTRIBUTION,
|
|
6541
|
+
LEGACY_CONFIG_FILE,
|
|
6442
6542
|
MEMORIES_DIR,
|
|
6443
6543
|
MIN_WORD_LEN,
|
|
6444
6544
|
MemoryFrontmatterSchema,
|
|
@@ -6602,6 +6702,7 @@ export {
|
|
|
6602
6702
|
newMemoryId,
|
|
6603
6703
|
normalizeFindingSeverity,
|
|
6604
6704
|
normalizeFramework,
|
|
6705
|
+
normalizeScaffoldStyle,
|
|
6605
6706
|
normalizeSessionId,
|
|
6606
6707
|
overallScore,
|
|
6607
6708
|
parseEslintJson,
|
|
@@ -6646,6 +6747,7 @@ export {
|
|
|
6646
6747
|
renderPreventionReceipt,
|
|
6647
6748
|
renderPreventionReceiptShare,
|
|
6648
6749
|
resolveBriefingBudget,
|
|
6750
|
+
resolveConfigPath,
|
|
6649
6751
|
resolveHaivePaths,
|
|
6650
6752
|
resolveManifestFiles,
|
|
6651
6753
|
resolveProjectInfo,
|