@llblab/pi-actors 0.45.0 → 0.46.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 (211) hide show
  1. package/AGENTS.md +10 -6
  2. package/CHANGELOG.md +14 -1
  3. package/README.md +28 -12
  4. package/dist/fixtures/protocol/recipe-summary.json +1 -1
  5. package/dist/index.d.ts +1 -2
  6. package/dist/index.js +10 -110
  7. package/dist/lib/async-runs.d.ts +4 -1
  8. package/dist/lib/async-runs.js +22 -23
  9. package/dist/lib/automatic-review-runtime.d.ts +2 -0
  10. package/dist/lib/automatic-review-runtime.js +12 -5
  11. package/dist/lib/draft-sleep.js +0 -1
  12. package/dist/lib/extension-runtime.d.ts +21 -0
  13. package/dist/lib/extension-runtime.js +122 -0
  14. package/dist/lib/inspector.js +45 -7
  15. package/dist/lib/paths.d.ts +0 -1
  16. package/dist/lib/paths.js +0 -7
  17. package/dist/lib/prompts.d.ts +1 -1
  18. package/dist/lib/prompts.js +2 -2
  19. package/dist/lib/recipes-context.js +2 -2
  20. package/dist/lib/recipes-references.d.ts +24 -9
  21. package/dist/lib/recipes-references.js +152 -126
  22. package/dist/lib/runtime.d.ts +0 -1
  23. package/dist/lib/runtime.js +1 -3
  24. package/dist/lib/tools-inspect.d.ts +0 -1
  25. package/dist/lib/tools-inspect.js +35 -8
  26. package/dist/lib/tools-local.d.ts +2 -0
  27. package/dist/lib/tools-local.js +1 -1
  28. package/dist/lib/tools-spawn.d.ts +2 -0
  29. package/dist/lib/tools-spawn.js +24 -52
  30. package/dist/scripts/async-runner.mjs +0 -16
  31. package/dist/scripts/build-dist.mjs +13 -4
  32. package/dist/skills/actors/SKILL.md +6 -6
  33. package/dist/skills/actors/recipes/recipe-validate.json +11 -0
  34. package/{recipes/utility-coordinator-lock-snapshot.json → dist/skills/actors/recipes/resource-locker-snapshot.json} +1 -3
  35. package/dist/{recipes → skills/actors/recipes}/resource-locker.json +1 -3
  36. package/dist/{recipes/utility-run-ops-snapshot.json → skills/actors/recipes/run-ops-snapshot.json} +1 -3
  37. package/dist/skills/actors/recipes/run-summary.json +9 -0
  38. package/dist/{scripts/locker.mjs → skills/actors/scripts/resource-locker.mjs} +2 -23
  39. package/dist/skills/actors/scripts/run-utils.mjs +164 -0
  40. package/{scripts → dist/skills/actors/scripts}/validate-recipe.mjs +134 -18
  41. package/dist/skills/artifacts/SKILL.md +16 -0
  42. package/{recipes/pipeline-artifact-bundle.json → dist/skills/artifacts/recipes/bundle.json} +4 -4
  43. package/dist/{recipes/utility-artifact-write.json → skills/artifacts/recipes/file-write.json} +1 -3
  44. package/dist/{recipes/utility-artifact-manifest.json → skills/artifacts/recipes/manifest.json} +1 -3
  45. package/{recipes/pipeline-artifact-report.json → dist/skills/artifacts/recipes/report.json} +2 -2
  46. package/dist/{recipes/pipeline-artifact-write.json → skills/artifacts/recipes/write.json} +3 -3
  47. package/dist/skills/artifacts/scripts/artifact-utils.mjs +63 -0
  48. package/dist/skills/media/SKILL.md +16 -0
  49. package/dist/{recipes/pipeline-media-library.json → skills/media/recipes/library.json} +2 -2
  50. package/{recipes/music-player.json → dist/skills/media/recipes/player.json} +1 -3
  51. package/dist/{recipes/utility-playlist-build.json → skills/media/recipes/playlist-build.json} +1 -3
  52. package/dist/skills/media/scripts/media-utils.mjs +47 -0
  53. package/dist/{scripts → skills/media/scripts}/music-player.mjs +9 -3
  54. package/dist/skills/project-work/SKILL.md +16 -0
  55. package/dist/skills/project-work/recipes/changelog-section.json +11 -0
  56. package/{recipes/pipeline-docs-maintenance.json → dist/skills/project-work/recipes/docs-maintenance.json} +4 -4
  57. package/dist/skills/project-work/recipes/package-summary.json +9 -0
  58. package/{recipes/pipeline-release-readiness.json → dist/skills/project-work/recipes/release-readiness.json} +6 -6
  59. package/dist/{recipes/pipeline-release-summary.json → skills/project-work/recipes/release-summary.json} +5 -5
  60. package/{recipes/pipeline-repo-health.json → dist/skills/project-work/recipes/repo-health.json} +6 -6
  61. package/{recipes/pipeline-async-run-ops.json → dist/skills/project-work/recipes/run-ops.json} +3 -3
  62. package/dist/skills/project-work/recipes/skill-summary.json +11 -0
  63. package/dist/skills/project-work/scripts/project-utils.mjs +89 -0
  64. package/dist/skills/recipe-memory/SKILL.md +16 -0
  65. package/dist/skills/swarm/SKILL.md +4 -4
  66. package/{recipes/pipeline-architect-coordinator.json → dist/skills/swarm/recipes/architect.json} +5 -5
  67. package/{recipes/pipeline-checkpoint-continuation.json → dist/skills/swarm/recipes/checkpoint-continuation.json} +3 -3
  68. package/dist/{recipes/pipeline-development-tasking.json → skills/swarm/recipes/development-tasking.json} +4 -4
  69. package/dist/{recipes/lens-swarm.json → skills/swarm/recipes/lens-review.json} +1 -1
  70. package/dist/{recipes/pipeline-quorum-review.json → skills/swarm/recipes/quorum-review.json} +4 -4
  71. package/{recipes/pipeline-research-synthesis.json → dist/skills/swarm/recipes/research-synthesis.json} +6 -6
  72. package/{recipes/pipeline-review-readiness.json → dist/skills/swarm/recipes/review-readiness.json} +1 -1
  73. package/{recipes/subagents-prompts.json → dist/skills/swarm/recipes/subagent-prompts.json} +1 -1
  74. package/{recipes → dist/skills/swarm/recipes}/subagent-quorum.json +1 -1
  75. package/dist/{recipes → skills/swarm/recipes}/subagent-review-coordinator.json +6 -6
  76. package/docs/actor-inspector.md +4 -3
  77. package/docs/async-runs.md +2 -2
  78. package/docs/recipe-library.md +23 -23
  79. package/docs/releasing.md +2 -2
  80. package/docs/template-recipes.md +30 -14
  81. package/docs/tool-registry.md +2 -2
  82. package/fixtures/protocol/recipe-summary.json +1 -1
  83. package/index.ts +18 -112
  84. package/lib/async-runs.ts +47 -24
  85. package/lib/automatic-review-runtime.ts +16 -3
  86. package/lib/draft-sleep.ts +0 -1
  87. package/lib/extension-runtime.ts +158 -0
  88. package/lib/inspector.ts +56 -11
  89. package/lib/paths.ts +0 -7
  90. package/lib/prompts.ts +2 -2
  91. package/lib/recipes-context.ts +2 -2
  92. package/lib/recipes-references.ts +223 -134
  93. package/lib/runtime.ts +1 -5
  94. package/lib/tools-inspect.ts +42 -9
  95. package/lib/tools-local.ts +2 -0
  96. package/lib/tools-spawn.ts +37 -74
  97. package/package.json +3 -5
  98. package/scripts/async-runner.mjs +0 -16
  99. package/scripts/build-dist.mjs +13 -4
  100. package/skills/actors/SKILL.md +6 -6
  101. package/skills/actors/recipes/recipe-validate.json +11 -0
  102. package/{dist/recipes/utility-coordinator-lock-snapshot.json → skills/actors/recipes/resource-locker-snapshot.json} +1 -3
  103. package/{recipes → skills/actors/recipes}/resource-locker.json +1 -3
  104. package/{recipes/utility-run-ops-snapshot.json → skills/actors/recipes/run-ops-snapshot.json} +1 -3
  105. package/skills/actors/recipes/run-summary.json +9 -0
  106. package/{scripts/locker.mjs → skills/actors/scripts/resource-locker.mjs} +2 -23
  107. package/skills/actors/scripts/run-utils.mjs +164 -0
  108. package/{dist → skills/actors}/scripts/validate-recipe.mjs +134 -18
  109. package/skills/artifacts/SKILL.md +16 -0
  110. package/{dist/recipes/pipeline-artifact-bundle.json → skills/artifacts/recipes/bundle.json} +4 -4
  111. package/{recipes/utility-artifact-write.json → skills/artifacts/recipes/file-write.json} +1 -3
  112. package/{recipes/utility-artifact-manifest.json → skills/artifacts/recipes/manifest.json} +1 -3
  113. package/{dist/recipes/pipeline-artifact-report.json → skills/artifacts/recipes/report.json} +2 -2
  114. package/{recipes/pipeline-artifact-write.json → skills/artifacts/recipes/write.json} +3 -3
  115. package/skills/artifacts/scripts/artifact-utils.mjs +63 -0
  116. package/skills/media/SKILL.md +16 -0
  117. package/{recipes/pipeline-media-library.json → skills/media/recipes/library.json} +2 -2
  118. package/{dist/recipes/music-player.json → skills/media/recipes/player.json} +1 -3
  119. package/{recipes/utility-playlist-build.json → skills/media/recipes/playlist-build.json} +1 -3
  120. package/skills/media/scripts/media-utils.mjs +47 -0
  121. package/{scripts → skills/media/scripts}/music-player.mjs +9 -3
  122. package/skills/project-work/SKILL.md +16 -0
  123. package/skills/project-work/recipes/changelog-section.json +11 -0
  124. package/{dist/recipes/pipeline-docs-maintenance.json → skills/project-work/recipes/docs-maintenance.json} +4 -4
  125. package/skills/project-work/recipes/package-summary.json +9 -0
  126. package/{dist/recipes/pipeline-release-readiness.json → skills/project-work/recipes/release-readiness.json} +6 -6
  127. package/{recipes/pipeline-release-summary.json → skills/project-work/recipes/release-summary.json} +5 -5
  128. package/{dist/recipes/pipeline-repo-health.json → skills/project-work/recipes/repo-health.json} +6 -6
  129. package/{dist/recipes/pipeline-async-run-ops.json → skills/project-work/recipes/run-ops.json} +3 -3
  130. package/skills/project-work/recipes/skill-summary.json +11 -0
  131. package/skills/project-work/scripts/project-utils.mjs +89 -0
  132. package/skills/recipe-memory/SKILL.md +16 -0
  133. package/skills/swarm/SKILL.md +4 -4
  134. package/{dist/recipes/pipeline-architect-coordinator.json → skills/swarm/recipes/architect.json} +5 -5
  135. package/{dist/recipes/pipeline-checkpoint-continuation.json → skills/swarm/recipes/checkpoint-continuation.json} +3 -3
  136. package/{recipes/pipeline-development-tasking.json → skills/swarm/recipes/development-tasking.json} +4 -4
  137. package/{recipes/lens-swarm.json → skills/swarm/recipes/lens-review.json} +1 -1
  138. package/{recipes/pipeline-quorum-review.json → skills/swarm/recipes/quorum-review.json} +4 -4
  139. package/{dist/recipes/pipeline-research-synthesis.json → skills/swarm/recipes/research-synthesis.json} +6 -6
  140. package/{dist/recipes/pipeline-review-readiness.json → skills/swarm/recipes/review-readiness.json} +1 -1
  141. package/{dist/recipes/subagents-prompts.json → skills/swarm/recipes/subagent-prompts.json} +1 -1
  142. package/{dist → skills/swarm}/recipes/subagent-quorum.json +1 -1
  143. package/{recipes → skills/swarm/recipes}/subagent-review-coordinator.json +6 -6
  144. package/dist/recipes/utility-changelog-section.json +0 -13
  145. package/dist/recipes/utility-package-summary.json +0 -11
  146. package/dist/recipes/utility-run-summary.json +0 -11
  147. package/dist/recipes/utility-skill-summary.json +0 -13
  148. package/dist/recipes/utility-validate-recipe.json +0 -13
  149. package/dist/scripts/recipe-utils.mjs +0 -405
  150. package/dist/scripts/release-gates.mjs +0 -278
  151. package/recipes/utility-changelog-section.json +0 -13
  152. package/recipes/utility-package-summary.json +0 -11
  153. package/recipes/utility-run-summary.json +0 -11
  154. package/recipes/utility-skill-summary.json +0 -13
  155. package/recipes/utility-validate-recipe.json +0 -13
  156. package/scripts/recipe-utils.mjs +0 -405
  157. package/scripts/release-gates.mjs +0 -278
  158. /package/dist/{recipes/utility-validation-wrapper.json → skills/actors/recipes/command-validate.json} +0 -0
  159. /package/dist/{recipes/utility-jsonl-tail.json → skills/actors/recipes/jsonl-tail.json} +0 -0
  160. /package/dist/{recipes/utility-run-state-files.json → skills/actors/recipes/run-state-files.json} +0 -0
  161. /package/dist/{recipes/utility-playlist-scan.json → skills/media/recipes/playlist-scan.json} +0 -0
  162. /package/dist/{recipes/utility-changelog-head.json → skills/project-work/recipes/changelog-head.json} +0 -0
  163. /package/dist/{recipes/utility-git-log.json → skills/project-work/recipes/git-log.json} +0 -0
  164. /package/dist/{recipes/utility-git-status.json → skills/project-work/recipes/git-status.json} +0 -0
  165. /package/dist/{recipes/utility-markdown-index.json → skills/project-work/recipes/markdown-index.json} +0 -0
  166. /package/dist/{recipes → skills/recipe-memory/recipes}/draft-review.json +0 -0
  167. /package/dist/{recipes → skills/recipe-memory/recipes}/tool-review.json +0 -0
  168. /package/dist/{recipes → skills/swarm/recipes}/subagent-artifact.json +0 -0
  169. /package/dist/{recipes → skills/swarm/recipes}/subagent-checkpoint.json +0 -0
  170. /package/dist/{recipes → skills/swarm/recipes}/subagent-conflict-report.json +0 -0
  171. /package/dist/{recipes → skills/swarm/recipes}/subagent-contradiction-map.json +0 -0
  172. /package/dist/{recipes → skills/swarm/recipes}/subagent-critic.json +0 -0
  173. /package/dist/{recipes → skills/swarm/recipes}/subagent-evidence-map.json +0 -0
  174. /package/dist/{recipes → skills/swarm/recipes}/subagent-followup.json +0 -0
  175. /package/dist/{recipes → skills/swarm/recipes}/subagent-judge.json +0 -0
  176. /package/dist/{recipes → skills/swarm/recipes}/subagent-merge.json +0 -0
  177. /package/dist/{recipes → skills/swarm/recipes}/subagent-normalize.json +0 -0
  178. /package/dist/{recipes → skills/swarm/recipes}/subagent-plan.json +0 -0
  179. /package/dist/{recipes → skills/swarm/recipes}/subagent-preflight.json +0 -0
  180. /package/dist/{recipes → skills/swarm/recipes}/subagent-prompt.json +0 -0
  181. /package/dist/{recipes → skills/swarm/recipes}/subagent-review.json +0 -0
  182. /package/dist/{recipes → skills/swarm/recipes}/subagent-task-card.json +0 -0
  183. /package/dist/{recipes → skills/swarm/recipes}/subagent-tools.json +0 -0
  184. /package/dist/{recipes → skills/swarm/recipes}/subagent-verify.json +0 -0
  185. /package/{recipes/utility-validation-wrapper.json → skills/actors/recipes/command-validate.json} +0 -0
  186. /package/{recipes/utility-jsonl-tail.json → skills/actors/recipes/jsonl-tail.json} +0 -0
  187. /package/{recipes/utility-run-state-files.json → skills/actors/recipes/run-state-files.json} +0 -0
  188. /package/{recipes/utility-playlist-scan.json → skills/media/recipes/playlist-scan.json} +0 -0
  189. /package/{recipes/utility-changelog-head.json → skills/project-work/recipes/changelog-head.json} +0 -0
  190. /package/{recipes/utility-git-log.json → skills/project-work/recipes/git-log.json} +0 -0
  191. /package/{recipes/utility-git-status.json → skills/project-work/recipes/git-status.json} +0 -0
  192. /package/{recipes/utility-markdown-index.json → skills/project-work/recipes/markdown-index.json} +0 -0
  193. /package/{recipes → skills/recipe-memory/recipes}/draft-review.json +0 -0
  194. /package/{recipes → skills/recipe-memory/recipes}/tool-review.json +0 -0
  195. /package/{recipes → skills/swarm/recipes}/subagent-artifact.json +0 -0
  196. /package/{recipes → skills/swarm/recipes}/subagent-checkpoint.json +0 -0
  197. /package/{recipes → skills/swarm/recipes}/subagent-conflict-report.json +0 -0
  198. /package/{recipes → skills/swarm/recipes}/subagent-contradiction-map.json +0 -0
  199. /package/{recipes → skills/swarm/recipes}/subagent-critic.json +0 -0
  200. /package/{recipes → skills/swarm/recipes}/subagent-evidence-map.json +0 -0
  201. /package/{recipes → skills/swarm/recipes}/subagent-followup.json +0 -0
  202. /package/{recipes → skills/swarm/recipes}/subagent-judge.json +0 -0
  203. /package/{recipes → skills/swarm/recipes}/subagent-merge.json +0 -0
  204. /package/{recipes → skills/swarm/recipes}/subagent-normalize.json +0 -0
  205. /package/{recipes → skills/swarm/recipes}/subagent-plan.json +0 -0
  206. /package/{recipes → skills/swarm/recipes}/subagent-preflight.json +0 -0
  207. /package/{recipes → skills/swarm/recipes}/subagent-prompt.json +0 -0
  208. /package/{recipes → skills/swarm/recipes}/subagent-review.json +0 -0
  209. /package/{recipes → skills/swarm/recipes}/subagent-task-card.json +0 -0
  210. /package/{recipes → skills/swarm/recipes}/subagent-tools.json +0 -0
  211. /package/{recipes → skills/swarm/recipes}/subagent-verify.json +0 -0
