Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ See `docs/guidelines/TESTING.md` for comprehensive patterns.

## Workspace Boundaries

- Root `src/**` is still the published `githits` CLI implementation until the CLI package move completes. It owns Commander commands, local auth storage, browser login, init/setup flows, local stdio MCP startup, and plugin/assistant packaging assets.
- `packages/core-internal` is private source. It owns transport-neutral service clients, service interfaces, shared request/header/telemetry primitives, neutral service errors, PKCE helpers, and `TokenProvider`. Never publish or leak `@githits/core-internal` into public artifacts.
- `packages/mcp` is the public `@githits/mcp` package. Its public tool/server API is `packages/mcp/src/index.ts`: transport-neutral MCP server creation, tool registration, descriptors, instructions, request-scoped service provider types, and MCP service types. Its public runtime/client API is `packages/mcp/src/client.ts`, exported as `@githits/mcp/client`, for remote MCP servers that need concrete service implementations and token/header/config helpers.
- Root `src/**` is still the published `githits` CLI implementation until the CLI package move completes. It owns Commander commands, local auth storage, browser login, init/setup flows, local stdio MCP startup, plugin/assistant packaging assets, and the diagnostics implementation/lifecycle (environment, process, and output destinations).
- `packages/core-internal` is private source. It owns transport-neutral service clients, service interfaces, shared request/header primitives, the host-supplied `ServiceDiagnostics` contract, neutral service errors, PKCE helpers, and `TokenProvider`. It must not discover diagnostics environment settings or own diagnostics process/output destinations. Never publish or leak `@githits/core-internal` into public artifacts.
- `packages/mcp` is the public `@githits/mcp` package. Its public tool/server API is `packages/mcp/src/index.ts`: transport-neutral MCP server creation, tool registration, descriptors, instructions, request-scoped service provider types, and MCP service types. Its public runtime/client API is `packages/mcp/src/client.ts`, exported as `@githits/mcp/client`, for remote MCP servers that need concrete service implementations, token/header/config helpers, and optional injected `ServiceDiagnostics`.
- `@githits/mcp/smoke-test` is a public validation helper entrypoint for remote MCP servers. It exports smoke assertions and `runMcpSmoke()` without depending on local CLI startup.
- `@githits/mcp/internal` is a workspace-only alias for root CLI transition helpers. External packages and the future remote MCP server repo must never import it. If remote server work needs something internal, promote the smallest stable API through `@githits/mcp` instead.
- Public package artifacts for both root `githits` and `@githits/mcp` must not contain `@githits/core-internal`, `workspace:*`, `@githits/mcp/internal`, or private source aliases in JS, declarations, or manifests.
- Public package artifacts for both root `githits` and `@githits/mcp` must not contain `@githits/core-internal`, `workspace:*`, `@githits/mcp/internal`, or private source aliases in JS, declarations, or manifests. The public-package validator also rejects static `fs`, `node:fs`, `fs/promises`, and `node:fs/promises` imports in core source and packed MCP artifacts, and rejects direct core `process.stderr`/`process.stdout` access. These checks cover statically resolved string-literal module edges; they do not claim browser compatibility.

## Release Boundaries

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"githits": none
"@githits/mcp": patch
---

- **Remove client telemetry lifecycle globals** - The pre-1.0 `@githits/mcp/client` telemetry lifecycle exports are removed; remote hosts inject `ServiceDiagnostics` when they need operation or debug diagnostics.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"githits": patch
"@githits/mcp": none
---

- **Clarify packaged ownership guidance** - Agent guidance now assigns diagnostics lifecycle and output destinations to the CLI host while core and MCP remain host-neutral; MCP error classifiers no longer emit CLI debug lines, while core service diagnostics can still emit when the CLI container injects them.
20 changes: 16 additions & 4 deletions docs/implementation/workspace-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ manifest move is complete.
## Current Layout

- `packages/core-internal` is private and source-exported. It owns the
transport-neutral API clients, shared request/header/telemetry primitives,
neutral service errors, PKCE helpers, and `TokenProvider` contract.
transport-neutral API clients, shared request/header primitives, the
host-supplied `ServiceDiagnostics` contract, neutral service errors, PKCE
helpers, and `TokenProvider` contract. It does not own diagnostics environment
discovery, process lifecycle, or output destinations.
- `packages/mcp` is the public `@githits/mcp` package boundary. Its public root
export is intentionally small: transport-neutral MCP server factory, tool
registration, static tool descriptors, instructions, and MCP-facing types. It
Expand Down Expand Up @@ -38,8 +40,11 @@ manifest move is complete.
`@githits/mcp/smoke-test`, and `@githits/mcp/package.json`.
- `@githits/mcp/client` is the public runtime/client entry for remote MCP server
composition. It re-exports bundled service implementations, token/header
helpers, URL/config helpers, telemetry helpers, and registry helpers without
publishing `@githits/core-internal`.
helpers, URL/config helpers, the injectable `ServiceDiagnostics` type, and
registry helpers without publishing `@githits/core-internal`. Clients are
silent by default; hosts own diagnostics implementations and destinations.
The removed module-global telemetry lifecycle helpers are not part of this
entry.
- `@githits/mcp/smoke-test` is the public validation-helper entry for remote MCP
servers. It re-exports the shared smoke runner and assertions used by the
local CLI smoke script without requiring local stdio startup.
Expand Down Expand Up @@ -112,6 +117,13 @@ manifest move is complete.
workspace imports, `workspace:*`, and internal aliases.
- Keep artifact scans strict for code, declaration files, and manifests. README
or docs may mention internal paths only as approved boundary warnings.
- The public-package validator separately scans non-test core TypeScript source
for static filesystem imports and direct `process.stderr`/`process.stdout`
access, then scans built and packed MCP code for static filesystem imports.
It also bundles the packed MCP root, client, and smoke-test entries with a
Node target and inspects each resolved import graph. This is a static
string-literal/import-graph guardrail, not a browser-compatibility claim and
not a ban on the root CLI's host-only filesystem code.
- The MCP package build settings live in `packages/mcp/bunup.config.ts`. Its
runtime externals are the MCP SDK and Zod; `@githits/core-internal` is resolved
and bundled into JS/declaration output so the packed public package does not
Expand Down
106 changes: 106 additions & 0 deletions docs/plans/core-mcp-host-runtime-boundary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Plan: Phase 2 browser/WebMCP boundary

