brewers-almanack 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data/geb-inventory.d.ts +10 -0
- package/dist/data/geb-inventory.js +308 -0
- package/dist/data/geb-inventory.js.map +1 -0
- package/dist/data/styles.js +80 -0
- package/dist/data/styles.js.map +1 -1
- package/dist/register-tools.js +10 -0
- package/dist/register-tools.js.map +1 -1
- package/dist/tools/calculate-ibu.d.ts +3 -0
- package/dist/tools/calculate-ibu.js +68 -0
- package/dist/tools/calculate-ibu.js.map +1 -0
- package/dist/tools/calculate-water-additions.d.ts +3 -0
- package/dist/tools/calculate-water-additions.js +277 -0
- package/dist/tools/calculate-water-additions.js.map +1 -0
- package/dist/tools/check-geb-stock.d.ts +3 -0
- package/dist/tools/check-geb-stock.js +133 -0
- package/dist/tools/check-geb-stock.js.map +1 -0
- package/dist/tools/review-recipe.d.ts +3 -0
- package/dist/tools/review-recipe.js +148 -0
- package/dist/tools/review-recipe.js.map +1 -0
- package/dist/tools/suggest-recipe.js +44 -0
- package/dist/tools/suggest-recipe.js.map +1 -1
- package/dist/tools/suggest-substitution.d.ts +3 -0
- package/dist/tools/suggest-substitution.js +185 -0
- package/dist/tools/suggest-substitution.js.map +1 -0
- package/dist/types.d.ts +19 -0
- package/package.json +7 -1
package/dist/register-tools.js
CHANGED
|
@@ -4,6 +4,11 @@ import { registerDiagnoseOffFlavour } from "./tools/diagnose-off-flavour.js";
|
|
|
4
4
|
import { registerMatchWaterProfile } from "./tools/match-water-profile.js";
|
|
5
5
|
import { registerSuggestRecipe } from "./tools/suggest-recipe.js";
|
|
6
6
|
import { registerPairingGuide } from "./tools/pairing-guide.js";
|
|
7
|
+
import { registerCalculateIbu } from "./tools/calculate-ibu.js";
|
|
8
|
+
import { registerReviewRecipe } from "./tools/review-recipe.js";
|
|
9
|
+
import { registerSuggestSubstitution } from "./tools/suggest-substitution.js";
|
|
10
|
+
import { registerCalculateWaterAdditions } from "./tools/calculate-water-additions.js";
|
|
11
|
+
import { registerCheckGebStock } from "./tools/check-geb-stock.js";
|
|
7
12
|
export function registerTools(server) {
|
|
8
13
|
registerSearchStyles(server);
|
|
9
14
|
registerSearchIngredients(server);
|
|
@@ -11,5 +16,10 @@ export function registerTools(server) {
|
|
|
11
16
|
registerMatchWaterProfile(server);
|
|
12
17
|
registerSuggestRecipe(server);
|
|
13
18
|
registerPairingGuide(server);
|
|
19
|
+
registerCalculateIbu(server);
|
|
20
|
+
registerReviewRecipe(server);
|
|
21
|
+
registerSuggestSubstitution(server);
|
|
22
|
+
registerCalculateWaterAdditions(server);
|
|
23
|
+
registerCheckGebStock(server);
|
|
14
24
|
}
|
|
15
25
|
//# sourceMappingURL=register-tools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-tools.js","sourceRoot":"","sources":["../src/register-tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"register-tools.js","sourceRoot":"","sources":["../src/register-tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,UAAU,aAAa,CAAC,MAAiB;IAC7C,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAClC,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACnC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAClC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC9B,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACpC,+BAA+B,CAAC,MAAM,CAAC,CAAC;IACxC,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Tinseth IBU formula:
|
|
4
|
+
* IBU = (W_grams × AA_decimal × U × 1000) / V_litres
|
|
5
|
+
* U = bignessFactor × boilTimeFactor
|
|
6
|
+
* bignessFactor = 1.65 × 0.000125^(OG - 1)
|
|
7
|
+
* boilTimeFactor = (1 - e^(-0.04 × t)) / 4.15
|
|
8
|
+
*/
|
|
9
|
+
function tinsethIbu(weightGrams, alphaAcidPct, boilMinutes, batchVolumeLitres, originalGravity) {
|
|
10
|
+
if (boilMinutes <= 0)
|
|
11
|
+
return 0;
|
|
12
|
+
const alphaDecimal = alphaAcidPct / 100;
|
|
13
|
+
const bignessFactor = 1.65 * Math.pow(0.000125, originalGravity - 1);
|
|
14
|
+
const boilTimeFactor = (1 - Math.exp(-0.04 * boilMinutes)) / 4.15;
|
|
15
|
+
const utilisation = bignessFactor * boilTimeFactor;
|
|
16
|
+
return (weightGrams * alphaDecimal * utilisation * 1000) / batchVolumeLitres;
|
|
17
|
+
}
|
|
18
|
+
export function registerCalculateIbu(server) {
|
|
19
|
+
server.registerTool("calculate_ibu", {
|
|
20
|
+
title: "Calculate IBU",
|
|
21
|
+
description: "Calculate International Bitterness Units using the Tinseth formula. Accepts batch volume, original gravity, and a list of hop additions with weight, alpha acid percentage, and boil time.",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
batch_volume_litres: z
|
|
24
|
+
.number()
|
|
25
|
+
.describe("Final batch volume in litres"),
|
|
26
|
+
original_gravity: z
|
|
27
|
+
.number()
|
|
28
|
+
.describe("Original gravity (e.g. 1.065)"),
|
|
29
|
+
hop_additions: z
|
|
30
|
+
.array(z.object({
|
|
31
|
+
name: z.string().describe("Hop variety name"),
|
|
32
|
+
weight_g: z.number().describe("Hop weight in grams"),
|
|
33
|
+
alpha_acid_pct: z
|
|
34
|
+
.number()
|
|
35
|
+
.describe("Alpha acid percentage (e.g. 10 for 10%)"),
|
|
36
|
+
boil_minutes: z
|
|
37
|
+
.number()
|
|
38
|
+
.describe("Boil time in minutes (0 for dry hop/whirlpool)"),
|
|
39
|
+
}))
|
|
40
|
+
.describe("List of hop additions"),
|
|
41
|
+
},
|
|
42
|
+
}, async ({ batch_volume_litres, original_gravity, hop_additions }) => {
|
|
43
|
+
const additions = hop_additions.map((hop) => {
|
|
44
|
+
const ibu = tinsethIbu(hop.weight_g, hop.alpha_acid_pct, hop.boil_minutes, batch_volume_litres, original_gravity);
|
|
45
|
+
return {
|
|
46
|
+
name: hop.name,
|
|
47
|
+
weight_g: hop.weight_g,
|
|
48
|
+
alpha_acid_pct: hop.alpha_acid_pct,
|
|
49
|
+
boil_minutes: hop.boil_minutes,
|
|
50
|
+
ibu: Math.round(ibu * 10) / 10,
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
const totalIbu = Math.round(additions.reduce((sum, a) => sum + a.ibu, 0) * 10) / 10;
|
|
54
|
+
const lines = [
|
|
55
|
+
`# IBU Calculation (Tinseth)`,
|
|
56
|
+
`Batch: ${batch_volume_litres}L | OG: ${original_gravity}`,
|
|
57
|
+
"",
|
|
58
|
+
"## Hop Additions",
|
|
59
|
+
...additions.map((a) => `- ${a.name}: ${a.weight_g}g @ ${a.alpha_acid_pct}% AA, ${a.boil_minutes} min → ${a.ibu.toFixed(1)} IBU`),
|
|
60
|
+
"",
|
|
61
|
+
`## Total: ${totalIbu.toFixed(1)} IBU`,
|
|
62
|
+
];
|
|
63
|
+
return {
|
|
64
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=calculate-ibu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculate-ibu.js","sourceRoot":"","sources":["../../src/tools/calculate-ibu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,SAAS,UAAU,CACjB,WAAmB,EACnB,YAAoB,EACpB,WAAmB,EACnB,iBAAyB,EACzB,eAAuB;IAEvB,IAAI,WAAW,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAE/B,MAAM,YAAY,GAAG,YAAY,GAAG,GAAG,CAAC;IACxC,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,eAAe,GAAG,CAAC,CAAC,CAAC;IACrE,MAAM,cAAc,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,WAAW,CAAC,CAAC,GAAG,IAAI,CAAC;IA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;gBACd,QAAQ,EAAE,GAAG,CAAC,QAAQ;gBACtB,cAAc,EAAE,GAAG,CAAC,cAAc;gBAClC,YAAY,EAAE,GAAG,CAAC,YAAY;gBAC9B,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,EAAE;aAC/B,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,MAAM,QAAQ,GACZ,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;QAErE,MAAM,KAAK,GAAa;YACtB,6BAA6B;YAC7B,UAAU,mBAAmB,WAAW,gBAAgB,EAAE;YAC1D,EAAE;YACF,kBAAkB;YAClB,GAAG,SAAS,CAAC,GAAG,CACd,CAAC,CAAC,EAAE,EAAE,CACJ,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,cAAc,SAAS,CAAC,CAAC,YAAY,UAAU,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAC3G;YACD,EAAE;YACF,aAAa,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;SACvC,CAAC;QAEF,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SAC7D,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { WATER_PROFILES } from "../data/water-profiles.js";
|
|
3
|
+
import { fuzzySearch } from "../lib/search.js";
|
|
4
|
+
/**
|
|
5
|
+
* Chemistry constants: ppm contribution per gram per litre of water.
|
|
6
|
+
*/
|
|
7
|
+
const SALTS = {
|
|
8
|
+
gypsum: { calcium: 61.5, sulfate: 147.4 },
|
|
9
|
+
calciumChloride: { calcium: 72.0, chloride: 127.4 },
|
|
10
|
+
epsom: { magnesium: 26.1, sulfate: 103.0 },
|
|
11
|
+
bakingSoda: { sodium: 72.3, bicarbonate: 176.1 },
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Lactic acid (88%, 1mL/L): reduces alkalinity by ~50 ppm as CaCO3.
|
|
15
|
+
* We approximate: 1 mL/L removes ~50 ppm bicarbonate equivalent.
|
|
16
|
+
*/
|
|
17
|
+
const LACTIC_ACID_BICARB_REDUCTION_PER_ML = 50;
|
|
18
|
+
function resolveProfile(name) {
|
|
19
|
+
const results = fuzzySearch(WATER_PROFILES, name, ["name", "city"]);
|
|
20
|
+
if (results.length === 0)
|
|
21
|
+
return null;
|
|
22
|
+
const p = results[0];
|
|
23
|
+
return {
|
|
24
|
+
calcium: p.calcium,
|
|
25
|
+
magnesium: p.magnesium,
|
|
26
|
+
sodium: p.sodium,
|
|
27
|
+
chloride: p.chloride,
|
|
28
|
+
sulfate: p.sulfate,
|
|
29
|
+
bicarbonate: p.bicarbonate,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function calculateAdditions(source, target) {
|
|
33
|
+
const delta = {
|
|
34
|
+
calcium: Math.max(0, target.calcium - source.calcium),
|
|
35
|
+
magnesium: Math.max(0, target.magnesium - source.magnesium),
|
|
36
|
+
sodium: Math.max(0, target.sodium - source.sodium),
|
|
37
|
+
chloride: Math.max(0, target.chloride - source.chloride),
|
|
38
|
+
sulfate: Math.max(0, target.sulfate - source.sulfate),
|
|
39
|
+
bicarbonate: target.bicarbonate - source.bicarbonate, // can be negative
|
|
40
|
+
};
|
|
41
|
+
// Sulfate deficit: 80% from gypsum, 20% from Epsom
|
|
42
|
+
const sulfateFromGypsum = delta.sulfate * 0.8;
|
|
43
|
+
const sulfateFromEpsom = delta.sulfate * 0.2;
|
|
44
|
+
// g/L of gypsum needed for sulfate contribution
|
|
45
|
+
let gypsumGPerL = sulfateFromGypsum / SALTS.gypsum.sulfate;
|
|
46
|
+
// g/L of Epsom needed for sulfate contribution
|
|
47
|
+
let epsomGPerL = sulfateFromEpsom / SALTS.epsom.sulfate;
|
|
48
|
+
// Calcium contributed by gypsum
|
|
49
|
+
const caFromGypsum = gypsumGPerL * SALTS.gypsum.calcium;
|
|
50
|
+
// Chloride deficit: from CaCl2
|
|
51
|
+
let cacl2GPerL = delta.chloride / SALTS.calciumChloride.chloride;
|
|
52
|
+
const caFromCaCl2 = cacl2GPerL * SALTS.calciumChloride.calcium;
|
|
53
|
+
// Remaining calcium need after gypsum + CaCl2 contributions
|
|
54
|
+
const remainingCa = delta.calcium - caFromGypsum - caFromCaCl2;
|
|
55
|
+
if (remainingCa > 0) {
|
|
56
|
+
// Add more CaCl2 to cover remaining calcium
|
|
57
|
+
const extraCaCl2 = remainingCa / SALTS.calciumChloride.calcium;
|
|
58
|
+
cacl2GPerL += extraCaCl2;
|
|
59
|
+
}
|
|
60
|
+
// Magnesium beyond what Epsom already provides
|
|
61
|
+
const mgFromEpsom = epsomGPerL * SALTS.epsom.magnesium;
|
|
62
|
+
const remainingMg = delta.magnesium - mgFromEpsom;
|
|
63
|
+
if (remainingMg > 0) {
|
|
64
|
+
const extraEpsom = remainingMg / SALTS.epsom.magnesium;
|
|
65
|
+
epsomGPerL += extraEpsom;
|
|
66
|
+
}
|
|
67
|
+
// Sodium deficit: from baking soda
|
|
68
|
+
let bakingSodaGPerL = 0;
|
|
69
|
+
if (delta.sodium > 0) {
|
|
70
|
+
bakingSodaGPerL = delta.sodium / SALTS.bakingSoda.sodium;
|
|
71
|
+
}
|
|
72
|
+
// Bicarbonate: if target < source, need acid
|
|
73
|
+
let lacticAcidMlPerL = 0;
|
|
74
|
+
if (delta.bicarbonate < 0) {
|
|
75
|
+
const bicarbReduction = Math.abs(delta.bicarbonate);
|
|
76
|
+
lacticAcidMlPerL = bicarbReduction / LACTIC_ACID_BICARB_REDUCTION_PER_ML;
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
gypsum: gypsumGPerL,
|
|
80
|
+
calciumChloride: cacl2GPerL,
|
|
81
|
+
epsom: epsomGPerL,
|
|
82
|
+
bakingSoda: bakingSodaGPerL,
|
|
83
|
+
lacticAcidMl: lacticAcidMlPerL,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function round1(n) {
|
|
87
|
+
return Math.round(n * 10) / 10;
|
|
88
|
+
}
|
|
89
|
+
export function registerCalculateWaterAdditions(server) {
|
|
90
|
+
server.registerTool("calculate_water_additions", {
|
|
91
|
+
title: "Calculate Water Additions",
|
|
92
|
+
description: "Calculate mineral salt additions needed to adjust brewing water from a source profile to a target profile. Supports named profiles or custom ion values.",
|
|
93
|
+
inputSchema: {
|
|
94
|
+
source_profile: z
|
|
95
|
+
.string()
|
|
96
|
+
.optional()
|
|
97
|
+
.describe("Named source water profile (e.g. 'Reverse Osmosis', 'Dublin')"),
|
|
98
|
+
source_calcium: z.number().optional().describe("Source calcium (ppm)"),
|
|
99
|
+
source_magnesium: z.number().optional().describe("Source magnesium (ppm)"),
|
|
100
|
+
source_sodium: z.number().optional().describe("Source sodium (ppm)"),
|
|
101
|
+
source_chloride: z.number().optional().describe("Source chloride (ppm)"),
|
|
102
|
+
source_sulfate: z.number().optional().describe("Source sulfate (ppm)"),
|
|
103
|
+
source_bicarbonate: z.number().optional().describe("Source bicarbonate (ppm)"),
|
|
104
|
+
target_profile: z
|
|
105
|
+
.string()
|
|
106
|
+
.optional()
|
|
107
|
+
.describe("Named target water profile (e.g. 'Burton-on-Trent', 'Pilsen')"),
|
|
108
|
+
target_calcium: z.number().optional().describe("Target calcium (ppm)"),
|
|
109
|
+
target_magnesium: z.number().optional().describe("Target magnesium (ppm)"),
|
|
110
|
+
target_sodium: z.number().optional().describe("Target sodium (ppm)"),
|
|
111
|
+
target_chloride: z.number().optional().describe("Target chloride (ppm)"),
|
|
112
|
+
target_sulfate: z.number().optional().describe("Target sulfate (ppm)"),
|
|
113
|
+
target_bicarbonate: z.number().optional().describe("Target bicarbonate (ppm)"),
|
|
114
|
+
volume_litres: z.number().describe("Water volume in litres"),
|
|
115
|
+
},
|
|
116
|
+
}, async ({ source_profile, source_calcium, source_magnesium, source_sodium, source_chloride, source_sulfate, source_bicarbonate, target_profile, target_calcium, target_magnesium, target_sodium, target_chloride, target_sulfate, target_bicarbonate, volume_litres, }) => {
|
|
117
|
+
// Resolve source
|
|
118
|
+
let source = null;
|
|
119
|
+
if (source_profile) {
|
|
120
|
+
source = resolveProfile(source_profile);
|
|
121
|
+
if (!source) {
|
|
122
|
+
return {
|
|
123
|
+
content: [
|
|
124
|
+
{
|
|
125
|
+
type: "text",
|
|
126
|
+
text: `Source profile '${source_profile}' not found. Try: ${WATER_PROFILES.map((p) => p.name).join(", ")}`,
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else if (source_calcium !== undefined ||
|
|
133
|
+
source_magnesium !== undefined ||
|
|
134
|
+
source_sodium !== undefined ||
|
|
135
|
+
source_chloride !== undefined ||
|
|
136
|
+
source_sulfate !== undefined ||
|
|
137
|
+
source_bicarbonate !== undefined) {
|
|
138
|
+
source = {
|
|
139
|
+
calcium: source_calcium ?? 0,
|
|
140
|
+
magnesium: source_magnesium ?? 0,
|
|
141
|
+
sodium: source_sodium ?? 0,
|
|
142
|
+
chloride: source_chloride ?? 0,
|
|
143
|
+
sulfate: source_sulfate ?? 0,
|
|
144
|
+
bicarbonate: source_bicarbonate ?? 0,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
return {
|
|
149
|
+
content: [
|
|
150
|
+
{
|
|
151
|
+
type: "text",
|
|
152
|
+
text: "Please provide either a source_profile name or custom source ion values (source_calcium, source_magnesium, etc.).",
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
// Resolve target
|
|
158
|
+
let target = null;
|
|
159
|
+
let targetName = "Custom";
|
|
160
|
+
if (target_profile) {
|
|
161
|
+
target = resolveProfile(target_profile);
|
|
162
|
+
if (!target) {
|
|
163
|
+
return {
|
|
164
|
+
content: [
|
|
165
|
+
{
|
|
166
|
+
type: "text",
|
|
167
|
+
text: `Target profile '${target_profile}' not found. Try: ${WATER_PROFILES.map((p) => p.name).join(", ")}`,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
targetName = target_profile;
|
|
173
|
+
}
|
|
174
|
+
else if (target_calcium !== undefined ||
|
|
175
|
+
target_magnesium !== undefined ||
|
|
176
|
+
target_sodium !== undefined ||
|
|
177
|
+
target_chloride !== undefined ||
|
|
178
|
+
target_sulfate !== undefined ||
|
|
179
|
+
target_bicarbonate !== undefined) {
|
|
180
|
+
target = {
|
|
181
|
+
calcium: target_calcium ?? 0,
|
|
182
|
+
magnesium: target_magnesium ?? 0,
|
|
183
|
+
sodium: target_sodium ?? 0,
|
|
184
|
+
chloride: target_chloride ?? 0,
|
|
185
|
+
sulfate: target_sulfate ?? 0,
|
|
186
|
+
bicarbonate: target_bicarbonate ?? 0,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
return {
|
|
191
|
+
content: [
|
|
192
|
+
{
|
|
193
|
+
type: "text",
|
|
194
|
+
text: "Please provide either a target_profile name or custom target ion values (target_calcium, target_sulfate, etc.).",
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
// Check if source and target are identical
|
|
200
|
+
const ionsMatch = source.calcium === target.calcium &&
|
|
201
|
+
source.magnesium === target.magnesium &&
|
|
202
|
+
source.sodium === target.sodium &&
|
|
203
|
+
source.chloride === target.chloride &&
|
|
204
|
+
source.sulfate === target.sulfate &&
|
|
205
|
+
source.bicarbonate === target.bicarbonate;
|
|
206
|
+
if (ionsMatch) {
|
|
207
|
+
return {
|
|
208
|
+
content: [
|
|
209
|
+
{
|
|
210
|
+
type: "text",
|
|
211
|
+
text: `# Water Additions: → ${targetName}\nVolume: ${volume_litres}L\n\n## No additions needed — source already matches target.`,
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
// Calculate additions per litre
|
|
217
|
+
const additionsPerL = calculateAdditions(source, target);
|
|
218
|
+
// Scale to batch volume
|
|
219
|
+
const batch = {
|
|
220
|
+
gypsum: round1(additionsPerL.gypsum * volume_litres),
|
|
221
|
+
calciumChloride: round1(additionsPerL.calciumChloride * volume_litres),
|
|
222
|
+
epsom: round1(additionsPerL.epsom * volume_litres),
|
|
223
|
+
bakingSoda: round1(additionsPerL.bakingSoda * volume_litres),
|
|
224
|
+
lacticAcidMl: round1(additionsPerL.lacticAcidMl * volume_litres),
|
|
225
|
+
};
|
|
226
|
+
// Build output
|
|
227
|
+
const ions = [
|
|
228
|
+
{ label: "Ca", src: source.calcium, tgt: target.calcium },
|
|
229
|
+
{ label: "Mg", src: source.magnesium, tgt: target.magnesium },
|
|
230
|
+
{ label: "Na", src: source.sodium, tgt: target.sodium },
|
|
231
|
+
{ label: "Cl", src: source.chloride, tgt: target.chloride },
|
|
232
|
+
{ label: "SO4", src: source.sulfate, tgt: target.sulfate },
|
|
233
|
+
{ label: "HCO3", src: source.bicarbonate, tgt: target.bicarbonate },
|
|
234
|
+
];
|
|
235
|
+
const lines = [
|
|
236
|
+
`# Water Additions: → ${targetName}`,
|
|
237
|
+
`Volume: ${volume_litres}L`,
|
|
238
|
+
"",
|
|
239
|
+
"## Source → Target",
|
|
240
|
+
"| Ion | Source | Target | Delta |",
|
|
241
|
+
"|-----|--------|--------|-------|",
|
|
242
|
+
...ions.map((ion) => {
|
|
243
|
+
const delta = ion.tgt - ion.src;
|
|
244
|
+
const sign = delta >= 0 ? "+" : "";
|
|
245
|
+
return `| ${ion.label} | ${ion.src} | ${ion.tgt} | ${sign}${delta} |`;
|
|
246
|
+
}),
|
|
247
|
+
"",
|
|
248
|
+
"## Additions",
|
|
249
|
+
];
|
|
250
|
+
const additionLines = [];
|
|
251
|
+
if (batch.gypsum > 0) {
|
|
252
|
+
additionLines.push(`- **Gypsum (CaSO4):** ${batch.gypsum} g`);
|
|
253
|
+
}
|
|
254
|
+
if (batch.calciumChloride > 0) {
|
|
255
|
+
additionLines.push(`- **Calcium Chloride (CaCl2):** ${batch.calciumChloride} g`);
|
|
256
|
+
}
|
|
257
|
+
if (batch.epsom > 0) {
|
|
258
|
+
additionLines.push(`- **Epsom Salt (MgSO4):** ${batch.epsom} g`);
|
|
259
|
+
}
|
|
260
|
+
if (batch.bakingSoda > 0) {
|
|
261
|
+
additionLines.push(`- **Baking Soda (NaHCO3):** ${batch.bakingSoda} g`);
|
|
262
|
+
}
|
|
263
|
+
if (batch.lacticAcidMl > 0) {
|
|
264
|
+
additionLines.push(`- **Lactic Acid (88%):** ${batch.lacticAcidMl} mL`);
|
|
265
|
+
}
|
|
266
|
+
if (additionLines.length === 0) {
|
|
267
|
+
additionLines.push("No salt additions needed.");
|
|
268
|
+
}
|
|
269
|
+
lines.push(...additionLines);
|
|
270
|
+
lines.push("");
|
|
271
|
+
lines.push("*Note: This is a simplified calculation. Actual results may vary based on water chemistry interactions, mash pH buffering, and grain bill composition. Always measure and adjust.*");
|
|
272
|
+
return {
|
|
273
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
274
|
+
};
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=calculate-water-additions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculate-water-additions.js","sourceRoot":"","sources":["../../src/tools/calculate-water-additions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE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CAAmC,KAAK,CAAC,eAAe,IAAI,CAC7D,CAAC;QACJ,CAAC;QACD,IAAI,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;YACpB,aAAa,CAAC,IAAI,CAAC,6BAA6B,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,KAAK,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;YACzB,aAAa,CAAC,IAAI,CAAC,+BAA+B,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,KAAK,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;YAC3B,aAAa,CAAC,IAAI,CAChB,4BAA4B,KAAK,CAAC,YAAY,KAAK,CACpD,CAAC;QACJ,CAAC;QAED,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,aAAa,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAClD,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CACR,oLAAoL,CACrL,CAAC;QAEF,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SAC7D,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { GEB_INVENTORY, GEB_LAST_UPDATED } from "../data/geb-inventory.js";
|
|
3
|
+
import { HOPS } from "../data/hops.js";
|
|
4
|
+
import { MALTS } from "../data/malts.js";
|
|
5
|
+
import { YEASTS } from "../data/yeasts.js";
|
|
6
|
+
function searchInventory(query, category) {
|
|
7
|
+
let items = GEB_INVENTORY;
|
|
8
|
+
if (category) {
|
|
9
|
+
items = items.filter((p) => p.category.toLowerCase().includes(category.toLowerCase()));
|
|
10
|
+
}
|
|
11
|
+
const queryLower = query.toLowerCase();
|
|
12
|
+
return items.filter((p) => p.name.toLowerCase().includes(queryLower));
|
|
13
|
+
}
|
|
14
|
+
function formatPrice(product) {
|
|
15
|
+
if (product.unit === "per_gram") {
|
|
16
|
+
// Show as £/kg for readability (price is stored per gram)
|
|
17
|
+
return `£${(product.price_per_gram_gbp * 1000).toFixed(2)}/kg`;
|
|
18
|
+
}
|
|
19
|
+
return `£${product.price_per_gram_gbp.toFixed(2)} each`;
|
|
20
|
+
}
|
|
21
|
+
function formatStock(status) {
|
|
22
|
+
switch (status) {
|
|
23
|
+
case "in_stock": return "✓ In Stock";
|
|
24
|
+
case "low_stock": return "⚠ Low Stock";
|
|
25
|
+
case "out_of_stock": return "✗ Out of Stock";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function isAvailable(product) {
|
|
29
|
+
return product.stock_status !== "out_of_stock";
|
|
30
|
+
}
|
|
31
|
+
function findSubstitutes(query) {
|
|
32
|
+
const hop = HOPS.find((h) => h.name.toLowerCase().includes(query.toLowerCase()));
|
|
33
|
+
if (hop)
|
|
34
|
+
return hop.substitutes;
|
|
35
|
+
const malt = MALTS.find((m) => m.name.toLowerCase().includes(query.toLowerCase()));
|
|
36
|
+
if (malt) {
|
|
37
|
+
const colourMin = malt.colour * 0.5;
|
|
38
|
+
const colourMax = malt.colour * 1.5 + 2;
|
|
39
|
+
return MALTS.filter((m) => m.name !== malt.name &&
|
|
40
|
+
m.type === malt.type &&
|
|
41
|
+
m.colour >= colourMin &&
|
|
42
|
+
m.colour <= colourMax)
|
|
43
|
+
.slice(0, 3)
|
|
44
|
+
.map((m) => m.name);
|
|
45
|
+
}
|
|
46
|
+
const yeast = YEASTS.find((y) => y.name.toLowerCase().includes(query.toLowerCase()) ||
|
|
47
|
+
y.code.toLowerCase().includes(query.toLowerCase()));
|
|
48
|
+
if (yeast) {
|
|
49
|
+
return YEASTS.filter((y) => y.name !== yeast.name && y.type === yeast.type)
|
|
50
|
+
.slice(0, 3)
|
|
51
|
+
.map((y) => `${y.name} (${y.code})`);
|
|
52
|
+
}
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
export function registerCheckGebStock(server) {
|
|
56
|
+
server.registerTool("check_geb_stock", {
|
|
57
|
+
title: "Check GEB Stock",
|
|
58
|
+
description: "Check GetErBrewed.com custom kit builder inventory for ingredient availability and pricing. Data is updated weekly. If an item is out of stock, suggests substitutions.",
|
|
59
|
+
inputSchema: {
|
|
60
|
+
query: z
|
|
61
|
+
.string()
|
|
62
|
+
.describe("Ingredient to search for (e.g. 'Citra', 'Maris Otter', 'US-05')"),
|
|
63
|
+
category: z
|
|
64
|
+
.string()
|
|
65
|
+
.optional()
|
|
66
|
+
.describe("Filter by category (e.g. 'T90 Hops', 'Base Malt', 'Dried Yeast')"),
|
|
67
|
+
},
|
|
68
|
+
}, async ({ query, category }) => {
|
|
69
|
+
const matches = searchInventory(query, category);
|
|
70
|
+
const lines = [
|
|
71
|
+
`# GEB Stock: ${query}`,
|
|
72
|
+
`*Last updated: ${GEB_LAST_UPDATED.split("T")[0]}*`,
|
|
73
|
+
"",
|
|
74
|
+
];
|
|
75
|
+
if (GEB_INVENTORY.length === 0) {
|
|
76
|
+
lines.push("Inventory data not yet synced. Run `npm run fetch-geb` or wait for the weekly sync.");
|
|
77
|
+
return {
|
|
78
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (matches.length === 0) {
|
|
82
|
+
lines.push(`No products found matching "${query}".`);
|
|
83
|
+
const subs = findSubstitutes(query);
|
|
84
|
+
if (subs.length > 0) {
|
|
85
|
+
lines.push("", "## Try Instead");
|
|
86
|
+
for (const sub of subs) {
|
|
87
|
+
const subMatches = searchInventory(sub);
|
|
88
|
+
const available = subMatches.filter(isAvailable);
|
|
89
|
+
if (available.length > 0) {
|
|
90
|
+
lines.push(`- **${sub}** — ${formatPrice(available[0])} ${formatStock(available[0].stock_status)}`);
|
|
91
|
+
}
|
|
92
|
+
else if (subMatches.length > 0) {
|
|
93
|
+
lines.push(`- **${sub}** — listed but out of stock`);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
lines.push(`- **${sub}** — not found at GEB`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
const available = matches.filter(isAvailable);
|
|
103
|
+
const outOfStock = matches.filter((m) => !isAvailable(m));
|
|
104
|
+
if (available.length > 0) {
|
|
105
|
+
lines.push("## Available");
|
|
106
|
+
for (const p of available) {
|
|
107
|
+
lines.push(`- ${p.name} — ${formatPrice(p)} ${formatStock(p.stock_status)}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (outOfStock.length > 0) {
|
|
111
|
+
lines.push("", "## Out of Stock");
|
|
112
|
+
for (const p of outOfStock) {
|
|
113
|
+
lines.push(`- ${p.name} — ${formatPrice(p)}`);
|
|
114
|
+
}
|
|
115
|
+
if (available.length === 0) {
|
|
116
|
+
const subs = findSubstitutes(query);
|
|
117
|
+
if (subs.length > 0) {
|
|
118
|
+
lines.push("", "## Substitutes Available at GEB");
|
|
119
|
+
for (const sub of subs) {
|
|
120
|
+
const subMatches = searchInventory(sub);
|
|
121
|
+
const subAvailable = subMatches.filter(isAvailable);
|
|
122
|
+
if (subAvailable.length > 0) {
|
|
123
|
+
lines.push(`- **${sub}** — ${formatPrice(subAvailable[0])} ${formatStock(subAvailable[0].stock_status)}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=check-geb-stock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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