agentfold 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +197 -0
- package/agentfold.mjs +1115 -0
- package/lib/compose-layers.mjs +23 -0
- package/lib/diff.mjs +47 -0
- package/lib/load-profile.mjs +112 -0
- package/lib/manifest.mjs +66 -0
- package/lib/pipeline-steps.mjs +853 -0
- package/lib/scope.mjs +158 -0
- package/lib/util.mjs +348 -0
- package/lib/validate.mjs +209 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Francisco Hernandez
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# AgentFold
|
|
2
|
+
|
|
3
|
+
Layered generator for AI agent configuration. Define guidance once, compose by profile, and output deterministic config files for Copilot, Codex, Cursor, and Claude Code.
|
|
4
|
+
|
|
5
|
+
## Quickstart
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Initialise config hub (defaults to ~/.agentfold)
|
|
9
|
+
npx agentfold init --targets codex,copilot
|
|
10
|
+
|
|
11
|
+
# Apply to a project
|
|
12
|
+
cd ~/code/my-project
|
|
13
|
+
npx agentfold apply
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
This creates a config hub at `~/.agentfold` with a default profile and global layer, then renders target-specific files into the current project.
|
|
17
|
+
|
|
18
|
+
## Architecture
|
|
19
|
+
|
|
20
|
+
AgentFold is a **central configuration hub**. You author all layers, profiles, and tags in one place (`~/.agentfold` or `--config <path>`), then selectively apply generated output to any number of target projects.
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
~/.agentfold/ (config hub — one per user)
|
|
24
|
+
config/
|
|
25
|
+
profiles/ (profile definitions)
|
|
26
|
+
definitions/ (scope tags)
|
|
27
|
+
layers/
|
|
28
|
+
global/ (shared baseline)
|
|
29
|
+
team-x/ (team-specific content)
|
|
30
|
+
...
|
|
31
|
+
|
|
32
|
+
~/code/my-project/ (target project — receives output)
|
|
33
|
+
.github/ (Copilot output)
|
|
34
|
+
.codex/ (Codex output)
|
|
35
|
+
.agentfold/
|
|
36
|
+
manifest.json (tracks managed files)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Commands
|
|
40
|
+
|
|
41
|
+
| Command | Description |
|
|
42
|
+
|---------|-------------|
|
|
43
|
+
| `init` | Bootstrap config hub (default: `~/.agentfold`) |
|
|
44
|
+
| `lint` | Validate profile and layers |
|
|
45
|
+
| `build` | Render outputs to `<config>/out/` |
|
|
46
|
+
| `diff` | Compare rendered vs project files |
|
|
47
|
+
| `apply` | Write rendered files to project |
|
|
48
|
+
| `status` | Show current config summary |
|
|
49
|
+
| `doctor` | Health-check config hub and project |
|
|
50
|
+
| `explain` | Trace why a content file is included/excluded |
|
|
51
|
+
| `create-layer` | Scaffold a new layer directory |
|
|
52
|
+
| `create-profile` | Create a new profile JSON |
|
|
53
|
+
| `list-layers` | List available layers |
|
|
54
|
+
| `list-profiles` | List available profiles |
|
|
55
|
+
| `list-tags` | List allowed scope tags |
|
|
56
|
+
| `add-tag` | Add a scope tag |
|
|
57
|
+
| `delete-tag` | Remove a scope tag |
|
|
58
|
+
| `add-rule` | Add a rule file to a layer |
|
|
59
|
+
| `add-skill` | Add a skill directory to a layer |
|
|
60
|
+
| `add-subagent` | Add a subagent file to a layer |
|
|
61
|
+
| `add-command` | Add a command file to a layer |
|
|
62
|
+
| `add-reference` | Add a reference file to a layer |
|
|
63
|
+
|
|
64
|
+
Run `agentfold --help` for full flag reference.
|
|
65
|
+
|
|
66
|
+
## How It Works
|
|
67
|
+
|
|
68
|
+
1. **Layers** contain your canonical content: rules, skills, subagents, commands, references, MCP configs.
|
|
69
|
+
2. **Profiles** define which layers to compose and which targets to generate (copilot, codex, cursor, claude).
|
|
70
|
+
3. **Scope selectors** (tags + namespaces) on profiles filter content via frontmatter metadata.
|
|
71
|
+
4. The **render pipeline** merges selected content by layer order and writes deterministic output files.
|
|
72
|
+
|
|
73
|
+
### Layer Structure
|
|
74
|
+
|
|
75
|
+
Each layer has 7 canonical folders:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
layers/<name>/
|
|
79
|
+
agents/
|
|
80
|
+
commands/
|
|
81
|
+
mcp/
|
|
82
|
+
references/
|
|
83
|
+
rules/
|
|
84
|
+
skills/
|
|
85
|
+
subagents/
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Resolution
|
|
89
|
+
|
|
90
|
+
All layers, profiles, and tags resolve from the **config hub** (`--config` or `~/.agentfold`):
|
|
91
|
+
|
|
92
|
+
| Resource | Path |
|
|
93
|
+
|----------|------|
|
|
94
|
+
| Layers | `<config>/layers/<name>/` |
|
|
95
|
+
| Profiles | `<config>/config/profiles/<name>.json` |
|
|
96
|
+
| Tags | `<config>/config/definitions/scope-tags.json` |
|
|
97
|
+
|
|
98
|
+
### Scope Filtering
|
|
99
|
+
|
|
100
|
+
Content files use YAML frontmatter for scope metadata:
|
|
101
|
+
|
|
102
|
+
```yaml
|
|
103
|
+
---
|
|
104
|
+
metadata:
|
|
105
|
+
scope:
|
|
106
|
+
namespace: team-name
|
|
107
|
+
tags:
|
|
108
|
+
- frontend
|
|
109
|
+
- testing
|
|
110
|
+
---
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Profile selectors filter by tags (`any`/`all` mode) and namespaces. Empty selectors include everything.
|
|
114
|
+
|
|
115
|
+
## Typical Workflow
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# 1. Bootstrap config hub
|
|
119
|
+
agentfold init --targets codex,copilot
|
|
120
|
+
|
|
121
|
+
# 2. Create a team layer and profile
|
|
122
|
+
agentfold create-layer --name my-team
|
|
123
|
+
agentfold create-profile --name dev --layers my-team --targets codex,copilot
|
|
124
|
+
|
|
125
|
+
# 3. Add content to the layer via CLI
|
|
126
|
+
agentfold add-rule --layer my-team --name code-review
|
|
127
|
+
agentfold add-skill --layer my-team --name api-patterns
|
|
128
|
+
agentfold add-subagent --layer my-team --name test-writer
|
|
129
|
+
agentfold add-command --layer my-team --name run-checks
|
|
130
|
+
|
|
131
|
+
# 4. Open the config hub to edit the generated boilerplate
|
|
132
|
+
code ~/.agentfold # VS Code
|
|
133
|
+
cursor ~/.agentfold # Cursor
|
|
134
|
+
|
|
135
|
+
# 5. Apply to a project
|
|
136
|
+
agentfold lint --profile dev --project ~/code/app
|
|
137
|
+
agentfold apply --profile dev --project ~/code/app --prune
|
|
138
|
+
|
|
139
|
+
# 6. Check status
|
|
140
|
+
agentfold status --profile dev --project ~/code/app
|
|
141
|
+
agentfold doctor --profile dev --project ~/code/app
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Or specify a custom config hub:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
agentfold init --config ~/my-config --targets codex
|
|
148
|
+
agentfold apply --config ~/my-config --profile dev --project ~/code/app
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Editing the Config Hub
|
|
152
|
+
|
|
153
|
+
To add or edit layers, rules, skills, and other content, open the config hub in your editor:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Navigate to the default hub
|
|
157
|
+
cd ~/.agentfold
|
|
158
|
+
|
|
159
|
+
# Open in VS Code
|
|
160
|
+
code ~/.agentfold
|
|
161
|
+
|
|
162
|
+
# Open in Cursor
|
|
163
|
+
cursor ~/.agentfold
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
From there you can edit files directly under `layers/`, create new profiles in `config/profiles/`, and manage tags in `config/definitions/`. Changes take effect the next time you run `agentfold apply`.
|
|
167
|
+
|
|
168
|
+
## Generated Outputs
|
|
169
|
+
|
|
170
|
+
| Target | Output |
|
|
171
|
+
|--------|--------|
|
|
172
|
+
| Copilot | `.github/instructions/`, `.github/prompts/`, `.github/agents/`, `.vscode/mcp.json` |
|
|
173
|
+
| Codex | `.codex/AGENTS.md`, `.codex/config.toml` |
|
|
174
|
+
| Cursor | `.cursor/rules/`, `.cursor/agents/`, `.cursor/mcp.json` |
|
|
175
|
+
| Claude | `.claude/AGENTS.md`, `.claude/agents/` |
|
|
176
|
+
| Portable | `.agents/skills/`, `.agents/subagents/`, `.agents/commands/`, `.agents/references/` |
|
|
177
|
+
|
|
178
|
+
## Behavior Contracts
|
|
179
|
+
|
|
180
|
+
- Layer order from `profile.layers` is authoritative.
|
|
181
|
+
- Destination collisions fail fast with clear errors.
|
|
182
|
+
- Deletions are manifest-scoped only (`.agentfold/manifest.json`).
|
|
183
|
+
- Output ordering is deterministic (sorted traversal + hashing).
|
|
184
|
+
- MCP configs are deep-merged per target from `layers/*/mcp/*.json`.
|
|
185
|
+
- References are demand-driven: only files referenced in rendered content are included.
|
|
186
|
+
|
|
187
|
+
## Development
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
npm test # Run full test suite
|
|
191
|
+
npm run lint # Validate current profile
|
|
192
|
+
npm run sync # Lint + build + apply --prune
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## License
|
|
196
|
+
|
|
197
|
+
MIT
|