@agentskit/doc-bridge 1.3.0 → 1.4.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.
@@ -21,7 +21,7 @@ jobs:
21
21
  runs-on: ubuntu-latest
22
22
  steps:
23
23
  - uses: actions/checkout@v4
24
- - uses: AgentsKit-io/doc-bridge@v1.2.1
24
+ - uses: AgentsKit-io/doc-bridge@v1.4.0
25
25
  with:
26
26
  config-path: doc-bridge.config.json
27
27
  ```
@@ -0,0 +1,129 @@
1
+ ---
2
+ title: Choose the right context layer
3
+ description: Decide when an agent needs repository rules, deterministic routing, code search, RAG, or human review.
4
+ ---
5
+
6
+ # Choose the right context layer
7
+
8
+ Coding agents rarely fail because a repository has no context. They fail because the right context arrives too late, or because several different kinds of context are treated as interchangeable.
9
+
10
+ `AGENTS.md`, Doc Bridge, code search, RAG, and human review solve different problems. The most reliable workflow composes them in that order instead of asking one layer to do every job.
11
+
12
+ ## The short version
13
+
14
+ | Layer | Best question | Use it for | Do not rely on it for |
15
+ | --- | --- | --- | --- |
16
+ | `AGENTS.md` | What rules apply here? | Repository-wide invariants, conventions, safety rules, and workflow expectations | Selecting the owner of every task in a large monorepo |
17
+ | Doc Bridge | Where does this task belong? | Deterministic ownership, starting docs, declared edit roots, package checks, and matching human docs | Explaining every implementation detail or enforcing filesystem permissions |
18
+ | Code search | Where is this exact thing used? | Symbols, imports, references, call sites, and concrete strings | Deciding ownership from similarity alone |
19
+ | RAG | What broader context may be relevant? | Design history, migrations, scattered documentation, and open-ended questions | Overriding an explicit ownership contract |
20
+ | Human review | Is this boundary still correct? | Ambiguous, cross-cutting, security-sensitive, or high-impact decisions | Routine routing that the repository can declare and test |
21
+
22
+ ## Start with repository rules
23
+
24
+ An `AGENTS.md` file is the right place for rules that should survive individual tasks:
25
+
26
+ - required coding conventions;
27
+ - security and privacy constraints;
28
+ - commands that must run before a change is accepted;
29
+ - architectural invariants;
30
+ - contribution and release expectations.
31
+
32
+ Doc Bridge does not replace those rules. A handoff can include `AGENTS.md` in `readBeforeEditing`, then narrow the task to the package-specific material that matters.
33
+
34
+ ## Use Doc Bridge for deterministic routing
35
+
36
+ When the repository already knows which package owns authentication, the agent should not infer ownership from filenames or semantic similarity. Resolve a handoff first:
37
+
38
+ ```bash
39
+ ak-docs query package auth --agent
40
+ ```
41
+
42
+ A useful handoff answers four operational questions:
43
+
44
+ ```json
45
+ {
46
+ "startHere": "docs/for-agents/packages/auth.md",
47
+ "editRoots": ["packages/auth"],
48
+ "checks": [
49
+ "pnpm --filter @example/auth test",
50
+ "pnpm --filter @example/auth lint"
51
+ ],
52
+ "humanDoc": "docs/guides/auth.md"
53
+ }
54
+ ```
55
+
56
+ This is intentionally smaller than a repository dump. It gives the agent an explicit starting point, declared scope, evidence to run, and a human-facing description of the same feature.
57
+
58
+ `editRoots` is a routing and audit contract. It does not create an operating-system sandbox by itself. If a workflow must technically prevent writes outside those roots, enforce that boundary with the agent runner, sandbox, permissions, or CI policy.
59
+
60
+ ## Search after scope is known
61
+
62
+ Code search is strongest after the owner is resolved. Inside the intended scope, use it to find:
63
+
64
+ - the implementation of a symbol;
65
+ - all imports of an adapter;
66
+ - tests for an error code;
67
+ - callers affected by a signature change.
68
+
69
+ Search can reveal that a task is genuinely cross-cutting. When it does, expand the declared handoff or ask for human review. Do not quietly turn a package-scoped change into a repository-wide edit.
70
+
71
+ ## Add RAG for open-ended context
72
+
73
+ RAG is useful when the question does not have one exact answer:
74
+
75
+ - Why did the authentication design change?
76
+ - Which migration notes mention token rotation?
77
+ - What guidance exists for moving from one provider to another?
78
+
79
+ That context can improve the implementation, but it should expand a deterministic handoff rather than replace one. Similar documents are evidence, not ownership.
80
+
81
+ Doc Bridge keeps this distinction explicit: Layer 0 indexing and handoffs work offline without a model or API key; RAG and chat are optional intelligence layers.
82
+
83
+ ## Escalate ambiguity to a human
84
+
85
+ Some changes should not be forced into a convenient directory. Ask for human review when:
86
+
87
+ - multiple packages legitimately own part of the change;
88
+ - a public contract or security boundary may change;
89
+ - the handoff conflicts with the current repository shape;
90
+ - checks are missing or no longer prove the behavior;
91
+ - the cost of a wrong boundary is high.
92
+
93
+ A useful routing system should make uncertainty visible. It should not produce false confidence when the repository has not declared an answer.
94
+
95
+ ## Recommended order
96
+
97
+ ```text
98
+ resolve handoff
99
+ → read AGENTS.md and startHere
100
+ → search exact code inside the declared scope
101
+ → retrieve broader context when needed
102
+ → edit the intended roots
103
+ → run the declared checks
104
+ → request human review for unresolved boundaries
105
+ ```
106
+
107
+ For an existing repository, the smallest adoption path is:
108
+
109
+ ```bash
110
+ npm install --save-dev @agentskit/doc-bridge@1.2.6
111
+ npx ak-docs init
112
+ npx ak-docs index
113
+ npx ak-docs query package example --agent
114
+ npx ak-docs gate run
115
+ ```
116
+
117
+ The gate makes drift visible when ownership inputs or linked documentation change without a refreshed index. That keeps the routing contract reviewable instead of silently rebuilding it during validation.
118
+
119
+ ## A practical decision rule
120
+
121
+ If the question begins with **must**, put the invariant in repository instructions. If it begins with **where**, resolve a Doc Bridge handoff. If it begins with **which exact reference**, search the code. If it begins with **why** or **what else**, retrieve broader context. If the answers disagree, stop and ask a human.
122
+
123
+ ## Related
124
+
125
+ - [Index and query](./index-and-query.md)
126
+ - [For agents](../for-agents.md)
127
+ - [Chat and RAG](../chat-and-rag.md)
128
+ - [Gate in CI](./gate-ci.md)
129
+ - [AgentHandoff schema](../schemas/agent-handoff-v1.md)
@@ -38,7 +38,7 @@ jobs:
38
38
  runs-on: ubuntu-latest
39
39
  steps:
40
40
  - uses: actions/checkout@v4
41
- - uses: AgentsKit-io/doc-bridge@v1.2.1
41
+ - uses: AgentsKit-io/doc-bridge@v1.4.0
42
42
  with:
43
43
  config-path: doc-bridge.config.json
44
44
  ```
