# @shadowclone/environment

Holds what agents receive: the environment record, skill publication, native instruction sections, hooks, install, and undo.

<!-- package-facts:start -->

(generated by `bun run guides`; do not edit by hand)

- Package name: `@shadowclone/environment`
- Workspace dependencies: `@shadowclone/agents`, `@shadowclone/changes`, `@shadowclone/core`, `@shadowclone/profile`, `@shadowclone/redact`, `@shadowclone/sessions`, `@shadowclone/skills`
- External dependencies: `zod`
- Export subpaths: `.`, `./testing`, `./browser`

<!-- package-facts:end -->

## Owns

- `src/environment/`: the store (`readEnvironment`, `writeEnvironment`), `publishEnvironmentRevision`, `undoRevision`, `syncLearningEnvironment`, and `environmentStatus`.
- `src/environment/builds/` and `harness/`: build definitions, routing text, and the harness manifest.
- `src/integrations/`: native sections, hooks, `installIntegration`, `uninstallIntegration`, and `compileContext`.
- `src/integrations/installation/`: the install record and artifact ownership checks.
- `src/environment/learningNotice.ts` and `repositoryQuestion.ts`: the one-time triage notice and the repository destination question in session-start context.

## Rules

- Every write goes through `publishEnvironmentRevision`. A path outside the authorized destinations is an error.
- `undoRevision` takes the write lock. It refuses an unauthorized root and a revision that conflicts with later edits.
- Native routing text is at most 4096 bytes. A longer text is an error, and the old section stays.
- Shadowclone rewrites only the text between the `<shadowclone-guidance>` markers. Malformed markers are an error.
- Shadowclone replaces an installed file only when its fingerprint matches the install record. A manual edit stays.
- Migration copies the original skills and native instructions to `environment-baselines/` before it publishes.
- A repository with `privateSkillsDirectory` publishes skills only under `~/.shadowclone/builds/`. Its routing names each skill by its file path, and no repository file changes.

## Tests

Run `bun test` in this folder, or `bun test packages/environment` from the root. The `./testing` export gives `learningRecord` and `skillFixture`. Several tests run `git` on temporary repositories.

Update this file in the same commit when you change the package purpose, public exports, dependencies, or a rule above.
