@kurvball/ashlar 1.4.0 → 1.5.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/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ changesets merged since the release before it, under its version and release dat
6
6
  and patch changes; see [RELEASING.md](RELEASING.md). Versions up to 1.0.1 follow
7
7
  [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/).
8
8
 
9
+ ## 1.5.0
10
+
11
+ _Released 2026-12-04._
12
+
13
+ ### Minor Changes
14
+
15
+ - `ashlar mcp` serves `brief`, `check`, `affected`, `map` and `onboard` as MCP tools on stdio. Each takes its command's options and answers with the object its command prints with `--json`, with the command's v1 schema as its output schema. The Ashlar skill, `skill/ashlar/SKILL.md` in the package and `/SKILL.md` on the docs site, teaches agents to brief before writing and check before pushing, through the server or the commands.
16
+
9
17
  ## 1.4.0
10
18
 
11
19
  _Released 2026-12-04._
package/README.md CHANGED
@@ -108,6 +108,7 @@ wrong type, gets one line saying which key and what is wrong.
108
108
  | `ashlar skill onboard` | Prints the skill an agent follows to read its brief and keep decisions. |
109
109
  | `ashlar dependents <files>` | Lists what reaches each file, for Rehearse's `rehearse list --affected`. |
110
110
  | `ashlar rehearse` | Prints the blocks of `rehearse.yaml` Ashlar fills: each reach script a flow. |
111
+ | `ashlar mcp` | Serves `brief`, `check`, `affected`, `map` and `onboard` as MCP tools, for agents. |
111
112
 
112
113
  A feature's reach script, `reach.ts` in its folder, lists the steps a person takes to get to it in the running
113
114
  app. `affected` follows imports, stylesheets, setup files and builds. `skill verify --write` writes the skill
@@ -0,0 +1,40 @@
1
+ import { type AffectedReport } from './affected.ts';
2
+ import { type CheckOptions, type CheckReport } from './check.ts';
3
+ import { type Loaded } from './config.ts';
4
+ import { type Feature } from './features.ts';
5
+ import { type Brief } from './onboard/brief.ts';
6
+ import { type OnboardReport } from './onboard/onboard.ts';
7
+ export declare function checkAnswer(config: Loaded, options: CheckOptions): {
8
+ checked: CheckReport;
9
+ warnings: string[];
10
+ json: {
11
+ ok: boolean;
12
+ seconds: number;
13
+ files: number;
14
+ baseline: import("./check.ts").BaselineState;
15
+ rules: import("./check.ts").RuleTotal[];
16
+ rises: import("./check.ts").RiseReport[];
17
+ taken: import("./baseline.ts").Rise[];
18
+ slack: number;
19
+ moves: import("./git.ts").Renamed[];
20
+ version: 1;
21
+ };
22
+ };
23
+ export declare function affectedAnswer(config: Loaded, files: readonly string[], since: string | undefined): {
24
+ report: AffectedReport;
25
+ json: {
26
+ changed: string[];
27
+ deleted: string[];
28
+ tests: string[];
29
+ features: import("./affected.ts").AffectedFeature[];
30
+ unreached: string[];
31
+ seconds: number;
32
+ version: 1;
33
+ };
34
+ };
35
+ export declare function mapAnswer(config: Loaded): {
36
+ features: Feature[];
37
+ json: import("./map.ts").FeatureMap;
38
+ };
39
+ export declare function onboardAnswer(config: Loaded, checkOnly: boolean): OnboardReport;
40
+ export declare function briefAnswer(config: Loaded, files: readonly string[], cwd?: string): Brief;
@@ -0,0 +1,30 @@
1
+ import { affected } from './affected.js';
2
+ import { check } from './check.js';
3
+ import { AshlarError } from './config.js';
4
+ import { buildMap, featuresOf } from './features.js';
5
+ import { brief } from './onboard/brief.js';
6
+ import { onboard } from './onboard/onboard.js';
7
+ export function checkAnswer(config, options) {
8
+ const checked = check(config, options);
9
+ const { warnings, ...report } = checked;
10
+ return { checked, warnings, json: { version: 1, ...report } };
11
+ }
12
+ export function affectedAnswer(config, files, since) {
13
+ if (files.length === 0 && since === undefined) {
14
+ throw new AshlarError('Name the changed files, or give `--since <ref>`.');
15
+ }
16
+ const report = affected(config, { files: [...files], since });
17
+ return { report, json: { version: 1, ...report } };
18
+ }
19
+ export function mapAnswer(config) {
20
+ const features = featuresOf(config);
21
+ return { features, json: buildMap(config, features) };
22
+ }
23
+ export function onboardAnswer(config, checkOnly) {
24
+ return onboard(config, { check: checkOnly });
25
+ }
26
+ export function briefAnswer(config, files, cwd) {
27
+ if (files.length === 0)
28
+ throw new AshlarError('Name the files or folders the agent will change.');
29
+ return brief(config, files, cwd);
30
+ }
package/dist/cli.js CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  import { readFileSync } from 'node:fs';
3
3
  import { relative } from 'node:path';
