@hivelore/core 0.58.1 → 0.60.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 +54 -5
- package/dist/index.js +92 -35
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,14 @@ declare const SensorSchema: z.ZodObject<{
|
|
|
64
64
|
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
65
65
|
/** Glob-ish path prefixes the sensor applies to. Falls back to the memory's anchor paths when empty. */
|
|
66
66
|
paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
67
|
+
/**
|
|
68
|
+
* Glob-ish paths the sensor must NOT fire on, even when they fall inside `paths`. Lets a
|
|
69
|
+
* production-only lesson (e.g. "no `any`") skip test doubles and fixtures without narrowing its
|
|
70
|
+
* scope file by file — the missing negation that made `paths: ['**']` fire on every `.test.ts`
|
|
71
|
+
* (field report 2026-09-02 §3.2). A lesson that IS about tests (e.g. "no `LocalDate.now()` in a
|
|
72
|
+
* test") simply leaves this empty, so it still fires there.
|
|
73
|
+
*/
|
|
74
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
67
75
|
/** LLM-facing self-correction message: what was done wrong and what to do instead. */
|
|
68
76
|
message: z.ZodString;
|
|
69
77
|
/**
|
|
@@ -108,6 +116,7 @@ declare const SensorSchema: z.ZodObject<{
|
|
|
108
116
|
require_present?: boolean | undefined;
|
|
109
117
|
command?: string | undefined;
|
|
110
118
|
timeout_ms?: number | undefined;
|
|
119
|
+
exclude?: string[] | undefined;
|
|
111
120
|
incident?: string | undefined;
|
|
112
121
|
red_proven?: boolean | undefined;
|
|
113
122
|
promoted_at?: string | undefined;
|
|
@@ -123,6 +132,7 @@ declare const SensorSchema: z.ZodObject<{
|
|
|
123
132
|
require_present?: boolean | undefined;
|
|
124
133
|
command?: string | undefined;
|
|
125
134
|
timeout_ms?: number | undefined;
|
|
135
|
+
exclude?: string[] | undefined;
|
|
126
136
|
incident?: string | undefined;
|
|
127
137
|
red_proven?: boolean | undefined;
|
|
128
138
|
severity?: "warn" | "block" | undefined;
|
|
@@ -213,6 +223,14 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
213
223
|
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
214
224
|
/** Glob-ish path prefixes the sensor applies to. Falls back to the memory's anchor paths when empty. */
|
|
215
225
|
paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
226
|
+
/**
|
|
227
|
+
* Glob-ish paths the sensor must NOT fire on, even when they fall inside `paths`. Lets a
|
|
228
|
+
* production-only lesson (e.g. "no `any`") skip test doubles and fixtures without narrowing its
|
|
229
|
+
* scope file by file — the missing negation that made `paths: ['**']` fire on every `.test.ts`
|
|
230
|
+
* (field report 2026-09-02 §3.2). A lesson that IS about tests (e.g. "no `LocalDate.now()` in a
|
|
231
|
+
* test") simply leaves this empty, so it still fires there.
|
|
232
|
+
*/
|
|
233
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
216
234
|
/** LLM-facing self-correction message: what was done wrong and what to do instead. */
|
|
217
235
|
message: z.ZodString;
|
|
218
236
|
/**
|
|
@@ -257,6 +275,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
257
275
|
require_present?: boolean | undefined;
|
|
258
276
|
command?: string | undefined;
|
|
259
277
|
timeout_ms?: number | undefined;
|
|
278
|
+
exclude?: string[] | undefined;
|
|
260
279
|
incident?: string | undefined;
|
|
261
280
|
red_proven?: boolean | undefined;
|
|
262
281
|
promoted_at?: string | undefined;
|
|
@@ -272,6 +291,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
272
291
|
require_present?: boolean | undefined;
|
|
273
292
|
command?: string | undefined;
|
|
274
293
|
timeout_ms?: number | undefined;
|
|
294
|
+
exclude?: string[] | undefined;
|
|
275
295
|
incident?: string | undefined;
|
|
276
296
|
red_proven?: boolean | undefined;
|
|
277
297
|
severity?: "warn" | "block" | undefined;
|
|
@@ -370,6 +390,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
370
390
|
require_present?: boolean | undefined;
|
|
371
391
|
command?: string | undefined;
|
|
372
392
|
timeout_ms?: number | undefined;
|
|
393
|
+
exclude?: string[] | undefined;
|
|
373
394
|
incident?: string | undefined;
|
|
374
395
|
red_proven?: boolean | undefined;
|
|
375
396
|
promoted_at?: string | undefined;
|
|
@@ -407,6 +428,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
407
428
|
require_present?: boolean | undefined;
|
|
408
429
|
command?: string | undefined;
|
|
409
430
|
timeout_ms?: number | undefined;
|
|
431
|
+
exclude?: string[] | undefined;
|
|
410
432
|
incident?: string | undefined;
|
|
411
433
|
red_proven?: boolean | undefined;
|
|
412
434
|
severity?: "warn" | "block" | undefined;
|
|
@@ -468,6 +490,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
468
490
|
require_present?: boolean | undefined;
|
|
469
491
|
command?: string | undefined;
|
|
470
492
|
timeout_ms?: number | undefined;
|
|
493
|
+
exclude?: string[] | undefined;
|
|
471
494
|
incident?: string | undefined;
|
|
472
495
|
red_proven?: boolean | undefined;
|
|
473
496
|
promoted_at?: string | undefined;
|
|
@@ -505,6 +528,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
505
528
|
require_present?: boolean | undefined;
|
|
506
529
|
command?: string | undefined;
|
|
507
530
|
timeout_ms?: number | undefined;
|
|
531
|
+
exclude?: string[] | undefined;
|
|
508
532
|
incident?: string | undefined;
|
|
509
533
|
red_proven?: boolean | undefined;
|
|
510
534
|
severity?: "warn" | "block" | undefined;
|
|
@@ -2725,6 +2749,11 @@ interface SensorTarget {
|
|
|
2725
2749
|
* Does this sensor apply to `path`? A sensor with no explicit `paths` (and whose
|
|
2726
2750
|
* memory has no anchor paths) applies everywhere. Otherwise it applies to the exact
|
|
2727
2751
|
* file, a directory prefix, or a glob (`**` / `*.controller.ts` style) scope.
|
|
2752
|
+
*
|
|
2753
|
+
* Two guards keep a rule from firing where it can only be a false positive: an explicit `exclude`
|
|
2754
|
+
* glob list (a production-only lesson skips its own test doubles), and a built-in skip of
|
|
2755
|
+
* DOCUMENTATION files for content sensors — example code in a `.md`/`.rst` is never shipped, so a
|
|
2756
|
+
* regex/ast match there is always wrong unless the sensor names that exact file.
|
|
2728
2757
|
*/
|
|
2729
2758
|
declare function sensorAppliesToPath(sensor: Sensor, anchorPaths: string[], path: string): boolean;
|
|
2730
2759
|
/**
|
|
@@ -2745,21 +2774,41 @@ declare const SENSOR_ABSENT_LOOKBACK = 2;
|
|
|
2745
2774
|
declare function compileRegexSensor(sensor: Sensor): RegExp | null;
|
|
2746
2775
|
/**
|
|
2747
2776
|
* Blank comment spans in scannable text so a sensor's regex matches CODE, not the prose that
|
|
2748
|
-
* documents it
|
|
2777
|
+
* documents it — including MULTI-LINE block comments whose forbidden token sits on a middle line
|
|
2778
|
+
* that starts with neither the opener nor `*` (field report 2026-09-04 §3.1: a `bg-emerald-600` in a
|
|
2779
|
+
* multi-line CSS comment still tripped the sensor because the earlier fix was purely per-line).
|
|
2780
|
+
* Returns `content` unchanged for unknown file types. Pure.
|
|
2749
2781
|
*/
|
|
2750
2782
|
declare function stripCommentsForScan(content: string, path: string): string;
|
|
2783
|
+
/**
|
|
2784
|
+
* An inline waiver a developer wrote to excuse ONE line from ONE sensor, recorded so the exception
|
|
2785
|
+
* is auditable rather than silent. Field report 2026-09-04 §3.1: a false positive had no outlet
|
|
2786
|
+
* other than rewriting correct code or deleting the sensor — and "a linter with no exception
|
|
2787
|
+
* mechanism ends up disabled", which costs the whole rule, not one line.
|
|
2788
|
+
*/
|
|
2789
|
+
interface SensorWaiver {
|
|
2790
|
+
memory_id: string;
|
|
2791
|
+
/** Project-relative file the waiver was used in. */
|
|
2792
|
+
file?: string;
|
|
2793
|
+
/** The waived line, trimmed and capped. */
|
|
2794
|
+
line: string;
|
|
2795
|
+
/** The reason the author gave after the slug. Never empty — a reasonless waiver does not apply. */
|
|
2796
|
+
reason: string;
|
|
2797
|
+
}
|
|
2798
|
+
declare function sensorWaiverOnLine(memoryId: string, rawLine: string): string | null;
|
|
2751
2799
|
/**
|
|
2752
2800
|
* Run a single regex sensor over one target. Returns the first matching line as a hit,
|
|
2753
|
-
* or null. Deterministic and side-effect-free
|
|
2801
|
+
* or null. Deterministic and side-effect-free — waivers found along the way are pushed into the
|
|
2802
|
+
* optional `waivers` sink so the caller can journal them (the exception stays visible).
|
|
2754
2803
|
*/
|
|
2755
|
-
declare function runRegexSensor(memoryId: string, sensor: Sensor, target: SensorTarget): SensorHit | null;
|
|
2804
|
+
declare function runRegexSensor(memoryId: string, sensor: Sensor, target: SensorTarget, waivers?: SensorWaiver[]): SensorHit | null;
|
|
2756
2805
|
/**
|
|
2757
2806
|
* Run every memory's regex sensor against every applicable target.
|
|
2758
2807
|
*
|
|
2759
2808
|
* Memories without a sensor, or with a non-regex sensor, are skipped (non-regex kinds
|
|
2760
2809
|
* are the CLI's responsibility). At most one hit per (memory, file) pair is returned.
|
|
2761
2810
|
*/
|
|
2762
|
-
declare function runSensors(memories: Memory[], targets: SensorTarget[]): SensorHit[];
|
|
2811
|
+
declare function runSensors(memories: Memory[], targets: SensorTarget[], waivers?: SensorWaiver[]): SensorHit[];
|
|
2763
2812
|
/**
|
|
2764
2813
|
* Parse every touched file path out of a unified diff (`diff --git a/X b/X` headers), including
|
|
2765
2814
|
* files changed by pure DELETIONS — the case a presence sensor exists for. Pure.
|
|
@@ -4189,4 +4238,4 @@ interface ReviewDraftOptions {
|
|
|
4189
4238
|
/** Template review learnings into proposed-memory drafts (reuses the scanner-ingest draft shape). */
|
|
4190
4239
|
declare function reviewLearningsToDrafts(learnings: ReviewLearning[], options?: ReviewDraftOptions): MemoryDraft[];
|
|
4191
4240
|
|
|
4192
|
-
export { ADAPTIVE_FLOOR_MIN_SAMPLES, AUTOPILOT_DEFAULTS, type Activation, type ActivationContext, ActivationSchema, type AgentContext, type Anchor, type AnchorAuditRow, type AnchorChurn, AnchorSchema, type AntiPatternGate, type AppendFrictionInput, type AppendFrictionResult, type AppliedConflictResolution, type AstExport, type AutoPromoteRule, BRIDGE_MARKERS, BRIDGE_TARGETS, BRIDGE_TARGET_PATH, BRIEFING_MARKER_TTL_MS, BRIEFING_PRESET_DEFAULTS, type BaselineHealth, 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, CONTENT_CATCH_CODES, 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 ContractCheck, 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_POSTURE, DEFAULT_PRIORITY_SIGNALS, DEFAULT_SPECIFICITY, 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, FRICTION_FIELD_MAX, FRICTION_LOG_FILE, FRICTION_STATE_FILE, type FailureCoverageOptions, type FailureObservation, type FeedbackAdjustment, type FeedbackAdjustmentAction, type FeedbackAdjustmentOptions, type Finding, type FindingFormat, type FindingSeverity, type FrictionGroup, type FrictionKind, type FrictionReport, type FrictionState, type FrictionStateEntry, type FrictionStatus, GATE_REMINDER_WINDOW_MS, GUESSABLE_THRESHOLD, type GateFinding, type GateMissProposal, type GatePolicy, type GatePolicyInput, type GatePosture, type GatePrecision, type GatePrecisionDelta, type GatePrecisionMetricDelta, type GateSeverity, type GateStage, type GateTuningSuggestion, type GateVerdict, type GateVerdictInput, type GenerateBridgesOptions, type GitCommit, type GitWatchPlan, type GitWatchState, type GithubReleaseCode, type GithubReleaseInput, type GithubReleaseVerdict, 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, type NpmPublicationCode, type NpmPublicationInput, type NpmPublicationVerdict, PREVENTION_DEBOUNCE_MS, PREVENTION_RECEIPT_MARKER, PROCESS_GATE_CODES, PROJECT_CONTEXT_FILE, PROJECT_CONTEXT_THROTTLE_MS, type PostIncidentLesson, type PreventionCommentFinding, type PreventionEvent, type PreventionEventDetail, type PreventionReceipt, type PreventionReceiptRow, type PreventionRow, type PreventionSource, type PreventionTrend, type PrioritySignals, type ProposedEvalSpec, type ProposedSensorVerdict, RECAP_HISTORY_HEADING, RECAP_HISTORY_MAX, 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, SETUP_GATE_CODES, 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, WEAK_ANCHOR_CHURN_RATIO, adaptiveSemanticFloor, addedLineNumbersFromDiff, addedLinesFromDiff, aggregateRetrieval, aggregateSensors, aggregateUsage, allocateBudget, anchorMatchesComponent, anchorSpecificity, antiPatternGateParams, appendEvalHistory, appendFrictionReport, appendPreventionEvent, appendProposedRetrievalCases, appendRuntimeJournalEntry, appendSensorEvaluations, appendUsageEvent, applyConflictResolution, applyFeedbackAdjustment, approveProposedCases, assessBehaviourCoverage, assessBootstrapState, assessScaffoldLoop, assessSensorHealth, auditAnchorSpecificity, bridgeMemorySummary, briefingMarkerPath, briefingMarkersDir, briefingProofLine, buildBaselineHealthFinding, buildCodeMap, buildCoverageIndex, buildDashboard, buildDocFrequency, buildFrontmatter, buildHandoffMarkdown, buildPreventionReceipt, buildProposeCommand, buildRecapWithHistory, buildReport, bumpRead, changedPathsFromDiff, churnForAnchors, classifyGithubRelease, classifyMemoryPriority, classifyNpmPublication, codeMapContentHash, codeMapPath, collectTimelineEntries, compactAutoRecapBody, compareEvalReports, compareGatePrecision, compareImpact, compareVersions, compileRegexSensor, componentOf, computeBaselineHealth, computeEvalTrend, computeGatePrecision, computeImpact, computePreventionTrend, computeRecurrence, computeScopeHash, configPath, contractLockPath, countSourceFilesOnDisk, decideVerdict, dedupeRefusals, deriveConfidence, deriveMainAreas, describePosture, detectAgentContext, detectSensorWeakening, detectStacksFromManifests, diffContract, diffHasDistinctiveOverlap, distillFailureObservations, distinctiveCap, draftsFromFindings, emptyUsage, emptyUsageIndex, enforcementDir, estimateTokens, evalHistoryPath, evaluateSkillActivation, existingGateMissShas, explainSensorRejection, extractActionsBriefBody, extractCorrectApproachExamples, extractReferencedPaths, extractReviewLearnings, extractSensorExamples, extractSnippet, extractTestFilePathsFromCommand, filterNewDrafts, findCoverageGaps, findLexicalConflictPairs, findProjectRoot, findTopicStatusConflictPairs, findUncapturedFailures, findingBody, findingToDraft, firstMemoryOneLine, formatFrictionIssue, frictionFingerprint, frictionLogPath, frictionStatePath, gatePassedShas, generateBridges, getUsage, globToRegExp, groupFriction, handoffAgeMs, handoffFilePath, hasPendingTestMarker, hasRecentBriefingMarker, hashProjectContext, incidentHintsFromDiff, incidentSuffix, inferModulesFromPaths, isAutoPromoteEligible, isAutoRecap, isCovered, isDecaying, isDistinctiveToken, isEnvWorkaroundMemory, isFreshIsoDate, isGlobPath, isHarnessErrorOutput, isLikelyGuessable, isNoiseSubject, isProductionCodeFile, isRetiredMemory, isSensorScannablePath, isSkill, isSkillSuppressed, isStackPackSeed, isStylisticRule, isTemplateProjectContext, isWeakAnchor, judgeProposedSensor, lessonShortName, listMarkdownFilesRecursive, literalMatchesAllTokens, literalMatchesAnyToken, loadCodeMap, loadConfig, loadConfigSync, loadEvalHistory, loadFrictionState, loadMemoriesFromDir, loadMemoriesFromDirDetailed, loadMemory, loadPreventionEvents, loadSensorLedger, loadUsageIndex, looksLikeGenericAdvice, meetsSeedQualityFloor, memoryFilePath, memoryHasExcludedTag, memoryMatchesAnchorPaths, mergeHotFiles, mergeMemoryVersions, mineSensorSeedFromDiff, moduleNameOf, newMemoryId, normalizeChurnPath, normalizeFindingSeverity, normalizeFramework, normalizeFrictionSummary, normalizeKind, 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, readFrictionReports, readRecentBriefingMarker, readRuntimeJournalTail, readSessionHandoff, readUsageEvents, recapBriefingExcerpt, recommendFeedbackAdjustment, recordApplied, recordGateReminder, recordPrevention, recordPreventionHits, recordProjectContextEmission, recordRejection, relPathFrom, renderBehaviourCoverageLine, renderBootstrapChecklist, renderCaughtForYou, renderPreventionComment, renderPreventionReceipt, renderPreventionReceiptShare, resolveBriefingBudget, resolveConfigPath, resolveGatePolicy, resolveHaivePaths, resolveManifestFiles, resolveProjectInfo, retirementSignal, revertedShaFromCommit, reviewLearningsToDrafts, runPresenceSensors, runRegexSensor, runSensors, runTierContract, runValidationContract, runtimeJournalPath, saveCodeMap, saveConfig, saveFrictionState, saveUsageIndex, scaffoldPostIncidentTest, scannableSensorTargets, scoreRetrievalCase, scoreSensorCase, scrubbedCommandEnv, selectCommandSensors, sensorAppliesToPath, sensorLedgerPath, sensorPatternBrittleness, sensorPromotedAtMap, sensorSelfCheck, sensorTargetsFromDiff, serializeCodeMap, serializeMemory, setFrictionStatus, shouldExpandGateReminder, snapshotContract, specificityScore, stripCommentsForScan, stripPrivate, suggestGate, suggestSensorFromMemory, suggestSensorSeed, suggestTopicKey, summarizeCaughtForYou, summarizeImpact, synthesizeSelfEvalCases, tallyHotFiles, titleFromBody, tokenizeQuery, tokenizeWords, trackDependencies, trackReads, truncateToTokens, usageLogPath, usageLogSize, usagePath, verifyAnchor, watchContracts, withQuarantineNote, withoutQuarantineNote, writeBriefingMarker, writeSessionHandoff };
|
|
4241
|
+
export { ADAPTIVE_FLOOR_MIN_SAMPLES, AUTOPILOT_DEFAULTS, type Activation, type ActivationContext, ActivationSchema, type AgentContext, type Anchor, type AnchorAuditRow, type AnchorChurn, AnchorSchema, type AntiPatternGate, type AppendFrictionInput, type AppendFrictionResult, type AppliedConflictResolution, type AstExport, type AutoPromoteRule, BRIDGE_MARKERS, BRIDGE_TARGETS, BRIDGE_TARGET_PATH, BRIEFING_MARKER_TTL_MS, BRIEFING_PRESET_DEFAULTS, type BaselineHealth, 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, CONTENT_CATCH_CODES, 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 ContractCheck, 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_POSTURE, DEFAULT_PRIORITY_SIGNALS, DEFAULT_SPECIFICITY, 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, FRICTION_FIELD_MAX, FRICTION_LOG_FILE, FRICTION_STATE_FILE, type FailureCoverageOptions, type FailureObservation, type FeedbackAdjustment, type FeedbackAdjustmentAction, type FeedbackAdjustmentOptions, type Finding, type FindingFormat, type FindingSeverity, type FrictionGroup, type FrictionKind, type FrictionReport, type FrictionState, type FrictionStateEntry, type FrictionStatus, GATE_REMINDER_WINDOW_MS, GUESSABLE_THRESHOLD, type GateFinding, type GateMissProposal, type GatePolicy, type GatePolicyInput, type GatePosture, type GatePrecision, type GatePrecisionDelta, type GatePrecisionMetricDelta, type GateSeverity, type GateStage, type GateTuningSuggestion, type GateVerdict, type GateVerdictInput, type GenerateBridgesOptions, type GitCommit, type GitWatchPlan, type GitWatchState, type GithubReleaseCode, type GithubReleaseInput, type GithubReleaseVerdict, 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, type NpmPublicationCode, type NpmPublicationInput, type NpmPublicationVerdict, PREVENTION_DEBOUNCE_MS, PREVENTION_RECEIPT_MARKER, PROCESS_GATE_CODES, PROJECT_CONTEXT_FILE, PROJECT_CONTEXT_THROTTLE_MS, type PostIncidentLesson, type PreventionCommentFinding, type PreventionEvent, type PreventionEventDetail, type PreventionReceipt, type PreventionReceiptRow, type PreventionRow, type PreventionSource, type PreventionTrend, type PrioritySignals, type ProposedEvalSpec, type ProposedSensorVerdict, RECAP_HISTORY_HEADING, RECAP_HISTORY_MAX, 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, SETUP_GATE_CODES, 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 SensorWaiver, 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, WEAK_ANCHOR_CHURN_RATIO, adaptiveSemanticFloor, addedLineNumbersFromDiff, addedLinesFromDiff, aggregateRetrieval, aggregateSensors, aggregateUsage, allocateBudget, anchorMatchesComponent, anchorSpecificity, antiPatternGateParams, appendEvalHistory, appendFrictionReport, appendPreventionEvent, appendProposedRetrievalCases, appendRuntimeJournalEntry, appendSensorEvaluations, appendUsageEvent, applyConflictResolution, applyFeedbackAdjustment, approveProposedCases, assessBehaviourCoverage, assessBootstrapState, assessScaffoldLoop, assessSensorHealth, auditAnchorSpecificity, bridgeMemorySummary, briefingMarkerPath, briefingMarkersDir, briefingProofLine, buildBaselineHealthFinding, buildCodeMap, buildCoverageIndex, buildDashboard, buildDocFrequency, buildFrontmatter, buildHandoffMarkdown, buildPreventionReceipt, buildProposeCommand, buildRecapWithHistory, buildReport, bumpRead, changedPathsFromDiff, churnForAnchors, classifyGithubRelease, classifyMemoryPriority, classifyNpmPublication, codeMapContentHash, codeMapPath, collectTimelineEntries, compactAutoRecapBody, compareEvalReports, compareGatePrecision, compareImpact, compareVersions, compileRegexSensor, componentOf, computeBaselineHealth, computeEvalTrend, computeGatePrecision, computeImpact, computePreventionTrend, computeRecurrence, computeScopeHash, configPath, contractLockPath, countSourceFilesOnDisk, decideVerdict, dedupeRefusals, deriveConfidence, deriveMainAreas, describePosture, detectAgentContext, detectSensorWeakening, detectStacksFromManifests, diffContract, diffHasDistinctiveOverlap, distillFailureObservations, distinctiveCap, draftsFromFindings, emptyUsage, emptyUsageIndex, enforcementDir, estimateTokens, evalHistoryPath, evaluateSkillActivation, existingGateMissShas, explainSensorRejection, extractActionsBriefBody, extractCorrectApproachExamples, extractReferencedPaths, extractReviewLearnings, extractSensorExamples, extractSnippet, extractTestFilePathsFromCommand, filterNewDrafts, findCoverageGaps, findLexicalConflictPairs, findProjectRoot, findTopicStatusConflictPairs, findUncapturedFailures, findingBody, findingToDraft, firstMemoryOneLine, formatFrictionIssue, frictionFingerprint, frictionLogPath, frictionStatePath, gatePassedShas, generateBridges, getUsage, globToRegExp, groupFriction, handoffAgeMs, handoffFilePath, hasPendingTestMarker, hasRecentBriefingMarker, hashProjectContext, incidentHintsFromDiff, incidentSuffix, inferModulesFromPaths, isAutoPromoteEligible, isAutoRecap, isCovered, isDecaying, isDistinctiveToken, isEnvWorkaroundMemory, isFreshIsoDate, isGlobPath, isHarnessErrorOutput, isLikelyGuessable, isNoiseSubject, isProductionCodeFile, isRetiredMemory, isSensorScannablePath, isSkill, isSkillSuppressed, isStackPackSeed, isStylisticRule, isTemplateProjectContext, isWeakAnchor, judgeProposedSensor, lessonShortName, listMarkdownFilesRecursive, literalMatchesAllTokens, literalMatchesAnyToken, loadCodeMap, loadConfig, loadConfigSync, loadEvalHistory, loadFrictionState, loadMemoriesFromDir, loadMemoriesFromDirDetailed, loadMemory, loadPreventionEvents, loadSensorLedger, loadUsageIndex, looksLikeGenericAdvice, meetsSeedQualityFloor, memoryFilePath, memoryHasExcludedTag, memoryMatchesAnchorPaths, mergeHotFiles, mergeMemoryVersions, mineSensorSeedFromDiff, moduleNameOf, newMemoryId, normalizeChurnPath, normalizeFindingSeverity, normalizeFramework, normalizeFrictionSummary, normalizeKind, 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, readFrictionReports, readRecentBriefingMarker, readRuntimeJournalTail, readSessionHandoff, readUsageEvents, recapBriefingExcerpt, recommendFeedbackAdjustment, recordApplied, recordGateReminder, recordPrevention, recordPreventionHits, recordProjectContextEmission, recordRejection, relPathFrom, renderBehaviourCoverageLine, renderBootstrapChecklist, renderCaughtForYou, renderPreventionComment, renderPreventionReceipt, renderPreventionReceiptShare, resolveBriefingBudget, resolveConfigPath, resolveGatePolicy, resolveHaivePaths, resolveManifestFiles, resolveProjectInfo, retirementSignal, revertedShaFromCommit, reviewLearningsToDrafts, runPresenceSensors, runRegexSensor, runSensors, runTierContract, runValidationContract, runtimeJournalPath, saveCodeMap, saveConfig, saveFrictionState, saveUsageIndex, scaffoldPostIncidentTest, scannableSensorTargets, scoreRetrievalCase, scoreSensorCase, scrubbedCommandEnv, selectCommandSensors, sensorAppliesToPath, sensorLedgerPath, sensorPatternBrittleness, sensorPromotedAtMap, sensorSelfCheck, sensorTargetsFromDiff, sensorWaiverOnLine, serializeCodeMap, serializeMemory, setFrictionStatus, shouldExpandGateReminder, snapshotContract, specificityScore, stripCommentsForScan, 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
|
@@ -64,6 +64,14 @@ var SensorSchema = z.object({
|
|
|
64
64
|
timeout_ms: z.number().int().positive().optional(),
|
|
65
65
|
/** Glob-ish path prefixes the sensor applies to. Falls back to the memory's anchor paths when empty. */
|
|
66
66
|
paths: z.array(z.string()).default([]),
|
|
67
|
+
/**
|
|
68
|
+
* Glob-ish paths the sensor must NOT fire on, even when they fall inside `paths`. Lets a
|
|
69
|
+
* production-only lesson (e.g. "no `any`") skip test doubles and fixtures without narrowing its
|
|
70
|
+
* scope file by file — the missing negation that made `paths: ['**']` fire on every `.test.ts`
|
|
71
|
+
* (field report 2026-09-02 §3.2). A lesson that IS about tests (e.g. "no `LocalDate.now()` in a
|
|
72
|
+
* test") simply leaves this empty, so it still fires there.
|
|
73
|
+
*/
|
|
74
|
+
exclude: z.array(z.string()).optional(),
|
|
67
75
|
/** LLM-facing self-correction message: what was done wrong and what to do instead. */
|
|
68
76
|
message: z.string().min(1),
|
|
69
77
|
/**
|
|
@@ -960,7 +968,7 @@ function applyFeedbackAdjustment(fm, adjustment, now = /* @__PURE__ */ new Date(
|
|
|
960
968
|
}
|
|
961
969
|
|
|
962
970
|
// src/prevention.ts
|
|
963
|
-
import { appendFile, mkdir as mkdir2, readFile as readFile4
|
|
971
|
+
import { appendFile, mkdir as mkdir2, readFile as readFile4 } from "fs/promises";
|
|
964
972
|
import { existsSync as existsSync4 } from "fs";
|
|
965
973
|
import path6 from "path";
|
|
966
974
|
function preventionLogPath(paths) {
|
|
@@ -988,22 +996,8 @@ async function recordPreventionHits(paths, firedIds, source, now = /* @__PURE__
|
|
|
988
996
|
await appendPreventionEvent(paths, { at, id, source, ...details[id] }).catch(() => {
|
|
989
997
|
});
|
|
990
998
|
}
|
|
991
|
-
await stampSensorLastFired(paths, recordedIds, at).catch(() => {
|
|
992
|
-
});
|
|
993
999
|
return recordedIds;
|
|
994
1000
|
}
|
|
995
|
-
async function stampSensorLastFired(paths, ids, at) {
|
|
996
|
-
if (ids.length === 0 || !existsSync4(paths.memoriesDir)) return;
|
|
997
|
-
const wanted = new Set(ids);
|
|
998
|
-
const loaded = await loadMemoriesFromDir(paths.memoriesDir);
|
|
999
|
-
for (const { memory, filePath } of loaded) {
|
|
1000
|
-
const fm = memory.frontmatter;
|
|
1001
|
-
if (!wanted.has(fm.id) || !fm.sensor || fm.sensor.last_fired === at) continue;
|
|
1002
|
-
const next = { ...memory, frontmatter: { ...fm, sensor: { ...fm.sensor, last_fired: at } } };
|
|
1003
|
-
await writeFile2(filePath, serializeMemory(next), "utf8").catch(() => {
|
|
1004
|
-
});
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
1001
|
function buildPreventionReceipt(events, memories, usage, options) {
|
|
1008
1002
|
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
1009
1003
|
const sinceMs = options.since.getTime();
|
|
@@ -1704,6 +1698,11 @@ function bridgeMemorySummary(body) {
|
|
|
1704
1698
|
const oneLine2 = firstLine.replace(/\s+/g, " ");
|
|
1705
1699
|
return oneLine2.length > 140 ? oneLine2.slice(0, 137) + "\u2026" : oneLine2;
|
|
1706
1700
|
}
|
|
1701
|
+
function breadcrumbTypeRank(type) {
|
|
1702
|
+
if (type === "attempt") return 0;
|
|
1703
|
+
if (type === "architecture" || type === "decision") return 1;
|
|
1704
|
+
return 2;
|
|
1705
|
+
}
|
|
1707
1706
|
function prepareBridgeData(memories, sensors, opts) {
|
|
1708
1707
|
const max = opts?.maxMemories ?? 8;
|
|
1709
1708
|
const topMemories = memories.filter((m) => {
|
|
@@ -1713,8 +1712,12 @@ function prepareBridgeData(memories, sensors, opts) {
|
|
|
1713
1712
|
if (m.frontmatter.tags?.includes("stack-pack") || m.frontmatter.tags?.includes("seed")) return false;
|
|
1714
1713
|
return s === "validated" || s === "proposed";
|
|
1715
1714
|
}).sort((a, b) => {
|
|
1716
|
-
const
|
|
1717
|
-
|
|
1715
|
+
const statusScore = (m) => m.frontmatter.status === "validated" ? 0 : 1;
|
|
1716
|
+
const s = statusScore(a) - statusScore(b);
|
|
1717
|
+
if (s !== 0) return s;
|
|
1718
|
+
const r = breadcrumbTypeRank(a.frontmatter.type) - breadcrumbTypeRank(b.frontmatter.type);
|
|
1719
|
+
if (r !== 0) return r;
|
|
1720
|
+
return b.frontmatter.id.localeCompare(a.frontmatter.id);
|
|
1718
1721
|
}).slice(0, max).map((m) => ({
|
|
1719
1722
|
id: m.frontmatter.id,
|
|
1720
1723
|
scope: m.frontmatter.scope,
|
|
@@ -1753,12 +1756,15 @@ function renderSensorsBlock(blockSensors) {
|
|
|
1753
1756
|
"",
|
|
1754
1757
|
"The patterns below are blocked by the repo enforcement gate.",
|
|
1755
1758
|
"Introducing them will fail the pre-commit check (`hivelore enforce check`).",
|
|
1759
|
+
"",
|
|
1760
|
+
"Wrong about one specific line? Waive that line \u2014 `// hivelore:allow <memory-id> \u2014 <reason>` at",
|
|
1761
|
+
"end of line \u2014 instead of deleting the rule or rewriting correct code. It covers that line only",
|
|
1762
|
+
"and is reported. Repeating it means the scope is wrong: narrow `paths`/`exclude`/`absent`.",
|
|
1756
1763
|
""
|
|
1757
1764
|
];
|
|
1758
1765
|
for (const s of blockSensors) {
|
|
1759
1766
|
const pathNote = s.paths.length > 0 ? ` _(applies to: ${s.paths.join(", ")})_` : "";
|
|
1760
1767
|
lines.push(`- **${s.id}**${pathNote}: ${s.message}`);
|
|
1761
|
-
if (s.pattern) lines.push(` - Pattern: \`${s.pattern}\``);
|
|
1762
1768
|
}
|
|
1763
1769
|
lines.push("", BRIDGE_MARKERS.sensorsEnd);
|
|
1764
1770
|
return lines.join("\n");
|
|
@@ -1833,15 +1839,26 @@ function normalizeProjectPath(value) {
|
|
|
1833
1839
|
return value.replace(/\\/g, "/").replace(/^\.\//, "").replace(/^[ab]\//, "").replace(/\/+$/g, "");
|
|
1834
1840
|
}
|
|
1835
1841
|
function sensorAppliesToPath(sensor, anchorPaths, path22) {
|
|
1836
|
-
const scopes = sensor.paths.length > 0 ? sensor.paths : anchorPaths;
|
|
1837
|
-
if (scopes.length === 0) return true;
|
|
1838
1842
|
const target = normalizeProjectPath(path22);
|
|
1839
|
-
|
|
1843
|
+
const matchesScope = (rawScope) => {
|
|
1840
1844
|
const scope = normalizeProjectPath(rawScope);
|
|
1841
1845
|
if (!scope) return false;
|
|
1842
1846
|
if (isGlobPath(scope)) return globToRegExp(scope).test(target);
|
|
1843
1847
|
return target === scope || target.startsWith(`${scope}/`);
|
|
1844
|
-
}
|
|
1848
|
+
};
|
|
1849
|
+
if (sensor.exclude?.some(matchesScope)) return false;
|
|
1850
|
+
const scopes = sensor.paths.length > 0 ? sensor.paths : anchorPaths;
|
|
1851
|
+
if ((sensor.kind === "regex" || sensor.kind === "ast") && isDocumentationPath(target)) {
|
|
1852
|
+
return scopes.map(normalizeProjectPath).includes(target);
|
|
1853
|
+
}
|
|
1854
|
+
if (scopes.length === 0) return true;
|
|
1855
|
+
return scopes.some(matchesScope);
|
|
1856
|
+
}
|
|
1857
|
+
var DOCUMENTATION_EXTENSIONS = /* @__PURE__ */ new Set(["md", "mdx", "markdown", "rst", "txt", "adoc"]);
|
|
1858
|
+
function isDocumentationPath(target) {
|
|
1859
|
+
const base = target.split("/").pop() ?? "";
|
|
1860
|
+
const dot = base.lastIndexOf(".");
|
|
1861
|
+
return dot >= 0 && DOCUMENTATION_EXTENSIONS.has(base.slice(dot + 1).toLowerCase());
|
|
1845
1862
|
}
|
|
1846
1863
|
var SENSOR_ABSENT_WINDOW = 6;
|
|
1847
1864
|
var SENSOR_ABSENT_LOOKBACK = 2;
|
|
@@ -1926,13 +1943,21 @@ function commentSyntaxForPath(path22) {
|
|
|
1926
1943
|
if (dot < 0) return null;
|
|
1927
1944
|
return COMMENT_SYNTAX_BY_EXT[base.slice(dot + 1).toLowerCase()] ?? null;
|
|
1928
1945
|
}
|
|
1929
|
-
function blankCommentsOnLine(line, syntax) {
|
|
1930
|
-
if (syntax.starContinuation && /^\*(\s|\/|$)/.test(line.trimStart())) {
|
|
1931
|
-
return " ".repeat(line.length);
|
|
1932
|
-
}
|
|
1946
|
+
function blankCommentsOnLine(line, syntax, inBlock) {
|
|
1933
1947
|
let out = "";
|
|
1934
1948
|
let stringDelim = null;
|
|
1935
|
-
|
|
1949
|
+
let i = 0;
|
|
1950
|
+
if (inBlock) {
|
|
1951
|
+
if (!syntax.block) return { text: line, inBlock: false };
|
|
1952
|
+
const close = syntax.block[1];
|
|
1953
|
+
const closeIdx = line.indexOf(close);
|
|
1954
|
+
if (closeIdx === -1) return { text: " ".repeat(line.length), inBlock: true };
|
|
1955
|
+
out += " ".repeat(closeIdx + close.length);
|
|
1956
|
+
i = closeIdx + close.length;
|
|
1957
|
+
} else if (syntax.starContinuation && /^\*(\s|\/|$)/.test(line.trimStart())) {
|
|
1958
|
+
return { text: " ".repeat(line.length), inBlock: false };
|
|
1959
|
+
}
|
|
1960
|
+
for (; i < line.length; i++) {
|
|
1936
1961
|
const ch = line[i];
|
|
1937
1962
|
if (stringDelim) {
|
|
1938
1963
|
out += ch;
|
|
@@ -1953,9 +1978,12 @@ function blankCommentsOnLine(line, syntax) {
|
|
|
1953
1978
|
const [open, close] = syntax.block;
|
|
1954
1979
|
if (line.startsWith(open, i)) {
|
|
1955
1980
|
const closeIdx = line.indexOf(close, i + open.length);
|
|
1956
|
-
|
|
1981
|
+
if (closeIdx === -1) {
|
|
1982
|
+
out += " ".repeat(line.length - i);
|
|
1983
|
+
return { text: out, inBlock: true };
|
|
1984
|
+
}
|
|
1985
|
+
const end = closeIdx + close.length;
|
|
1957
1986
|
out += " ".repeat(end - i);
|
|
1958
|
-
if (closeIdx === -1) break;
|
|
1959
1987
|
i = end - 1;
|
|
1960
1988
|
continue;
|
|
1961
1989
|
}
|
|
@@ -1971,14 +1999,32 @@ function blankCommentsOnLine(line, syntax) {
|
|
|
1971
1999
|
if (hitLineComment) break;
|
|
1972
2000
|
out += ch;
|
|
1973
2001
|
}
|
|
1974
|
-
return out;
|
|
2002
|
+
return { text: out, inBlock: false };
|
|
1975
2003
|
}
|
|
1976
2004
|
function stripCommentsForScan(content, path22) {
|
|
1977
2005
|
const syntax = commentSyntaxForPath(path22);
|
|
1978
2006
|
if (!syntax) return content;
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
2007
|
+
let inBlock = false;
|
|
2008
|
+
const out = [];
|
|
2009
|
+
for (const line of content.split("\n")) {
|
|
2010
|
+
const res = blankCommentsOnLine(line, syntax, inBlock);
|
|
2011
|
+
out.push(res.text);
|
|
2012
|
+
inBlock = res.inBlock;
|
|
2013
|
+
}
|
|
2014
|
+
return out.join("\n");
|
|
2015
|
+
}
|
|
2016
|
+
var WAIVER_MARKER = /hivelore:allow\s+([A-Za-z0-9._/-]+)(?=\s|$)\s*[—–:-]*\s*(.*)$/i;
|
|
2017
|
+
function sensorWaiverOnLine(memoryId, rawLine) {
|
|
2018
|
+
const m = WAIVER_MARKER.exec(rawLine);
|
|
2019
|
+
if (!m) return null;
|
|
2020
|
+
const slug = (m[1] ?? "").toLowerCase();
|
|
2021
|
+
const reason = (m[2] ?? "").replace(/(?:\*\/|-->|#>)\s*$/, "").trim();
|
|
2022
|
+
if (!slug || !reason) return null;
|
|
2023
|
+
const id = memoryId.toLowerCase();
|
|
2024
|
+
if (id !== slug && !id.includes(slug)) return null;
|
|
2025
|
+
return reason;
|
|
2026
|
+
}
|
|
2027
|
+
function runRegexSensor(memoryId, sensor, target, waivers) {
|
|
1982
2028
|
const re = compileRegexSensor(sensor);
|
|
1983
2029
|
if (!re) return null;
|
|
1984
2030
|
const absentRe = compileAbsentRegex(sensor);
|
|
@@ -1995,6 +2041,16 @@ function runRegexSensor(memoryId, sensor, target) {
|
|
|
1995
2041
|
absentRe.lastIndex = 0;
|
|
1996
2042
|
if (absentRe.test(scanLines.slice(from, to).join("\n"))) continue;
|
|
1997
2043
|
}
|
|
2044
|
+
const waivedReason = sensorWaiverOnLine(memoryId, rawLine);
|
|
2045
|
+
if (waivedReason) {
|
|
2046
|
+
waivers?.push({
|
|
2047
|
+
memory_id: memoryId,
|
|
2048
|
+
file: target.path,
|
|
2049
|
+
line: rawLine.trim().slice(0, 200),
|
|
2050
|
+
reason: waivedReason
|
|
2051
|
+
});
|
|
2052
|
+
continue;
|
|
2053
|
+
}
|
|
1998
2054
|
const brittle = sensor.kind === "regex" && sensor.pattern ? sensorPatternBrittleness(sensor.pattern) : null;
|
|
1999
2055
|
const severity = brittle ? "warn" : sensor.severity;
|
|
2000
2056
|
return {
|
|
@@ -2008,7 +2064,7 @@ function runRegexSensor(memoryId, sensor, target) {
|
|
|
2008
2064
|
}
|
|
2009
2065
|
return null;
|
|
2010
2066
|
}
|
|
2011
|
-
function runSensors(memories, targets) {
|
|
2067
|
+
function runSensors(memories, targets, waivers) {
|
|
2012
2068
|
const hits = [];
|
|
2013
2069
|
for (const memory of memories) {
|
|
2014
2070
|
const sensor = memory.frontmatter.sensor;
|
|
@@ -2017,7 +2073,7 @@ function runSensors(memories, targets) {
|
|
|
2017
2073
|
const anchorPaths = memory.frontmatter.anchor.paths;
|
|
2018
2074
|
for (const target of targets) {
|
|
2019
2075
|
if (!sensorAppliesToPath(sensor, anchorPaths, target.path)) continue;
|
|
2020
|
-
const hit = runRegexSensor(memory.frontmatter.id, sensor, target);
|
|
2076
|
+
const hit = runRegexSensor(memory.frontmatter.id, sensor, target, waivers);
|
|
2021
2077
|
if (hit) hits.push(hit);
|
|
2022
2078
|
}
|
|
2023
2079
|
}
|
|
@@ -7900,6 +7956,7 @@ export {
|
|
|
7900
7956
|
sensorPromotedAtMap,
|
|
7901
7957
|
sensorSelfCheck,
|
|
7902
7958
|
sensorTargetsFromDiff,
|
|
7959
|
+
sensorWaiverOnLine,
|
|
7903
7960
|
serializeCodeMap,
|
|
7904
7961
|
serializeMemory,
|
|
7905
7962
|
setFrictionStatus,
|