create-agdf 0.10.0 → 0.10.2
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 +30 -22
- package/bin/agdf-validator.js +11 -0
- package/generated/.agdf/control/README.md +3 -3
- package/generated/.github/skills/agdf-brownfield-analysis/SKILL.md +1 -1
- package/generated/.github/skills/agdf-delivery-path-search/SKILL.md +7 -6
- package/generated/.github/skills/agdf-gate-check/SKILL.md +28 -91
- package/generated/.github/skills/agdf-interaction-locales.json +2 -0
- package/generated/.github/skills/contracts/gate-transition.md +4 -2
- package/generated/.github/skills/contracts/modes.md +12 -1
- package/generated/.opencode/README.md +6 -8
- package/generated/.opencode/agdf-interaction-locales.json +2 -0
- package/generated/.opencode/contracts/gate-transition.md +4 -2
- package/generated/.opencode/contracts/modes.md +12 -1
- package/generated/.opencode/skills/agdf-brownfield-analysis/SKILL.md +1 -1
- package/generated/.opencode/skills/agdf-delivery-path-search/SKILL.md +7 -6
- package/generated/.opencode/skills/agdf-gate-check/SKILL.md +28 -91
- package/generated/plugins/agdf/.claude-plugin/plugin.json +19 -0
- package/generated/plugins/agdf/.codex-plugin/plugin.json +1 -1
- package/generated/plugins/agdf/control/README.md +3 -3
- package/generated/plugins/agdf/hooks/session-start.sh +1 -1
- package/generated/plugins/agdf/meta/agdf-interaction-locales.json +2 -0
- package/generated/plugins/agdf/meta/agdf-plugin.definition.json +1 -1
- package/generated/plugins/agdf/meta/contracts/gate-transition.md +4 -2
- package/generated/plugins/agdf/meta/contracts/modes.md +12 -1
- package/generated/plugins/agdf/runtime/agdf-local.js +11 -0
- package/generated/plugins/agdf/runtime/create-agdf/NOTICE +10 -0
- package/generated/plugins/agdf/runtime/create-agdf/bin/agdf-validator.js +11 -0
- package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-interaction-locales.json +418 -0
- package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-plugin.definition.json +220 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/cli/command-registry.js +136 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/cli/delivery-path-search-command.js +75 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/cli/parse-args.js +156 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/cli/runtime-context.js +83 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/cli/validation-handlers.js +45 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-evaluation/delivery-map.js +291 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-evaluation/doctor.js +265 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-evaluation/gate-check.js +459 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-evaluation/gate-policy.js +283 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-evaluation/required-files.js +9 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-evaluation/run-state.js +217 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-evaluation/shared.js +344 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-evaluation/verified-change.js +156 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-state/aggregate.js +18 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-state/gate-approval-validator.js +49 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-state/index.js +7 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-state/legacy-migration.js +95 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-state/run-state-parser.js +227 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-state/run-state-repository.js +68 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-state/run-state-resolver.js +45 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/control-state/run-state-writer.js +97 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/candidate-policy.js +99 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/contracts.js +237 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/evaluators/claude.js +44 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/evaluators/codex.js +53 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/evaluators/protocol.js +13 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/generators/claude.js +40 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/generators/codex.js +38 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/generators/protocol.js +12 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/persistence.js +39 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/scoring.js +21 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/search-engine.js +154 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/state-adapter.js +161 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/surfaces/capabilities.js +14 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/transports/read-only-guard.js +43 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/interaction-presentation.js +590 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/runtime/local-validator.js +142 -0
- package/generated/plugins/agdf/runtime/create-agdf/lib/runtime/validator-application.js +40 -0
- package/generated/plugins/agdf/runtime/create-agdf/package.json +66 -0
- package/generated/plugins/agdf/runtime/runtime-manifest.json +8 -0
- package/generated/plugins/agdf/scripts/check-runtime-integrity.mjs +1040 -0
- package/generated/plugins/agdf/skills/brownfield-analysis/SKILL.md +1 -1
- package/generated/plugins/agdf/skills/delivery-path-search/SKILL.md +7 -6
- package/generated/plugins/agdf/skills/gate-check/SKILL.md +28 -91
- package/lib/cli/application.js +21 -59
- package/lib/cli/command-registry.js +9 -11
- package/lib/cli/validation-handlers.js +45 -0
- package/lib/control-evaluation/doctor.js +1 -1
- package/lib/control-evaluation/gate-check.js +7 -7
- package/lib/control-evaluation/required-files.js +9 -0
- package/lib/installers/local-marketplace.js +322 -0
- package/lib/installers/opencode-activation.js +43 -0
- package/lib/installers/opencode.js +60 -18
- package/lib/installers/plugin-installers.js +102 -26
- package/lib/runtime/local-validator.js +142 -0
- package/lib/runtime/validator-application.js +40 -0
- package/lib/scaffold/plan.js +1 -30
- package/lib/scaffold/presentation.js +9 -14
- package/opencode-plugin.js +32 -24
- package/package.json +6 -2
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
CONTRACT_VERSION,
|
|
5
|
+
GENERATOR_CONTRACT_VERSION,
|
|
6
|
+
validateGeneratorRequest,
|
|
7
|
+
} from "./contracts.js";
|
|
8
|
+
import { resolveRuns, verifyLegacyProjection } from "../control-state/index.js";
|
|
9
|
+
|
|
10
|
+
function section(content, heading) {
|
|
11
|
+
return (
|
|
12
|
+
content.match(
|
|
13
|
+
new RegExp(`## ${heading}\\r?\\n([\\s\\S]*?)(?=\\r?\\n## |$)`),
|
|
14
|
+
)?.[1] ?? ""
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function tableAnswers(content) {
|
|
19
|
+
const answers = {};
|
|
20
|
+
for (const line of section(content, "Current Control State").split(/\r?\n/)) {
|
|
21
|
+
const cells = line
|
|
22
|
+
.split("|")
|
|
23
|
+
.slice(1, -1)
|
|
24
|
+
.map((cell) => cell.trim());
|
|
25
|
+
if (
|
|
26
|
+
cells.length >= 2 &&
|
|
27
|
+
cells[0] &&
|
|
28
|
+
!cells[0].startsWith("---") &&
|
|
29
|
+
cells[0] !== "Question"
|
|
30
|
+
)
|
|
31
|
+
answers[cells[0]] = cells[1];
|
|
32
|
+
}
|
|
33
|
+
return answers;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function statusCard(content) {
|
|
37
|
+
const card = {};
|
|
38
|
+
for (const line of section(content, "Run Status Card").split(/\r?\n/)) {
|
|
39
|
+
const cells = line
|
|
40
|
+
.split("|")
|
|
41
|
+
.slice(1, -1)
|
|
42
|
+
.map((cell) => cell.trim().replace(/^`|`$/g, ""));
|
|
43
|
+
if (
|
|
44
|
+
cells.length >= 2 &&
|
|
45
|
+
cells[0] &&
|
|
46
|
+
!cells[0].startsWith("---") &&
|
|
47
|
+
cells[0] !== "Run status"
|
|
48
|
+
)
|
|
49
|
+
card[cells[0]] = cells[1];
|
|
50
|
+
}
|
|
51
|
+
return card;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function listCell(value) {
|
|
55
|
+
return String(value ?? "")
|
|
56
|
+
.split(/\s*;\s*/)
|
|
57
|
+
.map((item) => item.trim())
|
|
58
|
+
.filter(Boolean);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function searchInputFromControl(targetDir, options = {}) {
|
|
62
|
+
const canonicalRoot = join(targetDir, ".agdf", "control", "runs");
|
|
63
|
+
if (existsSync(canonicalRoot)) {
|
|
64
|
+
const projection = verifyLegacyProjection(targetDir);
|
|
65
|
+
if (!["absent", "valid"].includes(projection.status)) {
|
|
66
|
+
throw new Error(`AGDF_LEGACY_PROJECTION_DRIFT:${projection.status}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const resolved = existsSync(canonicalRoot)
|
|
70
|
+
? resolveRuns(targetDir, {
|
|
71
|
+
runIdArg: options.scopeKey,
|
|
72
|
+
runIdEnv: process.env.AGDF_RUN_ID,
|
|
73
|
+
})
|
|
74
|
+
: null;
|
|
75
|
+
const runPath =
|
|
76
|
+
resolved?.run.path ?? join(targetDir, ".agdf", "control", "AGDF_RUN.md");
|
|
77
|
+
if (!existsSync(runPath)) throw new Error("missing AGDF run state");
|
|
78
|
+
const content = readFileSync(runPath, "utf8");
|
|
79
|
+
const meta = Object.fromEntries(
|
|
80
|
+
[...content.matchAll(/^- ([a-z_]+):\s*(.+)$/gm)].map((match) => [
|
|
81
|
+
match[1],
|
|
82
|
+
match[2].replace(/^`|`$/g, "").trim(),
|
|
83
|
+
]),
|
|
84
|
+
);
|
|
85
|
+
const answers = tableAnswers(content);
|
|
86
|
+
const card = statusCard(content);
|
|
87
|
+
const result = {
|
|
88
|
+
contract_version: CONTRACT_VERSION,
|
|
89
|
+
scope_key: options.scopeKey ?? meta.run_id ?? "unknown-scope",
|
|
90
|
+
objective: section(content, "Objective").trim(),
|
|
91
|
+
current_gate: card["Current gate"] ?? meta.current_gate ?? "unknown",
|
|
92
|
+
allowed_actions: options.allowedActions ?? listCell(card["Allowed now"]),
|
|
93
|
+
forbidden_actions:
|
|
94
|
+
options.forbiddenActions ??
|
|
95
|
+
listCell(answers["What is explicitly forbidden right now?"]),
|
|
96
|
+
evidence_refs: [
|
|
97
|
+
...content.matchAll(
|
|
98
|
+
/\|\s*([^|]+)\s*\|\s*([^|]+)\s*\|\s*([^|]+)\s*\|\s*(direct|indirect)\s*\|/g,
|
|
99
|
+
),
|
|
100
|
+
]
|
|
101
|
+
.slice(1)
|
|
102
|
+
.map((match) => `${match[1].trim()}: ${match[2].trim()}`),
|
|
103
|
+
risks: section(content, "Risks")
|
|
104
|
+
.split(/\r?\n/)
|
|
105
|
+
.filter(
|
|
106
|
+
(line) =>
|
|
107
|
+
line.startsWith("|") &&
|
|
108
|
+
!line.includes("---") &&
|
|
109
|
+
!line.includes("| Risk |"),
|
|
110
|
+
)
|
|
111
|
+
.map((line) => line.split("|")[1].trim()),
|
|
112
|
+
enforcement: options.enforcement ?? {
|
|
113
|
+
level: "instruction_only",
|
|
114
|
+
evidence: ["surface instruction prohibits implementation during search"],
|
|
115
|
+
},
|
|
116
|
+
budgets: {
|
|
117
|
+
max_candidates: options.maxCandidates ?? 5,
|
|
118
|
+
max_depth: options.maxDepth ?? 2,
|
|
119
|
+
max_evaluations: options.maxEvaluations ?? 8,
|
|
120
|
+
max_duration_ms: options.maxDurationMs ?? 120000,
|
|
121
|
+
max_cost_units: options.maxCostUnits ?? 20,
|
|
122
|
+
stability_window: options.stabilityWindow ?? 3,
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
if (options.generation?.enabled)
|
|
126
|
+
result.generation = {
|
|
127
|
+
enabled: true,
|
|
128
|
+
max_calls: 1,
|
|
129
|
+
max_proposals: options.generation.maxProposals ?? 5,
|
|
130
|
+
max_duration_ms: options.generation.maxDurationMs ?? 30000,
|
|
131
|
+
max_cost_units: options.generation.maxCostUnits ?? 5,
|
|
132
|
+
};
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function generatorRequestFromInput(input) {
|
|
137
|
+
return validateGeneratorRequest({
|
|
138
|
+
contract_version: GENERATOR_CONTRACT_VERSION,
|
|
139
|
+
scope_key: input.scope_key,
|
|
140
|
+
objective: input.objective,
|
|
141
|
+
scope_summary: input.objective,
|
|
142
|
+
current_gate: input.current_gate,
|
|
143
|
+
allowed_actions: input.allowed_actions,
|
|
144
|
+
forbidden_actions: input.forbidden_actions,
|
|
145
|
+
artefact_refs: [],
|
|
146
|
+
evidence: input.evidence_refs ?? [],
|
|
147
|
+
missing_evidence: [],
|
|
148
|
+
risks: input.risks ?? [],
|
|
149
|
+
constraints: [
|
|
150
|
+
"advisory only",
|
|
151
|
+
"canonical gate-check remains authoritative",
|
|
152
|
+
],
|
|
153
|
+
enforcement: input.enforcement,
|
|
154
|
+
budgets: {
|
|
155
|
+
max_calls: input.generation.max_calls,
|
|
156
|
+
max_proposals: input.generation.max_proposals,
|
|
157
|
+
max_duration_ms: input.generation.max_duration_ms,
|
|
158
|
+
max_cost_units: input.generation.max_cost_units,
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
}
|
package/generated/plugins/agdf/runtime/create-agdf/lib/delivery-path-search/surfaces/capabilities.js
ADDED
|
@@ -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: "tool_enforced", evidence: ["claude -p --disallowedTools Edit,Write,Bash"] },
|
|
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
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
export function repositoryState(cwd) {
|
|
4
|
+
try {
|
|
5
|
+
return execFileSync("git", ["status", "--porcelain=v1", "-z"], {
|
|
6
|
+
cwd,
|
|
7
|
+
encoding: "utf8",
|
|
8
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
9
|
+
});
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function guardedExecFileSync(file, args, options = {}) {
|
|
16
|
+
const before = repositoryState(options.cwd);
|
|
17
|
+
let output;
|
|
18
|
+
let failure;
|
|
19
|
+
try {
|
|
20
|
+
output = execFileSync(file, args, {
|
|
21
|
+
...options,
|
|
22
|
+
encoding: options.encoding ?? "utf8",
|
|
23
|
+
stdio: options.stdio ?? ["ignore", "pipe", "pipe"],
|
|
24
|
+
timeout: options.timeout ?? 30000,
|
|
25
|
+
killSignal: "SIGTERM",
|
|
26
|
+
});
|
|
27
|
+
} catch (error) {
|
|
28
|
+
failure = error;
|
|
29
|
+
}
|
|
30
|
+
const after = repositoryState(options.cwd);
|
|
31
|
+
if (before !== null && after !== before) {
|
|
32
|
+
const error = new Error("repository mutation detected during read-only run");
|
|
33
|
+
error.code = "GENERATOR_MUTATION_DETECTED";
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
if (failure?.code === "ETIMEDOUT" || failure?.signal === "SIGTERM") {
|
|
37
|
+
const timeout = new Error("read-only process timed out");
|
|
38
|
+
timeout.code = "GENERATOR_TIMEOUT";
|
|
39
|
+
throw timeout;
|
|
40
|
+
}
|
|
41
|
+
if (failure) throw failure;
|
|
42
|
+
return output;
|
|
43
|
+
}
|