@hivelore/core 0.37.0 → 0.39.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 +79 -2
- package/dist/index.js +131 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2006,6 +2006,26 @@ declare function isSensorScannablePath(p: string): boolean;
|
|
|
2006
2006
|
* with bare content) — never when every header was a Hivelore-owned path, so `.ai/`-only diffs scan nothing.
|
|
2007
2007
|
*/
|
|
2008
2008
|
declare function scannableSensorTargets(diff: string): SensorTarget[];
|
|
2009
|
+
interface SensorWeakening {
|
|
2010
|
+
/** The `.ai/memories/**` file whose sensor the diff weakens. */
|
|
2011
|
+
file: string;
|
|
2012
|
+
/** Memory id derived from the filename (best-effort). */
|
|
2013
|
+
memory_id: string;
|
|
2014
|
+
change: "severity-demoted" | "oracle-changed" | "oracle-removed" | "sensor-removed" | "memory-deleted" | "suppression-broadened";
|
|
2015
|
+
detail: string;
|
|
2016
|
+
}
|
|
2017
|
+
/**
|
|
2018
|
+
* Detect diff hunks that WEAKEN the enforcement surface: demoting a block sensor to warn, changing
|
|
2019
|
+
* or removing its oracle (`pattern`/`command`), broadening its `absent` suppression, deleting the
|
|
2020
|
+
* whole sensor block, or deleting a memory file that carried a block sensor.
|
|
2021
|
+
*
|
|
2022
|
+
* Rationale: the gate is written in `.ai/` — the same tree the agent it constrains can edit. A
|
|
2023
|
+
* legitimate demotion exists (that's why this yields REVIEW findings, never blocks), but a weakening
|
|
2024
|
+
* that sails through unmentioned is exactly how a documented lesson silently stops protecting.
|
|
2025
|
+
* Deterministic, pure, diff-text only. Additions (new sensors) never flag; removing `absent`
|
|
2026
|
+
* TIGHTENS a sensor and never flags.
|
|
2027
|
+
*/
|
|
2028
|
+
declare function detectSensorWeakening(diff: string): SensorWeakening[];
|
|
2009
2029
|
interface SensorSelfCheck {
|
|
2010
2030
|
/** The sensor stays SILENT on the current, presumed-correct code — i.e. it won't false-positive. */
|
|
2011
2031
|
silent_on_current: boolean;
|
|
@@ -2209,9 +2229,33 @@ interface TestScaffold {
|
|
|
2209
2229
|
}
|
|
2210
2230
|
interface ScaffoldOptions {
|
|
2211
2231
|
framework: TestFramework;
|
|
2212
|
-
/** Override the generated file path (project-relative). */
|
|
2232
|
+
/** Override the generated file path (project-relative). Wins over baseDir. */
|
|
2213
2233
|
outPath?: string;
|
|
2234
|
+
/**
|
|
2235
|
+
* Repo-relative directory of the package that owns the incident (monorepo awareness). The default
|
|
2236
|
+
* test path and run command are placed inside it. Empty/omitted → repo root.
|
|
2237
|
+
*/
|
|
2238
|
+
baseDir?: string;
|
|
2239
|
+
/**
|
|
2240
|
+
* Override the propose command embedded in the header and returned. Used by multi-package
|
|
2241
|
+
* scaffolds: a memory carries ONE sensor, so several generated tests share a single proposal
|
|
2242
|
+
* whose command chains every run command.
|
|
2243
|
+
*/
|
|
2244
|
+
proposeCommandOverride?: string;
|
|
2214
2245
|
}
|
|
2246
|
+
/** Map a user-supplied framework string (with common aliases) to a TestFramework, or null. */
|
|
2247
|
+
declare function normalizeFramework(input: string): TestFramework | null;
|
|
2248
|
+
/**
|
|
2249
|
+
* Pure framework decision from already-gathered facts (a package.json's deps + non-JS signals). The
|
|
2250
|
+
* FS walking that produces these facts is I/O and lives in the caller (cli/mcp), keeping core pure.
|
|
2251
|
+
*/
|
|
2252
|
+
declare function pickTestFramework(pkg: {
|
|
2253
|
+
dependencies?: Record<string, string>;
|
|
2254
|
+
devDependencies?: Record<string, string>;
|
|
2255
|
+
} | null, signals?: {
|
|
2256
|
+
goMod?: boolean;
|
|
2257
|
+
pySignal?: boolean;
|
|
2258
|
+
}): TestFramework;
|
|
2215
2259
|
/** Strip the `YYYY-MM-DD-<type>-` id prefix to the descriptive slug (`importing-momentjs`). */
|
|
2216
2260
|
declare function lessonShortName(memoryId: string): string;
|
|
2217
2261
|
/**
|
|
@@ -2224,8 +2268,41 @@ declare function parseLessonFields(body: string): {
|
|
|
2224
2268
|
whyFailed?: string;
|
|
2225
2269
|
instead?: string;
|
|
2226
2270
|
};
|
|
2271
|
+
/**
|
|
2272
|
+
* Build the `sensors propose --kind test` line that arms a written post-incident test as the
|
|
2273
|
+
* lesson's oracle. Exported so multi-package scaffolds can chain several run commands into ONE
|
|
2274
|
+
* proposal (a memory carries a single sensor).
|
|
2275
|
+
*/
|
|
2276
|
+
declare function buildProposeCommand(lesson: PostIncidentLesson, runCommand: string): string;
|
|
2227
2277
|
/** Build a scaffold for the given lesson + framework. Pure — the caller writes `content` to `relPath`. */
|
|
2228
2278
|
declare function scaffoldPostIncidentTest(lesson: PostIncidentLesson, options: ScaffoldOptions): TestScaffold;
|
|
2279
|
+
/** First-line provenance marker every generated scaffold carries. */
|
|
2280
|
+
declare const SCAFFOLD_MARKER_RE: RegExp;
|
|
2281
|
+
interface ScaffoldLoopGap {
|
|
2282
|
+
/** Memory id the scaffold was generated from (parsed from the provenance marker). */
|
|
2283
|
+
memory_id: string;
|
|
2284
|
+
/** Project-relative path of the scaffold file. */
|
|
2285
|
+
path: string;
|
|
2286
|
+
/** The stub is still pending (todo/skip) — the assertion was never written. */
|
|
2287
|
+
pending: boolean;
|
|
2288
|
+
/** The lesson carries a validated shell/test sensor — the oracle is routed to the gate. */
|
|
2289
|
+
armed: boolean;
|
|
2290
|
+
/** The referenced memory no longer exists (scaffold orphaned). */
|
|
2291
|
+
memory_missing: boolean;
|
|
2292
|
+
}
|
|
2293
|
+
/**
|
|
2294
|
+
* Cross-check written post-incident scaffolds against the corpus: a scaffold whose assertion is
|
|
2295
|
+
* still pending, or whose lesson has no armed command sensor, is an OPEN behaviour loop — the
|
|
2296
|
+
* incident is documented but nothing deterministic guards it yet. Pure: callers collect the files.
|
|
2297
|
+
* Returns only the gaps (closed loops are silent).
|
|
2298
|
+
*/
|
|
2299
|
+
declare function assessScaffoldLoop(files: Array<{
|
|
2300
|
+
path: string;
|
|
2301
|
+
content: string;
|
|
2302
|
+
}>, memories: Array<{
|
|
2303
|
+
id: string;
|
|
2304
|
+
sensorKind?: "regex" | "shell" | "test" | null;
|
|
2305
|
+
}>): ScaffoldLoopGap[];
|
|
2229
2306
|
|
|
2230
2307
|
/**
|
|
2231
2308
|
* First-agent bootstrap state — is the repo's knowledge layer filled enough for later agents to rely on?
|
|
@@ -3075,4 +3152,4 @@ interface AgentContext {
|
|
|
3075
3152
|
}
|
|
3076
3153
|
declare function detectAgentContext(env?: Record<string, string | undefined>): AgentContext;
|
|
3077
3154
|
|
|
3078
|
-
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 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 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 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 ProposedSensorVerdict, RUNTIME_JOURNAL_FILENAME, type RecurrenceReport, type RecurrenceRow, type ResolveProjectInfo, type RetirementSignal, type RetrievalAggregate, type RetrievalCase, type RetrievalCaseResult, type RuntimeJournalEntry, SEED_QUALITY_FLOOR, SENSOR_ABSENT_LOOKBACK, SENSOR_ABSENT_WINDOW, SESSION_RECAP_TTL_MS, STACK_PACK_TAG, 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 SessionHandoffData, type SkillActivation, TEST_FRAMEWORKS, type TestFramework, type TestScaffold, type TimelineEntry, type TopicStatusPair, type TruncateOptions, type TruncateResult, USAGE_FILE, USAGE_LOG_DIR, USAGE_LOG_FILE, type UncapturedFailure, type UsageAggregate, type UsageEvent, type UsageIndex, type VerifyOptions, type VerifyResult, addedLinesFromDiff, aggregateRetrieval, aggregateSensors, aggregateUsage, allocateBudget, antiPatternGateParams, appendEvalHistory, appendPreventionEvent, appendRuntimeJournalEntry, appendSensorEvaluations, appendUsageEvent, applyConflictResolution, applyFeedbackAdjustment, assessBootstrapState, assessSensorHealth, bridgeMemorySummary, briefingMarkerPath, briefingMarkersDir, briefingProofLine, buildCodeMap, buildCoverageIndex, buildDashboard, buildDocFrequency, buildFrontmatter, buildHandoffMarkdown, buildPreventionReceipt, buildReport, bumpRead, classifyMemoryPriority, codeMapPath, collectTimelineEntries, compactAutoRecapBody, compareEvalReports, compareGatePrecision, compareImpact, compileRegexSensor, componentOf, computeEvalTrend, computeGatePrecision, computeImpact, computePreventionTrend, computeRecurrence, computeScopeHash, configPath, contractLockPath, countSourceFilesOnDisk, deriveConfidence, detectAgentContext, detectStacksFromManifests, diffContract, diffHasDistinctiveOverlap, distinctiveCap, draftsFromFindings, emptyUsage, emptyUsageIndex, enforcementDir, estimateTokens, evalHistoryPath, evaluateSkillActivation, existingGateMissShas, extractActionsBriefBody, extractReferencedPaths, extractSensorExamples, extractSnippet, filterNewDrafts, findCoverageGaps, findLexicalConflictPairs, findProjectRoot, findTopicStatusConflictPairs, findUncapturedFailures, findingBody, findingToDraft, firstMemoryOneLine, gatePassedShas, generateBridges, getUsage, globToRegExp, handoffAgeMs, handoffFilePath, hasRecentBriefingMarker, hashProjectContext, incidentSuffix, inferModulesFromPaths, isAutoPromoteEligible, isAutoRecap, isCovered, isDecaying, isDistinctiveToken, isEnvWorkaroundMemory, isFreshIsoDate, isGlobPath, isLikelyGuessable, isNoiseSubject, 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, normalizeSessionId, overallScore, parseEslintJson, parseFileAst, parseFindings, parseLessonFields, parseMemory, parseNpmAudit, parseSarif, parseSince, parseSonar, pathsOverlap, pickSnippetNeedle, planConflictResolution, planGitWatch, prepareBridgeData, preventionLogPath, priorityRank, prioritySignals, projectContextRecentlyEmitted, proposeGateMissDrafts, proposeSeedsFromCommits, pullCrossRepoSources, quarantineNote, queryCodeMap, rankMemoriesLexical, readRecentBriefingMarker, readRuntimeJournalTail, readSessionHandoff, readUsageEvents, recommendFeedbackAdjustment, recordApplied, recordPrevention, recordPreventionHits, recordProjectContextEmission, recordRejection, relPathFrom, renderBootstrapChecklist, renderCaughtForYou, renderPreventionReceipt, renderPreventionReceiptShare, resolveBriefingBudget, resolveHaivePaths, resolveManifestFiles, resolveProjectInfo, retirementSignal, revertedShaFromCommit, runRegexSensor, runSensors, runtimeJournalPath, saveCodeMap, saveConfig, saveUsageIndex, scaffoldPostIncidentTest, scannableSensorTargets, scoreRetrievalCase, scoreSensorCase, 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 };
|
|
3155
|
+
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 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 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 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 ProposedSensorVerdict, RUNTIME_JOURNAL_FILENAME, type RecurrenceReport, type RecurrenceRow, type ResolveProjectInfo, type RetirementSignal, type RetrievalAggregate, type RetrievalCase, type RetrievalCaseResult, 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 TimelineEntry, type TopicStatusPair, type TruncateOptions, type TruncateResult, USAGE_FILE, USAGE_LOG_DIR, USAGE_LOG_FILE, type UncapturedFailure, type UsageAggregate, type UsageEvent, type UsageIndex, type VerifyOptions, type VerifyResult, addedLinesFromDiff, aggregateRetrieval, aggregateSensors, aggregateUsage, allocateBudget, antiPatternGateParams, appendEvalHistory, appendPreventionEvent, appendRuntimeJournalEntry, appendSensorEvaluations, appendUsageEvent, applyConflictResolution, applyFeedbackAdjustment, 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, detectAgentContext, detectSensorWeakening, detectStacksFromManifests, diffContract, diffHasDistinctiveOverlap, distinctiveCap, draftsFromFindings, emptyUsage, emptyUsageIndex, enforcementDir, estimateTokens, evalHistoryPath, evaluateSkillActivation, existingGateMissShas, extractActionsBriefBody, extractReferencedPaths, extractSensorExamples, extractSnippet, filterNewDrafts, findCoverageGaps, findLexicalConflictPairs, findProjectRoot, findTopicStatusConflictPairs, findUncapturedFailures, findingBody, findingToDraft, firstMemoryOneLine, gatePassedShas, generateBridges, getUsage, globToRegExp, handoffAgeMs, handoffFilePath, hasRecentBriefingMarker, hashProjectContext, incidentSuffix, inferModulesFromPaths, isAutoPromoteEligible, isAutoRecap, isCovered, isDecaying, isDistinctiveToken, isEnvWorkaroundMemory, isFreshIsoDate, isGlobPath, isLikelyGuessable, isNoiseSubject, 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, renderBootstrapChecklist, renderCaughtForYou, renderPreventionReceipt, renderPreventionReceiptShare, resolveBriefingBudget, resolveHaivePaths, resolveManifestFiles, resolveProjectInfo, retirementSignal, revertedShaFromCommit, runRegexSensor, runSensors, runtimeJournalPath, saveCodeMap, saveConfig, saveUsageIndex, scaffoldPostIncidentTest, scannableSensorTargets, scoreRetrievalCase, scoreSensorCase, 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
|
@@ -4035,6 +4035,79 @@ function scannableSensorTargets(diff) {
|
|
|
4035
4035
|
if (all.length === 0) return [{ path: "", content: diff }];
|
|
4036
4036
|
return all.filter((t) => isSensorScannablePath(t.path));
|
|
4037
4037
|
}
|
|
4038
|
+
function diffFileChanges(diff) {
|
|
4039
|
+
const files = [];
|
|
4040
|
+
let current = null;
|
|
4041
|
+
let oldPath = null;
|
|
4042
|
+
for (const line of diff.split("\n")) {
|
|
4043
|
+
if (line.startsWith("--- ")) {
|
|
4044
|
+
const raw = line.slice(4).trim();
|
|
4045
|
+
oldPath = raw === "/dev/null" ? null : normalizeProjectPath(raw);
|
|
4046
|
+
continue;
|
|
4047
|
+
}
|
|
4048
|
+
if (line.startsWith("+++ ")) {
|
|
4049
|
+
const raw = line.slice(4).trim();
|
|
4050
|
+
const newPath = raw === "/dev/null" ? null : normalizeProjectPath(raw);
|
|
4051
|
+
current = {
|
|
4052
|
+
path: newPath ?? oldPath ?? "",
|
|
4053
|
+
deleted: newPath === null,
|
|
4054
|
+
removed: [],
|
|
4055
|
+
added: []
|
|
4056
|
+
};
|
|
4057
|
+
files.push(current);
|
|
4058
|
+
continue;
|
|
4059
|
+
}
|
|
4060
|
+
if (!current) continue;
|
|
4061
|
+
if (line.startsWith("-") && !line.startsWith("---")) current.removed.push(line.slice(1));
|
|
4062
|
+
else if (line.startsWith("+") && !line.startsWith("+++")) current.added.push(line.slice(1));
|
|
4063
|
+
}
|
|
4064
|
+
return files;
|
|
4065
|
+
}
|
|
4066
|
+
var SENSOR_ORACLE_KEY_RE = /^\s*(pattern|command):\s*(.*)$/;
|
|
4067
|
+
var SENSOR_ABSENT_KEY_RE = /^\s*absent:\s*(.*)$/;
|
|
4068
|
+
var SEVERITY_BLOCK_RE = /^\s*severity:\s*['"]?block['"]?\s*$/;
|
|
4069
|
+
var SEVERITY_WARN_RE = /^\s*severity:\s*['"]?warn['"]?\s*$/;
|
|
4070
|
+
var SENSOR_BLOCK_START_RE = /^\s*sensor:\s*$/;
|
|
4071
|
+
function detectSensorWeakening(diff) {
|
|
4072
|
+
const weakenings = [];
|
|
4073
|
+
for (const file of diffFileChanges(diff)) {
|
|
4074
|
+
if (!file.path.startsWith(".ai/memories/") || !file.path.endsWith(".md")) continue;
|
|
4075
|
+
const memoryId = file.path.replace(/^.*\//, "").replace(/\.md$/, "");
|
|
4076
|
+
const flag = (change, detail) => {
|
|
4077
|
+
weakenings.push({ file: file.path, memory_id: memoryId, change, detail });
|
|
4078
|
+
};
|
|
4079
|
+
const removedBlockSeverity = file.removed.some((l) => SEVERITY_BLOCK_RE.test(l));
|
|
4080
|
+
if (file.deleted) {
|
|
4081
|
+
if (file.removed.some((l) => SENSOR_BLOCK_START_RE.test(l)) && removedBlockSeverity) {
|
|
4082
|
+
flag("memory-deleted", "memory file with a block sensor deleted");
|
|
4083
|
+
}
|
|
4084
|
+
continue;
|
|
4085
|
+
}
|
|
4086
|
+
if (removedBlockSeverity && file.added.some((l) => SEVERITY_WARN_RE.test(l))) {
|
|
4087
|
+
flag("severity-demoted", "severity: block \u2192 warn");
|
|
4088
|
+
}
|
|
4089
|
+
for (const line of file.removed) {
|
|
4090
|
+
const m = line.match(SENSOR_ORACLE_KEY_RE);
|
|
4091
|
+
if (!m) continue;
|
|
4092
|
+
const key = m[1];
|
|
4093
|
+
const replacement = file.added.find((l) => l.match(SENSOR_ORACLE_KEY_RE)?.[1] === key);
|
|
4094
|
+
if (replacement === void 0) {
|
|
4095
|
+
flag("oracle-removed", `sensor ${key} removed`);
|
|
4096
|
+
} else if (replacement.trim() !== line.trim()) {
|
|
4097
|
+
flag("oracle-changed", `sensor ${key} changed`);
|
|
4098
|
+
}
|
|
4099
|
+
}
|
|
4100
|
+
const removedAbsent = file.removed.find((l) => SENSOR_ABSENT_KEY_RE.test(l));
|
|
4101
|
+
const addedAbsent = file.added.find((l) => SENSOR_ABSENT_KEY_RE.test(l));
|
|
4102
|
+
if (addedAbsent !== void 0 && addedAbsent.trim() !== removedAbsent?.trim()) {
|
|
4103
|
+
flag("suppression-broadened", removedAbsent === void 0 ? "absent marker added" : "absent marker changed");
|
|
4104
|
+
}
|
|
4105
|
+
if (file.removed.some((l) => SENSOR_BLOCK_START_RE.test(l)) && removedBlockSeverity && !file.added.some((l) => SENSOR_BLOCK_START_RE.test(l))) {
|
|
4106
|
+
flag("sensor-removed", "block sensor block deleted");
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
return weakenings;
|
|
4110
|
+
}
|
|
4038
4111
|
function sensorSelfCheck(sensor, input) {
|
|
4039
4112
|
const firedOn = [];
|
|
4040
4113
|
for (const target of input.currentTargets) {
|
|
@@ -4488,6 +4561,26 @@ function escapeRegExp(value) {
|
|
|
4488
4561
|
|
|
4489
4562
|
// src/test-scaffold.ts
|
|
4490
4563
|
var TEST_FRAMEWORKS = ["vitest", "jest", "pytest", "gotest"];
|
|
4564
|
+
function normalizeFramework(input) {
|
|
4565
|
+
const v = input.trim().toLowerCase();
|
|
4566
|
+
if (v === "vitest") return "vitest";
|
|
4567
|
+
if (v === "jest") return "jest";
|
|
4568
|
+
if (v === "pytest" || v === "py" || v === "python") return "pytest";
|
|
4569
|
+
if (v === "go" || v === "gotest" || v === "go-test") return "gotest";
|
|
4570
|
+
return null;
|
|
4571
|
+
}
|
|
4572
|
+
function pickTestFramework(pkg, signals = {}) {
|
|
4573
|
+
const deps = { ...pkg?.dependencies, ...pkg?.devDependencies };
|
|
4574
|
+
if (deps.vitest) return "vitest";
|
|
4575
|
+
if (deps.jest || deps["ts-jest"]) return "jest";
|
|
4576
|
+
if (signals.goMod) return "gotest";
|
|
4577
|
+
if (signals.pySignal) return "pytest";
|
|
4578
|
+
return "vitest";
|
|
4579
|
+
}
|
|
4580
|
+
function joinRel(baseDir, rest) {
|
|
4581
|
+
const base = (baseDir ?? "").replace(/^\/+|\/+$/g, "");
|
|
4582
|
+
return base ? `${base}/${rest}` : rest;
|
|
4583
|
+
}
|
|
4491
4584
|
function lessonShortName(memoryId) {
|
|
4492
4585
|
const stripped = memoryId.replace(
|
|
4493
4586
|
/^\d{4}-\d{2}-\d{2}-(?:attempt|gotcha|decision|convention|architecture|glossary|skill|session_recap)-/,
|
|
@@ -4511,7 +4604,7 @@ function parseLessonFields(body) {
|
|
|
4511
4604
|
const instead = body.match(/\*\*Instead,\s*use:\*\*\s*([^\n]+)/i)?.[1]?.trim();
|
|
4512
4605
|
return { title, whyFailed, instead };
|
|
4513
4606
|
}
|
|
4514
|
-
function
|
|
4607
|
+
function buildProposeCommand(lesson, runCommand) {
|
|
4515
4608
|
const parts = [
|
|
4516
4609
|
`hivelore sensors propose ${lesson.memoryId}`,
|
|
4517
4610
|
"--kind test",
|
|
@@ -4539,18 +4632,19 @@ function scaffoldPostIncidentTest(lesson, options) {
|
|
|
4539
4632
|
const framework = options.framework;
|
|
4540
4633
|
const short = lessonShortName(lesson.memoryId);
|
|
4541
4634
|
const desc = oneLine(lesson.title) || short;
|
|
4635
|
+
const propose = (run) => options.proposeCommandOverride ?? buildProposeCommand(lesson, run);
|
|
4542
4636
|
let relPath;
|
|
4543
4637
|
let runCommand;
|
|
4544
4638
|
let content;
|
|
4545
4639
|
if (framework === "vitest" || framework === "jest") {
|
|
4546
|
-
relPath = options.outPath ?? `tests/incidents/${short}.test.ts
|
|
4640
|
+
relPath = options.outPath ?? joinRel(options.baseDir, `tests/incidents/${short}.test.ts`);
|
|
4547
4641
|
runCommand = framework === "vitest" ? `npx vitest run ${relPath}` : `npx jest ${relPath}`;
|
|
4548
4642
|
const hc = (l) => l ? `// ${l}` : "//";
|
|
4549
4643
|
const importLine = framework === "vitest" ? `import { describe, it, expect } from "vitest";
|
|
4550
4644
|
|
|
4551
4645
|
` : "";
|
|
4552
4646
|
content = `${header(lesson, hc)}
|
|
4553
|
-
// ${
|
|
4647
|
+
// ${propose(runCommand)}
|
|
4554
4648
|
|
|
4555
4649
|
` + importLine + `describe(${JSON.stringify(desc)}, () => {
|
|
4556
4650
|
it.todo("reproduces ${lesson.memoryId} and stays fixed");
|
|
@@ -4563,11 +4657,11 @@ function scaffoldPostIncidentTest(lesson, options) {
|
|
|
4563
4657
|
`;
|
|
4564
4658
|
} else if (framework === "pytest") {
|
|
4565
4659
|
const fn = snake(short);
|
|
4566
|
-
relPath = options.outPath ?? `tests/incidents/test_${fn}.py
|
|
4660
|
+
relPath = options.outPath ?? joinRel(options.baseDir, `tests/incidents/test_${fn}.py`);
|
|
4567
4661
|
runCommand = `pytest ${relPath}`;
|
|
4568
4662
|
const hc = (l) => l ? `# ${l}` : "#";
|
|
4569
4663
|
content = `${header(lesson, hc)}
|
|
4570
|
-
# ${
|
|
4664
|
+
# ${propose(runCommand)}
|
|
4571
4665
|
|
|
4572
4666
|
import pytest
|
|
4573
4667
|
|
|
@@ -4579,12 +4673,12 @@ def test_${fn}():
|
|
|
4579
4673
|
`;
|
|
4580
4674
|
} else {
|
|
4581
4675
|
const fn = pascal(short);
|
|
4582
|
-
const dir = options.outPath ? options.outPath.replace(/\/[^/]+$/, "") : "incidents";
|
|
4583
|
-
relPath = options.outPath ?? `incidents/incident_${snake(short)}_test.go
|
|
4676
|
+
const dir = options.outPath ? options.outPath.replace(/\/[^/]+$/, "") : joinRel(options.baseDir, "incidents");
|
|
4677
|
+
relPath = options.outPath ?? joinRel(options.baseDir, `incidents/incident_${snake(short)}_test.go`);
|
|
4584
4678
|
runCommand = `go test ./${dir}/`;
|
|
4585
4679
|
const hc = (l) => l ? `// ${l}` : "//";
|
|
4586
4680
|
content = `${header(lesson, hc)}
|
|
4587
|
-
// ${
|
|
4681
|
+
// ${propose(runCommand)}
|
|
4588
4682
|
|
|
4589
4683
|
package incidents
|
|
4590
4684
|
|
|
@@ -4596,7 +4690,29 @@ func Test${fn}(t *testing.T) {
|
|
|
4596
4690
|
}
|
|
4597
4691
|
`;
|
|
4598
4692
|
}
|
|
4599
|
-
return { framework, relPath, content, runCommand, proposeCommand:
|
|
4693
|
+
return { framework, relPath, content, runCommand, proposeCommand: propose(runCommand) };
|
|
4694
|
+
}
|
|
4695
|
+
var SCAFFOLD_MARKER_RE = /Post-incident guard generated by Hivelore from (\S+?)\.?\s*$/m;
|
|
4696
|
+
var PENDING_MARKERS = [/\bit\.todo\(/, /\bpytest\.mark\.skip\b/, /\bt\.Skip\(/];
|
|
4697
|
+
function assessScaffoldLoop(files, memories) {
|
|
4698
|
+
const byId = new Map(memories.map((m) => [m.id, m]));
|
|
4699
|
+
const gaps = [];
|
|
4700
|
+
for (const file of files) {
|
|
4701
|
+
const memoryId = file.content.match(SCAFFOLD_MARKER_RE)?.[1];
|
|
4702
|
+
if (!memoryId) continue;
|
|
4703
|
+
const memory = byId.get(memoryId);
|
|
4704
|
+
const pending = PENDING_MARKERS.some((re) => re.test(file.content));
|
|
4705
|
+
const armed = memory?.sensorKind === "shell" || memory?.sensorKind === "test";
|
|
4706
|
+
if (!pending && armed) continue;
|
|
4707
|
+
gaps.push({
|
|
4708
|
+
memory_id: memoryId,
|
|
4709
|
+
path: file.path,
|
|
4710
|
+
pending,
|
|
4711
|
+
armed,
|
|
4712
|
+
memory_missing: memory === void 0
|
|
4713
|
+
});
|
|
4714
|
+
}
|
|
4715
|
+
return gaps;
|
|
4600
4716
|
}
|
|
4601
4717
|
|
|
4602
4718
|
// src/bootstrap-state.ts
|
|
@@ -5856,6 +5972,7 @@ export {
|
|
|
5856
5972
|
PROJECT_CONTEXT_FILE,
|
|
5857
5973
|
PROJECT_CONTEXT_THROTTLE_MS,
|
|
5858
5974
|
RUNTIME_JOURNAL_FILENAME,
|
|
5975
|
+
SCAFFOLD_MARKER_RE,
|
|
5859
5976
|
SEED_QUALITY_FLOOR,
|
|
5860
5977
|
SENSOR_ABSENT_LOOKBACK,
|
|
5861
5978
|
SENSOR_ABSENT_WINDOW,
|
|
@@ -5880,6 +5997,7 @@ export {
|
|
|
5880
5997
|
applyConflictResolution,
|
|
5881
5998
|
applyFeedbackAdjustment,
|
|
5882
5999
|
assessBootstrapState,
|
|
6000
|
+
assessScaffoldLoop,
|
|
5883
6001
|
assessSensorHealth,
|
|
5884
6002
|
bridgeMemorySummary,
|
|
5885
6003
|
briefingMarkerPath,
|
|
@@ -5892,6 +6010,7 @@ export {
|
|
|
5892
6010
|
buildFrontmatter,
|
|
5893
6011
|
buildHandoffMarkdown,
|
|
5894
6012
|
buildPreventionReceipt,
|
|
6013
|
+
buildProposeCommand,
|
|
5895
6014
|
buildReport,
|
|
5896
6015
|
bumpRead,
|
|
5897
6016
|
classifyMemoryPriority,
|
|
@@ -5914,6 +6033,7 @@ export {
|
|
|
5914
6033
|
countSourceFilesOnDisk,
|
|
5915
6034
|
deriveConfidence,
|
|
5916
6035
|
detectAgentContext,
|
|
6036
|
+
detectSensorWeakening,
|
|
5917
6037
|
detectStacksFromManifests,
|
|
5918
6038
|
diffContract,
|
|
5919
6039
|
diffHasDistinctiveOverlap,
|
|
@@ -5991,6 +6111,7 @@ export {
|
|
|
5991
6111
|
moduleNameOf,
|
|
5992
6112
|
newMemoryId,
|
|
5993
6113
|
normalizeFindingSeverity,
|
|
6114
|
+
normalizeFramework,
|
|
5994
6115
|
normalizeSessionId,
|
|
5995
6116
|
overallScore,
|
|
5996
6117
|
parseEslintJson,
|
|
@@ -6004,6 +6125,7 @@ export {
|
|
|
6004
6125
|
parseSonar,
|
|
6005
6126
|
pathsOverlap,
|
|
6006
6127
|
pickSnippetNeedle,
|
|
6128
|
+
pickTestFramework,
|
|
6007
6129
|
planConflictResolution,
|
|
6008
6130
|
planGitWatch,
|
|
6009
6131
|
prepareBridgeData,
|