agentplane 0.3.22 → 0.3.24
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/policy/incidents.md +1 -0
- package/dist/.build-manifest.json +83 -28
- package/dist/cli/run-cli/commands/init/orchestrate-v2.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/orchestrate-v2.js +10 -2
- package/dist/cli/run-cli/commands/init/orchestrate.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/orchestrate.js +10 -2
- package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/recipes.js +3 -1
- package/dist/cli.js +337 -337
- package/dist/commands/guard/impl/commit-refresh.d.ts +25 -0
- package/dist/commands/guard/impl/commit-refresh.d.ts.map +1 -0
- package/dist/commands/guard/impl/commit-refresh.js +116 -0
- package/dist/commands/guard/impl/commit-stage.d.ts +21 -0
- package/dist/commands/guard/impl/commit-stage.d.ts.map +1 -0
- package/dist/commands/guard/impl/commit-stage.js +43 -0
- package/dist/commands/guard/impl/commit.d.ts.map +1 -1
- package/dist/commands/guard/impl/commit.js +10 -150
- package/dist/commands/hooks/install.d.ts +4 -0
- package/dist/commands/hooks/install.d.ts.map +1 -1
- package/dist/commands/hooks/install.js +19 -0
- package/dist/commands/hooks/run.pre-push.d.ts.map +1 -1
- package/dist/commands/hooks/run.pre-push.js +5 -2
- package/dist/commands/recipes/impl/installed-recipes.d.ts +5 -1
- package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -1
- package/dist/commands/recipes/impl/installed-recipes.js +38 -19
- package/dist/commands/release/apply.mutation.d.ts.map +1 -1
- package/dist/commands/release/apply.mutation.js +5 -4
- package/dist/commands/release/apply.pipeline/mutation.d.ts.map +1 -1
- package/dist/commands/release/apply.pipeline/mutation.js +6 -1
- package/dist/commands/release/apply.preflight.d.ts +4 -29
- package/dist/commands/release/apply.preflight.d.ts.map +1 -1
- package/dist/commands/release/apply.preflight.git.d.ts +7 -0
- package/dist/commands/release/apply.preflight.git.d.ts.map +1 -0
- package/dist/commands/release/apply.preflight.git.js +138 -0
- package/dist/commands/release/apply.preflight.js +4 -368
- package/dist/commands/release/apply.preflight.package.d.ts +7 -0
- package/dist/commands/release/apply.preflight.package.d.ts.map +1 -0
- package/dist/commands/release/apply.preflight.package.js +69 -0
- package/dist/commands/release/apply.preflight.plan.d.ts +16 -0
- package/dist/commands/release/apply.preflight.plan.d.ts.map +1 -0
- package/dist/commands/release/apply.preflight.plan.js +92 -0
- package/dist/commands/release/apply.preflight.publish.d.ts +4 -0
- package/dist/commands/release/apply.preflight.publish.d.ts.map +1 -0
- package/dist/commands/release/apply.preflight.publish.js +81 -0
- package/dist/commands/task/migrate-doc.d.ts.map +1 -1
- package/dist/commands/task/migrate-doc.js +25 -248
- package/dist/commands/task/migrate-doc.readme.d.ts +8 -0
- package/dist/commands/task/migrate-doc.readme.d.ts.map +1 -0
- package/dist/commands/task/migrate-doc.readme.js +225 -0
- package/dist/runtime/prompt-modules/index.d.ts +3 -0
- package/dist/runtime/prompt-modules/index.d.ts.map +1 -0
- package/dist/runtime/prompt-modules/index.js +1 -0
- package/dist/runtime/prompt-modules/model.d.ts +89 -0
- package/dist/runtime/prompt-modules/model.d.ts.map +1 -0
- package/dist/runtime/prompt-modules/model.js +1 -0
- package/dist/runtime/prompt-modules/mutations.d.ts +103 -0
- package/dist/runtime/prompt-modules/mutations.d.ts.map +1 -0
- package/dist/runtime/prompt-modules/mutations.js +1 -0
- package/dist/shared/runtime-env.d.ts +3 -0
- package/dist/shared/runtime-env.d.ts.map +1 -0
- package/dist/shared/runtime-env.js +73 -0
- package/package.json +3 -3
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { atomicWriteFile } from "@agentplaneorg/core/fs";
|
|
3
|
+
import { ensureDocSections, extractTaskDoc, mergeTaskDoc, normalizeTaskDoc, parseTaskReadme, renderTaskDocFromSections, renderTaskReadme, setMarkdownSection, taskDocToSectionMap, } from "@agentplaneorg/core/tasks";
|
|
4
|
+
import { decodeEscapedTaskTextNewlines, extractDocSection, extractTaskObservationSection, normalizeTaskDocVersion, normalizeVerificationSectionLayout, } from "./shared/docs.js";
|
|
5
|
+
import { defaultTaskDocV3 } from "./doc-template.js";
|
|
6
|
+
const V3_CANONICAL_ORDER = [
|
|
7
|
+
"Summary",
|
|
8
|
+
"Scope",
|
|
9
|
+
"Plan",
|
|
10
|
+
"Verify Steps",
|
|
11
|
+
"Verification",
|
|
12
|
+
"Rollback Plan",
|
|
13
|
+
"Findings",
|
|
14
|
+
];
|
|
15
|
+
const HUMAN_TEXT_SECTIONS = new Set(["summary", "context", "scope", "plan", "findings", "notes"]);
|
|
16
|
+
function isRecord(value) {
|
|
17
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
18
|
+
}
|
|
19
|
+
function normalizeRevision(value) {
|
|
20
|
+
return Number.isInteger(value) && typeof value === "number" && value > 0 ? value : null;
|
|
21
|
+
}
|
|
22
|
+
function normalizeCanonicalSections(value) {
|
|
23
|
+
if (!isRecord(value))
|
|
24
|
+
return null;
|
|
25
|
+
const out = {};
|
|
26
|
+
for (const [title, text] of Object.entries(value)) {
|
|
27
|
+
const normalizedTitle = title.trim();
|
|
28
|
+
if (!normalizedTitle || typeof text !== "string")
|
|
29
|
+
continue;
|
|
30
|
+
out[normalizedTitle] = text.replaceAll("\r\n", "\n").trimEnd();
|
|
31
|
+
}
|
|
32
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
33
|
+
}
|
|
34
|
+
function normalizeSectionKey(section) {
|
|
35
|
+
return section.trim().replaceAll(/\s+/g, " ").toLowerCase();
|
|
36
|
+
}
|
|
37
|
+
function parseMarkdownSections(doc) {
|
|
38
|
+
const lines = doc.replaceAll("\r\n", "\n").split("\n");
|
|
39
|
+
const sections = [];
|
|
40
|
+
let current = null;
|
|
41
|
+
for (const line of lines) {
|
|
42
|
+
const match = /^##\s+(.*)$/.exec(line.trim());
|
|
43
|
+
if (match) {
|
|
44
|
+
if (current) {
|
|
45
|
+
current.text = current.text.trimEnd();
|
|
46
|
+
sections.push(current);
|
|
47
|
+
}
|
|
48
|
+
current = { title: (match[1] ?? "").trim(), text: "" };
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (current) {
|
|
52
|
+
current.text = current.text.length > 0 ? `${current.text}\n${line}` : line;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (current) {
|
|
56
|
+
current.text = current.text.trimEnd();
|
|
57
|
+
sections.push(current);
|
|
58
|
+
}
|
|
59
|
+
return sections;
|
|
60
|
+
}
|
|
61
|
+
function renderMarkdownSections(sections) {
|
|
62
|
+
return sections
|
|
63
|
+
.map((section) => {
|
|
64
|
+
const text = section.text.trimEnd();
|
|
65
|
+
return text ? `## ${section.title}\n\n${text}` : `## ${section.title}\n`;
|
|
66
|
+
})
|
|
67
|
+
.join("\n\n")
|
|
68
|
+
.trimEnd();
|
|
69
|
+
}
|
|
70
|
+
function normalizeLiteralNewlinesInHumanSection(title, text) {
|
|
71
|
+
if (!HUMAN_TEXT_SECTIONS.has(normalizeSectionKey(title)))
|
|
72
|
+
return text.trimEnd();
|
|
73
|
+
return decodeEscapedTaskTextNewlines(text).trimEnd();
|
|
74
|
+
}
|
|
75
|
+
function firstSectionText(sections, title) {
|
|
76
|
+
const target = normalizeSectionKey(title);
|
|
77
|
+
return sections.find((section) => normalizeSectionKey(section.title) === target)?.text ?? null;
|
|
78
|
+
}
|
|
79
|
+
function mergeObservationText(doc, version) {
|
|
80
|
+
const preferred = extractTaskObservationSection(doc, version)?.trim() ?? "";
|
|
81
|
+
const notes = extractDocSection(doc, "Notes")?.trim() ?? "";
|
|
82
|
+
const findings = extractDocSection(doc, "Findings")?.trim() ?? "";
|
|
83
|
+
const out = [];
|
|
84
|
+
for (const candidate of [preferred, findings, notes]) {
|
|
85
|
+
if (!candidate)
|
|
86
|
+
continue;
|
|
87
|
+
if (out.includes(candidate))
|
|
88
|
+
continue;
|
|
89
|
+
out.push(candidate);
|
|
90
|
+
}
|
|
91
|
+
return out.join("\n\n").trim();
|
|
92
|
+
}
|
|
93
|
+
function migrateDocToV3(opts) {
|
|
94
|
+
const currentSections = parseMarkdownSections(opts.doc);
|
|
95
|
+
const defaultSections = parseMarkdownSections(defaultTaskDocV3({ title: opts.title, description: opts.description }));
|
|
96
|
+
const emitted = new Set();
|
|
97
|
+
const nextSections = [];
|
|
98
|
+
const observationText = mergeObservationText(opts.doc, 2);
|
|
99
|
+
for (const title of V3_CANONICAL_ORDER) {
|
|
100
|
+
const key = normalizeSectionKey(title);
|
|
101
|
+
const currentText = firstSectionText(currentSections, title);
|
|
102
|
+
const defaultText = firstSectionText(defaultSections, title) ?? "";
|
|
103
|
+
let nextText = currentText ?? defaultText;
|
|
104
|
+
if (title === "Verification") {
|
|
105
|
+
nextText = normalizeVerificationSectionLayout(currentText ?? defaultText, 3);
|
|
106
|
+
}
|
|
107
|
+
if (title === "Findings") {
|
|
108
|
+
nextText = observationText || defaultText;
|
|
109
|
+
}
|
|
110
|
+
if (nextText === null)
|
|
111
|
+
continue;
|
|
112
|
+
nextText = normalizeLiteralNewlinesInHumanSection(title, nextText);
|
|
113
|
+
nextSections.push({ title, text: nextText.trimEnd() });
|
|
114
|
+
emitted.add(key);
|
|
115
|
+
if (title === "Findings")
|
|
116
|
+
emitted.add("notes");
|
|
117
|
+
}
|
|
118
|
+
for (const section of currentSections) {
|
|
119
|
+
const key = normalizeSectionKey(section.title);
|
|
120
|
+
if (emitted.has(key))
|
|
121
|
+
continue;
|
|
122
|
+
nextSections.push({ title: section.title, text: section.text.trimEnd() });
|
|
123
|
+
emitted.add(key);
|
|
124
|
+
}
|
|
125
|
+
return renderMarkdownSections(nextSections);
|
|
126
|
+
}
|
|
127
|
+
function ensurePlanApprovalFrontmatter(frontmatter) {
|
|
128
|
+
const raw = frontmatter.plan_approval;
|
|
129
|
+
if (isRecord(raw) && typeof raw.state === "string")
|
|
130
|
+
return;
|
|
131
|
+
frontmatter.plan_approval = {
|
|
132
|
+
state: "pending",
|
|
133
|
+
updated_at: null,
|
|
134
|
+
updated_by: null,
|
|
135
|
+
note: null,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function ensureVerificationFrontmatter(frontmatter) {
|
|
139
|
+
const raw = frontmatter.verification;
|
|
140
|
+
if (isRecord(raw) && typeof raw.state === "string")
|
|
141
|
+
return;
|
|
142
|
+
frontmatter.verification = {
|
|
143
|
+
state: "pending",
|
|
144
|
+
updated_at: null,
|
|
145
|
+
updated_by: null,
|
|
146
|
+
note: null,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const DATE_ONLY_ON_RE = /\bon (\d{4}-\d{2}-\d{2})(?!T)\b/g;
|
|
150
|
+
function isIsoTimestamp(value) {
|
|
151
|
+
if (!value.includes("T") || !value.endsWith("Z"))
|
|
152
|
+
return false;
|
|
153
|
+
const ms = Date.parse(value);
|
|
154
|
+
return Number.isFinite(ms);
|
|
155
|
+
}
|
|
156
|
+
function normalizeNoteTimestamp(opts) {
|
|
157
|
+
if (!isIsoTimestamp(opts.updatedAt))
|
|
158
|
+
return opts.note;
|
|
159
|
+
const updatedDate = opts.updatedAt.slice(0, 10);
|
|
160
|
+
return opts.note.replaceAll(DATE_ONLY_ON_RE, (match, date) => {
|
|
161
|
+
if (date !== updatedDate)
|
|
162
|
+
return match;
|
|
163
|
+
return `on ${opts.updatedAt}`;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function normalizeFrontmatterNoteTimestamps(frontmatter) {
|
|
167
|
+
const plan = frontmatter.plan_approval;
|
|
168
|
+
if (isRecord(plan) && typeof plan.note === "string" && typeof plan.updated_at === "string") {
|
|
169
|
+
plan.note = normalizeNoteTimestamp({ note: plan.note, updatedAt: plan.updated_at });
|
|
170
|
+
}
|
|
171
|
+
const verification = frontmatter.verification;
|
|
172
|
+
if (isRecord(verification) &&
|
|
173
|
+
typeof verification.note === "string" &&
|
|
174
|
+
typeof verification.updated_at === "string") {
|
|
175
|
+
verification.note = normalizeNoteTimestamp({
|
|
176
|
+
note: verification.note,
|
|
177
|
+
updatedAt: verification.updated_at,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
export async function migrateTaskReadmeDoc(opts) {
|
|
182
|
+
const originalRaw = await readFile(opts.readmePath, "utf8");
|
|
183
|
+
const original = originalRaw.endsWith("\n") ? originalRaw : `${originalRaw}\n`;
|
|
184
|
+
const parsed = parseTaskReadme(original);
|
|
185
|
+
const frontmatter = { ...parsed.frontmatter };
|
|
186
|
+
ensurePlanApprovalFrontmatter(frontmatter);
|
|
187
|
+
ensureVerificationFrontmatter(frontmatter);
|
|
188
|
+
normalizeFrontmatterNoteTimestamps(frontmatter);
|
|
189
|
+
const canonicalSections = normalizeCanonicalSections(frontmatter.sections);
|
|
190
|
+
const required = opts.config.tasks.doc.required_sections;
|
|
191
|
+
const extracted = extractTaskDoc(parsed.body);
|
|
192
|
+
const baseDoc = canonicalSections === null
|
|
193
|
+
? extracted || parsed.body
|
|
194
|
+
: renderTaskDocFromSections(canonicalSections);
|
|
195
|
+
let nextDoc = normalizeTaskDoc(ensureDocSections(baseDoc, required));
|
|
196
|
+
const docVersion = normalizeTaskDocVersion(frontmatter.doc_version);
|
|
197
|
+
if (docVersion === 2) {
|
|
198
|
+
frontmatter.doc_version = 3;
|
|
199
|
+
nextDoc = migrateDocToV3({
|
|
200
|
+
title: typeof frontmatter.title === "string" ? frontmatter.title : "",
|
|
201
|
+
description: typeof frontmatter.description === "string" ? frontmatter.description : "",
|
|
202
|
+
doc: nextDoc,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
const verificationSection = extractDocSection(nextDoc, "Verification");
|
|
207
|
+
const normalizedVerification = normalizeVerificationSectionLayout(verificationSection, docVersion);
|
|
208
|
+
nextDoc = setMarkdownSection(nextDoc, "Verification", normalizedVerification);
|
|
209
|
+
for (const sectionTitle of ["Summary", "Context", "Scope", "Plan", "Findings", "Notes"]) {
|
|
210
|
+
const sectionText = extractDocSection(nextDoc, sectionTitle);
|
|
211
|
+
if (sectionText == null)
|
|
212
|
+
continue;
|
|
213
|
+
nextDoc = setMarkdownSection(nextDoc, sectionTitle, normalizeLiteralNewlinesInHumanSection(sectionTitle, sectionText));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const nextBody = extracted ? mergeTaskDoc(parsed.body, nextDoc) : nextDoc;
|
|
217
|
+
frontmatter.sections = taskDocToSectionMap(nextDoc);
|
|
218
|
+
frontmatter.revision = normalizeRevision(frontmatter.revision) ?? 1;
|
|
219
|
+
const rendered = renderTaskReadme(frontmatter, nextBody);
|
|
220
|
+
const next = rendered.endsWith("\n") ? rendered : `${rendered}\n`;
|
|
221
|
+
if (next === original)
|
|
222
|
+
return { changed: false };
|
|
223
|
+
await atomicWriteFile(opts.readmePath, next, "utf8");
|
|
224
|
+
return { changed: true };
|
|
225
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { PROMPT_MODULE_CONTRACT_SCHEMA_VERSION, type PromptModule, type PromptModuleAddress, type PromptModuleConflictPolicy, type PromptModuleContentKind, type PromptModuleContractSchemaVersion, type PromptModuleDependency, type PromptModuleGraph, type PromptModuleGraphNode, type PromptModuleLoadCondition, type PromptModuleMergeMode, type PromptModuleMergePolicy, type PromptModuleMutability, type PromptModuleNamespace, type PromptModuleOwner, type PromptModuleProvenance, type PromptModuleReference, type PromptModuleSlot, type PromptModuleSourceKind, type PromptModuleSurface, type PromptModuleTarget, } from "./model.js";
|
|
2
|
+
export type { PromptModuleAddMutation, PromptModuleBindMutation, PromptModuleBinding, PromptModuleBindingKind, PromptModuleDisableMutation, PromptModuleMutation, PromptModuleMutationBase, PromptModuleMutationSet, PromptModuleMutationSource, PromptModuleMutationWhen, PromptModulePatchMutation, PromptModuleReplaceMutation, PromptModuleSelector, PromptModuleStructuredPatch, PromptModuleValidator, PromptModuleValidatorMutation, PromptModuleValidatorPhase, } from "./mutations.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/prompt-modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qCAAqC,EACrC,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,iCAAiC,EACtC,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC3B,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,EACrB,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PROMPT_MODULE_CONTRACT_SCHEMA_VERSION, } from "./model.js";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export declare const PROMPT_MODULE_CONTRACT_SCHEMA_VERSION: 1;
|
|
2
|
+
export type PromptModuleContractSchemaVersion = typeof PROMPT_MODULE_CONTRACT_SCHEMA_VERSION;
|
|
3
|
+
export type PromptModuleNamespace = "framework" | "project" | "runtime" | `recipe.${string}`;
|
|
4
|
+
export type PromptModuleSurface = "gateway" | "policy" | "agent_profile" | "runner" | "validator" | "template";
|
|
5
|
+
export type PromptModuleTarget = "AGENTS.md" | "CLAUDE.md" | ".agentplane/policy" | ".agentplane/agents" | "runner.bundle" | "recipe.manifest" | "generated.artifact";
|
|
6
|
+
export type PromptModuleSlot = "frontmatter" | "purpose" | "startup" | "commands" | "load_rules" | "source_of_truth" | "hard_constraint" | "body" | "example" | "identity" | "inputs" | "outputs" | "permissions" | "workflow" | "cli_notes" | "context" | "schema" | "check" | "partial" | "file";
|
|
7
|
+
export type PromptModuleAddress = {
|
|
8
|
+
/**
|
|
9
|
+
* Canonical stable address, for example
|
|
10
|
+
* `framework/gateway/AGENTS.md/load_rules/base`.
|
|
11
|
+
*/
|
|
12
|
+
value: string;
|
|
13
|
+
namespace: PromptModuleNamespace;
|
|
14
|
+
surface: PromptModuleSurface;
|
|
15
|
+
target: PromptModuleTarget;
|
|
16
|
+
slot: PromptModuleSlot;
|
|
17
|
+
name: string;
|
|
18
|
+
};
|
|
19
|
+
export type PromptModuleOwner = {
|
|
20
|
+
kind: "framework";
|
|
21
|
+
package_name: "agentplane";
|
|
22
|
+
version?: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "project";
|
|
25
|
+
project_root?: string;
|
|
26
|
+
} | {
|
|
27
|
+
kind: "recipe";
|
|
28
|
+
recipe_id: string;
|
|
29
|
+
version?: string;
|
|
30
|
+
} | {
|
|
31
|
+
kind: "runtime";
|
|
32
|
+
adapter_id?: string;
|
|
33
|
+
};
|
|
34
|
+
export type PromptModuleContentKind = "markdown" | "json" | "text" | "typescript" | "command";
|
|
35
|
+
export type PromptModuleMutability = "locked" | "replaceable" | "extendable" | "append_only";
|
|
36
|
+
export type PromptModuleMergeMode = "pick_one" | "replace" | "prepend" | "append" | "merge_object" | "union_by_id";
|
|
37
|
+
export type PromptModuleConflictPolicy = "error" | "highest_precedence" | "last_writer_wins" | "keep_all";
|
|
38
|
+
export type PromptModuleMergePolicy = {
|
|
39
|
+
mode: PromptModuleMergeMode;
|
|
40
|
+
conflict: PromptModuleConflictPolicy;
|
|
41
|
+
precedence?: number;
|
|
42
|
+
};
|
|
43
|
+
export type PromptModuleLoadCondition = {
|
|
44
|
+
workflow_modes?: ("direct" | "branch_pr")[];
|
|
45
|
+
policy_gateways?: ("codex" | "claude")[];
|
|
46
|
+
roles?: string[];
|
|
47
|
+
commands?: string[];
|
|
48
|
+
task_tags_any?: string[];
|
|
49
|
+
repo_types?: string[];
|
|
50
|
+
recipe_ids?: string[];
|
|
51
|
+
};
|
|
52
|
+
export type PromptModuleSourceKind = "framework_builtin" | "project_file" | "recipe_asset" | "generated" | "runtime";
|
|
53
|
+
export type PromptModuleProvenance = {
|
|
54
|
+
source_kind: PromptModuleSourceKind;
|
|
55
|
+
source_ref: string;
|
|
56
|
+
recipe_id?: string;
|
|
57
|
+
recipe_version?: string;
|
|
58
|
+
generated_by?: string;
|
|
59
|
+
content_hash?: string;
|
|
60
|
+
};
|
|
61
|
+
export type PromptModuleDependency = {
|
|
62
|
+
address: string;
|
|
63
|
+
required: boolean;
|
|
64
|
+
};
|
|
65
|
+
export type PromptModule<TContent = string | Record<string, unknown>> = {
|
|
66
|
+
schema_version: PromptModuleContractSchemaVersion;
|
|
67
|
+
address: PromptModuleAddress;
|
|
68
|
+
owner: PromptModuleOwner;
|
|
69
|
+
title: string;
|
|
70
|
+
summary?: string;
|
|
71
|
+
content_kind: PromptModuleContentKind;
|
|
72
|
+
content: TContent;
|
|
73
|
+
mutability: PromptModuleMutability;
|
|
74
|
+
merge: PromptModuleMergePolicy;
|
|
75
|
+
load?: PromptModuleLoadCondition;
|
|
76
|
+
dependencies?: PromptModuleDependency[];
|
|
77
|
+
provenance: PromptModuleProvenance;
|
|
78
|
+
};
|
|
79
|
+
export type PromptModuleReference = Pick<PromptModule, "address" | "owner" | "provenance">;
|
|
80
|
+
export type PromptModuleGraphNode = {
|
|
81
|
+
module: PromptModule;
|
|
82
|
+
replaces?: string[];
|
|
83
|
+
extends?: string[];
|
|
84
|
+
};
|
|
85
|
+
export type PromptModuleGraph = {
|
|
86
|
+
schema_version: PromptModuleContractSchemaVersion;
|
|
87
|
+
nodes: PromptModuleGraphNode[];
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/runtime/prompt-modules/model.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qCAAqC,EAAG,CAAU,CAAC;AAEhE,MAAM,MAAM,iCAAiC,GAAG,OAAO,qCAAqC,CAAC;AAE7F,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,MAAM,EAAE,CAAC;AAE7F,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,QAAQ,GACR,eAAe,GACf,QAAQ,GACR,WAAW,GACX,UAAU,CAAC;AAEf,MAAM,MAAM,kBAAkB,GAC1B,WAAW,GACX,WAAW,GACX,oBAAoB,GACpB,oBAAoB,GACpB,eAAe,GACf,iBAAiB,GACjB,oBAAoB,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,SAAS,GACT,SAAS,GACT,UAAU,GACV,YAAY,GACZ,iBAAiB,GACjB,iBAAiB,GACjB,MAAM,GACN,SAAS,GACT,UAAU,GACV,QAAQ,GACR,SAAS,GACT,aAAa,GACb,UAAU,GACV,WAAW,GACX,SAAS,GACT,QAAQ,GACR,OAAO,GACP,SAAS,GACT,MAAM,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,qBAAqB,CAAC;IACjC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,IAAI,EAAE,gB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M,EAAE,YAAY,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,iCAAiC,CAAC;IAClD,KAAK,EAAE,qBAAqB,EAAE,CAAC;CAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PROMPT_MODULE_CONTRACT_SCHEMA_VERSION = 1;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { PromptModule, PromptModuleAddress, PromptModuleDependency, PromptModuleLoadCondition, PromptModuleMergePolicy, PromptModuleMutability, PromptModuleOwner, PromptModuleProvenance, PromptModuleSlot, PromptModuleSurface, PromptModuleTarget } from "./model.js";
|
|
2
|
+
export type PromptModuleSelector = {
|
|
3
|
+
address?: string;
|
|
4
|
+
namespace?: PromptModuleAddress["namespace"];
|
|
5
|
+
surface?: PromptModuleSurface;
|
|
6
|
+
target?: PromptModuleTarget;
|
|
7
|
+
slot?: PromptModuleSlot;
|
|
8
|
+
owner?: PromptModuleOwner["kind"];
|
|
9
|
+
recipe_id?: string;
|
|
10
|
+
};
|
|
11
|
+
export type PromptModuleMutationWhen = PromptModuleLoadCondition & {
|
|
12
|
+
module_present?: string[];
|
|
13
|
+
module_absent?: string[];
|
|
14
|
+
};
|
|
15
|
+
export type PromptModuleMutationSource = {
|
|
16
|
+
owner: PromptModuleOwner;
|
|
17
|
+
provenance: PromptModuleProvenance;
|
|
18
|
+
};
|
|
19
|
+
export type PromptModuleStructuredPatch<TContent = string | Record<string, unknown>> = {
|
|
20
|
+
title?: string;
|
|
21
|
+
summary?: string | null;
|
|
22
|
+
content?: TContent;
|
|
23
|
+
mutability?: PromptModuleMutability;
|
|
24
|
+
merge?: PromptModuleMergePolicy;
|
|
25
|
+
load?: PromptModuleLoadCondition | null;
|
|
26
|
+
dependencies?: PromptModuleDependency[] | null;
|
|
27
|
+
provenance?: PromptModuleProvenance;
|
|
28
|
+
};
|
|
29
|
+
export type PromptModuleBindingKind = "extends" | "replaces" | "requires" | "feeds" | "validates";
|
|
30
|
+
export type PromptModuleBinding = {
|
|
31
|
+
id: string;
|
|
32
|
+
kind: PromptModuleBindingKind;
|
|
33
|
+
from: string;
|
|
34
|
+
to: string;
|
|
35
|
+
order?: number;
|
|
36
|
+
required?: boolean;
|
|
37
|
+
when?: PromptModuleMutationWhen;
|
|
38
|
+
};
|
|
39
|
+
export type PromptModuleValidatorPhase = "resolve" | "compile" | "emit" | "doctor";
|
|
40
|
+
export type PromptModuleValidator = {
|
|
41
|
+
id: string;
|
|
42
|
+
phase: PromptModuleValidatorPhase;
|
|
43
|
+
kind: "required_module";
|
|
44
|
+
target: PromptModuleSelector;
|
|
45
|
+
required: true;
|
|
46
|
+
when?: PromptModuleMutationWhen;
|
|
47
|
+
} | {
|
|
48
|
+
id: string;
|
|
49
|
+
phase: PromptModuleValidatorPhase;
|
|
50
|
+
kind: "forbidden_module";
|
|
51
|
+
target: PromptModuleSelector;
|
|
52
|
+
required: true;
|
|
53
|
+
when?: PromptModuleMutationWhen;
|
|
54
|
+
} | {
|
|
55
|
+
id: string;
|
|
56
|
+
phase: PromptModuleValidatorPhase;
|
|
57
|
+
kind: "required_command";
|
|
58
|
+
command: string;
|
|
59
|
+
required: boolean;
|
|
60
|
+
when?: PromptModuleMutationWhen;
|
|
61
|
+
};
|
|
62
|
+
export type PromptModuleMutationBase = {
|
|
63
|
+
id: string;
|
|
64
|
+
source: PromptModuleMutationSource;
|
|
65
|
+
when?: PromptModuleMutationWhen;
|
|
66
|
+
reason?: string;
|
|
67
|
+
};
|
|
68
|
+
export type PromptModuleAddMutation = PromptModuleMutationBase & {
|
|
69
|
+
op: "add_module";
|
|
70
|
+
module: PromptModule;
|
|
71
|
+
};
|
|
72
|
+
export type PromptModuleReplaceMutation = PromptModuleMutationBase & {
|
|
73
|
+
op: "replace_module";
|
|
74
|
+
target: PromptModuleSelector;
|
|
75
|
+
module: PromptModule;
|
|
76
|
+
};
|
|
77
|
+
export type PromptModulePatchMutation<TContent = string | Record<string, unknown>> = PromptModuleMutationBase & {
|
|
78
|
+
op: "patch_module";
|
|
79
|
+
target: PromptModuleSelector;
|
|
80
|
+
patch: PromptModuleStructuredPatch<TContent>;
|
|
81
|
+
};
|
|
82
|
+
export type PromptModuleDisableMutation = PromptModuleMutationBase & {
|
|
83
|
+
op: "disable_module";
|
|
84
|
+
target: PromptModuleSelector;
|
|
85
|
+
};
|
|
86
|
+
export type PromptModuleBindMutation = PromptModuleMutationBase & {
|
|
87
|
+
op: "bind_module";
|
|
88
|
+
binding: PromptModuleBinding;
|
|
89
|
+
};
|
|
90
|
+
export type PromptModuleValidatorMutation = PromptModuleMutationBase & ({
|
|
91
|
+
op: "add_validator";
|
|
92
|
+
validator: PromptModuleValidator;
|
|
93
|
+
} | {
|
|
94
|
+
op: "disable_validator";
|
|
95
|
+
validator_id: string;
|
|
96
|
+
});
|
|
97
|
+
export type PromptModuleMutation = PromptModuleAddMutation | PromptModuleReplaceMutation | PromptModulePatchMutation | PromptModuleDisableMutation | PromptModuleBindMutation | PromptModuleValidatorMutation;
|
|
98
|
+
export type PromptModuleMutationSet = {
|
|
99
|
+
schema_version: 1;
|
|
100
|
+
recipe_id?: string;
|
|
101
|
+
mutations: PromptModuleMutation[];
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=mutations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../../src/runtime/prompt-modules/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAA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shared/runtime-env.ts"],"names":[],"mappings":"AAUA,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,MAAM,CAAC,UAAwB,GACvC,MAAM,CAAC,UAAU,CA0BnB;AA8BD,wBAAgB,8BAA8B,CAAC,OAAO,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAe/F"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
function pushUnique(entries, value) {
|
|
5
|
+
const trimmed = value.trim();
|
|
6
|
+
if (!trimmed || entries.includes(trimmed))
|
|
7
|
+
return;
|
|
8
|
+
entries.push(trimmed);
|
|
9
|
+
}
|
|
10
|
+
export function withPreferredRuntimePath(baseEnv = process.env) {
|
|
11
|
+
const env = { ...baseEnv };
|
|
12
|
+
const pathEntries = String(baseEnv.PATH ?? "")
|
|
13
|
+
.split(path.delimiter)
|
|
14
|
+
.map((entry) => entry.trim())
|
|
15
|
+
.filter(Boolean);
|
|
16
|
+
const preferredEntries = [];
|
|
17
|
+
pushUnique(preferredEntries, path.dirname(resolvePreferredNodeExecutable(baseEnv)));
|
|
18
|
+
const bunInstallDir = String(baseEnv.BUN_INSTALL ?? "").trim();
|
|
19
|
+
if (bunInstallDir) {
|
|
20
|
+
pushUnique(preferredEntries, path.join(bunInstallDir, "bin"));
|
|
21
|
+
}
|
|
22
|
+
const homeDir = String(baseEnv.HOME ?? os.homedir() ?? "").trim();
|
|
23
|
+
if (homeDir) {
|
|
24
|
+
pushUnique(preferredEntries, path.join(homeDir, ".bun", "bin"));
|
|
25
|
+
}
|
|
26
|
+
for (const entry of pathEntries) {
|
|
27
|
+
pushUnique(preferredEntries, entry);
|
|
28
|
+
}
|
|
29
|
+
env.PATH = preferredEntries.join(path.delimiter);
|
|
30
|
+
return env;
|
|
31
|
+
}
|
|
32
|
+
function isExecutableFile(filePath) {
|
|
33
|
+
try {
|
|
34
|
+
return fs.statSync(filePath).isFile();
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function readLatestNvmNodeBin(homeDir) {
|
|
41
|
+
const versionsDir = path.join(homeDir, ".nvm", "versions", "node");
|
|
42
|
+
let entries = [];
|
|
43
|
+
try {
|
|
44
|
+
entries = fs.readdirSync(versionsDir);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const latest = entries
|
|
50
|
+
.map((entry) => entry.trim())
|
|
51
|
+
.filter(Boolean)
|
|
52
|
+
.toSorted()
|
|
53
|
+
.at(-1);
|
|
54
|
+
if (!latest)
|
|
55
|
+
return null;
|
|
56
|
+
const candidate = path.join(versionsDir, latest, "bin", "node");
|
|
57
|
+
return isExecutableFile(candidate) ? candidate : null;
|
|
58
|
+
}
|
|
59
|
+
export function resolvePreferredNodeExecutable(baseEnv = process.env) {
|
|
60
|
+
const homeDir = String(baseEnv.HOME ?? os.homedir() ?? "").trim();
|
|
61
|
+
const candidates = [
|
|
62
|
+
path.join(String(baseEnv.NVM_BIN ?? "").trim(), "node"),
|
|
63
|
+
path.join(String(baseEnv.VOLTA_HOME ?? "").trim(), "bin", "node"),
|
|
64
|
+
homeDir ? readLatestNvmNodeBin(homeDir) : null,
|
|
65
|
+
process.execPath,
|
|
66
|
+
];
|
|
67
|
+
for (const candidate of candidates) {
|
|
68
|
+
if (typeof candidate === "string" && candidate.trim() && isExecutableFile(candidate)) {
|
|
69
|
+
return candidate;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return process.execPath;
|
|
73
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentplane",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.24",
|
|
4
4
|
"description": "Agent Plane CLI for task workflows, recipes, and project automation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentplane",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"prepublishOnly": "node ../../scripts/enforce-github-publish.mjs && npm run prepack"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@agentplaneorg/core": "0.3.
|
|
60
|
-
"@agentplaneorg/recipes": "0.3.
|
|
59
|
+
"@agentplaneorg/core": "0.3.24",
|
|
60
|
+
"@agentplaneorg/recipes": "0.3.24",
|
|
61
61
|
"@clack/prompts": "^1.2.0",
|
|
62
62
|
"yauzl": "^2.10.0",
|
|
63
63
|
"zod": "^3",
|