@dhzh/foundry 8.0.1 → 9.0.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.
@@ -99,7 +99,7 @@ Success prints JSON:
99
99
  {"name":"hello","description":"Use when greeting users.","content":""}
100
100
  ```
101
101
 
102
- The file is `<home>/.foundry/skill/hello/SKILL.md`:
102
+ The file is `<home>/.foundry/skills/hello/SKILL.md`:
103
103
 
104
104
  ```markdown
105
105
  ---
@@ -113,6 +113,34 @@ Markdown body starts empty. The name matches the directory. Writes use Foundry
113
113
  storage transactions and interrupted writes are recovered. POSIX directories
114
114
  and files use `0700` and `0600` permissions.
115
115
 
116
+ ## Import from a local path
117
+
118
+ ```bash
119
+ foundry skills create local ./my-skill
120
+ foundry skills create local ./collection.zip
121
+ foundry skills create local ./example.skill
122
+ ```
123
+
124
+ Pass one source path, absolute or relative to the current directory. The CLI
125
+ reads it directly without opening a picker or starting the Web server. The
126
+ same service and validation as Web import apply:
127
+
128
+ - A folder must contain `SKILL.md` directly at its root; its whole tree is one Skill.
129
+ - An archive with root `SKILL.md` is one Skill. Otherwise, only its immediate
130
+ child folders are candidates; each must have its own root `SKILL.md`.
131
+ - Metadata `name` determines the destination under `~/.foundry/skills`.
132
+ Existing destinations are never overwritten. Standalone `.md` files are rejected.
133
+ - In archive collection mode, invalid or conflicting candidates are skipped;
134
+ other candidates continue. The CLI does not search deeper for Skills.
135
+
136
+ Success prints `{ "imported": [...], "skipped": [...] }`. Imported items are
137
+ Skills with `name`, `description`, and Markdown `content`; skipped items have
138
+ `source`, `code`, and `message`. Partial or all-skipped collection results exit
139
+ with code 0; callers must inspect both arrays. An invalid single source or
140
+ unreadable/corrupt archive prints the JSON error envelope on stderr and exits
141
+ with code 1. Original files, resources, extra metadata, and empty directories
142
+ are preserved. Import does not assign Skills to agents.
143
+
116
144
  ## Edit metadata
117
145
 
118
146
  ```bash
@@ -195,8 +223,9 @@ for filesystem behavior and official agent references.
195
223
  ## Errors and scope
196
224
 
197
225
  - `INVALID_SKILL_INPUT`: fix the name or description and retry.
198
- - `SKILL_NAME_CONFLICT`: choose another name. Existing directories, including
199
- incomplete skill directories, are preserved.
226
+ - `SKILL_NAME_CONFLICT`: the destination already exists. Create/edit flows require
227
+ another name; import leaves the existing directory, including an incomplete
228
+ skill directory, untouched.
200
229
  - `SKILL_LINK_CONFLICT`: an unrelated entry occupies a registered agent
201
230
  destination. Preserve that entry and resolve the conflict before retrying.
202
231
  - `SKILL_AGENT_NOT_FOUND`: the agent is not registered with Skills support.
@@ -206,16 +235,59 @@ for filesystem behavior and official agent references.
206
235
  indicate an invalid `--file` path. Operation errors use the JSON error
207
236
  envelope on stderr and exit with code 1.
208
237
 
209
- `manual` is currently the only implemented creation source. Local and URL
210
- import menu entries are UI placeholders. Creation does not distribute the Skill;
238
+ CLI creation supports `manual` and `local`. The Web UI also supports local
239
+ import; URL import remains a placeholder. Creation does not distribute the Skill;
211
240
  editing refreshes assigned agent links. Skill sources and assignments are
212
- included in version-3 encrypted backups with complete source files and resources.
241
+ included in version-4 encrypted backups with complete source files and resources.
213
242
  Import replaces source files first; Agent configuration is applied only by the
214
243
  subsequent Web choice or CLI `--apply-agents`. Declining clears saved assignments
215
244
  and preserves external links. See [Backups](backups.md).
216
245
 
217
246
  ## Web UI
218
247
 
248
+ Use **New skill → Import from local** to open
249
+ a native picker on the computer running Foundry. Select
250
+ one folder or one `.skill` / `.zip` archive. Standalone Markdown files and
251
+ multiple selection are not supported.
252
+
253
+ - A selected folder must contain `SKILL.md` directly at its root. The complete
254
+ folder is one Skill; its children are resources, not additional candidates.
255
+ - An archive with root `SKILL.md` is one Skill. Its frontmatter `name` determines
256
+ the destination directory, independent of the archive filename.
257
+ - An archive without root `SKILL.md` checks each immediate child folder as a
258
+ separate candidate. Each must contain its own root `SKILL.md`. Invalid or
259
+ conflicting candidates are skipped and processing continues. Discovery never
260
+ descends to grandchildren; root files are ignored in this mode.
261
+
262
+ Each accepted candidate is copied into `<home>/.foundry/skills/<name>`, using the
263
+ same name/description rules as manual creation. Original Markdown, extra
264
+ metadata, binary resources, and empty directories are preserved. Node reads
265
+ the source directly; file contents never pass through the browser.
266
+
267
+ Import validates each candidate before writing it. Invalid UTF-8/frontmatter,
268
+ unsafe or duplicate paths, and symbolic links are rejected. Archive corruption,
269
+ unsafe archive paths, or archive-wide limits abort the request before any import.
270
+ Sources support at most 5,000 entries and 32 MiB of expanded file contents;
271
+ Skill paths support 32 levels and `SKILL.md` is limited to 2 MiB. An occupied
272
+ destination is never overwritten. Each accepted Skill uses its own recovery
273
+ transaction; rejected candidates do not undo other successful imports. Import
274
+ does not assign Skills to agents.
275
+
276
+ `POST /api/skills/import/local` accepts JSON `{ "path": "/absolute/source/path" }`.
277
+ It returns `{ imported: Skill[], skipped: [{ source, code, message }] }` with
278
+ HTTP 201 when any Skill was imported, or HTTP 200 when every candidate was
279
+ skipped. A source with no candidates is invalid. Missing/unreadable sources use
280
+ `SKILL_IMPORT_READ_FAILED` (400). Single-Skill validation errors use specific
281
+ `SKILL_IMPORT_*` codes (400), total-size errors use `SKILL_IMPORT_TOO_LARGE`
282
+ (413), `SKILL.md` over 2 MiB uses `SKILL_IMPORT_SKILL_MD_TOO_LARGE` (413), and
283
+ occupied names use `SKILL_NAME_CONFLICT` (409). In archive collection mode,
284
+ candidate validation and conflict errors appear in `skipped` instead.
285
+
286
+ The Web UI shows imported/skipped counts and skipped folder names. One successful
287
+ Skill with no skipped items opens its detail page; collections and partial
288
+ results stay in the refreshed library list. Cancelling the picker sends no
289
+ business request.
290
+
219
291
  At `#/library/skills`, select **New skill → Create manually**, enter the same
220
292
  metadata, and submit. Success opens `#/library/skills/<name>`. The detail page
221
293
  has file navigation on the left and a Monaco source editor on the right,