@namzu/sdk 64.0.0 → 64.2.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.
Files changed (132) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/agents/file-definitions.d.ts +10 -0
  3. package/dist/agents/file-definitions.d.ts.map +1 -1
  4. package/dist/agents/file-definitions.js +10 -2
  5. package/dist/agents/file-definitions.js.map +1 -1
  6. package/dist/plugin/file-change-hooks.d.ts +53 -0
  7. package/dist/plugin/file-change-hooks.d.ts.map +1 -0
  8. package/dist/plugin/file-change-hooks.js +111 -0
  9. package/dist/plugin/file-change-hooks.js.map +1 -0
  10. package/dist/plugin/file-change-watch.d.ts +111 -0
  11. package/dist/plugin/file-change-watch.d.ts.map +1 -0
  12. package/dist/plugin/file-change-watch.js +324 -0
  13. package/dist/plugin/file-change-watch.js.map +1 -0
  14. package/dist/plugin/index.d.ts +10 -1
  15. package/dist/plugin/index.d.ts.map +1 -1
  16. package/dist/plugin/index.js +7 -1
  17. package/dist/plugin/index.js.map +1 -1
  18. package/dist/plugin/lifecycle.d.ts +60 -1
  19. package/dist/plugin/lifecycle.d.ts.map +1 -1
  20. package/dist/plugin/lifecycle.js +118 -7
  21. package/dist/plugin/lifecycle.js.map +1 -1
  22. package/dist/plugin/loader.d.ts.map +1 -1
  23. package/dist/plugin/loader.js +24 -1
  24. package/dist/plugin/loader.js.map +1 -1
  25. package/dist/plugin/session-hook-env.d.ts +140 -0
  26. package/dist/plugin/session-hook-env.d.ts.map +1 -0
  27. package/dist/plugin/session-hook-env.js +458 -0
  28. package/dist/plugin/session-hook-env.js.map +1 -0
  29. package/dist/plugin/shell-hook-env.d.ts +107 -0
  30. package/dist/plugin/shell-hook-env.d.ts.map +1 -0
  31. package/dist/plugin/shell-hook-env.js +272 -0
  32. package/dist/plugin/shell-hook-env.js.map +1 -0
  33. package/dist/plugin/shell-hook.d.ts +105 -2
  34. package/dist/plugin/shell-hook.d.ts.map +1 -1
  35. package/dist/plugin/shell-hook.js +282 -24
  36. package/dist/plugin/shell-hook.js.map +1 -1
  37. package/dist/plugin/worktree-hook-answer.d.ts +26 -0
  38. package/dist/plugin/worktree-hook-answer.d.ts.map +1 -0
  39. package/dist/plugin/worktree-hook-answer.js +132 -0
  40. package/dist/plugin/worktree-hook-answer.js.map +1 -0
  41. package/dist/public-runtime.d.ts +4 -4
  42. package/dist/public-runtime.d.ts.map +1 -1
  43. package/dist/public-runtime.js +4 -4
  44. package/dist/public-runtime.js.map +1 -1
  45. package/dist/public-types.d.ts +7 -1
  46. package/dist/public-types.d.ts.map +1 -1
  47. package/dist/runtime/query/executor.d.ts +8 -1
  48. package/dist/runtime/query/executor.d.ts.map +1 -1
  49. package/dist/runtime/query/executor.js +4 -0
  50. package/dist/runtime/query/executor.js.map +1 -1
  51. package/dist/runtime/query/index.d.ts +9 -0
  52. package/dist/runtime/query/index.d.ts.map +1 -1
  53. package/dist/runtime/query/index.js +20 -0
  54. package/dist/runtime/query/index.js.map +1 -1
  55. package/dist/runtime/query/tooling.d.ts +8 -1
  56. package/dist/runtime/query/tooling.d.ts.map +1 -1
  57. package/dist/runtime/query/tooling.js +6 -0
  58. package/dist/runtime/query/tooling.js.map +1 -1
  59. package/dist/session/workspace/hooked-driver.d.ts +72 -0
  60. package/dist/session/workspace/hooked-driver.d.ts.map +1 -0
  61. package/dist/session/workspace/hooked-driver.js +204 -0
  62. package/dist/session/workspace/hooked-driver.js.map +1 -0
  63. package/dist/session/workspace/index.d.ts +2 -0
  64. package/dist/session/workspace/index.d.ts.map +1 -1
  65. package/dist/session/workspace/index.js +1 -0
  66. package/dist/session/workspace/index.js.map +1 -1
  67. package/dist/skills/index.d.ts +1 -1
  68. package/dist/skills/index.d.ts.map +1 -1
  69. package/dist/skills/index.js +1 -1
  70. package/dist/skills/index.js.map +1 -1
  71. package/dist/skills/loader.d.ts +22 -0
  72. package/dist/skills/loader.d.ts.map +1 -1
  73. package/dist/skills/loader.js +41 -0
  74. package/dist/skills/loader.js.map +1 -1
  75. package/dist/tools/builtins/bash-cwd.d.ts +6 -1
  76. package/dist/tools/builtins/bash-cwd.d.ts.map +1 -1
  77. package/dist/tools/builtins/bash-cwd.js +27 -2
  78. package/dist/tools/builtins/bash-cwd.js.map +1 -1
  79. package/dist/tools/builtins/bash.js +1 -1
  80. package/dist/tools/builtins/bash.js.map +1 -1
  81. package/dist/tools/builtins/skill.d.ts.map +1 -1
  82. package/dist/tools/builtins/skill.js +114 -17
  83. package/dist/tools/builtins/skill.js.map +1 -1
  84. package/dist/types/plugin/index.d.ts +75 -2
  85. package/dist/types/plugin/index.d.ts.map +1 -1
  86. package/dist/types/plugin/index.js +5 -0
  87. package/dist/types/plugin/index.js.map +1 -1
  88. package/dist/types/session/records.d.ts +73 -1
  89. package/dist/types/session/records.d.ts.map +1 -1
  90. package/dist/types/session/records.js +25 -0
  91. package/dist/types/session/records.js.map +1 -1
  92. package/dist/types/skills/index.d.ts +8 -0
  93. package/dist/types/skills/index.d.ts.map +1 -1
  94. package/dist/types/skills/index.js.map +1 -1
  95. package/dist/types/tool/index.d.ts +97 -0
  96. package/dist/types/tool/index.d.ts.map +1 -1
  97. package/dist/types/tool/index.js.map +1 -1
  98. package/dist/types/workspace/ref.d.ts +6 -0
  99. package/dist/types/workspace/ref.d.ts.map +1 -1
  100. package/dist/utils/frontmatter.d.ts +16 -0
  101. package/dist/utils/frontmatter.d.ts.map +1 -1
  102. package/dist/utils/frontmatter.js +31 -1
  103. package/dist/utils/frontmatter.js.map +1 -1
  104. package/package.json +1 -1
  105. package/src/agents/file-definitions.ts +17 -2
  106. package/src/plugin/file-change-hooks.ts +131 -0
  107. package/src/plugin/file-change-watch.ts +367 -0
  108. package/src/plugin/index.ts +39 -1
  109. package/src/plugin/lifecycle.ts +162 -8
  110. package/src/plugin/loader.ts +22 -1
  111. package/src/plugin/session-hook-env.ts +475 -0
  112. package/src/plugin/shell-hook-env.ts +335 -0
  113. package/src/plugin/shell-hook.ts +416 -24
  114. package/src/plugin/worktree-hook-answer.ts +142 -0
  115. package/src/public-runtime.ts +33 -0
  116. package/src/public-types.ts +20 -1
  117. package/src/runtime/query/executor.ts +12 -0
  118. package/src/runtime/query/index.ts +28 -0
  119. package/src/runtime/query/tooling.ts +19 -1
  120. package/src/session/workspace/hooked-driver.ts +272 -0
  121. package/src/session/workspace/index.ts +7 -0
  122. package/src/skills/index.ts +3 -0
  123. package/src/skills/loader.ts +47 -0
  124. package/src/tools/builtins/bash-cwd.ts +25 -1
  125. package/src/tools/builtins/bash.ts +1 -1
  126. package/src/tools/builtins/skill.ts +138 -27
  127. package/src/types/plugin/index.ts +84 -1
  128. package/src/types/session/records.ts +28 -0
  129. package/src/types/skills/index.ts +9 -0
  130. package/src/types/tool/index.ts +105 -0
  131. package/src/types/workspace/ref.ts +6 -0
  132. package/src/utils/frontmatter.ts +52 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
