@lmzhen/dsh-evolution-core 0.3.22 → 0.3.24
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/README.md +1 -0
- package/lib/index.js +46 -4
- package/lib/types/index.d.ts +1 -0
- package/lib/types/numeric.d.ts +38 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -2532,9 +2532,9 @@ const SECRET_PATTERNS = [
|
|
|
2532
2532
|
["gitlab token", /glpat-[A-Za-z0-9_-]{16,}/g],
|
|
2533
2533
|
["slack token", /xox[baprs]-[A-Za-z0-9-]{10,}/g],
|
|
2534
2534
|
["jwt", /eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g],
|
|
2535
|
-
["bearer credential", /Bearer
|
|
2535
|
+
["bearer credential", /Bearer[\s]+[a-z0-9._~+/=\-]{16,}/gi]
|
|
2536
2536
|
];
|
|
2537
|
-
const INLINE_ASSIGNMENT_PATTERN =
|
|
2537
|
+
const INLINE_ASSIGNMENT_PATTERN = /* @__PURE__ */ new RegExp("((?:\\b|[\\w-]+[_\\-])(?:token|api[_-]?key|secret|password|passwd)(?:[_\\-][\\w-]+)?\\b[\\s]*[:=][\\s]*[\"']?)([A-Z0-9._~+/=\\-]{12,})", "gi");
|
|
2538
2538
|
/**
|
|
2539
2539
|
* Mask credential-shaped text before it crosses a session boundary.
|
|
2540
2540
|
* @param text - the text about to be sent to a model outside this session.
|
|
@@ -2663,7 +2663,7 @@ function advanceReview(state, turn, signal, config) {
|
|
|
2663
2663
|
state.lastTurn = turn;
|
|
2664
2664
|
signal.substantive = signal.toolCalls >= config.substantiveMinToolCalls || signal.userChars >= config.substantiveMinUserChars || signal.assistantChars >= config.substantiveMinAgentChars;
|
|
2665
2665
|
if (!signal.substantive) return null;
|
|
2666
|
-
state.turnsSinceMemory += signal.memorySignal ? 1 :
|
|
2666
|
+
state.turnsSinceMemory += signal.memorySignal ? 1 : Math.max(1, signal.toolCalls);
|
|
2667
2667
|
state.turnsSinceSkill += signal.skillSignal ? 1 : Math.max(1, signal.toolCalls);
|
|
2668
2668
|
const memoryDue = state.turnsSinceMemory >= config.memoryInterval;
|
|
2669
2669
|
const skillDue = state.turnsSinceSkill >= config.skillInterval;
|
|
@@ -4642,4 +4642,46 @@ function evolutionHome(env = process.env) {
|
|
|
4642
4642
|
return join(evolutionRoot(env), "evolution");
|
|
4643
4643
|
}
|
|
4644
4644
|
//#endregion
|
|
4645
|
-
|
|
4645
|
+
//#region lib/types/numeric.js
|
|
4646
|
+
/**
|
|
4647
|
+
* Numeric config clamping for the dsh-evolution plugin family.
|
|
4648
|
+
*
|
|
4649
|
+
* G3.1 (0.3.23): numeric configuration values are normalised through a single
|
|
4650
|
+
* helper so 0 / negative / NaN / ±Infinity / out-of-range all fall back to the
|
|
4651
|
+
* package default instead of silently becoming a "disabled" special value or
|
|
4652
|
+
* folding as NaN into a computation. A non-finite value (NaN, ±Infinity) is
|
|
4653
|
+
* never a legitimate config, so it always falls back. The schema layer (a
|
|
4654
|
+
* `.min(1)` clamp on the number schema) is a first-line guard where it can
|
|
4655
|
+
* reject invalid values; this helper is the mandatory assembly-time clamp that
|
|
4656
|
+
* also catches what schemastery lets through (NaN and +Infinity both pass a
|
|
4657
|
+
* bare number schema).
|
|
4658
|
+
*
|
|
4659
|
+
* The scope here is pure numeric conversion only (no schemastery import), so
|
|
4660
|
+
* evolution-core stays free of a schemastery dependency. Per-package Config
|
|
4661
|
+
* schemas keep their own `.min()`/`.default()` call sites.
|
|
4662
|
+
* @module @lmzhen/dsh-evolution-core
|
|
4663
|
+
*/
|
|
4664
|
+
/**
|
|
4665
|
+
* Clamp a numeric config to the `[min, max]` range.
|
|
4666
|
+
*
|
|
4667
|
+
* A non-finite value (NaN, ±Infinity), a non-number, or a value outside the
|
|
4668
|
+
* inclusive range falls back to `fallback`. When `opts.min >= 1`, 0 and
|
|
4669
|
+
* negative values also fall back to `fallback` — a 0 is never treated as a
|
|
4670
|
+
* special "disabled" meaning (G3.1 decision). Callers that legitimately allow
|
|
4671
|
+
* 0 (e.g. a threshold or a zero-cost weight) pass `{ min: 0 }` or omit the
|
|
4672
|
+
* range.
|
|
4673
|
+
*
|
|
4674
|
+
* @param value - the raw numeric config, possibly `undefined` (absent).
|
|
4675
|
+
* @param fallback - the default value to return when the value is invalid.
|
|
4676
|
+
* @param opts - optional inclusive lower/upper bound.
|
|
4677
|
+
* @returns `value` when it is a finite number within range, else `fallback`.
|
|
4678
|
+
*/
|
|
4679
|
+
function clampedNumber(value, fallback, opts) {
|
|
4680
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
|
|
4681
|
+
const { min, max } = opts ?? {};
|
|
4682
|
+
if (min !== void 0 && value < min) return fallback;
|
|
4683
|
+
if (max !== void 0 && value > max) return fallback;
|
|
4684
|
+
return value;
|
|
4685
|
+
}
|
|
4686
|
+
//#endregion
|
|
4687
|
+
export { AUTHORING_DESCRIPTION_BAR, COMBINED_REVIEW_PLAN_PROMPT, COMBINED_REVIEW_PROMPT, COMPLETION_SKILL_REVIEW_PROMPT, CURATOR_DRY_RUN_BANNER, CURATOR_PROMPT, DEFAULT_ARCHIVE_AFTER_DAYS, DEFAULT_CONSOLIDATION_FAILURES, DEFAULT_CURATOR_INTERVAL_HOURS, DEFAULT_HEALTH_THRESHOLDS, DEFAULT_MAX_OPS_PER_PLAN, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_MIN_IDLE_HOURS, DEFAULT_MUTATION_CAP, DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, DEFAULT_SKILL_REVIEW_TRIGGER, DEFAULT_STALE_AFTER_DAYS, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, DEFAULT_USER_CHAR_LIMIT, 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_WRITE_TOOLS, EvolutionGateSet, FORBIDDEN_CONTROL_KEYS, HEALTH_STAMP_RE, LOW_QUALITY_THRESHOLD, MAINTAIN_PROMPT, MAX_DESCRIPTION_LENGTH, MAX_RESTRUCTURE_MOVES, MAX_SKILL_CONTENT_CHARS, MAX_SKILL_FILE_BYTES, MAX_SKILL_NAME_LENGTH, MEMORY_REVIEW_PROMPT, MIN_STAMP_BODY_CHARS, MUTATIONS_FILE_VERSION, MemoryStore, PROMPT_BUNDLE, PROMPT_BUNDLE_ID, PROMPT_BUNDLE_VERSION, PROTECTED_BUILTIN_SKILLS, QUALITY_WEIGHTS, RESTRUCTURE_TARGET_RE, SKILLS_GUIDANCE, SKILL_NAME_RE, SKILL_REVIEW_PLAN_PROMPT, SKILL_REVIEW_PROMPT, SNAPSHOT_EXTRA_NAME_RE, SUPPORT_DIRS, SUPPRESSED_FILE_VERSION, SkillLibrary, advanceReview, appendEvolutionEvent, applyCuratorFields, applyCuratorLifecycleFields, applyCuratorMetaFields, assessStructureHealth, authoringFeedback, buildCuratorRunReport, buildLearnPrompt, bumpPatch, bumpUse, bumpView, clampedNumber, composePresetComposition, computeDedupGroups, computeDriftSignals, computeLifecycleTransitions, computePrefixClusters, computeQualityScores, computeScopeView, contentHash, createGateSet, duplicateHeadings, emptyRecord, evaluateThreat, eventsFile, evolutionHome, evolutionIoAdapter, evolutionRoot, findDriftSignal, foldCuratorFields, foldTurn, frontmatterBlock, frontmatterYamlUnsafeValues, getRecord, latestActivityAt, lifecycleCandidate, listEventArchives, loadMutations, loadSuppressedNames, loadUsage, makeSerialQueue, markAgentCreated, memoryRoot, missingSupportPointers, mutateUsage, mutationsFile, narrowNameMatches, nodeEvolutionIo, normalizeFrontmatter, normalizeUsageRecord, observeEvent, overlongLines, parseCuratorNominations, parseEvolutionEvents, parseFrontmatter, readEvolutionEvents, readEvolutionTimeline, recordMutation, redactSecrets, relatedSkillNames, renameWithRetry, renderCuratorReportMarkdown, resolveOrigins, resolveSkillsRoot, retainEventArchives, reviewPrompt, saveSuppressedNames, saveUsage, scanContentThreats, scanMemoryThreats, scanThreats, skillsRoot, suppressedFile, transactIo, updateSuppressedNames, usageFile, usageObserved, validateFrontmatter, verifyPromptBundle, yamlPlainScalarNeedsQuotes };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Numeric config clamping for the dsh-evolution plugin family.
|
|
3
|
+
*
|
|
4
|
+
* G3.1 (0.3.23): numeric configuration values are normalised through a single
|
|
5
|
+
* helper so 0 / negative / NaN / ±Infinity / out-of-range all fall back to the
|
|
6
|
+
* package default instead of silently becoming a "disabled" special value or
|
|
7
|
+
* folding as NaN into a computation. A non-finite value (NaN, ±Infinity) is
|
|
8
|
+
* never a legitimate config, so it always falls back. The schema layer (a
|
|
9
|
+
* `.min(1)` clamp on the number schema) is a first-line guard where it can
|
|
10
|
+
* reject invalid values; this helper is the mandatory assembly-time clamp that
|
|
11
|
+
* also catches what schemastery lets through (NaN and +Infinity both pass a
|
|
12
|
+
* bare number schema).
|
|
13
|
+
*
|
|
14
|
+
* The scope here is pure numeric conversion only (no schemastery import), so
|
|
15
|
+
* evolution-core stays free of a schemastery dependency. Per-package Config
|
|
16
|
+
* schemas keep their own `.min()`/`.default()` call sites.
|
|
17
|
+
* @module @lmzhen/dsh-evolution-core
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Clamp a numeric config to the `[min, max]` range.
|
|
21
|
+
*
|
|
22
|
+
* A non-finite value (NaN, ±Infinity), a non-number, or a value outside the
|
|
23
|
+
* inclusive range falls back to `fallback`. When `opts.min >= 1`, 0 and
|
|
24
|
+
* negative values also fall back to `fallback` — a 0 is never treated as a
|
|
25
|
+
* special "disabled" meaning (G3.1 decision). Callers that legitimately allow
|
|
26
|
+
* 0 (e.g. a threshold or a zero-cost weight) pass `{ min: 0 }` or omit the
|
|
27
|
+
* range.
|
|
28
|
+
*
|
|
29
|
+
* @param value - the raw numeric config, possibly `undefined` (absent).
|
|
30
|
+
* @param fallback - the default value to return when the value is invalid.
|
|
31
|
+
* @param opts - optional inclusive lower/upper bound.
|
|
32
|
+
* @returns `value` when it is a finite number within range, else `fallback`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function clampedNumber(value: number | undefined, fallback: number, opts?: {
|
|
35
|
+
min?: number;
|
|
36
|
+
max?: number;
|
|
37
|
+
}): number;
|
|
38
|
+
//# sourceMappingURL=numeric.d.ts.map
|
package/package.json
CHANGED