@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,35 @@
1
+ type JevCaller = "semantic-memory-hook" | "semantic-memory-judge" | "semantic-memory-skill-loop";
2
+ interface JevQuestion {
3
+ key: string;
4
+ instructions: string;
5
+ }
6
+ interface JevAnswer {
7
+ scores: Record<string, number>;
8
+ tokens?: number;
9
+ error?: string;
10
+ /** The live caller's daily ceiling was reached: nothing was sent. */
11
+ ceiling?: boolean;
12
+ }
13
+ /** jev-loop's bar: act on a yes only at or above it, on a no only at or below 1 - it. */
14
+ declare const JEV_BAR = 0.95;
15
+ declare const BRIDGE: string;
16
+ declare function askJev(input: {
17
+ cwd: string;
18
+ caller: JevCaller;
19
+ state: string;
20
+ questions: JevQuestion[];
21
+ }, opts?: {
22
+ timeoutMs?: number;
23
+ env?: NodeJS.ProcessEnv;
24
+ bridge?: string;
25
+ }): Promise<JevAnswer>;
26
+ /** Tokens each semantic-memory caller spent with Jev today, from jev-loop's usage ledger (numbers only). */
27
+ declare function jevSpendToday(jevDir: string, now?: Date): Record<string, number>;
28
+ /** A Jev probability as a verdict: yes at or above the bar, no at or below 1 − bar, otherwise unsure (null). */
29
+ declare const jevVerdict: (p: number | undefined, bar?: number) => boolean | null;
30
+ /** The failure → document relevance question (judge, gate and the failure hook ask the same thing). */
31
+ declare const relevanceQuestion: (title: string, excerpt: string) => string;
32
+ /** The state Jev sees for a failed tool call: the command and its error, capped. */
33
+ declare const failureState: (command: string, error: string) => string;
34
+
35
+ export { BRIDGE, JEV_BAR, type JevAnswer, type JevCaller, type JevQuestion, askJev, failureState, jevSpendToday, jevVerdict, relevanceQuestion };
@@ -0,0 +1,20 @@
1
+ import {
2
+ BRIDGE,
3
+ JEV_BAR,
4
+ askJev,
5
+ failureState,
6
+ jevSpendToday,
7
+ jevVerdict,
8
+ relevanceQuestion
9
+ } from "../chunk-GYR7U6KA.js";
10
+ import "../chunk-PZ5AY32C.js";
11
+ export {
12
+ BRIDGE,
13
+ JEV_BAR,
14
+ askJev,
15
+ failureState,
16
+ jevSpendToday,
17
+ jevVerdict,
18
+ relevanceQuestion
19
+ };
20
+ //# sourceMappingURL=jev.js.map
@@ -5,7 +5,7 @@ import {
5
5
  redactDeep,
6
6
  redactedNote,
7
7
  resetRedactCache
8
- } from "../chunk-OEF5U5GV.js";
8
+ } from "../chunk-H2BES6FU.js";
9
9
  import "../chunk-PZ5AY32C.js";