1
  # Changelog
2
2
 
3
+ ## 64.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a29a071: A skill's hooks can now be kept with the conversation. The `skill` tool asks its host (`SkillHooksPlan.resumable`) and writes a `skill_hooks_attached` record (new, `ignorable`, so older releases skip it and read the conversation unchanged) through `ToolContext.recordSkillHooks`; the model is told when it could not be written. New exported types: `SkillHooksRecordFact`, `SkillHooksAttachedRecord`. Nothing is required of you; a host that does not set `resumable` behaves as before.
8
+
9
+ ## 64.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 53e644a: Hooks gain two events and can set variables for later commands. `file_changed` fires once a watched file has been still for half a second (`filePath`, `change`: `add`, `change` or `unlink`); `cwd_changed` fires when the folder the shell tool's next command starts in changes (`oldCwd`, `newCwd`). Both are in `PluginHookEvent` and `SHELL_HOOK_EVENTS` (`FileChanged`, `CwdChanged` in the common shape); a hook answers with `hookSpecificOutput.watchPaths` (the files to watch from now on) and `systemMessage`, and cannot refuse anything. A command hook on `session_start`, `cwd_changed` or `file_changed` is started with `NAMZU_ENV_FILE`; with `ShellHookOptions.hookEnv` (a `SessionHookEnv`) its `export NAME=value` lines become the environment of later shell commands. New exports: `SessionHookEnv`, `FileChangeHooks`, `FileChangeWatcher`, `fileChangedMatches`, `fileChangedMatcherPaths`, `QueryParams.onWorkingDirectoryChange`, `ToolContext.workingDirectoryChanged`. Nothing is removed or changed by default. If you switch on a union of event names (`PluginHookEvent`, `ShellHookEvent`) with an exhaustive check, add the two new names. A `file_changed` hook that writes the file it watches runs once for the change that started it, not again every half second; a matcher naming a file in a folder not yet made is watched when the folder appears. A variable two hooks of one kind both set takes the value of the one later in the configuration. `__proto__`, `SHELL`, `PYTHONPATH`, `PYTHONHOME`, `RUBYLIB` and the programs Git runs on its own (`GIT_SSH`, `GIT_SSH_COMMAND`, `GIT_ASKPASS`, `GIT_PROXY_COMMAND`, `GIT_EXEC_PATH`, `GIT_EXTERNAL_DIFF`) are refused as hook variables: set `PATH` to reach another interpreter or tool instead. `SessionHookEnv.fileFor` and `absorb` take an optional slot (the hook's place in the configuration); callers that pass none behave as before.
14
+
15
+ A `file_changed` hook attached by anything is watched: `createShellHook` returns a definition with `watches` (the paths its matcher names), `PluginLifecycleManager.listHooks()` lists them, `PluginLifecycleManager.onHooksChanged(listener)` tells a host when hooks come or go, and `FileChangeHooks` follows them, so a hook a plugin ships or a skill carries is watched and fires like one in a config file. `NAMZU_ENV_FILE` joins the names an entry's `env` cannot replace, and an unset variable in a command whose name ends in `_ENV_FILE` is given the same file on the events that have one (`MOVED_FOLDER_ENDINGS` gains `_ENV_FILE`; `MovedFolder` gains `envFile`).
16
+
17
+ - f5be253: An agent file can carry a `hooks` key. Nothing is removed or renamed.
18
+
19
+ What you can now do:
20
+
21
+ - Write a `hooks` block in an agent file's front matter. The kernel keeps the block as text (`AgentFileDefinition.hooksSource`, read by the same raw-block option the skill reader uses) because it is a list of mappings, which the front matter reader cannot hold, and no other key is read differently. `hooks` joins `AGENT_FILE_KEYS`, so a host that checks agent files against that list no longer reports it as an unknown key.
22
+
23
+ What to do: if an agent file of yours already has a `hooks:` block written for another tool, it was ignored until now (or the file was refused, if its shape could not be read). A host that runs agent hooks (the CLI does) will run it for each run of the agent, so read it first. A host that does not read `hooksSource` is not affected.
24
+
25
+ - f5be253: A skill can carry hooks, and a host can take hooks off again. No exported name, key, field or default is removed or renamed. One behaviour changes for a skill that carries a `hooks:` block: a host that does not implement the new optional `SkillRegistryRef.prepareHooks` no longer applies that skill's `allowed-tools` pre-approval (it loads, with a line telling the model why); a skill without a `hooks:` block is read exactly as before.
26
+
27
+ What you can now do:
28
+
29
+ - Write a `hooks` key in a skill's `SKILL.md` front matter. The kernel keeps the block as text (`SkillMetadata.hooksSource`; `parseFrontmatter` takes a `raw` option and returns `rawBlocks`, and `SKILL_FRONTMATTER_RAW_KEYS` lists the keys read this way) because it is a list of mappings, which the front matter reader cannot hold, and no other key is read differently. `hooks` joins `SKILL_FRONTMATTER_KEYS`.
30
+ - Run a skill's hooks from your own host: the `skill` tool asks `SkillRegistryRef.prepareHooks` (new, optional) what to do about a skill that carries them. The answer says what to tell the model, whether the skill's `allowed-tools` pre-approval must be withheld (a guard that could not be loaded must not leave the skill running pre-approved), and `attach`, which the tool calls once the instructions are delivered, and for a `context: fork` skill around the delegated agent's run. A registry without `prepareHooks` loads a skill that carries hooks without its pre-approval and tells the model why.
31
+ - Attach hooks that can leave: `PluginLifecycleManager.attachHooks(pluginId, hooks)` returns a `HookAttachment` whose `remove` takes off exactly the hooks that call attached and `removeAt` one of them. Before, hooks left only by plugin id.
32
+ - Give every command of a `ShellHookOptions` adapter extra variables (`extraEnv`, which never replaces the kernel's own) and hear when a hook was selected to run (`onRun`).
33
+
34
+ What to do: if a skill of yours already has a `hooks:` block written for another tool, it was ignored until now. A host that runs skill hooks (the CLI does) will run it when the skill is used, so read it first. To keep the pre-approval on your own host, implement `prepareHooks` and return `withholdGrants: false`.
35
+
36
+ Also added: a hook event written at the top level of the front matter (`PreToolUse:` beside `name:`) is read as if it were under `hooks:` (`skillHooksSource`, `SKILL_FRONTMATTER_HOOK_EVENT_KEYS`; `SKILL_FRONTMATTER_RAW_KEYS` is unchanged); `SkillHooksOptions.prompt` carries a forked skill's delegated prompt so a host can bind the skill's hooks to the agent that received it; and the `skill` tool is an `executionBarrier`, so in one message the calls written before it finish first and the calls after it wait for it (their `pre_tool_use` hooks were still asked before the batch started, so a skill's `pre_tool_use` guard does not see a call written in the same message).
37
+
38
+ The rule by the shape of a variable name that serves a moved command also serves a skill's hooks: `ShellHookOptions.skillRoot` (new, optional) is the skill's folder, and an unset variable the command or its arguments refer to whose name ends in `_PLUGIN_ROOT` or `_SKILL_ROOT` is given it, under the name the command used. `_PLUGIN_DATA` is not given to a skill. `MovedFolder` gains `'skill'` and `MOVED_FOLDER_ENDINGS` gains `_SKILL_ROOT`; `movedFolderFor` is new.
39
+
40
+ - efcfde6: A hook command written for another tool now finds the project folder. When a shell hook's `command` or `args` refer to a variable (`$NAME` or `${NAME}`) that is not set and whose name ends in `_PROJECT_DIR`, the command is started with that variable set to the project folder, the value of `NAMZU_PROJECT_DIR`. A variable that is already set is never overwritten, and an entry that refers to no such variable starts with exactly the environment it had.
41
+
42
+ A command entry (`ShellHookEntry`) also takes `env`, a map of names to text, for a script that reads such a variable inside its own file. A value may use `$NAME` or `${NAME}` of a variable the hook already has, such as `${NAMZU_PROJECT_DIR}`. The variables Namzu sets for every hook cannot be replaced. When a hook cannot find its program and its command refers to a variable that is set nowhere, its failure reason (and the warning in the log) names the variable and the `env` key. New exports: `shellHookEnvProblems`, `shellHookEnvNameProblem`, `referencedVariables`, `MOVED_FOLDER_ENDINGS`, `SHELL_HOOK_RESERVED_ENV`, and `ShellHookOutcome.unsetVariables`. Nothing existing changes and nothing has to be done to upgrade; if you pass your own environment variable ending in `_PROJECT_DIR` through a hook, it is still never replaced.
43
+
44
+ - efcfde6: A plugin can ship hook entries (a command, an http address or a prompt), and a command started for one finds the plugin's own folder. Nothing existing changes and nothing has to be done to upgrade: a hook command in a config file that refers to a variable ending in `_PLUGIN_ROOT` or `_PLUGIN_DATA` keeps running exactly as it did.
45
+
46
+ For a host that embeds the kernel: `PluginLifecycleManagerConfig.hooksFor` is called when a plugin is enabled and returns the hooks the host read for it; they are registered under the plugin's id, so disabling, uninstalling or a failed enable removes them with the plugin's other hooks, and `listHooks()` marks them `shell: true` so a host can list them apart from the plugin's JavaScript hooks. The manifest gains `hookEntries`, an events object written inline (kept as written; the host reads it), and a path in the manifest's `hooks` that ends in `.json` is now a file of entries and is no longer imported as a module (`isHookEntriesPath`); `hooks` is still a list of paths. `parsePluginManifestText` also reads the two spellings the common hook contract uses, `"hooks": "<file>"` (one path) and `"hooks": { <events> }` (read as `hookEntries`); both used to be refused. `ShellHookOptions.plugin` (`{ root, dataDir }`) starts every command of those entries with `NAMZU_PLUGIN_ROOT` and `NAMZU_PLUGIN_DATA` and creates the data folder when a command first runs. A name ending in `_PLUGIN_ROOT` or `_PLUGIN_DATA` that the command refers to and nothing sets is exported with the folder, under that name, so the script the command starts reads it; a shell command expands it itself and an entry in the exec form (`args`) has the folder put into its command and arguments (`MOVED_FOLDER_ENDINGS`, `isPluginFolderVariable`, `PluginFolders`; `substitutePluginFolders` stays exported).
47
+
48
+ Smaller: the hook's shell is found on the host's own `PATH`, so an entry whose `env` sets `PATH` to something without `sh` still starts; the "refers to variables set nowhere" report skips loop and `read` variables and names a shell keeps for itself (new exports `assignedWithin` and `isShellOwnVariable`); in the exec form the project folder variable (`$X_PROJECT_DIR`) is put into the command and arguments as the plugin folders are.
49
+
50
+ - 53e644a: Hooks can take over making and removing worktrees. `worktree_create` (`WorktreeCreate`) fires before a worktree is made with `worktreeName`, `worktreeRoot` and `worktreeBaseRef`; a shell hook makes the folder and prints it as its last line (or answers `hookSpecificOutput.worktreePath`) and the host uses it instead of Git. `worktree_remove` (`WorktreeRemove`) fires with `worktreePath` and the hook does the removing. With hooks on `worktree_create`, a failure or a missing path fails the creation with the hook's own words and never falls back to Git. New exports: `HookedWorkspaceDriver` and `worktreeHookHost` (wrap any `WorkspaceBackendDriver` so the two events apply to it), `WorktreeHookError`, `worktreeHookVerdict`, and the types `WorkspaceBackendDriver`, `CreateWorkspaceParams`, `BranchWorkspaceParams`, `WorkspaceInspection`, `WorktreeHookHost`, `WorktreeHookContext`; `GitWorktreeBackendMeta.hookOwned` marks a folder a hook made (the Git driver never removes it). Both events are in `PluginHookEvent` and `SHELL_HOOK_EVENTS`; `PluginHookContext` gains `worktreeName`, `worktreeRoot`, `worktreeBaseRef`, `worktreePath` and `PluginHookNotes` gains `worktreePath`. Nothing is removed and no default changes: a host that registers `GitWorktreeDriver` as before behaves as before. If you switch on a union of event names with an exhaustive check, add the two new names.
51
+
3
52
  ## 64.0.0
4
53
 
5
54
  ### Major Changes
@@ -27,6 +27,10 @@
27
27
  * You review changes for this repository. Cite file:line for every finding …
28
28
  * ```
29
29
  *
30
+ * `hooks` is a block of hook entries in either shape a config file takes (see
31
+ * `AgentFileDefinition.hooksSource`); the kernel keeps its text and the host
32
+ * reads it.
33
+ *
30
34
  * `tools`, `disallowedTools` and `skills` are each one comma-separated line: this kernel's frontmatter reader
31
35
  * refuses block lists and flow sequences by design, so there is no other
32
36
  * form to accept.
@@ -79,6 +83,12 @@ export interface AgentFileDefinition {
79
83
  */
80
84
  readonly permissionMode?: string;
81
85
  readonly readOnly: boolean;
86
+ /**
87
+ * The text of the file's `hooks` key, as written (the key's own line and the
88
+ * lines under it), for the host to read with a YAML reader: the frontmatter
89
+ * reader here cannot hold a list of mappings. The kernel only keeps it.
90
+ */
91
+ readonly hooksSource?: string;
82
92
  readonly path: string;
83
93
  /** The host's label for the root this file came from (`user`, `project`, …). */
84
94
  readonly source: string;
@@ -1 +1 @@
1
- {"version":3,"file":"file-definitions.d.ts","sourceRoot":"","sources":["../../src/agents/file-definitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAKH,OAAO,KAAK,EAAE,eAAe,E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,GAAG,gBAAgB,CAAC,CAcjD;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,WAAW,CAAC,MAAM,CAAgC,EAC5D,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GACnC,mBAAmB,GAAG,gBAAgB,CA+IxC"}
@@ -27,6 +27,10 @@
27
27
  * You review changes for this repository. Cite file:line for every finding …
28
28
  * ```
29
29
  *
30
+ * `hooks` is a block of hook entries in either shape a config file takes (see
31
+ * `AgentFileDefinition.hooksSource`); the kernel keeps its text and the host
32
+ * reads it.
33
+ *
30
34
  * `tools`, `disallowedTools` and `skills` are each one comma-separated line: this kernel's frontmatter reader
31
35
  * refuses block lists and flow sequences by design, so there is no other
32
36
  * form to accept.
@@ -83,6 +87,7 @@ export const AGENT_FILE_KEYS = Object.freeze([
83
87
  'skills',
84
88
  'permissionMode',
85
89
  'readOnly',
90
+ 'hooks',
86
91
  ]);
87
92
  /**
88
93
  * Every `*.md` in every root, later roots shadowing earlier ones by name.
@@ -138,7 +143,7 @@ export function parseAgentMarkdown(raw, path, source, reserved = DEFAULT_RESERVE
138
143
  }
139
144
  let parsed;
140
145
  try {
141
- parsed = parseFrontmatter(raw, path);
146
+ parsed = parseFrontmatter(raw, path, { raw: ['hooks'] });
142
147
  }
143
148
  catch (error) {
144
149
  return {
@@ -146,7 +151,7 @@ export function parseAgentMarkdown(raw, path, source, reserved = DEFAULT_RESERVE
146
151
  reason: `frontmatter did not parse: ${error instanceof Error ? error.message : String(error)}`,
147
152
  };
148
153
  }
149
- const { values, body } = parsed;
154
+ const { values, body, rawBlocks } = parsed;
150
155
  const name = scalar(values.name);
151
156
  if (name === undefined)
152
157
  return { path, reason: 'has no `name:` in its frontmatter' };
@@ -246,6 +251,8 @@ export function parseAgentMarkdown(raw, path, source, reserved = DEFAULT_RESERVE
246
251
  }
247
252
  readOnly = flag === 'true';
248
253
  }
254
+ const hooksText = Object.hasOwn(rawBlocks, 'hooks') ? rawBlocks.hooks : undefined;
255
+ const hooksSource = hooksText !== undefined && hooksText.trim() !== '' ? hooksText : undefined;
249
256
  const trimmed = body.trim();
250
257
  if (trimmed.length === 0) {
251
258
  return { path, reason: "has an empty body; the body is the agent's system prompt" };
@@ -267,6 +274,7 @@ export function parseAgentMarkdown(raw, path, source, reserved = DEFAULT_RESERVE
267
274
  ...(preloaded.list ? { skills: preloaded.list } : {}),
268
275
  ...(permissionMode ? { permissionMode } : {}),
269
276
  readOnly,
277
+ ...(hooksSource !== undefined ? { hooksSource } : {}),
270
278
  path,
271
279
  source,
272
280
  };
@@ -1 +1 @@
1
- {"version":3,"file":"file-definitions.js","sourceRoot":"","sources":["../../src/agents/file-definitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAe,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAE/D,qDAAqD;AACrD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAE1C,iDAAiD;AACjD,MAAM,oBAAoB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AAE5C,kFAAkF;AAClF,MAAM,CAAC,MAAM,4BAA4B,GAAwB,IAAI,GAAG,CAAC;IACxE,iBAAiB;IACjB,SAAS;CACT,CAAC,CAAA;AAEF,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAkB;IACnE,MAAM;IACN,SAAS;IACT,KAAK;IACL,QAAQ;IACR,MAAM;IACN,O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AAS,CAAA;IAC7C,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;IAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACnF,MAAM,KAAK,GAAG,KAAK;SACjB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACnC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;AAC5C,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * `file_changed` events for a session: the watcher and what it fires.
3
+ *
4
+ * The files watched are the ones named in the matchers of the `file_changed`
5
+ * hooks the host attached, plus the list hooks have handed back with
6
+ * `hookSpecificOutput.watchPaths`. A new list from any hook of `session_start`,
7
+ * `file_changed` or `cwd_changed` replaces the one handed back before; the
8
+ * matcher paths stay. With neither, no watcher exists.
9
+ *
10
+ * A hook of `file_changed` cannot refuse anything and gives the model nothing:
11
+ * what it may answer is a line for the person (`systemMessage`, passed to
12
+ * `onNotice`) and the next list of paths.
13
+ */
14
+ import type { PluginHookResult } from '../types/plugin/index.js';
15
+ import { type FileChangeWatcherOptions } from './file-change-watch.js';
16
+ import type { PluginLifecycleManager } from './lifecycle.js';
17
+ export interface FileChangeHooksOptions {
18
+ readonly manager: Pick<PluginLifecycleManager, 'executeHooks'> & Partial<Pick<PluginLifecycleManager, 'listHooks' | 'onHooksChanged'>>;
19
+ /** Relative paths are under this folder. */
20
+ readonly cwd: string;
21
+ /** The session now; asked at each event, because a host's session can change. */
22
+ readonly sessionId: () => string;
23
+ /**
24
+ * Paths the `file_changed` matchers name, from the host's hook configuration.
25
+ * The matchers of hooks attached to the manager (a plugin's, a skill's, an
26
+ * agent file's) are read from it and added, now and whenever they change.
27
+ */
28
+ readonly matcherPaths: readonly string[];
29
+ /** A line a hook gave for the person. */
30
+ readonly onNotice?: (line: string) => void;
31
+ /** A watch that failed or was cut short, once per distinct sentence. */
32
+ readonly onProblem?: (line: string) => void;
33
+ /** Seams for tests. */
34
+ readonly watcher?: Pick<FileChangeWatcherOptions, 'settleMs' | 'maxPaths' | 'watchDirectory' | 'exists'>;
35
+ }
36
+ /** The paths a set of answers hand back: the union, or `undefined` when no answer carried the field. */
37
+ export declare function watchPathsOf(results: readonly PluginHookResult[]): readonly string[] | undefined;
38
+ export declare class FileChangeHooks {
39
+ private readonly options;
40
+ private handedBack;
41
+ private readonly watcher;
42
+ private closed;
43
+ private readonly stopListening;
44
+ constructor(options: FileChangeHooksOptions);
45
+ /** The files watched now, absolute. */
46
+ get watching(): readonly string[];
47
+ /** What the answers of a `session_start`, `file_changed` or `cwd_changed` run said: notices and a new list. */
48
+ absorb(results: readonly PluginHookResult[]): void;
49
+ close(): void;
50
+ private refresh;
51
+ private fire;
52
+ }
53
+ //# sourceMappingURL=file-change-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-change-hooks.d.ts","sourceRoot":"","sources":["../../src/plugin/file-change-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAqB,KAAK,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AACzF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAE5D,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,sB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 * `file_changed` events for a session: the watcher and what it fires.
3
+ *
4
+ * The files watched are the ones named in the matchers of the `file_changed`
5
+ * hooks the host attached, plus the list hooks have handed back with
6
+ * `hookSpecificOutput.watchPaths`. A new list from any hook of `session_start`,
7
+ * `file_changed` or `cwd_changed` replaces the one handed back before; the
8
+ * matcher paths stay. With neither, no watcher exists.
9
+ *
10
+ * A hook of `file_changed` cannot refuse anything and gives the model nothing:
11
+ * what it may answer is a line for the person (`systemMessage`, passed to
12
+ * `onNotice`) and the next list of paths.
13
+ */
14
+ import { FileChangeWatcher } from './file-change-watch.js';
15
+ /** The paths a set of answers hand back: the union, or `undefined` when no answer carried the field. */
16
+ export function watchPathsOf(results) {
17
+ let seen = false;
18
+ const paths = [];
19
+ for (const result of results) {
20
+ if (!('watchPaths' in result) || result.watchPaths === undefined)
21
+ continue;
22
+ seen = true;
23
+ for (const path of result.watchPaths)
24
+ if (!paths.includes(path))
25
+ paths.push(path);
26
+ }
27
+ return seen ? paths : undefined;
28
+ }
29
+ export class FileChangeHooks {
30
+ options;
31
+ handedBack = [];
32
+ watcher;
33
+ closed = false;
34
+ stopListening;
35
+ constructor(options) {
36
+ this.options = options;
37
+ this.watcher = new FileChangeWatcher({
38
+ ...options.watcher,
39
+ ...(options.onProblem ? { onProblem: options.onProblem } : {}),
40
+ onChange: (change) => {
41
+ void this.fire(change.path, change.change);
42
+ },
43
+ });
44
+ this.stopListening = options.manager.onHooksChanged?.(() => {
45
+ if (!this.closed)
46
+ this.refresh();
47
+ });
48
+ this.refresh();
49
+ }
50
+ /** The files watched now, absolute. */
51
+ get watching() {
52
+ return this.watcher.watching;
53
+ }
54
+ /** What the answers of a `session_start`, `file_changed` or `cwd_changed` run said: notices and a new list. */
55
+ absorb(results) {
56
+ if (this.closed)
57
+ return;
58
+ for (const result of results) {
59
+ const notice = 'notice' in result ? result.notice : undefined;
60
+ if (notice !== undefined && notice.trim() !== '')
61
+ this.options.onNotice?.(notice.trim());
62
+ }
63
+ const next = watchPathsOf(results);
64
+ if (next === undefined)
65
+ return;
66
+ this.handedBack = next;
67
+ this.refresh();
68
+ }
69
+ close() {
70
+ this.closed = true;
71
+ this.stopListening?.();
72
+ this.watcher.close();
73
+ }
74
+ refresh() {
75
+ const all = [...this.options.matcherPaths];
76
+ for (const hook of this.options.manager.listHooks?.() ?? []) {
77
+ if (hook.event !== 'file_changed')
78
+ continue;
79
+ for (const path of hook.watches ?? [])
80
+ if (!all.includes(path))
81
+ all.push(path);
82
+ }
83
+ for (const path of this.handedBack)
84
+ if (!all.includes(path))
85
+ all.push(path);
86
+ this.watcher.setPaths(all, this.options.cwd);
87
+ }
88
+ async fire(path, change) {
89
+ if (this.closed)
90
+ return;
91
+ // What the hook writes to this very file is not a new change: without
92
+ // this a hook that touches the file it watches would start itself again
93
+ // every half second for as long as the session lives.
94
+ this.watcher.hold(path);
95
+ try {
96
+ const results = await this.options.manager.executeHooks('file_changed', {
97
+ sessionId: this.options.sessionId(),
98
+ filePath: path,
99
+ change,
100
+ });
101
+ this.absorb(results);
102
+ }
103
+ catch (error) {
104
+ this.options.onProblem?.(`A file_changed hook could not run for ${path}: ${error instanceof Error ? error.message : String(error)}.`);
105
+ }
106
+ finally {
107
+ this.watcher.release(path);
108
+ }
109
+ }
110
+ }
111
+ //# sourceMappingURL=file-change-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-change-hooks.js","sourceRoot":"","sources":["../../src/plugin/file-change-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,iBAAiB,EAAiC,MAAM,wBAAwB,CAAA;AA2BzF,wGAAwG;AACxG,MAAM,UAAU,YAAY,CAAC,OAAoC;IAChE,IAAI,IAAI,GAAG,KAAK,CAAA;IAChB,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,CAAC,YAAY,IAAI,MAAM,CAAC,IAAI,MAAM,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,CAAC,IAAI,CAAC;gBAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC3E,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC7C,CAAC;IAEO,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,MAAmC;QACnE,IAAI,IAAI,CAAC,MAAM;YAAE,OAAM;QACvB,sEAAsE;QACtE,wEAAwE;QACxE,sDAAsD;QACtD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvB,IAAI,CAAC;YACJ,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,EAAE;gBACvE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAe;gBAChD,QAAQ,EAAE,IAAI;gBACd,MAAM;aACN,CAAC,CAAA;YACF,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CACvB,yCAAyC,IAAI,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAC3G,CAAA;QACF,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC3B,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Watching the files hooks asked about, and nothing else.
3
+ *
4
+ * A `file_changed` hook names the files it cares about in its matcher
5
+ * (`.envrc|package.json`), and may hand back more (`watchPaths`). This file
6
+ * turns those paths into events. No watcher exists until a path is given, and
7
+ * `setPaths([])` closes them all.
8
+ *
9
+ * ## How
10
+ *
11
+ * The platform's own `fs.watch`, on the folder that holds each file rather
12
+ * than on the file: an editor that saves by writing a new file and renaming
13
+ * it over the old one would leave a watch on the file pointing at a file that
14
+ * is gone, and a watch on a folder also sees a file appear and disappear.
15
+ * One watch serves every file in a folder.
16
+ *
17
+ * ## Settling
18
+ *
19
+ * What the platform reports is noisy: an editor's save is several events, and
20
+ * the names differ between systems. Every event for a watched file only
21
+ * restarts a timer; when the file has been still for `settleMs` (half a
22
+ * second) the file is looked at once, and the event is `add` (it did not exist
23
+ * and does now), `unlink` (it did and does not) or `change` (it exists, and
24
+ * did). A file that did not exist before and does not now is no event.
25
+ *
26
+ * ## Limits
27
+ *
28
+ * At most {@link MAX_WATCHED_PATHS} files are watched. A longer list is cut
29
+ * (the first ones are kept, in the order given) and the cut is reported once.
30
+ * A watch that cannot be started or breaks (the folder does not exist, no
31
+ * permission, the system's watch limit) is reported once for that folder and
32
+ * the others carry on; the watch is not retried until the list is set again.
33
+ * Watches never keep the process alive.
34
+ */
35
+ import type { PluginFileChange } from '../types/plugin/index.js';
36
+ /** The most files watched at once, matcher paths and handed-back paths together. */
37
+ export declare const MAX_WATCHED_PATHS = 64;
38
+ /** How long a file must be still before its change is reported, in milliseconds. */
39
+ export declare const FILE_SETTLE_MS = 500;
40
+ export interface FileChange {
41
+ readonly path: string;
42
+ readonly change: PluginFileChange;
43
+ }
44
+ /** The platform's folder watch, as far as this file uses it. */
45
+ export type WatchDirectory = (directory: string, listener: (name: string | null) => void, onError: (error: Error) => void) => {
46
+ close(): void;
47
+ };
48
+ export interface FileChangeWatcherOptions {
49
+ readonly onChange: (change: FileChange) => void;
50
+ /** Called once for each distinct problem, in a sentence. */
51
+ readonly onProblem?: (message: string) => void;
52
+ readonly settleMs?: number;
53
+ readonly maxPaths?: number;
54
+ /** A seam for tests; default `fs.watch`, not persistent. */
55
+ readonly watchDirectory?: WatchDirectory;
56
+ /** A seam for tests; default a `stat`. */
57
+ readonly exists?: (path: string) => boolean;
58
+ /**
59
+ * A seam for tests: a string that differs whenever the file's content or
60
+ * identity does (default a `stat`'s inode, size and modification time;
61
+ * `'absent'` when the file is not there).
62
+ */
63
+ readonly signature?: (path: string) => string;
64
+ }
65
+ export declare class FileChangeWatcher {
66
+ private readonly options;
67
+ private readonly files;
68
+ private readonly folders;
69
+ private readonly failed;
70
+ /** Folders that did not exist when asked for, each with a watch on the nearest folder that does. */
71
+ private readonly waiting;
72
+ private readonly reported;
73
+ private closed;
74
+ constructor(options: FileChangeWatcherOptions);
75
+ /** The files watched now, absolute. */
76
+ get watching(): readonly string[];
77
+ /**
78
+ * Watch exactly these files from now on. A relative path is under `base`.
79
+ * A file already watched keeps its state; one no longer named is let go.
80
+ */
81
+ setPaths(paths: readonly string[], base: string): void;
82
+ /**
83
+ * A hook run for `path` begins: what it writes to that file is its own, not
84
+ * a change to report. Paired with {@link release}.
85
+ */
86
+ hold(path: string): void;
87
+ /**
88
+ * The hook run for `path` ended. The file as it is now is what that run
89
+ * left, so a settle that finds it unchanged is the run's own write and
90
+ * reports nothing; a change by anyone after this moment is reported.
91
+ */
92
+ release(path: string): void;
93
+ private defaultSignatureFor;
94
+ close(): void;
95
+ private report;
96
+ private start;
97
+ /**
98
+ * A folder that does not exist yet: watch the nearest one that does, and
99
+ * try the folder again whenever something happens there. When the folder
100
+ * appears its files are looked at, so a file made right after it is seen.
101
+ */
102
+ private waitFor;
103
+ private stopWaiting;
104
+ private retry;
105
+ private drop;
106
+ /** An event in `folder`: for one name, or for every file in it when the system gave no name. */
107
+ private touched;
108
+ private schedule;
109
+ private settle;
110
+ }
111
+ //# sourceMappingURL=file-change-watch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-change-watch.d.ts","sourceRoot":"","sources":["../../src/plugin/file-change-watch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAEhE,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,K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