create-agdf 0.4.1 → 0.4.3
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/README.md +21 -0
- package/bin/create-agdf.js +124 -5
- package/generated/.agdf/control/templates/AGDF_RUN.md +1 -0
- package/generated/.agdf/control/templates/artefacts/OR.md +1 -0
- package/generated/.github/skills/README.md +1 -0
- package/generated/.github/skills/agdf-delivery-closeout/SKILL.md +9 -4
- package/generated/.github/skills/agdf-delivery-path-search/SKILL.md +75 -0
- package/generated/.github/skills/agdf-release-or/SKILL.md +8 -4
- package/generated/.github/skills/agdf-runtime-contract.md +24 -0
- package/generated/.opencode/AGDF.md +2 -0
- package/generated/.opencode/README.md +1 -0
- package/generated/.opencode/agdf-runtime-contract.md +24 -0
- package/generated/.opencode/agents/agdf-delivery-closeout.md +9 -4
- package/generated/.opencode/agents/agdf-delivery-path-search.md +76 -0
- package/generated/.opencode/agents/agdf-release-or.md +8 -4
- package/generated/AGENTS.md +2 -0
- package/generated/plugins/agdf/.codex-plugin/plugin.json +1 -1
- package/generated/plugins/agdf/control/templates/AGDF_RUN.md +1 -0
- package/generated/plugins/agdf/control/templates/artefacts/OR.md +1 -0
- package/generated/plugins/agdf/meta/agdf-agent-router.md +2 -0
- package/generated/plugins/agdf/meta/agdf-plugin.definition.json +6 -1
- package/generated/plugins/agdf/meta/agdf-runtime-contract.md +24 -0
- package/generated/plugins/agdf/skills/delivery-closeout/SKILL.md +9 -4
- package/generated/plugins/agdf/skills/delivery-path-search/SKILL.md +75 -0
- package/generated/plugins/agdf/skills/delivery-path-search/help.md +5 -0
- package/generated/plugins/agdf/skills/release-or/SKILL.md +8 -4
- package/lib/delivery-path-search/candidate-policy.js +34 -0
- package/lib/delivery-path-search/contracts.js +110 -0
- package/lib/delivery-path-search/evaluators/codex.js +67 -0
- package/lib/delivery-path-search/evaluators/protocol.js +13 -0
- package/lib/delivery-path-search/persistence.js +34 -0
- package/lib/delivery-path-search/scoring.js +21 -0
- package/lib/delivery-path-search/search-engine.js +92 -0
- package/lib/delivery-path-search/state-adapter.js +58 -0
- package/lib/delivery-path-search/surfaces/capabilities.js +14 -0
- package/package.json +4 -2
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { CONTRACT_VERSION, SCORING_POLICY_VERSION, validateEvaluation, validateSearchInput } from "./contracts.js";
|
|
2
|
+
import { candidateLegality, candidatesFromInput } from "./candidate-policy.js";
|
|
3
|
+
import { scoreEvaluation } from "./scoring.js";
|
|
4
|
+
|
|
5
|
+
export async function runDeliveryPathSearch(inputValue, evaluator, options = {}) {
|
|
6
|
+
const input = validateSearchInput(inputValue);
|
|
7
|
+
const startedAt = Date.now();
|
|
8
|
+
const queue = [...(options.candidates ?? candidatesFromInput(input))];
|
|
9
|
+
const rejected = [];
|
|
10
|
+
const evaluated = [];
|
|
11
|
+
let evaluations = 0;
|
|
12
|
+
let costUnits = 0;
|
|
13
|
+
let lastLeaderId = null;
|
|
14
|
+
let stableComparisons = 0;
|
|
15
|
+
let stoppingReason = "candidate_queue_exhausted";
|
|
16
|
+
|
|
17
|
+
while (queue.length > 0) {
|
|
18
|
+
if (evaluations >= input.budgets.max_evaluations) { stoppingReason = "evaluation_budget_exhausted"; break; }
|
|
19
|
+
if (costUnits >= input.budgets.max_cost_units) { stoppingReason = "cost_budget_exhausted"; break; }
|
|
20
|
+
if (Date.now() - startedAt >= input.budgets.max_duration_ms) { stoppingReason = "duration_budget_exhausted"; break; }
|
|
21
|
+
const candidate = queue.shift();
|
|
22
|
+
const legality = candidateLegality(candidate, input);
|
|
23
|
+
if (!legality.legal) {
|
|
24
|
+
rejected.push({ candidate_id: candidate.id, action: candidate.action, reason: legality.reason });
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const evaluation = validateEvaluation(await evaluator.evaluate(input, candidate), candidate.id);
|
|
30
|
+
evaluations += 1;
|
|
31
|
+
costUnits += evaluation.cost;
|
|
32
|
+
const scored = scoreEvaluation(evaluation, input.enforcement.level);
|
|
33
|
+
evaluated.push({ candidate, evaluation, ...scored });
|
|
34
|
+
const currentLeader = [...evaluated].sort((a, b) => b.score - a.score || a.candidate.id.localeCompare(b.candidate.id))[0];
|
|
35
|
+
if (currentLeader?.candidate.id === lastLeaderId) stableComparisons += 1;
|
|
36
|
+
else stableComparisons = 1;
|
|
37
|
+
lastLeaderId = currentLeader?.candidate.id ?? null;
|
|
38
|
+
if (evaluated.length > 1 && stableComparisons >= input.budgets.stability_window) {
|
|
39
|
+
stoppingReason = "stable_leader";
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
if ((candidate.depth ?? 0) + 1 < input.budgets.max_depth) {
|
|
43
|
+
for (const [index, action] of evaluation.child_actions.slice(0, input.budgets.max_candidates).entries()) {
|
|
44
|
+
queue.push({
|
|
45
|
+
id: `${candidate.id}.${index + 1}`,
|
|
46
|
+
parent_id: candidate.id,
|
|
47
|
+
depth: (candidate.depth ?? 0) + 1,
|
|
48
|
+
action,
|
|
49
|
+
expected_evidence: [],
|
|
50
|
+
tests: [],
|
|
51
|
+
assumptions: evaluation.assumptions,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} catch (error) {
|
|
56
|
+
rejected.push({ candidate_id: candidate.id, action: candidate.action, reason: `invalid_evaluation: ${error.message}` });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
evaluated.sort((a, b) => b.score - a.score || a.candidate.id.localeCompare(b.candidate.id));
|
|
61
|
+
const leader = evaluated[0];
|
|
62
|
+
if (!leader) stoppingReason = rejected.length ? "no_safe_candidate" : stoppingReason;
|
|
63
|
+
return {
|
|
64
|
+
contract_version: CONTRACT_VERSION,
|
|
65
|
+
scoring_policy_version: SCORING_POLICY_VERSION,
|
|
66
|
+
scope_key: input.scope_key,
|
|
67
|
+
current_gate: input.current_gate,
|
|
68
|
+
status: leader ? "recommendation" : "no_safe_recommendation",
|
|
69
|
+
recommendation: leader ? {
|
|
70
|
+
candidate_id: leader.candidate.id,
|
|
71
|
+
action: leader.candidate.action,
|
|
72
|
+
score: leader.score,
|
|
73
|
+
rationale: leader.evaluation.rationale,
|
|
74
|
+
expected_evidence: leader.candidate.expected_evidence,
|
|
75
|
+
tests: leader.candidate.tests,
|
|
76
|
+
risks: leader.evaluation.risks,
|
|
77
|
+
assumptions: leader.evaluation.assumptions,
|
|
78
|
+
} : null,
|
|
79
|
+
alternatives: evaluated.slice(1).map((item) => ({
|
|
80
|
+
candidate_id: item.candidate.id,
|
|
81
|
+
action: item.candidate.action,
|
|
82
|
+
score: item.score,
|
|
83
|
+
rejection_reason: `ranked_below_${leader?.candidate.id ?? "safety_threshold"}`,
|
|
84
|
+
})),
|
|
85
|
+
rejected,
|
|
86
|
+
enforcement: input.enforcement,
|
|
87
|
+
evaluator: evaluator.metadata ?? { name: evaluator.name ?? "unknown" },
|
|
88
|
+
budgets: { configured: input.budgets, evaluations, cost_units: costUnits, stable_comparisons: stableComparisons, duration_ms: Date.now() - startedAt },
|
|
89
|
+
stopping_reason: stoppingReason,
|
|
90
|
+
next_gate_action: "Run canonical AGDF gate-check; search does not grant permission.",
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { CONTRACT_VERSION } from "./contracts.js";
|
|
4
|
+
|
|
5
|
+
function section(content, heading) {
|
|
6
|
+
return content.match(new RegExp(`## ${heading}\\r?\\n([\\s\\S]*?)(?=\\r?\\n## |$)`))?.[1] ?? "";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function tableAnswers(content) {
|
|
10
|
+
const answers = {};
|
|
11
|
+
for (const line of section(content, "Current Control State").split(/\r?\n/)) {
|
|
12
|
+
const cells = line.split("|").slice(1, -1).map((cell) => cell.trim());
|
|
13
|
+
if (cells.length >= 2 && cells[0] && !cells[0].startsWith("---") && cells[0] !== "Question") answers[cells[0]] = cells[1];
|
|
14
|
+
}
|
|
15
|
+
return answers;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function statusCard(content) {
|
|
19
|
+
const card = {};
|
|
20
|
+
for (const line of section(content, "Run Status Card").split(/\r?\n/)) {
|
|
21
|
+
const cells = line.split("|").slice(1, -1).map((cell) => cell.trim().replace(/^`|`$/g, ""));
|
|
22
|
+
if (cells.length >= 2 && cells[0] && !cells[0].startsWith("---") && cells[0] !== "Run status") card[cells[0]] = cells[1];
|
|
23
|
+
}
|
|
24
|
+
return card;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function listCell(value) {
|
|
28
|
+
return String(value ?? "").split(/\s*;\s*/).map((item) => item.trim()).filter(Boolean);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function searchInputFromControl(targetDir, options = {}) {
|
|
32
|
+
const runPath = join(targetDir, ".agdf", "control", "AGDF_RUN.md");
|
|
33
|
+
if (!existsSync(runPath)) throw new Error("missing .agdf/control/AGDF_RUN.md");
|
|
34
|
+
const content = readFileSync(runPath, "utf8");
|
|
35
|
+
const meta = Object.fromEntries([...content.matchAll(/^- ([a-z_]+):\s*(.+)$/gm)].map((match) => [match[1], match[2].replace(/^`|`$/g, "").trim()]));
|
|
36
|
+
const answers = tableAnswers(content);
|
|
37
|
+
const card = statusCard(content);
|
|
38
|
+
return {
|
|
39
|
+
contract_version: CONTRACT_VERSION,
|
|
40
|
+
scope_key: options.scopeKey ?? meta.run_id ?? "unknown-scope",
|
|
41
|
+
objective: section(content, "Objective").trim(),
|
|
42
|
+
current_gate: card["Current gate"] ?? meta.current_gate ?? "unknown",
|
|
43
|
+
allowed_actions: options.allowedActions ?? listCell(card["Allowed now"]),
|
|
44
|
+
forbidden_actions: options.forbiddenActions ?? listCell(answers["What is explicitly forbidden right now?"]),
|
|
45
|
+
evidence_refs: [...content.matchAll(/\|\s*([^|]+)\s*\|\s*([^|]+)\s*\|\s*([^|]+)\s*\|\s*(direct|indirect)\s*\|/g)]
|
|
46
|
+
.slice(1).map((match) => `${match[1].trim()}: ${match[2].trim()}`),
|
|
47
|
+
risks: section(content, "Risks").split(/\r?\n/).filter((line) => line.startsWith("|") && !line.includes("---") && !line.includes("| Risk |")).map((line) => line.split("|")[1].trim()),
|
|
48
|
+
enforcement: options.enforcement ?? { level: "instruction_only", evidence: ["surface instruction prohibits implementation during search"] },
|
|
49
|
+
budgets: {
|
|
50
|
+
max_candidates: options.maxCandidates ?? 5,
|
|
51
|
+
max_depth: options.maxDepth ?? 2,
|
|
52
|
+
max_evaluations: options.maxEvaluations ?? 8,
|
|
53
|
+
max_duration_ms: options.maxDurationMs ?? 120000,
|
|
54
|
+
max_cost_units: options.maxCostUnits ?? 20,
|
|
55
|
+
stability_window: options.stabilityWindow ?? 3,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { validateEnforcement } from "../contracts.js";
|
|
2
|
+
|
|
3
|
+
export function enforcementForSurface(surface, evidence = []) {
|
|
4
|
+
const defaults = {
|
|
5
|
+
codex: { level: "tool_enforced", evidence: ["codex exec --sandbox read-only --ephemeral"] },
|
|
6
|
+
claude: { level: "instruction_only", evidence: [] },
|
|
7
|
+
copilot: { level: "instruction_only", evidence: [] },
|
|
8
|
+
opencode: { level: "instruction_only", evidence: [] },
|
|
9
|
+
generic: { level: "instruction_only", evidence: [] },
|
|
10
|
+
};
|
|
11
|
+
const selected = structuredClone(defaults[surface] ?? defaults.generic);
|
|
12
|
+
if (evidence.length) selected.evidence = evidence;
|
|
13
|
+
return validateEnforcement(selected);
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-agdf",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Bootstrap AGDF repository-local plugin files, Copilot/OpenCode instructions, skills, control files and machine-readable checks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"bin",
|
|
8
|
+
"lib",
|
|
8
9
|
"generated",
|
|
9
10
|
"opencode-plugin.js",
|
|
10
11
|
"README.md",
|
|
@@ -20,8 +21,9 @@
|
|
|
20
21
|
},
|
|
21
22
|
"scripts": {
|
|
22
23
|
"sync-package-assets": "node ./scripts/sync-package-assets.js",
|
|
24
|
+
"test:delivery-path-search": "node ./scripts/delivery-path-search-test.js",
|
|
23
25
|
"test:routing": "npm run sync-package-assets && node ./scripts/test-routing.js",
|
|
24
|
-
"smoke-test": "npm run sync-package-assets && node ./scripts/smoke-test.js && node ./scripts/test-routing.js",
|
|
26
|
+
"smoke-test": "npm run sync-package-assets && npm run test:delivery-path-search && node ./scripts/smoke-test.js && node ./scripts/test-routing.js",
|
|
25
27
|
"prepack": "npm run sync-package-assets"
|
|
26
28
|
},
|
|
27
29
|
"keywords": [
|