@dhzh/foundry 7.0.1 → 7.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.
@@ -1,39 +1,224 @@
1
1
  ---
2
2
  name: foundry
3
- description: Operate the local Foundry workbench through its installed CLI. Use when a task asks to read or change Foundry settings, open its configuration folder, export or import Foundry data, install the Foundry Skill, or start its Web UI.
3
+ description: Operate the local Foundry workbench through its installed CLI. Use when a task asks to create, read, edit, delete, list, assign, enable, disable, or reapply Foundry instructions for ChatGPT or Claude Code, read or change Foundry settings, open its configuration folder, export or import encrypted Foundry data, install or inspect the Foundry Skill, or start its Web UI.
4
4
  ---
5
5
 
6
6
  # Foundry
7
7
 
8
- Use the installed `foundry` CLI to operate the local workbench. If the command is
9
- unavailable, report the missing prerequisite. This Skill documents product usage;
10
- repository development guidance belongs to the project's own documentation.
8
+ Foundry is a local personal workbench distributed as a CLI with a bundled Web
9
+ UI. The CLI is the stable interface for agents: it creates and reads runtime
10
+ data, applies instructions to external agent files, and prints machine-readable
11
+ JSON.
11
12
 
12
- ## Choose a feature
13
+ Use this Skill when the user wants to:
13
14
 
14
- Read the reference for the requested feature before operating it. The table
15
- lists features supported by the current CLI. Use installed command help to check
16
- availability when versions differ.
15
+ - Save, read, edit, delete, or inspect reusable Markdown instructions.
16
+ - Make ChatGPT or Claude Code follow selected instructions.
17
+ - Reorder, enable, disable, or reapply an agent's instruction set.
18
+ - Read or change appearance, language, time zone, or time format.
19
+ - Export or replace Foundry data with an encrypted backup.
20
+ - Open Foundry's data folder or install this Skill for other agents.
21
+ - Start the local Web UI for visual inspection.
17
22
 
