@nazty_labs/common-ground 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -0
  3. package/SETUP.md +219 -0
  4. package/dist/access.d.ts +172 -0
  5. package/dist/access.js +175 -0
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cli.js +198 -0
  8. package/dist/commands.d.ts +189 -0
  9. package/dist/commands.js +202 -0
  10. package/dist/discovery.d.ts +73 -0
  11. package/dist/discovery.js +417 -0
  12. package/dist/errors.d.ts +15 -0
  13. package/dist/errors.js +22 -0
  14. package/dist/export.d.ts +14 -0
  15. package/dist/export.js +86 -0
  16. package/dist/guidance.d.ts +11 -0
  17. package/dist/guidance.js +75 -0
  18. package/dist/hooks.d.ts +4 -0
  19. package/dist/hooks.js +141 -0
  20. package/dist/init.d.ts +304 -0
  21. package/dist/init.js +150 -0
  22. package/dist/maintenance.d.ts +126 -0
  23. package/dist/maintenance.js +23 -0
  24. package/dist/matching.d.ts +17 -0
  25. package/dist/matching.js +32 -0
  26. package/dist/model.d.ts +974 -0
  27. package/dist/model.js +21 -0
  28. package/dist/navigation.d.ts +164 -0
  29. package/dist/navigation.js +164 -0
  30. package/dist/operations.d.ts +10 -0
  31. package/dist/operations.js +130 -0
  32. package/dist/paging.d.ts +5 -0
  33. package/dist/paging.js +32 -0
  34. package/dist/retrieval.d.ts +146 -0
  35. package/dist/retrieval.js +150 -0
  36. package/dist/review-files.d.ts +3 -0
  37. package/dist/review-files.js +106 -0
  38. package/dist/review.d.ts +86 -0
  39. package/dist/review.js +124 -0
  40. package/dist/server.d.ts +8 -0
  41. package/dist/server.js +105 -0
  42. package/dist/source-search.d.ts +63 -0
  43. package/dist/source-search.js +245 -0
  44. package/dist/store.d.ts +452 -0
  45. package/dist/store.js +718 -0
  46. package/dist/version.d.ts +1 -0
  47. package/dist/version.js +2 -0
  48. package/dist/workflow.d.ts +450 -0
  49. package/dist/workflow.js +317 -0
  50. package/docs/architecture.md +65 -0
  51. package/docs/audit-0.4.0.md +42 -0
  52. package/docs/demo.md +42 -0
  53. package/docs/discovery.md +70 -0
  54. package/docs/knowledge-policy.md +51 -0
  55. package/docs/pillar-contract.md +98 -0
  56. package/docs/quiet-workflow.md +98 -0
  57. package/docs/releases.md +157 -0
  58. package/package.json +52 -0
  59. package/schemas/admission.schema.json +75 -0
  60. package/schemas/knowledge.schema.json +192 -0
  61. package/schemas/patch.schema.json +220 -0
  62. package/schemas/update.schema.json +218 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Common Ground contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # Common Ground
