@llblab/pi-actors 0.45.1 → 0.46.1
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 +9 -7
- package/BACKLOG.md +582 -0
- package/CHANGELOG.md +17 -1
- package/README.md +27 -13
- package/dist/fixtures/protocol/recipe-summary.json +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/async-runs.d.ts +5 -1
- package/dist/lib/async-runs.js +26 -24
- 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/execution.d.ts +1 -0
- package/dist/lib/execution.js +1 -0
- package/dist/lib/extension-runtime.d.ts +1 -1
- package/dist/lib/extension-runtime.js +26 -4
- package/dist/lib/inspector.js +46 -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 +4 -4
- package/dist/lib/recipes-context.d.ts +12 -3
- package/dist/lib/recipes-context.js +30 -6
- package/dist/lib/recipes-discovery.d.ts +18 -0
- package/dist/lib/recipes-discovery.js +95 -22
- package/dist/lib/recipes-references.d.ts +42 -9
- package/dist/lib/recipes-references.js +248 -135
- package/dist/lib/registry.d.ts +14 -1
- package/dist/lib/registry.js +110 -87
- package/dist/lib/runtime.d.ts +30 -4
- package/dist/lib/runtime.js +74 -12
- package/dist/lib/tools-inspect.d.ts +3 -1
- package/dist/lib/tools-inspect.js +56 -9
- package/dist/lib/tools-local.d.ts +2 -0
- package/dist/lib/tools-local.js +5 -2
- package/dist/lib/tools-response.js +2 -0
- package/dist/lib/tools-spawn.d.ts +2 -0
- package/dist/lib/tools-spawn.js +24 -52
- package/dist/lib/tools.d.ts +4 -1
- package/dist/lib/tools.js +2 -0
- package/dist/scripts/build-dist.mjs +13 -4
- package/dist/skills/actors/SKILL.md +8 -8
- 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 -2
- package/dist/skills/actors/scripts/run-utils.mjs +164 -0
- package/{scripts → dist/skills/actors/scripts}/validate-recipe.mjs +134 -17
- 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 +32 -14
- package/docs/tool-registry.md +10 -4
- package/fixtures/protocol/recipe-summary.json +1 -1
- package/index.ts +2 -1
- package/lib/async-runs.ts +52 -25
- package/lib/automatic-review-runtime.ts +16 -3
- package/lib/draft-sleep.ts +0 -1
- package/lib/execution.ts +2 -0
- package/lib/extension-runtime.ts +42 -4
- package/lib/inspector.ts +57 -11
- package/lib/paths.ts +0 -7
- package/lib/prompts.ts +4 -4
- package/lib/recipes-context.ts +51 -6
- package/lib/recipes-discovery.ts +164 -24
- package/lib/recipes-references.ts +359 -146
- package/lib/registry.ts +185 -94
- package/lib/runtime.ts +109 -17
- package/lib/tools-inspect.ts +77 -10
- package/lib/tools-local.ts +9 -1
- package/lib/tools-response.ts +2 -0
- package/lib/tools-spawn.ts +38 -74
- package/lib/tools.ts +4 -1
- package/package.json +2 -4
- package/scripts/build-dist.mjs +13 -4
- package/skills/actors/SKILL.md +8 -8
- 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 -2
- package/skills/actors/scripts/run-utils.mjs +164 -0
- package/{dist → skills/actors}/scripts/validate-recipe.mjs +134 -17
- 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/executable-block-style.d.mts +0 -1
- package/dist/scripts/executable-block-style.mjs +0 -73
- package/dist/scripts/recipe-utils.mjs +0 -404
- package/dist/scripts/release-gates.mjs +0 -281
- 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/executable-block-style.d.mts +0 -1
- package/scripts/executable-block-style.mjs +0 -73
- package/scripts/recipe-utils.mjs +0 -404
- package/scripts/release-gates.mjs +0 -281
- /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/index.ts
CHANGED
|
@@ -18,10 +18,11 @@ export default function toolRegistryExtension(pi: Pi.ExtensionAPI) {
|
|
|
18
18
|
pi.on("session_shutdown", async (event, ctx) =>
|
|
19
19
|
runtime.onSessionShutdown(event.reason, ctx),
|
|
20
20
|
);
|
|
21
|
-
pi.on("before_agent_start", async (event) =>
|
|
21
|
+
pi.on("before_agent_start", async (event, ctx) =>
|
|
22
22
|
runtime.beforeAgentStart(
|
|
23
23
|
event.systemPrompt,
|
|
24
24
|
event.systemPromptOptions.skills ?? [],
|
|
25
|
+
ctx,
|
|
25
26
|
),
|
|
26
27
|
);
|
|
27
28
|
InspectorCommand.registerActorInspectorCommand(pi, runtime.getRunOwnerId);
|
package/lib/async-runs.ts
CHANGED
|
@@ -161,6 +161,7 @@ export interface AsyncRunMeta {
|
|
|
161
161
|
argv: string[];
|
|
162
162
|
createdAt: string;
|
|
163
163
|
cwd: string;
|
|
164
|
+
launch_kind?: AsyncRunLaunchSource;
|
|
164
165
|
launch_source?: AsyncRunLaunchSource;
|
|
165
166
|
launch_correlation?: {
|
|
166
167
|
correlation_id?: string;
|
|
@@ -259,11 +260,23 @@ function assertNoActiveRunState(stateDir: string): void {
|
|
|
259
260
|
RunsStart.assertNoActiveRunState(stateDir, readJson, RUNNER_PATH);
|
|
260
261
|
}
|
|
261
262
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
263
|
+
export interface AsyncRunStartOptions {
|
|
264
|
+
skillContext?: RecipesReferences.ActiveSkillRecipeContext;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function resolveRecipeFile(
|
|
268
|
+
file: string,
|
|
269
|
+
cwd: string,
|
|
270
|
+
options: AsyncRunStartOptions,
|
|
271
|
+
): string {
|
|
272
|
+
const path = RecipesReferences.resolveRecipeReferencePath(
|
|
273
|
+
file,
|
|
274
|
+
cwd,
|
|
275
|
+
options.skillContext,
|
|
276
|
+
);
|
|
277
|
+
if (path) return path;
|
|
278
|
+
throw new Error(
|
|
279
|
+
`Recipe reference not found. Use <skill>/<recipe> or an explicit .json/.md file path: ${file}`,
|
|
267
280
|
);
|
|
268
281
|
}
|
|
269
282
|
|
|
@@ -274,13 +287,18 @@ function isMutableUsageRecipeFile(file: string): boolean {
|
|
|
274
287
|
return relation !== "" && !relation.startsWith("..") && !isAbsolute(relation);
|
|
275
288
|
}
|
|
276
289
|
|
|
277
|
-
function readRecipeFile(
|
|
278
|
-
|
|
290
|
+
function readRecipeFile(
|
|
291
|
+
file: string,
|
|
292
|
+
cwd: string,
|
|
293
|
+
options: AsyncRunStartOptions,
|
|
294
|
+
): AsyncRunStartParams {
|
|
295
|
+
const path = resolveRecipeFile(file, cwd, options);
|
|
279
296
|
const raw = RecipesReferences.readRawRecipeConfig(path);
|
|
280
297
|
const includeActorRecipeContext =
|
|
281
298
|
raw?.actor_context !== false && raw?.actor_context !== "off";
|
|
282
299
|
const config = RecipesReferences.readResolvedRecipeConfig(path, [], {
|
|
283
300
|
includeActorRecipeContext,
|
|
301
|
+
skillContext: options.skillContext,
|
|
284
302
|
});
|
|
285
303
|
if (!config) {
|
|
286
304
|
throw new Error(`Template recipe must define template: ${path}`);
|
|
@@ -301,9 +319,13 @@ function getRunIdFromFile(file: string | undefined): string | undefined {
|
|
|
301
319
|
return name || undefined;
|
|
302
320
|
}
|
|
303
321
|
|
|
304
|
-
function resolveStartParams(
|
|
322
|
+
function resolveStartParams(
|
|
323
|
+
params: AsyncRunStartParams,
|
|
324
|
+
cwd: string,
|
|
325
|
+
options: AsyncRunStartOptions,
|
|
326
|
+
): AsyncRunStartParams {
|
|
305
327
|
if (!params.file) return params;
|
|
306
|
-
const fileParams = readRecipeFile(params.file);
|
|
328
|
+
const fileParams = readRecipeFile(params.file, cwd, options);
|
|
307
329
|
return {
|
|
308
330
|
...fileParams,
|
|
309
331
|
...params,
|
|
@@ -468,25 +490,15 @@ function prepareStateDirForStart(stateDir: string): void {
|
|
|
468
490
|
export function startRun(
|
|
469
491
|
params: AsyncRunStartParams,
|
|
470
492
|
cwd: string,
|
|
493
|
+
options: AsyncRunStartOptions = {},
|
|
471
494
|
): AsyncRunMeta {
|
|
472
|
-
const startParams = resolveStartParams(params);
|
|
495
|
+
const startParams = resolveStartParams(params, cwd, options);
|
|
473
496
|
const resolved = resolveRunTemplate(startParams);
|
|
474
497
|
const run = safeRunId(startParams.run_id);
|
|
475
498
|
const stateDir = resolveStateDir(startParams, run);
|
|
476
499
|
const recipeFile = startParams.file
|
|
477
|
-
? resolveRecipeFile(startParams.file)
|
|
500
|
+
? resolveRecipeFile(startParams.file, cwd, options)
|
|
478
501
|
: undefined;
|
|
479
|
-
const packagedRecipeRoot = resolve(Paths.getPackagedRecipeRoot());
|
|
480
|
-
const recipeRelation = recipeFile
|
|
481
|
-
? relative(packagedRecipeRoot, recipeFile)
|
|
482
|
-
: undefined;
|
|
483
|
-
const packagedRepo =
|
|
484
|
-
startParams.defaults?.repo === "~/.pi/agent/extensions/pi-actors" &&
|
|
485
|
-
recipeRelation &&
|
|
486
|
-
!recipeRelation.startsWith("..") &&
|
|
487
|
-
!isAbsolute(recipeRelation)
|
|
488
|
-
? dirname(packagedRecipeRoot)
|
|
489
|
-
: undefined;
|
|
490
502
|
const argSpec = Schema.parseToolArgDeclarationList(startParams.args ?? []);
|
|
491
503
|
if (argSpec.error) throw new Error(argSpec.error);
|
|
492
504
|
const declaredArgs = new Set(argSpec.args);
|
|
@@ -498,7 +510,6 @@ export function startRun(
|
|
|
498
510
|
{
|
|
499
511
|
...argSpec.defaults,
|
|
500
512
|
...(startParams.defaults || {}),
|
|
501
|
-
...(packagedRepo ? { repo: packagedRepo } : {}),
|
|
502
513
|
...(startParams.values || {}),
|
|
503
514
|
run_id: run,
|
|
504
515
|
state_dir: stateDir,
|
|
@@ -546,7 +557,20 @@ export function startRun(
|
|
|
546
557
|
startParams.actor_context !== "off";
|
|
547
558
|
const recipeContextRecords =
|
|
548
559
|
recipeFile && includeActorRecipeContext
|
|
549
|
-
? RecipesReferences.buildRecipeContextRecords(
|
|
560
|
+
? RecipesReferences.buildRecipeContextRecords(
|
|
561
|
+
recipeFile,
|
|
562
|
+
options.skillContext,
|
|
563
|
+
).map((record, index) =>
|
|
564
|
+
index === 0 &&
|
|
565
|
+
startParams.launch_source === "tool" &&
|
|
566
|
+
record.source_kind === "explicit_file_recipe"
|
|
567
|
+
? {
|
|
568
|
+
...record,
|
|
569
|
+
logical_reference: record.name,
|
|
570
|
+
source_kind: "user_registry_capability" as const,
|
|
571
|
+
}
|
|
572
|
+
: record,
|
|
573
|
+
)
|
|
550
574
|
: undefined;
|
|
551
575
|
if (
|
|
552
576
|
recipeFile &&
|
|
@@ -577,7 +601,10 @@ export function startRun(
|
|
|
577
601
|
createdAt: new Date().toISOString(),
|
|
578
602
|
cwd,
|
|
579
603
|
...(startParams.launch_source
|
|
580
|
-
? {
|
|
604
|
+
? {
|
|
605
|
+
launch_kind: startParams.launch_source,
|
|
606
|
+
launch_source: startParams.launch_source,
|
|
607
|
+
}
|
|
581
608
|
: {}),
|
|
582
609
|
...(startParams.launch_correlation
|
|
583
610
|
? { launch_correlation: startParams.launch_correlation } : {}),
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
* Owns automatic-review lifecycle wiring without owning review decisions or filesystem transactions.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
8
|
|
|
9
9
|
import * as AsyncRuns from "./async-runs.ts";
|
|
10
10
|
import * as DraftSleep from "./draft-sleep.ts";
|
|
11
11
|
import * as ModelContext from "./model-context.ts";
|
|
12
12
|
import * as Paths from "./paths.ts";
|
|
13
13
|
import type * as Pi from "./pi.ts";
|
|
14
|
+
import * as RecipesReferences from "./recipes-references.ts";
|
|
14
15
|
import * as ReviewControl from "./review-control.ts";
|
|
15
16
|
import * as ToolReviewScheduler from "./tool-review-scheduler.ts";
|
|
16
17
|
|
|
@@ -27,6 +28,16 @@ export interface AutomaticReviewRuntimeDeps {
|
|
|
27
28
|
getThinkingLevel(): unknown;
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
export const PACKAGE_RECIPE_MEMORY_CONTEXT =
|
|
32
|
+
RecipesReferences.createActiveSkillRecipeContext([
|
|
33
|
+
{
|
|
34
|
+
name: "recipe-memory",
|
|
35
|
+
filePath: fileURLToPath(
|
|
36
|
+
new URL("../skills/recipe-memory/SKILL.md", import.meta.url),
|
|
37
|
+
),
|
|
38
|
+
},
|
|
39
|
+
]);
|
|
40
|
+
|
|
30
41
|
export function createAutomaticReviewRuntime(
|
|
31
42
|
deps: AutomaticReviewRuntimeDeps,
|
|
32
43
|
): AutomaticReviewRuntime {
|
|
@@ -88,7 +99,7 @@ export function createAutomaticReviewRuntime(
|
|
|
88
99
|
}
|
|
89
100
|
return AsyncRuns.startRun(
|
|
90
101
|
{
|
|
91
|
-
file:
|
|
102
|
+
file: "recipe-memory/draft-review",
|
|
92
103
|
launch_source: "tool",
|
|
93
104
|
notification_policy: "silent",
|
|
94
105
|
ownerId: deps.getRunOwnerId(ctx),
|
|
@@ -97,6 +108,7 @@ export function createAutomaticReviewRuntime(
|
|
|
97
108
|
values: { input_path: batch.reviewerInputPath },
|
|
98
109
|
},
|
|
99
110
|
ctx.cwd,
|
|
111
|
+
{ skillContext: PACKAGE_RECIPE_MEMORY_CONTEXT },
|
|
100
112
|
);
|
|
101
113
|
},
|
|
102
114
|
process: (state) =>
|
|
@@ -113,7 +125,7 @@ export function createAutomaticReviewRuntime(
|
|
|
113
125
|
}
|
|
114
126
|
return AsyncRuns.startRun(
|
|
115
127
|
{
|
|
116
|
-
file:
|
|
128
|
+
file: "recipe-memory/tool-review",
|
|
117
129
|
launch_source: "tool",
|
|
118
130
|
notification_policy: "silent",
|
|
119
131
|
ownerId: deps.getRunOwnerId(ctx),
|
|
@@ -122,6 +134,7 @@ export function createAutomaticReviewRuntime(
|
|
|
122
134
|
values: { input_path: batch.reviewerInputPath },
|
|
123
135
|
},
|
|
124
136
|
ctx.cwd,
|
|
137
|
+
{ skillContext: PACKAGE_RECIPE_MEMORY_CONTEXT },
|
|
125
138
|
);
|
|
126
139
|
},
|
|
127
140
|
process: (state) =>
|
package/lib/draft-sleep.ts
CHANGED
|
@@ -96,7 +96,6 @@ function readState(path: string): DraftSleepState | undefined {
|
|
|
96
96
|
function defaultActiveTools(recipeRoot: string): DraftReviewActiveTool[] {
|
|
97
97
|
const discovered = RecipesDiscovery.discoverRecipeSources([
|
|
98
98
|
{ root: recipeRoot, defaultTool: true, mutableUsage: true },
|
|
99
|
-
{ root: Paths.getPackagedRecipeRoot() },
|
|
100
99
|
]);
|
|
101
100
|
return [...discovered.active.values()]
|
|
102
101
|
.filter((entry) => existsSync(entry.path))
|
package/lib/execution.ts
CHANGED
|
@@ -83,6 +83,7 @@ export interface RegisteredToolExecutionResult {
|
|
|
83
83
|
command: string;
|
|
84
84
|
fullOutputPath?: string;
|
|
85
85
|
killed: boolean;
|
|
86
|
+
launch_kind: "tool";
|
|
86
87
|
stderrBytes?: number;
|
|
87
88
|
stderrCapturedBytes?: number;
|
|
88
89
|
stderrFile?: string;
|
|
@@ -1136,6 +1137,7 @@ export async function executeRegisteredTool(
|
|
|
1136
1137
|
command,
|
|
1137
1138
|
fullOutputPath: result.stdoutFile ?? formatted.fullOutputPath,
|
|
1138
1139
|
killed: result.killed,
|
|
1140
|
+
launch_kind: "tool",
|
|
1139
1141
|
...getCaptureDetails(result),
|
|
1140
1142
|
...(executed.branches.length > 0 ? { branches: executed.branches } : {}),
|
|
1141
1143
|
...(executed.failures.length > 0
|
package/lib/extension-runtime.ts
CHANGED
|
@@ -9,6 +9,7 @@ import * as CommandTemplates from "./command-templates.ts";
|
|
|
9
9
|
import * as Paths from "./paths.ts";
|
|
10
10
|
import * as Pi from "./pi.ts";
|
|
11
11
|
import * as Prompts from "./prompts.ts";
|
|
12
|
+
import * as RecipeResolution from "./recipes-context.ts";
|
|
12
13
|
import * as RecipesReferences from "./recipes-references.ts";
|
|
13
14
|
import * as RunUiRuntime from "./run-ui-runtime.ts";
|
|
14
15
|
import * as Runtime from "./runtime.ts";
|
|
@@ -20,6 +21,7 @@ export interface ActorExtensionRuntime {
|
|
|
20
21
|
beforeAgentStart(
|
|
21
22
|
systemPrompt: string,
|
|
22
23
|
skills: RecipesReferences.ActiveSkillRecipeSource[],
|
|
24
|
+
ctx: Pi.ExtensionContext,
|
|
23
25
|
): { systemPrompt: string };
|
|
24
26
|
discoverResources(metaUrl: string): { skillPaths: string[] } | undefined;
|
|
25
27
|
getRunOwnerId(ctx: Pi.ExtensionContext): string;
|
|
@@ -33,7 +35,21 @@ export function createActorExtensionRuntime(
|
|
|
33
35
|
pi: Pi.ExtensionAPI,
|
|
34
36
|
): ActorExtensionRuntime {
|
|
35
37
|
let activeRunContext: Pi.ExtensionContext | undefined;
|
|
38
|
+
const recipeResolutionContextsBySession = new Map<
|
|
39
|
+
string,
|
|
40
|
+
RecipeResolution.RecipeResolutionContext
|
|
41
|
+
>();
|
|
36
42
|
const getRunOwnerId = Pi.getSessionId;
|
|
43
|
+
const getRecipeResolutionContext = (ctx: Pi.ExtensionContext) => {
|
|
44
|
+
const sessionId = getRunOwnerId(ctx);
|
|
45
|
+
const resolutionContext = recipeResolutionContextsBySession.get(sessionId);
|
|
46
|
+
if (!resolutionContext) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`Recipe resolution context is unavailable for session ${sessionId}.`,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return resolutionContext;
|
|
52
|
+
};
|
|
37
53
|
const automaticReview = AutomaticReviewRuntime.createAutomaticReviewRuntime({
|
|
38
54
|
getActiveContext: () => activeRunContext,
|
|
39
55
|
getRunOwnerId,
|
|
@@ -59,6 +75,9 @@ export function createActorExtensionRuntime(
|
|
|
59
75
|
if (ctx && typeof ctx === "object") {
|
|
60
76
|
nextArgs[4] = {
|
|
61
77
|
...(ctx as Record<string, unknown>),
|
|
78
|
+
recipeResolutionContext: getRecipeResolutionContext(
|
|
79
|
+
ctx as Pi.ExtensionContext,
|
|
80
|
+
),
|
|
62
81
|
getThinkingLevel: () => pi.getThinkingLevel(),
|
|
63
82
|
};
|
|
64
83
|
}
|
|
@@ -74,6 +93,7 @@ export function createActorExtensionRuntime(
|
|
|
74
93
|
configPath: Paths.EXTENSION_RUNTIME_PATHS.configPath,
|
|
75
94
|
exec: CommandTemplates.execCommandTemplate,
|
|
76
95
|
getActiveTools: () => pi.getActiveTools(),
|
|
96
|
+
getAllTools: () => pi.getAllTools(),
|
|
77
97
|
registerTool: (definition) => {
|
|
78
98
|
const wrapped = withCurrentThinkingContext(definition);
|
|
79
99
|
actorToolDefinitions.set(wrapped.name, wrapped);
|
|
@@ -82,10 +102,22 @@ export function createActorExtensionRuntime(
|
|
|
82
102
|
reservedToolNames: Tools.RESERVED_TOOL_NAMES,
|
|
83
103
|
setActiveTools: (toolNames) => pi.setActiveTools(toolNames),
|
|
84
104
|
});
|
|
85
|
-
const recipeReload = Runtime.createRecipeToolReloadWatcher(runtime
|
|
105
|
+
const recipeReload = Runtime.createRecipeToolReloadWatcher(runtime, {
|
|
106
|
+
getResolutionContext: () =>
|
|
107
|
+
activeRunContext
|
|
108
|
+
? getRecipeResolutionContext(activeRunContext)
|
|
109
|
+
: undefined,
|
|
110
|
+
});
|
|
86
111
|
return {
|
|
87
|
-
beforeAgentStart(systemPrompt, skills) {
|
|
88
|
-
|
|
112
|
+
beforeAgentStart(systemPrompt, skills, ctx) {
|
|
113
|
+
const sessionId = getRunOwnerId(ctx);
|
|
114
|
+
const resolutionContext = RecipeResolution.createRecipeResolutionContext(
|
|
115
|
+
sessionId,
|
|
116
|
+
ctx.cwd,
|
|
117
|
+
RecipesReferences.createActiveSkillRecipeContext(skills),
|
|
118
|
+
);
|
|
119
|
+
recipeResolutionContextsBySession.set(sessionId, resolutionContext);
|
|
120
|
+
runtime.loadTools(ctx, resolutionContext);
|
|
89
121
|
return {
|
|
90
122
|
systemPrompt: `${systemPrompt}\n\n${Prompts.ONBOARDING_SYSTEM_PROMPT}`,
|
|
91
123
|
};
|
|
@@ -99,12 +131,18 @@ export function createActorExtensionRuntime(
|
|
|
99
131
|
if (activeRunContext === ctx) automaticReview.schedule();
|
|
100
132
|
},
|
|
101
133
|
onSessionShutdown(reason, ctx) {
|
|
134
|
+
recipeResolutionContextsBySession.delete(getRunOwnerId(ctx));
|
|
102
135
|
activeRunContext = undefined;
|
|
103
136
|
automaticReview.close();
|
|
104
137
|
recipeReload.close();
|
|
105
138
|
runUiRuntime.shutdown(reason, ctx);
|
|
106
139
|
},
|
|
107
140
|
async onSessionStart(ctx) {
|
|
141
|
+
const sessionId = getRunOwnerId(ctx);
|
|
142
|
+
recipeResolutionContextsBySession.set(
|
|
143
|
+
sessionId,
|
|
144
|
+
RecipeResolution.createEmptyRecipeResolutionContext(sessionId, ctx.cwd),
|
|
145
|
+
);
|
|
108
146
|
ctx.ui.setWidget("zz-pi-actors-comms", undefined);
|
|
109
147
|
activeRunContext = ctx;
|
|
110
148
|
runUiRuntime.close();
|
|
@@ -113,7 +151,6 @@ export function createActorExtensionRuntime(
|
|
|
113
151
|
await Temp.prepareExtensionTempDir(Paths.EXTENSION_RUNTIME_PATHS.tempDir);
|
|
114
152
|
if (activeRunContext !== ctx) return;
|
|
115
153
|
automaticReview.start(ctx);
|
|
116
|
-
runtime.loadTools(ctx);
|
|
117
154
|
runUiRuntime.start(ctx);
|
|
118
155
|
recipeReload.watch(ctx);
|
|
119
156
|
},
|
|
@@ -129,6 +166,7 @@ export function createActorExtensionRuntime(
|
|
|
129
166
|
runtime.getTools(),
|
|
130
167
|
(activeName) => actorToolDefinitions.get(activeName),
|
|
131
168
|
),
|
|
169
|
+
getRuntimeToolStatus: runtime.getToolStatus,
|
|
132
170
|
handleRuntimeControl: automaticReview.handleControl,
|
|
133
171
|
registryRuntime: runtime,
|
|
134
172
|
setActiveTools: (toolNames) => pi.setActiveTools(toolNames),
|
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,11 @@ 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,
|
|
186
|
+
launch_kind: meta.launch_kind ?? meta.launch_source,
|
|
141
187
|
launch_source: meta.launch_source,
|
|
142
188
|
}),
|
|
143
189
|
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
|
@@ -14,7 +14,7 @@ export const REGISTER_TOOL_PROMPT_SNIPPET =
|
|
|
14
14
|
|
|
15
15
|
export const REGISTER_TOOL_GUIDELINES = [
|
|
16
16
|
"Use register_tool to wrap trusted local commands, scripts, programs, libraries, or template recipes as persistent pi tools.",
|
|
17
|
-
"After register_tool succeeds,
|
|
17
|
+
"After register_tool succeeds, trust its callable_now and activation result; persisted definitions remain available for admission after reload.",
|
|
18
18
|
'Set template=null or template="" in register_tool to delete a persisted tool.',
|
|
19
19
|
"Set update=true in register_tool to overwrite an existing tool registration.",
|
|
20
20
|
];
|
|
@@ -24,14 +24,14 @@ export const ONBOARDING_SYSTEM_PROMPT = `pi-actors quick model:
|
|
|
24
24
|
- Layers: task -> command template -> recipe/tool -> spawn -> run:<id>; tool:<name> wraps registered capabilities.
|
|
25
25
|
- Command templates stay sync and shell-free: string leaves split into executable + argv, infer .js/.mjs through node→bun→deno run and .sh through bash, and treat operators such as && as literal arguments; use template arrays for sequencing or an explicit trusted shell/script when shell semantics are required. Flags include args/defaults, parallel, concurrency, min_successful, when, timeout, delay, retry, failure, recover, repeat, accept_output, output.
|
|
26
26
|
- Placeholders support typed/default args plus {value??fallback} and {flag?yes:no}.
|
|
27
|
-
- ~/.pi/agent/recipes/*.json is actor muscle memory:
|
|
27
|
+
- ~/.pi/agent/recipes/*.json is actor muscle memory: valid admitted recipes are reconciled as tools across sessions; register_tool writes there and reports current activation truth.
|
|
28
28
|
- Recipes own template directly and may declare metadata/defaults/imports/control/artifacts; files >1 MiB or import depth >32 fail closed.
|
|
29
29
|
- Recipe imports are local variables; imported recipes are definitions, not nested async runs; parent async:true creates one run.
|
|
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
|
@@ -1,15 +1,60 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Recipe context prompt assembly.
|
|
3
|
-
* Zones: async runner prompt context, recipe provenance, LLM child launches
|
|
4
|
-
* Owns compact actor
|
|
2
|
+
* Recipe context contracts and prompt assembly.
|
|
3
|
+
* Zones: live session resolution, async runner prompt context, recipe provenance, LLM child launches
|
|
4
|
+
* Owns the immutable live Recipe environment and compact actor context appended to child-agent prompts.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
7
8
|
import { writeFileSync } from "node:fs";
|
|
8
|
-
import { basename } from "node:path";
|
|
9
|
+
import { basename, resolve } from "node:path";
|
|
9
10
|
|
|
10
11
|
import type { CommandTemplateActorRecipeContext } from "./command-templates.ts";
|
|
12
|
+
import * as RecipesReferences from "./recipes-references.ts";
|
|
11
13
|
import type { TemplateRecipeContextRecord } from "./recipes-references.ts";
|
|
12
14
|
|
|
15
|
+
export interface RecipeResolutionContext {
|
|
16
|
+
readonly activeSkills: RecipesReferences.ActiveSkillRecipeContext;
|
|
17
|
+
readonly cwd: string;
|
|
18
|
+
readonly generation: string;
|
|
19
|
+
readonly sessionId: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function createRecipeResolutionContext(
|
|
23
|
+
sessionId: string,
|
|
24
|
+
cwd: string,
|
|
25
|
+
activeSkills: RecipesReferences.ActiveSkillRecipeContext,
|
|
26
|
+
): RecipeResolutionContext {
|
|
27
|
+
const normalizedSessionId = sessionId.trim();
|
|
28
|
+
if (!normalizedSessionId) throw new Error("Recipe resolution session id is required.");
|
|
29
|
+
const normalizedCwd = resolve(cwd);
|
|
30
|
+
const generation = createHash("sha256")
|
|
31
|
+
.update(
|
|
32
|
+
JSON.stringify({
|
|
33
|
+
activeSkills: RecipesReferences.getActiveSkillRecipeNamespaces(activeSkills),
|
|
34
|
+
cwd: normalizedCwd,
|
|
35
|
+
sessionId: normalizedSessionId,
|
|
36
|
+
}),
|
|
37
|
+
)
|
|
38
|
+
.digest("hex");
|
|
39
|
+
return Object.freeze({
|
|
40
|
+
activeSkills,
|
|
41
|
+
cwd: normalizedCwd,
|
|
42
|
+
generation,
|
|
43
|
+
sessionId: normalizedSessionId,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function createEmptyRecipeResolutionContext(
|
|
48
|
+
sessionId: string,
|
|
49
|
+
cwd: string,
|
|
50
|
+
): RecipeResolutionContext {
|
|
51
|
+
return createRecipeResolutionContext(
|
|
52
|
+
sessionId,
|
|
53
|
+
cwd,
|
|
54
|
+
RecipesReferences.EMPTY_ACTIVE_SKILL_RECIPE_CONTEXT,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
13
58
|
export interface MarkedRecipeContextRecord extends TemplateRecipeContextRecord {
|
|
14
59
|
you_are_here?: true;
|
|
15
60
|
you_are_here_path?: string;
|
|
@@ -96,7 +141,7 @@ function matchesActorContext(
|
|
|
96
141
|
context: CommandTemplateActorRecipeContext | undefined,
|
|
97
142
|
): boolean {
|
|
98
143
|
if (!context) return record.role === "entry";
|
|
99
|
-
if (context.file && context.file === record.
|
|
144
|
+
if (context.file && context.file === record.source_file) return true;
|
|
100
145
|
if (context.name && context.name === record.name) return true;
|
|
101
146
|
if (context.alias && context.alias === record.alias) return true;
|
|
102
147
|
return false;
|
|
@@ -131,7 +176,7 @@ export function formatRecipeContextJsonl(
|
|
|
131
176
|
context?: CommandTemplateActorRecipeContext,
|
|
132
177
|
): string {
|
|
133
178
|
return markRecipeContextRecords(records, context)
|
|
134
|
-
.map((record) => JSON.stringify(record))
|
|
179
|
+
.map(({ source_file: _sourceFile, ...record }) => JSON.stringify(record))
|
|
135
180
|
.join("\n");
|
|
136
181
|
}
|
|
137
182
|
|