@theglitchking/semantic-memory 1.6.0 → 1.7.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.
Files changed (149) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +90 -0
  4. package/LICENSES/Apache-2.0.txt +202 -0
  5. package/README.md +49 -29
  6. package/THIRD_PARTY_NOTICES.md +17 -0
  7. package/commands/jev-mode.md +18 -0
  8. package/commands/skill-loop.md +23 -0
  9. package/dist/{chunk-7PNF3AP2.js → chunk-34VN47IW.js} +2 -2
  10. package/dist/chunk-3FPUBAEW.js +113 -0
  11. package/dist/chunk-3FPUBAEW.js.map +1 -0
  12. package/dist/{chunk-WZEKIUYG.js → chunk-6TIKWOY4.js} +10 -8
  13. package/dist/{chunk-WZEKIUYG.js.map → chunk-6TIKWOY4.js.map} +1 -1
  14. package/dist/{chunk-NBY4TRP7.js → chunk-7M34JDTH.js} +3 -3
  15. package/dist/{chunk-FTRXH2WC.js → chunk-7UAVDOI6.js} +15 -12
  16. package/dist/chunk-7UAVDOI6.js.map +1 -0
  17. package/dist/{chunk-BBP3DG2U.js → chunk-AIXQFTSB.js} +25 -26
  18. package/dist/{chunk-BBP3DG2U.js.map → chunk-AIXQFTSB.js.map} +1 -1
  19. package/dist/chunk-BEACL25M.js +224 -0
  20. package/dist/chunk-BEACL25M.js.map +1 -0
  21. package/dist/chunk-CATPGINC.js +186 -0
  22. package/dist/chunk-CATPGINC.js.map +1 -0
  23. package/dist/{chunk-IGHCVAAL.js → chunk-CJUY55GG.js} +6 -3
  24. package/dist/{chunk-IGHCVAAL.js.map → chunk-CJUY55GG.js.map} +1 -1
  25. package/dist/chunk-DBFD3MTT.js +130 -0
  26. package/dist/chunk-DBFD3MTT.js.map +1 -0
  27. package/dist/{chunk-XAXK7NM4.js → chunk-EXAUVIGW.js} +9 -7
  28. package/dist/{chunk-XAXK7NM4.js.map → chunk-EXAUVIGW.js.map} +1 -1
  29. package/dist/{chunk-LGQPP5FQ.js → chunk-EYVFC745.js} +2 -2
  30. package/dist/chunk-GYR7U6KA.js +80 -0
  31. package/dist/chunk-GYR7U6KA.js.map +1 -0
  32. package/dist/{chunk-OEF5U5GV.js → chunk-H2BES6FU.js} +10 -2
  33. package/dist/{chunk-OEF5U5GV.js.map → chunk-H2BES6FU.js.map} +1 -1
  34. package/dist/chunk-IEZVFKUT.js +157 -0
  35. package/dist/chunk-IEZVFKUT.js.map +1 -0
  36. package/dist/chunk-J7LYDRML.js +9 -0
  37. package/dist/chunk-J7LYDRML.js.map +1 -0
  38. package/dist/chunk-MQS7JEBD.js +137 -0
  39. package/dist/chunk-MQS7JEBD.js.map +1 -0
  40. package/dist/chunk-NCGM36NX.js +118 -0
  41. package/dist/chunk-NCGM36NX.js.map +1 -0
  42. package/dist/chunk-NIZLBNH4.js +165 -0
  43. package/dist/chunk-NIZLBNH4.js.map +1 -0
  44. package/dist/chunk-OT3MV7XF.js +123 -0
  45. package/dist/chunk-OT3MV7XF.js.map +1 -0
  46. package/dist/chunk-P3GLY42T.js +291 -0
  47. package/dist/chunk-P3GLY42T.js.map +1 -0
  48. package/dist/chunk-PJXYCCI2.js +177 -0
  49. package/dist/chunk-PJXYCCI2.js.map +1 -0
  50. package/dist/chunk-R6GNP7DS.js +87 -0
  51. package/dist/chunk-R6GNP7DS.js.map +1 -0
  52. package/dist/{chunk-44BQDRXD.js → chunk-SHSOCFJH.js} +4 -1
  53. package/dist/chunk-SHSOCFJH.js.map +1 -0
  54. package/dist/chunk-TKHWVISV.js +71 -0
  55. package/dist/chunk-TKHWVISV.js.map +1 -0
  56. package/dist/{chunk-CAX46XLY.js → chunk-VBLCUWT4.js} +23 -12
  57. package/dist/chunk-VBLCUWT4.js.map +1 -0
  58. package/dist/chunk-VQCNWRTL.js +121 -0
  59. package/dist/chunk-VQCNWRTL.js.map +1 -0
  60. package/dist/{chunk-SX427M2R.js → chunk-XKGK643R.js} +2 -2
  61. package/dist/{chunk-FURCIJBO.js → chunk-Y7H76Q7F.js} +6 -3
  62. package/dist/chunk-Y7H76Q7F.js.map +1 -0
  63. package/dist/chunk-ZSWI3Y4Y.js +232 -0
  64. package/dist/chunk-ZSWI3Y4Y.js.map +1 -0
  65. package/dist/cli/index.js +389 -60
  66. package/dist/cli/index.js.map +1 -1
  67. package/dist/core/features.d.ts +38 -0
  68. package/dist/core/features.js +28 -0
  69. package/dist/core/index.d.ts +285 -2
  70. package/dist/core/index.js +170 -20
  71. package/dist/core/index.js.map +1 -1
  72. package/dist/core/jev.d.ts +35 -0
  73. package/dist/core/jev.js +20 -0
  74. package/dist/core/redact.js +1 -1
  75. package/dist/core/skill-curator.d.ts +1 -0
  76. package/dist/core/skill-curator.js +41 -0
  77. package/dist/core/skill-evidence.d.ts +25 -0
  78. package/dist/core/skill-evidence.js +23 -0
  79. package/dist/core/skill-queue.d.ts +40 -0
  80. package/dist/core/skill-queue.js +38 -0
  81. package/dist/core/skill-review.d.ts +3 -0
  82. package/dist/core/skill-review.js +29 -0
  83. package/dist/core/skill-worker.d.ts +21 -0
  84. package/dist/core/skill-worker.js +70 -0
  85. package/dist/core/skill-worker.js.map +1 -0
  86. package/dist/{dossier-RWTIMGZN.js → dossier-RXBLQOXC.js} +5 -4
  87. package/dist/failure-eval-IUJO47UC.js +18 -0
  88. package/dist/healthcheck-S7D6YNTA.js +21 -0
  89. package/dist/indexer-RZPH2PVL.js +9 -0
  90. package/dist/{lexicon-IVNJTMWE.js → lexicon-SEJSLBHO.js} +6 -5
  91. package/dist/lexicon-SEJSLBHO.js.map +1 -0
  92. package/dist/lint-3JNLRM5U.js +18 -0
  93. package/dist/lint-3JNLRM5U.js.map +1 -0
  94. package/dist/log-RM2NDNPH.js +11 -0
  95. package/dist/log-RM2NDNPH.js.map +1 -0
  96. package/dist/matter-SNJ2WDL6.js +8 -0
  97. package/dist/matter-SNJ2WDL6.js.map +1 -0
  98. package/dist/mcp/server.js +43 -38
  99. package/dist/mcp/server.js.map +1 -1
  100. package/dist/{profile-UE4YVTDC.js → profile-SNULTJ27.js} +6 -5
  101. package/dist/profile-SNULTJ27.js.map +1 -0
  102. package/dist/{schema-LY6533NJ.js → schema-RDYUK6CC.js} +3 -2
  103. package/dist/schema-RDYUK6CC.js.map +1 -0
  104. package/dist/{search-MZC4DC7H.js → search-325ULY57.js} +4 -3
  105. package/dist/{search-MZC4DC7H.js.map → search-325ULY57.js.map} +1 -1
  106. package/dist/skill-curator-D7HHZaUI.d.ts +71 -0
  107. package/dist/skill-land-XU2APPBJ.js +31 -0
  108. package/dist/skill-land-XU2APPBJ.js.map +1 -0
  109. package/dist/skill-ledger-AYXVNFX7.js +18 -0
  110. package/dist/skill-ledger-AYXVNFX7.js.map +1 -0
  111. package/dist/skill-merge-GXBQLBZA.js +24 -0
  112. package/dist/skill-merge-GXBQLBZA.js.map +1 -0
  113. package/dist/skill-review-BaW5n0Zg.d.ts +179 -0
  114. package/dist/skill-schema-RVB3EHEF.js +30 -0
  115. package/dist/skill-schema-RVB3EHEF.js.map +1 -0
  116. package/dist/{telemetry-B4KP3UVE.js → telemetry-YAG3VA4Y.js} +4 -4
  117. package/dist/telemetry-YAG3VA4Y.js.map +1 -0
  118. package/docs/regression-snapshot.md +5 -5
  119. package/hooks/hooks.json +26 -1
  120. package/hooks/jev-bridge.py +109 -0
  121. package/hooks/session-start.js +5 -0
  122. package/hooks/skill-loop.js +65 -0
  123. package/hooks/vault-context.js +104 -6
  124. package/package.json +4 -2
  125. package/dist/chunk-44BQDRXD.js.map +0 -1
  126. package/dist/chunk-5F5ZIAW2.js +0 -79
  127. package/dist/chunk-5F5ZIAW2.js.map +0 -1
  128. package/dist/chunk-CAX46XLY.js.map +0 -1
  129. package/dist/chunk-FTRXH2WC.js.map +0 -1
  130. package/dist/chunk-FURCIJBO.js.map +0 -1
  131. package/dist/failure-eval-37JRNTIW.js +0 -10
  132. package/dist/healthcheck-3FSNL2U7.js +0 -20
  133. package/dist/indexer-RAKJ7JR3.js +0 -8
  134. package/dist/lint-36WTW762.js +0 -17
  135. package/dist/log-YIXF6CYM.js +0 -11
  136. /package/dist/{chunk-7PNF3AP2.js.map → chunk-34VN47IW.js.map} +0 -0
  137. /package/dist/{chunk-NBY4TRP7.js.map → chunk-7M34JDTH.js.map} +0 -0
  138. /package/dist/{chunk-LGQPP5FQ.js.map → chunk-EYVFC745.js.map} +0 -0
  139. /package/dist/{chunk-SX427M2R.js.map → chunk-XKGK643R.js.map} +0 -0
  140. /package/dist/{dossier-RWTIMGZN.js.map → core/features.js.map} +0 -0
  141. /package/dist/{failure-eval-37JRNTIW.js.map → core/jev.js.map} +0 -0
  142. /package/dist/{healthcheck-3FSNL2U7.js.map → core/skill-curator.js.map} +0 -0
  143. /package/dist/{indexer-RAKJ7JR3.js.map → core/skill-evidence.js.map} +0 -0
  144. /package/dist/{lexicon-IVNJTMWE.js.map → core/skill-queue.js.map} +0 -0
  145. /package/dist/{lint-36WTW762.js.map → core/skill-review.js.map} +0 -0
  146. /package/dist/{log-YIXF6CYM.js.map → dossier-RXBLQOXC.js.map} +0 -0
  147. /package/dist/{profile-UE4YVTDC.js.map → failure-eval-IUJO47UC.js.map} +0 -0
  148. /package/dist/{schema-LY6533NJ.js.map → healthcheck-S7D6YNTA.js.map} +0 -0
  149. /package/dist/{telemetry-B4KP3UVE.js.map → indexer-RZPH2PVL.js.map} +0 -0
