@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.
- package/AGENTS.md +10 -6
- package/CHANGELOG.md +14 -1
- package/README.md +28 -12
- package/dist/fixtures/protocol/recipe-summary.json +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +10 -110
- package/dist/lib/async-runs.d.ts +4 -1
- package/dist/lib/async-runs.js +22 -23
- package/dist/lib/automatic-review-runtime.d.ts +2 -0
- package/dist/lib/automatic-review-runtime.js +12 -5
- package/dist/lib/draft-sleep.js +0 -1
- package/dist/lib/extension-runtime.d.ts +21 -0
- package/dist/lib/extension-runtime.js +122 -0
- package/dist/lib/inspector.js +45 -7
- package/dist/lib/paths.d.ts +0 -1
- package/dist/lib/paths.js +0 -7
- package/dist/lib/prompts.d.ts +1 -1
- package/dist/lib/prompts.js +2 -2
- package/dist/lib/recipes-context.js +2 -2
- package/dist/lib/recipes-references.d.ts +24 -9
- package/dist/lib/recipes-references.js +152 -126
- package/dist/lib/runtime.d.ts +0 -1
- package/dist/lib/runtime.js +1 -3
- package/dist/lib/tools-inspect.d.ts +0 -1
- package/dist/lib/tools-inspect.js +35 -8
- package/dist/lib/tools-local.d.ts +2 -0
- package/dist/lib/tools-local.js +1 -1
- package/dist/lib/tools-spawn.d.ts +2 -0
- package/dist/lib/tools-spawn.js +24 -52
- package/dist/scripts/async-runner.mjs +0 -16
- package/dist/scripts/build-dist.mjs +13 -4
- package/dist/skills/actors/SKILL.md +6 -6
- package/dist/skills/actors/recipes/recipe-validate.json +11 -0
- package/{recipes/utility-coordinator-lock-snapshot.json → dist/skills/actors/recipes/resource-locker-snapshot.json} +1 -3
- package/dist/{recipes → skills/actors/recipes}/resource-locker.json +1 -3
- package/dist/{recipes/utility-run-ops-snapshot.json → skills/actors/recipes/run-ops-snapshot.json} +1 -3
- package/dist/skills/actors/recipes/run-summary.json +9 -0
- package/dist/{scripts/locker.mjs → skills/actors/scripts/resource-locker.mjs} +2 -23
- package/dist/skills/actors/scripts/run-utils.mjs +164 -0
- package/{scripts → dist/skills/actors/scripts}/validate-recipe.mjs +134 -18
- package/dist/skills/artifacts/SKILL.md +16 -0
- package/{recipes/pipeline-artifact-bundle.json → dist/skills/artifacts/recipes/bundle.json} +4 -4
- package/dist/{recipes/utility-artifact-write.json → skills/artifacts/recipes/file-write.json} +1 -3
- package/dist/{recipes/utility-artifact-manifest.json → skills/artifacts/recipes/manifest.json} +1 -3
- package/{recipes/pipeline-artifact-report.json → dist/skills/artifacts/recipes/report.json} +2 -2
- package/dist/{recipes/pipeline-artifact-write.json → skills/artifacts/recipes/write.json} +3 -3
- package/dist/skills/artifacts/scripts/artifact-utils.mjs +63 -0
- package/dist/skills/media/SKILL.md +16 -0
- package/dist/{recipes/pipeline-media-library.json → skills/media/recipes/library.json} +2 -2
- package/{recipes/music-player.json → dist/skills/media/recipes/player.json} +1 -3
- package/dist/{recipes/utility-playlist-build.json → skills/media/recipes/playlist-build.json} +1 -3
- package/dist/skills/media/scripts/media-utils.mjs +47 -0
- package/dist/{scripts → skills/media/scripts}/music-player.mjs +9 -3
- package/dist/skills/project-work/SKILL.md +16 -0
- package/dist/skills/project-work/recipes/changelog-section.json +11 -0
- package/{recipes/pipeline-docs-maintenance.json → dist/skills/project-work/recipes/docs-maintenance.json} +4 -4
- package/dist/skills/project-work/recipes/package-summary.json +9 -0
- package/{recipes/pipeline-release-readiness.json → dist/skills/project-work/recipes/release-readiness.json} +6 -6
- package/dist/{recipes/pipeline-release-summary.json → skills/project-work/recipes/release-summary.json} +5 -5
- package/{recipes/pipeline-repo-health.json → dist/skills/project-work/recipes/repo-health.json} +6 -6
- package/{recipes/pipeline-async-run-ops.json → dist/skills/project-work/recipes/run-ops.json} +3 -3
- package/dist/skills/project-work/recipes/skill-summary.json +11 -0
- package/dist/skills/project-work/scripts/project-utils.mjs +89 -0
- package/dist/skills/recipe-memory/SKILL.md +16 -0
- package/dist/skills/swarm/SKILL.md +4 -4
- package/{recipes/pipeline-architect-coordinator.json → dist/skills/swarm/recipes/architect.json} +5 -5
- package/{recipes/pipeline-checkpoint-continuation.json → dist/skills/swarm/recipes/checkpoint-continuation.json} +3 -3
- package/dist/{recipes/pipeline-development-tasking.json → skills/swarm/recipes/development-tasking.json} +4 -4
- package/dist/{recipes/lens-swarm.json → skills/swarm/recipes/lens-review.json} +1 -1
- package/dist/{recipes/pipeline-quorum-review.json → skills/swarm/recipes/quorum-review.json} +4 -4
- package/{recipes/pipeline-research-synthesis.json → dist/skills/swarm/recipes/research-synthesis.json} +6 -6
- package/{recipes/pipeline-review-readiness.json → dist/skills/swarm/recipes/review-readiness.json} +1 -1
- package/{recipes/subagents-prompts.json → dist/skills/swarm/recipes/subagent-prompts.json} +1 -1
- package/{recipes → dist/skills/swarm/recipes}/subagent-quorum.json +1 -1
- package/dist/{recipes → skills/swarm/recipes}/subagent-review-coordinator.json +6 -6
- package/docs/actor-inspector.md +4 -3
- package/docs/async-runs.md +2 -2
- package/docs/recipe-library.md +23 -23
- package/docs/releasing.md +2 -2
- package/docs/template-recipes.md +30 -14
- package/docs/tool-registry.md +2 -2
- package/fixtures/protocol/recipe-summary.json +1 -1
- package/index.ts +18 -112
- package/lib/async-runs.ts +47 -24
- package/lib/automatic-review-runtime.ts +16 -3
- package/lib/draft-sleep.ts +0 -1
- package/lib/extension-runtime.ts +158 -0
- package/lib/inspector.ts +56 -11
- package/lib/paths.ts +0 -7
- package/lib/prompts.ts +2 -2
- package/lib/recipes-context.ts +2 -2
- package/lib/recipes-references.ts +223 -134
- package/lib/runtime.ts +1 -5
- package/lib/tools-inspect.ts +42 -9
- package/lib/tools-local.ts +2 -0
- package/lib/tools-spawn.ts +37 -74
- package/package.json +3 -5
- package/scripts/async-runner.mjs +0 -16
- package/scripts/build-dist.mjs +13 -4
- package/skills/actors/SKILL.md +6 -6
- package/skills/actors/recipes/recipe-validate.json +11 -0
- package/{dist/recipes/utility-coordinator-lock-snapshot.json → skills/actors/recipes/resource-locker-snapshot.json} +1 -3
- package/{recipes → skills/actors/recipes}/resource-locker.json +1 -3
- package/{recipes/utility-run-ops-snapshot.json → skills/actors/recipes/run-ops-snapshot.json} +1 -3
- package/skills/actors/recipes/run-summary.json +9 -0
- package/{scripts/locker.mjs → skills/actors/scripts/resource-locker.mjs} +2 -23
- package/skills/actors/scripts/run-utils.mjs +164 -0
- package/{dist → skills/actors}/scripts/validate-recipe.mjs +134 -18
- package/skills/artifacts/SKILL.md +16 -0
- package/{dist/recipes/pipeline-artifact-bundle.json → skills/artifacts/recipes/bundle.json} +4 -4
- package/{recipes/utility-artifact-write.json → skills/artifacts/recipes/file-write.json} +1 -3
- package/{recipes/utility-artifact-manifest.json → skills/artifacts/recipes/manifest.json} +1 -3
- package/{dist/recipes/pipeline-artifact-report.json → skills/artifacts/recipes/report.json} +2 -2
- package/{recipes/pipeline-artifact-write.json → skills/artifacts/recipes/write.json} +3 -3
- package/skills/artifacts/scripts/artifact-utils.mjs +63 -0
- package/skills/media/SKILL.md +16 -0
- package/{recipes/pipeline-media-library.json → skills/media/recipes/library.json} +2 -2
- package/{dist/recipes/music-player.json → skills/media/recipes/player.json} +1 -3
- package/{recipes/utility-playlist-build.json → skills/media/recipes/playlist-build.json} +1 -3
- package/skills/media/scripts/media-utils.mjs +47 -0
- package/{scripts → skills/media/scripts}/music-player.mjs +9 -3
- package/skills/project-work/SKILL.md +16 -0
- package/skills/project-work/recipes/changelog-section.json +11 -0
- package/{dist/recipes/pipeline-docs-maintenance.json → skills/project-work/recipes/docs-maintenance.json} +4 -4
- package/skills/project-work/recipes/package-summary.json +9 -0
- package/{dist/recipes/pipeline-release-readiness.json → skills/project-work/recipes/release-readiness.json} +6 -6
- package/{recipes/pipeline-release-summary.json → skills/project-work/recipes/release-summary.json} +5 -5
- package/{dist/recipes/pipeline-repo-health.json → skills/project-work/recipes/repo-health.json} +6 -6
- package/{dist/recipes/pipeline-async-run-ops.json → skills/project-work/recipes/run-ops.json} +3 -3
- package/skills/project-work/recipes/skill-summary.json +11 -0
- package/skills/project-work/scripts/project-utils.mjs +89 -0
- package/skills/recipe-memory/SKILL.md +16 -0
- package/skills/swarm/SKILL.md +4 -4
- package/{dist/recipes/pipeline-architect-coordinator.json → skills/swarm/recipes/architect.json} +5 -5
- package/{dist/recipes/pipeline-checkpoint-continuation.json → skills/swarm/recipes/checkpoint-continuation.json} +3 -3
- package/{recipes/pipeline-development-tasking.json → skills/swarm/recipes/development-tasking.json} +4 -4
- package/{recipes/lens-swarm.json → skills/swarm/recipes/lens-review.json} +1 -1
- package/{recipes/pipeline-quorum-review.json → skills/swarm/recipes/quorum-review.json} +4 -4
- package/{dist/recipes/pipeline-research-synthesis.json → skills/swarm/recipes/research-synthesis.json} +6 -6
- package/{dist/recipes/pipeline-review-readiness.json → skills/swarm/recipes/review-readiness.json} +1 -1
- package/{dist/recipes/subagents-prompts.json → skills/swarm/recipes/subagent-prompts.json} +1 -1
- package/{dist → skills/swarm}/recipes/subagent-quorum.json +1 -1
- package/{recipes → skills/swarm/recipes}/subagent-review-coordinator.json +6 -6
- package/dist/recipes/utility-changelog-section.json +0 -13
- package/dist/recipes/utility-package-summary.json +0 -11
- package/dist/recipes/utility-run-summary.json +0 -11
- package/dist/recipes/utility-skill-summary.json +0 -13
- package/dist/recipes/utility-validate-recipe.json +0 -13
- package/dist/scripts/recipe-utils.mjs +0 -405
- package/dist/scripts/release-gates.mjs +0 -278
- package/recipes/utility-changelog-section.json +0 -13
- package/recipes/utility-package-summary.json +0 -11
- package/recipes/utility-run-summary.json +0 -11
- package/recipes/utility-skill-summary.json +0 -13
- package/recipes/utility-validate-recipe.json +0 -13
- package/scripts/recipe-utils.mjs +0 -405
- package/scripts/release-gates.mjs +0 -278
- /package/dist/{recipes/utility-validation-wrapper.json → skills/actors/recipes/command-validate.json} +0 -0
- /package/dist/{recipes/utility-jsonl-tail.json → skills/actors/recipes/jsonl-tail.json} +0 -0
- /package/dist/{recipes/utility-run-state-files.json → skills/actors/recipes/run-state-files.json} +0 -0
- /package/dist/{recipes/utility-playlist-scan.json → skills/media/recipes/playlist-scan.json} +0 -0
- /package/dist/{recipes/utility-changelog-head.json → skills/project-work/recipes/changelog-head.json} +0 -0
- /package/dist/{recipes/utility-git-log.json → skills/project-work/recipes/git-log.json} +0 -0
- /package/dist/{recipes/utility-git-status.json → skills/project-work/recipes/git-status.json} +0 -0
- /package/dist/{recipes/utility-markdown-index.json → skills/project-work/recipes/markdown-index.json} +0 -0
- /package/dist/{recipes → skills/recipe-memory/recipes}/draft-review.json +0 -0
- /package/dist/{recipes → skills/recipe-memory/recipes}/tool-review.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-artifact.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-checkpoint.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-conflict-report.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-contradiction-map.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-critic.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-evidence-map.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-followup.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-judge.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-merge.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-normalize.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-plan.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-preflight.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-prompt.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-review.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-task-card.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-tools.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-verify.json +0 -0
- /package/{recipes/utility-validation-wrapper.json → skills/actors/recipes/command-validate.json} +0 -0
- /package/{recipes/utility-jsonl-tail.json → skills/actors/recipes/jsonl-tail.json} +0 -0
- /package/{recipes/utility-run-state-files.json → skills/actors/recipes/run-state-files.json} +0 -0
- /package/{recipes/utility-playlist-scan.json → skills/media/recipes/playlist-scan.json} +0 -0
- /package/{recipes/utility-changelog-head.json → skills/project-work/recipes/changelog-head.json} +0 -0
- /package/{recipes/utility-git-log.json → skills/project-work/recipes/git-log.json} +0 -0
- /package/{recipes/utility-git-status.json → skills/project-work/recipes/git-status.json} +0 -0
- /package/{recipes/utility-markdown-index.json → skills/project-work/recipes/markdown-index.json} +0 -0
- /package/{recipes → skills/recipe-memory/recipes}/draft-review.json +0 -0
- /package/{recipes → skills/recipe-memory/recipes}/tool-review.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-artifact.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-checkpoint.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-conflict-report.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-contradiction-map.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-critic.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-evidence-map.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-followup.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-judge.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-merge.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-normalize.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-plan.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-preflight.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-prompt.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-review.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-task-card.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-tools.json +0 -0
- /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
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
132
|
-
|
|
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
|
-
|
|
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;
|
|
34
|
-
- Prefer maintained
|
|
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 = {
|
package/lib/recipes-context.ts
CHANGED
|
@@ -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.
|
|
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 {
|
|
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:
|
|
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
|
|
102
|
+
export interface ActiveSkillRecipeContext {
|
|
103
|
+
readonly namespaces: Readonly<Record<string, readonly string[]>>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function createActiveSkillRecipeContext(
|
|
99
107
|
skills: ActiveSkillRecipeSource[],
|
|
100
|
-
):
|
|
101
|
-
|
|
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 =
|
|
118
|
+
const roots = rootsByName.get(name) ?? new Set<string>();
|
|
111
119
|
roots.add(resolve(skillDir, "recipes"));
|
|
112
|
-
|
|
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
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
137
|
+
Object.entries(context.namespaces).map(([name, roots]) => [
|
|
138
|
+
name,
|
|
139
|
+
[...roots],
|
|
140
|
+
]),
|
|
121
141
|
);
|
|
122
142
|
}
|
|
123
143
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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 (
|
|
139
|
-
|
|
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
|
|
239
|
+
function assertRecipeReferencePrefixWasNotRemoved(value: string): void {
|
|
145
240
|
if (value.startsWith("std:")) {
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
|
|
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
|
|
261
|
+
throw new Error(`Active Skill Recipe not found: ${skillName}/${recipeName}`);
|
|
160
262
|
if (roots.length > 1)
|
|
161
263
|
throw new Error(
|
|
162
|
-
`
|
|
264
|
+
`Duplicate active Skill identity ${skillName}: ${roots.join(", ")}`,
|
|
163
265
|
);
|
|
164
266
|
const root = roots[0];
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
|
175
|
-
|
|
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
|
-
|
|
327
|
+
baseDir = Paths.getRecipeRoot(),
|
|
206
328
|
): string {
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return [
|
|
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
|
-
|
|
344
|
+
recipeDir: string,
|
|
345
|
+
context: ActiveSkillRecipeContext,
|
|
263
346
|
): string {
|
|
264
|
-
const candidates =
|
|
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
|
-
|
|
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
|
|
274
|
-
|
|
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
|
-
|
|
368
|
+
baseDir = Paths.getRecipeRoot(),
|
|
369
|
+
context = EMPTY_ACTIVE_SKILL_RECIPE_CONTEXT,
|
|
292
370
|
): string | undefined {
|
|
293
|
-
|
|
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(
|
|
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:
|
|
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
|
-
|
|
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(
|