groundwork-mcp 0.3.0 → 0.4.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.
package/dist/index.d.ts CHANGED
@@ -131,9 +131,11 @@ type Priority = "must" | "should" | "could";
131
131
  */
132
132
  type RequirementStatus = "draft" | "awaiting-approval" | "approved" | "in-delivery" | "obsolete";
133
133
  /**
134
- * Stakeholder requirements state what a group of stakeholders needs, in their terms.
135
- * Solution requirements state what the product must do to meet one or more of those needs,
136
- * for a specific product and product area.
134
+ * Stakeholder requirements state who needs what and why, as a user story
135
+ * ("As a <role> I want <need> so that <reason>").
136
+ * Solution requirements state the qualities and behaviour the solution must have to meet one or
137
+ * more stakeholder requirements, as "shall" statements. Every solution requirement fulfils at
138
+ * least one stakeholder requirement.
137
139
  */
138
140
  type RequirementKind = "stakeholder" | "solution";
139
141
  /**
@@ -169,13 +171,13 @@ interface Requirement {
169
171
  /** Unset on requirements saved before the split; treat as "solution". */
170
172
  kind?: RequirementKind;
171
173
  title: string;
172
- /** Stakeholder requirements: the need statement. Solution requirements: the user story. */
174
+ /** Stakeholder requirements: the user story. Solution requirements: the "shall" statements. */
173
175
  story: string;
174
176
  /** Stakeholder requirements: who has the need, e.g. "Finance managers". */
175
177
  stakeholder?: string;
176
178
  /** Solution requirements: the product that delivers it, e.g. "Acme mobile app". */
177
179
  product?: string;
178
- /** Solution requirements: the stakeholder requirements this one helps meet. */
180
+ /** Solution requirements: the stakeholder requirements this one fulfils (at least one). */
179
181
  stakeholderIds?: ID[];
180
182
  acceptanceCriteria: string[];
181
183
  priority: Priority;