@@ -0,0 +1,38 @@
1
+ type Feature = "skill_loop" | "jev";
2
+ interface FeatureState {
3
+ feature: Feature;
4
+ on: boolean;
5
+ /** Where the on/off came from. */
6
+ why: "default" | "env" | "repo";
7
+ /** jev only: whether jev-loop, the key and python are present. Always true for the skill loop. */
8
+ available: boolean;
9
+ /** Why it is unavailable, when it is on but cannot run. */
10
+ reason?: string;
11
+ }
12
+ declare const ENV: Record<Feature, string>;
13
+ declare const repoConfigPath: (projectRoot: string) => string;
14
+ /** `<repo>/.claude/.semantic-memory/config` as an object ({} when missing or unparseable). */
15
+ declare function readRepoConfig(projectRoot: string): Record<string, unknown>;
16
+ declare const jevLoopDir: (env?: NodeJS.ProcessEnv) => string;
17
+ declare const claudeSettingsPath: (env?: NodeJS.ProcessEnv) => string;
18
+ /** Whether jev mode could run: jev-loop's router, the TypeSafe key (env or settings, never read out), python3. */
19
+ declare function jevAvailable(env?: NodeJS.ProcessEnv): {
20
+ available: boolean;
21
+ reason?: string;
22
+ };
23
+ declare function featureState(feature: Feature, projectRoot?: string, env?: NodeJS.ProcessEnv): FeatureState;
24
+ /** On and able to run. The check every hook path makes first. */
25
+ declare const featureOn: (feature: Feature, projectRoot?: string, env?: NodeJS.ProcessEnv) => boolean;
26
+ /**
27
+ * Set (true / false) or clear (undefined) one env key in ~/.claude/settings.json, touching nothing else.
28
+ * Keeps a `.bak` of the previous file. Refuses (throws, writes nothing) when the file is not valid JSON.
29
+ */
30
+ declare function setSettingsEnv(key: string, value: string | undefined, env?: NodeJS.ProcessEnv): {
31
+ path: string;
32
+ backup?: string;
33
+ };
34
+ /** Set or clear `<key>: <value>` in the repo config, keeping the other keys. */
35
+ declare function setRepoConfig(projectRoot: string, key: string, value: string | boolean | undefined): string;
36
+ declare function describeFeature(s: FeatureState): string;
37
+
38
+ export { ENV, type Feature, type FeatureState, claudeSettingsPath, describeFeature, featureOn, featureState, jevAvailable, jevLoopDir, readRepoConfig, repoConfigPath, setRepoConfig, setSettingsEnv };
@@ -0,0 +1,28 @@
1
+ import {
2
+ ENV,
3
+ claudeSettingsPath,
4
+ describeFeature,
5
+ featureOn,
6
+ featureState,
7
+ jevAvailable,
8
+ jevLoopDir,
9
+ readRepoConfig,
10
+ repoConfigPath,
11
+ setRepoConfig,
12
+ setSettingsEnv
13
+ } from "../chunk-VQCNWRTL.js";
14
+ import "../chunk-PZ5AY32C.js";
15
+ export {
16
+ ENV,
17
+ claudeSettingsPath,
18
+ describeFeature,
19
+ featureOn,
20
+ featureState,
21
+ jevAvailable,
22
+ jevLoopDir,
23
+ readRepoConfig,
24
+ repoConfigPath,
25
+ setRepoConfig,
26
+ setSettingsEnv
27
+ };
28
+ //# sourceMappingURL=features.js.map
@@ -2,6 +2,14 @@ import Graph from 'graphology';
2
2
  import { EventEmitter } from 'node:events';
