@hivelore/core 0.30.0 → 0.31.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 +37 -4
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1348,6 +1348,16 @@ interface HaiveConfig {
|
|
|
1348
1348
|
* Config/docs-only commits (no production code changed) are downgraded to a warning regardless.
|
|
1349
1349
|
*/
|
|
1350
1350
|
bootstrapGate?: "off" | "warn" | "block";
|
|
1351
|
+
/**
|
|
1352
|
+
* Who the PROCESS gates (briefing-loaded, session-recap, decision-coverage, bootstrap) bind at
|
|
1353
|
+
* commit/push time. "relaxed" (default): when no agent harness is detected in the environment
|
|
1354
|
+
* (see detectAgentContext), those gates downgrade to warnings — a human committing by hand is
|
|
1355
|
+
* the trusted owner of the team knowledge the gates exist to inject into AGENTS. Deterministic
|
|
1356
|
+
* gates (block sensors, anti-pattern blocks, artifact hygiene) always bind everyone, and CI is
|
|
1357
|
+
* unaffected (it validates the merged result regardless of author). "strict": process gates
|
|
1358
|
+
* block humans too.
|
|
1359
|
+
*/
|
|
1360
|
+
humanCommits?: "relaxed" | "strict";
|
|
1351
1361
|
/**
|
|
1352
1362
|
* Pre-commit/pre-push decision-coverage behaviour. When true (default), the gate SURFACES the
|
|
1353
1363
|
* relevant anchored decisions/policies itself and records them in the session marker at commit
|
|
@@ -1794,9 +1804,8 @@ interface SensorTarget {
|
|
|
1794
1804
|
}
|
|
1795
1805
|
/**
|
|
1796
1806
|
* Does this sensor apply to `path`? A sensor with no explicit `paths` (and whose
|
|
1797
|
-
* memory has no anchor paths) applies everywhere. Otherwise it applies
|
|
1798
|
-
*
|
|
1799
|
-
* sensor should cover a whole subtree.
|
|
1807
|
+
* memory has no anchor paths) applies everywhere. Otherwise it applies to the exact
|
|
1808
|
+
* file, a directory prefix, or a glob (`**` / `*.controller.ts` style) scope.
|
|
1800
1809
|
*/
|
|
1801
1810
|
declare function sensorAppliesToPath(sensor: Sensor, anchorPaths: string[], path: string): boolean;
|
|
1802
1811
|
/**
|
|
@@ -2749,4 +2758,28 @@ declare function prepareBridgeData(memories: Memory[], sensors: BridgeSensor[],
|
|
|
2749
2758
|
*/
|
|
2750
2759
|
declare function generateBridges(memories: Memory[], sensors: BridgeSensor[], opts?: GenerateBridgesOptions): BridgeFileOutput[];
|
|
2751
2760
|
|
|
2752
|
-
|
|
2761
|
+
/**
|
|
2762
|
+
* Detect whether the current process runs inside an AI coding-agent harness.
|
|
2763
|
+
*
|
|
2764
|
+
* WHY: Hivelore's PROCESS gates (briefing-loaded, session-recap, decision-coverage,
|
|
2765
|
+
* first-agent bootstrap) encode the agent workflow contract — "AI changes should not
|
|
2766
|
+
* enter the codebase without consulting the team's knowledge". A human committing by
|
|
2767
|
+
* hand from a terminal is the trusted owner of that knowledge, so those gates can
|
|
2768
|
+
* relax to warnings for them (config `enforcement.humanCommits`). DETERMINISTIC gates
|
|
2769
|
+
* (block sensors, anti-pattern blocks, artifact hygiene) are about the code itself and
|
|
2770
|
+
* must keep binding everyone — this module only informs the process-gate decision.
|
|
2771
|
+
*
|
|
2772
|
+
* Detection is environment-based and deliberately conservative: agent harnesses run
|
|
2773
|
+
* shell commands (and therefore git hooks) with identifying env vars, which propagate
|
|
2774
|
+
* into hook processes. Unknown harnesses can opt in by exporting HAIVE_AGENT=1 — the
|
|
2775
|
+
* `hivelore run` wrapper does exactly that. HAIVE_AGENT=0 force-overrides to human.
|
|
2776
|
+
*/
|
|
2777
|
+
interface AgentContext {
|
|
2778
|
+
/** True when the process appears to run under an AI coding-agent harness. */
|
|
2779
|
+
agent: boolean;
|
|
2780
|
+
/** Which environment signals matched (empty for a plain human shell). */
|
|
2781
|
+
signals: string[];
|
|
2782
|
+
}
|
|
2783
|
+
declare function detectAgentContext(env?: Record<string, string | undefined>): AgentContext;
|
|
2784
|
+
|
|
2785
|
+
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_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 GatePrecision, type GatePrecisionDelta, type GatePrecisionMetricDelta, type GateTuningSuggestion, type GenerateBridgesOptions, type GitCommit, HAIVE_DIR, HAIVE_OWNED_FILES, HANDOFF_FILENAME, type HaiveConfig, type HaivePaths, type HotFile, type HotFileSource, type ImpactOptions, type ImpactRow, type ImpactScore, type ImpactSummary, type ImpactTier, 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 PreventionEvent, 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 SeedProposal, type SelfEvalOptions, type Sensor, type SensorAggregate, type SensorCase, type SensorCaseResult, type SensorHit, type SensorRow, SensorSchema, type SensorSeed, type SensorSelfCheck, type SensorSuggestionOptions, type SensorTarget, type SessionHandoffData, type SkillActivation, 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, appendUsageEvent, applyConflictResolution, applyFeedbackAdjustment, assessBootstrapState, bridgeMemorySummary, briefingMarkerPath, briefingMarkersDir, briefingProofLine, buildCodeMap, buildCoverageIndex, buildDashboard, buildDocFrequency, buildFrontmatter, buildHandoffMarkdown, buildReport, bumpRead, classifyMemoryPriority, codeMapPath, collectTimelineEntries, compactAutoRecapBody, compareEvalReports, compareGatePrecision, compareImpact, compileRegexSensor, componentOf, computeEvalTrend, computeGatePrecision, computeImpact, computePreventionTrend, computeRecurrence, configPath, contractLockPath, countSourceFilesOnDisk, deriveConfidence, detectAgentContext, detectStacksFromManifests, diffContract, diffHasDistinctiveOverlap, distinctiveCap, draftsFromFindings, emptyUsage, emptyUsageIndex, enforcementDir, estimateTokens, evalHistoryPath, evaluateSkillActivation, extractActionsBriefBody, extractReferencedPaths, extractSensorExamples, extractSnippet, filterNewDrafts, findCoverageGaps, findLexicalConflictPairs, findProjectRoot, findTopicStatusConflictPairs, findUncapturedFailures, findingBody, findingToDraft, firstMemoryOneLine, generateBridges, getUsage, globToRegExp, handoffAgeMs, handoffFilePath, hasRecentBriefingMarker, hashProjectContext, inferModulesFromPaths, isAutoPromoteEligible, isAutoRecap, isCovered, isDecaying, isDistinctiveToken, isEnvWorkaroundMemory, isFreshIsoDate, isGlobPath, isLikelyGuessable, isNoiseSubject, isRetiredMemory, isSensorScannablePath, isSkill, isSkillSuppressed, isStackPackSeed, isStylisticRule, isTemplateProjectContext, judgeProposedSensor, listMarkdownFilesRecursive, literalMatchesAllTokens, literalMatchesAnyToken, loadCodeMap, loadConfig, loadConfigSync, loadEvalHistory, loadMemoriesFromDir, loadMemory, loadPreventionEvents, loadUsageIndex, looksLikeGenericAdvice, meetsSeedQualityFloor, memoryFilePath, memoryHasExcludedTag, memoryMatchesAnchorPaths, mergeHotFiles, mergeMemoryVersions, moduleNameOf, newMemoryId, normalizeFindingSeverity, normalizeSessionId, overallScore, parseEslintJson, parseFileAst, parseFindings, parseMemory, parseNpmAudit, parseSarif, parseSince, parseSonar, pathsOverlap, pickSnippetNeedle, planConflictResolution, prepareBridgeData, preventionLogPath, priorityRank, prioritySignals, projectContextRecentlyEmitted, proposeSeedsFromCommits, pullCrossRepoSources, queryCodeMap, rankMemoriesLexical, readRecentBriefingMarker, readRuntimeJournalTail, readSessionHandoff, readUsageEvents, recommendFeedbackAdjustment, recordApplied, recordPrevention, recordPreventionHits, recordProjectContextEmission, recordRejection, relPathFrom, renderBootstrapChecklist, renderCaughtForYou, resolveBriefingBudget, resolveHaivePaths, resolveManifestFiles, resolveProjectInfo, retirementSignal, runRegexSensor, runSensors, runtimeJournalPath, saveCodeMap, saveConfig, saveUsageIndex, scannableSensorTargets, scoreRetrievalCase, scoreSensorCase, selectCommandSensors, sensorAppliesToPath, sensorPatternBrittleness, 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, writeBriefingMarker, writeSessionHandoff };
|
package/dist/index.js
CHANGED
|
@@ -2334,6 +2334,7 @@ var DEFAULT_CONFIG = {
|
|
|
2334
2334
|
requireDecisionCoverage: true,
|
|
2335
2335
|
antiPatternGate: "anchored",
|
|
2336
2336
|
bootstrapGate: "block",
|
|
2337
|
+
humanCommits: "relaxed",
|
|
2337
2338
|
scoreThreshold: 80,
|
|
2338
2339
|
cleanupGeneratedArtifacts: true,
|
|
2339
2340
|
toolProfile: "enforcement",
|
|
@@ -2367,6 +2368,7 @@ var AUTOPILOT_DEFAULTS = {
|
|
|
2367
2368
|
requireDecisionCoverage: true,
|
|
2368
2369
|
antiPatternGate: "anchored",
|
|
2369
2370
|
bootstrapGate: "block",
|
|
2371
|
+
humanCommits: "relaxed",
|
|
2370
2372
|
scoreThreshold: 85,
|
|
2371
2373
|
cleanupGeneratedArtifacts: true,
|
|
2372
2374
|
toolProfile: "enforcement",
|
|
@@ -3780,6 +3782,7 @@ function sensorAppliesToPath(sensor, anchorPaths, path19) {
|
|
|
3780
3782
|
return scopes.some((rawScope) => {
|
|
3781
3783
|
const scope = normalizeProjectPath(rawScope);
|
|
3782
3784
|
if (!scope) return false;
|
|
3785
|
+
if (isGlobPath(scope)) return globToRegExp(scope).test(target);
|
|
3783
3786
|
return target === scope || target.startsWith(`${scope}/`);
|
|
3784
3787
|
});
|
|
3785
3788
|
}
|
|
@@ -5344,6 +5347,24 @@ function classifyMemoryPriority(signals) {
|
|
|
5344
5347
|
function priorityRank(priority) {
|
|
5345
5348
|
return priority === "must_read" ? 3 : priority === "useful" ? 2 : 1;
|
|
5346
5349
|
}
|
|
5350
|
+
|
|
5351
|
+
// src/agent-context.ts
|
|
5352
|
+
var AGENT_ENV_SIGNALS = [
|
|
5353
|
+
{ name: "HAIVE_SESSION_ID", label: "hivelore-run-wrapper" },
|
|
5354
|
+
{ name: "CLAUDECODE", label: "claude-code" },
|
|
5355
|
+
{ name: "CLAUDE_CODE_ENTRYPOINT", label: "claude-code" },
|
|
5356
|
+
{ name: "CURSOR_AGENT", label: "cursor" },
|
|
5357
|
+
{ name: "GEMINI_CLI", label: "gemini-cli" },
|
|
5358
|
+
{ name: "CODEX_SANDBOX", label: "codex" },
|
|
5359
|
+
{ name: "AIDER_MODEL", label: "aider" }
|
|
5360
|
+
];
|
|
5361
|
+
function detectAgentContext(env = typeof process !== "undefined" ? process.env : {}) {
|
|
5362
|
+
const explicit = env["HAIVE_AGENT"]?.trim().toLowerCase();
|
|
5363
|
+
if (explicit === "1" || explicit === "true") return { agent: true, signals: ["HAIVE_AGENT=1"] };
|
|
5364
|
+
if (explicit === "0" || explicit === "false") return { agent: false, signals: ["HAIVE_AGENT=0"] };
|
|
5365
|
+
const signals = AGENT_ENV_SIGNALS.filter(({ name }) => (env[name] ?? "").trim().length > 0).map(({ name, label }) => `${label} (${name})`);
|
|
5366
|
+
return { agent: signals.length > 0, signals: [...new Set(signals)] };
|
|
5367
|
+
}
|
|
5347
5368
|
export {
|
|
5348
5369
|
AUTOPILOT_DEFAULTS,
|
|
5349
5370
|
ActivationSchema,
|
|
@@ -5432,6 +5453,7 @@ export {
|
|
|
5432
5453
|
contractLockPath,
|
|
5433
5454
|
countSourceFilesOnDisk,
|
|
5434
5455
|
deriveConfidence,
|
|
5456
|
+
detectAgentContext,
|
|
5435
5457
|
detectStacksFromManifests,
|
|
5436
5458
|
diffContract,
|
|
5437
5459
|
diffHasDistinctiveOverlap,
|