2
+
3
+ **Give your coding agents a shared map of your codebase.**
4
+
5
+ Common Ground is an open-source framework for shared, Git-backed repository knowledge. Your agents record what your code does, where responsibilities live, and which sources support each claim. The next agent can pick up that context and get to work.
6
+
7
+ Ask about your release process. Start a feature in an unfamiliar package. Trace a change across subsystems. Common Ground helps agents find relevant knowledge and source locations, then check the code before acting.
8
+
9
+ **Local files. Shared through Git. No model API key, telemetry, cloud service, or vector database.**
10
+
11
+ ## Get started with your agent
12
+
13
+ Install Common Ground once in the environment where your agent runs. Requires Node.js 22+ and npm.
14
+
15
+ Download the `.tgz` package from [GitHub Releases](https://github.com/naztylabs/common-ground/releases), then install it:
16
+
17
+ ```sh
18
+ npm install -g ./nazty_labs-common-ground-0.5.1.tgz
19
+ ```
20
+
21
+ Open your repository with a coding agent that has terminal or MCP tool access, and tell it:
22
+
23
+ > Use Common Ground to initialize this repository. Inspect the source and READMEs, create a responsibility map and source-backed initial facts, and save them autonomously. Summarize what you saved and any coverage gaps.
24
+
25
+ Your agent handles setup, source inspection, verification, and the initial map. That prompt explicitly delegates saving it; ask for a draft instead if you want to review the content first.
26
+
27
+ Then give your agent a normal development task:
28
+
29
+ > Add this feature using the existing project patterns. Verify any Common Ground facts affected by your changes.
30
+
31
+ You direct the work. Your agent uses the CLI or local MCP server to look up knowledge and maintain relevant facts as the code changes.
32
+
33
+ **[Read the setup and usage guide →](SETUP.md)** for detailed commands, MCP configuration, approval rules, and troubleshooting.
34
+
35
+ ## Knowledge your team can inspect
36
+
37
+ Common Ground organizes repository knowledge into three levels:
38
+
39
+ | Level | What it captures | Example |
40
+ | --- | --- | --- |
41
+ | Pillar | A distinct responsibility | Build and delivery |
42
+ | Chapter | An area within that responsibility | Release pipeline |
43
+ | Fact | One durable claim backed by exact source evidence | Publication runs only after the release job succeeds |
44
+
45
+ The map lives in `.common-ground/knowledge.json`. Commit it alongside your code so teammates and their agents share the same reference. A generated local Markdown view makes it easy to read.
46
+
47
+ - **Start with useful context.** Agents retrieve a few relevant facts and source paths without loading the entire map.
48
+ - **Keep claims connected to code.** Source fingerprints identify drift; agents verify affected claims before correcting them. Unrelated work and unchanged facts produce no knowledge writes.
49
+ - **Keep developers in control.** You can delegate initial publication explicitly. New knowledge and responsibility expansion during everyday work come back for approval.
50
+ - **Review meaningful changes.** Agents explain what changed, why, and which sources support it. Conflicting source or knowledge revisions reject publication.
51
+
52
+ Code remains the source of truth. A map can be incomplete, and mechanical checks cannot prove a natural-language claim is true. Agents still read source and use normal build and test checks.
53
+
54
+ ## Adopt it. Extend it.
55
+
56
+ Common Ground runs locally through a CLI and a stdio MCP server. It includes setup for VS Code Copilot and can connect to other agents with shell or MCP tool access. Shape the responsibility map around your repository and extend the TypeScript implementation for your team's needs.
57
+
58
+ - [Setup and usage](SETUP.md) — installation, commands, workflows, and upgrades
59
+ - [Architecture](docs/architecture.md) — how the framework works and its limits
60
+ - [Synthetic demo](docs/demo.md) — a complete example repository workflow
61
+ - [Discovery](docs/discovery.md) — how candidate responsibilities are found
62
+ - [Release guide](docs/releases.md) — changes, packaging, and migration
63
+
64
+ Common Ground is MIT licensed.
package/SETUP.md ADDED
@@ -0,0 +1,219 @@
1
+ # Common Ground setup and usage
2
+
3
+ This guide covers installation, agent setup, initial knowledge publication, everyday usage, and the CLI/MCP reference. For an introduction to the framework, start with the [README](README.md).
4
+
5
+ - [Install and initialize](#get-started)
6
+ - [Initial map and publication](#cli-reference-for-agents)
7
+ - [Everyday lookup and maintenance](#everyday-lookup-and-maintenance)
8
+ - [Search live source when knowledge is thin](#search-live-source-when-knowledge-is-thin)
9
+ - [Command help and output formats](#help-wherever-you-need-it)
10
+ - [Validation and cleanup](#check-and-clean-up-knowledge)
11
+ - [Review knowledge changes](#review-with-your-agent-not-the-json-file)
12
+ - [Git integration and setup recovery](#share-knowledge-keep-generated-views-local)
13
+ - [Connect an agent through MCP](#connect-an-agent)
14
+ - [Extend the framework](#adopt-and-extend)
15
+ - [Development and upgrades](#develop-and-upgrade)
16
+
17
+ ## Get started
18
+
19
+ Requires Node.js 22+ and npm. Download the `.tgz` package from [GitHub Releases](https://github.com/naztylabs/common-ground/releases), then install it:
20
+
21
+ ```sh
22
+ npm install -g ./nazty_labs-common-ground-0.5.1.tgz
23
+ ```
24
+
25
+ The package is distributed through GitHub Releases, not npmjs.com. Choose the `.tgz` asset, not GitHub's source archive. npm still needs registry access to install runtime dependencies.
26
+
27
+ Open your project with your coding agent and tell it:
28
+
29
+ > Use the Common Ground CLI to initialize this repository with `cground init`. Inspect the source, propose a responsibility map and initial facts for my approval, and handle setup and ongoing knowledge maintenance.
30
+
31
+ Your agent runs `init` to create repository guidance, MCP configuration, an advisory Git hook, and a local Markdown reference. It handles discovery, verification, and setup, explaining the proposed map and facts in plain language. After your approval, it populates `.common-ground/knowledge.json`. To delegate initial publication, explicitly ask it to “initialize and save the source-verified responsibility map and initial facts autonomously.” That request authorizes publication within its scope; a request just to initialize or generate a map produces a draft. Continue giving your agent normal development tasks; it uses Common Ground as needed.
32
+
33
+ ## CLI reference for agents
34
+
35
+ The commands below are a reference for agents and developers extending or troubleshooting the framework. Developers can ask their agent to perform these workflows in plain language.
36
+
37
+ For a complete initial transaction, your agent can prepare a JSON payload with `pillars` and `batches: [{chapterId, facts}]`, then run:
38
+
39
+ ```sh
40
+ cground bootstrap setup.json --dry-run
41
+ # With content approval or explicit delegation to publish the initial map:
42
+ cground bootstrap setup.json --approve --preflight TOKEN
43
+ ```
44
+
45
+ The dry run validates the whole map and all fact batches without creating a registry, reports source-file counts, and returns `TOKEN`. Initial publication requires content approval or explicit developer delegation to save/publish the initial boundaries and facts. An existing delegation does not need a second approval question. Receipts declare direction and bind content; they do not attest human review. Changes to the payload, source or registry reject publication. `seed-batch` provides the same preflight/apply workflow for already approved empty chapters. JSON commands accept `--stdin` instead of their filename (or `-` as the filename). Boundary-only `approve` and single-chapter `seed` remain available; approving boundaries does not approve facts.
46
+
47
+ For ongoing checks, the agent can use:
48
+
49
+ ```sh
50
+ cground review # Ask your agent to explain knowledge changes
51
+ cground check # Check all recorded knowledge
52
+ cground check cicd # Check one pillar (use your actual ID)
53
+ cground tidy all # Give your agent a complete cleanup plan
54
+ cground export # Refresh the local Markdown reference
55
+ cground doctor # Check repository setup
56
+ ```
57
+
58
+ In an MCP-capable agent, you can say: “Check the facts in the CI/CD pillar and freshen them if needed.” The agent finds the pillar, checks its facts, reads source, and submits verified corrections. Common Ground does not run a model internally.
59
+
60
+ ## Everyday lookup and maintenance
61
+
62
+ ```sh
63
+ cground lookup --path src/runtime.ts # A few stored facts and source locations
64
+ cground lookup "runtime mode" --verify # Also check selected facts and dependencies
65
+ cground assess --touched src/runtime.ts # Assess only this task's changed paths
66
+ cground assess --touched src/runtime.ts --review # Complete package if a correction is needed
67
+ ```
68
+
69
+ Lookup and search preserve technical versions such as `1.4` as whole tokens: `1.40` and `1.4.0` are different versions. Short terms such as CI also require token boundaries, including path segments, underscores and camel-case boundaries. Longer words retain partial matching. Repository-wide terms carry less weight, so distinctive concepts rank higher. Direct evidence-path matches take priority. Use `lookup --path` for any literal file or directory; paths containing `/` also work as queries.
70
+
71
+ Each lookup result contains its fact ID, statement, source paths, relevance and freshness once. Shared caveats appear once for the response. Use `--verbose` (MCP `verbose:true`) for matching reasons, matched/unmatched terms, lexical coverage and navigation counts. Weak coverage leads with **“No direct answer found”**, followed by the best navigation hints and partial stored matches. Coverage is lexical: a match never proves that a fact answers the question.
72
+
73
+ A separate `navigation` object suggests up to three chapters and five stored ownership/source paths per chapter. These are unverified navigation hints, including when no fact matches. Lookup does not scan for new files, and `--verify` does not verify navigation hints. With weak coverage, `sourceSearch.status: "not-run"` offers a separate source-search operation using matching facts' evidence and chapter paths where available.
74
+
75
+ Lookup and assessment create no task state and require no start/finish sequence. Lookup defaults to at most five facts and explicitly reports freshness as `not-checked`; open source before relying on a claim. `--verify` checks selected facts and upstream sources, not entire unrelated chapters or semantic truth.
76
+
77
+ Assessment returns `no-fact-review` for unrelated or fingerprint-identical source, with focused local/ancestor documentation paths. Changed source returns `source-review-required`: verify the affected claims before deciding whether knowledge needs revision. `--review` expands the relevant chapters into a bounded package containing all facts, evidence, revisions and source/documentation paths. Follow every page before revising knowledge. Path matching cannot detect every semantic connection.
78
+
79
+ `prepare-patch` accepts a standalone correction without `taskId`; whole-chapter review and source/revision conflict checks remain enforced. Task contexts remain available for aggregate reporting and deferred additions. Start one when additions need `propose_facts`, finish after the developer task, and obtain approval before admission.
80
+
81
+ ## Search live source when knowledge is thin
82
+
83
+ An agent can follow weak lookup coverage with targeted searches of source files or directories. Choose paths from the returned hints or repository inspection; the examples below use hypothetical source paths:
84
+
85
+ ```sh
86
+ cground lookup "format 1.4 hierarchy" --verbose
87
+ cground source-search "version 1.4" --path src/header.ts
88
+ cground source-search "chunk node write" --path src/writer.ts
89
+ cground source-search "hierarchy serialize" --path src,docs/format.md
90
+ ```
91
+
92
+ The MCP equivalent is `{"operation":"source-search","args":{"query":"version 1.4","paths":["src/header.ts"]}}`. Both MCP profiles support it. The operation requires explicit repository-relative paths, works without an initialized registry, and returns `kind: "live-source-evidence"` with file paths, line numbers and short excerpts. These are current lexical source hits; the agent must read the surrounding implementation before making a claim. They are never stored facts, and the operation writes no knowledge or task state.
93
+
94
+ Search reads UTF-8 text within the selected paths, skips symlinks, dependencies, generated output and hidden configuration (except `.github`), and never runs project commands. Read excluded configuration files directly when relevant. It scans at most 2,000 entries and 200 files, with limits of 1 MiB per file and 4 MiB total, and returns up to five hits with 300-character excerpt windows. Queries accept up to 32 technical terms and 500 characters. Scan limits, skipped-file counts and result truncation are reported; an empty or truncated result does not prove absence. Terms common across scanned files are downweighted, while exact version tokens remain distinct.
95
+
96
+ Discovery may also suggest reviewing format architecture when several independent implementation filenames and a format specification are present. Verify how those pieces relate, whether the navigation would help repeated tasks, and whether it fits existing ownership before proposing an entry. One unsuccessful lookup does not authorize new knowledge or a new pillar.
97
+
98
+ ## Help wherever you need it
99
+
100
+ ```sh
101
+ cground --help
102
+ cground check --help
103
+ cground help tidy
104
+ cground hook --help
105
+ cground task assess -h
106
+ cground schema seed # Exact input schema and facts-array payload
107
+ cground bootstrap --help --example
108
+ cground --version
109
+ ```
110
+
111
+ Every command supports `--help` and `-h`, with its arguments, options, and an example. Help never executes the command or requires an initialized repository. Options accept both `--root PATH` and `--root=PATH`. Unknown flags, unsupported options, and missing or extra arguments fail with a usage hint.
112
+
113
+ Use `--root PATH` to select another repository. In terminals, checks return a concise summary. Validation returns failing rows by default; `--all-results` includes passing rows, with a global summary in either mode. `approve`, `approve-chapters`, `seed` and `admit` return compact receipts; `--verbose` returns full objects. Pipes preserve structured JSON; `--json` requests it explicitly and disables interactive prompts. `init` keeps its short agent handoff and Markdown link; `review` prints readable text by default. Use `--json` for structured output from either command. Diagnostics go to stderr, and MCP stdout stays reserved for the protocol.
114
+
115
+ `cground schema OPERATION` returns the CLI payload schema by default; `--both` also includes MCP arguments. With `--json`, failures return one JSON error object on stderr with `code`, `message`, `fields` and `recovery`, and exit nonzero. Successful results remain on stdout.
116
+
117
+ Exit codes are `0` for success and `1` for a failed command or knowledge needing attention. Pre-commit hook checks remain advisory and never block a commit.
118
+
119
+ ## Check and clean up knowledge
120
+
121
+ `check` and `validate` are equivalent. They check structure, exact evidence, source changes, and recorded dependencies. Targets can be `all`, a pillar, `pillar/chapter`, `pillar/chapter/fact`, or a unique fact ID. Omitted targets mean `all`.
122
+
123
+ When knowledge is stale, the result lists affected pillars, chapters, and facts and asks **“Start automatic cleanup?”** An interactive terminal offers `[y/N]`. For scripts or agents:
124
+
125
+ ```sh
126
+ cground check cicd --cleanup n --json
127
+ cground validate all --cleanup y --json
128
+ ```
129
+
130
+ Acceptance creates a scoped cleanup plan and `tidyId`. Your agent still has to read all required chapters, source, and documentation, then submit verified corrections and check again. A plan is not a completed repair: the command continues to exit `1` while knowledge needs attention. Unpopulated chapters need approved setup. Matching evidence or hashes cannot prove a natural-language claim is true.
131
+
132
+ `tidy TARGET` can also request cleanup when source has not changed, such as merging duplicates or tightening existing facts. Both CLI and MCP enforce complete reviews and reject conflicting source or knowledge changes. Unchanged facts are not rewritten. New facts and ownership expansion require developer approval.
133
+
134
+ ## Review with your agent, not the JSON file
135
+
136
+ The developer reviews a short explanation in chat. The agent reads and verifies source, then presents **what changed, why, evidence links, and whether to keep or approve it**. Verified corrections are applied to the working tree and summarized afterward. During ordinary development, new facts, chapters, pillars and ownership expansion still need explicit approval of the plain-language proposal. Initial setup may instead use the explicit publication delegation described above. Developers do not need to open or edit `knowledge.json`.
137
+
138
+ `task_context finish` supplies compact before/after details and recommendations for that task. Unchanged facts and fingerprint/revision noise are excluded. An evidence-only change is identified even when the statement stays the same. Any uncertainty or later drift is flagged for another review; mechanical validation alone is not proof of truth.
139
+
140
+ ```sh
141
+ cground review # Meaningful changes against Git HEAD
142
+ cground review cicd # Only this pillar's changes
143
+ cground review --staged # The knowledge in the proposed commit
144
+ cground review --evidence # Include exact changed quotes
145
+ cground review --json # Structured delta for an agent
146
+ ```
147
+
148
+ The equivalent MCP call is `{"operation":"review","args":{"target":"cicd"}}`. Review is read-only, paginated, and covers pillars, chapters and facts. It cannot know why an arbitrary Git change was made or whether it was approved; the agent must verify and explain that. Full source/chapter review is still required before publishing corrections. Initial pillar/chapter proposals are summarized from the agent's proposed map before approval.
149
+
150
+ ## Share knowledge, keep generated views local
151
+
152
+ Commit `.common-ground/knowledge.json` and the generated repository guidance/configuration with your code. It is one shared JSON registry, organized as pillars → chapters → facts. Each fact has a stable ID, a statement of up to 2,000 characters, exact evidence, source scope, and dependency references. Keep one durable claim per fact; the limit is room for context, not a target.
153
+
154
+ `.common-ground/local/knowledge.md` is a complete, human-readable view of the stored registry, including evidence, dependencies, revisions, and fingerprints. `init`, checks, tidy, explicit export, and successful knowledge writes refresh it when content changes. The local directory is Git-ignored and also holds disposable task and review state. Draft facts never appear in the shared reference.
155
+
156
+ `init --skip-hook` (MCP `skipHook:true`) completes setup without accessing the hook. Hook permission errors also allow the rest of setup to finish, with `setup.status: "complete-with-warnings"`. The setup report identifies completed, skipped, failed and pending steps. Other failures return `INIT_INCOMPLETE` with the same detail and the underlying error. The MCP `cground` tool includes this structured failure under `diagnostic`, alongside its error message. Reruns preserve existing knowledge and edited bootstrap drafts; use `scan` for fresh discovery signals and `hook install` when Git metadata is writable.
157
+
158
+ The default Git hook checks staged knowledge against staged source and reminds you to review before sharing. It never changes facts. Existing hooks and hook managers are preserved; `init` explains how to add `cground hook check` to their entry point.
159
+
160
+ ```sh
161
+ cground hook mute # Suppress reminders in this checkout
162
+ cground hook unmute # Restore reminders
163
+ ```
164
+
165
+ ## Connect an agent
166
+
167
+ For VS Code Copilot, `init` merges `.vscode/mcp.json` and a Copilot instruction link while preserving existing guidance and JSONC comments. Ensure `cground` is on VS Code's PATH, start Common Ground through **MCP: List Servers**, and complete the host's trust prompts. Restart an existing server after upgrading.
168
+
169
+ Other MCP clients can launch:
170
+
171
+ ```sh
172
+ cground serve --root /absolute/path/to/repository
173
+ ```
174
+
175
+ Remote SSH and dev-container sessions need the package installed in that environment. This targets agents with tool access, not inline completion or chats without tools. Automated tests cover stdio; VS Code GUI acceptance remains a separate check.
176
+
177
+ The default profile has six tools:
178
+
179
+ | Tool | Purpose |
180
+ | --- | --- |
181
+ | `task_context` | Optional aggregate reporting and deferred fact additions |
182
+ | `read_knowledge` | Navigate indexes, facts, evidence, dependencies, and review checklists |
183
+ | `prepare_patch` | Prepare changes after complete chapter and source review |
184
+ | `commit_update` | Apply a prepared correction to the Git working tree |
185
+ | `propose_facts` | Queue verified additions locally for developer approval |
186
+ | `cground` | Discover and execute every CLI workflow through structured MCP inputs |
187
+
188
+ Call `cground` with `{"operation":"help"}` for a paginated catalog, or `{"operation":"help","args":{"operation":"validate"}}` for that operation's exact input schema. For developer-requested cleanup:
189
+
190
+ ```json
191
+ {"operation":"validate","args":{"target":"cicd","cleanup":true}}
192
+ ```
193
+
194
+ Setup, migration, admission, navigation, cleanup, hooks, diagnostics, export, and task workflows are available without a shell. Approval operations require `approved:true` under actual developer direction. Initial setup permits explicit delegation to publish verified boundaries and facts within scope; ordinary additions still require content approval. Flags declare direction; they do not grant permission. Host tool approval settings still apply.
195
+
196
+ `serve --profile full` preserves the thirteen original tools plus `cground` for existing integrations. Both profiles use the same framework operations. See [the task workflow](docs/quiet-workflow.md) for request formats and [the record contract](docs/pillar-contract.md) for review and publication rules.
197
+
198
+ ## Adopt and extend
199
+
200
+ Shape pillars and chapters around your repository. Add team-specific guidance outside the managed instruction blocks. Build integrations with the CLI, MCP, and [published JSON schemas](schemas). Custom discovery rules, validators, fields, or storage currently require TypeScript changes; there is no plugin loader or stable public SDK.
201
+
202
+ The implementation uses three direct runtime dependencies: the MCP SDK, Zod, and a JSONC parser. Storage is local JSON with bounded discovery and paginated reads. There is no background watcher or service. The engine still loads the registry and hashes source internally; pagination reduces transferred context, not all computation. Huge registries and dense dependency graphs need performance evaluation before production claims.
203
+
204
+ ## Develop and upgrade
205
+
206
+ ```sh
207
+ nvm use # Node 24 for source development
208
+ npm ci
209
+ npm test
210
+ npm run demo # Synthetic repository only
211
+ npm run release:pack # Tested archive + checksum in release/
212
+ npm install -g ./release/nazty_labs-common-ground-0.5.1.tgz
213
+ ```
214
+
215
+ After upgrading, run `cground doctor` and `cground refresh-guidance` for stale instructions, then restart the MCP server. Use `cground init` when full setup needs repair. `refresh-guidance` lists `changedFiles` and `unchangedFiles`; a healthy doctor or completed refresh returns `next: null`. Existing schema-v2 records are preserved. For a schema-v1 pillar-only registry, first review and run `cground migrate --approve`. Read the [release guide](docs/releases.md) for publishing and migration details.
216
+
217
+ More: [architecture and limits](docs/architecture.md), [complete knowledge policy](docs/knowledge-policy.md), [synthetic demo](docs/demo.md), [discovery](docs/discovery.md), [0.4.0 audit](docs/audit-0.4.0.md). Run `npm run measure:context` for reproducible context-size comparisons; these are byte measurements, not billing guarantees.
218
+
219
+ Common Ground is MIT licensed.
@@ -0,0 +1,172 @@
1
+ import { z } from 'zod';
2
+ import { type RegistryRecord } from './model.js';
3
+ import { Store } from './store.js';
4
+ export declare const Lookup: z.ZodObject<{
5
+ path: z.ZodOptional<z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>>>;
6
+ query: z.ZodOptional<z.ZodString>;
7
+ verify: z.ZodDefault<z.ZodBoolean>;
8
+ verbose: z.ZodDefault<z.ZodBoolean>;
9
+ cursor: z.ZodOptional<z.ZodString>;
10
+ limit: z.ZodDefault<z.ZodNumber>;
11
+ }, "strict", z.ZodTypeAny, {
12
+ limit: number;
13
+ verify: boolean;
14
+ verbose: boolean;
15
+ path?: string | undefined;
16
+ query?: string | undefined;
17
+ cursor?: string | undefined;
18
+ }, {
19
+ path?: string | undefined;
20
+ query?: string | undefined;
21
+ limit?: number | undefined;
22
+ verify?: boolean | undefined;
23
+ verbose?: boolean | undefined;
24
+ cursor?: string | undefined;
25
+ }>;
26
+ export declare const Assess: z.ZodObject<{
27
+ cursor: z.ZodOptional<z.ZodString>;
28
+ limit: z.ZodOptional<z.ZodNumber>;
29
+ paths: z.ZodArray<z.ZodPipeline<z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>>, "many">;
30
+ review: z.ZodDefault<z.ZodBoolean>;
31
+ }, "strict", z.ZodTypeAny, {
32
+ paths: string[];
33
+ review: boolean;
34
+ limit?: number | undefined;
35
+ cursor?: string | undefined;
36
+ }, {
37
+ paths: string[];
38
+ limit?: number | undefined;
39
+ cursor?: string | undefined;
40
+ review?: boolean | undefined;
41
+ }>;
42
+ /** Cheap navigation: registry reads only unless live verification is explicitly requested. */
43
+ export declare function lookup(store: Store, input: unknown): Promise<{
44
+ coverage: {
45
+ status: string;
46
+ };
47
+ sourceSearch: {
48
+ status: string;
49
+ next: string;
50
+ };
51
+ state: string;
52
+ writesKnowledge: boolean;
53
+ items: never[];
54
+ next: string;
55
+ summary: string;
56
+ } | {
57
+ caveat: string;
58
+ next: string;
59
+ sourceSearch?: {
60
+ next: string;
61
+ args?: {
62
+ query: string | undefined;
63
+ paths: string[];
64
+ } | undefined;
65
+ status: string;
66
+ operation: string;
67
+ } | undefined;
68
+ navigation?: {
69
+ kind: string;
70
+ freshness: string;
71
+ items: {
72
+ matchedTerms?: string[] | undefined;
73
+ pathCount?: number | undefined;
74
+ pathsTruncated?: boolean | undefined;
75
+ chapterId: string;
76
+ title: string;
77
+ paths: string[];
78
+ }[];
79
+ total: number;
80
+ truncated: boolean;
81
+ } | undefined;
82
+ items: {
83
+ freshness: {
84
+ status: string;
85
+ };
86
+ chapterId?: string | undefined;
87
+ matchReason?: string | undefined;
88
+ matchedTerms?: string[] | undefined;
89
+ unmatchedTerms?: string[] | undefined;
90
+ queryCoverage?: {
91
+ matched: number;
92
+ total: number;
93
+ } | null | undefined;
94
+ matchedPaths?: string[] | undefined;
95
+ factId: string;
96
+ statement: string;
97
+ sourcePaths: string[];
98
+ relevance: string;
99
+ }[];
100
+ total: number;
101
+ nextCursor: string | null;
102
+ summary: string;
103
+ state: string;
104
+ writesKnowledge: boolean;
105
+ coverage: {
106
+ terms?: string[] | undefined;
107
+ downweightedTerms?: string[] | undefined;
108
+ distinctiveTerms?: string[] | undefined;
109
+ status: string;
110
+ };
111
+ }>;
112
+ /** Compare only task-touched portions of candidate fact scopes, including additions/deletions. */
113
+ export declare function changedFacts(store: Store, registry: RegistryRecord, paths: string[]): Promise<{
114
+ candidates: {
115
+ key: string;
116
+ chapterId: string;
117
+ chapter: {
118
+ id: string;
119
+ title: string;
120
+ scope: string;
121
+ excludes: string;
122
+ paths: string[];
123
+ revision: number;
124
+ facts: {
125
+ id: string;
126
+ statement: string;
127
+ evidence: {
128
+ path: string;
129
+ quote: string;
130
+ }[];
131
+ sourceScope: string[];
132
+ dependsOn: string[];
133
+ }[];
134
+ sources: Record<string, string>;
135
+ dependencyFingerprints: Record<string, string>;
136
+ };
137
+ fact: {
138
+ id: string;
139
+ statement: string;
140
+ evidence: {
141
+ path: string;
142
+ quote: string;
143
+ }[];
144
+ sourceScope: string[];
145
+ dependsOn: string[];
146
+ };
147
+ }[];
148
+ candidateFactCount: number;
149
+ changed: {
150
+ entry: ReturnType<Store["facts"]>[number];
151
+ changedPaths: string[];
152
+ errors: string[];
153
+ }[];
154
+ fingerprint: string;
155
+ }>;
156
+ /** Read-only change assessment. Review records are created only by subsequent preparation. */
157
+ export declare function assessChanges(store: Store, input: unknown): Promise<{
158
+ state: string;
159
+ writesKnowledge: boolean;
160
+ items: never[];
161
+ next: string;
162
+ } | {
163
+ next: string;
164
+ items: object[];
165
+ total: number;
166
+ nextCursor: string | null;
167
+ state: string;
168
+ writesKnowledge: boolean;
169
+ createsTask: boolean;
170
+ candidateFactCount: number;
171
+ affectedFactCount: number;
172
+ }>;