@@ -3,6 +3,7 @@
3
3
  "pages": [
4
4
  "install-and-run",
5
5
  "index-and-query",
6
+ "choose-context-layer",
6
7
  "gate-ci",
7
8
  "mcp-agents",
8
9
  "memory-pipeline",
@@ -337,7 +337,7 @@
337
337
  <div class="terminal-bar"><span class="dot dot-r"></span><span class="dot dot-y"></span><span class="dot dot-g"></span></div>
338
338
  <div class="terminal-body">
339
339
  <div class="t-dim"># .github/workflows/pr.yml</div>
340
- <div>- uses: <span class="t-hi">AgentsKit-io/doc-bridge@v1.2.1</span></div>
340
+ <div>- uses: <span class="t-hi">AgentsKit-io/doc-bridge@v1.4.0</span></div>
341
341
  <div>&nbsp;&nbsp;with:</div>
342
342
  <div>&nbsp;&nbsp;&nbsp;&nbsp;config-path: doc-bridge.config.json</div>
343
343
  </div>
@@ -77,7 +77,7 @@ Agents call `handoff.resolve` before editing `packages/*`:
77
77
  ## CI gate
78
78
 
79
79
  ```yaml
80
- - uses: AgentsKit-io/doc-bridge@v1.2.1
80
+ - uses: AgentsKit-io/doc-bridge@v1.4.0
81
81
  ```
82
82
 
83
83
  Or: `ak-docs index && ak-docs gate run` — stale index fails the PR.
@@ -71,7 +71,7 @@ Root `package.json`:
71
71
  ## CI (GitHub Action)
72
72
 
73
73
  ```yaml
74
- - uses: AgentsKit-io/doc-bridge@v1.2.1
74
+ - uses: AgentsKit-io/doc-bridge@v1.4.0
75
75
  ```
76
76
 
77
77
  Or manual:
@@ -2,7 +2,7 @@
2
2
  "manifest_version": "0.3",
3
3
  "name": "doc-bridge",
4
4
  "display_name": "Doc Bridge",
5
- "version": "1.3.0",
5
+ "version": "1.4.1",
6
6
  "description": "Deterministic repository handoffs for coding agents, running locally without an LLM or API key.",
7
7
  "long_description": "Doc Bridge turns a repository's own documentation and ownership metadata into deterministic handoffs: where an agent should start, which paths it may edit, which checks it must run, and when a human must take over. The local connector exposes the same read-only contract available through Doc Bridge CLI and CI.",
8
8
  "author": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentskit/doc-bridge",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "mcpName": "io.github.AgentsKit-io/doc-bridge",
5
5
  "description": "Human↔agent documentation bridge — deterministic handoffs, doc-site links, memory→docs, optional AgentsKit RAG/chat.",
6
6
  "type": "module",
@@ -40,12 +40,13 @@
40
40
  "mcpb",
41
41
  "tsup.config.ts",
42
42
  "tsconfig.json",
43
- "src"
43
+ "src",
44
+ "skills"
44
45
  ],
