@isaacriehm/cairn-core 0.3.5 → 0.3.7

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.
@@ -0,0 +1,87 @@
1
+ /**
2
+ * `cairn_bulk_accept_attention` MCP tool.
3
+ *
4
+ * Wraps `bulkAcceptObvious` so the cairn-attention skill can drain
5
+ * obvious DEC drafts in one tool call instead of N rounds of
6
+ * `cairn_resolve_attention(choice="a")` per draft. Loads the project
7
+ * globs + pilot module from `.cairn/config.yaml` so the scoring
8
+ * heuristic has the same context the cli subcommand does.
9
+ *
10
+ * Returns a slim count-distribution shape — no draft bodies, no file
11
+ * paths beyond the accepted ID list. Skill renders the summary inline,
12
+ * then proceeds to interactive triage of the remaining (medium + low)
13
+ * drafts via the existing per-item flow.
14
+ */
15
+ import { existsSync, readFileSync } from "node:fs";
16
+ import { join } from "node:path";
17
+ import { parse as parseYaml } from "yaml";
18
+ import { z } from "zod";
19
+ import { bulkAcceptObvious, } from "../../attention/index.js";
20
+ const confidenceSchema = z.enum(["high", "medium", "low"]);
21
+ const inputShape = {
22
+ threshold: confidenceSchema.optional(),
23
+ dryRun: z.boolean().optional(),
24
+ };
25
+ function loadProjectGlobs(repoRoot) {
26
+ const configPath = join(repoRoot, ".cairn", "config.yaml");
27
+ if (!existsSync(configPath)) {
28
+ return { globs: {} };
29
+ }
30
+ let parsed;
31
+ try {
32
+ parsed = parseYaml(readFileSync(configPath, "utf8"));
33
+ }
34
+ catch {
35
+ return { globs: {} };
36
+ }
37
+ if (typeof parsed !== "object" || parsed === null)
38
+ return { globs: {} };
39
+ const cfg = parsed;
40
+ const globs = {};
41
+ const pickList = (v) => {
42
+ if (!Array.isArray(v))
43
+ return undefined;
44
+ return v.filter((x) => typeof x === "string");
45
+ };
46
+ const high = pickList(cfg["high_stakes_globs"]);
47
+ if (high !== undefined)
48
+ globs.high_stakes_globs = high;
49
+ const off = pickList(cfg["off_limits"]);
50
+ if (off !== undefined)
51
+ globs.off_limits = off;
52
+ const projectGlobs = cfg["project_globs"];
53
+ if (typeof projectGlobs === "object" && projectGlobs !== null) {
54
+ const pg = projectGlobs;
55
+ const route = pickList(pg["route_handler_globs"]);
56
+ if (route !== undefined)
57
+ globs.route_handler_globs = route;
58
+ const dto = pickList(pg["dto_globs"]);
59
+ if (dto !== undefined)
60
+ globs.dto_globs = dto;
61
+ const gen = pickList(pg["generator_source_globs"]);
62
+ if (gen !== undefined)
63
+ globs.generator_source_globs = gen;
64
+ const hi = pickList(pg["high_stakes_globs"]);
65
+ if (hi !== undefined && globs.high_stakes_globs === undefined) {
66
+ globs.high_stakes_globs = hi;
67
+ }
68
+ }
69
+ const pilot = typeof cfg["pilot_module"] === "string" ? cfg["pilot_module"] : undefined;
70
+ return pilot !== undefined ? { globs, pilotModule: pilot } : { globs };
71
+ }
72
+ export const bulkAcceptAttentionTool = {
73
+ name: "cairn_bulk_accept_attention",
74
+ description: "Score every DEC draft + invariant in `.cairn/ground/decisions/_inbox/` and `.cairn/ground/invariants/` against a confidence heuristic (file in high_stakes_globs / pilot module / route or dto globs, prose substantiveness, decision verbs, JSDoc tags). Auto-promote DEC drafts at or above `threshold` (default 'high') out of the inbox to accepted state and rebuild the decisions ledger. Stamp `capture_confidence` on every draft + invariant so subsequent attention surfaces can sort. Use this once per adoption to drain the obvious classifications before per-item triage. Returns count distributions and the accepted ID list. `dryRun: true` reports the same distribution without writing.",
75
+ inputSchema: inputShape,
76
+ handler: async (ctx, input) => {
77
+ const { globs, pilotModule } = loadProjectGlobs(ctx.repoRoot);
78
+ return bulkAcceptObvious({
79
+ repoRoot: ctx.repoRoot,
80
+ globs,
81
+ ...(pilotModule !== undefined ? { pilotModule } : {}),
82
+ threshold: input.threshold ?? "high",
83
+ ...(input.dryRun !== undefined ? { dryRun: input.dryRun } : {}),
84
+ });
85
+ },
86
+ };
87
+ //# sourceMappingURL=bulk-accept-attention.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulk-accept-attention.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opicTool } from "./canonical-for-topic.js";
3
4
  import { decisionGetTool } from "./decision-get.js";
4
5
  import { decisionsForSymbolTool } from "./decisions-for-symbol.js";
@@ -37,6 +38,7 @@ export const allTools = [
37
38
  archiveTool,
38
39
  // Write — plugin-era
39
40
  resolveAttentionTool,
41
+ bulkAcceptAttentionTool,
40
42
  // Write — init pipeline (v0.2.0 MCP-native init)
41
43
  initResumeTool,
42
44
  ...initPhaseTools,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAA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C9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,yBAAyB;IACzB,eAAmC;IACnC,oBAAwC;IACxC,sBAA0C;IAC1C,qBAAyC;IACzC,aAAiC;IACjC,mBAAuC;IACvC,gBAAoC;IACpC,qBAAyC;IACzC,6BAA6B;IAC7B,UAA8B;IAC9B,YAAgC;IAChC,WAA+B;IAC/B,4BAA4B;IAC5B,gBAAoC;IACpC,QAAQ;IACR,kBAAsC;IACtC,cAAkC;IAClC,WAA+B;IAC/B,qBAAqB;IACrB,oBAAwC;IACxC,uBAA2C;IAC3C,iDAAiD;IACjD,cAAkC;IAClC,GAAI,cAAqC;CAC1C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isaacriehm/cairn-core",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Cairn core — state + context layer. Curated `.cairn/ground/` (decisions, §INV invariants, canonical-map, brand, quality-grades), MCP server, init wizard, hook runners, sensors, GC drift sweep.",
5
5
  "author": "Isaac Riehm",
6
6
  "license": "MIT",