10
10
  export {
11
11
  REDACTED,
@@ -0,0 +1 @@
1
+ export { A as ARCHIVE_DAYS, C as CURATOR_INTERVAL_DAYS, d as CuratorAction, I as IDLE_HOURS, S as STALE_DAYS, c as curate, e as curatorDue, f as curatorState, g as curatorStatePath, l as listArchived, p as plan, a as restore, v as verifySkills } from '../skill-curator-D7HHZaUI.js';
@@ -0,0 +1,41 @@
1
+ import {
2
+ ARCHIVE_DAYS,
3
+ CURATOR_INTERVAL_DAYS,
4
+ IDLE_HOURS,
5
+ STALE_DAYS,
6
+ curate,
7
+ curatorDue,
8
+ curatorState,
9
+ curatorStatePath,
10
+ listArchived,
11
+ plan,
12
+ restore,
13
+ verifySkills
14
+ } from "../chunk-CATPGINC.js";
15
+ import "../chunk-TKHWVISV.js";
16
+ import "../chunk-3FPUBAEW.js";
17
+ import "../chunk-DBFD3MTT.js";
18
+ import "../chunk-IEZVFKUT.js";
19
+ import "../chunk-ZSWI3Y4Y.js";
20
+ import "../chunk-J7LYDRML.js";
21
+ import "../chunk-VQCNWRTL.js";
22
+ import "../chunk-GYR7U6KA.js";
23
+ import "../chunk-NIZLBNH4.js";
24
+ import "../chunk-R6GNP7DS.js";
25
+ import "../chunk-H2BES6FU.js";
26
+ import "../chunk-PZ5AY32C.js";
27
+ export {
28
+ ARCHIVE_DAYS,
29
+ CURATOR_INTERVAL_DAYS,
30
+ IDLE_HOURS,
31
+ STALE_DAYS,
32
+ curate,
33
+ curatorDue,
34
+ curatorState,
35
+ curatorStatePath,
36
+ listArchived,
37
+ plan,
38
+ restore,
39
+ verifySkills
40
+ };
41
+ //# sourceMappingURL=skill-curator.js.map
@@ -0,0 +1,25 @@
1
+ type EvidenceKind = "usage" | "failures" | "corrections";
2
+ declare const stateDir: (repoRoot: string) => string;
3
+ declare const evidencePath: (repoRoot: string, kind: EvidenceKind) => string;
4
+ /** The repo a hook's cwd belongs to: the nearest ancestor holding .git, else the cwd itself. */
5
+ declare function repoRoot(cwd: string): string;
6
+ declare function appendEvidence(root: string, kind: EvidenceKind, record: Record<string, unknown>, env?: NodeJS.ProcessEnv): void;
7
+ declare function readEvidence<T = Record<string, any>>(root: string, kind: EvidenceKind): T[];
8
+ declare const failureRecord: (input: {
9
+ session_id?: string;
10
+ tool_use_id?: string;
11
+ tool_name?: string;
12
+ tool_input?: any;
13
+ error?: string;
14
+ }) => {
15
+ session_id: string | null;
16
+ id: string | null;
17
+ tool: string | null;
18
+ command: string;
19
+ error: string;
20
+ };
21
+ declare function detectCorrection(prompt: string): string | null;
22
+ /** `/name …` typed by the user: Claude Code runs the skill without a Skill tool call, so PostToolUse never sees it. */
23
+ declare function slashSkill(prompt: string): string | null;
24
+
25
+ export { type EvidenceKind, appendEvidence, detectCorrection, evidencePath, failureRecord, readEvidence, repoRoot, slashSkill, stateDir };
@@ -0,0 +1,23 @@
1
+ import {
2
+ appendEvidence,
3
+ detectCorrection,
4
+ evidencePath,
5
+ failureRecord,
6
+ readEvidence,
7
+ repoRoot,
8
+ slashSkill,
9
+ stateDir
10
+ } from "../chunk-R6GNP7DS.js";
11
+ import "../chunk-H2BES6FU.js";
12
+ import "../chunk-PZ5AY32C.js";
13
+ export {
14
+ appendEvidence,
15
+ detectCorrection,
16
+ evidencePath,
17
+ failureRecord,
18
+ readEvidence,
19
+ repoRoot,
20
+ slashSkill,
21
+ stateDir
22
+ };
23
+ //# sourceMappingURL=skill-evidence.js.map
@@ -0,0 +1,40 @@
1
+ interface ReviewJob {
2
+ session_id: string;
3
+ repo: string;
4
+ transcript_path: string | null;
5
+ reason: string;
6
+ ts: string;
7
+ evidence: {
8
+ failures: string[];
9
+ corrections: number;
10
+ skills_used: string[];
11
+ tool_calls: number;
12
+ };
13
+ attempts?: number;
14
+ }
15
+ declare const smHome: (env?: NodeJS.ProcessEnv) => string;
16
+ declare const queueDir: (env?: NodeJS.ProcessEnv) => string;
17
+ declare const lockPath: (repo: string) => string;
18
+ declare const logPath: (repo: string) => string;
19
+ declare const dailyRunCap: (env?: NodeJS.ProcessEnv) => number;
20
+ /** The job SessionEnd would write for this session, or null when the session has nothing to learn from. */
21
+ declare function sessionJob(repo: string, input: {
22
+ session_id?: string;
23
+ transcript_path?: string;
24
+ reason?: string;
25
+ }, env?: NodeJS.ProcessEnv): ReviewJob | null;
26
+ declare function enqueue(job: ReviewJob, env?: NodeJS.ProcessEnv): string;
27
+ declare function pendingJobs(repo: string, env?: NodeJS.ProcessEnv): {
28
+ path: string;
29
+ job: ReviewJob;
30
+ }[];
31
+ declare function finishJob(path: string, outcome: "done" | "failed", result: Record<string, unknown>, env?: NodeJS.ProcessEnv): void;
32
+ declare function bumpAttempts(path: string): number;
33
+ declare function runsToday(env?: NodeJS.ProcessEnv, now?: Date): number;
34
+ declare function recordRun(repo: string, session_id: string, env?: NodeJS.ProcessEnv, now?: Date): void;
35
+ declare function lockHolder(repo: string): number | null;
36
+ /** Take the repo's worker lock (reclaiming a dead holder's). Returns a release function, or null if held. */
37
+ declare function takeLock(repo: string): (() => void) | null;
38
+ declare function log(repo: string, line: string): void;
39
+
40
+ export { type ReviewJob, bumpAttempts, dailyRunCap, enqueue, finishJob, lockHolder, lockPath, log, logPath, pendingJobs, queueDir, recordRun, runsToday, sessionJob, smHome, takeLock };
@@ -0,0 +1,38 @@
1
+ import {
2
+ bumpAttempts,
3
+ dailyRunCap,
4
+ enqueue,
5
+ finishJob,
6
+ lockHolder,
7
+ lockPath,
8
+ log,
9
+ logPath,
10
+ pendingJobs,
11
+ queueDir,
12
+ recordRun,
13
+ runsToday,
14
+ sessionJob,
15
+ smHome,
16
+ takeLock
17
+ } from "../chunk-NIZLBNH4.js";
18
+ import "../chunk-R6GNP7DS.js";
19
+ import "../chunk-H2BES6FU.js";
20
+ import "../chunk-PZ5AY32C.js";
21
+ export {
22
+ bumpAttempts,
23
+ dailyRunCap,
24
+ enqueue,
25
+ finishJob,
26
+ lockHolder,
27
+ lockPath,
28
+ log,
29
+ logPath,
30
+ pendingJobs,
31
+ queueDir,
32
+ recordRun,
33
+ runsToday,
34
+ sessionJob,
35
+ smHome,
36
+ takeLock
37
+ };
38
+ //# sourceMappingURL=skill-queue.js.map
@@ -0,0 +1,3 @@
1
+ export { D as DraftRecord, R as ReviewOptions, q as ReviewerDraft, s as ScopeResolver, h as buildBrief, j as draftsDir, n as listDrafts, t as materializeDraft, u as parseReviewerJson, o as reviewSession, v as transcriptTimeline } from '../skill-review-BaW5n0Zg.js';
2
+ import './skill-queue.js';
3
+ import './skill-worker.js';
@@ -0,0 +1,29 @@
1
+ import {
2
+ buildBrief,
3
+ draftsDir,
4
+ listDrafts,
5
+ materializeDraft,
6
+ parseReviewerJson,
7
+ reviewSession,
8
+ transcriptTimeline
9
+ } from "../chunk-P3GLY42T.js";
10
+ import "../chunk-3FPUBAEW.js";
11
+ import "../chunk-IEZVFKUT.js";
12
+ import "../chunk-ZSWI3Y4Y.js";
13
+ import "../chunk-J7LYDRML.js";
14
+ import "../chunk-VQCNWRTL.js";
15
+ import "../chunk-GYR7U6KA.js";
16
+ import "../chunk-NIZLBNH4.js";
17
+ import "../chunk-R6GNP7DS.js";
18
+ import "../chunk-H2BES6FU.js";
19
+ import "../chunk-PZ5AY32C.js";
20
+ export {
21
+ buildBrief,
22
+ draftsDir,
23
+ listDrafts,
24
+ materializeDraft,
25
+ parseReviewerJson,
26
+ reviewSession,
27
+ transcriptTimeline
28
+ };
29
+ //# sourceMappingURL=skill-review.js.map
@@ -0,0 +1,21 @@
1
+ import { ReviewJob } from './skill-queue.js';
2
+
3
+ interface ReviewOutcome {
4
+ drafts: string[];
5
+ rejected: {
6
+ reason: string;
7
+ }[];
8
+ costUsd: number;
9
+ note?: string;
10
+ }
11
+ declare const MAX_ATTEMPTS = 3;
12
+ declare function drain(repo: string, review: (job: ReviewJob) => Promise<ReviewOutcome>, env?: NodeJS.ProcessEnv): Promise<{
13
+ locked: boolean;
14
+ reviewed: number;
15
+ capped: boolean;
16
+ failed: number;
17
+ }>;
18
+ /** Start `semantic-memory skill-loop worker --repo <repo>` detached, unless a live worker holds the repo's lock. */
19
+ declare function spawnWorker(repo: string, env?: NodeJS.ProcessEnv): boolean;
20
+
21
+ export { MAX_ATTEMPTS, type ReviewOutcome, drain, spawnWorker };
@@ -0,0 +1,70 @@
1
+ import {
2
+ bumpAttempts,
3
+ dailyRunCap,
4
+ finishJob,
5
+ lockHolder,
6
+ log,
7
+ pendingJobs,
8
+ recordRun,
9
+ runsToday,
10
+ takeLock
11
+ } from "../chunk-NIZLBNH4.js";
12
+ import "../chunk-R6GNP7DS.js";
13
+ import "../chunk-H2BES6FU.js";
14
+ import "../chunk-PZ5AY32C.js";
15
+
16
+ // src/core/skill-worker.ts
17
+ import { spawn } from "child_process";
18
+ import { fileURLToPath } from "url";
19
+ import { existsSync } from "fs";
20
+ var MAX_ATTEMPTS = 3;
21
+ async function drain(repo, review, env = process.env) {
22
+ const release = takeLock(repo);
23
+ if (!release) return { locked: true, reviewed: 0, capped: false, failed: 0 };
24
+ let reviewed = 0, failed = 0, capped = false;
25
+ try {
26
+ for (let next = pendingJobs(repo, env)[0]; next; next = pendingJobs(repo, env)[0]) {
27
+ if (runsToday(env) >= dailyRunCap(env)) {
28
+ capped = true;
29
+ log(repo, `daily cap reached (${dailyRunCap(env)} reviews; SEMANTIC_MEMORY_SKILL_LOOP_DAILY_RUNS): ${pendingJobs(repo, env).length} job(s) wait for tomorrow`);
30
+ break;
31
+ }
32
+ const attempts = bumpAttempts(next.path);
33
+ if (attempts > MAX_ATTEMPTS) {
34
+ finishJob(next.path, "failed", { reason: `gave up after ${MAX_ATTEMPTS} attempts` }, env);
35
+ failed++;
36
+ continue;
37
+ }
38
+ recordRun(repo, next.job.session_id, env);
39
+ try {
40
+ const outcome = await review(next.job);
41
+ finishJob(next.path, "done", { ...outcome }, env);
42
+ reviewed++;
43
+ log(repo, `reviewed ${next.job.session_id} (${next.job.reason}): ${outcome.drafts.length} draft(s), ${outcome.rejected.length} rejected, $${outcome.costUsd.toFixed(3)}${outcome.note ? ` \u2014 ${outcome.note}` : ""}`);
44
+ } catch (e) {
45
+ log(repo, `review of ${next.job.session_id} failed (attempt ${attempts}): ${e.message}`);
46
+ if (attempts >= MAX_ATTEMPTS) {
47
+ finishJob(next.path, "failed", { reason: e.message }, env);
48
+ failed++;
49
+ } else break;
50
+ }
51
+ }
52
+ } finally {
53
+ release();
54
+ }
55
+ return { locked: false, reviewed, capped, failed };
56
+ }
57
+ function spawnWorker(repo, env = process.env) {
58
+ if (lockHolder(repo) !== null) return false;
59
+ const cli = ["../cli/index.js", "./cli/index.js", "../../dist/cli/index.js"].map((p) => fileURLToPath(new URL(p, import.meta.url))).find((p) => existsSync(p));
60
+ if (!cli) return false;
61
+ const child = spawn(process.execPath, [cli, "skill-loop", "worker", "--repo", repo], { cwd: repo, env, detached: true, stdio: "ignore" });
62
+ child.unref();
63
+ return true;
64
+ }
65
+ export {
66
+ MAX_ATTEMPTS,
67
+ drain,
68
+ spawnWorker
69
+ };
70
+ //# sourceMappingURL=skill-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/skill-worker.ts"],"sourcesContent":["/**\n * The skill loop's worker (v1.7): drains one repo's review queue, oldest job first, one worker per repo\n * (lock), stopping at the global daily cap (SEMANTIC_MEMORY_SKILL_LOOP_DAILY_RUNS, default 10). A job is\n * moved to done/ only after its review returns, so a crash leaves it queued; after 3 attempts it goes to\n * failed/ instead of retrying forever. Started detached by SessionEnd; also `semantic-memory skill-loop worker`.\n */\nimport { spawn } from \"node:child_process\";\nimport { fileURLToPath } from \"node:url\";\nimport { existsSync } from \"node:fs\";\nimport { bumpAttempts, dailyRunCap, finishJob, lockHolder, log, pendingJobs, recordRun, runsToday, takeLock, type ReviewJob } from \"./skill-queue.js\";\n\nexport interface ReviewOutcome {\n drafts: string[];\n rejected: { reason: string }[];\n costUsd: number;\n note?: string;\n}\n\nexport const MAX_ATTEMPTS = 3;\n\nexport async function drain(\n repo: string,\n review: (job: ReviewJob) => Promise<ReviewOutcome>,\n env = process.env,\n): Promise<{ locked: boolean; reviewed: number; capped: boolean; failed: number }> {\n const release = takeLock(repo);\n if (!release) return { locked: true, reviewed: 0, capped: false, failed: 0 };\n let reviewed = 0, failed = 0, capped = false;\n try {\n // re-read each time: SessionEnds of other sessions may add jobs while this one drains\n for (let next = pendingJobs(repo, env)[0]; next; next = pendingJobs(repo, env)[0]) {\n if (runsToday(env) >= dailyRunCap(env)) {\n capped = true;\n log(repo, `daily cap reached (${dailyRunCap(env)} reviews; SEMANTIC_MEMORY_SKILL_LOOP_DAILY_RUNS): ${pendingJobs(repo, env).length} job(s) wait for tomorrow`);\n break;\n }\n const attempts = bumpAttempts(next.path);\n if (attempts > MAX_ATTEMPTS) {\n finishJob(next.path, \"failed\", { reason: `gave up after ${MAX_ATTEMPTS} attempts` }, env);\n failed++;\n continue;\n }\n recordRun(repo, next.job.session_id, env);\n try {\n const outcome = await review(next.job);\n finishJob(next.path, \"done\", { ...outcome }, env);\n reviewed++;\n log(repo, `reviewed ${next.job.session_id} (${next.job.reason}): ${outcome.drafts.length} draft(s), ${outcome.rejected.length} rejected, $${outcome.costUsd.toFixed(3)}${outcome.note ? ` — ${outcome.note}` : \"\"}`);\n } catch (e) {\n log(repo, `review of ${next.job.session_id} failed (attempt ${attempts}): ${(e as Error).message}`);\n if (attempts >= MAX_ATTEMPTS) {\n finishJob(next.path, \"failed\", { reason: (e as Error).message }, env);\n failed++;\n } else break; // leave it queued for the next worker start\n }\n }\n } finally {\n release();\n }\n return { locked: false, reviewed, capped, failed };\n}\n\n/** Start `semantic-memory skill-loop worker --repo <repo>` detached, unless a live worker holds the repo's lock. */\nexport function spawnWorker(repo: string, env = process.env): boolean {\n if (lockHolder(repo) !== null) return false;\n // from dist/core, a dist/ chunk, or src/core (tests)\n const cli = [\"../cli/index.js\", \"./cli/index.js\", \"../../dist/cli/index.js\"].map((p) => fileURLToPath(new URL(p, import.meta.url))).find((p) => existsSync(p));\n if (!cli) return false;\n const child = spawn(process.execPath, [cli, \"skill-loop\", \"worker\", \"--repo\", repo], { cwd: repo, env, detached: true, stdio: \"ignore\" });\n child.unref();\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAMA,SAAS,aAAa;AACtB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAUpB,IAAM,eAAe;AAE5B,eAAsB,MACpB,MACA,QACA,MAAM,QAAQ,KACmE;AACjF,QAAM,UAAU,SAAS,IAAI;AAC7B,MAAI,CAAC,QAAS,QAAO,EAAE,QAAQ,MAAM,UAAU,GAAG,QAAQ,OAAO,QAAQ,EAAE;AAC3E,MAAI,WAAW,GAAG,SAAS,GAAG,SAAS;AACvC,MAAI;AAEF,aAAS,OAAO,YAAY,MAAM,GAAG,EAAE,CAAC,GAAG,MAAM,OAAO,YAAY,MAAM,GAAG,EAAE,CAAC,GAAG;AACjF,UAAI,UAAU,GAAG,KAAK,YAAY,GAAG,GAAG;AACtC,iBAAS;AACT,YAAI,MAAM,sBAAsB,YAAY,GAAG,CAAC,qDAAqD,YAAY,MAAM,GAAG,EAAE,MAAM,2BAA2B;AAC7J;AAAA,MACF;AACA,YAAM,WAAW,aAAa,KAAK,IAAI;AACvC,UAAI,WAAW,cAAc;AAC3B,kBAAU,KAAK,MAAM,UAAU,EAAE,QAAQ,iBAAiB,YAAY,YAAY,GAAG,GAAG;AACxF;AACA;AAAA,MACF;AACA,gBAAU,MAAM,KAAK,IAAI,YAAY,GAAG;AACxC,UAAI;AACF,cAAM,UAAU,MAAM,OAAO,KAAK,GAAG;AACrC,kBAAU,KAAK,MAAM,QAAQ,EAAE,GAAG,QAAQ,GAAG,GAAG;AAChD;AACA,YAAI,MAAM,YAAY,KAAK,IAAI,UAAU,KAAK,KAAK,IAAI,MAAM,MAAM,QAAQ,OAAO,MAAM,cAAc,QAAQ,SAAS,MAAM,eAAe,QAAQ,QAAQ,QAAQ,CAAC,CAAC,GAAG,QAAQ,OAAO,WAAM,QAAQ,IAAI,KAAK,EAAE,EAAE;AAAA,MACrN,SAAS,GAAG;AACV,YAAI,MAAM,aAAa,KAAK,IAAI,UAAU,oBAAoB,QAAQ,MAAO,EAAY,OAAO,EAAE;AAClG,YAAI,YAAY,cAAc;AAC5B,oBAAU,KAAK,MAAM,UAAU,EAAE,QAAS,EAAY,QAAQ,GAAG,GAAG;AACpE;AAAA,QACF,MAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,UAAE;AACA,YAAQ;AAAA,EACV;AACA,SAAO,EAAE,QAAQ,OAAO,UAAU,QAAQ,OAAO;AACnD;AAGO,SAAS,YAAY,MAAc,MAAM,QAAQ,KAAc;AACpE,MAAI,WAAW,IAAI,MAAM,KAAM,QAAO;AAEtC,QAAM,MAAM,CAAC,mBAAmB,kBAAkB,yBAAyB,EAAE,IAAI,CAAC,MAAM,cAAc,IAAI,IAAI,GAAG,YAAY,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,WAAW,CAAC,CAAC;AAC7J,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,QAAQ,MAAM,QAAQ,UAAU,CAAC,KAAK,cAAc,UAAU,UAAU,IAAI,GAAG,EAAE,KAAK,MAAM,KAAK,UAAU,MAAM,OAAO,SAAS,CAAC;AACxI,QAAM,MAAM;AACZ,SAAO;AACT;","names":[]}
@@ -15,9 +15,10 @@ import {
15
15
  resolveDossierPath,
16
16
  setCurrentState,
17
17
  slugifyEntity
18
- } from "./chunk-XAXK7NM4.js";
19
- import "./chunk-LGQPP5FQ.js";
20
- import "./chunk-OEF5U5GV.js";
18
+ } from "./chunk-EXAUVIGW.js";
19
+ import "./chunk-EYVFC745.js";
20
+ import "./chunk-J7LYDRML.js";
21
+ import "./chunk-H2BES6FU.js";
21
22
  import "./chunk-PZ5AY32C.js";