package/lib/inspector.ts CHANGED
@@ -102,17 +102,51 @@ export function readActorInspectorRecipe(
102
102
  !Array.isArray(primary.recipe)
103
103
  ? (primary.recipe as Record<string, unknown>)
104
104
  : undefined;
105
- const redactedRecord = (value: Record<string, unknown>): Record<string, unknown> =>
106
- SessionEvidence.redactSessionEvidenceValue(
107
- Object.fromEntries(
108
- Object.entries(value).filter(
105
+ const stripPrivateOrigins = (value: unknown): unknown => {
106
+ if (Array.isArray(value)) return value.map(stripPrivateOrigins);
107
+ if (!value || typeof value !== "object") return value;
108
+ return Object.fromEntries(
109
+ Object.entries(value as Record<string, unknown>)
110
+ .filter(
109
111
  ([key, entry]) =>
110
112
  entry !== undefined &&
111
113
  key !== "recipe_dir" &&
112
- key !== "skill_dir",
113
- ),
114
- ),
114
+ key !== "skill_dir" &&
115
+ key !== "source_file",
116
+ )
117
+ .map(([key, entry]) => [
118
+ key,
119
+ key === "actorRecipeContext" && entry && typeof entry === "object"
120
+ ? stripPrivateOrigins(
121
+ Object.fromEntries(
122
+ Object.entries(entry as Record<string, unknown>).filter(
123
+ ([contextKey]) => contextKey !== "file",
124
+ ),
125
+ ),
126
+ )
127
+ : stripPrivateOrigins(entry),
128
+ ]),
129
+ );
130
+ };
131
+ const redactedRecord = (value: Record<string, unknown>): Record<string, unknown> =>
132
+ SessionEvidence.redactSessionEvidenceValue(
133
+ stripPrivateOrigins(value),
115
134
  ) as Record<string, unknown>;
135
+ const primarySourceKind =
136
+ primary?.source_kind === "active_skill_component"
137
+ ? "active_skill_component"
138
+ : primary?.source_kind === "user_registry_capability" ||
139
+ meta.launch_source === "tool"
140
+ ? "user_registry_capability"
141
+ : "explicit_file_recipe";
142
+ const primaryLogicalReference =
143
+ typeof primary?.logical_reference === "string"
144
+ ? primary.logical_reference
145
+ : typeof primary?.name === "string"
146
+ ? primary.name
147
+ : typeof meta.recipe === "string"
148
+ ? meta.recipe
149
+ : "unknown";
116
150
  const launchValues =
117
151
  meta.values && typeof meta.values === "object" && !Array.isArray(meta.values)
118
152
  ? Object.fromEntries(
@@ -126,10 +160,18 @@ export function readActorInspectorRecipe(
126
160
  redactedRecord({
127
161
  ...(typeof entry.alias === "string" ? { alias: entry.alias } : {}),
128
162
  depth: entry.depth,
129
- file: entry.file,
130
163
  import_path: entry.import_path,
131
- name: entry.name,
132
- qualified_name: entry.qualified_name,
164
+ logical_reference: entry.logical_reference ?? entry.name,
165
+ recipe_stem: entry.name,
166
+ role: entry.role,
167
+ ...(typeof entry.skill === "string" ? { skill: entry.skill } : {}),
168
+ source_kind:
169
+ entry.source_kind === "active_skill_component"
170
+ ? "active_skill_component"
171
+ : entry.source_kind === "user_registry_capability" ||
172
+ (entry.depth === 0 && meta.launch_source === "tool")
173
+ ? "user_registry_capability"
174
+ : "explicit_file_recipe",
133
175
  }),
134
176
  ),
135
177
  ...(definition ? { definition: redactedRecord(definition) } : {}),
@@ -137,7 +179,10 @@ export function readActorInspectorRecipe(
137
179
  identity: redactedRecord({
138
180
  run: meta.run,
139
181
  recipe: meta.recipe,
140
- recipe_file: meta.recipe_file,
182
+ recipe_stem: primary?.name ?? meta.recipe,
183
+ logical_reference: primaryLogicalReference,
184
+ ...(typeof primary?.skill === "string" ? { skill: primary.skill } : {}),
185
+ source_kind: primarySourceKind,
141
186
  launch_source: meta.launch_source,
142
187
  }),
143
188
  launch: redactedRecord({
package/lib/paths.ts CHANGED
@@ -109,10 +109,3 @@ export function getRecipeRoot(agentDir = getAgentDir()): string {
109
109
  export function getRecipeDraftRoot(agentDir = getAgentDir()): string {
110
110
  return join(getRecipeRoot(agentDir), "drafts");
111
111
  }
112
-
113
- export function getPackagedRecipeRoot(): string {
114
- const here = dirname(fileURLToPath(import.meta.url));
115
- const compiledRoot = resolve(here, "..", "..", "recipes");
116
- if (existsSync(compiledRoot)) return compiledRoot;
117
- return resolve(here, "..", "recipes");
118
- }
package/lib/prompts.ts CHANGED
@@ -30,8 +30,8 @@ export const ONBOARDING_SYSTEM_PROMPT = `pi-actors quick model:
30
30
  - Actor-mode trigger: if work may outlive this turn, need steering/follow-up/artifacts, run as a service, fan out, or be resumed/inspected later, use spawn -> message -> inspect instead of ad hoc shell backgrounding.
31
31
  - Use spawn/message/inspect for actor-level start/send/observe; short foreground checks can stay ordinary tools/templates; avoid internal transport vocabulary in public guidance.
32
32
  - Run state lives under ~/.pi/agent/tmp/pi-actors/runs. Inspect intentionally and avoid busy-polling. Terminal and coordinator-bound notifications queue as Pi follow-ups so concurrently completed actors can reach the coordinator after current work instead of steering between tool calls. Terminal follow-up content stays minimal: run, status, one base path, and relative artifact names only; semantic output stays in non-LLM details and run state. When a deferred actor result gates the next step, wait for its terminal follow-up; do not schedule continuation loops, repeatedly inspect, or mutate its reviewed scope while it runs. Inspect early only for an operator request, a meaningful actor event, or diagnosis of an overdue/stuck run.
33
- - Maintain ~/.pi/agent/recipes like MEMORY.md for capabilities: keep useful tools, curate stale ones, and fix/remove/disable invalid recipes flagged by registry warnings; packaged/ad hoc recipes are lower-priority components; offer to save successful recurring patterns only after confirmation.
34
- - Prefer maintained packaged recipes/pipelines with spawn file=<recipe> before ad hoc scripts/wrappers; review swarms inherit current model/thinking, preflight before fanout, and expose quorum/concurrency/TTL knobs unless explicit args are passed.
33
+ - Maintain ~/.pi/agent/recipes like MEMORY.md for capabilities: keep useful tools, curate stale ones, and fix/remove/disable invalid recipes flagged by registry warnings; active-Skill and explicit file Recipes remain components outside user tool discovery; offer to save successful recurring patterns only after confirmation.
34
+ - Prefer maintained active-Skill Recipes with spawn recipe=<skill>/<recipe> before ad hoc scripts/wrappers; explicit file Recipes use exact .json/.md paths; review swarms inherit current model/thinking, preflight before fanout, and expose quorum/concurrency/TTL knobs unless explicit args are passed.
35
35
  - For any non-trivial actor use or pi-actors change, read the bundled actors skill first. Before launching multiple actors/subagents for parallel implementation, independent artifact generation, delegated audit, or review, also read the bundled swarm skill; the coordinator owns decomposition, disjoint scopes, launch correctness, integration, and final validation. For deeper guidance, inspect installed extension sources/docs/recipes because README/docs are not automatically in context.`;
36
36
 
37
37
  export const REGISTER_TOOL_PARAM_DESCRIPTIONS = {
@@ -96,7 +96,7 @@ function matchesActorContext(
96
96
  context: CommandTemplateActorRecipeContext | undefined,
97
97
  ): boolean {
98
98
  if (!context) return record.role === "entry";
99
- if (context.file && context.file === record.file) return true;
99
+ if (context.file && context.file === record.source_file) return true;
100
100
  if (context.name && context.name === record.name) return true;
101
101
  if (context.alias && context.alias === record.alias) return true;
102
102
  return false;
@@ -131,7 +131,7 @@ export function formatRecipeContextJsonl(
131
131
  context?: CommandTemplateActorRecipeContext,
132
132
  ): string {
133
133
  return markRecipeContextRecords(records, context)
134
- .map((record) => JSON.stringify(record))
134
+ .map(({ source_file: _sourceFile, ...record }) => JSON.stringify(record))
135
135
  .join("\n");
136
136
  }
137
137
 
@@ -4,9 +4,8 @@
4
4
  * Owns detection, loading, and recipe-layer expansion for template recipe files
5
5
  */
6
6
 
7
- import { existsSync, readFileSync, statSync } from "node:fs";
8
- import { homedir } from "node:os";
9
- import { basename, dirname, extname, isAbsolute, relative, resolve } from "node:path";
7
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
8
+ import { basename, dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
10
9
 
11
10
  import type {
12
11
  CommandTemplateConfig,
@@ -29,7 +28,6 @@ export interface TemplateRecipeImportBinding {
29
28
  export type TemplateRecipeImport = string | TemplateRecipeImportBinding;
30
29
 
31
30
  export interface TemplateRecipeDefinition {
32
- name?: string;
33
31
  description?: string;
34
32
  disabled?: boolean;
35
33
  imports?: Record<string, TemplateRecipeImport>;
@@ -57,6 +55,7 @@ export interface TemplateRecipeDefinition {
57
55
  }
58
56
 
59
57
  export interface TemplateRecipeConfig extends TemplateRecipeDefinition {
58
+ name?: string;
60
59
  async?: boolean;
61
60
  recipe_dir?: string;
62
61
  skill_dir?: string;
@@ -66,7 +65,7 @@ interface ImportedRecipe {
66
65
  alias: string;
67
66
  file: string;
68
67
  name: string;
69
- config: TemplateRecipeDefinition;
68
+ config: TemplateRecipeConfig;
70
69
  defaults: Record<string, unknown>;
71
70
  values: Record<string, unknown>;
72
71
  }
@@ -74,20 +73,25 @@ interface ImportedRecipe {
74
73
  export interface TemplateRecipeContextRecord {
75
74
  alias?: string;
76
75
  depth: number;
77
- file: string;
78
76
  import_path: string[];
77
+ logical_reference: string;
79
78
  name: string;
80
- qualified_name?: string;
81
79
  recipe: Record<string, unknown>;
82
80
  role: "entry" | "import";
81
+ skill?: string;
82
+ source_file: string;
83
+ source_kind:
84
+ | "active_skill_component"
85
+ | "explicit_file_recipe"
86
+ | "user_registry_capability";
83
87
  }
84
88
 
85
89
  export interface ReadResolvedRecipeConfigOptions {
86
90
  includeActorRecipeContext?: boolean;
91
+ skillContext?: ActiveSkillRecipeContext;
87
92
  }
88
93
 
89
94
  const RUNTIME_RECIPE_VALUE_NAMES = new Set(["recipe_dir", "skill_dir"]);
90
- const activeSkillRecipeRoots = new Map<string, Set<string>>();
91
95
 
92
96
  export interface ActiveSkillRecipeSource {
93
97
  name: string;
@@ -95,10 +99,14 @@ export interface ActiveSkillRecipeSource {
95
99
  baseDir?: string;
96
100
  }
97
101
 
98
- export function setActiveSkillRecipeSources(
102
+ export interface ActiveSkillRecipeContext {
103
+ readonly namespaces: Readonly<Record<string, readonly string[]>>;
104
+ }
105
+
106
+ export function createActiveSkillRecipeContext(
99
107
  skills: ActiveSkillRecipeSource[],
100
- ): void {
101
- activeSkillRecipeRoots.clear();
108
+ ): ActiveSkillRecipeContext {
109
+ const rootsByName = new Map<string, Set<string>>();
102
110
  for (const skill of skills) {
103
111
  const name = skill.name.trim();
104
112
  const skillDir = skill.baseDir
@@ -107,72 +115,179 @@ export function setActiveSkillRecipeSources(
107
115
  ? dirname(resolve(skill.filePath))
108
116
  : undefined;
109
117
  if (!name || !skillDir) continue;
110
- const roots = activeSkillRecipeRoots.get(name) ?? new Set<string>();
118
+ const roots = rootsByName.get(name) ?? new Set<string>();
111
119
  roots.add(resolve(skillDir, "recipes"));
112
- activeSkillRecipeRoots.set(name, roots);
120
+ rootsByName.set(name, roots);
113
121
  }
122
+ const namespaces = Object.fromEntries(
123
+ [...rootsByName.entries()]
124
+ .sort(([left], [right]) => left.localeCompare(right))
125
+ .map(([name, roots]) => [name, Object.freeze([...roots].sort())]),
126
+ );
127
+ return Object.freeze({ namespaces: Object.freeze(namespaces) });
114
128
  }
115
129
 
116
- export function getActiveSkillRecipeNamespaces(): Record<string, string[]> {
130
+ export const EMPTY_ACTIVE_SKILL_RECIPE_CONTEXT =
131
+ createActiveSkillRecipeContext([]);
132
+
133
+ export function getActiveSkillRecipeNamespaces(
134
+ context: ActiveSkillRecipeContext,
135
+ ): Record<string, string[]> {
117
136
  return Object.fromEntries(
118
- [...activeSkillRecipeRoots.entries()]
119
- .sort(([left], [right]) => left.localeCompare(right))
120
- .map(([name, roots]) => [name, [...roots].sort()]),
137
+ Object.entries(context.namespaces).map(([name, roots]) => [
138
+ name,
139
+ [...roots],
140
+ ]),
121
141
  );
122
142
  }
123
143
 
124
- function qualifiedRecipeNameForFile(file: string): string | undefined {
125
- const path = resolve(file);
126
- const stdRelation = relative(Paths.getPackagedRecipeRoot(), path);
127
- if (
128
- stdRelation &&
129
- !stdRelation.startsWith("..") &&
130
- !isAbsolute(stdRelation)
131
- ) {
132
- return `std:${stdRelation.replace(/\.(?:json|md)$/u, "")}`;
144
+ export interface ActiveSkillRecipeComponent {
145
+ file: string;
146
+ identity: string;
147
+ imports: Record<string, string>;
148
+ skill: string;
149
+ stem: string;
150
+ }
151
+
152
+ function nestedRecipeFiles(root: string): string[] {
153
+ if (!existsSync(root)) return [];
154
+ return readdirSync(root, { withFileTypes: true }).flatMap((entry) => {
155
+ const path = join(root, entry.name);
156
+ if (entry.isDirectory()) return nestedRecipeFiles(path);
157
+ return entry.isFile() && /\.(?:json|md)$/u.test(entry.name) ? [path] : [];
158
+ });
159
+ }
160
+
161
+ export function listActiveSkillRecipeComponents(
162
+ context: ActiveSkillRecipeContext,
163
+ ): ActiveSkillRecipeComponent[] {
164
+ const components: ActiveSkillRecipeComponent[] = [];
165
+ for (const [skill, roots] of Object.entries(context.namespaces)) {
166
+ if (roots.length > 1)
167
+ throw new Error(`Duplicate active Skill identity ${skill}: ${roots.join(", ")}`);
168
+ const root = roots[0];
169
+ if (!root || !existsSync(root)) continue;
170
+ const direct = readdirSync(root, { withFileTypes: true });
171
+ for (const entry of direct.filter((candidate) => candidate.isDirectory())) {
172
+ const nested = nestedRecipeFiles(join(root, entry.name));
173
+ if (nested.length > 0)
174
+ throw new Error(`Nested Skill Recipe file is not addressable: ${nested[0]}`);
175
+ }
176
+ const files = direct
177
+ .filter(
178
+ (entry) => entry.isFile() && /\.(?:json|md)$/u.test(entry.name),
179
+ )
180
+ .map((entry) => join(root, entry.name));
181
+ const byStem = new Map<string, string[]>();
182
+ for (const file of files) {
183
+ const stem = getRecipeIdFromPath(file);
184
+ const matches = byStem.get(stem) ?? [];
185
+ matches.push(file);
186
+ byStem.set(stem, matches);
187
+ }
188
+ for (const [stem, matches] of [...byStem].sort(([a], [b]) => a.localeCompare(b))) {
189
+ if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(stem))
190
+ throw new Error(`Invalid Skill Recipe filename stem: ${stem}`);
191
+ if (matches.length > 1)
192
+ throw new Error(`Skill Recipe stem collision: ${skill}/${stem} has both .json and .md files`);
193
+ const file = matches[0];
194
+ const raw = readRawRecipeConfig(file);
195
+ if (!raw || !Object.hasOwn(raw, "template"))
196
+ throw new Error(`Invalid Skill Recipe component: ${skill}/${stem}`);
197
+ assertRecipeHasNoDeclaredName(raw);
198
+ components.push({
199
+ file,
200
+ identity: `${skill}/${stem}`,
201
+ imports: Object.fromEntries(
202
+ Object.entries(getRecipeImports(raw)).map(([alias, value]) => [
203
+ alias,
204
+ getImportFrom(value),
205
+ ]),
206
+ ),
207
+ skill,
208
+ stem,
209
+ });
210
+ }
133
211
  }
134
- for (const [skillName, roots] of activeSkillRecipeRoots) {
135
- if (roots.size !== 1) continue;
136
- const root = [...roots][0];
212
+ return components;
213
+ }
214
+
215
+ const SKILL_RECIPE_REFERENCE =
216
+ /^([a-z][a-z0-9]*(?:-[a-z0-9]+)*)\/([a-z][a-z0-9]*(?:-[a-z0-9]+)*)$/;
217
+
218
+ function qualifiedRecipeNameForFile(
219
+ file: string,
220
+ context: ActiveSkillRecipeContext,
221
+ ): string | undefined {
222
+ const path = resolve(file);
223
+ for (const [skillName, roots] of Object.entries(context.namespaces)) {
224
+ if (roots.length !== 1) continue;
225
+ const root = roots[0];
137
226
  const relation = relative(root, path);
138
- if (relation && !relation.startsWith("..") && !isAbsolute(relation))
139
- return `skill:${skillName}/${relation.replaceAll("\\", "/").replace(/\.(?:json|md)$/u, "")}`;
227
+ if (
228
+ relation &&
229
+ dirname(relation) === "." &&
230
+ !relation.startsWith("..") &&
231
+ !isAbsolute(relation)
232
+ ) {
233
+ return `${skillName}/${basename(relation, extname(relation))}`;
234
+ }
140
235
  }
141
236
  return undefined;
142
237
  }
143
238
 
144
- function qualifiedRecipeCandidates(value: string): string[] | undefined {
239
+ function assertRecipeReferencePrefixWasNotRemoved(value: string): void {
145
240
  if (value.startsWith("std:")) {
146
- return recipeNameFiles(value.slice(4)).map((file) =>
147
- resolve(Paths.getPackagedRecipeRoot(), file),
241
+ throw new Error(
242
+ "std: Recipe references were removed in pi-actors 0.46.\nUse <skill>/<recipe> or an explicit .json/.md file path.",
243
+ );
244
+ }
245
+ if (value.startsWith("skill:")) {
246
+ throw new Error(
247
+ "skill: Recipe references were removed in pi-actors 0.46.\nUse <skill>/<recipe> without a prefix.",
148
248
  );
149
249
  }
150
- if (!value.startsWith("skill:")) return undefined;
151
- const qualified = value.slice(6);
152
- const separator = qualified.indexOf("/");
153
- if (separator <= 0 || separator === qualified.length - 1)
154
- throw new Error(`Invalid Skill Recipe reference: ${value}`);
155
- const skillName = qualified.slice(0, separator);
156
- const recipeName = qualified.slice(separator + 1);
157
- const roots = [...(activeSkillRecipeRoots.get(skillName) ?? [])];
250
+ }
251
+
252
+ function skillRecipeCandidates(
253
+ value: string,
254
+ context: ActiveSkillRecipeContext,
255
+ ): string[] | undefined {
256
+ const match = SKILL_RECIPE_REFERENCE.exec(value);
257
+ if (!match) return undefined;
258
+ const [, skillName, recipeName] = match;
259
+ const roots = [...(context.namespaces[skillName] ?? [])];
158
260
  if (roots.length === 0)
159
- throw new Error(`Active Skill Recipe namespace not found: ${skillName}`);
261
+ throw new Error(`Active Skill Recipe not found: ${skillName}/${recipeName}`);
160
262
  if (roots.length > 1)
161
263
  throw new Error(
162
- `Ambiguous active Skill Recipe namespace ${skillName}: ${roots.join(", ")}`,
264
+ `Duplicate active Skill identity ${skillName}: ${roots.join(", ")}`,
163
265
  );
164
266
  const root = roots[0];
165
- return recipeNameFiles(recipeName).map((file) => {
166
- const candidate = resolve(root, file);
167
- const relation = relative(root, candidate);
168
- if (!relation || relation.startsWith("..") || isAbsolute(relation))
169
- throw new Error(`Skill Recipe reference escapes its recipes root: ${value}`);
170
- return candidate;
171
- });
267
+ const candidates = ["json", "md"].map((extension) =>
268
+ resolve(root, `${recipeName}.${extension}`),
269
+ );
270
+ const existing = candidates.filter((candidate) => existsSync(candidate));
271
+ if (existing.length > 1) {
272
+ throw new Error(
273
+ `Skill Recipe stem collision: ${skillName}/${recipeName} has both .json and .md files`,
274
+ );
275
+ }
276
+ return candidates;
172
277
  }
173
278
 
174
- function hasWhitespace(value: string): boolean {
175
- return /\s/.test(value);
279
+ function recipeReferenceCandidates(
280
+ value: string,
281
+ baseDir: string,
282
+ context: ActiveSkillRecipeContext,
283
+ ): string[] | undefined {
284
+ const trimmed = value.trim();
285
+ if (!trimmed) return undefined;
286
+ assertRecipeReferencePrefixWasNotRemoved(trimmed);
287
+ if (trimmed.endsWith(".json") || trimmed.endsWith(".md")) {
288
+ return [resolve(baseDir, trimmed)];
289
+ }
290
+ return skillRecipeCandidates(trimmed, context);
176
291
  }
177
292
 
178
293
  function findOwningSkillDir(recipeFile: string): string | undefined {
@@ -185,6 +300,13 @@ function findOwningSkillDir(recipeFile: string): string | undefined {
185
300
  }
186
301
  }
187
302
 
303
+ function assertRecipeHasNoDeclaredName(raw: Record<string, unknown>): void {
304
+ if (!Object.hasOwn(raw, "name")) return;
305
+ throw new Error(
306
+ "Recipe.name was removed in pi-actors 0.46.\nFile-backed Recipe identity is derived from its file name.",
307
+ );
308
+ }
309
+
188
310
  function assertRuntimeRecipeValuesNotDeclared(raw: Record<string, unknown>): void {
189
311
  const args = Array.isArray(raw.args)
190
312
  ? Schema.getExplicitToolArgNames(raw.args.map(String))
@@ -202,100 +324,51 @@ function assertRuntimeRecipeValuesNotDeclared(raw: Record<string, unknown>): voi
202
324
 
203
325
  export function resolveRecipePath(
204
326
  value: string,
205
- recipeRoot = Paths.getRecipeRoot(),
327
+ baseDir = Paths.getRecipeRoot(),
206
328
  ): string {
207
- const trimmed = value.trim();
208
- const repoRoot = resolve(recipeRoot, "..");
209
- const expanded = trimmed
210
- .replaceAll("{repo}", repoRoot)
211
- .replaceAll("{agent}", Paths.getAgentDir());
212
- if (expanded.startsWith("~/")) return resolve(homedir(), expanded.slice(2));
213
- if (expanded.includes("/")) return resolve(expanded);
214
- return resolve(
215
- recipeRoot,
216
- expanded.endsWith(".json") || expanded.endsWith(".md")
217
- ? expanded
218
- : `${expanded}.json`,
219
- );
220
- }
221
-
222
- function isBareRecipeName(value: string): boolean {
223
- const trimmed = value.trim();
224
- return (
225
- Boolean(trimmed) &&
226
- !trimmed.includes("/") &&
227
- !trimmed.startsWith("~") &&
228
- !trimmed.includes("{")
329
+ const candidates = recipeReferenceCandidates(
330
+ value,
331
+ baseDir,
332
+ EMPTY_ACTIVE_SKILL_RECIPE_CONTEXT,
229
333
  );
230
- }
231
-
232
- function recipeNameFiles(value: string): string[] {
233
- const trimmed = value.trim();
234
- if (trimmed.endsWith(".json") || trimmed.endsWith(".md")) return [trimmed];
235
- return [`${trimmed}.json`, `${trimmed}.md`];
236
- }
237
-
238
- function recipeCandidatePaths(
239
- value: string,
240
- currentRecipeRoot: string,
241
- ): string[] {
242
- const qualified = qualifiedRecipeCandidates(value.trim());
243
- if (qualified) return qualified;
244
- if (!isBareRecipeName(value))
245
- return [resolveRecipePath(value, currentRecipeRoot)];
246
- const roots = [
247
- Paths.getRecipeRoot(),
248
- currentRecipeRoot,
249
- Paths.getPackagedRecipeRoot(),
250
- ];
251
- return [
252
- ...new Set(
253
- roots.flatMap((root) =>
254
- recipeNameFiles(value).map((file) => resolve(root, file)),
255
- ),
256
- ),
257
- ];
334
+ if (!candidates || candidates.length !== 1) {
335
+ throw new Error(
336
+ `Recipe file reference must be an explicit .json or .md path: ${value}`,
337
+ );
338
+ }
339
+ return candidates[0];
258
340
  }
259
341
 
260
342
  function resolveRecipeImportPath(
261
343
  value: string,
262
- currentRecipeRoot: string,
344
+ recipeDir: string,
345
+ context: ActiveSkillRecipeContext,
263
346
  ): string {
264
- const candidates = recipeCandidatePaths(value, currentRecipeRoot);
347
+ const candidates = recipeReferenceCandidates(value, recipeDir, context);
348
+ if (!candidates) {
349
+ throw new Error(
350
+ `Recipe import must use <skill>/<recipe> or an explicit .json/.md file path: ${value}`,
351
+ );
352
+ }
265
353
  return candidates.find((candidate) => existsSync(candidate)) ?? candidates[0];
266
354
  }
267
355
 
268
356
  export function resolveRecipeReferencePath(
269
357
  value: unknown,
270
- currentRecipeRoot = Paths.getRecipeRoot(),
358
+ baseDir = Paths.getRecipeRoot(),
359
+ context = EMPTY_ACTIVE_SKILL_RECIPE_CONTEXT,
271
360
  ): string | undefined {
272
361
  if (typeof value !== "string") return undefined;
273
- const trimmed = value.trim();
274
- if (!trimmed || hasWhitespace(trimmed)) return undefined;
275
- for (const path of recipeCandidatePaths(trimmed, currentRecipeRoot)) {
276
- if (!existsSync(path)) continue;
277
- try {
278
- const raw = readRawRecipeConfig(path);
279
- if (raw && typeof raw === "object" && Object.hasOwn(raw, "template"))
280
- return path;
281
- return path;
282
- } catch {
283
- return path;
284
- }
285
- }
286
- return undefined;
362
+ const candidates = recipeReferenceCandidates(value, baseDir, context);
363
+ return candidates?.find((candidate) => existsSync(candidate));
287
364
  }
288
365
 
289
366
  export function getRecipePath(
290
367
  value: unknown,
291
- recipeRoot = Paths.getRecipeRoot(),
368
+ baseDir = Paths.getRecipeRoot(),
369
+ context = EMPTY_ACTIVE_SKILL_RECIPE_CONTEXT,
292
370
  ): string | undefined {
293
- if (typeof value !== "string") return undefined;
294
- const trimmed = value.trim();
295
- if (!trimmed || hasWhitespace(trimmed)) return undefined;
296
- if (trimmed.endsWith(".json") || trimmed.endsWith(".md"))
297
- return resolveRecipePath(trimmed, recipeRoot);
298
- return resolveRecipeReferencePath(trimmed, recipeRoot);
371
+ return resolveRecipeReferencePath(value, baseDir, context);
299
372
  }
300
373
 
301
374
  function isImportNode(value: unknown): boolean {
@@ -873,7 +946,11 @@ function loadDelegatedRecipe(
873
946
  stack: string[],
874
947
  options: ReadResolvedRecipeConfigOptions,
875
948
  ): TemplateRecipeConfig | undefined {
876
- const path = resolveRecipeReferencePath(value, dirname(currentRecipeFile));
949
+ const path = resolveRecipeReferencePath(
950
+ value,
951
+ dirname(currentRecipeFile),
952
+ options.skillContext,
953
+ );
877
954
  if (!path) return undefined;
878
955
  const config = readResolvedRecipeConfig(
879
956
  path,
@@ -1082,6 +1159,7 @@ export function readResolvedRecipeConfig(
1082
1159
  }
1083
1160
  const raw = readRawRecipeConfig(path);
1084
1161
  if (!raw || !Object.hasOwn(raw, "template")) return undefined;
1162
+ assertRecipeHasNoDeclaredName(raw);
1085
1163
  RecipeControl.assertRecipeHasNoMailbox(raw);
1086
1164
  assertRuntimeRecipeValuesNotDeclared(raw);
1087
1165
  assertRecipeArgumentContract(raw as unknown as TemplateRecipeDefinition);
@@ -1090,6 +1168,7 @@ export function readResolvedRecipeConfig(
1090
1168
  const importPath = resolveRecipeImportPath(
1091
1169
  getImportFrom(binding),
1092
1170
  dirname(path),
1171
+ options.skillContext ?? EMPTY_ACTIVE_SKILL_RECIPE_CONTEXT,
1093
1172
  );
1094
1173
  const config = readResolvedRecipeConfig(
1095
1174
  importPath,
@@ -1109,7 +1188,7 @@ export function readResolvedRecipeConfig(
1109
1188
  imports[alias] = {
1110
1189
  alias,
1111
1190
  file: importPath,
1112
- name: config.name ?? alias,
1191
+ name: getRecipeIdFromPath(importPath),
1113
1192
  config,
1114
1193
  defaults: { ...(config.defaults ?? {}), ...(bindingDefaults ?? {}) },
1115
1194
  values: {
@@ -1286,6 +1365,7 @@ function collectRecipeContextRecords(
1286
1365
  file: string,
1287
1366
  stack: string[],
1288
1367
  importPath: string[],
1368
+ context: ActiveSkillRecipeContext,
1289
1369
  alias?: string,
1290
1370
  ): TemplateRecipeContextRecord[] {
1291
1371
  const path = resolveRecipePath(
@@ -1302,27 +1382,35 @@ function collectRecipeContextRecords(
1302
1382
  }
1303
1383
  const raw = readRawRecipeConfig(path);
1304
1384
  if (!raw || !Object.hasOwn(raw, "template")) return [];
1305
- const qualifiedName = qualifiedRecipeNameForFile(path);
1385
+ assertRecipeHasNoDeclaredName(raw);
1386
+ const qualifiedName = qualifiedRecipeNameForFile(path, context);
1387
+ const skill = qualifiedName?.split("/", 1)[0];
1306
1388
  const record: TemplateRecipeContextRecord = {
1307
1389
  ...(alias ? { alias } : {}),
1308
1390
  depth: stack.length,
1309
- file: path,
1310
1391
  import_path: importPath,
1392
+ logical_reference: qualifiedName ?? basename(path),
1311
1393
  name: getRecipeIdFromPath(path),
1312
- ...(qualifiedName ? { qualified_name: qualifiedName } : {}),
1313
1394
  recipe: raw,
1314
1395
  role: stack.length === 0 ? "entry" : "import",
1396
+ ...(skill ? { skill } : {}),
1397
+ source_file: path,
1398
+ source_kind: qualifiedName
1399
+ ? "active_skill_component"
1400
+ : "explicit_file_recipe",
1315
1401
  };
1316
1402
  const imports = getRecipeImports(raw);
1317
1403
  const children = Object.entries(imports).flatMap(([childAlias, binding]) => {
1318
1404
  const importFile = resolveRecipeImportPath(
1319
1405
  getImportFrom(binding),
1320
1406
  dirname(path),
1407
+ context,
1321
1408
  );
1322
1409
  return collectRecipeContextRecords(
1323
1410
  importFile,
1324
1411
  [...stack, path],
1325
1412
  [...importPath, childAlias],
1413
+ context,
1326
1414
  childAlias,
1327
1415
  );
1328
1416
  });
@@ -1331,8 +1419,9 @@ function collectRecipeContextRecords(
1331
1419
 
1332
1420
  export function buildRecipeContextRecords(
1333
1421
  file: string,
1422
+ context = EMPTY_ACTIVE_SKILL_RECIPE_CONTEXT,
1334
1423
  ): TemplateRecipeContextRecord[] {
1335
- return collectRecipeContextRecords(file, [], []);
1424
+ return collectRecipeContextRecords(file, [], [], context);
1336
1425
  }
1337
1426
 
1338
1427
  export function getRecipeTemplate(