agent-dir 0.4.1 → 1.0.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/docs/MCP.md ADDED
@@ -0,0 +1,106 @@
1
+ # MCP interface and security model
2
+
3
+ Agent Dir exposes a local project through an authenticated, stateless Model Context Protocol endpoint.
4
+
5
+ ## Endpoint and authentication
6
+
7
+ - `POST /mcp` is the application MCP endpoint and requires authentication.
8
+ - `HEAD /__health` is reserved for local tunnel health checks and does not expose project contents.
9
+ - Legacy direct filesystem REST routes such as `/__tree` and direct `GET`/`PUT`/`DELETE` file paths are not supported.
10
+
11
+ Use the Bearer token in the standard header:
12
+
13
+ ```http
14
+ Authorization: Bearer <token>
15
+ ```
16
+
17
+ The server also accepts a query-string token for clients that cannot set an Authorization header. Prefer the header because query-string tokens can be exposed in URLs and logs.
18
+
19
+ ## Stateless protocol behavior
20
+
21
+ The implementation supports MCP protocol version `2026-07-28`. Requests carry protocol version and client capabilities in `params._meta`; this path does not require an initialize handshake or `Mcp-Session-Id`.
22
+
23
+ Standard Streamable HTTP requests do not need implementation-specific `MCP-Protocol-Version`, `Mcp-Method`, or `Mcp-Name` headers. If supplied, these headers are validated against the JSON-RPC request and metadata.
24
+
25
+ Supported features include:
26
+
27
+ - `server/discover`
28
+ - cursor pagination for list-style methods
29
+ - `subscriptions/listen` for tool, prompt, and resource change events
30
+ - resource subscriptions and filesystem change notifications
31
+ - cache metadata
32
+ - structured tool results with `resultType` and `outputSchema`
33
+ - the stable `io.modelcontextprotocol/skills` extension
34
+
35
+ Modern `subscriptions/listen` replaces the legacy GET/SSE notification model. List-style methods use opaque cursors when more than 50 entries are available.
36
+
37
+ ## Public tool set
38
+
39
+ The core public tool set is intentionally small:
40
+
41
+ | Tool | Purpose |
42
+ | --- | --- |
43
+ | `project_context` | Compact project overview and active execution policy |
44
+ | `find_files` | Find paths by glob |
45
+ | `search_code` | Search source-like files with bounded output |
46
+ | `find_symbol` | Locate likely symbol definitions |
47
+ | `find_references` | Locate symbol references |
48
+ | `read_range` | Read a bounded line range from a UTF-8 file |
49
+ | `apply_changes` | Create, patch, or delete files |
50
+ | `file_info` | Inspect filesystem metadata |
51
+ | `validate` | Run lightweight diagnostics and explicitly requested allowed npm scripts |
52
+ | `run_npm_batch` | Run explicitly allowlisted npm scripts sequentially |
53
+ | `run_command_batch` | Run explicitly allowlisted executables sequentially without a shell |
54
+ | `codegraph_explore` | Optional structural code intelligence when CodeGraph is available |
55
+
56
+ `codegraph_explore` is only advertised when CodeGraph is installed and the current project has a readable `.codegraph/codegraph.db` index. Other CodeGraph tools are not forwarded.
57
+
58
+ Batch command operations execute sequentially and stop at the first failed command. Tool results include structured content and a serialized text representation; tools returning structured data advertise an output schema.
59
+
60
+ ## Command execution policy
61
+
62
+ npm scripts and other executables use separate allowlists. An executable not in the configured allowlist is rejected, and configured `blacklistedCommands` prefixes override the allowlist. Commands are launched without a shell.
63
+
64
+ Git is run through `run_command_batch` when `git` is allowlisted. There are no dedicated Git MCP tools. This keeps the advertised tool set small while preserving explicit executable and argument restrictions. Avoid allowing shells or interpreters unless broader command execution is intentional.
65
+
66
+ ## CodeGraph integration
67
+
68
+ CodeGraph is optional and installed separately:
69
+
70
+ ```bash
71
+ npm install -g @colbymchenry/codegraph
72
+ codegraph init
73
+ ```
74
+
75
+ Agent Dir exposes `codegraph_explore` only when the executable is on `PATH` and the current project has a readable index. It starts CodeGraph on first use and reuses the child process for subsequent calls. The project root is fixed as the CodeGraph path; callers cannot forward arbitrary `projectPath` values. Agent Dir passes a limited environment to the child process and terminates it during shutdown.
76
+
77
+ Discovery distinguishes these states:
78
+
79
+ - `not_installed` — CodeGraph is unavailable on `PATH`.
80
+ - `not_indexed` — installed, but this project has no readable index.
81
+ - `available` — installed and indexed.
82
+ - `startup_failed` / `runtime_failed` — CodeGraph failed to start or later terminated; Agent Dir remains available.
83
+
84
+ When indexed, agents are instructed to use CodeGraph for non-trivial structural questions such as call/data flow, symbol relationships, and change impact. Exact-text searches and focused file edits use Agent Dir's native tools.
85
+
86
+ ## Agent instructions and Skills
87
+
88
+ `server/discover` returns dynamically generated instructions. The Resources primitive exposes:
89
+
90
+ ```text
91
+ agent-dir://instructions
92
+ agent-dir://capabilities
93
+ ```
94
+
95
+ The capabilities resource reports the Agent Dir version, registered tool names, execution policy, and preferred/avoid tool-selection patterns.
96
+
97
+ Agent Dir implements the stable MCP Skills extension (`io.modelcontextprotocol/skills`) and discovers project-local `SKILL.md` files under:
98
+
99
+ ```text
100
+ skills/
101
+ .agents/skills/
102
+ .claude/skills/
103
+ .github/skills/
104
+ ```
105
+
106
+ Skills are exposed through `skills/list`, `skills/get`, `resources/list`, and `resources/read`. Skill manifests are bounded to 512 resources and 16 MiB. Binary supporting files are returned as MCP blobs; `resources/directory/read` lists direct children of a skill resource directory.
@@ -0,0 +1,213 @@
1
+ # Releasing agent-dir
2
+
3
+ This document is the authoritative maintainer/agent procedure for publishing `agent-dir`.
4
+
5
+ ## Architecture
6
+
7
+ feature/*
8
+ │
9
+ ├── PR → staging
10
+ │ └── CI
11
+ │
12
+ └── promotion PR → main
13
+ └── CI
14
+ │
15
+ ▼
16
+ .github/workflows/publish.yml
17
+ │
18
+ ├── npm run check
19
+ ├── npm test
20
+ ├── npm pack --dry-run
21
+ └── npm run release
22
+ │
23
+ └── semantic-release
24
+ ├── determine SemVer
25
+ ├── update package.json/package-lock.json
26
+ ├── commit release
27
+ ├── create vX.Y.Z tag
28
+ ├── create GitHub Release
29
+ └── publish npm package
30
+
31
+ `main` and `staging` are protected. Normal human and agent changes reach them through pull requests.
32
+
33
+ ## Release source of truth
34
+
35
+ - `.releaserc.json` — semantic-release configuration
36
+ - `.github/workflows/publish.yml` — production release workflow
37
+ - `package.json` — package metadata and release script
38
+ - npm Trusted Publishing/OIDC — npm authentication for GitHub Actions
39
+
40
+ The workflow filename `publish.yml` is intentional. Do not rename it. npm Trusted Publishing is configured against the workflow identity.
41
+
42
+ The semantic-release repository URL uses SSH: `git@github.com:SarfDime/agent-dir.git`.
43
+
44
+ The release workflow uses the repository's release SSH key to allow semantic-release to update protected `main` with its release commit/tag.
45
+
46
+ ## Normal release procedure
47
+
48
+ ### 1. Make the change
49
+
50
+ Work on a feature branch. Keep the change focused. Use a Conventional Commit message whose type reflects the intended release impact.
51
+
52
+ Examples: `fix: handle tunnel reconnect`, `feat: add project snapshots`, `feat!: change authentication protocol`.
53
+
54
+ Do not manually edit the package version.
55
+
56
+ ### 2. Validate locally
57
+
58
+ npm run check
59
+ npm test
60
+ npm pack --dry-run
61
+
62
+ `npm pack --dry-run` is important: inspect the file list and make sure the package does not contain credentials, local configuration, development-only files, or other unintended content.
63
+
64
+ ### 3. Merge through staging
65
+
66
+ Push the feature branch and open a PR targeting `staging`.
67
+
68
+ The required CI check is `Check`. It runs `npm ci`, `npm run check`, `npm test`, and `npm pack --dry-run`.
69
+
70
+ Do not bypass a failing check. After checks pass, merge the PR into `staging`.
71
+
72
+ ### 4. Promote staging to main
73
+
74
+ Create a promotion PR: `staging → main`.
75
+
76
+ CI runs again because `main` is also a pull-request target. Merge only after the required `Check` status is green.
77
+
78
+ ### 5. Let GitHub Actions publish
79
+
80
+ The merge to `main` creates a push to `main`, which starts `.github/workflows/publish.yml`.
81
+
82
+ The workflow validates the package again and invokes `npm run release`.
83
+
84
+ Do not run `npm publish` locally and do not manually create a release tag.
85
+
86
+ semantic-release reads the Conventional Commit history since the previous release and decides whether a release is required.
87
+
88
+ ## Version rules
89
+
90
+ | Change | Version impact |
91
+ |---|---|
92
+ | `fix:` | patch |
93
+ | `feat:` | minor |
94
+ | `feat!:` | major |
95
+ | `BREAKING CHANGE:` footer | major |
96
+ | `docs:` | none |
97
+ | `test:` | none |
98
+ | `chore:` | none |
99
+ | `refactor:` | none |
100
+ | `ci:` | none |
101
+
102
+ There is an explicit semantic-release rule: `fix(ci)` has `release: false`.
103
+
104
+ A CI-only repair can be promoted to `main` without creating a package release. Do not change its commit type merely to force publication.
105
+
106
+ ## What semantic-release changes
107
+
108
+ When a release is required, semantic-release is responsible for:
109
+
110
+ - calculating the next SemVer version;
111
+ - updating `package.json`;
112
+ - updating `package-lock.json`;
113
+ - creating the release commit with `[skip ci]`;
114
+ - creating the `vX.Y.Z` Git tag;
115
+ - creating the GitHub Release;
116
+ - publishing the package to npm.
117
+
118
+ The release commit is `chore(release): <version> [skip ci]`. The release commit itself must not start another release cycle.
119
+
120
+ ## npm authentication
121
+
122
+ npm publishing is performed by GitHub Actions using npm Trusted Publishing/OIDC.
123
+
124
+ The workflow requests `id-token: write`. Do not add an npm token to the workflow unless the publishing architecture is deliberately changed and reconfigured.
125
+
126
+ Do not expose or print npm credentials.
127
+
128
+ `GITHUB_TOKEN` is separate from npm authentication and is used by semantic-release for GitHub release operations. The repository currently supplies the release workflow's GitHub credential through the `RELEASE_TOKEN` Actions secret.
129
+
130
+ ## Protected-branch automation
131
+
132
+ The release workflow needs to write the semantic-release commit/tag back to `main`, even though normal pushes to `main` are blocked.
133
+
134
+ That automation is authorized separately through the release SSH deploy key stored in the `RELEASE_DEPLOY_KEY_B64` Actions secret.
135
+
136
+ Do not remove or replace this mechanism casually. If it must change, verify the complete release flow and npm Trusted Publishing configuration before merging the change.
137
+
138
+ The intended security boundary is:
139
+
140
+ - humans/agents: PR-only changes;
141
+ - release automation: narrowly authorized to perform the semantic-release update on `main`.
142
+
143
+ ## How to verify a release
144
+
145
+ After a release-worthy change reaches `main`, verify:
146
+
147
+ 1. The `Release` workflow completed successfully.
148
+ 2. semantic-release reported the expected next version.
149
+ 3. The repository has a matching `vX.Y.Z` tag.
150
+ 4. The GitHub Release exists for that tag.
151
+ 5. npm reports the expected package version.
152
+ 6. `package.json` and `package-lock.json` on `main` contain the released version after the release commit.
153
+
154
+ The package version and release tag must agree: `package.json version = X.Y.Z` and `Git tag = vX.Y.Z`.
155
+
156
+ ## When a release does not happen
157
+
158
+ A successful `Release` workflow can legitimately produce no release when commits since the previous release contain no release-worthy Conventional Commit.
159
+
160
+ Examples: `docs: update README`, `test: add regression coverage`, `chore: update development tooling`, `fix(ci): correct workflow configuration`.
161
+
162
+ Do not interpret a successful workflow with no release as a publishing failure.
163
+
164
+ ## Release failure recovery
165
+
166
+ When a release fails:
167
+
168
+ 1. Inspect the exact failing workflow step.
169
+ 2. Determine whether semantic-release calculated a release.
170
+ 3. Check the latest Git tag.
171
+ 4. Check the current npm published version.
172
+ 5. Check whether a GitHub Release was created.
173
+ 6. Check whether the release commit was created.
174
+ 7. Only then decide whether another change or rerun is appropriate.
175
+
176
+ Do not manually bump the version, move/delete/recreate an existing release tag, run `npm publish` from a workstation, create a second tag for the same version, or rewrite commit history just to make semantic-release produce a version.
177
+
178
+ If a release was partially created, reconcile the actual Git/npm/GitHub state before making another release attempt.
179
+
180
+ ## CI workflow constraints
181
+
182
+ `.github/workflows/ci.yml` runs for pull requests targeting `staging` and `main`.
183
+
184
+ Its concurrency key must remain safe for both PR events and any diagnostic/manual event that may temporarily be introduced:
185
+
186
+ group: ci-${{ github.event.pull_request.number || github.ref }}
187
+
188
+ Do not replace this with a direct `pull_request.number` reference.
189
+
190
+ The production release workflow intentionally runs only on pushes to `main`:
191
+
192
+ on:
193
+ push:
194
+ branches:
195
+ - main
196
+
197
+ Keep release execution serialized:
198
+
199
+ concurrency:
200
+ group: release
201
+ cancel-in-progress: false
202
+
203
+ ## Files an agent should inspect first
204
+
205
+ AGENTS.md
206
+ docs/RELEASING.md
207
+ .releaserc.json
208
+ package.json
209
+ .github/workflows/ci.yml
210
+ .github/workflows/publish.yml
211
+ .github/CONTRIBUTING.md
212
+
213
+ Do not assume the release process from generic npm conventions. This repository's protected-branch and Trusted Publishing configuration is intentional.
@@ -0,0 +1,109 @@
1
+ # Telemetry interpretation
2
+
3
+ Agent Dir telemetry is a local operational record of MCP activity. It describes what the server handled, how long it took, and where failures occurred without recording project contents, command arguments, tokens, environment variables, or project paths at standard levels. The opt-in diagnostic level additionally records local troubleshooting metadata, including project paths, hostname, username, process identifiers, full Node version, Linux distribution ID/name/version, kernel version, memory usage, process uptime, and bounded raw tool inputs/outputs or error details. Diagnostic records can contain source code, command arguments, project data, and other sensitive material; they are stored locally and should be enabled only when intended.
4
+
5
+ ## Data hierarchy
6
+
7
+ Telemetry is organized as:
8
+
9
+ - `none`: disabled.
10
+ - `anonymous`: operational events without runtime/project context.
11
+ - `basic`: anonymous events plus coarse runtime context.
12
+ - `detailed`: basic context plus coarse project classification.
13
+ - `diagnostic`: detailed context plus identifying/troubleshooting metadata and bounded raw tool input/output or error details. This can contain source code, command arguments, and sensitive project information; it is stored locally. Use only when intended.
14
+
15
+ configuration → session → event
16
+
17
+ - **Configuration** identifies the Agent Dir configuration that produced the event. Named profiles use the profile name; direct CLI configurations use a stable hash of the effective share configuration.
18
+ - **Session** identifies one MCP handler lifetime. A session starts with its first MCP request and is finalized when the server closes the handler.
19
+ - **Event** is one recorded operation or one session-finalization record.
20
+
21
+ ## Event types
22
+
23
+ ### mcp_request
24
+
25
+ One MCP/JSON-RPC request handled by Agent Dir. Its duration covers the request from entry through response/error handling.
26
+
27
+ ### tool_call
28
+
29
+ One Agent Dir tool execution inside an MCP request. Tool metrics are the best measure of individual Agent Dir capability reliability. Tool events include UTF-8 input/output byte counts, a rough token-size estimate (`ceil(bytes / 4)`), hashed request/input/output fingerprints, output repetition within the current process session, and bounded per-file metadata. File metadata contains hashes of paths and returned file text plus byte counts; it does not contain the paths or text themselves. A matching output fingerprint means the serialized tool result was identical, not that Claude necessarily re-read or billed those bytes again.
30
+
31
+ Token estimates are **not tokenizer measurements** and do not represent Claude's actual input/output tokens or billing. Agent Dir cannot observe Claude's hidden prompt, cached tokens, reasoning tokens, or context carried between turns. Search results can be compared by result count, output bytes, truncation, and pagination, but Agent Dir does not currently judge semantic search relevance. Repeated input fingerprints and event ordering can help identify retry patterns, while validation-after-change counts must be inferred from the raw event sequence rather than treated as a definitive causal metric.
32
+
33
+ ### command_call
34
+
35
+ One command operation performed by an Agent Dir command tool. Command metrics describe command execution separately from MCP transport success.
36
+
37
+ ### session
38
+
39
+ A final summary emitted when the MCP handler closes. It contains:
40
+
41
+ - wallClockDurationMs: elapsed time from the first request to the last request.
42
+ - activeRequestDurationMs: sum of MCP request processing durations.
43
+ - idleGapDurationMs: wall-clock time minus active request time.
44
+ - requestCount: number of MCP requests in the session.
45
+ - toolCallCount: number of tool calls in the session.
46
+ - commandCallCount: number of command operations in the session.
47
+
48
+ Idle gaps are **not agent thinking time**. They can contain agent reasoning, network latency, client delays, scheduling, or other time outside Agent Dir request processing.
49
+
50
+ ## Success rates
51
+
52
+ There is intentionally **no single overall success rate**.
53
+
54
+ An MCP tool invocation normally produces both a tool_call event and an enclosing mcp_request event. Counting both as independent successes or failures would double-count the same operation and make the metric misleading.
55
+
56
+ Instead, interpret these independently:
57
+
58
+ - **MCP success** = successful MCP requests / MCP requests.
59
+ - **Tool success** = successful tool calls / tool calls.
60
+ - **Command success** = successful command calls / command calls.
61
+ - **Per-tool success** = successful calls for that tool / calls for that tool.
62
+ - **Per-command success** = successful calls for that command operation / calls for that command operation.
63
+
64
+ A rate of — means there were no events of that type, not that the type failed.
65
+
66
+ ## Failures
67
+
68
+ Failure categories are separated by event type:
69
+
70
+ - mcp failures belong to MCP request handling.
71
+ - tool failures belong to Agent Dir tool execution.
72
+ - command failures belong to command execution.
73
+
74
+ This separation prevents a failed tool call and its failed enclosing MCP request from being presented as one combined failure metric.
75
+
76
+ ## Duration metrics
77
+
78
+ - **Avg** is the arithmetic mean of recorded durations for that operation.
79
+ - **P95** is the 95th-percentile recorded duration using the nearest observed sample at or above the percentile rank.
80
+ - Session wall-clock time is not equivalent to active server processing time.
81
+
82
+ Do not infer agent reasoning time, user wait time, or network latency from tool duration alone.
83
+
84
+ ## Privacy levels
85
+
86
+ - **anonymous** records operational event data only.
87
+ - **basic** adds bounded Agent Dir/runtime and MCP client information.
88
+ - **detailed** additionally adds coarse project classification such as language, package manager, Git/CodeGraph availability, and project size.
89
+ - **diagnostic** additionally adds local troubleshooting metadata such as project paths, hostname, username, process identifiers, Node version, memory usage, and process uptime. This level is opt-in and should only be enabled when needed for local diagnosis.
90
+
91
+ Telemetry is persisted locally only when enabled. Persistence failures must never affect MCP request handling.
92
+
93
+ ## Reading telemetry show
94
+
95
+ telemetry show is the raw event stream grouped by configuration and session. Use it when exact event order, timestamps, event fields, or individual failures matter.
96
+
97
+ ## Reading telemetry summary
98
+
99
+ telemetry summary is an aggregation for humans and agents. Prefer its separate MCP/tool/command success rates and per-tool/per-command metrics for reliability analysis. Use the raw stream when investigating a specific request or reconstructing event order. Raw tool events currently provide the token-size, fingerprint, duplicate-output, and file-metadata signals described above; aggregated summary fields for those measurements have not yet been added.
100
+
101
+ ## Data quality rules
102
+
103
+ Telemetry should be treated as measurement data, not as a complete audit log:
104
+
105
+ 1. Session records are only emitted when a handler closes normally through Agent Dir shutdown.
106
+ 2. An active session may therefore have no session event yet.
107
+ 3. Legacy persisted session records without the current timing fields are identified separately and are not used as current session timing data.
108
+ 4. Event counts include session records, because they are recorded telemetry events; success rates exclude session records because sessions are summaries, not operations.
109
+ 5. MCP request and tool events are deliberately not combined into one reliability denominator.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-dir",
3
- "version": "0.4.1",
3
+ "version": "1.0.0",
4
4
  "description": "Expose a local project to an AI agent through authenticated MCP, filesystem tools, and allowlisted development commands",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,6 +14,9 @@
14
14
  "dist/bin",
15
15
  "dist/src",
16
16
  "README.md",
17
+ "docs",
18
+ "assets/agent-dir-banner.svg",
19
+ "SECURITY.md",
17
20
  "LICENSE"
18
21
  ],
19
22
  "engines": {