@lmzhen/dsh-evolution-core 0.51.0 → 0.52.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.
@@ -1,4 +1,4 @@
1
- import { E as selectSections, H as externalRefs, K as planReferenceRewrite, N as frontmatterBlock, U as supportRefs, W as applyReferenceRewrite, q as planRehoming } from "./usage-B5a90TKv.js";
1
+ import { F as frontmatterBlock, G as supportRefs, J as planReferenceRewrite, K as applyReferenceRewrite, O as selectSections, W as externalRefs, Y as planRehoming } from "./usage-B1qveKi9.js";
2
2
  import { createHash } from "node:crypto";
3
3
  //#region lib/types/extract-plan.js
4
4
  const LF = String.fromCharCode(10);
package/lib/extract.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { p as isPresent } from "./io-GxghO3Ip.js";
2
- import { i as DEFAULT_SKILL_LIMITS } from "./limits-C9jfvxBl.js";
3
- import { I as parseFrontmatter } from "./usage-B5a90TKv.js";
4
- import { C as EXTRACT_PROMPT_VERSION, S as EXTRACT_PROMPT_V1, T as ownerCandidatesFromSummaries, _ as readProposalReport, b as proposalFromPlan, d as nearDuplicateSummaries, m as readExternalSupport, v as readProposalReports, w as findOwnerCandidate, x as EXTRACT_PROMPT_HASH, y as writeProposalReport } from "./quality-DpAS0rd9.js";
2
+ import { i as DEFAULT_SKILL_LIMITS } from "./limits-TD4Pv92Q.js";
3
+ import { R as parseFrontmatter } from "./usage-B1qveKi9.js";
4
+ import { C as EXTRACT_PROMPT_VERSION, S as EXTRACT_PROMPT_V1, T as ownerCandidatesFromSummaries, _ as readProposalReport, b as proposalFromPlan, d as nearDuplicateSummaries, m as readExternalSupport, v as readProposalReports, w as findOwnerCandidate, x as EXTRACT_PROMPT_HASH, y as writeProposalReport } from "./quality-BLc6UQQb.js";
5
5
  import { r as contentHash } from "./mutations-DQXddSJd.js";
6
- import { n as projectExtractBodies, t as planExtract } from "./extract-plan-D6o__2Kf.js";
6
+ import { n as projectExtractBodies, t as planExtract } from "./extract-plan-D4zO7dmD.js";
7
7
  import { dirname, join } from "node:path";
8
8
  //#region lib/types/extract-request.js
9
9
  /** The one human-readable owner decision shared by tool and CLI. */
@@ -46,7 +46,8 @@ const HOST_ROUTES = {
46
46
  diff: "/api/dsh-evolution/skill-history/versions/diff",
47
47
  body: "/api/dsh-evolution/skill-history/versions/body",
48
48
  undo: "/api/dsh-evolution/skill-history/undo",
49
- health: "/api/dsh-evolution/skill-history/health"
49
+ health: "/api/dsh-evolution/skill-history/health",
50
+ stats: "/api/dsh-evolution/skill-history/stats"
50
51
  },
51
52
  skillHealth: { rows: "/api/dsh-evolution/skill-health/rows" },