3
3
  export { REDACTED, RedactMode, RedactResult, redact, redactDeep } from './redact.js';
4
4
  export { commandVerbs, errorSignal, failureQuery } from './failure-query.js';
5
+ export { Feature, FeatureState, describeFeature, featureOn, featureState, jevAvailable } from './features.js';
6
+ import { P as ParsedSkill, D as DraftRecord, S as SkillLoopMeta } from '../skill-review-BaW5n0Zg.js';
7
+ export { a as SKILL_SCOPES, b as SKILL_SECTIONS, c as SKILL_STATUSES, d as SkillFile, e as SkillFinding, f as SkillScope, g as SkillStatus, h as buildBrief, i as decideScope, j as draftsDir, k as findSkills, l as lintSkill, m as lintSkills, n as listDrafts, p as parseSkill, r as renderSkill, o as reviewSession } from '../skill-review-BaW5n0Zg.js';
8
+ import { L as LedgerEntry } from '../skill-curator-D7HHZaUI.js';
9
+ export { c as curate, r as readLedger, a as restore, b as rollback, v as verifySkills } from '../skill-curator-D7HHZaUI.js';
10
+ export { JEV_BAR, JevAnswer, JevCaller, JevQuestion, askJev, failureState, jevSpendToday, jevVerdict, relevanceQuestion } from './jev.js';
11
+ import './skill-queue.js';
12
+ import './skill-worker.js';
5
13
 