22
23
  export {
23
24
  DOSSIER_DIR,
@@ -37,4 +38,4 @@ export {
37
38
  setCurrentState,
38
39
  slugifyEntity
39
40
  };
40
- //# sourceMappingURL=dossier-RWTIMGZN.js.map
41
+ //# sourceMappingURL=dossier-RXBLQOXC.js.map
@@ -0,0 +1,18 @@
1
+ import {
2
+ calibrateJudge,
3
+ evaluateFailures,
4
+ evaluateGate,
5
+ formatFailureEval,
6
+ formatGate,
7
+ meetsBar
8
+ } from "./chunk-PJXYCCI2.js";
9
+ import "./chunk-PZ5AY32C.js";
10
+ export {
11
+ calibrateJudge,
12
+ evaluateFailures,
13
+ evaluateGate,
14
+ formatFailureEval,
15
+ formatGate,
16
+ meetsBar
17
+ };
18
+ //# sourceMappingURL=failure-eval-IUJO47UC.js.map
@@ -0,0 +1,21 @@
1
+ import {
2
+ filterToDrift,
3
+ formatDriftBanner,
4
+ runHealthcheck
5
+ } from "./chunk-34VN47IW.js";
6
+ import "./chunk-VBLCUWT4.js";
7
+ import "./chunk-Y7H76Q7F.js";
8
+ import "./chunk-5ZKNO6ZD.js";
9
+ import "./chunk-7M34JDTH.js";
10
+ import "./chunk-7UAVDOI6.js";
11
+ import "./chunk-EXAUVIGW.js";
12
+ import "./chunk-EYVFC745.js";
13
+ import "./chunk-J7LYDRML.js";
14
+ import "./chunk-H2BES6FU.js";
15
+ import "./chunk-PZ5AY32C.js";
16
+ export {
17
+ filterToDrift,
18
+ formatDriftBanner,
19
+ runHealthcheck
20
+ };
21
+ //# sourceMappingURL=healthcheck-S7D6YNTA.js.map
@@ -0,0 +1,9 @@
1
+ import {
2
+ Indexer
3
+ } from "./chunk-CJUY55GG.js";
4
+ import "./chunk-J7LYDRML.js";
5
+ import "./chunk-PZ5AY32C.js";
6
+ export {
7
+ Indexer
8
+ };
9
+ //# sourceMappingURL=indexer-RZPH2PVL.js.map
@@ -8,10 +8,11 @@ import {
8
8
  normalizePhrase,
9
9
  removeAlias,
10
10
  slugify
11
- } from "./chunk-FTRXH2WC.js";
12
- import "./chunk-XAXK7NM4.js";
13
- import "./chunk-LGQPP5FQ.js";
14
- import "./chunk-OEF5U5GV.js";
11
+ } from "./chunk-7UAVDOI6.js";
12
+ import "./chunk-EXAUVIGW.js";
13
+ import "./chunk-EYVFC745.js";
14
+ import "./chunk-J7LYDRML.js";
15
+ import "./chunk-H2BES6FU.js";
15
16
  import "./chunk-PZ5AY32C.js";