## Status

Phase 1 is complete. Core service clients now accept optional host-supplied
`ServiceDiagnostics`; core and MCP have no diagnostics output implementation;
the CLI owns telemetry/debug lifecycle; MCP error mapping is pure; and public
MCP artifacts are checked for the removed filesystem edge. The implementation
was verified with targeted service, mapper, CLI, container, MCP, and typecheck
suites.

This document is now only the forward-looking Phase 2 plan. It intentionally
does not claim browser or WebMCP compatibility.

## Objective

Build a real browser-target WebMCP proof of concept from the smallest useful
GitHits descriptor, schema, handler, and HTTP-client surface. Keep Node-only
CLI and remote-server conveniences behind explicit host entrypoints or
injected values. Choose the public browser export boundary from the observed
dependency graph rather than from source assumptions.

## Verified remaining blockers

Filesystem access has been removed from core and packed MCP artifacts, but the
remaining direct host assumptions still require investigation:

- `node:crypto` in core PKCE helpers for CLI verifier, state, and challenge
generation.
- `node:crypto`, `process`, and `Buffer` in core request headers for session
hashing/fallback, agent detection, and byte limits.
- `process.env` in core config helpers for Node/CLI URL and token defaults.
- `node:async_hooks` in MCP error options for request-local auth remediation
text.
- `process.stdout`, `process.env`, and `Buffer` in MCP text formatting for
terminal width/color defaults and UTF-8 byte limits.
- The MCP SDK package advertises a Node engine and has Node-specific
subpaths/dependencies; importing its Node server path does not establish
browser safety.

These are verified inventory findings, not a compatibility claim. The Phase 2
PoC must re-check the resolved graph because dependency versions and imports
can change.

## Verified remaining ownership issue

Core recovery prose still names CLI commands and environment variables. This
includes the schema-mismatch examples `githits update-check` and
`GITHITS_DEBUG`, plus the terms-acceptance helper at
`packages/core-internal/src/shared/terms-acceptance.ts:19`, which names
`githits settings terms accept`. The root correction is to move host-specific
remediation to host mapping. Phase 1 did not change this runtime prose; Phase
2 should address it at that host boundary.

## Open decisions

- Should browser support use a new public subpath, or should an existing public
entry become browser-safe?
- Which MCP SDK modules, if any, belong in the browser entry after a real
browser-target dependency trace?
- Should remote Node convenience helpers remain in `@githits/mcp/client`, or
move to an explicit Node-specific entry?
- Which descriptors/handlers are in the first WebMCP PoC, and what browser
bundler/target is the compatibility gate?

## Rolling-wave implementation

1. Build a minimal browser-target probe from the exact descriptors, schemas,
handlers, and concrete HTTP clients the WebMCP adapter will import. Record
every remaining GitHits and third-party Node edge in the probe output.
2. Move CLI-only PKCE generation out of core or behind a host-provided crypto
implementation, preserving the CLI behavior.
3. Split request-header formatting from Node terminal/session discovery; inject
precomputed session identity and use web-standard byte counting where
needed.
4. Split pure URL validation/default constants from `process.env` config
resolution and make browser configuration explicit.
5. Replace MCP `AsyncLocalStorage` auth-action propagation with explicit
request-handler closure/context threading if the selected browser surface
reaches it.
6. Make terminal color/width defaults explicit at the formatter host boundary;
browser handlers must not infer terminal output settings.
7. Trace the selected MCP SDK imports in the browser target and isolate Node
server transport code from descriptor/handler reuse.
8. Decide the public browser export only from the completed dependency trace,
then add a browser build/import test with no Node polyfills.

## Acceptance criteria

- The chosen browser entry builds for the recorded browser target with no Node
built-ins or Node polyfills in its resolved graph.
- A browser-target test imports the chosen descriptor/handler surface and
executes one representative tool call against mocked `fetch`.
- Node CLI and remote MCP entrypoints retain their current behavior and remain
separately validated.
- The public export decision and every intentionally retained host boundary are
documented with the probe evidence.

## Constraints

- Do not infer WebMCP support from a Node-target bundle or from package
dependency declarations alone.
- Do not remove Node assumptions globally before the PoC identifies the exact
browser import set.
- Do not add a general runtime abstraction, logger bridge, polyfill bundle, or
compatibility claim without a verified need from the browser probe.
3 changes: 1 addition & 2 deletions packages/core-internal/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ export * from "./services/package-intelligence-service.js";
export * from "./services/promote-version-not-found.js";
export * from "./services/refreshing-githits-service.js";
export * from "./services/resolve-target-service.js";
export * from "./services/runtime-diagnostics.js";
export * from "./services/token-provider.js";
export * from "./shared/debug-log.js";
export * from "./shared/fetch-timeout.js";
export * from "./shared/http-error-detail.js";
export * from "./shared/pkgseer-graphql.js";
export * from "./shared/pkgseer-registry.js";
export * from "./shared/request-headers.js";
export * from "./shared/telemetry.js";
Loading