6
14
  interface IndexedDocument {
7
15
  path: string;
@@ -261,7 +269,7 @@ interface VaultSchema {
261
269
  type Severity$1 = "warn" | "error";
262
270
  interface LintFinding {
263
271
  path: string;
264
- rule: "missing_provenance" | "stale" | "schema_violations" | "broken_links" | "code_symbols" | "decay_candidates" | "alias_conflicts" | "decoys" | "secrets";
272
+ rule: "missing_provenance" | "stale" | "schema_violations" | "broken_links" | "code_symbols" | "decay_candidates" | "alias_conflicts" | "decoys" | "secrets" | "skills";
265
273
  severity: Severity$1;
266
274
  message: string;
267
275
  }
@@ -543,6 +551,8 @@ interface LintReport {
543
551
  decoys: LintFinding[];
544
552
  /** only present when the opt-in secrets check ran */
545
553
  secrets?: LintFinding[];
554
+ /** only present when the opt-in skills check ran */
555
+ skills?: LintFinding[];
546
556
  };
547
557
  counts: {
548
558
  errors: number;
@@ -593,6 +603,8 @@ declare function lintVault(notesPath: string, opts?: {
593
603
  * git history if the note was ever committed.
594
604
  */
595
605
  checkSecrets?: boolean;
606
+ /** When true, lint the skill loop's learned skills this repo loads (v1.7): format, evidence, cites, clashes. Opt-in. */
607
+ checkSkills?: boolean;
596
608
  }): Promise<LintReport>;
597
609
  declare function formatLintReport(report: LintReport, opts?: {
598
610
  rule?: keyof LintReport["byRule"];
@@ -874,5 +886,276 @@ declare function evaluateFailures(results: CaseResult[], judgments: Judgment[],
874
886
  thresholds?: number[];
875
887
  }): FailureEvalReport;
876
888
  declare function formatFailureEval(report: FailureEvalReport, label?: string): string;
889
+ /** jev-loop's adoption bar: right >= 95% of the time over >= 40 picks, with at most 2 wrong. */
890
+ declare const meetsBar: (picks: number, wrong: number) => boolean;
891
+ interface JevJudgment {
892
+ case: string;
893
+ path: string;
894
+ p: number | null;
895
+ }
896
+ interface JudgeCalibration {
897
+ /** labelled pairs Jev answered */
898
+ pairs: number;
899
+ /** label relevant / not relevant: picks Jev made (>= bar yes, <= 1-bar no), how many disagree, unsure */
900
+ relevant: {
901
+ pairs: number;
902
+ yes: number;
903
+ no: number;
904
+ unsure: number;
905
+ };
906
+ notRelevant: {
907
+ pairs: number;
908
+ yes: number;
909
+ no: number;
910
+ unsure: number;
911
+ };
912
+ /** every pick (yes or no): agreement with the labels */
913
+ picks: number;
914
+ wrong: number;
915
+ agreement: number | null;
916
+ unsureRate: number;
917
+ /** yes picks alone (the side that would inject) */
918
+ yesPicks: number;
919
+ yesWrong: number;
920
+ /** no picks alone (the side that would filter) */
921
+ noPicks: number;
922
+ noWrong: number;
923
+ /**
924
+ * "jev": Jev alone may judge (its yes picks and its no picks each meet the bar);
925
+ * "hybrid": its no picks meet the bar — Jev filters, the rest (yes and unsure) go to Claude;
926
+ * "claude": neither side does.
927
+ */
928
+ verdict: "jev" | "hybrid" | "claude";
929
+ }
930
+ declare function calibrateJudge(labels: Judgment[], jev: JevJudgment[], bar?: number): JudgeCalibration;
931
+ interface GateRow {
932
+ threshold: number;
933
+ /** cases with a candidate fact (first fact in the top hits scoring >= threshold) */
934
+ candidates: number;
935
+ /** candidates Jev has not answered yet (ask, then re-run) */
936
+ missing: number;
937
+ /** candidates Jev said yes to at >= the bar: would be injected */
938
+ injected: number;
939
+ judged: number;
940
+ correct: number;
941
+ precision: number | null;
942
+ coverage: number;
943
+ meetsBar: boolean;
944
+ }
945
+ /**
946
+ * The failure hook's Jev gate, replayed: per threshold T, the candidate is the first fact among the top
947
+ * `topK` hits scoring >= T. `confirm` injects it only when Jev scores it >= the bar; `veto` injects it unless
948
+ * Jev scores it <= 1 - bar (a confident no). Precision is measured on the injected candidates that carry a label.
949
+ */
950
+ declare function evaluateGate(results: CaseResult[], judgments: Judgment[], jev: JevJudgment[], opts?: {
951
+ thresholds?: number[];
952
+ topK?: number;
953
+ bar?: number;
954
+ isCandidate?: (path: string) => boolean;
955
+ mode?: "confirm" | "veto";
956
+ }): {
957
+ rows: GateRow[];
958
+ missing: {
959
+ case: string;
960
+ path: string;
961
+ }[];
962
+ };
963
+ declare function formatGate(rows: GateRow[], mode?: "confirm" | "veto"): string;
964
+
965
+ /**
966
+ * Adoption gate for learned skills (v1.7): turns eval scores into adopt / keep-draft / reject. Pure — no I/O.
967
+ * A new skill must trigger on its own evidence, stay quiet on near-misses and beat doing the task without it;
968
+ * a patch must not make any score worse. A failing draft stays a draft with its scores.
969
+ */
970
+ /** A skill that fires on fewer than half its own held-out prompts is not findable. */
971
+ declare const GATE_MIN_POSITIVE_RATE = 0.5;
972
+ /** More than a quarter false triggers on near-misses means it would hijack unrelated work. */
973
+ declare const GATE_MAX_FALSE_TRIGGER_RATE = 0.25;
974
+ /** Held-out trigger rates and task pass rates, each 0..1 or null when not measured. */
975
+ interface SkillScores {
976
+ positiveRate: number | null;
977
+ falseTriggerRate: number | null;
978
+ taskWith: number | null;
979
+ taskWithout: number | null;
980
+ }
981
+ interface GateVerdict {
982
+ verdict: "adopt" | "keep-draft" | "reject";
983
+ reasons: string[];
984
+ }
985
+ declare function gateSkill(candidate: SkillScores, current?: SkillScores): GateVerdict;
986
+
987
+ interface CandidatePrompt {
988
+ session: string;
989
+ text: string;
990
+ }
991
+ interface EvalPrompt {
992
+ text: string;
993
+ should_trigger: boolean;
994
+ split: "train" | "heldout";
995
+ }
996
+ /** Same prompt, same side of the split, on every machine. */
997
+ declare const splitOf: (text: string) => EvalPrompt["split"];
998
+ declare function buildEvalSet(skill: ParsedSkill, candidates: CandidatePrompt[], opts?: {
999
+ maxNegatives?: number;
1000
+ }): EvalPrompt[];
1001
+
1002
+ type Verify = {
1003
+ kind: "command";
1004
+ command: string;
1005
+ } | {
1006
+ kind: "prose";
1007
+ text: string;
1008
+ } | {
1009
+ kind: "none";
1010
+ };
1011
+ /** The `## Verify` section as a command (fenced block, or a leading inline-backtick span) or as prose. */
1012
+ declare function parseVerify(body: string): Verify;
1013
+ interface TaskArm {
1014
+ passed: boolean;
1015
+ evidence: string;
1016
+ /** the run's final text */
1017
+ finalText: string;
1018
+ error?: string;
1019
+ }
1020
+ interface TaskReport {
1021
+ skill: string;
1022
+ verify: Verify;
1023
+ with: TaskArm;
1024
+ without: TaskArm;
1025
+ }
1026
+ interface TaskOptions {
1027
+ repoRoot: string;
1028
+ skillRaw: string;
1029
+ prompt: string;
1030
+ env?: NodeJS.ProcessEnv;
1031
+ maxTurns?: number;
1032
+ timeoutMs?: number;
1033
+ verifyTimeoutMs?: number;
1034
+ }
1035
+ declare function runTaskEval(o: TaskOptions): Promise<TaskReport>;
1036
+
1037
+ interface DraftView {
1038
+ id: string;
1039
+ kind: DraftRecord["kind"];
1040
+ name: string;
1041
+ scope: string;
1042
+ destination: string;
1043
+ scope_why?: string;
1044
+ provenance: SkillLoopMeta["provenance"] | null;
1045
+ warnings: string[];
1046
+ evals?: Record<string, unknown>;
1047
+ promotion?: DraftRecord["promotion"];
1048
+ global_candidate?: boolean;
1049
+ /** the Verify command a task eval would run, shown before anyone runs it */
1050
+ verify: ReturnType<typeof parseVerify>;
1051
+ text: string;
1052
+ diff?: string;
1053
+ }
1054
+ declare function describeDrafts(repo: string, env?: NodeJS.ProcessEnv): DraftView[];
1055
+ declare function approveDraft(repo: string, id: string, opts?: {
1056
+ promote?: boolean;
1057
+ override?: string;
1058
+ env?: NodeJS.ProcessEnv;
1059
+ }): LedgerEntry;
1060
+ declare function rejectDraft(repo: string, id: string, why?: string): LedgerEntry;
1061
+ /** Run the evals on a draft and store the scores and the gate's verdict in its record. */
1062
+ declare function evalDraft(repo: string, id: string, opts?: {
1063
+ task?: boolean;
1064
+ env?: NodeJS.ProcessEnv;
1065
+ }): Promise<{
1066
+ at: string;
1067
+ prompts: number;
1068
+ runs: number;
1069
+ heldout: Rates;
1070
+ train: Rates;
1071
+ task: unknown;
1072
+ gate: GateVerdict;
1073
+ }>;
1074
+
1075
+ declare function proposeMerges(repo: string, env?: NodeJS.ProcessEnv): Promise<{
1076
+ drafted: string[];
1077
+ skipped: string[];
1078
+ }>;
1079
+
1080
+ declare const MAX_TRIGGER_RUNS = 3;
1081
+ declare const evalCachePath: (env?: NodeJS.ProcessEnv) => string;
1082
+ interface PromptTrigger extends EvalPrompt {
1083
+ triggers: number;
1084
+ runs: number;
1085
+ /** a majority of the runs called the skill */
1086
+ triggered: boolean;
1087
+ cached: boolean;
1088
+ error?: string;
1089
+ }
1090
+ interface Rates {
1091
+ n: number;
1092
+ /** share of should-trigger prompts that triggered; null when there are none */
1093
+ positiveRate: number | null;
1094
+ /** share of near-miss prompts that triggered; null when there are none */
1095
+ falseTriggerRate: number | null;
1096
+ /** prompts that behaved as expected / n */
1097
+ accuracy: number | null;
1098
+ }
1099
+ interface TriggerReport {
1100
+ skill: string;
1101
+ results: PromptTrigger[];
1102
+ train: Rates;
1103
+ heldout: Rates;
1104
+ /** claude runs started (0 when everything was cached) */
1105
+ runs: number;
1106
+ }
1107
+ declare function ratesOf(rs: PromptTrigger[]): Rates;
1108
+ /** A scratch dir with the skill under test and copies of the repo's other project skills. The caller removes it. */
1109
+ declare function makeScratch(repoRoot: string, name: string, skillRaw: string): string;
1110
+ interface TriggerOptions {
1111
+ repoRoot: string;
1112
+ /** the skill file as it is on disk (or a candidate version of it) */
1113
+ skillRaw: string;
1114
+ env?: NodeJS.ProcessEnv;
1115
+ timeoutMs?: number;
1116
+ }
1117
+ declare function runTrigger(prompts: EvalPrompt[], o: TriggerOptions): Promise<TriggerReport>;
1118
+
1119
+ declare const MAX_TUNE_ITERATIONS = 3;
1120
+ interface TuneCandidate {
1121
+ description: string;
1122
+ train: number | null;
1123
+ heldout: number | null;
1124
+ }
1125
+ interface TuneReport {
1126
+ original: TuneCandidate;
1127
+ best: TuneCandidate;
1128
+ /** the best candidate is not the original */
1129
+ improved: boolean;
1130
+ candidates: TuneCandidate[];
1131
+ }
1132
+ /** The skill file with its frontmatter description replaced and nothing else changed. */
1133
+ declare function withDescription(raw: string, description: string): string;
1134
+ declare function tuneDescription(o: {
1135
+ repoRoot: string;
1136
+ skillRaw: string;
1137
+ prompts: EvalPrompt[];
1138
+ env?: NodeJS.ProcessEnv;
1139
+ maxIterations?: number;
1140
+ }): Promise<TuneReport>;
1141
+
1142
+ /**
1143
+ * Skill-creator's `evals/evals.json` (references/schemas.md), read and written as-is so evals made here
1144
+ * open in skill-creator and the other way round.
1145
+ */
1146
+ interface EvalCase {
1147
+ id: number;
1148
+ prompt: string;
1149
+ expected_output: string;
1150
+ /** input file paths, relative to the skill root */
1151
+ files?: string[];
1152
+ expectations: string[];
1153
+ }
1154
+ interface EvalsFile {
1155
+ skill_name: string;
1156
+ evals: EvalCase[];
1157
+ }
1158
+ declare function parseEvals(text: string): EvalsFile;
1159
+ declare const renderEvals: (f: EvalsFile) => string;
877
1160
 
878
- export { type ApplyPatchOptions, type ApplyPatchResult, type CaseResult, type ChangeSet, type DriftFinding, Embedder, type FailureCase, type FailureEvalReport, FrontmatterManager, GraphBuilder, type GraphEdge, type GraphNode, type HealthcheckOptions, type HealthcheckResult, type Severity as HealthcheckSeverity, type Tier as HealthcheckTier, INDEX_FILE, INDEX_OVERFLOW_THRESHOLD, type IndexEntry, type IndexedDocument, Indexer, type IngestInput, type IngestPreview, type IngestSource, type IngestUnit, type Judgment, type LintFinding, type LintReport, type LogEntry, type LogEventInput, type LogQueryOptions, type ModeSummary, NoteCrud, type PromoteInput, type PromotePreview, type RegenResult, type RegenerateContractOptions, type RegenerateContractResult, type SearchResult, type SessionFinishInput, SessionManager, type SessionStartOptions, type SessionState, type SessionStatus, type Severity$1 as Severity, type SynthesizeNoteInput, type SynthesizePreview, TagManager, TextSearch, type ThresholdRow, type ToolSummary, type VaultSchema, type VaultStats, VectorIndex, type VerificationRecord, Watcher, applyPatch, buildIngestChangeSet, buildPromoteChangeSet, buildSynthesizeChangeSet, deriveProjectRoot, deriveSessionDir, evaluateFailures, filterToDrift, formatDriftBanner, formatFailureEval, formatLintReport, inspectAgentsContract, installDefaultSchema, lintVault, loadSchema, logEvent, logQuery, regenDirectoryIndex, regenIndexesForPaths, regenerateAgentsContract, runHealthcheck, validateNote };
1161
+ export { type ApplyPatchOptions, type ApplyPatchResult, type CandidatePrompt, type CaseResult, type ChangeSet, DraftRecord, type DriftFinding, Embedder, type EvalCase, type EvalPrompt, type EvalsFile, type FailureCase, type FailureEvalReport, FrontmatterManager, GATE_MAX_FALSE_TRIGGER_RATE, GATE_MIN_POSITIVE_RATE, type GateRow, type GateVerdict, GraphBuilder, type GraphEdge, type GraphNode, type HealthcheckOptions, type HealthcheckResult, type Severity as HealthcheckSeverity, type Tier as HealthcheckTier, INDEX_FILE, INDEX_OVERFLOW_THRESHOLD, type IndexEntry, type IndexedDocument, Indexer, type IngestInput, type IngestPreview, type IngestSource, type IngestUnit, type JevJudgment, type JudgeCalibration, type Judgment, type LintFinding, type LintReport, type LogEntry, type LogEventInput, type LogQueryOptions, MAX_TRIGGER_RUNS, MAX_TUNE_ITERATIONS, type ModeSummary, NoteCrud, ParsedSkill, type PromoteInput, type PromotePreview, type PromptTrigger, type Rates, type RegenResult, type RegenerateContractOptions, type RegenerateContractResult, type SearchResult, type SessionFinishInput, SessionManager, type SessionStartOptions, type SessionState, type SessionStatus, type Severity$1 as Severity, SkillLoopMeta, type SkillScores, type SynthesizeNoteInput, type SynthesizePreview, TagManager, type TaskArm, type TaskOptions, type TaskReport, TextSearch, type ThresholdRow, type ToolSummary, type TriggerOptions, type TriggerReport, type TuneCandidate, type TuneReport, type VaultSchema, type VaultStats, VectorIndex, type VerificationRecord, type Verify, Watcher, applyPatch, approveDraft, buildEvalSet, buildIngestChangeSet, buildPromoteChangeSet, buildSynthesizeChangeSet, calibrateJudge, deriveProjectRoot, deriveSessionDir, describeDrafts, evalCachePath, evalDraft, evaluateFailures, evaluateGate, filterToDrift, formatDriftBanner, formatFailureEval, formatGate, formatLintReport, gateSkill, inspectAgentsContract, installDefaultSchema, lintVault, loadSchema, logEvent, logQuery, makeScratch, meetsBar, parseEvals, parseVerify, proposeMerges, ratesOf, regenDirectoryIndex, regenIndexesForPaths, regenerateAgentsContract, rejectDraft, renderEvals, runHealthcheck, runTaskEval, runTrigger, splitOf, tuneDescription, validateNote, withDescription };
@@ -1,17 +1,46 @@
1
+ import {
2
+ calibrateJudge,
3
+ evaluateFailures,
4
+ evaluateGate,
5
+ formatFailureEval,
6
+ formatGate,
7
+ meetsBar
8
+ } from "../chunk-PJXYCCI2.js";
9
+ import {
10
+ GATE_MAX_FALSE_TRIGGER_RATE,
11
+ GATE_MIN_POSITIVE_RATE,
12
+ approveDraft,
13
+ describeDrafts,
14
+ evalDraft,
15
+ gateSkill,
16
+ rejectDraft
17
+ } from "../chunk-BEACL25M.js";
18
+ import {
19
+ proposeMerges
20
+ } from "../chunk-NCGM36NX.js";
1
21
  import {
2
22
  filterToDrift,
3
23
  formatDriftBanner,
4
24
  runHealthcheck
5
- } from "../chunk-7PNF3AP2.js";
25
+ } from "../chunk-34VN47IW.js";
6
26
  import {
7
- evaluateFailures,
8
- formatFailureEval
9
- } from "../chunk-5F5ZIAW2.js";
27
+ buildBrief,
28
+ draftsDir,
29
+ listDrafts,
30
+ reviewSession
31
+ } from "../chunk-P3GLY42T.js";
10
32
  import {
11
- commandVerbs,
12
- errorSignal,
13
- failureQuery
14
- } from "../chunk-5LQIWCLK.js";
33
+ curate,
34
+ restore,
35
+ verifySkills
36
+ } from "../chunk-CATPGINC.js";
37
+ import {
38
+ readLedger,
39
+ rollback
40
+ } from "../chunk-TKHWVISV.js";
41
+ import {
42
+ decideScope
43
+ } from "../chunk-3FPUBAEW.js";
15
44
  import {
16
45
  FrontmatterManager,
17
46
  INDEX_FILE,
@@ -27,84 +56,205 @@ import {
27
56
  regenDirectoryIndex,
28
57
  regenIndexesForPaths,
29
58
  regenerateAgentsContract
30
- } from "../chunk-BBP3DG2U.js";
59
+ } from "../chunk-AIXQFTSB.js";
31
60
  import {
32
61
  Embedder,
33
62
  GraphBuilder,
34
63
  TextSearch,
35
64
  VectorIndex
36
- } from "../chunk-44BQDRXD.js";
65
+ } from "../chunk-SHSOCFJH.js";
37
66
  import {
38
67
  formatLintReport,
39
68
  lintVault
40
- } from "../chunk-CAX46XLY.js";
69
+ } from "../chunk-VBLCUWT4.js";
41
70
  import {
42
71
  installDefaultSchema,
43
72
  loadSchema,
44
73
  validateNote
45
- } from "../chunk-FURCIJBO.js";
74
+ } from "../chunk-Y7H76Q7F.js";
46
75
  import "../chunk-5ZKNO6ZD.js";
