@dhzh/foundry 8.0.0 → 8.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.
@@ -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/skill`.
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
@@ -206,8 +234,8 @@ for filesystem behavior and official agent references.
206
234
  indicate an invalid `--file` path. Operation errors use the JSON error
207
235
  envelope on stderr and exit with code 1.
208
236
 
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;
237
+ CLI creation supports `manual` and `local`. The Web UI also supports local
238
+ import; URL import remains a placeholder. Creation does not distribute the Skill;
211
239
  editing refreshes assigned agent links. Skill sources and assignments are
212
240
  included in version-3 encrypted backups with complete source files and resources.
213
241
  Import replaces source files first; Agent configuration is applied only by the
@@ -216,6 +244,48 @@ and preserves external links. See [Backups](backups.md).
216
244
 
217
245
  ## Web UI
218
246
 
247
+ Use **New skill → Import from local** to open
248
+ a native picker on the computer running Foundry. Select
249
+ one folder or one `.skill` / `.zip` archive. Standalone Markdown files and
250
+ multiple selection are not supported.
251
+
252
+ - A selected folder must contain `SKILL.md` directly at its root. The complete
253
+ folder is one Skill; its children are resources, not additional candidates.
254
+ - An archive with root `SKILL.md` is one Skill. Its frontmatter `name` determines
255
+ the destination directory, independent of the archive filename.
256
+ - An archive without root `SKILL.md` checks each immediate child folder as a
257
+ separate candidate. Each must contain its own root `SKILL.md`. Invalid or
258
+ conflicting candidates are skipped and processing continues. Discovery never
259
+ descends to grandchildren; root files are ignored in this mode.
260
+
261
+ Each accepted candidate is copied into `<home>/.foundry/skill/<name>`, using the
262
+ same name/description rules as manual creation. Original Markdown, extra
263
+ metadata, binary resources, and empty directories are preserved. Node reads
264
+ the source directly; file contents never pass through the browser.
265
+
266
+ Import validates each candidate before writing it. Invalid UTF-8/frontmatter,
267
+ unsafe or duplicate paths, and symbolic links are rejected. Archive corruption,
268
+ unsafe archive paths, or archive-wide limits abort the request before any import.
269
+ Sources support at most 5,000 entries and 32 MiB of expanded file contents;
270
+ Skill paths support 32 levels and `SKILL.md` is limited to 2 MiB. An occupied
271
+ destination is never overwritten. Each accepted Skill uses its own recovery
272
+ transaction; rejected candidates do not undo other successful imports. Import
273
+ does not assign Skills to agents.
274
+
275
+ `POST /api/skills/import/local` accepts JSON `{ "path": "/absolute/source/path" }`.
276
+ It returns `{ imported: Skill[], skipped: [{ source, code, message }] }` with
277
+ HTTP 201 when any Skill was imported, or HTTP 200 when every candidate was
278
+ skipped. A source with no candidates is invalid. Missing/unreadable sources use
279
+ `SKILL_IMPORT_READ_FAILED` (400). Single-Skill validation errors use
280
+ `INVALID_SKILL_IMPORT` (400), size errors use `SKILL_IMPORT_TOO_LARGE` (413), and
281
+ occupied names use `SKILL_NAME_CONFLICT` (409). In archive collection mode,
282
+ candidate validation and conflict errors appear in `skipped` instead.
283
+
284
+ The Web UI shows imported/skipped counts and skipped folder names. One successful
285
+ Skill with no skipped items opens its detail page; collections and partial
286
+ results stay in the refreshed library list. Cancelling the picker sends no
287
+ business request.
288
+
219
289
  At `#/library/skills`, select **New skill → Create manually**, enter the same
220
290
  metadata, and submit. Success opens `#/library/skills/<name>`. The detail page
221
291
  has file navigation on the left and a Monaco source editor on the right,