@nikovirtala/adr 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/README.md +49 -6
- package/dist/cli.js +168 -39
- package/dist/cli.js.map +1 -1
- package/dist/index.js +4 -2
- package/dist/init-YgW7g9Fx.js +588 -0
- package/dist/init-YgW7g9Fx.js.map +1 -0
- package/dist/list-Dt4KGxvj.js +58 -0
- package/dist/list-Dt4KGxvj.js.map +1 -0
- package/dist/{scope-CLqH-q1y.js → search-CwIPlNGd.js} +379 -487
- package/dist/search-CwIPlNGd.js.map +1 -0
- package/dist/server-CXCO5zfp.js +938 -0
- package/dist/server-CXCO5zfp.js.map +1 -0
- package/dist/types/cli/init.d.ts +5 -2
- package/dist/types/cli/mcp.d.ts +6 -0
- package/dist/types/cli/search.d.ts +3 -0
- package/dist/types/cli/text.d.ts +6 -0
- package/dist/types/commit-actions.d.ts +2 -0
- package/dist/types/index.d.ts +5 -2
- package/dist/types/init.d.ts +16 -1
- package/dist/types/log.d.ts +10 -0
- package/dist/types/mcp/policy.d.ts +33 -0
- package/dist/types/mcp/prompt.d.ts +7 -0
- package/dist/types/mcp/resources.d.ts +16 -0
- package/dist/types/mcp/server.d.ts +16 -0
- package/dist/types/mcp/text.d.ts +42 -0
- package/dist/types/mcp/tools.d.ts +27 -0
- package/dist/types/scope.d.ts +3 -1
- package/dist/types/search.d.ts +61 -0
- package/dist/types/skill.d.ts +5 -0
- package/dist/types/templates/list.d.ts +31 -0
- package/dist/types/views.d.ts +3 -1
- package/dist/types/write.d.ts +39 -1
- package/package.json +5 -2
- package/dist/scope-CLqH-q1y.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-CXCO5zfp.js","names":[],"sources":["../src/mcp/policy.ts","../src/mcp/resources.ts","../src/mcp/text.ts","../src/mcp/tools.ts","../src/mcp/prompt.ts","../src/mcp/server.ts"],"sourcesContent":["import type { Actor, Finding } from \"@nikovirtala/ledger\";\nimport type { AdrConfig } from \"../config.js\";\nimport { adrKind, type DecisionView } from \"../kind.js\";\nimport type { DecisionsRead } from \"../log.js\";\n\n/** The tools that decide; listed only with `[policy] mcp_can_decide = true`. */\nexport const DECISION_TOOLS = [\n \"adr_accept\",\n \"adr_reject\",\n \"adr_deprecate\",\n \"adr_supersede\",\n] as const;\n\n/** Whether `adr mcp` offers the decision tools (design §7.5, Table A). */\nexport function decisionToolsAvailable(adr: AdrConfig): boolean {\n return adr.mcpCanDecide;\n}\n\n/**\n * Who a proposal is for (design D5): its `proposed` event's actor, `on_behalf_of` for an agent\n * and `email` for a human, lower-cased; `null` when the event or the address is missing.\n */\nexport function proposalOwner(read: DecisionsRead, id: string): string | null {\n const proposed = read.folded.subjects\n .get(id)\n ?.applied.find((a) => a.event.type === adrKind.machine.initial.type);\n const actor = proposed?.event.actor;\n if (actor === undefined) return null;\n const owner = actor.kind === \"agent\" ? actor.on_behalf_of : actor.email;\n return typeof owner === \"string\" && owner.trim() !== \"\" ? owner.trim().toLowerCase() : null;\n}\n\n/** The writes `mcpWriteRefusal` judges: the ones whose ownership matters. */\nexport type PolicyTool = \"adr_scope\" | \"adr_update_draft\" | \"adr_withdraw\";\n\n/**\n * The MCP policy (design §7.5, Table B): `null` when the write may go ahead, else the\n * `decision/mcp-cannot-decide` finding. Without `mcp_can_decide` an agent may scope, edit and\n * withdraw only the proposals made for the person it acts for, and rescope no accepted or\n * deprecated decision.\n * Writes the state machine forbids anyway get `null`, so the library refuses them with the real\n * reason.\n */\nexport function mcpWriteRefusal(o: {\n readonly tool: PolicyTool;\n readonly view: DecisionView;\n readonly owner: string | null;\n readonly actor: Actor;\n readonly mcpCanDecide: boolean;\n readonly display: (id: string) => string;\n /** The finding's file when the decision has no body: its events directory. */\n readonly eventsDir: string;\n}): Finding | null {\n const { view } = o;\n if (o.tool === \"adr_scope\" && !adrKind.machine.allowed(view.status, \"scoped\")) return null;\n if (o.tool === \"adr_update_draft\" && view.status !== \"proposed\") return null;\n if (o.tool === \"adr_withdraw\" && !adrKind.machine.allowed(view.status, \"withdrawn\")) return null;\n if (o.mcpCanDecide) return null;\n const me = o.actor.on_behalf_of?.trim().toLowerCase() ?? null;\n if (view.status === \"proposed\" && o.owner !== null && o.owner === me) return null;\n const shown = o.display(view.id);\n const named = shown === view.id ? view.id : `${shown} (${view.id})`;\n const verb = o.tool === \"adr_withdraw\" ? \"withdrawing\" : \"changing\";\n const message =\n view.status === \"proposed\"\n ? `${named} was proposed for ${o.owner ?? \"someone else\"}, and you act for ${o.actor.on_behalf_of ?? \"nobody\"}; ${verb} another person's proposal needs [policy] mcp_can_decide = true. Add a note with adr_note instead.`\n : `${named} is ${view.status}; rescoping it needs [policy] mcp_can_decide = true, because narrowing a scope can switch a decision off. Ask a human to run adr scope ${shown} …, or propose a superseding decision.`;\n return {\n severity: \"error\",\n rule: \"decision/mcp-cannot-decide\",\n message,\n file: view.body_path ?? o.eventsDir,\n line: null,\n subject: view.id,\n kind: adrKind.name,\n };\n}\n","import { renderIndex, resolveSubjectInput, UsageError } from \"@nikovirtala/ledger\";\nimport type { McpResource, McpResourceTemplate } from \"@nikovirtala/ledger/mcp\";\nimport { adrKind } from \"../kind.js\";\nimport { type DecisionsRead, readDecisions, resolveDecision } from \"../log.js\";\nimport { DECISION_INDEX } from \"../log-index.js\";\nimport { showDecision } from \"../views.js\";\nimport { mcpHeader } from \"./text.js\";\nimport { type AdrMcpEnv, openLog } from \"./tools.js\";\n\nconst MAX_ID = 64;\n\n/**\n * Where an MCP client reads a decision: `adr://decision/ADR-0012` when numbered, else\n * `adr://decision/<id>`. The `refer` of every header the MCP texts show.\n */\nexport function decisionUri(read: DecisionsRead): (id: string) => string {\n return (id) => `adr://decision/${read.projection.views.get(id)?.display ?? id}`;\n}\n\n/** `adr://index`: the index table, numbered like every other read (design §7.7). */\nexport function indexResource(e: AdrMcpEnv): McpResource {\n return {\n uri: \"adr://index\",\n name: \"index\",\n title: \"Decision index\",\n description: \"All decisions, grouped by status, with numbers and dates\",\n mimeType: \"text/markdown\",\n async read() {\n const read = await readDecisions(await openLog(e));\n const views = read.projection.views;\n return {\n header: null,\n text: renderIndex(DECISION_INDEX(read.root, views), [...views.values()], read.numbering),\n };\n },\n };\n}\n\n/**\n * `adr://decision/{id}`: the decision's state header, then its body. `{id}` is the id, the number\n * (`12`, `0012`) or `ADR-0012`; an unknown one is not found, a malformed or qualified one is the\n * caller's error.\n */\nexport function decisionResource(e: AdrMcpEnv): McpResourceTemplate {\n return {\n uriTemplate: \"adr://decision/{id}\",\n name: \"decision\",\n title: \"Decision\",\n description:\n \"One decision: its state header, then its body. {id} is the id (k3f9q8a1), the number (12) or ADR-0012\",\n mimeType: \"text/markdown\",\n async read({ id = \"\" }) {\n if (id.length > MAX_ID) {\n throw new UsageError(\n `invalid decision ${JSON.stringify(`${id.slice(0, MAX_ID)}…`)}: an id or number is at most ${MAX_ID} characters`,\n );\n }\n const read = await readDecisions(await openLog(e));\n const r = resolveSubjectInput(id, {\n subjects: new Set(read.folded.subjects.keys()),\n kind: adrKind,\n numbering: read.numbering,\n });\n if (!r.ok && r.reason === \"not-found\") return null;\n const doc = await showDecision(read, resolveDecision(read, id));\n return {\n header: mcpHeader(doc.decision, read),\n text: doc.body === null ? \"(no body file)\\n\" : doc.body,\n };\n },\n };\n}\n","/**\n * The readable text of each MCP tool result (design §7.4, last column). The documents are the\n * CLI's; these texts are MCP's own, and their state headers point at `adr://decision/…`.\n */\nimport {\n type EventEnvelope,\n type Finding,\n renderStateHeader,\n type StateHeader,\n} from \"@nikovirtala/ledger\";\nimport type { McpToolResult } from \"@nikovirtala/ledger/mcp\";\nimport type { DecisionView } from \"../kind.js\";\nimport type { DecisionsRead } from \"../log.js\";\nimport type { DecisionsForJson } from \"../scope.js\";\nimport type { DecisionSearchJson } from \"../search.js\";\nimport type { TemplatesJson } from \"../templates/list.js\";\nimport { type DecisionListJson, type DecisionShowJson, stateHeader } from \"../views.js\";\nimport type { WriteResultJson } from \"../write.js\";\nimport { decisionUri } from \"./resources.js\";\n\ntype Text = Omit<McpToolResult, \"document\">;\n\nconst display = (read: DecisionsRead) => (id: string) =>\n read.projection.views.get(id)?.display ?? id;\n\nfunction named(read: DecisionsRead, id: string): string {\n const shown = display(read)(id);\n return shown === id ? id : `${shown} (${id})`;\n}\n\n/** The decision's state header with MCP's `adr://` references. */\nexport function mcpHeader(view: DecisionView, read: DecisionsRead): StateHeader {\n return stateHeader(view, read, { refer: decisionUri(read) });\n}\n\n/** `adr_search`: each result's header, title and excerpt, then the counts. */\nexport function searchText(doc: DecisionSearchJson, read: DecisionsRead): Text {\n if (doc.results.length === 0) {\n const more =\n doc.inactive_omitted > 0\n ? [`${inactiveLine(doc.inactive_omitted)}; pass include_inactive`]\n : [];\n return { headers: [], text: [\"No decisions match.\", ...more].join(\"\\n\") };\n }\n const lines: string[] = [];\n for (const r of doc.results) {\n lines.push(renderStateHeader(mcpHeader(r.decision, read)).trimEnd());\n lines.push(` ${r.decision.title}`);\n const where = r.matched.filter((f) => f === \"id\" || f === \"title\").join(\" and \");\n lines.push(r.excerpt === null ? ` (${where} match)` : ` ${r.excerpt}`);\n }\n lines.push(`${doc.results.length} of ${doc.total} shown`);\n if (doc.inactive_omitted > 0) {\n lines.push(`${inactiveLine(doc.inactive_omitted)}; pass include_inactive`);\n }\n return { headers: [], text: lines.join(\"\\n\") };\n}\n\nconst inactiveLine = (k: number) =>\n k === 1 ? \"1 inactive decision also matches\" : `${k} inactive decisions also match`;\n\nfunction listOf(read: DecisionsRead, ids: readonly string[]): string {\n return ids.length === 0 ? \"none\" : ids.map((id) => named(read, id)).join(\", \");\n}\n\nfunction historyLines(events: readonly EventEnvelope[]): string[] {\n return events.map((e) => {\n const a = e.actor;\n const who = a.kind === \"agent\" ? `${a.name} (agent for ${a.on_behalf_of})` : a.name;\n const why = typeof e.reason === \"string\" ? ` — ${e.reason}` : \"\";\n return ` ${e.at} ${e.type} ${who}${why}`;\n });\n}\n\n/** `adr_get`: the header, the decision's fields as `adr show` lists them, then the body. */\nexport function getText(doc: DecisionShowJson, read: DecisionsRead): Text {\n const v = doc.decision;\n const lines = [\n `Title: ${v.title}`,\n `Status: ${v.status} (${v.status_at.slice(0, 10)})`,\n `Effective: ${v.effective === null ? \"none (supersession cycle)\" : named(read, v.effective)}`,\n `Chain: ${v.chain.map(display(read)).join(\" → \")}`,\n `Supersedes: ${listOf(read, v.supersedes)}`,\n `Applies to: ${v.applies_to.length === 0 ? \"no globs recorded\" : v.applies_to.join(\", \")}`,\n ];\n if (doc.events !== null) lines.push(\"History:\", ...historyLines(doc.events));\n lines.push(\"\", doc.body === null ? \"(no body file)\" : doc.body.trimEnd());\n return { headers: [mcpHeader(v, read)], text: lines.join(\"\\n\") };\n}\n\n/** `adr_list`: one line per decision. */\nexport function listText(doc: DecisionListJson, read: DecisionsRead): Text {\n if (doc.decisions.length === 0) return { headers: [], text: \"No decisions.\" };\n const lines = doc.decisions.map((v) => {\n const head = v.number === null ? v.id : `${v.display} (${v.id})`;\n const to =\n v.effective !== null && v.effective !== v.id ? ` → ${display(read)(v.effective)}` : \"\";\n return `${head} · ${v.status} · ${v.title}${to}`;\n });\n return { headers: [], text: lines.join(\"\\n\") };\n}\n\n/** `adr_templates`: each template, then its sections. */\nexport function templatesText(doc: TemplatesJson): Text {\n const lines = doc.templates.flatMap((t) => [\n `${t.name} v${t.version} (${t.source})${t.name === doc.default ? \" default\" : \"\"}`,\n ...t.sections.map(\n (s) =>\n ` ${s.id}: ${s.heading} (${s.required ? \"required\" : \"optional\"})${s.guidance === null ? \"\" : ` — ${s.guidance}`}`,\n ),\n ]);\n return { headers: [], text: lines.length === 0 ? \"No templates.\" : lines.join(\"\\n\") };\n}\n\n/** `adr_for_path`: per path, each decision's header and how it matched. */\nexport function forText(doc: DecisionsForJson, read: DecisionsRead): Text {\n const lines: string[] = [];\n for (const p of doc.paths) {\n lines.push(p.tracked ? p.path : `${p.path} (not tracked)`);\n if (p.decisions.length === 0 && p.unresolved.length === 0) lines.push(\" no decisions\");\n for (const d of p.decisions) {\n const view = read.projection.views.get(d.id);\n const h =\n view === undefined\n ? { line: `${named(read, d.id)} · ${d.status}`, warning: d.warning }\n : mcpHeader(view, read);\n lines.push(` ${h.line}`);\n if (h.warning !== null) lines.push(` ${h.warning}`);\n for (const via of d.via) {\n lines.push(\n via.type === \"glob\" ? ` via glob ${via.glob}` : ` via anchor line ${via.line}`,\n );\n }\n }\n for (const u of p.unresolved) {\n const why = u.reason === \"other-log\" ? \"in another log\" : \"not in this log\";\n lines.push(` unresolved: ${u.ref} (line ${u.line}, ${why})`);\n }\n }\n return { headers: [], text: lines.join(\"\\n\") };\n}\n\nconst SECTION_FINDING =\n /^(?:required )?section (.+?) (is missing|is empty|still contains its guidance text)$/;\nconst REASONS: Readonly<Record<string, string>> = {\n \"is missing\": \"missing\",\n \"is empty\": \"empty\",\n \"still contains its guidance text\": \"guidance\",\n};\n\n/** Lint findings as `Fill in: <heading> (<reason>)`, others as `Draft: <message> [<rule>]`. */\nfunction lintLines(findings: readonly Finding[]): string[] {\n return findings.map((f) => {\n const m = SECTION_FINDING.exec(f.message);\n if (m === null) return `Draft: ${f.message} [${f.rule}]`;\n const [, heading = \"\", what = \"\"] = m;\n return `Fill in: ${heading} (${REASONS[what] ?? what})`;\n });\n}\n\nconst noteLines = (doc: WriteResultJson) => doc.notes.map((n) => `Note: ${n}`);\n\n/** What a write's text needs besides the document. */\nexport interface WriteTextOptions {\n /** The log read after the write, for the headers and how decisions display. */\n readonly read: DecisionsRead;\n /** For `adr_propose`: whether a human must accept. */\n readonly acceptRequiresHuman?: boolean;\n /** For `adr_scope`: the globs before the write. */\n readonly scopeBefore?: readonly string[];\n /** For `adr_update_draft`: the section ids sent. */\n readonly sections?: readonly string[];\n /** The tool, for the refusal's last line. */\n readonly tool: string;\n}\n\n/** A write's text: `Refused:` and the findings, or what was written; then the notes. */\nexport function writeText(doc: WriteResultJson, o: WriteTextOptions): Text {\n const { read } = o;\n const view =\n doc.decision === null ? null : (read.projection.views.get(doc.decision.id) ?? doc.decision);\n const headers = view === null ? [] : [mcpHeader(view, read), ...affectedHeaders(doc, read)];\n if (!doc.ok) {\n const lint =\n doc.findings.length > 0 && doc.findings.every((f) => f.rule.startsWith(\"template/\"));\n const again =\n lint && (o.tool === \"adr_propose\" || o.tool === \"adr_update_draft\")\n ? [`Fill in every required section and call ${o.tool} again.`]\n : [];\n const lines = [\n \"Refused:\",\n ...doc.findings.map(\n (f) => ` ${f.file === null ? \"\" : `${f.file}: `}${f.message} [${f.rule}]`,\n ),\n ...again,\n ...noteLines(doc),\n ];\n return { headers, text: lines.join(\"\\n\") };\n }\n if (view === null) return { headers, text: noteLines(doc).join(\"\\n\") };\n const lines = bodyLines(doc, view, o);\n return { headers, text: [...lines, ...noteLines(doc)].join(\"\\n\") };\n}\n\nfunction bodyLines(doc: WriteResultJson, v: DecisionView, o: WriteTextOptions): string[] {\n const { read } = o;\n const who = named(read, v.id);\n const recorded = doc.commit === null ? [] : [`Committed ${doc.commit.slice(0, 7)}.`];\n switch (doc.command) {\n case \"new\":\n return [\n `Proposed ${v.id}: ${v.title}`,\n ...(v.body_path === null ? [] : [` ${v.body_path}`]),\n ...lintLines(doc.findings),\n ...recorded,\n o.acceptRequiresHuman === true\n ? `Next: ask a human to review and accept it (adr accept ${v.id})`\n : `Next: adr_accept or adr accept ${v.id}`,\n ];\n case \"update\":\n return doc.written.length === 0\n ? [\"Unchanged\"]\n : [\n `Updated the draft of ${who}: ${(o.sections ?? []).join(\", \")}`,\n ...lintLines(doc.findings),\n ...recorded,\n ];\n case \"note\":\n return [`Noted on ${who}`, ...recorded];\n case \"link\": {\n const link = doc.written.length === 0 ? undefined : v.links.at(-1);\n if (link === undefined) return [`Links of ${who} unchanged`];\n return [`Linked ${who} ${link.rel} ${named(read, link.to)}`, ...recorded];\n }\n case \"scope\": {\n const before = new Set(o.scopeBefore ?? []);\n const after = new Set(v.applies_to);\n if (doc.written.length === 0) return [\"unchanged\"];\n return [\n ...v.applies_to.filter((g) => !before.has(g)).map((g) => `+ ${g}`),\n ...[...before].filter((g) => !after.has(g)).map((g) => `- ${g}`),\n `= ${v.applies_to.length === 0 ? \"no globs\" : v.applies_to.join(\", \")}`,\n ...recorded,\n ];\n }\n case \"accept\":\n return [\n `Accepted ${who}: ${v.title}`,\n ...doc.affected.map((a) => `Superseded ${named(read, a.id)}: ${a.title}`),\n ...recorded,\n ];\n case \"reject\":\n return [`Rejected ${who}`, ...recorded];\n case \"withdraw\":\n return [`Withdrawn ${who}`, ...recorded];\n case \"deprecate\":\n return [`Deprecated ${who}`, ...recorded];\n case \"supersede\":\n return [`Superseded ${who} by ${named(read, v.superseded_by ?? \"\")}`, ...recorded];\n default:\n return [`${doc.command} ${who}`, ...recorded];\n }\n}\n\n/** The headers of the decisions a write affected (superseded), other than its own. */\nfunction affectedHeaders(doc: WriteResultJson, read: DecisionsRead): StateHeader[] {\n return doc.affected\n .filter((a) => a.id !== doc.decision?.id)\n .map((a) => mcpHeader(read.projection.views.get(a.id) ?? a, read));\n}\n","import {\n type Attribution,\n eventDir,\n type JsonValue,\n MAX_GLOB_LENGTH,\n UsageError,\n} from \"@nikovirtala/ledger\";\nimport { type McpTool, type McpToolResult, mcpAttribution } from \"@nikovirtala/ledger/mcp\";\nimport { DECISION_STATUSES, type DecisionStatus } from \"../kind.js\";\nimport {\n type DecisionLog,\n type DecisionsRead,\n openDecisionLog,\n readDecisions,\n resolveDecision,\n} from \"../log.js\";\nimport { decisionsFor } from \"../scope.js\";\nimport { searchDecisions } from \"../search.js\";\nimport { listTemplates } from \"../templates/list.js\";\nimport { listDecisions, showDecision } from \"../views.js\";\nimport {\n acceptDecision,\n deprecateDecision,\n linkDecision,\n noteDecision,\n proposeDecision,\n rejectDecision,\n scopeDecision,\n supersedeDecision,\n updateDraft,\n type WriteResultJson,\n withdrawDecision,\n} from \"../write.js\";\nimport { mcpWriteRefusal, type PolicyTool, proposalOwner } from \"./policy.js\";\nimport {\n forText,\n getText,\n listText,\n searchText,\n templatesText,\n type WriteTextOptions,\n writeText,\n} from \"./text.js\";\n\n/** Where `adr mcp` runs: every call opens the log afresh from here (design D2). */\nexport interface AdrMcpEnv {\n readonly cwd: string;\n readonly root: string | null;\n readonly env: NodeJS.ProcessEnv;\n}\n\ntype Schema = Readonly<Record<string, JsonValue>>;\n\nexport const ID: Schema = { type: \"string\", minLength: 1, maxLength: 64 };\nconst TEXT: Schema = { type: \"string\", minLength: 1, maxLength: 65_536 };\nconst SECTIONS: Schema = {\n type: \"object\",\n propertyNames: { type: \"string\", pattern: \"^[a-z][a-z0-9-]*$\", maxLength: 64 },\n additionalProperties: { type: \"string\", maxLength: 65_536 },\n maxProperties: 50,\n};\nconst GLOBS: Schema = {\n type: \"array\",\n items: { type: \"string\", minLength: 1, maxLength: MAX_GLOB_LENGTH },\n maxItems: 200,\n};\n\nconst object = (properties: Record<string, Schema>, required: string[] = []): Schema => ({\n type: \"object\",\n properties,\n ...(required.length === 0 ? {} : { required }),\n additionalProperties: false,\n});\n\nexport const READ = { readOnlyHint: true, openWorldHint: false } as const;\nexport const WRITE = { readOnlyHint: false, destructiveHint: false, openWorldHint: false } as const;\n\n/** The log for one call, opened again so outside edits and `[policy]` changes are seen. */\nexport const openLog = (e: AdrMcpEnv, ref: string | null = null): Promise<DecisionLog> =>\n openDecisionLog({ cwd: e.cwd, root: e.root, ref, gitOptions: { env: e.env } });\n\nconst str = (v: JsonValue | undefined): string | undefined =>\n typeof v === \"string\" ? v : undefined;\nconst strings = (v: JsonValue | undefined): string[] | undefined =>\n Array.isArray(v) ? v.filter((x): x is string => typeof x === \"string\") : undefined;\nconst sectionsOf = (v: JsonValue | undefined): Record<string, string> =>\n typeof v === \"object\" && v !== null && !Array.isArray(v)\n ? Object.fromEntries(\n Object.entries(v).flatMap(([k, x]) => (typeof x === \"string\" ? [[k, x]] : [])),\n )\n : {};\n\nconst doc = (d: unknown): JsonValue => d as JsonValue;\n\n/**\n * A write tool's result: the library's document, and its text rendered from a read of the log\n * after the write.\n */\nasync function writeResult(\n log: DecisionLog,\n d: WriteResultJson,\n o: Omit<WriteTextOptions, \"read\">,\n): Promise<McpToolResult> {\n const read = await readDecisions(log);\n return { document: doc(d), ...writeText(d, { ...o, read }) };\n}\n\n/** The `adr-write/v1` command of each policy tool, as the CLI names it. */\nconst COMMAND: Record<PolicyTool, WriteResultJson[\"command\"]> = {\n adr_scope: \"scope\",\n adr_update_draft: \"update\",\n adr_withdraw: \"withdraw\",\n};\n\n/**\n * The MCP policy step of `adr_scope`, `adr_update_draft` and `adr_withdraw` (design §7.5): the refusal document\n * when the agent may not make this write, else `null`.\n */\nfunction policyRefusal(\n log: DecisionLog,\n read: DecisionsRead,\n tool: PolicyTool,\n id: string,\n attribution: Attribution,\n): WriteResultJson | null {\n const view = read.projection.views.get(id);\n if (view === undefined) return null;\n const finding = mcpWriteRefusal({\n tool,\n view,\n owner: proposalOwner(read, id),\n actor: attribution.actor,\n mcpCanDecide: log.adr.mcpCanDecide,\n display: (x) => read.projection.views.get(x)?.display ?? x,\n eventsDir: eventDir(read.layout, id),\n });\n if (finding === null) return null;\n return {\n format: \"adr-write/v1\",\n command: COMMAND[tool],\n ok: false,\n decision: view,\n affected: [],\n written: [],\n commit: null,\n findings: [finding],\n notes: [...log.notes, ...attribution.notes],\n };\n}\n\n/** The eleven tools `adr mcp` always lists (design §7.4). */\nexport function alwaysOnTools(e: AdrMcpEnv): McpTool[] {\n return [\n {\n name: \"adr_search\",\n title: \"Search decisions\",\n description:\n \"Full-text search of the decision log: every word must appear in a decision's id, title, body or notes. Returns active (proposed or accepted) decisions unless include_inactive is true, each with its state header and an excerpt.\",\n inputSchema: object(\n {\n query: { type: \"string\", minLength: 1, maxLength: 200 },\n include_inactive: { type: \"boolean\" },\n limit: { type: \"integer\", minimum: 1, maximum: 100 },\n },\n [\"query\"],\n ),\n annotations: READ,\n async run(input) {\n const read = await readDecisions(await openLog(e));\n const d = searchDecisions(read, {\n query: str(input.query) ?? \"\",\n includeInactive: input.include_inactive === true,\n limit: typeof input.limit === \"number\" ? input.limit : 10,\n });\n return { document: doc(d), ...searchText(d, read) };\n },\n },\n {\n name: \"adr_get\",\n title: \"Get a decision\",\n description:\n \"One decision with its state header, computed status, supersession chain, effective decision and body. Use this or adr://decision/{id} instead of reading files under docs/adr. A SUPERSEDED or DEPRECATED header means: don't apply it, follow the warning.\",\n inputSchema: object(\n {\n id: ID,\n include_history: { type: \"boolean\" },\n ref: { type: \"string\", minLength: 1, maxLength: 256 },\n },\n [\"id\"],\n ),\n annotations: READ,\n async run(input) {\n const read = await readDecisions(await openLog(e, str(input.ref) ?? null));\n const id = resolveDecision(read, str(input.id) ?? \"\");\n const d = await showDecision(read, id, { history: input.include_history === true });\n return { document: doc(d), ...getText(d, read) };\n },\n },\n {\n name: \"adr_list\",\n title: \"List decisions\",\n description:\n \"All decisions with their computed status, for orientation. Filter by status; limit truncates.\",\n inputSchema: object({\n status: {\n type: \"array\",\n items: { type: \"string\", enum: [...DECISION_STATUSES] },\n uniqueItems: true,\n minItems: 1,\n maxItems: DECISION_STATUSES.length,\n },\n limit: { type: \"integer\", minimum: 1, maximum: 1000 },\n }),\n annotations: READ,\n async run(input) {\n const read = await readDecisions(await openLog(e));\n const status = strings(input.status) as DecisionStatus[] | undefined;\n const d = listDecisions(read, {\n ...(status === undefined ? {} : { status }),\n ...(typeof input.limit === \"number\" ? { limit: input.limit } : {}),\n });\n return { document: doc(d), ...listText(d, read) };\n },\n },\n {\n name: \"adr_templates\",\n title: \"List templates\",\n description:\n \"The templates adr_propose can use, with each section's id, heading, whether it is required, and guidance for filling it in.\",\n inputSchema: object({}),\n annotations: READ,\n async run() {\n const d = await listTemplates(await readDecisions(await openLog(e)));\n return { document: doc(d), ...templatesText(d) };\n },\n },\n {\n name: \"adr_propose\",\n title: \"Propose a decision\",\n description:\n \"Propose a decision: give the title and a sections map (section id → markdown) for the template; the tool renders and stages the draft. Lint findings come back in findings: fix them with adr_update_draft. With auto_commit on, an incomplete draft is refused; send every required section. You can't accept your own proposal; tell the user its id.\",\n inputSchema: object(\n {\n title: { type: \"string\", minLength: 1, maxLength: 200 },\n template: { type: \"string\", pattern: \"^[a-z][a-z0-9-]*$\", maxLength: 64 },\n sections: SECTIONS,\n supersedes: { type: \"array\", items: ID, maxItems: 20 },\n },\n [\"title\"],\n ),\n annotations: WRITE,\n async run(input, ctx) {\n const log = await openLog(e);\n const { actor, notes } = await mcpAttribution(log.git, ctx);\n const template = str(input.template);\n const supersedes = strings(input.supersedes);\n const d = await proposeDecision(\n log,\n {\n title: str(input.title) ?? \"\",\n sections: sectionsOf(input.sections),\n actor,\n ...(template === undefined ? {} : { template }),\n ...(supersedes === undefined ? {} : { supersedes }),\n },\n { notes },\n );\n return writeResult(log, d, {\n tool: \"adr_propose\",\n acceptRequiresHuman: log.adr.acceptRequiresHuman,\n });\n },\n },\n {\n name: \"adr_update_draft\",\n title: \"Update a draft\",\n description:\n \"Replace sections of a proposed decision's draft (section id → markdown). Only your own proposals unless mcp_can_decide is on. Returns the lint result. With auto_commit on, an incomplete draft is refused; send every required section.\",\n inputSchema: object({ id: ID, sections: { ...SECTIONS, minProperties: 1 } }, [\n \"id\",\n \"sections\",\n ]),\n annotations: WRITE,\n async run(input, ctx) {\n const log = await openLog(e);\n const read = await readDecisions(log);\n const id = resolveDecision(read, str(input.id) ?? \"\");\n const attribution = await mcpAttribution(log.git, ctx);\n const sections = sectionsOf(input.sections);\n const o = { tool: \"adr_update_draft\", sections: Object.keys(sections) };\n const refused = policyRefusal(log, read, \"adr_update_draft\", id, attribution);\n if (refused !== null) return writeResult(log, refused, o);\n const d = await updateDraft(log, { id, sections }, { notes: attribution.notes });\n return writeResult(log, d, o);\n },\n },\n {\n name: \"adr_note\",\n title: \"Note on a decision\",\n description:\n \"Add a note to a decision in any state. Notes clarify; a changed decision needs a superseding proposal.\",\n inputSchema: object({ id: ID, text: TEXT }, [\"id\", \"text\"]),\n annotations: WRITE,\n async run(input, ctx) {\n const log = await openLog(e);\n const { actor, notes } = await mcpAttribution(log.git, ctx);\n const d = await noteDecision(\n log,\n { id: str(input.id) ?? \"\", text: str(input.text) ?? \"\", actor },\n { notes },\n );\n return writeResult(log, d, { tool: \"adr_note\" });\n },\n },\n {\n name: \"adr_link\",\n title: \"Link decisions\",\n description:\n \"Record a relation (relates-to, refines, depends-on) from one decision to another.\",\n inputSchema: object(\n {\n id: ID,\n to: { type: \"string\", minLength: 1, maxLength: 100 },\n rel: { type: \"string\", enum: [\"relates-to\", \"refines\", \"depends-on\"] },\n },\n [\"id\", \"to\"],\n ),\n annotations: WRITE,\n async run(input, ctx) {\n const log = await openLog(e);\n const { actor, notes } = await mcpAttribution(log.git, ctx);\n const rel = str(input.rel);\n const d = await linkDecision(\n log,\n {\n id: str(input.id) ?? \"\",\n to: str(input.to) ?? \"\",\n actor,\n ...(rel === undefined ? {} : { rel }),\n },\n { notes },\n );\n return writeResult(log, d, { tool: \"adr_link\" });\n },\n },\n {\n name: \"adr_for_path\",\n title: \"Decisions for paths\",\n description:\n \"The decisions that govern each file, from scope globs and code anchors. Inactive ones carry a warning.\",\n inputSchema: object(\n {\n paths: {\n type: \"array\",\n items: { type: \"string\", minLength: 1, maxLength: 4096 },\n minItems: 1,\n maxItems: 100,\n },\n },\n [\"paths\"],\n ),\n annotations: READ,\n async run(input) {\n const log = await openLog(e);\n const read = await readDecisions(log);\n const d = await decisionsFor(read, log, { paths: strings(input.paths) ?? [] });\n return { document: doc(d), ...forText(d, read) };\n },\n },\n {\n name: \"adr_scope\",\n title: \"Scope a decision\",\n description:\n \"Set, add or remove the globs that map a decision to code. Allowed on your own proposals; rescoping someone else's proposal or an accepted or deprecated decision needs mcp_can_decide. If the decision's Scope section would no longer read true, propose a superseding decision instead.\",\n inputSchema: {\n ...object({ id: ID, set: GLOBS, add: GLOBS, remove: GLOBS }, [\"id\"]),\n minProperties: 2,\n },\n inputHint: \"adr_scope needs id and at least one of set, add or remove\",\n annotations: WRITE,\n async run(input, ctx) {\n const log = await openLog(e);\n const read = await readDecisions(log);\n const id = resolveDecision(read, str(input.id) ?? \"\");\n const attribution = await mcpAttribution(log.git, ctx);\n const scopeBefore = read.projection.views.get(id)?.applies_to ?? [];\n const o = { tool: \"adr_scope\", scopeBefore };\n const refused = policyRefusal(log, read, \"adr_scope\", id, attribution);\n if (refused !== null) return writeResult(log, refused, o);\n const set = strings(input.set);\n const op = {\n ...(set === undefined ? {} : { set }),\n add: strings(input.add) ?? [],\n remove: strings(input.remove) ?? [],\n };\n const d = await scopeDecision(\n log,\n { id, op, actor: attribution.actor },\n { notes: attribution.notes },\n );\n return writeResult(log, d, o);\n },\n },\n {\n name: \"adr_withdraw\",\n title: \"Withdraw a proposal\",\n description:\n \"Withdraw a proposed decision, with an optional reason, for example your own proposal when the user decides against it. Withdrawing someone else's proposal needs mcp_can_decide. Only proposals can be withdrawn; an accepted decision needs a superseding proposal.\",\n inputSchema: object({ id: ID, reason: TEXT }, [\"id\"]),\n annotations: WRITE,\n async run(input, ctx) {\n const log = await openLog(e);\n const read = await readDecisions(log);\n const id = resolveDecision(read, str(input.id) ?? \"\");\n const attribution = await mcpAttribution(log.git, ctx);\n const o = { tool: \"adr_withdraw\" };\n const refused = policyRefusal(log, read, \"adr_withdraw\", id, attribution);\n if (refused !== null) return writeResult(log, refused, o);\n const d = await withdrawDecision(\n log,\n { id, reason: str(input.reason) ?? null, actor: attribution.actor },\n { notes: attribution.notes },\n );\n return writeResult(log, d, o);\n },\n },\n ];\n}\n\n/**\n * The log for a decision tool's call. The tool list was fixed at startup, so a call after\n * `mcp_can_decide` was turned off is a usage error telling the user to restart (design §7.3).\n */\nasync function decidingLog(e: AdrMcpEnv): Promise<DecisionLog> {\n const log = await openLog(e);\n if (!log.adr.mcpCanDecide) {\n throw new UsageError(\n `[policy] mcp_can_decide is now false in ${log.configPath ?? \"adr.toml (not present)\"}; restart adr mcp to update its tool list`,\n );\n }\n return log;\n}\n\n/** The four tools `adr mcp` lists only with `[policy] mcp_can_decide = true` (design §7.4). */\nexport function decisionTools(e: AdrMcpEnv): McpTool[] {\n return [\n {\n name: \"adr_accept\",\n title: \"Accept a decision\",\n description:\n \"Accept a proposed decision (lints it, freezes the body, supersedes what it declares). Refused for agents while accept_requires_human is on.\",\n inputSchema: object({ id: ID, copy_scope: { type: \"boolean\" } }, [\"id\"]),\n annotations: WRITE,\n async run(input, ctx) {\n const log = await decidingLog(e);\n const { actor, notes } = await mcpAttribution(log.git, ctx);\n const copyScope =\n input.copy_scope === true ? \"copy\" : input.copy_scope === false ? \"skip\" : \"suggest\";\n const d = await acceptDecision(\n log,\n { id: str(input.id) ?? \"\", actor },\n { notes, copyScope },\n );\n return writeResult(log, d, { tool: \"adr_accept\" });\n },\n },\n {\n name: \"adr_reject\",\n title: \"Reject a decision\",\n description: \"Reject a proposed decision, with a reason.\",\n inputSchema: object({ id: ID, reason: TEXT }, [\"id\", \"reason\"]),\n annotations: WRITE,\n async run(input, ctx) {\n const log = await decidingLog(e);\n const { actor, notes } = await mcpAttribution(log.git, ctx);\n const d = await rejectDecision(\n log,\n { id: str(input.id) ?? \"\", reason: str(input.reason) ?? \"\", actor },\n { notes },\n );\n return writeResult(log, d, { tool: \"adr_reject\" });\n },\n },\n {\n name: \"adr_deprecate\",\n title: \"Deprecate a decision\",\n description: \"Deprecate an accepted decision that nothing replaces, with a reason.\",\n inputSchema: object({ id: ID, reason: TEXT }, [\"id\", \"reason\"]),\n annotations: WRITE,\n async run(input, ctx) {\n const log = await decidingLog(e);\n const { actor, notes } = await mcpAttribution(log.git, ctx);\n const d = await deprecateDecision(\n log,\n { id: str(input.id) ?? \"\", reason: str(input.reason) ?? \"\", actor },\n { notes },\n );\n return writeResult(log, d, { tool: \"adr_deprecate\" });\n },\n },\n {\n name: \"adr_supersede\",\n title: \"Supersede a decision\",\n description: \"Mark an accepted or deprecated decision superseded by an accepted one.\",\n inputSchema: object({ id: ID, by: ID, reason: TEXT }, [\"id\", \"by\"]),\n annotations: WRITE,\n async run(input, ctx) {\n const log = await decidingLog(e);\n const { actor, notes } = await mcpAttribution(log.git, ctx);\n const reason = str(input.reason);\n const d = await supersedeDecision(\n log,\n {\n id: str(input.id) ?? \"\",\n by: str(input.by) ?? \"\",\n actor,\n ...(reason === undefined ? {} : { reason }),\n },\n { notes },\n );\n return writeResult(log, d, { tool: \"adr_supersede\" });\n },\n },\n ];\n}\n","import { UsageError } from \"@nikovirtala/ledger\";\nimport type { McpPrompt } from \"@nikovirtala/ledger/mcp\";\nimport { readDecisions, resolveDecision } from \"../log.js\";\nimport { listTemplates } from \"../templates/list.js\";\nimport { type AdrMcpEnv, openLog } from \"./tools.js\";\n\n/**\n * `adr_draft_from_discussion` (design §7.8): the steps from a discussion to a proposal, with the\n * template's sections spelled out, ending with a human's `adr accept`.\n */\nexport function draftPrompt(e: AdrMcpEnv): McpPrompt {\n return {\n name: \"adr_draft_from_discussion\",\n title: \"Draft a decision from the discussion\",\n description:\n \"Turn the current discussion into a proposed architecture decision, checking the existing ones first.\",\n arguments: [\n { name: \"title\", description: \"Working title of the decision\", required: false },\n {\n name: \"template\",\n description: \"Template name; default [log] default_template\",\n required: false,\n },\n {\n name: \"supersedes\",\n description: \"A decision this proposal replaces: id or number\",\n required: false,\n },\n ],\n async get(args) {\n const read = await readDecisions(await openLog(e));\n const templates = await listTemplates(read);\n const name = args.template ?? templates.default;\n const t = templates.templates.find((x) => x.name === name);\n if (t === undefined)\n throw new UsageError(`unknown template ${name}; adr_templates lists them`);\n const replaced =\n args.supersedes === undefined ? null : resolveDecision(read, args.supersedes);\n const shown = (id: string) => {\n const display = read.projection.views.get(id)?.display ?? id;\n return display === id ? id : `${display} (${id})`;\n };\n const title =\n args.title === undefined\n ? 'a short title that states the decision, such as \"Use PostgreSQL for orders\"'\n : JSON.stringify(args.title);\n return [\n \"Turn the current discussion into an architecture decision proposal with adr.\",\n \"\",\n \"1. Call adr_search with the main subject of the discussion, and adr_for_path for the files it concerns. If an accepted decision already covers this, tell the user which one, and ask whether the proposal should supersede it.\",\n ...(replaced === null\n ? []\n : [\n `1a. The user named ${shown(replaced)} as the decision this replaces; read it with adr_get first.`,\n ]),\n `2. Use the template ${t.name} (version ${t.version}). Its sections:`,\n ...t.sections.map(\n (s) =>\n ` - ${s.id}: ${s.heading}, ${s.required ? \"required\" : \"optional\"}.${s.guidance === null ? \"\" : ` ${s.guidance}`}`,\n ),\n \"3. Fill every required section with facts from the discussion and the code only. Where something wasn't settled, write it as an open question in that section instead of inventing an answer. If the template has an options section, list at least two options with their trade-offs, including those the discussion rejected.\",\n `4. Call adr_propose with the title ${title}, template \"${t.name}\", the sections map${replaced === null ? \"\" : `, and supersedes [\"${replaced}\"]`}.`,\n \"5. If the result has ok: true with findings, fix those sections with adr_update_draft and the new decision's id. If it was refused (ok: false), fill in every section the findings name and call adr_propose again.\",\n \"6. Don't accept the proposal. Tell the user its id, and that they can review it and run: adr accept <id>\",\n ].join(\"\\n\");\n },\n };\n}\n","import { parseOnBehalfOf } from \"@nikovirtala/ledger\";\nimport { type McpServeOptions, serveMcp } from \"@nikovirtala/ledger/mcp\";\nimport { openDecisionLog } from \"../log.js\";\nimport { DECISION_TOOLS, decisionToolsAvailable } from \"./policy.js\";\nimport { draftPrompt } from \"./prompt.js\";\nimport { decisionResource, indexResource } from \"./resources.js\";\nimport { type AdrMcpEnv, alwaysOnTools, decisionTools } from \"./tools.js\";\n\nexport const INSTRUCTIONS =\n \"Architecture decisions in this repository are managed by adr. Decision files don't show their status: read decisions with adr_get or adr://decision/{id}, check adr_for_path and adr_search before changing architecture, and propose changes with adr_propose; a human accepts them.\";\n\n/**\n * `adr mcp` (design §7.2): checks `ARK_ON_BEHALF_OF` and opens the log first, so a bad\n * environment exits 2 before serving, then serves adr's tools over stdio until the client goes.\n */\nexport async function serveAdrMcp(o: {\n readonly cwd: string;\n readonly root: string | null;\n readonly env: NodeJS.ProcessEnv;\n readonly version: string;\n readonly stderr: { write(s: string): void };\n readonly transport?: McpServeOptions[\"transport\"];\n}): Promise<void> {\n parseOnBehalfOf(o.env.ARK_ON_BEHALF_OF);\n const log = await openDecisionLog({ cwd: o.cwd, root: o.root, gitOptions: { env: o.env } });\n const e: AdrMcpEnv = { cwd: o.cwd, root: o.root, env: o.env };\n const decide = decisionToolsAvailable(log.adr);\n const tools = [...alwaysOnTools(e), ...(decide ? decisionTools(e) : [])];\n const unavailable: Record<string, string> = {};\n if (decide && log.adr.acceptRequiresHuman) {\n o.stderr.write(\n \"adr: warning: adr_accept refuses agents while [policy] accept_requires_human is true\\n\",\n );\n }\n if (!decide) {\n const where = log.configPath ?? \"adr.toml (not present)\";\n for (const name of DECISION_TOOLS) {\n unavailable[name] =\n `[policy] mcp_can_decide is false in ${where}; a human decides with the adr CLI, or set it to true and restart adr mcp`;\n }\n }\n await serveMcp(\n {\n name: \"adr\",\n version: o.version,\n instructions: INSTRUCTIONS,\n tools,\n unavailable,\n resources: [indexResource(e)],\n resourceTemplates: [decisionResource(e)],\n prompts: [draftPrompt(e)],\n },\n {\n env: o.env,\n stderr: o.stderr,\n ...(o.transport === undefined ? {} : { transport: o.transport }),\n },\n );\n}\n"],"mappings":";;;;;;;AAMA,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;AACF;;AAGA,SAAgB,uBAAuB,KAAyB;CAC9D,OAAO,IAAI;AACb;;;;;AAMA,SAAgB,cAAc,MAAqB,IAA2B;CAI5E,MAAM,SAHW,KAAK,OAAO,SAC1B,IAAI,EAAE,CAAC,EACN,QAAQ,MAAM,MAAM,EAAE,MAAM,SAAS,QAAQ,QAAQ,QAAQ,IAAI,EAAA,EAC7C,MAAM;CAC9B,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,QAAQ,MAAM,SAAS,UAAU,MAAM,eAAe,MAAM;CAClE,OAAO,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,KAAK,MAAM,KAAK,CAAC,CAAC,YAAY,IAAI;AACzF;;;;;;;;;AAaA,SAAgB,gB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GAAG;CAC7C,MAAM,QAAQ,CAAC,GAAG,cAAc,CAAC,GAAG,GAAI,SAAS,cAAc,CAAC,IAAI,CAAC,CAAE;CACvE,MAAM,cAAsC,CAAC;CAC7C,IAAI,UAAU,IAAI,IAAI,qBACpB,EAAE,OAAO,MACP,wFACF;CAEF,IAAI,CAAC,QAAQ;EACX,MAAM,QAAQ,IAAI,cAAc;EAChC,KAAK,MAAM,QAAQ,gBACjB,YAAY,QACV,uCAAuC,MAAM;CAEnD;CACA,MAAM,SACJ;EACE,MAAM;EACN,SAAS,EAAE;EACX,cAAc;EACd;EACA;EACA,WAAW,CAAC,cAAc,CAAC,CAAC;EAC5B,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;EACvC,SAAS,CAAC,YAAY,CAAC,CAAC;CAC1B,GACA;EACE,KAAK,EAAE;EACP,QAAQ,EAAE;EACV,GAAI,EAAE,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,EAAE,UAAU;CAChE,CACF;AACF"}
|
package/dist/types/cli/init.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { type CommandSpec } from "@nikovirtala/ledger/cli";
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* `adr init [--template <name>]… [--skill [--skill-dir <path>]] [--commit | --no-commit]
|
|
4
|
+
* [-m <message>]` (design §6.2, phase 3 §9).
|
|
5
|
+
*/
|
|
6
|
+
export declare function initCommand(version: string): CommandSpec;
|
package/dist/types/cli/text.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { type Actor } from "@nikovirtala/ledger";
|
|
|
2
2
|
import type { InitResultJson } from "../init.js";
|
|
3
3
|
import type { ChangedSince } from "../log.js";
|
|
4
4
|
import type { DecisionsForJson } from "../scope.js";
|
|
5
|
+
import type { DecisionSearchJson } from "../search.js";
|
|
5
6
|
import type { DecisionListJson, DecisionShowJson } from "../views.js";
|
|
6
7
|
import type { ScopeOffer, WriteResultJson } from "../write.js";
|
|
7
8
|
/** How a decision id is shown: its display (`ADR-0007`), or the id when it has no number. */
|
|
@@ -48,5 +49,10 @@ export declare function showText(doc: DecisionShowJson, display: Display): strin
|
|
|
48
49
|
* below it when it isn't in force, then the anchors that name no decision of this log.
|
|
49
50
|
*/
|
|
50
51
|
export declare function forText(doc: DecisionsForJson, display: Display, keyword: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* `adr search`: one padded row per result with its excerpt (or which field matched) under it, and
|
|
54
|
+
* an inactive result's warning; then the count.
|
|
55
|
+
*/
|
|
56
|
+
export declare function searchText(doc: DecisionSearchJson): string;
|
|
51
57
|
/** `adr init`: what was written and kept, then the next step; or that nothing was needed. */
|
|
52
58
|
export declare function initText(doc: InitResultJson): string;
|
|
@@ -44,6 +44,8 @@ export declare const ACTIONS: {
|
|
|
44
44
|
export declare const INDEX_ACTION = "regenerate";
|
|
45
45
|
/** What `adr index --commit`'s title slot holds. */
|
|
46
46
|
export declare const INDEX_TITLE = "the decision index";
|
|
47
|
+
/** `{action}` of a draft update (`adr_update_draft`), whose title slot holds the display. */
|
|
48
|
+
export declare const DRAFT_ACTION = "update the draft of";
|
|
47
49
|
/** The longest `{action}`, which `[commit] subject` must leave room for. */
|
|
48
50
|
export declare const LONGEST_ACTION: number;
|
|
49
51
|
/** The longest display: `ADR-` and up to 9 digits (`formatDecisionNumber`, kind/project.ts). */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,9 +2,12 @@ export { type AdrConfig, DEFAULT_ADR_CONFIG, parseAdrConfig } from "./config.js"
|
|
|
2
2
|
export { addHookTrailers, decisionHookCommands, type HooksResultJson, installDecisionHooks, printDecisionHooks, runPreCommitHook, uninstallDecisionHooks, } from "./hooks.js";
|
|
3
3
|
export { type InitResultJson, initDecisionLog } from "./init.js";
|
|
4
4
|
export { type AdrOptions, adrKind, DECISION_STATUSES, type DecisionEvents, type DecisionState, type DecisionStatus, type DecisionView, formatDecisionNumber, type LinkRel, parseDecisionNumber, REF, } from "./kind.js";
|
|
5
|
-
export { type ChangedSince, changedSince, type DecisionLog, type DecisionsRead, openDecisionLog, readDecisions, readDecisionsFrom, resolveDecision, } from "./log.js";
|
|
5
|
+
export { type ChangedSince, changedSince, type DecisionLog, type DecisionsRead, openDecisionLog, readDecisions, readDecisionsFrom, resolveDecision, sourcesNote, } from "./log.js";
|
|
6
6
|
export { type IndexResultJson, indexDecisionLog, renderDecisionIndex } from "./log-index.js";
|
|
7
7
|
export { type DecisionForJson, type DecisionsForJson, decisionsFor, type UnresolvedAnchorJson, } from "./scope.js";
|
|
8
|
+
export { type DecisionSearchJson, type DecisionSearchResultJson, searchDecisions, } from "./search.js";
|
|
9
|
+
export { SKILL_MD } from "./skill.js";
|
|
10
|
+
export { listTemplates, type TemplatesJson } from "./templates/list.js";
|
|
8
11
|
export { adrChecks, verifyDecisions } from "./verify.js";
|
|
9
12
|
export { type DecisionListJson, type DecisionShowJson, listDecisions, type NumberingJson, showDecision, stateHeader, } from "./views.js";
|
|
10
|
-
export { acceptDecision, type CopyScope, deprecateDecision, followScopeRenames, type LinkInput, linkDecision, noteDecision, type ProposeInput, proposeDecision, type ReasonInput, rejectDecision, type ScopeInput, type ScopeOffer, scopeDecision, scopeToCopy, supersedeDecision, type WriteOptions, type WriteResultJson, withdrawDecision, } from "./write.js";
|
|
13
|
+
export { acceptDecision, type CopyScope, deprecateDecision, followScopeRenames, type LinkInput, linkDecision, noteDecision, type ProposeInput, proposeDecision, type ReasonInput, rejectDecision, type ScopeInput, type ScopeOffer, scopeDecision, scopeToCopy, supersedeDecision, type UpdateDraftInput, updateDraft, type WriteOptions, type WriteResultJson, withdrawDecision, } from "./write.js";
|
package/dist/types/init.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export interface InitResultJson {
|
|
|
9
9
|
readonly written: readonly string[];
|
|
10
10
|
/** Files that were already there and were left as they are. */
|
|
11
11
|
readonly kept: readonly string[];
|
|
12
|
+
/** With `--skill`, the SKILL.md path (written or kept); else `null`. */
|
|
13
|
+
readonly skill: string | null;
|
|
12
14
|
readonly commit: string | null;
|
|
13
15
|
readonly notes: readonly string[];
|
|
14
16
|
}
|
|
@@ -17,6 +19,8 @@ export interface InitResultJson {
|
|
|
17
19
|
* init keeps existing files, so it would commit nothing.
|
|
18
20
|
*/
|
|
19
21
|
export declare const INIT_RERUN = "Running adr init again won't commit them: the files exist now, so it keeps them and commits nothing.";
|
|
22
|
+
/** The line `adr init --skill` adds to AGENTS.md for tools that don't load skills. */
|
|
23
|
+
export declare const agentsPointer: (skill: string) => string;
|
|
20
24
|
/**
|
|
21
25
|
* `adr init` (design §6.2): writes a config for the log, unless one is found, and each built-in
|
|
22
26
|
* template in `o.templates` (default `nygard`) to `<root>/templates/`, never overwriting a file.
|
|
@@ -24,10 +28,21 @@ export declare const INIT_RERUN = "Running adr init again won't commit them: the
|
|
|
24
28
|
* the log without `--root`; when that file exists for another log, the config goes in the root.
|
|
25
29
|
* With `[log] index = "committed"` it also writes `<root>/index.md` unless one exists. With
|
|
26
30
|
* `commit` (default `[policy] auto_commit`) the written files are committed on their own;
|
|
27
|
-
* nothing written means nothing committed. No events are written.
|
|
31
|
+
* nothing written means nothing committed. No events are written. With `o.skill` it also writes
|
|
32
|
+
* the agent skill, unless a SKILL.md is there, and adds the pointer line to `AGENTS.md`, unless a
|
|
33
|
+
* line already names the skill; an AGENTS.md with unstaged changes or not tracked is refused
|
|
34
|
+
* with a commit and left unstaged without one.
|
|
28
35
|
*/
|
|
29
36
|
export declare function initDecisionLog(log: DecisionLog, o?: {
|
|
30
37
|
readonly templates?: readonly string[];
|
|
31
38
|
readonly commit?: boolean;
|
|
32
39
|
readonly message?: string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Also write `<dir>/SKILL.md` (`dir` repo-relative, `""` for the root) and the AGENTS.md
|
|
42
|
+
* pointer (design §9); `version` is adr's, for the note on a SKILL.md that differs.
|
|
43
|
+
*/
|
|
44
|
+
readonly skill?: {
|
|
45
|
+
readonly dir: string;
|
|
46
|
+
readonly version: string;
|
|
47
|
+
};
|
|
33
48
|
}): Promise<InitResultJson>;
|
package/dist/types/log.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export interface DecisionsRead {
|
|
|
32
32
|
readonly findings: readonly Finding[];
|
|
33
33
|
/** How the log was located (`ToolLog.notes`); `[]` for a MemoryTree read. */
|
|
34
34
|
readonly notes: readonly string[];
|
|
35
|
+
/** The `[[sources]]` names in the config; their logs aren't read yet (ark's step 4). */
|
|
36
|
+
readonly sources: readonly string[];
|
|
35
37
|
}
|
|
36
38
|
/**
|
|
37
39
|
* `numberLog` on the repository, then `readDecisionsFrom(log.tree, …)`. In a shallow clone of a
|
|
@@ -50,7 +52,15 @@ export declare function readDecisionsFrom(tree: TreeReader, o: {
|
|
|
50
52
|
readonly ref?: string | null;
|
|
51
53
|
readonly commit?: string | null;
|
|
52
54
|
readonly notes?: readonly string[];
|
|
55
|
+
readonly sources?: readonly string[];
|
|
53
56
|
}): Promise<DecisionsRead>;
|
|
57
|
+
/**
|
|
58
|
+
* The note listing reads add while only the local log is read: the logs of `[[sources]]` aren't
|
|
59
|
+
* listed or searched until ark's step 4. `null` without sources.
|
|
60
|
+
*/
|
|
61
|
+
export declare function sourcesNote(read: DecisionsRead): string | null;
|
|
62
|
+
/** `read.notes`, then the sources note when there is one. */
|
|
63
|
+
export declare function listingNotes(read: DecisionsRead): readonly string[];
|
|
54
64
|
/**
|
|
55
65
|
* The note a read command adds about where numbers come from: the shallow-clone index, or why
|
|
56
66
|
* they are unavailable (`unavailable: false` leaves that one out); `null` for none.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Actor, Finding } from "@nikovirtala/ledger";
|
|
2
|
+
import type { AdrConfig } from "../config.js";
|
|
3
|
+
import { type DecisionView } from "../kind.js";
|
|
4
|
+
import type { DecisionsRead } from "../log.js";
|
|
5
|
+
/** The tools that decide; listed only with `[policy] mcp_can_decide = true`. */
|
|
6
|
+
export declare const DECISION_TOOLS: readonly ["adr_accept", "adr_reject", "adr_deprecate", "adr_supersede"];
|
|
7
|
+
/** Whether `adr mcp` offers the decision tools (design §7.5, Table A). */
|
|
8
|
+
export declare function decisionToolsAvailable(adr: AdrConfig): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Who a proposal is for (design D5): its `proposed` event's actor, `on_behalf_of` for an agent
|
|
11
|
+
* and `email` for a human, lower-cased; `null` when the event or the address is missing.
|
|
12
|
+
*/
|
|
13
|
+
export declare function proposalOwner(read: DecisionsRead, id: string): string | null;
|
|
14
|
+
/** The writes `mcpWriteRefusal` judges: the ones whose ownership matters. */
|
|
15
|
+
export type PolicyTool = "adr_scope" | "adr_update_draft" | "adr_withdraw";
|
|
16
|
+
/**
|
|
17
|
+
* The MCP policy (design §7.5, Table B): `null` when the write may go ahead, else the
|
|
18
|
+
* `decision/mcp-cannot-decide` finding. Without `mcp_can_decide` an agent may scope, edit and
|
|
19
|
+
* withdraw only the proposals made for the person it acts for, and rescope no accepted or
|
|
20
|
+
* deprecated decision.
|
|
21
|
+
* Writes the state machine forbids anyway get `null`, so the library refuses them with the real
|
|
22
|
+
* reason.
|
|
23
|
+
*/
|
|
24
|
+
export declare function mcpWriteRefusal(o: {
|
|
25
|
+
readonly tool: PolicyTool;
|
|
26
|
+
readonly view: DecisionView;
|
|
27
|
+
readonly owner: string | null;
|
|
28
|
+
readonly actor: Actor;
|
|
29
|
+
readonly mcpCanDecide: boolean;
|
|
30
|
+
readonly display: (id: string) => string;
|
|
31
|
+
/** The finding's file when the decision has no body: its events directory. */
|
|
32
|
+
readonly eventsDir: string;
|
|
33
|
+
}): Finding | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { McpPrompt } from "@nikovirtala/ledger/mcp";
|
|
2
|
+
import { type AdrMcpEnv } from "./tools.js";
|
|
3
|
+
/**
|
|
4
|
+
* `adr_draft_from_discussion` (design §7.8): the steps from a discussion to a proposal, with the
|
|
5
|
+
* template's sections spelled out, ending with a human's `adr accept`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function draftPrompt(e: AdrMcpEnv): McpPrompt;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { McpResource, McpResourceTemplate } from "@nikovirtala/ledger/mcp";
|
|
2
|
+
import { type DecisionsRead } from "../log.js";
|
|
3
|
+
import { type AdrMcpEnv } from "./tools.js";
|
|
4
|
+
/**
|
|
5
|
+
* Where an MCP client reads a decision: `adr://decision/ADR-0012` when numbered, else
|
|
6
|
+
* `adr://decision/<id>`. The `refer` of every header the MCP texts show.
|
|
7
|
+
*/
|
|
8
|
+
export declare function decisionUri(read: DecisionsRead): (id: string) => string;
|
|
9
|
+
/** `adr://index`: the index table, numbered like every other read (design §7.7). */
|
|
10
|
+
export declare function indexResource(e: AdrMcpEnv): McpResource;
|
|
11
|
+
/**
|
|
12
|
+
* `adr://decision/{id}`: the decision's state header, then its body. `{id}` is the id, the number
|
|
13
|
+
* (`12`, `0012`) or `ADR-0012`; an unknown one is not found, a malformed or qualified one is the
|
|
14
|
+
* caller's error.
|
|
15
|
+
*/
|
|
16
|
+
export declare function decisionResource(e: AdrMcpEnv): McpResourceTemplate;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type McpServeOptions } from "@nikovirtala/ledger/mcp";
|
|
2
|
+
export declare const INSTRUCTIONS = "Architecture decisions in this repository are managed by adr. Decision files don't show their status: read decisions with adr_get or adr://decision/{id}, check adr_for_path and adr_search before changing architecture, and propose changes with adr_propose; a human accepts them.";
|
|
3
|
+
/**
|
|
4
|
+
* `adr mcp` (design §7.2): checks `ARK_ON_BEHALF_OF` and opens the log first, so a bad
|
|
5
|
+
* environment exits 2 before serving, then serves adr's tools over stdio until the client goes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function serveAdrMcp(o: {
|
|
8
|
+
readonly cwd: string;
|
|
9
|
+
readonly root: string | null;
|
|
10
|
+
readonly env: NodeJS.ProcessEnv;
|
|
11
|
+
readonly version: string;
|
|
12
|
+
readonly stderr: {
|
|
13
|
+
write(s: string): void;
|
|
14
|
+
};
|
|
15
|
+
readonly transport?: McpServeOptions["transport"];
|
|
16
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The readable text of each MCP tool result (design §7.4, last column). The documents are the
|
|
3
|
+
* CLI's; these texts are MCP's own, and their state headers point at `adr://decision/…`.
|
|
4
|
+
*/
|
|
5
|
+
import { type StateHeader } from "@nikovirtala/ledger";
|
|
6
|
+
import type { McpToolResult } from "@nikovirtala/ledger/mcp";
|
|
7
|
+
import type { DecisionView } from "../kind.js";
|
|
8
|
+
import type { DecisionsRead } from "../log.js";
|
|
9
|
+
import type { DecisionsForJson } from "../scope.js";
|
|
10
|
+
import type { DecisionSearchJson } from "../search.js";
|
|
11
|
+
import type { TemplatesJson } from "../templates/list.js";
|
|
12
|
+
import { type DecisionListJson, type DecisionShowJson } from "../views.js";
|
|
13
|
+
import type { WriteResultJson } from "../write.js";
|
|
14
|
+
type Text = Omit<McpToolResult, "document">;
|
|
15
|
+
/** The decision's state header with MCP's `adr://` references. */
|
|
16
|
+
export declare function mcpHeader(view: DecisionView, read: DecisionsRead): StateHeader;
|
|
17
|
+
/** `adr_search`: each result's header, title and excerpt, then the counts. */
|
|
18
|
+
export declare function searchText(doc: DecisionSearchJson, read: DecisionsRead): Text;
|
|
19
|
+
/** `adr_get`: the header, the decision's fields as `adr show` lists them, then the body. */
|
|
20
|
+
export declare function getText(doc: DecisionShowJson, read: DecisionsRead): Text;
|
|
21
|
+
/** `adr_list`: one line per decision. */
|
|
22
|
+
export declare function listText(doc: DecisionListJson, read: DecisionsRead): Text;
|
|
23
|
+
/** `adr_templates`: each template, then its sections. */
|
|
24
|
+
export declare function templatesText(doc: TemplatesJson): Text;
|
|
25
|
+
/** `adr_for_path`: per path, each decision's header and how it matched. */
|
|
26
|
+
export declare function forText(doc: DecisionsForJson, read: DecisionsRead): Text;
|
|
27
|
+
/** What a write's text needs besides the document. */
|
|
28
|
+
export interface WriteTextOptions {
|
|
29
|
+
/** The log read after the write, for the headers and how decisions display. */
|
|
30
|
+
readonly read: DecisionsRead;
|
|
31
|
+
/** For `adr_propose`: whether a human must accept. */
|
|
32
|
+
readonly acceptRequiresHuman?: boolean;
|
|
33
|
+
/** For `adr_scope`: the globs before the write. */
|
|
34
|
+
readonly scopeBefore?: readonly string[];
|
|
35
|
+
/** For `adr_update_draft`: the section ids sent. */
|
|
36
|
+
readonly sections?: readonly string[];
|
|
37
|
+
/** The tool, for the refusal's last line. */
|
|
38
|
+
readonly tool: string;
|
|
39
|
+
}
|
|
40
|
+
/** A write's text: `Refused:` and the findings, or what was written; then the notes. */
|
|
41
|
+
export declare function writeText(doc: WriteResultJson, o: WriteTextOptions): Text;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type JsonValue } from "@nikovirtala/ledger";
|
|
2
|
+
import { type McpTool } from "@nikovirtala/ledger/mcp";
|
|
3
|
+
import { type DecisionLog } from "../log.js";
|
|
4
|
+
/** Where `adr mcp` runs: every call opens the log afresh from here (design D2). */
|
|
5
|
+
export interface AdrMcpEnv {
|
|
6
|
+
readonly cwd: string;
|
|
7
|
+
readonly root: string | null;
|
|
8
|
+
readonly env: NodeJS.ProcessEnv;
|
|
9
|
+
}
|
|
10
|
+
type Schema = Readonly<Record<string, JsonValue>>;
|
|
11
|
+
export declare const ID: Schema;
|
|
12
|
+
export declare const READ: {
|
|
13
|
+
readonly readOnlyHint: true;
|
|
14
|
+
readonly openWorldHint: false;
|
|
15
|
+
};
|
|
16
|
+
export declare const WRITE: {
|
|
17
|
+
readonly readOnlyHint: false;
|
|
18
|
+
readonly destructiveHint: false;
|
|
19
|
+
readonly openWorldHint: false;
|
|
20
|
+
};
|
|
21
|
+
/** The log for one call, opened again so outside edits and `[policy]` changes are seen. */
|
|
22
|
+
export declare const openLog: (e: AdrMcpEnv, ref?: string | null) => Promise<DecisionLog>;
|
|
23
|
+
/** The eleven tools `adr mcp` always lists (design §7.4). */
|
|
24
|
+
export declare function alwaysOnTools(e: AdrMcpEnv): McpTool[];
|
|
25
|
+
/** The four tools `adr mcp` lists only with `[policy] mcp_can_decide = true` (design §7.4). */
|
|
26
|
+
export declare function decisionTools(e: AdrMcpEnv): McpTool[];
|
|
27
|
+
export {};
|
package/dist/types/scope.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Finding, type ScopeVia } from "@nikovirtala/ledger";
|
|
2
2
|
import type { DecisionStatus } from "./kind.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type DecisionLog, type DecisionsRead } from "./log.js";
|
|
4
4
|
import { type NumberingJson } from "./views.js";
|
|
5
5
|
/** One decision that governs a path in `adr-for/v1` (design §6.9). */
|
|
6
6
|
export interface DecisionForJson {
|
|
@@ -39,6 +39,8 @@ export interface DecisionsForJson {
|
|
|
39
39
|
readonly findings: readonly Finding[];
|
|
40
40
|
readonly notes: readonly string[];
|
|
41
41
|
}
|
|
42
|
+
/** The order `adr for` and `adr search` list statuses in: in force first. */
|
|
43
|
+
export declare const STATUS_ORDER: readonly DecisionStatus[];
|
|
42
44
|
/**
|
|
43
45
|
* Which decisions govern each path (design §6.9): globs of decisions that were ever in force, and
|
|
44
46
|
* comment anchors of any decision, read from the work tree or, with a `--ref` log, that commit.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type Finding, type StateHeader } from "@nikovirtala/ledger";
|
|
2
|
+
import type { DecisionView } from "./kind.js";
|
|
3
|
+
import { type DecisionsRead } from "./log.js";
|
|
4
|
+
import { type NumberingJson } from "./views.js";
|
|
5
|
+
export type SearchField = "id" | "title" | "body" | "notes";
|
|
6
|
+
/** One decision `adr search` found. */
|
|
7
|
+
export interface DecisionSearchResultJson {
|
|
8
|
+
readonly decision: DecisionView;
|
|
9
|
+
/** `stateHeader(view, read)`: the CLI's wording. */
|
|
10
|
+
readonly header: StateHeader;
|
|
11
|
+
readonly score: number;
|
|
12
|
+
/** The fields with a hit, in the order id, title, body, notes (the display number is `id`). */
|
|
13
|
+
readonly matched: readonly SearchField[];
|
|
14
|
+
/** The best matching line of the body or a note, cut to about 160 characters; `null` if none. */
|
|
15
|
+
readonly excerpt: string | null;
|
|
16
|
+
}
|
|
17
|
+
/** `adr search <query>… --json` and `adr_search` (design §6.4). */
|
|
18
|
+
export interface DecisionSearchJson {
|
|
19
|
+
readonly format: "adr-search/v1";
|
|
20
|
+
readonly root: string;
|
|
21
|
+
readonly ref: string | null;
|
|
22
|
+
readonly commit: string | null;
|
|
23
|
+
readonly numbering: NumberingJson;
|
|
24
|
+
/** As given, trimmed. */
|
|
25
|
+
readonly query: string;
|
|
26
|
+
/** Folded, deduplicated, in query order. */
|
|
27
|
+
readonly terms: readonly string[];
|
|
28
|
+
readonly include_inactive: boolean;
|
|
29
|
+
/** Matching decisions before `limit`. */
|
|
30
|
+
readonly total: number;
|
|
31
|
+
/** Decisions that match but aren't active; `0` with `include_inactive`. */
|
|
32
|
+
readonly inactive_omitted: number;
|
|
33
|
+
readonly results: readonly DecisionSearchResultJson[];
|
|
34
|
+
/** The read's findings of the listed decisions and of the log as a whole. */
|
|
35
|
+
readonly findings: readonly Finding[];
|
|
36
|
+
/** `read.notes`, then the sources note. */
|
|
37
|
+
readonly notes: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
/** A folded string and, for every folded UTF-16 offset (and its end), the original offset. */
|
|
40
|
+
interface Folded {
|
|
41
|
+
readonly text: string;
|
|
42
|
+
readonly at: readonly number[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Case- and accent-insensitive form: per code point NFKD, combining marks dropped, lower-cased.
|
|
46
|
+
* `Café` → `cafe` and `fi` → `fi`; `ß` and `ø` have no decomposition and stay as they are.
|
|
47
|
+
*/
|
|
48
|
+
export declare function fold(s: string): Folded;
|
|
49
|
+
/**
|
|
50
|
+
* Full-text search of the log (design §8.1): a decision matches when every term of the folded
|
|
51
|
+
* query is a substring of its folded id, display number, title, body or note texts. Ranked by
|
|
52
|
+
* score (10 for a term equal to the id or number, 5 in the title, up to 3 for body hits and 2
|
|
53
|
+
* for note hits), then status as `adr for` orders them, then list order. Only proposed and
|
|
54
|
+
* accepted decisions unless `includeInactive`. Throws `UsageError` for an invalid query.
|
|
55
|
+
*/
|
|
56
|
+
export declare function searchDecisions(read: DecisionsRead, o: {
|
|
57
|
+
readonly query: string;
|
|
58
|
+
readonly includeInactive?: boolean;
|
|
59
|
+
readonly limit?: number;
|
|
60
|
+
}): DecisionSearchJson;
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The agent skill `adr init --skill` writes (01, "Agent skill (SKILL.md)"): the judgment of when
|
|
3
|
+
* to use adr's MCP tools. `skill.test.ts` keeps it equal to the block in docs/01-adr-v1.md.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SKILL_MD = "---\nname: adr\ndescription: Use before changing architecture, data stores, integration patterns, dependencies or cross-cutting conventions, and whenever asked to record, propose or look up an architectural decision.\n---\n\n# Architectural decisions (adr)\n\nDecisions in this repo are managed by adr. Decision files do not\nshow their own status, so never judge from the raw files whether a\ndecision applies.\n\n## Before changing architecture\n\n1. Call adr_for_path for the files you will touch, and adr_search\n for the area you are about to change. adr_search returns active\n decisions only; adr_for_path also lists inactive ones, each with\n a warning.\n2. If your change conflicts with an accepted decision, stop and tell\n the user which ADR it conflicts with. Do not work around it silently.\n3. If the user still wants the change, propose a superseding ADR.\n\n## Reading decisions\n\n- Use adr_get or adr://decision/{id}, never docs/adr/decisions/*.md.\n- If a response says SUPERSEDED or DEPRECATED, follow it to the\n effective decision before acting.\n- If it says REJECTED or WITHDRAWN, the decision was never in force;\n do not apply it.\n\n## Proposing decisions\n\n1. Call adr_templates and fill every required section.\n2. Use only facts from the conversation and the code. Mark unknowns\n as open questions instead of inventing them.\n3. List at least two options considered when the template has that section.\n4. Set supersedes when the proposal replaces an existing decision.\n5. Do not accept your own proposal. Tell the user the ADR id and\n that they can review it and run: adr accept <id>\n6. If the user decides against your proposal, withdraw it with\n adr_withdraw and give their reason. Don't withdraw other\n people's proposals; tell the user instead.\n\n## Changing scope\n\n- When you move or rename code covered by a decision, let the\n pre-commit hook update its globs (adr hooks install). For your\n own proposals, you can use adr_scope. Rescoping an accepted\n decision needs mcp_can_decide; otherwise tell the user and\n suggest adr scope <id> \u2026.\n- Before any scope change, read the decision's Scope section. If it\n would no longer read true after the change, do not rescope: tell\n the user the decision itself is changing and propose a\n superseding ADR.\n\n## Never\n\n- Edit an accepted decision body, any file under docs/adr/events/,\n or index.md by hand.\n- Use adr_note to change the meaning of a decision. Notes clarify;\n changed decisions need a superseding ADR.\n\n## Without the MCP server\n\nUse the CLI with --json: adr search, adr for, adr show, adr new,\nadr note. Set ARK_AGENT=<your name> and ARK_ON_BEHALF_OF=<the user's\nemail> so your writes are attributed.\n";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Finding } from "@nikovirtala/ledger";
|
|
2
|
+
import type { DecisionsRead } from "../log.js";
|
|
3
|
+
/** `adr_templates` (and phase 4's `adr template list --json`): the templates a proposal can use. */
|
|
4
|
+
export interface TemplatesJson {
|
|
5
|
+
readonly format: "adr-templates/v1";
|
|
6
|
+
readonly root: string;
|
|
7
|
+
/** `[log] default_template`. */
|
|
8
|
+
readonly default: string;
|
|
9
|
+
readonly templates: readonly {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly version: number;
|
|
12
|
+
readonly source: "repo" | "builtin";
|
|
13
|
+
/** `<root>/templates/<name>.md` for a repo template; `null` for a built-in one. */
|
|
14
|
+
readonly path: string | null;
|
|
15
|
+
readonly sections: readonly {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly heading: string;
|
|
18
|
+
readonly required: boolean;
|
|
19
|
+
readonly guidance: string | null;
|
|
20
|
+
}[];
|
|
21
|
+
}[];
|
|
22
|
+
/** Why a repo template is left out: it doesn't parse or fails the template lint. */
|
|
23
|
+
readonly findings: readonly Finding[];
|
|
24
|
+
readonly notes: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The templates of `<root>/templates` that parse and pass the template lint, and the built-in
|
|
28
|
+
* ones no repo template or file of the same name shadows (`adr new` copies those on first use),
|
|
29
|
+
* sorted by name.
|
|
30
|
+
*/
|
|
31
|
+
export declare function listTemplates(read: DecisionsRead): Promise<TemplatesJson>;
|
package/dist/types/views.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type EventEnvelope, type Finding, type StateHeader } from "@nikovirtala/ledger";
|
|
2
2
|
import type { DecisionStatus, DecisionView } from "./kind.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type ChangedSince, type DecisionsRead } from "./log.js";
|
|
4
4
|
/** The `numbering` key of the read documents. */
|
|
5
5
|
export interface NumberingJson {
|
|
6
6
|
readonly available: boolean;
|
|
@@ -41,6 +41,8 @@ export interface DecisionShowJson {
|
|
|
41
41
|
}
|
|
42
42
|
/** The `numbering` key of `adr-list/v1`, `adr-show/v1` and `adr-for/v1`. */
|
|
43
43
|
export declare const numberingJson: (read: DecisionsRead) => NumberingJson;
|
|
44
|
+
/** Numbered decisions by number, then unnumbered ones by `proposed_at`, then id. */
|
|
45
|
+
export declare function compareViews(a: DecisionView, b: DecisionView): number;
|
|
44
46
|
/**
|
|
45
47
|
* The `adr-list/v1` document: decisions in list order, filtered by `status` and by `since` (only
|
|
46
48
|
* the decisions with event files added since its revision, from `changedSince`), and truncated to
|