47
- import "../chunk-NBY4TRP7.js";
48
- import "../chunk-FTRXH2WC.js";
49
- import "../chunk-XAXK7NM4.js";
76
+ import "../chunk-7M34JDTH.js";
77
+ import "../chunk-7UAVDOI6.js";
78
+ import "../chunk-EXAUVIGW.js";
50
79
  import {
51
80
  SessionManager,
52
81
  deriveProjectRoot,
53
82
  deriveSessionDir
54
- } from "../chunk-LGQPP5FQ.js";
83
+ } from "../chunk-EYVFC745.js";
84
+ import {
85
+ MAX_TUNE_ITERATIONS,
86
+ tuneDescription,
87
+ withDescription
88
+ } from "../chunk-OT3MV7XF.js";
89
+ import {
90
+ MAX_TRIGGER_RUNS,
91
+ buildEvalSet,
92
+ evalCachePath,
93
+ makeScratch,
94
+ ratesOf,
95
+ runTrigger,
96
+ splitOf
97
+ } from "../chunk-MQS7JEBD.js";
98
+ import {
99
+ parseVerify,
100
+ runTaskEval
101
+ } from "../chunk-DBFD3MTT.js";
102
+ import "../chunk-IEZVFKUT.js";
103
+ import {
104
+ SKILL_SCOPES,
105
+ SKILL_SECTIONS,
106
+ SKILL_STATUSES,
107
+ findSkills,
108
+ lintSkill,
109
+ lintSkills,
110
+ parseSkill,
111
+ renderSkill
112
+ } from "../chunk-ZSWI3Y4Y.js";
55
113
  import {
56
114
  Indexer
57
- } from "../chunk-IGHCVAAL.js";
115
+ } from "../chunk-CJUY55GG.js";
116
+ import "../chunk-J7LYDRML.js";
58
117
  import {
59
118
  logEvent,
60
119
  logQuery
61
- } from "../chunk-SX427M2R.js";
120
+ } from "../chunk-XKGK643R.js";
121
+ import {
122
+ commandVerbs,
123
+ errorSignal,
124
+ failureQuery
125
+ } from "../chunk-5LQIWCLK.js";
126
+ import {
127
+ describeFeature,
128
+ featureOn,
129
+ featureState,
130
+ jevAvailable
131
+ } from "../chunk-VQCNWRTL.js";
132
+ import {
133
+ JEV_BAR,
134
+ askJev,
135
+ failureState,
136
+ jevSpendToday,
137
+ jevVerdict,
138
+ relevanceQuestion
139
+ } from "../chunk-GYR7U6KA.js";
140
+ import "../chunk-NIZLBNH4.js";
141
+ import "../chunk-R6GNP7DS.js";
62
142
  import {
63
143
  REDACTED,
64
144
  redact,
65
145
  redactDeep
66
- } from "../chunk-OEF5U5GV.js";
146
+ } from "../chunk-H2BES6FU.js";
67
147
  import "../chunk-PZ5AY32C.js";