45
46
  "scripts": {
46
47
  "prebuild": "node scripts/sync-version.mjs",
47
48
  "build": "tsup",
48
- "test": "vitest run",
49
+ "test": "vitest run && pnpm test:cursor-plugin && pnpm test:claude-plugin && pnpm test:copilot-plugin && pnpm test:portable-skill",
49
50
  "test:watch": "vitest",
50
51
  "coverage": "vitest run --coverage",
51
52
  "check:ecosystem-upstream": "node scripts/check-ecosystem-upstream.mjs",
@@ -60,6 +61,10 @@
60
61
  "mcpb:smoke": "node scripts/smoke-mcpb.mjs",
61
62
  "mcpb:pack": "npm run mcpb:stage && npm run mcpb:smoke && node scripts/build-mcpb.mjs pack",
62
63
  "test:mcpb": "node --test scripts/mcpb-contract.test.mjs",
64
+ "test:cursor-plugin": "node --test scripts/cursor-plugin-contract.test.mjs",
65
+ "test:claude-plugin": "node --test scripts/claude-plugin-contract.test.mjs",
66
+ "test:copilot-plugin": "node --test scripts/copilot-plugin-contract.test.mjs",
67
+ "test:portable-skill": "node --test scripts/portable-skill-contract.test.mjs",
63
68
  "coverage:badge": "node scripts/update-coverage-badge.mjs",
64
69
  "changeset": "changeset",
65
70
  "version-packages": "changeset version && node scripts/sync-version.mjs",
@@ -85,12 +90,18 @@
85
90
  "agentskit",
86
91
  "documentation",
87
92
  "mcp",
93
+ "pi-package",
88
94
  "for-agents",
89
95
  "llms-txt",
90
96
  "agent-handoff",
91
97
  "rag",
92
98
  "human-agent-bridge"
93
99
  ],
100
+ "pi": {
101
+ "skills": [
102
+ "./skills"
103
+ ]
104
+ },
94
105
  "license": "MIT",
