add embed contract for host integrations#242
Merged
Merged
Conversation
nahiyankhan
marked this pull request as ready for review
July 18, 2026 23:58
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Category: new-feature
User Impact: Applications can embed ghost's package loading, gather, pull, and material inspection behavior without shelling out to the CLI.
Problem: Host integrations currently have to parse CLI presentation output or reimplement package semantics, which risks drift in selection, ordering, material handling, and safety policy.
Solution: Add a model-free
@design-intelligence/ghost/embedcontract and make the CLI consume the same gather and pull primitives. The API exposes immutable snapshots, complete menus, validated pulls, host-policy material inspection, and pure observability event stamping while leaving persistence to the host.Validation:
pnpm check: passedpnpm test: 192 passed, 1 skippedpnpm build: passed@design-intelligence/ghost/embedChangeset: added as a minor release for the new public subpath and host API.
ghost Review:
ghost check --base origin/main: not available in this CLI version; deterministic repository checks passed viapnpm checkghost review --base origin/main --include-memory: not run because the repository has no.ghost/checks/package and this CLI does not support--include-memoryFile changes
.changeset/ghost-embed-contract.md
Records the new public embed capability as a minor release.
packages/ghost/README.md
Documents embed imports, semantics, inspection policy, markup safety, and host-owned observability persistence.
packages/ghost/package.json
Publishes the
@design-intelligence/ghost/embedsubpath.packages/ghost/src/commands/gather-command.ts
Uses the shared embed gather result while preserving CLI formatting and event writes.
packages/ghost/src/commands/pull-command.ts
Uses the shared embed pull result while preserving CLI formatting and event writes.
packages/ghost/src/embed/gather.ts
Builds the complete, unfiltered guidance menu and explicit applicability contract.
packages/ghost/src/embed/index.ts
Defines the public embed exports.
packages/ghost/src/embed/inspect.ts
Adds policy-gated, contained local material inspection with declared-glob support and no network fetching.
packages/ghost/src/embed/pull.ts
Validates requested node ids, preserves steering order, transports materials, and extracts Skeletons.
packages/ghost/src/embed/readonly-map.ts
Provides a mutation-free map view for loaded snapshots.
packages/ghost/src/embed/snapshot.ts
Loads and freezes package, cover, glossary, node, and check state for hosts.
packages/ghost/src/embed/types.ts
Defines the public snapshot, gather, pull, inspection, and policy contracts.
packages/ghost/src/ghost-core/index.ts
Exports the material helpers needed by the embed implementation.
packages/ghost/src/ghost-core/material-transport.ts
Shares MIME and containment helpers, keeps text sniffing backward compatible, and prevents pull from following symlinks outside the repo.
packages/ghost/src/observability-events.ts
Adds a pure event-stamping helper and reusable event input types.
packages/ghost/test/cli.test.ts
Checks semantic parity between CLI JSON and embed gather and pull results.
packages/ghost/test/embed.test.ts
Covers snapshots, menus, pulls, inspection policy, globs, MIME and size limits, UTF-8 handling, containment, text compatibility, and events.
packages/ghost/test/public-exports.test.ts
Verifies the built embed subpath and public functions.
scripts/check-packed-package.mjs
Includes the embed subpath in packed-package import validation.
Screenshots/Demos: N/A