148
+
149
+ // src/core/skill-eval/evals-json.ts
150
+ function parseEvals(text) {
151
+ const j = JSON.parse(text);
152
+ if (typeof j?.skill_name !== "string" || !Array.isArray(j.evals)) throw new Error("evals.json needs skill_name and an evals array");
153
+ const ids = /* @__PURE__ */ new Set();
154
+ for (const e of j.evals) {
155
+ if (!Number.isInteger(e?.id) || typeof e.prompt !== "string" || typeof e.expected_output !== "string" || !Array.isArray(e.expectations) || e.expectations.some((x) => typeof x !== "string"))
156
+ throw new Error(`evals.json: bad eval ${JSON.stringify(e?.id)}: id (integer), prompt, expected_output and expectations (strings) are required`);
157
+ if (e.files !== void 0 && (!Array.isArray(e.files) || e.files.some((x) => typeof x !== "string"))) throw new Error(`evals.json: eval ${e.id}: files must be strings`);
158
+ if (ids.has(e.id)) throw new Error(`evals.json: duplicate id ${e.id}`);
159
+ ids.add(e.id);
160
+ }
161
+ return j;
162
+ }
163
+ var renderEvals = (f) => JSON.stringify(f, null, 2) + "\n";
68
164
  export {
69
165
  Embedder,
70
166
  FrontmatterManager,
167
+ GATE_MAX_FALSE_TRIGGER_RATE,
168
+ GATE_MIN_POSITIVE_RATE,
71
169
  GraphBuilder,
72
170
  INDEX_FILE,
73
171
  INDEX_OVERFLOW_THRESHOLD,
74
172
  Indexer,
173
+ JEV_BAR,
174
+ MAX_TRIGGER_RUNS,
175
+ MAX_TUNE_ITERATIONS,
75
176
  NoteCrud,
76
177
  REDACTED,
178
+ SKILL_SCOPES,
179
+ SKILL_SECTIONS,
180
+ SKILL_STATUSES,
77
181
  SessionManager,
78
182
  TagManager,
79
183
  TextSearch,
80
184
  VectorIndex,
81
185
  Watcher,
82
186
  applyPatch,
187
+ approveDraft,
188
+ askJev,
189
+ buildBrief,
190
+ buildEvalSet,
83
191
  buildIngestChangeSet,
84
192
  buildPromoteChangeSet,
85
193
  buildSynthesizeChangeSet,
194
+ calibrateJudge,
86
195
  commandVerbs,
196
+ curate,
197
+ decideScope,
87
198
  deriveProjectRoot,
88
199
  deriveSessionDir,
200
+ describeDrafts,
201
+ describeFeature,
202
+ draftsDir,
89
203
  errorSignal,
204
+ evalCachePath,
205
+ evalDraft,
90
206
  evaluateFailures,
207
+ evaluateGate,
91
208
  failureQuery,
209
+ failureState,
210
+ featureOn,
211
+ featureState,
92
212
  filterToDrift,
213
+ findSkills,
93
214
  formatDriftBanner,
94
215
  formatFailureEval,
216
+ formatGate,
95
217
  formatLintReport,
218
+ gateSkill,
96
219
  inspectAgentsContract,
97
220
  installDefaultSchema,
221
+ jevAvailable,
222
+ jevSpendToday,
223
+ jevVerdict,
224
+ lintSkill,
225
+ lintSkills,
98
226
  lintVault,
227
+ listDrafts,
99
228
  loadSchema,
100
229
  logEvent,
101
230
  logQuery,
231
+ makeScratch,
232
+ meetsBar,
233
+ parseEvals,
234
+ parseSkill,
235
+ parseVerify,
236
+ proposeMerges,
237
+ ratesOf,
238
+ readLedger,
102
239
  redact,
103
240
  redactDeep,
104
241
  regenDirectoryIndex,
105
242
  regenIndexesForPaths,
106
243
  regenerateAgentsContract,
244
+ rejectDraft,
245
+ relevanceQuestion,
246
+ renderEvals,
247
+ renderSkill,
248
+ restore,
249
+ reviewSession,
250
+ rollback,
107
251
  runHealthcheck,
108
- validateNote
252
+ runTaskEval,
253
+ runTrigger,
254
+ splitOf,
255
+ tuneDescription,
256
+ validateNote,
257
+ verifySkills,
258
+ withDescription
109
259
  };
