Repository navigation
feat(instructions)!: generate targets from instructions files - #37
Merged
Merged
Conversation
Instruction files carry front matter with a required description and optional paths, may sit in subdirectories, and are named by their container-relative path. A project's own files in .agent/instructions are read from the working tree and selected by bare name. Targets are generated in full from the selected sections: a notice line followed by the bodies as written. Sections with paths are scoped by a line after their first heading and, in project scope, written to the AGENTS.md of the directory their patterns share. Managed blocks, title detection, heading offsets and adoption are removed; writing over a file agents did not generate requires replace. Local links must resolve in the checkout being written. Doctor reports hand-written targets, changed own files and broken links, and its Codex size check now budgets only the project chain. Export maps locked targets to their sections.
- Doctor reports any difference from a locked target as drift; the lock owns the file whether or not the notice line remains. - Restoring a lock stops with InstructionError.ownChanged when a project's own instructions file changed since the lock. - initializeInstructions(named:environment:) creates .agent/instructions/<name>.md under the project's state lock instead of writing into an arbitrary directory with its own lock.
- A file is owned when it is blank or starts with the notice; a lock entry alone no longer is, so a 0.1.2 target with custom content needs replace, and install, remove and doctor treat it as foreign. - Install restores the locked targets and Claude import files instead of recomputing forwarding. - Nested target directories cannot be symbolic links, .git, or inside another repository; local links resolve symbolic links before '..'. - Own instructions are read by name for resolution and restore; a symbolic link at or below a search path is an error; discovery skips AGENTS.md and GEMINI.md. - Removing a name equal to a declared reference removes that reference. - Doctor covers own files used only by prompts, checks root forwarding only for a root Claude target, and reports Claude files that hide a nested AGENTS.md. - Export places user sections without their content. - A declaration may omit sources, and an unchanged declaration is not rewritten.
- Adding named own files reads only those files. - Install leaves a deleted locked Claude import file deleted. - Watch skips AGENTS.md and GEMINI.md in containers, as discovery does. - State which containers cannot hold targets, and keep a retired target that differs from its lock without writing over it.
Declare this repository's guide with the agents-tools shared package route and test isolation units, and track the declaration and lock.
A committed link to an uncommitted file made materialization reject the whole source, because Foundation resolves dangling links inconsistently. Links are now checked with the kernel's resolution and lexical targets: one that leaves the tree or resolves outside it is rejected, a dangling one inside is kept. Copied subtrees use the same rule.
Lexical normalization treated 'here/..' as a no-op even when 'here' is a link, so a dangling link such as 'here/here/../../settings.json' in a skill passed validation and, once copied, read a file above the installed skill. Links are now resolved component by component from their directory, following links inside the root: a step above the root, an absolute destination or a loop is rejected, and reaching a missing entry, which the tree lacks wherever it is placed, is safe.
…arents Splitting a destination into Swift characters let a prepended Unicode mark join a following slash, hiding a separator from validation. Components are now split and compared as UTF-8 bytes. A missing entry ends resolution only when no '..' follows it, because a filesystem that looks names up by case or normalization can resolve that entry to another one in the same directory.
agents.json and agents.resolved were written in Foundation's layout,
which `prettier --check` rejects. They now use Prettier's default layout:
two-space indentation, "key": value, expanded objects, {} and [] for
empty containers, and arrays on one line when they fit in 80 columns.
Any operation that writes state rewrites a file in another layout even
when its content is unchanged. Empty lock sections stay because skill
0.3.1 requires them; journals, watch state and content hashes keep the
encoder's fixed bytes. This repository's own state is rewritten.
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.
Summary
Instruction targets are now generated in full from instructions files, replacing the managed block that was spliced into hand-written files.
description, optionalpathsglobs) and a body that starts with one heading at any level; every other heading is deeper.instructions/or.agents/instructions/, including subdirectories; a file's name is its container-relative path. A project's own files in.agent/instructions/are selected by bare name, read from the working tree and locked by hash.pathsgets an "Applies when working on files matching …" line and, in project scope, goes to theAGENTS.mdorGEMINI.mdof the directory its patterns share.replace. Local links must resolve to a file in the checkout being written.InstructionOperations.export(projectRoots:environment:)maps locked targets to their sections without writing.AGENTS.md.initializeInstructions(named:environment:)creates.agent/instructions/<name>.md.sources, and operations rewriteagents.jsononly when its content changes.Breaking changes are listed under Unreleased in
CHANGELOG.md. The version bump is left to release preparation.Validation
swift build: passenv -u CODEX_HOME -u CLAUDE_CONFIG_DIR -u XDG_CONFIG_HOME -u XDG_STATE_HOME -u XDG_CACHE_HOME swift test: 366 tests passswift build -c release: passswift format lint --strict --configuration .swift-format --recursive Package.swift Sources Tests: cleanAGENTS.mdgenerated from its own and organization-shared files matches the expected content and keeps the committed declaration's bytes;skill0.3.1 still reads and writes the resulting user state.Documentation
Documentation/Proposals/AgentInstructions.md,Documentation/Architecture/Instructions.md,State.md,Package.md,Watch.md,README.mdandCHANGELOG.mddescribe the new behavior.Consumer: agents-tools/cli#30 builds on this branch.