52
53
  merge: {
package/lib/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { S as reportTime, _ as probeMtime, a as isProcessAlive, b as probeText, c as transactIo, d as isAbsent, f as isMissingPath, g as probeList, h as probeAbsent, i as isCommittedWarning, l as writeDurableTmp, m as isUnknown, n as atomicWriteFiles, o as nodeEvolutionIo, p as isPresent, r as evolutionIoAdapter, s as renameWithRetry, t as TransactionNotInvokedError, u as declaredReportStamp, v as probePresent, x as probeUnknown, y as probeReason } from "./io-GxghO3Ip.js";
2
2
  import { a as leaseFile, c as AuthorityBusyError, d as HomeAuthority, f as authorityHolder, i as LeaseStore, l as AuthorityOrderError, n as mutationLockFrom, o as HomeFence, p as leaseAsTreeLock, r as DEFAULT_LEASE_TTL_MS, s as HomeFenceError, t as MutationAuthority, u as AuthorityReentryError } from "./mutation-authority-DQfpXs1O.js";
3
3
  import { a as isFileShapedPath, i as KEEP_LINE_RE, n as DEFAULT_CITATION_REF_BUDGET, o as resolveCitations, r as HOOK_LINE_RE, s as scanBodyHooks, t as CITATION_SUPPORT_DIRS } from "./citations-CZKTUGQF.js";
4
- import { A as DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, B as MAX_TIMER_DELAY_MS, C as DEFAULT_SKILL_CONTENT_CHARS, D as DEFAULT_STALE_AFTER_DAYS, E as DEFAULT_SKILL_VERSION_KEEP, F as FORBIDDEN_CONTROL_KEYS, G as SKILL_NAME_RE, H as PROTECTED_BUILTIN_SKILLS, I as MAX_DESCRIPTION_LENGTH, J as UPSTREAM_LIMIT_CHARS_PER_TOKEN, K as SUPPORT_DIRS, L as MAX_SKILL_CONTENT_CHARS, M as DEFAULT_USER_CHAR_LIMIT, N as ENTRY_DELIMITER, O as DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, P as EVOLUTION_WRITE_TOOLS, R as MAX_SKILL_FILE_BYTES, S as DEFAULT_REVIEW_TIMEOUT_MS, T as DEFAULT_SKILL_REVIEW_TRIGGER, U as SKILLS_GUIDANCE_SECTION_ORDER, V as MEMORY_GUIDANCE_SECTION_ORDER, W as SKILL_ACTION_REQUIRED_FIELDS, _ as DEFAULT_MEMORY_CHAR_LIMIT, a as DEFAULT_SUPPORT_FILE_CHAR_POLICY, b as DEFAULT_REVIEW_MEMORY_INTERVAL, c as AUTHORING_DESCRIPTION_BAR, d as DEFAULT_ARCHIVE_AFTER_DAYS, f as DEFAULT_CONSOLIDATION_FAILURES, g as DEFAULT_CURATOR_REVIEW_MAX_TOKENS, h as DEFAULT_CURATOR_MODEL, i as DEFAULT_SKILL_LIMITS, j as DEFAULT_THREAT_MAX_SCAN_CHARS, k as DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, l as AUTHORING_SPLIT_LINE_CHARS, m as DEFAULT_CURATOR_INTERVAL_HOURS, n as DEFAULT_CITATION_POLICY, o as POLICY_STAGE_DEFAULTS, p as DEFAULT_CURATOR_BOOT_GRACE_SECONDS, q as SUPPORT_SPRAWL_FILES, r as DEFAULT_REFERENCE_REWRITE_POLICY, s as policyStageLimits, t as DEFAULT_ARCHIVE_RETENTION_POLICY, u as CONTENT_SPLIT_HINT, v as DEFAULT_MIN_IDLE_HOURS, w as DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, x as DEFAULT_REVIEW_SKILL_INTERVAL, y as DEFAULT_PROBE_TIMEOUT_MS, z as MAX_SKILL_NAME_LENGTH } from "./limits-C9jfvxBl.js";
4
+ import { A as DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, B as MAX_TIMER_DELAY_MS, C as DEFAULT_SKILL_CONTENT_CHARS, D as DEFAULT_STALE_AFTER_DAYS, E as DEFAULT_SKILL_VERSION_KEEP, F as FORBIDDEN_CONTROL_KEYS, G as SKILL_NAME_RE, H as PROTECTED_BUILTIN_SKILLS, I as MAX_DESCRIPTION_LENGTH, J as UPSTREAM_LIMIT_CHARS_PER_TOKEN, K as SUPPORT_DIRS, L as MAX_SKILL_CONTENT_CHARS, M as DEFAULT_USER_CHAR_LIMIT, N as ENTRY_DELIMITER, O as DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, P as EVOLUTION_WRITE_TOOLS, R as MAX_SKILL_FILE_BYTES, S as DEFAULT_REVIEW_TIMEOUT_MS, T as DEFAULT_SKILL_REVIEW_TRIGGER, U as SKILLS_GUIDANCE_SECTION_ORDER, V as MEMORY_GUIDANCE_SECTION_ORDER, W as SKILL_ACTION_REQUIRED_FIELDS, _ as DEFAULT_MEMORY_CHAR_LIMIT, a as DEFAULT_SUPPORT_FILE_CHAR_POLICY, b as DEFAULT_REVIEW_MEMORY_INTERVAL, c as AUTHORING_DESCRIPTION_BAR, d as DEFAULT_ARCHIVE_AFTER_DAYS, f as DEFAULT_CONSOLIDATION_FAILURES, g as DEFAULT_CURATOR_REVIEW_MAX_TOKENS, h as DEFAULT_CURATOR_MODEL, i as DEFAULT_SKILL_LIMITS, j as DEFAULT_THREAT_MAX_SCAN_CHARS, k as DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, l as AUTHORING_SPLIT_LINE_CHARS, m as DEFAULT_CURATOR_INTERVAL_HOURS, n as DEFAULT_CITATION_POLICY, o as POLICY_STAGE_DEFAULTS, p as DEFAULT_CURATOR_BOOT_GRACE_SECONDS, q as SUPPORT_SPRAWL_FILES, r as DEFAULT_REFERENCE_REWRITE_POLICY, s as policyStageLimits, t as DEFAULT_ARCHIVE_RETENTION_POLICY, u as CONTENT_SPLIT_HINT, v as DEFAULT_MIN_IDLE_HOURS, w as DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, x as DEFAULT_REVIEW_SKILL_INTERVAL, y as DEFAULT_PROBE_TIMEOUT_MS, z as MAX_SKILL_NAME_LENGTH } from "./limits-TD4Pv92Q.js";
5
5
  import { _ as scopedPackageName, d as RESTRICTED_TOOLS_ROW_ID, f as RESTRICTOR_MODULE, g as scopeOfNearestManifest, l as MAINTAINER_PRESET_ID, p as REVIEWER_PRESET_ID, s as EVOLUTION_PRESET_IDS, u as RESTRICTED_PRESET_DISPLAY } from "./ensure-BLmEW0Ju.js";
6
- import { $ as DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, A as evolutionEventPayloadIssue, B as COST_ASCII_TOKEN_LOW, C as trimPatternBoundaries, D as EVENT_LOG_VERSION, E as EVENT_LOG_ROTATE_AT, F as retainEventArchives, G as bodyCost, H as COST_CJK_TOKEN_LOW, I as RULES, K as tokenLineFor, M as parseEvolutionEvents, N as readEvolutionEvents, O as appendEvolutionEvent, P as readEvolutionTimeline, Q as DEFAULT_WRITE_CONFIRM_MODE, R as lintSkill, S as fuzzyPatch, T as EVENT_LOG_RETAIN_ARCHIVES, U as TOKEN_ASCII_WEIGHT, V as COST_CJK_TOKEN_HIGH, W as TOKEN_CJK_WEIGHT, Y as isUnreadWrite, _ as scanMemoryThreats, b as FUZZY_MAX_PATTERN_CHARS, c as withReviewContext, d as markReviewChannel, et as authorityFrom, f as sweepReviewChannelSessions, g as scanContentThreats, h as evaluateThreat, i as assessStructureHealth, j as listEventArchives, k as eventsFile, l as clearReviewChannel, m as THREAT_EXEMPTION_HINT, o as currentReviewContext, p as PATTERN_OVERLAP, s as recordReviewRead, t as DEFAULT_HEALTH_THRESHOLDS, u as isReviewChannelSession, v as scanThreats, w as EVENT_ARCHIVE_PREFIX, x as FUZZY_MAX_WORK, y as makeSerialQueue, z as COST_ASCII_TOKEN_HIGH } from "./skill-health-BQCM4N8z.js";
6
+ import { $ as DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, A as evolutionEventPayloadIssue, B as COST_ASCII_TOKEN_LOW, C as trimPatternBoundaries, D as EVENT_LOG_VERSION, E as EVENT_LOG_ROTATE_AT, F as retainEventArchives, G as bodyCost, H as COST_CJK_TOKEN_LOW, I as RULES, K as tokenLineFor, M as parseEvolutionEvents, N as readEvolutionEvents, O as appendEvolutionEvent, P as readEvolutionTimeline, Q as DEFAULT_WRITE_CONFIRM_MODE, R as lintSkill, S as fuzzyPatch, T as EVENT_LOG_RETAIN_ARCHIVES, U as TOKEN_ASCII_WEIGHT, V as COST_CJK_TOKEN_HIGH, W as TOKEN_CJK_WEIGHT, Y as isUnreadWrite, _ as scanMemoryThreats, b as FUZZY_MAX_PATTERN_CHARS, c as withReviewContext, d as markReviewChannel, et as authorityFrom, f as sweepReviewChannelSessions, g as scanContentThreats, h as evaluateThreat, i as assessStructureHealth, j as listEventArchives, k as eventsFile, l as clearReviewChannel, m as THREAT_EXEMPTION_HINT, o as currentReviewContext, p as PATTERN_OVERLAP, s as recordReviewRead, t as DEFAULT_HEALTH_THRESHOLDS, u as isReviewChannelSession, v as scanThreats, w as EVENT_ARCHIVE_PREFIX, x as FUZZY_MAX_WORK, y as makeSerialQueue, z as COST_ASCII_TOKEN_HIGH } from "./skill-health-BIpiPvw6.js";
7
7
  import { i as HOST_LOCALES, n as errorText, r as errorTextIn, t as EVOLUTION_ERRORS } from "./errors-BxzLTVbS.js";
8
8
  import { A as dispatchKeyOf, C as PTC_DISPATCH_EVENT, D as assertDispatchPayload, E as ToolDispatchPayloadError, F as isSkillToolName, I as readDispatchSignal, L as skillReadNameOf, M as dispatchStepOf, N as foldToolDispatches, O as collectReadSkillNames, P as isSkillReadToolName, R as supportFileReadFromPath, S as NATIVE_RESULT_EVENT, T as ToolDispatchNormalizer, _ as isBookkeepingFrame, a as evolutionSignalsProjection, b as MODEL_SESSION_EVENT_TYPES, c as sessionLastEventTime, d as advanceReview, f as foldTurnEvent, g as evidenceKindIndex, h as observeEvent, i as evolutionReadsProjection, j as dispatchPathOf, k as collectReadSupportFiles, l as sessionReadNames, m as initialTurnFold, n as evolutionEvidenceProjection, o as isProjectableSession, p as foldTurnEvents, r as evolutionProjectionHistoryProjection, s as sessionEvidenceIndex, t as evolutionActivityProjection, u as sessionTurnSignals, v as DEFAULT_SUPPORT_READ_TOOL_NAMES, w as PTC_DISPATCH_START_EVENT, x as NATIVE_CALL_EVENT, y as DISPATCH_EVENT_TYPES, z as supportFileReadOf } from "./session-projection-ByNxQi9O.js";
9
- import { C as updateSuppressedNames, D as displayBodyOf, E as selectSections, G as describeReferenceRewrite, H as externalRefs, K as planReferenceRewrite, O as h2Sections, S as suppressedFile, T as usageObserved, U as supportRefs, W as applyReferenceRewrite, _ as markAgentCreated, a as bumpPatch, b as saveSuppressedNames, c as bumpView, d as foldCuratorFields, f as getRecord, g as loadUsage, h as loadSuppressedNames, i as applyCuratorMetaFields, k as readingStats, l as daysSinceIso, m as latestActivityAt, n as SUPPRESSED_FILE_VERSION, o as bumpSupportRead, p as idleDays, q as planRehoming, r as applyCuratorLifecycleFields, s as bumpUse, t as MAX_SUPPORT_READ_PATHS, u as emptyRecord, v as mutateUsage, w as usageFile, x as saveUsage, y as normalizeUsageRecord } from "./usage-B5a90TKv.js";
9
+ import { A as h2Sections, C as saveUsage, D as usageObserved, E as usageFile, G as supportRefs, J as planReferenceRewrite, K as applyReferenceRewrite, O as selectSections, S as saveSuppressedNames, T as updateSuppressedNames, W as externalRefs, Y as planRehoming, _ as loadUsage, a as applyCuratorMetaFields, b as normalizeUsageRecord, c as bumpUse, d as emptyRecord, f as foldCuratorFields, g as loadSuppressedNames, h as latestActivityAt, i as applyCuratorLifecycleFields, j as readingStats, k as displayBodyOf, l as bumpView, m as idleDays, n as SUPPRESSED_FILE_VERSION, o as bumpPatch, p as getRecord, q as describeReferenceRewrite, r as VIEW_WINDOW_DAYS, s as bumpSupportRead, t as MAX_SUPPORT_READ_PATHS, u as daysSinceIso, v as markAgentCreated, w as suppressedFile, x as recentViewCount, y as mutateUsage } from "./usage-B1qveKi9.js";
10
10
  import { n as isRecord, t as asRecord } from "./guards-3f02mnf2.js";
11
- import { T as ownerCandidatesFromSummaries, _ as readProposalReport, a as SUMMARY_DUPLICATE_HINT_THRESHOLD, b as proposalFromPlan, c as computePrefixClusters, d as nearDuplicateSummaries, f as projectionText, g as proposalReportName, h as proposalReportDir, i as QUALITY_WEIGHTS, l as computeQualityScores, m as readExternalSupport, n as DEDUP_SIMILARITY_THRESHOLD, o as affinity, p as vocabulary, r as LOW_QUALITY_THRESHOLD, s as computeDedupGroups, t as DEDUP_MAX_PAIR_COMPARISONS, u as identity, v as readProposalReports, w as findOwnerCandidate, y as writeProposalReport } from "./quality-DpAS0rd9.js";
11
+ import { T as ownerCandidatesFromSummaries, _ as readProposalReport, a as SUMMARY_DUPLICATE_HINT_THRESHOLD, b as proposalFromPlan, c as computePrefixClusters, d as nearDuplicateSummaries, f as projectionText, g as proposalReportName, h as proposalReportDir, i as QUALITY_WEIGHTS, l as computeQualityScores, m as readExternalSupport, n as DEDUP_SIMILARITY_THRESHOLD, o as affinity, p as vocabulary, r as LOW_QUALITY_THRESHOLD, s as computeDedupGroups, t as DEDUP_MAX_PAIR_COMPARISONS, u as identity, v as readProposalReports, w as findOwnerCandidate, y as writeProposalReport } from "./quality-BLc6UQQb.js";
12
12
  import { n as evolutionRoot, t as evolutionHome } from "./state-store-Jpa-iYIZ.js";
13
13
  import { HOST_ROUTES, MAX_REQUEST_BODY_BYTES, hostSurface, json, methodNotAllowed, readJsonObject, registerHostRoutes } from "./http-routes.js";
14
14
  import { w as allowRowCollisions } from "./composition-CtNbVHq3.js";
@@ -5271,4 +5271,4 @@ function classifySessionEvent(event) {
5271
5271
  return MODEL_EVENT_TYPES.has(type) ? "model" : "unknown";
5272
5272
  }
5273
5273
  //#endregion
5274
- export { AUTHORING_DESCRIPTION_BAR, AUTHORING_SPLIT_LINE_CHARS, AuthorityBusyError, AuthorityOrderError, AuthorityReentryError, CITATION_SUPPORT_DIRS, COMBINED_REVIEW_PROMPT, COMPLETION_SKILL_REVIEW_PROMPT, CONTENT_SPLIT_HINT, COST_ASCII_TOKEN_HIGH, COST_ASCII_TOKEN_LOW, COST_CJK_TOKEN_HIGH, COST_CJK_TOKEN_LOW, CURATOR_DRY_RUN_BANNER, CURATOR_PROMPT, DEDUP_MAX_PAIR_COMPARISONS, DEDUP_SIMILARITY_THRESHOLD, DEFAULT_ARCHIVE_AFTER_DAYS, DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_CITATION_POLICY, DEFAULT_CITATION_REF_BUDGET, DEFAULT_CONSOLIDATION_FAILURES, DEFAULT_CURATOR_BOOT_GRACE_SECONDS, DEFAULT_CURATOR_INTERVAL_HOURS, DEFAULT_CURATOR_MODEL, DEFAULT_CURATOR_REVIEW_MAX_TOKENS, DEFAULT_LEASE_TTL_MS, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_MIN_IDLE_HOURS, DEFAULT_MUTATION_CAP, DEFAULT_PROBE_TIMEOUT_MS, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_REVIEW_TIMEOUT_MS, DEFAULT_RUN_RECORDS, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, DEFAULT_SKILL_REVIEW_TRIGGER, DEFAULT_SKILL_VERSION_KEEP, DEFAULT_STALE_AFTER_DAYS, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, DEFAULT_SUPPORT_FILE_CHAR_POLICY, DEFAULT_SUPPORT_READ_TOOL_NAMES, DEFAULT_THREAT_MAX_SCAN_CHARS, DEFAULT_USER_CHAR_LIMIT, DEFAULT_WRITE_CONFIRM_MODE, DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, DIAGNOSTICS_FACT_KEYS, DIAGNOSTICS_RUNTIME_KEYS, DIAGNOSTICS_VIEW_SCHEMA_VERSION, DISPATCH_EVENT_TYPES, DRIFT_MAX_LINE_CHARS, DRIFT_SIGNALS_VERSION, DRIFT_SIGNAL_NOUNS, DSH_AUTHORING_STANDARDS, ENTRY_DELIMITER, EVENT_ARCHIVE_PREFIX, EVENT_LOG_RETAIN_ARCHIVES, EVENT_LOG_ROTATE_AT, EVENT_LOG_VERSION, EVOLUTION_ERRORS, EVOLUTION_PRESET_IDS, EVOLUTION_WRITE_TOOLS, EvolutionGateSet, FAMILY_SESSION_TOOL_NAMES, FORBIDDEN_CONTROL_KEYS, FUZZY_MAX_PATTERN_CHARS, FUZZY_MAX_WORK, GOVERNANCE_PROMPT_TEMPLATE, HOOK_LINE_RE, HOST_LOCALES, HOST_ROUTES, HomeAuthority, HomeFence, HomeFenceError, INJECT_COMBINED_REVIEW_PROMPT, INJECT_COMPLETION_SKILL_REVIEW_PROMPT, INJECT_MEMORY_REVIEW_PROMPT, INJECT_SKILL_REVIEW_PROMPT, INSTANCE_KEYS, KEEP_LINE_RE, LONG_RUNS, LOW_QUALITY_THRESHOLD, LeaseStore, MAINTAINER_PRESET_ID, MAINTAIN_OUTPUT_INSTRUCTION, MAINTAIN_PROMPT, MAX_DESCRIPTION_LENGTH, MAX_REQUEST_BODY_BYTES, MAX_SKILL_CONTENT_CHARS, MAX_SKILL_FILE_BYTES, MAX_SKILL_NAME_LENGTH, MAX_SUPPORT_READ_PATHS, MAX_TIMER_DELAY_MS, MEMORY_GUIDANCE_SECTION_ORDER, MEMORY_REVIEW_PROMPT, MODEL_SESSION_EVENT_TYPES, MUTATIONS_FILE_VERSION, MemoryStore, MutationAuthority, NAMESPACE_MIGRATIONS, NATIVE_CALL_EVENT, NATIVE_RESULT_EVENT, PARAM_ALIASES, PARAM_EXPOSURE, PARAM_GROUP_LABELS, PARAM_NAMESPACES, PATTERN_OVERLAP, PLATFORM_LINE, PLATFORM_SERVICE_PROBES, POLICY_STAGE_DEFAULTS, PROMPT_BUNDLE, PROMPT_BUNDLE_ID, PROMPT_BUNDLE_VERSION, PROTECTED_BUILTIN_SKILLS, PTC_DISPATCH_EVENT, PTC_DISPATCH_START_EVENT, QUALITY_WEIGHTS, RESTRICTED_PRESET_DISPLAY, RESTRICTED_TOOLS_ROW_ID, RESTRICTOR_MODULE, REVIEWER_PRESET_ID, RUNS_SCHEMA_VERSION, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, SKILL_ACTION_REQUIRED_FIELDS, SKILL_NAME_RE, SKILL_REVIEW_PROMPT, STORE_LEDGER, SUMMARY_DUPLICATE_HINT_THRESHOLD, SUPPORT_DIRS, SUPPORT_SPRAWL_FILES, SUPPRESSED_FILE_VERSION, THREAT_EXEMPTION_HINT, TOKEN_ASCII_WEIGHT, TOKEN_CJK_WEIGHT, ToolDispatchNormalizer, ToolDispatchPayloadError, TransactionNotInvokedError, UPSTREAM_LIMIT_CHARS_PER_TOKEN, abortLink, absentHostServices, advanceReview, affinity, allowRowCollisions, appendEvolutionEvent, applyCuratorLifecycleFields, applyCuratorMetaFields, applyNamespaceMigration, applyReferenceRewrite, asRecord, assertDispatchPayload, atomicWriteFiles, authorityFrom, authorityHolder, backupsReachability, bodyCost, buildCuratorRunReport, buildHealthBaseline, buildLearnPrompt, bumpPatch, bumpSupportRead, bumpUse, bumpView, callingScope, claimInstance, clampOnce, clampedNumber, classifyNamespaceMigration, classifySessionEvent, clearReviewChannel, collectReadSkillNames, collectReadSupportFiles, computeDedupGroups, computeDriftSignals, computeLifecycleTransitions, computePrefixClusters, computeQualityScores, computeScopeView, contentHash, createGateSet, createSubagentKernel as createSubagentChannel, createSubagentKernel, createSubagentRun, currentReviewContext, daysSinceIso, declaredReportStamp, describeReferenceRewrite, dispatchKeyOf, dispatchPathOf, dispatchStepOf, displayBodyOf, duplicateHeadings, emptyRecord, errorText, errorTextIn, evaluateThreat, eventsFile, evidenceKindIndex, evolutionActivityProjection, evolutionEventPayloadIssue, evolutionEvidenceProjection, evolutionHome, evolutionIoAdapter, evolutionProjectionHistoryProjection, evolutionReadsProjection, evolutionRoot, evolutionSignalsProjection, externalRefs, findDriftSignal, findOwnerCandidate, foldCuratorFields, foldToolDispatches, foldTurnEvent, foldTurnEvents, fuzzyPatch, getRecord, h2Sections, historyReachability, hostSurface, identity, idleDays, initialTurnFold, instanceClaimKey, instanceHolder, isAbsent, isBookkeepingFrame, isCommittedWarning, isDeprecatedParamId, isFileShapedPath, isMissingPath, isPresent, isProcessAlive, isProjectableSession, isRecord, isReviewChannelSession, isSkillReadToolName, isSkillToolName, isUnknown, json, latestActivityAt, leaseAsTreeLock, leaseFile, lifecycleCandidate, listEventArchives, liveBool, liveNumber, loadMutations, loadSuppressedNames, loadUsage, makeSerialQueue, markAgentCreated, markReviewChannel, memoryRoot, methodNotAllowed, missingSupportPointers, mutateUsage, mutationLockFrom, mutationsFile, narrowNameMatches, nearDuplicateSummaries, newRunRegistry, nodeEvolutionIo, normalizeUsageRecord, observeEvent, overlongLines, ownerCandidatesFromSummaries, paramRowId, paramSettingsId, parseCuratorNominations, parseEvolutionEvents, payloadText, persistedWriteSites, pickWithPolicy, planNamespaceMigration, planReferenceRewrite, planRehoming, policyStageLimits, probeAbsent, probeChannelState, probeList, probeMtime, probePresent, probeReason, probeText, probeUnknown, projectionText, proposalFromPlan, proposalReportDir, proposalReportName, protectedSkillNamesOf, readDispatchSignal, readEvolutionEvents, readEvolutionTimeline, readExternalSupport, readJsonObject, readNumberParam, readParam, readProposalReport, readProposalReports, readingStats, recordMutation, recordReviewRead, redactSecrets, referencedBlobs, registerHostRoutes, releaseInstance, renameWithRetry, renderCuratorReportMarkdown, reportTime, reportsReachability, reportsSweepLockTarget, resolveCitations, resolveParamId, retainEventArchives, retirementReport, reviewPrompt, runWriteGates, runsFile, saveSuppressedNames, saveUsage, scanBodyHooks, scanContentThreats, scanMemoryThreats, scanThreats, scopeOfNearestManifest, scopedPackageName, scopedProbeReport, selectSections, sessionAudited, sessionEvidenceIndex, sessionLastEventTime, sessionReadNames, sessionSeesFamilyTools, sessionTurnSignals, skillReadNameOf, skillWriteGateContext, supportFileReadFromPath, supportFileReadOf, supportRefs, suppressedFile, sweepReports, sweepReviewChannelSessions, textOfValue, tokenLineFor, transactIo, trimPatternBoundaries, unhookedSupportPointers, unwrapLive, updateSuppressedNames, usageFile, usageObserved, userSetKeys, verifyPromptBundle, vocabulary, waitForSubagentEnd, withReviewContext, withTreeWrite, writeDurableTmp, writeProposalReport };
5274
+ export { AUTHORING_DESCRIPTION_BAR, AUTHORING_SPLIT_LINE_CHARS, AuthorityBusyError, AuthorityOrderError, AuthorityReentryError, CITATION_SUPPORT_DIRS, COMBINED_REVIEW_PROMPT, COMPLETION_SKILL_REVIEW_PROMPT, CONTENT_SPLIT_HINT, COST_ASCII_TOKEN_HIGH, COST_ASCII_TOKEN_LOW, COST_CJK_TOKEN_HIGH, COST_CJK_TOKEN_LOW, CURATOR_DRY_RUN_BANNER, CURATOR_PROMPT, DEDUP_MAX_PAIR_COMPARISONS, DEDUP_SIMILARITY_THRESHOLD, DEFAULT_ARCHIVE_AFTER_DAYS, DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_CITATION_POLICY, DEFAULT_CITATION_REF_BUDGET, DEFAULT_CONSOLIDATION_FAILURES, DEFAULT_CURATOR_BOOT_GRACE_SECONDS, DEFAULT_CURATOR_INTERVAL_HOURS, DEFAULT_CURATOR_MODEL, DEFAULT_CURATOR_REVIEW_MAX_TOKENS, DEFAULT_LEASE_TTL_MS, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_MIN_IDLE_HOURS, DEFAULT_MUTATION_CAP, DEFAULT_PROBE_TIMEOUT_MS, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_REVIEW_TIMEOUT_MS, DEFAULT_RUN_RECORDS, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, DEFAULT_SKILL_REVIEW_TRIGGER, DEFAULT_SKILL_VERSION_KEEP, DEFAULT_STALE_AFTER_DAYS, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, DEFAULT_SUPPORT_FILE_CHAR_POLICY, DEFAULT_SUPPORT_READ_TOOL_NAMES, DEFAULT_THREAT_MAX_SCAN_CHARS, DEFAULT_USER_CHAR_LIMIT, DEFAULT_WRITE_CONFIRM_MODE, DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, DIAGNOSTICS_FACT_KEYS, DIAGNOSTICS_RUNTIME_KEYS, DIAGNOSTICS_VIEW_SCHEMA_VERSION, DISPATCH_EVENT_TYPES, DRIFT_MAX_LINE_CHARS, DRIFT_SIGNALS_VERSION, DRIFT_SIGNAL_NOUNS, DSH_AUTHORING_STANDARDS, ENTRY_DELIMITER, EVENT_ARCHIVE_PREFIX, EVENT_LOG_RETAIN_ARCHIVES, EVENT_LOG_ROTATE_AT, EVENT_LOG_VERSION, EVOLUTION_ERRORS, EVOLUTION_PRESET_IDS, EVOLUTION_WRITE_TOOLS, EvolutionGateSet, FAMILY_SESSION_TOOL_NAMES, FORBIDDEN_CONTROL_KEYS, FUZZY_MAX_PATTERN_CHARS, FUZZY_MAX_WORK, GOVERNANCE_PROMPT_TEMPLATE, HOOK_LINE_RE, HOST_LOCALES, HOST_ROUTES, HomeAuthority, HomeFence, HomeFenceError, INJECT_COMBINED_REVIEW_PROMPT, INJECT_COMPLETION_SKILL_REVIEW_PROMPT, INJECT_MEMORY_REVIEW_PROMPT, INJECT_SKILL_REVIEW_PROMPT, INSTANCE_KEYS, KEEP_LINE_RE, LONG_RUNS, LOW_QUALITY_THRESHOLD, LeaseStore, MAINTAINER_PRESET_ID, MAINTAIN_OUTPUT_INSTRUCTION, MAINTAIN_PROMPT, MAX_DESCRIPTION_LENGTH, MAX_REQUEST_BODY_BYTES, MAX_SKILL_CONTENT_CHARS, MAX_SKILL_FILE_BYTES, MAX_SKILL_NAME_LENGTH, MAX_SUPPORT_READ_PATHS, MAX_TIMER_DELAY_MS, MEMORY_GUIDANCE_SECTION_ORDER, MEMORY_REVIEW_PROMPT, MODEL_SESSION_EVENT_TYPES, MUTATIONS_FILE_VERSION, MemoryStore, MutationAuthority, NAMESPACE_MIGRATIONS, NATIVE_CALL_EVENT, NATIVE_RESULT_EVENT, PARAM_ALIASES, PARAM_EXPOSURE, PARAM_GROUP_LABELS, PARAM_NAMESPACES, PATTERN_OVERLAP, PLATFORM_LINE, PLATFORM_SERVICE_PROBES, POLICY_STAGE_DEFAULTS, PROMPT_BUNDLE, PROMPT_BUNDLE_ID, PROMPT_BUNDLE_VERSION, PROTECTED_BUILTIN_SKILLS, PTC_DISPATCH_EVENT, PTC_DISPATCH_START_EVENT, QUALITY_WEIGHTS, RESTRICTED_PRESET_DISPLAY, RESTRICTED_TOOLS_ROW_ID, RESTRICTOR_MODULE, REVIEWER_PRESET_ID, RUNS_SCHEMA_VERSION, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, SKILL_ACTION_REQUIRED_FIELDS, SKILL_NAME_RE, SKILL_REVIEW_PROMPT, STORE_LEDGER, SUMMARY_DUPLICATE_HINT_THRESHOLD, SUPPORT_DIRS, SUPPORT_SPRAWL_FILES, SUPPRESSED_FILE_VERSION, THREAT_EXEMPTION_HINT, TOKEN_ASCII_WEIGHT, TOKEN_CJK_WEIGHT, ToolDispatchNormalizer, ToolDispatchPayloadError, TransactionNotInvokedError, UPSTREAM_LIMIT_CHARS_PER_TOKEN, VIEW_WINDOW_DAYS, abortLink, absentHostServices, advanceReview, affinity, allowRowCollisions, appendEvolutionEvent, applyCuratorLifecycleFields, applyCuratorMetaFields, applyNamespaceMigration, applyReferenceRewrite, asRecord, assertDispatchPayload, atomicWriteFiles, authorityFrom, authorityHolder, backupsReachability, bodyCost, buildCuratorRunReport, buildHealthBaseline, buildLearnPrompt, bumpPatch, bumpSupportRead, bumpUse, bumpView, callingScope, claimInstance, clampOnce, clampedNumber, classifyNamespaceMigration, classifySessionEvent, clearReviewChannel, collectReadSkillNames, collectReadSupportFiles, computeDedupGroups, computeDriftSignals, computeLifecycleTransitions, computePrefixClusters, computeQualityScores, computeScopeView, contentHash, createGateSet, createSubagentKernel as createSubagentChannel, createSubagentKernel, createSubagentRun, currentReviewContext, daysSinceIso, declaredReportStamp, describeReferenceRewrite, dispatchKeyOf, dispatchPathOf, dispatchStepOf, displayBodyOf, duplicateHeadings, emptyRecord, errorText, errorTextIn, evaluateThreat, eventsFile, evidenceKindIndex, evolutionActivityProjection, evolutionEventPayloadIssue, evolutionEvidenceProjection, evolutionHome, evolutionIoAdapter, evolutionProjectionHistoryProjection, evolutionReadsProjection, evolutionRoot, evolutionSignalsProjection, externalRefs, findDriftSignal, findOwnerCandidate, foldCuratorFields, foldToolDispatches, foldTurnEvent, foldTurnEvents, fuzzyPatch, getRecord, h2Sections, historyReachability, hostSurface, identity, idleDays, initialTurnFold, instanceClaimKey, instanceHolder, isAbsent, isBookkeepingFrame, isCommittedWarning, isDeprecatedParamId, isFileShapedPath, isMissingPath, isPresent, isProcessAlive, isProjectableSession, isRecord, isReviewChannelSession, isSkillReadToolName, isSkillToolName, isUnknown, json, latestActivityAt, leaseAsTreeLock, leaseFile, lifecycleCandidate, listEventArchives, liveBool, liveNumber, loadMutations, loadSuppressedNames, loadUsage, makeSerialQueue, markAgentCreated, markReviewChannel, memoryRoot, methodNotAllowed, missingSupportPointers, mutateUsage, mutationLockFrom, mutationsFile, narrowNameMatches, nearDuplicateSummaries, newRunRegistry, nodeEvolutionIo, normalizeUsageRecord, observeEvent, overlongLines, ownerCandidatesFromSummaries, paramRowId, paramSettingsId, parseCuratorNominations, parseEvolutionEvents, payloadText, persistedWriteSites, pickWithPolicy, planNamespaceMigration, planReferenceRewrite, planRehoming, policyStageLimits, probeAbsent, probeChannelState, probeList, probeMtime, probePresent, probeReason, probeText, probeUnknown, projectionText, proposalFromPlan, proposalReportDir, proposalReportName, protectedSkillNamesOf, readDispatchSignal, readEvolutionEvents, readEvolutionTimeline, readExternalSupport, readJsonObject, readNumberParam, readParam, readProposalReport, readProposalReports, readingStats, recentViewCount, recordMutation, recordReviewRead, redactSecrets, referencedBlobs, registerHostRoutes, releaseInstance, renameWithRetry, renderCuratorReportMarkdown, reportTime, reportsReachability, reportsSweepLockTarget, resolveCitations, resolveParamId, retainEventArchives, retirementReport, reviewPrompt, runWriteGates, runsFile, saveSuppressedNames, saveUsage, scanBodyHooks, scanContentThreats, scanMemoryThreats, scanThreats, scopeOfNearestManifest, scopedPackageName, scopedProbeReport, selectSections, sessionAudited, sessionEvidenceIndex, sessionLastEventTime, sessionReadNames, sessionSeesFamilyTools, sessionTurnSignals, skillReadNameOf, skillWriteGateContext, supportFileReadFromPath, supportFileReadOf, supportRefs, suppressedFile, sweepReports, sweepReviewChannelSessions, textOfValue, tokenLineFor, transactIo, trimPatternBoundaries, unhookedSupportPointers, unwrapLive, updateSuppressedNames, usageFile, usageObserved, userSetKeys, verifyPromptBundle, vocabulary, waitForSubagentEnd, withReviewContext, withTreeWrite, writeDurableTmp, writeProposalReport };
@@ -37,7 +37,6 @@
37
37
  */
38
38
  const SKILL_ACTION_REQUIRED_FIELDS = {
39
39
  create: ["name", "content"],
40
- edit: ["name", "content"],
41
40
  update: ["name", "content"],
42
41
  patch: [
43
42
  "name",
package/lib/policy.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as DEFAULT_SKILL_CONTENT_CHARS, F as FORBIDDEN_CONTROL_KEYS, H as PROTECTED_BUILTIN_SKILLS, M as DEFAULT_USER_CHAR_LIMIT, P as EVOLUTION_WRITE_TOOLS, _ as DEFAULT_MEMORY_CHAR_LIMIT, a as DEFAULT_SUPPORT_FILE_CHAR_POLICY, h as DEFAULT_CURATOR_MODEL, n as DEFAULT_CITATION_POLICY, o as POLICY_STAGE_DEFAULTS, r as DEFAULT_REFERENCE_REWRITE_POLICY, t as DEFAULT_ARCHIVE_RETENTION_POLICY } from "./limits-C9jfvxBl.js";
1
+ import { C as DEFAULT_SKILL_CONTENT_CHARS, F as FORBIDDEN_CONTROL_KEYS, H as PROTECTED_BUILTIN_SKILLS, M as DEFAULT_USER_CHAR_LIMIT, P as EVOLUTION_WRITE_TOOLS, _ as DEFAULT_MEMORY_CHAR_LIMIT, a as DEFAULT_SUPPORT_FILE_CHAR_POLICY, h as DEFAULT_CURATOR_MODEL, n as DEFAULT_CITATION_POLICY, o as POLICY_STAGE_DEFAULTS, r as DEFAULT_REFERENCE_REWRITE_POLICY, t as DEFAULT_ARCHIVE_RETENTION_POLICY } from "./limits-TD4Pv92Q.js";
2
2
  import { t as asRecord } from "./guards-3f02mnf2.js";
3
3
  import { t as clampedNumber } from "./numeric-Dc53KQoe.js";
4
4
  import { n as toolsPort } from "./tools-BrUswg8v.js";
@@ -1,5 +1,5 @@
1
1
  import { b as probeText, g as probeList, m as isUnknown, p as isPresent } from "./io-GxghO3Ip.js";
2
- import { H as externalRefs, O as h2Sections, m as latestActivityAt } from "./usage-B5a90TKv.js";
2
+ import { A as h2Sections, W as externalRefs, h as latestActivityAt } from "./usage-B1qveKi9.js";
3
3
  import { t as evolutionHome } from "./state-store-Jpa-iYIZ.js";
4
4
  import { readFile, realpath, stat } from "node:fs/promises";
5
5
  import { basename, isAbsolute, join, relative, resolve } from "node:path";
@@ -1,7 +1,7 @@
1
1
  import { c as transactIo } from "./io-GxghO3Ip.js";
2
- import { J as UPSTREAM_LIMIT_CHARS_PER_TOKEN, j as DEFAULT_THREAT_MAX_SCAN_CHARS, l as AUTHORING_SPLIT_LINE_CHARS } from "./limits-C9jfvxBl.js";
2
+ import { J as UPSTREAM_LIMIT_CHARS_PER_TOKEN, j as DEFAULT_THREAT_MAX_SCAN_CHARS, l as AUTHORING_SPLIT_LINE_CHARS } from "./limits-TD4Pv92Q.js";
3
3
  import { O as collectReadSkillNames, R as supportFileReadFromPath, k as collectReadSupportFiles, l as sessionReadNames, o as isProjectableSession, v as DEFAULT_SUPPORT_READ_TOOL_NAMES } from "./session-projection-ByNxQi9O.js";
4
- import { z as skillMdOnDisk } from "./usage-B5a90TKv.js";
4
+ import { V as skillMdOnDisk } from "./usage-B1qveKi9.js";
5
5
  import { t as clampedNumber } from "./numeric-Dc53KQoe.js";
6
6
  import { AsyncLocalStorage } from "node:async_hooks";
7
7
  import { dirname, join } from "node:path";
@@ -92,7 +92,6 @@ function sessionReadSupportFiles(ctx, session, options) {
92
92
  }
93
93
  /** Actions whose target must have been read first (create is authorship, so it is exempt). */
94
94
  const READ_REQUIRED_ACTIONS = Object.freeze([
95
- "edit",
96
95
  "update",
97
96
  "patch",
98
97
  "delete",
@@ -117,7 +116,7 @@ function isUnreadWrite(op, readNames) {
117
116
  /**
118
117
  * Drop mutating ops whose target was not read this session, in place.
119
118
  *
120
- * Covers the same mutating surface Hermes guards (edit/patch/write_file/remove_file), so a
119
+ * Covers the same mutating surface Hermes guards (update/patch/write_file/remove_file), so a
121
120
  * background review cannot blind-touch support files or edits of skills it never loaded.
122
121
  * @param ops - the plan's ops; dropped entries are removed in place.
123
122
  * @param readNames - names read this session.
package/lib/skills.js CHANGED
@@ -1,14 +1,113 @@
1
1
  import { _ as probeMtime, b as probeText, c as transactIo, d as isAbsent, g as probeList, h as probeAbsent, i as isCommittedWarning, m as isUnknown, o as nodeEvolutionIo, p as isPresent, t as TransactionNotInvokedError, v as probePresent, x as probeUnknown, y as probeReason } from "./io-GxghO3Ip.js";
2
2
  import { n as mutationLockFrom } from "./mutation-authority-DQfpXs1O.js";
3
3
  import { o as resolveCitations } from "./citations-CZKTUGQF.js";
4
- import { G as SKILL_NAME_RE, H as PROTECTED_BUILTIN_SKILLS, K as SUPPORT_DIRS, a as DEFAULT_SUPPORT_FILE_CHAR_POLICY, i as DEFAULT_SKILL_LIMITS, n as DEFAULT_CITATION_POLICY, o as POLICY_STAGE_DEFAULTS, r as DEFAULT_REFERENCE_REWRITE_POLICY, s as policyStageLimits, t as DEFAULT_ARCHIVE_RETENTION_POLICY, u as CONTENT_SPLIT_HINT } from "./limits-C9jfvxBl.js";
5
- import { C as trimPatternBoundaries, I as RULES, J as filterUnreadSkillOps, L as diffFindings, O as appendEvolutionEvent, R as lintSkill, S as fuzzyPatch, X as sessionReadSkillNames, Y as isUnreadWrite, Z as sessionReadSupportFiles, a as lintBody, et as authorityFrom, g as scanContentThreats, i as assessStructureHealth, k as eventsFile, n as HEALTH_STAMP_RE, o as currentReviewContext, q as READ_REQUIRED_ACTIONS, r as MIN_STAMP_BODY_CHARS, t as DEFAULT_HEALTH_THRESHOLDS, u as isReviewChannelSession, y as makeSerialQueue } from "./skill-health-BQCM4N8z.js";
6
- import { A as authoringFeedback, B as validateFrontmatter, E as selectSections, F as normalizeFrontmatter, G as describeReferenceRewrite, I as parseFrontmatter, K as planReferenceRewrite, L as relatedSkillNames, M as exceedsContentLimit, N as frontmatterBlock, P as frontmatterCatalogInvalid, R as shrinksOverLimit, S as suppressedFile, U as supportRefs, V as yamlPlainScalarNeedsQuotes, W as applyReferenceRewrite, f as getRecord, g as loadUsage, j as ensureSkillFrontmatter, q as planRehoming, v as mutateUsage, w as usageFile, z as skillMdOnDisk } from "./usage-B5a90TKv.js";
4
+ import { G as SKILL_NAME_RE, H as PROTECTED_BUILTIN_SKILLS, K as SUPPORT_DIRS, a as DEFAULT_SUPPORT_FILE_CHAR_POLICY, i as DEFAULT_SKILL_LIMITS, n as DEFAULT_CITATION_POLICY, o as POLICY_STAGE_DEFAULTS, r as DEFAULT_REFERENCE_REWRITE_POLICY, s as policyStageLimits, t as DEFAULT_ARCHIVE_RETENTION_POLICY, u as CONTENT_SPLIT_HINT } from "./limits-TD4Pv92Q.js";
5
+ import { C as trimPatternBoundaries, I as RULES, J as filterUnreadSkillOps, L as diffFindings, O as appendEvolutionEvent, R as lintSkill, S as fuzzyPatch, X as sessionReadSkillNames, Y as isUnreadWrite, Z as sessionReadSupportFiles, a as lintBody, et as authorityFrom, g as scanContentThreats, i as assessStructureHealth, k as eventsFile, n as HEALTH_STAMP_RE, o as currentReviewContext, q as READ_REQUIRED_ACTIONS, r as MIN_STAMP_BODY_CHARS, t as DEFAULT_HEALTH_THRESHOLDS, u as isReviewChannelSession, y as makeSerialQueue } from "./skill-health-BIpiPvw6.js";
6
+ import { B as shrinksOverLimit, E as usageFile, F as frontmatterBlock, G as supportRefs, H as validateFrontmatter, I as frontmatterCatalogInvalid, J as planReferenceRewrite, K as applyReferenceRewrite, L as normalizeFrontmatter, M as authoringFeedback, N as ensureSkillFrontmatter, O as selectSections, P as exceedsContentLimit, R as parseFrontmatter, U as yamlPlainScalarNeedsQuotes, V as skillMdOnDisk, Y as planRehoming, _ as loadUsage, p as getRecord, q as describeReferenceRewrite, w as suppressedFile, y as mutateUsage, z as relatedSkillNames } from "./usage-B1qveKi9.js";
7
7
  import { n as evolutionRoot } from "./state-store-Jpa-iYIZ.js";
8
8
  import { i as loadMutations, o as recordMutation, r as contentHash } from "./mutations-DQXddSJd.js";
9
9
  import { A as pruneTreeChangeUnits, C as partitionVersions, D as textDiffFacts, E as summaryChars, M as unitSnapshotPort, O as versionActionKind, S as parseHistoryIndex, T as recordVersions, _ as loadVersionContent, a as RETENTION_FEEDBACK_KEEP_RATIO, b as normalizeChangeSummary, c as TEXT_DIFF_MAX_LINES, d as contentRetentionFeedback, f as elapsedSince, g as latestVersionAt, h as historyRoot, i as HISTORY_INDEX_VERSION, j as unitJournalPort, k as versionTarget, l as blobPath, m as historyIndexFile, n as DEFAULT_SKILL_WRITE_SUMMARY_CHARS, nt as fileMutationLock, o as RETENTION_FEEDBACK_MIN_CHARS, p as entryTarget, r as HISTORY_DIR, s as TEXT_DIFF_MAX_CHARS, t as BASELINE_ACTION, tt as MutationUnit, u as clipChangeSummary, v as loadVersions, w as readHistoryIndex, x as orderVersions, y as nextHistoryIndex } from "./skill-history-CZp8vhyL.js";
10
- import { n as projectExtractBodies } from "./extract-plan-D6o__2Kf.js";
10
+ import { n as projectExtractBodies } from "./extract-plan-D4zO7dmD.js";
11
11
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
12
+ //#region lib/types/skill-stats.js
13
+ /**
14
+ * Skill statistics: the read-only domain model shared by the host projection and the browser table.
15
+ *
16
+ * WHY THIS FILE EXISTS: the panel used to carry a probe response, raw health rows, a serialized
17
+ * usage map and a feedback score map as separate ad-hoc shapes. A table needs one row model and one
18
+ * sorting/totals rule; putting it here keeps that rule out of React and out of the HTTP handler.
19
+ *
20
+ * Null semantics are part of the contract: `null` means "not measured / service absent"; `0` means
21
+ * "measured as zero". A sorter or formatter must never collapse the two.
22
+ *
23
+ * @module @lmzhen/dsh-evolution-core
24
+ */
25
+ /** A verdict that asks the user to act; `healthy` and `unknown` do not. */
26
+ function needsAttention(row) {
27
+ const verdict = row.health?.verdict;
28
+ return verdict === "warn" || verdict === "needs-restructure";
29
+ }
30
+ /** Severity order for the status column: actionable first, healthy last. */
31
+ function verdictRank(verdict) {
32
+ if (verdict === null || verdict === void 0 || verdict === "") return null;
33
+ if (verdict === "needs-restructure") return 0;
34
+ if (verdict === "warn") return 1;
35
+ if (verdict === "unknown") return 2;
36
+ if (verdict === "healthy") return 3;
37
+ return 4;
38
+ }
39
+ /** Stable name comparison shared by every tie-break. */
40
+ function compareNames(left, right) {
41
+ return left.localeCompare(right, "zh-Hans", {
42
+ numeric: true,
43
+ sensitivity: "base"
44
+ });
45
+ }
46
+ /** A row's value for one sortable column, or null when that fact was not measured. */
47
+ function sortValue(row, key) {
48
+ switch (key) {
49
+ case "name": return row.name;
50
+ case "verdict": return verdictRank(row.health?.verdict);
51
+ case "bodyChars": return row.health?.bodyChars ?? null;
52
+ case "supportFiles": return row.health?.supportFiles ?? null;
53
+ case "versions": return row.versions;
54
+ case "useCount": return row.usage?.useCount ?? null;
55
+ case "viewCount": return row.usage?.viewCount ?? null;
56
+ case "viewCount30d": return row.usage?.viewCount30d ?? null;
57
+ case "feedback": return row.feedback;
58
+ case "feedback30d": return row.feedback30d;
59
+ case "negativeFeedback30d": return row.negativeFeedback30d;
60
+ case "feedbackRate30d": return row.feedbackRate30d;
61
+ case "lastAt": return row.lastAt === null ? null : Date.parse(row.lastAt);
62
+ }
63
+ }
64
+ /**
65
+ * Compare two rows for one column. Nulls always sort last regardless of direction; equal values
66
+ * fall back to the stable name order so pagination-free tables never reshuffle on re-render.
67
+ */
68
+ function compareSkillStats(left, right, key, direction) {
69
+ const a = sortValue(left, key);
70
+ const b = sortValue(right, key);
71
+ const nameCmp = compareNames(left.name, right.name);
72
+ if (a === null && b === null) return nameCmp;
73
+ if (a === null) return 1;
74
+ if (b === null) return -1;
75
+ const cmp = typeof a === "number" && typeof b === "number" ? a - b : compareNames(String(a), String(b));
76
+ if (cmp === 0) return nameCmp;
77
+ return direction === "asc" ? cmp : -cmp;
78
+ }
79
+ /** Return a sorted copy; the snapshot itself is never mutated. */
80
+ function sortSkillStats(rows, key, direction) {
81
+ return [...rows].sort((left, right) => compareSkillStats(left, right, key, direction));
82
+ }
83
+ /** Keep only rows matching the header filter. */
84
+ function filterSkillStats(rows, filter) {
85
+ if (filter === "all") return [...rows];
86
+ if (filter === "attention") return rows.filter(needsAttention);
87
+ return rows.filter((row) => row.lastAt !== null);
88
+ }
89
+ /** Sum a nullable numeric column: all-null means the total itself is unknown, not zero. */
90
+ function sumNullable(values) {
91
+ let seen = false;
92
+ let total = 0;
93
+ for (const value of values) {
94
+ if (value === null) continue;
95
+ seen = true;
96
+ total += value;
97
+ }
98
+ return seen ? total : null;
99
+ }
100
+ /** Compute the strip totals from the already-merged rows. */
101
+ function computeSkillStatsTotals(rows, counts) {
102
+ return {
103
+ skills: rows.length,
104
+ needsAttention: rows.filter(needsAttention).length,
105
+ bodyChars: sumNullable(rows.map((row) => row.health?.bodyChars ?? null)),
106
+ supportFiles: sumNullable(rows.map((row) => row.health?.supportFiles ?? null)),
107
+ successes: counts
108
+ };
109
+ }
110
+ //#endregion
12
111
  //#region lib/types/skill-row-cells.js
13
112
  /**
14
113
  * The cells one row shows, decided here and rendered by the client.
@@ -122,6 +221,12 @@ function versionRowCells(row) {
122
221
  tone: "secondary",
123
222
  slot: "lead"
124
223
  });
224
+ else if (row.summarySource === void 0) meta.push({
225
+ key: "summary.legacy",
226
+ copy: "row.summary.legacy",
227
+ tone: "tertiary",
228
+ slot: "lead"
229
+ });
125
230
  return {
126
231
  title,
127
232
  meta
@@ -4169,4 +4274,4 @@ function newSkillLibrary(options) {
4169
4274
  } : void 0, transact, [...threatExemptLabels ?? []], authority, options.mutationLock ?? mutationLockFrom(ctx), options.fence ?? ctx?.get?.("evolutionMutationAuthority")?.homeFence);
4170
4275
  }
4171
4276
  //#endregion
4172
- export { BASELINE_ACTION, DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_CITATION_POLICY, DEFAULT_HEALTH_THRESHOLDS, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_WRITE_SUMMARY_CHARS, DEFAULT_SUPPORT_FILE_CHAR_POLICY, HEALTH_STAMP_RE, HISTORY_DIR, HISTORY_INDEX_VERSION, MAX_RESTRUCTURE_MOVES, MIN_STAMP_BODY_CHARS, POLICY_STAGE_DEFAULTS, READ_REQUIRED_ACTIONS, RESTRUCTURE_TARGET_RE, RETENTION_FEEDBACK_KEEP_RATIO, RETENTION_FEEDBACK_MIN_CHARS, RULES, SNAPSHOT_EXTRA_NAME_RE, SkillLibrary, SkillModel, TEXT_DIFF_MAX_CHARS, TEXT_DIFF_MAX_LINES, ageCopyKey, anchorVerdict, assertSkillsRootAliasRetired, assessStructureHealth, authoringFeedback, blobPath, clipChangeSummary, contentRetentionFeedback, diffFindings, elapsedSince, ensureSkillFrontmatter, entryTarget, exceedsContentLimit, filterUnreadSkillOps, frontmatterBlock, frontmatterCatalogInvalid, historyIndexFile, historyRoot, isUnreadWrite, latestVersionAt, lintBody, lintSkill, loadVersionContent, loadVersions, markerEntryName, newSkillLibrary, nextHistoryIndex, normalizeChangeSummary, normalizeFrontmatter, orderVersions, parseFrontmatter, parseHistoryIndex, partitionVersions, policyStageLimits, readHistoryIndex, recordVersions, relatedSkillNames, resolveExecOrigins, resolveOrigins, resolveRootConfig, resolveSkillsRoot, revisionAnchor, revisionAnchorOf, revisionFingerprint, revisionSupportDigest, sessionReadSkillNames, sessionReadSupportFiles, shrinksOverLimit, skillMdOnDisk, skillRowCells, skillStateKey, skillsRoot, summaryChars, textDiffFacts, validateFrontmatter, validateRestructureTarget, validateSupportPath, versionActionKind, versionRowCells, versionTarget, yamlPlainScalarNeedsQuotes };
4277
+ export { BASELINE_ACTION, DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_CITATION_POLICY, DEFAULT_HEALTH_THRESHOLDS, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_WRITE_SUMMARY_CHARS, DEFAULT_SUPPORT_FILE_CHAR_POLICY, HEALTH_STAMP_RE, HISTORY_DIR, HISTORY_INDEX_VERSION, MAX_RESTRUCTURE_MOVES, MIN_STAMP_BODY_CHARS, POLICY_STAGE_DEFAULTS, READ_REQUIRED_ACTIONS, RESTRUCTURE_TARGET_RE, RETENTION_FEEDBACK_KEEP_RATIO, RETENTION_FEEDBACK_MIN_CHARS, RULES, SNAPSHOT_EXTRA_NAME_RE, SkillLibrary, SkillModel, TEXT_DIFF_MAX_CHARS, TEXT_DIFF_MAX_LINES, ageCopyKey, anchorVerdict, assertSkillsRootAliasRetired, assessStructureHealth, authoringFeedback, blobPath, clipChangeSummary, compareSkillStats, computeSkillStatsTotals, contentRetentionFeedback, diffFindings, elapsedSince, ensureSkillFrontmatter, entryTarget, exceedsContentLimit, filterSkillStats, filterUnreadSkillOps, frontmatterBlock, frontmatterCatalogInvalid, historyIndexFile, historyRoot, isUnreadWrite, latestVersionAt, lintBody, lintSkill, loadVersionContent, loadVersions, markerEntryName, needsAttention, newSkillLibrary, nextHistoryIndex, normalizeChangeSummary, normalizeFrontmatter, orderVersions, parseFrontmatter, parseHistoryIndex, partitionVersions, policyStageLimits, readHistoryIndex, recordVersions, relatedSkillNames, resolveExecOrigins, resolveOrigins, resolveRootConfig, resolveSkillsRoot, revisionAnchor, revisionAnchorOf, revisionFingerprint, revisionSupportDigest, sessionReadSkillNames, sessionReadSupportFiles, shrinksOverLimit, skillMdOnDisk, skillRowCells, skillStateKey, skillsRoot, sortSkillStats, sortValue, summaryChars, textDiffFacts, validateFrontmatter, validateRestructureTarget, validateSupportPath, verdictRank, versionActionKind, versionRowCells, versionTarget, yamlPlainScalarNeedsQuotes };
@@ -37,7 +37,6 @@
37
37
  */
38
38
  export const SKILL_ACTION_REQUIRED_FIELDS = {
39
39
  create: ['name', 'content'],
40
- edit: ['name', 'content'],
41
40
  update: ['name', 'content'],
42
41
  patch: ['name', 'old_string', 'new_string'],
43
42
  delete: ['name'],
@@ -50,6 +50,7 @@ export declare const HOST_ROUTES: {
50
50
  readonly body: "/api/dsh-evolution/skill-history/versions/body";
51
51
  readonly undo: "/api/dsh-evolution/skill-history/undo";
52
52
  readonly health: "/api/dsh-evolution/skill-history/health";
53
+ readonly stats: "/api/dsh-evolution/skill-history/stats";
53
54
  };
54
55
  readonly skillHealth: {
55
56
  readonly rows: "/api/dsh-evolution/skill-health/rows";
@@ -48,6 +48,7 @@ export const HOST_ROUTES = {
48
48
  body: '/api/dsh-evolution/skill-history/versions/body',
49
49
  undo: '/api/dsh-evolution/skill-history/undo',
50
50
  health: '/api/dsh-evolution/skill-history/health',
51
+ stats: '/api/dsh-evolution/skill-history/stats',
51
52
  },
52
53
  skillHealth: {
53
54
  rows: '/api/dsh-evolution/skill-health/rows',
@@ -93,7 +93,7 @@ export declare function isUnreadWrite(op: {
93
93
  /**
94
94
  * Drop mutating ops whose target was not read this session, in place.
95
95
  *
96
- * Covers the same mutating surface Hermes guards (edit/patch/write_file/remove_file), so a
96
+ * Covers the same mutating surface Hermes guards (update/patch/write_file/remove_file), so a
97
97
  * background review cannot blind-touch support files or edits of skills it never loaded.
98
98
  * @param ops - the plan's ops; dropped entries are removed in place.
99
99
  * @param readNames - names read this session.
@@ -66,7 +66,7 @@ export function sessionReadSupportFiles(ctx, session, options) {
66
66
  }
67
67
  /** Actions whose target must have been read first (create is authorship, so it is exempt). */
68
68
  export const READ_REQUIRED_ACTIONS = Object.freeze([
69
- 'edit', 'update', 'patch', 'delete', 'write_file', 'remove_file', 'restructure', 'extract',
69
+ 'update', 'patch', 'delete', 'write_file', 'remove_file', 'restructure', 'extract',
70
70
  ]);
71
71
  /**
72
72
  * Does this one op write a skill the caller never read?
@@ -85,7 +85,7 @@ export function isUnreadWrite(op, readNames) {
85
85
  /**
86
86
  * Drop mutating ops whose target was not read this session, in place.
87
87
  *
88
- * Covers the same mutating surface Hermes guards (edit/patch/write_file/remove_file), so a
88
+ * Covers the same mutating surface Hermes guards (update/patch/write_file/remove_file), so a
89
89
  * background review cannot blind-touch support files or edits of skills it never loaded.
90
90
  * @param ops - the plan's ops; dropped entries are removed in place.
91
91
  * @param readNames - names read this session.
@@ -57,6 +57,8 @@ export interface VersionRowFacts {
57
57
  readonly charsDelta?: number;
58
58
  readonly path?: string;
59
59
  readonly summary?: string;
60
+ /** Where the summary came from; absent on entries recorded before summaries existed. */
61
+ readonly summarySource?: 'model' | 'host' | 'fallback';
60
62
  /** U-5: the body hash the host recorded for this version (the row shows a short code, hover = full). */
61
63
  readonly hash?: string;
62
64
  }
@@ -88,6 +88,11 @@ export function versionRowCells(row) {
88
88
  if (row.summary !== undefined && row.summary !== '') {
89
89
  meta.push({ key: 'summary', literal: row.summary, tone: 'secondary', slot: 'lead' });
90
90
  }
91
+ else if (row.summarySource === undefined) {
92
+ // Entries recorded before summaries existed carry neither a summary nor a source. Say so
93
+ // explicitly instead of rendering an empty second line or pretending the write had no reason.
94
+ meta.push({ key: 'summary.legacy', copy: 'row.summary.legacy', tone: 'tertiary', slot: 'lead' });
95
+ }
91
96
  return { title, meta };
92
97
  }
93
98
  /**
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Skill statistics: the read-only domain model shared by the host projection and the browser table.
3
+ *
4
+ * WHY THIS FILE EXISTS: the panel used to carry a probe response, raw health rows, a serialized
5
+ * usage map and a feedback score map as separate ad-hoc shapes. A table needs one row model and one
6
+ * sorting/totals rule; putting it here keeps that rule out of React and out of the HTTP handler.
7
+ *
8
+ * Null semantics are part of the contract: `null` means "not measured / service absent"; `0` means
9
+ * "measured as zero". A sorter or formatter must never collapse the two.
10
+ *
11
+ * @module @lmzhen/dsh-evolution-core
12
+ */
13
+ /** One health dimension the aggregate view exposes for a skill. */
14
+ export interface SkillHealthFacts {
15
+ readonly verdict: string;
16
+ readonly bodyChars: number | null;
17
+ readonly bodyTokens: number | null;
18
+ readonly supportFiles: number | null;
19
+ readonly stampDensityPerKb: number | null;
20
+ readonly churnPatches: number | null;
21
+ readonly churnReads: number | null;
22
+ readonly hardCapHits: number | null;
23
+ readonly findings: number;
24
+ }
25
+ /** One bounded negative-report explanation shown in the skill page's report history. */
26
+ export interface SkillErrorNote {
27
+ readonly at: string;
28
+ readonly note: string;
29
+ }
30
+ /** One usage fact set; every field stays null when the usage store did not answer for this skill. */
31
+ export interface SkillUsageFacts {
32
+ readonly useCount: number | null;
33
+ readonly viewCount: number | null;
34
+ /** Loads inside the last 30 days; null when the record predates per-day buckets. */
35
+ readonly viewCount30d: number | null;
36
+ readonly patchCount: number | null;
37
+ readonly lastUsedAt: string | null;
38
+ readonly lastViewedAt: string | null;
39
+ readonly lastPatchedAt: string | null;
40
+ readonly state: string | null;
41
+ readonly pinned: boolean | null;
42
+ }
43
+ /** One row of the full skill table. */
44
+ export interface SkillStatsRow {
45
+ readonly name: string;
46
+ readonly description: string;
47
+ readonly versions: number;
48
+ /** Last content change, or null when the skill has no recorded versions. */
49
+ readonly lastAt: string | null;
50
+ readonly health: SkillHealthFacts | null;
51
+ readonly usage: SkillUsageFacts | null;
52
+ readonly feedback: number | null;
53
+ /** Feedback events inside the last 30 days; null means the rolling window was not measured. */
54
+ readonly feedback30d: number | null;
55
+ /** Negative feedback events inside the last 30 days; the rate denominator is loads. */
56
+ readonly negativeFeedback30d: number | null;
57
+ /** negativeFeedback30d / loads30d; null when loads30d is null or zero (no denominator). */
58
+ readonly feedbackRate30d: number | null;
59
+ /** Negative-report notes in the window, newest first; null when the window was not measured. */
60
+ readonly errorNotes: readonly SkillErrorNote[] | null;
61
+ }
62
+ /** Successful operation counts, as the panel's aggregate read reports them. */
63
+ export interface SkillStatsCounts {
64
+ readonly offload: number;
65
+ readonly condense: number;
66
+ readonly extract: number;
67
+ }
68
+ /** Totals the table strip shows; a null total means at least one contributing row was unmeasured. */
69
+ export interface SkillStatsTotals {
70
+ readonly skills: number;
71
+ readonly needsAttention: number;
72
+ readonly bodyChars: number | null;
73
+ readonly supportFiles: number | null;
74
+ readonly successes: SkillStatsCounts | null;
75
+ }
76
+ /** One recent governance run, as the aggregate read reports it. */
77
+ export interface SkillStatsGovernance {
78
+ readonly runId: string;
79
+ readonly state: string;
80
+ readonly startedAt: number;
81
+ readonly target: string | null;
82
+ readonly mode: string | null;
83
+ readonly resultRef: string | null;
84
+ }
85
+ /** One complete read of the skill library, as the host route returns it. */
86
+ export interface SkillStatsSnapshot {
87
+ readonly rows: readonly SkillStatsRow[];
88
+ readonly totals: SkillStatsTotals;
89
+ readonly counts: SkillStatsCounts | null;
90
+ readonly governance: readonly SkillStatsGovernance[];
91
+ readonly generatedAt: string;
92
+ }
93
+ /** Sortable columns the table exposes. */
94
+ export type SkillStatsSortKey = 'name' | 'verdict' | 'bodyChars' | 'supportFiles' | 'versions' | 'useCount' | 'viewCount' | 'viewCount30d' | 'feedback' | 'feedback30d' | 'negativeFeedback30d' | 'feedbackRate30d' | 'lastAt';
95
+ export type SortDirection = 'asc' | 'desc';
96
+ /** Filter chips in the table header. */
97
+ export type SkillStatsFilter = 'all' | 'attention' | 'recent';
98
+ /** A verdict that asks the user to act; `healthy` and `unknown` do not. */
99
+ export declare function needsAttention(row: SkillStatsRow): boolean;
100
+ /** Severity order for the status column: actionable first, healthy last. */
101
+ export declare function verdictRank(verdict: string | null | undefined): number | null;
102
+ /** A row's value for one sortable column, or null when that fact was not measured. */
103
+ export declare function sortValue(row: SkillStatsRow, key: SkillStatsSortKey): string | number | null;
104
+ /**
105
+ * Compare two rows for one column. Nulls always sort last regardless of direction; equal values
106
+ * fall back to the stable name order so pagination-free tables never reshuffle on re-render.
107
+ */
108
+ export declare function compareSkillStats(left: SkillStatsRow, right: SkillStatsRow, key: SkillStatsSortKey, direction: SortDirection): number;
109
+ /** Return a sorted copy; the snapshot itself is never mutated. */
110
+ export declare function sortSkillStats(rows: readonly SkillStatsRow[], key: SkillStatsSortKey, direction: SortDirection): SkillStatsRow[];
111
+ /** Keep only rows matching the header filter. */
112
+ export declare function filterSkillStats(rows: readonly SkillStatsRow[], filter: SkillStatsFilter): SkillStatsRow[];
113
+ /** Compute the strip totals from the already-merged rows. */
114
+ export declare function computeSkillStatsTotals(rows: readonly SkillStatsRow[], counts: SkillStatsCounts | null): SkillStatsTotals;
115
+ //# sourceMappingURL=skill-stats.d.ts.map
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Skill statistics: the read-only domain model shared by the host projection and the browser table.
3
+ *
4
+ * WHY THIS FILE EXISTS: the panel used to carry a probe response, raw health rows, a serialized
5
+ * usage map and a feedback score map as separate ad-hoc shapes. A table needs one row model and one
6
+ * sorting/totals rule; putting it here keeps that rule out of React and out of the HTTP handler.
7
+ *
8
+ * Null semantics are part of the contract: `null` means "not measured / service absent"; `0` means
9
+ * "measured as zero". A sorter or formatter must never collapse the two.
10
+ *
11
+ * @module @lmzhen/dsh-evolution-core
12
+ */
13
+ /** A verdict that asks the user to act; `healthy` and `unknown` do not. */
14
+ export function needsAttention(row) {
15
+ const verdict = row.health?.verdict;
16
+ return verdict === 'warn' || verdict === 'needs-restructure';
17
+ }
18
+ /** Severity order for the status column: actionable first, healthy last. */
19
+ export function verdictRank(verdict) {
20
+ if (verdict === null || verdict === undefined || verdict === '')
21
+ return null;
22
+ if (verdict === 'needs-restructure')
23
+ return 0;
24
+ if (verdict === 'warn')
25
+ return 1;
26
+ if (verdict === 'unknown')
27
+ return 2;
28
+ if (verdict === 'healthy')
29
+ return 3;
30
+ return 4;
31
+ }
32
+ /** Stable name comparison shared by every tie-break. */
33
+ function compareNames(left, right) {
34
+ return left.localeCompare(right, 'zh-Hans', { numeric: true, sensitivity: 'base' });
35
+ }
36
+ /** A row's value for one sortable column, or null when that fact was not measured. */
37
+ export function sortValue(row, key) {
38
+ switch (key) {
39
+ case 'name': return row.name;
40
+ case 'verdict': return verdictRank(row.health?.verdict);
41
+ case 'bodyChars': return row.health?.bodyChars ?? null;
42
+ case 'supportFiles': return row.health?.supportFiles ?? null;
43
+ case 'versions': return row.versions;
44
+ case 'useCount': return row.usage?.useCount ?? null;
45
+ case 'viewCount': return row.usage?.viewCount ?? null;
46
+ case 'viewCount30d': return row.usage?.viewCount30d ?? null;
47
+ case 'feedback': return row.feedback;
48
+ case 'feedback30d': return row.feedback30d;
49
+ case 'negativeFeedback30d': return row.negativeFeedback30d;
50
+ case 'feedbackRate30d': return row.feedbackRate30d;
51
+ case 'lastAt': return row.lastAt === null ? null : Date.parse(row.lastAt);
52
+ }
53
+ }
54
+ /**
55
+ * Compare two rows for one column. Nulls always sort last regardless of direction; equal values
56
+ * fall back to the stable name order so pagination-free tables never reshuffle on re-render.
57
+ */
58
+ export function compareSkillStats(left, right, key, direction) {
59
+ const a = sortValue(left, key);
60
+ const b = sortValue(right, key);
61
+ const nameCmp = compareNames(left.name, right.name);
62
+ if (a === null && b === null)
63
+ return nameCmp;
64
+ if (a === null)
65
+ return 1;
66
+ if (b === null)
67
+ return -1;
68
+ const cmp = typeof a === 'number' && typeof b === 'number'
69
+ ? a - b
70
+ : compareNames(String(a), String(b));
71
+ if (cmp === 0)
72
+ return nameCmp;
73
+ return direction === 'asc' ? cmp : -cmp;
74
+ }
75
+ /** Return a sorted copy; the snapshot itself is never mutated. */
76
+ export function sortSkillStats(rows, key, direction) {
77
+ return [...rows].sort((left, right) => compareSkillStats(left, right, key, direction));
78
+ }
79
+ /** Keep only rows matching the header filter. */
80
+ export function filterSkillStats(rows, filter) {
81
+ if (filter === 'all')
82
+ return [...rows];
83
+ if (filter === 'attention')
84
+ return rows.filter(needsAttention);
85
+ return rows.filter(row => row.lastAt !== null);
86
+ }
87
+ /** Sum a nullable numeric column: all-null means the total itself is unknown, not zero. */
88
+ function sumNullable(values) {
89
+ let seen = false;
90
+ let total = 0;
91
+ for (const value of values) {
92
+ if (value === null)
93
+ continue;
94
+ seen = true;
95
+ total += value;
96
+ }
97
+ return seen ? total : null;
98
+ }
99
+ /** Compute the strip totals from the already-merged rows. */
100
+ export function computeSkillStatsTotals(rows, counts) {
101
+ return {
102
+ skills: rows.length,
103
+ needsAttention: rows.filter(needsAttention).length,
104
+ bodyChars: sumNullable(rows.map(row => row.health?.bodyChars ?? null)),
105
+ supportFiles: sumNullable(rows.map(row => row.health?.supportFiles ?? null)),
106
+ successes: counts,
107
+ };
108
+ }
109
+ //# sourceMappingURL=skill-stats.js.map
@@ -1,6 +1,7 @@
1
1
  /** Skill-domain surface. Consumers import it from the documented subpath. */
2
2
  export * from './skill-lint.ts';
3
3
  export * from './skill-health.ts';
4
+ export * from './skill-stats.ts';
4
5
  export * from './skill-reads.ts';
5
6
  export * from './skill-row-cells.ts';
6
7
  export * from './skill-history.ts';
@@ -1,6 +1,7 @@
1
1
  /** Skill-domain surface. Consumers import it from the documented subpath. */
2
2
  export * from "./skill-lint.js";
3
3
  export * from "./skill-health.js";
4
+ export * from "./skill-stats.js";
4
5
  export * from "./skill-reads.js";
5
6
  export * from "./skill-row-cells.js";
6
7
  export * from "./skill-history.js";
@@ -33,6 +33,9 @@ export interface UsageRecord {
33
33
  * record written before this field existed, and on skills whose support
34
34
  * files were never read — absence means "no evidence", never "zero demand". */
35
35
  support_reads?: Record<string, number> | undefined;
36
+ /** Per-day load buckets (`YYYY-MM-DD` → count) for the rolling window. Absent on every record
37
+ * written before this field existed: absence means "window not measured", never "zero loads". */
38
+ view_days?: Record<string, number> | undefined;
36
39
  }
37
40
  export type UsageMap = Map<string, UsageRecord>;
38
41
  export declare function usageFile(root: string): string;
@@ -49,6 +52,8 @@ export declare function emptyRecord(): UsageRecord;
49
52
  * Pure — exported for unit tests; `loadUsage` is the production caller.
50
53
  */
51
54
  export declare function normalizeUsageRecord(record: unknown): UsageRecord;
55
+ /** Rolling load buckets: keep enough days for the 30-day view plus one grace month. */
56
+ export declare const VIEW_WINDOW_DAYS = 60;
52
57
  /** Sidecar bound: a pathological path set must not grow the usage file forever. */
53
58
  export declare const MAX_SUPPORT_READ_PATHS = 200;
54
59
  export declare function loadUsage(root: string, io?: EvolutionIoLike): Promise<UsageMap>;
@@ -109,6 +114,14 @@ export declare function foldCuratorFields(disk: UsageMap, curated: UsageMap, sta
109
114
  export declare function saveUsage(root: string, map: UsageMap, io?: EvolutionIoLike): Promise<void>;
110
115
  export declare function getRecord(map: UsageMap, name: string): UsageRecord;
111
116
  export declare function bumpView(map: UsageMap, name: string, when?: Date): void;
117
+ /**
118
+ * Loads inside the rolling window, or null when the record predates per-day buckets.
119
+ * @param record - one usage record.
120
+ * @param days - window length in days (default 30).
121
+ * @param now - reference instant (default now).
122
+ * @returns the summed buckets, or null when this record has no bucket evidence.
123
+ */
124
+ export declare function recentViewCount(record: UsageRecord, days?: number, now?: Date): number | null;
112
125
  export declare function bumpUse(map: UsageMap, name: string, when?: Date): void;
113
126
  export declare function bumpPatch(map: UsageMap, name: string, when?: Date): void;
114
127
  /** Count one observed support-file read (design §5.5). The map is created on
@@ -21,6 +21,9 @@ export function emptyRecord() {
21
21
  state: 'active',
22
22
  pinned: false,
23
23
  archived_at: null,
24
+ // A record CREATED by this runtime is a measured empty window; a legacy record normalized
25
+ // without the field stays undefined (unknown, not zero).
26
+ view_days: {},
24
27
  };
25
28
  }
26
29
  /** A timestamp passes only when `Date.parse` yields a finite epoch (N-3): a bare
@@ -78,8 +81,47 @@ export function normalizeUsageRecord(record) {
78
81
  feedback_score: typeof raw.feedback_score === 'number' && Number.isFinite(raw.feedback_score) ? raw.feedback_score : undefined,
79
82
  feedback_warn: typeof raw.feedback_warn === 'boolean' ? raw.feedback_warn : undefined,
80
83
  support_reads: normalizeSupportReads(raw.support_reads),
84
+ view_days: normalizeViewDays(raw.view_days),
81
85
  };
82
86
  }
87
+ /** Rolling load buckets: keep enough days for the 30-day view plus one grace month. */
88
+ export const VIEW_WINDOW_DAYS = 60;
89
+ const DAY_KEY = /^\d{4}-\d{2}-\d{2}$/;
90
+ /** Sanitize per-day load buckets; an absent field stays unmeasured, a present empty object is measured zero. */
91
+ function normalizeViewDays(value) {
92
+ if (value === undefined || value === null || typeof value !== 'object' || Array.isArray(value))
93
+ return undefined;
94
+ const entries = Object.entries(value);
95
+ // A present empty object is the explicit "record created, window measured, zero loads" state.
96
+ if (entries.length === 0)
97
+ return {};
98
+ // Retain the newest 60 buckets, not the first 60 insertion-ordered ones.
99
+ entries.sort((a, b) => b[0].localeCompare(a[0]));
100
+ const out = {};
101
+ for (const [key, count] of entries) {
102
+ if (Object.keys(out).length >= VIEW_WINDOW_DAYS)
103
+ break;
104
+ if (!DAY_KEY.test(key))
105
+ continue;
106
+ if (typeof count !== 'number' || !Number.isInteger(count) || count < 0)
107
+ continue;
108
+ out[key] = count;
109
+ }
110
+ return Object.keys(out).length === 0 ? undefined : out;
111
+ }
112
+ /** Day key in UTC; the bucket is a bounded rolling window, not a calendar report. */
113
+ function dayKey(at) {
114
+ return at.toISOString().slice(0, 10);
115
+ }
116
+ function pruneViewDays(days, now) {
117
+ const cutoff = new Date(now.getTime() - VIEW_WINDOW_DAYS * 86_400_000).toISOString().slice(0, 10);
118
+ const out = {};
119
+ for (const [key, count] of Object.entries(days)) {
120
+ if (key >= cutoff)
121
+ out[key] = count;
122
+ }
123
+ return out;
124
+ }
83
125
  /** Sidecar bound: a pathological path set must not grow the usage file forever. */
84
126
  export const MAX_SUPPORT_READ_PATHS = 200;
85
127
  /** Sanitize the per-support-file read counts: non-negative finite numbers under
@@ -307,6 +349,28 @@ export function bumpView(map, name, when = new Date()) {
307
349
  const record = getRecord(map, name);
308
350
  record.view_count += 1;
309
351
  record.last_viewed_at = when.toISOString();
352
+ const key = dayKey(when);
353
+ const days = record.view_days ?? {};
354
+ days[key] = (days[key] ?? 0) + 1;
355
+ record.view_days = pruneViewDays(days, when);
356
+ }
357
+ /**
358
+ * Loads inside the rolling window, or null when the record predates per-day buckets.
359
+ * @param record - one usage record.
360
+ * @param days - window length in days (default 30).
361
+ * @param now - reference instant (default now).
362
+ * @returns the summed buckets, or null when this record has no bucket evidence.
363
+ */
364
+ export function recentViewCount(record, days = 30, now = new Date()) {
365
+ if (record.view_days === undefined)
366
+ return null;
367
+ const cutoff = new Date(now.getTime() - days * 86_400_000).toISOString().slice(0, 10);
368
+ let total = 0;
369
+ for (const [key, count] of Object.entries(record.view_days)) {
370
+ if (key >= cutoff)
371
+ total += count;
372
+ }
373
+ return total;
310
374
  }
311
375
  export function bumpUse(map, name, when = new Date()) {
312
376
  const record = getRecord(map, name);
@@ -1,6 +1,6 @@
1
1
  import { c as transactIo, o as nodeEvolutionIo } from "./io-GxghO3Ip.js";
2
2
  import { o as resolveCitations } from "./citations-CZKTUGQF.js";
3
- import { G as SKILL_NAME_RE, i as DEFAULT_SKILL_LIMITS, u as CONTENT_SPLIT_HINT } from "./limits-C9jfvxBl.js";
3
+ import { G as SKILL_NAME_RE, i as DEFAULT_SKILL_LIMITS, u as CONTENT_SPLIT_HINT } from "./limits-TD4Pv92Q.js";
4
4
  import { n as isRecord } from "./guards-3f02mnf2.js";
5
5
  import { join } from "node:path";
6
6
  import { parse } from "yaml";
@@ -907,7 +907,8 @@ function emptyRecord() {
907
907
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
908
908
  state: "active",
909
909
  pinned: false,
910
- archived_at: null
910
+ archived_at: null,
911
+ view_days: {}
911
912
  };
912
913
  }
913
914
  /** A timestamp passes only when `Date.parse` yields a finite epoch (N-3): a bare
@@ -949,9 +950,38 @@ function normalizeUsageRecord(record) {
949
950
  quality_warn: typeof raw.quality_warn === "boolean" ? raw.quality_warn : void 0,
950
951
  feedback_score: typeof raw.feedback_score === "number" && Number.isFinite(raw.feedback_score) ? raw.feedback_score : void 0,
951
952
  feedback_warn: typeof raw.feedback_warn === "boolean" ? raw.feedback_warn : void 0,
952
- support_reads: normalizeSupportReads(raw.support_reads)
953
+ support_reads: normalizeSupportReads(raw.support_reads),
954
+ view_days: normalizeViewDays(raw.view_days)
953
955
  };
954
956
  }
957
+ /** Rolling load buckets: keep enough days for the 30-day view plus one grace month. */
958
+ const VIEW_WINDOW_DAYS = 60;
959
+ const DAY_KEY = /^\d{4}-\d{2}-\d{2}$/;
960
+ /** Sanitize per-day load buckets; an absent field stays unmeasured, a present empty object is measured zero. */
961
+ function normalizeViewDays(value) {
962
+ if (value === void 0 || value === null || typeof value !== "object" || Array.isArray(value)) return void 0;
963
+ const entries = Object.entries(value);
964
+ if (entries.length === 0) return {};
965
+ entries.sort((a, b) => b[0].localeCompare(a[0]));
966
+ const out = {};
967
+ for (const [key, count] of entries) {
968
+ if (Object.keys(out).length >= 60) break;
969
+ if (!DAY_KEY.test(key)) continue;
970
+ if (typeof count !== "number" || !Number.isInteger(count) || count < 0) continue;
971
+ out[key] = count;
972
+ }
973
+ return Object.keys(out).length === 0 ? void 0 : out;
974
+ }
975
+ /** Day key in UTC; the bucket is a bounded rolling window, not a calendar report. */
976
+ function dayKey(at) {
977
+ return at.toISOString().slice(0, 10);
978
+ }
979
+ function pruneViewDays(days, now) {
980
+ const cutoff = (/* @__PURE__ */ new Date(now.getTime() - 60 * 864e5)).toISOString().slice(0, 10);
981
+ const out = {};
982
+ for (const [key, count] of Object.entries(days)) if (key >= cutoff) out[key] = count;
983
+ return out;
984
+ }
955
985
  /** Sidecar bound: a pathological path set must not grow the usage file forever. */
956
986
  const MAX_SUPPORT_READ_PATHS = 200;
957
987
  /** Sanitize the per-support-file read counts: non-negative finite numbers under
@@ -1113,6 +1143,24 @@ function bumpView(map, name, when = /* @__PURE__ */ new Date()) {
1113
1143
  const record = getRecord(map, name);
1114
1144
  record.view_count += 1;
1115
1145
  record.last_viewed_at = when.toISOString();
1146
+ const key = dayKey(when);
1147
+ const days = record.view_days ?? {};
1148
+ days[key] = (days[key] ?? 0) + 1;
1149
+ record.view_days = pruneViewDays(days, when);
1150
+ }
1151
+ /**
1152
+ * Loads inside the rolling window, or null when the record predates per-day buckets.
1153
+ * @param record - one usage record.
1154
+ * @param days - window length in days (default 30).
1155
+ * @param now - reference instant (default now).
1156
+ * @returns the summed buckets, or null when this record has no bucket evidence.
1157
+ */
1158
+ function recentViewCount(record, days = 30, now = /* @__PURE__ */ new Date()) {
1159
+ if (record.view_days === void 0) return null;
1160
+ const cutoff = (/* @__PURE__ */ new Date(now.getTime() - days * 864e5)).toISOString().slice(0, 10);
1161
+ let total = 0;
1162
+ for (const [key, count] of Object.entries(record.view_days)) if (key >= cutoff) total += count;
1163
+ return total;
1116
1164
  }
1117
1165
  function bumpUse(map, name, when = /* @__PURE__ */ new Date()) {
1118
1166
  const record = getRecord(map, name);
@@ -1254,4 +1302,4 @@ async function updateSuppressedNames(root, io, task) {
1254
1302
  });
1255
1303
  }
1256
1304
  //#endregion
1257
- export { authoringFeedback as A, validateFrontmatter as B, updateSuppressedNames as C, displayBodyOf as D, selectSections as E, normalizeFrontmatter as F, describeReferenceRewrite as G, externalRefs as H, parseFrontmatter as I, planReferenceRewrite as K, relatedSkillNames as L, exceedsContentLimit as M, frontmatterBlock as N, h2Sections as O, frontmatterCatalogInvalid as P, shrinksOverLimit as R, suppressedFile as S, usageObserved as T, supportRefs as U, yamlPlainScalarNeedsQuotes as V, applyReferenceRewrite as W, markAgentCreated as _, bumpPatch as a, saveSuppressedNames as b, bumpView as c, foldCuratorFields as d, getRecord as f, loadUsage as g, loadSuppressedNames as h, applyCuratorMetaFields as i, ensureSkillFrontmatter as j, readingStats as k, daysSinceIso as l, latestActivityAt as m, SUPPRESSED_FILE_VERSION as n, bumpSupportRead as o, idleDays as p, planRehoming as q, applyCuratorLifecycleFields as r, bumpUse as s, MAX_SUPPORT_READ_PATHS as t, emptyRecord as u, mutateUsage as v, usageFile as w, saveUsage as x, normalizeUsageRecord as y, skillMdOnDisk as z };
1305
+ export { h2Sections as A, shrinksOverLimit as B, saveUsage as C, usageObserved as D, usageFile as E, frontmatterBlock as F, supportRefs as G, validateFrontmatter as H, frontmatterCatalogInvalid as I, planReferenceRewrite as J, applyReferenceRewrite as K, normalizeFrontmatter as L, authoringFeedback as M, ensureSkillFrontmatter as N, selectSections as O, exceedsContentLimit as P, parseFrontmatter as R, saveSuppressedNames as S, updateSuppressedNames as T, yamlPlainScalarNeedsQuotes as U, skillMdOnDisk as V, externalRefs as W, planRehoming as Y, loadUsage as _, applyCuratorMetaFields as a, normalizeUsageRecord as b, bumpUse as c, emptyRecord as d, foldCuratorFields as f, loadSuppressedNames as g, latestActivityAt as h, applyCuratorLifecycleFields as i, readingStats as j, displayBodyOf as k, bumpView as l, idleDays as m, SUPPRESSED_FILE_VERSION as n, bumpPatch as o, getRecord as p, describeReferenceRewrite as q, VIEW_WINDOW_DAYS as r, bumpSupportRead as s, MAX_SUPPORT_READ_PATHS as t, daysSinceIso as u, markAgentCreated as v, suppressedFile as w, recentViewCount as x, mutateUsage as y, relatedSkillNames as z };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-core",
3
3
  "description": "Shared stores, prompts, signals and lifecycle logic for the dsh-evolution plugin family (community build)",
4
- "version": "0.51.0",
4
+ "version": "0.52.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },