@hivelore/core 0.57.5 → 0.57.6
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 +36 -1
- package/dist/index.js +104 -35
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -50,6 +50,14 @@ declare const SensorSchema: z.ZodObject<{
|
|
|
50
50
|
absent: z.ZodOptional<z.ZodString>;
|
|
51
51
|
/** Regex flags (e.g. "i", "m"). Ignored for non-regex kinds. */
|
|
52
52
|
flags: z.ZodOptional<z.ZodString>;
|
|
53
|
+
/**
|
|
54
|
+
* kind=regex only: flip the sensor into a REQUIRED-PRESENCE invariant. `pattern` then names a line
|
|
55
|
+
* that must REMAIN present in the anchored file's final content; the sensor FIRES when a change
|
|
56
|
+
* removes it. A normal regex sensor scans ADDED lines and so structurally cannot see a deletion —
|
|
57
|
+
* this catches the "someone deleted the critical line" class (e.g. a `TimeZone.setDefault(UTC)`
|
|
58
|
+
* guard) that a diff-of-additions sensor misses (field report §3.5).
|
|
59
|
+
*/
|
|
60
|
+
require_present: z.ZodOptional<z.ZodBoolean>;
|
|
53
61
|
/** Shell/test command to run (for kind=shell|test). Executed by the CLI, never by core. */
|
|
54
62
|
command: z.ZodOptional<z.ZodString>;
|
|
55
63
|
/** Max runtime for kind=shell|test commands (default 120000). The executor kills on expiry. */
|
|
@@ -97,6 +105,7 @@ declare const SensorSchema: z.ZodObject<{
|
|
|
97
105
|
language?: string | undefined;
|
|
98
106
|
absent?: string | undefined;
|
|
99
107
|
flags?: string | undefined;
|
|
108
|
+
require_present?: boolean | undefined;
|
|
100
109
|
command?: string | undefined;
|
|
101
110
|
timeout_ms?: number | undefined;
|
|
102
111
|
incident?: string | undefined;
|
|
@@ -111,6 +120,7 @@ declare const SensorSchema: z.ZodObject<{
|
|
|
111
120
|
language?: string | undefined;
|
|
112
121
|
absent?: string | undefined;
|
|
113
122
|
flags?: string | undefined;
|
|
123
|
+
require_present?: boolean | undefined;
|
|
114
124
|
command?: string | undefined;
|
|
115
125
|
timeout_ms?: number | undefined;
|
|
116
126
|
incident?: string | undefined;
|
|
@@ -189,6 +199,14 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
189
199
|
absent: z.ZodOptional<z.ZodString>;
|
|
190
200
|
/** Regex flags (e.g. "i", "m"). Ignored for non-regex kinds. */
|
|
191
201
|
flags: z.ZodOptional<z.ZodString>;
|
|
202
|
+
/**
|
|
203
|
+
* kind=regex only: flip the sensor into a REQUIRED-PRESENCE invariant. `pattern` then names a line
|
|
204
|
+
* that must REMAIN present in the anchored file's final content; the sensor FIRES when a change
|
|
205
|
+
* removes it. A normal regex sensor scans ADDED lines and so structurally cannot see a deletion —
|
|
206
|
+
* this catches the "someone deleted the critical line" class (e.g. a `TimeZone.setDefault(UTC)`
|
|
207
|
+
* guard) that a diff-of-additions sensor misses (field report §3.5).
|
|
208
|
+
*/
|
|
209
|
+
require_present: z.ZodOptional<z.ZodBoolean>;
|
|
192
210
|
/** Shell/test command to run (for kind=shell|test). Executed by the CLI, never by core. */
|
|
193
211
|
command: z.ZodOptional<z.ZodString>;
|
|
194
212
|
/** Max runtime for kind=shell|test commands (default 120000). The executor kills on expiry. */
|
|
@@ -236,6 +254,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
236
254
|
language?: string | undefined;
|
|
237
255
|
absent?: string | undefined;
|
|
238
256
|
flags?: string | undefined;
|
|
257
|
+
require_present?: boolean | undefined;
|
|
239
258
|
command?: string | undefined;
|
|
240
259
|
timeout_ms?: number | undefined;
|
|
241
260
|
incident?: string | undefined;
|
|
@@ -250,6 +269,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
250
269
|
language?: string | undefined;
|
|
251
270
|
absent?: string | undefined;
|
|
252
271
|
flags?: string | undefined;
|
|
272
|
+
require_present?: boolean | undefined;
|
|
253
273
|
command?: string | undefined;
|
|
254
274
|
timeout_ms?: number | undefined;
|
|
255
275
|
incident?: string | undefined;
|
|
@@ -347,6 +367,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
347
367
|
language?: string | undefined;
|
|
348
368
|
absent?: string | undefined;
|
|
349
369
|
flags?: string | undefined;
|
|
370
|
+
require_present?: boolean | undefined;
|
|
350
371
|
command?: string | undefined;
|
|
351
372
|
timeout_ms?: number | undefined;
|
|
352
373
|
incident?: string | undefined;
|
|
@@ -383,6 +404,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
383
404
|
language?: string | undefined;
|
|
384
405
|
absent?: string | undefined;
|
|
385
406
|
flags?: string | undefined;
|
|
407
|
+
require_present?: boolean | undefined;
|
|
386
408
|
command?: string | undefined;
|
|
387
409
|
timeout_ms?: number | undefined;
|
|
388
410
|
incident?: string | undefined;
|
|
@@ -443,6 +465,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
443
465
|
language?: string | undefined;
|
|
444
466
|
absent?: string | undefined;
|
|
445
467
|
flags?: string | undefined;
|
|
468
|
+
require_present?: boolean | undefined;
|
|
446
469
|
command?: string | undefined;
|
|
447
470
|
timeout_ms?: number | undefined;
|
|
448
471
|
incident?: string | undefined;
|
|
@@ -479,6 +502,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
|
|
|
479
502
|
language?: string | undefined;
|
|
480
503
|
absent?: string | undefined;
|
|
481
504
|
flags?: string | undefined;
|
|
505
|
+
require_present?: boolean | undefined;
|
|
482
506
|
command?: string | undefined;
|
|
483
507
|
timeout_ms?: number | undefined;
|
|
484
508
|
incident?: string | undefined;
|
|
@@ -2714,6 +2738,17 @@ declare function runRegexSensor(memoryId: string, sensor: Sensor, target: Sensor
|
|
|
2714
2738
|
* are the CLI's responsibility). At most one hit per (memory, file) pair is returned.
|
|
2715
2739
|
*/
|
|
2716
2740
|
declare function runSensors(memories: Memory[], targets: SensorTarget[]): SensorHit[];
|
|
2741
|
+
/**
|
|
2742
|
+
* Parse every touched file path out of a unified diff (`diff --git a/X b/X` headers), including
|
|
2743
|
+
* files changed by pure DELETIONS — the case a presence sensor exists for. Pure.
|
|
2744
|
+
*/
|
|
2745
|
+
declare function changedPathsFromDiff(diff: string): string[];
|
|
2746
|
+
/**
|
|
2747
|
+
* Run REQUIRED-PRESENCE regex sensors (`require_present`) against the FINAL content of touched files.
|
|
2748
|
+
* Fires when the required `pattern` is ABSENT from a file the change touched — i.e. the guarded line
|
|
2749
|
+
* was removed. Deterministic and side-effect-free; the caller supplies the final file contents.
|
|
2750
|
+
*/
|
|
2751
|
+
declare function runPresenceSensors(memories: Memory[], finalTargets: SensorTarget[]): SensorHit[];
|
|
2717
2752
|
/**
|
|
2718
2753
|
* A shell/test sensor selected for execution — the feedback *computational* layer that a regex
|
|
2719
2754
|
* can't express. The schema reserves `kind: "shell" | "test"`; this picks the ones whose memory
|
|
@@ -4109,4 +4144,4 @@ interface ReviewDraftOptions {
|
|
|
4109
4144
|
/** Template review learnings into proposed-memory drafts (reuses the scanner-ingest draft shape). */
|
|
4110
4145
|
declare function reviewLearningsToDrafts(learnings: ReviewLearning[], options?: ReviewDraftOptions): MemoryDraft[];
|
|
4111
4146
|
|
|
4112
|
-
export { 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, 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, 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, buildReport, bumpRead, 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, recommendFeedbackAdjustment, recordApplied, recordGateReminder, recordPrevention, recordPreventionHits, recordProjectContextEmission, recordRejection, relPathFrom, renderBehaviourCoverageLine, renderBootstrapChecklist, renderCaughtForYou, renderPreventionComment, renderPreventionReceipt, renderPreventionReceiptShare, resolveBriefingBudget, resolveConfigPath, resolveGatePolicy, resolveHaivePaths, resolveManifestFiles, resolveProjectInfo, retirementSignal, revertedShaFromCommit, reviewLearningsToDrafts, 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, stripPrivate, suggestGate, suggestSensorFromMemory, suggestSensorSeed, suggestTopicKey, summarizeCaughtForYou, summarizeImpact, synthesizeSelfEvalCases, tallyHotFiles, titleFromBody, tokenizeQuery, tokenizeWords, trackDependencies, trackReads, truncateToTokens, usageLogPath, usageLogSize, usagePath, verifyAnchor, watchContracts, withQuarantineNote, withoutQuarantineNote, writeBriefingMarker, writeSessionHandoff };
|
|
4147
|
+
export { 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, 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, 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, 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, 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, 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
|
@@ -50,6 +50,14 @@ var SensorSchema = z.object({
|
|
|
50
50
|
absent: z.string().optional(),
|
|
51
51
|
/** Regex flags (e.g. "i", "m"). Ignored for non-regex kinds. */
|
|
52
52
|
flags: z.string().optional(),
|
|
53
|
+
/**
|
|
54
|
+
* kind=regex only: flip the sensor into a REQUIRED-PRESENCE invariant. `pattern` then names a line
|
|
55
|
+
* that must REMAIN present in the anchored file's final content; the sensor FIRES when a change
|
|
56
|
+
* removes it. A normal regex sensor scans ADDED lines and so structurally cannot see a deletion —
|
|
57
|
+
* this catches the "someone deleted the critical line" class (e.g. a `TimeZone.setDefault(UTC)`
|
|
58
|
+
* guard) that a diff-of-additions sensor misses (field report §3.5).
|
|
59
|
+
*/
|
|
60
|
+
require_present: z.boolean().optional(),
|
|
53
61
|
/** Shell/test command to run (for kind=shell|test). Executed by the CLI, never by core. */
|
|
54
62
|
command: z.string().optional(),
|
|
55
63
|
/** Max runtime for kind=shell|test commands (default 120000). The executor kills on expiry. */
|
|
@@ -936,7 +944,7 @@ function applyFeedbackAdjustment(fm, adjustment, now = /* @__PURE__ */ new Date(
|
|
|
936
944
|
}
|
|
937
945
|
|
|
938
946
|
// src/prevention.ts
|
|
939
|
-
import { appendFile, mkdir as mkdir2, readFile as readFile4 } from "fs/promises";
|
|
947
|
+
import { appendFile, mkdir as mkdir2, readFile as readFile4, writeFile as writeFile2 } from "fs/promises";
|
|
940
948
|
import { existsSync as existsSync4 } from "fs";
|
|
941
949
|
import path6 from "path";
|
|
942
950
|
function preventionLogPath(paths) {
|
|
@@ -964,8 +972,22 @@ async function recordPreventionHits(paths, firedIds, source, now = /* @__PURE__
|
|
|
964
972
|
await appendPreventionEvent(paths, { at, id, source, ...details[id] }).catch(() => {
|
|
965
973
|
});
|
|
966
974
|
}
|
|
975
|
+
await stampSensorLastFired(paths, recordedIds, at).catch(() => {
|
|
976
|
+
});
|
|
967
977
|
return recordedIds;
|
|
968
978
|
}
|
|
979
|
+
async function stampSensorLastFired(paths, ids, at) {
|
|
980
|
+
if (ids.length === 0 || !existsSync4(paths.memoriesDir)) return;
|
|
981
|
+
const wanted = new Set(ids);
|
|
982
|
+
const loaded = await loadMemoriesFromDir(paths.memoriesDir);
|
|
983
|
+
for (const { memory, filePath } of loaded) {
|
|
984
|
+
const fm = memory.frontmatter;
|
|
985
|
+
if (!wanted.has(fm.id) || !fm.sensor || fm.sensor.last_fired === at) continue;
|
|
986
|
+
const next = { ...memory, frontmatter: { ...fm, sensor: { ...fm.sensor, last_fired: at } } };
|
|
987
|
+
await writeFile2(filePath, serializeMemory(next), "utf8").catch(() => {
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
}
|
|
969
991
|
function buildPreventionReceipt(events, memories, usage, options) {
|
|
970
992
|
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
971
993
|
const sinceMs = options.since.getTime();
|
|
@@ -1016,6 +1038,11 @@ function buildPreventionReceipt(events, memories, usage, options) {
|
|
|
1016
1038
|
events: rows
|
|
1017
1039
|
};
|
|
1018
1040
|
}
|
|
1041
|
+
function trendClause(total, previous) {
|
|
1042
|
+
const counts = `${total} this window vs ${previous} previous window`;
|
|
1043
|
+
if (total + previous < 3) return counts;
|
|
1044
|
+
return `${counts} (${total <= previous ? "recurrences declining" : "recurrences rising"})`;
|
|
1045
|
+
}
|
|
1019
1046
|
function renderPreventionReceipt(receipt) {
|
|
1020
1047
|
const lines = [
|
|
1021
1048
|
`Hivelore prevention receipt \u2014 last ${receipt.window_days} days`,
|
|
@@ -1033,9 +1060,7 @@ function renderPreventionReceipt(receipt) {
|
|
|
1033
1060
|
const red = row.red_proven ? " \u2713 RED-proven" : "";
|
|
1034
1061
|
lines.push(` \u2717\u2192\u2713 ${row.at.slice(0, 10)} ${row.id.padEnd(32)} (${kind}${exit}${stage})${incident}${red}`);
|
|
1035
1062
|
}
|
|
1036
|
-
lines.push(
|
|
1037
|
-
` Trend: ${receipt.total} this window vs ${receipt.previous_total} previous window (${receipt.total <= receipt.previous_total ? "recurrences declining" : "recurrences rising"}).`
|
|
1038
|
-
);
|
|
1063
|
+
lines.push(` Trend: ${trendClause(receipt.total, receipt.previous_total)}.`);
|
|
1039
1064
|
return lines.join("\n");
|
|
1040
1065
|
}
|
|
1041
1066
|
var HIVELORE_ATTRIBUTION = "\u{1F6E1}\uFE0F Generated by [Hivelore](https://github.com/Doucs91/hivelore) \u2014 the deterministic policy gate for agent-written code.";
|
|
@@ -1062,7 +1087,7 @@ function renderPreventionReceiptShare(receipt) {
|
|
|
1062
1087
|
}
|
|
1063
1088
|
lines.push(
|
|
1064
1089
|
"",
|
|
1065
|
-
`_Trend: ${
|
|
1090
|
+
`_Trend: ${trendClause(receipt.total, receipt.previous_total)}._`
|
|
1066
1091
|
);
|
|
1067
1092
|
}
|
|
1068
1093
|
lines.push("", `<sub>${HIVELORE_ATTRIBUTION}</sub>`);
|
|
@@ -1221,7 +1246,7 @@ function renderCaughtForYou(summary) {
|
|
|
1221
1246
|
|
|
1222
1247
|
// src/context-throttle.ts
|
|
1223
1248
|
import { createHash } from "crypto";
|
|
1224
|
-
import { mkdir as mkdir3, readFile as readFile5, writeFile as
|
|
1249
|
+
import { mkdir as mkdir3, readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
1225
1250
|
import { existsSync as existsSync5 } from "fs";
|
|
1226
1251
|
import path7 from "path";
|
|
1227
1252
|
var PROJECT_CONTEXT_THROTTLE_MS = 8 * 60 * 1e3;
|
|
@@ -1246,12 +1271,12 @@ async function recordProjectContextEmission(paths, hash, now = Date.now()) {
|
|
|
1246
1271
|
const file = throttleMarkerPath(paths);
|
|
1247
1272
|
await mkdir3(path7.dirname(file), { recursive: true }).catch(() => {
|
|
1248
1273
|
});
|
|
1249
|
-
await
|
|
1274
|
+
await writeFile3(file, JSON.stringify({ hash, at: new Date(now).toISOString() }), "utf8").catch(() => {
|
|
1250
1275
|
});
|
|
1251
1276
|
}
|
|
1252
1277
|
|
|
1253
1278
|
// src/gate-reminder.ts
|
|
1254
|
-
import { mkdir as mkdir4, readFile as readFile6, writeFile as
|
|
1279
|
+
import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile4 } from "fs/promises";
|
|
1255
1280
|
import { existsSync as existsSync6 } from "fs";
|
|
1256
1281
|
import path8 from "path";
|
|
1257
1282
|
var GATE_REMINDER_WINDOW_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -1280,7 +1305,7 @@ async function recordGateReminder(paths, key, now = Date.now()) {
|
|
|
1280
1305
|
markers[key] = new Date(now).toISOString();
|
|
1281
1306
|
await mkdir4(path8.dirname(file), { recursive: true }).catch(() => {
|
|
1282
1307
|
});
|
|
1283
|
-
await
|
|
1308
|
+
await writeFile4(file, JSON.stringify(markers, null, 2), "utf8").catch(() => {
|
|
1284
1309
|
});
|
|
1285
1310
|
}
|
|
1286
1311
|
|
|
@@ -1854,6 +1879,7 @@ function runSensors(memories, targets) {
|
|
|
1854
1879
|
for (const memory of memories) {
|
|
1855
1880
|
const sensor = memory.frontmatter.sensor;
|
|
1856
1881
|
if (!sensor || sensor.kind !== "regex") continue;
|
|
1882
|
+
if (sensor.require_present) continue;
|
|
1857
1883
|
const anchorPaths = memory.frontmatter.anchor.paths;
|
|
1858
1884
|
for (const target of targets) {
|
|
1859
1885
|
if (!sensorAppliesToPath(sensor, anchorPaths, target.path)) continue;
|
|
@@ -1863,6 +1889,47 @@ function runSensors(memories, targets) {
|
|
|
1863
1889
|
}
|
|
1864
1890
|
return hits;
|
|
1865
1891
|
}
|
|
1892
|
+
function changedPathsFromDiff(diff) {
|
|
1893
|
+
const out = /* @__PURE__ */ new Set();
|
|
1894
|
+
for (const m of diff.matchAll(/^diff --git a\/(.+?) b\/(.+)$/gm)) {
|
|
1895
|
+
out.add((m[2] ?? m[1] ?? "").trim());
|
|
1896
|
+
}
|
|
1897
|
+
for (const m of diff.matchAll(/^\+\+\+ b\/(.+)$/gm)) {
|
|
1898
|
+
const p = (m[1] ?? "").trim();
|
|
1899
|
+
if (p && p !== "/dev/null") out.add(p);
|
|
1900
|
+
}
|
|
1901
|
+
return [...out];
|
|
1902
|
+
}
|
|
1903
|
+
function runPresenceSensors(memories, finalTargets) {
|
|
1904
|
+
const hits = [];
|
|
1905
|
+
for (const memory of memories) {
|
|
1906
|
+
const sensor = memory.frontmatter.sensor;
|
|
1907
|
+
if (!sensor || sensor.kind !== "regex" || !sensor.require_present || !sensor.pattern) continue;
|
|
1908
|
+
let re;
|
|
1909
|
+
try {
|
|
1910
|
+
const flags = new Set(["m", ...(sensor.flags ?? "").split("")].filter(Boolean));
|
|
1911
|
+
re = new RegExp(sensor.pattern, [...flags].join(""));
|
|
1912
|
+
} catch {
|
|
1913
|
+
continue;
|
|
1914
|
+
}
|
|
1915
|
+
const anchorPaths = memory.frontmatter.anchor.paths;
|
|
1916
|
+
for (const target of finalTargets) {
|
|
1917
|
+
if (!sensorAppliesToPath(sensor, anchorPaths, target.path)) continue;
|
|
1918
|
+
re.lastIndex = 0;
|
|
1919
|
+
if (!re.test(target.content)) {
|
|
1920
|
+
hits.push({
|
|
1921
|
+
memory_id: memory.frontmatter.id,
|
|
1922
|
+
sensor,
|
|
1923
|
+
file: target.path,
|
|
1924
|
+
message: sensor.message,
|
|
1925
|
+
severity: sensor.severity
|
|
1926
|
+
});
|
|
1927
|
+
break;
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
return hits;
|
|
1932
|
+
}
|
|
1866
1933
|
var COMMAND_ENV_EXACT = /* @__PURE__ */ new Set([
|
|
1867
1934
|
"PATH",
|
|
1868
1935
|
"HOME",
|
|
@@ -2104,14 +2171,14 @@ function sensorSelfCheck(sensor, input) {
|
|
|
2104
2171
|
function judgeProposedSensor(sensor, input) {
|
|
2105
2172
|
const brittle = sensor.kind === "regex" && sensor.pattern ? sensorPatternBrittleness(sensor.pattern) : null;
|
|
2106
2173
|
const self_check = sensorSelfCheck(sensor, input);
|
|
2174
|
+
if (self_check.fires_on_correct === true) {
|
|
2175
|
+
return { accepted: false, reason: "fires-on-correct", self_check, brittle };
|
|
2176
|
+
}
|
|
2107
2177
|
if (sensor.severity === "block") {
|
|
2108
2178
|
if (brittle) return { accepted: false, reason: "brittle", self_check, brittle };
|
|
2109
2179
|
if (input.currentTargets.length > 0 && !self_check.silent_on_current) {
|
|
2110
2180
|
return { accepted: false, reason: "fires-on-current", self_check, brittle };
|
|
2111
2181
|
}
|
|
2112
|
-
if (self_check.fires_on_correct === true) {
|
|
2113
|
-
return { accepted: false, reason: "fires-on-correct", self_check, brittle };
|
|
2114
|
-
}
|
|
2115
2182
|
if (self_check.fires_on_bad === false) {
|
|
2116
2183
|
return { accepted: false, reason: "missed-bad-example", self_check, brittle };
|
|
2117
2184
|
}
|
|
@@ -3099,7 +3166,7 @@ function allocateBudget(parts, maxTokens) {
|
|
|
3099
3166
|
}
|
|
3100
3167
|
|
|
3101
3168
|
// src/code-map.ts
|
|
3102
|
-
import { mkdir as mkdir5, readFile as readFile7, readdir as readdir3, stat as stat2, writeFile as
|
|
3169
|
+
import { mkdir as mkdir5, readFile as readFile7, readdir as readdir3, stat as stat2, writeFile as writeFile5 } from "fs/promises";
|
|
3103
3170
|
import { createHash as createHash2 } from "crypto";
|
|
3104
3171
|
import { existsSync as existsSync7 } from "fs";
|
|
3105
3172
|
import { spawnSync } from "child_process";
|
|
@@ -3542,10 +3609,10 @@ async function saveCodeMap(paths, map) {
|
|
|
3542
3609
|
const current = existsSync7(file) ? await readFile7(file, "utf8").catch(() => null) : null;
|
|
3543
3610
|
if (current === payload) return;
|
|
3544
3611
|
await mkdir5(path9.dirname(file), { recursive: true });
|
|
3545
|
-
await
|
|
3612
|
+
await writeFile5(file, payload, "utf8");
|
|
3546
3613
|
await mkdir5(paths.runtimeDir, { recursive: true }).catch(() => {
|
|
3547
3614
|
});
|
|
3548
|
-
await
|
|
3615
|
+
await writeFile5(
|
|
3549
3616
|
codeMapMetaPath(paths),
|
|
3550
3617
|
`${JSON.stringify({ generated_at: (/* @__PURE__ */ new Date()).toISOString(), content_hash: codeMapContentHash(map) }, null, 2)}
|
|
3551
3618
|
`,
|
|
@@ -3914,7 +3981,7 @@ function queryCodeMap(map, options) {
|
|
|
3914
3981
|
// src/config.ts
|
|
3915
3982
|
import { existsSync as existsSync8 } from "fs";
|
|
3916
3983
|
import { readFileSync } from "fs";
|
|
3917
|
-
import { readFile as readFile8, rm, writeFile as
|
|
3984
|
+
import { readFile as readFile8, rm, writeFile as writeFile6 } from "fs/promises";
|
|
3918
3985
|
import path10 from "path";
|
|
3919
3986
|
var CONFIG_FILE = "hivelore.config.json";
|
|
3920
3987
|
var LEGACY_CONFIG_FILE = "haive.config.json";
|
|
@@ -4046,7 +4113,7 @@ function loadConfigSync(paths) {
|
|
|
4046
4113
|
}
|
|
4047
4114
|
}
|
|
4048
4115
|
async function saveConfig(paths, config) {
|
|
4049
|
-
await
|
|
4116
|
+
await writeFile6(configPath(paths), JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
4050
4117
|
const legacy = path10.join(paths.haiveDir, LEGACY_CONFIG_FILE);
|
|
4051
4118
|
if (existsSync8(legacy)) {
|
|
4052
4119
|
try {
|
|
@@ -4072,7 +4139,7 @@ function mergeConfig(base, override) {
|
|
|
4072
4139
|
|
|
4073
4140
|
// src/cross-repo.ts
|
|
4074
4141
|
import { existsSync as existsSync9 } from "fs";
|
|
4075
|
-
import { mkdir as mkdir6, readFile as readFile9, writeFile as
|
|
4142
|
+
import { mkdir as mkdir6, readFile as readFile9, writeFile as writeFile7 } from "fs/promises";
|
|
4076
4143
|
import path11 from "path";
|
|
4077
4144
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
4078
4145
|
async function loadImportMap(cacheDir) {
|
|
@@ -4085,7 +4152,7 @@ async function loadImportMap(cacheDir) {
|
|
|
4085
4152
|
}
|
|
4086
4153
|
}
|
|
4087
4154
|
async function saveImportMap(cacheDir, map) {
|
|
4088
|
-
await
|
|
4155
|
+
await writeFile7(path11.join(cacheDir, "import-map.json"), JSON.stringify(map, null, 2) + "\n", "utf8");
|
|
4089
4156
|
}
|
|
4090
4157
|
async function pullCrossRepoSources(paths, config, projectRoot) {
|
|
4091
4158
|
const sources = config.crossRepoSources ?? [];
|
|
@@ -4171,7 +4238,7 @@ async function pullFromSource(paths, source, projectRoot) {
|
|
|
4171
4238
|
}
|
|
4172
4239
|
const updatedBody = importedBodyPrefix + memory.body;
|
|
4173
4240
|
if (existingEntry) {
|
|
4174
|
-
await
|
|
4241
|
+
await writeFile7(
|
|
4175
4242
|
existingLocalPath,
|
|
4176
4243
|
serializeMemory({ frontmatter: existingEntry.memory.frontmatter, body: updatedBody }),
|
|
4177
4244
|
"utf8"
|
|
@@ -4196,7 +4263,7 @@ async function pullFromSource(paths, source, projectRoot) {
|
|
|
4196
4263
|
});
|
|
4197
4264
|
const body = importedBodyPrefix + memory.body;
|
|
4198
4265
|
const destPath = path11.join(destDir, `${newFm.id}.md`);
|
|
4199
|
-
await
|
|
4266
|
+
await writeFile7(destPath, serializeMemory({ frontmatter: newFm, body }), "utf8");
|
|
4200
4267
|
importMap[sourceId] = destPath;
|
|
4201
4268
|
dirty = true;
|
|
4202
4269
|
report.imported.push(sourceId);
|
|
@@ -4234,7 +4301,7 @@ async function cloneOrFetchGitSource(source, paths, report) {
|
|
|
4234
4301
|
|
|
4235
4302
|
// src/dep-tracker.ts
|
|
4236
4303
|
import { existsSync as existsSync10 } from "fs";
|
|
4237
|
-
import { readFile as readFile10, writeFile as
|
|
4304
|
+
import { readFile as readFile10, writeFile as writeFile8, mkdir as mkdir7 } from "fs/promises";
|
|
4238
4305
|
import path12 from "path";
|
|
4239
4306
|
function parsePackageJson(content) {
|
|
4240
4307
|
try {
|
|
@@ -4347,7 +4414,7 @@ async function trackDependencies(projectRoot, haiveDir, manifestFiles) {
|
|
|
4347
4414
|
captured_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4348
4415
|
deps: currentDeps
|
|
4349
4416
|
};
|
|
4350
|
-
await
|
|
4417
|
+
await writeFile8(lockPath, JSON.stringify(snapshot2, null, 2) + "\n", "utf8");
|
|
4351
4418
|
continue;
|
|
4352
4419
|
}
|
|
4353
4420
|
const snapshot = JSON.parse(await readFile10(lockPath, "utf8"));
|
|
@@ -4370,7 +4437,7 @@ async function trackDependencies(projectRoot, haiveDir, manifestFiles) {
|
|
|
4370
4437
|
captured_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4371
4438
|
deps: currentDeps
|
|
4372
4439
|
};
|
|
4373
|
-
await
|
|
4440
|
+
await writeFile8(lockPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
4374
4441
|
}
|
|
4375
4442
|
}
|
|
4376
4443
|
return results;
|
|
@@ -4378,7 +4445,7 @@ async function trackDependencies(projectRoot, haiveDir, manifestFiles) {
|
|
|
4378
4445
|
|
|
4379
4446
|
// src/contract-watcher.ts
|
|
4380
4447
|
import { existsSync as existsSync11 } from "fs";
|
|
4381
|
-
import { readFile as readFile11, writeFile as
|
|
4448
|
+
import { readFile as readFile11, writeFile as writeFile9, mkdir as mkdir8 } from "fs/promises";
|
|
4382
4449
|
import path13 from "path";
|
|
4383
4450
|
import crypto from "crypto";
|
|
4384
4451
|
function sha256(content) {
|
|
@@ -4601,7 +4668,7 @@ async function snapshotContract(projectRoot, haiveDir, contract) {
|
|
|
4601
4668
|
};
|
|
4602
4669
|
const contractsDir = path13.join(haiveDir, "contracts");
|
|
4603
4670
|
await mkdir8(contractsDir, { recursive: true });
|
|
4604
|
-
await
|
|
4671
|
+
await writeFile9(contractLockPath(haiveDir, contract.name), JSON.stringify(snapshot, null, 2) + "\n", "utf8");
|
|
4605
4672
|
return snapshot;
|
|
4606
4673
|
}
|
|
4607
4674
|
async function diffContract(projectRoot, haiveDir, contract) {
|
|
@@ -4625,7 +4692,7 @@ async function diffContract(projectRoot, haiveDir, contract) {
|
|
|
4625
4692
|
};
|
|
4626
4693
|
const changes = diffSnapshots(beforeSnapshot, afterSnapshot);
|
|
4627
4694
|
if (changes.length > 0) {
|
|
4628
|
-
await
|
|
4695
|
+
await writeFile9(lockPath, JSON.stringify(afterSnapshot, null, 2) + "\n", "utf8");
|
|
4629
4696
|
}
|
|
4630
4697
|
return {
|
|
4631
4698
|
contract: contract.name,
|
|
@@ -4719,7 +4786,7 @@ async function usageLogSize(paths) {
|
|
|
4719
4786
|
}
|
|
4720
4787
|
|
|
4721
4788
|
// src/friction.ts
|
|
4722
|
-
import { appendFile as appendFile3, mkdir as mkdir10, readFile as readFile13, writeFile as
|
|
4789
|
+
import { appendFile as appendFile3, mkdir as mkdir10, readFile as readFile13, writeFile as writeFile10 } from "fs/promises";
|
|
4723
4790
|
import { existsSync as existsSync13 } from "fs";
|
|
4724
4791
|
import { createHash as createHash3 } from "crypto";
|
|
4725
4792
|
import path15 from "path";
|
|
@@ -4819,7 +4886,7 @@ async function loadFrictionState(paths) {
|
|
|
4819
4886
|
}
|
|
4820
4887
|
async function saveFrictionState(paths, state) {
|
|
4821
4888
|
if (!existsSync13(paths.runtimeDir)) await mkdir10(paths.runtimeDir, { recursive: true });
|
|
4822
|
-
await
|
|
4889
|
+
await writeFile10(frictionStatePath(paths), JSON.stringify(state, null, 2) + "\n", "utf8");
|
|
4823
4890
|
}
|
|
4824
4891
|
async function setFrictionStatus(paths, fingerprint, status, url) {
|
|
4825
4892
|
const state = await loadFrictionState(paths);
|
|
@@ -5279,7 +5346,7 @@ async function readRuntimeJournalTail(paths, limit) {
|
|
|
5279
5346
|
}
|
|
5280
5347
|
|
|
5281
5348
|
// src/enforcement.ts
|
|
5282
|
-
import { mkdir as mkdir12, readdir as readdir4, readFile as readFile15, writeFile as
|
|
5349
|
+
import { mkdir as mkdir12, readdir as readdir4, readFile as readFile15, writeFile as writeFile11 } from "fs/promises";
|
|
5283
5350
|
import { existsSync as existsSync16 } from "fs";
|
|
5284
5351
|
import path18 from "path";
|
|
5285
5352
|
var BRIEFING_MARKER_TTL_MS = 12 * 60 * 60 * 1e3;
|
|
@@ -5320,7 +5387,7 @@ async function writeBriefingMarker(paths, input) {
|
|
|
5320
5387
|
root: paths.root
|
|
5321
5388
|
};
|
|
5322
5389
|
await mkdir12(briefingMarkersDir(paths), { recursive: true });
|
|
5323
|
-
await
|
|
5390
|
+
await writeFile11(
|
|
5324
5391
|
briefingMarkerPath(paths, marker.session_id),
|
|
5325
5392
|
JSON.stringify(marker, null, 2) + "\n",
|
|
5326
5393
|
"utf8"
|
|
@@ -5431,7 +5498,7 @@ function isRetiredMemory(fm, body = "", now = /* @__PURE__ */ new Date()) {
|
|
|
5431
5498
|
// src/sensor-ledger.ts
|
|
5432
5499
|
import { createHash as createHash4 } from "crypto";
|
|
5433
5500
|
import { existsSync as existsSync17, readFileSync as readFileSync2 } from "fs";
|
|
5434
|
-
import { appendFile as appendFile5, mkdir as mkdir13, readFile as readFile16, rename, writeFile as
|
|
5501
|
+
import { appendFile as appendFile5, mkdir as mkdir13, readFile as readFile16, rename, writeFile as writeFile12 } from "fs/promises";
|
|
5435
5502
|
import path19 from "path";
|
|
5436
5503
|
var MAX_LINES = 1e4;
|
|
5437
5504
|
var RETAINED_LINES = 8e3;
|
|
@@ -5454,7 +5521,7 @@ async function appendSensorEvaluations(paths, evaluations) {
|
|
|
5454
5521
|
const lines = raw.split("\n").filter(Boolean);
|
|
5455
5522
|
if (lines.length > MAX_LINES) {
|
|
5456
5523
|
const temp = `${file}.${process.pid}.tmp`;
|
|
5457
|
-
await
|
|
5524
|
+
await writeFile12(temp, lines.slice(-RETAINED_LINES).join("\n") + "\n", "utf8");
|
|
5458
5525
|
await rename(temp, file);
|
|
5459
5526
|
}
|
|
5460
5527
|
} catch {
|
|
@@ -7155,7 +7222,7 @@ ${trimmed}`;
|
|
|
7155
7222
|
}
|
|
7156
7223
|
|
|
7157
7224
|
// src/handoff.ts
|
|
7158
|
-
import { writeFile as
|
|
7225
|
+
import { writeFile as writeFile13, readFile as readFile18, stat as stat4 } from "fs/promises";
|
|
7159
7226
|
import { existsSync as existsSync19 } from "fs";
|
|
7160
7227
|
import path21 from "path";
|
|
7161
7228
|
var HANDOFF_FILENAME = "NEXT.md";
|
|
@@ -7209,7 +7276,7 @@ function buildHandoffMarkdown(data) {
|
|
|
7209
7276
|
}
|
|
7210
7277
|
async function writeSessionHandoff(root, data) {
|
|
7211
7278
|
const file = handoffFilePath(root);
|
|
7212
|
-
await
|
|
7279
|
+
await writeFile13(file, buildHandoffMarkdown(data), "utf8");
|
|
7213
7280
|
return file;
|
|
7214
7281
|
}
|
|
7215
7282
|
async function readSessionHandoff(root) {
|
|
@@ -7434,6 +7501,7 @@ export {
|
|
|
7434
7501
|
buildProposeCommand,
|
|
7435
7502
|
buildReport,
|
|
7436
7503
|
bumpRead,
|
|
7504
|
+
changedPathsFromDiff,
|
|
7437
7505
|
churnForAnchors,
|
|
7438
7506
|
classifyGithubRelease,
|
|
7439
7507
|
classifyMemoryPriority,
|
|
@@ -7619,6 +7687,7 @@ export {
|
|
|
7619
7687
|
retirementSignal,
|
|
7620
7688
|
revertedShaFromCommit,
|
|
7621
7689
|
reviewLearningsToDrafts,
|
|
7690
|
+
runPresenceSensors,
|
|
7622
7691
|
runRegexSensor,
|
|
7623
7692
|
runSensors,
|
|
7624
7693
|
runTierContract,
|