110
260
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../src/core/skill-eval/evals-json.ts"],"sourcesContent":["/**\n * Skill-creator's `evals/evals.json` (references/schemas.md), read and written as-is so evals made here\n * open in skill-creator and the other way round.\n */\nexport interface EvalCase {\n id: number;\n prompt: string;\n expected_output: string;\n /** input file paths, relative to the skill root */\n files?: string[];\n expectations: string[];\n}\n\nexport interface EvalsFile {\n skill_name: string;\n evals: EvalCase[];\n}\n\nexport function parseEvals(text: string): EvalsFile {\n const j = JSON.parse(text);\n if (typeof j?.skill_name !== \"string\" || !Array.isArray(j.evals)) throw new Error(\"evals.json needs skill_name and an evals array\");\n const ids = new Set<number>();\n for (const e of j.evals) {\n if (!Number.isInteger(e?.id) || typeof e.prompt !== \"string\" || typeof e.expected_output !== \"string\" || !Array.isArray(e.expectations) || e.expectations.some((x: unknown) => typeof x !== \"string\"))\n throw new Error(`evals.json: bad eval ${JSON.stringify(e?.id)}: id (integer), prompt, expected_output and expectations (strings) are required`);\n if (e.files !== undefined && (!Array.isArray(e.files) || e.files.some((x: unknown) => typeof x !== \"string\"))) throw new Error(`evals.json: eval ${e.id}: files must be strings`);\n if (ids.has(e.id)) throw new Error(`evals.json: duplicate id ${e.id}`);\n ids.add(e.id);\n }\n return j as EvalsFile;\n}\n\nexport const renderEvals = (f: EvalsFile): string => JSON.stringify(f, null, 2) + \"\\n\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,SAAS,WAAW,MAAyB;AAClD,QAAM,IAAI,KAAK,MAAM,IAAI;AACzB,MAAI,OAAO,GAAG,eAAe,YAAY,CAAC,MAAM,QAAQ,EAAE,KAAK,EAAG,OAAM,IAAI,MAAM,gDAAgD;AAClI,QAAM,MAAM,oBAAI,IAAY;AAC5B,aAAW,KAAK,EAAE,OAAO;AACvB,QAAI,CAAC,OAAO,UAAU,GAAG,EAAE,KAAK,OAAO,EAAE,WAAW,YAAY,OAAO,EAAE,oBAAoB,YAAY,CAAC,MAAM,QAAQ,EAAE,YAAY,KAAK,EAAE,aAAa,KAAK,CAAC,MAAe,OAAO,MAAM,QAAQ;AAClM,YAAM,IAAI,MAAM,wBAAwB,KAAK,UAAU,GAAG,EAAE,CAAC,iFAAiF;AAChJ,QAAI,EAAE,UAAU,WAAc,CAAC,MAAM,QAAQ,EAAE,KAAK,KAAK,EAAE,MAAM,KAAK,CAAC,MAAe,OAAO,MAAM,QAAQ,GAAI,OAAM,IAAI,MAAM,oBAAoB,EAAE,EAAE,yBAAyB;AAChL,QAAI,IAAI,IAAI,EAAE,EAAE,EAAG,OAAM,IAAI,MAAM,4BAA4B,EAAE,EAAE,EAAE;AACrE,QAAI,IAAI,EAAE,EAAE;AAAA,EACd;AACA,SAAO;AACT;AAEO,IAAM,cAAc,CAAC,MAAyB,KAAK,UAAU,GAAG,MAAM,CAAC,IAAI;","names":[]}