95
106
  "repository": {
96
107
  "type": "git",
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: doc-bridge-handoff
3
+ description: Resolve Doc Bridge boundaries before changing code.
4
+ version: 1.0.0
5
+ author: AgentsKit
6
+ license: MIT
7
+ platforms:
8
+ - darwin
9
+ - linux
10
+ - windows
11
+ ---
12
+
13
+ # Doc Bridge handoff
14
+
15
+ Use this skill before editing a repository that contains `doc-bridge.config.json`.
16
+
17
+ 1. Resolve the package or ownership id that best matches the requested change:
18
+ - Prefer the read-only MCP tool `handoff.resolve` when it is available.
19
+ - Otherwise run `node <skill-directory>/scripts/resolve-handoff.mjs <id>` from the repository.
20
+ 2. Read every file in `readBeforeEditing`, beginning with `startHere`.
21
+ 3. Keep changes inside `editRoots`. If the requested path is not covered, stop and report the missing route instead of guessing.
22
+ 4. Make the smallest change that satisfies the request.
23
+ 5. Run every command in `checks` before claiming completion.
24
+ 6. If documentation changed, refresh the Doc Bridge index and run its gate.
25
+
26
+ If resolution fails, returns incomplete fields, or names an unknown target, stop. Do not infer edit permission from repository layout.
27
+
28
+ The resolver and MCP tools are read-only. They resolve project guidance but never authorize edits, publish changes, execute returned checks, or replace repository instructions. The skill uses no credentials and has no provider, hosted service, or AKOS dependency.
29
+
30
+ ## Portable runtimes
31
+
32
+ This directory follows the open Agent Skills layout: one `SKILL.md` plus optional scripts and fixtures. It can be loaded as a local skill by OpenClaw-compatible clients, Hermes Agent, Pi, Cursor, or another runtime that supports Agent Skills and shell execution. Runtime-specific publication metadata is intentionally kept outside the skill.
@@ -0,0 +1,23 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "corpus": {
4
+ "agent": {
5
+ "root": "docs/for-agents"
6
+ }
7
+ },
8
+ "routing": {
9
+ "options": {
10
+ "ownership": {
11
+ "payments": {
12
+ "path": "packages/payments",
13
+ "purpose": "Synthetic package used only to verify portable handoff routing",
14
+ "checks": ["npm test -- payments"],
15
+ "agentDoc": "docs/for-agents/packages/payments.md"
16
+ }
17
+ }
18
+ }
19
+ },
20
+ "gates": {
21
+ "preset": "minimal"
22
+ }
23
+ }
@@ -0,0 +1,5 @@
1
+ # Payments package
2
+
3
+ This is public synthetic guidance for the portable skill compatibility test.
4
+
5
+ Only edit `packages/payments` and run the checks returned by Doc Bridge.
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "synthetic-payments",
3
+ "private": true
4
+ }
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawnSync } from 'node:child_process'
4
+ import { isAbsolute } from 'node:path'
5
+
6
+ const VERSION = '1.4.1'
7
+ const kinds = new Set(['package', 'ownership'])
8
+ const args = process.argv.slice(2)
9
+ const id = args[0]
10
+ const kindFlag = args.indexOf('--kind')
11
+ const configFlag = args.indexOf('--config')
12
+ const kind = kindFlag === -1 ? 'package' : args[kindFlag + 1]
13
+ const config = configFlag === -1 ? undefined : args[configFlag + 1]
14
+
15
+ const fail = (message) => {
16
+ process.stderr.write(`Doc Bridge handoff blocked: ${message}\n`)
17
+ process.exit(1)
18
+ }
19
+
20
+ if (!id || id.startsWith('--') || /[\u0000-\u001f\u007f]/u.test(id)) {
21
+ fail('provide a package or ownership id')
22
+ }
23
+ if (!kind || !kinds.has(kind)) fail('--kind must be package or ownership')
24
+ if (configFlag !== -1 && (!config || config.startsWith('--'))) fail('--config requires a path')
25
+
26
+ const queryArgs = ['query', kind, id, '--agent']
27
+ if (config) queryArgs.push('--config', config)
28
+
29
+ const localBin = process.env.DOC_BRIDGE_BIN
30
+ const command = localBin ? process.execPath : 'npx'
31
+ const commandArgs = localBin
32
+ ? [localBin, ...queryArgs]
33
+ : ['-y', `@agentskit/doc-bridge@${VERSION}`, ...queryArgs]
34
+ const result = spawnSync(command, commandArgs, {
35
+ cwd: process.cwd(),
36
+ encoding: 'utf8',
37
+ timeout: 60_000,
38
+ maxBuffer: 1024 * 1024,
39
+ })
40
+
41
+ if (result.error) fail(result.error.message)
42
+ if (result.status !== 0) fail(result.stderr.trim() || `resolver exited with status ${result.status}`)
43
+
44
+ let handoff
45
+ try {
46
+ handoff = JSON.parse(result.stdout)
47
+ } catch {
48
+ fail('resolver returned invalid JSON')
49
+ }
50
+
51
+ const nonEmptyStrings = (value) =>
52
+ Array.isArray(value) && value.length > 0 && value.every((item) => typeof item === 'string' && item.trim())
53
+ const safeRelativePath = (value) => {
54
+ if (typeof value !== 'string' || !value.trim() || isAbsolute(value)) return false
55
+ if (/^(?:[a-z]:[\\/]|\\\\)/iu.test(value)) return false
56
+ return !value.split(/[\\/]+/u).includes('..')
57
+ }
58
+
59
+ if (handoff?.target?.id !== id) fail('resolver returned a different target')
60
+ if (!safeRelativePath(handoff.startHere)) fail('startHere is missing or unsafe')
61
+ if (!nonEmptyStrings(handoff.readBeforeEditing) || !handoff.readBeforeEditing.every(safeRelativePath)) {
62
+ fail('readBeforeEditing is missing or unsafe')
63
+ }
64
+ if (!handoff.readBeforeEditing.includes(handoff.startHere)) fail('readBeforeEditing omits startHere')
65
+ if (!nonEmptyStrings(handoff.editRoots) || !handoff.editRoots.every(safeRelativePath)) {
66
+ fail('editRoots is missing or unsafe')
67
+ }
68
+ if (!nonEmptyStrings(handoff.checks)) fail('checks are missing')
69
+
70
+ process.stdout.write(`${JSON.stringify(handoff, null, 2)}\n`)
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const PACKAGE_VERSION = '1.3.0'
1
+ export const PACKAGE_VERSION = '1.4.1'