Skip to content

add embed contract for host integrations#242

Merged
nahiyankhan merged 1 commit into
mainfrom
nahiyankhan/embed-contract
Jul 18, 2026
Merged

add embed contract for host integrations#242
nahiyankhan merged 1 commit into
mainfrom
nahiyankhan/embed-contract

Conversation

@nahiyankhan

Copy link
Copy Markdown
Collaborator

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/embed contract 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: passed
  • pnpm test: 192 passed, 1 skipped
  • pnpm build: passed
  • packed-package import check: passed for @design-intelligence/ghost/embed

Changeset: 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 via pnpm check
  • ghost review --base origin/main --include-memory: not run because the repository has no .ghost/checks/ package and this CLI does not support --include-memory
File 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/embed subpath.

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

@nahiyankhan
nahiyankhan marked this pull request as ready for review July 18, 2026 23:58
@nahiyankhan
nahiyankhan merged commit 2579381 into main Jul 18, 2026
5 checks passed
@nahiyankhan
nahiyankhan deleted the nahiyankhan/embed-contract branch July 18, 2026 23:58
@github-actions github-actions Bot mentioned this pull request Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant