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
5 changes: 5 additions & 0 deletions .changeset/clean-scan-boundary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@anarchitecture/ghost": major
---

Restore scan to readiness and source-signal APIs, move fingerprint package operations to the fingerprint export, remove context-bundle emission, and add Relay gather for agent context.
7 changes: 4 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,17 @@ fingerprint input for new Ghost work.
| `ghost ack` | Record stance toward the tracked fingerprint in `.ghost-sync.json`. |
| `ghost track` | Shift the tracked fingerprint. |
| `ghost diverge` | Declare intentional divergence on a dimension. |
| `ghost emit <kind>` | Emit `review-command` or the `context-bundle` generation packet. |
| `ghost emit <kind>` | Emit `review-command`. |
| `ghost skill install` | Install the unified `ghost` agentskills.io bundle. |

`ghost scan --format json` is deterministic handoff state for the host agent.
`ghost scan --format json` is deterministic readiness and source-signal state.
It does not run an LLM.

## Public Exports

- `@anarchitecture/ghost` for the combined surface.
- `@anarchitecture/ghost/scan` for scan and bundle helpers.
- `@anarchitecture/ghost/scan` for scan readiness, source signals, and stack discovery.
- `@anarchitecture/ghost/fingerprint` for fingerprint package authoring, linting, verification, parsing, and serialization.
- `@anarchitecture/ghost/drift` for check/review/compare/stance helpers.
- `@anarchitecture/ghost/core` for shared schemas, types, and loaders.
- `@anarchitecture/ghost/cli` for `buildCli()`.
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ truth.

## Generate From Ghost

Before generating or revising UI, emit the context bundle:
Before generating or revising UI, gather the Relay brief for the target path:

```bash
ghost emit context-bundle
ghost relay gather apps/checkout/review/page.tsx
```

The bundle gives a host agent the selected prose, inventory, composition,
optional memory, and active checks. The important shift is timing: Ghost gives
agents surface-composition context before they build, not only after a review
finds drift.
Relay gives a host agent the selected prose, inventory, composition, optional
memory, active checks, suggested reads, and provenance. The important shift is
timing: Ghost gives agents surface-composition context before they build, not
only after a review finds drift.

After implementation, run the deterministic and advisory workflows against the
same fingerprint:
Expand Down Expand Up @@ -162,7 +162,8 @@ useful layer content. It does not call an LLM.
| `ghost verify` | Validate evidence paths, exemplar paths, typed check refs, and optional rationale files. |
| `ghost check` | Run active deterministic gates against a diff. |
| `ghost review` | Emit an evidence-routed advisory packet from fingerprint layers and a diff. |
| `ghost emit <kind>` | Emit `review-command` or `context-bundle` artifacts. |
| `ghost relay gather` | Gather fingerprint-grounded context for an agent target. |
| `ghost emit <kind>` | Emit `review-command` artifacts. |
| `ghost skill install` | Install the unified Ghost skill bundle. |
| `ghost stack` | Inspect resolved root-to-leaf fingerprint stacks. |
| `ghost inventory` | Emit raw repo signals as JSON for optional cache material. |
Expand Down
15 changes: 11 additions & 4 deletions apps/docs/src/content/docs/cli-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,21 @@ ghost verify .ghost --root .
ghost verify --all --memory-dir .design/memory
```

### Generate handoff packets - `emit`
### Reusable Review Command - `emit`

Emit `review-command` or the `context-bundle` compact entrypoint from split
fingerprint layers. Use `context-bundle` before generation and
`review-command` when a host wants a reusable review prompt.
Emit `review-command` from split fingerprint layers when a host wants a
reusable review prompt.

<CliHelp tool="ghost" command="emit" hideDescription />

### Agent Context - `relay gather`

Gather a compact Relay brief from the resolved fingerprint stack for a target
path. Use this before generation so the host agent starts with selected refs,
suggested reads, active checks, and provenance.

<CliHelp tool="ghost" command="relay" hideDescription />

### Inspection - `describe`

Print optional `.ghost/fingerprint/memory/intent.md` or a markdown section map.
Expand Down
12 changes: 6 additions & 6 deletions apps/docs/src/content/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ approval. For a fuller human-agent workflow, read

</DocSection>

<DocSection title="Generate From Ghost">
<DocSection title="Brief From Ghost">

Before generating or revising UI, emit the upstream compact entrypoint:
Before generating or revising UI, gather a Relay brief for the target path:

```bash
ghost emit context-bundle
ghost relay gather apps/checkout/review/page.tsx
```

Give the generated bundle to Codex, Claude, Cursor, Goose, or another host
agent so the work starts from the approved product fingerprint rather than from
post-hoc review feedback alone.
Relay points the host agent at selected fingerprint refs, suggested reads,
active checks, and provenance. The package remains the approved product-surface
context; review and check commands apply it after implementation.

</DocSection>

Expand Down
78 changes: 49 additions & 29 deletions apps/docs/src/generated/cli-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"generatedAt": "2026-06-10T17:47:36.455Z",
"generatedAt": "2026-06-12T19:26:14.540Z",
"tools": [
{
"tool": "ghost",
Expand Down Expand Up @@ -315,11 +315,11 @@
"tool": "ghost",
"name": "emit",
"rawName": "emit <kind>",
"description": "Emit a derived artifact from the fingerprint package (review command or compact context entrypoint)",
"description": "Emit a derived artifact from the fingerprint package (review-command).",
"group": "core",
"defaultHelp": true,
"compactName": "emit",
"summary": "Emit review-command or context-bundle artifacts.",
"summary": "Emit review-command artifacts.",
"options": [
{
"rawName": "--path <path>",
Expand Down Expand Up @@ -348,42 +348,18 @@
{
"rawName": "-o, --out <path>",
"name": "out",
"description": "Output path (review-command → .claude/commands/design-review.md; context-bundle → ghost-context/)",
"description": "Output path (review-command → .claude/commands/design-review.md)",
"default": null,
"takesValue": true,
"negated": false
},
{
"rawName": "--stdout",
"name": "stdout",
"description": "Write to stdout instead of a file (review-command only)",
"description": "Write to stdout instead of a file",
"default": null,
"takesValue": false,
"negated": false
},
{
"rawName": "--readme",
"name": "readme",
"description": "Include README.md (context-bundle)",
"default": null,
"takesValue": false,
"negated": false
},
{
"rawName": "--prompt-only",
"name": "promptOnly",
"description": "Emit only prompt.md (context-bundle compact entrypoint)",
"default": null,
"takesValue": false,
"negated": false
},
{
"rawName": "--name <name>",
"name": "name",
"description": "Override the skill name (default: prose.yml product or first scope) (context-bundle)",
"default": null,
"takesValue": true,
"negated": false
}
]
},
Expand Down Expand Up @@ -571,6 +547,50 @@
}
]
},
{
"tool": "ghost",
"name": "relay",
"rawName": "relay <action> [target]",
"description": "Gather fingerprint-grounded context for an agent target.",
"group": "core",
"defaultHelp": true,
"compactName": "relay gather",
"summary": "Gather fingerprint context for an agent target.",
"options": [
{
"rawName": "--package <dir>",
"name": "package",
"description": "Use exactly this fingerprint package directory instead of resolving a stack",
"default": null,
"takesValue": true,
"negated": false
},
{
"rawName": "--memory-dir <relative-dir>",
"name": "memoryDir",
"description": "Relative fingerprint package directory for stack resolution (default: .ghost)",
"default": null,
"takesValue": true,
"negated": false
},
{
"rawName": "--name <name>",
"name": "name",
"description": "Override the gathered context name (default: prose.yml product or resolved scope)",
"default": null,
"takesValue": true,
"negated": false
},
{
"rawName": "--format <fmt>",
"name": "format",
"description": "Output format: markdown or json",
"default": "markdown",
"takesValue": true,
"negated": false
}
]
},
{
"tool": "ghost",
"name": "skill",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"node": "^20.19.0 || >=22.12.0"
},
"scripts": {
"build": "tsc --build",
"build": "tsc --build --force",
"clean": "tsc --build --clean",
"test": "vitest run",
"test:watch": "vitest",
Expand Down
14 changes: 10 additions & 4 deletions packages/ghost/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,15 @@ ghost lint .ghost
ghost verify .ghost --root .
```

Emit the pre-generation packet and govern changes afterward:
Gather context before generation:

```bash
ghost relay gather apps/checkout/review/page.tsx
```

Govern changes afterward:

```bash
ghost emit context-bundle
ghost check --base main
ghost review --base main --include-memory
```
Expand All @@ -70,6 +75,7 @@ host opts in.
```ts
import { compare } from "@anarchitecture/ghost/compare";
import { runGhostCheck } from "@anarchitecture/ghost/govern";
import { gatherRelayContext } from "@anarchitecture/ghost/relay";
import {
initFingerprintPackage,
lintFingerprintPackage,
Expand All @@ -80,8 +86,8 @@ import {
## BYOA

Ghost is bring-your-own-agent. The CLI performs deterministic work: inventory,
readiness reporting, linting, verification, comparison, checks, and handoff
packet generation. The installed `ghost` skill teaches a host agent how to
readiness reporting, linting, verification, comparison, checks, and advisory
review packet generation. The installed `ghost` skill teaches a host agent how to
capture canonical `.ghost/fingerprint/` surface-composition context, brief and
generate work from it, review changes against it, verify generated UI,
remediate issues, and suggest fingerprint edits when the user asks.
Expand Down
4 changes: 4 additions & 0 deletions packages/ghost/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
"types": "./dist/compare.d.ts",
"import": "./dist/compare.js"
},
"./relay": {
"types": "./dist/relay.d.ts",
"import": "./dist/relay.js"
},
"./drift": {
"types": "./dist/core/index.d.ts",
"import": "./dist/core/index.js"
Expand Down
8 changes: 5 additions & 3 deletions packages/ghost/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ import {
registerDivergeCommand,
registerTrackCommand,
} from "./evolution-commands.js";
import { formatSemanticDiff } from "./fingerprint.js";
import { registerFingerprintCommands } from "./fingerprint-commands.js";
import { registerRelayCommand } from "./relay.js";
import {
buildReviewPacket,
formatReviewPacketMarkdown,
} from "./review-packet.js";
import { formatSemanticDiff } from "./scan/index.js";
import { registerScanCommands } from "./scan-commands.js";
import { registerSkillCommand } from "./skill-command.js";

const execFileAsync = promisify(execFile);
Expand All @@ -41,7 +42,7 @@ export { getCommandDiscoveryMetadata } from "./command-discovery.js";
export function buildCli(): ReturnType<typeof cac> {
const cli = cac("ghost");

registerScanCommands(cli);
registerFingerprintCommands(cli);

// --- compare ---
cli
Expand Down Expand Up @@ -152,6 +153,7 @@ export function buildCli(): ReturnType<typeof cac> {
registerAckCommand(cli);
registerTrackCommand(cli);
registerDivergeCommand(cli);
registerRelayCommand(cli);
registerSkillCommand(cli);

// --- check ---
Expand Down
9 changes: 8 additions & 1 deletion packages/ghost/src/command-discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,19 @@ const COMMAND_DISCOVERY = [
compactName: "review",
summary: "Emit an advisory packet from fingerprint layers and a diff.",
},
{
name: "relay",
group: "core",
defaultHelp: true,
compactName: "relay gather",
summary: "Gather fingerprint context for an agent target.",
},
{
name: "emit",
group: "core",
defaultHelp: true,
compactName: "emit",
summary: "Emit review-command or context-bundle artifacts.",
summary: "Emit review-command artifacts.",
},
{
name: "skill",
Expand Down
2 changes: 1 addition & 1 deletion packages/ghost/src/comparable-fingerprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type GhostPatternsDocument,
type Survey,
} from "#ghost-core";
import { loadFingerprint, resolveFingerprintPackage } from "#scan";
import { loadFingerprint, resolveFingerprintPackage } from "./fingerprint.js";

export async function loadComparableFingerprint(
path: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import {
type FingerprintPackagePaths,
loadFingerprintPackage,
} from "../fingerprint-package.js";
} from "../scan/fingerprint-package.js";

export interface PackageInventorySummary {
root?: string;
Expand Down
8 changes: 5 additions & 3 deletions packages/ghost/src/core/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import {
routeGhostChecksForPath,
} from "#ghost-core";
import {
groupFingerprintStacksForPaths,
loadFingerprintPackage,
mapFromFingerprint,
resolveFingerprintPackage,
} from "../scan/index.js";
} from "../scan/fingerprint-package.js";
import {
groupFingerprintStacksForPaths,
mapFromFingerprint,
} from "../scan/fingerprint-stack.js";
import {
INLINE_COLOR_LITERAL_PATTERN,
isInlineColorDetector,
Expand Down
4 changes: 2 additions & 2 deletions packages/ghost/src/core/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type {
TemporalComparison,
} from "#ghost-core";
import { compareFingerprints } from "#ghost-core";
import type { SemanticDiff } from "#scan";
import { diffFingerprints } from "#scan";
import type { SemanticDiff } from "../scan/diff.js";
import { diffFingerprints } from "../scan/diff.js";
import { compareComposite } from "./evolution/composite.js";
import { computeTemporalComparison } from "./evolution/temporal.js";

Expand Down
5 changes: 4 additions & 1 deletion packages/ghost/src/core/evolution/emit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { mkdir, writeFile } from "node:fs/promises";
import type { Fingerprint } from "#ghost-core";
import { resolveFingerprintPackage, serializeFingerprint } from "#scan";
import {
resolveFingerprintPackage,
serializeFingerprint,
} from "../../fingerprint.js";

/**
* Write a fingerprint as the publishable design-language prior inside the
Expand Down
Loading
Loading