16
17
  export {
17
18
  addAlias,
@@ -24,4 +25,4 @@ export {
24
25
  removeAlias,
25
26
  slugify
26
27
  };
27
- //# sourceMappingURL=lexicon-IVNJTMWE.js.map
28
+ //# sourceMappingURL=lexicon-SEJSLBHO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,18 @@
1
+ import {
2
+ formatLintReport,
3
+ lintVault
4
+ } from "./chunk-VBLCUWT4.js";
5
+ import "./chunk-Y7H76Q7F.js";
6
+ import "./chunk-5ZKNO6ZD.js";
7
+ import "./chunk-7M34JDTH.js";
8
+ import "./chunk-7UAVDOI6.js";
9
+ import "./chunk-EXAUVIGW.js";
10
+ import "./chunk-EYVFC745.js";
11
+ import "./chunk-J7LYDRML.js";
12
+ import "./chunk-H2BES6FU.js";
13
+ import "./chunk-PZ5AY32C.js";
14
+ export {
15
+ formatLintReport,
16
+ lintVault
17
+ };
18
+ //# sourceMappingURL=lint-3JNLRM5U.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,11 @@
1
+ import {
2
+ logEvent,
3
+ logQuery
4
+ } from "./chunk-XKGK643R.js";
5
+ import "./chunk-H2BES6FU.js";
6
+ import "./chunk-PZ5AY32C.js";
7
+ export {
8
+ logEvent,
9
+ logQuery
10
+ };
11
+ //# sourceMappingURL=log-RM2NDNPH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ matter_default
3
+ } from "./chunk-J7LYDRML.js";
4
+ import "./chunk-PZ5AY32C.js";
5
+ export {
6
+ matter_default as default
7
+ };
8
+ //# sourceMappingURL=matter-SNJ2WDL6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}