agentplane 0.3.13 → 0.3.15
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/assets/RUNNER.md +1 -1
- package/assets/agents/ORCHESTRATOR.json +1 -1
- package/assets/agents/SKILL_EXTRACTOR.json +31 -0
- package/assets/framework.manifest.json +7 -0
- package/assets/policy/incidents.md +5 -3
- package/assets/policy/workflow.branch_pr.md +10 -5
- package/dist/.build-manifest.json +280 -180
- package/dist/cli/output.d.ts +29 -0
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +33 -0
- package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/core.js +29 -87
- package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/lifecycle.js +4 -12
- package/dist/cli/run-cli/command-catalog/project.d.ts +1 -1
- package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/project.js +16 -38
- package/dist/cli/run-cli/command-catalog/shared.d.ts +9 -6
- package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/shared.js +23 -6
- package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/task.js +6 -18
- package/dist/cli/run-cli/command-catalog.d.ts +1 -1
- package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/recipes.js +1 -0
- package/dist/cli/run-cli.js +1 -1
- package/dist/cli/run-cli.test-helpers.d.ts +1 -74
- package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
- package/dist/cli/run-cli.test-helpers.js +1 -769
- package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
- package/dist/commands/branch/cleanup-merged.js +5 -9
- package/dist/commands/branch/work-start.command.d.ts.map +1 -1
- package/dist/commands/branch/work-start.command.js +1 -0
- package/dist/commands/commit.spec.d.ts.map +1 -1
- package/dist/commands/commit.spec.js +2 -0
- package/dist/commands/doctor/branch-pr.d.ts +1 -1
- package/dist/commands/doctor/branch-pr.d.ts.map +1 -1
- package/dist/commands/doctor/branch-pr.js +5 -2
- package/dist/commands/guard/impl/commands.d.ts.map +1 -1
- package/dist/commands/guard/impl/commands.js +4 -1
- package/dist/commands/guard/impl/comment-commit.d.ts.map +1 -1
- package/dist/commands/guard/impl/comment-commit.js +2 -1
- package/dist/commands/guard/impl/env.d.ts +6 -0
- package/dist/commands/guard/impl/env.d.ts.map +1 -1
- package/dist/commands/guard/impl/env.js +41 -0
- package/dist/commands/pr/internal/auto-commit.d.ts.map +1 -1
- package/dist/commands/pr/internal/auto-commit.js +2 -1
- package/dist/commands/pr/internal/sync-branch.d.ts +36 -0
- package/dist/commands/pr/internal/sync-branch.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-branch.js +113 -0
- package/dist/commands/pr/internal/sync-github.d.ts +28 -0
- package/dist/commands/pr/internal/sync-github.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-github.js +178 -0
- package/dist/commands/pr/internal/sync-model.d.ts +36 -0
- package/dist/commands/pr/internal/sync-model.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-model.js +1 -0
- package/dist/commands/pr/internal/sync-open-step.d.ts +10 -0
- package/dist/commands/pr/internal/sync-open-step.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-open-step.js +128 -0
- package/dist/commands/pr/internal/sync-support.d.ts +7 -0
- package/dist/commands/pr/internal/sync-support.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-support.js +29 -0
- package/dist/commands/pr/internal/sync-update-step.d.ts +6 -0
- package/dist/commands/pr/internal/sync-update-step.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-update-step.js +68 -0
- package/dist/commands/pr/internal/sync.d.ts +2 -6
- package/dist/commands/pr/internal/sync.d.ts.map +1 -1
- package/dist/commands/pr/internal/sync.js +83 -529
- package/dist/commands/pr/open.d.ts.map +1 -1
- package/dist/commands/pr/open.js +25 -8
- package/dist/commands/pr/pr.command.d.ts.map +1 -1
- package/dist/commands/pr/pr.command.js +7 -2
- package/dist/commands/recipes/impl/apply.d.ts +1 -1
- package/dist/commands/recipes/impl/apply.d.ts.map +1 -1
- package/dist/commands/recipes/impl/apply.js +1 -2
- package/dist/commands/recipes/impl/commands/active.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/active.js +6 -5
- package/dist/commands/recipes/impl/commands/add.d.ts +1 -0
- package/dist/commands/recipes/impl/commands/add.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/add.js +32 -27
- package/dist/commands/recipes/impl/commands/detach.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/detach.js +35 -21
- package/dist/commands/recipes/impl/commands/disable.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/disable.js +5 -3
- package/dist/commands/recipes/impl/commands/enable.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/enable.js +5 -3
- package/dist/commands/recipes/impl/commands/explain.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/explain.js +57 -47
- package/dist/commands/recipes/impl/commands/info.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/info.js +25 -21
- package/dist/commands/recipes/impl/commands/install.d.ts +1 -1
- package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/install.js +3 -13
- package/dist/commands/recipes/impl/commands/list-remote.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/list-remote.js +2 -3
- package/dist/commands/recipes/impl/commands/list.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/list.js +7 -6
- package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/remove.js +12 -7
- package/dist/commands/recipes/impl/commands/update.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/update.js +38 -24
- package/dist/commands/recipes/impl/index.d.ts +1 -1
- package/dist/commands/recipes/impl/index.d.ts.map +1 -1
- package/dist/commands/recipes/impl/installed-recipes.d.ts +1 -1
- package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -1
- package/dist/commands/recipes/impl/installed-recipes.js +1 -2
- package/dist/commands/recipes/impl/mutation-transaction.d.ts +7 -0
- package/dist/commands/recipes/impl/mutation-transaction.d.ts.map +1 -0
- package/dist/commands/recipes/impl/mutation-transaction.js +47 -0
- package/dist/commands/recipes/impl/overlay-project.d.ts +19 -3
- package/dist/commands/recipes/impl/overlay-project.d.ts.map +1 -1
- package/dist/commands/recipes/impl/overlay-project.js +76 -38
- package/dist/commands/recipes/impl/paths.d.ts +0 -3
- package/dist/commands/recipes/impl/paths.d.ts.map +1 -1
- package/dist/commands/recipes/impl/paths.js +0 -3
- package/dist/commands/recipes/impl/project-installed-recipes.d.ts +4 -1
- package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -1
- package/dist/commands/recipes/impl/project-installed-recipes.js +6 -4
- package/dist/commands/recipes/impl/project-recipe-state.d.ts +1 -1
- package/dist/commands/recipes/impl/project-recipe-state.d.ts.map +1 -1
- package/dist/commands/recipes/impl/project-registry.d.ts +5 -1
- package/dist/commands/recipes/impl/project-registry.d.ts.map +1 -1
- package/dist/commands/recipes/impl/project-registry.js +34 -14
- package/dist/commands/recipes/impl/resolver.d.ts +1 -1
- package/dist/commands/recipes/impl/resolver.d.ts.map +1 -1
- package/dist/commands/recipes/impl/resolver.js +1 -1
- package/dist/commands/recipes/impl/types.d.ts +1 -1
- package/dist/commands/recipes/impl/types.d.ts.map +1 -1
- package/dist/commands/recipes/impl/version.d.ts +5 -0
- package/dist/commands/recipes/impl/version.d.ts.map +1 -0
- package/dist/commands/recipes/impl/version.js +9 -0
- package/dist/commands/recipes.d.ts +5 -4
- package/dist/commands/recipes.d.ts.map +1 -1
- package/dist/commands/recipes.js +3 -3
- package/dist/commands/release/apply.command.d.ts +1 -1
- package/dist/commands/release/apply.command.d.ts.map +1 -1
- package/dist/commands/release/apply.command.js +15 -379
- package/dist/commands/release/apply.mutation.d.ts +1 -0
- package/dist/commands/release/apply.mutation.d.ts.map +1 -1
- package/dist/commands/release/apply.mutation.js +24 -1
- package/dist/commands/release/apply.pipeline.d.ts +22 -0
- package/dist/commands/release/apply.pipeline.d.ts.map +1 -0
- package/dist/commands/release/apply.pipeline.js +371 -0
- package/dist/commands/release/apply.preflight.d.ts +2 -0
- package/dist/commands/release/apply.preflight.d.ts.map +1 -1
- package/dist/commands/release/apply.preflight.js +13 -4
- package/dist/commands/release/apply.types.d.ts +27 -0
- package/dist/commands/release/apply.types.d.ts.map +1 -1
- package/dist/commands/release.test-helpers.d.ts +4 -0
- package/dist/commands/release.test-helpers.d.ts.map +1 -1
- package/dist/commands/release.test-helpers.js +7 -0
- package/dist/commands/shared/reconcile-check.d.ts.map +1 -1
- package/dist/commands/shared/reconcile-check.js +2 -2
- package/dist/commands/shared/task-backend.d.ts +6 -1
- package/dist/commands/shared/task-backend.d.ts.map +1 -1
- package/dist/commands/shared/task-backend.js +34 -2
- package/dist/commands/shared/task-mutation.d.ts.map +1 -1
- package/dist/commands/shared/task-mutation.js +4 -4
- package/dist/commands/shared/task-store/intents.d.ts +34 -0
- package/dist/commands/shared/task-store/intents.d.ts.map +1 -0
- package/dist/commands/shared/task-store/intents.js +265 -0
- package/dist/commands/shared/task-store/readme.d.ts +28 -0
- package/dist/commands/shared/task-store/readme.d.ts.map +1 -0
- package/dist/commands/shared/task-store/readme.js +125 -0
- package/dist/commands/shared/task-store/store.d.ts +26 -0
- package/dist/commands/shared/task-store/store.d.ts.map +1 -0
- package/dist/commands/shared/task-store/store.js +105 -0
- package/dist/commands/shared/task-store/types.d.ts +94 -0
- package/dist/commands/shared/task-store/types.d.ts.map +1 -0
- package/dist/commands/shared/task-store/types.js +1 -0
- package/dist/commands/shared/task-store.d.ts +3 -109
- package/dist/commands/shared/task-store.d.ts.map +1 -1
- package/dist/commands/shared/task-store.js +2 -493
- package/dist/commands/task/block.d.ts.map +1 -1
- package/dist/commands/task/block.js +7 -2
- package/dist/commands/task/comment.d.ts.map +1 -1
- package/dist/commands/task/comment.js +7 -2
- package/dist/commands/task/finish-shared.d.ts.map +1 -1
- package/dist/commands/task/finish-shared.js +3 -3
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +102 -15
- package/dist/commands/task/hosted-close.command.d.ts.map +1 -1
- package/dist/commands/task/hosted-close.command.js +23 -2
- package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
- package/dist/commands/task/hosted-merge-sync.js +9 -4
- package/dist/commands/task/list.run.d.ts.map +1 -1
- package/dist/commands/task/list.run.js +14 -4
- package/dist/commands/task/new.command.d.ts.map +1 -1
- package/dist/commands/task/new.command.js +16 -2
- package/dist/commands/task/new.js +2 -2
- package/dist/commands/task/show.d.ts.map +1 -1
- package/dist/commands/task/show.js +3 -3
- package/dist/commands/task/update.d.ts.map +1 -1
- package/dist/commands/task/update.js +11 -3
- package/dist/runner/adapters/codex.d.ts.map +1 -1
- package/dist/runner/adapters/codex.js +3 -33
- package/dist/runner/adapters/custom.d.ts.map +1 -1
- package/dist/runner/adapters/custom.js +3 -30
- package/dist/runner/adapters/runtime-shared.d.ts +14 -0
- package/dist/runner/adapters/runtime-shared.d.ts.map +1 -0
- package/dist/runner/adapters/runtime-shared.js +36 -0
- package/dist/runner/context/base-prompt-sources.d.ts +30 -0
- package/dist/runner/context/base-prompt-sources.d.ts.map +1 -0
- package/dist/runner/context/base-prompt-sources.js +144 -0
- package/dist/runner/context/base-prompts.d.ts +3 -22
- package/dist/runner/context/base-prompts.d.ts.map +1 -1
- package/dist/runner/context/base-prompts.js +6 -450
- package/dist/runner/context/overlay-prompt-blocks.d.ts +7 -0
- package/dist/runner/context/overlay-prompt-blocks.d.ts.map +1 -0
- package/dist/runner/context/overlay-prompt-blocks.js +72 -0
- package/dist/runner/context/prompt-block-shared.d.ts +54 -0
- package/dist/runner/context/prompt-block-shared.d.ts.map +1 -0
- package/dist/runner/context/prompt-block-shared.js +106 -0
- package/dist/runner/context/recipe-context.d.ts +2 -1
- package/dist/runner/context/recipe-context.d.ts.map +1 -1
- package/dist/runner/context/recipe-context.js +2 -1
- package/dist/runner/context/recipe-prompt-blocks.d.ts +6 -0
- package/dist/runner/context/recipe-prompt-blocks.d.ts.map +1 -0
- package/dist/runner/context/recipe-prompt-blocks.js +143 -0
- package/dist/runner/usecases/scenario-materialize-task.js +2 -2
- package/dist/runner/usecases/task-run-inspect.js +2 -2
- package/dist/runner/usecases/task-run-lifecycle-shared.js +2 -2
- package/dist/runner/usecases/task-run.d.ts.map +1 -1
- package/dist/runner/usecases/task-run.js +4 -2
- package/dist/runtime/capabilities/recipe.d.ts +1 -1
- package/dist/runtime/capabilities/recipe.d.ts.map +1 -1
- package/dist/runtime/execution-context.d.ts +63 -0
- package/dist/runtime/execution-context.d.ts.map +1 -0
- package/dist/{usecases/context/resolve-context.js → runtime/execution-context.js} +23 -26
- package/dist/runtime/incidents/advice-strategy.d.ts +15 -0
- package/dist/runtime/incidents/advice-strategy.d.ts.map +1 -0
- package/dist/runtime/incidents/advice-strategy.js +54 -0
- package/dist/runtime/incidents/plan-strategy.d.ts +9 -0
- package/dist/runtime/incidents/plan-strategy.d.ts.map +1 -0
- package/dist/runtime/incidents/plan-strategy.js +205 -0
- package/dist/runtime/incidents/registry-strategy.d.ts +6 -0
- package/dist/runtime/incidents/registry-strategy.d.ts.map +1 -0
- package/dist/runtime/incidents/registry-strategy.js +280 -0
- package/dist/runtime/incidents/resolve.d.ts +3 -25
- package/dist/runtime/incidents/resolve.d.ts.map +1 -1
- package/dist/runtime/incidents/resolve.js +3 -683
- package/dist/runtime/incidents/shared.d.ts +34 -0
- package/dist/runtime/incidents/shared.d.ts.map +1 -0
- package/dist/runtime/incidents/shared.js +171 -0
- package/dist/testing/cli-harness/recipe-archives.d.ts +28 -0
- package/dist/testing/cli-harness/recipe-archives.d.ts.map +1 -0
- package/dist/testing/cli-harness/recipe-archives.js +374 -0
- package/dist/testing/cli-harness/stdio.d.ts +26 -0
- package/dist/testing/cli-harness/stdio.d.ts.map +1 -0
- package/dist/testing/cli-harness/stdio.js +84 -0
- package/dist/testing/cli-harness.d.ts +25 -0
- package/dist/testing/cli-harness.d.ts.map +1 -0
- package/dist/testing/cli-harness.js +313 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +1 -0
- package/package.json +7 -4
- package/dist/commands/recipes/impl/manifest.d.ts +0 -4
- package/dist/commands/recipes/impl/manifest.d.ts.map +0 -1
- package/dist/commands/recipes/impl/manifest.js +0 -7
- package/dist/commands/recipes/impl/normalize.d.ts +0 -8
- package/dist/commands/recipes/impl/normalize.d.ts.map +0 -1
- package/dist/commands/recipes/impl/normalize.js +0 -54
- package/dist/commands/recipes/impl/scenario.d.ts +0 -16
- package/dist/commands/recipes/impl/scenario.d.ts.map +0 -1
- package/dist/commands/recipes/impl/scenario.js +0 -262
- package/dist/recipes/bundled-recipes.d.ts +0 -17
- package/dist/recipes/bundled-recipes.d.ts.map +0 -1
- package/dist/recipes/bundled-recipes.js +0 -15
- package/dist/usecases/context/resolve-context.d.ts +0 -68
- package/dist/usecases/context/resolve-context.d.ts.map +0 -1
- package/dist/usecases/task/task-list-usecase.d.ts +0 -9
- package/dist/usecases/task/task-list-usecase.d.ts.map +0 -1
- package/dist/usecases/task/task-list-usecase.js +0 -17
- package/dist/usecases/task/task-new-usecase.d.ts +0 -9
- package/dist/usecases/task/task-new-usecase.d.ts.map +0 -1
- package/dist/usecases/task/task-new-usecase.js +0 -17
|
@@ -1,453 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { resolveBehavior, stripBehaviorValue, } from "../../runtime/behavior/index.js";
|
|
7
|
-
import { resolvePolicyGatewayForRepo, } from "../../shared/policy-gateway.js";
|
|
8
|
-
const FRAMEWORK_RUNNER_PROMPT_URL = new URL("../../../assets/RUNNER.md", import.meta.url);
|
|
9
|
-
const BASE_PROMPT_PRIORITIES = {
|
|
10
|
-
framework_runner: 100,
|
|
11
|
-
policy_gateway: 200,
|
|
12
|
-
execution_profile: 250,
|
|
13
|
-
owner_profile: 300,
|
|
14
|
-
recipe_execution_context: 400,
|
|
15
|
-
recipe_agent_profile: 500,
|
|
16
|
-
recipe_skill_context: 600,
|
|
17
|
-
recipe_tools_context: 700,
|
|
18
|
-
};
|
|
19
|
-
const OVERLAY_PROMPT_PRIORITIES = {
|
|
20
|
-
planning: 410,
|
|
21
|
-
execution: 420,
|
|
22
|
-
coding: 430,
|
|
23
|
-
debugging: 440,
|
|
24
|
-
review: 450,
|
|
25
|
-
verification: 460,
|
|
26
|
-
docs: 470,
|
|
27
|
-
finish: 480,
|
|
28
|
-
};
|
|
29
|
-
function ensureTrailingNewline(text) {
|
|
30
|
-
return text.endsWith("\n") ? text : `${text}\n`;
|
|
31
|
-
}
|
|
32
|
-
function normalizeOwnerId(ownerIdRaw) {
|
|
33
|
-
const trimmed = ownerIdRaw.trim();
|
|
34
|
-
if (!trimmed)
|
|
35
|
-
throw new Error("Runner base prompt collection requires a non-empty owner id.");
|
|
36
|
-
return trimmed.toUpperCase();
|
|
37
|
-
}
|
|
38
|
-
function normalizeText(text) {
|
|
39
|
-
return ensureTrailingNewline(text.trimEnd());
|
|
40
|
-
}
|
|
41
|
-
async function detectRepoTypes(gitRoot) {
|
|
42
|
-
const repoTypes = ["generic"];
|
|
43
|
-
const checks = [
|
|
44
|
-
["package.json", "node"],
|
|
45
|
-
["pyproject.toml", "python"],
|
|
46
|
-
["go.mod", "go"],
|
|
47
|
-
["Cargo.toml", "rust"],
|
|
48
|
-
];
|
|
49
|
-
for (const [relativePath, repoType] of checks) {
|
|
50
|
-
if (await fileExists(path.join(gitRoot, relativePath)))
|
|
51
|
-
repoTypes.push(repoType);
|
|
52
|
-
}
|
|
53
|
-
return [...new Set(repoTypes)].toSorted();
|
|
54
|
-
}
|
|
55
|
-
function inferTaskKind(task) {
|
|
56
|
-
const tags = Array.isArray(task?.data.tags)
|
|
57
|
-
? task?.data.tags.filter((tag) => typeof tag === "string")
|
|
58
|
-
: [];
|
|
59
|
-
if (tags.includes("docs"))
|
|
60
|
-
return "docs";
|
|
61
|
-
if (tags.includes("refactor"))
|
|
62
|
-
return "refactor";
|
|
63
|
-
if (tags.includes("research"))
|
|
64
|
-
return "research";
|
|
65
|
-
if (tags.includes("bug") || tags.includes("bugfix"))
|
|
66
|
-
return "bugfix";
|
|
67
|
-
if (tags.length > 0)
|
|
68
|
-
return "feature";
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
function validateJsonPrompt(source, text) {
|
|
72
|
-
let parsed;
|
|
73
|
-
try {
|
|
74
|
-
parsed = JSON.parse(text);
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
throw new Error(`Invalid prompt JSON: ${source} (malformed JSON)`);
|
|
78
|
-
}
|
|
79
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
80
|
-
throw new Error(`Invalid prompt JSON: ${source} (expected object)`);
|
|
81
|
-
}
|
|
82
|
-
return normalizeText(text);
|
|
83
|
-
}
|
|
84
|
-
function renderRecipePromptJson(value) {
|
|
85
|
-
return normalizeText(JSON.stringify(value, null, 2));
|
|
86
|
-
}
|
|
87
|
-
async function collectOverlayPromptBlocks(opts) {
|
|
88
|
-
const bundlePath = path.join(opts.git_root, ".agentplane", "generated", "overlay-bundle.json");
|
|
89
|
-
if (!(await fileExists(bundlePath)))
|
|
90
|
-
return [];
|
|
91
|
-
const bundle = JSON.parse(await readFile(bundlePath, "utf8"));
|
|
92
|
-
const repoTypes = await detectRepoTypes(opts.git_root);
|
|
93
|
-
const tags = Array.isArray(opts.task?.data.tags)
|
|
94
|
-
? opts.task?.data.tags.filter((tag) => typeof tag === "string")
|
|
95
|
-
: [];
|
|
96
|
-
const taskKind = inferTaskKind(opts.task);
|
|
97
|
-
const blocks = [];
|
|
98
|
-
for (const [surface, fragments] of Object.entries(bundle.surfaces)) {
|
|
99
|
-
for (const fragment of fragments) {
|
|
100
|
-
if (!matchOverlayWhen(fragment.when, {
|
|
101
|
-
task_kind: taskKind,
|
|
102
|
-
tags,
|
|
103
|
-
repo_types: repoTypes,
|
|
104
|
-
})) {
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
blocks.push({
|
|
108
|
-
id: `overlay.${fragment.recipe_id}.${fragment.id}`,
|
|
109
|
-
role: fragment.strength === "required" ? "policy" : "context",
|
|
110
|
-
title: `${fragment.recipe_name}: ${fragment.id}`,
|
|
111
|
-
source: fragment.source,
|
|
112
|
-
priority: OVERLAY_PROMPT_PRIORITIES[surface] +
|
|
113
|
-
(fragment.order ?? 0),
|
|
114
|
-
surface: surface,
|
|
115
|
-
strength: fragment.strength,
|
|
116
|
-
content: normalizeText(fragment.content),
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return blocks;
|
|
121
|
-
}
|
|
122
|
-
function toPromptSource(gitRoot, absPath) {
|
|
123
|
-
return path.relative(gitRoot, absPath).replaceAll("\\", "/");
|
|
124
|
-
}
|
|
125
|
-
function isRecord(value) {
|
|
126
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
127
|
-
}
|
|
128
|
-
function readOptionalStringArray(value) {
|
|
129
|
-
return Array.isArray(value)
|
|
130
|
-
? value.filter((entry) => typeof entry === "string")
|
|
131
|
-
: [];
|
|
132
|
-
}
|
|
133
|
-
function promptCandidate(opts) {
|
|
134
|
-
return {
|
|
135
|
-
layer: opts.layer,
|
|
136
|
-
source: opts.source,
|
|
137
|
-
value: opts.value,
|
|
138
|
-
order: opts.order,
|
|
139
|
-
metadata: {
|
|
140
|
-
title: opts.value.title,
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
function promptBlockFromResolved(opts) {
|
|
145
|
-
return {
|
|
146
|
-
id: opts.id,
|
|
147
|
-
role: opts.role,
|
|
148
|
-
title: opts.resolved.value.title,
|
|
149
|
-
source: opts.resolved.value.source,
|
|
150
|
-
priority: opts.priority,
|
|
151
|
-
content: opts.resolved.value.content,
|
|
152
|
-
resolution: stripBehaviorValue(opts.resolved),
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
async function resolveRepoAgentProfilePath(opts) {
|
|
156
|
-
const agentsDir = path.join(opts.git_root, opts.agents_dir);
|
|
157
|
-
if (!(await fileExists(agentsDir)))
|
|
158
|
-
return null;
|
|
159
|
-
const entries = await readdir(agentsDir);
|
|
160
|
-
const wanted = `${opts.owner_id}.json`.toLowerCase();
|
|
161
|
-
const match = entries.find((entry) => entry.endsWith(".json") && entry.toLowerCase() === wanted);
|
|
162
|
-
if (!match)
|
|
163
|
-
return null;
|
|
164
|
-
return path.join(agentsDir, match);
|
|
165
|
-
}
|
|
166
|
-
export async function resolveOwnerProfilePromptSource(opts) {
|
|
167
|
-
const candidates = [];
|
|
168
|
-
const repoProfilePath = await resolveRepoAgentProfilePath(opts);
|
|
169
|
-
if (repoProfilePath) {
|
|
170
|
-
const source = toPromptSource(opts.git_root, repoProfilePath);
|
|
171
|
-
candidates.push(promptCandidate({
|
|
172
|
-
layer: "user",
|
|
173
|
-
source,
|
|
174
|
-
value: {
|
|
175
|
-
source,
|
|
176
|
-
title: `Owner Agent Profile (${opts.owner_id})`,
|
|
177
|
-
content: validateJsonPrompt(source, await readFile(repoProfilePath, "utf8")),
|
|
178
|
-
},
|
|
179
|
-
}));
|
|
180
|
-
}
|
|
181
|
-
const bundledFileName = `${opts.owner_id}.json`;
|
|
182
|
-
const bundledTemplates = await loadAgentTemplates();
|
|
183
|
-
const bundled = bundledTemplates.find((entry) => entry.fileName.toLowerCase() === bundledFileName.toLowerCase());
|
|
184
|
-
if (!bundled) {
|
|
185
|
-
throw new Error(`Bundled agent profile not found: ${bundledFileName}`);
|
|
186
|
-
}
|
|
187
|
-
candidates.push(promptCandidate({
|
|
188
|
-
layer: "builtin",
|
|
189
|
-
source: `bundled:agent-profile:${bundled.fileName}`,
|
|
190
|
-
value: {
|
|
191
|
-
source: `bundled:agent-profile:${bundled.fileName}`,
|
|
192
|
-
title: `Owner Agent Profile (${opts.owner_id})`,
|
|
193
|
-
content: validateJsonPrompt(`bundled:agent-profile:${bundled.fileName}`, bundled.contents),
|
|
194
|
-
},
|
|
195
|
-
order: 10,
|
|
196
|
-
}));
|
|
197
|
-
return resolveBehavior({
|
|
198
|
-
key: `runner.owner_profile:${opts.owner_id}`,
|
|
199
|
-
candidates,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
async function loadOwnerProfilePrompt(opts) {
|
|
203
|
-
const resolved = await resolveOwnerProfilePromptSource(opts);
|
|
204
|
-
return promptBlockFromResolved({
|
|
205
|
-
id: "base.owner_profile",
|
|
206
|
-
role: "profile",
|
|
207
|
-
priority: BASE_PROMPT_PRIORITIES.owner_profile,
|
|
208
|
-
resolved,
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
async function loadFrameworkRunnerPrompt() {
|
|
212
|
-
const resolved = resolveBehavior({
|
|
213
|
-
key: "runner.framework_prompt",
|
|
214
|
-
candidates: [
|
|
215
|
-
promptCandidate({
|
|
216
|
-
layer: "builtin",
|
|
217
|
-
source: "bundled:runner-prompt:RUNNER.md",
|
|
218
|
-
value: {
|
|
219
|
-
source: "bundled:runner-prompt:RUNNER.md",
|
|
220
|
-
title: "Framework Runner Prompt",
|
|
221
|
-
content: normalizeText(await readFile(FRAMEWORK_RUNNER_PROMPT_URL, "utf8")),
|
|
222
|
-
},
|
|
223
|
-
}),
|
|
224
|
-
],
|
|
225
|
-
});
|
|
226
|
-
return promptBlockFromResolved({
|
|
227
|
-
id: "base.framework_runner",
|
|
228
|
-
role: "system",
|
|
229
|
-
priority: BASE_PROMPT_PRIORITIES.framework_runner,
|
|
230
|
-
resolved,
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
export async function resolvePolicyGatewayPromptSource(opts) {
|
|
234
|
-
const gateway = opts.harness?.repo.policy_gateway ??
|
|
235
|
-
(await resolvePolicyGatewayForRepo({
|
|
236
|
-
gitRoot: opts.git_root,
|
|
237
|
-
fallbackFlavor: opts.fallback_flavor,
|
|
238
|
-
}));
|
|
239
|
-
const candidates = [];
|
|
240
|
-
if (await fileExists(gateway.absPath)) {
|
|
241
|
-
const source = path.relative(opts.git_root, gateway.absPath).replaceAll("\\", "/");
|
|
242
|
-
candidates.push(promptCandidate({
|
|
243
|
-
layer: "harness",
|
|
244
|
-
source,
|
|
245
|
-
value: {
|
|
246
|
-
source,
|
|
247
|
-
title: `Repository Policy Gateway (${gateway.fileName})`,
|
|
248
|
-
content: normalizeText(await readFile(gateway.absPath, "utf8")),
|
|
249
|
-
},
|
|
250
|
-
}));
|
|
251
|
-
}
|
|
252
|
-
candidates.push(promptCandidate({
|
|
253
|
-
layer: "builtin",
|
|
254
|
-
source: `bundled:policy-gateway:${gateway.fileName}`,
|
|
255
|
-
value: {
|
|
256
|
-
source: `bundled:policy-gateway:${gateway.fileName}`,
|
|
257
|
-
title: `Bundled Policy Gateway Fallback (${gateway.fileName})`,
|
|
258
|
-
content: await loadPolicyGatewayTemplate(gateway.flavor),
|
|
259
|
-
},
|
|
260
|
-
order: 10,
|
|
261
|
-
}));
|
|
262
|
-
return resolveBehavior({
|
|
263
|
-
key: `runner.policy_gateway:${gateway.fileName}`,
|
|
264
|
-
candidates,
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
async function loadPolicyGatewayPrompt(opts) {
|
|
268
|
-
const resolved = await resolvePolicyGatewayPromptSource(opts);
|
|
269
|
-
return promptBlockFromResolved({
|
|
270
|
-
id: "base.policy_gateway",
|
|
271
|
-
role: "policy",
|
|
272
|
-
priority: BASE_PROMPT_PRIORITIES.policy_gateway,
|
|
273
|
-
resolved,
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
function renderExecutionProfilePromptContent(runtime) {
|
|
277
|
-
return renderRecipePromptJson({
|
|
278
|
-
profile: runtime.profile,
|
|
279
|
-
reasoning_effort: runtime.reasoning_effort,
|
|
280
|
-
budget: runtime.budget,
|
|
281
|
-
approvals: runtime.approvals,
|
|
282
|
-
stop_conditions: runtime.stop_conditions,
|
|
283
|
-
handoff_conditions: runtime.handoff_conditions,
|
|
284
|
-
unsafe_actions_requiring_explicit_user_ok: runtime.unsafe_actions_requiring_explicit_user_ok,
|
|
285
|
-
runner: runtime.runner,
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
function loadExecutionProfilePrompt(opts) {
|
|
289
|
-
if (!opts.execution_profile)
|
|
290
|
-
return null;
|
|
291
|
-
const source = `runtime:execution-profile:${opts.execution_profile.profile}`;
|
|
292
|
-
const resolved = resolveBehavior({
|
|
293
|
-
key: "runner.execution_profile",
|
|
294
|
-
candidates: [
|
|
295
|
-
promptCandidate({
|
|
296
|
-
layer: "harness",
|
|
297
|
-
source,
|
|
298
|
-
value: {
|
|
299
|
-
source,
|
|
300
|
-
title: `Execution Profile Runtime (${opts.execution_profile.profile})`,
|
|
301
|
-
content: renderExecutionProfilePromptContent(opts.execution_profile),
|
|
302
|
-
},
|
|
303
|
-
}),
|
|
304
|
-
],
|
|
305
|
-
});
|
|
306
|
-
return promptBlockFromResolved({
|
|
307
|
-
id: "base.execution_profile",
|
|
308
|
-
role: "policy",
|
|
309
|
-
priority: BASE_PROMPT_PRIORITIES.execution_profile,
|
|
310
|
-
resolved,
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
async function loadRecipePromptTextBlock(opts) {
|
|
314
|
-
const candidates = [];
|
|
315
|
-
const relativeFile = opts.relative_file?.trim();
|
|
316
|
-
if (relativeFile) {
|
|
317
|
-
const absPath = path.join(opts.recipe_dir, relativeFile);
|
|
318
|
-
if (await fileExists(absPath)) {
|
|
319
|
-
const source = toPromptSource(opts.git_root, absPath);
|
|
320
|
-
candidates.push(promptCandidate({
|
|
321
|
-
layer: "extension",
|
|
322
|
-
source,
|
|
323
|
-
value: {
|
|
324
|
-
source,
|
|
325
|
-
title: opts.title,
|
|
326
|
-
content: normalizeText(await readFile(absPath, "utf8")),
|
|
327
|
-
},
|
|
328
|
-
}));
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
if (typeof opts.fallback_content === "string" && opts.fallback_content.trim().length > 0) {
|
|
332
|
-
candidates.push(promptCandidate({
|
|
333
|
-
layer: "extension",
|
|
334
|
-
source: opts.fallback_source,
|
|
335
|
-
value: {
|
|
336
|
-
source: opts.fallback_source,
|
|
337
|
-
title: opts.title,
|
|
338
|
-
content: normalizeText(opts.fallback_content),
|
|
339
|
-
},
|
|
340
|
-
order: 10,
|
|
341
|
-
}));
|
|
342
|
-
}
|
|
343
|
-
else if (opts.fallback_payload) {
|
|
344
|
-
candidates.push(promptCandidate({
|
|
345
|
-
layer: "extension",
|
|
346
|
-
source: opts.fallback_source,
|
|
347
|
-
value: {
|
|
348
|
-
source: opts.fallback_source,
|
|
349
|
-
title: opts.title,
|
|
350
|
-
content: renderRecipePromptJson(opts.fallback_payload),
|
|
351
|
-
},
|
|
352
|
-
order: 10,
|
|
353
|
-
}));
|
|
354
|
-
}
|
|
355
|
-
const resolved = resolveBehavior({
|
|
356
|
-
key: opts.prompt_id,
|
|
357
|
-
candidates,
|
|
358
|
-
});
|
|
359
|
-
return promptBlockFromResolved({
|
|
360
|
-
id: opts.prompt_id,
|
|
361
|
-
role: opts.role,
|
|
362
|
-
priority: opts.priority,
|
|
363
|
-
resolved,
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
async function collectRecipePromptBlocks(opts) {
|
|
367
|
-
const recipeDir = opts.recipe.recipe_dir?.trim();
|
|
368
|
-
if (!recipeDir)
|
|
369
|
-
return [];
|
|
370
|
-
const promptBlocks = [];
|
|
371
|
-
const scenario = isRecord(opts.recipe.scenario) ? opts.recipe.scenario : {};
|
|
372
|
-
const executionContext = {
|
|
373
|
-
recipe: {
|
|
374
|
-
id: opts.recipe.recipe_id,
|
|
375
|
-
name: opts.recipe.recipe_name ?? null,
|
|
376
|
-
version: opts.recipe.recipe_version ?? null,
|
|
377
|
-
scenario_id: opts.recipe.scenario_id,
|
|
378
|
-
scenario_file: opts.recipe.scenario_file ?? null,
|
|
379
|
-
},
|
|
380
|
-
selection_reasons: opts.recipe.selection_reasons ?? [],
|
|
381
|
-
run_profile: opts.recipe.run_profile ?? {},
|
|
382
|
-
scenario: {
|
|
383
|
-
summary: typeof scenario.summary === "string" ? scenario.summary : null,
|
|
384
|
-
description: typeof scenario.description === "string" ? scenario.description : null,
|
|
385
|
-
goal: typeof scenario.goal === "string" ? scenario.goal : null,
|
|
386
|
-
evidence: isRecord(scenario.evidence) ? scenario.evidence : null,
|
|
387
|
-
outputs: readOptionalStringArray(scenario.outputs),
|
|
388
|
-
},
|
|
389
|
-
};
|
|
390
|
-
promptBlocks.push({
|
|
391
|
-
id: "recipe.execution_context",
|
|
392
|
-
role: "context",
|
|
393
|
-
title: `Recipe Scenario Context (${opts.recipe.recipe_id}:${opts.recipe.scenario_id})`,
|
|
394
|
-
source: `recipe:${opts.recipe.recipe_id}:${opts.recipe.scenario_id}`,
|
|
395
|
-
priority: BASE_PROMPT_PRIORITIES.recipe_execution_context,
|
|
396
|
-
content: renderRecipePromptJson(executionContext),
|
|
397
|
-
});
|
|
398
|
-
const agentBlocks = await Promise.all((opts.recipe.agents ?? []).map(async (agent, index) => {
|
|
399
|
-
const agentId = typeof agent.id === "string" ? agent.id : `agent_${index + 1}`;
|
|
400
|
-
return loadRecipePromptTextBlock({
|
|
401
|
-
git_root: opts.git_root,
|
|
402
|
-
recipe_dir: recipeDir,
|
|
403
|
-
prompt_id: `recipe.agent.${agentId}`,
|
|
404
|
-
role: "profile",
|
|
405
|
-
title: `Recipe Agent Prompt (${agentId})`,
|
|
406
|
-
relative_file: typeof agent.file === "string" ? agent.file : undefined,
|
|
407
|
-
fallback_source: `recipe:${opts.recipe.recipe_id}:agent:${agentId}`,
|
|
408
|
-
fallback_content: typeof agent.content === "string" ? agent.content : undefined,
|
|
409
|
-
fallback_payload: agent,
|
|
410
|
-
priority: BASE_PROMPT_PRIORITIES.recipe_agent_profile + index,
|
|
411
|
-
});
|
|
412
|
-
}));
|
|
413
|
-
promptBlocks.push(...agentBlocks);
|
|
414
|
-
const skillBlocks = await Promise.all((opts.recipe.skills ?? []).map(async (skill, index) => {
|
|
415
|
-
const skillId = typeof skill.id === "string" ? skill.id : `skill_${index + 1}`;
|
|
416
|
-
return loadRecipePromptTextBlock({
|
|
417
|
-
git_root: opts.git_root,
|
|
418
|
-
recipe_dir: recipeDir,
|
|
419
|
-
prompt_id: `recipe.skill.${skillId}`,
|
|
420
|
-
role: "context",
|
|
421
|
-
title: `Recipe Skill Prompt (${skillId})`,
|
|
422
|
-
relative_file: typeof skill.file === "string" ? skill.file : undefined,
|
|
423
|
-
fallback_source: `recipe:${opts.recipe.recipe_id}:skill:${skillId}`,
|
|
424
|
-
fallback_content: typeof skill.content === "string" ? skill.content : undefined,
|
|
425
|
-
fallback_payload: skill,
|
|
426
|
-
priority: BASE_PROMPT_PRIORITIES.recipe_skill_context + index,
|
|
427
|
-
});
|
|
428
|
-
}));
|
|
429
|
-
promptBlocks.push(...skillBlocks);
|
|
430
|
-
if ((opts.recipe.tools ?? []).length > 0) {
|
|
431
|
-
const toolPayload = (opts.recipe.tools ?? []).map((tool) => ({
|
|
432
|
-
id: typeof tool.id === "string" ? tool.id : null,
|
|
433
|
-
summary: typeof tool.summary === "string" ? tool.summary : null,
|
|
434
|
-
runtime: typeof tool.runtime === "string" ? tool.runtime : null,
|
|
435
|
-
entrypoint: typeof tool.entrypoint === "string" ? tool.entrypoint : null,
|
|
436
|
-
permissions: readOptionalStringArray(tool.permissions),
|
|
437
|
-
timeout_ms: typeof tool.timeout_ms === "number" ? tool.timeout_ms : null,
|
|
438
|
-
cwd_policy: typeof tool.cwd_policy === "string" ? tool.cwd_policy : null,
|
|
439
|
-
}));
|
|
440
|
-
promptBlocks.push({
|
|
441
|
-
id: "recipe.tools_summary",
|
|
442
|
-
role: "context",
|
|
443
|
-
title: "Recipe Tool Context",
|
|
444
|
-
source: `recipe:${opts.recipe.recipe_id}:tools`,
|
|
445
|
-
priority: BASE_PROMPT_PRIORITIES.recipe_tools_context,
|
|
446
|
-
content: renderRecipePromptJson(toolPayload),
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
return promptBlocks;
|
|
450
|
-
}
|
|
1
|
+
import { loadExecutionProfilePrompt, loadOwnerProfilePrompt, loadPolicyGatewayPrompt, } from "./base-prompt-sources.js";
|
|
2
|
+
import { collectOverlayPromptBlocks } from "./overlay-prompt-blocks.js";
|
|
3
|
+
import { loadFrameworkRunnerPrompt, normalizeOwnerId } from "./prompt-block-shared.js";
|
|
4
|
+
import { collectRecipePromptBlocks } from "./recipe-prompt-blocks.js";
|
|
5
|
+
export { resolveOwnerProfilePromptSource, resolvePolicyGatewayPromptSource, } from "./base-prompt-sources.js";
|
|
451
6
|
export async function collectRunnerBasePrompts(opts) {
|
|
452
7
|
const owner_id = normalizeOwnerId(opts.owner_id);
|
|
453
8
|
const trimmedAgentsDir = opts.agents_dir?.trim() ?? opts.harness?.workflow.paths.agents_dir;
|
|
@@ -469,6 +24,7 @@ export async function collectRunnerBasePrompts(opts) {
|
|
|
469
24
|
...(await collectOverlayPromptBlocks({
|
|
470
25
|
git_root: opts.git_root,
|
|
471
26
|
task: opts.task,
|
|
27
|
+
command: opts.command,
|
|
472
28
|
})),
|
|
473
29
|
...(await collectRecipePromptBlocks({
|
|
474
30
|
git_root: opts.git_root,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RunnerPromptBlock, RunnerTaskContext } from "../types.js";
|
|
2
|
+
export declare function collectOverlayPromptBlocks(opts: {
|
|
3
|
+
git_root: string;
|
|
4
|
+
task?: RunnerTaskContext;
|
|
5
|
+
command?: string;
|
|
6
|
+
}): Promise<RunnerPromptBlock[]>;
|
|
7
|
+
//# sourceMappingURL=overlay-prompt-blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay-prompt-blocks.d.ts","sourceRoot":"","sources":["../../../src/runner/context/overlay-prompt-blocks.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AA6BxE,wBAAsB,0BAA0B,CAAC,IAAI,EAAE;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAuC/B"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { matchOverlayWhen } from "@agentplaneorg/recipes";
|
|
3
|
+
import { fileExists } from "../../cli/fs-utils.js";
|
|
4
|
+
import { readProjectOverlayBundle } from "../../commands/recipes.js";
|
|
5
|
+
import { normalizeText, OVERLAY_PROMPT_PRIORITIES } from "./prompt-block-shared.js";
|
|
6
|
+
async function detectRepoTypes(gitRoot) {
|
|
7
|
+
const repoTypes = ["generic"];
|
|
8
|
+
const checks = [
|
|
9
|
+
["package.json", "node"],
|
|
10
|
+
["pyproject.toml", "python"],
|
|
11
|
+
["go.mod", "go"],
|
|
12
|
+
["Cargo.toml", "rust"],
|
|
13
|
+
];
|
|
14
|
+
for (const [relativePath, repoType] of checks) {
|
|
15
|
+
if (await fileExists(path.join(gitRoot, relativePath)))
|
|
16
|
+
repoTypes.push(repoType);
|
|
17
|
+
}
|
|
18
|
+
return [...new Set(repoTypes)].toSorted();
|
|
19
|
+
}
|
|
20
|
+
function inferTaskKind(task) {
|
|
21
|
+
const tags = Array.isArray(task?.data.tags)
|
|
22
|
+
? task.data.tags.filter((tag) => typeof tag === "string")
|
|
23
|
+
: [];
|
|
24
|
+
if (tags.includes("docs"))
|
|
25
|
+
return "docs";
|
|
26
|
+
if (tags.includes("refactor"))
|
|
27
|
+
return "refactor";
|
|
28
|
+
if (tags.includes("research"))
|
|
29
|
+
return "research";
|
|
30
|
+
if (tags.includes("bug") || tags.includes("bugfix"))
|
|
31
|
+
return "bugfix";
|
|
32
|
+
if (tags.length > 0)
|
|
33
|
+
return "feature";
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
export async function collectOverlayPromptBlocks(opts) {
|
|
37
|
+
const bundle = await readProjectOverlayBundle({
|
|
38
|
+
agentplaneDir: path.join(opts.git_root, ".agentplane"),
|
|
39
|
+
});
|
|
40
|
+
if (!bundle)
|
|
41
|
+
return [];
|
|
42
|
+
const repoTypes = await detectRepoTypes(opts.git_root);
|
|
43
|
+
const tags = Array.isArray(opts.task?.data.tags)
|
|
44
|
+
? opts.task.data.tags.filter((tag) => typeof tag === "string")
|
|
45
|
+
: [];
|
|
46
|
+
const taskKind = inferTaskKind(opts.task);
|
|
47
|
+
const blocks = [];
|
|
48
|
+
for (const [surface, fragments] of Object.entries(bundle.surfaces)) {
|
|
49
|
+
for (const fragment of fragments) {
|
|
50
|
+
if (!matchOverlayWhen(fragment.when, {
|
|
51
|
+
task_kind: taskKind,
|
|
52
|
+
command: opts.command,
|
|
53
|
+
tags,
|
|
54
|
+
repo_types: repoTypes,
|
|
55
|
+
})) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
blocks.push({
|
|
59
|
+
id: `overlay.${fragment.recipe_id}.${fragment.id}`,
|
|
60
|
+
role: fragment.strength === "required" ? "policy" : "context",
|
|
61
|
+
title: `${fragment.recipe_name}: ${fragment.id}`,
|
|
62
|
+
source: fragment.source,
|
|
63
|
+
priority: OVERLAY_PROMPT_PRIORITIES[surface] +
|
|
64
|
+
(fragment.order ?? 0),
|
|
65
|
+
surface: surface,
|
|
66
|
+
strength: fragment.strength,
|
|
67
|
+
content: normalizeText(fragment.content),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return blocks;
|
|
72
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type BehaviorCandidate, type ResolvedBehavior } from "../../runtime/behavior/index.js";
|
|
2
|
+
import type { RunnerPromptBlock, RunnerPromptRole } from "../types.js";
|
|
3
|
+
export declare const FRAMEWORK_RUNNER_PROMPT_URL: import("node:url").URL;
|
|
4
|
+
export declare const BASE_PROMPT_PRIORITIES: {
|
|
5
|
+
readonly framework_runner: 100;
|
|
6
|
+
readonly policy_gateway: 200;
|
|
7
|
+
readonly execution_profile: 250;
|
|
8
|
+
readonly owner_profile: 300;
|
|
9
|
+
readonly recipe_execution_context: 400;
|
|
10
|
+
readonly recipe_agent_profile: 500;
|
|
11
|
+
readonly recipe_skill_context: 600;
|
|
12
|
+
readonly recipe_tools_context: 700;
|
|
13
|
+
};
|
|
14
|
+
export declare const OVERLAY_PROMPT_PRIORITIES: {
|
|
15
|
+
readonly planning: 410;
|
|
16
|
+
readonly execution: 420;
|
|
17
|
+
readonly coding: 430;
|
|
18
|
+
readonly debugging: 440;
|
|
19
|
+
readonly review: 450;
|
|
20
|
+
readonly verification: 460;
|
|
21
|
+
readonly docs: 470;
|
|
22
|
+
readonly finish: 480;
|
|
23
|
+
};
|
|
24
|
+
export declare function ensureTrailingNewline(text: string): string;
|
|
25
|
+
export declare function normalizeOwnerId(ownerIdRaw: string): string;
|
|
26
|
+
export declare function normalizeText(text: string): string;
|
|
27
|
+
export declare function validateJsonPrompt(source: string, text: string): string;
|
|
28
|
+
export declare function renderRecipePromptJson(value: Record<string, unknown> | Record<string, unknown>[]): string;
|
|
29
|
+
export declare function toPromptSource(gitRoot: string, absPath: string): string;
|
|
30
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
31
|
+
export declare function readOptionalStringArray(value: unknown): string[];
|
|
32
|
+
export type PromptSourcePayload = {
|
|
33
|
+
source: string;
|
|
34
|
+
title: string;
|
|
35
|
+
content: string;
|
|
36
|
+
};
|
|
37
|
+
export type PromptSourceTraceMetadata = {
|
|
38
|
+
title: string;
|
|
39
|
+
};
|
|
40
|
+
export type ResolvedPromptSource = ResolvedBehavior<PromptSourcePayload, PromptSourceTraceMetadata>;
|
|
41
|
+
export declare function promptCandidate(opts: {
|
|
42
|
+
layer: BehaviorCandidate<PromptSourcePayload, PromptSourceTraceMetadata>["layer"];
|
|
43
|
+
source: string;
|
|
44
|
+
value: PromptSourcePayload;
|
|
45
|
+
order?: number;
|
|
46
|
+
}): BehaviorCandidate<PromptSourcePayload, PromptSourceTraceMetadata>;
|
|
47
|
+
export declare function promptBlockFromResolved(opts: {
|
|
48
|
+
id: string;
|
|
49
|
+
role: RunnerPromptRole;
|
|
50
|
+
priority: number;
|
|
51
|
+
resolved: ResolvedPromptSource;
|
|
52
|
+
}): RunnerPromptBlock;
|
|
53
|
+
export declare function loadFrameworkRunnerPrompt(): Promise<RunnerPromptBlock>;
|
|
54
|
+
//# sourceMappingURL=prompt-block-shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-block-shared.d.ts","sourceRoot":"","sources":["../../../src/runner/context/prompt-block-shared.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEvE,eAAO,MAAM,2BAA2B,wBAAwD,CAAC;AAEjG,eAAO,MAAM,sBAAsB;;;;;;;;;CASzB,CAAC;AAEX,eAAO,MAAM,yBAAyB;;;;;;;;;CAS5B,CAAC;AAEX,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAI3D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAWvE;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACzD,MAAM,CAER;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAIhE;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,mBAAmB,EAAE,yBAAyB,CAAC,CAAC;AAEpG,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,KAAK,EAAE,iBAAiB,CAAC,mBAAmB,EAAE,yBAAyB,CAAC,CAAC,OAAO,CAAC,CAAC;IAClF,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,mBAAmB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,iBAAiB,CAAC,mBAAmB,EAAE,yBAAyB,CAAC,CAUpE;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,oBAAoB,CAAC;CAChC,GAAG,iBAAiB,CAUpB;AAED,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAsB5E"}
|