4
- import { affected } from './affected.js';
5
- import { check } from './check.js';
4
+ import { affectedAnswer, briefAnswer, checkAnswer, mapAnswer, onboardAnswer } from './answers.js';
6
5
  import { AshlarError, loadConfig } from './config.js';
7
- import { buildMap, featuresOf, unreadText } from './features.js';
6
+ import { serve } from './mcp.js';
7
+ import { featuresOf, unreadText } from './features.js';
8
8
  import { ledgerOf, ledgerText } from './ledger.js';
9
9
  import { mapText } from './map.js';
10
10
  import { move } from './move.js';
11
11
  import { driveFeature, driveOf, featureNamed, isScheme, runsText, SCHEMES } from './reachDrive.js';
12
12
  import { affectedText, checkText, movedText } from './report.js';
13
13
  import { USAGE } from './usage.js';
14
- import { brief, briefText } from './onboard/brief.js';
15
- import { onboard, onboardText } from './onboard/onboard.js';
14
+ import { briefText } from './onboard/brief.js';
15
+ import { onboardText } from './onboard/onboard.js';
16
16
  import { snapshot, snapshotText } from './onboard/snapshot.js';
17
17
  import { dependentsOf, dependentsText } from './rehearse/dependents.js';
18
18
  import { fillText, rehearseFill } from './rehearse/fill.js';
@@ -30,6 +30,7 @@ const FLAGS = {
30
30
  snapshot: ['json'],
31
31
  dependents: ['json'],
32
32
  rehearse: ['json'],
33
+ mcp: [],
33
34
  };
34
35
  const VALUED = new Map([
35
36
  ['since', 'a ref'],
@@ -90,25 +91,24 @@ async function main(args) {
90
91
  throw new AshlarError(`\`ashlar ${command}\` takes no ${unknown.map((f) => `--${f}`).join(', ')}: it takes ${named}.`);
91
92
  }
92
93
  }
94
+ if (command === 'mcp') {
95
+ if (positional.length > 0)
96
+ throw new AshlarError('`ashlar mcp` takes no files.');
97
+ await serve();
98
+ return 0;
99
+ }
93
100
  const config = await loadConfig();
94
101
  if (command === 'check') {
95
- const checked = check(config, {
96
- shrink: flags.has('shrink'),
97
- acceptRise: flags.has('accept-rise'),
98
- since,
99
- });
100
- const { warnings, ...report } = checked;
101
- print(json, { version: 1, ...report }, checkText(checked, relative(process.cwd(), config.baseline), since));
102
+ const options = { shrink: flags.has('shrink'), acceptRise: flags.has('accept-rise'), since };
103
+ const { checked, warnings, json: answer } = checkAnswer(config, options);
104
+ print(json, answer, checkText(checked, relative(process.cwd(), config.baseline), since));
102
105
  for (const warning of warnings)
103
106
  process.stderr.write(`Warning: ${warning}\n`);
104
- return report.ok ? 0 : 1;
107
+ return answer.ok ? 0 : 1;
105
108
  }
106
109
  if (command === 'affected') {
107
- if (positional.length === 0 && since === undefined) {
108
- throw new AshlarError('Name the changed files, or give `--since <ref>`.');
109
- }
110
- const report = affected(config, { files: positional, since });
111
- print(json, { version: 1, ...report }, affectedText(report));
110
+ const { report, json: answer } = affectedAnswer(config, positional, since);
111
+ print(json, answer, affectedText(report));
112
112
  if (!json && report.unreached.length > 0) {
113
113
  process.stderr.write(`No test reaches ${report.unreached.join(', ')}.\n`);
114
114
  }
@@ -131,22 +131,19 @@ async function main(args) {
131
131
  return 0;
132
132
  }
133
133
  if (command === 'map') {
134
- const features = featuresOf(config);
135
- const map = buildMap(config, features);
134
+ const { features, json: map } = mapAnswer(config);
136
135
  const unreadable = new Set(features.filter((f) => f.reach && !f.reach.ok).map((f) => f.folder));
137
136
  print(json, map, `${mapText(map, unreadable)}${unreadText(features)}`);
138
137
  return 0;
139
138
  }
140
139
  if (command === 'onboard') {
141
140
  const check = flags.has('check');
142
- const report = onboard(config, { check });
141
+ const report = onboardAnswer(config, check);
143
142
  print(json, report, onboardText(report, check));
144
143
  return report.ok ? 0 : 1;
145
144
  }
146
145
  if (command === 'brief') {
147
- if (positional.length === 0)
148
- throw new AshlarError('Name the files or folders the agent will change.');
149
- const said = brief(config, positional);
146
+ const said = briefAnswer(config, positional);
150
147
  print(json, said, briefText(said));
151
148
  return 0;
152
149
  }
package/dist/config.js CHANGED
@@ -6,7 +6,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
6
6
  }
7
7
  return path;
8
8
  };