@@ -185,6 +187,10 @@ interface Requirement {
185
187
  approver?: string;
186
188
  approvedBy?: string;
187
189
  approvedAt?: string;
190
+ /** Set when someone recorded an approval given by another person, e.g. verbally: who entered it. */
191
+ recordedBy?: string;
192
+ /** How or where it was approved, e.g. "Approved by Maria in sprint planning". */
193
+ approvalNote?: string;
188
194
  findingIds: ID[];
189
195
  /** Set when the requirement was created directly: decided, not validated by an experiment. */
190
196
  origin?: RequirementOrigin;
@@ -251,11 +257,22 @@ declare function diffCollections(before: Collections, after: Collections): {
251
257
  /** Requirements saved before the stakeholder / solution split are solution requirements. */
252
258
  declare function kindOf(r: Pick<Requirement, "kind">): RequirementKind;
253
259
  declare const isObsolete: (r: Pick<Requirement, "status">) => boolean;
260
+ declare const isActive: (r: Pick<Requirement, "status">) => boolean;
254
261
  /** Only approved requirements can be made obsolete. Drafts are updated in place instead. */
255
262
  declare const canObsolete: (r: Pick<Requirement, "status">) => boolean;
256
263
  declare const canUpdateInPlace: (r: Pick<Requirement, "status">) => boolean;
257
264
  /** Only approved solution requirements go to a delivery tool, and only once. */
258
265
  declare const canSendToDelivery: (r: Pick<Requirement, "kind" | "status" | "delivery">) => boolean;
266
+ /** A stakeholder requirement is a user story: "As a <role> I want <need> so that <reason>". */
267
+ declare const STAKEHOLDER_STORY: RegExp;
268
+ /** A solution requirement is one or more "shall" statements. */
269
+ declare const SOLUTION_STATEMENT: RegExp;
270
+ /** Advice when a requirement's story isn't written the way its layer expects. Never blocks a write. */
271
+ declare function wordingWarnings(r: Pick<Requirement, "kind" | "story">): string[];
272
+ /** The active solution requirements that fulfil a stakeholder requirement. */
273
+ declare function fulfilledBy(id: ID, requirements: Requirement[]): Requirement[];
274
+ /** Why this combination of kind and stakeholder links isn't allowed, if it isn't. */
275
+ declare function layerProblem(r: Pick<Requirement, "kind" | "stakeholderIds">): string | undefined;
259
276
  /** New requirements, rewritten drafts and approved requirements made obsolete, decided together. */
260
277
  interface RequirementChanges {
261
278
  create: Requirement[];
@@ -340,7 +357,11 @@ declare function updateRequirement(s: Collections, id: string, patch: Partial<Re
340
357
  declare function deleteRequirement(s: Collections, id: string): Change;
341
358
  /** Ask someone to sign off a draft. */
342
359
  declare function submitRequirement(s: Collections, c: Ctx, id: string, approver: string): Change<boolean>;
343
- declare function approveRequirement(s: Collections, c: Ctx, id: string): Change<boolean>;
360
+ /** Approve a requirement. `by` records an approval someone else gave outside Groundwork, e.g. verbally. */
361
+ declare function approveRequirement(s: Collections, c: Ctx, id: string, by?: {
362
+ approvedBy: string;
363
+ note?: string;
364
+ }): Change<boolean>;
344
365
  declare function sendBackRequirement(s: Collections, c: Ctx, id: string): Change<boolean>;
345
366
  declare function obsoleteRequirement(s: Collections, c: Ctx, id: string, by?: string[]): Change<boolean>;
346
367
  /** Save the outcome of deriving requirements: new ones, updated drafts, and approved ones made obsolete. */
@@ -547,10 +568,10 @@ declare function makeSchemas(id: z.ZodString): {
547
568
  productArea: z.ZodOptional<z.ZodString>;
548
569
  }, z.core.$strip>;
549
570
  requirementInput: z.ZodObject<{
550
- kind: z.ZodDefault<z.ZodEnum<{
571
+ kind: z.ZodEnum<{
551
572
  stakeholder: "stakeholder";
552
573
  solution: "solution";
553
- }>>;
574
+ }>;
554
575
  title: z.ZodString;
555
576
  story: z.ZodString;
556
577
  stakeholder: z.ZodOptional<z.ZodString>;
@@ -815,10 +836,10 @@ declare const localSchemas: {
815
836
  productArea: z.ZodOptional<z.ZodString>;
816
837
  }, z.core.$strip>;
817
838
  requirementInput: z.ZodObject<{
818
- kind: z.ZodDefault<z.ZodEnum<{
839
+ kind: z.ZodEnum<{
819
840
  stakeholder: "stakeholder";
820
841
  solution: "solution";
821
- }>>;
842
+ }>;
822
843
  title: z.ZodString;
823
844
  story: z.ZodString;
824
845
  stakeholder: z.ZodOptional<z.ZodString>;
@@ -1114,11 +1135,11 @@ interface Problem {
1114
1135
  /** Every problem in a project: unreadable files, invalid fields, broken or wrong-kind links, unknown areas. */
1115
1136
  declare function validate(loaded: Loaded, config: Config): Problem[];
1116
1137
 
1117
- declare const INSTRUCTIONS = "Groundwork keeps this product's evidence and decisions as linked Markdown files in the groundwork/ folder, as a chain:\ninsight -> hypothesis -> experiment -> finding -> requirement.\n\n- Insight: evidence from a real person: what they said or did (quote), where it came from (source) and who they are (persona). Not opinions or ideas. Never store full names or contact details; use a role and an optional participant ref like P07.\n- Hypothesis: \"We believe we will [outcome] if [forWhom] get [benefit] with [feature]\", built on insights (insightIds), ideally with a successMetric (baseline, target, timeframe).\n- Experiment: tests exactly one hypothesis (hypothesisId) with one primary metric and optional guardrails. Lifecycle: planned -> start_experiment -> record_experiment_results (Groundwork computes the verdict and updates the hypothesis).\n- Finding: what was learned, linked to the experiments, hypotheses and insights behind it.\n- Requirement: \"stakeholder\" (a need, in the stakeholder's words) or \"solution\" (what the product must do). Justified by findingIds, or, when decided elsewhere, by an origin (tender, regulation, contract, customer-need).\n\nHow to work:\n1. Call get_workspace first: it gives product areas, products and people (for approvers). If an area or product you need is missing, add it with add_product_areas or add_products, after checking for an existing match.\n2. Before creating anything, search_items for duplicates and for evidence to link. Prefer linking to existing items over creating near-duplicates.\n3. Always link evidence: hypotheses to insights, experiments to a hypothesis, findings to experiments/hypotheses/insights, requirements to findings.\n4. Ask the user before deleting items or approving requirements, unless they already told you to.\n5. Use these tools rather than editing the files directly: they keep ids unique and links valid. Each result includes the item's file: mention it so the user can open it.\n6. The Markdown body under an item's frontmatter is the user's own notes. Read it, but don't overwrite it.";
1138
+ declare const INSTRUCTIONS = "Groundwork keeps this product's evidence and decisions as linked Markdown files in the groundwork/ folder, as a chain:\ninsight -> hypothesis -> experiment -> finding -> requirement.\n\n- Insight: evidence from a real person: what they said or did (quote), where it came from (source) and who they are (persona). Not opinions or ideas. Never store full names or contact details; use a role and an optional participant ref like P07.\n- Hypothesis: \"We believe we will [outcome] if [forWhom] get [benefit] with [feature]\", built on insights (insightIds), ideally with a successMetric (baseline, target, timeframe).\n- Experiment: tests exactly one hypothesis (hypothesisId) with one primary metric and optional guardrails. Lifecycle: planned -> start_experiment -> record_experiment_results (Groundwork computes the verdict and updates the hypothesis).\n- Finding: what was learned, linked to the experiments, hypotheses and insights behind it.\n- Requirement, in two layers, written before building:\n - \"stakeholder\": who needs what and why, as a user story: \"As a <role> I want <need> so that <reason>\".\n - \"solution\": the qualities and behaviour the solution must have, as \"shall\" statements: \"The <system or part> shall \u2026\". Every solution requirement fulfils at least one stakeholder requirement (stakeholderIds); one stakeholder requirement is usually fulfilled by several solution requirements.\n Add the stakeholder requirements first, then the solution requirements that reference their ids. Link findingIds, insightIds or an origin (tender, regulation, contract, customer-need) when there is evidence or an outside source; they're optional.\n\nHow to work:\n1. Call get_workspace first: it gives product areas, products and people (for approvers). If an area or product you need is missing, add it with add_product_areas or add_products, after checking for an existing match.\n2. Before creating anything, search_items for duplicates and for evidence to link. Prefer linking to existing items over creating near-duplicates.\n3. Always link evidence: hypotheses to insights, experiments to a hypothesis, findings to experiments/hypotheses/insights, solution requirements to the stakeholder requirements they fulfil, and requirements to findings when there are any.\n4. Ask the user before deleting items or approving requirements, unless they already told you to.\n5. Use these tools rather than editing the files directly: they keep ids unique and links valid. Each result includes the item's file: mention it so the user can open it.\n6. The Markdown body under an item's frontmatter is the user's own notes. Read it, but don't overwrite it.\n\nWhen you plan work (a plan, plan mode, or a step in an autonomous workflow):\n1. Classify the task first. If unsure, search_items for related requirements.\n - New need: something users can't do today, e.g. \"Let's add a feature to book appointments\".\n - Change: existing behaviour that should work differently.\n - Fix: restores intended behaviour, e.g. \"This path is broken, fix it\". Refactors and dependency bumps count as fixes.\n2. State the call in one line of the plan, e.g. \"New need: adds 2 stakeholder and 4 solution requirements\" or \"Bug fix under REQ-0007; no requirement changes\".\n3. New need: the plan's first steps add the stakeholder requirements, then the solution requirements that fulfil them, before writing code.\n4. Change: update the requirement with update_item if it's a draft. If it's approved, add a new one, and once that's agreed make the old one obsolete with obsolete_requirement and replacedBy.\n5. Fix: don't write requirements. Name the requirement the fix restores when you can tell.\n6. With no person to review the plan (an autonomous workflow), follow your own call. The one-line call stays in the plan as the record.\n7. When the workflow creates tickets or user stories, use the solution requirements and the stakeholder stories they fulfil as a source. Put the REQ ids and each requirement's file path in the ticket. By default, one ticket per solution requirement.\n8. Approval given outside Groundwork (e.g. verbally by a PM): record it with approve_requirement, passing approvedBy and a note. Only do this when the user tells you who approved it.\n\nRecording evidence or requirements directly isn't planning work. A product manager logging interview notes, drafting hypotheses, recording experiment results or writing requirements gets no new need / change / fix call: record what they ask for with the tools above.";
1118
1139
  interface ServerOptions {
1119
1140
  /** The project folder (the one that holds groundwork/). */
1120
1141
  root: string;
1121
1142
  }
1122
1143
  declare function buildServer({ root }: ServerOptions): McpServer;
1123
1144
 
1124
- export { type Activity, COLLECTIONS, COLLECTION_KEYS, COLLECTION_KIND, CONFIG_FILE, type Collections, type Config, ConfigError, DIR, type Delivery, type DeliverySettings, type DeliveryStateType, EXPERIMENT_STATUS, type Experiment, type ExperimentMethod, type ExperimentStatus, FINDING_CONFIDENCE, type Finding, type Graph, HYPOTHESIS_STATUS, type Hypothesis, type HypothesisStatus, type ID, ID_PREFIX, INSTRUCTIONS, type Insight, KIND, type Kind, LOCAL_ID, type Loaded, METHOD, type Metric, PRIORITY, type Person, type Prioritization, type Priority, type Problem, type ProductArea, REQUIREMENT_KIND, REQUIREMENT_ORIGIN, type Requirement, type RequirementChanges, type RequirementKind, type RequirementOrigin, type RequirementStatus, SCHEMA_VERSION, SENTIMENT, SOURCE, type Schemas, type Score, type Sentiment, type SourceType, type SuccessMetric, type Trail, type Upsert, type Verdict, type VerdictResult, appendToConfig, assignIds, buildServer, canObsolete, canSendToDelivery, canUpdateInPlace, composeKnowWhen, composeStatement, computeVerdict, configPath, configSchema, connectedIds, defaultConfig, describeSuccess, diffCollections, emptyCollections, evidenceStrength, findRoot, fmtMetric, hasSuccessMetric, isInitialized, isObsolete, kindOf, load, localId, localSchemas, makeSchemas, metricPasses, ops, parseItem, readConfig, renderItem, resolveActor, save, targetLabel, trailForRequirement, validate, writeConfig };
1145
+ export { type Activity, COLLECTIONS, COLLECTION_KEYS, COLLECTION_KIND, CONFIG_FILE, type Collections, type Config, ConfigError, DIR, type Delivery, type DeliverySettings, type DeliveryStateType, EXPERIMENT_STATUS, type Experiment, type ExperimentMethod, type ExperimentStatus, FINDING_CONFIDENCE, type Finding, type Graph, HYPOTHESIS_STATUS, type Hypothesis, type HypothesisStatus, type ID, ID_PREFIX, INSTRUCTIONS, type Insight, KIND, type Kind, LOCAL_ID, type Loaded, METHOD, type Metric, PRIORITY, type Person, type Prioritization, type Priority, type Problem, type ProductArea, REQUIREMENT_KIND, REQUIREMENT_ORIGIN, type Requirement, type RequirementChanges, type RequirementKind, type RequirementOrigin, type RequirementStatus, SCHEMA_VERSION, SENTIMENT, SOLUTION_STATEMENT, SOURCE, STAKEHOLDER_STORY, type Schemas, type Score, type Sentiment, type SourceType, type SuccessMetric, type Trail, type Upsert, type Verdict, type VerdictResult, appendToConfig, assignIds, buildServer, canObsolete, canSendToDelivery, canUpdateInPlace, composeKnowWhen, composeStatement, computeVerdict, configPath, configSchema, connectedIds, defaultConfig, describeSuccess, diffCollections, emptyCollections, evidenceStrength, findRoot, fmtMetric, fulfilledBy, hasSuccessMetric, isActive, isInitialized, isObsolete, kindOf, layerProblem, load, localId, localSchemas, makeSchemas, metricPasses, ops, parseItem, readConfig, renderItem, resolveActor, save, targetLabel, trailForRequirement, validate, wordingWarnings, writeConfig };
package/dist/index.js CHANGED
@@ -18,7 +18,9 @@ import {
18
18
  REQUIREMENT_ORIGIN,
19
19
  SCHEMA_VERSION,
20
20
  SENTIMENT,
21
+ SOLUTION_STATEMENT,
21
22
  SOURCE,
23
+ STAKEHOLDER_STORY,
22
24
  appendToConfig,
23
25
  assignIds,
24
26
  buildServer,
@@ -36,10 +38,13 @@ import {
36
38
  emptyCollections,
37
39
  findRoot,
38
40
  fmtMetric,
41
+ fulfilledBy,
39
42
  hasSuccessMetric,
43
+ isActive,
40
44
  isInitialized,
41
45
  isObsolete,
42
46
  kindOf,
47
+ layerProblem,
43
48
  load,
44
49
  localId,
45
50
  localSchemas,
@@ -53,8 +58,9 @@ import {
53
58
  save,
54
59
  targetLabel,
55
60
  validate,
61
+ wordingWarnings,
56
62
  writeConfig
57
- } from "./chunk-3YZLRKZH.js";
63
+ } from "./chunk-TXXV5YDG.js";
58
64
 
59
65
  // src/core/trace.ts
60
66
  function trailForRequirement(r, g) {
@@ -140,7 +146,9 @@ export {
140
146
  REQUIREMENT_ORIGIN,
141
147
  SCHEMA_VERSION,
142
148
  SENTIMENT,
149
+ SOLUTION_STATEMENT,
143
150
  SOURCE,
151
+ STAKEHOLDER_STORY,
144
152
  appendToConfig,
145
153
  assignIds,
146
154
  buildServer,
@@ -160,10 +168,13 @@ export {
160
168
  evidenceStrength,
161
169
  findRoot,
162
170
  fmtMetric,
171
+ fulfilledBy,
163
172
  hasSuccessMetric,
173
+ isActive,
164
174
  isInitialized,
165
175
  isObsolete,
166
176
  kindOf,
177
+ layerProblem,
167
178
  load,
168
179
  localId,
169
180
  localSchemas,
@@ -178,6 +189,7 @@ export {
178
189
  targetLabel,
179
190
  trailForRequirement,
180
191
  validate,
192
+ wordingWarnings,
181
193
  writeConfig
182
194
  };
183
195
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/trace.ts"],"sourcesContent":["import type { Experiment, Finding, Hypothesis, Insight, Requirement } from \"./types\";\n\nexport interface Graph {\n insights: Insight[];\n hypotheses: Hypothesis[];\n experiments: Experiment[];\n findings: Finding[];\n requirements: Requirement[];\n}\n\nexport interface Trail {\n /** Solution requirements: the stakeholder requirements they help meet. */\n stakeholderRequirements: Requirement[];\n findings: Finding[];\n experiments: Experiment[];\n hypotheses: Hypothesis[];\n insights: Insight[];\n}\n\n/** Walk a requirement back to every piece of evidence behind it. */\nexport function trailForRequirement(r: Requirement, g: Graph): Trail {\n const stakeholderRequirements = g.requirements.filter((x) => r.stakeholderIds?.includes(x.id));\n const findings = g.findings.filter((f) => r.findingIds.includes(f.id));\n const experiments = g.experiments.filter((e) => findings.some((f) => f.experimentIds.includes(e.id)));\n const hypIds = new Set([\n ...findings.flatMap((f) => f.hypothesisIds),\n ...experiments.map((e) => e.hypothesisId),\n ...(r.hypothesisIds ?? []),\n ]);\n const hypotheses = g.hypotheses.filter((h) => hypIds.has(h.id));\n const insIds = new Set([\n ...findings.flatMap((f) => f.insightIds),\n ...hypotheses.flatMap((h) => h.insightIds),\n ...(r.insightIds ?? []),\n ]);\n const insights = g.insights.filter((i) => insIds.has(i.id));\n return { stakeholderRequirements, findings, experiments, hypotheses, insights };\n}\n\n/** All node ids connected (upstream and downstream) to a given node. */\nexport function connectedIds(id: string, g: Graph): Set<string> {\n const edges: [string, string][] = [];\n g.hypotheses.forEach((h) => h.insightIds.forEach((i) => edges.push([i, h.id])));\n g.experiments.forEach((e) => edges.push([e.hypothesisId, e.id]));\n g.findings.forEach((f) => {\n f.experimentIds.forEach((e) => edges.push([e, f.id]));\n if (!f.experimentIds.length) f.hypothesisIds.forEach((h) => edges.push([h, f.id]));\n });\n g.requirements.forEach((r) => {\n r.findingIds.forEach((f) => edges.push([f, r.id]));\n // Directly created requirements link straight to their evidence and source hypotheses.\n r.insightIds?.forEach((i) => edges.push([i, r.id]));\n r.hypothesisIds?.forEach((h) => edges.push([h, r.id]));\n // Solution requirements meet stakeholder requirements.\n r.stakeholderIds?.forEach((s) => edges.push([s, r.id]));\n });\n\n const result = new Set<string>([id]);\n // upstream\n const up = [id];\n while (up.length) {\n const cur = up.pop()!;\n edges.forEach(([a, b]) => {\n if (b === cur && !result.has(a)) {\n result.add(a);\n up.push(a);\n }\n });\n }\n // downstream\n const down = [id];\n const seenDown = new Set([id]);\n while (down.length) {\n const cur = down.pop()!;\n edges.forEach(([a, b]) => {\n if (a === cur && !seenDown.has(b)) {\n seenDown.add(b);\n result.add(b);\n down.push(b);\n }\n });\n }\n return result;\n}\n\nexport function evidenceStrength(t: Trail): { score: number; label: \"Strong\" | \"Moderate\" | \"Weak\" } {\n const validated = t.experiments.filter((e) => e.verdict === \"validated\").length;\n const invalidated = t.experiments.filter((e) => e.verdict === \"invalidated\").length;\n const score = Math.min(100, t.insights.length * 8 + validated * 35 + invalidated * 20 + t.findings.length * 10);\n return { score, label: score >= 70 ? \"Strong\" : score >= 40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AC,GAAG,CAAC,MAAM;AACxB,UAAI,MAAM,OAAO,CAAC,SAAS,IAAI,CAAC,GAAG;AACjC,iBAAS,IAAI,CAAC;AACd,eAAO,IAAI,CAAC;AACZ,aAAK,KAAK,CAAC;AAAA,MACb;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEO,SAAS,iBAAiB,GAAoE;AACnG,QAAM,YAAY,EAAE,YAAY,OAAO,CAAC,MAAM,EAAE,YAAY,WAAW,EAAE;AACzE,QAAM,cAAc,EAAE,YAAY,OAAO,CAAC,MAAM,EAAE,YAAY,aAAa,EAAE;AAC7E,QAAM,QAAQ,KAAK,IAAI,KAAK,EAAE,SAAS,SAAS,IAAI,YAAY,KAAK,cAAc,KAAK,EAAE,SAAS,SAAS,EAAE;AAC9G,SAAO,EAAE,OAAO,OAAO,SAAS,KAAK,WAAW,SAAS,KAAK,aAAa,OAAO;AACpF;","names":[]}
1
+ {"version":3,"sources":["../src/core/trace.ts"],"sourcesContent":["import type { Experiment, Finding, Hypothesis, Insight, Requirement } from \"./types\";\n\nexport interface Graph {\n insights: Insight[];\n hypotheses: Hypothesis[];\n experiments: Experiment[];\n findings: Finding[];\n requirements: Requirement[];\n}\n\nexport interface Trail {\n /** Solution requirements: the stakeholder requirements they help meet. */\n stakeholderRequirements: Requirement[];\n findings: Finding[];\n experiments: Experiment[];\n hypotheses: Hypothesis[];\n insights: Insight[];\n}\n\n/** Walk a requirement back to every piece of evidence behind it. */\nexport function trailForRequirement(r: Requirement, g: Graph): Trail {\n const stakeholderRequirements = g.requirements.filter((x) => r.stakeholderIds?.includes(x.id));\n const findings = g.findings.filter((f) => r.findingIds.includes(f.id));\n const experiments = g.experiments.filter((e) => findings.some((f) => f.experimentIds.includes(e.id)));\n const hypIds = new Set([\n ...findings.flatMap((f) => f.hypothesisIds),\n ...experiments.map((e) => e.hypothesisId),\n ...(r.hypothesisIds ?? []),\n ]);\n const hypotheses = g.hypotheses.filter((h) => hypIds.has(h.id));\n const insIds = new Set([\n ...findings.flatMap((f) => f.insightIds),\n ...hypotheses.flatMap((h) => h.insightIds),\n ...(r.insightIds ?? []),\n ]);\n const insights = g.insights.filter((i) => insIds.has(i.id));\n return { stakeholderRequirements, findings, experiments, hypotheses, insights };\n}\n\n/** All node ids connected (upstream and downstream) to a given node. */\nexport function connectedIds(id: string, g: Graph): Set<string> {\n const edges: [string, string][] = [];\n g.hypotheses.forEach((h) => h.insightIds.forEach((i) => edges.push([i, h.id])));\n g.experiments.forEach((e) => edges.push([e.hypothesisId, e.id]));\n g.findings.forEach((f) => {\n f.experimentIds.forEach((e) => edges.push([e, f.id]));\n if (!f.experimentIds.length) f.hypothesisIds.forEach((h) => edges.push([h, f.id]));\n });\n g.requirements.forEach((r) => {\n r.findingIds.forEach((f) => edges.push([f, r.id]));\n // Directly created requirements link straight to their evidence and source hypotheses.\n r.insightIds?.forEach((i) => edges.push([i, r.id]));\n r.hypothesisIds?.forEach((h) => edges.push([h, r.id]));\n // Solution requirements meet stakeholder requirements.\n r.stakeholderIds?.forEach((s) => edges.push([s, r.id]));\n });\n\n const result = new Set<string>([id]);\n // upstream\n const up = [id];\n while (up.length) {\n const cur = up.pop()!;\n edges.forEach(([a, b]) => {\n if (b === cur && !result.has(a)) {\n result.add(a);\n up.push(a);\n }\n });\n }\n // downstream\n const down = [id];\n const seenDown = new Set([id]);\n while (down.length) {\n const cur = down.pop()!;\n edges.forEach(([a, b]) => {\n if (a === cur && !seenDown.has(b)) {\n seenDown.add(b);\n result.add(b);\n down.push(b);\n }\n });\n }\n return result;\n}\n\nexport function evidenceStrength(t: Trail): { score: number; label: \"Strong\" | \"Moderate\" | \"Weak\" } {\n const validated = t.experiments.filter((e) => e.verdict === \"validated\").length;\n const invalidated = t.experiments.filter((e) => e.verdict === \"invalidated\").length;\n const score = Math.min(100, t.insights.length * 8 + validated * 35 + invalidated * 20 + t.findings.length * 10);\n return { score, label: score >= 70 ? \"Strong\" : score >= 40 ? \"Moderate\" : \"Weak\" };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AAM;AACxB,UAAI,MAAM,OAAO,CAAC,SAAS,IAAI,CAAC,GAAG;AACjC,iBAAS,IAAI,CAAC;AACd,eAAO,IAAI,CAAC;AACZ,aAAK,KAAK,CAAC;AAAA,MACb;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEO,SAAS,iBAAiB,GAAoE;AACnG,QAAM,YAAY,EAAE,YAAY,OAAO,CAAC,MAAM,EAAE,YAAY,WAAW,EAAE;AACzE,QAAM,cAAc,EAAE,YAAY,OAAO,CAAC,MAAM,EAAE,YAAY,aAAa,EAAE;AAC7E,QAAM,QAAQ,KAAK,IAAI,KAAK,EAAE,SAAS,SAAS,IAAI,YAAY,KAAK,cAAc,KAAK,EAAE,SAAS,SAAS,EAAE;AAC9G,SAAO,EAAE,OAAO,OAAO,SAAS,KAAK,WAAW,SAAS,KAAK,aAAa,OAAO;AACpF;","names":[]}
package/dist/mcp.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runMcp
4
- } from "./chunk-DU4P7DDY.js";
5
- import "./chunk-3YZLRKZH.js";
4
+ } from "./chunk-4F24STNS.js";
5
+ import "./chunk-TXXV5YDG.js";
6
6
 
7
7
  // src/mcp/main.ts
8
8
  runMcp().catch((e) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groundwork-mcp",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Keep product evidence (insights, hypotheses, experiments, findings, requirements) as linked Markdown files in your repo, written by your own coding agent over MCP.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",