Files
skillshare/internal/server
Willie f6e7265414 feat(hooks): read hook code and scripts from files next to the config (#586)
* feat(hooks): read hook code and scripts from files next to the config

Code Agent extensions and command scripts lived as strings in
config.yaml, so a longer Pi extension or shell script was edited inside
a YAML block scalar with no editor support, and nothing type-checked or
linted it. A breaking change in an Agent's extension API went unnoticed
because the generated file is not part of any tsconfig.

A binding now takes `codeFile: path` instead of `code`, and a `files`
value may be `{from: path}` instead of the contents. Paths resolve
against the folder of the config that holds the entry and are read
every time the config is read, so the regular typecheck or shellcheck
can cover the real source. The revision and drift checks use the
resolved contents, so a file edited after a preview fails the apply as
stale.

Saving keeps the references: enable/disable, `hooks edit` and the
dashboard write `codeFile` and `{from}` back instead of inlining the
contents. JSON carries the contents plus `codeFile`/`filesFrom`, and an
entry echoed back with both must match the file, so an edit is refused
rather than silently dropped. Paths must stay inside the config folder
without symlinks, so a cloned project cannot pull in files from
elsewhere. References are taken from the YAML tree before one strict
decode, which keeps unknown-field checks and anchors shared across
bindings working.

Closes #585

* fix(hooks): refuse an emptied file sent with its reference

An empty files value stood for "contents not sent", so a file cleared in
the dashboard's Git YAML editor while its filesFrom reference stayed was
treated as unsent: the file was read again from disk and the save
reported success with the user's edit discarded.

A value read from {from: path} now keeps a dedicated mark until it is
resolved, so an empty value is compared with the file like any other
contents and refused when they differ. Code keeps using empty as unsent,
since a code binding can never be empty.

* fix(hooks): render referenced files as they are on disk

RenderNative rendered the contents the caller sent. The dashboard sends
the entry it loaded, so after a referenced file changed, View
configuration still showed the old contents while describing them as
what sync would write.

Render now drops sent contents for codeFile and {from} references and
reads every reference again, like preview and save. Draft, render and
config decoding are the only paths that take an entry, and all three now
resolve references.

* fix(hooks): accept file references in JSON entries and anchored values

Two inputs that config.yaml accepts failed to load elsewhere.

A `{from}` value carrying its own YAML anchor, aliased from another
binding, lost its anchor because the value node was replaced instead of
rewritten, so the alias no longer resolved. The node is now rewritten in
place with its anchor kept.

An entry JSON file (`hooks add|edit --file x.json`) could not write a
files value as `{"from": path}`, because JSON decoded straight into
string contents. Binding now decodes JSON files values as contents or a
reference, strictly, like YAML, so both entry formats and the Web API
take the same shapes.
2026-10-19 22:48:00 +08:00
..
2026-04-14 18:16:11 +08:00
2026-04-19 09:29:18 +08:00
2026-04-19 09:29:18 +08:00