9
- import { existsSync, realpathSync } from 'node:fs';
9
+ import { existsSync, realpathSync, statSync } from 'node:fs';
10
10
  import { basename, dirname, join, resolve } from 'node:path';
11
11
  import { pathToFileURL } from 'node:url';
12
12
  import { checkConfig } from './configCheck.js';
@@ -91,7 +91,8 @@ export async function loadConfig(from = process.cwd()) {
91
91
  const file = findConfig(from);
92
92
  if (!file)
93
93
  throw new AshlarError(`There is no ${CONFIG_FILE} in ${resolve(from)} or above it.`);
94
- const loaded = (await import(__rewriteRelativeImportExtension(pathToFileURL(file).href)));
94
+ const fresh = `${pathToFileURL(file).href}?v=${statSync(file).mtimeMs}`;
95
+ const loaded = (await import(__rewriteRelativeImportExtension(fresh)));
95
96
  if (!loaded.default)
96
97
  throw new AshlarError(`${file} has no default export: export its config.`);
97
98
  return settle(loaded.default, realpathSync(dirname(file)), basename(file));
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ import type { Readable, Writable } from 'node:stream';
2
+ import { type Loaded } from './config.ts';
3
+ export declare const PROTOCOL_VERSIONS: readonly ['2025-11-25', '2025-06-18', '2025-03-26'];
4
+ export declare const INSTRUCTIONS = "Ashlar checks a TypeScript repository against rules that came from corrections, and holds each file to a baseline that only shrinks. Brief before you write, and check before you push: the skill at skill/ashlar/SKILL.md in the package teaches the loop.";
5
+ type Kind = 'boolean' | 'string' | 'paths';
6
+ interface Argument {
7
+ kind: Kind;
8
+ description: string;
9
+ }
10
+ interface Answer {
11
+ json: object;
12
+ warnings?: readonly string[];
13
+ }
14
+ interface Tool {
15
+ name: string;
16
+ description: string;
17
+ args: Record<string, Argument>;
18
+ required?: string[];
19
+ readOnly: boolean;
20
+ run: (config: Loaded, args: Record<string, unknown>) => Answer;
21
+ }
22
+ export declare const TOOLS: readonly Tool[];
23
+ export declare function outputSchemaOf(name: string): Record<string, unknown>;
24
+ export declare function toolList(): Record<string, unknown>[];
25
+ export declare function callTool(name: string, given: unknown, cwd?: string, log?: NodeJS.WriteStream & {
26
+ fd: 2;
27
+ }): Promise<{
28
+ content: {
29
+ type: string;
30
+ text: string;
31
+ }[];
32
+ isError: boolean;
33
+ } | {
34
+ content: {
35
+ type: string;
36
+ text: string;
37
+ }[];
38
+ structuredContent: object;
39
+ isError: boolean;
40
+ } | null>;
41
+ export declare function serve(input?: Readable, output?: Writable): Promise<void>;
42
+ export {};
package/dist/mcp.js ADDED
@@ -0,0 +1,222 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { createInterface } from 'node:readline';
3
+ import { affectedAnswer, briefAnswer, checkAnswer, mapAnswer, onboardAnswer } from './answers.js';
4
+ import { AshlarError, loadConfig } from './config.js';
5
+ export const PROTOCOL_VERSIONS = ['2025-11-25', '2025-06-18', '2025-03-26'];
6
+ export const INSTRUCTIONS = 'Ashlar checks a TypeScript repository against rules that came from corrections, and holds each file to a baseline that only shrinks. Brief before you write, and check before you push: the skill at skill/ashlar/SKILL.md in the package teaches the loop.';
7
+ const paths = (args, name) => args[name] ?? [];
8
+ const flag = (args, name) => args[name] === true;
9
+ const text = (args, name) => args[name];
10
+ export const TOOLS = [
11
+ {
12
+ name: 'brief',
13
+ description: 'What an agent needs before it changes some files: the data rules, the rules that apply there, the folder rules and gotchas, the decisions, the features and the open questions. Answers with brief.v1.json.',
14
+ args: { paths: { kind: 'paths', description: 'The files or folders the agent will change.' } },
15
+ required: ['paths'],
16
+ readOnly: true,
17
+ run: (config, args) => ({ json: briefAnswer(config, paths(args, 'paths')) }),
18
+ },
19
+ {
20
+ name: 'check',
21
+ description: "Runs the rules and the import graph, and answers ok: false when a file's count rises above what the baseline holds for it. A rise is a finding, not an error. Answers with check.v1.json.",
22
+ args: {
23
+ shrink: {
24
+ kind: 'boolean',
25
+ description: 'Write the baseline: take it the first time, then only lower each file’s counts.',
26
+ },
27
+ acceptRise: {
28
+ kind: 'boolean',
29
+ description: 'Take each count that rose into the baseline. Ask a person first.',
30
+ },
31
+ since: {
32
+ kind: 'string',
33
+ description: 'Measure the lines a change wrote from where it left this ref rather than main, such as a release line.',
34
+ },
35
+ },
36
+ readOnly: false,
37
+ run: (config, args) => {
38
+ const { json, warnings } = checkAnswer(config, {
39
+ shrink: flag(args, 'shrink'),
40
+ acceptRise: flag(args, 'acceptRise'),
41
+ since: text(args, 'since'),
42
+ });
43
+ return { json, warnings };
44
+ },
45
+ },
46
+ {
47
+ name: 'affected',
48
+ description: 'Lists the tests that reach the files, or the files changed since a ref, through imports, stylesheets, setup files and builds. Answers with affected.v1.json.',
49
+ args: {
50
+ files: { kind: 'paths', description: 'The changed files.' },
51
+ since: { kind: 'string', description: 'Take the files changed since this ref instead, or as well.' },
52
+ },
53
+ readOnly: true,
54
+ run: (config, args) => ({ json: affectedAnswer(config, paths(args, 'files'), text(args, 'since')).json }),
55
+ },
56
+ {
57
+ name: 'map',
58
+ description: 'Lists each feature folder in the layout: its name, its reach script and its proofs, the tests in it. Answers with map.v1.json.',
59
+ args: {},
60
+ readOnly: true,
61
+ run: (config) => ({ json: mapAnswer(config).json }),
62
+ },
63
+ {
64
+ name: 'onboard',
65
+ description: 'Writes the onboarding guide from the map, DECISIONS.md and .claude/rules/, with every unknown as a question routed to its owner. With check, answers ok: false when the guide is stale, and writes nothing. Answers with onboard.v1.json.',
66
+ args: {
67
+ check: { kind: 'boolean', description: 'Only check that the guide is current, and write nothing.' },
68
+ },
69
+ readOnly: false,
70
+ run: (config, args) => ({ json: onboardAnswer(config, flag(args, 'check')) }),
71
+ },
72
+ ];
73
+ const SCHEMA_DIR = new URL('../schema/', import.meta.url);
74
+ export function outputSchemaOf(name) {
75
+ return JSON.parse(readFileSync(new URL(`${name}.v1.json`, SCHEMA_DIR), 'utf8'));
76
+ }
77
+ function inputSchemaOf(tool) {
78
+ const properties = Object.fromEntries(Object.entries(tool.args).map(([name, arg]) => [
79
+ name,
80
+ arg.kind === 'paths'
81
+ ? { type: 'array', items: { type: 'string' }, description: arg.description }
82
+ : { type: arg.kind, description: arg.description },
83
+ ]));
84
+ return {
85
+ type: 'object',
86
+ properties,
87
+ ...(tool.required ? { required: tool.required } : {}),
88
+ additionalProperties: false,
89
+ };
90
+ }
91
+ export function toolList() {
92
+ return TOOLS.map((tool) => ({
93
+ name: tool.name,
94
+ description: tool.description,
95
+ inputSchema: inputSchemaOf(tool),
96
+ outputSchema: outputSchemaOf(tool.name),
97
+ annotations: {
98
+ readOnlyHint: tool.readOnly,
99
+ ...(tool.readOnly ? {} : { destructiveHint: false }),
100
+ idempotentHint: true,
101
+ openWorldHint: false,
102
+ },
103
+ }));
104
+ }
105
+ function argumentsOf(tool, given) {
106
+ if (given === undefined || given === null)
107
+ given = {};
108
+ if (typeof given !== 'object' || Array.isArray(given)) {
109
+ throw new AshlarError(`Give \`${tool.name}\` its arguments as an object.`);
110
+ }
111
+ const args = given;
112
+ const takes = Object.keys(tool.args);
113
+ for (const [name, value] of Object.entries(args)) {
114
+ const arg = tool.args[name];
115
+ if (!arg) {
116
+ const named = takes.length ? takes.join(', ') : 'none';
117
+ throw new AshlarError(`\`${tool.name}\` takes no ${name}: it takes ${named}.`);
118
+ }
119
+ const fits = arg.kind === 'paths'
120
+ ? Array.isArray(value) && value.every((entry) => typeof entry === 'string')
121
+ : typeof value === arg.kind;
122
+ if (!fits) {
123
+ const wanted = arg.kind === 'paths' ? 'a list of paths' : arg.kind === 'string' ? 'a string' : 'true or false';
124
+ throw new AshlarError(`Give \`${name}\` ${wanted}.`);
125
+ }
126
+ }
127
+ for (const name of tool.required ?? []) {
128
+ if (args[name] === undefined)
129
+ throw new AshlarError(`\`${tool.name}\` needs ${name}.`);
130
+ }
131
+ return args;
132
+ }
133
+ const said = (message) => ({ content: [{ type: 'text', text: message }], isError: true });
134
+ export async function callTool(name, given, cwd = process.cwd(), log = process.stderr) {
135
+ const tool = TOOLS.find((entry) => entry.name === name);
136
+ if (!tool)
137
+ return null;
138
+ try {
139
+ const args = argumentsOf(tool, given);
140
+ const config = await loadConfig(cwd);
141
+ const { json, warnings = [] } = tool.run(config, args);
142
+ for (const warning of warnings)
143
+ log.write(`Warning: ${warning}\n`);
144
+ return {
145
+ content: [{ type: 'text', text: JSON.stringify(json) }],
146
+ structuredContent: json,
147
+ isError: false,
148
+ };
149
+ }
150
+ catch (error) {
151
+ if (error instanceof AshlarError)
152
+ return said(error.message);
153
+ log.write(`${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`);
154
+ return said(`Ashlar failed: ${error instanceof Error ? error.message : String(error)}`);
155
+ }
156
+ }
157
+ const VERSION = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
158
+ async function reply(message) {
159
+ const id = message.id;
160
+ const answer = (result) => ({ jsonrpc: '2.0', id, result });
161
+ const fail = (code, text) => ({
162
+ jsonrpc: '2.0',
163
+ id: id ?? null,
164
+ error: { code, message: text },
165
+ });
166
+ if (message.jsonrpc !== '2.0' || typeof message.method !== 'string') {
167
+ return id === undefined || message.method === undefined ? null : fail(-32600, 'Invalid request');
168
+ }
169
+ if (id === undefined)
170
+ return null;
171
+ const params = message.params ?? {};
172
+ switch (message.method) {
173
+ case 'initialize': {
174
+ const asked = params.protocolVersion;
175
+ const protocolVersion = PROTOCOL_VERSIONS.find((version) => version === asked) ?? PROTOCOL_VERSIONS[0];
176
+ return answer({
177
+ protocolVersion,
178
+ capabilities: { tools: { listChanged: false } },
179
+ serverInfo: { name: 'ashlar', version: VERSION },
180
+ instructions: INSTRUCTIONS,
181
+ });
182
+ }
183
+ case 'ping':
184
+ return answer({});
185
+ case 'tools/list':
186
+ return answer({ tools: toolList() });
187
+ case 'tools/call': {
188
+ if (typeof params.name !== 'string')
189
+ return fail(-32602, 'Name the tool to call.');
190
+ const result = await callTool(params.name, params.arguments);
191
+ return result ? answer(result) : fail(-32602, `Ashlar has no ${params.name} tool.`);
192
+ }
193
+ default:
194
+ return fail(-32601, `Ashlar's server has no method ${message.method}.`);
195
+ }
196
+ }
197
+ export async function serve(input = process.stdin, output = process.stdout) {
198
+ const write = output.write.bind(output);
199
+ if (output === process.stdout) {
200
+ process.stdout.write = process.stderr.write.bind(process.stderr);
201
+ }
202
+ const send = (message) => write(`${JSON.stringify(message)}\n`);
203
+ for await (const line of createInterface({ input, crlfDelay: Infinity })) {
204
+ if (line.trim() === '')
205
+ continue;
206
+ let message;
207
+ try {
208
+ message = JSON.parse(line);
209
+ }
210
+ catch {
211
+ send({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } });
212
+ continue;
213
+ }
214
+ if (typeof message !== 'object' || message === null || Array.isArray(message)) {
215
+ send({ jsonrpc: '2.0', id: null, error: { code: -32600, message: 'Invalid request' } });
216
+ continue;
217
+ }
218
+ const response = await reply(message);
219
+ if (response)
220
+ send(response);
221
+ }
222
+ }
package/dist/usage.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const USAGE = "Usage:\n ashlar check [--shrink] [--accept-rise] [--since <ref>] [--json]\n Runs the rules and the import graph, and fails when a file's count rises above what the\n baseline holds for that file. A file the baseline doesn't name holds none.\n --shrink writes the baseline: it takes it the first time, then only lowers each file's counts.\n A file that is gone drops out, and a file git saw renamed takes its counts to its new name.\n --accept-rise takes each count that rose into the baseline, and says what it took in.\n --since <ref> measures the lines a change touched, and the files it renamed, from where it\n left <ref> rather than main: on a pull request into a release line, give that line.\n ashlar affected [files...] [--since <ref>] [--json]\n Lists the tests that reach the files, or the files changed since <ref>, through imports,\n stylesheets, setup files and builds. A deleted file lists the tests that imported it,\n and --json lists the deleted files apart.\n ashlar move <from> <to> [<from> <to> ...] [--accept-rise] [--json]\n Moves a file's counts in the baseline to its new name, or those of every file in a folder.\n Each file keeps what it holds now, up to what the baseline held for it.\n It refuses a move that takes in new breaks, unless --accept-rise is given.\n ashlar ledger [--json]\n Lists Ashlar's ledger: each rule and each check from the import graph, what it corrected, the\n case it came from as a test, the prose it replaced and the message agents read.\n ashlar map [--json]\n Lists each feature folder in the layout: its name, its reach and its proofs, the tests in it.\n --json prints it as JSON, in the feature map's schema.\n ashlar drive <feature> [--scheme light|dark] [--json]\n ashlar drive --all [--scheme light|dark] [--json]\n Walks a feature's reach script, step by step, through the config's drive command, or through\n rehearse drive when the project has a rehearse.yaml and names none. It stops at the first step\n that fails, saying which and why. --all walks every feature's.\n ashlar onboard [--check] [--json]\n Writes the onboarding guide from the map, DECISIONS.md and .claude/rules/: what the system is, a\n page per area, and every unknown as a question routed to its owner. --check fails when the\n guide is stale or was edited by hand, and writes nothing.\n ashlar brief <paths...> [--json]\n Prints what an agent needs before it changes those files: the data rules, the rules that apply\n there, the folder rules and gotchas, the decisions, the features and the open questions. Never\n access lines, and never a secret-shaped value.\n ashlar snapshot [--json]\n Prints where things stand today: the ratchet, the map, the decisions and questions, and each\n area's recent commits. It writes nothing.\n ashlar dependents <files...> [--json]\n Lists every file that reaches each file through imports, directly or not, and the reach script\n of each feature whose folder they touch: what Rehearse reads for rehearse list --affected.\n --json prints it in Rehearse's dependents contract.\n ashlar rehearse [--json]\n Prints the blocks of rehearse.yaml Ashlar fills: each feature's reach script as a flow that\n covers its folder. --json adds each flow as Rehearse reads it.\n ashlar skill verify|onboard [--write] [--force]\n Prints a skill for agents. verify: how an agent checks its own work with the map and drive,\n and shows what it made, through the attach section the config names, if any. onboard: how an\n agent reads its brief before it changes files, and keeps what people decide.\n --write writes it into .claude/skills/<name>/SKILL.md, and --force replaces one that differs.\n\n ashlar --version\n Prints the version of Ashlar that runs.\n";
1
+ export declare const USAGE = "Usage:\n ashlar check [--shrink] [--accept-rise] [--since <ref>] [--json]\n Runs the rules and the import graph, and fails when a file's count rises above what the\n baseline holds for that file. A file the baseline doesn't name holds none.\n --shrink writes the baseline: it takes it the first time, then only lowers each file's counts.\n A file that is gone drops out, and a file git saw renamed takes its counts to its new name.\n --accept-rise takes each count that rose into the baseline, and says what it took in.\n --since <ref> measures the lines a change touched, and the files it renamed, from where it\n left <ref> rather than main: on a pull request into a release line, give that line.\n ashlar affected [files...] [--since <ref>] [--json]\n Lists the tests that reach the files, or the files changed since <ref>, through imports,\n stylesheets, setup files and builds. A deleted file lists the tests that imported it,\n and --json lists the deleted files apart.\n ashlar move <from> <to> [<from> <to> ...] [--accept-rise] [--json]\n Moves a file's counts in the baseline to its new name, or those of every file in a folder.\n Each file keeps what it holds now, up to what the baseline held for it.\n It refuses a move that takes in new breaks, unless --accept-rise is given.\n ashlar ledger [--json]\n Lists Ashlar's ledger: each rule and each check from the import graph, what it corrected, the\n case it came from as a test, the prose it replaced and the message agents read.\n ashlar map [--json]\n Lists each feature folder in the layout: its name, its reach and its proofs, the tests in it.\n --json prints it as JSON, in the feature map's schema.\n ashlar drive <feature> [--scheme light|dark] [--json]\n ashlar drive --all [--scheme light|dark] [--json]\n Walks a feature's reach script, step by step, through the config's drive command, or through\n rehearse drive when the project has a rehearse.yaml and names none. It stops at the first step\n that fails, saying which and why. --all walks every feature's.\n ashlar onboard [--check] [--json]\n Writes the onboarding guide from the map, DECISIONS.md and .claude/rules/: what the system is, a\n page per area, and every unknown as a question routed to its owner. --check fails when the\n guide is stale or was edited by hand, and writes nothing.\n ashlar brief <paths...> [--json]\n Prints what an agent needs before it changes those files: the data rules, the rules that apply\n there, the folder rules and gotchas, the decisions, the features and the open questions. Never\n access lines, and never a secret-shaped value.\n ashlar mcp\n Serves brief, check, affected, map and onboard as MCP tools on stdio, for agents. Each tool\n takes its command's options and answers with the object its command prints with --json.\n ashlar snapshot [--json]\n Prints where things stand today: the ratchet, the map, the decisions and questions, and each\n area's recent commits. It writes nothing.\n ashlar dependents <files...> [--json]\n Lists every file that reaches each file through imports, directly or not, and the reach script\n of each feature whose folder they touch: what Rehearse reads for rehearse list --affected.\n --json prints it in Rehearse's dependents contract.\n ashlar rehearse [--json]\n Prints the blocks of rehearse.yaml Ashlar fills: each feature's reach script as a flow that\n covers its folder. --json adds each flow as Rehearse reads it.\n ashlar skill verify|onboard [--write] [--force]\n Prints a skill for agents. verify: how an agent checks its own work with the map and drive,\n and shows what it made, through the attach section the config names, if any. onboard: how an\n agent reads its brief before it changes files, and keeps what people decide.\n --write writes it into .claude/skills/<name>/SKILL.md, and --force replaces one that differs.\n\n ashlar --version\n Prints the version of Ashlar that runs.\n";
package/dist/usage.js CHANGED
@@ -34,6 +34,9 @@ export const USAGE = `Usage:
34
34
  Prints what an agent needs before it changes those files: the data rules, the rules that apply
35
35
  there, the folder rules and gotchas, the decisions, the features and the open questions. Never
36
36
  access lines, and never a secret-shaped value.
37
+ ashlar mcp
38
+ Serves brief, check, affected, map and onboard as MCP tools on stdio, for agents. Each tool
39
+ takes its command's options and answers with the object its command prints with --json.
37
40
  ashlar snapshot [--json]
38
41
  Prints where things stand today: the ratchet, the map, the decisions and questions, and each
39
42
  area's recent commits. It writes nothing.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kurvball/ashlar",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "The rules for building software with agents: lint rules, an import graph with a shrink-only ratchet, a feature map and onboarding for TypeScript projects.",
5
5
  "keywords": [
6
6
  "agents",
@@ -46,6 +46,7 @@
46
46
  "dist",
47
47
  "ledger.json",
48
48
  "schema",
49
+ "skill",
49
50
  "CHANGELOG.md"
50
51
  ],
51
52
  "dependencies": {
@@ -53,6 +54,7 @@
53
54
  },
54
55
  "devDependencies": {
55
56
  "@changesets/cli": "3.0.3",
57
+ "@modelcontextprotocol/sdk": "1.32.2",
56
58
  "@types/node": "^22.20.5",
57
59
  "ajv": "8.20.0",
58
60
  "prettier": "3.9.10",
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: ashlar
3
+ description: Use in a TypeScript repository with an `ashlar.config.ts` at its root, often beside an `ashlar.baseline.json`. Brief before you change files, find the tests a change reaches, and check before you push. Answers "what rules apply to these files?", "which tests should I run?" and "did my change make a file worse?".
4
+ ---
5
+
6
+ # Ashlar
7
+
8
+ Ashlar checks a TypeScript repository against rules that came from corrections, and holds each file to a
9
+ baseline that only shrinks: old code stays as it is, and no file gets worse. Each rule's message says what to
10
+ do instead.
11
+
12
+ Every step below works two ways, and both answer with the same JSON object:
13
+
14
+ - **The MCP server,** when your client has it: call the tool named in the step. The repository's `.mcp.json`
15
+ starts it with `npx --no-install ashlar mcp`.
16
+ - **The command,** when it doesn't: run it with `--json` through the package manager, `pnpm exec ashlar`,
17
+ `yarn ashlar` or `npx --no-install ashlar`. Never a bare `npx ashlar`: that package is someone else's.
18
+
19
+ ## The loop
20
+
21
+ 1. **Brief before you write.** Name the files or folders you will change.
22
+ - Tool: `brief` with `{ "paths": ["src/cart"] }`.
23
+ - Command: `ashlar brief src/cart --json`.
24
+
25
+ Read every part of the answer before you write a line:
26
+ - `rules` and `dataRules`: the rules that hold there, each with the `message` that says what to do instead;
27
+ - `folderRules`: the folder's own rules and its gotchas, and a `guard` when a scenario tries one on every
28
+ change;
29
+ - `decisions`: what was decided, by whom, and when;
30
+ - `features`: the feature folders you touch, each with its reach script;
31
+ - `questions`: what nobody has answered yet. Don't guess an answer; ask its `owner`.
32
+
33
+ 2. **Write the change.** Follow the brief. A comment is a break: say it with a name or a test instead.
34
+
35
+ 3. **Run the tests the change reaches.**
36
+ - Tool: `affected` with `{ "since": "origin/main" }`, or `{ "files": [...] }`.
37
+ - Command: `ashlar affected --since origin/main --json`.
38
+
39
+ Run each test in `tests`. A file in `unreached` has no test that reaches it: write one, or say so in your
40
+ report. Each entry in `features` names the reach script that walks that feature in the app.
41
+
42
+ 4. **Check before you push.**
43
+ - Tool: `check`, with `{ "since": "origin/release/1.x" }` on a pull request into a release line.
44
+ - Command: `ashlar check --json`, or `ashlar check --since origin/release/1.x --json`.
45
+
46
+ `ok: true` means no file got worse. With `ok: false`, each entry in `rises` names the `rule`, the `file`, its
47
+ `count` against the `baseline`, the `breaks` (each `fresh` one is on a line you changed) and the `message`.
48
+ Do what the message says, then check again. A rise is a finding, not an error: the tool answers it with
49
+ `isError: false`.
50
+
51
+ 5. **Lower the baseline when you fixed breaks.** When `slack` is above zero, run `check` with
52
+ `{ "shrink": true }` (`ashlar check --shrink`) and commit `ashlar.baseline.json` with the fix.
53
+
54
+ ## Rules
55
+
56
+ - Never raise the baseline yourself. `acceptRise` (`--accept-rise`) takes a rise in for good: ask a person
57
+ first, and say which rule and file.
58
+ - Never edit `ashlar.baseline.json` or the onboarding guide by hand. `check --shrink` writes the baseline, and
59
+ `onboard` writes the guide.
60
+ - Never turn a rule off with a comment: there is no such comment. A rule is turned off only in
61
+ `ashlar.config.ts`, by a person.
62
+ - When `onboard` with `{ "check": true }` answers `ok: false`, the guide is stale: run `onboard` and commit
63
+ what it wrote.
64
+ - A refusal comes back with `isError: true` and a sentence saying what was wrong, such as a ref git doesn't
65
+ know. Fix the call; don't retry it unchanged.