18
- | Task | Reference |
19
- | --- | --- |
20
- | Settings: appearance, language and region, configuration folder, encrypted export/import, or Skill installation | [references/settings.md](references/settings.md) |
23
+ If `foundry` is unavailable, report the missing prerequisite instead of editing
24
+ runtime files by hand.
25
+
26
+ ## Feature map
27
+
28
+ Read the linked reference before operating a feature. Each reference contains
29
+ the command details, output shapes, failure modes, and end-to-end examples.
30
+
31
+ | Need | CLI entry point | Reference |
32
+ | --- | --- | --- |
33
+ | Create, read, edit, delete, or list reusable Markdown instructions | `foundry instructions` | [Instructions](references/instructions.md) |
34
+ | Inspect, assign, enable, disable, or reapply instructions for an agent | `foundry agents instructions` | [Agents](references/agents.md) |
35
+ | Inspect supported agents and raw assignment state | `foundry agents list` | [Agents](references/agents.md) |
36
+ | Read or change application preferences | `foundry settings get/set` | [Settings](references/settings.md) |
37
+ | Export or import an encrypted backup | `foundry settings export/import` | [Encrypted backups](references/backups.md) |
38
+ | Install or refresh this Skill | `foundry settings download-skill` | [Settings](references/settings.md#install-this-skill) |
39
+ | Open the Web UI | `foundry web` | [Web UI](#web-ui) |
40
+
41
+ ## How the pieces fit
42
+
43
+ Instructions, agent assignments, and agent files are three separate layers:
44
+
45
+ ```text
46
+ <home>/.foundry/instructions/<id>.md
47
+ |
48
+ | assign: choose IDs and order
49
+ v
50
+ <home>/.foundry/agents/<sha256(agent-id)>.json
51
+ |
52
+ | enable: write the managed block
53
+ v
54
+ ~/.codex/AGENTS.md or ~/.claude/CLAUDE.md
55
+ ```
56
+
57
+ - An instruction is reusable content with an ID, name, and Markdown body.
58
+ - An agent assignment is an ordered list of instruction IDs. The same
59
+ instruction can be assigned to multiple agents.
60
+ - Assigning only changes Foundry state. The external agent file changes only
61
+ through `enable`, `disable`, or `reapply`.
62
+ - Foundry owns only its marked block in the external file. Text outside the
63
+ block remains untouched.
64
+
65
+ ## Safe workflow
66
+
67
+ 1. Read current state before changing it:
68
+
69
+ ```bash
70
+ foundry instructions list
71
+ foundry agents instructions list
72
+ ```
73
+
74
+ 2. Use a feature command for the write. Do not hand-edit instructions,
75
+ assignment records, or Foundry's managed block.
76
+ 3. Verify the result:
77
+
78
+ ```bash
79
+ foundry agents instructions list chatgpt
80
+ ```
81
+
82
+ 4. When the task touches an agent file, confirm the returned JSON and the
83
+ resulting managed block.
84
+
85
+ ## Common workflows
86
+
87
+ ### Create an instruction and apply it to both agents
88
+
89
+ ```bash
90
+ foundry instructions new \
91
+ --name "Release checklist" \
92
+ --content "# Release
93
+
94
+ - Run tests
95
+ - Update the changelog"
96
+
97
+ foundry agents instructions assign chatgpt --instructions <instruction-id>
98
+ foundry agents instructions enable chatgpt
99
+
100
+ foundry agents instructions assign claude-code --instructions <instruction-id>
101
+ foundry agents instructions enable claude-code
102
+ ```
103
+
104
+ Read [Instructions](references/instructions.md) for creation rules and
105
+ [Agents](references/agents.md) for assignment and enable semantics.
106
+
107
+ ### Edit an instruction and propagate the new content
108
+
109
+ ```bash
110
+ foundry instructions edit <instruction-id> \
111
+ --name "Release checklist" \
112
+ --content "# Release
113
+
114
+ - Run tests
115
+ - Verify the changelog"
116
+ ```
117
+
118
+ Editing changes the stored instruction only. Reapply each enabled agent that
119
+ uses it:
120
+
121
+ ```bash
122
+ foundry agents instructions reapply chatgpt
123
+ foundry agents instructions reapply claude-code
124
+ ```
125
+
126
+ ### Inspect what each agent currently receives
127
+
128
+ ```bash
129
+ foundry agents instructions list
130
+ ```
131
+
132
+ This resolves ordered IDs to instruction names. Use `foundry instructions list`
133
+ when the full Markdown content is needed.
134
+
135
+ ### Delete an instruction nobody uses
136
+
137
+ ```bash
138
+ foundry agents instructions list
139
+ foundry instructions delete <instruction-id>
140
+ ```
141
+
142
+ Deletion is blocked while any agent assignment references the instruction.
143
+ Clear the assignment from every agent before deleting; see
144
+ [Instructions](references/instructions.md#delete-an-instruction).
145
+
146
+ ### Temporarily stop writing instructions without losing the order
147
+
148
+ ```bash
149
+ foundry agents instructions disable chatgpt
150
+ ```
151
+
152
+ The assignment remains stored. Later:
153
+
154
+ ```bash
155
+ foundry agents instructions enable chatgpt
156
+ ```
157
+
158
+ ### Change only application preferences
159
+
160
+ ```bash
161
+ foundry settings get
162
+ foundry settings set color-theme dark
163
+ foundry settings set language zh-CN
164
+ ```
21
165
 
22
166
  ## CLI conventions
23
167
 
24
- - Use `foundry --help` and `foundry <feature> --help` to check installed commands.
25
- Bare `foundry` prints help without initializing storage.
26
- - Successful business operations print JSON. Operation errors print
168
+ - Successful business operations print JSON. Parse the output instead of
169
+ scraping human text.
170
+ - Operation errors print
27
171
  `{"error":{"code":"...","message":"..."}}` to stderr and exit nonzero.
28
- Argument-parsing errors use the CLI's diagnostic output.
29
- - Help, version, and Web startup output are human-readable.
30
- - Read relevant current state before a change and verify the result afterward.
31
- Use feature commands for writes rather than editing runtime files directly.
32
- - Keep credentials and backup passphrases out of logs and responses.
172
+ - Argument-parsing errors use the CLI's diagnostic output.
173
+ - Use `foundry --help` and `foundry <feature> <command> --help` to confirm the
174
+ installed version's command tree and arguments.
175
+ - Quote values containing spaces or newlines. Commands are non-interactive.
176
+ - Run `foundry` without a command only to read help; it does not initialize
177
+ storage or start the Web UI.
178
+ - Keep backup passphrases and other credentials out of logs and responses.
179
+
180
+ ## Data locations
181
+
182
+ | Path | Contents |
183
+ | --- | --- |
184
+ | `<home>/.foundry/settings.json` | Normalized application settings |
185
+ | `<home>/.foundry/instructions/<id>.md` | One Markdown instruction per file |
186
+ | `<home>/.foundry/agents/<sha256(agent-id)>.json` | Assignment order and enabled state per agent |
187
+ | `~/.codex/AGENTS.md` | ChatGPT instruction file managed by Foundry |
188
+ | `~/.claude/CLAUDE.md` | Claude Code instruction file managed by Foundry |
189
+ | `<home>/.agents/skills/foundry` | Installed Skill for `.agents` targets |
190
+ | `<home>/.claude/skills/foundry` | Installed Skill for `.claude` targets |
191
+
192
+ `<home>` is the operating system user home directory (`~` on POSIX). Treat
193
+ Foundry's JSON and Markdown stores as runtime data; use the CLI for writes.
33
194
 
34
195
  ## Web UI
35
196
 
36
- Start the Web UI when requested with `foundry web`. Use `foundry web --no-open`
37
- to start the same local server without opening a browser. It prints the URL and
38
- serves the UI on port 11111. Feature-specific routes and behavior belong in their
39
- references.
197
+ Start the Web UI when the user asks for it:
198
+
199
+ ```bash
200
+ foundry web
201
+ ```
202
+
203
+ Use `--no-open` to start the same local server without opening a browser. It
204
+ prints the URL and serves the UI on port `11111`. Instructions and Settings are
205
+ the implemented Web features. The Instructions page is at
206
+ `#/library/instructions` and supports creation, direct source editing, and
207
+ agent assignment. Right-clicking an instruction row exposes Edit and Delete;
208
+ Delete is disabled while an agent assignment uses the instruction. The Web UI
209
+ edits Markdown source and does not render it.
210
+ Settings routes are documented in
211
+ [Settings](references/settings.md#web-ui-synchronization).
212
+
213
+ ## Safety boundaries
214
+
215
+ - Backup import is destructive and replaces supported data. Read
216
+ [Encrypted backups](references/backups.md) before running it.
217
+ - Encrypted backups include instructions and agent assignments, but not the
218
+ external agent instruction files. Reapply enabled agents after import.
219
+ - Deleting an instruction is rejected with `INSTRUCTION_IN_USE` while any agent
220
+ assignment references its ID. Clear those assignments first.
221
+ - Enabling an agent overwrites Foundry's managed block. Reapply is the recovery
222
+ path after manual or malformed edits inside that block.
223
+ - The agent output paths are fixed. No command accepts an arbitrary destination
224
+ path.
@@ -0,0 +1,280 @@
1
+ # Agents
2
+
3
+ ## Overview
4
+
5
+ Foundry composes saved instructions into external agent instruction files.
6
+ Agent orchestration has three layers:
7
+
8
+ 1. **Instruction library**: reusable Markdown records under
9
+ `<home>/.foundry/instructions`.
10
+ 2. **Assignment**: an ordered list of instruction IDs stored per agent under
11
+ `<home>/.foundry/agents`.
12
+ 3. **Managed block**: the marked region Foundry writes into the agent's
13
+ instruction file when the agent is enabled.
14
+
15
+ Assigning instructions changes Foundry state only. Enabling writes the block;
16
+ disabling removes the block; reapplying rewrites it. The instruction library
17
+ and all text outside Foundry's block remain independent.
18
+
19
+ Use this reference when the task is to inspect agent state, assign or reorder
20
+ instructions, turn instruction writing on or off, recover a managed block, or
21
+ open an agent's instruction file. Read [Instructions](instructions.md) first
22
+ when the needed instruction does not exist yet.
23
+
24
+ ## Supported agents
25
+
26
+ The agents and output paths are fixed:
27
+
28
+ | Agent ID | Name | Instruction file |
29
+ | --- | --- | --- |
30
+ | `chatgpt` | ChatGPT | `~/.codex/AGENTS.md` |
31
+ | `claude-code` | Claude Code | `~/.claude/CLAUDE.md` |
32
+
33
+ `~` is the operating system user home directory. No command accepts an
34
+ arbitrary output path.
35
+
36
+ ## When to use
37
+
38
+ Use `foundry agents` when the user wants to:
39
+
40
+ - See which instructions each agent currently receives.
41
+ - Make one or more instructions active for ChatGPT or Claude Code.
42
+ - Change the order in which instructions are concatenated.
43
+ - Temporarily stop Foundry from writing to an agent file without losing the
44
+ assignment.
45
+ - Repair the managed block after a manual or malformed edit.
46
+ - Open the external file for inspection.
47
+
48
+ Do not hand-edit assignment JSON to achieve these outcomes. Use the commands so
49
+ the external files and stored state stay consistent.
50
+
51
+ ## Inspect assignments
52
+
53
+ ### Raw agent state
54
+
55
+ ```bash
56
+ foundry agents list
57
+ ```
58
+
59
+ Prints the fixed agents with `id`, `name`, `icon`, `instructionFile`,
60
+ `enabled`, and the ordered `instructionIds`.
61
+
62
+ ### Resolved assignment view
63
+
64
+ ```bash
65
+ foundry agents instructions list
66
+ foundry agents instructions list chatgpt
67
+ ```
68
+
69
+ The optional agent ID filters the output to one agent. Each record resolves the
70
+ ordered IDs into names:
71
+
72
+ ```json
73
+ [
74
+ {
75
+ "id": "chatgpt",
76
+ "name": "ChatGPT",
77
+ "instructionFile": "~/.codex/AGENTS.md",
78
+ "enabled": false,
79
+ "instructions": [
80
+ { "id": "0a5fab1b-df3c-4721-8b0c-63ee87856292", "name": "Release checklist" },
81
+ { "id": "d24f45f8-5be2-4f4c-8d3a-e1a7f0d6f1c2", "name": "Review rules" }
82
+ ]
83
+ }
84
+ ]
85
+ ```
86
+
87
+ The array order is the composition order. `name` is `null` when the assignment
88
+ references an instruction file that is missing; the record still appears so the
89
+ broken assignment is visible. Use `foundry instructions list` when the full
90
+ instruction content is needed.
91
+
92
+ ## Assign and reorder
93
+
94
+ ```bash
95
+ foundry agents instructions assign chatgpt --instructions <id1>,<id2>
96
+ ```
97
+
98
+ `--instructions` replaces the entire ordered assignment for that agent. The
99
+ comma-separated order is the order the contents are concatenated.
100
+
101
+ - Adding an instruction: include all existing IDs plus the new ID in the
102
+ desired position.
103
+ - Reordering: pass the same IDs in the new order.
104
+ - Removing one instruction: pass the remaining IDs.
105
+ - Clearing: pass an empty string.
106
+
107
+ ```bash
108
+ foundry agents instructions assign chatgpt --instructions ""
109
+ ```
110
+
111
+ Rules:
112
+
113
+ - The same instruction cannot appear twice in one agent.
114
+ - Unknown IDs fail with `UNKNOWN_INSTRUCTION`.
115
+ - Duplicate IDs fail with `DUPLICATE_INSTRUCTION`.
116
+ - Assigning while the agent is disabled does not write the external file.
117
+ - Assigning while the agent is enabled rewrites the managed block immediately.
118
+ - Clearing the final instruction also turns the agent off and removes the
119
+ managed block.
120
+ - An instruction cannot be deleted while any agent assignment references its
121
+ ID. Clear it from every agent first; otherwise deletion fails with
122
+ `INSTRUCTION_IN_USE`.
123
+
124
+ ## Apply and remove
125
+
126
+ | Command | Effect |
127
+ | --- | --- |
128
+ | `foundry agents instructions enable <agent>` | Write the managed block and mark the agent enabled |
129
+ | `foundry agents instructions disable <agent>` | Remove Foundry's managed block and mark the agent disabled |
130
+ | `foundry agents instructions reapply <agent>` | Rewrite the block for an already enabled agent |
131
+
132
+ ```bash
133
+ foundry agents instructions enable chatgpt
134
+ foundry agents instructions disable chatgpt
135
+ foundry agents instructions reapply chatgpt
136
+ ```
137
+
138
+ Semantics:
139
+
140
+ - `enable` fails with `AGENT_HAS_NO_INSTRUCTIONS` when the assignment is empty.
141
+ - `disable` preserves the ordered assignment. Enabling again restores the same
142
+ block.
143
+ - `reapply` fails with `AGENT_DISABLED` when the agent is off.
144
+ - `disable` removes complete managed blocks and malformed Foundry markers while
145
+ preserving all other file content.
146
+ - Enabling an agent whose file does not exist creates the file with only the
147
+ managed block. Disabling a missing file does not create it.
148
+ - Editing an instruction does not rewrite enabled agent files. Reapply each
149
+ agent that uses the edited instruction to write the new content.
150
+
151
+ ## Open the file
152
+
153
+ ```bash
154
+ foundry agents instructions open chatgpt
155
+ ```
156
+
157
+ Opens the existing instruction file through the local operating system. Fails
158
+ with `AGENT_FILE_NOT_FOUND` when the file does not exist. Opening is a
159
+ read/inspection action; it does not rewrite the file.
160
+
161
+ ## Common scenarios
162
+
163
+ ### Apply the same instruction to both agents
164
+
165
+ ```bash
166
+ foundry agents instructions assign chatgpt --instructions <id1>,<id2>
167
+ foundry agents instructions enable chatgpt
168
+
169
+ foundry agents instructions assign claude-code --instructions <id1>,<id2>
170
+ foundry agents instructions enable claude-code
171
+ ```
172
+
173
+ Both files now contain the same instructions in the same order, each inside its
174
+ own Foundry managed block.
175
+
176
+ ### Pause one agent without losing its order
177
+
178
+ ```bash
179
+ foundry agents instructions disable claude-code
180
+ ```
181
+
182
+ The Claude Code file loses only Foundry's block. Its stored assignment remains.
183
+ Resume later:
184
+
185
+ ```bash
186
+ foundry agents instructions enable claude-code
187
+ ```
188
+
189
+ ### Move an instruction later in the composition
190
+
191
+ Read the current order, then reassign it explicitly:
192
+
193
+ ```bash
194
+ foundry agents instructions assign chatgpt \
195
+ --instructions <second-id>,<first-id>
196
+ ```
197
+
198
+ If the agent is enabled, the file is rewritten immediately in the new order.
199
+
200
+ ### Recover after editing inside the managed block
201
+
202
+ ```bash
203
+ foundry agents instructions reapply chatgpt
204
+ ```
205
+
206
+ Reapply regenerates the block from the current assignment. It does not recover
207
+ deleted text outside the block.
208
+
209
+ ### Remove all instructions from one agent
210
+
211
+ ```bash
212
+ foundry agents instructions assign chatgpt --instructions ""
213
+ ```
214
+
215
+ This clears the assignment, turns the agent off, and removes the managed block.
216
+ The instruction records remain in the library and other agents are unchanged.
217
+
218
+ ## Managed block
219
+
220
+ Foundry writes at most one block using these exact markers:
221
+
222
+ ```md
223
+ <!-- foundry:instructions:start -->
224
+
225
+ ...assigned instruction contents in order...
226
+
227
+ <!-- foundry:instructions:end -->
228
+ ```
229
+
230
+ Enabling and reapplying overwrite the managed block. Disabling removes complete
231
+ blocks and malformed Foundry markers while preserving text outside them. A
232
+ single instruction's content is inserted as stored; Foundry does not rewrite
233
+ the Markdown body.
234
+
235
+ ## Storage
236
+
237
+ Each agent has one JSON profile:
238
+
239
+ ```text
240
+ <home>/.foundry/agents/<sha256(agent-id)>.json
241
+ ```
242
+
243
+ The profile keeps the stable agent ID at the top level and instruction state in
244
+ an `instructions` namespace:
245
+
246
+ ```json
247
+ {
248
+ "id": "chatgpt",
249
+ "instructions": {
250
+ "instructionIds": ["instruction-id-1", "instruction-id-2"],
251
+ "enabled": true,
252
+ "createdAt": 1795824000000,
253
+ "updatedAt": 1795824000000
254
+ }
255
+ }
256
+ ```
257
+
258
+ Read it through `foundry agents list` or
259
+ `foundry agents instructions list`; use the CLI for writes. Timestamps are Unix
260
+ epoch milliseconds, not ISO strings.
261
+
262
+ ## Errors
263
+
264
+ | Code | Meaning | Recovery |
265
+ | --- | --- | --- |
266
+ | `AGENT_NOT_FOUND` | The agent ID is not `chatgpt` or `claude-code` | Use a supported ID |
267
+ | `UNKNOWN_INSTRUCTION` | An assigned instruction ID has no stored record | Create the instruction or remove the ID |
268
+ | `DUPLICATE_INSTRUCTION` | The same ID appears twice in one assignment | Pass each ID once |
269
+ | `AGENT_HAS_NO_INSTRUCTIONS` | Tried to enable an empty assignment | Assign at least one instruction |
270
+ | `AGENT_DISABLED` | Tried to reapply while the agent is off | Enable the agent first |
271
+ | `AGENT_FILE_NOT_FOUND` | Tried to open a file that does not exist | Enable the agent or write the file outside Foundry first |
272
+ | `INVALID_AGENT_INPUT` | Malformed API/CLI input shape | Correct the argument |
273
+
274
+ Operation errors use Foundry's JSON error envelope and exit nonzero.
275
+
276
+ ## Related
277
+
278
+ - [Instructions](instructions.md): create and list the Markdown records.
279
+ - [Settings](settings.md): application preferences and Skill installation.
280
+ - [Encrypted backups](backups.md): assignments are included; external files are not.